Skip to contentSkip to conversation

ASoC: cs42l73: Add platform data support for cs42l73 codec

PATCH Applied Brian Austin 2 participants 8 messages Oct 17, 2013 – Oct 18, 2013

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

PATCH 1/3 ASoC: cs42l73: Add platform data support for cs42l73 codec

Add support for RST GPIO and Charge Pump Freq in platform data

---
 include/sound/cs42l73.h    | 22 ++++++++++++++++++++
 sound/soc/codecs/cs42l73.c | 51 ++++++++++++++++++++++++++++++----------------
 sound/soc/codecs/cs42l73.h |  1 +
 3 files changed, 56 insertions(+), 18 deletions(-)
 create mode 100644 include/sound/cs42l73.h
include/sound/cs42l73.h new file +22 -0
new file mode 100644
index 0000000..f354be4
@@ -0,0 +1,22 @@
+/*
+ * linux/sound/cs42l73.h -- Platform data for CS42L73
+ *
+ * Copyright (c) 2012 Cirrus Logic Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#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 +33 -18

119 lines not on this page · raw message

sound/soc/codecs/cs42l73.h +1 -0
index f30a4c4..4f83d39 100644
@@ -159,6 +159,7 @@
 #define THMOVLD_115C		2
 #define THMOVLD_098C		3
 
+#define CS42L73_CHARGEPUMP_MASK	(0xF0)
 
 /* CS42L73_ASPC, CS42L73_XSPC, CS42L73_VSPC */
 #define	SP_3ST			(1 << 7)
Signature · 1 line
1.8.4.rc3
#1 lore raw

PATCH 2/3 ASoC: cs42l73: Namespace defines for cs42l73 codec

Cleanup to namespace the defines for the cs42l73 driver

---
 sound/soc/codecs/cs42l73.c |  38 ++++++++---------
 sound/soc/codecs/cs42l73.h | 104 ++++++++++++++++++++++-----------------------
 2 files changed, 70 insertions(+), 72 deletions(-)
sound/soc/codecs/cs42l73.c +19 -19
index dfdb715..e3187cc 100644
@@ -1047,11 +1047,11 @@ static int cs42l73_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt)
 
 	switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
 	case SND_SOC_DAIFMT_CBM_CFM:
-		mmcc |= MS_MASTER;
+		mmcc |= CS42L73_MS_MASTER;
 		break;
 
 	case SND_SOC_DAIFMT_CBS_CFS:
-		mmcc &= ~MS_MASTER;
+		mmcc &= ~CS42L73_MS_MASTER;
 		break;
 
 	default:
@@ -1063,11 +1063,11 @@ static int cs42l73_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt)
 
 	switch (format) {
 	case SND_SOC_DAIFMT_I2S:
-		spc &= ~SPDIF_PCM;
+		spc &= ~CS42L73_SPDIF_PCM;
 		break;
 	case SND_SOC_DAIFMT_DSP_A:
 	case SND_SOC_DAIFMT_DSP_B:
-		if (mmcc & MS_MASTER) {
+		if (mmcc & CS42L73_MS_MASTER) {
 			dev_err(codec->dev,
 				"PCM format in slave mode only\n");
 			return -EINVAL;
@@ -1077,25 +1077,25 @@ static int cs42l73_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt)
 				"PCM format is not supported on ASP port\n");
 			return -EINVAL;
 		}
-		spc |= SPDIF_PCM;
+		spc |= CS42L73_SPDIF_PCM;
 		break;
 	default:
 		return -EINVAL;
 	}
 
-	if (spc & SPDIF_PCM) {
+	if (spc & CS42L73_SPDIF_PCM) {
 		/* Clear PCM mode, clear PCM_BIT_ORDER bit for MSB->LSB */
-		spc &= ~(PCM_MODE_MASK | PCM_BIT_ORDER);
+		spc &= ~(CS42L73_PCM_MODE_MASK | CS42L73_PCM_BIT_ORDER);
 		switch (format) {
 		case SND_SOC_DAIFMT_DSP_B:
 			if (inv == SND_SOC_DAIFMT_IB_IF)
-				spc |= PCM_MODE0;
+				spc |= CS42L73_PCM_MODE0;
 			if (inv == SND_SOC_DAIFMT_IB_NF)
-				spc |= PCM_MODE1;
+				spc |= CS42L73_PCM_MODE1;
 		break;
 		case SND_SOC_DAIFMT_DSP_A:
 			if (inv == SND_SOC_DAIFMT_IB_IF)
-				spc |= PCM_MODE1;
+				spc |= CS42L73_PCM_MODE1;
 			break;
 		default:
 			return -EINVAL;
@@ -1155,7 +1155,7 @@ static int cs42l73_pcm_hw_params(struct snd_pcm_substream *substream,
 	int mclk_coeff;
 	int srate = params_rate(params);
 
-	if (priv->config[id].mmcc & MS_MASTER) {
+	if (priv->config[id].mmcc & CS42L73_MS_MASTER) {
 		/* CS42L73 Master */
 		/* MCLK -> srate */
 		mclk_coeff =
@@ -1174,13 +1174,13 @@ static int cs42l73_pcm_hw_params(struct snd_pcm_substream *substream,
 		priv->config[id].spc &= 0xFC;
 		/* Use SCLK=64*Fs if internal MCLK >= 6.4MHz */
 		if (priv->mclk >= 6400000)
-			priv->config[id].spc |= MCK_SCLK_64FS;
+			priv->config[id].spc |= CS42L73_MCK_SCLK_64FS;
 		else
-			priv->config[id].spc |= MCK_SCLK_MCLK;
+			priv->config[id].spc |= CS42L73_MCK_SCLK_MCLK;
 	} else {
 		/* CS42L73 Slave */
 		priv->config[id].spc &= 0xFC;
-		priv->config[id].spc |= MCK_SCLK_64FS;
+		priv->config[id].spc |= CS42L73_MCK_SCLK_64FS;
 	}
 	/* Update ASRCs */
 	priv->config[id].srate = srate;
@@ -1200,8 +1200,8 @@ static int cs42l73_set_bias_level(struct snd_soc_codec *codec,
 
 	switch (level) {
 	case SND_SOC_BIAS_ON:
-		snd_soc_update_bits(codec, CS42L73_DMMCC, MCLKDIS, 0);
-		snd_soc_update_bits(codec, CS42L73_PWRCTL1, PDN, 0);
+		snd_soc_update_bits(codec, CS42L73_DMMCC, CS42L73_MCLKDIS, 0);
+		snd_soc_update_bits(codec, CS42L73_PWRCTL1, CS42L73_PDN, 0);
 		break;
 
 	case SND_SOC_BIAS_PREPARE:
@@ -1212,11 +1212,11 @@ static int cs42l73_set_bias_level(struct snd_soc_codec *codec,
 			regcache_cache_only(cs42l73->regmap, false);
 			regcache_sync(cs42l73->regmap);
 		}
-		snd_soc_update_bits(codec, CS42L73_PWRCTL1, PDN, 1);
+		snd_soc_update_bits(codec, CS42L73_PWRCTL1, CS42L73_PDN, 1);
 		break;
 
 	case SND_SOC_BIAS_OFF:
-		snd_soc_update_bits(codec, CS42L73_PWRCTL1, PDN, 1);
+		snd_soc_update_bits(codec, CS42L73_PWRCTL1, CS42L73_PDN, 1);
 		if (cs42l73->shutdwn_delay > 0) {
 			mdelay(cs42l73->shutdwn_delay);
 			cs42l73->shutdwn_delay = 0;
@@ -1225,7 +1225,7 @@ static int cs42l73_set_bias_level(struct snd_soc_codec *codec,
 				     * down.
 				     */
 		}
-		snd_soc_update_bits(codec, CS42L73_DMMCC, MCLKDIS, 1);
+		snd_soc_update_bits(codec, CS42L73_DMMCC, CS42L73_MCLKDIS, 1);
 		break;
 	}
 	codec->dapm.bias_level = level;
sound/soc/codecs/cs42l73.h +51 -53

139 lines not on this page · raw message

Signature · 1 line
1.8.4.rc3
#2 lore raw

PATCH 3/3 ASoC: cs42l73: Add Device Tree support for CS42L73

In reply to Brian Austin

This patch adds device tree support for the cs42l73 codec. Reset Gpio and Charge Pump Frequency are available

---
 .../devicetree/bindings/sound/cs42l73.txt          | 22 +++++++++++++++
 sound/soc/codecs/cs42l73.c                         | 31 +++++++++++++++++++---
 2 files changed, 50 insertions(+), 3 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/sound/cs42l73.txt
Documentation/devicetree/bindings/sound/cs42l73.txt new file +22 -0
new file mode 100644
index 0000000..5a86495
@@ -0,0 +1,22 @@
+CS42L73 audio CODEC
+
+Required properties:
+
+  - compatible : "cirrus,cs42l73"
+
+  - reg : the I2C address of the device for I2C
+
+Optional properties:
+
+  - reset_gpio : a GPIO spec for the reset pin
+  - chgfreq    : Charge Pump Frequency values 0x00-0x0F
+
+
+Example:
+
+codec: cs42l73@4a {
+	compatible = "cirrus,cs42l73";
+	reg = <0x4a>;
+	reset_gpio = <&gpio 10 0>;
+	chgfreq = <0x05>;
+};
\ No newline at end of file
sound/soc/codecs/cs42l73.c +28 -3
index e3187cc..4607958 100644
@@ -17,7 +17,7 @@
 #include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/delay.h>
-#include <linux/gpio.h>
+#include <linux/of_gpio.h>
 #include <linux/pm.h>
 #include <linux/i2c.h>
 #include <linux/regmap.h>
@@ -1414,6 +1414,7 @@ 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);
 	int ret;
+	u32 val32;
 	unsigned int devid = 0;
 	unsigned int reg;
 
@@ -1431,9 +1432,26 @@ static int cs42l73_i2c_probe(struct i2c_client *i2c_client,
 		return ret;
 	}
 
-	if (pdata)
+	if (pdata) {
 		cs42l73->pdata = *pdata;
-
+	} else {
+		pdata = devm_kzalloc(&i2c_client->dev,
+				     sizeof(struct cs42l73_platform_data),
+				GFP_KERNEL);
+		if (!pdata) {
+			dev_err(&i2c_client->dev, "could not allocate pdata\n");
+			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);
 
 	if ( cs42l73->pdata.reset_gpio) {
@@ -1493,6 +1511,12 @@ static int cs42l73_i2c_remove(struct i2c_client *client)
 	return 0;
 }
 
+static const struct of_device_id cs42l73_of_match[] = {
+	{ .compatible = "cirrus,cs42l73", },
+	{},
+};
+MODULE_DEVICE_TABLE(of, cs42l73_of_match);
+
 static const struct i2c_device_id cs42l73_id[] = {
 	{"cs42l73", 0},
 	{}
@@ -1504,6 +1528,7 @@ static struct i2c_driver cs42l73_i2c_driver = {
 	.driver = {
 		   .name = "cs42l73",
 		   .owner = THIS_MODULE,
+		   .of_match_table = cs42l73_of_match,
 		   },
 	.id_table = cs42l73_id,
 	.probe = cs42l73_i2c_probe,
Signature · 1 line
1.8.4.rc3
maintainer
#3 lore raw

Re: [PATCH 3/3] ASoC: cs42l73: Add Device Tree support for CS42L73

Quoted 2 lines · Brian Austin

This patch adds device tree support for the cs42l73 codec. Reset Gpio and Charge Pump Frequency are available

Actually this doesn't apply for me, some missing dependency perhaps? I didn't check exactly what's conflicting.

#4 lore raw

Re: [PATCH 3/3] ASoC: cs42l73: Add Device Tree support for CS42L73

Quoted 10 lines · Mark Brown
Quoted 4 lines · Brian Austin

This patch adds device tree support for the cs42l73 codec. Reset Gpio and Charge Pump Frequency are available

Actually this doesn't apply for me, some missing dependency perhaps? I didn't check exactly what's conflicting.

Hmmm. I'll check when I get in. I'm pretty sure it's off the for-next but I'll check again.

#5 lore raw

Re: [PATCH 3/3] ASoC: cs42l73: Add Device Tree support for CS42L73

In reply to Mark Brown
Quoted 7 lines · Mark Brown
Quoted 2 lines · Brian Austin

This patch adds device tree support for the cs42l73 codec. Reset Gpio and Charge Pump Frequency are available

Actually this doesn't apply for me, some missing dependency perhaps? I didn't check exactly what's conflicting.

If you apply 0003 before the others it can fail with removal of gpio.h from patch 0002 for of_gpio.h. That's the only problem I can find. If I apply them in series they apply OK. Is that the dependency you see? Is is OK to have a patch dependant on another?

#6 lore raw

Re: [PATCH 3/3] ASoC: cs42l73: Add Device Tree support for CS42L73

Quoted 5 lines
Quoted 3 lines

Actually this doesn't apply for me, some missing dependency perhaps? I didn't check exactly what's conflicting.

If you apply 0003 before the others it can fail with removal of gpio.h from patch 0002 for of_gpio.h. That's the only problem I can find. If I apply them in series they apply OK. Is that the dependency you see? Is is OK to have a patch dependant on another?

It's broke. I'll resubmit v2 for 3/3

maintainer Applied
#7 lore raw
In reply to Brian Austin
Quoted 1 line · Brian Austin

Add support for RST GPIO and Charge Pump Freq in platform data

Applied all, thanks. The DT changes really should have been sent to the DT maintainers and the DT list but it looks like a pretty standard binding so let's not worry.