Lines Matching refs:twl
104 static inline int twl6030_writeb(struct twl6030_usb *twl, u8 module, in twl6030_writeb() argument
111 dev_err(twl->dev, in twl6030_writeb()
116 static inline u8 twl6030_readb(struct twl6030_usb *twl, u8 module, u8 address) in twl6030_readb() argument
125 dev_err(twl->dev, in twl6030_readb()
133 struct twl6030_usb *twl = comparator_to_twl(comparator); in twl6030_start_srp() local
135 twl6030_writeb(twl, TWL_MODULE_USB, 0x24, USB_VBUS_CTRL_SET); in twl6030_start_srp()
136 twl6030_writeb(twl, TWL_MODULE_USB, 0x84, USB_VBUS_CTRL_SET); in twl6030_start_srp()
139 twl6030_writeb(twl, TWL_MODULE_USB, 0xa0, USB_VBUS_CTRL_CLR); in twl6030_start_srp()
144 static int twl6030_usb_ldo_init(struct twl6030_usb *twl) in twl6030_usb_ldo_init() argument
147 twl6030_writeb(twl, TWL6030_MODULE_ID0, 0x1, TWL6030_BACKUP_REG); in twl6030_usb_ldo_init()
150 twl6030_writeb(twl, TWL6030_MODULE_ID0, 0x1, TWL6030_CFG_LDO_PD2); in twl6030_usb_ldo_init()
153 twl6030_writeb(twl, TWL6030_MODULE_ID0, 0x10, TWL6030_MISC2); in twl6030_usb_ldo_init()
155 twl->usb3v3 = regulator_get(twl->dev, "usb"); in twl6030_usb_ldo_init()
156 if (IS_ERR(twl->usb3v3)) in twl6030_usb_ldo_init()
160 twl6030_writeb(twl, TWL_MODULE_USB, 0x4, USB_VBUS_CTRL_SET); in twl6030_usb_ldo_init()
166 twl6030_writeb(twl, TWL_MODULE_USB, 0x14, USB_ID_CTRL_SET); in twl6030_usb_ldo_init()
174 struct twl6030_usb *twl = dev_get_drvdata(dev); in vbus_show() local
178 spin_lock_irqsave(&twl->lock, flags); in vbus_show()
180 switch (twl->linkstat) { in vbus_show()
193 spin_unlock_irqrestore(&twl->lock, flags); in vbus_show()
207 struct twl6030_usb *twl = _twl; in twl6030_usb_irq() local
212 hw_state = twl6030_readb(twl, TWL6030_MODULE_ID0, STS_HW_CONDITIONS); in twl6030_usb_irq()
214 vbus_state = twl6030_readb(twl, TWL_MODULE_MAIN_CHARGE, in twl6030_usb_irq()
218 ret = regulator_enable(twl->usb3v3); in twl6030_usb_irq()
220 dev_err(twl->dev, "Failed to enable usb3v3\n"); in twl6030_usb_irq()
222 twl->asleep = 1; in twl6030_usb_irq()
224 twl->linkstat = status; in twl6030_usb_irq()
227 twl->linkstat = MUSB_UNKNOWN; in twl6030_usb_irq()
229 if (twl->linkstat != MUSB_UNKNOWN) { in twl6030_usb_irq()
231 twl->linkstat = status; in twl6030_usb_irq()
234 twl->linkstat = MUSB_UNKNOWN; in twl6030_usb_irq()
235 if (twl->asleep) { in twl6030_usb_irq()
236 regulator_disable(twl->usb3v3); in twl6030_usb_irq()
237 twl->asleep = 0; in twl6030_usb_irq()
242 sysfs_notify(&twl->dev->kobj, NULL, "vbus"); in twl6030_usb_irq()
249 struct twl6030_usb *twl = _twl; in twl6030_usbotg_irq() local
254 hw_state = twl6030_readb(twl, TWL6030_MODULE_ID0, STS_HW_CONDITIONS); in twl6030_usbotg_irq()
257 ret = regulator_enable(twl->usb3v3); in twl6030_usbotg_irq()
259 dev_err(twl->dev, "Failed to enable usb3v3\n"); in twl6030_usbotg_irq()
261 twl->asleep = 1; in twl6030_usbotg_irq()
262 twl6030_writeb(twl, TWL_MODULE_USB, 0x1, USB_ID_INT_EN_HI_CLR); in twl6030_usbotg_irq()
263 twl6030_writeb(twl, TWL_MODULE_USB, 0x10, USB_ID_INT_EN_HI_SET); in twl6030_usbotg_irq()
265 twl->linkstat = status; in twl6030_usbotg_irq()
268 twl->linkstat = MUSB_UNKNOWN; in twl6030_usbotg_irq()
270 twl6030_writeb(twl, TWL_MODULE_USB, 0x10, USB_ID_INT_EN_HI_CLR); in twl6030_usbotg_irq()
271 twl6030_writeb(twl, TWL_MODULE_USB, 0x1, USB_ID_INT_EN_HI_SET); in twl6030_usbotg_irq()
273 twl6030_writeb(twl, TWL_MODULE_USB, status, USB_ID_INT_LATCH_CLR); in twl6030_usbotg_irq()
280 struct twl6030_usb *twl = container_of(work, struct twl6030_usb, in twl6030_status_work() local
283 twl6030_usb_irq(twl->irq2, twl); in twl6030_status_work()
284 twl6030_usbotg_irq(twl->irq1, twl); in twl6030_status_work()
287 static int twl6030_enable_irq(struct twl6030_usb *twl) in twl6030_enable_irq() argument
289 twl6030_writeb(twl, TWL_MODULE_USB, 0x1, USB_ID_INT_EN_HI_SET); in twl6030_enable_irq()
303 struct twl6030_usb *twl = container_of(data, struct twl6030_usb, in otg_set_vbus_work() local
311 if (twl->vbus_enable) in otg_set_vbus_work()
312 twl6030_writeb(twl, TWL_MODULE_MAIN_CHARGE, 0x40, in otg_set_vbus_work()
315 twl6030_writeb(twl, TWL_MODULE_MAIN_CHARGE, 0x00, in otg_set_vbus_work()
321 struct twl6030_usb *twl = comparator_to_twl(comparator); in twl6030_set_vbus() local
323 twl->vbus_enable = enabled; in twl6030_set_vbus()
324 schedule_work(&twl->set_vbus_work); in twl6030_set_vbus()
332 struct twl6030_usb *twl; in twl6030_usb_probe() local
342 twl = devm_kzalloc(dev, sizeof(*twl), GFP_KERNEL); in twl6030_usb_probe()
343 if (!twl) in twl6030_usb_probe()
346 twl->dev = &pdev->dev; in twl6030_usb_probe()
347 twl->irq1 = platform_get_irq(pdev, 0); in twl6030_usb_probe()
348 twl->irq2 = platform_get_irq(pdev, 1); in twl6030_usb_probe()
349 twl->linkstat = MUSB_UNKNOWN; in twl6030_usb_probe()
351 if (twl->irq1 < 0) in twl6030_usb_probe()
352 return twl->irq1; in twl6030_usb_probe()
353 if (twl->irq2 < 0) in twl6030_usb_probe()
354 return twl->irq2; in twl6030_usb_probe()
356 twl->comparator.set_vbus = twl6030_set_vbus; in twl6030_usb_probe()
357 twl->comparator.start_srp = twl6030_start_srp; in twl6030_usb_probe()
359 ret = omap_usb2_set_comparator(&twl->comparator); in twl6030_usb_probe()
366 spin_lock_init(&twl->lock); in twl6030_usb_probe()
368 err = twl6030_usb_ldo_init(twl); in twl6030_usb_probe()
374 platform_set_drvdata(pdev, twl); in twl6030_usb_probe()
376 INIT_WORK(&twl->set_vbus_work, otg_set_vbus_work); in twl6030_usb_probe()
377 INIT_DELAYED_WORK(&twl->get_status_work, twl6030_status_work); in twl6030_usb_probe()
379 status = request_threaded_irq(twl->irq1, NULL, twl6030_usbotg_irq, in twl6030_usb_probe()
381 "twl6030_usb", twl); in twl6030_usb_probe()
384 twl->irq1, status); in twl6030_usb_probe()
388 status = request_threaded_irq(twl->irq2, NULL, twl6030_usb_irq, in twl6030_usb_probe()
390 "twl6030_usb", twl); in twl6030_usb_probe()
393 twl->irq2, status); in twl6030_usb_probe()
397 twl->asleep = 0; in twl6030_usb_probe()
398 twl6030_enable_irq(twl); in twl6030_usb_probe()
399 schedule_delayed_work(&twl->get_status_work, HZ); in twl6030_usb_probe()
405 free_irq(twl->irq1, twl); in twl6030_usb_probe()
407 regulator_put(twl->usb3v3); in twl6030_usb_probe()
414 struct twl6030_usb *twl = platform_get_drvdata(pdev); in twl6030_usb_remove() local
416 cancel_delayed_work_sync(&twl->get_status_work); in twl6030_usb_remove()
421 free_irq(twl->irq1, twl); in twl6030_usb_remove()
422 free_irq(twl->irq2, twl); in twl6030_usb_remove()
423 regulator_put(twl->usb3v3); in twl6030_usb_remove()
424 cancel_work_sync(&twl->set_vbus_work); in twl6030_usb_remove()