aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/codecs/ad193x.c
diff options
context:
space:
mode:
authorLars-Peter Clausen <lars@metafoo.de>2011-11-28 11:28:12 -0500
committerMark Brown <broonie@opensource.wolfsonmicro.com>2011-11-28 13:57:52 -0500
commit34cbe16833a1840d6cde592123335fb3ad75b5d4 (patch)
tree809d763b148b32414c6bc2d024b19fd3d4828fdc /sound/soc/codecs/ad193x.c
parentb82ca578fd8b28d9600a077f4e24e22a71383fe8 (diff)
ASoC: ad193x: Convert to direct regmap API usage
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound/soc/codecs/ad193x.c')
-rw-r--r--sound/soc/codecs/ad193x.c61
1 files changed, 36 insertions, 25 deletions
diff --git a/sound/soc/codecs/ad193x.c b/sound/soc/codecs/ad193x.c
index 7d64f2021b06..c1b7d928c347 100644
--- a/sound/soc/codecs/ad193x.c
+++ b/sound/soc/codecs/ad193x.c
@@ -106,14 +106,14 @@ static const struct snd_soc_dapm_route audio_paths[] = {
106 106
107static int ad193x_mute(struct snd_soc_dai *dai, int mute) 107static int ad193x_mute(struct snd_soc_dai *dai, int mute)
108{ 108{
109 struct snd_soc_codec *codec = dai->codec; 109 struct ad193x_priv *ad193x = snd_soc_codec_get_drvdata(dai->codec);
110 110
111 if (mute) 111 if (mute)
112 snd_soc_update_bits(codec, AD193X_DAC_CTRL2, 112 regmap_update_bits(ad193x->regmap, AD193X_DAC_CTRL2,
113 AD193X_DAC_MASTER_MUTE, 113 AD193X_DAC_MASTER_MUTE,
114 AD193X_DAC_MASTER_MUTE); 114 AD193X_DAC_MASTER_MUTE);
115 else 115 else
116 snd_soc_update_bits(codec, AD193X_DAC_CTRL2, 116 regmap_update_bits(ad193x->regmap, AD193X_DAC_CTRL2,
117 AD193X_DAC_MASTER_MUTE, 0); 117 AD193X_DAC_MASTER_MUTE, 0);
118 118
119 return 0; 119 return 0;
@@ -122,7 +122,7 @@ static int ad193x_mute(struct snd_soc_dai *dai, int mute)
122static int ad193x_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, 122static int ad193x_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask,
123 unsigned int rx_mask, int slots, int width) 123 unsigned int rx_mask, int slots, int width)
124{ 124{
125 struct snd_soc_codec *codec = dai->codec; 125 struct ad193x_priv *ad193x = snd_soc_codec_get_drvdata(dai->codec);
126 unsigned int channels; 126 unsigned int channels;
127 127
128 switch (slots) { 128 switch (slots) {
@@ -142,10 +142,10 @@ static int ad193x_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask,
142 return -EINVAL; 142 return -EINVAL;
143 } 143 }
144 144
145 snd_soc_update_bits(codec, AD193X_DAC_CTRL1, AD193X_DAC_CHAN_MASK, 145 regmap_update_bits(ad193x->regmap, AD193X_DAC_CTRL1,
146 channels << AD193X_DAC_CHAN_SHFT); 146 AD193X_DAC_CHAN_MASK, channels << AD193X_DAC_CHAN_SHFT);
147 snd_soc_update_bits(codec, AD193X_ADC_CTRL2, AD193X_ADC_CHAN_MASK, 147 regmap_update_bits(ad193x->regmap, AD193X_ADC_CTRL2,
148 channels << AD193X_ADC_CHAN_SHFT); 148 AD193X_ADC_CHAN_MASK, channels << AD193X_ADC_CHAN_SHFT);
149 149
150 return 0; 150 return 0;
151} 151}
@@ -153,7 +153,7 @@ static int ad193x_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask,
153static int ad193x_set_dai_fmt(struct snd_soc_dai *codec_dai, 153static int ad193x_set_dai_fmt(struct snd_soc_dai *codec_dai,
154 unsigned int fmt) 154 unsigned int fmt)
155{ 155{
156 struct snd_soc_codec *codec = codec_dai->codec; 156 struct ad193x_priv *ad193x = snd_soc_codec_get_drvdata(codec_dai->codec);
157 unsigned int adc_serfmt = 0; 157 unsigned int adc_serfmt = 0;
158 unsigned int adc_fmt = 0; 158 unsigned int adc_fmt = 0;
159 unsigned int dac_fmt = 0; 159 unsigned int dac_fmt = 0;
@@ -214,12 +214,12 @@ static int ad193x_set_dai_fmt(struct snd_soc_dai *codec_dai,
214 return -EINVAL; 214 return -EINVAL;
215 } 215 }
216 216
217 snd_soc_update_bits(codec, AD193X_ADC_CTRL1, AD193X_ADC_SERFMT_MASK, 217 regmap_update_bits(ad193x->regmap, AD193X_ADC_CTRL1,
218 adc_serfmt); 218 AD193X_ADC_SERFMT_MASK, adc_serfmt);
219 snd_soc_update_bits(codec, AD193X_ADC_CTRL2, AD193X_ADC_FMT_MASK, 219 regmap_update_bits(ad193x->regmap, AD193X_ADC_CTRL2,
220 adc_fmt); 220 AD193X_ADC_FMT_MASK, adc_fmt);
221 snd_soc_update_bits(codec, AD193X_DAC_CTRL1, AD193X_DAC_FMT_MASK, 221 regmap_update_bits(ad193x->regmap, AD193X_DAC_CTRL1,
222 dac_fmt); 222 AD193X_DAC_FMT_MASK, dac_fmt);
223 223
224 return 0; 224 return 0;
225} 225}
@@ -279,14 +279,14 @@ static int ad193x_hw_params(struct snd_pcm_substream *substream,
279 break; 279 break;
280 } 280 }
281 281
282 snd_soc_update_bits(codec, AD193X_PLL_CLK_CTRL0, 282 regmap_update_bits(ad193x->regmap, AD193X_PLL_CLK_CTRL0,
283 AD193X_PLL_INPUT_MASK, master_rate); 283 AD193X_PLL_INPUT_MASK, master_rate);
284 284
285 snd_soc_update_bits(codec, AD193X_DAC_CTRL2, 285 regmap_update_bits(ad193x->regmap, AD193X_DAC_CTRL2,
286 AD193X_DAC_WORD_LEN_MASK, 286 AD193X_DAC_WORD_LEN_MASK,
287 word_len << AD193X_DAC_WORD_LEN_SHFT); 287 word_len << AD193X_DAC_WORD_LEN_SHFT);
288 288
289 snd_soc_update_bits(codec, AD193X_ADC_CTRL1, 289 regmap_update_bits(ad193x->regmap, AD193X_ADC_CTRL1,
290 AD193X_ADC_WORD_LEN_MASK, word_len); 290 AD193X_ADC_WORD_LEN_MASK, word_len);
291 291
292 return 0; 292 return 0;
@@ -337,18 +337,18 @@ static int ad193x_probe(struct snd_soc_codec *codec)
337 /* default setting for ad193x */ 337 /* default setting for ad193x */
338 338
339 /* unmute dac channels */ 339 /* unmute dac channels */
340 snd_soc_write(codec, AD193X_DAC_CHNL_MUTE, 0x0); 340 regmap_write(ad193x->regmap, AD193X_DAC_CHNL_MUTE, 0x0);
341 /* de-emphasis: 48kHz, powedown dac */ 341 /* de-emphasis: 48kHz, powedown dac */
342 snd_soc_write(codec, AD193X_DAC_CTRL2, 0x1A); 342 regmap_write(ad193x->regmap, AD193X_DAC_CTRL2, 0x1A);
343 /* powerdown dac, dac in tdm mode */ 343 /* powerdown dac, dac in tdm mode */
344 snd_soc_write(codec, AD193X_DAC_CTRL0, 0x41); 344 regmap_write(ad193x->regmap, AD193X_DAC_CTRL0, 0x41);
345 /* high-pass filter enable */ 345 /* high-pass filter enable */
346 snd_soc_write(codec, AD193X_ADC_CTRL0, 0x3); 346 regmap_write(ad193x->regmap, AD193X_ADC_CTRL0, 0x3);
347 /* sata delay=1, adc aux mode */ 347 /* sata delay=1, adc aux mode */
348 snd_soc_write(codec, AD193X_ADC_CTRL1, 0x43); 348 regmap_write(ad193x->regmap, AD193X_ADC_CTRL1, 0x43);
349 /* pll input: mclki/xi */ 349 /* pll input: mclki/xi */
350 snd_soc_write(codec, AD193X_PLL_CLK_CTRL0, 0x99); /* mclk=24.576Mhz: 0x9D; mclk=12.288Mhz: 0x99 */ 350 regmap_write(ad193x->regmap, AD193X_PLL_CLK_CTRL0, 0x99); /* mclk=24.576Mhz: 0x9D; mclk=12.288Mhz: 0x99 */
351 snd_soc_write(codec, AD193X_PLL_CLK_CTRL1, 0x04); 351 regmap_write(ad193x->regmap, AD193X_PLL_CLK_CTRL1, 0x04);
352 352
353 return ret; 353 return ret;
354} 354}
@@ -363,6 +363,11 @@ static struct snd_soc_codec_driver soc_codec_dev_ad193x = {
363 .num_dapm_routes = ARRAY_SIZE(audio_paths), 363 .num_dapm_routes = ARRAY_SIZE(audio_paths),
364}; 364};
365 365
366static bool adau193x_reg_volatile(struct device *dev, unsigned int reg)
367{
368 return false;
369}
370
366#if defined(CONFIG_SPI_MASTER) 371#if defined(CONFIG_SPI_MASTER)
367 372
368static const struct regmap_config ad193x_spi_regmap_config = { 373static const struct regmap_config ad193x_spi_regmap_config = {
@@ -370,6 +375,9 @@ static const struct regmap_config ad193x_spi_regmap_config = {
370 .reg_bits = 16, 375 .reg_bits = 16,
371 .read_flag_mask = 0x09, 376 .read_flag_mask = 0x09,
372 .write_flag_mask = 0x08, 377 .write_flag_mask = 0x08,
378
379 .max_register = AD193X_NUM_REGS - 1,
380 .volatile_reg = adau193x_reg_volatile,
373}; 381};
374 382
375static int __devinit ad193x_spi_probe(struct spi_device *spi) 383static int __devinit ad193x_spi_probe(struct spi_device *spi)
@@ -429,6 +437,9 @@ static struct spi_driver ad193x_spi_driver = {
429static const struct regmap_config ad193x_i2c_regmap_config = { 437static const struct regmap_config ad193x_i2c_regmap_config = {
430 .val_bits = 8, 438 .val_bits = 8,
431 .reg_bits = 8, 439 .reg_bits = 8,
440
441 .max_register = AD193X_NUM_REGS - 1,
442 .volatile_reg = adau193x_reg_volatile,
432}; 443};
433 444
434static const struct i2c_device_id ad193x_id[] = { 445static const struct i2c_device_id ad193x_id[] = {