summaryrefslogtreecommitdiff
path: root/drivers/extcon
diff options
context:
space:
mode:
authorRakesh Bodla <rbodla@nvidia.com>2014-05-27 12:12:18 +0530
committerMrutyunjay Sawant <msawant@nvidia.com>2014-06-04 00:35:55 -0700
commit98285c12dacb37b0204642f523a72247071b020b (patch)
treee16db8d198e8ffe60e298ad13ec010639eb2e233 /drivers/extcon
parent6126e9888ea116b19f256a46bda41be3bf6f6b54 (diff)
extcon: palmas: make aca detection platform dependent
Make ACA detection platform dependent. Also unset the mutually explosive property. Bug 200004368 Change-Id: I2bdd1008dc96debb29542cef0f6b7d4b801c6cd4 Signed-off-by: Rakesh Bodla <rbodla@nvidia.com> Reviewed-on: http://git-master/r/415127 (cherry picked from commit aa55d35202b5895068bdf8eace842102bf134dab) Reviewed-on: http://git-master/r/417467 Reviewed-by: Venkat Moganty <vmoganty@nvidia.com>
Diffstat (limited to 'drivers/extcon')
-rw-r--r--drivers/extcon/extcon-palmas.c91
1 files changed, 71 insertions, 20 deletions
diff --git a/drivers/extcon/extcon-palmas.c b/drivers/extcon/extcon-palmas.c
index ee6f716e3a20..0d98da8625f7 100644
--- a/drivers/extcon/extcon-palmas.c
+++ b/drivers/extcon/extcon-palmas.c
@@ -7,7 +7,7 @@
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
- * Copyright (c) 2013, NVIDIA CORPORATION. All rights reserved.
+ * Copyright (c) 2013-2014, NVIDIA CORPORATION. All rights reserved.
*
* Author: Graeme Gregory <gg@slimlogic.co.uk>
* Author: Kishon Vijay Abraham I <kishon@ti.com>
@@ -53,8 +53,6 @@ static char const *palmas_extcon_cable[] = {
NULL,
};
-static const int mutually_exclusive[] = {0x3, 0x0};
-
static void palmas_usb_wakeup(struct palmas *palmas, int enable)
{
if (enable)
@@ -244,11 +242,40 @@ static irqreturn_t palmas_id_irq_handler(int irq, void *_palmas_usb)
palmas_read(palmas_usb->palmas, PALMAS_USB_OTG_BASE,
PALMAS_USB_ID_INT_LATCH_SET, &set);
- palmas_write(palmas_usb->palmas, PALMAS_USB_OTG_BASE,
- PALMAS_USB_ID_INT_LATCH_CLR, set);
+ if (palmas_usb->enable_aca_detection) {
+ palmas_write(palmas_usb->palmas, PALMAS_USB_OTG_BASE,
+ PALMAS_USB_ID_INT_LATCH_CLR, set);
- schedule_delayed_work(&palmas_usb->cable_update_wq,
+ schedule_delayed_work(&palmas_usb->cable_update_wq,
msecs_to_jiffies(palmas_usb->cable_debounce_time));
+ } else {
+ dev_info(palmas_usb->dev, "id-irq() ID_INT_LATCH_SET 0x%02x\n",
+ set);
+ if (set & PALMAS_USB_ID_INT_SRC_ID_GND) {
+ palmas_write(palmas_usb->palmas, PALMAS_USB_OTG_BASE,
+ PALMAS_USB_ID_INT_LATCH_CLR,
+ PALMAS_USB_ID_INT_EN_HI_CLR_ID_GND);
+ palmas_usb->id_linkstat = PALMAS_USB_STATE_ID_FLOAT;
+ extcon_set_cable_state(&palmas_usb->edev, "USB-Host",
+ true);
+ dev_info(palmas_usb->dev, "USB-HOST cable is attached\n");
+ } else if (set & PALMAS_USB_ID_INT_SRC_ID_FLOAT) {
+ palmas_write(palmas_usb->palmas, PALMAS_USB_OTG_BASE,
+ PALMAS_USB_ID_INT_LATCH_CLR,
+ PALMAS_USB_ID_INT_EN_HI_CLR_ID_FLOAT);
+ palmas_usb->id_linkstat = PALMAS_USB_STATE_DISCONNECT;
+ extcon_set_cable_state(&palmas_usb->edev, "USB-Host",
+ false);
+ dev_info(palmas_usb->dev, "USB-HOST cable is detached\n");
+ } else if ((palmas_usb->id_linkstat ==
+ PALMAS_USB_STATE_ID_FLOAT) &&
+ (!(set & PALMAS_USB_ID_INT_SRC_ID_GND))) {
+ palmas_usb->id_linkstat = PALMAS_USB_STATE_DISCONNECT;
+ extcon_set_cable_state(&palmas_usb->edev, "USB-Host",
+ false);
+ dev_info(palmas_usb->dev, "USB-HOST cable is detached\n");
+ }
+ }
return IRQ_HANDLED;
}
@@ -262,22 +289,42 @@ static void palmas_enable_irq(struct palmas_usb *palmas_usb)
PALMAS_USB_VBUS_CTRL_SET,
PALMAS_USB_VBUS_CTRL_SET_VBUS_ACT_COMP);
- palmas_write(palmas_usb->palmas, PALMAS_USB_OTG_BASE,
- PALMAS_USB_ID_CTRL_CLEAR, PALMAS_USB_ID_CTRL_SET_ID_SRC_5U);
- palmas_write(palmas_usb->palmas, PALMAS_USB_OTG_BASE,
- PALMAS_USB_ID_CTRL_SET, PALMAS_USB_ID_CTRL_SET_ID_SRC_16U |
- PALMAS_USB_ID_CTRL_SET_ID_ACT_COMP);
+ if (palmas_usb->enable_aca_detection) {
+ palmas_write(palmas_usb->palmas, PALMAS_USB_OTG_BASE,
+ PALMAS_USB_ID_CTRL_CLEAR,
+ PALMAS_USB_ID_CTRL_SET_ID_SRC_5U);
+
+ palmas_write(palmas_usb->palmas, PALMAS_USB_OTG_BASE,
+ PALMAS_USB_ID_CTRL_SET,
+ PALMAS_USB_ID_CTRL_SET_ID_SRC_16U |
+ PALMAS_USB_ID_CTRL_SET_ID_ACT_COMP);
+ } else {
+ palmas_write(palmas_usb->palmas, PALMAS_USB_OTG_BASE,
+ PALMAS_USB_ID_CTRL_SET,
+ PALMAS_USB_ID_CTRL_SET_ID_ACT_COMP);
+
+ palmas_write(palmas_usb->palmas, PALMAS_USB_OTG_BASE,
+ PALMAS_USB_ID_INT_EN_HI_SET,
+ PALMAS_USB_ID_INT_EN_HI_SET_ID_GND |
+ PALMAS_USB_ID_INT_EN_HI_SET_ID_FLOAT);
+ }
if (palmas_usb->enable_vbus_detection)
palmas_vbus_irq_handler(palmas_usb->vbus_irq, palmas_usb);
if (palmas_usb->enable_id_detection) {
- /* Wait for the comparator to update status */
- msleep(palmas_usb->cable_debounce_time);
- ret = palmas_usb_id_state_update(palmas_usb);
- if (ret == -EAGAIN)
- schedule_delayed_work(&palmas_usb->cable_update_wq,
- msecs_to_jiffies(palmas_usb->cable_debounce_time));
+ if (palmas_usb->enable_aca_detection) {
+ /* Wait for the comparator to update status */
+ msleep(palmas_usb->cable_debounce_time);
+ ret = palmas_usb_id_state_update(palmas_usb);
+ if (ret == -EAGAIN)
+ schedule_delayed_work(
+ &palmas_usb->cable_update_wq, msecs_to_jiffies(
+ palmas_usb->cable_debounce_time));
+ } else {
+ msleep(30);
+ palmas_id_irq_handler(palmas_usb->id_irq, palmas_usb);
+ }
}
}
@@ -305,6 +352,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_aca_detection = of_property_read_bool(node,
+ "ti,enable-aca-detection");
status = of_property_read_string(node, "extcon-name", &ext_name);
if (status < 0)
ext_name = NULL;
@@ -340,7 +389,6 @@ static int palmas_usb_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, palmas_usb);
palmas_usb->edev.supported_cable = palmas_extcon_cable;
- palmas_usb->edev.mutually_exclusive = mutually_exclusive;
palmas_usb->edev.name = (ext_name) ? ext_name : dev_name(&pdev->dev);
status = extcon_dev_register(&palmas_usb->edev, palmas_usb->dev);
@@ -361,6 +409,9 @@ static int palmas_usb_probe(struct platform_device *pdev)
palmas_usb->id_irq, status);
goto fail_extcon;
}
+ }
+
+ if (palmas_usb->enable_aca_detection) {
status = devm_request_threaded_irq(palmas_usb->dev,
palmas_usb->id_otg_irq,
NULL, palmas_id_irq_handler,
@@ -396,7 +447,7 @@ static int palmas_usb_probe(struct platform_device *pdev)
fail_extcon:
extcon_dev_unregister(&palmas_usb->edev);
- if (palmas_usb->enable_id_detection)
+ if (palmas_usb->enable_aca_detection)
cancel_delayed_work(&palmas_usb->cable_update_wq);
return status;
@@ -408,7 +459,7 @@ static int palmas_usb_remove(struct platform_device *pdev)
extcon_dev_unregister(&palmas_usb->edev);
- if (palmas_usb->enable_id_detection)
+ if (palmas_usb->enable_aca_detection)
cancel_delayed_work(&palmas_usb->cable_update_wq);
return 0;
}