aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/extcon/extcon-arizona.c
diff options
context:
space:
mode:
authorCharles Keepax <ckeepax@opensource.wolfsonmicro.com>2015-06-19 12:23:31 -0400
committerChanwoo Choi <cw00.choi@samsung.com>2015-08-09 22:48:55 -0400
commit8e5838dd7b8c226cca235aa64c2f210517ef9b64 (patch)
tree35ae5e5ba14f98e6996afe428ac38fe426a82ce0 /drivers/extcon/extcon-arizona.c
parent4778d44ff3126b64f784ce9bf2b9dd3dbab1551b (diff)
extcon: arizona: Use gpiod inteface to handle micd_pol_gpio gpio
Convert to using the newer gpiod interface for the micd_pol_gpio. Although we still carry support for the old gpio interface from pdata. Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com> [cw00.choi: Modify the patch titlei to include the detailed content] Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Diffstat (limited to 'drivers/extcon/extcon-arizona.c')
-rw-r--r--drivers/extcon/extcon-arizona.c41
1 files changed, 36 insertions, 5 deletions
diff --git a/drivers/extcon/extcon-arizona.c b/drivers/extcon/extcon-arizona.c
index 7af42cb72e54..4dd684a32c3b 100644
--- a/drivers/extcon/extcon-arizona.c
+++ b/drivers/extcon/extcon-arizona.c
@@ -20,6 +20,7 @@
20#include <linux/slab.h> 20#include <linux/slab.h>
21#include <linux/interrupt.h> 21#include <linux/interrupt.h>
22#include <linux/err.h> 22#include <linux/err.h>
23#include <linux/gpio/consumer.h>
23#include <linux/gpio.h> 24#include <linux/gpio.h>
24#include <linux/input.h> 25#include <linux/input.h>
25#include <linux/platform_device.h> 26#include <linux/platform_device.h>
@@ -95,6 +96,8 @@ struct arizona_extcon_info {
95 int hpdet_ip_version; 96 int hpdet_ip_version;
96 97
97 struct extcon_dev *edev; 98 struct extcon_dev *edev;
99
100 struct gpio_desc *micd_pol_gpio;
98}; 101};
99 102
100static const struct arizona_micd_config micd_default_modes[] = { 103static const struct arizona_micd_config micd_default_modes[] = {
@@ -205,6 +208,10 @@ static void arizona_extcon_set_mode(struct arizona_extcon_info *info, int mode)
205 if (arizona->pdata.micd_pol_gpio > 0) 208 if (arizona->pdata.micd_pol_gpio > 0)
206 gpio_set_value_cansleep(arizona->pdata.micd_pol_gpio, 209 gpio_set_value_cansleep(arizona->pdata.micd_pol_gpio,
207 info->micd_modes[mode].gpio); 210 info->micd_modes[mode].gpio);
211 else
212 gpiod_set_value_cansleep(info->micd_pol_gpio,
213 info->micd_modes[mode].gpio);
214
208 regmap_update_bits(arizona->regmap, ARIZONA_MIC_DETECT_1, 215 regmap_update_bits(arizona->regmap, ARIZONA_MIC_DETECT_1,
209 ARIZONA_MICD_BIAS_SRC_MASK, 216 ARIZONA_MICD_BIAS_SRC_MASK,
210 info->micd_modes[mode].bias << 217 info->micd_modes[mode].bias <<
@@ -1258,6 +1265,27 @@ static int arizona_extcon_probe(struct platform_device *pdev)
1258 arizona->pdata.micd_pol_gpio, ret); 1265 arizona->pdata.micd_pol_gpio, ret);
1259 goto err_register; 1266 goto err_register;
1260 } 1267 }
1268 } else {
1269 if (info->micd_modes[0].gpio)
1270 mode = GPIOD_OUT_HIGH;
1271 else
1272 mode = GPIOD_OUT_LOW;
1273
1274 /* We can't use devm here because we need to do the get
1275 * against the MFD device, as that is where the of_node
1276 * will reside, but if we devm against that the GPIO
1277 * will not be freed if the extcon driver is unloaded.
1278 */
1279 info->micd_pol_gpio = gpiod_get_optional(arizona->dev,
1280 "wlf,micd-pol",
1281 GPIOD_OUT_LOW);
1282 if (IS_ERR(info->micd_pol_gpio)) {
1283 ret = PTR_ERR(info->micd_pol_gpio);
1284 dev_err(arizona->dev,
1285 "Failed to get microphone polarity GPIO: %d\n",
1286 ret);
1287 goto err_register;
1288 }
1261 } 1289 }
1262 1290
1263 if (arizona->pdata.hpdet_id_gpio > 0) { 1291 if (arizona->pdata.hpdet_id_gpio > 0) {
@@ -1268,7 +1296,7 @@ static int arizona_extcon_probe(struct platform_device *pdev)
1268 if (ret != 0) { 1296 if (ret != 0) {
1269 dev_err(arizona->dev, "Failed to request GPIO%d: %d\n", 1297 dev_err(arizona->dev, "Failed to request GPIO%d: %d\n",
1270 arizona->pdata.hpdet_id_gpio, ret); 1298 arizona->pdata.hpdet_id_gpio, ret);
1271 goto err_register; 1299 goto err_gpio;
1272 } 1300 }
1273 } 1301 }
1274 1302
@@ -1312,7 +1340,7 @@ static int arizona_extcon_probe(struct platform_device *pdev)
1312 dev_err(arizona->dev, 1340 dev_err(arizona->dev,
1313 "MICD ranges must be sorted\n"); 1341 "MICD ranges must be sorted\n");
1314 ret = -EINVAL; 1342 ret = -EINVAL;
1315 goto err_input; 1343 goto err_gpio;
1316 } 1344 }
1317 } 1345 }
1318 } 1346 }
@@ -1331,7 +1359,7 @@ static int arizona_extcon_probe(struct platform_device *pdev)
1331 dev_err(arizona->dev, "Unsupported MICD level %d\n", 1359 dev_err(arizona->dev, "Unsupported MICD level %d\n",
1332 info->micd_ranges[i].max); 1360 info->micd_ranges[i].max);
1333 ret = -EINVAL; 1361 ret = -EINVAL;
1334 goto err_input; 1362 goto err_gpio;
1335 } 1363 }
1336 1364
1337 dev_dbg(arizona->dev, "%d ohms for MICD threshold %d\n", 1365 dev_dbg(arizona->dev, "%d ohms for MICD threshold %d\n",
@@ -1404,7 +1432,7 @@ static int arizona_extcon_probe(struct platform_device *pdev)
1404 if (ret != 0) { 1432 if (ret != 0) {
1405 dev_err(&pdev->dev, "Failed to get JACKDET rise IRQ: %d\n", 1433 dev_err(&pdev->dev, "Failed to get JACKDET rise IRQ: %d\n",
1406 ret); 1434 ret);
1407 goto err_input; 1435 goto err_gpio;
1408 } 1436 }
1409 1437
1410 ret = arizona_set_irq_wake(arizona, jack_irq_rise, 1); 1438 ret = arizona_set_irq_wake(arizona, jack_irq_rise, 1);
@@ -1475,7 +1503,8 @@ err_rise_wake:
1475 arizona_set_irq_wake(arizona, jack_irq_rise, 0); 1503 arizona_set_irq_wake(arizona, jack_irq_rise, 0);
1476err_rise: 1504err_rise:
1477 arizona_free_irq(arizona, jack_irq_rise, info); 1505 arizona_free_irq(arizona, jack_irq_rise, info);
1478err_input: 1506err_gpio:
1507 gpiod_put(info->micd_pol_gpio);
1479err_register: 1508err_register:
1480 pm_runtime_disable(&pdev->dev); 1509 pm_runtime_disable(&pdev->dev);
1481 return ret; 1510 return ret;
@@ -1487,6 +1516,8 @@ static int arizona_extcon_remove(struct platform_device *pdev)
1487 struct arizona *arizona = info->arizona; 1516 struct arizona *arizona = info->arizona;
1488 int jack_irq_rise, jack_irq_fall; 1517 int jack_irq_rise, jack_irq_fall;
1489 1518
1519 gpiod_put(info->micd_pol_gpio);
1520
1490 pm_runtime_disable(&pdev->dev); 1521 pm_runtime_disable(&pdev->dev);
1491 1522
1492 regmap_update_bits(arizona->regmap, 1523 regmap_update_bits(arizona->regmap,