mfd: cpcap-whisper: Notify the USB sub-system of USB events
authorBenoit Goby <benoit@android.com>
Wed, 21 Jul 2010 03:29:02 +0000 (20:29 -0700)
committerColin Cross <ccross@android.com>
Wed, 6 Oct 2010 23:33:20 +0000 (16:33 -0700)
Change-Id: I7707f9c0589bcc46529cab13a34a5376aca4899a
Signed-off-by: Benoit Goby <benoit@android.com>
drivers/mfd/cpcap-whisper.c

index 87b14c30a693378dc9528a1dbbb88e8c60302ebf..f1a1051bbcd138d12bcc3ca78167abdf2619851d 100644 (file)
@@ -27,6 +27,7 @@
 #include <linux/workqueue.h>
 
 #include <linux/regulator/consumer.h>
+#include <linux/usb/otg.h>
 
 #include <linux/spi/cpcap.h>
 #include <linux/spi/cpcap-regbits.h>
@@ -96,6 +97,7 @@ struct cpcap_whisper_data {
        struct switch_dev wsdev;
        struct switch_dev dsdev;
        struct switch_dev asdev;
+       struct otg_transceiver *otg;
 };
 
 static int whisper_debug;
@@ -202,6 +204,9 @@ static int configure_hardware(struct cpcap_whisper_data *data,
                retval |= cpcap_regacc_write(data->cpcap, CPCAP_REG_USBC1, 0,
                                             CPCAP_BIT_VBUSPD);
                gpio_set_value(data->pdata->data_gpio, 1);
+               if (data->otg)
+                       blocking_notifier_call_chain(&data->otg->notifier,
+                                                    USB_EVENT_VBUS, NULL);
                break;
 
        case CPCAP_ACCY_USB_HOST:
@@ -209,6 +214,9 @@ static int configure_hardware(struct cpcap_whisper_data *data,
                                             CPCAP_BIT_VBUSPD);
                gpio_set_value(data->pdata->pwr_gpio, 1);
                gpio_set_value(data->pdata->data_gpio, 1);
+               if (data->otg)
+                       blocking_notifier_call_chain(&data->otg->notifier,
+                                                    USB_EVENT_ID, NULL);
                break;
 
        case CPCAP_ACCY_WHISPER:
@@ -237,6 +245,9 @@ static int configure_hardware(struct cpcap_whisper_data *data,
                retval |= cpcap_regacc_write(data->cpcap, CPCAP_REG_USBC2, 0,
                                             CPCAP_BIT_USBXCVREN);
                vusb_disable(data);
+               if (data->otg)
+                       blocking_notifier_call_chain(&data->otg->notifier,
+                                                    USB_EVENT_NONE, NULL);
                break;
        }
 
@@ -538,6 +549,10 @@ static int cpcap_whisper_probe(struct platform_device *pdev)
                goto free_irqs;
        }
 
+#ifdef CONFIG_USB_CPCAP_OTG
+       data->otg = otg_get_transceiver();
+#endif
+
        data->cpcap->accydata = data;
        dev_info(&pdev->dev, "CPCAP Whisper detection probed\n");
 
@@ -581,6 +596,11 @@ static int __exit cpcap_whisper_remove(struct platform_device *pdev)
        vusb_disable(data);
        regulator_put(data->regulator);
 
+#ifdef CONFIG_USB_CPCAP_OTG
+       if (data->otg)
+               otg_put_transceiver(data->otg);
+#endif
+
        wake_lock_destroy(&data->wake_lock);
 
        data->cpcap->accydata = NULL;