[alsa-devel] [PATCH 0/5] 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(-)
From: Mark Brown broonie@linaro.org
These functions are not referenced anywhere, nor prototyped, so just remove them.
Signed-off-by: Mark Brown broonie@linaro.org --- drivers/mfd/davinci_voicecodec.c | 11 ----------- 1 file changed, 11 deletions(-)
diff --git a/drivers/mfd/davinci_voicecodec.c b/drivers/mfd/davinci_voicecodec.c index fb643985..a292d71 100644 --- a/drivers/mfd/davinci_voicecodec.c +++ b/drivers/mfd/davinci_voicecodec.c @@ -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;
From: Mark Brown broonie@linaro.org
This will be used to support refactoring of the ASoC CODEC driver to use a regmap.
Signed-off-by: Mark Brown broonie@linaro.org --- drivers/mfd/davinci_voicecodec.c | 14 ++++++++++++++ include/linux/mfd/davinci_voicecodec.h | 3 +++ 2 files changed, 17 insertions(+)
diff --git a/drivers/mfd/davinci_voicecodec.c b/drivers/mfd/davinci_voicecodec.c index a292d71..013ba81 100644 --- a/drivers/mfd/davinci_voicecodec.c +++ b/drivers/mfd/davinci_voicecodec.c @@ -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"); diff --git a/include/linux/mfd/davinci_voicecodec.h b/include/linux/mfd/davinci_voicecodec.h index 13a1ee9..5166935 100644 --- a/include/linux/mfd/davinci_voicecodec.h +++ b/include/linux/mfd/davinci_voicecodec.h @@ -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];
From: Mark Brown broonie@linaro.org
Support future refactoring by using the core I/O functions rather than calling the driver provided I/O functions directly.
Signed-off-by: Mark Brown broonie@linaro.org --- sound/soc/codecs/cq93vc.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/sound/soc/codecs/cq93vc.c b/sound/soc/codecs/cq93vc.c index 1ba7588..424e9a4 100644 --- a/sound/soc/codecs/cq93vc.c +++ b/sound/soc/codecs/cq93vc.c @@ -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; }
From: Mark Brown broonie@linaro.org
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.
Signed-off-by: Mark Brown broonie@linaro.org --- sound/soc/codecs/cq93vc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sound/soc/codecs/cq93vc.c b/sound/soc/codecs/cq93vc.c index 424e9a4..2cbb584 100644 --- a/sound/soc/codecs/cq93vc.c +++ b/sound/soc/codecs/cq93vc.c @@ -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:
From: Mark Brown broonie@linaro.org
Avoid use of the ASoC-specific register I/O functions by converting to use the MMIO regmap provided the core MFD.
Signed-off-by: Mark Brown broonie@linaro.org --- sound/soc/codecs/cq93vc.c | 24 +++--------------------- 1 file changed, 3 insertions(+), 21 deletions(-)
diff --git a/sound/soc/codecs/cq93vc.c b/sound/soc/codecs/cq93vc.c index 2cbb584..43737a27 100644 --- a/sound/soc/codecs/cq93vc.c +++ b/sound/soc/codecs/cq93vc.c @@ -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,
Hi Mark,
On Sat, Aug 31, 2013 at 02:07:41PM +0100, Mark Brown wrote:
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.
On Sun, Sep 01, 2013 at 04:48:47PM +0200, Samuel Ortiz wrote:
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.
Hi Mark,
On Sun, Sep 01, 2013 at 04:08:53PM +0100, Mark Brown wrote:
On Sun, Sep 01, 2013 at 04:48:47PM +0200, Samuel Ortiz wrote:
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(-)
participants (2)
-
Mark Brown
-
Samuel Ortiz