Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

ASoC: codec: arizona: Convert to use GPIO descriptors

This converts the Arizona driver to use GPIO descriptors
exclusively, deletes the legacy code path an updates the
in-tree user of legacy GPIO.

The GPIO lines for mic detect polarity and headphone ID
detection are made exclusively descriptor-oriented. The
headphone ID detection could actually only be used by
the legacy GPIO code, but I converted it to use a
descriptor if someone would actually need it so we don't
just drop useful code.

The compatible "wlf,hpdet-id-gpio" is not in the device
tree bindings and only intended to be used by software
nodes if any. If someone insists I can try to add a
binding for it, but I doubt there is any real user so
it seems pointless.

Signed-off-by: Linus Walleij <linusw@kernel.org>
Reviewed-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Reviewed-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
Link: https://patch.msgid.link/20260314-asoc-arizona-v1-1-ecc9a165307c@kernel.org
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Linus Walleij and committed by
Mark Brown
cb15d8e6 fc1fbafc

+34 -78
+4 -2
arch/arm/mach-s3c/mach-crag6410-module.c
··· 239 239 static struct arizona_pdata wm5102_reva_pdata = { 240 240 .gpio_base = CODEC_GPIO_BASE, 241 241 .irq_flags = IRQF_TRIGGER_HIGH, 242 - .micd_pol_gpio = CODEC_GPIO_BASE + 4, 243 242 .micd_rate = 6, 244 243 .gpio_defaults = { 245 244 [2] = 0x10000, /* AIF3TXLRCLK */ ··· 264 265 .table = { 265 266 GPIO_LOOKUP("GPION", 7, 266 267 "wlf,ldoena", GPIO_ACTIVE_HIGH), 268 + GPIO_LOOKUP("arizona", 4, 269 + "wlf,micd-pol", GPIO_ACTIVE_HIGH), 267 270 { }, 268 271 }, 269 272 }; ··· 273 272 static struct arizona_pdata wm5102_pdata = { 274 273 .gpio_base = CODEC_GPIO_BASE, 275 274 .irq_flags = IRQF_TRIGGER_HIGH, 276 - .micd_pol_gpio = CODEC_GPIO_BASE + 2, 277 275 .gpio_defaults = { 278 276 [2] = 0x10000, /* AIF3TXLRCLK */ 279 277 [3] = 0x4, /* OPCLK */ ··· 297 297 .table = { 298 298 GPIO_LOOKUP("GPION", 7, 299 299 "wlf,ldo1ena", GPIO_ACTIVE_HIGH), 300 + GPIO_LOOKUP("arizona", 2, 301 + "wlf,micd-pol", GPIO_ACTIVE_HIGH), 300 302 { }, 301 303 }, 302 304 };
-10
include/linux/mfd/arizona/pdata.h
··· 117 117 /** Check for line output with HPDET method */ 118 118 bool hpdet_acc_id_line; 119 119 120 - #ifdef CONFIG_GPIOLIB_LEGACY 121 - /** GPIO used for mic isolation with HPDET */ 122 - int hpdet_id_gpio; 123 - #endif 124 - 125 120 /** Channel to use for headphone detection */ 126 121 unsigned int hpdet_channel; 127 122 ··· 125 130 126 131 /** Extra debounce timeout used during initial mic detection (ms) */ 127 132 unsigned int micd_detect_debounce; 128 - 129 - #ifdef CONFIG_GPIOLIB_LEGACY 130 - /** GPIO for mic detection polarity */ 131 - int micd_pol_gpio; 132 - #endif 133 133 134 134 /** Mic detect ramp rate */ 135 135 unsigned int micd_bias_start_time;
+29 -66
sound/soc/codecs/arizona-jack.c
··· 11 11 #include <linux/interrupt.h> 12 12 #include <linux/err.h> 13 13 #include <linux/gpio/consumer.h> 14 - #include <linux/gpio.h> 15 14 #include <linux/input.h> 16 15 #include <linux/pm_runtime.h> 17 16 #include <linux/property.h> ··· 458 459 bool *mic) 459 460 { 460 461 struct arizona *arizona = info->arizona; 461 - #ifdef CONFIG_GPIOLIB_LEGACY 462 - int id_gpio = arizona->pdata.hpdet_id_gpio; 463 - #else 464 - int id_gpio = 0; 465 - #endif 466 462 467 463 if (!arizona->pdata.hpdet_acc_id) 468 464 return 0; ··· 468 474 */ 469 475 info->hpdet_res[info->num_hpdet_res++] = *reading; 470 476 471 - #ifdef CONFIG_GPIOLIB_LEGACY 472 477 /* Only check the mic directly if we didn't already ID it */ 473 - if (id_gpio && info->num_hpdet_res == 1) { 478 + if (info->hpdet_id_gpio && info->num_hpdet_res == 1) { 474 479 dev_dbg(arizona->dev, "Measuring mic\n"); 475 480 476 481 regmap_update_bits(arizona->regmap, ··· 479 486 ARIZONA_ACCDET_MODE_HPR | 480 487 info->micd_modes[0].src); 481 488 482 - gpio_set_value_cansleep(id_gpio, 1); 489 + gpiod_set_value_cansleep(info->hpdet_id_gpio, 1); 483 490 484 491 regmap_update_bits(arizona->regmap, ARIZONA_HEADPHONE_DETECT_1, 485 492 ARIZONA_HP_POLL, ARIZONA_HP_POLL); 486 493 return -EAGAIN; 487 494 } 488 - #endif 489 495 490 496 /* OK, got both. Now, compare... */ 491 497 dev_dbg(arizona->dev, "HPDET measured %d %d\n", ··· 506 514 /* 507 515 * If we measure the mic as high impedance 508 516 */ 509 - if (!id_gpio || info->hpdet_res[1] > 50) { 517 + if (!info->hpdet_id_gpio || info->hpdet_res[1] > 50) { 510 518 dev_dbg(arizona->dev, "Detected mic\n"); 511 519 *mic = true; 512 520 info->detecting = true; ··· 525 533 { 526 534 struct arizona_priv *info = data; 527 535 struct arizona *arizona = info->arizona; 528 - #ifdef CONFIG_GPIOLIB_LEGACY 529 - int id_gpio = arizona->pdata.hpdet_id_gpio; 530 - #endif 531 536 int ret, reading, state, report; 532 537 bool mic = false; 533 538 ··· 580 591 581 592 arizona_extcon_hp_clamp(info, false); 582 593 583 - #ifdef CONFIG_GPIOLIB_LEGACY 584 - if (id_gpio) 585 - gpio_set_value_cansleep(id_gpio, 0); 586 - #endif 594 + if (info->hpdet_id_gpio) 595 + gpiod_set_value_cansleep(info->hpdet_id_gpio, 0); 587 596 588 597 /* If we have a mic then reenable MICDET */ 589 598 if (state && (mic || info->mic)) ··· 1312 1325 regmap_update_bits(arizona->regmap, ARIZONA_GP_SWITCH_1, 1313 1326 ARIZONA_SW1_MODE_MASK, arizona->pdata.gpsw); 1314 1327 1315 - #ifdef CONFIG_GPIOLIB_LEGACY 1316 - if (pdata->micd_pol_gpio > 0) { 1317 - if (info->micd_modes[0].gpio) 1318 - mode = GPIOF_OUT_INIT_HIGH; 1319 - else 1320 - mode = GPIOF_OUT_INIT_LOW; 1328 + if (info->micd_modes[0].gpio) 1329 + mode = GPIOD_OUT_HIGH; 1330 + else 1331 + mode = GPIOD_OUT_LOW; 1321 1332 1322 - ret = devm_gpio_request_one(dev, pdata->micd_pol_gpio, 1323 - mode, "MICD polarity"); 1324 - if (ret != 0) { 1325 - dev_err(arizona->dev, "Failed to request GPIO%d: %d\n", 1326 - pdata->micd_pol_gpio, ret); 1327 - return ret; 1328 - } 1329 - 1330 - info->micd_pol_gpio = gpio_to_desc(pdata->micd_pol_gpio); 1331 - } else 1332 - #endif 1333 - { 1334 - if (info->micd_modes[0].gpio) 1335 - mode = GPIOD_OUT_HIGH; 1336 - else 1337 - mode = GPIOD_OUT_LOW; 1338 - 1339 - /* We can't use devm here because we need to do the get 1340 - * against the MFD device, as that is where the of_node 1341 - * will reside, but if we devm against that the GPIO 1342 - * will not be freed if the extcon driver is unloaded. 1343 - */ 1344 - info->micd_pol_gpio = gpiod_get_optional(arizona->dev, 1345 - "wlf,micd-pol", 1346 - mode); 1347 - if (IS_ERR(info->micd_pol_gpio)) { 1348 - ret = PTR_ERR(info->micd_pol_gpio); 1349 - dev_err_probe(arizona->dev, ret, "getting microphone polarity GPIO\n"); 1350 - return ret; 1351 - } 1333 + /* We can't use devm here because we need to do the get 1334 + * against the MFD device, as that is where the of_node 1335 + * will reside, but if we devm against that the GPIO 1336 + * will not be freed if the extcon driver is unloaded. 1337 + */ 1338 + info->micd_pol_gpio = gpiod_get_optional(arizona->dev, 1339 + "wlf,micd-pol", 1340 + mode); 1341 + if (IS_ERR(info->micd_pol_gpio)) { 1342 + ret = PTR_ERR(info->micd_pol_gpio); 1343 + dev_err_probe(arizona->dev, ret, "getting microphone polarity GPIO\n"); 1344 + return ret; 1352 1345 } 1353 1346 1354 - #ifdef CONFIG_GPIOLIB_LEGACY 1355 - if (arizona->pdata.hpdet_id_gpio > 0) { 1356 - ret = devm_gpio_request_one(dev, arizona->pdata.hpdet_id_gpio, 1357 - GPIOF_OUT_INIT_LOW, 1358 - "HPDET"); 1359 - if (ret != 0) { 1360 - dev_err(arizona->dev, "Failed to request GPIO%d: %d\n", 1361 - arizona->pdata.hpdet_id_gpio, ret); 1362 - gpiod_put(info->micd_pol_gpio); 1363 - return ret; 1364 - } 1347 + info->hpdet_id_gpio = gpiod_get_optional(arizona->dev, 1348 + "wlf,hpdet-id-gpio", 1349 + mode); 1350 + if (IS_ERR(info->hpdet_id_gpio)) { 1351 + ret = PTR_ERR(info->hpdet_id_gpio); 1352 + dev_err_probe(arizona->dev, ret, "getting headphone detect ID GPIO\n"); 1353 + return ret; 1365 1354 } 1366 - #endif 1367 1355 1368 1356 return 0; 1369 1357 } ··· 1347 1385 int arizona_jack_codec_dev_remove(struct arizona_priv *info) 1348 1386 { 1349 1387 gpiod_put(info->micd_pol_gpio); 1388 + gpiod_put(info->hpdet_id_gpio); 1350 1389 return 0; 1351 1390 } 1352 1391 EXPORT_SYMBOL_GPL(arizona_jack_codec_dev_remove);
+1
sound/soc/codecs/arizona.h
··· 100 100 struct snd_soc_jack *jack; 101 101 struct regulator *micvdd; 102 102 struct gpio_desc *micd_pol_gpio; 103 + struct gpio_desc *hpdet_id_gpio; 103 104 104 105 u16 last_jackdet; 105 106