Skip to content

Commit 790d5f8

Browse files
MrVanbroonie
authored andcommitted
ASoC: codec: tlv320aic32x4: Convert to GPIO descriptors
of_gpio.h is deprecated, update the driver to use GPIO descriptors. - Use devm_gpiod_get_optional to get GPIO descriptor, and set consumer name. - Use gpiod_set_value to configure output value. While at here, reorder the included headers. Checking the DTS that use the device, all are using GPIOD_ACTIVE_LOW polarity for reset-gpios, so all should work as expected with this patch. Cc: Markus Niebel <[email protected]> Cc: Alexander Stein <[email protected]> Reviewed-by: Linus Walleij <[email protected]> Tested-by: Alexander Stein <[email protected]> Signed-off-by: Peng Fan <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent b709c1a commit 790d5f8

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

sound/soc/codecs/tlv320aic32x4.c

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,11 @@
1212
#include <linux/cdev.h>
1313
#include <linux/clk.h>
1414
#include <linux/delay.h>
15-
#include <linux/gpio.h>
15+
#include <linux/gpio/consumer.h>
1616
#include <linux/init.h>
1717
#include <linux/module.h>
1818
#include <linux/moduleparam.h>
1919
#include <linux/of_clk.h>
20-
#include <linux/of_gpio.h>
2120
#include <linux/pm.h>
2221
#include <linux/regulator/consumer.h>
2322
#include <linux/slab.h>
@@ -38,7 +37,7 @@ struct aic32x4_priv {
3837
u32 power_cfg;
3938
u32 micpga_routing;
4039
bool swapdacs;
41-
int rstn_gpio;
40+
struct gpio_desc *rstn_gpio;
4241
const char *mclk_name;
4342

4443
struct regulator *supply_ldo;
@@ -1236,7 +1235,14 @@ static int aic32x4_parse_dt(struct aic32x4_priv *aic32x4,
12361235

12371236
aic32x4->swapdacs = false;
12381237
aic32x4->micpga_routing = 0;
1239-
aic32x4->rstn_gpio = of_get_named_gpio(np, "reset-gpios", 0);
1238+
/* Assert reset using GPIOD_OUT_HIGH, because reset is GPIO_ACTIVE_LOW */
1239+
aic32x4->rstn_gpio = devm_gpiod_get_optional(aic32x4->dev, "reset", GPIOD_OUT_HIGH);
1240+
if (IS_ERR(aic32x4->rstn_gpio)) {
1241+
return dev_err_probe(aic32x4->dev, PTR_ERR(aic32x4->rstn_gpio),
1242+
"Failed to get reset gpio\n");
1243+
} else {
1244+
gpiod_set_consumer_name(aic32x4->rstn_gpio, "tlv320aic32x4_rstn");
1245+
}
12401246

12411247
if (of_property_read_u32_array(np, "aic32x4-gpio-func",
12421248
aic32x4_setup->gpio_func, 5) >= 0)
@@ -1372,26 +1378,20 @@ int aic32x4_probe(struct device *dev, struct regmap *regmap,
13721378
aic32x4->power_cfg = 0;
13731379
aic32x4->swapdacs = false;
13741380
aic32x4->micpga_routing = 0;
1375-
aic32x4->rstn_gpio = -1;
1381+
aic32x4->rstn_gpio = NULL;
13761382
aic32x4->mclk_name = "mclk";
13771383
}
13781384

1379-
if (gpio_is_valid(aic32x4->rstn_gpio)) {
1380-
ret = devm_gpio_request_one(dev, aic32x4->rstn_gpio,
1381-
GPIOF_OUT_INIT_LOW, "tlv320aic32x4 rstn");
1382-
if (ret != 0)
1383-
return ret;
1384-
}
1385-
13861385
ret = aic32x4_setup_regulators(dev, aic32x4);
13871386
if (ret) {
13881387
dev_err(dev, "Failed to setup regulators\n");
13891388
return ret;
13901389
}
13911390

1392-
if (gpio_is_valid(aic32x4->rstn_gpio)) {
1391+
if (!aic32x4->rstn_gpio) {
13931392
ndelay(10);
1394-
gpio_set_value_cansleep(aic32x4->rstn_gpio, 1);
1393+
/* deassert reset */
1394+
gpiod_set_value_cansleep(aic32x4->rstn_gpio, 0);
13951395
mdelay(1);
13961396
}
13971397

0 commit comments

Comments
 (0)