static int twl4030_set_peripheral(struct otg_transceiver *xceiv, struct usb_gadget *gadget) { struct twl4030_usb *twl = xceiv_to_twl(xceiv); if (!xceiv) return -ENODEV; if (!gadget) { OTG_IRQ_EN_REG = 0; twl4030_phy_suspend(1); twl->otg.gadget = NULL; return -ENODEV; } twl->otg.gadget = gadget; twl4030_phy_resume(); OTG_CTRL_REG = (OTG_CTRL_REG & OTG_CTRL_MASK & ~(OTG_XCEIV_OUTPUTS|OTG_CTRL_BITS)) | OTG_ID; twl->otg.state = OTG_STATE_B_IDLE; twl4030_usb_set_bits(twl, USB_INT_EN_RISE, USB_INT_SESSVALID | USB_INT_VBUSVALID); twl4030_usb_set_bits(twl, USB_INT_EN_FALL, USB_INT_SESSVALID | USB_INT_VBUSVALID); return 0; }
static int twl4030_set_peripheral(struct otg_transceiver *x, struct usb_gadget *gadget) { struct twl4030_usb *twl; u32 l; if (!x) return -ENODEV; twl = xceiv_to_twl(x); if (!gadget) { omap_writew(0, OTG_IRQ_EN); twl4030_phy_suspend(twl, 1); twl->otg.gadget = NULL; return -ENODEV; } twl->otg.gadget = gadget; twl4030_phy_resume(twl); l = omap_readl(OTG_CTRL) & OTG_CTRL_MASK; l &= ~(OTG_XCEIV_OUTPUTS|OTG_CTRL_BITS); l |= OTG_ID; omap_writel(l, OTG_CTRL); twl->otg.state = OTG_STATE_B_IDLE; return 0; }
static int archos_twl6030_phy_init(struct otg_transceiver *x) { u8 hw_state; struct archos_twl6030_usb *twl; struct device *dev; struct twl4030_usb_data *pdata; twl = xceiv_to_twl(x); dev = twl->dev; pdata = dev->platform_data; if (!twl->asleep) { regulator_enable(twl->usb3v3); twl->asleep = 1; } hw_state = archos_twl6030_readb(twl, TWL6030_MODULE_ID0, STS_HW_CONDITIONS); if (!twl->phy_powered) { if (hw_state & STS_USB_ID) pdata->phy_power(twl->dev, 1, 1); else pdata->phy_power(twl->dev, 0, 1); twl->phy_powered = 1; pr_err("PHY ON\n"); } return 0; }
static int twl4030_set_host(struct otg_transceiver *xceiv, struct usb_bus *host) { struct twl4030_usb *twl = xceiv_to_twl(xceiv); if (!xceiv) return -ENODEV; if (!host) { OTG_IRQ_EN_REG = 0; twl4030_phy_suspend(1); twl->otg.host = NULL; return -ENODEV; } twl->otg.host = host; twl4030_phy_resume(); twl4030_usb_set_bits(twl, OTG_CTRL, OTG_CTRL_DMPULLDOWN | OTG_CTRL_DPPULLDOWN); twl4030_usb_set_bits(twl, USB_INT_EN_RISE, USB_INT_IDGND); twl4030_usb_set_bits(twl, USB_INT_EN_FALL, USB_INT_IDGND); twl4030_usb_set_bits(twl, FUNC_CTRL, FUNC_CTRL_SUSPENDM); twl4030_usb_set_bits(twl, OTG_CTRL, OTG_CTRL_DRVVBUS); return 0; }
static int twl4030_set_host(struct otg_transceiver *x, struct usb_bus *host) { struct twl4030_usb *twl; if (!x) return -ENODEV; twl = xceiv_to_twl(x); if (!host) { omap_writew(0, OTG_IRQ_EN); twl4030_phy_suspend(twl, 1); twl->otg.host = NULL; return -ENODEV; } twl->otg.host = host; twl4030_phy_resume(twl); twl4030_usb_set_bits(twl, TWL4030_OTG_CTRL, TWL4030_OTG_CTRL_DMPULLDOWN | TWL4030_OTG_CTRL_DPPULLDOWN); twl4030_usb_set_bits(twl, FUNC_CTRL, FUNC_CTRL_SUSPENDM); twl4030_usb_set_bits(twl, TWL4030_OTG_CTRL, TWL4030_OTG_CTRL_DRVVBUS); return 0; }
static void archos_twl6030_phy_shutdown(struct otg_transceiver *x) { struct archos_twl6030_usb *twl; struct device *dev; struct twl4030_usb_data *pdata; twl = xceiv_to_twl(x); if (!twl->phy_powered) return; /* USB_VBUS_CTRL_CLR */ twl_i2c_write_u8(TWL6030_MODULE_ID1, 0xFF, 0x05); /* USB_ID_CRTL_CLR */ twl_i2c_write_u8(TWL6030_MODULE_ID1, 0xFF, 0x07); /* CHARGERUSB_CTRL3 */ twl_i2c_write_u8(TWL6030_MODULE_ID1, 0x21, 0xEA); dev = twl->dev; pdata = dev->platform_data; pdata->phy_power(twl->dev, 0, 0); pr_err("PHY OFF\n"); twl->phy_powered = 0; }
static int twl6030_set_vbus(struct otg_transceiver *x, bool enabled) { struct twl6030_usb *twl = xceiv_to_twl(x); twl->vbus_enable = enabled; schedule_work(&twl->set_vbus_work); return 0; }
static void phy_shutdown(struct otg_transceiver *x) { printk("%s\n",__func__); struct twl6030_usb *twl = xceiv_to_twl(x); set_phy_clk(x, 0); __raw_writel(PHY_PD, ctrl_base + CONTROL_DEV_CONF); regulator_disable(twl->vusb); }
static int archos_twl6030_set_power(struct otg_transceiver *x, unsigned int mA) { struct archos_twl6030_usb *twl = xceiv_to_twl(x); twl->usb_cinlimit_mA = mA; atomic_notifier_call_chain(&twl->otg.notifier, USB_EVENT_ENUMERATED, &twl->usb_cinlimit_mA); return 0; }
static int twl6030_set_power(struct otg_transceiver *x, unsigned int mA) { struct twl6030_usb *twl = xceiv_to_twl(x); twl->usb_cinlimit_mA = mA; if (mA && (twl->otg.last_event != USB_EVENT_NONE)) atomic_notifier_call_chain(&twl->otg.notifier, USB_EVENT_ENUMERATED, &twl->usb_cinlimit_mA); return 0; }
static int twl6030_phy_suspend(struct otg_transceiver *x, int suspend) { struct twl6030_usb *twl = xceiv_to_twl(x); struct device *dev = twl->dev; struct twl4030_usb_data *pdata = dev->platform_data; pdata->phy_suspend(dev, suspend); return 0; }
static int twl4030_set_suspend(struct otg_transceiver *x, int suspend) { struct twl4030_usb *twl = xceiv_to_twl(x); if (suspend) twl4030_phy_suspend(twl, 1); else twl4030_phy_resume(twl); return 0; }
static void twl6030_phy_shutdown(struct otg_transceiver *x) { struct twl6030_usb *twl; struct device *dev; struct twl4030_usb_data *pdata; twl = xceiv_to_twl(x); dev = twl->dev; pdata = dev->platform_data; pdata->phy_power(twl->dev, 0, 0); }
static int twl6030_start_srp(struct otg_transceiver *x) { struct twl6030_usb *twl = xceiv_to_twl(x); twl6030_writeb(twl, TWL_MODULE_USB, 0x24, USB_VBUS_CTRL_SET); twl6030_writeb(twl, TWL_MODULE_USB, 0x84, USB_VBUS_CTRL_SET); mdelay(100); twl6030_writeb(twl, TWL_MODULE_USB, 0xa0, USB_VBUS_CTRL_CLR); return 0; }
int twl6030_set_prevbus(struct otg_transceiver *x,int on) { struct twl6030_usb *twl; if (!x) return -ENODEV; twl = xceiv_to_twl(x); twl->prev_vbus = on; return 0; }
static int twl6030_set_host(struct otg_transceiver *x, struct usb_bus *host) { struct twl6030_usb *twl; if (!x) return -ENODEV; twl = xceiv_to_twl(x); twl->otg.host = host; if (!host) twl->otg.state = OTG_STATE_UNDEFINED; return 0; }
/*-------------------------------------------------------------------------*/ static int archos_twl6030_set_phy_clk(struct otg_transceiver *x, int on) { struct archos_twl6030_usb *twl; struct device *dev; struct twl4030_usb_data *pdata; twl = xceiv_to_twl(x); dev = twl->dev; pdata = dev->platform_data; pdata->phy_set_clock(twl->dev, on); return 0; }
static int twl6030_set_peripheral(struct otg_transceiver *x, struct usb_gadget *gadget) { struct twl6030_usb *twl; if (!x) return -ENODEV; twl = xceiv_to_twl(x); twl->otg.gadget = gadget; if (!gadget) twl->otg.state = OTG_STATE_UNDEFINED; return 0; }
static int twl6030_phy_suspend(struct otg_transceiver *x, int suspend) { struct twl6030_usb *twl = xceiv_to_twl(x); struct device *dev = twl->dev; struct twl4030_usb_data *pdata = dev->platform_data; if (suspend && !twl->is_phy_suspended) { pdata->phy_suspend(dev, 1); twl->is_phy_suspended = true; } else if (!suspend && twl->is_phy_suspended) { pdata->phy_suspend(dev, 0); twl->is_phy_suspended = false; } return 0; }
static int twl6030_set_vbus(struct otg_transceiver *x, bool enabled) { struct twl6030_usb *twl = xceiv_to_twl(x); /* * Start driving VBUS. Set OPA_MODE bit in CHARGERUSB_CTRL1 * register. This enables boost mode. */ if (enabled) twl6030_writeb(twl, TWL_MODULE_MAIN_CHARGE , 0x40, CHARGERUSB_CTRL1); else twl6030_writeb(twl, TWL_MODULE_MAIN_CHARGE , 0x00, CHARGERUSB_CTRL1); return 0; }
static int twl6030_enable_irq(struct otg_transceiver *x) { struct twl6030_usb *twl = xceiv_to_twl(x); twl6030_writeb(twl, TWL_MODULE_USB, USB_ID_INT_EN_HI_SET, 0x1); twl6030_interrupt_unmask(0x05, REG_INT_MSK_LINE_C); twl6030_interrupt_unmask(0x05, REG_INT_MSK_STS_C); twl6030_interrupt_unmask(TWL6030_CHARGER_CTRL_INT_MASK, REG_INT_MSK_LINE_C); twl6030_interrupt_unmask(TWL6030_CHARGER_CTRL_INT_MASK, REG_INT_MSK_STS_C); twl6030_usb_irq(twl->irq2, twl); twl6030_usbotg_irq(twl->irq1, twl); return 0; }
void twl6030_set_input_current_limit(struct otg_transceiver *x,unsigned mA) { struct twl6030_usb *twl = xceiv_to_twl(x); int event=0; switch(mA){ case 0: event = USB_EVENT_LIMIT_0; break; case 100: event = USB_EVENT_LIMIT_100; break; case 500: event = USB_EVENT_LIMIT_500; break; } blocking_notifier_call_chain(&twl->otg.notifier,event, twl->otg.gadget); }
static int twl6030_phy_init(struct otg_transceiver *x) { struct twl6030_usb *twl; struct device *dev; struct twl4030_usb_data *pdata; twl = xceiv_to_twl(x); dev = twl->dev; pdata = dev->platform_data; if (twl->linkstat == USB_EVENT_ID) pdata->phy_power(twl->dev, 1, 1); else pdata->phy_power(twl->dev, 0, 1); return 0; }
static int twl6030_phy_init(struct otg_transceiver *x) { u8 hw_state; struct twl6030_usb *twl; struct device *dev; struct twl4030_usb_data *pdata; twl = xceiv_to_twl(x); dev = twl->dev; pdata = dev->platform_data; hw_state = twl6030_readb(twl, TWL6030_MODULE_ID0, STS_HW_CONDITIONS); if (hw_state & STS_USB_ID) pdata->phy_power(twl->dev, 1, 1); else pdata->phy_power(twl->dev, 0, 1); return 0; }
static int twl6030_set_hz_mode(struct otg_transceiver *x, bool enabled) { u8 val; struct twl6030_usb *twl; if (!x) return -ENODEV; twl = xceiv_to_twl(x); /* set/reset USB charger in High impedence mode on VBUS */ val = twl6030_readb(twl, TWL_MODULE_MAIN_CHARGE, CHARGERUSB_CTRL1); if (enabled) val |= HZ_MODE; else val &= ~HZ_MODE; twl6030_writeb(twl, TWL_MODULE_MAIN_CHARGE , val, CHARGERUSB_CTRL1); return 0; }
static int archos_twl6030_set_vbus(struct otg_transceiver *x, bool enabled) { struct regulator *vbus_draw; struct archos_twl6030_usb *twl = xceiv_to_twl(x); vbus_draw = twl->vbus_draw; if (!vbus_draw) return -1; if (enabled) { if (!twl->vbus_enabled) { regulator_enable(vbus_draw); twl->vbus_enabled = true; } } else { if (twl->vbus_enabled) { regulator_disable(vbus_draw); twl->vbus_enabled = false; } } return 0; }
unsigned int archos_twl6030_get_usb_max_power(struct otg_transceiver *x) { struct archos_twl6030_usb *twl = xceiv_to_twl(x); return twl->usb_cinlimit_mA; }