aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/extcon/extcon-arizona.c
diff options
context:
space:
mode:
authorCharles Keepax <ckeepax@opensource.wolfsonmicro.com>2015-02-16 10:41:02 -0500
committerChanwoo Choi <cw00.choi@samsung.com>2015-03-03 19:41:48 -0500
commit112bdfaa525fd5993e17885861342893f15290b0 (patch)
tree9604310e1c88d9b8263b189fc809766aaf532c50 /drivers/extcon/extcon-arizona.c
parent27a28d32b4f22a4ae687837aeda6afb42116cca4 (diff)
extcon: arizona: Deobfuscate arizona_extcon_do_magic
arizona_extcon_do_magic does not lend a lot of clarity to the purpose of the function, and as all the registers used are described in the datasheet there is no need to obfuscate the code. This patch renames the function to arizona_extcon_hp_clamp, as it controls clamping on the headphone output. Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com> Acked-by: Lee Jones <lee.jones@linaro.org> Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Diffstat (limited to 'drivers/extcon/extcon-arizona.c')
-rw-r--r--drivers/extcon/extcon-arizona.c36
1 files changed, 20 insertions, 16 deletions
diff --git a/drivers/extcon/extcon-arizona.c b/drivers/extcon/extcon-arizona.c
index 63f01c42aed4..95cf7f875bb3 100644
--- a/drivers/extcon/extcon-arizona.c
+++ b/drivers/extcon/extcon-arizona.c
@@ -136,18 +136,22 @@ static const char *arizona_cable[] = {
136 136
137static void arizona_start_hpdet_acc_id(struct arizona_extcon_info *info); 137static void arizona_start_hpdet_acc_id(struct arizona_extcon_info *info);
138 138
139static void arizona_extcon_do_magic(struct arizona_extcon_info *info, 139static void arizona_extcon_hp_clamp(struct arizona_extcon_info *info,
140 unsigned int magic) 140 bool clamp)
141{ 141{
142 struct arizona *arizona = info->arizona; 142 struct arizona *arizona = info->arizona;
143 unsigned int val = 0;
143 int ret; 144 int ret;
144 145
146 if (clamp)
147 val = ARIZONA_RMV_SHRT_HP1L;
148
145 mutex_lock(&arizona->dapm->card->dapm_mutex); 149 mutex_lock(&arizona->dapm->card->dapm_mutex);
146 150
147 arizona->hpdet_magic = magic; 151 arizona->hpdet_clamp = clamp;
148 152
149 /* Keep the HP output stages disabled while doing the magic */ 153 /* Keep the HP output stages disabled while doing the clamp */
150 if (magic) { 154 if (clamp) {
151 ret = regmap_update_bits(arizona->regmap, 155 ret = regmap_update_bits(arizona->regmap,
152 ARIZONA_OUTPUT_ENABLES_1, 156 ARIZONA_OUTPUT_ENABLES_1,
153 ARIZONA_OUT1L_ENA | 157 ARIZONA_OUT1L_ENA |
@@ -158,20 +162,20 @@ static void arizona_extcon_do_magic(struct arizona_extcon_info *info,
158 ret); 162 ret);
159 } 163 }
160 164
161 ret = regmap_update_bits(arizona->regmap, 0x225, 0x4000, 165 ret = regmap_update_bits(arizona->regmap, ARIZONA_HP_CTRL_1L,
162 magic); 166 ARIZONA_RMV_SHRT_HP1L, val);
163 if (ret != 0) 167 if (ret != 0)
164 dev_warn(arizona->dev, "Failed to do magic: %d\n", 168 dev_warn(arizona->dev, "Failed to do clamp: %d\n",
165 ret); 169 ret);
166 170
167 ret = regmap_update_bits(arizona->regmap, 0x226, 0x4000, 171 ret = regmap_update_bits(arizona->regmap, ARIZONA_HP_CTRL_1R,
168 magic); 172 ARIZONA_RMV_SHRT_HP1R, val);
169 if (ret != 0) 173 if (ret != 0)
170 dev_warn(arizona->dev, "Failed to do magic: %d\n", 174 dev_warn(arizona->dev, "Failed to do clamp: %d\n",
171 ret); 175 ret);
172 176
173 /* Restore the desired state while not doing the magic */ 177 /* Restore the desired state while not doing the clamp */
174 if (!magic) { 178 if (!clamp) {
175 ret = regmap_update_bits(arizona->regmap, 179 ret = regmap_update_bits(arizona->regmap,
176 ARIZONA_OUTPUT_ENABLES_1, 180 ARIZONA_OUTPUT_ENABLES_1,
177 ARIZONA_OUT1L_ENA | 181 ARIZONA_OUT1L_ENA |
@@ -603,7 +607,7 @@ done:
603 ARIZONA_HP_IMPEDANCE_RANGE_MASK | ARIZONA_HP_POLL, 607 ARIZONA_HP_IMPEDANCE_RANGE_MASK | ARIZONA_HP_POLL,
604 0); 608 0);
605 609
606 arizona_extcon_do_magic(info, 0); 610 arizona_extcon_hp_clamp(info, false);
607 611
608 if (id_gpio) 612 if (id_gpio)
609 gpio_set_value_cansleep(id_gpio, 0); 613 gpio_set_value_cansleep(id_gpio, 0);
@@ -648,7 +652,7 @@ static void arizona_identify_headphone(struct arizona_extcon_info *info)
648 if (info->mic) 652 if (info->mic)
649 arizona_stop_mic(info); 653 arizona_stop_mic(info);
650 654
651 arizona_extcon_do_magic(info, 0x4000); 655 arizona_extcon_hp_clamp(info, true);
652 656
653 ret = regmap_update_bits(arizona->regmap, 657 ret = regmap_update_bits(arizona->regmap,
654 ARIZONA_ACCESSORY_DETECT_MODE_1, 658 ARIZONA_ACCESSORY_DETECT_MODE_1,
@@ -699,7 +703,7 @@ static void arizona_start_hpdet_acc_id(struct arizona_extcon_info *info)
699 703
700 info->hpdet_active = true; 704 info->hpdet_active = true;
701 705
702 arizona_extcon_do_magic(info, 0x4000); 706 arizona_extcon_hp_clamp(info, true);
703 707
704 ret = regmap_update_bits(arizona->regmap, 708 ret = regmap_update_bits(arizona->regmap,
705 ARIZONA_ACCESSORY_DETECT_MODE_1, 709 ARIZONA_ACCESSORY_DETECT_MODE_1,