blob: 17c9535956609c0df1a04f631da8f79a25a1e044 [file] [log] [blame]
Barry Songa1533d92010-03-19 14:48:33 +08001/*
2 * AD193X Audio Codec driver supporting AD1936/7/8/9
3 *
4 * Copyright 2010 Analog Devices Inc.
5 *
6 * Licensed under the GPL-2 or later.
7 */
8
Barry Songa1533d92010-03-19 14:48:33 +08009#include <linux/module.h>
10#include <linux/kernel.h>
11#include <linux/device.h>
Lars-Peter Clausen6c3d7132014-02-17 13:16:54 +010012#include <linux/regmap.h>
Stephen Rothwell1b132ea2010-03-29 15:32:18 +110013#include <linux/slab.h>
Barry Songa1533d92010-03-19 14:48:33 +080014#include <sound/core.h>
15#include <sound/pcm.h>
16#include <sound/pcm_params.h>
17#include <sound/initval.h>
18#include <sound/soc.h>
19#include <sound/tlv.h>
Lars-Peter Clausen6c3d7132014-02-17 13:16:54 +010020
Barry Songa1533d92010-03-19 14:48:33 +080021#include "ad193x.h"
22
23/* codec private data */
24struct ad193x_priv {
Lars-Peter Clausen30ab1e72011-09-05 20:46:33 +020025 struct regmap *regmap;
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +000026 int sysclk;
Barry Songa1533d92010-03-19 14:48:33 +080027};
28
Barry Songa1533d92010-03-19 14:48:33 +080029/*
30 * AD193X volume/mute/de-emphasis etc. controls
31 */
Lars-Peter Clausenc4e7a4a2011-11-28 17:28:08 +010032static const char * const ad193x_deemp[] = {"None", "48kHz", "44.1kHz", "32kHz"};
Barry Songa1533d92010-03-19 14:48:33 +080033
Takashi Iwaib6592d82014-02-18 09:55:27 +010034static SOC_ENUM_SINGLE_DECL(ad193x_deemp_enum, AD193X_DAC_CTRL2, 1,
35 ad193x_deemp);
Barry Songa1533d92010-03-19 14:48:33 +080036
Lars-Peter Clausen591c0342011-11-28 17:28:07 +010037static const DECLARE_TLV_DB_MINMAX(adau193x_tlv, -9563, 0);
38
Barry Songa1533d92010-03-19 14:48:33 +080039static const struct snd_kcontrol_new ad193x_snd_controls[] = {
40 /* DAC volume control */
Lars-Peter Clausen591c0342011-11-28 17:28:07 +010041 SOC_DOUBLE_R_TLV("DAC1 Volume", AD193X_DAC_L1_VOL,
42 AD193X_DAC_R1_VOL, 0, 0xFF, 1, adau193x_tlv),
43 SOC_DOUBLE_R_TLV("DAC2 Volume", AD193X_DAC_L2_VOL,
44 AD193X_DAC_R2_VOL, 0, 0xFF, 1, adau193x_tlv),
45 SOC_DOUBLE_R_TLV("DAC3 Volume", AD193X_DAC_L3_VOL,
46 AD193X_DAC_R3_VOL, 0, 0xFF, 1, adau193x_tlv),
47 SOC_DOUBLE_R_TLV("DAC4 Volume", AD193X_DAC_L4_VOL,
48 AD193X_DAC_R4_VOL, 0, 0xFF, 1, adau193x_tlv),
Barry Songa1533d92010-03-19 14:48:33 +080049
50 /* ADC switch control */
51 SOC_DOUBLE("ADC1 Switch", AD193X_ADC_CTRL0, AD193X_ADCL1_MUTE,
52 AD193X_ADCR1_MUTE, 1, 1),
53 SOC_DOUBLE("ADC2 Switch", AD193X_ADC_CTRL0, AD193X_ADCL2_MUTE,
54 AD193X_ADCR2_MUTE, 1, 1),
55
56 /* DAC switch control */
57 SOC_DOUBLE("DAC1 Switch", AD193X_DAC_CHNL_MUTE, AD193X_DACL1_MUTE,
58 AD193X_DACR1_MUTE, 1, 1),
59 SOC_DOUBLE("DAC2 Switch", AD193X_DAC_CHNL_MUTE, AD193X_DACL2_MUTE,
60 AD193X_DACR2_MUTE, 1, 1),
61 SOC_DOUBLE("DAC3 Switch", AD193X_DAC_CHNL_MUTE, AD193X_DACL3_MUTE,
62 AD193X_DACR3_MUTE, 1, 1),
63 SOC_DOUBLE("DAC4 Switch", AD193X_DAC_CHNL_MUTE, AD193X_DACL4_MUTE,
64 AD193X_DACR4_MUTE, 1, 1),
65
66 /* ADC high-pass filter */
67 SOC_SINGLE("ADC High Pass Filter Switch", AD193X_ADC_CTRL0,
68 AD193X_ADC_HIGHPASS_FILTER, 1, 0),
69
70 /* DAC de-emphasis */
71 SOC_ENUM("Playback Deemphasis", ad193x_deemp_enum),
72};
73
74static const struct snd_soc_dapm_widget ad193x_dapm_widgets[] = {
Lars-Peter Clausen1b86a3f2014-11-05 17:19:53 +010075 SND_SOC_DAPM_DAC("DAC", "Playback", SND_SOC_NOPM, 0, 0),
76 SND_SOC_DAPM_PGA("DAC Output", AD193X_DAC_CTRL0, 0, 1, NULL, 0),
Barry Songa1533d92010-03-19 14:48:33 +080077 SND_SOC_DAPM_ADC("ADC", "Capture", SND_SOC_NOPM, 0, 0),
78 SND_SOC_DAPM_SUPPLY("PLL_PWR", AD193X_PLL_CLK_CTRL0, 0, 1, NULL, 0),
79 SND_SOC_DAPM_SUPPLY("ADC_PWR", AD193X_ADC_CTRL0, 0, 1, NULL, 0),
Lars-Peter Clausen0718fd22011-11-28 17:28:10 +010080 SND_SOC_DAPM_SUPPLY("SYSCLK", AD193X_PLL_CLK_CTRL0, 7, 0, NULL, 0),
Lars-Peter Clausen1b86a3f2014-11-05 17:19:53 +010081 SND_SOC_DAPM_VMID("VMID"),
Barry Songa1533d92010-03-19 14:48:33 +080082 SND_SOC_DAPM_OUTPUT("DAC1OUT"),
83 SND_SOC_DAPM_OUTPUT("DAC2OUT"),
84 SND_SOC_DAPM_OUTPUT("DAC3OUT"),
85 SND_SOC_DAPM_OUTPUT("DAC4OUT"),
86 SND_SOC_DAPM_INPUT("ADC1IN"),
87 SND_SOC_DAPM_INPUT("ADC2IN"),
88};
89
90static const struct snd_soc_dapm_route audio_paths[] = {
Lars-Peter Clausen0718fd22011-11-28 17:28:10 +010091 { "DAC", NULL, "SYSCLK" },
Lars-Peter Clausen1b86a3f2014-11-05 17:19:53 +010092 { "DAC Output", NULL, "DAC" },
93 { "DAC Output", NULL, "VMID" },
Lars-Peter Clausen0718fd22011-11-28 17:28:10 +010094 { "ADC", NULL, "SYSCLK" },
Barry Songa1533d92010-03-19 14:48:33 +080095 { "DAC", NULL, "ADC_PWR" },
96 { "ADC", NULL, "ADC_PWR" },
Lars-Peter Clausen1b86a3f2014-11-05 17:19:53 +010097 { "DAC1OUT", NULL, "DAC Output" },
98 { "DAC2OUT", NULL, "DAC Output" },
99 { "DAC3OUT", NULL, "DAC Output" },
100 { "DAC4OUT", NULL, "DAC Output" },
Lars-Peter Clausenb21990b2011-11-28 17:28:09 +0100101 { "ADC", NULL, "ADC1IN" },
102 { "ADC", NULL, "ADC2IN" },
Lars-Peter Clausen0718fd22011-11-28 17:28:10 +0100103 { "SYSCLK", NULL, "PLL_PWR" },
Barry Songa1533d92010-03-19 14:48:33 +0800104};
105
106/*
107 * DAI ops entries
108 */
109
110static int ad193x_mute(struct snd_soc_dai *dai, int mute)
111{
Lars-Peter Clausen34cbe162011-11-28 17:28:12 +0100112 struct ad193x_priv *ad193x = snd_soc_codec_get_drvdata(dai->codec);
Barry Songa1533d92010-03-19 14:48:33 +0800113
Axel Lin54c96cf2011-10-18 06:25:08 +0800114 if (mute)
Lars-Peter Clausen34cbe162011-11-28 17:28:12 +0100115 regmap_update_bits(ad193x->regmap, AD193X_DAC_CTRL2,
Axel Lin54c96cf2011-10-18 06:25:08 +0800116 AD193X_DAC_MASTER_MUTE,
117 AD193X_DAC_MASTER_MUTE);
118 else
Lars-Peter Clausen34cbe162011-11-28 17:28:12 +0100119 regmap_update_bits(ad193x->regmap, AD193X_DAC_CTRL2,
Axel Lin54c96cf2011-10-18 06:25:08 +0800120 AD193X_DAC_MASTER_MUTE, 0);
Barry Songa1533d92010-03-19 14:48:33 +0800121
122 return 0;
123}
124
125static int ad193x_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask,
126 unsigned int rx_mask, int slots, int width)
127{
Lars-Peter Clausen34cbe162011-11-28 17:28:12 +0100128 struct ad193x_priv *ad193x = snd_soc_codec_get_drvdata(dai->codec);
Lars-Peter Clausenb82ca572011-11-28 17:28:11 +0100129 unsigned int channels;
Barry Songa1533d92010-03-19 14:48:33 +0800130
131 switch (slots) {
132 case 2:
Lars-Peter Clausenb82ca572011-11-28 17:28:11 +0100133 channels = AD193X_2_CHANNELS;
Barry Songa1533d92010-03-19 14:48:33 +0800134 break;
135 case 4:
Lars-Peter Clausenb82ca572011-11-28 17:28:11 +0100136 channels = AD193X_4_CHANNELS;
Barry Songa1533d92010-03-19 14:48:33 +0800137 break;
138 case 8:
Lars-Peter Clausenb82ca572011-11-28 17:28:11 +0100139 channels = AD193X_8_CHANNELS;
Barry Songa1533d92010-03-19 14:48:33 +0800140 break;
141 case 16:
Lars-Peter Clausenb82ca572011-11-28 17:28:11 +0100142 channels = AD193X_16_CHANNELS;
Barry Songa1533d92010-03-19 14:48:33 +0800143 break;
144 default:
145 return -EINVAL;
146 }
147
Lars-Peter Clausen34cbe162011-11-28 17:28:12 +0100148 regmap_update_bits(ad193x->regmap, AD193X_DAC_CTRL1,
149 AD193X_DAC_CHAN_MASK, channels << AD193X_DAC_CHAN_SHFT);
150 regmap_update_bits(ad193x->regmap, AD193X_ADC_CTRL2,
151 AD193X_ADC_CHAN_MASK, channels << AD193X_ADC_CHAN_SHFT);
Barry Songa1533d92010-03-19 14:48:33 +0800152
153 return 0;
154}
155
156static int ad193x_set_dai_fmt(struct snd_soc_dai *codec_dai,
157 unsigned int fmt)
158{
Lars-Peter Clausen34cbe162011-11-28 17:28:12 +0100159 struct ad193x_priv *ad193x = snd_soc_codec_get_drvdata(codec_dai->codec);
Lars-Peter Clausenb82ca572011-11-28 17:28:11 +0100160 unsigned int adc_serfmt = 0;
161 unsigned int adc_fmt = 0;
162 unsigned int dac_fmt = 0;
Barry Songa1533d92010-03-19 14:48:33 +0800163
164 /* At present, the driver only support AUX ADC mode(SND_SOC_DAIFMT_I2S
165 * with TDM) and ADC&DAC TDM mode(SND_SOC_DAIFMT_DSP_A)
166 */
167 switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
168 case SND_SOC_DAIFMT_I2S:
Lars-Peter Clausenb82ca572011-11-28 17:28:11 +0100169 adc_serfmt |= AD193X_ADC_SERFMT_TDM;
Barry Songa1533d92010-03-19 14:48:33 +0800170 break;
171 case SND_SOC_DAIFMT_DSP_A:
Lars-Peter Clausenb82ca572011-11-28 17:28:11 +0100172 adc_serfmt |= AD193X_ADC_SERFMT_AUX;
Barry Songa1533d92010-03-19 14:48:33 +0800173 break;
174 default:
175 return -EINVAL;
176 }
177
178 switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
179 case SND_SOC_DAIFMT_NB_NF: /* normal bit clock + frame */
Barry Songa1533d92010-03-19 14:48:33 +0800180 break;
181 case SND_SOC_DAIFMT_NB_IF: /* normal bclk + invert frm */
Lars-Peter Clausenb82ca572011-11-28 17:28:11 +0100182 adc_fmt |= AD193X_ADC_LEFT_HIGH;
183 dac_fmt |= AD193X_DAC_LEFT_HIGH;
Barry Songa1533d92010-03-19 14:48:33 +0800184 break;
185 case SND_SOC_DAIFMT_IB_NF: /* invert bclk + normal frm */
Lars-Peter Clausenb82ca572011-11-28 17:28:11 +0100186 adc_fmt |= AD193X_ADC_BCLK_INV;
187 dac_fmt |= AD193X_DAC_BCLK_INV;
Barry Songa1533d92010-03-19 14:48:33 +0800188 break;
Barry Songa1533d92010-03-19 14:48:33 +0800189 case SND_SOC_DAIFMT_IB_IF: /* invert bclk + frm */
Lars-Peter Clausenb82ca572011-11-28 17:28:11 +0100190 adc_fmt |= AD193X_ADC_LEFT_HIGH;
191 adc_fmt |= AD193X_ADC_BCLK_INV;
192 dac_fmt |= AD193X_DAC_LEFT_HIGH;
193 dac_fmt |= AD193X_DAC_BCLK_INV;
Barry Songa1533d92010-03-19 14:48:33 +0800194 break;
195 default:
196 return -EINVAL;
197 }
198
199 switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
200 case SND_SOC_DAIFMT_CBM_CFM: /* codec clk & frm master */
Lars-Peter Clausenb82ca572011-11-28 17:28:11 +0100201 adc_fmt |= AD193X_ADC_LCR_MASTER;
202 adc_fmt |= AD193X_ADC_BCLK_MASTER;
203 dac_fmt |= AD193X_DAC_LCR_MASTER;
204 dac_fmt |= AD193X_DAC_BCLK_MASTER;
Barry Songa1533d92010-03-19 14:48:33 +0800205 break;
206 case SND_SOC_DAIFMT_CBS_CFM: /* codec clk slave & frm master */
Lars-Peter Clausenb82ca572011-11-28 17:28:11 +0100207 adc_fmt |= AD193X_ADC_LCR_MASTER;
208 dac_fmt |= AD193X_DAC_LCR_MASTER;
Barry Songa1533d92010-03-19 14:48:33 +0800209 break;
210 case SND_SOC_DAIFMT_CBM_CFS: /* codec clk master & frame slave */
Lars-Peter Clausenb82ca572011-11-28 17:28:11 +0100211 adc_fmt |= AD193X_ADC_BCLK_MASTER;
212 dac_fmt |= AD193X_DAC_BCLK_MASTER;
Barry Songa1533d92010-03-19 14:48:33 +0800213 break;
214 case SND_SOC_DAIFMT_CBS_CFS: /* codec clk & frm slave */
Barry Songa1533d92010-03-19 14:48:33 +0800215 break;
216 default:
217 return -EINVAL;
218 }
219
Lars-Peter Clausen34cbe162011-11-28 17:28:12 +0100220 regmap_update_bits(ad193x->regmap, AD193X_ADC_CTRL1,
221 AD193X_ADC_SERFMT_MASK, adc_serfmt);
222 regmap_update_bits(ad193x->regmap, AD193X_ADC_CTRL2,
223 AD193X_ADC_FMT_MASK, adc_fmt);
224 regmap_update_bits(ad193x->regmap, AD193X_DAC_CTRL1,
225 AD193X_DAC_FMT_MASK, dac_fmt);
Barry Songa1533d92010-03-19 14:48:33 +0800226
227 return 0;
228}
229
Barry Songfab90aa2010-05-21 11:57:01 +0800230static int ad193x_set_dai_sysclk(struct snd_soc_dai *codec_dai,
231 int clk_id, unsigned int freq, int dir)
232{
233 struct snd_soc_codec *codec = codec_dai->codec;
234 struct ad193x_priv *ad193x = snd_soc_codec_get_drvdata(codec);
235 switch (freq) {
236 case 12288000:
237 case 18432000:
238 case 24576000:
239 case 36864000:
240 ad193x->sysclk = freq;
241 return 0;
242 }
243 return -EINVAL;
244}
245
Barry Songa1533d92010-03-19 14:48:33 +0800246static int ad193x_hw_params(struct snd_pcm_substream *substream,
247 struct snd_pcm_hw_params *params,
248 struct snd_soc_dai *dai)
249{
Axel Lin54c96cf2011-10-18 06:25:08 +0800250 int word_len = 0, master_rate = 0;
Mark Browne6968a12012-04-04 15:58:16 +0100251 struct snd_soc_codec *codec = dai->codec;
Barry Songfab90aa2010-05-21 11:57:01 +0800252 struct ad193x_priv *ad193x = snd_soc_codec_get_drvdata(codec);
Barry Songa1533d92010-03-19 14:48:33 +0800253
254 /* bit size */
Mark Brownd4dd1fd2014-01-08 18:38:20 +0000255 switch (params_width(params)) {
256 case 16:
Barry Songa1533d92010-03-19 14:48:33 +0800257 word_len = 3;
258 break;
Mark Brownd4dd1fd2014-01-08 18:38:20 +0000259 case 20:
Barry Songa1533d92010-03-19 14:48:33 +0800260 word_len = 1;
261 break;
Mark Brownd4dd1fd2014-01-08 18:38:20 +0000262 case 24:
263 case 32:
Barry Songa1533d92010-03-19 14:48:33 +0800264 word_len = 0;
265 break;
266 }
267
Barry Songfab90aa2010-05-21 11:57:01 +0800268 switch (ad193x->sysclk) {
269 case 12288000:
270 master_rate = AD193X_PLL_INPUT_256;
271 break;
272 case 18432000:
273 master_rate = AD193X_PLL_INPUT_384;
274 break;
275 case 24576000:
276 master_rate = AD193X_PLL_INPUT_512;
277 break;
278 case 36864000:
279 master_rate = AD193X_PLL_INPUT_768;
280 break;
281 }
282
Lars-Peter Clausen34cbe162011-11-28 17:28:12 +0100283 regmap_update_bits(ad193x->regmap, AD193X_PLL_CLK_CTRL0,
Axel Lin54c96cf2011-10-18 06:25:08 +0800284 AD193X_PLL_INPUT_MASK, master_rate);
Barry Songfab90aa2010-05-21 11:57:01 +0800285
Lars-Peter Clausen34cbe162011-11-28 17:28:12 +0100286 regmap_update_bits(ad193x->regmap, AD193X_DAC_CTRL2,
Axel Lin54c96cf2011-10-18 06:25:08 +0800287 AD193X_DAC_WORD_LEN_MASK,
288 word_len << AD193X_DAC_WORD_LEN_SHFT);
Barry Songa1533d92010-03-19 14:48:33 +0800289
Lars-Peter Clausen34cbe162011-11-28 17:28:12 +0100290 regmap_update_bits(ad193x->regmap, AD193X_ADC_CTRL1,
Axel Lin54c96cf2011-10-18 06:25:08 +0800291 AD193X_ADC_WORD_LEN_MASK, word_len);
Barry Songa1533d92010-03-19 14:48:33 +0800292
293 return 0;
294}
295
Lars-Peter Clausen85e76522011-11-23 11:40:40 +0100296static const struct snd_soc_dai_ops ad193x_dai_ops = {
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +0000297 .hw_params = ad193x_hw_params,
298 .digital_mute = ad193x_mute,
299 .set_tdm_slot = ad193x_set_tdm_slot,
300 .set_sysclk = ad193x_set_dai_sysclk,
301 .set_fmt = ad193x_set_dai_fmt,
302};
303
304/* codec DAI instance */
305static struct snd_soc_dai_driver ad193x_dai = {
306 .name = "ad193x-hifi",
307 .playback = {
308 .stream_name = "Playback",
309 .channels_min = 2,
310 .channels_max = 8,
311 .rates = SNDRV_PCM_RATE_48000,
312 .formats = SNDRV_PCM_FMTBIT_S32_LE | SNDRV_PCM_FMTBIT_S16_LE |
313 SNDRV_PCM_FMTBIT_S20_3LE | SNDRV_PCM_FMTBIT_S24_LE,
314 },
315 .capture = {
316 .stream_name = "Capture",
317 .channels_min = 2,
318 .channels_max = 4,
319 .rates = SNDRV_PCM_RATE_48000,
320 .formats = SNDRV_PCM_FMTBIT_S32_LE | SNDRV_PCM_FMTBIT_S16_LE |
321 SNDRV_PCM_FMTBIT_S20_3LE | SNDRV_PCM_FMTBIT_S24_LE,
322 },
323 .ops = &ad193x_dai_ops,
324};
325
Lars-Peter Clausen6c3d7132014-02-17 13:16:54 +0100326static int ad193x_codec_probe(struct snd_soc_codec *codec)
Barry Songa1533d92010-03-19 14:48:33 +0800327{
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +0000328 struct ad193x_priv *ad193x = snd_soc_codec_get_drvdata(codec);
Barry Songa1533d92010-03-19 14:48:33 +0800329
330 /* default setting for ad193x */
331
332 /* unmute dac channels */
Lars-Peter Clausen34cbe162011-11-28 17:28:12 +0100333 regmap_write(ad193x->regmap, AD193X_DAC_CHNL_MUTE, 0x0);
Barry Songa1533d92010-03-19 14:48:33 +0800334 /* de-emphasis: 48kHz, powedown dac */
Lars-Peter Clausen34cbe162011-11-28 17:28:12 +0100335 regmap_write(ad193x->regmap, AD193X_DAC_CTRL2, 0x1A);
Lars-Peter Clausenbdb2c742015-01-12 13:54:13 +0100336 /* dac in tdm mode */
337 regmap_write(ad193x->regmap, AD193X_DAC_CTRL0, 0x40);
Barry Songa1533d92010-03-19 14:48:33 +0800338 /* high-pass filter enable */
Lars-Peter Clausen34cbe162011-11-28 17:28:12 +0100339 regmap_write(ad193x->regmap, AD193X_ADC_CTRL0, 0x3);
Barry Songa1533d92010-03-19 14:48:33 +0800340 /* sata delay=1, adc aux mode */
Lars-Peter Clausen34cbe162011-11-28 17:28:12 +0100341 regmap_write(ad193x->regmap, AD193X_ADC_CTRL1, 0x43);
Barry Songa1533d92010-03-19 14:48:33 +0800342 /* pll input: mclki/xi */
Lars-Peter Clausen34cbe162011-11-28 17:28:12 +0100343 regmap_write(ad193x->regmap, AD193X_PLL_CLK_CTRL0, 0x99); /* mclk=24.576Mhz: 0x9D; mclk=12.288Mhz: 0x99 */
344 regmap_write(ad193x->regmap, AD193X_PLL_CLK_CTRL1, 0x04);
Barry Songa1533d92010-03-19 14:48:33 +0800345
Xiubo Li5d6be5a2014-03-11 12:43:20 +0800346 return 0;
Barry Songa1533d92010-03-19 14:48:33 +0800347}
348
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +0000349static struct snd_soc_codec_driver soc_codec_dev_ad193x = {
Lars-Peter Clausen6c3d7132014-02-17 13:16:54 +0100350 .probe = ad193x_codec_probe,
Lars-Peter Clausenb90d4182011-11-28 17:28:06 +0100351 .controls = ad193x_snd_controls,
352 .num_controls = ARRAY_SIZE(ad193x_snd_controls),
353 .dapm_widgets = ad193x_dapm_widgets,
354 .num_dapm_widgets = ARRAY_SIZE(ad193x_dapm_widgets),
355 .dapm_routes = audio_paths,
356 .num_dapm_routes = ARRAY_SIZE(audio_paths),
Barry Songa1533d92010-03-19 14:48:33 +0800357};
Barry Songa1533d92010-03-19 14:48:33 +0800358
Lars-Peter Clausen34cbe162011-11-28 17:28:12 +0100359static bool adau193x_reg_volatile(struct device *dev, unsigned int reg)
360{
361 return false;
362}
363
Lars-Peter Clausen6c3d7132014-02-17 13:16:54 +0100364const struct regmap_config ad193x_regmap_config = {
Lars-Peter Clausen34cbe162011-11-28 17:28:12 +0100365 .max_register = AD193X_NUM_REGS - 1,
366 .volatile_reg = adau193x_reg_volatile,
Lars-Peter Clausen30ab1e72011-09-05 20:46:33 +0200367};
Lars-Peter Clausen6c3d7132014-02-17 13:16:54 +0100368EXPORT_SYMBOL_GPL(ad193x_regmap_config);
Lars-Peter Clausen30ab1e72011-09-05 20:46:33 +0200369
Lars-Peter Clausen6c3d7132014-02-17 13:16:54 +0100370int ad193x_probe(struct device *dev, struct regmap *regmap)
Barry Songa1533d92010-03-19 14:48:33 +0800371{
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +0000372 struct ad193x_priv *ad193x;
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +0000373
Lars-Peter Clausen6c3d7132014-02-17 13:16:54 +0100374 if (IS_ERR(regmap))
375 return PTR_ERR(regmap);
376
377 ad193x = devm_kzalloc(dev, sizeof(*ad193x), GFP_KERNEL);
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +0000378 if (ad193x == NULL)
379 return -ENOMEM;
380
Lars-Peter Clausen6c3d7132014-02-17 13:16:54 +0100381 ad193x->regmap = regmap;
Lars-Peter Clausen30ab1e72011-09-05 20:46:33 +0200382
Lars-Peter Clausen6c3d7132014-02-17 13:16:54 +0100383 dev_set_drvdata(dev, ad193x);
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +0000384
Lars-Peter Clausen6c3d7132014-02-17 13:16:54 +0100385 return snd_soc_register_codec(dev, &soc_codec_dev_ad193x,
386 &ad193x_dai, 1);
Barry Songa1533d92010-03-19 14:48:33 +0800387}
Lars-Peter Clausen6c3d7132014-02-17 13:16:54 +0100388EXPORT_SYMBOL_GPL(ad193x_probe);
Barry Songa1533d92010-03-19 14:48:33 +0800389
390MODULE_DESCRIPTION("ASoC ad193x driver");
391MODULE_AUTHOR("Barry Song <21cnbao@gmail.com>");
392MODULE_LICENSE("GPL");