extcon: extcon-palmas: Provision ID status check from VBUS interrupt
Somdutta Roy [Mon, 5 Oct 2015 23:39:44 +0000 (16:39 -0700)]
Resistance changes upon RIDB Y-Cable insertion sometimes not raising
ID interrupt causing failure in RIDB Y-Cable detection. Provisioned
checking ID status on VBUS interrupt if enabled in DTB.

Bug 1690930

Change-Id: If120d77048138d4dfeb7508b98fb20fa6051cb3d
Signed-off-by: Somdutta Roy <somduttar@nvidia.com>
Reviewed-on: http://git-master/r/814902
Reviewed-by: Venkat Reddy Talla <vreddytalla@nvidia.com>
Tested-by: Venkat Reddy Talla <vreddytalla@nvidia.com>
Reviewed-by: Laxman Dewangan <ldewangan@nvidia.com>

Documentation/devicetree/bindings/extcon/extcon-palmas.txt
drivers/extcon/extcon-palmas.c
include/linux/mfd/palmas.h

index 723aaf7..d6d7740 100644 (file)
@@ -8,6 +8,7 @@ Optional Properties:
  - ti,wakeup : To enable the wakeup comparator in probe
  - ti,enable-id-detection: Perform ID detection.
  - ti,enable-vbus-detection: Perform VBUS detection.
+ - ti,enable-id-detect-on-vbus: Perform ID detection on VBUS interrupt
  - extcon-name: Name of extcon connection.
 
 palmas-usb {
index 42c00e1..9c4bd86 100644 (file)
@@ -218,6 +218,12 @@ static irqreturn_t palmas_vbus_irq_handler(int irq, void *_palmas_usb)
                        palmas_usb->vbus_linkstat = PALMAS_USB_STATE_VBUS;
                        extcon_set_cable_state(&palmas_usb->edev, "USB", true);
                        dev_info(palmas_usb->dev, "USB cable is attached\n");
+                       if (palmas_usb->enable_id_detect_on_vbus) {
+                               schedule_delayed_work(
+                                       &palmas_usb->cable_update_wq,
+                                        msecs_to_jiffies(
+                                         palmas_usb->cable_debounce_time));
+                   }
                } else {
                        dev_info(palmas_usb->dev,
                                "Spurious connect event detected\n");
@@ -305,6 +311,8 @@ static int palmas_usb_probe(struct platform_device *pdev)
                                                "ti,enable-id-detection");
                palmas_usb->enable_vbus_detection = of_property_read_bool(node,
                                                "ti,enable-vbus-detection");
+               palmas_usb->enable_id_detect_on_vbus = of_property_read_bool(
+                                      node, "ti,enable-id-detect-on-vbus");
                status = of_property_read_string(node, "extcon-name", &ext_name);
                if (status < 0)
                        ext_name = NULL;
@@ -312,6 +320,7 @@ static int palmas_usb_probe(struct platform_device *pdev)
                palmas_usb->wakeup = true;
                palmas_usb->enable_id_detection = true;
                palmas_usb->enable_vbus_detection = true;
+               palmas_usb->enable_id_detect_on_vbus = false;
 
                if (epdata) {
                        palmas_usb->wakeup = epdata->wakeup;
@@ -350,16 +359,22 @@ static int palmas_usb_probe(struct platform_device *pdev)
        }
 
        if (palmas_usb->enable_id_detection) {
-               status = devm_request_threaded_irq(palmas_usb->dev,
-                               palmas_usb->id_irq,
-                               NULL, palmas_id_irq_handler,
-                               IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING |
-                               IRQF_ONESHOT | IRQF_EARLY_RESUME,
-                               "palmas_usb_id", palmas_usb);
-               if (status < 0) {
-                       dev_err(&pdev->dev, "can't get IRQ %d, err %d\n",
+               if (!palmas_usb->enable_id_detect_on_vbus) {
+                       status = devm_request_threaded_irq(
+                                       palmas_usb->dev,
+                                       palmas_usb->id_irq,
+                                       NULL, palmas_id_irq_handler,
+                                       IRQF_TRIGGER_FALLING |
+                                       IRQF_TRIGGER_RISING |
+                                       IRQF_ONESHOT |
+                                       IRQF_EARLY_RESUME,
+                                       "palmas_usb_id", palmas_usb);
+                       if (status < 0) {
+                               dev_err(&pdev->dev,
+                                       "can't get IRQ %d, err %d\n",
                                        palmas_usb->id_irq, status);
-                       goto fail_extcon;
+                               goto fail_extcon;
+                       }
                }
                status = devm_request_threaded_irq(palmas_usb->dev,
                                palmas_usb->id_otg_irq,
index 6cf156d..cf2ae8f 100644 (file)
@@ -775,6 +775,7 @@ struct palmas_usb {
        int wakeup;
        bool enable_vbus_detection;
        bool enable_id_detection;
+       bool enable_id_detect_on_vbus;
        struct delayed_work cable_update_wq;
        int cable_debounce_time;
        int cur_cable_index;