diff options
author | Takashi Iwai <tiwai@suse.de> | 2014-10-06 08:01:11 -0400 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2014-10-06 08:01:11 -0400 |
commit | 8df22a4d6f5b81c9c1703579d4907b57002689ed (patch) | |
tree | 064e9662d427a82076e1151fcd9aa78a1066f9f4 /sound/soc/codecs/ab8500-codec.c | |
parent | 0cae90a96c15f2fd3bd139ba5505755c9c9ef2eb (diff) | |
parent | a5448c88b812390a3622e76d774e10c0da1fb970 (diff) |
Merge tag 'asoc-v3.18' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound into for-next
ASoC: Updates for v3.18
- More componentisation work from Lars-Peter, this time mainly
cleaning up the suspend and bias level transition callbacks.
- Real system support for the Intel drivers and a bunch of fixes and
enhancements for the associated CODEC drivers, this is going to need
a lot quirks over time due to the lack of any firmware description of
the boards.
- Jack detect support for simple card from Dylan Reid.
- A bunch of small fixes and enhancements for the Freescale drivers.
- New drivers for Analog Devices SSM4567, Cirrus Logic CS35L32, Everest
Semiconductor ES8328 and Freescale cards using the ASRC in newer i.MX
processors.
Diffstat (limited to 'sound/soc/codecs/ab8500-codec.c')
-rw-r--r-- | sound/soc/codecs/ab8500-codec.c | 73 |
1 files changed, 33 insertions, 40 deletions
diff --git a/sound/soc/codecs/ab8500-codec.c b/sound/soc/codecs/ab8500-codec.c index 1fb4402bf72d..fd43827bb856 100644 --- a/sound/soc/codecs/ab8500-codec.c +++ b/sound/soc/codecs/ab8500-codec.c | |||
@@ -56,8 +56,7 @@ | |||
56 | #define GPIO31_DIR_OUTPUT 0x40 | 56 | #define GPIO31_DIR_OUTPUT 0x40 |
57 | 57 | ||
58 | /* Macrocell register definitions */ | 58 | /* Macrocell register definitions */ |
59 | #define AB8500_CTRL3_REG 0x0200 | 59 | #define AB8500_GPIO_DIR4_REG 0x13 /* Bank AB8500_MISC */ |
60 | #define AB8500_GPIO_DIR4_REG 0x1013 | ||
61 | 60 | ||
62 | /* Nr of FIR/IIR-coeff banks in ANC-block */ | 61 | /* Nr of FIR/IIR-coeff banks in ANC-block */ |
63 | #define AB8500_NR_OF_ANC_COEFF_BANKS 2 | 62 | #define AB8500_NR_OF_ANC_COEFF_BANKS 2 |
@@ -126,6 +125,8 @@ struct ab8500_codec_drvdata_dbg { | |||
126 | 125 | ||
127 | /* Private data for AB8500 device-driver */ | 126 | /* Private data for AB8500 device-driver */ |
128 | struct ab8500_codec_drvdata { | 127 | struct ab8500_codec_drvdata { |
128 | struct regmap *regmap; | ||
129 | |||
129 | /* Sidetone */ | 130 | /* Sidetone */ |
130 | long *sid_fir_values; | 131 | long *sid_fir_values; |
131 | enum sid_state sid_status; | 132 | enum sid_state sid_status; |
@@ -166,49 +167,35 @@ static inline const char *amic_type_str(enum amic_type type) | |||
166 | */ | 167 | */ |
167 | 168 | ||
168 | /* Read a register from the audio-bank of AB8500 */ | 169 | /* Read a register from the audio-bank of AB8500 */ |
169 | static unsigned int ab8500_codec_read_reg(struct snd_soc_codec *codec, | 170 | static int ab8500_codec_read_reg(void *context, unsigned int reg, |
170 | unsigned int reg) | 171 | unsigned int *value) |
171 | { | 172 | { |
173 | struct device *dev = context; | ||
172 | int status; | 174 | int status; |
173 | unsigned int value = 0; | ||
174 | 175 | ||
175 | u8 value8; | 176 | u8 value8; |
176 | status = abx500_get_register_interruptible(codec->dev, AB8500_AUDIO, | 177 | status = abx500_get_register_interruptible(dev, AB8500_AUDIO, |
177 | reg, &value8); | 178 | reg, &value8); |
178 | if (status < 0) { | 179 | *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 | 180 | ||
189 | return value; | 181 | return status; |
190 | } | 182 | } |
191 | 183 | ||
192 | /* Write to a register in the audio-bank of AB8500 */ | 184 | /* Write to a register in the audio-bank of AB8500 */ |
193 | static int ab8500_codec_write_reg(struct snd_soc_codec *codec, | 185 | static int ab8500_codec_write_reg(void *context, unsigned int reg, |
194 | unsigned int reg, unsigned int value) | 186 | unsigned int value) |
195 | { | 187 | { |
196 | int status; | 188 | struct device *dev = context; |
197 | |||
198 | status = abx500_set_register_interruptible(codec->dev, AB8500_AUDIO, | ||
199 | 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 | 189 | ||
209 | return status; | 190 | return abx500_set_register_interruptible(dev, AB8500_AUDIO, |
191 | reg, value); | ||
210 | } | 192 | } |
211 | 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 | |||
212 | /* | 199 | /* |
213 | * Controls - DAPM | 200 | * Controls - DAPM |
214 | */ | 201 | */ |
@@ -1968,16 +1955,16 @@ static int ab8500_audio_setup_mics(struct snd_soc_codec *codec, | |||
1968 | dev_dbg(codec->dev, "%s: Enter.\n", __func__); | 1955 | dev_dbg(codec->dev, "%s: Enter.\n", __func__); |
1969 | 1956 | ||
1970 | /* Set DMic-clocks to outputs */ | 1957 | /* Set DMic-clocks to outputs */ |
1971 | status = abx500_get_register_interruptible(codec->dev, (u8)AB8500_MISC, | 1958 | status = abx500_get_register_interruptible(codec->dev, AB8500_MISC, |
1972 | (u8)AB8500_GPIO_DIR4_REG, | 1959 | AB8500_GPIO_DIR4_REG, |
1973 | &value8); | 1960 | &value8); |
1974 | if (status < 0) | 1961 | if (status < 0) |
1975 | return status; | 1962 | return status; |
1976 | value = value8 | GPIO27_DIR_OUTPUT | GPIO29_DIR_OUTPUT | | 1963 | value = value8 | GPIO27_DIR_OUTPUT | GPIO29_DIR_OUTPUT | |
1977 | GPIO31_DIR_OUTPUT; | 1964 | GPIO31_DIR_OUTPUT; |
1978 | status = abx500_set_register_interruptible(codec->dev, | 1965 | status = abx500_set_register_interruptible(codec->dev, |
1979 | (u8)AB8500_MISC, | 1966 | AB8500_MISC, |
1980 | (u8)AB8500_GPIO_DIR4_REG, | 1967 | AB8500_GPIO_DIR4_REG, |
1981 | value); | 1968 | value); |
1982 | if (status < 0) | 1969 | if (status < 0) |
1983 | return status; | 1970 | return status; |
@@ -2565,9 +2552,6 @@ static int ab8500_codec_probe(struct snd_soc_codec *codec) | |||
2565 | 2552 | ||
2566 | static struct snd_soc_codec_driver ab8500_codec_driver = { | 2553 | static struct snd_soc_codec_driver ab8500_codec_driver = { |
2567 | .probe = ab8500_codec_probe, | 2554 | .probe = ab8500_codec_probe, |
2568 | .read = ab8500_codec_read_reg, | ||
2569 | .write = ab8500_codec_write_reg, | ||
2570 | .reg_word_size = sizeof(u8), | ||
2571 | .controls = ab8500_ctrls, | 2555 | .controls = ab8500_ctrls, |
2572 | .num_controls = ARRAY_SIZE(ab8500_ctrls), | 2556 | .num_controls = ARRAY_SIZE(ab8500_ctrls), |
2573 | .dapm_widgets = ab8500_dapm_widgets, | 2557 | .dapm_widgets = ab8500_dapm_widgets, |
@@ -2592,6 +2576,15 @@ static int ab8500_codec_driver_probe(struct platform_device *pdev) | |||
2592 | drvdata->anc_status = ANC_UNCONFIGURED; | 2576 | drvdata->anc_status = ANC_UNCONFIGURED; |
2593 | dev_set_drvdata(&pdev->dev, drvdata); | 2577 | dev_set_drvdata(&pdev->dev, drvdata); |
2594 | 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 | |||
2595 | dev_dbg(&pdev->dev, "%s: Register codec.\n", __func__); | 2588 | dev_dbg(&pdev->dev, "%s: Register codec.\n", __func__); |
2596 | status = snd_soc_register_codec(&pdev->dev, &ab8500_codec_driver, | 2589 | status = snd_soc_register_codec(&pdev->dev, &ab8500_codec_driver, |
2597 | ab8500_codec_dai, | 2590 | ab8500_codec_dai, |