ASoC: codec: cs42l[56,73,52]: Convert to GPIO descriptors
Subsystems (4)
v3 cover ASoC: codec: cs42l[56,73,52]: Convert to GPIO descriptors
This patchset is separate from [1], and not merging changes in one patch. So separate changes into three patches for each chip.
- sort headers
- Drop legacy platform support
- 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.
I not have platforms to test, just do the patches with my best efforts, and make build pass.
[1] https://lore.kernel.org/all/[email protected]/
---
Changes in v3:
- Fix build break in patch 2 when using allmodconfig
- Link to v2: https://lore.kernel.org/r/[email protected]
---
Peng Fan (9):
ASoC: codec: cs42l56: Sort headers alphabetically
ASoC: codec: cs42l56: Drop cs42l56.h
ASoC: codec: cs42l56: Convert to GPIO descriptors
ASoC: codec: cs42l73: Sort headers alphabetically
ASoC: codec: cs42l73: Drop cs42l73.h
ASoC: codec: cs42l73: Convert to GPIO descriptors
ASoC: codec: cs42l52: Sort headers alphabetically
ASoC: codec: cs42l52: Drop cs42l52.h
ASoC: codec: cs42l52: Convert to GPIO descriptors
include/sound/cs42l52.h | 29 ------------ include/sound/cs42l56.h | 45 ------------------ include/sound/cs42l73.h | 19 -------- sound/soc/codecs/cs42l52.c | 112 ++++++++++++++++++++++++--------------------- sound/soc/codecs/cs42l56.c | 90 ++++++++++++++++++++++-------------- sound/soc/codecs/cs42l73.c | 70 +++++++++++++--------------- 6 files changed, 150 insertions(+), 215 deletions(-)
---
base-commit: d9889ee34d3ea05284d5df6182692c12595b671d
change-id: 20250427-csl42x-0151784a1230
Best regards,
Signature · 1 line
Peng Fan <[email protected]>
PATCH v3 1/9 ASoC: codec: cs42l56: Sort headers alphabetically
From: Peng Fan <[email protected]>
Sort headers alphabetically to easily insert new ones and drop unused ones.
--- sound/soc/codecs/cs42l56.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-)
sound/soc/codecs/cs42l56.c +11 -11
@@ -7,29 +7,29 @@* Author: Brian Austin <[email protected]> */ -#include <linux/module.h> -#include <linux/moduleparam.h> -#include <linux/kernel.h> -#include <linux/init.h> #include <linux/delay.h> -#include <linux/pm.h> #include <linux/i2c.h> +#include <linux/init.h> #include <linux/input.h> +#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/moduleparam.h> +#include <linux/of.h> +#include <linux/of_gpio.h> +#include <linux/platform_device.h> +#include <linux/pm.h> #include <linux/regmap.h> +#include <linux/regulator/consumer.h> #include <linux/slab.h> #include <linux/workqueue.h> -#include <linux/platform_device.h> -#include <linux/regulator/consumer.h> -#include <linux/of.h> -#include <linux/of_gpio.h> #include <sound/core.h> +#include <sound/cs42l56.h> +#include <sound/initval.h> #include <sound/pcm.h> #include <sound/pcm_params.h> #include <sound/soc.h> #include <sound/soc-dapm.h> -#include <sound/initval.h> #include <sound/tlv.h> -#include <sound/cs42l56.h> #include "cs42l56.h" #define CS42L56_NUM_SUPPLIES 3
Signature · 1 line
2.37.1
PATCH v3 2/9 ASoC: codec: cs42l56: Drop cs42l56.h
In reply to Peng Fan (OSS)From: Peng Fan <[email protected]>
There is no in-tree user of "include/sound/cs42l56.h", so move 'struct cs42l56_platform_data' to cs42l56.c and remove the header file. And platform data is mostly for platforms that create devices non using device tree. CS42L56 is a discontinued product, there is less possibility that new users will use legacy method to create devices. So drop cs42l56.h to prepare using GPIOD API.
--- include/sound/cs42l56.h | 45 ------------------------------------------ sound/soc/codecs/cs42l56.c | 49 ++++++++++++++++++++++++++++++++++------------ 2 files changed, 37 insertions(+), 57 deletions(-)
include/sound/cs42l56.h deleted +0 -45
@@ -1,45 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-only */ -/* -* linux/sound/cs42l56.h -- Platform data for CS42L56 -* -* Copyright (c) 2014 Cirrus Logic Inc. -*/ - -#ifndef __CS42L56_H -#define __CS42L56_H - -struct cs42l56_platform_data { - -/* GPIO for Reset */ -unsigned int gpio_nreset; - -/* MICBIAS Level. Check datasheet Pg48 */ -unsigned int micbias_lvl; - -/* Analog Input 1A Reference 0=Single 1=Pseudo-Differential */ -unsigned int ain1a_ref_cfg; - -/* Analog Input 2A Reference 0=Single 1=Pseudo-Differential */ -unsigned int ain2a_ref_cfg; - -/* Analog Input 1B Reference 0=Single 1=Pseudo-Differential */ -unsigned int ain1b_ref_cfg; - -/* Analog Input 2B Reference 0=Single 1=Pseudo-Differential */ -unsigned int ain2b_ref_cfg; - -/* Charge Pump Freq. Check datasheet Pg62 */ -unsigned int chgfreq; - -/* HighPass Filter Right Channel Corner Frequency */ -unsigned int hpfb_freq; - -/* HighPass Filter Left Channel Corner Frequency */ -unsigned int hpfa_freq; - -/* Adaptive Power Control for LO/HP */ -unsigned int adaptive_pwr; - -}; - -#endif /* __CS42L56_H */
sound/soc/codecs/cs42l56.c +37 -12
73 lines not on this page · raw message
Signature · 1 line
2.37.1
PATCH v3 3/9 ASoC: codec: cs42l56: Convert to GPIO descriptors
In reply to Peng Fan (OSS)From: Peng Fan <[email protected]>
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 nreset value is first output HIGH, then LOW, then HIGH.
Checking the datasheet, nreset is should be held low after power on, when nreset is high, it starts to work.
Since the driver has been here for quite long time and no complain on the nreset flow, still follow original flow when using GPIOD descriptors.
Commit 944004eb56dc ("gpiolib: of: add a quirk for reset line for Cirrus CS42L56 codec") added quirks, so the gpio request API will work as before.
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.
--- sound/soc/codecs/cs42l56.c | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-)
sound/soc/codecs/cs42l56.c +11 -14
@@ -8,6 +8,7 @@*/ #include <linux/delay.h> +#include <linux/gpio/consumer.h> #include <linux/i2c.h> #include <linux/init.h> #include <linux/input.h>
@@ -15,7 +16,6 @@#include <linux/module.h> #include <linux/moduleparam.h> #include <linux/of.h> -#include <linux/of_gpio.h> #include <linux/platform_device.h> #include <linux/pm.h> #include <linux/regmap.h>
@@ -35,7 +35,7 @@struct cs42l56_platform_data {/* GPIO for Reset */ -unsigned int gpio_nreset; +struct gpio_desc *gpio_nreset;/* MICBIAS Level. Check datasheet Pg48 */ unsigned int micbias_lvl;
@@ -1193,7 +1193,13 @@ static int cs42l56_handle_of_data(struct i2c_client *i2c_client,if (of_property_read_u32 (np,"cirrus,hpf-left-freq" , &val32) >=0 ) pdata->hpfb_freq = val32; - pdata->gpio_nreset =of_get_named_gpio (np,"cirrus,gpio-nreset" ,0 ); + pdata->gpio_nreset =devm_gpiod_get_optional (&i2c_client->dev,"cirrus,gpio-nreset" , +GPIOD_OUT_LOW ); + +if (IS_ERR (pdata->gpio_nreset)) +return PTR_ERR (pdata->gpio_nreset); + +gpiod_set_consumer_name (pdata->gpio_nreset,"CS42L56 /RST" );return 0 ; }
@@ -1225,19 +1231,10 @@ static int cs42l56_i2c_probe(struct i2c_client *i2c_client) }if (cs42l56->pdata.gpio_nreset) { - ret =gpio_request_one (cs42l56->pdata.gpio_nreset, -GPIOF_OUT_INIT_HIGH ,"CS42L56 /RST" ); -if (ret <0 ) { -dev_err (&i2c_client->dev, -"Failed to request /RST %d: %d\n" , - cs42l56->pdata.gpio_nreset, ret); -return ret; - } -gpio_set_value_cansleep (cs42l56->pdata.gpio_nreset,0 ); -gpio_set_value_cansleep (cs42l56->pdata.gpio_nreset,1 ); +gpiod_set_value_cansleep (cs42l56->pdata.gpio_nreset,1 ); +gpiod_set_value_cansleep (cs42l56->pdata.gpio_nreset,0 ); } -i2c_set_clientdata (i2c_client, cs42l56);for (i =0 ; i <ARRAY_SIZE (cs42l56->supplies); i++)
Signature · 1 line
2.37.1
Re: [PATCH v3 3/9] ASoC: codec: cs42l56: Convert to GPIO descriptors
Quoted 25 lines · Peng Fan (OSS)
From: Peng Fan <[email protected]>
of_gpio.his deprecated, update the driver to use GPIO descriptors.
- Usedevm_gpiod_get_optionalto get GPIO descriptor with default polarityGPIOD_OUT_LOW, set consumer name.
- Usegpiod_set_value_cansleepto configure output value.Checking the current driver using legacy GPIO API, the nreset value is first output HIGH, then LOW, then HIGH.
Checking the datasheet, nreset is should be held low after power on, when nreset is high, it starts to work.
Since the driver has been here for quite long time and no complain on the nreset flow, still follow original flow when using GPIOD descriptors.
Commit
944004eb56dc("gpiolib: of: add a quirk for reset line for Cirrus CS42L56 codec") added quirks, so the gpio request API will work as before.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 <[email protected]>
Re: [PATCH v3 3/9] ASoC: codec: cs42l56: Convert to GPIO descriptors
In reply to Peng Fan (OSS)Quoted 17 lines · Peng Fan (OSS)
From: Peng Fan <[email protected]>
of_gpio.his deprecated, update the driver to use GPIO descriptors.
- Usedevm_gpiod_get_optionalto get GPIO descriptor with default polarityGPIOD_OUT_LOW, set consumer name.
- Usegpiod_set_value_cansleepto configure output value.Checking the current driver using legacy GPIO API, the nreset value is first output HIGH, then LOW, then HIGH.
Checking the datasheet, nreset is should be held low after power on, when nreset is high, it starts to work.
Since the driver has been here for quite long time and no complain on the nreset flow, still follow original flow when using GPIOD descriptors.
Quoted 8 lines
Commit
944004eb56dc("gpiolib: of: add a quirk for reset line for Cirrus CS42L56 codec") added quirks, so the gpio request API will work as before.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 <[email protected]>
Yours,
Linus Walleij
PATCH v3 4/9 ASoC: codec: cs42l73: Sort headers alphabetically
In reply to Peng Fan (OSS)From: Peng Fan <[email protected]>
Sort headers alphabetically to easily insert new ones and drop unused ones.
--- sound/soc/codecs/cs42l73.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
sound/soc/codecs/cs42l73.c +7 -7
@@ -8,26 +8,26 @@* Brian Austin, Cirrus Logic Inc, <[email protected]> */ +#include <linux/delay.h> +#include <linux/i2c.h> +#include <linux/init.h> +#include <linux/kernel.h> #include <linux/module.h> #include <linux/moduleparam.h> -#include <linux/kernel.h> -#include <linux/init.h> -#include <linux/delay.h> #include <linux/of_gpio.h> #include <linux/pm.h> -#include <linux/i2c.h> #include <linux/regmap.h> #include <linux/slab.h> #include <sound/core.h> +#include <sound/cs42l73.h> +#include <sound/initval.h> #include <sound/pcm.h> #include <sound/pcm_params.h> #include <sound/soc.h> #include <sound/soc-dapm.h> -#include <sound/initval.h> #include <sound/tlv.h> -#include <sound/cs42l73.h> -#include "cs42l73.h" #include "cirrus_legacy.h" +#include "cs42l73.h" struct sp_config {u8 spc, mmcc, spfs;
Signature · 1 line
2.37.1
PATCH v3 5/9 ASoC: codec: cs42l73: Drop cs42l73.h
In reply to Peng Fan (OSS)From: Peng Fan <[email protected]>
There is no in-tree user of "include/sound/cs42l56.h", so move 'struct cs42l73_platform_data ' to cs42l73.c and remove the header file. And platform data is mostly for legacy platforms that create devices non using device tree. So drop cs42l73.h to prepare using GPIOD API.
--- include/sound/cs42l73.h | 19 ------------------- sound/soc/codecs/cs42l73.c | 36 ++++++++++++++++++------------------ 2 files changed, 18 insertions(+), 37 deletions(-)
include/sound/cs42l73.h deleted +0 -19
@@ -1,19 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-only */ -/* -* linux/sound/cs42l73.h -- Platform data for CS42L73 -* -* Copyright (c) 2012 Cirrus Logic Inc. -*/ - -#ifndef __CS42L73_H -#define __CS42L73_H - -struct cs42l73_platform_data { -/* RST GPIO */ -unsigned int reset_gpio; -unsigned int chgfreq; -int jack_detection; -unsigned int mclk_freq; -}; - -#endif /* __CS42L73_H */
sound/soc/codecs/cs42l73.c +18 -18
@@ -19,7 +19,6 @@#include <linux/regmap.h> #include <linux/slab.h> #include <sound/core.h> -#include <sound/cs42l73.h> #include <sound/initval.h> #include <sound/pcm.h> #include <sound/pcm_params.h>
@@ -29,6 +28,14 @@#include "cirrus_legacy.h" #include "cs42l73.h" +struct cs42l73_platform_data { +/* RST GPIO */ +unsigned int reset_gpio; +unsigned int chgfreq; +int jack_detection; +unsigned int mclk_freq; +}; +struct sp_config {u8 spc, mmcc, spfs;u32 srate;
@@ -1276,7 +1283,7 @@ static const struct regmap_config cs42l73_regmap = {static int cs42l73_i2c_probe (struct i2c_client *i2c_client) {struct cs42l73_private *cs42l73; -struct cs42l73_platform_data *pdata =dev_get_platdata (&i2c_client->dev); +struct cs42l73_platform_data *pdata;int ret, devid;unsigned int reg;u32 val32;
@@ -1292,23 +1299,16 @@ static int cs42l73_i2c_probe(struct i2c_client *i2c_client)return ret; } -if (pdata) { - cs42l73->pdata = *pdata; - }else { - pdata =devm_kzalloc (&i2c_client->dev,sizeof (*pdata), -GFP_KERNEL ); -if (!pdata) -return -ENOMEM ; - -if (i2c_client->dev.of_node) { -if (of_property_read_u32 (i2c_client->dev.of_node, -"chgfreq" , &val32) >=0 ) - pdata->chgfreq = val32; - } - pdata->reset_gpio =of_get_named_gpio (i2c_client->dev.of_node, -"reset-gpio" ,0 ); - cs42l73->pdata = *pdata; + pdata =devm_kzalloc (&i2c_client->dev,sizeof (*pdata),GFP_KERNEL ); +if (!pdata) +return -ENOMEM ; + +if (i2c_client->dev.of_node) { +if (of_property_read_u32 (i2c_client->dev.of_node,"chgfreq" , &val32) >=0 ) + pdata->chgfreq = val32; } + pdata->reset_gpio =of_get_named_gpio (i2c_client->dev.of_node,"reset-gpio" ,0 ); + cs42l73->pdata = *pdata;i2c_set_clientdata (i2c_client, cs42l73);
Signature · 1 line
2.37.1
PATCH v3 6/9 ASoC: codec: cs42l73: Convert to GPIO descriptors
In reply to Peng Fan (OSS)From: Peng Fan <[email protected]>
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.
--- sound/soc/codecs/cs42l73.c | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-)
sound/soc/codecs/cs42l73.c +11 -15
@@ -9,12 +9,12 @@*/ #include <linux/delay.h> +#include <linux/gpio/consumer.h> #include <linux/i2c.h> #include <linux/init.h> #include <linux/kernel.h> #include <linux/module.h> #include <linux/moduleparam.h> -#include <linux/of_gpio.h> #include <linux/pm.h> #include <linux/regmap.h> #include <linux/slab.h>
@@ -30,7 +30,7 @@struct cs42l73_platform_data {/* RST GPIO */ -unsigned int reset_gpio; +struct gpio_desc *reset_gpio;unsigned int chgfreq;int jack_detection;unsigned int mclk_freq;
@@ -1307,23 +1307,19 @@ static int cs42l73_i2c_probe(struct i2c_client *i2c_client)if (of_property_read_u32 (i2c_client->dev.of_node,"chgfreq" , &val32) >=0 ) pdata->chgfreq = val32; } - pdata->reset_gpio =of_get_named_gpio (i2c_client->dev.of_node,"reset-gpio" ,0 ); + pdata->reset_gpio =devm_gpiod_get_optional (&i2c_client->dev,"reset" ,GPIOD_OUT_LOW ); + +if (IS_ERR (pdata->reset_gpio)) +return PTR_ERR (pdata->reset_gpio); + +gpiod_set_consumer_name (pdata->reset_gpio,"CS42L73 /RST" ); cs42l73->pdata = *pdata;i2c_set_clientdata (i2c_client, cs42l73);if (cs42l73->pdata.reset_gpio) { - ret =devm_gpio_request_one (&i2c_client->dev, - cs42l73->pdata.reset_gpio, -GPIOF_OUT_INIT_HIGH , -"CS42L73 /RST" ); -if (ret <0 ) { -dev_err (&i2c_client->dev,"Failed to request /RST %d: %d\n" , - cs42l73->pdata.reset_gpio, ret); -return ret; - } -gpio_set_value_cansleep (cs42l73->pdata.reset_gpio,0 ); -gpio_set_value_cansleep (cs42l73->pdata.reset_gpio,1 ); +gpiod_set_value_cansleep (cs42l73->pdata.reset_gpio,1 ); +gpiod_set_value_cansleep (cs42l73->pdata.reset_gpio,0 ); }/* initialize codec */
@@ -1360,7 +1356,7 @@ static int cs42l73_i2c_probe(struct i2c_client *i2c_client)return 0 ; err_reset: -gpio_set_value_cansleep (cs42l73->pdata.reset_gpio,0 ); +gpiod_set_value_cansleep (cs42l73->pdata.reset_gpio,1 );return ret; }
Signature · 1 line
2.37.1
Re: [PATCH v3 6/9] ASoC: codec: cs42l73: Convert to GPIO descriptors
Quoted 18 lines · Peng Fan (OSS)
From: Peng Fan <[email protected]>
of_gpio.his deprecated, update the driver to use GPIO descriptors.
- Usedevm_gpiod_get_optionalto get GPIO descriptor with default polarityGPIOD_OUT_LOW, set consumer name.
- Usegpiod_set_value_cansleepto 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.
Quoted 5 lines
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 <[email protected]>
Yours,
Linus Walleij
PATCH v3 7/9 ASoC: codec: cs42l52: Sort headers alphabetically
In reply to Peng Fan (OSS)From: Peng Fan <[email protected]>
Sort headers alphabetically to easily insert new ones and drop unused ones.
--- sound/soc/codecs/cs42l52.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
sound/soc/codecs/cs42l52.c +8 -8
@@ -8,27 +8,27 @@* Author: Brian Austin <[email protected]> */ +#include <linux/delay.h> +#include <linux/i2c.h> +#include <linux/init.h> +#include <linux/input.h> +#include <linux/kernel.h> #include <linux/module.h> #include <linux/moduleparam.h> -#include <linux/kernel.h> -#include <linux/init.h> -#include <linux/delay.h> #include <linux/of_gpio.h> #include <linux/pm.h> -#include <linux/i2c.h> -#include <linux/input.h> +#include <linux/platform_device.h> #include <linux/regmap.h> #include <linux/slab.h> #include <linux/workqueue.h> -#include <linux/platform_device.h> #include <sound/core.h> +#include <sound/cs42l52.h> +#include <sound/initval.h> #include <sound/pcm.h> #include <sound/pcm_params.h> #include <sound/soc.h> #include <sound/soc-dapm.h> -#include <sound/initval.h> #include <sound/tlv.h> -#include <sound/cs42l52.h> #include "cs42l52.h" struct sp_config {
Signature · 1 line
2.37.1
PATCH v3 8/9 ASoC: codec: cs42l52: Drop cs42l52.h
In reply to Peng Fan (OSS)From: Peng Fan <[email protected]>
There is no in-tree user of "include/sound/cs42l52.h", so move 'struct cs42l52_platform_data ' to cs42l52.c and remove the header file. And platform data is mostly for legacy platforms that create devices non using device tree. So drop cs42l52.h to prepare using GPIOD API.
--- include/sound/cs42l52.h | 29 ----------------- sound/soc/codecs/cs42l52.c | 78 +++++++++++++++++++++++++++------------------- 2 files changed, 46 insertions(+), 61 deletions(-)
include/sound/cs42l52.h deleted +0 -29
@@ -1,29 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-only */ -/* -* linux/sound/cs42l52.h -- Platform data for CS42L52 -* -* Copyright (c) 2012 Cirrus Logic Inc. -*/ - -#ifndef __CS42L52_H -#define __CS42L52_H - -struct cs42l52_platform_data { - -/* MICBIAS Level. Check datasheet Pg48 */ -unsigned int micbias_lvl; - -/* MICA mode selection Differential or Single-ended */ -bool mica_diff_cfg; - -/* MICB mode selection Differential or Single-ended */ -bool micb_diff_cfg; - -/* Charge Pump Freq. Check datasheet Pg73 */ -unsigned int chgfreq; - -/* Reset GPIO */ -unsigned int reset_gpio; -}; - -#endif /* __CS42L52_H */
sound/soc/codecs/cs42l52.c +46 -32
104 lines not on this page · raw message
Signature · 1 line
2.37.1
PATCH v3 9/9 ASoC: codec: cs42l52: Convert to GPIO descriptors
In reply to Peng Fan (OSS)From: Peng Fan <[email protected]>
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, the device remains in Power-down state until RESET pin is brought high.
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. And the binding use reset-gpio as example, not same as driver using "cirrus,reset-gpio", and there is no in-tree DTS has the device, so all should be fine with this patch.
--- sound/soc/codecs/cs42l52.c | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-)
sound/soc/codecs/cs42l52.c +12 -16
@@ -9,13 +9,13 @@*/ #include <linux/delay.h> +#include <linux/gpio/consumer.h> #include <linux/i2c.h> #include <linux/init.h> #include <linux/input.h> #include <linux/kernel.h> #include <linux/module.h> #include <linux/moduleparam.h> -#include <linux/of_gpio.h> #include <linux/pm.h> #include <linux/platform_device.h> #include <linux/regmap.h>
@@ -50,7 +50,7 @@ struct cs42l52_platform_data {unsigned int chgfreq;/* Reset GPIO */ -unsigned int reset_gpio; +struct gpio_desc *reset_gpio; };struct cs42l52_private {
@@ -1146,25 +1146,21 @@ static int cs42l52_i2c_probe(struct i2c_client *i2c_client) "cirrus,chgfreq-divisor", &val32) >= 0) pdata->chgfreq = val32; - pdata->reset_gpio = -of_get_named_gpio (i2c_client->dev.of_node, -"cirrus,reset-gpio" ,0 ); + pdata->reset_gpio =devm_gpiod_get_optional (&i2c_client->dev, +"cirrus,reset" , +GPIOD_OUT_LOW ); + +if (IS_ERR (pdata->reset_gpio)) +return PTR_ERR (pdata->reset_gpio); + +gpiod_set_consumer_name (pdata->reset_gpio,"CS42L52 /RST" ); } cs42l52->pdata = *pdata;if (cs42l52->pdata.reset_gpio) { - ret =devm_gpio_request_one (&i2c_client->dev, - cs42l52->pdata.reset_gpio, -GPIOF_OUT_INIT_HIGH , -"CS42L52 /RST" ); -if (ret <0 ) { -dev_err (&i2c_client->dev,"Failed to request /RST %d: %d\n" , - cs42l52->pdata.reset_gpio, ret); -return ret; - } -gpio_set_value_cansleep (cs42l52->pdata.reset_gpio,0 ); -gpio_set_value_cansleep (cs42l52->pdata.reset_gpio,1 ); +gpiod_set_value_cansleep (cs42l52->pdata.reset_gpio,1 ); +gpiod_set_value_cansleep (cs42l52->pdata.reset_gpio,0 ); }i2c_set_clientdata (i2c_client, cs42l52);
Signature · 1 line
2.37.1
Re: [PATCH v3 9/9] ASoC: codec: cs42l52: Convert to GPIO descriptors
Quoted 17 lines · Peng Fan (OSS)
From: Peng Fan <[email protected]>
of_gpio.his deprecated, update the driver to use GPIO descriptors.
- Usedevm_gpiod_get_optionalto get GPIO descriptor with default polarityGPIOD_OUT_LOW, set consumer name.
- Usegpiod_set_value_cansleepto 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, the device remains in Power-down state until RESET pin is brought high.
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.
Quoted 7 lines
Per datasheet, the DTS polarity should be
GPIOD_ACTIVE_LOW. The binding example use value 0(GPIOD_ACTIVE_HIGH) which seems wrong. And the binding use reset-gpio as example, not same as driver using "cirrus,reset-gpio", and there is no in-tree DTS has the device, so all should be fine with this patch.Signed-off-by Peng Fan <[email protected]>
Yours,
Linus Walleij
Mark Brown
maintainerQuoted 6 lines · Peng Fan (OSS)
This patchset is separate from [1], and not merging changes in one patch. So separate changes into three patches for each chip.
- sort headers
- Drop legacy platform support
- Convert to GPIO descriptors
Quoted 6 lines
of_gpio.his deprecated, update the driver to use GPIO descriptors.
- Usedevm_gpiod_get_optionalto get GPIO descriptor with default polarityGPIOD_OUT_LOW, set consumer name.
- Usegpiod_set_value_cansleepto configure output value.[...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
Thanks!
[1/9] ASoC: codec: cs42l56: Sort headers alphabetically
commit: 4060ebdd5063eed98a8f81f78f1e67ffc4ff0942
[2/9] ASoC: codec: cs42l56: Drop cs42l56.h
commit: 86f6e4791c40c33891299d95c055e5d06d396284
[3/9] ASoC: codec: cs42l56: Convert to GPIO descriptors
commit: 0bb92e4736a9dd43e3215b378db5ac63075a3cc1
[4/9] ASoC: codec: cs42l73: Sort headers alphabetically
commit: f3e7298848f0e6c09e4da5fd80bca7cd0c58ccc1
[5/9] ASoC: codec: cs42l73: Drop cs42l73.h
commit: 43ef0dccbc2528924c4b03a902fa39502faabb16
[6/9] ASoC: codec: cs42l73: Convert to GPIO descriptors
commit: b6118100382c9e4c8ca623b3a8e8bf1a09c42aa5
[7/9] ASoC: codec: cs42l52: Sort headers alphabetically
commit: 2d703321b856acdb6589d74906e19aa5cb328d4e
[8/9] ASoC: codec: cs42l52: Drop cs42l52.h
commit: 772c036befb875c904731fb309fb9d2e065ba3f8
[9/9] ASoC: codec: cs42l52: Convert to GPIO descriptors
commit: 5bf5bdfd007e07f2ec5b3e07aa02616f4eebef67All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark