Skip to contentSkip to conversation

ASoC: codec: cs42l[56,73,52]: Convert to GPIO descriptors

PATCH In review Peng Fan (OSS) 3 participants 15 messages May 6, 2025 – May 13, 2025

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

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]>
#1 lore raw

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
index aaf90c8b7339dc7d9fa469048a56f38dca1797cd..0201206518cd9ea8ecfb823a96fb59cae37c36f4 100644
@@ -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
#2 lore raw

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
deleted file mode 100644
index 62e9f7a3b414f6d1bcb651b22f7f8bd1f29b0eb3..0000000000000000000000000000000000000000
@@ -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
#3 lore raw

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
index 9c58d4f08692871c5baf2702c73367287735cf24..98fa812bc07b87fae717d601561d4ab3b9ee6bdd 100644
@@ -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
#4 lore raw

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.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.

Reviewed-by on v3 3/9
#5 lore raw

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.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.

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.

Yours,
Linus Walleij

#6 lore raw

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
index ddf36001100eef29f74f4d99420511f620f1948d..556270befa941a69e17b47a15677e1c4f912b14f 100644
@@ -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
#7 lore raw

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
deleted file mode 100644
index 5a93393b6124f746bfb7bf5076e4bd1f458019d2..0000000000000000000000000000000000000000
@@ -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
index 556270befa941a69e17b47a15677e1c4f912b14f..c09c23487d2e73340b8947ed0e1ffadb24414e7c 100644
@@ -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
#8 lore raw

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
index c09c23487d2e73340b8947ed0e1ffadb24414e7c..535a867f9f2a6d32986190c4302dfeb1e9f06913 100644
@@ -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
Reviewed-by on v3 6/9
#9 lore raw

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.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.

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.

Yours,
Linus Walleij

#10 lore raw

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
index cd3f92c19045ad32f1f0f0f1764390640d68eb10..ba2ccc818ba6cc1b5fbcfb38e07e9bc8f68c4a6e 100644
@@ -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
#11 lore raw

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
deleted file mode 100644
index c20649666abe5dcbbf628f6c2d1692d3e7190eeb..0000000000000000000000000000000000000000
@@ -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
#12 lore raw

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
index aa8c001cce099e3c1dfc979678fe8000caed097f..a9ffba62aaf88c55a715d83609382d6fc5cfaa8d 100644
@@ -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
Reviewed-by on v3 9/9
#13 lore raw

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.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.

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.

Yours,
Linus Walleij

maintainer
#14 lore raw
In reply to Peng Fan (OSS)
Quoted 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.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.

[...]

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: 5bf5bdfd007e07f2ec5b3e07aa02616f4eebef67

All 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