isp1704_charger: Detect charger after probe
authorHeikki Krogerus <heikki.krogerus@nokia.com>
Mon, 8 Nov 2010 10:22:40 +0000 (12:22 +0200)
committerAnton Vorontsov <cbouatmailru@gmail.com>
Thu, 18 Nov 2010 13:56:21 +0000 (16:56 +0300)
If the device is booted up with cable connected, or the
module is loaded after plugging in the cable, the
notification has come and gone, so not relying on it at
probe time. Instead this checks the VBUS level manually
after probe.

Signed-off-by: Heikki Krogerus <heikki.krogerus@nokia.com>
Signed-off-by: Anton Vorontsov <cbouatmailru@gmail.com>
drivers/power/isp1704_charger.c

index 77c11f1d72e2b5bf0bfecfa702910f7c9430d43e..2ad9b14a5ce37c4ec15f8cb8b319c7845e982c4f 100644 (file)
@@ -422,6 +422,23 @@ static int __devinit isp1704_charger_probe(struct platform_device *pdev)
 
        dev_info(isp->dev, "registered with product id %s\n", isp->model);
 
+       /*
+        * Taking over the D+ pullup.
+        *
+        * FIXME: The device will be disconnected if it was already
+        * enumerated. The charger driver should be always loaded before any
+        * gadget is loaded.
+        */
+       if (isp->otg->gadget)
+               usb_gadget_disconnect(isp->otg->gadget);
+
+       /* Detect charger if VBUS is valid (the cable was already plugged). */
+       ret = otg_io_read(isp->otg, ULPI_USB_INT_STS);
+       if ((ret & ULPI_INT_VBUS_VALID) && !isp->otg->default_a) {
+               isp->event = USB_EVENT_VBUS;
+               schedule_work(&isp->work);
+       }
+
        return 0;
 fail2:
        power_supply_unregister(&isp->psy);
This page took 0.027886 seconds and 5 git commands to generate.