Commit 966277df authored by Mark Brown's avatar Mark Brown

ASoC: Convert some Maxim codecs to use GPIO

Merge series from Linus Walleij <linus.walleij@linaro.org>:

The Maxim devices are pretty straight-forward to convert
over to use GPIO descriptors, so let's do it.
parents f3dbb935 ce22caa4
...@@ -9,14 +9,10 @@ ...@@ -9,14 +9,10 @@
/** /**
* struct max9768_pdata - optional platform specific MAX9768 configuration * struct max9768_pdata - optional platform specific MAX9768 configuration
* @shdn_gpio: GPIO to SHDN pin. If not valid, pin must be hardwired HIGH
* @mute_gpio: GPIO to MUTE pin. If not valid, control for mute won't be added
* @flags: configuration flags, e.g. set classic PWM mode (check datasheet * @flags: configuration flags, e.g. set classic PWM mode (check datasheet
* regarding "filterless modulation" which is default). * regarding "filterless modulation" which is default).
*/ */
struct max9768_pdata { struct max9768_pdata {
int shdn_gpio;
int mute_gpio;
unsigned flags; unsigned flags;
#define MAX9768_FLAG_CLASSIC_PWM (1 << 0) #define MAX9768_FLAG_CLASSIC_PWM (1 << 0)
}; };
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
#include <linux/module.h> #include <linux/module.h>
#include <linux/i2c.h> #include <linux/i2c.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/gpio.h> #include <linux/gpio/consumer.h>
#include <linux/regmap.h> #include <linux/regmap.h>
#include <sound/core.h> #include <sound/core.h>
...@@ -27,8 +27,8 @@ ...@@ -27,8 +27,8 @@
struct max9768 { struct max9768 {
struct regmap *regmap; struct regmap *regmap;
int mute_gpio; struct gpio_desc *mute;
int shdn_gpio; struct gpio_desc *shdn;
u32 flags; u32 flags;
}; };
...@@ -42,7 +42,7 @@ static int max9768_get_gpio(struct snd_kcontrol *kcontrol, ...@@ -42,7 +42,7 @@ static int max9768_get_gpio(struct snd_kcontrol *kcontrol,
{ {
struct snd_soc_component *c = snd_soc_kcontrol_component(kcontrol); struct snd_soc_component *c = snd_soc_kcontrol_component(kcontrol);
struct max9768 *max9768 = snd_soc_component_get_drvdata(c); struct max9768 *max9768 = snd_soc_component_get_drvdata(c);
int val = gpio_get_value_cansleep(max9768->mute_gpio); int val = gpiod_get_value_cansleep(max9768->mute);
ucontrol->value.integer.value[0] = !val; ucontrol->value.integer.value[0] = !val;
...@@ -55,7 +55,7 @@ static int max9768_set_gpio(struct snd_kcontrol *kcontrol, ...@@ -55,7 +55,7 @@ static int max9768_set_gpio(struct snd_kcontrol *kcontrol,
struct snd_soc_component *c = snd_soc_kcontrol_component(kcontrol); struct snd_soc_component *c = snd_soc_kcontrol_component(kcontrol);
struct max9768 *max9768 = snd_soc_component_get_drvdata(c); struct max9768 *max9768 = snd_soc_component_get_drvdata(c);
gpio_set_value_cansleep(max9768->mute_gpio, !ucontrol->value.integer.value[0]); gpiod_set_value_cansleep(max9768->mute, !ucontrol->value.integer.value[0]);
return 0; return 0;
} }
...@@ -138,7 +138,7 @@ static int max9768_probe(struct snd_soc_component *component) ...@@ -138,7 +138,7 @@ static int max9768_probe(struct snd_soc_component *component)
return ret; return ret;
} }
if (gpio_is_valid(max9768->mute_gpio)) { if (max9768->mute) {
ret = snd_soc_add_component_controls(component, max9768_mute, ret = snd_soc_add_component_controls(component, max9768_mute,
ARRAY_SIZE(max9768_mute)); ARRAY_SIZE(max9768_mute));
if (ret) if (ret)
...@@ -171,28 +171,29 @@ static int max9768_i2c_probe(struct i2c_client *client) ...@@ -171,28 +171,29 @@ static int max9768_i2c_probe(struct i2c_client *client)
{ {
struct max9768 *max9768; struct max9768 *max9768;
struct max9768_pdata *pdata = client->dev.platform_data; struct max9768_pdata *pdata = client->dev.platform_data;
int err;
max9768 = devm_kzalloc(&client->dev, sizeof(*max9768), GFP_KERNEL); max9768 = devm_kzalloc(&client->dev, sizeof(*max9768), GFP_KERNEL);
if (!max9768) if (!max9768)
return -ENOMEM; return -ENOMEM;
if (pdata) { /* Mute on powerup to avoid clicks */
/* Mute on powerup to avoid clicks */ max9768->mute = devm_gpiod_get_optional(&client->dev,
err = devm_gpio_request_one(&client->dev, pdata->mute_gpio, "mute",
GPIOF_INIT_HIGH, "MAX9768 Mute"); GPIOD_OUT_HIGH);
max9768->mute_gpio = err ?: pdata->mute_gpio; if (IS_ERR(max9768->mute))
return PTR_ERR(max9768->mute);
/* Activate chip by releasing shutdown, enables I2C */ gpiod_set_consumer_name(max9768->mute, "MAX9768 Mute");
err = devm_gpio_request_one(&client->dev, pdata->shdn_gpio,
GPIOF_INIT_HIGH, "MAX9768 Shutdown"); /* Activate chip by releasing shutdown, enables I2C */
max9768->shdn_gpio = err ?: pdata->shdn_gpio; max9768->shdn = devm_gpiod_get_optional(&client->dev,
"shutdown",
GPIOD_OUT_HIGH);
if (IS_ERR(max9768->shdn))
return PTR_ERR(max9768->shdn);
gpiod_set_consumer_name(max9768->shdn, "MAX9768 Shutdown");
if (pdata)
max9768->flags = pdata->flags; max9768->flags = pdata->flags;
} else {
max9768->shdn_gpio = -EINVAL;
max9768->mute_gpio = -EINVAL;
}
i2c_set_clientdata(client, max9768); i2c_set_clientdata(client, max9768);
......
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/device.h> #include <linux/device.h>
#include <linux/err.h> #include <linux/err.h>
#include <linux/gpio.h>
#include <linux/gpio/consumer.h> #include <linux/gpio/consumer.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/mod_devicetable.h> #include <linux/mod_devicetable.h>
......
...@@ -3,12 +3,10 @@ ...@@ -3,12 +3,10 @@
#include <linux/acpi.h> #include <linux/acpi.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/gpio.h>
#include <linux/i2c.h> #include <linux/i2c.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/mod_devicetable.h> #include <linux/mod_devicetable.h>
#include <linux/of.h> #include <linux/of.h>
#include <linux/of_gpio.h>
#include <linux/pm.h> #include <linux/pm.h>
#include <linux/regmap.h> #include <linux/regmap.h>
#include <linux/slab.h> #include <linux/slab.h>
...@@ -560,21 +558,6 @@ static int max98373_i2c_probe(struct i2c_client *i2c) ...@@ -560,21 +558,6 @@ static int max98373_i2c_probe(struct i2c_client *i2c)
/* voltage/current slot & gpio configuration */ /* voltage/current slot & gpio configuration */
max98373_slot_config(&i2c->dev, max98373); 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 */ /* Check Revision ID */
ret = regmap_read(max98373->regmap, ret = regmap_read(max98373->regmap,
MAX98373_R21FF_REV_ID, &reg); MAX98373_R21FF_REV_ID, &reg);
......
...@@ -12,9 +12,8 @@ ...@@ -12,9 +12,8 @@
#include <sound/pcm.h> #include <sound/pcm.h>
#include <sound/pcm_params.h> #include <sound/pcm_params.h>
#include <sound/soc.h> #include <sound/soc.h>
#include <linux/gpio.h> #include <linux/gpio/consumer.h>
#include <linux/of.h> #include <linux/of.h>
#include <linux/of_gpio.h>
#include <sound/tlv.h> #include <sound/tlv.h>
#include "max98373.h" #include "max98373.h"
...@@ -478,20 +477,24 @@ void max98373_slot_config(struct device *dev, ...@@ -478,20 +477,24 @@ void max98373_slot_config(struct device *dev,
max98373->i_slot = value & 0xF; max98373->i_slot = value & 0xF;
else else
max98373->i_slot = 1; max98373->i_slot = 1;
if (dev->of_node) {
max98373->reset_gpio = of_get_named_gpio(dev->of_node, /* This will assert RESET */
"maxim,reset-gpio", 0); max98373->reset = devm_gpiod_get_optional(dev,
if (!gpio_is_valid(max98373->reset_gpio)) { "maxim,reset",
dev_err(dev, "Looking up %s property in node %s failed %d\n", GPIOD_OUT_HIGH);
"maxim,reset-gpio", dev->of_node->full_name, if (IS_ERR(max98373->reset)) {
max98373->reset_gpio); dev_err(dev, "error %ld looking up RESET GPIO line\n",
} else { PTR_ERR(max98373->reset));
dev_dbg(dev, "maxim,reset-gpio=%d", return;
max98373->reset_gpio); }
}
} else { /* Cycle reset */
/* this makes reset_gpio as invalid */ if (max98373->reset) {
max98373->reset_gpio = -1; 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)) if (!device_property_read_u32(dev, "maxim,spkfb-slot-no", &value))
......
...@@ -213,7 +213,7 @@ struct max98373_cache { ...@@ -213,7 +213,7 @@ struct max98373_cache {
struct max98373_priv { struct max98373_priv {
struct regmap *regmap; struct regmap *regmap;
int reset_gpio; struct gpio_desc *reset;
unsigned int v_slot; unsigned int v_slot;
unsigned int i_slot; unsigned int i_slot;
unsigned int spkfb_slot; unsigned int spkfb_slot;
......
...@@ -3,12 +3,11 @@ ...@@ -3,12 +3,11 @@
#include <linux/acpi.h> #include <linux/acpi.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/gpio.h> #include <linux/gpio/consumer.h>
#include <linux/i2c.h> #include <linux/i2c.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/mod_devicetable.h> #include <linux/mod_devicetable.h>
#include <linux/of.h> #include <linux/of.h>
#include <linux/of_gpio.h>
#include <linux/pm_runtime.h> #include <linux/pm_runtime.h>
#include <linux/regmap.h> #include <linux/regmap.h>
#include <linux/slab.h> #include <linux/slab.h>
......
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
#include <sound/pcm_params.h> #include <sound/pcm_params.h>
#include <linux/regulator/consumer.h> #include <linux/regulator/consumer.h>
#include <sound/soc.h> #include <sound/soc.h>
#include <linux/gpio.h>
#include <sound/tlv.h> #include <sound/tlv.h>
#include "max98396.h" #include "max98396.h"
......
...@@ -11,10 +11,8 @@ ...@@ -11,10 +11,8 @@
#include <sound/pcm.h> #include <sound/pcm.h>
#include <sound/pcm_params.h> #include <sound/pcm_params.h>
#include <sound/soc.h> #include <sound/soc.h>
#include <linux/gpio.h>
#include <linux/gpio/consumer.h> #include <linux/gpio/consumer.h>
#include <linux/of.h> #include <linux/of.h>
#include <linux/of_gpio.h>
#include <sound/tlv.h> #include <sound/tlv.h>
#include "max98520.h" #include "max98520.h"
......
...@@ -15,9 +15,7 @@ ...@@ -15,9 +15,7 @@
#include <sound/pcm.h> #include <sound/pcm.h>
#include <sound/pcm_params.h> #include <sound/pcm_params.h>
#include <sound/soc.h> #include <sound/soc.h>
#include <linux/gpio.h>
#include <linux/gpio/consumer.h> #include <linux/gpio/consumer.h>
#include <linux/of_gpio.h>
#include <sound/tlv.h> #include <sound/tlv.h>
#include "max98927.h" #include "max98927.h"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment