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

ASoC: max98373: Convert to use GPIO descriptors

Instead of relying on legacy interfaces, convert the driver to
use GPIO descriptors. This is a straight-forward conversion,
we support also sdw devices providing GPIO descriptor tables
if they so desire.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20230911-descriptors-asoc-max-v2-3-b9d793fb768e@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Linus Walleij and committed by
Mark Brown
d3091d09 02de8983

+20 -34
-17
sound/soc/codecs/max98373-i2c.c
··· 3 3 4 4 #include <linux/acpi.h> 5 5 #include <linux/delay.h> 6 - #include <linux/gpio.h> 7 6 #include <linux/i2c.h> 8 7 #include <linux/module.h> 9 8 #include <linux/mod_devicetable.h> 10 9 #include <linux/of.h> 11 - #include <linux/of_gpio.h> 12 10 #include <linux/pm.h> 13 11 #include <linux/regmap.h> 14 12 #include <linux/slab.h> ··· 557 559 558 560 /* voltage/current slot & gpio configuration */ 559 561 max98373_slot_config(&i2c->dev, max98373); 560 - 561 - /* Power on device */ 562 - if (gpio_is_valid(max98373->reset_gpio)) { 563 - ret = devm_gpio_request(&i2c->dev, max98373->reset_gpio, 564 - "MAX98373_RESET"); 565 - if (ret) { 566 - dev_err(&i2c->dev, "%s: Failed to request gpio %d\n", 567 - __func__, max98373->reset_gpio); 568 - return -EINVAL; 569 - } 570 - gpio_direction_output(max98373->reset_gpio, 0); 571 - msleep(50); 572 - gpio_direction_output(max98373->reset_gpio, 1); 573 - msleep(20); 574 - } 575 562 576 563 /* Check Revision ID */ 577 564 ret = regmap_read(max98373->regmap,
+19 -16
sound/soc/codecs/max98373.c
··· 12 12 #include <sound/pcm.h> 13 13 #include <sound/pcm_params.h> 14 14 #include <sound/soc.h> 15 - #include <linux/gpio.h> 15 + #include <linux/gpio/consumer.h> 16 16 #include <linux/of.h> 17 - #include <linux/of_gpio.h> 18 17 #include <sound/tlv.h> 19 18 #include "max98373.h" 20 19 ··· 477 478 max98373->i_slot = value & 0xF; 478 479 else 479 480 max98373->i_slot = 1; 480 - if (dev->of_node) { 481 - max98373->reset_gpio = of_get_named_gpio(dev->of_node, 482 - "maxim,reset-gpio", 0); 483 - if (!gpio_is_valid(max98373->reset_gpio)) { 484 - dev_err(dev, "Looking up %s property in node %s failed %d\n", 485 - "maxim,reset-gpio", dev->of_node->full_name, 486 - max98373->reset_gpio); 487 - } else { 488 - dev_dbg(dev, "maxim,reset-gpio=%d", 489 - max98373->reset_gpio); 490 - } 491 - } else { 492 - /* this makes reset_gpio as invalid */ 493 - max98373->reset_gpio = -1; 481 + 482 + /* This will assert RESET */ 483 + max98373->reset = devm_gpiod_get_optional(dev, 484 + "maxim,reset", 485 + GPIOD_OUT_HIGH); 486 + if (IS_ERR(max98373->reset)) { 487 + dev_err(dev, "error %ld looking up RESET GPIO line\n", 488 + PTR_ERR(max98373->reset)); 489 + return; 490 + } 491 + 492 + /* Cycle reset */ 493 + if (max98373->reset) { 494 + gpiod_set_consumer_name(max98373->reset ,"MAX98373_RESET"); 495 + gpiod_direction_output(max98373->reset, 1); 496 + msleep(50); 497 + gpiod_direction_output(max98373->reset, 0); 498 + msleep(20); 494 499 } 495 500 496 501 if (!device_property_read_u32(dev, "maxim,spkfb-slot-no", &value))
+1 -1
sound/soc/codecs/max98373.h
··· 213 213 214 214 struct max98373_priv { 215 215 struct regmap *regmap; 216 - int reset_gpio; 216 + struct gpio_desc *reset; 217 217 unsigned int v_slot; 218 218 unsigned int i_slot; 219 219 unsigned int spkfb_slot;