mxs: add 3.18 support
[openwrt/svn-archive/archive.git] / target / linux / mxs / patches-3.18 / 001-soc-audio-support.patch
1 From ef05a3ce8340c7156610b173324ab793b06e0ae2 Mon Sep 17 00:00:00 2001
2 From: Michal Ulianko <info@itserve.cz>
3 Date: Mon, 29 Jul 2013 20:14:38 +0200
4 Subject: [PATCH 1/2] Added ASoC driver for i.MX233's builtin ADC/DAC codec.
5
6 ---
7 sound/soc/codecs/Kconfig | 4 +
8 sound/soc/codecs/Makefile | 2 +
9 sound/soc/codecs/mxs-builtin-codec.c | 1128 ++++++++++++++++++++++++++++++++++
10 sound/soc/codecs/mxs-builtin-codec.h | 825 +++++++++++++++++++++++++
11 sound/soc/mxs/Kconfig | 10 +
12 sound/soc/mxs/Makefile | 9 +
13 sound/soc/mxs/mxs-builtin-audio.c | 120 ++++
14 sound/soc/mxs/mxs-builtin-dai.c | 588 ++++++++++++++++++
15 sound/soc/mxs/mxs-builtin-pcm.c | 69 +++
16 sound/soc/mxs/mxs-builtin-pcm.h | 25 +
17 10 files changed, 2780 insertions(+)
18 create mode 100644 sound/soc/codecs/mxs-builtin-codec.c
19 create mode 100644 sound/soc/codecs/mxs-builtin-codec.h
20 create mode 100644 sound/soc/mxs/mxs-builtin-audio.c
21 create mode 100644 sound/soc/mxs/mxs-builtin-dai.c
22 create mode 100644 sound/soc/mxs/mxs-builtin-pcm.c
23 create mode 100644 sound/soc/mxs/mxs-builtin-pcm.h
24
25 diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig
26 index badb6fb..dc1f4ac 100644
27 --- a/sound/soc/codecs/Kconfig
28 +++ b/sound/soc/codecs/Kconfig
29 @@ -127,6 +127,7 @@ config SND_SOC_ALL_CODECS
30 select SND_SOC_WM9705 if SND_SOC_AC97_BUS
31 select SND_SOC_WM9712 if SND_SOC_AC97_BUS
32 select SND_SOC_WM9713 if SND_SOC_AC97_BUS
33 + select SND_SOC_MXS_BUILTIN_CODEC
34 help
35 Normally ASoC codec drivers are only built if a machine driver which
36 uses them is also built since they are only usable with a machine
37 @@ -515,6 +516,9 @@ config SND_SOC_WM9712
38 config SND_SOC_WM9713
39 tristate
40
41 +config SND_SOC_MXS_BUILTIN_CODEC
42 + tristate
43 +
44 # Amp
45 config SND_SOC_LM4857
46 tristate
47 diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile
48 index 70fd806..9c3b73a 100644
49 --- a/sound/soc/codecs/Makefile
50 +++ b/sound/soc/codecs/Makefile
51 @@ -120,6 +120,7 @@ snd-soc-wm9705-objs := wm9705.o
52 snd-soc-wm9712-objs := wm9712.o
53 snd-soc-wm9713-objs := wm9713.o
54 snd-soc-wm-hubs-objs := wm_hubs.o
55 +snd-soc-mxs-builtin-codec-objs := mxs-builtin-codec.o
56
57 # Amp
58 snd-soc-max9877-objs := max9877.o
59 @@ -246,6 +247,7 @@ obj-$(CONFIG_SND_SOC_WM9712) += snd-soc-wm9712.o
60 obj-$(CONFIG_SND_SOC_WM9713) += snd-soc-wm9713.o
61 obj-$(CONFIG_SND_SOC_WM_ADSP) += snd-soc-wm-adsp.o
62 obj-$(CONFIG_SND_SOC_WM_HUBS) += snd-soc-wm-hubs.o
63 +obj-$(CONFIG_SND_SOC_MXS_BUILTIN_CODEC) += snd-soc-mxs-builtin-codec.o
64
65 # Amp
66 obj-$(CONFIG_SND_SOC_MAX9877) += snd-soc-max9877.o
67 diff --git a/sound/soc/codecs/mxs-builtin-codec.c b/sound/soc/codecs/mxs-builtin-codec.c
68 new file mode 100644
69 index 0000000..e5dcb4e
70 --- /dev/null
71 +++ b/sound/soc/codecs/mxs-builtin-codec.c
72 @@ -0,0 +1,1128 @@
73 +/*
74 + * mxs-builtin-codec.c -- i.MX233 built-in codec ALSA Soc Audio driver
75 + *
76 + * Author: Michal Ulianko <michal.ulianko@gmail.com>
77 + *
78 + * Based on sound/soc/codecs/mxs-adc-codec.c for kernel 2.6.35
79 + * by Vladislav Buzov <vbuzov@embeddedalley.com>
80 + *
81 + * This program is free software; you can redistribute it and/or modify
82 + * it under the terms of the GNU General Public License version 2 as
83 + * published by the Free Software Foundation.
84 + */
85 +
86 +#include <linux/clk.h>
87 +#include <linux/delay.h>
88 +#include <linux/module.h>
89 +#include <linux/platform_device.h>
90 +#include <sound/pcm.h>
91 +#include <sound/pcm_params.h>
92 +#include <sound/soc.h>
93 +
94 +#include "mxs-builtin-codec.h"
95 +
96 +#ifndef BF
97 +#define BF(value, field) (((value) << BP_##field) & BM_##field)
98 +#endif
99 +
100 +/* TODO Delete this and use BM_RTC_PERSISTENT0_RELEASE_GND from header file
101 + * if it works. */
102 +#define BP_RTC_PERSISTENT0_SPARE_ANALOG 18
103 +#define BM_RTC_PERSISTENT0_SPARE_ANALOG 0xFFFC0000
104 +#define BM_RTC_PERSISTENT0_RELEASE_GND BF(0x2, RTC_PERSISTENT0_SPARE_ANALOG)
105 +
106 +/* TODO Use codec IO function soc snd write etc, instead of __writel __readl */
107 +
108 +struct mxs_adc_priv {
109 + void __iomem *ain_base;
110 + void __iomem *aout_base;
111 + void __iomem *rtc_base;
112 + struct clk *clk;
113 +};
114 +
115 +static unsigned int mxs_regmap[] = {
116 + HW_AUDIOOUT_CTRL,
117 + HW_AUDIOOUT_STAT,
118 + HW_AUDIOOUT_DACSRR,
119 + HW_AUDIOOUT_DACVOLUME,
120 + HW_AUDIOOUT_DACDEBUG,
121 + HW_AUDIOOUT_HPVOL,
122 + HW_AUDIOOUT_PWRDN,
123 + HW_AUDIOOUT_REFCTRL,
124 + HW_AUDIOOUT_ANACTRL,
125 + HW_AUDIOOUT_TEST,
126 + HW_AUDIOOUT_BISTCTRL,
127 + HW_AUDIOOUT_BISTSTAT0,
128 + HW_AUDIOOUT_BISTSTAT1,
129 + HW_AUDIOOUT_ANACLKCTRL,
130 + HW_AUDIOOUT_DATA,
131 + HW_AUDIOOUT_SPEAKERCTRL,
132 + HW_AUDIOOUT_VERSION,
133 + HW_AUDIOIN_CTRL,
134 + HW_AUDIOIN_STAT,
135 + HW_AUDIOIN_ADCSRR,
136 + HW_AUDIOIN_ADCVOLUME,
137 + HW_AUDIOIN_ADCDEBUG,
138 + HW_AUDIOIN_ADCVOL,
139 + HW_AUDIOIN_MICLINE,
140 + HW_AUDIOIN_ANACLKCTRL,
141 + HW_AUDIOIN_DATA,
142 +};
143 +
144 +static void __iomem *mxs_getreg(struct mxs_adc_priv *mxs_adc, int i)
145 +{
146 + if (i <= 16)
147 + return mxs_adc->aout_base + mxs_regmap[i];
148 + else if (i < ADC_REGNUM)
149 + return mxs_adc->ain_base + mxs_regmap[i];
150 + else
151 + return NULL;
152 +}
153 +
154 +static u8 dac_volumn_control_word[] = {
155 + 0x37, 0x5e, 0x7e, 0x8e,
156 + 0x9e, 0xae, 0xb6, 0xbe,
157 + 0xc6, 0xce, 0xd6, 0xde,
158 + 0xe6, 0xee, 0xf6, 0xfe,
159 +};
160 +
161 +struct dac_srr {
162 + u32 rate;
163 + u32 basemult;
164 + u32 src_hold;
165 + u32 src_int;
166 + u32 src_frac;
167 +};
168 +
169 +static struct dac_srr srr_values[] = {
170 + {192000, 0x4, 0x0, 0x0F, 0x13FF},
171 + {176400, 0x4, 0x0, 0x11, 0x0037},
172 + {128000, 0x4, 0x0, 0x17, 0x0E00},
173 + {96000, 0x2, 0x0, 0x0F, 0x13FF},
174 + {88200, 0x2, 0x0, 0x11, 0x0037},
175 + {64000, 0x2, 0x0, 0x17, 0x0E00},
176 + {48000, 0x1, 0x0, 0x0F, 0x13FF},
177 + {44100, 0x1, 0x0, 0x11, 0x0037},
178 + {32000, 0x1, 0x0, 0x17, 0x0E00},
179 + {24000, 0x1, 0x1, 0x0F, 0x13FF},
180 + {22050, 0x1, 0x1, 0x11, 0x0037},
181 + {16000, 0x1, 0x1, 0x17, 0x0E00},
182 + {12000, 0x1, 0x3, 0x0F, 0x13FF},
183 + {11025, 0x1, 0x3, 0x11, 0x0037},
184 + {8000, 0x1, 0x3, 0x17, 0x0E00}
185 +};
186 +
187 +static inline int get_srr_values(int rate)
188 +{
189 + int i;
190 +
191 + for (i = 0; i < ARRAY_SIZE(srr_values); i++)
192 + if (srr_values[i].rate == rate)
193 + return i;
194 +
195 + return -1;
196 +}
197 +
198 +/* SoC IO functions */
199 +static void mxs_codec_write_cache(struct snd_soc_codec *codec, unsigned int reg, unsigned int value)
200 +{
201 + u16 *cache = codec->reg_cache;
202 + if (reg < ADC_REGNUM)
203 + cache[reg] = value;
204 +}
205 +
206 +static int mxs_codec_write(struct snd_soc_codec *codec, unsigned int reg, unsigned int value)
207 +{
208 + struct mxs_adc_priv *mxs_adc = snd_soc_codec_get_drvdata(codec);
209 + unsigned int reg_val;
210 + unsigned int mask = 0xffff;
211 +
212 + if (reg >= ADC_REGNUM)
213 + return -EIO;
214 +
215 + mxs_codec_write_cache(codec, reg, value);
216 +
217 + if (reg & 0x1) {
218 + mask <<= 16;
219 + value <<= 16;
220 + }
221 +
222 + reg_val = __raw_readl(mxs_getreg(mxs_adc, reg >> 1));
223 + reg_val = (reg_val & ~mask) | value;
224 + __raw_writel(reg_val, mxs_getreg(mxs_adc, reg >> 1));
225 +
226 + return 0;
227 +}
228 +
229 +static unsigned int mxs_codec_read(struct snd_soc_codec *codec, unsigned int reg)
230 +{
231 + struct mxs_adc_priv *mxs_adc = snd_soc_codec_get_drvdata(codec);
232 + unsigned int reg_val;
233 +
234 + if (reg >= ADC_REGNUM)
235 + return -1;
236 +
237 + reg_val = __raw_readl(mxs_getreg(mxs_adc, reg >> 1));
238 + if (reg & 1)
239 + reg_val >>= 16;
240 +
241 + return reg_val & 0xffff;
242 +}
243 +
244 +// static unsigned int mxs_codec_read_cache(struct snd_soc_codec *codec, unsigned int reg)
245 +// {
246 +// u16 *cache = codec->reg_cache;
247 +// if (reg >= ADC_REGNUM)
248 +// return -EINVAL;
249 +// return cache[reg];
250 +// }
251 +
252 +static void mxs_codec_sync_reg_cache(struct snd_soc_codec *codec)
253 +{
254 + int reg;
255 + for (reg = 0; reg < ADC_REGNUM; reg += 1)
256 + mxs_codec_write_cache(codec, reg,
257 + mxs_codec_read(codec, reg));
258 +}
259 +
260 +// static int mxs_codec_restore_reg(struct snd_soc_codec *codec, unsigned int reg)
261 +// {
262 +// unsigned int cached_val, hw_val;
263 +//
264 +// cached_val = mxs_codec_read_cache(codec, reg);
265 +// hw_val = mxs_codec_read(codec, reg);
266 +//
267 +// if (hw_val != cached_val)
268 +// return mxs_codec_write(codec, reg, cached_val);
269 +//
270 +// return 0;
271 +// }
272 +/* END SoC IO functions */
273 +
274 +/* Codec routines */
275 +#define VAG_BASE_VALUE ((1400/2 - 625)/25)
276 +
277 +static void mxs_codec_dac_set_vag(struct mxs_adc_priv *mxs_adc)
278 +{
279 + u32 refctrl_val = __raw_readl(mxs_adc->aout_base + HW_AUDIOOUT_REFCTRL);
280 +
281 + refctrl_val &= ~(BM_AUDIOOUT_REFCTRL_VAG_VAL);
282 + refctrl_val &= ~(BM_AUDIOOUT_REFCTRL_VBG_ADJ);
283 + refctrl_val |= BF(VAG_BASE_VALUE, AUDIOOUT_REFCTRL_VAG_VAL) |
284 + BM_AUDIOOUT_REFCTRL_ADJ_VAG |
285 + BF(0xF, AUDIOOUT_REFCTRL_ADC_REFVAL) |
286 + BM_AUDIOOUT_REFCTRL_ADJ_ADC |
287 + BF(0x3, AUDIOOUT_REFCTRL_VBG_ADJ) | BM_AUDIOOUT_REFCTRL_RAISE_REF;
288 +
289 + __raw_writel(refctrl_val, mxs_adc->aout_base + HW_AUDIOOUT_REFCTRL);
290 +}
291 +
292 +static bool mxs_codec_dac_is_capless(struct mxs_adc_priv *mxs_adc)
293 +{
294 + if ((__raw_readl(mxs_adc->aout_base + HW_AUDIOOUT_PWRDN)
295 + & BM_AUDIOOUT_PWRDN_CAPLESS) == 0)
296 + return false;
297 + else
298 + return true;
299 +}
300 +
301 +static void mxs_codec_dac_arm_short_cm(struct mxs_adc_priv *mxs_adc, bool bShort)
302 +{
303 + __raw_writel(BF(3, AUDIOOUT_ANACTRL_SHORTMODE_CM),
304 + mxs_adc->aout_base + HW_AUDIOOUT_ANACTRL_CLR);
305 + __raw_writel(BM_AUDIOOUT_ANACTRL_SHORT_CM_STS,
306 + mxs_adc->aout_base + HW_AUDIOOUT_ANACTRL_CLR);
307 + if (bShort)
308 + __raw_writel(BF(1, AUDIOOUT_ANACTRL_SHORTMODE_CM),
309 + mxs_adc->aout_base + HW_AUDIOOUT_ANACTRL_SET);
310 +}
311 +
312 +static void mxs_codec_dac_arm_short_lr(struct mxs_adc_priv *mxs_adc, bool bShort)
313 +{
314 + __raw_writel(BF(3, AUDIOOUT_ANACTRL_SHORTMODE_LR),
315 + mxs_adc->aout_base + HW_AUDIOOUT_ANACTRL_CLR);
316 + __raw_writel(BM_AUDIOOUT_ANACTRL_SHORT_LR_STS,
317 + mxs_adc->aout_base + HW_AUDIOOUT_ANACTRL_CLR);
318 + if (bShort)
319 + __raw_writel(BF(1, AUDIOOUT_ANACTRL_SHORTMODE_LR),
320 + mxs_adc->aout_base + HW_AUDIOOUT_ANACTRL_SET);
321 +}
322 +
323 +static void mxs_codec_dac_set_short_trip_level(struct mxs_adc_priv *mxs_adc, u8 u8level)
324 +{
325 + __raw_writel(__raw_readl(mxs_adc->aout_base +
326 + HW_AUDIOOUT_ANACTRL)
327 + & (~BM_AUDIOOUT_ANACTRL_SHORT_LVLADJL)
328 + & (~BM_AUDIOOUT_ANACTRL_SHORT_LVLADJR)
329 + | BF(u8level, AUDIOOUT_ANACTRL_SHORT_LVLADJL)
330 + | BF(u8level, AUDIOOUT_ANACTRL_SHORT_LVLADJR),
331 + mxs_adc->aout_base + HW_AUDIOOUT_ANACTRL);
332 +}
333 +
334 +static void mxs_codec_dac_arm_short(struct mxs_adc_priv *mxs_adc, bool bLatchCM, bool bLatchLR)
335 +{
336 + if (bLatchCM) {
337 + if (mxs_codec_dac_is_capless(mxs_adc))
338 + mxs_codec_dac_arm_short_cm(mxs_adc, true);
339 + } else
340 + mxs_codec_dac_arm_short_cm(mxs_adc, false);
341 +
342 + if (bLatchLR)
343 + mxs_codec_dac_arm_short_lr(mxs_adc, true);
344 + else
345 + mxs_codec_dac_arm_short_lr(mxs_adc, false);
346 +}
347 +
348 +static void
349 +mxs_codec_dac_power_on(struct mxs_adc_priv *mxs_adc)
350 +{
351 + /* Ungate DAC clocks */
352 + __raw_writel(BM_AUDIOOUT_CTRL_CLKGATE,
353 + mxs_adc->aout_base + HW_AUDIOOUT_CTRL_CLR);
354 + __raw_writel(BM_AUDIOOUT_ANACLKCTRL_CLKGATE,
355 + mxs_adc->aout_base + HW_AUDIOOUT_ANACLKCTRL_CLR);
356 +
357 + /* 16 bit word length */
358 + __raw_writel(BM_AUDIOOUT_CTRL_WORD_LENGTH,
359 + mxs_adc->aout_base + HW_AUDIOOUT_CTRL_SET);
360 +
361 + /* Arm headphone LR short protect */
362 + mxs_codec_dac_set_short_trip_level(mxs_adc, 0);
363 + mxs_codec_dac_arm_short(mxs_adc, false, true);
364 +
365 + /* Update DAC volume over zero crossings */
366 + __raw_writel(BM_AUDIOOUT_DACVOLUME_EN_ZCD,
367 + mxs_adc->aout_base + HW_AUDIOOUT_DACVOLUME_SET);
368 + /* Mute DAC */
369 + __raw_writel(BM_AUDIOOUT_DACVOLUME_MUTE_LEFT |
370 + BM_AUDIOOUT_DACVOLUME_MUTE_RIGHT,
371 + mxs_adc->aout_base + HW_AUDIOOUT_DACVOLUME_SET);
372 +
373 + /* Update HP volume over zero crossings */
374 + __raw_writel(BM_AUDIOOUT_HPVOL_EN_MSTR_ZCD,
375 + mxs_adc->aout_base + HW_AUDIOOUT_HPVOL_SET);
376 +
377 + __raw_writel(BM_AUDIOOUT_ANACTRL_HP_CLASSAB,
378 + mxs_adc->aout_base + HW_AUDIOOUT_ANACTRL_SET);
379 +
380 + /* Mute HP output */
381 + __raw_writel(BM_AUDIOOUT_HPVOL_MUTE,
382 + mxs_adc->aout_base + HW_AUDIOOUT_HPVOL_SET);
383 + /* Mute speaker amp */
384 + __raw_writel(BM_AUDIOOUT_SPEAKERCTRL_MUTE,
385 + mxs_adc->aout_base + HW_AUDIOOUT_SPEAKERCTRL_SET);
386 + /* Enable the audioout */
387 + __raw_writel(BM_AUDIOOUT_CTRL_RUN,
388 + mxs_adc->aout_base + HW_AUDIOOUT_CTRL_SET);
389 +}
390 +
391 +static void
392 +mxs_codec_dac_power_down(struct mxs_adc_priv *mxs_adc)
393 +{
394 + /* Disable the audioout */
395 + __raw_writel(BM_AUDIOOUT_CTRL_RUN,
396 + mxs_adc->aout_base + HW_AUDIOOUT_CTRL_CLR);
397 + /* Disable class AB */
398 + __raw_writel(BM_AUDIOOUT_ANACTRL_HP_CLASSAB,
399 + mxs_adc->aout_base + HW_AUDIOOUT_ANACTRL_CLR);
400 +
401 + /* Set hold to ground */
402 + __raw_writel(BM_AUDIOOUT_ANACTRL_HP_HOLD_GND,
403 + mxs_adc->aout_base + HW_AUDIOOUT_ANACTRL_SET);
404 +
405 + /* Mute HP output */
406 + __raw_writel(BM_AUDIOOUT_HPVOL_MUTE,
407 + mxs_adc->aout_base + HW_AUDIOOUT_HPVOL_SET);
408 + /* Power down HP output */
409 + __raw_writel(BM_AUDIOOUT_PWRDN_HEADPHONE,
410 + mxs_adc->aout_base + HW_AUDIOOUT_PWRDN_SET);
411 +
412 + /* Mute speaker amp */
413 + __raw_writel(BM_AUDIOOUT_SPEAKERCTRL_MUTE,
414 + mxs_adc->aout_base + HW_AUDIOOUT_SPEAKERCTRL_SET);
415 + /* Power down speaker amp */
416 + __raw_writel(BM_AUDIOOUT_PWRDN_SPEAKER,
417 + mxs_adc->aout_base + HW_AUDIOOUT_PWRDN_SET);
418 +
419 + /* Mute DAC */
420 + __raw_writel(BM_AUDIOOUT_DACVOLUME_MUTE_LEFT |
421 + BM_AUDIOOUT_DACVOLUME_MUTE_RIGHT,
422 + mxs_adc->aout_base + HW_AUDIOOUT_DACVOLUME_SET);
423 + /* Power down DAC */
424 + __raw_writel(BM_AUDIOOUT_PWRDN_DAC,
425 + mxs_adc->aout_base + HW_AUDIOOUT_PWRDN_SET);
426 +
427 + /* Gate DAC clocks */
428 + __raw_writel(BM_AUDIOOUT_ANACLKCTRL_CLKGATE,
429 + mxs_adc->aout_base + HW_AUDIOOUT_ANACLKCTRL_SET);
430 + __raw_writel(BM_AUDIOOUT_CTRL_CLKGATE,
431 + mxs_adc->aout_base + HW_AUDIOOUT_CTRL_SET);
432 +}
433 +
434 +static void
435 +mxs_codec_adc_power_on(struct mxs_adc_priv *mxs_adc)
436 +{
437 + u32 reg;
438 +
439 + /* Ungate ADC clocks */
440 + __raw_writel(BM_AUDIOIN_CTRL_CLKGATE,
441 + mxs_adc->ain_base + HW_AUDIOIN_CTRL_CLR);
442 + __raw_writel(BM_AUDIOIN_ANACLKCTRL_CLKGATE,
443 + mxs_adc->ain_base + HW_AUDIOIN_ANACLKCTRL_CLR);
444 +
445 + /* 16 bit word length */
446 + __raw_writel(BM_AUDIOIN_CTRL_WORD_LENGTH,
447 + mxs_adc->ain_base + HW_AUDIOIN_CTRL_SET);
448 +
449 + /* Unmute ADC channels */
450 + __raw_writel(BM_AUDIOIN_ADCVOL_MUTE,
451 + mxs_adc->ain_base + HW_AUDIOIN_ADCVOL_CLR);
452 +
453 + /*
454 + * The MUTE_LEFT and MUTE_RIGHT fields need to be cleared.
455 + * They aren't presented in the datasheet, so this is hardcode.
456 + */
457 + __raw_writel(0x01000100, mxs_adc->ain_base + HW_AUDIOIN_ADCVOLUME_CLR);
458 +
459 + /* Set the Input channel gain 3dB */
460 + __raw_writel(BM_AUDIOIN_ADCVOL_GAIN_LEFT,
461 + mxs_adc->ain_base + HW_AUDIOIN_ADCVOL_CLR);
462 + __raw_writel(BM_AUDIOIN_ADCVOL_GAIN_RIGHT,
463 + mxs_adc->ain_base + HW_AUDIOIN_ADCVOL_CLR);
464 + __raw_writel(BF(2, AUDIOIN_ADCVOL_GAIN_LEFT),
465 + mxs_adc->ain_base + HW_AUDIOIN_ADCVOL_SET);
466 + __raw_writel(BF(2, AUDIOIN_ADCVOL_GAIN_RIGHT),
467 + mxs_adc->ain_base + HW_AUDIOIN_ADCVOL_SET);
468 +
469 + /* Select default input - Microphone */
470 + __raw_writel(BM_AUDIOIN_ADCVOL_SELECT_LEFT,
471 + mxs_adc->ain_base + HW_AUDIOIN_ADCVOL_CLR);
472 + __raw_writel(BM_AUDIOIN_ADCVOL_SELECT_RIGHT,
473 + mxs_adc->ain_base + HW_AUDIOIN_ADCVOL_CLR);
474 + __raw_writel(BF
475 + (BV_AUDIOIN_ADCVOL_SELECT__MIC,
476 + AUDIOIN_ADCVOL_SELECT_LEFT),
477 + mxs_adc->ain_base + HW_AUDIOIN_ADCVOL_SET);
478 + __raw_writel(BF
479 + (BV_AUDIOIN_ADCVOL_SELECT__MIC,
480 + AUDIOIN_ADCVOL_SELECT_RIGHT),
481 + mxs_adc->ain_base + HW_AUDIOIN_ADCVOL_SET);
482 +
483 + /* Supply bias voltage to microphone */
484 + __raw_writel(BF(1, AUDIOIN_MICLINE_MIC_RESISTOR),
485 + mxs_adc->ain_base + HW_AUDIOIN_MICLINE_SET);
486 + __raw_writel(BM_AUDIOIN_MICLINE_MIC_SELECT,
487 + mxs_adc->ain_base + HW_AUDIOIN_MICLINE_SET);
488 + __raw_writel(BF(1, AUDIOIN_MICLINE_MIC_GAIN),
489 + mxs_adc->ain_base + HW_AUDIOIN_MICLINE_SET);
490 + __raw_writel(BF(7, AUDIOIN_MICLINE_MIC_BIAS),
491 + mxs_adc->ain_base + HW_AUDIOIN_MICLINE_SET);
492 +
493 + /* Set max ADC volume */
494 + reg = __raw_readl(mxs_adc->ain_base + HW_AUDIOIN_ADCVOLUME);
495 + reg &= ~BM_AUDIOIN_ADCVOLUME_VOLUME_LEFT;
496 + reg &= ~BM_AUDIOIN_ADCVOLUME_VOLUME_RIGHT;
497 + reg |= BF(ADC_VOLUME_MAX, AUDIOIN_ADCVOLUME_VOLUME_LEFT);
498 + reg |= BF(ADC_VOLUME_MAX, AUDIOIN_ADCVOLUME_VOLUME_RIGHT);
499 + __raw_writel(reg, mxs_adc->ain_base + HW_AUDIOIN_ADCVOLUME);
500 +}
501 +
502 +static void
503 +mxs_codec_adc_power_down(struct mxs_adc_priv *mxs_adc)
504 +{
505 + /* Mute ADC channels */
506 + __raw_writel(BM_AUDIOIN_ADCVOL_MUTE,
507 + mxs_adc->ain_base + HW_AUDIOIN_ADCVOL_SET);
508 +
509 + /* Power Down ADC */
510 + __raw_writel(BM_AUDIOOUT_PWRDN_ADC | BM_AUDIOOUT_PWRDN_RIGHT_ADC,
511 + mxs_adc->aout_base + HW_AUDIOOUT_PWRDN_SET);
512 +
513 + /* Gate ADC clocks */
514 + __raw_writel(BM_AUDIOIN_CTRL_CLKGATE,
515 + mxs_adc->ain_base + HW_AUDIOIN_CTRL_SET);
516 + __raw_writel(BM_AUDIOIN_ANACLKCTRL_CLKGATE,
517 + mxs_adc->ain_base + HW_AUDIOIN_ANACLKCTRL_SET);
518 +
519 + /* Disable bias voltage to microphone */
520 + __raw_writel(BF(0, AUDIOIN_MICLINE_MIC_RESISTOR),
521 + mxs_adc->ain_base + HW_AUDIOIN_MICLINE_SET);
522 +}
523 +
524 +static void mxs_codec_dac_enable(struct mxs_adc_priv *mxs_adc)
525 +{
526 + /* Move DAC codec out of reset */
527 + __raw_writel(BM_AUDIOOUT_CTRL_SFTRST,
528 + mxs_adc->aout_base + HW_AUDIOOUT_CTRL_CLR);
529 +
530 + /* Reduce analog power */
531 + __raw_writel(BM_AUDIOOUT_TEST_HP_I1_ADJ,
532 + mxs_adc->aout_base + HW_AUDIOOUT_TEST_CLR);
533 + __raw_writel(BF(0x1, AUDIOOUT_TEST_HP_I1_ADJ),
534 + mxs_adc->aout_base + HW_AUDIOOUT_TEST_SET);
535 + __raw_writel(BM_AUDIOOUT_REFCTRL_LOW_PWR,
536 + mxs_adc->aout_base + HW_AUDIOOUT_REFCTRL_SET);
537 + __raw_writel(BM_AUDIOOUT_REFCTRL_XTAL_BGR_BIAS,
538 + mxs_adc->aout_base + HW_AUDIOOUT_REFCTRL_SET);
539 + __raw_writel(BM_AUDIOOUT_REFCTRL_BIAS_CTRL,
540 + mxs_adc->aout_base + HW_AUDIOOUT_REFCTRL_CLR);
541 + __raw_writel(BF(0x1, AUDIOOUT_REFCTRL_BIAS_CTRL),
542 + mxs_adc->aout_base + HW_AUDIOOUT_REFCTRL_CLR);
543 +
544 + /* Set Vag value */
545 + mxs_codec_dac_set_vag(mxs_adc);
546 +
547 + /* Power on DAC codec */
548 + mxs_codec_dac_power_on(mxs_adc);
549 +}
550 +
551 +static void mxs_codec_dac_disable(struct mxs_adc_priv *mxs_adc)
552 +{
553 + mxs_codec_dac_power_down(mxs_adc);
554 +}
555 +
556 +static void mxs_codec_adc_enable(struct mxs_adc_priv *mxs_adc)
557 +{
558 + /* Move ADC codec out of reset */
559 + __raw_writel(BM_AUDIOIN_CTRL_SFTRST,
560 + mxs_adc->ain_base + HW_AUDIOIN_CTRL_CLR);
561 +
562 + /* Power on ADC codec */
563 + mxs_codec_adc_power_on(mxs_adc);
564 +}
565 +
566 +static void mxs_codec_adc_disable(struct mxs_adc_priv *mxs_adc)
567 +{
568 + mxs_codec_adc_power_down(mxs_adc);
569 +}
570 +
571 +static void mxs_codec_startup(struct snd_soc_codec *codec)
572 +{
573 + struct mxs_adc_priv *mxs_adc = snd_soc_codec_get_drvdata(codec);
574 +
575 + /* Soft reset DAC block */
576 + __raw_writel(BM_AUDIOOUT_CTRL_SFTRST,
577 + mxs_adc->aout_base + HW_AUDIOOUT_CTRL_SET);
578 + while (!(__raw_readl(mxs_adc->aout_base + HW_AUDIOOUT_CTRL)
579 + & BM_AUDIOOUT_CTRL_CLKGATE)){
580 + }
581 +
582 + /* Soft reset ADC block */
583 + __raw_writel(BM_AUDIOIN_CTRL_SFTRST,
584 + mxs_adc->ain_base + HW_AUDIOIN_CTRL_SET);
585 + while (!(__raw_readl(mxs_adc->ain_base + HW_AUDIOIN_CTRL)
586 + & BM_AUDIOIN_CTRL_CLKGATE)){
587 + }
588 +
589 + mxs_codec_dac_enable(mxs_adc);
590 + mxs_codec_adc_enable(mxs_adc);
591 +
592 + /* Sync regs and cache */
593 + mxs_codec_sync_reg_cache(codec);
594 +}
595 +
596 +static void mxs_codec_stop(struct snd_soc_codec *codec)
597 +{
598 + struct mxs_adc_priv *mxs_adc = snd_soc_codec_get_drvdata(codec);
599 +
600 + mxs_codec_dac_disable(mxs_adc);
601 + mxs_codec_adc_disable(mxs_adc);
602 +}
603 +/* END Codec routines */
604 +
605 +/* kcontrol */
606 +static int dac_info_volsw(struct snd_kcontrol *kcontrol,
607 + struct snd_ctl_elem_info *uinfo)
608 +{
609 + uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
610 + uinfo->count = 2;
611 + uinfo->value.integer.min = 0;
612 + uinfo->value.integer.max = 0xf;
613 + return 0;
614 +}
615 +
616 +static int dac_get_volsw(struct snd_kcontrol *kcontrol,
617 + struct snd_ctl_elem_value *ucontrol)
618 +{
619 + struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
620 + struct mxs_adc_priv *mxs_adc = snd_soc_codec_get_drvdata(codec);
621 + int reg, l, r;
622 + int i;
623 +
624 + reg = __raw_readl(mxs_adc->aout_base + HW_AUDIOOUT_DACVOLUME);
625 +
626 + l = (reg & BM_AUDIOOUT_DACVOLUME_VOLUME_LEFT) >>
627 + BP_AUDIOOUT_DACVOLUME_VOLUME_LEFT;
628 + r = (reg & BM_AUDIOOUT_DACVOLUME_VOLUME_RIGHT) >>
629 + BP_AUDIOOUT_DACVOLUME_VOLUME_RIGHT;
630 + /*Left channel */
631 + i = 0;
632 + while (i < 16) {
633 + if (l == dac_volumn_control_word[i]) {
634 + ucontrol->value.integer.value[0] = i;
635 + break;
636 + }
637 + i++;
638 + }
639 + if (i == 16)
640 + ucontrol->value.integer.value[0] = i;
641 + /*Right channel */
642 + i = 0;
643 + while (i < 16) {
644 + if (r == dac_volumn_control_word[i]) {
645 + ucontrol->value.integer.value[1] = i;
646 + break;
647 + }
648 + i++;
649 + }
650 + if (i == 16)
651 + ucontrol->value.integer.value[1] = i;
652 +
653 + return 0;
654 +}
655 +
656 +static int dac_put_volsw(struct snd_kcontrol *kcontrol,
657 + struct snd_ctl_elem_value *ucontrol)
658 +{
659 + struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
660 + struct mxs_adc_priv *mxs_adc = snd_soc_codec_get_drvdata(codec);
661 + int reg, l, r;
662 + int i;
663 +
664 + i = ucontrol->value.integer.value[0];
665 + l = dac_volumn_control_word[i];
666 + /*Get dac volume for left channel */
667 + reg = BF(l, AUDIOOUT_DACVOLUME_VOLUME_LEFT);
668 +
669 + i = ucontrol->value.integer.value[1];
670 + r = dac_volumn_control_word[i];
671 + /*Get dac volume for right channel */
672 + reg = reg | BF(r, AUDIOOUT_DACVOLUME_VOLUME_RIGHT);
673 +
674 + /*Clear left/right dac volume */
675 + __raw_writel(BM_AUDIOOUT_DACVOLUME_VOLUME_LEFT |
676 + BM_AUDIOOUT_DACVOLUME_VOLUME_RIGHT,
677 + mxs_adc->aout_base + HW_AUDIOOUT_DACVOLUME_CLR);
678 + __raw_writel(reg, mxs_adc->aout_base + HW_AUDIOOUT_DACVOLUME_SET);
679 +
680 + return 0;
681 +}
682 +
683 +static const char *mxs_codec_adc_input_sel[] = {
684 + "Mic", "Line In 1", "Head Phone", "Line In 2" };
685 +
686 +static const char *mxs_codec_hp_output_sel[] = { "DAC Out", "Line In 1" };
687 +
688 +static const char *mxs_codec_adc_3d_sel[] = {
689 + "Off", "Low", "Medium", "High" };
690 +
691 +static const struct soc_enum mxs_codec_enum[] = {
692 + SOC_ENUM_SINGLE(ADC_ADCVOL_L, 12, 4, mxs_codec_adc_input_sel),
693 + SOC_ENUM_SINGLE(ADC_ADCVOL_L, 4, 4, mxs_codec_adc_input_sel),
694 + SOC_ENUM_SINGLE(DAC_HPVOL_H, 0, 2, mxs_codec_hp_output_sel),
695 + SOC_ENUM_SINGLE(DAC_CTRL_L, 8, 4, mxs_codec_adc_3d_sel),
696 +};
697 +
698 +static const struct snd_kcontrol_new mxs_snd_controls[] = {
699 + /* Playback Volume */
700 + {
701 + .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
702 + .name = "DAC Playback Volume",
703 + .access = SNDRV_CTL_ELEM_ACCESS_READWRITE |
704 + SNDRV_CTL_ELEM_ACCESS_VOLATILE,
705 + .info = dac_info_volsw,
706 + .get = dac_get_volsw,
707 + .put = dac_put_volsw,
708 + },
709 +
710 + SOC_DOUBLE_R("DAC Playback Switch",
711 + DAC_VOLUME_H, DAC_VOLUME_L, 8, 0x01, 1),
712 + SOC_DOUBLE("HP Playback Volume", DAC_HPVOL_L, 8, 0, 0x7F, 1),
713 +
714 + /* Capture Volume */
715 + SOC_DOUBLE_R("ADC Capture Volume",
716 + ADC_VOLUME_H, ADC_VOLUME_L, 0, 0xFF, 0),
717 + SOC_DOUBLE("ADC PGA Capture Volume", ADC_ADCVOL_L, 8, 0, 0x0F, 0),
718 + SOC_SINGLE("ADC PGA Capture Switch", ADC_ADCVOL_H, 8, 0x1, 1),
719 + SOC_SINGLE("Mic PGA Capture Volume", ADC_MICLINE_L, 0, 0x03, 0),
720 +
721 + /* Virtual 3D effect */
722 + SOC_ENUM("3D effect", mxs_codec_enum[3]),
723 +};
724 +/* END kcontrol */
725 +
726 +/* DAPM */
727 +static int pga_event(struct snd_soc_dapm_widget *w,
728 + struct snd_kcontrol *kcontrol, int event)
729 +{
730 + struct mxs_adc_priv *mxs_adc = snd_soc_codec_get_drvdata(w->codec);
731 +
732 + switch (event) {
733 + case SND_SOC_DAPM_PRE_PMU:
734 + /* Prepare powering up HP and SPEAKER output */
735 + __raw_writel(BM_AUDIOOUT_ANACTRL_HP_HOLD_GND,
736 + mxs_adc->aout_base + HW_AUDIOOUT_ANACTRL_SET);
737 + __raw_writel(BM_RTC_PERSISTENT0_RELEASE_GND,
738 + mxs_adc->rtc_base + HW_RTC_PERSISTENT0_SET);
739 + msleep(100);
740 + break;
741 + case SND_SOC_DAPM_POST_PMU:
742 + __raw_writel(BM_AUDIOOUT_ANACTRL_HP_HOLD_GND,
743 + mxs_adc->aout_base + HW_AUDIOOUT_ANACTRL_CLR);
744 + break;
745 + case SND_SOC_DAPM_POST_PMD:
746 + __raw_writel(BM_RTC_PERSISTENT0_RELEASE_GND,
747 + mxs_adc->rtc_base + HW_RTC_PERSISTENT0_CLR);
748 + break;
749 + }
750 + return 0;
751 +}
752 +
753 +static int adc_event(struct snd_soc_dapm_widget *w,
754 + struct snd_kcontrol *kcontrol, int event)
755 +{
756 + struct mxs_adc_priv *mxs_adc = snd_soc_codec_get_drvdata(w->codec);
757 +
758 + switch (event) {
759 + case SND_SOC_DAPM_PRE_PMU:
760 + __raw_writel(BM_RTC_PERSISTENT0_RELEASE_GND,
761 + mxs_adc->rtc_base + HW_RTC_PERSISTENT0_SET);
762 + msleep(100);
763 + break;
764 + case SND_SOC_DAPM_POST_PMD:
765 + __raw_writel(BM_RTC_PERSISTENT0_RELEASE_GND,
766 + mxs_adc->rtc_base + HW_RTC_PERSISTENT0_CLR);
767 + break;
768 + }
769 + return 0;
770 +}
771 +
772 +/* Left ADC Mux */
773 +static const struct snd_kcontrol_new mxs_left_adc_controls =
774 +SOC_DAPM_ENUM("Route", mxs_codec_enum[0]);
775 +
776 +/* Right ADC Mux */
777 +static const struct snd_kcontrol_new mxs_right_adc_controls =
778 +SOC_DAPM_ENUM("Route", mxs_codec_enum[1]);
779 +
780 +/* Head Phone Mux */
781 +static const struct snd_kcontrol_new mxs_hp_controls =
782 +SOC_DAPM_ENUM("Route", mxs_codec_enum[2]);
783 +
784 +static const struct snd_soc_dapm_widget mxs_dapm_widgets[] = {
785 + SND_SOC_DAPM_ADC_E("ADC", "Capture", DAC_PWRDN_L, 8, 1, adc_event,
786 + SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
787 +
788 + SND_SOC_DAPM_DAC("DAC", "Playback", DAC_PWRDN_L, 12, 1),
789 +
790 + SND_SOC_DAPM_MUX("Left ADC Mux", SND_SOC_NOPM, 0, 0,
791 + &mxs_left_adc_controls),
792 + SND_SOC_DAPM_MUX("Right ADC Mux", SND_SOC_NOPM, 0, 0,
793 + &mxs_right_adc_controls),
794 + SND_SOC_DAPM_MUX("HP Mux", SND_SOC_NOPM, 0, 0,
795 + &mxs_hp_controls),
796 + SND_SOC_DAPM_PGA_E("HP AMP", DAC_PWRDN_L, 0, 1, NULL, 0, pga_event,
797 + SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
798 + SND_SOC_DAPM_POST_PMD),
799 + SND_SOC_DAPM_PGA("SPEAKER AMP", DAC_PWRDN_H, 8, 1, NULL, 0),
800 + SND_SOC_DAPM_INPUT("LINE1L"),
801 + SND_SOC_DAPM_INPUT("LINE1R"),
802 + SND_SOC_DAPM_INPUT("LINE2L"),
803 + SND_SOC_DAPM_INPUT("LINE2R"),
804 + SND_SOC_DAPM_INPUT("MIC"),
805 +
806 + SND_SOC_DAPM_OUTPUT("SPEAKER"),
807 + SND_SOC_DAPM_OUTPUT("HPL"),
808 + SND_SOC_DAPM_OUTPUT("HPR"),
809 +};
810 +
811 +/* routes for sgtl5000 */
812 +static const struct snd_soc_dapm_route mxs_dapm_routes[] = {
813 + /* Left ADC Mux */
814 + {"Left ADC Mux", "Mic", "MIC"},
815 + {"Left ADC Mux", "Line In 1", "LINE1L"},
816 + {"Left ADC Mux", "Line In 2", "LINE2L"},
817 + {"Left ADC Mux", "Head Phone", "HPL"},
818 +
819 + /* Right ADC Mux */
820 + {"Right ADC Mux", "Mic", "MIC"},
821 + {"Right ADC Mux", "Line In 1", "LINE1R"},
822 + {"Right ADC Mux", "Line In 2", "LINE2R"},
823 + {"Right ADC Mux", "Head Phone", "HPR"},
824 +
825 + /* ADC */
826 + {"ADC", NULL, "Left ADC Mux"},
827 + {"ADC", NULL, "Right ADC Mux"},
828 +
829 + /* HP Mux */
830 + {"HP Mux", "DAC Out", "DAC"},
831 + {"HP Mux", "Line In 1", "LINE1L"},
832 + {"HP Mux", "Line In 1", "LINE1R"},
833 +
834 + /* HP amp */
835 + {"HP AMP", NULL, "HP Mux"},
836 + /* HP output */
837 + {"HPR", NULL, "HP AMP"},
838 + {"HPL", NULL, "HP AMP"},
839 +
840 + /* Speaker amp */
841 + {"SPEAKER AMP", NULL, "DAC"},
842 + {"SPEAKER", NULL, "SPEAKER AMP"},
843 +};
844 +/* END DAPM */
845 +
846 +static int mxs_set_bias_level(struct snd_soc_codec *codec,
847 + enum snd_soc_bias_level level)
848 +{
849 + struct mxs_adc_priv *mxs_adc = snd_soc_codec_get_drvdata(codec);
850 +
851 + pr_debug("dapm level %d\n", level);
852 + switch (level) {
853 + case SND_SOC_BIAS_ON: /* full On */
854 + if (codec->dapm.bias_level == SND_SOC_BIAS_ON)
855 + break;
856 + break;
857 +
858 + case SND_SOC_BIAS_PREPARE: /* partial On */
859 + if (codec->dapm.bias_level == SND_SOC_BIAS_PREPARE)
860 + break;
861 + /* Set Capless mode */
862 + __raw_writel(BM_AUDIOOUT_PWRDN_CAPLESS,
863 + mxs_adc->aout_base + HW_AUDIOOUT_PWRDN_CLR);
864 + break;
865 +
866 + case SND_SOC_BIAS_STANDBY: /* Off, with power */
867 + if (codec->dapm.bias_level == SND_SOC_BIAS_STANDBY)
868 + break;
869 + /* Unset Capless mode */
870 + __raw_writel(BM_AUDIOOUT_PWRDN_CAPLESS,
871 + mxs_adc->aout_base + HW_AUDIOOUT_PWRDN_SET);
872 + break;
873 +
874 + case SND_SOC_BIAS_OFF: /* Off, without power */
875 + if (codec->dapm.bias_level == SND_SOC_BIAS_OFF)
876 + break;
877 + /* Unset Capless mode */
878 + __raw_writel(BM_AUDIOOUT_PWRDN_CAPLESS,
879 + mxs_adc->aout_base + HW_AUDIOOUT_PWRDN_SET);
880 + break;
881 + }
882 +
883 + codec->dapm.bias_level = level;
884 + return 0;
885 +}
886 +
887 +/* MXS-ADC Codec DAI driver */
888 +static int mxs_pcm_hw_params(struct snd_pcm_substream *substream,
889 + struct snd_pcm_hw_params *params,
890 + struct snd_soc_dai *dai)
891 +{
892 + struct snd_soc_codec *codec = dai->codec;
893 + struct mxs_adc_priv *mxs_adc = snd_soc_codec_get_drvdata(codec);
894 + int playback = substream->stream == SNDRV_PCM_STREAM_PLAYBACK ? 1 : 0;
895 + int i;
896 + u32 srr_value = 0;
897 + u32 src_hold = 0;
898 +
899 + i = get_srr_values(params_rate(params));
900 + if (i < 0)
901 + dev_warn(codec->dev, "codec doesn't support rate %d\n",
902 + params_rate(params));
903 + else {
904 + src_hold = srr_values[i].src_hold;
905 +
906 + srr_value =
907 + BF(srr_values[i].basemult, AUDIOOUT_DACSRR_BASEMULT) |
908 + BF(srr_values[i].src_int, AUDIOOUT_DACSRR_SRC_INT) |
909 + BF(srr_values[i].src_frac, AUDIOOUT_DACSRR_SRC_FRAC) |
910 + BF(src_hold, AUDIOOUT_DACSRR_SRC_HOLD);
911 +
912 + if (playback)
913 + __raw_writel(srr_value,
914 + mxs_adc->aout_base + HW_AUDIOOUT_DACSRR);
915 + else
916 + __raw_writel(srr_value,
917 + mxs_adc->ain_base + HW_AUDIOIN_ADCSRR);
918 + }
919 +
920 + switch (params_format(params)) {
921 + case SNDRV_PCM_FORMAT_S16_LE:
922 + if (playback)
923 + __raw_writel(BM_AUDIOOUT_CTRL_WORD_LENGTH,
924 + mxs_adc->aout_base + HW_AUDIOOUT_CTRL_SET);
925 + else
926 + __raw_writel(BM_AUDIOIN_CTRL_WORD_LENGTH,
927 + mxs_adc->ain_base + HW_AUDIOIN_CTRL_SET);
928 +
929 + break;
930 +
931 + case SNDRV_PCM_FORMAT_S32_LE:
932 + if (playback)
933 + __raw_writel(BM_AUDIOOUT_CTRL_WORD_LENGTH,
934 + mxs_adc->aout_base + HW_AUDIOOUT_CTRL_CLR);
935 + else
936 + __raw_writel(BM_AUDIOIN_CTRL_WORD_LENGTH,
937 + mxs_adc->ain_base + HW_AUDIOIN_CTRL_CLR);
938 +
939 + break;
940 +
941 + default:
942 + dev_warn(codec->dev, "codec doesn't support format %d\n",
943 + params_format(params));
944 +
945 + }
946 +
947 + return 0;
948 +}
949 +
950 +/* mute the codec used by alsa core */
951 +static int mxs_codec_dig_mute(struct snd_soc_dai *codec_dai, int mute)
952 +{
953 + struct mxs_adc_priv *mxs_adc = snd_soc_codec_get_drvdata(codec_dai->codec);
954 + int l, r;
955 + int ll, rr;
956 + u32 reg, reg1, reg2;
957 + u32 dac_mask = BM_AUDIOOUT_DACVOLUME_MUTE_LEFT |
958 + BM_AUDIOOUT_DACVOLUME_MUTE_RIGHT;
959 +
960 + if (mute) {
961 + reg = __raw_readl(mxs_adc->aout_base + \
962 + HW_AUDIOOUT_DACVOLUME);
963 +
964 + reg1 = reg & ~BM_AUDIOOUT_DACVOLUME_VOLUME_LEFT;
965 + reg1 = reg1 & ~BM_AUDIOOUT_DACVOLUME_VOLUME_RIGHT;
966 +
967 + l = (reg & BM_AUDIOOUT_DACVOLUME_VOLUME_LEFT) >>
968 + BP_AUDIOOUT_DACVOLUME_VOLUME_LEFT;
969 + r = (reg & BM_AUDIOOUT_DACVOLUME_VOLUME_RIGHT) >>
970 + BP_AUDIOOUT_DACVOLUME_VOLUME_RIGHT;
971 +
972 + /* fade out dac vol */
973 + while ((l > DAC_VOLUME_MIN) || (r > DAC_VOLUME_MIN)) {
974 + l -= 0x8;
975 + r -= 0x8;
976 + ll = l > DAC_VOLUME_MIN ? l : DAC_VOLUME_MIN;
977 + rr = r > DAC_VOLUME_MIN ? r : DAC_VOLUME_MIN;
978 + reg2 = reg1 | BF_AUDIOOUT_DACVOLUME_VOLUME_LEFT(ll)
979 + | BF_AUDIOOUT_DACVOLUME_VOLUME_RIGHT(rr);
980 + __raw_writel(reg2,
981 + mxs_adc->aout_base + HW_AUDIOOUT_DACVOLUME);
982 + msleep(1);
983 + }
984 +
985 + __raw_writel(dac_mask,
986 + mxs_adc->aout_base + HW_AUDIOOUT_DACVOLUME_SET);
987 + reg = reg | dac_mask;
988 + __raw_writel(reg,
989 + mxs_adc->aout_base + HW_AUDIOOUT_DACVOLUME);
990 + } else
991 + __raw_writel(dac_mask,
992 + mxs_adc->aout_base + HW_AUDIOOUT_DACVOLUME_CLR);
993 +
994 + return 0;
995 +}
996 +
997 +#define MXS_ADC_RATES SNDRV_PCM_RATE_8000_192000
998 +#define MXS_ADC_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S32_LE)
999 +
1000 +static const struct snd_soc_dai_ops mxs_codec_dai_ops = {
1001 + .hw_params = mxs_pcm_hw_params,
1002 + .digital_mute = mxs_codec_dig_mute,
1003 +};
1004 +
1005 +static struct snd_soc_dai_driver mxs_codec_dai_driver = {
1006 + .name = "mxs-builtin-codec-dai",
1007 + .playback = {
1008 + .stream_name = "Playback",
1009 + .channels_min = 2,
1010 + .channels_max = 2,
1011 + .rates = MXS_ADC_RATES,
1012 + .formats = MXS_ADC_FORMATS,
1013 + },
1014 + .capture = {
1015 + .stream_name = "Capture",
1016 + .channels_min = 2,
1017 + .channels_max = 2,
1018 + .rates = MXS_ADC_RATES,
1019 + .formats = MXS_ADC_FORMATS,
1020 + },
1021 + .ops = &mxs_codec_dai_ops,
1022 +};
1023 +/* END MXS-ADC Codec DAI driver */
1024 +
1025 +/* MXS-ADC Codec driver */
1026 +static int mxs_codec_driver_probe(struct snd_soc_codec *codec)
1027 +{
1028 + int ret = 0;
1029 + /* We don't use snd_soc_codec_set_cache_io because we are using
1030 + * our own IO functions: write, read. */
1031 +
1032 + mxs_codec_startup(codec);
1033 +
1034 + /* leading to standby state */
1035 + ret = mxs_set_bias_level(codec, SND_SOC_BIAS_STANDBY);
1036 + if (ret)
1037 + goto err;
1038 +
1039 + return 0;
1040 +
1041 +err:
1042 + mxs_codec_stop(codec);
1043 +
1044 + return ret;
1045 +}
1046 +
1047 +static int mxs_codec_driver_remove(struct snd_soc_codec *codec)
1048 +{
1049 + mxs_codec_stop(codec);
1050 +
1051 + return 0;
1052 +}
1053 +
1054 +// static int mxs_codec_driver_suspend(struct snd_soc_codec *codec)
1055 +// {
1056 +// /* TODO Enable power management. */
1057 +// return 0;
1058 +// }
1059 +
1060 +// static int mxs_codec_driver_resume(struct snd_soc_codec *codec)
1061 +// {
1062 +// /* TODO Enable power management. */
1063 +// return 0;
1064 +// }
1065 +
1066 +static struct snd_soc_codec_driver mxs_codec_driver = {
1067 + .probe = mxs_codec_driver_probe,
1068 + .remove = mxs_codec_driver_remove,
1069 +// .suspend = mxs_codec_driver_suspend,
1070 +// .resume = mxs_codec_driver_resume,
1071 + .set_bias_level = mxs_set_bias_level,
1072 + .reg_cache_size = ADC_REGNUM,
1073 + .reg_word_size = sizeof(u16),
1074 + .reg_cache_step = 1,
1075 +// .reg_cache_default = mxsadc_regs,
1076 +// .volatile_register = sgtl5000_volatile_register,
1077 + .controls = mxs_snd_controls,
1078 + .num_controls = ARRAY_SIZE(mxs_snd_controls),
1079 + .dapm_widgets = mxs_dapm_widgets,
1080 + .num_dapm_widgets = ARRAY_SIZE(mxs_dapm_widgets),
1081 + .dapm_routes = mxs_dapm_routes,
1082 + .num_dapm_routes = ARRAY_SIZE(mxs_dapm_routes),
1083 + .write = mxs_codec_write,
1084 + .read = mxs_codec_read,
1085 +};
1086 +/* END MXS-ADC Codec driver */
1087 +
1088 +/* Underlying platform device that registers codec */
1089 +static int mxs_adc_probe(struct platform_device *pdev)
1090 +{
1091 + struct mxs_adc_priv *mxs_adc;
1092 + struct resource *r;
1093 + int ret;
1094 +
1095 + mxs_adc = devm_kzalloc(&pdev->dev, sizeof(struct mxs_adc_priv), GFP_KERNEL);
1096 + if (!mxs_adc)
1097 + return -ENOMEM;
1098 +
1099 + platform_set_drvdata(pdev, mxs_adc);
1100 +
1101 + /* audio-in IO memory */
1102 + r = platform_get_resource_byname(pdev, IORESOURCE_MEM, "audioin");
1103 + if (IS_ERR(r)) {
1104 + dev_err(&pdev->dev, "failed to get resource\n");
1105 + return PTR_ERR(r);
1106 + }
1107 +
1108 + mxs_adc->ain_base = devm_ioremap(&pdev->dev, r->start, resource_size(r));
1109 + if (IS_ERR(mxs_adc->ain_base)) {
1110 + dev_err(&pdev->dev, "ioremap failed\n");
1111 + return PTR_ERR(mxs_adc->ain_base);
1112 + }
1113 +
1114 + /* audio-out IO memory */
1115 + r = platform_get_resource_byname(pdev, IORESOURCE_MEM, "audioout");
1116 + if (IS_ERR(r)) {
1117 + dev_err(&pdev->dev, "failed to get resource\n");
1118 + return PTR_ERR(r);
1119 + }
1120 +
1121 + mxs_adc->aout_base = devm_ioremap(&pdev->dev, r->start, resource_size(r));
1122 + if (IS_ERR(mxs_adc->aout_base)) {
1123 + dev_err(&pdev->dev, "ioremap failed\n");
1124 + return PTR_ERR(mxs_adc->aout_base);
1125 + }
1126 +
1127 + /* rtc IO memory */
1128 + r = platform_get_resource_byname(pdev, IORESOURCE_MEM, "rtc");
1129 + if (IS_ERR(r)) {
1130 + dev_err(&pdev->dev, "failed to get resource\n");
1131 + return PTR_ERR(r);
1132 + }
1133 +
1134 + mxs_adc->rtc_base = devm_ioremap(&pdev->dev, r->start, resource_size(r));
1135 + if (IS_ERR(mxs_adc->rtc_base)) {
1136 + dev_err(&pdev->dev, "ioremap failed\n");
1137 + return PTR_ERR(mxs_adc->rtc_base);
1138 + }
1139 +
1140 + /* Get audio clock */
1141 + mxs_adc->clk = devm_clk_get(&pdev->dev, "filt");
1142 + if (IS_ERR(mxs_adc->clk)) {
1143 + ret = PTR_ERR(mxs_adc->clk);
1144 + dev_err(&pdev->dev, "%s: Clock initialization failed\n", __func__);
1145 + return ret;
1146 + }
1147 +
1148 + /* Turn on audio clock */
1149 + ret = clk_prepare_enable(mxs_adc->clk);
1150 + if (unlikely(ret != 0)) {
1151 + dev_err(&pdev->dev, "%s: Clock prepare or enable failed\n", __func__);
1152 + return ret;
1153 + }
1154 +
1155 + ret = snd_soc_register_codec(&pdev->dev,
1156 + &mxs_codec_driver,&mxs_codec_dai_driver, 1);
1157 + if (unlikely(ret != 0)) {
1158 + dev_err(&pdev->dev, "Codec registration failed\n");
1159 + goto disable_clk;
1160 + }
1161 +
1162 + return 0;
1163 +
1164 +disable_clk:
1165 + clk_disable_unprepare(mxs_adc->clk);
1166 + return ret;
1167 +}
1168 +
1169 +static int mxs_adc_remove(struct platform_device *pdev)
1170 +{
1171 + struct mxs_adc_priv *mxs_adc = platform_get_drvdata(pdev);
1172 +
1173 + clk_disable_unprepare(mxs_adc->clk);
1174 + snd_soc_unregister_codec(&pdev->dev);
1175 +
1176 + return 0;
1177 +}
1178 +
1179 +static const struct of_device_id mxs_adc_dt_ids[] = {
1180 + { .compatible = "fsl,mxs-builtin-codec", },
1181 + { /* sentinel */ }
1182 +};
1183 +MODULE_DEVICE_TABLE(of, mxs_adc_dt_ids);
1184 +
1185 +static struct platform_driver mxs_adc_driver = {
1186 + .driver = {
1187 + .name = "mxs-builtin-codec",
1188 + .owner = THIS_MODULE,
1189 + .of_match_table = mxs_adc_dt_ids,
1190 + },
1191 + .probe = mxs_adc_probe,
1192 + .remove = mxs_adc_remove,
1193 +};
1194 +
1195 +module_platform_driver(mxs_adc_driver);
1196 +/* END Underlying platform device that registers codec */
1197 +
1198 +MODULE_DESCRIPTION("Freescale MXS ADC/DAC SoC Codec Driver");
1199 +MODULE_AUTHOR("Michal Ulianko <michal.ulianko@gmail.com>");
1200 +MODULE_LICENSE("GPL");
1201 diff --git a/sound/soc/codecs/mxs-builtin-codec.h b/sound/soc/codecs/mxs-builtin-codec.h
1202 new file mode 100644
1203 index 0000000..75dee0b
1204 --- /dev/null
1205 +++ b/sound/soc/codecs/mxs-builtin-codec.h
1206 @@ -0,0 +1,825 @@
1207 +#ifndef __MXS_ADC_CODEC_H
1208 +
1209 +#include <linux/io.h>
1210 +
1211 +/* MXS ADC/DAC registers */
1212 +#define DAC_CTRL_L 0
1213 +#define DAC_CTRL_H 1
1214 +#define DAC_STAT_L 2
1215 +#define DAC_STAT_H 3
1216 +#define DAC_SRR_L 4
1217 +#define DAC_VOLUME_L 6
1218 +#define DAC_VOLUME_H 7
1219 +#define DAC_DEBUG_L 8
1220 +#define DAC_DEBUG_H 9
1221 +#define DAC_HPVOL_L 10
1222 +#define DAC_HPVOL_H 11
1223 +#define DAC_PWRDN_L 12
1224 +#define DAC_PWRDN_H 13
1225 +#define DAC_REFCTRL_L 14
1226 +#define DAC_REFCTRL_H 15
1227 +#define DAC_ANACTRL_L 16
1228 +#define DAC_ANACTRL_H 17
1229 +#define DAC_TEST_L 18
1230 +#define DAC_TEST_H 19
1231 +#define DAC_BISTCTRL_L 20
1232 +#define DAC_BISTCTRL_H 21
1233 +#define DAC_BISTSTAT0_L 22
1234 +#define DAC_BISTSTAT0_H 23
1235 +#define DAC_BISTSTAT1_L 24
1236 +#define DAC_BISTSTAT1_H 25
1237 +#define DAC_ANACLKCTRL_L 26
1238 +#define DAC_ANACLKCTRL_H 27
1239 +#define DAC_DATA_L 28
1240 +#define DAC_DATA_H 29
1241 +#define DAC_SPEAKERCTRL_L 30
1242 +#define DAC_SPEAKERCTRL_H 31
1243 +#define DAC_VERSION_L 32
1244 +#define DAC_VERSION_H 33
1245 +#define ADC_CTRL_L 34
1246 +#define ADC_CTRL_H 35
1247 +#define ADC_STAT_L 36
1248 +#define ADC_STAT_H 37
1249 +#define ADC_SRR_L 38
1250 +#define ADC_SRR_H 39
1251 +#define ADC_VOLUME_L 40
1252 +#define ADC_VOLUME_H 41
1253 +#define ADC_DEBUG_L 42
1254 +#define ADC_DEBUG_H 43
1255 +#define ADC_ADCVOL_L 44
1256 +#define ADC_ADCVOL_H 45
1257 +#define ADC_MICLINE_L 46
1258 +#define ADC_MICLINE_H 47
1259 +#define ADC_ANACLKCTRL_L 48
1260 +#define ADC_ANACLKCTRL_H 49
1261 +#define ADC_DATA_L 50
1262 +#define ADC_DATA_H 51
1263 +
1264 +#define ADC_REGNUM 52
1265 +
1266 +#define DAC_VOLUME_MIN 0x37
1267 +#define DAC_VOLUME_MAX 0xFE
1268 +#define ADC_VOLUME_MIN 0x37
1269 +#define ADC_VOLUME_MAX 0xFE
1270 +#define HP_VOLUME_MAX 0x0
1271 +#define HP_VOLUME_MIN 0x7F
1272 +#define LO_VOLUME_MAX 0x0
1273 +#define LO_VOLUME_MIN 0x1F
1274 +
1275 +/* RTC */
1276 +#define HW_RTC_PERSISTENT0 (0x00000060)
1277 +#define HW_RTC_PERSISTENT0_SET (0x00000064)
1278 +#define HW_RTC_PERSISTENT0_CLR (0x00000068)
1279 +#define HW_RTC_PERSISTENT0_TOG (0x0000006c)
1280 +
1281 +// TODO
1282 +//#define BM_RTC_PERSISTENT0_RELEASE_GND 0x00080000
1283 +
1284 +/* AUDIOOUT */
1285 +#define HW_AUDIOOUT_CTRL (0x00000000)
1286 +#define HW_AUDIOOUT_CTRL_SET (0x00000004)
1287 +#define HW_AUDIOOUT_CTRL_CLR (0x00000008)
1288 +#define HW_AUDIOOUT_CTRL_TOG (0x0000000c)
1289 +
1290 +#define BM_AUDIOOUT_CTRL_SFTRST 0x80000000
1291 +#define BM_AUDIOOUT_CTRL_CLKGATE 0x40000000
1292 +#define BP_AUDIOOUT_CTRL_RSRVD4 21
1293 +#define BM_AUDIOOUT_CTRL_RSRVD4 0x3FE00000
1294 +#define BF_AUDIOOUT_CTRL_RSRVD4(v) \
1295 + (((v) << 21) & BM_AUDIOOUT_CTRL_RSRVD4)
1296 +#define BP_AUDIOOUT_CTRL_DMAWAIT_COUNT 16
1297 +#define BM_AUDIOOUT_CTRL_DMAWAIT_COUNT 0x001F0000
1298 +#define BF_AUDIOOUT_CTRL_DMAWAIT_COUNT(v) \
1299 + (((v) << 16) & BM_AUDIOOUT_CTRL_DMAWAIT_COUNT)
1300 +#define BM_AUDIOOUT_CTRL_RSRVD3 0x00008000
1301 +#define BM_AUDIOOUT_CTRL_LR_SWAP 0x00004000
1302 +#define BM_AUDIOOUT_CTRL_EDGE_SYNC 0x00002000
1303 +#define BM_AUDIOOUT_CTRL_INVERT_1BIT 0x00001000
1304 +#define BP_AUDIOOUT_CTRL_RSRVD2 10
1305 +#define BM_AUDIOOUT_CTRL_RSRVD2 0x00000C00
1306 +#define BF_AUDIOOUT_CTRL_RSRVD2(v) \
1307 + (((v) << 10) & BM_AUDIOOUT_CTRL_RSRVD2)
1308 +#define BP_AUDIOOUT_CTRL_SS3D_EFFECT 8
1309 +#define BM_AUDIOOUT_CTRL_SS3D_EFFECT 0x00000300
1310 +#define BF_AUDIOOUT_CTRL_SS3D_EFFECT(v) \
1311 + (((v) << 8) & BM_AUDIOOUT_CTRL_SS3D_EFFECT)
1312 +#define BM_AUDIOOUT_CTRL_RSRVD1 0x00000080
1313 +#define BM_AUDIOOUT_CTRL_WORD_LENGTH 0x00000040
1314 +#define BM_AUDIOOUT_CTRL_DAC_ZERO_ENABLE 0x00000020
1315 +#define BM_AUDIOOUT_CTRL_LOOPBACK 0x00000010
1316 +#define BM_AUDIOOUT_CTRL_FIFO_UNDERFLOW_IRQ 0x00000008
1317 +#define BM_AUDIOOUT_CTRL_FIFO_OVERFLOW_IRQ 0x00000004
1318 +#define BM_AUDIOOUT_CTRL_FIFO_ERROR_IRQ_EN 0x00000002
1319 +#define BM_AUDIOOUT_CTRL_RUN 0x00000001
1320 +
1321 +#define HW_AUDIOOUT_STAT (0x00000010)
1322 +#define HW_AUDIOOUT_STAT_SET (0x00000014)
1323 +#define HW_AUDIOOUT_STAT_CLR (0x00000018)
1324 +#define HW_AUDIOOUT_STAT_TOG (0x0000001c)
1325 +
1326 +#define BM_AUDIOOUT_STAT_DAC_PRESENT 0x80000000
1327 +#define BP_AUDIOOUT_STAT_RSRVD1 0
1328 +#define BM_AUDIOOUT_STAT_RSRVD1 0x7FFFFFFF
1329 +#define BF_AUDIOOUT_STAT_RSRVD1(v) \
1330 + (((v) << 0) & BM_AUDIOOUT_STAT_RSRVD1)
1331 +
1332 +#define HW_AUDIOOUT_DACSRR (0x00000020)
1333 +#define HW_AUDIOOUT_DACSRR_SET (0x00000024)
1334 +#define HW_AUDIOOUT_DACSRR_CLR (0x00000028)
1335 +#define HW_AUDIOOUT_DACSRR_TOG (0x0000002c)
1336 +
1337 +#define BM_AUDIOOUT_DACSRR_OSR 0x80000000
1338 +#define BV_AUDIOOUT_DACSRR_OSR__OSR6 0x0
1339 +#define BV_AUDIOOUT_DACSRR_OSR__OSR12 0x1
1340 +#define BP_AUDIOOUT_DACSRR_BASEMULT 28
1341 +#define BM_AUDIOOUT_DACSRR_BASEMULT 0x70000000
1342 +#define BF_AUDIOOUT_DACSRR_BASEMULT(v) \
1343 + (((v) << 28) & BM_AUDIOOUT_DACSRR_BASEMULT)
1344 +#define BV_AUDIOOUT_DACSRR_BASEMULT__SINGLE_RATE 0x1
1345 +#define BV_AUDIOOUT_DACSRR_BASEMULT__DOUBLE_RATE 0x2
1346 +#define BV_AUDIOOUT_DACSRR_BASEMULT__QUAD_RATE 0x4
1347 +#define BM_AUDIOOUT_DACSRR_RSRVD2 0x08000000
1348 +#define BP_AUDIOOUT_DACSRR_SRC_HOLD 24
1349 +#define BM_AUDIOOUT_DACSRR_SRC_HOLD 0x07000000
1350 +#define BF_AUDIOOUT_DACSRR_SRC_HOLD(v) \
1351 + (((v) << 24) & BM_AUDIOOUT_DACSRR_SRC_HOLD)
1352 +#define BP_AUDIOOUT_DACSRR_RSRVD1 21
1353 +#define BM_AUDIOOUT_DACSRR_RSRVD1 0x00E00000
1354 +#define BF_AUDIOOUT_DACSRR_RSRVD1(v) \
1355 + (((v) << 21) & BM_AUDIOOUT_DACSRR_RSRVD1)
1356 +#define BP_AUDIOOUT_DACSRR_SRC_INT 16
1357 +#define BM_AUDIOOUT_DACSRR_SRC_INT 0x001F0000
1358 +#define BF_AUDIOOUT_DACSRR_SRC_INT(v) \
1359 + (((v) << 16) & BM_AUDIOOUT_DACSRR_SRC_INT)
1360 +#define BP_AUDIOOUT_DACSRR_RSRVD0 13
1361 +#define BM_AUDIOOUT_DACSRR_RSRVD0 0x0000E000
1362 +#define BF_AUDIOOUT_DACSRR_RSRVD0(v) \
1363 + (((v) << 13) & BM_AUDIOOUT_DACSRR_RSRVD0)
1364 +#define BP_AUDIOOUT_DACSRR_SRC_FRAC 0
1365 +#define BM_AUDIOOUT_DACSRR_SRC_FRAC 0x00001FFF
1366 +#define BF_AUDIOOUT_DACSRR_SRC_FRAC(v) \
1367 + (((v) << 0) & BM_AUDIOOUT_DACSRR_SRC_FRAC)
1368 +
1369 +#define HW_AUDIOOUT_DACVOLUME (0x00000030)
1370 +#define HW_AUDIOOUT_DACVOLUME_SET (0x00000034)
1371 +#define HW_AUDIOOUT_DACVOLUME_CLR (0x00000038)
1372 +#define HW_AUDIOOUT_DACVOLUME_TOG (0x0000003c)
1373 +
1374 +#define BP_AUDIOOUT_DACVOLUME_RSRVD4 29
1375 +#define BM_AUDIOOUT_DACVOLUME_RSRVD4 0xE0000000
1376 +#define BF_AUDIOOUT_DACVOLUME_RSRVD4(v) \
1377 + (((v) << 29) & BM_AUDIOOUT_DACVOLUME_RSRVD4)
1378 +#define BM_AUDIOOUT_DACVOLUME_VOLUME_UPDATE_LEFT 0x10000000
1379 +#define BP_AUDIOOUT_DACVOLUME_RSRVD3 26
1380 +#define BM_AUDIOOUT_DACVOLUME_RSRVD3 0x0C000000
1381 +#define BF_AUDIOOUT_DACVOLUME_RSRVD3(v) \
1382 + (((v) << 26) & BM_AUDIOOUT_DACVOLUME_RSRVD3)
1383 +#define BM_AUDIOOUT_DACVOLUME_EN_ZCD 0x02000000
1384 +#define BM_AUDIOOUT_DACVOLUME_MUTE_LEFT 0x01000000
1385 +#define BP_AUDIOOUT_DACVOLUME_VOLUME_LEFT 16
1386 +#define BM_AUDIOOUT_DACVOLUME_VOLUME_LEFT 0x00FF0000
1387 +#define BF_AUDIOOUT_DACVOLUME_VOLUME_LEFT(v) \
1388 + (((v) << 16) & BM_AUDIOOUT_DACVOLUME_VOLUME_LEFT)
1389 +#define BP_AUDIOOUT_DACVOLUME_RSRVD2 13
1390 +#define BM_AUDIOOUT_DACVOLUME_RSRVD2 0x0000E000
1391 +#define BF_AUDIOOUT_DACVOLUME_RSRVD2(v) \
1392 + (((v) << 13) & BM_AUDIOOUT_DACVOLUME_RSRVD2)
1393 +#define BM_AUDIOOUT_DACVOLUME_VOLUME_UPDATE_RIGHT 0x00001000
1394 +#define BP_AUDIOOUT_DACVOLUME_RSRVD1 9
1395 +#define BM_AUDIOOUT_DACVOLUME_RSRVD1 0x00000E00
1396 +#define BF_AUDIOOUT_DACVOLUME_RSRVD1(v) \
1397 + (((v) << 9) & BM_AUDIOOUT_DACVOLUME_RSRVD1)
1398 +#define BM_AUDIOOUT_DACVOLUME_MUTE_RIGHT 0x00000100
1399 +#define BP_AUDIOOUT_DACVOLUME_VOLUME_RIGHT 0
1400 +#define BM_AUDIOOUT_DACVOLUME_VOLUME_RIGHT 0x000000FF
1401 +#define BF_AUDIOOUT_DACVOLUME_VOLUME_RIGHT(v) \
1402 + (((v) << 0) & BM_AUDIOOUT_DACVOLUME_VOLUME_RIGHT)
1403 +
1404 +#define HW_AUDIOOUT_DACDEBUG (0x00000040)
1405 +#define HW_AUDIOOUT_DACDEBUG_SET (0x00000044)
1406 +#define HW_AUDIOOUT_DACDEBUG_CLR (0x00000048)
1407 +#define HW_AUDIOOUT_DACDEBUG_TOG (0x0000004c)
1408 +
1409 +#define BM_AUDIOOUT_DACDEBUG_ENABLE_DACDMA 0x80000000
1410 +#define BP_AUDIOOUT_DACDEBUG_RSRVD2 12
1411 +#define BM_AUDIOOUT_DACDEBUG_RSRVD2 0x7FFFF000
1412 +#define BF_AUDIOOUT_DACDEBUG_RSRVD2(v) \
1413 + (((v) << 12) & BM_AUDIOOUT_DACDEBUG_RSRVD2)
1414 +#define BP_AUDIOOUT_DACDEBUG_RAM_SS 8
1415 +#define BM_AUDIOOUT_DACDEBUG_RAM_SS 0x00000F00
1416 +#define BF_AUDIOOUT_DACDEBUG_RAM_SS(v) \
1417 + (((v) << 8) & BM_AUDIOOUT_DACDEBUG_RAM_SS)
1418 +#define BP_AUDIOOUT_DACDEBUG_RSRVD1 6
1419 +#define BM_AUDIOOUT_DACDEBUG_RSRVD1 0x000000C0
1420 +#define BF_AUDIOOUT_DACDEBUG_RSRVD1(v) \
1421 + (((v) << 6) & BM_AUDIOOUT_DACDEBUG_RSRVD1)
1422 +#define BM_AUDIOOUT_DACDEBUG_SET_INTERRUPT1_CLK_CROSS 0x00000020
1423 +#define BM_AUDIOOUT_DACDEBUG_SET_INTERRUPT0_CLK_CROSS 0x00000010
1424 +#define BM_AUDIOOUT_DACDEBUG_SET_INTERRUPT1_HAND_SHAKE 0x00000008
1425 +#define BM_AUDIOOUT_DACDEBUG_SET_INTERRUPT0_HAND_SHAKE 0x00000004
1426 +#define BM_AUDIOOUT_DACDEBUG_DMA_PREQ 0x00000002
1427 +#define BM_AUDIOOUT_DACDEBUG_FIFO_STATUS 0x00000001
1428 +
1429 +#define HW_AUDIOOUT_HPVOL (0x00000050)
1430 +#define HW_AUDIOOUT_HPVOL_SET (0x00000054)
1431 +#define HW_AUDIOOUT_HPVOL_CLR (0x00000058)
1432 +#define HW_AUDIOOUT_HPVOL_TOG (0x0000005c)
1433 +
1434 +#define BP_AUDIOOUT_HPVOL_RSRVD5 29
1435 +#define BM_AUDIOOUT_HPVOL_RSRVD5 0xE0000000
1436 +#define BF_AUDIOOUT_HPVOL_RSRVD5(v) \
1437 + (((v) << 29) & BM_AUDIOOUT_HPVOL_RSRVD5)
1438 +#define BM_AUDIOOUT_HPVOL_VOLUME_UPDATE_PENDING 0x10000000
1439 +#define BP_AUDIOOUT_HPVOL_RSRVD4 26
1440 +#define BM_AUDIOOUT_HPVOL_RSRVD4 0x0C000000
1441 +#define BF_AUDIOOUT_HPVOL_RSRVD4(v) \
1442 + (((v) << 26) & BM_AUDIOOUT_HPVOL_RSRVD4)
1443 +#define BM_AUDIOOUT_HPVOL_EN_MSTR_ZCD 0x02000000
1444 +#define BM_AUDIOOUT_HPVOL_MUTE 0x01000000
1445 +#define BP_AUDIOOUT_HPVOL_RSRVD3 17
1446 +#define BM_AUDIOOUT_HPVOL_RSRVD3 0x00FE0000
1447 +#define BF_AUDIOOUT_HPVOL_RSRVD3(v) \
1448 + (((v) << 17) & BM_AUDIOOUT_HPVOL_RSRVD3)
1449 +#define BM_AUDIOOUT_HPVOL_SELECT 0x00010000
1450 +#define BM_AUDIOOUT_HPVOL_RSRVD2 0x00008000
1451 +#define BP_AUDIOOUT_HPVOL_VOL_LEFT 8
1452 +#define BM_AUDIOOUT_HPVOL_VOL_LEFT 0x00007F00
1453 +#define BF_AUDIOOUT_HPVOL_VOL_LEFT(v) \
1454 + (((v) << 8) & BM_AUDIOOUT_HPVOL_VOL_LEFT)
1455 +#define BM_AUDIOOUT_HPVOL_RSRVD1 0x00000080
1456 +#define BP_AUDIOOUT_HPVOL_VOL_RIGHT 0
1457 +#define BM_AUDIOOUT_HPVOL_VOL_RIGHT 0x0000007F
1458 +#define BF_AUDIOOUT_HPVOL_VOL_RIGHT(v) \
1459 + (((v) << 0) & BM_AUDIOOUT_HPVOL_VOL_RIGHT)
1460 +
1461 +#define HW_AUDIOOUT_RESERVED (0x00000060)
1462 +#define HW_AUDIOOUT_RESERVED_SET (0x00000064)
1463 +#define HW_AUDIOOUT_RESERVED_CLR (0x00000068)
1464 +#define HW_AUDIOOUT_RESERVED_TOG (0x0000006c)
1465 +
1466 +#define BP_AUDIOOUT_RESERVED_RSRVD1 0
1467 +#define BM_AUDIOOUT_RESERVED_RSRVD1 0xFFFFFFFF
1468 +#define BF_AUDIOOUT_RESERVED_RSRVD1(v) (v)
1469 +
1470 +#define HW_AUDIOOUT_PWRDN (0x00000070)
1471 +#define HW_AUDIOOUT_PWRDN_SET (0x00000074)
1472 +#define HW_AUDIOOUT_PWRDN_CLR (0x00000078)
1473 +#define HW_AUDIOOUT_PWRDN_TOG (0x0000007c)
1474 +
1475 +#define BP_AUDIOOUT_PWRDN_RSRVD7 25
1476 +#define BM_AUDIOOUT_PWRDN_RSRVD7 0xFE000000
1477 +#define BF_AUDIOOUT_PWRDN_RSRVD7(v) \
1478 + (((v) << 25) & BM_AUDIOOUT_PWRDN_RSRVD7)
1479 +#define BM_AUDIOOUT_PWRDN_SPEAKER 0x01000000
1480 +#define BP_AUDIOOUT_PWRDN_RSRVD6 21
1481 +#define BM_AUDIOOUT_PWRDN_RSRVD6 0x00E00000
1482 +#define BF_AUDIOOUT_PWRDN_RSRVD6(v) \
1483 + (((v) << 21) & BM_AUDIOOUT_PWRDN_RSRVD6)
1484 +#define BM_AUDIOOUT_PWRDN_SELFBIAS 0x00100000
1485 +#define BP_AUDIOOUT_PWRDN_RSRVD5 17
1486 +#define BM_AUDIOOUT_PWRDN_RSRVD5 0x000E0000
1487 +#define BF_AUDIOOUT_PWRDN_RSRVD5(v) \
1488 + (((v) << 17) & BM_AUDIOOUT_PWRDN_RSRVD5)
1489 +#define BM_AUDIOOUT_PWRDN_RIGHT_ADC 0x00010000
1490 +#define BP_AUDIOOUT_PWRDN_RSRVD4 13
1491 +#define BM_AUDIOOUT_PWRDN_RSRVD4 0x0000E000
1492 +#define BF_AUDIOOUT_PWRDN_RSRVD4(v) \
1493 + (((v) << 13) & BM_AUDIOOUT_PWRDN_RSRVD4)
1494 +#define BM_AUDIOOUT_PWRDN_DAC 0x00001000
1495 +#define BP_AUDIOOUT_PWRDN_RSRVD3 9
1496 +#define BM_AUDIOOUT_PWRDN_RSRVD3 0x00000E00
1497 +#define BF_AUDIOOUT_PWRDN_RSRVD3(v) \
1498 + (((v) << 9) & BM_AUDIOOUT_PWRDN_RSRVD3)
1499 +#define BM_AUDIOOUT_PWRDN_ADC 0x00000100
1500 +#define BP_AUDIOOUT_PWRDN_RSRVD2 5
1501 +#define BM_AUDIOOUT_PWRDN_RSRVD2 0x000000E0
1502 +#define BF_AUDIOOUT_PWRDN_RSRVD2(v) \
1503 + (((v) << 5) & BM_AUDIOOUT_PWRDN_RSRVD2)
1504 +#define BM_AUDIOOUT_PWRDN_CAPLESS 0x00000010
1505 +#define BP_AUDIOOUT_PWRDN_RSRVD1 1
1506 +#define BM_AUDIOOUT_PWRDN_RSRVD1 0x0000000E
1507 +#define BF_AUDIOOUT_PWRDN_RSRVD1(v) \
1508 + (((v) << 1) & BM_AUDIOOUT_PWRDN_RSRVD1)
1509 +#define BM_AUDIOOUT_PWRDN_HEADPHONE 0x00000001
1510 +
1511 +#define HW_AUDIOOUT_REFCTRL (0x00000080)
1512 +#define HW_AUDIOOUT_REFCTRL_SET (0x00000084)
1513 +#define HW_AUDIOOUT_REFCTRL_CLR (0x00000088)
1514 +#define HW_AUDIOOUT_REFCTRL_TOG (0x0000008c)
1515 +
1516 +#define BP_AUDIOOUT_REFCTRL_RSRVD4 27
1517 +#define BM_AUDIOOUT_REFCTRL_RSRVD4 0xF8000000
1518 +#define BF_AUDIOOUT_REFCTRL_RSRVD4(v) \
1519 + (((v) << 27) & BM_AUDIOOUT_REFCTRL_RSRVD4)
1520 +#define BM_AUDIOOUT_REFCTRL_FASTSETTLING 0x04000000
1521 +#define BM_AUDIOOUT_REFCTRL_RAISE_REF 0x02000000
1522 +#define BM_AUDIOOUT_REFCTRL_XTAL_BGR_BIAS 0x01000000
1523 +#define BM_AUDIOOUT_REFCTRL_RSRVD3 0x00800000
1524 +#define BP_AUDIOOUT_REFCTRL_VBG_ADJ 20
1525 +#define BM_AUDIOOUT_REFCTRL_VBG_ADJ 0x00700000
1526 +#define BF_AUDIOOUT_REFCTRL_VBG_ADJ(v) \
1527 + (((v) << 20) & BM_AUDIOOUT_REFCTRL_VBG_ADJ)
1528 +#define BM_AUDIOOUT_REFCTRL_LOW_PWR 0x00080000
1529 +#define BM_AUDIOOUT_REFCTRL_LW_REF 0x00040000
1530 +#define BP_AUDIOOUT_REFCTRL_BIAS_CTRL 16
1531 +#define BM_AUDIOOUT_REFCTRL_BIAS_CTRL 0x00030000
1532 +#define BF_AUDIOOUT_REFCTRL_BIAS_CTRL(v) \
1533 + (((v) << 16) & BM_AUDIOOUT_REFCTRL_BIAS_CTRL)
1534 +#define BM_AUDIOOUT_REFCTRL_RSRVD2 0x00008000
1535 +#define BM_AUDIOOUT_REFCTRL_VDDXTAL_TO_VDDD 0x00004000
1536 +#define BM_AUDIOOUT_REFCTRL_ADJ_ADC 0x00002000
1537 +#define BM_AUDIOOUT_REFCTRL_ADJ_VAG 0x00001000
1538 +#define BP_AUDIOOUT_REFCTRL_ADC_REFVAL 8
1539 +#define BM_AUDIOOUT_REFCTRL_ADC_REFVAL 0x00000F00
1540 +#define BF_AUDIOOUT_REFCTRL_ADC_REFVAL(v) \
1541 + (((v) << 8) & BM_AUDIOOUT_REFCTRL_ADC_REFVAL)
1542 +#define BP_AUDIOOUT_REFCTRL_VAG_VAL 4
1543 +#define BM_AUDIOOUT_REFCTRL_VAG_VAL 0x000000F0
1544 +#define BF_AUDIOOUT_REFCTRL_VAG_VAL(v) \
1545 + (((v) << 4) & BM_AUDIOOUT_REFCTRL_VAG_VAL)
1546 +#define BM_AUDIOOUT_REFCTRL_RSRVD1 0x00000008
1547 +#define BP_AUDIOOUT_REFCTRL_DAC_ADJ 0
1548 +#define BM_AUDIOOUT_REFCTRL_DAC_ADJ 0x00000007
1549 +#define BF_AUDIOOUT_REFCTRL_DAC_ADJ(v) \
1550 + (((v) << 0) & BM_AUDIOOUT_REFCTRL_DAC_ADJ)
1551 +
1552 +#define HW_AUDIOOUT_ANACTRL (0x00000090)
1553 +#define HW_AUDIOOUT_ANACTRL_SET (0x00000094)
1554 +#define HW_AUDIOOUT_ANACTRL_CLR (0x00000098)
1555 +#define HW_AUDIOOUT_ANACTRL_TOG (0x0000009c)
1556 +
1557 +#define BP_AUDIOOUT_ANACTRL_RSRVD8 29
1558 +#define BM_AUDIOOUT_ANACTRL_RSRVD8 0xE0000000
1559 +#define BF_AUDIOOUT_ANACTRL_RSRVD8(v) \
1560 + (((v) << 29) & BM_AUDIOOUT_ANACTRL_RSRVD8)
1561 +#define BM_AUDIOOUT_ANACTRL_SHORT_CM_STS 0x10000000
1562 +#define BP_AUDIOOUT_ANACTRL_RSRVD7 25
1563 +#define BM_AUDIOOUT_ANACTRL_RSRVD7 0x0E000000
1564 +#define BF_AUDIOOUT_ANACTRL_RSRVD7(v) \
1565 + (((v) << 25) & BM_AUDIOOUT_ANACTRL_RSRVD7)
1566 +#define BM_AUDIOOUT_ANACTRL_SHORT_LR_STS 0x01000000
1567 +#define BP_AUDIOOUT_ANACTRL_RSRVD6 22
1568 +#define BM_AUDIOOUT_ANACTRL_RSRVD6 0x00C00000
1569 +#define BF_AUDIOOUT_ANACTRL_RSRVD6(v) \
1570 + (((v) << 22) & BM_AUDIOOUT_ANACTRL_RSRVD6)
1571 +#define BP_AUDIOOUT_ANACTRL_SHORTMODE_CM 20
1572 +#define BM_AUDIOOUT_ANACTRL_SHORTMODE_CM 0x00300000
1573 +#define BF_AUDIOOUT_ANACTRL_SHORTMODE_CM(v) \
1574 + (((v) << 20) & BM_AUDIOOUT_ANACTRL_SHORTMODE_CM)
1575 +#define BM_AUDIOOUT_ANACTRL_RSRVD5 0x00080000
1576 +#define BP_AUDIOOUT_ANACTRL_SHORTMODE_LR 17
1577 +#define BM_AUDIOOUT_ANACTRL_SHORTMODE_LR 0x00060000
1578 +#define BF_AUDIOOUT_ANACTRL_SHORTMODE_LR(v) \
1579 + (((v) << 17) & BM_AUDIOOUT_ANACTRL_SHORTMODE_LR)
1580 +#define BP_AUDIOOUT_ANACTRL_RSRVD4 15
1581 +#define BM_AUDIOOUT_ANACTRL_RSRVD4 0x00018000
1582 +#define BF_AUDIOOUT_ANACTRL_RSRVD4(v) \
1583 + (((v) << 15) & BM_AUDIOOUT_ANACTRL_RSRVD4)
1584 +#define BP_AUDIOOUT_ANACTRL_SHORT_LVLADJL 12
1585 +#define BM_AUDIOOUT_ANACTRL_SHORT_LVLADJL 0x00007000
1586 +#define BF_AUDIOOUT_ANACTRL_SHORT_LVLADJL(v) \
1587 + (((v) << 12) & BM_AUDIOOUT_ANACTRL_SHORT_LVLADJL)
1588 +#define BM_AUDIOOUT_ANACTRL_RSRVD3 0x00000800
1589 +#define BP_AUDIOOUT_ANACTRL_SHORT_LVLADJR 8
1590 +#define BM_AUDIOOUT_ANACTRL_SHORT_LVLADJR 0x00000700
1591 +#define BF_AUDIOOUT_ANACTRL_SHORT_LVLADJR(v) \
1592 + (((v) << 8) & BM_AUDIOOUT_ANACTRL_SHORT_LVLADJR)
1593 +#define BP_AUDIOOUT_ANACTRL_RSRVD2 6
1594 +#define BM_AUDIOOUT_ANACTRL_RSRVD2 0x000000C0
1595 +#define BF_AUDIOOUT_ANACTRL_RSRVD2(v) \
1596 + (((v) << 6) & BM_AUDIOOUT_ANACTRL_RSRVD2)
1597 +#define BM_AUDIOOUT_ANACTRL_HP_HOLD_GND 0x00000020
1598 +#define BM_AUDIOOUT_ANACTRL_HP_CLASSAB 0x00000010
1599 +#define BP_AUDIOOUT_ANACTRL_RSRVD1 0
1600 +#define BM_AUDIOOUT_ANACTRL_RSRVD1 0x0000000F
1601 +#define BF_AUDIOOUT_ANACTRL_RSRVD1(v) \
1602 + (((v) << 0) & BM_AUDIOOUT_ANACTRL_RSRVD1)
1603 +
1604 +#define HW_AUDIOOUT_TEST (0x000000a0)
1605 +#define HW_AUDIOOUT_TEST_SET (0x000000a4)
1606 +#define HW_AUDIOOUT_TEST_CLR (0x000000a8)
1607 +#define HW_AUDIOOUT_TEST_TOG (0x000000ac)
1608 +
1609 +#define BM_AUDIOOUT_TEST_RSRVD4 0x80000000
1610 +#define BP_AUDIOOUT_TEST_HP_ANTIPOP 28
1611 +#define BM_AUDIOOUT_TEST_HP_ANTIPOP 0x70000000
1612 +#define BF_AUDIOOUT_TEST_HP_ANTIPOP(v) \
1613 + (((v) << 28) & BM_AUDIOOUT_TEST_HP_ANTIPOP)
1614 +#define BM_AUDIOOUT_TEST_RSRVD3 0x08000000
1615 +#define BM_AUDIOOUT_TEST_TM_ADCIN_TOHP 0x04000000
1616 +#define BM_AUDIOOUT_TEST_TM_LOOP 0x02000000
1617 +#define BM_AUDIOOUT_TEST_TM_HPCOMMON 0x01000000
1618 +#define BP_AUDIOOUT_TEST_HP_I1_ADJ 22
1619 +#define BM_AUDIOOUT_TEST_HP_I1_ADJ 0x00C00000
1620 +#define BF_AUDIOOUT_TEST_HP_I1_ADJ(v) \
1621 + (((v) << 22) & BM_AUDIOOUT_TEST_HP_I1_ADJ)
1622 +#define BP_AUDIOOUT_TEST_HP_IALL_ADJ 20
1623 +#define BM_AUDIOOUT_TEST_HP_IALL_ADJ 0x00300000
1624 +#define BF_AUDIOOUT_TEST_HP_IALL_ADJ(v) \
1625 + (((v) << 20) & BM_AUDIOOUT_TEST_HP_IALL_ADJ)
1626 +#define BP_AUDIOOUT_TEST_RSRVD2 14
1627 +#define BM_AUDIOOUT_TEST_RSRVD2 0x000FC000
1628 +#define BF_AUDIOOUT_TEST_RSRVD2(v) \
1629 + (((v) << 14) & BM_AUDIOOUT_TEST_RSRVD2)
1630 +#define BM_AUDIOOUT_TEST_VAG_CLASSA 0x00002000
1631 +#define BM_AUDIOOUT_TEST_VAG_DOUBLE_I 0x00001000
1632 +#define BP_AUDIOOUT_TEST_RSRVD1 4
1633 +#define BM_AUDIOOUT_TEST_RSRVD1 0x00000FF0
1634 +#define BF_AUDIOOUT_TEST_RSRVD1(v) \
1635 + (((v) << 4) & BM_AUDIOOUT_TEST_RSRVD1)
1636 +#define BM_AUDIOOUT_TEST_ADCTODAC_LOOP 0x00000008
1637 +#define BM_AUDIOOUT_TEST_DAC_CLASSA 0x00000004
1638 +#define BM_AUDIOOUT_TEST_DAC_DOUBLE_I 0x00000002
1639 +#define BM_AUDIOOUT_TEST_DAC_DIS_RTZ 0x00000001
1640 +
1641 +#define HW_AUDIOOUT_BISTCTRL (0x000000b0)
1642 +#define HW_AUDIOOUT_BISTCTRL_SET (0x000000b4)
1643 +#define HW_AUDIOOUT_BISTCTRL_CLR (0x000000b8)
1644 +#define HW_AUDIOOUT_BISTCTRL_TOG (0x000000bc)
1645 +
1646 +#define BP_AUDIOOUT_BISTCTRL_RSVD0 4
1647 +#define BM_AUDIOOUT_BISTCTRL_RSVD0 0xFFFFFFF0
1648 +#define BF_AUDIOOUT_BISTCTRL_RSVD0(v) \
1649 + (((v) << 4) & BM_AUDIOOUT_BISTCTRL_RSVD0)
1650 +#define BM_AUDIOOUT_BISTCTRL_FAIL 0x00000008
1651 +#define BM_AUDIOOUT_BISTCTRL_PASS 0x00000004
1652 +#define BM_AUDIOOUT_BISTCTRL_DONE 0x00000002
1653 +#define BM_AUDIOOUT_BISTCTRL_START 0x00000001
1654 +
1655 +#define HW_AUDIOOUT_BISTSTAT0 (0x000000c0)
1656 +#define HW_AUDIOOUT_BISTSTAT0_SET (0x000000c4)
1657 +#define HW_AUDIOOUT_BISTSTAT0_CLR (0x000000c8)
1658 +#define HW_AUDIOOUT_BISTSTAT0_TOG (0x000000cc)
1659 +
1660 +#define BP_AUDIOOUT_BISTSTAT0_RSVD0 24
1661 +#define BM_AUDIOOUT_BISTSTAT0_RSVD0 0xFF000000
1662 +#define BF_AUDIOOUT_BISTSTAT0_RSVD0(v) \
1663 + (((v) << 24) & BM_AUDIOOUT_BISTSTAT0_RSVD0)
1664 +#define BP_AUDIOOUT_BISTSTAT0_DATA 0
1665 +#define BM_AUDIOOUT_BISTSTAT0_DATA 0x00FFFFFF
1666 +#define BF_AUDIOOUT_BISTSTAT0_DATA(v) \
1667 + (((v) << 0) & BM_AUDIOOUT_BISTSTAT0_DATA)
1668 +
1669 +#define HW_AUDIOOUT_BISTSTAT1 (0x000000d0)
1670 +#define HW_AUDIOOUT_BISTSTAT1_SET (0x000000d4)
1671 +#define HW_AUDIOOUT_BISTSTAT1_CLR (0x000000d8)
1672 +#define HW_AUDIOOUT_BISTSTAT1_TOG (0x000000dc)
1673 +
1674 +#define BP_AUDIOOUT_BISTSTAT1_RSVD1 29
1675 +#define BM_AUDIOOUT_BISTSTAT1_RSVD1 0xE0000000
1676 +#define BF_AUDIOOUT_BISTSTAT1_RSVD1(v) \
1677 + (((v) << 29) & BM_AUDIOOUT_BISTSTAT1_RSVD1)
1678 +#define BP_AUDIOOUT_BISTSTAT1_STATE 24
1679 +#define BM_AUDIOOUT_BISTSTAT1_STATE 0x1F000000
1680 +#define BF_AUDIOOUT_BISTSTAT1_STATE(v) \
1681 + (((v) << 24) & BM_AUDIOOUT_BISTSTAT1_STATE)
1682 +#define BP_AUDIOOUT_BISTSTAT1_RSVD0 8
1683 +#define BM_AUDIOOUT_BISTSTAT1_RSVD0 0x00FFFF00
1684 +#define BF_AUDIOOUT_BISTSTAT1_RSVD0(v) \
1685 + (((v) << 8) & BM_AUDIOOUT_BISTSTAT1_RSVD0)
1686 +#define BP_AUDIOOUT_BISTSTAT1_ADDR 0
1687 +#define BM_AUDIOOUT_BISTSTAT1_ADDR 0x000000FF
1688 +#define BF_AUDIOOUT_BISTSTAT1_ADDR(v) \
1689 + (((v) << 0) & BM_AUDIOOUT_BISTSTAT1_ADDR)
1690 +
1691 +#define HW_AUDIOOUT_ANACLKCTRL (0x000000e0)
1692 +#define HW_AUDIOOUT_ANACLKCTRL_SET (0x000000e4)
1693 +#define HW_AUDIOOUT_ANACLKCTRL_CLR (0x000000e8)
1694 +#define HW_AUDIOOUT_ANACLKCTRL_TOG (0x000000ec)
1695 +
1696 +#define BM_AUDIOOUT_ANACLKCTRL_CLKGATE 0x80000000
1697 +#define BP_AUDIOOUT_ANACLKCTRL_RSRVD3 5
1698 +#define BM_AUDIOOUT_ANACLKCTRL_RSRVD3 0x7FFFFFE0
1699 +#define BF_AUDIOOUT_ANACLKCTRL_RSRVD3(v) \
1700 + (((v) << 5) & BM_AUDIOOUT_ANACLKCTRL_RSRVD3)
1701 +#define BM_AUDIOOUT_ANACLKCTRL_INVERT_DACCLK 0x00000010
1702 +#define BM_AUDIOOUT_ANACLKCTRL_RSRVD2 0x00000008
1703 +#define BP_AUDIOOUT_ANACLKCTRL_DACDIV 0
1704 +#define BM_AUDIOOUT_ANACLKCTRL_DACDIV 0x00000007
1705 +#define BF_AUDIOOUT_ANACLKCTRL_DACDIV(v) \
1706 + (((v) << 0) & BM_AUDIOOUT_ANACLKCTRL_DACDIV)
1707 +
1708 +#define HW_AUDIOOUT_DATA (0x000000f0)
1709 +#define HW_AUDIOOUT_DATA_SET (0x000000f4)
1710 +#define HW_AUDIOOUT_DATA_CLR (0x000000f8)
1711 +#define HW_AUDIOOUT_DATA_TOG (0x000000fc)
1712 +
1713 +#define BP_AUDIOOUT_DATA_HIGH 16
1714 +#define BM_AUDIOOUT_DATA_HIGH 0xFFFF0000
1715 +#define BF_AUDIOOUT_DATA_HIGH(v) \
1716 + (((v) << 16) & BM_AUDIOOUT_DATA_HIGH)
1717 +#define BP_AUDIOOUT_DATA_LOW 0
1718 +#define BM_AUDIOOUT_DATA_LOW 0x0000FFFF
1719 +#define BF_AUDIOOUT_DATA_LOW(v) \
1720 + (((v) << 0) & BM_AUDIOOUT_DATA_LOW)
1721 +
1722 +#define HW_AUDIOOUT_SPEAKERCTRL (0x00000100)
1723 +#define HW_AUDIOOUT_SPEAKERCTRL_SET (0x00000104)
1724 +#define HW_AUDIOOUT_SPEAKERCTRL_CLR (0x00000108)
1725 +#define HW_AUDIOOUT_SPEAKERCTRL_TOG (0x0000010c)
1726 +
1727 +#define BP_AUDIOOUT_SPEAKERCTRL_RSRVD2 25
1728 +#define BM_AUDIOOUT_SPEAKERCTRL_RSRVD2 0xFE000000
1729 +#define BF_AUDIOOUT_SPEAKERCTRL_RSRVD2(v) \
1730 + (((v) << 25) & BM_AUDIOOUT_SPEAKERCTRL_RSRVD2)
1731 +#define BM_AUDIOOUT_SPEAKERCTRL_MUTE 0x01000000
1732 +#define BP_AUDIOOUT_SPEAKERCTRL_I1_ADJ 22
1733 +#define BM_AUDIOOUT_SPEAKERCTRL_I1_ADJ 0x00C00000
1734 +#define BF_AUDIOOUT_SPEAKERCTRL_I1_ADJ(v) \
1735 + (((v) << 22) & BM_AUDIOOUT_SPEAKERCTRL_I1_ADJ)
1736 +#define BP_AUDIOOUT_SPEAKERCTRL_IALL_ADJ 20
1737 +#define BM_AUDIOOUT_SPEAKERCTRL_IALL_ADJ 0x00300000
1738 +#define BF_AUDIOOUT_SPEAKERCTRL_IALL_ADJ(v) \
1739 + (((v) << 20) & BM_AUDIOOUT_SPEAKERCTRL_IALL_ADJ)
1740 +#define BP_AUDIOOUT_SPEAKERCTRL_RSRVD1 16
1741 +#define BM_AUDIOOUT_SPEAKERCTRL_RSRVD1 0x000F0000
1742 +#define BF_AUDIOOUT_SPEAKERCTRL_RSRVD1(v) \
1743 + (((v) << 16) & BM_AUDIOOUT_SPEAKERCTRL_RSRVD1)
1744 +#define BP_AUDIOOUT_SPEAKERCTRL_POSDRIVER 14
1745 +#define BM_AUDIOOUT_SPEAKERCTRL_POSDRIVER 0x0000C000
1746 +#define BF_AUDIOOUT_SPEAKERCTRL_POSDRIVER(v) \
1747 + (((v) << 14) & BM_AUDIOOUT_SPEAKERCTRL_POSDRIVER)
1748 +#define BP_AUDIOOUT_SPEAKERCTRL_NEGDRIVER 12
1749 +#define BM_AUDIOOUT_SPEAKERCTRL_NEGDRIVER 0x00003000
1750 +#define BF_AUDIOOUT_SPEAKERCTRL_NEGDRIVER(v) \
1751 + (((v) << 12) & BM_AUDIOOUT_SPEAKERCTRL_NEGDRIVER)
1752 +#define BP_AUDIOOUT_SPEAKERCTRL_RSRVD0 0
1753 +#define BM_AUDIOOUT_SPEAKERCTRL_RSRVD0 0x00000FFF
1754 +#define BF_AUDIOOUT_SPEAKERCTRL_RSRVD0(v) \
1755 + (((v) << 0) & BM_AUDIOOUT_SPEAKERCTRL_RSRVD0)
1756 +
1757 +#define HW_AUDIOOUT_VERSION (0x00000200)
1758 +
1759 +#define BP_AUDIOOUT_VERSION_MAJOR 24
1760 +#define BM_AUDIOOUT_VERSION_MAJOR 0xFF000000
1761 +#define BF_AUDIOOUT_VERSION_MAJOR(v) \
1762 + (((v) << 24) & BM_AUDIOOUT_VERSION_MAJOR)
1763 +#define BP_AUDIOOUT_VERSION_MINOR 16
1764 +#define BM_AUDIOOUT_VERSION_MINOR 0x00FF0000
1765 +#define BF_AUDIOOUT_VERSION_MINOR(v) \
1766 + (((v) << 16) & BM_AUDIOOUT_VERSION_MINOR)
1767 +#define BP_AUDIOOUT_VERSION_STEP 0
1768 +#define BM_AUDIOOUT_VERSION_STEP 0x0000FFFF
1769 +#define BF_AUDIOOUT_VERSION_STEP(v) \
1770 + (((v) << 0) & BM_AUDIOOUT_VERSION_STEP)
1771 +
1772 +/* AUDIOIN */
1773 +#define HW_AUDIOIN_CTRL (0x00000000)
1774 +#define HW_AUDIOIN_CTRL_SET (0x00000004)
1775 +#define HW_AUDIOIN_CTRL_CLR (0x00000008)
1776 +#define HW_AUDIOIN_CTRL_TOG (0x0000000c)
1777 +
1778 +#define BM_AUDIOIN_CTRL_SFTRST 0x80000000
1779 +#define BM_AUDIOIN_CTRL_CLKGATE 0x40000000
1780 +#define BP_AUDIOIN_CTRL_RSRVD3 21
1781 +#define BM_AUDIOIN_CTRL_RSRVD3 0x3FE00000
1782 +#define BF_AUDIOIN_CTRL_RSRVD3(v) \
1783 + (((v) << 21) & BM_AUDIOIN_CTRL_RSRVD3)
1784 +#define BP_AUDIOIN_CTRL_DMAWAIT_COUNT 16
1785 +#define BM_AUDIOIN_CTRL_DMAWAIT_COUNT 0x001F0000
1786 +#define BF_AUDIOIN_CTRL_DMAWAIT_COUNT(v) \
1787 + (((v) << 16) & BM_AUDIOIN_CTRL_DMAWAIT_COUNT)
1788 +#define BP_AUDIOIN_CTRL_RSRVD1 11
1789 +#define BM_AUDIOIN_CTRL_RSRVD1 0x0000F800
1790 +#define BF_AUDIOIN_CTRL_RSRVD1(v) \
1791 + (((v) << 11) & BM_AUDIOIN_CTRL_RSRVD1)
1792 +#define BM_AUDIOIN_CTRL_LR_SWAP 0x00000400
1793 +#define BM_AUDIOIN_CTRL_EDGE_SYNC 0x00000200
1794 +#define BM_AUDIOIN_CTRL_INVERT_1BIT 0x00000100
1795 +#define BM_AUDIOIN_CTRL_OFFSET_ENABLE 0x00000080
1796 +#define BM_AUDIOIN_CTRL_HPF_ENABLE 0x00000040
1797 +#define BM_AUDIOIN_CTRL_WORD_LENGTH 0x00000020
1798 +#define BM_AUDIOIN_CTRL_LOOPBACK 0x00000010
1799 +#define BM_AUDIOIN_CTRL_FIFO_UNDERFLOW_IRQ 0x00000008
1800 +#define BM_AUDIOIN_CTRL_FIFO_OVERFLOW_IRQ 0x00000004
1801 +#define BM_AUDIOIN_CTRL_FIFO_ERROR_IRQ_EN 0x00000002
1802 +#define BM_AUDIOIN_CTRL_RUN 0x00000001
1803 +
1804 +#define HW_AUDIOIN_STAT (0x00000010)
1805 +#define HW_AUDIOIN_STAT_SET (0x00000014)
1806 +#define HW_AUDIOIN_STAT_CLR (0x00000018)
1807 +#define HW_AUDIOIN_STAT_TOG (0x0000001c)
1808 +
1809 +#define BM_AUDIOIN_STAT_ADC_PRESENT 0x80000000
1810 +#define BP_AUDIOIN_STAT_RSRVD3 0
1811 +#define BM_AUDIOIN_STAT_RSRVD3 0x7FFFFFFF
1812 +#define BF_AUDIOIN_STAT_RSRVD3(v) \
1813 + (((v) << 0) & BM_AUDIOIN_STAT_RSRVD3)
1814 +
1815 +#define HW_AUDIOIN_ADCSRR (0x00000020)
1816 +#define HW_AUDIOIN_ADCSRR_SET (0x00000024)
1817 +#define HW_AUDIOIN_ADCSRR_CLR (0x00000028)
1818 +#define HW_AUDIOIN_ADCSRR_TOG (0x0000002c)
1819 +
1820 +#define BM_AUDIOIN_ADCSRR_OSR 0x80000000
1821 +#define BV_AUDIOIN_ADCSRR_OSR__OSR6 0x0
1822 +#define BV_AUDIOIN_ADCSRR_OSR__OSR12 0x1
1823 +#define BP_AUDIOIN_ADCSRR_BASEMULT 28
1824 +#define BM_AUDIOIN_ADCSRR_BASEMULT 0x70000000
1825 +#define BF_AUDIOIN_ADCSRR_BASEMULT(v) \
1826 + (((v) << 28) & BM_AUDIOIN_ADCSRR_BASEMULT)
1827 +#define BV_AUDIOIN_ADCSRR_BASEMULT__SINGLE_RATE 0x1
1828 +#define BV_AUDIOIN_ADCSRR_BASEMULT__DOUBLE_RATE 0x2
1829 +#define BV_AUDIOIN_ADCSRR_BASEMULT__QUAD_RATE 0x4
1830 +#define BM_AUDIOIN_ADCSRR_RSRVD2 0x08000000
1831 +#define BP_AUDIOIN_ADCSRR_SRC_HOLD 24
1832 +#define BM_AUDIOIN_ADCSRR_SRC_HOLD 0x07000000
1833 +#define BF_AUDIOIN_ADCSRR_SRC_HOLD(v) \
1834 + (((v) << 24) & BM_AUDIOIN_ADCSRR_SRC_HOLD)
1835 +#define BP_AUDIOIN_ADCSRR_RSRVD1 21
1836 +#define BM_AUDIOIN_ADCSRR_RSRVD1 0x00E00000
1837 +#define BF_AUDIOIN_ADCSRR_RSRVD1(v) \
1838 + (((v) << 21) & BM_AUDIOIN_ADCSRR_RSRVD1)
1839 +#define BP_AUDIOIN_ADCSRR_SRC_INT 16
1840 +#define BM_AUDIOIN_ADCSRR_SRC_INT 0x001F0000
1841 +#define BF_AUDIOIN_ADCSRR_SRC_INT(v) \
1842 + (((v) << 16) & BM_AUDIOIN_ADCSRR_SRC_INT)
1843 +#define BP_AUDIOIN_ADCSRR_RSRVD0 13
1844 +#define BM_AUDIOIN_ADCSRR_RSRVD0 0x0000E000
1845 +#define BF_AUDIOIN_ADCSRR_RSRVD0(v) \
1846 + (((v) << 13) & BM_AUDIOIN_ADCSRR_RSRVD0)
1847 +#define BP_AUDIOIN_ADCSRR_SRC_FRAC 0
1848 +#define BM_AUDIOIN_ADCSRR_SRC_FRAC 0x00001FFF
1849 +#define BF_AUDIOIN_ADCSRR_SRC_FRAC(v) \
1850 + (((v) << 0) & BM_AUDIOIN_ADCSRR_SRC_FRAC)
1851 +
1852 +#define HW_AUDIOIN_ADCVOLUME (0x00000030)
1853 +#define HW_AUDIOIN_ADCVOLUME_SET (0x00000034)
1854 +#define HW_AUDIOIN_ADCVOLUME_CLR (0x00000038)
1855 +#define HW_AUDIOIN_ADCVOLUME_TOG (0x0000003c)
1856 +
1857 +#define BP_AUDIOIN_ADCVOLUME_RSRVD5 29
1858 +#define BM_AUDIOIN_ADCVOLUME_RSRVD5 0xE0000000
1859 +#define BF_AUDIOIN_ADCVOLUME_RSRVD5(v) \
1860 + (((v) << 29) & BM_AUDIOIN_ADCVOLUME_RSRVD5)
1861 +#define BM_AUDIOIN_ADCVOLUME_VOLUME_UPDATE_LEFT 0x10000000
1862 +#define BP_AUDIOIN_ADCVOLUME_RSRVD4 26
1863 +#define BM_AUDIOIN_ADCVOLUME_RSRVD4 0x0C000000
1864 +#define BF_AUDIOIN_ADCVOLUME_RSRVD4(v) \
1865 + (((v) << 26) & BM_AUDIOIN_ADCVOLUME_RSRVD4)
1866 +#define BM_AUDIOIN_ADCVOLUME_EN_ZCD 0x02000000
1867 +#define BM_AUDIOIN_ADCVOLUME_RSRVD3 0x01000000
1868 +#define BP_AUDIOIN_ADCVOLUME_VOLUME_LEFT 16
1869 +#define BM_AUDIOIN_ADCVOLUME_VOLUME_LEFT 0x00FF0000
1870 +#define BF_AUDIOIN_ADCVOLUME_VOLUME_LEFT(v) \
1871 + (((v) << 16) & BM_AUDIOIN_ADCVOLUME_VOLUME_LEFT)
1872 +#define BP_AUDIOIN_ADCVOLUME_RSRVD2 13
1873 +#define BM_AUDIOIN_ADCVOLUME_RSRVD2 0x0000E000
1874 +#define BF_AUDIOIN_ADCVOLUME_RSRVD2(v) \
1875 + (((v) << 13) & BM_AUDIOIN_ADCVOLUME_RSRVD2)
1876 +#define BM_AUDIOIN_ADCVOLUME_VOLUME_UPDATE_RIGHT 0x00001000
1877 +#define BP_AUDIOIN_ADCVOLUME_RSRVD1 8
1878 +#define BM_AUDIOIN_ADCVOLUME_RSRVD1 0x00000F00
1879 +#define BF_AUDIOIN_ADCVOLUME_RSRVD1(v) \
1880 + (((v) << 8) & BM_AUDIOIN_ADCVOLUME_RSRVD1)
1881 +#define BP_AUDIOIN_ADCVOLUME_VOLUME_RIGHT 0
1882 +#define BM_AUDIOIN_ADCVOLUME_VOLUME_RIGHT 0x000000FF
1883 +#define BF_AUDIOIN_ADCVOLUME_VOLUME_RIGHT(v) \
1884 + (((v) << 0) & BM_AUDIOIN_ADCVOLUME_VOLUME_RIGHT)
1885 +
1886 +#define HW_AUDIOIN_ADCDEBUG (0x00000040)
1887 +#define HW_AUDIOIN_ADCDEBUG_SET (0x00000044)
1888 +#define HW_AUDIOIN_ADCDEBUG_CLR (0x00000048)
1889 +#define HW_AUDIOIN_ADCDEBUG_TOG (0x0000004c)
1890 +
1891 +#define BM_AUDIOIN_ADCDEBUG_ENABLE_ADCDMA 0x80000000
1892 +#define BP_AUDIOIN_ADCDEBUG_RSRVD1 4
1893 +#define BM_AUDIOIN_ADCDEBUG_RSRVD1 0x7FFFFFF0
1894 +#define BF_AUDIOIN_ADCDEBUG_RSRVD1(v) \
1895 + (((v) << 4) & BM_AUDIOIN_ADCDEBUG_RSRVD1)
1896 +#define BM_AUDIOIN_ADCDEBUG_ADC_DMA_REQ_HAND_SHAKE_CLK_CROSS 0x00000008
1897 +#define BM_AUDIOIN_ADCDEBUG_SET_INTERRUPT3_HAND_SHAKE 0x00000004
1898 +#define BM_AUDIOIN_ADCDEBUG_DMA_PREQ 0x00000002
1899 +#define BM_AUDIOIN_ADCDEBUG_FIFO_STATUS 0x00000001
1900 +
1901 +#define HW_AUDIOIN_ADCVOL (0x00000050)
1902 +#define HW_AUDIOIN_ADCVOL_SET (0x00000054)
1903 +#define HW_AUDIOIN_ADCVOL_CLR (0x00000058)
1904 +#define HW_AUDIOIN_ADCVOL_TOG (0x0000005c)
1905 +
1906 +#define BP_AUDIOIN_ADCVOL_RSRVD4 29
1907 +#define BM_AUDIOIN_ADCVOL_RSRVD4 0xE0000000
1908 +#define BF_AUDIOIN_ADCVOL_RSRVD4(v) \
1909 + (((v) << 29) & BM_AUDIOIN_ADCVOL_RSRVD4)
1910 +#define BM_AUDIOIN_ADCVOL_VOLUME_UPDATE_PENDING 0x10000000
1911 +#define BP_AUDIOIN_ADCVOL_RSRVD3 26
1912 +#define BM_AUDIOIN_ADCVOL_RSRVD3 0x0C000000
1913 +#define BF_AUDIOIN_ADCVOL_RSRVD3(v) \
1914 + (((v) << 26) & BM_AUDIOIN_ADCVOL_RSRVD3)
1915 +#define BM_AUDIOIN_ADCVOL_EN_ADC_ZCD 0x02000000
1916 +#define BM_AUDIOIN_ADCVOL_MUTE 0x01000000
1917 +#define BP_AUDIOIN_ADCVOL_RSRVD2 14
1918 +#define BM_AUDIOIN_ADCVOL_RSRVD2 0x00FFC000
1919 +#define BF_AUDIOIN_ADCVOL_RSRVD2(v) \
1920 + (((v) << 14) & BM_AUDIOIN_ADCVOL_RSRVD2)
1921 +#define BP_AUDIOIN_ADCVOL_SELECT_LEFT 12
1922 +#define BM_AUDIOIN_ADCVOL_SELECT_LEFT 0x00003000
1923 +#define BF_AUDIOIN_ADCVOL_SELECT_LEFT(v) \
1924 + (((v) << 12) & BM_AUDIOIN_ADCVOL_SELECT_LEFT)
1925 +#define BP_AUDIOIN_ADCVOL_GAIN_LEFT 8
1926 +#define BM_AUDIOIN_ADCVOL_GAIN_LEFT 0x00000F00
1927 +#define BF_AUDIOIN_ADCVOL_GAIN_LEFT(v) \
1928 + (((v) << 8) & BM_AUDIOIN_ADCVOL_GAIN_LEFT)
1929 +#define BP_AUDIOIN_ADCVOL_RSRVD1 6
1930 +#define BM_AUDIOIN_ADCVOL_RSRVD1 0x000000C0
1931 +#define BF_AUDIOIN_ADCVOL_RSRVD1(v) \
1932 + (((v) << 6) & BM_AUDIOIN_ADCVOL_RSRVD1)
1933 +#define BP_AUDIOIN_ADCVOL_SELECT_RIGHT 4
1934 +#define BM_AUDIOIN_ADCVOL_SELECT_RIGHT 0x00000030
1935 +#define BF_AUDIOIN_ADCVOL_SELECT_RIGHT(v) \
1936 + (((v) << 4) & BM_AUDIOIN_ADCVOL_SELECT_RIGHT)
1937 +#define BP_AUDIOIN_ADCVOL_GAIN_RIGHT 0
1938 +#define BM_AUDIOIN_ADCVOL_GAIN_RIGHT 0x0000000F
1939 +#define BF_AUDIOIN_ADCVOL_GAIN_RIGHT(v) \
1940 + (((v) << 0) & BM_AUDIOIN_ADCVOL_GAIN_RIGHT)
1941 +
1942 +#define HW_AUDIOIN_MICLINE (0x00000060)
1943 +#define HW_AUDIOIN_MICLINE_SET (0x00000064)
1944 +#define HW_AUDIOIN_MICLINE_CLR (0x00000068)
1945 +#define HW_AUDIOIN_MICLINE_TOG (0x0000006c)
1946 +
1947 +#define BP_AUDIOIN_MICLINE_RSRVD6 30
1948 +#define BM_AUDIOIN_MICLINE_RSRVD6 0xC0000000
1949 +#define BF_AUDIOIN_MICLINE_RSRVD6(v) \
1950 + (((v) << 30) & BM_AUDIOIN_MICLINE_RSRVD6)
1951 +#define BM_AUDIOIN_MICLINE_DIVIDE_LINE1 0x20000000
1952 +#define BM_AUDIOIN_MICLINE_DIVIDE_LINE2 0x10000000
1953 +#define BP_AUDIOIN_MICLINE_RSRVD5 25
1954 +#define BM_AUDIOIN_MICLINE_RSRVD5 0x0E000000
1955 +#define BF_AUDIOIN_MICLINE_RSRVD5(v) \
1956 + (((v) << 25) & BM_AUDIOIN_MICLINE_RSRVD5)
1957 +#define BM_AUDIOIN_MICLINE_MIC_SELECT 0x01000000
1958 +#define BP_AUDIOIN_MICLINE_RSRVD4 22
1959 +#define BM_AUDIOIN_MICLINE_RSRVD4 0x00C00000
1960 +#define BF_AUDIOIN_MICLINE_RSRVD4(v) \
1961 + (((v) << 22) & BM_AUDIOIN_MICLINE_RSRVD4)
1962 +#define BP_AUDIOIN_MICLINE_MIC_RESISTOR 20
1963 +#define BM_AUDIOIN_MICLINE_MIC_RESISTOR 0x00300000
1964 +#define BF_AUDIOIN_MICLINE_MIC_RESISTOR(v) \
1965 + (((v) << 20) & BM_AUDIOIN_MICLINE_MIC_RESISTOR)
1966 +#define BM_AUDIOIN_MICLINE_RSRVD3 0x00080000
1967 +#define BP_AUDIOIN_MICLINE_MIC_BIAS 16
1968 +#define BM_AUDIOIN_MICLINE_MIC_BIAS 0x00070000
1969 +#define BF_AUDIOIN_MICLINE_MIC_BIAS(v) \
1970 + (((v) << 16) & BM_AUDIOIN_MICLINE_MIC_BIAS)
1971 +#define BP_AUDIOIN_MICLINE_RSRVD2 6
1972 +#define BM_AUDIOIN_MICLINE_RSRVD2 0x0000FFC0
1973 +#define BF_AUDIOIN_MICLINE_RSRVD2(v) \
1974 + (((v) << 6) & BM_AUDIOIN_MICLINE_RSRVD2)
1975 +#define BP_AUDIOIN_MICLINE_MIC_CHOPCLK 4
1976 +#define BM_AUDIOIN_MICLINE_MIC_CHOPCLK 0x00000030
1977 +#define BF_AUDIOIN_MICLINE_MIC_CHOPCLK(v) \
1978 + (((v) << 4) & BM_AUDIOIN_MICLINE_MIC_CHOPCLK)
1979 +#define BP_AUDIOIN_MICLINE_RSRVD1 2
1980 +#define BM_AUDIOIN_MICLINE_RSRVD1 0x0000000C
1981 +#define BF_AUDIOIN_MICLINE_RSRVD1(v) \
1982 + (((v) << 2) & BM_AUDIOIN_MICLINE_RSRVD1)
1983 +#define BP_AUDIOIN_MICLINE_MIC_GAIN 0
1984 +#define BM_AUDIOIN_MICLINE_MIC_GAIN 0x00000003
1985 +#define BF_AUDIOIN_MICLINE_MIC_GAIN(v) \
1986 + (((v) << 0) & BM_AUDIOIN_MICLINE_MIC_GAIN)
1987 +
1988 +#define HW_AUDIOIN_ANACLKCTRL (0x00000070)
1989 +#define HW_AUDIOIN_ANACLKCTRL_SET (0x00000074)
1990 +#define HW_AUDIOIN_ANACLKCTRL_CLR (0x00000078)
1991 +#define HW_AUDIOIN_ANACLKCTRL_TOG (0x0000007c)
1992 +
1993 +#define BM_AUDIOIN_ANACLKCTRL_CLKGATE 0x80000000
1994 +#define BP_AUDIOIN_ANACLKCTRL_RSRVD4 11
1995 +#define BM_AUDIOIN_ANACLKCTRL_RSRVD4 0x7FFFF800
1996 +#define BF_AUDIOIN_ANACLKCTRL_RSRVD4(v) \
1997 + (((v) << 11) & BM_AUDIOIN_ANACLKCTRL_RSRVD4)
1998 +#define BM_AUDIOIN_ANACLKCTRL_DITHER_OFF 0x00000400
1999 +#define BM_AUDIOIN_ANACLKCTRL_SLOW_DITHER 0x00000200
2000 +#define BM_AUDIOIN_ANACLKCTRL_INVERT_ADCCLK 0x00000100
2001 +#define BP_AUDIOIN_ANACLKCTRL_RSRVD3 6
2002 +#define BM_AUDIOIN_ANACLKCTRL_RSRVD3 0x000000C0
2003 +#define BF_AUDIOIN_ANACLKCTRL_RSRVD3(v) \
2004 + (((v) << 6) & BM_AUDIOIN_ANACLKCTRL_RSRVD3)
2005 +#define BP_AUDIOIN_ANACLKCTRL_ADCCLK_SHIFT 4
2006 +#define BM_AUDIOIN_ANACLKCTRL_ADCCLK_SHIFT 0x00000030
2007 +#define BF_AUDIOIN_ANACLKCTRL_ADCCLK_SHIFT(v) \
2008 + (((v) << 4) & BM_AUDIOIN_ANACLKCTRL_ADCCLK_SHIFT)
2009 +#define BM_AUDIOIN_ANACLKCTRL_RSRVD2 0x00000008
2010 +#define BP_AUDIOIN_ANACLKCTRL_ADCDIV 0
2011 +#define BM_AUDIOIN_ANACLKCTRL_ADCDIV 0x00000007
2012 +#define BF_AUDIOIN_ANACLKCTRL_ADCDIV(v) \
2013 + (((v) << 0) & BM_AUDIOIN_ANACLKCTRL_ADCDIV)
2014 +
2015 +#define HW_AUDIOIN_DATA (0x00000080)
2016 +#define HW_AUDIOIN_DATA_SET (0x00000084)
2017 +#define HW_AUDIOIN_DATA_CLR (0x00000088)
2018 +#define HW_AUDIOIN_DATA_TOG (0x0000008c)
2019 +
2020 +#define BP_AUDIOIN_DATA_HIGH 16
2021 +#define BM_AUDIOIN_DATA_HIGH 0xFFFF0000
2022 +#define BF_AUDIOIN_DATA_HIGH(v) \
2023 + (((v) << 16) & BM_AUDIOIN_DATA_HIGH)
2024 +#define BP_AUDIOIN_DATA_LOW 0
2025 +#define BM_AUDIOIN_DATA_LOW 0x0000FFFF
2026 +#define BF_AUDIOIN_DATA_LOW(v) \
2027 + (((v) << 0) & BM_AUDIOIN_DATA_LOW)
2028 +
2029 +#define BV_AUDIOIN_ADCVOL_SELECT__MIC 0x00
2030 +
2031 +#endif /* __MXS_ADC_CODEC_H */
2032 diff --git a/sound/soc/mxs/Kconfig b/sound/soc/mxs/Kconfig
2033 index 78d321c..9b8dd7d 100644
2034 --- a/sound/soc/mxs/Kconfig
2035 +++ b/sound/soc/mxs/Kconfig
2036 @@ -18,3 +18,13 @@ config SND_SOC_MXS_SGTL5000
2037 a sgtl5000 codec.
2038
2039 endif # SND_MXS_SOC
2040 +
2041 +
2042 +config SND_MXS_SOC_BUILTIN
2043 + tristate "SoC Audio for Freescale i.MX23 built-in codec"
2044 + depends on ARCH_MXS
2045 + select SND_SOC_GENERIC_DMAENGINE_PCM
2046 + select SND_SOC_MXS_BUILTIN_CODEC
2047 + help
2048 + Say Y or M if you want to add support for codecs attached to
2049 + the MXS SAIF interface.
2050 diff --git a/sound/soc/mxs/Makefile b/sound/soc/mxs/Makefile
2051 index 565b5b5..cd0cf16 100644
2052 --- a/sound/soc/mxs/Makefile
2053 +++ b/sound/soc/mxs/Makefile
2054 @@ -8,3 +8,12 @@ obj-$(CONFIG_SND_MXS_SOC) += snd-soc-mxs.o snd-soc-mxs-pcm.o
2055 snd-soc-mxs-sgtl5000-objs := mxs-sgtl5000.o
2056
2057 obj-$(CONFIG_SND_SOC_MXS_SGTL5000) += snd-soc-mxs-sgtl5000.o
2058 +
2059 +# i.MX23 built-in audio Machine and Platform support
2060 +snd-soc-mxs-builtin-pcm-objs := mxs-builtin-pcm.o
2061 +snd-soc-mxs-builtin-dai-objs := mxs-builtin-dai.o
2062 +snd-soc-mxs-builtin-audio-objs := mxs-builtin-audio.o
2063 +
2064 +obj-$(CONFIG_SND_MXS_SOC_BUILTIN) += snd-soc-mxs-builtin-pcm.o
2065 +obj-$(CONFIG_SND_MXS_SOC_BUILTIN) += snd-soc-mxs-builtin-dai.o
2066 +obj-$(CONFIG_SND_MXS_SOC_BUILTIN) += snd-soc-mxs-builtin-audio.o
2067 diff --git a/sound/soc/mxs/mxs-builtin-audio.c b/sound/soc/mxs/mxs-builtin-audio.c
2068 new file mode 100644
2069 index 0000000..7a27c63
2070 --- /dev/null
2071 +++ b/sound/soc/mxs/mxs-builtin-audio.c
2072 @@ -0,0 +1,120 @@
2073 +/*
2074 + * mxs-builtin-audio.c -- i.MX233 built-in codec ALSA Soc Audio driver
2075 + *
2076 + * Author: Michal Ulianko <michal.ulianko@gmail.com>
2077 + *
2078 + * This program is free software; you can redistribute it and/or modify
2079 + * it under the terms of the GNU General Public License version 2 as
2080 + * published by the Free Software Foundation.
2081 + */
2082 +
2083 +#include <linux/module.h>
2084 +#include <linux/device.h>
2085 +#include <linux/of.h>
2086 +#include <linux/of_device.h>
2087 +#include <sound/core.h>
2088 +#include <sound/pcm.h>
2089 +#include <sound/soc.h>
2090 +#include <sound/jack.h>
2091 +#include <sound/soc-dapm.h>
2092 +#include <asm/mach-types.h>
2093 +
2094 +static struct snd_soc_dai_link mxs_adc_dai_link[] = {
2095 + {
2096 + .name = "MXS ADC/DAC",
2097 + .stream_name = "MXS ADC/DAC",
2098 + .codec_dai_name = "mxs-builtin-codec-dai",
2099 +// .codec_name = "mxs-builtin-codec",
2100 +// .cpu_dai_name = "mxs-builtin-cpu-dai",
2101 +// .platform_name = "mxs-builtin-cpu-dai",
2102 +// .ops = &mxs_sgtl5000_hifi_ops,
2103 + },
2104 +};
2105 +
2106 +static struct snd_soc_card mxs_adc_audio = {
2107 + .name = "mxs-builtin-audio",
2108 + .owner = THIS_MODULE,
2109 + .dai_link = mxs_adc_dai_link,
2110 + .num_links = ARRAY_SIZE(mxs_adc_dai_link),
2111 +};
2112 +
2113 +static int mxsadc_audio_probe_dt(struct platform_device *pdev)
2114 +{
2115 + struct device_node *np = pdev->dev.of_node;
2116 + struct device_node *cpu_dai_np, *codec_np;
2117 + int ret = 0;
2118 +
2119 + if (!np)
2120 + return 1; /* no device tree */
2121 +
2122 + cpu_dai_np = of_parse_phandle(np, "cpu-dai", 0);
2123 + codec_np = of_parse_phandle(np, "audio-codec", 0);
2124 + if (!cpu_dai_np || !codec_np) {
2125 + dev_err(&pdev->dev, "phandle missing or invalid\n");
2126 + return -EINVAL;
2127 + }
2128 +
2129 + mxs_adc_dai_link[0].codec_name = NULL;
2130 + mxs_adc_dai_link[0].codec_of_node = codec_np;
2131 + mxs_adc_dai_link[0].cpu_dai_name = NULL;
2132 + mxs_adc_dai_link[0].cpu_of_node = cpu_dai_np;
2133 + mxs_adc_dai_link[0].platform_name = NULL;
2134 + mxs_adc_dai_link[0].platform_of_node = cpu_dai_np;
2135 +
2136 +// of_node_put(codec_np);
2137 +// of_node_put(cpu_dai_np);
2138 +
2139 + return ret;
2140 +}
2141 +
2142 +static int mxsadc_audio_probe(struct platform_device *pdev)
2143 +{
2144 + struct snd_soc_card *card = &mxs_adc_audio;
2145 + int ret;
2146 +
2147 + ret = mxsadc_audio_probe_dt(pdev);
2148 + if (ret < 0)
2149 + return ret;
2150 +
2151 + card->dev = &pdev->dev;
2152 + platform_set_drvdata(pdev, card);
2153 +
2154 + ret = snd_soc_register_card(card);
2155 + if (ret) {
2156 + dev_err(&pdev->dev, "snd_soc_register_card failed (%d)\n", ret);
2157 + return ret;
2158 + }
2159 +
2160 + return 0;
2161 +}
2162 +
2163 +static int mxsadc_audio_remove(struct platform_device *pdev)
2164 +{
2165 + struct snd_soc_card *card = platform_get_drvdata(pdev);
2166 +
2167 + snd_soc_unregister_card(card);
2168 +
2169 + return 0;
2170 +}
2171 +
2172 +static const struct of_device_id mxs_adc_audio_dt_ids[] = {
2173 + { .compatible = "fsl,mxs-builtin-audio", },
2174 + { /* sentinel */ }
2175 +};
2176 +MODULE_DEVICE_TABLE(of, mxs_adc_audio_dt_ids);
2177 +
2178 +static struct platform_driver mxs_adc_audio_driver = {
2179 + .driver = {
2180 + .name = "mxs-builtin-audio",
2181 + .owner = THIS_MODULE,
2182 + .of_match_table = mxs_adc_audio_dt_ids,
2183 + },
2184 + .probe = mxsadc_audio_probe,
2185 + .remove = mxsadc_audio_remove,
2186 +};
2187 +
2188 +module_platform_driver(mxs_adc_audio_driver);
2189 +
2190 +MODULE_DESCRIPTION("Freescale MXS ADC/DAC SoC Machine Driver");
2191 +MODULE_AUTHOR("Michal Ulianko <michal.ulianko@gmail.com>");
2192 +MODULE_LICENSE("GPL");
2193 diff --git a/sound/soc/mxs/mxs-builtin-dai.c b/sound/soc/mxs/mxs-builtin-dai.c
2194 new file mode 100644
2195 index 0000000..cc81f9a
2196 --- /dev/null
2197 +++ b/sound/soc/mxs/mxs-builtin-dai.c
2198 @@ -0,0 +1,588 @@
2199 +/*
2200 + * mxs-builtin-dai.c -- i.MX233 built-in codec ALSA Soc Audio driver
2201 + *
2202 + * Author: Michal Ulianko <michal.ulianko@gmail.com>
2203 + *
2204 + * Based on sound/soc/mxs/mxs-adc.c for kernel 2.6.35
2205 + * by Vladislav Buzov <vbuzov@embeddedalley.com>
2206 + *
2207 + * This program is free software; you can redistribute it and/or modify
2208 + * it under the terms of the GNU General Public License version 2 as
2209 + * published by the Free Software Foundation.
2210 + */
2211 +
2212 +#include <linux/module.h>
2213 +#include <linux/init.h>
2214 +#include <linux/interrupt.h>
2215 +#include <linux/delay.h>
2216 +#include <linux/dma-mapping.h>
2217 +#include <linux/platform_device.h>
2218 +#include <sound/pcm.h>
2219 +#include <sound/pcm_params.h>
2220 +#include <sound/soc.h>
2221 +
2222 +#include "../codecs/mxs-builtin-codec.h"
2223 +#include "mxs-builtin-pcm.h"
2224 +
2225 +#define ADC_VOLUME_MIN 0x37
2226 +
2227 +/* TODO Use codec IO function soc snd write etc, instead of __writel __readl */
2228 +
2229 +// TODO use container_of
2230 +struct mxs_irq_data {
2231 + struct snd_pcm_substream *substream;
2232 + struct mxs_adc_priv *mxs_adc;
2233 +};
2234 +
2235 +struct mxs_adc_priv {
2236 + struct mxs_irq_data irq_data;
2237 + int dma_adc_err_irq;
2238 + int dma_dac_err_irq;
2239 + int hp_short_irq;
2240 + void __iomem *audioin_base;
2241 + void __iomem *audioout_base;
2242 + void __iomem *rtc_base;
2243 +};
2244 +
2245 +typedef struct {
2246 + struct work_struct work;
2247 + struct timer_list timer;
2248 +
2249 + /* target workqueue and CPU ->timer uses to queue ->work */
2250 + struct workqueue_struct *wq;
2251 + int cpu;
2252 +
2253 + struct mxs_adc_priv *mxs_adc;
2254 +} my_delayed_work_t;
2255 +
2256 +// static struct delayed_work work;
2257 +// static struct delayed_work adc_ramp_work;
2258 +// static struct delayed_work dac_ramp_work;
2259 +// static struct delayed_work test;
2260 +static my_delayed_work_t work;
2261 +static my_delayed_work_t adc_ramp_work;
2262 +static my_delayed_work_t dac_ramp_work;
2263 +static my_delayed_work_t test;
2264 +static bool adc_ramp_done = 1;
2265 +static bool dac_ramp_done = 1;
2266 +
2267 +static inline void mxs_adc_schedule_work(struct delayed_work *work)
2268 +{
2269 + schedule_delayed_work(work, HZ / 10);
2270 +}
2271 +
2272 +static void mxs_adc_work(struct work_struct *work)
2273 +{
2274 + struct mxs_adc_priv *mxs_adc = ((my_delayed_work_t *)work)->mxs_adc;
2275 + /* disable irq */
2276 + disable_irq(mxs_adc->hp_short_irq);
2277 +
2278 + while (true) {
2279 + __raw_writel(BM_AUDIOOUT_PWRDN_HEADPHONE,
2280 + mxs_adc->audioout_base + HW_AUDIOOUT_PWRDN_CLR);
2281 + msleep(10);
2282 + if ((__raw_readl(mxs_adc->audioout_base + HW_AUDIOOUT_ANACTRL)
2283 + & BM_AUDIOOUT_ANACTRL_SHORT_LR_STS) != 0) {
2284 + /* rearm the short protection */
2285 + __raw_writel(BM_AUDIOOUT_ANACTRL_SHORTMODE_LR,
2286 + mxs_adc->audioout_base + HW_AUDIOOUT_ANACTRL_CLR);
2287 + __raw_writel(BM_AUDIOOUT_ANACTRL_SHORT_LR_STS,
2288 + mxs_adc->audioout_base + HW_AUDIOOUT_ANACTRL_CLR);
2289 + __raw_writel(BF_AUDIOOUT_ANACTRL_SHORTMODE_LR(0x1),
2290 + mxs_adc->audioout_base + HW_AUDIOOUT_ANACTRL_SET);
2291 +
2292 + __raw_writel(BM_AUDIOOUT_PWRDN_HEADPHONE,
2293 + mxs_adc->audioout_base + HW_AUDIOOUT_PWRDN_SET);
2294 + printk(KERN_WARNING "WARNING : Headphone LR short!\r\n");
2295 + } else {
2296 + printk(KERN_WARNING "INFO : Headphone LR no longer short!\r\n");
2297 + break;
2298 + }
2299 + msleep(1000);
2300 + }
2301 +
2302 + /* power up the HEADPHONE and un-mute the HPVOL */
2303 + __raw_writel(BM_AUDIOOUT_HPVOL_MUTE,
2304 + mxs_adc->audioout_base + HW_AUDIOOUT_HPVOL_CLR);
2305 + __raw_writel(BM_AUDIOOUT_PWRDN_HEADPHONE,
2306 + mxs_adc->audioout_base + HW_AUDIOOUT_PWRDN_CLR);
2307 +
2308 + /* enable irq for next short detect*/
2309 + enable_irq(mxs_adc->hp_short_irq);
2310 +}
2311 +
2312 +static void mxs_adc_schedule_ramp_work(struct delayed_work *work)
2313 +{
2314 + schedule_delayed_work(work, msecs_to_jiffies(2));
2315 + adc_ramp_done = 0;
2316 +}
2317 +
2318 +static void mxs_adc_ramp_work(struct work_struct *work)
2319 +{
2320 + struct mxs_adc_priv *mxs_adc = ((my_delayed_work_t *)work)->mxs_adc;
2321 + u32 reg = 0;
2322 + u32 reg1 = 0;
2323 + u32 reg2 = 0;
2324 + u32 l, r;
2325 + u32 ll, rr;
2326 + int i;
2327 +
2328 + reg = __raw_readl(mxs_adc->audioin_base + \
2329 + HW_AUDIOIN_ADCVOLUME);
2330 +
2331 + reg1 = reg & ~BM_AUDIOIN_ADCVOLUME_VOLUME_LEFT;
2332 + reg1 = reg1 & ~BM_AUDIOIN_ADCVOLUME_VOLUME_RIGHT;
2333 + /* minimize adc volume */
2334 + reg2 = reg1 |
2335 + BF_AUDIOIN_ADCVOLUME_VOLUME_LEFT(ADC_VOLUME_MIN) |
2336 + BF_AUDIOIN_ADCVOLUME_VOLUME_RIGHT(ADC_VOLUME_MIN);
2337 + __raw_writel(reg2,
2338 + mxs_adc->audioin_base + HW_AUDIOIN_ADCVOLUME);
2339 + msleep(1);
2340 +
2341 + l = (reg & BM_AUDIOIN_ADCVOLUME_VOLUME_LEFT) >>
2342 + BP_AUDIOIN_ADCVOLUME_VOLUME_LEFT;
2343 + r = (reg & BM_AUDIOIN_ADCVOLUME_VOLUME_RIGHT) >>
2344 + BP_AUDIOIN_ADCVOLUME_VOLUME_RIGHT;
2345 +
2346 + /* fade in adc vol */
2347 + for (i = ADC_VOLUME_MIN; (i < l) || (i < r);) {
2348 + i += 0x8;
2349 + ll = i < l ? i : l;
2350 + rr = i < r ? i : r;
2351 + reg2 = reg1 |
2352 + BF_AUDIOIN_ADCVOLUME_VOLUME_LEFT(ll) |
2353 + BF_AUDIOIN_ADCVOLUME_VOLUME_RIGHT(rr);
2354 + __raw_writel(reg2,
2355 + mxs_adc->audioin_base + HW_AUDIOIN_ADCVOLUME);
2356 + msleep(1);
2357 + }
2358 + adc_ramp_done = 1;
2359 +}
2360 +
2361 +static void mxs_dac_schedule_ramp_work(struct delayed_work *work)
2362 +{
2363 + schedule_delayed_work(work, msecs_to_jiffies(2));
2364 + dac_ramp_done = 0;
2365 +}
2366 +
2367 +static void mxs_dac_ramp_work(struct work_struct *work)
2368 +{
2369 + struct mxs_adc_priv *mxs_adc = ((my_delayed_work_t *)work)->mxs_adc;
2370 + u32 reg = 0;
2371 + u32 reg1 = 0;
2372 + u32 l, r;
2373 + u32 ll, rr;
2374 + int i;
2375 +
2376 + /* unmute hp and speaker */
2377 + __raw_writel(BM_AUDIOOUT_HPVOL_MUTE,
2378 + mxs_adc->audioout_base + HW_AUDIOOUT_HPVOL_CLR);
2379 + __raw_writel(BM_AUDIOOUT_SPEAKERCTRL_MUTE,
2380 + mxs_adc->audioout_base + HW_AUDIOOUT_SPEAKERCTRL_CLR);
2381 +
2382 + reg = __raw_readl(mxs_adc->audioout_base + \
2383 + HW_AUDIOOUT_HPVOL);
2384 +
2385 + reg1 = reg & ~BM_AUDIOOUT_HPVOL_VOL_LEFT;
2386 + reg1 = reg1 & ~BM_AUDIOOUT_HPVOL_VOL_RIGHT;
2387 +
2388 + l = (reg & BM_AUDIOOUT_HPVOL_VOL_LEFT) >>
2389 + BP_AUDIOOUT_HPVOL_VOL_LEFT;
2390 + r = (reg & BM_AUDIOOUT_HPVOL_VOL_RIGHT) >>
2391 + BP_AUDIOOUT_HPVOL_VOL_RIGHT;
2392 + /* fade in hp vol */
2393 + for (i = 0x7f; i > 0 ;) {
2394 + i -= 0x8;
2395 + ll = i > (int)l ? i : l;
2396 + rr = i > (int)r ? i : r;
2397 + reg = reg1 | BF_AUDIOOUT_HPVOL_VOL_LEFT(ll)
2398 + | BF_AUDIOOUT_HPVOL_VOL_RIGHT(rr);
2399 + __raw_writel(reg,
2400 + mxs_adc->audioout_base + HW_AUDIOOUT_HPVOL);
2401 + msleep(1);
2402 + }
2403 + dac_ramp_done = 1;
2404 +}
2405 +
2406 +/* IRQs */
2407 +static irqreturn_t mxs_short_irq(int irq, void *dev_id)
2408 +{
2409 + struct mxs_adc_priv *mxs_adc = dev_id;
2410 + //struct snd_pcm_substream *substream = mxs_adc->irq_data.substream;
2411 +
2412 + __raw_writel(BM_AUDIOOUT_ANACTRL_SHORTMODE_LR,
2413 + mxs_adc->audioout_base + HW_AUDIOOUT_ANACTRL_CLR);
2414 + __raw_writel(BM_AUDIOOUT_ANACTRL_SHORT_LR_STS,
2415 + mxs_adc->audioout_base + HW_AUDIOOUT_ANACTRL_CLR);
2416 + __raw_writel(BF_AUDIOOUT_ANACTRL_SHORTMODE_LR(0x1),
2417 + mxs_adc->audioout_base + HW_AUDIOOUT_ANACTRL_SET);
2418 +
2419 + __raw_writel(BM_AUDIOOUT_HPVOL_MUTE,
2420 + mxs_adc->audioout_base + HW_AUDIOOUT_HPVOL_SET);
2421 + __raw_writel(BM_AUDIOOUT_PWRDN_HEADPHONE,
2422 + mxs_adc->audioout_base + HW_AUDIOOUT_PWRDN_SET);
2423 + __raw_writel(BM_AUDIOOUT_ANACTRL_HP_CLASSAB,
2424 + mxs_adc->audioout_base + HW_AUDIOOUT_ANACTRL_SET);
2425 +
2426 + mxs_adc_schedule_work((struct delayed_work *) &work);
2427 + return IRQ_HANDLED;
2428 +}
2429 +
2430 +static irqreturn_t mxs_err_irq(int irq, void *dev_id)
2431 +{
2432 + struct mxs_adc_priv *mxs_adc = dev_id;
2433 + struct snd_pcm_substream *substream = mxs_adc->irq_data.substream;
2434 + int playback = substream->stream == SNDRV_PCM_STREAM_PLAYBACK ? 1 : 0;
2435 + u32 ctrl_reg;
2436 + u32 overflow_mask;
2437 + u32 underflow_mask;
2438 +
2439 + if (playback) {
2440 + ctrl_reg = __raw_readl(mxs_adc->audioout_base + HW_AUDIOOUT_CTRL);
2441 + underflow_mask = BM_AUDIOOUT_CTRL_FIFO_UNDERFLOW_IRQ;
2442 + overflow_mask = BM_AUDIOOUT_CTRL_FIFO_OVERFLOW_IRQ;
2443 + } else {
2444 + ctrl_reg = __raw_readl(mxs_adc->audioin_base + HW_AUDIOIN_CTRL);
2445 + underflow_mask = BM_AUDIOIN_CTRL_FIFO_UNDERFLOW_IRQ;
2446 + overflow_mask = BM_AUDIOIN_CTRL_FIFO_OVERFLOW_IRQ;
2447 + }
2448 +
2449 + if (ctrl_reg & underflow_mask) {
2450 + printk(KERN_DEBUG "%s underflow detected\n",
2451 + playback ? "DAC" : "ADC");
2452 +
2453 + if (playback)
2454 + __raw_writel(
2455 + BM_AUDIOOUT_CTRL_FIFO_UNDERFLOW_IRQ,
2456 + mxs_adc->audioout_base + HW_AUDIOOUT_CTRL_CLR);
2457 + else
2458 + __raw_writel(
2459 + BM_AUDIOIN_CTRL_FIFO_UNDERFLOW_IRQ,
2460 + mxs_adc->audioin_base + HW_AUDIOIN_CTRL_CLR);
2461 +
2462 + } else if (ctrl_reg & overflow_mask) {
2463 + printk(KERN_DEBUG "%s overflow detected\n",
2464 + playback ? "DAC" : "ADC");
2465 +
2466 + if (playback)
2467 + __raw_writel(
2468 + BM_AUDIOOUT_CTRL_FIFO_OVERFLOW_IRQ,
2469 + mxs_adc->audioout_base + HW_AUDIOOUT_CTRL_CLR);
2470 + else
2471 + __raw_writel(BM_AUDIOIN_CTRL_FIFO_OVERFLOW_IRQ,
2472 + mxs_adc->audioin_base + HW_AUDIOIN_CTRL_CLR);
2473 + } else
2474 + printk(KERN_WARNING "Unknown DAC error interrupt\n");
2475 +
2476 + return IRQ_HANDLED;
2477 +}
2478 +/* END IRQs */
2479 +
2480 +static int mxs_trigger(struct snd_pcm_substream *substream,
2481 + int cmd,
2482 + struct snd_soc_dai *cpu_dai)
2483 +{
2484 + struct mxs_adc_priv *mxs_adc = snd_soc_dai_get_drvdata(cpu_dai);
2485 + int playback = substream->stream == SNDRV_PCM_STREAM_PLAYBACK ? 1 : 0;
2486 + int ret = 0;
2487 +
2488 + switch (cmd) {
2489 + case SNDRV_PCM_TRIGGER_START:
2490 + case SNDRV_PCM_TRIGGER_RESUME:
2491 + case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
2492 +
2493 + if (playback) {
2494 + /* enable the fifo error interrupt */
2495 + __raw_writel(BM_AUDIOOUT_CTRL_FIFO_ERROR_IRQ_EN,
2496 + mxs_adc->audioout_base + HW_AUDIOOUT_CTRL_SET);
2497 + /* write a data to data reg to trigger the transfer */
2498 + __raw_writel(0x0,
2499 + mxs_adc->audioout_base + HW_AUDIOOUT_DATA);
2500 + mxs_dac_schedule_ramp_work((struct delayed_work *) &dac_ramp_work);
2501 + } else {
2502 +// mxs_dma_get_info(prtd->dma_ch, &dma_info);
2503 +// cur_bar1 = dma_info.buf_addr;
2504 +// xfer_count1 = dma_info.xfer_count;
2505 +
2506 + __raw_writel(BM_AUDIOIN_CTRL_RUN,
2507 + mxs_adc->audioin_base + HW_AUDIOIN_CTRL_SET);
2508 + udelay(100);
2509 +
2510 +// mxs_dma_get_info(prtd->dma_ch, &dma_info);
2511 +// cur_bar2 = dma_info.buf_addr;
2512 +// xfer_count2 = dma_info.xfer_count;
2513 +//
2514 +// /* check if DMA getting stuck */
2515 +// if ((xfer_count1 == xfer_count2) && (cur_bar1 == cur_bar2))
2516 +// /* read a data from data reg to trigger the receive */
2517 +// reg = __raw_readl(mxs_adc->audioin_base + HW_AUDIOIN_DATA);
2518 +
2519 + mxs_adc_schedule_ramp_work((struct delayed_work *) &adc_ramp_work);
2520 + }
2521 + break;
2522 +
2523 + case SNDRV_PCM_TRIGGER_SUSPEND:
2524 + case SNDRV_PCM_TRIGGER_STOP:
2525 + case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
2526 +
2527 + if (playback) {
2528 +// printk(KERN_INFO "SNDRV_PCM_TRIGGER_START\n");
2529 +// printk(KERN_INFO "ctrl:%x\n", __raw_readl(mxs_adc->audioout_base + HW_AUDIOOUT_CTRL));
2530 +// printk(KERN_INFO "stat:%x\n", __raw_readl(mxs_adc->audioout_base + HW_AUDIOOUT_STAT));
2531 +// printk(KERN_INFO "srr:%x\n", __raw_readl(mxs_adc->audioout_base + HW_AUDIOOUT_DACSRR));
2532 +// printk(KERN_INFO "vol:%x\n", __raw_readl(mxs_adc->audioout_base + HW_AUDIOOUT_DACVOLUME));
2533 +// printk(KERN_INFO "debug:%x\n", __raw_readl(mxs_adc->audioout_base + HW_AUDIOOUT_DACDEBUG));
2534 +// printk(KERN_INFO "hpvol:%x\n", __raw_readl(mxs_adc->audioout_base + HW_AUDIOOUT_HPVOL));
2535 +// printk(KERN_INFO "pwrdn:%x\n", __raw_readl(mxs_adc->audioout_base + HW_AUDIOOUT_PWRDN));
2536 +// printk(KERN_INFO "refc:%x\n", __raw_readl(mxs_adc->audioout_base + HW_AUDIOOUT_REFCTRL));
2537 +// printk(KERN_INFO "anac:%x\n", __raw_readl(mxs_adc->audioout_base + HW_AUDIOOUT_ANACTRL));
2538 +// printk(KERN_INFO "test:%x\n", __raw_readl(mxs_adc->audioout_base + HW_AUDIOOUT_TEST));
2539 +// printk(KERN_INFO "bist:%x\n", __raw_readl(mxs_adc->audioout_base + HW_AUDIOOUT_BISTCTRL));
2540 +// printk(KERN_INFO "anaclk:%x\n", __raw_readl(mxs_adc->audioout_base + HW_AUDIOOUT_ANACLKCTRL));
2541 +
2542 + if (dac_ramp_done == 0) {
2543 + cancel_delayed_work((struct delayed_work *) &dac_ramp_work);
2544 + dac_ramp_done = 1;
2545 + }
2546 + __raw_writel(BM_AUDIOOUT_HPVOL_MUTE,
2547 + mxs_adc->audioout_base + HW_AUDIOOUT_HPVOL_SET);
2548 + __raw_writel(BM_AUDIOOUT_SPEAKERCTRL_MUTE,
2549 + mxs_adc->audioout_base + HW_AUDIOOUT_SPEAKERCTRL_SET);
2550 + /* disable the fifo error interrupt */
2551 + __raw_writel(BM_AUDIOOUT_CTRL_FIFO_ERROR_IRQ_EN,
2552 + mxs_adc->audioout_base + HW_AUDIOOUT_CTRL_CLR);
2553 + mdelay(50);
2554 + } else {
2555 + if (adc_ramp_done == 0) {
2556 + cancel_delayed_work((struct delayed_work *) &adc_ramp_work);
2557 + adc_ramp_done = 1;
2558 + }
2559 + __raw_writel(BM_AUDIOIN_CTRL_RUN,
2560 + mxs_adc->audioin_base + HW_AUDIOIN_CTRL_CLR);
2561 + }
2562 + break;
2563 +
2564 + default:
2565 + printk(KERN_ERR "TRIGGER ERROR\n");
2566 + ret = -EINVAL;
2567 + }
2568 +
2569 + return ret;
2570 +}
2571 +
2572 +static int mxs_startup(struct snd_pcm_substream *substream,
2573 + struct snd_soc_dai *cpu_dai)
2574 +{
2575 + struct mxs_adc_priv *mxs_adc = snd_soc_dai_get_drvdata(cpu_dai);
2576 + int playback = substream->stream == SNDRV_PCM_STREAM_PLAYBACK ? 1 : 0;
2577 + mxs_adc->irq_data.mxs_adc = mxs_adc;
2578 + mxs_adc->irq_data.substream = substream;
2579 +
2580 + work.mxs_adc = mxs_adc;
2581 + adc_ramp_work.mxs_adc = mxs_adc;
2582 + dac_ramp_work.mxs_adc = mxs_adc;
2583 + test.mxs_adc = mxs_adc;
2584 + INIT_DELAYED_WORK(&work, mxs_adc_work);
2585 + INIT_DELAYED_WORK(&adc_ramp_work, mxs_adc_ramp_work);
2586 + INIT_DELAYED_WORK(&dac_ramp_work, mxs_dac_ramp_work);
2587 +
2588 + /* Enable error interrupt */
2589 + if (playback) {
2590 + __raw_writel(BM_AUDIOOUT_CTRL_FIFO_OVERFLOW_IRQ,
2591 + mxs_adc->audioout_base + HW_AUDIOOUT_CTRL_CLR);
2592 + __raw_writel(BM_AUDIOOUT_CTRL_FIFO_UNDERFLOW_IRQ,
2593 + mxs_adc->audioout_base + HW_AUDIOOUT_CTRL_CLR);
2594 + } else {
2595 + __raw_writel(BM_AUDIOIN_CTRL_FIFO_OVERFLOW_IRQ,
2596 + mxs_adc->audioin_base + HW_AUDIOIN_CTRL_CLR);
2597 + __raw_writel(BM_AUDIOIN_CTRL_FIFO_UNDERFLOW_IRQ,
2598 + mxs_adc->audioin_base + HW_AUDIOIN_CTRL_CLR);
2599 + __raw_writel(BM_AUDIOIN_CTRL_FIFO_ERROR_IRQ_EN,
2600 + mxs_adc->audioin_base + HW_AUDIOIN_CTRL_SET);
2601 + }
2602 +
2603 + return 0;
2604 +}
2605 +
2606 +static void mxs_shutdown(struct snd_pcm_substream *substream,
2607 + struct snd_soc_dai *cpu_dai)
2608 +{
2609 + struct mxs_adc_priv *mxs_adc = snd_soc_dai_get_drvdata(cpu_dai);
2610 + int playback = substream->stream == SNDRV_PCM_STREAM_PLAYBACK ? 1 : 0;
2611 +
2612 + /* Disable error interrupt */
2613 + if (playback) {
2614 + __raw_writel(BM_AUDIOOUT_CTRL_FIFO_ERROR_IRQ_EN,
2615 + mxs_adc->audioout_base + HW_AUDIOOUT_CTRL_CLR);
2616 + } else {
2617 + __raw_writel(BM_AUDIOIN_CTRL_FIFO_ERROR_IRQ_EN,
2618 + mxs_adc->audioin_base + HW_AUDIOIN_CTRL_CLR);
2619 + }
2620 +}
2621 +
2622 +#define MXS_ADC_RATES SNDRV_PCM_RATE_8000_192000
2623 +#define MXS_ADC_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S32_LE)
2624 +
2625 +static const struct snd_soc_dai_ops mxs_adc_dai_ops = {
2626 + .startup = mxs_startup,
2627 + .trigger = mxs_trigger,
2628 + .shutdown = mxs_shutdown,
2629 +};
2630 +
2631 +static int mxs_dai_probe(struct snd_soc_dai *dai)
2632 +{
2633 + // TODO This does not make any sense.
2634 + struct mxs_adc_priv *mxs_adc = dev_get_drvdata(dai->dev);
2635 +
2636 + snd_soc_dai_set_drvdata(dai, mxs_adc);
2637 +
2638 + return 0;
2639 +}
2640 +
2641 +static struct snd_soc_dai_driver mxs_adc_dai = {
2642 + .name = "mxs-builtin-cpu-dai",
2643 + .probe = mxs_dai_probe,
2644 + .playback = {
2645 + .channels_min = 2,
2646 + .channels_max = 2,
2647 + .rates = MXS_ADC_RATES,
2648 + .formats = MXS_ADC_FORMATS,
2649 + },
2650 + .capture = {
2651 + .channels_min = 2,
2652 + .channels_max = 2,
2653 + .rates = MXS_ADC_RATES,
2654 + .formats = MXS_ADC_FORMATS,
2655 + },
2656 + .ops = &mxs_adc_dai_ops,
2657 +};
2658 +
2659 +static const struct snd_soc_component_driver mxs_adc_component = {
2660 + .name = "mxs-xxx", //TODO change this name
2661 +};
2662 +
2663 +static int mxs_adc_probe(struct platform_device *pdev)
2664 +{
2665 + struct device_node *np = pdev->dev.of_node;
2666 + struct mxs_adc_priv *mxs_adc;
2667 + int ret = 0;
2668 +
2669 + if (!np)
2670 + return -EINVAL;
2671 +
2672 + mxs_adc = devm_kzalloc(&pdev->dev, sizeof(*mxs_adc), GFP_KERNEL);
2673 + if (!mxs_adc)
2674 + return -ENOMEM;
2675 +
2676 + mxs_adc->audioout_base = devm_ioremap(&pdev->dev, 0x80048000, 0x2000);
2677 + if (IS_ERR(mxs_adc->audioout_base))
2678 + return PTR_ERR(mxs_adc->audioout_base);
2679 +
2680 + mxs_adc->audioin_base = devm_ioremap(&pdev->dev, 0x8004c000, 0x2000);
2681 + if (IS_ERR(mxs_adc->audioin_base))
2682 + return PTR_ERR(mxs_adc->audioin_base);
2683 +
2684 + mxs_adc->rtc_base = devm_ioremap(&pdev->dev, 0x8005c000, 0x2000);
2685 + if (IS_ERR(mxs_adc->rtc_base))
2686 + return PTR_ERR(mxs_adc->rtc_base);
2687 +
2688 + /* Get IRQ numbers */
2689 + mxs_adc->dma_adc_err_irq = platform_get_irq(pdev, 0);
2690 + if (mxs_adc->dma_adc_err_irq < 0) {
2691 + ret = mxs_adc->dma_adc_err_irq;
2692 + dev_err(&pdev->dev, "failed to get ADC DMA ERR irq resource: %d\n", ret);
2693 + return ret;
2694 + }
2695 +
2696 + mxs_adc->dma_dac_err_irq = platform_get_irq(pdev, 1);
2697 + if (mxs_adc->dma_dac_err_irq < 0) {
2698 + ret = mxs_adc->dma_dac_err_irq;
2699 + dev_err(&pdev->dev, "failed to get DAC DMA ERR irq resource: %d\n", ret);
2700 + return ret;
2701 + }
2702 +
2703 + mxs_adc->hp_short_irq = platform_get_irq(pdev, 2);
2704 + if (mxs_adc->hp_short_irq < 0) {
2705 + ret = mxs_adc->hp_short_irq;
2706 + dev_err(&pdev->dev, "failed to get HP_SHORT irq resource: %d\n", ret);
2707 + return ret;
2708 + }
2709 +
2710 + /* Request IRQs */
2711 + ret = devm_request_irq(&pdev->dev, mxs_adc->dma_adc_err_irq, mxs_err_irq, 0, "MXS DAC and ADC Error",
2712 + mxs_adc);
2713 + if (ret) {
2714 + printk(KERN_ERR "%s: Unable to request ADC/DAC error irq %d\n",
2715 + __func__, mxs_adc->dma_adc_err_irq);
2716 + return ret;
2717 + }
2718 +
2719 + ret = devm_request_irq(&pdev->dev, mxs_adc->dma_dac_err_irq, mxs_err_irq, 0, "MXS DAC and ADC Error",
2720 + mxs_adc);
2721 + if (ret) {
2722 + printk(KERN_ERR "%s: Unable to request ADC/DAC error irq %d\n",
2723 + __func__, mxs_adc->dma_dac_err_irq);
2724 + return ret;
2725 + }
2726 +
2727 + ret = devm_request_irq(&pdev->dev, mxs_adc->hp_short_irq, mxs_short_irq,
2728 + IRQF_DISABLED | IRQF_SHARED, "MXS DAC and ADC HP SHORT", mxs_adc);
2729 + if (ret) {
2730 + printk(KERN_ERR "%s: Unable to request ADC/DAC HP SHORT irq %d\n",
2731 + __func__, mxs_adc->hp_short_irq);
2732 + return ret;
2733 + }
2734 +
2735 + platform_set_drvdata(pdev, mxs_adc);
2736 +
2737 + ret = snd_soc_register_component(&pdev->dev, &mxs_adc_component, &mxs_adc_dai, 1);
2738 + if (ret) {
2739 + dev_err(&pdev->dev, "register DAI failed\n");
2740 + return ret;
2741 + }
2742 +
2743 + ret = mxs_adc_pcm_platform_register(&pdev->dev);
2744 + if (ret) {
2745 + dev_err(&pdev->dev, "register PCM failed: %d\n", ret);
2746 + goto failed_pdev_alloc;
2747 + }
2748 +
2749 + return 0;
2750 +
2751 +failed_pdev_alloc:
2752 + snd_soc_unregister_component(&pdev->dev);
2753 +
2754 + return ret;
2755 +}
2756 +
2757 +static int mxs_adc_remove(struct platform_device *pdev)
2758 +{
2759 + mxs_adc_pcm_platform_unregister(&pdev->dev);
2760 + snd_soc_unregister_component(&pdev->dev);
2761 +
2762 + return 0;
2763 +}
2764 +
2765 +static const struct of_device_id mxs_adc_dai_dt_ids[] = {
2766 + { .compatible = "fsl,mxs-builtin-cpu-dai", },
2767 + { /* sentinel */ }
2768 +};
2769 +MODULE_DEVICE_TABLE(of, mxs_adc_dai_dt_ids);
2770 +
2771 +static struct platform_driver mxs_adc_dai_driver = {
2772 + .probe = mxs_adc_probe,
2773 + .remove = mxs_adc_remove,
2774 +
2775 + .driver = {
2776 + .name = "mxs-builtin-cpu-dai",
2777 + .owner = THIS_MODULE,
2778 + .of_match_table = mxs_adc_dai_dt_ids,
2779 + },
2780 +};
2781 +
2782 +module_platform_driver(mxs_adc_dai_driver);
2783 +
2784 +MODULE_DESCRIPTION("Freescale MXS ADC/DAC SoC Codec DAI Driver");
2785 +MODULE_AUTHOR("Michal Ulianko <michal.ulianko@gmail.com>");
2786 +MODULE_LICENSE("GPL");
2787 diff --git a/sound/soc/mxs/mxs-builtin-pcm.c b/sound/soc/mxs/mxs-builtin-pcm.c
2788 new file mode 100644
2789 index 0000000..9f155df
2790 --- /dev/null
2791 +++ b/sound/soc/mxs/mxs-builtin-pcm.c
2792 @@ -0,0 +1,69 @@
2793 +/*
2794 + * Copyright (C) 2011 Freescale Semiconductor, Inc. All Rights Reserved.
2795 + *
2796 + * Based on sound/soc/imx/imx-pcm-dma-mx2.c
2797 + *
2798 + * This program is free software; you can redistribute it and/or modify
2799 + * it under the terms of the GNU General Public License as published by
2800 + * the Free Software Foundation; either version 2 of the License, or
2801 + * (at your option) any later version.
2802 + *
2803 + * This program is distributed in the hope that it will be useful,
2804 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
2805 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2806 + * GNU General Public License for more details.
2807 + *
2808 + * You should have received a copy of the GNU General Public License along
2809 + * with this program; if not, write to the Free Software Foundation, Inc.,
2810 + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
2811 + */
2812 +
2813 +#include <linux/device.h>
2814 +#include <linux/init.h>
2815 +#include <linux/module.h>
2816 +
2817 +#include <sound/core.h>
2818 +#include <sound/pcm.h>
2819 +#include <sound/soc.h>
2820 +#include <sound/dmaengine_pcm.h>
2821 +
2822 +#include "mxs-builtin-pcm.h"
2823 +
2824 +static const struct snd_pcm_hardware snd_mxs_hardware = {
2825 + .info = SNDRV_PCM_INFO_MMAP |
2826 + SNDRV_PCM_INFO_MMAP_VALID |
2827 + SNDRV_PCM_INFO_PAUSE |
2828 + SNDRV_PCM_INFO_RESUME |
2829 + SNDRV_PCM_INFO_INTERLEAVED,
2830 + .formats = SNDRV_PCM_FMTBIT_S16_LE |
2831 + SNDRV_PCM_FMTBIT_S20_3LE |
2832 + SNDRV_PCM_FMTBIT_S24_LE,
2833 + .channels_min = 2,
2834 + .channels_max = 2,
2835 + .period_bytes_min = 32,
2836 + .period_bytes_max = 8192,
2837 + .periods_min = 1,
2838 + .periods_max = 52,
2839 + .buffer_bytes_max = 64 * 1024,
2840 + .fifo_size = 32,
2841 +};
2842 +
2843 +static const struct snd_dmaengine_pcm_config mxs_dmaengine_pcm_config = {
2844 + .pcm_hardware = &snd_mxs_hardware,
2845 + .prealloc_buffer_size = 64 * 1024,
2846 +};
2847 +
2848 +int mxs_adc_pcm_platform_register(struct device *dev)
2849 +{
2850 + return snd_dmaengine_pcm_register(dev, &mxs_dmaengine_pcm_config,
2851 + SND_DMAENGINE_PCM_FLAG_NO_RESIDUE);
2852 +}
2853 +EXPORT_SYMBOL_GPL(mxs_adc_pcm_platform_register);
2854 +
2855 +void mxs_adc_pcm_platform_unregister(struct device *dev)
2856 +{
2857 + snd_dmaengine_pcm_unregister(dev);
2858 +}
2859 +EXPORT_SYMBOL_GPL(mxs_adc_pcm_platform_unregister);
2860 +
2861 +MODULE_LICENSE("GPL");
2862 diff --git a/sound/soc/mxs/mxs-builtin-pcm.h b/sound/soc/mxs/mxs-builtin-pcm.h
2863 new file mode 100644
2864 index 0000000..2fba109
2865 --- /dev/null
2866 +++ b/sound/soc/mxs/mxs-builtin-pcm.h
2867 @@ -0,0 +1,25 @@
2868 +/*
2869 + * Copyright (C) 2011 Freescale Semiconductor, Inc. All Rights Reserved.
2870 + *
2871 + * This program is free software; you can redistribute it and/or modify
2872 + * it under the terms of the GNU General Public License as published by
2873 + * the Free Software Foundation; either version 2 of the License, or
2874 + * (at your option) any later version.
2875 + *
2876 + * This program is distributed in the hope that it will be useful,
2877 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
2878 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2879 + * GNU General Public License for more details.
2880 + *
2881 + * You should have received a copy of the GNU General Public License along
2882 + * with this program; if not, write to the Free Software Foundation, Inc.,
2883 + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
2884 + */
2885 +
2886 +#ifndef _MXS_PCM_H
2887 +#define _MXS_PCM_H
2888 +
2889 +int mxs_adc_pcm_platform_register(struct device *dev);
2890 +void mxs_adc_pcm_platform_unregister(struct device *dev);
2891 +
2892 +#endif
2893 --
2894 1.7.10.4
2895