diff options
author | Laxman Dewangan <ldewangan@nvidia.com> | 2013-07-09 09:04:22 -0400 |
---|---|---|
committer | Chanwoo Choi <cw00.choi@samsung.com> | 2013-08-04 19:53:34 -0400 |
commit | 002945f014ab51c470fdbd30b199fa85f715280d (patch) | |
tree | 13a25899562aef60b583952d61d98dd6b016cebf /drivers/extcon | |
parent | 43e3f38892a6a521ff5901cdb97cf6985101badd (diff) |
extcon: palmas: enable ID_GND and ID_FLOAT detection always
When integrating driver with Tegra platform, it is found that
the ID pins get detected only once after booting system and
further removal and re-insert does not detect the ID pin.
Fixing this issue with enabling interrupt on ID_GND and ID_FLOAT
always and clearing the status on LATCH register which actually
occurred.
Also if interrupt occurs with line status as zero then based on
previous status, set the cable state.
Add debug prints to display the cable state when any cable
insertion/removal happen.
Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
Acked-by: Graeme Gregory <gg@slimlogic.co.uk>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: Myungjoo Ham <myungjoo.ham@samsung.com>
Diffstat (limited to 'drivers/extcon')
-rw-r--r-- | drivers/extcon/extcon-palmas.c | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/drivers/extcon/extcon-palmas.c b/drivers/extcon/extcon-palmas.c index 7350ac2ec5e4..ef77a461ca39 100644 --- a/drivers/extcon/extcon-palmas.c +++ b/drivers/extcon/extcon-palmas.c | |||
@@ -57,6 +57,7 @@ static irqreturn_t palmas_vbus_irq_handler(int irq, void *_palmas_usb) | |||
57 | if (palmas_usb->linkstat != PALMAS_USB_STATE_VBUS) { | 57 | if (palmas_usb->linkstat != PALMAS_USB_STATE_VBUS) { |
58 | palmas_usb->linkstat = PALMAS_USB_STATE_VBUS; | 58 | palmas_usb->linkstat = PALMAS_USB_STATE_VBUS; |
59 | extcon_set_cable_state(&palmas_usb->edev, "USB", true); | 59 | extcon_set_cable_state(&palmas_usb->edev, "USB", true); |
60 | dev_info(palmas_usb->dev, "USB cable is attached\n"); | ||
60 | } else { | 61 | } else { |
61 | dev_dbg(palmas_usb->dev, | 62 | dev_dbg(palmas_usb->dev, |
62 | "Spurious connect event detected\n"); | 63 | "Spurious connect event detected\n"); |
@@ -65,6 +66,7 @@ static irqreturn_t palmas_vbus_irq_handler(int irq, void *_palmas_usb) | |||
65 | if (palmas_usb->linkstat == PALMAS_USB_STATE_VBUS) { | 66 | if (palmas_usb->linkstat == PALMAS_USB_STATE_VBUS) { |
66 | palmas_usb->linkstat = PALMAS_USB_STATE_DISCONNECT; | 67 | palmas_usb->linkstat = PALMAS_USB_STATE_DISCONNECT; |
67 | extcon_set_cable_state(&palmas_usb->edev, "USB", false); | 68 | extcon_set_cable_state(&palmas_usb->edev, "USB", false); |
69 | dev_info(palmas_usb->dev, "USB cable is detached\n"); | ||
68 | } else { | 70 | } else { |
69 | dev_dbg(palmas_usb->dev, | 71 | dev_dbg(palmas_usb->dev, |
70 | "Spurious disconnect event detected\n"); | 72 | "Spurious disconnect event detected\n"); |
@@ -84,28 +86,23 @@ static irqreturn_t palmas_id_irq_handler(int irq, void *_palmas_usb) | |||
84 | 86 | ||
85 | if (set & PALMAS_USB_ID_INT_SRC_ID_GND) { | 87 | if (set & PALMAS_USB_ID_INT_SRC_ID_GND) { |
86 | palmas_write(palmas_usb->palmas, PALMAS_USB_OTG_BASE, | 88 | palmas_write(palmas_usb->palmas, PALMAS_USB_OTG_BASE, |
87 | PALMAS_USB_ID_INT_EN_HI_SET, | ||
88 | PALMAS_USB_ID_INT_EN_HI_SET_ID_FLOAT); | ||
89 | palmas_write(palmas_usb->palmas, PALMAS_USB_OTG_BASE, | ||
90 | PALMAS_USB_ID_INT_EN_HI_CLR, | ||
91 | PALMAS_USB_ID_INT_EN_HI_CLR_ID_GND); | ||
92 | palmas_write(palmas_usb->palmas, PALMAS_USB_OTG_BASE, | ||
93 | PALMAS_USB_ID_INT_LATCH_CLR, | 89 | PALMAS_USB_ID_INT_LATCH_CLR, |
94 | PALMAS_USB_ID_INT_EN_HI_CLR_ID_GND); | 90 | PALMAS_USB_ID_INT_EN_HI_CLR_ID_GND); |
95 | palmas_usb->linkstat = PALMAS_USB_STATE_ID; | 91 | palmas_usb->linkstat = PALMAS_USB_STATE_ID; |
96 | extcon_set_cable_state(&palmas_usb->edev, "USB-HOST", true); | 92 | extcon_set_cable_state(&palmas_usb->edev, "USB-HOST", true); |
93 | dev_info(palmas_usb->dev, "USB-HOST cable is attached\n"); | ||
97 | } else if (set & PALMAS_USB_ID_INT_SRC_ID_FLOAT) { | 94 | } else if (set & PALMAS_USB_ID_INT_SRC_ID_FLOAT) { |
98 | palmas_write(palmas_usb->palmas, PALMAS_USB_OTG_BASE, | 95 | palmas_write(palmas_usb->palmas, PALMAS_USB_OTG_BASE, |
99 | PALMAS_USB_ID_INT_EN_HI_SET, | ||
100 | PALMAS_USB_ID_INT_EN_HI_SET_ID_GND); | ||
101 | palmas_write(palmas_usb->palmas, PALMAS_USB_OTG_BASE, | ||
102 | PALMAS_USB_ID_INT_EN_HI_CLR, | ||
103 | PALMAS_USB_ID_INT_EN_HI_CLR_ID_FLOAT); | ||
104 | palmas_write(palmas_usb->palmas, PALMAS_USB_OTG_BASE, | ||
105 | PALMAS_USB_ID_INT_LATCH_CLR, | 96 | PALMAS_USB_ID_INT_LATCH_CLR, |
106 | PALMAS_USB_ID_INT_EN_HI_CLR_ID_FLOAT); | 97 | PALMAS_USB_ID_INT_EN_HI_CLR_ID_FLOAT); |
107 | palmas_usb->linkstat = PALMAS_USB_STATE_DISCONNECT; | 98 | palmas_usb->linkstat = PALMAS_USB_STATE_DISCONNECT; |
108 | extcon_set_cable_state(&palmas_usb->edev, "USB-HOST", false); | 99 | extcon_set_cable_state(&palmas_usb->edev, "USB-HOST", false); |
100 | dev_info(palmas_usb->dev, "USB-HOST cable is detached\n"); | ||
101 | } else if ((palmas_usb->linkstat == PALMAS_USB_STATE_ID) && | ||
102 | (!(set & PALMAS_USB_ID_INT_SRC_ID_GND))) { | ||
103 | palmas_usb->linkstat = PALMAS_USB_STATE_DISCONNECT; | ||
104 | extcon_set_cable_state(&palmas_usb->edev, "USB-HOST", false); | ||
105 | dev_info(palmas_usb->dev, "USB-HOST cable is detached\n"); | ||
109 | } | 106 | } |
110 | 107 | ||
111 | return IRQ_HANDLED; | 108 | return IRQ_HANDLED; |
@@ -122,7 +119,8 @@ static void palmas_enable_irq(struct palmas_usb *palmas_usb) | |||
122 | 119 | ||
123 | palmas_write(palmas_usb->palmas, PALMAS_USB_OTG_BASE, | 120 | palmas_write(palmas_usb->palmas, PALMAS_USB_OTG_BASE, |
124 | PALMAS_USB_ID_INT_EN_HI_SET, | 121 | PALMAS_USB_ID_INT_EN_HI_SET, |
125 | PALMAS_USB_ID_INT_EN_HI_SET_ID_GND); | 122 | PALMAS_USB_ID_INT_EN_HI_SET_ID_GND | |
123 | PALMAS_USB_ID_INT_EN_HI_SET_ID_FLOAT); | ||
126 | 124 | ||
127 | palmas_vbus_irq_handler(palmas_usb->vbus_irq, palmas_usb); | 125 | palmas_vbus_irq_handler(palmas_usb->vbus_irq, palmas_usb); |
128 | 126 | ||