Skip to content

Commit ba79bca

Browse files
nunojsabroonie
authored andcommitted
ASoC: codecs: adau1373: add powerdown gpio
If the powerdown GPIO is specified, we use it for reset. Otherwise, fallback to a software reset. Signed-off-by: Nuno Sa <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 71743cb commit ba79bca

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

sound/soc/codecs/adau1373.c

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
#include <linux/module.h>
1010
#include <linux/init.h>
11+
#include <linux/gpio/consumer.h>
1112
#include <linux/delay.h>
1213
#include <linux/pm.h>
1314
#include <linux/property.h>
@@ -1485,6 +1486,11 @@ static const struct snd_soc_component_driver adau1373_component_driver = {
14851486
.endianness = 1,
14861487
};
14871488

1489+
static void adau1373_reset(void *reset_gpio)
1490+
{
1491+
gpiod_set_value_cansleep(reset_gpio, 1);
1492+
}
1493+
14881494
static int adau1373_parse_fw(struct device *dev, struct adau1373 *adau1373)
14891495
{
14901496
int ret, drc_count;
@@ -1547,6 +1553,7 @@ static int adau1373_parse_fw(struct device *dev, struct adau1373 *adau1373)
15471553
static int adau1373_i2c_probe(struct i2c_client *client)
15481554
{
15491555
struct adau1373 *adau1373;
1556+
struct gpio_desc *gpiod;
15501557
int ret;
15511558

15521559
adau1373 = devm_kzalloc(&client->dev, sizeof(*adau1373), GFP_KERNEL);
@@ -1558,7 +1565,26 @@ static int adau1373_i2c_probe(struct i2c_client *client)
15581565
if (IS_ERR(adau1373->regmap))
15591566
return PTR_ERR(adau1373->regmap);
15601567

1561-
regmap_write(adau1373->regmap, ADAU1373_SOFT_RESET, 0x00);
1568+
/*
1569+
* If the powerdown GPIO is specified, we use it for reset. Otherwise
1570+
* a software reset is done.
1571+
*/
1572+
gpiod = devm_gpiod_get_optional(&client->dev, "powerdown",
1573+
GPIOD_OUT_HIGH);
1574+
if (IS_ERR(gpiod))
1575+
return PTR_ERR(gpiod);
1576+
1577+
if (gpiod) {
1578+
gpiod_set_value_cansleep(gpiod, 0);
1579+
fsleep(10);
1580+
1581+
ret = devm_add_action_or_reset(&client->dev, adau1373_reset,
1582+
gpiod);
1583+
if (ret)
1584+
return ret;
1585+
} else {
1586+
regmap_write(adau1373->regmap, ADAU1373_SOFT_RESET, 0x00);
1587+
}
15621588

15631589
dev_set_drvdata(&client->dev, adau1373);
15641590

0 commit comments

Comments
 (0)