aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Brown <broonie@linaro.org>2013-09-20 05:38:16 -0400
committerMark Brown <broonie@linaro.org>2013-09-20 12:42:53 -0400
commitff795d614bfa62a3c6fc0bcb75cb8842e5a87892 (patch)
treed3746d997d76ea81907ce2f03a4f625837181cdd
parent51f20e4cd83e804fb4fd940873763f29616f12a8 (diff)
ASoC: ab8500: Convert register I/O to regmap
As part of a general push to eliminate the duplicated register I/O support in ASoC convert ab8500 to use regmap. Signed-off-by: Mark Brown <broonie@linaro.org> Acked-by: Lee Jones <lee.jones@linaro.org>
-rw-r--r--sound/soc/codecs/ab8500-codec.c64
1 files changed, 30 insertions, 34 deletions
diff --git a/sound/soc/codecs/ab8500-codec.c b/sound/soc/codecs/ab8500-codec.c
index c2b663696611..d5a0fc4b2fe2 100644
--- a/sound/soc/codecs/ab8500-codec.c
+++ b/sound/soc/codecs/ab8500-codec.c
@@ -126,6 +126,8 @@ struct ab8500_codec_drvdata_dbg {
126 126
127/* Private data for AB8500 device-driver */ 127/* Private data for AB8500 device-driver */
128struct ab8500_codec_drvdata { 128struct ab8500_codec_drvdata {
129 struct regmap *regmap;
130
129 /* Sidetone */ 131 /* Sidetone */
130 long *sid_fir_values; 132 long *sid_fir_values;
131 enum sid_state sid_status; 133 enum sid_state sid_status;
@@ -166,49 +168,35 @@ static inline const char *amic_type_str(enum amic_type type)
166 */ 168 */
167 169
168/* Read a register from the audio-bank of AB8500 */ 170/* Read a register from the audio-bank of AB8500 */
169static unsigned int ab8500_codec_read_reg(struct snd_soc_codec *codec, 171static int ab8500_codec_read_reg(void *context, unsigned int reg,
170 unsigned int reg) 172 unsigned int *value)
171{ 173{
174 struct device *dev = context;
172 int status; 175 int status;
173 unsigned int value = 0;
174 176
175 u8 value8; 177 u8 value8;
176 status = abx500_get_register_interruptible(codec->dev, AB8500_AUDIO, 178 status = abx500_get_register_interruptible(dev, AB8500_AUDIO,
177 reg, &value8); 179 reg, &value8);
178 if (status < 0) { 180 *value = (unsigned int)value8;
179 dev_err(codec->dev,
180 "%s: ERROR: Register (0x%02x:0x%02x) read failed (%d).\n",
181 __func__, (u8)AB8500_AUDIO, (u8)reg, status);
182 } else {
183 dev_dbg(codec->dev,
184 "%s: Read 0x%02x from register 0x%02x:0x%02x\n",
185 __func__, value8, (u8)AB8500_AUDIO, (u8)reg);
186 value = (unsigned int)value8;
187 }
188 181
189 return value; 182 return status;
190} 183}
191 184
192/* Write to a register in the audio-bank of AB8500 */ 185/* Write to a register in the audio-bank of AB8500 */
193static int ab8500_codec_write_reg(struct snd_soc_codec *codec, 186static int ab8500_codec_write_reg(void *context, unsigned int reg,
194 unsigned int reg, unsigned int value) 187 unsigned int value)
195{ 188{
196 int status; 189 struct device *dev = context;
197 190
198 status = abx500_set_register_interruptible(codec->dev, AB8500_AUDIO, 191 return abx500_set_register_interruptible(dev, AB8500_AUDIO,
199 reg, value); 192 reg, value);
200 if (status < 0)
201 dev_err(codec->dev,
202 "%s: ERROR: Register (%02x:%02x) write failed (%d).\n",
203 __func__, (u8)AB8500_AUDIO, (u8)reg, status);
204 else
205 dev_dbg(codec->dev,
206 "%s: Wrote 0x%02x into register %02x:%02x\n",
207 __func__, (u8)value, (u8)AB8500_AUDIO, (u8)reg);
208
209 return status;
210} 193}
211 194
195static const struct regmap_config ab8500_codec_regmap = {
196 .reg_read = ab8500_codec_read_reg,
197 .reg_write = ab8500_codec_write_reg,
198};
199
212/* 200/*
213 * Controls - DAPM 201 * Controls - DAPM
214 */ 202 */
@@ -2483,6 +2471,8 @@ static int ab8500_codec_probe(struct snd_soc_codec *codec)
2483 /* Setup AB8500 according to board-settings */ 2471 /* Setup AB8500 according to board-settings */
2484 pdata = dev_get_platdata(dev->parent); 2472 pdata = dev_get_platdata(dev->parent);
2485 2473
2474 codec->control_data = drvdata->regmap;
2475
2486 if (np) { 2476 if (np) {
2487 if (!pdata) 2477 if (!pdata)
2488 pdata = devm_kzalloc(dev, 2478 pdata = devm_kzalloc(dev,
@@ -2560,9 +2550,6 @@ static int ab8500_codec_probe(struct snd_soc_codec *codec)
2560 2550
2561static struct snd_soc_codec_driver ab8500_codec_driver = { 2551static struct snd_soc_codec_driver ab8500_codec_driver = {
2562 .probe = ab8500_codec_probe, 2552 .probe = ab8500_codec_probe,
2563 .read = ab8500_codec_read_reg,
2564 .write = ab8500_codec_write_reg,
2565 .reg_word_size = sizeof(u8),
2566 .controls = ab8500_ctrls, 2553 .controls = ab8500_ctrls,
2567 .num_controls = ARRAY_SIZE(ab8500_ctrls), 2554 .num_controls = ARRAY_SIZE(ab8500_ctrls),
2568 .dapm_widgets = ab8500_dapm_widgets, 2555 .dapm_widgets = ab8500_dapm_widgets,
@@ -2585,6 +2572,15 @@ static int ab8500_codec_driver_probe(struct platform_device *pdev)
2585 drvdata->anc_status = ANC_UNCONFIGURED; 2572 drvdata->anc_status = ANC_UNCONFIGURED;
2586 dev_set_drvdata(&pdev->dev, drvdata); 2573 dev_set_drvdata(&pdev->dev, drvdata);
2587 2574
2575 drvdata->regmap = devm_regmap_init(&pdev->dev, NULL, &pdev->dev,
2576 &ab8500_codec_regmap);
2577 if (IS_ERR(drvdata->regmap)) {
2578 status = PTR_ERR(drvdata->regmap);
2579 dev_err(&pdev->dev, "%s: Failed to allocate regmap: %d\n",
2580 __func__, status);
2581 return status;
2582 }
2583
2588 dev_dbg(&pdev->dev, "%s: Register codec.\n", __func__); 2584 dev_dbg(&pdev->dev, "%s: Register codec.\n", __func__);
2589 status = snd_soc_register_codec(&pdev->dev, &ab8500_codec_driver, 2585 status = snd_soc_register_codec(&pdev->dev, &ab8500_codec_driver,
2590 ab8500_codec_dai, 2586 ab8500_codec_dai,