Skip to content

Commit b611810

Browse files
MrVanbroonie
authored andcommitted
ASoC: codec: cs42l73: 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 with default polarity GPIOD_OUT_LOW, set consumer name. - Use gpiod_set_value_cansleep to configure output value. Checking the current driver using legacy GPIO API, the reset value is first output HIGH, then LOW, then HIGH. Checking the datasheet, Hold RESET LOW (active) until all the power supply rails have risen to greater than or equal to the minimum recommended operating voltages. Since the driver has been here for quite long time and no complain on the reset flow, still follow original flow when using GPIOD descriptors. Per datasheet, the DTS polarity should be GPIOD_ACTIVE_LOW. The binding example use value 0(GPIOD_ACTIVE_HIGH) which seems wrong. There is no in-tree DTS has the device, so all should be fine. Signed-off-by: Peng Fan <peng.fan@nxp.com> Link: https://patch.msgid.link/20250506-csl42x-v3-6-e9496db544c4@nxp.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 43ef0dc commit b611810

1 file changed

Lines changed: 11 additions & 15 deletions

File tree

sound/soc/codecs/cs42l73.c

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@
99
*/
1010

1111
#include <linux/delay.h>
12+
#include <linux/gpio/consumer.h>
1213
#include <linux/i2c.h>
1314
#include <linux/init.h>
1415
#include <linux/kernel.h>
1516
#include <linux/module.h>
1617
#include <linux/moduleparam.h>
17-
#include <linux/of_gpio.h>
1818
#include <linux/pm.h>
1919
#include <linux/regmap.h>
2020
#include <linux/slab.h>
@@ -30,7 +30,7 @@
3030

3131
struct cs42l73_platform_data {
3232
/* RST GPIO */
33-
unsigned int reset_gpio;
33+
struct gpio_desc *reset_gpio;
3434
unsigned int chgfreq;
3535
int jack_detection;
3636
unsigned int mclk_freq;
@@ -1307,23 +1307,19 @@ static int cs42l73_i2c_probe(struct i2c_client *i2c_client)
13071307
if (of_property_read_u32(i2c_client->dev.of_node, "chgfreq", &val32) >= 0)
13081308
pdata->chgfreq = val32;
13091309
}
1310-
pdata->reset_gpio = of_get_named_gpio(i2c_client->dev.of_node, "reset-gpio", 0);
1310+
pdata->reset_gpio = devm_gpiod_get_optional(&i2c_client->dev, "reset", GPIOD_OUT_LOW);
1311+
1312+
if (IS_ERR(pdata->reset_gpio))
1313+
return PTR_ERR(pdata->reset_gpio);
1314+
1315+
gpiod_set_consumer_name(pdata->reset_gpio, "CS42L73 /RST");
13111316
cs42l73->pdata = *pdata;
13121317

13131318
i2c_set_clientdata(i2c_client, cs42l73);
13141319

13151320
if (cs42l73->pdata.reset_gpio) {
1316-
ret = devm_gpio_request_one(&i2c_client->dev,
1317-
cs42l73->pdata.reset_gpio,
1318-
GPIOF_OUT_INIT_HIGH,
1319-
"CS42L73 /RST");
1320-
if (ret < 0) {
1321-
dev_err(&i2c_client->dev, "Failed to request /RST %d: %d\n",
1322-
cs42l73->pdata.reset_gpio, ret);
1323-
return ret;
1324-
}
1325-
gpio_set_value_cansleep(cs42l73->pdata.reset_gpio, 0);
1326-
gpio_set_value_cansleep(cs42l73->pdata.reset_gpio, 1);
1321+
gpiod_set_value_cansleep(cs42l73->pdata.reset_gpio, 1);
1322+
gpiod_set_value_cansleep(cs42l73->pdata.reset_gpio, 0);
13271323
}
13281324

13291325
/* initialize codec */
@@ -1360,7 +1356,7 @@ static int cs42l73_i2c_probe(struct i2c_client *i2c_client)
13601356
return 0;
13611357

13621358
err_reset:
1363-
gpio_set_value_cansleep(cs42l73->pdata.reset_gpio, 0);
1359+
gpiod_set_value_cansleep(cs42l73->pdata.reset_gpio, 1);
13641360

13651361
return ret;
13661362
}

0 commit comments

Comments
 (0)