ASoC: codecs: cs4270: move to GPIO consumer API

Get the reset GPIO through the GPIO consumer API. This allows specifying the
DT property as "reset-gpios" without breaking existing DT users.

Signed-off-by: Daniel Mack <daniel@zonque.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
Daniel Mack 2018-12-06 13:24:26 +01:00 committed by Mark Brown
parent eab8e354a8
commit f98acd8a31
No known key found for this signature in database
GPG Key ID: 24D68B725D5487D0
1 changed files with 7 additions and 16 deletions

View File

@ -29,8 +29,8 @@
#include <linux/i2c.h> #include <linux/i2c.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/regulator/consumer.h> #include <linux/regulator/consumer.h>
#include <linux/gpio/consumer.h>
#include <linux/of_device.h> #include <linux/of_device.h>
#include <linux/of_gpio.h>
/* /*
* The codec isn't really big-endian or little-endian, since the I2S * The codec isn't really big-endian or little-endian, since the I2S
@ -658,8 +658,8 @@ static const struct regmap_config cs4270_regmap = {
static int cs4270_i2c_probe(struct i2c_client *i2c_client, static int cs4270_i2c_probe(struct i2c_client *i2c_client,
const struct i2c_device_id *id) const struct i2c_device_id *id)
{ {
struct device_node *np = i2c_client->dev.of_node;
struct cs4270_private *cs4270; struct cs4270_private *cs4270;
struct gpio_desc *reset_gpiod;
unsigned int val; unsigned int val;
int ret, i; int ret, i;
@ -678,20 +678,11 @@ static int cs4270_i2c_probe(struct i2c_client *i2c_client,
if (ret < 0) if (ret < 0)
return ret; return ret;
/* See if we have a way to bring the codec out of reset */ reset_gpiod = devm_gpiod_get_optional(&i2c_client->dev, "reset",
if (np) { GPIOD_OUT_HIGH);
enum of_gpio_flags flags; if (IS_ERR(reset_gpiod) &&
int gpio = of_get_named_gpio_flags(np, "reset-gpio", 0, &flags); PTR_ERR(reset_gpiod) == -EPROBE_DEFER)
return -EPROBE_DEFER;
if (gpio_is_valid(gpio)) {
ret = devm_gpio_request_one(&i2c_client->dev, gpio,
flags & OF_GPIO_ACTIVE_LOW ?
GPIOF_OUT_INIT_LOW : GPIOF_OUT_INIT_HIGH,
"cs4270 reset");
if (ret < 0)
return ret;
}
}
cs4270->regmap = devm_regmap_init_i2c(i2c_client, &cs4270_regmap); cs4270->regmap = devm_regmap_init_i2c(i2c_client, &cs4270_regmap);
if (IS_ERR(cs4270->regmap)) if (IS_ERR(cs4270->regmap))