diff options
author | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2013-01-10 18:55:46 -0500 |
---|---|---|
committer | Chanwoo Choi <cw00.choi@samsung.com> | 2013-01-15 01:42:18 -0500 |
commit | 9b1270c71fb5f4783c72cae7e458b2cf8c657f84 (patch) | |
tree | 2d1338c696d63eb8e70db529bfc0883661f5843b | |
parent | 4f340333822de79b3439bddccdbf3846f9794e42 (diff) |
extcon: Simple code motion supporting future work.
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: Myungjoo Ham <myungjoo.ham@samsung.com>
-rw-r--r-- | drivers/extcon/extcon-arizona.c | 120 |
1 files changed, 60 insertions, 60 deletions
diff --git a/drivers/extcon/extcon-arizona.c b/drivers/extcon/extcon-arizona.c index cc258a8842ef..dab4584a4ad5 100644 --- a/drivers/extcon/extcon-arizona.c +++ b/drivers/extcon/extcon-arizona.c | |||
@@ -112,6 +112,66 @@ static void arizona_extcon_set_mode(struct arizona_extcon_info *info, int mode) | |||
112 | dev_dbg(arizona->dev, "Set jack polarity to %d\n", mode); | 112 | dev_dbg(arizona->dev, "Set jack polarity to %d\n", mode); |
113 | } | 113 | } |
114 | 114 | ||
115 | static void arizona_start_mic(struct arizona_extcon_info *info) | ||
116 | { | ||
117 | struct arizona *arizona = info->arizona; | ||
118 | bool change; | ||
119 | int ret; | ||
120 | |||
121 | info->detecting = true; | ||
122 | info->mic = false; | ||
123 | info->jack_flips = 0; | ||
124 | |||
125 | /* Microphone detection can't use idle mode */ | ||
126 | pm_runtime_get(info->dev); | ||
127 | |||
128 | ret = regulator_enable(info->micvdd); | ||
129 | if (ret != 0) { | ||
130 | dev_err(arizona->dev, "Failed to enable MICVDD: %d\n", | ||
131 | ret); | ||
132 | } | ||
133 | |||
134 | if (info->micd_reva) { | ||
135 | regmap_write(arizona->regmap, 0x80, 0x3); | ||
136 | regmap_write(arizona->regmap, 0x294, 0); | ||
137 | regmap_write(arizona->regmap, 0x80, 0x0); | ||
138 | } | ||
139 | |||
140 | regmap_update_bits(arizona->regmap, | ||
141 | ARIZONA_ACCESSORY_DETECT_MODE_1, | ||
142 | ARIZONA_ACCDET_MODE_MASK, ARIZONA_ACCDET_MODE_MIC); | ||
143 | |||
144 | regmap_update_bits_check(arizona->regmap, ARIZONA_MIC_DETECT_1, | ||
145 | ARIZONA_MICD_ENA, ARIZONA_MICD_ENA, | ||
146 | &change); | ||
147 | if (!change) { | ||
148 | regulator_disable(info->micvdd); | ||
149 | pm_runtime_put_autosuspend(info->dev); | ||
150 | } | ||
151 | } | ||
152 | |||
153 | static void arizona_stop_mic(struct arizona_extcon_info *info) | ||
154 | { | ||
155 | struct arizona *arizona = info->arizona; | ||
156 | bool change; | ||
157 | |||
158 | regmap_update_bits_check(arizona->regmap, ARIZONA_MIC_DETECT_1, | ||
159 | ARIZONA_MICD_ENA, 0, | ||
160 | &change); | ||
161 | |||
162 | if (info->micd_reva) { | ||
163 | regmap_write(arizona->regmap, 0x80, 0x3); | ||
164 | regmap_write(arizona->regmap, 0x294, 2); | ||
165 | regmap_write(arizona->regmap, 0x80, 0x0); | ||
166 | } | ||
167 | |||
168 | if (change) { | ||
169 | regulator_disable(info->micvdd); | ||
170 | pm_runtime_mark_last_busy(info->dev); | ||
171 | pm_runtime_put_autosuspend(info->dev); | ||
172 | } | ||
173 | } | ||
174 | |||
115 | static struct { | 175 | static struct { |
116 | unsigned int factor_a; | 176 | unsigned int factor_a; |
117 | unsigned int factor_b; | 177 | unsigned int factor_b; |
@@ -396,66 +456,6 @@ err: | |||
396 | info->hpdet_active = false; | 456 | info->hpdet_active = false; |
397 | } | 457 | } |
398 | 458 | ||
399 | static void arizona_start_mic(struct arizona_extcon_info *info) | ||
400 | { | ||
401 | struct arizona *arizona = info->arizona; | ||
402 | bool change; | ||
403 | int ret; | ||
404 | |||
405 | info->detecting = true; | ||
406 | info->mic = false; | ||
407 | info->jack_flips = 0; | ||
408 | |||
409 | /* Microphone detection can't use idle mode */ | ||
410 | pm_runtime_get(info->dev); | ||
411 | |||
412 | ret = regulator_enable(info->micvdd); | ||
413 | if (ret != 0) { | ||
414 | dev_err(arizona->dev, "Failed to enable MICVDD: %d\n", | ||
415 | ret); | ||
416 | } | ||
417 | |||
418 | if (info->micd_reva) { | ||
419 | regmap_write(arizona->regmap, 0x80, 0x3); | ||
420 | regmap_write(arizona->regmap, 0x294, 0); | ||
421 | regmap_write(arizona->regmap, 0x80, 0x0); | ||
422 | } | ||
423 | |||
424 | regmap_update_bits(arizona->regmap, | ||
425 | ARIZONA_ACCESSORY_DETECT_MODE_1, | ||
426 | ARIZONA_ACCDET_MODE_MASK, ARIZONA_ACCDET_MODE_MIC); | ||
427 | |||
428 | regmap_update_bits_check(arizona->regmap, ARIZONA_MIC_DETECT_1, | ||
429 | ARIZONA_MICD_ENA, ARIZONA_MICD_ENA, | ||
430 | &change); | ||
431 | if (!change) { | ||
432 | regulator_disable(info->micvdd); | ||
433 | pm_runtime_put_autosuspend(info->dev); | ||
434 | } | ||
435 | } | ||
436 | |||
437 | static void arizona_stop_mic(struct arizona_extcon_info *info) | ||
438 | { | ||
439 | struct arizona *arizona = info->arizona; | ||
440 | bool change; | ||
441 | |||
442 | regmap_update_bits_check(arizona->regmap, ARIZONA_MIC_DETECT_1, | ||
443 | ARIZONA_MICD_ENA, 0, | ||
444 | &change); | ||
445 | |||
446 | if (info->micd_reva) { | ||
447 | regmap_write(arizona->regmap, 0x80, 0x3); | ||
448 | regmap_write(arizona->regmap, 0x294, 2); | ||
449 | regmap_write(arizona->regmap, 0x80, 0x0); | ||
450 | } | ||
451 | |||
452 | if (change) { | ||
453 | regulator_disable(info->micvdd); | ||
454 | pm_runtime_mark_last_busy(info->dev); | ||
455 | pm_runtime_put_autosuspend(info->dev); | ||
456 | } | ||
457 | } | ||
458 | |||
459 | static irqreturn_t arizona_micdet(int irq, void *data) | 459 | static irqreturn_t arizona_micdet(int irq, void *data) |
460 | { | 460 | { |
461 | struct arizona_extcon_info *info = data; | 461 | struct arizona_extcon_info *info = data; |