aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/extcon
diff options
context:
space:
mode:
authorLaxman Dewangan <ldewangan@nvidia.com>2013-07-10 05:29:06 -0400
committerChanwoo Choi <cw00.choi@samsung.com>2013-08-04 19:53:34 -0400
commit7281e05aabee7484624d448da208932690ed62b3 (patch)
tree27a6516f3d805e61c794d355f0e1c818497939d3 /drivers/extcon
parent024783ef422791d7ca58b106495f7c31802df6f3 (diff)
extcon: palmas: Option to disable ID/VBUS detection based on platform
Based on system design, platform needs to detect the VBUS or ID or both. Provide option to select this through platform data to disable part of cable detection through palmas-usb. 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.c87
1 files changed, 52 insertions, 35 deletions
diff --git a/drivers/extcon/extcon-palmas.c b/drivers/extcon/extcon-palmas.c
index d0ce0f16de70..89fdd05c5fd6 100644
--- a/drivers/extcon/extcon-palmas.c
+++ b/drivers/extcon/extcon-palmas.c
@@ -122,11 +122,14 @@ static void palmas_enable_irq(struct palmas_usb *palmas_usb)
122 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); 123 PALMAS_USB_ID_INT_EN_HI_SET_ID_FLOAT);
124 124
125 palmas_vbus_irq_handler(palmas_usb->vbus_irq, palmas_usb); 125 if (palmas_usb->enable_vbus_detection)
126 palmas_vbus_irq_handler(palmas_usb->vbus_irq, palmas_usb);
126 127
127 /* cold plug for host mode needs this delay */ 128 /* cold plug for host mode needs this delay */
128 msleep(30); 129 if (palmas_usb->enable_id_detection) {
129 palmas_id_irq_handler(palmas_usb->id_irq, palmas_usb); 130 msleep(30);
131 palmas_id_irq_handler(palmas_usb->id_irq, palmas_usb);
132 }
130} 133}
131 134
132static int palmas_usb_probe(struct platform_device *pdev) 135static int palmas_usb_probe(struct platform_device *pdev)
@@ -137,21 +140,25 @@ static int palmas_usb_probe(struct platform_device *pdev)
137 struct palmas_usb *palmas_usb; 140 struct palmas_usb *palmas_usb;
138 int status; 141 int status;
139 142
140 if (node && !pdata) {
141 pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
142
143 if (!pdata)
144 return -ENOMEM;
145
146 pdata->wakeup = of_property_read_bool(node, "ti,wakeup");
147 } else if (!pdata) {
148 return -EINVAL;
149 }
150
151 palmas_usb = devm_kzalloc(&pdev->dev, sizeof(*palmas_usb), GFP_KERNEL); 143 palmas_usb = devm_kzalloc(&pdev->dev, sizeof(*palmas_usb), GFP_KERNEL);
152 if (!palmas_usb) 144 if (!palmas_usb)
153 return -ENOMEM; 145 return -ENOMEM;
154 146
147 if (node && !pdata) {
148 palmas_usb->wakeup = of_property_read_bool(node, "ti,wakeup");
149 palmas_usb->enable_id_detection = of_property_read_bool(node,
150 "ti,enable-id-detection");
151 palmas_usb->enable_vbus_detection = of_property_read_bool(node,
152 "ti,enable-vbus-detection");
153 } else {
154 palmas_usb->wakeup = true;
155 palmas_usb->enable_id_detection = true;
156 palmas_usb->enable_vbus_detection = true;
157
158 if (pdata)
159 palmas_usb->wakeup = pdata->wakeup;
160 }
161
155 palmas->usb = palmas_usb; 162 palmas->usb = palmas_usb;
156 palmas_usb->palmas = palmas; 163 palmas_usb->palmas = palmas;
157 164
@@ -166,7 +173,7 @@ static int palmas_usb_probe(struct platform_device *pdev)
166 palmas_usb->vbus_irq = regmap_irq_get_virq(palmas->irq_data, 173 palmas_usb->vbus_irq = regmap_irq_get_virq(palmas->irq_data,
167 PALMAS_VBUS_IRQ); 174 PALMAS_VBUS_IRQ);
168 175
169 palmas_usb_wakeup(palmas, pdata->wakeup); 176 palmas_usb_wakeup(palmas, palmas_usb->wakeup);
170 177
171 platform_set_drvdata(pdev, palmas_usb); 178 platform_set_drvdata(pdev, palmas_usb);
172 179
@@ -179,26 +186,32 @@ static int palmas_usb_probe(struct platform_device *pdev)
179 return status; 186 return status;
180 } 187 }
181 188
182 status = devm_request_threaded_irq(palmas_usb->dev, palmas_usb->id_irq, 189 if (palmas_usb->enable_id_detection) {
183 NULL, palmas_id_irq_handler, 190 status = devm_request_threaded_irq(palmas_usb->dev,
184 IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING | 191 palmas_usb->id_irq,
185 IRQF_ONESHOT | IRQF_EARLY_RESUME, 192 NULL, palmas_id_irq_handler,
186 "palmas_usb_id", palmas_usb); 193 IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING |
187 if (status < 0) { 194 IRQF_ONESHOT | IRQF_EARLY_RESUME,
188 dev_err(&pdev->dev, "can't get IRQ %d, err %d\n", 195 "palmas_usb_id", palmas_usb);
196 if (status < 0) {
197 dev_err(&pdev->dev, "can't get IRQ %d, err %d\n",
189 palmas_usb->id_irq, status); 198 palmas_usb->id_irq, status);
190 goto fail_extcon; 199 goto fail_extcon;
200 }
191 } 201 }
192 202
193 status = devm_request_threaded_irq(palmas_usb->dev, 203 if (palmas_usb->enable_vbus_detection) {
194 palmas_usb->vbus_irq, NULL, palmas_vbus_irq_handler, 204 status = devm_request_threaded_irq(palmas_usb->dev,
195 IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING | 205 palmas_usb->vbus_irq, NULL,
196 IRQF_ONESHOT | IRQF_EARLY_RESUME, 206 palmas_vbus_irq_handler,
197 "palmas_usb_vbus", palmas_usb); 207 IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING |
198 if (status < 0) { 208 IRQF_ONESHOT | IRQF_EARLY_RESUME,
199 dev_err(&pdev->dev, "can't get IRQ %d, err %d\n", 209 "palmas_usb_vbus", palmas_usb);
210 if (status < 0) {
211 dev_err(&pdev->dev, "can't get IRQ %d, err %d\n",
200 palmas_usb->vbus_irq, status); 212 palmas_usb->vbus_irq, status);
201 goto fail_extcon; 213 goto fail_extcon;
214 }
202 } 215 }
203 216
204 palmas_enable_irq(palmas_usb); 217 palmas_enable_irq(palmas_usb);
@@ -226,8 +239,10 @@ static int palmas_usb_suspend(struct device *dev)
226 struct palmas_usb *palmas_usb = dev_get_drvdata(dev); 239 struct palmas_usb *palmas_usb = dev_get_drvdata(dev);
227 240
228 if (device_may_wakeup(dev)) { 241 if (device_may_wakeup(dev)) {
229 enable_irq_wake(palmas_usb->vbus_irq); 242 if (palmas_usb->enable_vbus_detection)
230 enable_irq_wake(palmas_usb->id_irq); 243 enable_irq_wake(palmas_usb->vbus_irq);
244 if (palmas_usb->enable_id_detection)
245 enable_irq_wake(palmas_usb->id_irq);
231 } 246 }
232 return 0; 247 return 0;
233} 248}
@@ -237,8 +252,10 @@ static int palmas_usb_resume(struct device *dev)
237 struct palmas_usb *palmas_usb = dev_get_drvdata(dev); 252 struct palmas_usb *palmas_usb = dev_get_drvdata(dev);
238 253
239 if (device_may_wakeup(dev)) { 254 if (device_may_wakeup(dev)) {
240 disable_irq_wake(palmas_usb->vbus_irq); 255 if (palmas_usb->enable_vbus_detection)
241 disable_irq_wake(palmas_usb->id_irq); 256 disable_irq_wake(palmas_usb->vbus_irq);
257 if (palmas_usb->enable_id_detection)
258 disable_irq_wake(palmas_usb->id_irq);
242 } 259 }
243 return 0; 260 return 0;
244}; 261};