blob: 3ef3bee7d1e65dabee5e9cadd7e404289706339e [file] [log] [blame]
Mark Brownf2c32a82012-06-24 12:09:45 +01001/*
2 * extcon-arizona.c - Extcon driver Wolfson Arizona devices
3 *
4 * Copyright (C) 2012 Wolfson Microelectronics plc
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 */
16
17#include <linux/kernel.h>
18#include <linux/module.h>
19#include <linux/i2c.h>
20#include <linux/slab.h>
21#include <linux/interrupt.h>
22#include <linux/err.h>
23#include <linux/gpio.h>
Mark Brown34efe4d2012-07-20 17:07:29 +010024#include <linux/input.h>
Mark Brownf2c32a82012-06-24 12:09:45 +010025#include <linux/platform_device.h>
26#include <linux/pm_runtime.h>
27#include <linux/regulator/consumer.h>
28#include <linux/extcon.h>
29
30#include <linux/mfd/arizona/core.h>
31#include <linux/mfd/arizona/pdata.h>
32#include <linux/mfd/arizona/registers.h>
33
Mark Brown34efe4d2012-07-20 17:07:29 +010034#define ARIZONA_NUM_BUTTONS 6
35
Mark Brownf2c32a82012-06-24 12:09:45 +010036struct arizona_extcon_info {
37 struct device *dev;
38 struct arizona *arizona;
39 struct mutex lock;
40 struct regulator *micvdd;
Mark Brown34efe4d2012-07-20 17:07:29 +010041 struct input_dev *input;
Mark Brownf2c32a82012-06-24 12:09:45 +010042
43 int micd_mode;
44 const struct arizona_micd_config *micd_modes;
45 int micd_num_modes;
46
47 bool micd_reva;
Mark Browndab63eb2013-01-11 08:55:36 +090048 bool micd_clamp;
Mark Brownf2c32a82012-06-24 12:09:45 +010049
50 bool mic;
51 bool detecting;
52 int jack_flips;
53
54 struct extcon_dev edev;
55};
56
57static const struct arizona_micd_config micd_default_modes[] = {
58 { ARIZONA_ACCDET_SRC, 1 << ARIZONA_MICD_BIAS_SRC_SHIFT, 0 },
59 { 0, 2 << ARIZONA_MICD_BIAS_SRC_SHIFT, 1 },
60};
61
Mark Brown34efe4d2012-07-20 17:07:29 +010062static struct {
63 u16 status;
64 int report;
65} arizona_lvl_to_key[ARIZONA_NUM_BUTTONS] = {
66 { 0x1, BTN_0 },
67 { 0x2, BTN_1 },
68 { 0x4, BTN_2 },
69 { 0x8, BTN_3 },
70 { 0x10, BTN_4 },
71 { 0x20, BTN_5 },
72};
73
Mark Brown325c6422012-06-28 13:08:30 +010074#define ARIZONA_CABLE_MECHANICAL 0
75#define ARIZONA_CABLE_MICROPHONE 1
76#define ARIZONA_CABLE_HEADPHONE 2
Mark Brownf2c32a82012-06-24 12:09:45 +010077
78static const char *arizona_cable[] = {
Mark Brown325c6422012-06-28 13:08:30 +010079 "Mechanical",
80 "Microphone",
81 "Headphone",
Mark Brownf2c32a82012-06-24 12:09:45 +010082 NULL,
83};
84
Mark Brownf2c32a82012-06-24 12:09:45 +010085static void arizona_extcon_set_mode(struct arizona_extcon_info *info, int mode)
86{
87 struct arizona *arizona = info->arizona;
88
Mark Browncd74f7b2012-11-27 16:14:26 +090089 if (arizona->pdata.micd_pol_gpio > 0)
90 gpio_set_value_cansleep(arizona->pdata.micd_pol_gpio,
91 info->micd_modes[mode].gpio);
Mark Brownf2c32a82012-06-24 12:09:45 +010092 regmap_update_bits(arizona->regmap, ARIZONA_MIC_DETECT_1,
93 ARIZONA_MICD_BIAS_SRC_MASK,
94 info->micd_modes[mode].bias);
95 regmap_update_bits(arizona->regmap, ARIZONA_ACCESSORY_DETECT_MODE_1,
96 ARIZONA_ACCDET_SRC, info->micd_modes[mode].src);
97
98 info->micd_mode = mode;
99
100 dev_dbg(arizona->dev, "Set jack polarity to %d\n", mode);
101}
102
103static void arizona_start_mic(struct arizona_extcon_info *info)
104{
105 struct arizona *arizona = info->arizona;
106 bool change;
107 int ret;
108
109 info->detecting = true;
110 info->mic = false;
111 info->jack_flips = 0;
112
113 /* Microphone detection can't use idle mode */
114 pm_runtime_get(info->dev);
115
116 ret = regulator_enable(info->micvdd);
117 if (ret != 0) {
118 dev_err(arizona->dev, "Failed to enable MICVDD: %d\n",
119 ret);
120 }
121
122 if (info->micd_reva) {
123 regmap_write(arizona->regmap, 0x80, 0x3);
124 regmap_write(arizona->regmap, 0x294, 0);
125 regmap_write(arizona->regmap, 0x80, 0x0);
126 }
127
128 regmap_update_bits_check(arizona->regmap, ARIZONA_MIC_DETECT_1,
129 ARIZONA_MICD_ENA, ARIZONA_MICD_ENA,
130 &change);
131 if (!change) {
132 regulator_disable(info->micvdd);
133 pm_runtime_put_autosuspend(info->dev);
134 }
135}
136
137static void arizona_stop_mic(struct arizona_extcon_info *info)
138{
139 struct arizona *arizona = info->arizona;
140 bool change;
141
142 regmap_update_bits_check(arizona->regmap, ARIZONA_MIC_DETECT_1,
143 ARIZONA_MICD_ENA, 0,
144 &change);
145
146 if (info->micd_reva) {
147 regmap_write(arizona->regmap, 0x80, 0x3);
148 regmap_write(arizona->regmap, 0x294, 2);
149 regmap_write(arizona->regmap, 0x80, 0x0);
150 }
151
152 if (change) {
153 regulator_disable(info->micvdd);
Mark Brown34efe4d2012-07-20 17:07:29 +0100154 pm_runtime_mark_last_busy(info->dev);
Mark Brownf2c32a82012-06-24 12:09:45 +0100155 pm_runtime_put_autosuspend(info->dev);
156 }
157}
158
159static irqreturn_t arizona_micdet(int irq, void *data)
160{
161 struct arizona_extcon_info *info = data;
162 struct arizona *arizona = info->arizona;
Mark Brown34efe4d2012-07-20 17:07:29 +0100163 unsigned int val, lvl;
164 int ret, i;
Mark Brownf2c32a82012-06-24 12:09:45 +0100165
166 mutex_lock(&info->lock);
167
168 ret = regmap_read(arizona->regmap, ARIZONA_MIC_DETECT_3, &val);
169 if (ret != 0) {
170 dev_err(arizona->dev, "Failed to read MICDET: %d\n", ret);
Alexey Khoroshilovbe31cc02012-11-05 17:11:41 +0900171 mutex_unlock(&info->lock);
Mark Brownf2c32a82012-06-24 12:09:45 +0100172 return IRQ_NONE;
173 }
174
175 dev_dbg(arizona->dev, "MICDET: %x\n", val);
176
177 if (!(val & ARIZONA_MICD_VALID)) {
178 dev_warn(arizona->dev, "Microphone detection state invalid\n");
179 mutex_unlock(&info->lock);
180 return IRQ_NONE;
181 }
182
183 /* Due to jack detect this should never happen */
184 if (!(val & ARIZONA_MICD_STS)) {
185 dev_warn(arizona->dev, "Detected open circuit\n");
186 info->detecting = false;
187 goto handled;
188 }
189
190 /* If we got a high impedence we should have a headset, report it. */
191 if (info->detecting && (val & 0x400)) {
Mark Brown325c6422012-06-28 13:08:30 +0100192 ret = extcon_update_state(&info->edev,
193 1 << ARIZONA_CABLE_MICROPHONE |
194 1 << ARIZONA_CABLE_HEADPHONE,
195 1 << ARIZONA_CABLE_MICROPHONE |
196 1 << ARIZONA_CABLE_HEADPHONE);
Mark Brownf2c32a82012-06-24 12:09:45 +0100197
198 if (ret != 0)
199 dev_err(arizona->dev, "Headset report failed: %d\n",
200 ret);
201
202 info->mic = true;
203 info->detecting = false;
204 goto handled;
205 }
206
207 /* If we detected a lower impedence during initial startup
208 * then we probably have the wrong polarity, flip it. Don't
209 * do this for the lowest impedences to speed up detection of
210 * plain headphones. If both polarities report a low
211 * impedence then give up and report headphones.
212 */
213 if (info->detecting && (val & 0x3f8)) {
214 info->jack_flips++;
215
216 if (info->jack_flips >= info->micd_num_modes) {
217 dev_dbg(arizona->dev, "Detected headphone\n");
218 info->detecting = false;
Mark Brown9ef2224d2012-06-28 13:08:31 +0100219 arizona_stop_mic(info);
220
Mark Brown325c6422012-06-28 13:08:30 +0100221 ret = extcon_set_cable_state_(&info->edev,
222 ARIZONA_CABLE_HEADPHONE,
223 true);
Mark Brownf2c32a82012-06-24 12:09:45 +0100224 if (ret != 0)
225 dev_err(arizona->dev,
226 "Headphone report failed: %d\n",
227 ret);
228 } else {
229 info->micd_mode++;
230 if (info->micd_mode == info->micd_num_modes)
231 info->micd_mode = 0;
232 arizona_extcon_set_mode(info, info->micd_mode);
233
234 info->jack_flips++;
235 }
236
237 goto handled;
238 }
239
240 /*
241 * If we're still detecting and we detect a short then we've
Mark Brown34efe4d2012-07-20 17:07:29 +0100242 * got a headphone. Otherwise it's a button press.
Mark Brownf2c32a82012-06-24 12:09:45 +0100243 */
244 if (val & 0x3fc) {
245 if (info->mic) {
246 dev_dbg(arizona->dev, "Mic button detected\n");
247
Mark Brown34efe4d2012-07-20 17:07:29 +0100248 lvl = val & ARIZONA_MICD_LVL_MASK;
249 lvl >>= ARIZONA_MICD_LVL_SHIFT;
250
251 for (i = 0; i < ARIZONA_NUM_BUTTONS; i++)
252 if (lvl & arizona_lvl_to_key[i].status)
253 input_report_key(info->input,
254 arizona_lvl_to_key[i].report,
255 1);
256 input_sync(info->input);
257
Mark Brownf2c32a82012-06-24 12:09:45 +0100258 } else if (info->detecting) {
259 dev_dbg(arizona->dev, "Headphone detected\n");
260 info->detecting = false;
261 arizona_stop_mic(info);
262
Mark Brown325c6422012-06-28 13:08:30 +0100263 ret = extcon_set_cable_state_(&info->edev,
264 ARIZONA_CABLE_HEADPHONE,
265 true);
Mark Brownf2c32a82012-06-24 12:09:45 +0100266 if (ret != 0)
267 dev_err(arizona->dev,
268 "Headphone report failed: %d\n",
269 ret);
270 } else {
271 dev_warn(arizona->dev, "Button with no mic: %x\n",
272 val);
273 }
274 } else {
275 dev_dbg(arizona->dev, "Mic button released\n");
Mark Brown34efe4d2012-07-20 17:07:29 +0100276 for (i = 0; i < ARIZONA_NUM_BUTTONS; i++)
277 input_report_key(info->input,
278 arizona_lvl_to_key[i].report, 0);
279 input_sync(info->input);
Mark Brownf2c32a82012-06-24 12:09:45 +0100280 }
281
282handled:
283 pm_runtime_mark_last_busy(info->dev);
284 mutex_unlock(&info->lock);
285
286 return IRQ_HANDLED;
287}
288
289static irqreturn_t arizona_jackdet(int irq, void *data)
290{
291 struct arizona_extcon_info *info = data;
292 struct arizona *arizona = info->arizona;
293 unsigned int val;
Mark Brown34efe4d2012-07-20 17:07:29 +0100294 int ret, i;
Mark Brownf2c32a82012-06-24 12:09:45 +0100295
296 pm_runtime_get_sync(info->dev);
297
298 mutex_lock(&info->lock);
299
300 ret = regmap_read(arizona->regmap, ARIZONA_AOD_IRQ_RAW_STATUS, &val);
301 if (ret != 0) {
302 dev_err(arizona->dev, "Failed to read jackdet status: %d\n",
303 ret);
304 mutex_unlock(&info->lock);
305 pm_runtime_put_autosuspend(info->dev);
306 return IRQ_NONE;
307 }
308
309 if (val & ARIZONA_JD1_STS) {
310 dev_dbg(arizona->dev, "Detected jack\n");
Mark Brown325c6422012-06-28 13:08:30 +0100311 ret = extcon_set_cable_state_(&info->edev,
312 ARIZONA_CABLE_MECHANICAL, true);
Mark Brownf2c32a82012-06-24 12:09:45 +0100313
314 if (ret != 0)
315 dev_err(arizona->dev, "Mechanical report failed: %d\n",
316 ret);
317
318 arizona_start_mic(info);
319 } else {
320 dev_dbg(arizona->dev, "Detected jack removal\n");
321
322 arizona_stop_mic(info);
323
Mark Brown34efe4d2012-07-20 17:07:29 +0100324 for (i = 0; i < ARIZONA_NUM_BUTTONS; i++)
325 input_report_key(info->input,
326 arizona_lvl_to_key[i].report, 0);
327 input_sync(info->input);
328
Mark Brownf2c32a82012-06-24 12:09:45 +0100329 ret = extcon_update_state(&info->edev, 0xffffffff, 0);
330 if (ret != 0)
331 dev_err(arizona->dev, "Removal report failed: %d\n",
332 ret);
333 }
334
335 mutex_unlock(&info->lock);
336
337 pm_runtime_mark_last_busy(info->dev);
338 pm_runtime_put_autosuspend(info->dev);
339
340 return IRQ_HANDLED;
341}
342
Bill Pemberton44f34fd2012-11-19 13:23:21 -0500343static int arizona_extcon_probe(struct platform_device *pdev)
Mark Brownf2c32a82012-06-24 12:09:45 +0100344{
345 struct arizona *arizona = dev_get_drvdata(pdev->dev.parent);
346 struct arizona_pdata *pdata;
347 struct arizona_extcon_info *info;
Mark Brown34efe4d2012-07-20 17:07:29 +0100348 int ret, mode, i;
Mark Brownf2c32a82012-06-24 12:09:45 +0100349
350 pdata = dev_get_platdata(arizona->dev);
351
352 info = devm_kzalloc(&pdev->dev, sizeof(*info), GFP_KERNEL);
353 if (!info) {
Peter Meerwald8e5f5012012-08-23 09:11:50 +0900354 dev_err(&pdev->dev, "Failed to allocate memory\n");
Mark Brownf2c32a82012-06-24 12:09:45 +0100355 ret = -ENOMEM;
356 goto err;
357 }
358
359 info->micvdd = devm_regulator_get(arizona->dev, "MICVDD");
360 if (IS_ERR(info->micvdd)) {
361 ret = PTR_ERR(info->micvdd);
362 dev_err(arizona->dev, "Failed to get MICVDD: %d\n", ret);
363 goto err;
364 }
365
366 mutex_init(&info->lock);
367 info->arizona = arizona;
368 info->dev = &pdev->dev;
369 info->detecting = true;
370 platform_set_drvdata(pdev, info);
371
372 switch (arizona->type) {
373 case WM5102:
374 switch (arizona->rev) {
375 case 0:
376 info->micd_reva = true;
377 break;
378 default:
Mark Browndab63eb2013-01-11 08:55:36 +0900379 info->micd_clamp = true;
Mark Brownf2c32a82012-06-24 12:09:45 +0100380 break;
381 }
382 break;
383 default:
384 break;
385 }
386
387 info->edev.name = "Headset Jack";
388 info->edev.supported_cable = arizona_cable;
Mark Brownf2c32a82012-06-24 12:09:45 +0100389
390 ret = extcon_dev_register(&info->edev, arizona->dev);
391 if (ret < 0) {
Peter Meerwald8e5f5012012-08-23 09:11:50 +0900392 dev_err(arizona->dev, "extcon_dev_register() failed: %d\n",
Mark Brownf2c32a82012-06-24 12:09:45 +0100393 ret);
394 goto err;
395 }
396
397 if (pdata->num_micd_configs) {
398 info->micd_modes = pdata->micd_configs;
399 info->micd_num_modes = pdata->num_micd_configs;
400 } else {
401 info->micd_modes = micd_default_modes;
402 info->micd_num_modes = ARRAY_SIZE(micd_default_modes);
403 }
404
405 if (arizona->pdata.micd_pol_gpio > 0) {
406 if (info->micd_modes[0].gpio)
407 mode = GPIOF_OUT_INIT_HIGH;
408 else
409 mode = GPIOF_OUT_INIT_LOW;
410
411 ret = devm_gpio_request_one(&pdev->dev,
412 arizona->pdata.micd_pol_gpio,
413 mode,
414 "MICD polarity");
415 if (ret != 0) {
416 dev_err(arizona->dev, "Failed to request GPIO%d: %d\n",
417 arizona->pdata.micd_pol_gpio, ret);
418 goto err_register;
419 }
420 }
421
Mark Brownb17e5462013-01-11 08:55:24 +0900422 if (arizona->pdata.micd_bias_start_time)
423 regmap_update_bits(arizona->regmap, ARIZONA_MIC_DETECT_1,
424 ARIZONA_MICD_BIAS_STARTTIME_MASK,
425 arizona->pdata.micd_bias_start_time
426 << ARIZONA_MICD_BIAS_STARTTIME_SHIFT);
427
Mark Browndab63eb2013-01-11 08:55:36 +0900428 /*
429 * If we have a clamp use it.
430 */
431 if (info->micd_clamp) {
432 regmap_update_bits(arizona->regmap,
433 ARIZONA_MICD_CLAMP_CONTROL,
434 ARIZONA_MICD_CLAMP_MODE_MASK, 4);
435 regmap_update_bits(arizona->regmap,
436 ARIZONA_JACK_DETECT_DEBOUNCE,
437 ARIZONA_MICD_CLAMP_DB,
438 ARIZONA_MICD_CLAMP_DB);
439 }
440
Mark Brownf2c32a82012-06-24 12:09:45 +0100441 arizona_extcon_set_mode(info, 0);
442
Mark Brown3d44ea12013-01-11 08:51:13 +0900443 info->input = devm_input_allocate_device(&pdev->dev);
Mark Brown34efe4d2012-07-20 17:07:29 +0100444 if (!info->input) {
445 dev_err(arizona->dev, "Can't allocate input dev\n");
446 ret = -ENOMEM;
447 goto err_register;
448 }
449
450 for (i = 0; i < ARIZONA_NUM_BUTTONS; i++)
451 input_set_capability(info->input, EV_KEY,
452 arizona_lvl_to_key[i].report);
453 info->input->name = "Headset";
454 info->input->phys = "arizona/extcon";
455 info->input->dev.parent = &pdev->dev;
456
Mark Brownf2c32a82012-06-24 12:09:45 +0100457 pm_runtime_enable(&pdev->dev);
458 pm_runtime_idle(&pdev->dev);
459 pm_runtime_get_sync(&pdev->dev);
460
461 ret = arizona_request_irq(arizona, ARIZONA_IRQ_JD_RISE,
462 "JACKDET rise", arizona_jackdet, info);
463 if (ret != 0) {
464 dev_err(&pdev->dev, "Failed to get JACKDET rise IRQ: %d\n",
465 ret);
Mark Brown34efe4d2012-07-20 17:07:29 +0100466 goto err_input;
Mark Brownf2c32a82012-06-24 12:09:45 +0100467 }
468
469 ret = arizona_set_irq_wake(arizona, ARIZONA_IRQ_JD_RISE, 1);
470 if (ret != 0) {
471 dev_err(&pdev->dev, "Failed to set JD rise IRQ wake: %d\n",
472 ret);
473 goto err_rise;
474 }
475
476 ret = arizona_request_irq(arizona, ARIZONA_IRQ_JD_FALL,
477 "JACKDET fall", arizona_jackdet, info);
478 if (ret != 0) {
479 dev_err(&pdev->dev, "Failed to get JD fall IRQ: %d\n", ret);
480 goto err_rise_wake;
481 }
482
483 ret = arizona_set_irq_wake(arizona, ARIZONA_IRQ_JD_FALL, 1);
484 if (ret != 0) {
485 dev_err(&pdev->dev, "Failed to set JD fall IRQ wake: %d\n",
486 ret);
487 goto err_fall;
488 }
489
490 ret = arizona_request_irq(arizona, ARIZONA_IRQ_MICDET,
491 "MICDET", arizona_micdet, info);
492 if (ret != 0) {
493 dev_err(&pdev->dev, "Failed to get MICDET IRQ: %d\n", ret);
494 goto err_fall_wake;
495 }
496
497 regmap_update_bits(arizona->regmap, ARIZONA_MIC_DETECT_1,
Mark Brownf2c32a82012-06-24 12:09:45 +0100498 ARIZONA_MICD_RATE_MASK,
Mark Brownf2c32a82012-06-24 12:09:45 +0100499 8 << ARIZONA_MICD_RATE_SHIFT);
500
501 arizona_clk32k_enable(arizona);
502 regmap_update_bits(arizona->regmap, ARIZONA_JACK_DETECT_DEBOUNCE,
503 ARIZONA_JD1_DB, ARIZONA_JD1_DB);
504 regmap_update_bits(arizona->regmap, ARIZONA_JACK_DETECT_ANALOGUE,
505 ARIZONA_JD1_ENA, ARIZONA_JD1_ENA);
506
Mark Brownb8575a12012-09-07 17:01:15 +0800507 ret = regulator_allow_bypass(info->micvdd, true);
508 if (ret != 0)
509 dev_warn(arizona->dev, "Failed to set MICVDD to bypass: %d\n",
510 ret);
511
Mark Brownf2c32a82012-06-24 12:09:45 +0100512 pm_runtime_put(&pdev->dev);
513
Mark Brown34efe4d2012-07-20 17:07:29 +0100514 ret = input_register_device(info->input);
515 if (ret) {
516 dev_err(&pdev->dev, "Can't register input device: %d\n", ret);
Mark Brown80732cc2012-08-26 13:58:20 -0700517 goto err_micdet;
Mark Brown34efe4d2012-07-20 17:07:29 +0100518 }
519
Mark Brownf2c32a82012-06-24 12:09:45 +0100520 return 0;
521
Mark Brown80732cc2012-08-26 13:58:20 -0700522err_micdet:
523 arizona_free_irq(arizona, ARIZONA_IRQ_MICDET, info);
Mark Brownf2c32a82012-06-24 12:09:45 +0100524err_fall_wake:
525 arizona_set_irq_wake(arizona, ARIZONA_IRQ_JD_FALL, 0);
526err_fall:
527 arizona_free_irq(arizona, ARIZONA_IRQ_JD_FALL, info);
528err_rise_wake:
529 arizona_set_irq_wake(arizona, ARIZONA_IRQ_JD_RISE, 0);
530err_rise:
531 arizona_free_irq(arizona, ARIZONA_IRQ_JD_RISE, info);
Mark Brown34efe4d2012-07-20 17:07:29 +0100532err_input:
Mark Brownf2c32a82012-06-24 12:09:45 +0100533err_register:
534 pm_runtime_disable(&pdev->dev);
535 extcon_dev_unregister(&info->edev);
536err:
537 return ret;
538}
539
Bill Pemberton93ed0322012-11-19 13:25:49 -0500540static int arizona_extcon_remove(struct platform_device *pdev)
Mark Brownf2c32a82012-06-24 12:09:45 +0100541{
542 struct arizona_extcon_info *info = platform_get_drvdata(pdev);
543 struct arizona *arizona = info->arizona;
544
545 pm_runtime_disable(&pdev->dev);
546
Mark Browndab63eb2013-01-11 08:55:36 +0900547 regmap_update_bits(arizona->regmap,
548 ARIZONA_MICD_CLAMP_CONTROL,
549 ARIZONA_MICD_CLAMP_MODE_MASK, 0);
550
Mark Brownf2c32a82012-06-24 12:09:45 +0100551 arizona_set_irq_wake(arizona, ARIZONA_IRQ_JD_RISE, 0);
552 arizona_set_irq_wake(arizona, ARIZONA_IRQ_JD_FALL, 0);
553 arizona_free_irq(arizona, ARIZONA_IRQ_MICDET, info);
554 arizona_free_irq(arizona, ARIZONA_IRQ_JD_RISE, info);
555 arizona_free_irq(arizona, ARIZONA_IRQ_JD_FALL, info);
556 regmap_update_bits(arizona->regmap, ARIZONA_JACK_DETECT_ANALOGUE,
557 ARIZONA_JD1_ENA, 0);
558 arizona_clk32k_disable(arizona);
Mark Brownf2c32a82012-06-24 12:09:45 +0100559 extcon_dev_unregister(&info->edev);
560
561 return 0;
562}
563
564static struct platform_driver arizona_extcon_driver = {
565 .driver = {
566 .name = "arizona-extcon",
567 .owner = THIS_MODULE,
568 },
569 .probe = arizona_extcon_probe,
Bill Pemberton5f7e2222012-11-19 13:20:06 -0500570 .remove = arizona_extcon_remove,
Mark Brownf2c32a82012-06-24 12:09:45 +0100571};
572
573module_platform_driver(arizona_extcon_driver);
574
575MODULE_DESCRIPTION("Arizona Extcon driver");
576MODULE_AUTHOR("Mark Brown <broonie@opensource.wolfsonmicro.com>");
577MODULE_LICENSE("GPL");
578MODULE_ALIAS("platform:extcon-arizona");