blob: 116372c91f5de3f60eafd9a738cd4a31e1ab0bcb [file] [log] [blame]
Mark Brown07ed8732012-06-18 21:08:44 +01001/*
2 * arizona.h - Wolfson Arizona class device shared support
3 *
4 * Copyright 2012 Wolfson Microelectronics plc
5 *
6 * Author: Mark Brown <broonie@opensource.wolfsonmicro.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 */
12
13#ifndef _ASOC_ARIZONA_H
14#define _ASOC_ARIZONA_H
15
16#include <linux/completion.h>
17
18#include <sound/soc.h>
19
Mark Brown0b09df62012-10-11 11:31:35 +090020#include "wm_adsp.h"
21
Mark Browncbd840d2012-08-08 17:52:44 +010022#define ARIZONA_CLK_SYSCLK 1
23#define ARIZONA_CLK_ASYNCCLK 2
24#define ARIZONA_CLK_OPCLK 3
25#define ARIZONA_CLK_ASYNC_OPCLK 4
Mark Brown07ed8732012-06-18 21:08:44 +010026
27#define ARIZONA_CLK_SRC_MCLK1 0x0
28#define ARIZONA_CLK_SRC_MCLK2 0x1
29#define ARIZONA_CLK_SRC_FLL1 0x4
30#define ARIZONA_CLK_SRC_FLL2 0x5
31#define ARIZONA_CLK_SRC_AIF1BCLK 0x8
32#define ARIZONA_CLK_SRC_AIF2BCLK 0x9
33#define ARIZONA_CLK_SRC_AIF3BCLK 0xa
34
35#define ARIZONA_FLL_SRC_MCLK1 0
36#define ARIZONA_FLL_SRC_MCLK2 1
Mark Browna8c02db2012-12-18 14:05:01 +000037#define ARIZONA_FLL_SRC_SLIMCLK 3
38#define ARIZONA_FLL_SRC_FLL1 4
39#define ARIZONA_FLL_SRC_FLL2 5
40#define ARIZONA_FLL_SRC_AIF1BCLK 8
41#define ARIZONA_FLL_SRC_AIF2BCLK 9
42#define ARIZONA_FLL_SRC_AIF3BCLK 10
43#define ARIZONA_FLL_SRC_AIF1LRCLK 12
44#define ARIZONA_FLL_SRC_AIF2LRCLK 13
45#define ARIZONA_FLL_SRC_AIF3LRCLK 14
Mark Brown07ed8732012-06-18 21:08:44 +010046
47#define ARIZONA_MIXER_VOL_MASK 0x00FE
48#define ARIZONA_MIXER_VOL_SHIFT 1
49#define ARIZONA_MIXER_VOL_WIDTH 7
50
Mark Brown0b09df62012-10-11 11:31:35 +090051#define ARIZONA_MAX_DAI 4
52#define ARIZONA_MAX_ADSP 4
Mark Brown5b2eec32012-07-04 17:32:05 +010053
Mark Brown07ed8732012-06-18 21:08:44 +010054struct arizona;
Mark Brown0b09df62012-10-11 11:31:35 +090055struct wm_adsp;
Mark Brown07ed8732012-06-18 21:08:44 +010056
Mark Brown5b2eec32012-07-04 17:32:05 +010057struct arizona_dai_priv {
58 int clk;
59};
60
Mark Brown07ed8732012-06-18 21:08:44 +010061struct arizona_priv {
Mark Brown0b09df62012-10-11 11:31:35 +090062 struct wm_adsp adsp[ARIZONA_MAX_ADSP];
Mark Brown07ed8732012-06-18 21:08:44 +010063 struct arizona *arizona;
64 int sysclk;
65 int asyncclk;
Mark Brown5b2eec32012-07-04 17:32:05 +010066 struct arizona_dai_priv dai[ARIZONA_MAX_DAI];
Mark Brown07ed8732012-06-18 21:08:44 +010067};
68
Mark Brown91660bd2012-12-05 20:35:24 +090069#define ARIZONA_NUM_MIXER_INPUTS 99
Mark Brown07ed8732012-06-18 21:08:44 +010070
71extern const unsigned int arizona_mixer_tlv[];
72extern const char *arizona_mixer_texts[ARIZONA_NUM_MIXER_INPUTS];
73extern int arizona_mixer_values[ARIZONA_NUM_MIXER_INPUTS];
74
75#define ARIZONA_MIXER_CONTROLS(name, base) \
76 SOC_SINGLE_RANGE_TLV(name " Input 1 Volume", base + 1, \
77 ARIZONA_MIXER_VOL_SHIFT, 0x20, 0x50, 0, \
78 arizona_mixer_tlv), \
79 SOC_SINGLE_RANGE_TLV(name " Input 2 Volume", base + 3, \
80 ARIZONA_MIXER_VOL_SHIFT, 0x20, 0x50, 0, \
81 arizona_mixer_tlv), \
82 SOC_SINGLE_RANGE_TLV(name " Input 3 Volume", base + 5, \
83 ARIZONA_MIXER_VOL_SHIFT, 0x20, 0x50, 0, \
84 arizona_mixer_tlv), \
85 SOC_SINGLE_RANGE_TLV(name " Input 4 Volume", base + 7, \
86 ARIZONA_MIXER_VOL_SHIFT, 0x20, 0x50, 0, \
87 arizona_mixer_tlv)
88
89#define ARIZONA_MUX_ENUM_DECL(name, reg) \
90 SOC_VALUE_ENUM_SINGLE_DECL(name, reg, 0, 0xff, \
91 arizona_mixer_texts, arizona_mixer_values)
92
93#define ARIZONA_MUX_CTL_DECL(name) \
94 const struct snd_kcontrol_new name##_mux = \
95 SOC_DAPM_VALUE_ENUM("Route", name##_enum)
96
Charles Keepax17bd09e2012-11-13 16:40:32 +000097#define ARIZONA_MUX_ENUMS(name, base_reg) \
98 static ARIZONA_MUX_ENUM_DECL(name##_enum, base_reg); \
99 static ARIZONA_MUX_CTL_DECL(name)
100
Mark Brown07ed8732012-06-18 21:08:44 +0100101#define ARIZONA_MIXER_ENUMS(name, base_reg) \
Charles Keepax17bd09e2012-11-13 16:40:32 +0000102 ARIZONA_MUX_ENUMS(name##_in1, base_reg); \
103 ARIZONA_MUX_ENUMS(name##_in2, base_reg + 2); \
104 ARIZONA_MUX_ENUMS(name##_in3, base_reg + 4); \
105 ARIZONA_MUX_ENUMS(name##_in4, base_reg + 6)
Mark Brown07ed8732012-06-18 21:08:44 +0100106
Mark Brown0b09df62012-10-11 11:31:35 +0900107#define ARIZONA_DSP_AUX_ENUMS(name, base_reg) \
Charles Keepax17bd09e2012-11-13 16:40:32 +0000108 ARIZONA_MUX_ENUMS(name##_aux1, base_reg); \
109 ARIZONA_MUX_ENUMS(name##_aux2, base_reg + 8); \
110 ARIZONA_MUX_ENUMS(name##_aux3, base_reg + 16); \
111 ARIZONA_MUX_ENUMS(name##_aux4, base_reg + 24); \
112 ARIZONA_MUX_ENUMS(name##_aux5, base_reg + 32); \
113 ARIZONA_MUX_ENUMS(name##_aux6, base_reg + 40)
Mark Brown0b09df62012-10-11 11:31:35 +0900114
Mark Brown07ed8732012-06-18 21:08:44 +0100115#define ARIZONA_MUX(name, ctrl) \
116 SND_SOC_DAPM_VALUE_MUX(name, SND_SOC_NOPM, 0, 0, ctrl)
117
Charles Keepax17bd09e2012-11-13 16:40:32 +0000118#define ARIZONA_MUX_WIDGETS(name, name_str) \
119 ARIZONA_MUX(name_str " Input", &name##_mux)
120
Mark Brown07ed8732012-06-18 21:08:44 +0100121#define ARIZONA_MIXER_WIDGETS(name, name_str) \
122 ARIZONA_MUX(name_str " Input 1", &name##_in1_mux), \
123 ARIZONA_MUX(name_str " Input 2", &name##_in2_mux), \
124 ARIZONA_MUX(name_str " Input 3", &name##_in3_mux), \
125 ARIZONA_MUX(name_str " Input 4", &name##_in4_mux), \
126 SND_SOC_DAPM_MIXER(name_str " Mixer", SND_SOC_NOPM, 0, 0, NULL, 0)
127
Mark Brown0b09df62012-10-11 11:31:35 +0900128#define ARIZONA_DSP_WIDGETS(name, name_str) \
129 ARIZONA_MIXER_WIDGETS(name##L, name_str "L"), \
130 ARIZONA_MIXER_WIDGETS(name##R, name_str "R"), \
131 ARIZONA_MUX(name_str " Aux 1", &name##_aux1_mux), \
132 ARIZONA_MUX(name_str " Aux 2", &name##_aux2_mux), \
133 ARIZONA_MUX(name_str " Aux 3", &name##_aux3_mux), \
134 ARIZONA_MUX(name_str " Aux 4", &name##_aux4_mux), \
135 ARIZONA_MUX(name_str " Aux 5", &name##_aux5_mux), \
136 ARIZONA_MUX(name_str " Aux 6", &name##_aux6_mux)
137
Charles Keepax17bd09e2012-11-13 16:40:32 +0000138#define ARIZONA_MUX_ROUTES(name) \
139 ARIZONA_MIXER_INPUT_ROUTES(name " Input")
140
Mark Brown07ed8732012-06-18 21:08:44 +0100141#define ARIZONA_MIXER_ROUTES(widget, name) \
142 { widget, NULL, name " Mixer" }, \
143 { name " Mixer", NULL, name " Input 1" }, \
144 { name " Mixer", NULL, name " Input 2" }, \
145 { name " Mixer", NULL, name " Input 3" }, \
146 { name " Mixer", NULL, name " Input 4" }, \
147 ARIZONA_MIXER_INPUT_ROUTES(name " Input 1"), \
148 ARIZONA_MIXER_INPUT_ROUTES(name " Input 2"), \
149 ARIZONA_MIXER_INPUT_ROUTES(name " Input 3"), \
150 ARIZONA_MIXER_INPUT_ROUTES(name " Input 4")
151
Mark Brown0b09df62012-10-11 11:31:35 +0900152#define ARIZONA_DSP_ROUTES(name) \
153 { name, NULL, name " Aux 1" }, \
154 { name, NULL, name " Aux 2" }, \
155 { name, NULL, name " Aux 3" }, \
156 { name, NULL, name " Aux 4" }, \
157 { name, NULL, name " Aux 5" }, \
158 { name, NULL, name " Aux 6" }, \
159 ARIZONA_MIXER_INPUT_ROUTES(name " Aux 1"), \
160 ARIZONA_MIXER_INPUT_ROUTES(name " Aux 2"), \
161 ARIZONA_MIXER_INPUT_ROUTES(name " Aux 3"), \
162 ARIZONA_MIXER_INPUT_ROUTES(name " Aux 4"), \
163 ARIZONA_MIXER_INPUT_ROUTES(name " Aux 5"), \
164 ARIZONA_MIXER_INPUT_ROUTES(name " Aux 6"), \
165 ARIZONA_MIXER_ROUTES(name, name "L"), \
166 ARIZONA_MIXER_ROUTES(name, name "R")
167
Mark Browne853a002012-12-09 12:25:52 +0900168extern const struct soc_enum arizona_in_vi_ramp;
169extern const struct soc_enum arizona_in_vd_ramp;
170
171extern const struct soc_enum arizona_out_vi_ramp;
172extern const struct soc_enum arizona_out_vd_ramp;
173
Mark Brown07ed8732012-06-18 21:08:44 +0100174extern const struct soc_enum arizona_lhpf1_mode;
175extern const struct soc_enum arizona_lhpf2_mode;
176extern const struct soc_enum arizona_lhpf3_mode;
177extern const struct soc_enum arizona_lhpf4_mode;
178
Mark Brown845571c2012-12-18 13:47:57 +0000179extern const struct soc_enum arizona_ng_hold;
180
Mark Brown07ed8732012-06-18 21:08:44 +0100181extern int arizona_in_ev(struct snd_soc_dapm_widget *w,
182 struct snd_kcontrol *kcontrol,
183 int event);
184extern int arizona_out_ev(struct snd_soc_dapm_widget *w,
185 struct snd_kcontrol *kcontrol,
186 int event);
187
188extern int arizona_set_sysclk(struct snd_soc_codec *codec, int clk_id,
189 int source, unsigned int freq, int dir);
190
191extern const struct snd_soc_dai_ops arizona_dai_ops;
192
193#define ARIZONA_FLL_NAME_LEN 20
194
195struct arizona_fll {
196 struct arizona *arizona;
197 int id;
198 unsigned int base;
Mark Brown2b4d39f2012-07-10 17:03:46 +0100199 unsigned int vco_mult;
Mark Brown07ed8732012-06-18 21:08:44 +0100200 struct completion ok;
Mark Brown1cbe4bc2012-11-21 14:12:22 +0900201 unsigned int fref;
202 unsigned int fout;
Mark Brown07ed8732012-06-18 21:08:44 +0100203
204 char lock_name[ARIZONA_FLL_NAME_LEN];
205 char clock_ok_name[ARIZONA_FLL_NAME_LEN];
206};
207
208extern int arizona_init_fll(struct arizona *arizona, int id, int base,
209 int lock_irq, int ok_irq, struct arizona_fll *fll);
210extern int arizona_set_fll(struct arizona_fll *fll, int source,
211 unsigned int Fref, unsigned int Fout);
212
Mark Brown5b2eec32012-07-04 17:32:05 +0100213extern int arizona_init_dai(struct arizona_priv *priv, int dai);
214
Mark Brownbc9ab6d2013-01-04 19:31:00 +0000215int arizona_set_output_mode(struct snd_soc_codec *codec, int output,
216 bool diff);
217
Mark Brown07ed8732012-06-18 21:08:44 +0100218#endif