From f8d44af473e8ad9043f6bbd6165691d8a209ec2e Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Sat, 15 Dec 2012 10:35:37 +1100 Subject: twl4030-usb - re-instate event notifications commit c9721438c009adf8e81d376839ed037c53b9b8d9 usb: musb: twl: use mailbox API to send VBUS or ID events went a bit too far in removing all event notification from twl4030-usb. The notifications are still needed for twl4030_charger.c to know when to enable the charger. Signed-off-by: NeilBrown --- drivers/usb/otg/twl4030-usb.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/drivers/usb/otg/twl4030-usb.c b/drivers/usb/otg/twl4030-usb.c index 3d5eb12..e0d98b2 100644 --- a/drivers/usb/otg/twl4030-usb.c +++ b/drivers/usb/otg/twl4030-usb.c @@ -38,6 +38,7 @@ #include #include #include +#include #include /* Register defines */ @@ -393,6 +394,28 @@ static void twl4030_phy_power(struct twl4030_usb *twl, int on) } } +static void do_notify(struct twl4030_usb *twl, + enum omap_musb_vbus_id_status status) +{ + enum usb_phy_events event; + + switch (status) { + case OMAP_MUSB_UNKNOWN: + event = USB_EVENT_NONE; break; + case OMAP_MUSB_ID_GROUND: + event = USB_EVENT_ID; break; + case OMAP_MUSB_ID_FLOAT: + event = USB_EVENT_NONE; break; + case OMAP_MUSB_VBUS_VALID: + event = USB_EVENT_VBUS; break; + case OMAP_MUSB_VBUS_OFF: + event = USB_EVENT_NONE; break; + } + + atomic_notifier_call_chain(&twl->phy.notifier, event, + twl->phy.otg->gadget); +} + static void twl4030_phy_suspend(struct twl4030_usb *twl, int controller_off) { if (twl->asleep) @@ -556,6 +579,7 @@ static irqreturn_t twl4030_usb_irq(int irq, void *_twl) twl4030_phy_suspend(twl, 0); else twl4030_phy_resume(twl); + do_notify(twl, status); omap_musb_mailbox(twl->linkstat); } @@ -579,6 +603,7 @@ static void twl4030_usb_phy_init(struct twl4030_usb *twl) twl->asleep = 0; } + do_notify(twl, status); omap_musb_mailbox(twl->linkstat); } sysfs_notify(&twl->dev->kobj, NULL, "vbus"); @@ -678,6 +703,8 @@ static int __devinit twl4030_usb_probe(struct platform_device *pdev) if (device_create_file(&pdev->dev, &dev_attr_id)) dev_warn(&pdev->dev, "could not create sysfs file\n"); + ATOMIC_INIT_NOTIFIER_HEAD(&twl->phy.notifier); + /* Our job is to use irqs and status from the power module * to keep the transceiver disabled when nothing's connected. * -- cgit v1.1