static int retu_wdt_set_timeout(struct watchdog_device *wdog, unsigned int timeout) { struct retu_wdt_dev *wdev = watchdog_get_drvdata(wdog); wdog->timeout = timeout; return retu_write(wdev->rdev, RETU_REG_WATCHDOG, wdog->timeout); }
static int retu_wdt_start(struct watchdog_device *wdog) { struct retu_wdt_dev *wdev = watchdog_get_drvdata(wdog); retu_wdt_ping_disable(wdev); return retu_write(wdev->rdev, RETU_REG_WATCHDOG, wdog->timeout); }
static void retu_io(void *opaque, int rw, int reg, uint16_t *val) { CBusRetu *s = (CBusRetu *) opaque; if (rw) *val = retu_read(s, reg); else retu_write(s, reg, *val); }
static void tahvo_usb_power_off(struct tahvo_usb *tu) { struct retu_dev *rdev = dev_get_drvdata(tu->pt_dev->dev.parent); /* Disable gadget controller if any */ if (tu->phy.otg->gadget) usb_gadget_vbus_disconnect(tu->phy.otg->gadget); /* Power off transceiver */ retu_write(rdev, TAHVO_REG_USBR, 0); tu->phy.state = OTG_STATE_UNDEFINED; }
static void tahvo_usb_become_peripheral(struct tahvo_usb *tu) { struct retu_dev *rdev = dev_get_drvdata(tu->pt_dev->dev.parent); extcon_set_cable_state(&tu->extcon, "USB-HOST", false); /* Power up transceiver and set it in USB peripheral mode */ retu_write(rdev, TAHVO_REG_USBR, USBR_SLAVE_CONTROL | USBR_REGOUT | USBR_NSUSPEND | USBR_SLAVE_SW); tu->phy.state = OTG_STATE_B_IDLE; check_vbus_state(tu); }
static void tahvo_usb_become_host(struct tahvo_usb *tu) { struct retu_dev *rdev = dev_get_drvdata(tu->pt_dev->dev.parent); extcon_set_cable_state(&tu->extcon, "USB-HOST", true); /* Power up the transceiver in USB host mode */ retu_write(rdev, TAHVO_REG_USBR, USBR_REGOUT | USBR_NSUSPEND | USBR_MASTER_SW2 | USBR_MASTER_SW1); tu->phy.state = OTG_STATE_A_IDLE; check_vbus_state(tu); }
static int tahvo_usb_set_suspend(struct usb_phy *dev, int suspend) { struct tahvo_usb *tu = container_of(dev, struct tahvo_usb, phy); struct retu_dev *rdev = dev_get_drvdata(tu->pt_dev->dev.parent); u16 w; dev_dbg(&tu->pt_dev->dev, "%s\n", __func__); w = retu_read(rdev, TAHVO_REG_USBR); if (suspend) w &= ~USBR_NSUSPEND; else w |= USBR_NSUSPEND; retu_write(rdev, TAHVO_REG_USBR, w); return 0; }
static void retu_wdt_ping_disable(struct retu_wdt_dev *wdev) { retu_write(wdev->rdev, RETU_REG_WATCHDOG, RETU_WDT_MAX_TIMER); cancel_delayed_work_sync(&wdev->ping_work); }
/* * Since Retu watchdog cannot be disabled in hardware, we must kick it * with a timer until userspace watchdog software takes over. If * CONFIG_WATCHDOG_NOWAYOUT is set, we never start the feeding. */ static void retu_wdt_ping_enable(struct retu_wdt_dev *wdev) { retu_write(wdev->rdev, RETU_REG_WATCHDOG, RETU_WDT_MAX_TIMER); schedule_delayed_work(&wdev->ping_work, round_jiffies_relative(RETU_WDT_MAX_TIMER * HZ / 2)); }