diff options
author | Lars-Peter Clausen <lars@metafoo.de> | 2014-08-25 04:20:44 -0400 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2014-09-01 12:59:23 -0400 |
commit | ae70b190fce4a09a969dd69d0bd1c33441e24e60 (patch) | |
tree | 383c75f521c0f0187c2dd1e8affe28cca451638f /sound/soc/codecs/ab8500-codec.c | |
parent | 6391fffb7b6099fae0e869229279d147c47f617a (diff) |
ASoC: ab8500-codec: Revert back to regmap
Commit ff795d614bfa ("ASoC: ab8500: Convert register I/O to regmap")
initially converted the ab8500 CODEC driver to use regmap rather than
legacy ASoC IO. This was reverted though in commit 63e6d43bf80d ("ASoC:
ab8500: Revert to using custom I/O functions") since the inital conversion
was not working properly. This was presumebly because the SOC_SINGLE_XR_SX
controls, which are used by this driver, did not properly support regmap at
that point. This has since been fixed in commit 6137a5ca326d ("ASoC: Prepare
SOC_SINGLE_XR_SX controls for regmap"). So revert back to regmap again.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound/soc/codecs/ab8500-codec.c')
-rw-r--r-- | sound/soc/codecs/ab8500-codec.c | 62 |
1 files changed, 28 insertions, 34 deletions
diff --git a/sound/soc/codecs/ab8500-codec.c b/sound/soc/codecs/ab8500-codec.c index 62cf231f34cb..fd43827bb856 100644 --- a/sound/soc/codecs/ab8500-codec.c +++ b/sound/soc/codecs/ab8500-codec.c | |||
@@ -125,6 +125,8 @@ struct ab8500_codec_drvdata_dbg { | |||
125 | 125 | ||
126 | /* Private data for AB8500 device-driver */ | 126 | /* Private data for AB8500 device-driver */ |
127 | struct ab8500_codec_drvdata { | 127 | struct ab8500_codec_drvdata { |
128 | struct regmap *regmap; | ||
129 | |||
128 | /* Sidetone */ | 130 | /* Sidetone */ |
129 | long *sid_fir_values; | 131 | long *sid_fir_values; |
130 | enum sid_state sid_status; | 132 | enum sid_state sid_status; |
@@ -165,49 +167,35 @@ static inline const char *amic_type_str(enum amic_type type) | |||
165 | */ | 167 | */ |
166 | 168 | ||
167 | /* Read a register from the audio-bank of AB8500 */ | 169 | /* Read a register from the audio-bank of AB8500 */ |
168 | static unsigned int ab8500_codec_read_reg(struct snd_soc_codec *codec, | 170 | static int ab8500_codec_read_reg(void *context, unsigned int reg, |
169 | unsigned int reg) | 171 | unsigned int *value) |
170 | { | 172 | { |
173 | struct device *dev = context; | ||
171 | int status; | 174 | int status; |
172 | unsigned int value = 0; | ||
173 | 175 | ||
174 | u8 value8; | 176 | u8 value8; |
175 | status = abx500_get_register_interruptible(codec->dev, AB8500_AUDIO, | 177 | status = abx500_get_register_interruptible(dev, AB8500_AUDIO, |
176 | reg, &value8); | 178 | reg, &value8); |
177 | if (status < 0) { | 179 | *value = (unsigned int)value8; |
178 | dev_err(codec->dev, | ||
179 | "%s: ERROR: Register (0x%02x:0x%02x) read failed (%d).\n", | ||
180 | __func__, (u8)AB8500_AUDIO, (u8)reg, status); | ||
181 | } else { | ||
182 | dev_dbg(codec->dev, | ||
183 | "%s: Read 0x%02x from register 0x%02x:0x%02x\n", | ||
184 | __func__, value8, (u8)AB8500_AUDIO, (u8)reg); | ||
185 | value = (unsigned int)value8; | ||
186 | } | ||
187 | 180 | ||
188 | return value; | 181 | return status; |
189 | } | 182 | } |
190 | 183 | ||
191 | /* Write to a register in the audio-bank of AB8500 */ | 184 | /* Write to a register in the audio-bank of AB8500 */ |
192 | static int ab8500_codec_write_reg(struct snd_soc_codec *codec, | 185 | static int ab8500_codec_write_reg(void *context, unsigned int reg, |
193 | unsigned int reg, unsigned int value) | 186 | unsigned int value) |
194 | { | 187 | { |
195 | int status; | 188 | struct device *dev = context; |
196 | |||
197 | status = abx500_set_register_interruptible(codec->dev, AB8500_AUDIO, | ||
198 | reg, value); | ||
199 | if (status < 0) | ||
200 | dev_err(codec->dev, | ||
201 | "%s: ERROR: Register (%02x:%02x) write failed (%d).\n", | ||
202 | __func__, (u8)AB8500_AUDIO, (u8)reg, status); | ||
203 | else | ||
204 | dev_dbg(codec->dev, | ||
205 | "%s: Wrote 0x%02x into register %02x:%02x\n", | ||
206 | __func__, (u8)value, (u8)AB8500_AUDIO, (u8)reg); | ||
207 | 189 | ||
208 | return status; | 190 | return abx500_set_register_interruptible(dev, AB8500_AUDIO, |
191 | reg, value); | ||
209 | } | 192 | } |
210 | 193 | ||
194 | static const struct regmap_config ab8500_codec_regmap = { | ||
195 | .reg_read = ab8500_codec_read_reg, | ||
196 | .reg_write = ab8500_codec_write_reg, | ||
197 | }; | ||
198 | |||
211 | /* | 199 | /* |
212 | * Controls - DAPM | 200 | * Controls - DAPM |
213 | */ | 201 | */ |
@@ -2564,9 +2552,6 @@ static int ab8500_codec_probe(struct snd_soc_codec *codec) | |||
2564 | 2552 | ||
2565 | static struct snd_soc_codec_driver ab8500_codec_driver = { | 2553 | static struct snd_soc_codec_driver ab8500_codec_driver = { |
2566 | .probe = ab8500_codec_probe, | 2554 | .probe = ab8500_codec_probe, |
2567 | .read = ab8500_codec_read_reg, | ||
2568 | .write = ab8500_codec_write_reg, | ||
2569 | .reg_word_size = sizeof(u8), | ||
2570 | .controls = ab8500_ctrls, | 2555 | .controls = ab8500_ctrls, |
2571 | .num_controls = ARRAY_SIZE(ab8500_ctrls), | 2556 | .num_controls = ARRAY_SIZE(ab8500_ctrls), |
2572 | .dapm_widgets = ab8500_dapm_widgets, | 2557 | .dapm_widgets = ab8500_dapm_widgets, |
@@ -2591,6 +2576,15 @@ static int ab8500_codec_driver_probe(struct platform_device *pdev) | |||
2591 | drvdata->anc_status = ANC_UNCONFIGURED; | 2576 | drvdata->anc_status = ANC_UNCONFIGURED; |
2592 | dev_set_drvdata(&pdev->dev, drvdata); | 2577 | dev_set_drvdata(&pdev->dev, drvdata); |
2593 | 2578 | ||
2579 | drvdata->regmap = devm_regmap_init(&pdev->dev, NULL, &pdev->dev, | ||
2580 | &ab8500_codec_regmap); | ||
2581 | if (IS_ERR(drvdata->regmap)) { | ||
2582 | status = PTR_ERR(drvdata->regmap); | ||
2583 | dev_err(&pdev->dev, "%s: Failed to allocate regmap: %d\n", | ||
2584 | __func__, status); | ||
2585 | return status; | ||
2586 | } | ||
2587 | |||
2594 | dev_dbg(&pdev->dev, "%s: Register codec.\n", __func__); | 2588 | dev_dbg(&pdev->dev, "%s: Register codec.\n", __func__); |
2595 | status = snd_soc_register_codec(&pdev->dev, &ab8500_codec_driver, | 2589 | status = snd_soc_register_codec(&pdev->dev, &ab8500_codec_driver, |
2596 | ab8500_codec_dai, | 2590 | ab8500_codec_dai, |