summaryrefslogtreecommitdiff
path: root/sound/soc/codecs/max98373.c
diff options
context:
space:
mode:
authorLinus Walleij <linus.walleij@linaro.org>2023-09-11 10:23:50 +0200
committerMark Brown <broonie@kernel.org>2023-09-11 12:50:07 +0100
commitd3091d09de46e7ea88fa943efd458094e6a6ceb6 (patch)
tree42bcd5526589ee7fe1422d5817b999ce5f20aad1 /sound/soc/codecs/max98373.c
parent02de898322869442cf6d6f4ba8f22cbdc5889f4b (diff)
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>
Diffstat (limited to 'sound/soc/codecs/max98373.c')
-rw-r--r--sound/soc/codecs/max98373.c35
1 files changed, 19 insertions, 16 deletions
diff --git a/sound/soc/codecs/max98373.c b/sound/soc/codecs/max98373.c
index fde055c6c894..33eb4576da23 100644
--- a/sound/soc/codecs/max98373.c
+++ b/sound/soc/codecs/max98373.c
@@ -12,9 +12,8 @@
#include <sound/pcm.h>
#include <sound/pcm_params.h>
#include <sound/soc.h>
-#include <linux/gpio.h>
+#include <linux/gpio/consumer.h>
#include <linux/of.h>
-#include <linux/of_gpio.h>
#include <sound/tlv.h>
#include "max98373.h"
@@ -478,20 +477,24 @@ void max98373_slot_config(struct device *dev,
max98373->i_slot = value & 0xF;
else
max98373->i_slot = 1;
- if (dev->of_node) {
- max98373->reset_gpio = of_get_named_gpio(dev->of_node,
- "maxim,reset-gpio", 0);
- if (!gpio_is_valid(max98373->reset_gpio)) {
- dev_err(dev, "Looking up %s property in node %s failed %d\n",
- "maxim,reset-gpio", dev->of_node->full_name,
- max98373->reset_gpio);
- } else {
- dev_dbg(dev, "maxim,reset-gpio=%d",
- max98373->reset_gpio);
- }
- } else {
- /* this makes reset_gpio as invalid */
- max98373->reset_gpio = -1;
+
+ /* This will assert RESET */
+ max98373->reset = devm_gpiod_get_optional(dev,
+ "maxim,reset",
+ GPIOD_OUT_HIGH);
+ if (IS_ERR(max98373->reset)) {
+ dev_err(dev, "error %ld looking up RESET GPIO line\n",
+ PTR_ERR(max98373->reset));
+ return;
+ }
+
+ /* Cycle reset */
+ if (max98373->reset) {
+ gpiod_set_consumer_name(max98373->reset ,"MAX98373_RESET");
+ gpiod_direction_output(max98373->reset, 1);
+ msleep(50);
+ gpiod_direction_output(max98373->reset, 0);
+ msleep(20);
}
if (!device_property_read_u32(dev, "maxim,spkfb-slot-no", &value))