Skip to contentSkip to conversation

Remove ASoC-level I/O functions from cq93vc

PATCH In review Mark Brown 3 participants 10 messages Aug 31, 2013 – Sep 2, 2013 1 message not in the archive

Subsystems (3)
lore
Share & tools
lore

Mark Brown

author maintainer
#0 lore raw

cover Remove ASoC-level I/O functions from cq93vc

This patch series removes the use of the ASoC-level read and write functions from the cq93vc driver as part of a wider push to remove them completely and just use regmap for all register I/O. Since the driver is essentially doing what regmap-mmio is doing this is done by adding a MMIO regmap to the core device and using that. This is compile tested only, I don't have any hardware to run on.

Since I anticipate doing more cleanups over the CODEC drivers during the next release cycle it'd be good to merge via ASoC, though there shouldn't be any overlap with the first patch.

Mark Brown (5):
mfd: davinci_voicecodec: Remove unused read and write functions
mfd: davinci_voicecodec: Provide a regmap for register I/O
ASoC: cq93vc: Use core I/O functions
ASoC: cq93vc: Don't use control data for core driver data
ASoC: cq93vc: Use regmap for I/O

 drivers/mfd/davinci_voicecodec.c       | 23 +++++++++++--------
 include/linux/mfd/davinci_voicecodec.h |  3 +++
 sound/soc/codecs/cq93vc.c              | 42 +++++++++++-----------------------
 3 files changed, 29 insertions(+), 39 deletions(-)
author maintainer
#1 lore raw

PATCH 1/5 mfd: davinci_voicecodec: Remove unused read and write functions

From: Mark Brown <[email protected]>

These functions are not referenced anywhere, nor prototyped, so just remove them.

---
 drivers/mfd/davinci_voicecodec.c | 11 -----------
 1 file changed, 11 deletions(-)
drivers/mfd/davinci_voicecodec.c +0 -11
index fb643985..a292d71 100644
@@ -32,17 +32,6 @@
 
 #include <linux/mfd/davinci_voicecodec.h>
 
-u32 davinci_vc_read(struct davinci_vc *davinci_vc, int reg)
-{
-	return __raw_readl(davinci_vc->base + reg);
-}
-
-void davinci_vc_write(struct davinci_vc *davinci_vc,
-					   int reg, u32 val)
-{
-	__raw_writel(val, davinci_vc->base + reg);
-}
-
 static int __init davinci_vc_probe(struct platform_device *pdev)
 {
 	struct davinci_vc *davinci_vc;
Signature · 1 line
1.8.4.rc3

A message that is not in the archive (sent off-list or not yet received): 1377954539-7532-1-git-send-email-broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org

#3 lore raw

PATCH 3/5 ASoC: cq93vc: Use core I/O functions

From: Mark Brown <[email protected]>

Support future refactoring by using the core I/O functions rather than calling the driver provided I/O functions directly.

---
 sound/soc/codecs/cq93vc.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)
sound/soc/codecs/cq93vc.c +9 -7
index 1ba7588..424e9a4 100644
@@ -64,13 +64,15 @@ static const struct snd_kcontrol_new cq93vc_snd_controls[] = {
 static int cq93vc_mute(struct snd_soc_dai *dai, int mute)
 {
 	struct snd_soc_codec *codec = dai->codec;
-	u8 reg = cq93vc_read(codec, DAVINCI_VC_REG09) & ~DAVINCI_VC_REG09_MUTE;
+	u8 reg;
 
 	if (mute)
-		cq93vc_write(codec, DAVINCI_VC_REG09,
-			     reg | DAVINCI_VC_REG09_MUTE);
+		reg = DAVINCI_VC_REG09_MUTE;
 	else
-		cq93vc_write(codec, DAVINCI_VC_REG09, reg);
+		reg = 0;
+
+	snd_soc_update_bits(codec, DAVINCI_VC_REG09, DAVINCI_VC_REG09_MUTE,
+			    reg);
 
 	return 0;
 }
@@ -97,18 +99,18 @@ static int cq93vc_set_bias_level(struct snd_soc_codec *codec,
 {
 	switch (level) {
 	case SND_SOC_BIAS_ON:
-		cq93vc_write(codec, DAVINCI_VC_REG12,
+		snd_soc_write(codec, DAVINCI_VC_REG12,
 			     DAVINCI_VC_REG12_POWER_ALL_ON);
 		break;
 	case SND_SOC_BIAS_PREPARE:
 		break;
 	case SND_SOC_BIAS_STANDBY:
-		cq93vc_write(codec, DAVINCI_VC_REG12,
+		snd_soc_write(codec, DAVINCI_VC_REG12,
 			     DAVINCI_VC_REG12_POWER_ALL_OFF);
 		break;
 	case SND_SOC_BIAS_OFF:
 		/* force all power off */
-		cq93vc_write(codec, DAVINCI_VC_REG12,
+		snd_soc_write(codec, DAVINCI_VC_REG12,
 			     DAVINCI_VC_REG12_POWER_ALL_OFF);
 		break;
 	}
Signature · 1 line
1.8.4.rc3
#4 lore raw

PATCH 5/5 ASoC: cq93vc: Use regmap for I/O

In reply to a message not in the archive

From: Mark Brown <[email protected]>

Avoid use of the ASoC-specific register I/O functions by converting to use the MMIO regmap provided the core MFD.

---
 sound/soc/codecs/cq93vc.c | 24 +++---------------------
 1 file changed, 3 insertions(+), 21 deletions(-)
sound/soc/codecs/cq93vc.c +3 -21
index 2cbb584..43737a27 100644
@@ -38,24 +38,6 @@
 #include <sound/soc.h>
 #include <sound/initval.h>
 
-static inline unsigned int cq93vc_read(struct snd_soc_codec *codec,
-						unsigned int reg)
-{
-	struct davinci_vc *davinci_vc = codec->control_data;
-
-	return readl(davinci_vc->base + reg);
-}
-
-static inline int cq93vc_write(struct snd_soc_codec *codec, unsigned int reg,
-		       unsigned int value)
-{
-	struct davinci_vc *davinci_vc = codec->control_data;
-
-	writel(value, davinci_vc->base + reg);
-
-	return 0;
-}
-
 static const struct snd_kcontrol_new cq93vc_snd_controls[] = {
 	SOC_SINGLE("PGA Capture Volume", DAVINCI_VC_REG05, 0, 0x03, 0),
 	SOC_SINGLE("Mono DAC Playback Volume", DAVINCI_VC_REG09, 0, 0x3f, 0),
@@ -156,7 +138,9 @@ static int cq93vc_probe(struct snd_soc_codec *codec)
 	struct davinci_vc *davinci_vc = codec->dev->platform_data;
 
 	davinci_vc->cq93vc.codec = codec;
-	codec->control_data = davinci_vc;
+	codec->control_data = davinci_vc->regmap;
+
+	snd_soc_codec_set_cache_io(codec, 32, 32, SND_SOC_REGMAP);
 
 	/* Off, with power on */
 	cq93vc_set_bias_level(codec, SND_SOC_BIAS_STANDBY);
@@ -172,8 +156,6 @@ static int cq93vc_remove(struct snd_soc_codec *codec)
 }
 
 static struct snd_soc_codec_driver soc_codec_dev_cq93vc = {
-	.read = cq93vc_read,
-	.write = cq93vc_write,
 	.set_bias_level = cq93vc_set_bias_level,
 	.probe = cq93vc_probe,
 	.remove = cq93vc_remove,
Signature · 1 line
1.8.4.rc3
author maintainer
#5 lore raw

PATCH 2/5 mfd: davinci_voicecodec: Provide a regmap for register I/O

In reply to Mark Brown

From: Mark Brown <[email protected]>

This will be used to support refactoring of the ASoC CODEC driver to use a regmap.

---
 drivers/mfd/davinci_voicecodec.c       | 14 ++++++++++++++
 include/linux/mfd/davinci_voicecodec.h |  3 +++
 2 files changed, 17 insertions(+)
drivers/mfd/davinci_voicecodec.c +14 -0
index a292d71..013ba81 100644
@@ -27,11 +27,17 @@
 #include <linux/delay.h>
 #include <linux/io.h>
 #include <linux/clk.h>
+#include <linux/regmap.h>
 
 #include <sound/pcm.h>
 
 #include <linux/mfd/davinci_voicecodec.h>
 
+static struct regmap_config davinci_vc_regmap = {
+	.reg_bits = 32,
+	.val_bits = 32,
+};
+
 static int __init davinci_vc_probe(struct platform_device *pdev)
 {
 	struct davinci_vc *davinci_vc;
@@ -63,6 +69,14 @@ static int __init davinci_vc_probe(struct platform_device *pdev)
 		goto fail;
 	}
 
+	davinci_vc->regmap = devm_regmap_init_mmio(&pdev->dev,
+						   davinci_vc->base,
+						   &davinci_vc_regmap);
+	if (IS_ERR(davinci_vc->regmap)) {
+		ret = PTR_ERR(davinci_vc->regmap);
+		goto fail;
+	}
+
 	res = platform_get_resource(pdev, IORESOURCE_DMA, 0);
 	if (!res) {
 		dev_err(&pdev->dev, "no DMA resource\n");
include/linux/mfd/davinci_voicecodec.h +3 -0
index 13a1ee9..5166935 100644
@@ -30,6 +30,8 @@
 
 #include <mach/hardware.h>
 
+struct regmap;
+
 /*
  * Register values.
  */
@@ -113,6 +115,7 @@ struct davinci_vc {
 
 	/* Memory resources */
 	void __iomem *base;
+	struct regmap *regmap;
 
 	/* MFD cells */
 	struct mfd_cell cells[DAVINCI_VC_CELLS];
Signature · 1 line
1.8.4.rc3
author maintainer
#6 lore raw

PATCH 4/5 ASoC: cq93vc: Don't use control data for core driver data

In reply to Mark Brown

From: Mark Brown <[email protected]>

The platform data is being used to obtain the core driver data for the device (which is a bit of an abuse but not the issue at hand) so reference it directly in order to support refactoring to use regmap.

---
 sound/soc/codecs/cq93vc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/codecs/cq93vc.c +1 -1
index 424e9a4..2cbb584 100644
@@ -81,7 +81,7 @@ static int cq93vc_set_dai_sysclk(struct snd_soc_dai *codec_dai,
 				 int clk_id, unsigned int freq, int dir)
 {
 	struct snd_soc_codec *codec = codec_dai->codec;
-	struct davinci_vc *davinci_vc = codec->control_data;
+	struct davinci_vc *davinci_vc = codec->dev->platform_data;
 
 	switch (freq) {
 	case 22579200:
Signature · 1 line
1.8.4.rc3
#7 lore raw
In reply to Mark Brown

Hi Mark,

Quoted 10 lines · Mark Brown

This patch series removes the use of the ASoC-level read and write functions from the cq93vc driver as part of a wider push to remove them completely and just use regmap for all register I/O. Since the driver is essentially doing what regmap-mmio is doing this is done by adding a MMIO regmap to the core device and using that. This is compile tested only, I don't have any hardware to run on.

Since I anticipate doing more cleanups over the CODEC drivers during the next release cycle it'd be good to merge via ASoC, though there shouldn't be any overlap with the first patch.

As I'd prefer to carry the MFD ones (Including the twl6040 one) through mfd-next, I can build a branch for you to pull from. Would that be fine with you ?

Cheers,
Samuel.

Signature · 2 lines
Intel Open Source Technology Centre
http://oss.intel.com/
author maintainer
#8 lore raw
Quoted 3 lines · Samuel Ortiz

As I'd prefer to carry the MFD ones (Including the twl6040 one) through mfd-next, I can build a branch for you to pull from. Would that be fine with you ?

That's fine by me, I just want the patches in ASoC - obviously the branch couldn't be rebased though.

#9 lore raw

Hi Mark,

Quoted 8 lines · Mark Brown
Quoted 3 lines · Samuel Ortiz

As I'd prefer to carry the MFD ones (Including the twl6040 one) through mfd-next, I can build a branch for you to pull from. Would that be fine with you ?

That's fine by me, I just want the patches in ASoC - obviously the branch couldn't be rebased though.

I put a topic/for-asoc branch upstream for you to pull from:

The following changes since commit 5ae90d8e467e625e447000cb4335c4db973b1095:

Linux 3.11-rc3 (2013-07-28 20:53:33 -0700)

are available in the git repository at:

git://git.kernel.org/pub/scm/linux/kernel/git/sameo/mfd-next.git topic/for-asoc

for you to fetch changes up to c6f39257c952bc7da974bf93255936ff2ece2c34:

mfd: twl6040: Use regmap for register cache (2013-09-02 10:30:14
+0200)

----------------------------------------------------------------
Mark Brown (3):
mfd: davinci_voicecodec: Remove unused read and write functions
mfd: davinci_voicecodec: Provide a regmap for register I/O
mfd: twl6040: Use regmap for register cache

 drivers/mfd/davinci_voicecodec.c       |   23 +++++++++++++----------
 drivers/mfd/twl6040.c                  |   43 ++++++++++++++++++++++++++++++-------------
 include/linux/mfd/davinci_voicecodec.h |    3 +++
 include/linux/mfd/twl6040.h            |    1 -
 4 files changed, 46 insertions(+), 24 deletions(-)
Signature · 2 lines
Intel Open Source Technology Centre
http://oss.intel.com/
author maintainer
#10 lore raw
Quoted 1 line · Samuel Ortiz

I put a topic/for-asoc branch upstream for you to pull from:

Great, thanks!