Unverified Commit d3091d09 authored by Linus Walleij's avatar Linus Walleij Committed by Mark Brown
Browse files

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: default avatarLinus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20230911-descriptors-asoc-max-v2-3-b9d793fb768e@linaro.org


Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent 02de8983
Loading
Loading
Loading
Loading
+0 −17
Original line number Diff line number Diff line
@@ -3,12 +3,10 @@

#include <linux/acpi.h>
#include <linux/delay.h>
#include <linux/gpio.h>
#include <linux/i2c.h>
#include <linux/module.h>
#include <linux/mod_devicetable.h>
#include <linux/of.h>
#include <linux/of_gpio.h>
#include <linux/pm.h>
#include <linux/regmap.h>
#include <linux/slab.h>
@@ -560,21 +558,6 @@ static int max98373_i2c_probe(struct i2c_client *i2c)
	/* voltage/current slot & gpio configuration */
	max98373_slot_config(&i2c->dev, max98373);

	/* Power on device */
	if (gpio_is_valid(max98373->reset_gpio)) {
		ret = devm_gpio_request(&i2c->dev, max98373->reset_gpio,
					"MAX98373_RESET");
		if (ret) {
			dev_err(&i2c->dev, "%s: Failed to request gpio %d\n",
				__func__, max98373->reset_gpio);
			return -EINVAL;
		}
		gpio_direction_output(max98373->reset_gpio, 0);
		msleep(50);
		gpio_direction_output(max98373->reset_gpio, 1);
		msleep(20);
	}

	/* Check Revision ID */
	ret = regmap_read(max98373->regmap,
			  MAX98373_R21FF_REV_ID, &reg);
+19 −16
Original line number Diff line number Diff line
@@ -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);

	/* 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;
	}
	} else {
		/* this makes reset_gpio as invalid */
		max98373->reset_gpio = -1;

	/* 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))
+1 −1
Original line number Diff line number Diff line
@@ -213,7 +213,7 @@ struct max98373_cache {

struct max98373_priv {
	struct regmap *regmap;
	int reset_gpio;
	struct gpio_desc *reset;
	unsigned int v_slot;
	unsigned int i_slot;
	unsigned int spkfb_slot;