Mark Brown | 07ed873 | 2012-06-18 21:08:44 +0100 | [diff] [blame] | 1 | /* |
| 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 Brown | 0b09df6 | 2012-10-11 11:31:35 +0900 | [diff] [blame] | 20 | #include "wm_adsp.h" |
| 21 | |
Mark Brown | cbd840d | 2012-08-08 17:52:44 +0100 | [diff] [blame] | 22 | #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 Brown | 07ed873 | 2012-06-18 21:08:44 +0100 | [diff] [blame] | 26 | |
| 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 | |
Charles Keepax | f3f1163 | 2013-02-20 17:28:41 +0000 | [diff] [blame] | 35 | #define ARIZONA_FLL_SRC_NONE -1 |
Mark Brown | 07ed873 | 2012-06-18 21:08:44 +0100 | [diff] [blame] | 36 | #define ARIZONA_FLL_SRC_MCLK1 0 |
| 37 | #define ARIZONA_FLL_SRC_MCLK2 1 |
Mark Brown | a8c02db | 2012-12-18 14:05:01 +0000 | [diff] [blame] | 38 | #define ARIZONA_FLL_SRC_SLIMCLK 3 |
| 39 | #define ARIZONA_FLL_SRC_FLL1 4 |
| 40 | #define ARIZONA_FLL_SRC_FLL2 5 |
| 41 | #define ARIZONA_FLL_SRC_AIF1BCLK 8 |
| 42 | #define ARIZONA_FLL_SRC_AIF2BCLK 9 |
| 43 | #define ARIZONA_FLL_SRC_AIF3BCLK 10 |
| 44 | #define ARIZONA_FLL_SRC_AIF1LRCLK 12 |
| 45 | #define ARIZONA_FLL_SRC_AIF2LRCLK 13 |
| 46 | #define ARIZONA_FLL_SRC_AIF3LRCLK 14 |
Mark Brown | 07ed873 | 2012-06-18 21:08:44 +0100 | [diff] [blame] | 47 | |
| 48 | #define ARIZONA_MIXER_VOL_MASK 0x00FE |
| 49 | #define ARIZONA_MIXER_VOL_SHIFT 1 |
| 50 | #define ARIZONA_MIXER_VOL_WIDTH 7 |
| 51 | |
Mark Brown | 0b09df6 | 2012-10-11 11:31:35 +0900 | [diff] [blame] | 52 | #define ARIZONA_MAX_DAI 4 |
| 53 | #define ARIZONA_MAX_ADSP 4 |
Mark Brown | 5b2eec3 | 2012-07-04 17:32:05 +0100 | [diff] [blame] | 54 | |
Mark Brown | 07ed873 | 2012-06-18 21:08:44 +0100 | [diff] [blame] | 55 | struct arizona; |
Mark Brown | 0b09df6 | 2012-10-11 11:31:35 +0900 | [diff] [blame] | 56 | struct wm_adsp; |
Mark Brown | 07ed873 | 2012-06-18 21:08:44 +0100 | [diff] [blame] | 57 | |
Mark Brown | 5b2eec3 | 2012-07-04 17:32:05 +0100 | [diff] [blame] | 58 | struct arizona_dai_priv { |
| 59 | int clk; |
| 60 | }; |
| 61 | |
Mark Brown | 07ed873 | 2012-06-18 21:08:44 +0100 | [diff] [blame] | 62 | struct arizona_priv { |
Mark Brown | 0b09df6 | 2012-10-11 11:31:35 +0900 | [diff] [blame] | 63 | struct wm_adsp adsp[ARIZONA_MAX_ADSP]; |
Mark Brown | 07ed873 | 2012-06-18 21:08:44 +0100 | [diff] [blame] | 64 | struct arizona *arizona; |
| 65 | int sysclk; |
| 66 | int asyncclk; |
Mark Brown | 5b2eec3 | 2012-07-04 17:32:05 +0100 | [diff] [blame] | 67 | struct arizona_dai_priv dai[ARIZONA_MAX_DAI]; |
Mark Brown | ddbce97 | 2013-02-15 17:27:22 +0000 | [diff] [blame^] | 68 | |
| 69 | int num_inputs; |
| 70 | unsigned int in_pending; |
Mark Brown | 07ed873 | 2012-06-18 21:08:44 +0100 | [diff] [blame] | 71 | }; |
| 72 | |
Mark Brown | 91660bd | 2012-12-05 20:35:24 +0900 | [diff] [blame] | 73 | #define ARIZONA_NUM_MIXER_INPUTS 99 |
Mark Brown | 07ed873 | 2012-06-18 21:08:44 +0100 | [diff] [blame] | 74 | |
| 75 | extern const unsigned int arizona_mixer_tlv[]; |
| 76 | extern const char *arizona_mixer_texts[ARIZONA_NUM_MIXER_INPUTS]; |
| 77 | extern int arizona_mixer_values[ARIZONA_NUM_MIXER_INPUTS]; |
| 78 | |
| 79 | #define ARIZONA_MIXER_CONTROLS(name, base) \ |
| 80 | SOC_SINGLE_RANGE_TLV(name " Input 1 Volume", base + 1, \ |
| 81 | ARIZONA_MIXER_VOL_SHIFT, 0x20, 0x50, 0, \ |
| 82 | arizona_mixer_tlv), \ |
| 83 | SOC_SINGLE_RANGE_TLV(name " Input 2 Volume", base + 3, \ |
| 84 | ARIZONA_MIXER_VOL_SHIFT, 0x20, 0x50, 0, \ |
| 85 | arizona_mixer_tlv), \ |
| 86 | SOC_SINGLE_RANGE_TLV(name " Input 3 Volume", base + 5, \ |
| 87 | ARIZONA_MIXER_VOL_SHIFT, 0x20, 0x50, 0, \ |
| 88 | arizona_mixer_tlv), \ |
| 89 | SOC_SINGLE_RANGE_TLV(name " Input 4 Volume", base + 7, \ |
| 90 | ARIZONA_MIXER_VOL_SHIFT, 0x20, 0x50, 0, \ |
| 91 | arizona_mixer_tlv) |
| 92 | |
| 93 | #define ARIZONA_MUX_ENUM_DECL(name, reg) \ |
| 94 | SOC_VALUE_ENUM_SINGLE_DECL(name, reg, 0, 0xff, \ |
| 95 | arizona_mixer_texts, arizona_mixer_values) |
| 96 | |
| 97 | #define ARIZONA_MUX_CTL_DECL(name) \ |
| 98 | const struct snd_kcontrol_new name##_mux = \ |
| 99 | SOC_DAPM_VALUE_ENUM("Route", name##_enum) |
| 100 | |
Charles Keepax | 17bd09e | 2012-11-13 16:40:32 +0000 | [diff] [blame] | 101 | #define ARIZONA_MUX_ENUMS(name, base_reg) \ |
| 102 | static ARIZONA_MUX_ENUM_DECL(name##_enum, base_reg); \ |
| 103 | static ARIZONA_MUX_CTL_DECL(name) |
| 104 | |
Mark Brown | 07ed873 | 2012-06-18 21:08:44 +0100 | [diff] [blame] | 105 | #define ARIZONA_MIXER_ENUMS(name, base_reg) \ |
Charles Keepax | 17bd09e | 2012-11-13 16:40:32 +0000 | [diff] [blame] | 106 | ARIZONA_MUX_ENUMS(name##_in1, base_reg); \ |
| 107 | ARIZONA_MUX_ENUMS(name##_in2, base_reg + 2); \ |
| 108 | ARIZONA_MUX_ENUMS(name##_in3, base_reg + 4); \ |
| 109 | ARIZONA_MUX_ENUMS(name##_in4, base_reg + 6) |
Mark Brown | 07ed873 | 2012-06-18 21:08:44 +0100 | [diff] [blame] | 110 | |
Mark Brown | 0b09df6 | 2012-10-11 11:31:35 +0900 | [diff] [blame] | 111 | #define ARIZONA_DSP_AUX_ENUMS(name, base_reg) \ |
Charles Keepax | 17bd09e | 2012-11-13 16:40:32 +0000 | [diff] [blame] | 112 | ARIZONA_MUX_ENUMS(name##_aux1, base_reg); \ |
| 113 | ARIZONA_MUX_ENUMS(name##_aux2, base_reg + 8); \ |
| 114 | ARIZONA_MUX_ENUMS(name##_aux3, base_reg + 16); \ |
| 115 | ARIZONA_MUX_ENUMS(name##_aux4, base_reg + 24); \ |
| 116 | ARIZONA_MUX_ENUMS(name##_aux5, base_reg + 32); \ |
| 117 | ARIZONA_MUX_ENUMS(name##_aux6, base_reg + 40) |
Mark Brown | 0b09df6 | 2012-10-11 11:31:35 +0900 | [diff] [blame] | 118 | |
Mark Brown | 07ed873 | 2012-06-18 21:08:44 +0100 | [diff] [blame] | 119 | #define ARIZONA_MUX(name, ctrl) \ |
| 120 | SND_SOC_DAPM_VALUE_MUX(name, SND_SOC_NOPM, 0, 0, ctrl) |
| 121 | |
Charles Keepax | 17bd09e | 2012-11-13 16:40:32 +0000 | [diff] [blame] | 122 | #define ARIZONA_MUX_WIDGETS(name, name_str) \ |
| 123 | ARIZONA_MUX(name_str " Input", &name##_mux) |
| 124 | |
Mark Brown | 07ed873 | 2012-06-18 21:08:44 +0100 | [diff] [blame] | 125 | #define ARIZONA_MIXER_WIDGETS(name, name_str) \ |
| 126 | ARIZONA_MUX(name_str " Input 1", &name##_in1_mux), \ |
| 127 | ARIZONA_MUX(name_str " Input 2", &name##_in2_mux), \ |
| 128 | ARIZONA_MUX(name_str " Input 3", &name##_in3_mux), \ |
| 129 | ARIZONA_MUX(name_str " Input 4", &name##_in4_mux), \ |
| 130 | SND_SOC_DAPM_MIXER(name_str " Mixer", SND_SOC_NOPM, 0, 0, NULL, 0) |
| 131 | |
Mark Brown | 0b09df6 | 2012-10-11 11:31:35 +0900 | [diff] [blame] | 132 | #define ARIZONA_DSP_WIDGETS(name, name_str) \ |
| 133 | ARIZONA_MIXER_WIDGETS(name##L, name_str "L"), \ |
| 134 | ARIZONA_MIXER_WIDGETS(name##R, name_str "R"), \ |
| 135 | ARIZONA_MUX(name_str " Aux 1", &name##_aux1_mux), \ |
| 136 | ARIZONA_MUX(name_str " Aux 2", &name##_aux2_mux), \ |
| 137 | ARIZONA_MUX(name_str " Aux 3", &name##_aux3_mux), \ |
| 138 | ARIZONA_MUX(name_str " Aux 4", &name##_aux4_mux), \ |
| 139 | ARIZONA_MUX(name_str " Aux 5", &name##_aux5_mux), \ |
| 140 | ARIZONA_MUX(name_str " Aux 6", &name##_aux6_mux) |
| 141 | |
Charles Keepax | 17bd09e | 2012-11-13 16:40:32 +0000 | [diff] [blame] | 142 | #define ARIZONA_MUX_ROUTES(name) \ |
| 143 | ARIZONA_MIXER_INPUT_ROUTES(name " Input") |
| 144 | |
Mark Brown | 07ed873 | 2012-06-18 21:08:44 +0100 | [diff] [blame] | 145 | #define ARIZONA_MIXER_ROUTES(widget, name) \ |
| 146 | { widget, NULL, name " Mixer" }, \ |
| 147 | { name " Mixer", NULL, name " Input 1" }, \ |
| 148 | { name " Mixer", NULL, name " Input 2" }, \ |
| 149 | { name " Mixer", NULL, name " Input 3" }, \ |
| 150 | { name " Mixer", NULL, name " Input 4" }, \ |
| 151 | ARIZONA_MIXER_INPUT_ROUTES(name " Input 1"), \ |
| 152 | ARIZONA_MIXER_INPUT_ROUTES(name " Input 2"), \ |
| 153 | ARIZONA_MIXER_INPUT_ROUTES(name " Input 3"), \ |
| 154 | ARIZONA_MIXER_INPUT_ROUTES(name " Input 4") |
| 155 | |
Mark Brown | 0b09df6 | 2012-10-11 11:31:35 +0900 | [diff] [blame] | 156 | #define ARIZONA_DSP_ROUTES(name) \ |
| 157 | { name, NULL, name " Aux 1" }, \ |
| 158 | { name, NULL, name " Aux 2" }, \ |
| 159 | { name, NULL, name " Aux 3" }, \ |
| 160 | { name, NULL, name " Aux 4" }, \ |
| 161 | { name, NULL, name " Aux 5" }, \ |
| 162 | { name, NULL, name " Aux 6" }, \ |
| 163 | ARIZONA_MIXER_INPUT_ROUTES(name " Aux 1"), \ |
| 164 | ARIZONA_MIXER_INPUT_ROUTES(name " Aux 2"), \ |
| 165 | ARIZONA_MIXER_INPUT_ROUTES(name " Aux 3"), \ |
| 166 | ARIZONA_MIXER_INPUT_ROUTES(name " Aux 4"), \ |
| 167 | ARIZONA_MIXER_INPUT_ROUTES(name " Aux 5"), \ |
| 168 | ARIZONA_MIXER_INPUT_ROUTES(name " Aux 6"), \ |
| 169 | ARIZONA_MIXER_ROUTES(name, name "L"), \ |
| 170 | ARIZONA_MIXER_ROUTES(name, name "R") |
| 171 | |
Mark Brown | e853a00 | 2012-12-09 12:25:52 +0900 | [diff] [blame] | 172 | extern const struct soc_enum arizona_in_vi_ramp; |
| 173 | extern const struct soc_enum arizona_in_vd_ramp; |
| 174 | |
| 175 | extern const struct soc_enum arizona_out_vi_ramp; |
| 176 | extern const struct soc_enum arizona_out_vd_ramp; |
| 177 | |
Mark Brown | 07ed873 | 2012-06-18 21:08:44 +0100 | [diff] [blame] | 178 | extern const struct soc_enum arizona_lhpf1_mode; |
| 179 | extern const struct soc_enum arizona_lhpf2_mode; |
| 180 | extern const struct soc_enum arizona_lhpf3_mode; |
| 181 | extern const struct soc_enum arizona_lhpf4_mode; |
| 182 | |
Mark Brown | 845571c | 2012-12-18 13:47:57 +0000 | [diff] [blame] | 183 | extern const struct soc_enum arizona_ng_hold; |
| 184 | |
Mark Brown | 07ed873 | 2012-06-18 21:08:44 +0100 | [diff] [blame] | 185 | extern int arizona_in_ev(struct snd_soc_dapm_widget *w, |
| 186 | struct snd_kcontrol *kcontrol, |
| 187 | int event); |
| 188 | extern int arizona_out_ev(struct snd_soc_dapm_widget *w, |
| 189 | struct snd_kcontrol *kcontrol, |
| 190 | int event); |
| 191 | |
| 192 | extern int arizona_set_sysclk(struct snd_soc_codec *codec, int clk_id, |
| 193 | int source, unsigned int freq, int dir); |
| 194 | |
| 195 | extern const struct snd_soc_dai_ops arizona_dai_ops; |
| 196 | |
| 197 | #define ARIZONA_FLL_NAME_LEN 20 |
| 198 | |
| 199 | struct arizona_fll { |
| 200 | struct arizona *arizona; |
| 201 | int id; |
| 202 | unsigned int base; |
Mark Brown | 2b4d39f | 2012-07-10 17:03:46 +0100 | [diff] [blame] | 203 | unsigned int vco_mult; |
Mark Brown | 07ed873 | 2012-06-18 21:08:44 +0100 | [diff] [blame] | 204 | struct completion ok; |
| 205 | |
Charles Keepax | de1e6ee | 2013-02-20 17:28:39 +0000 | [diff] [blame] | 206 | unsigned int fout; |
Charles Keepax | 9e359c6 | 2013-02-20 17:28:35 +0000 | [diff] [blame] | 207 | int sync_src; |
| 208 | unsigned int sync_freq; |
Charles Keepax | 19b34bd | 2013-02-20 17:28:34 +0000 | [diff] [blame] | 209 | int ref_src; |
| 210 | unsigned int ref_freq; |
| 211 | |
Mark Brown | 07ed873 | 2012-06-18 21:08:44 +0100 | [diff] [blame] | 212 | char lock_name[ARIZONA_FLL_NAME_LEN]; |
| 213 | char clock_ok_name[ARIZONA_FLL_NAME_LEN]; |
| 214 | }; |
| 215 | |
| 216 | extern int arizona_init_fll(struct arizona *arizona, int id, int base, |
| 217 | int lock_irq, int ok_irq, struct arizona_fll *fll); |
Charles Keepax | ee929a9 | 2013-02-20 17:28:40 +0000 | [diff] [blame] | 218 | extern int arizona_set_fll_refclk(struct arizona_fll *fll, int source, |
| 219 | unsigned int Fref, unsigned int Fout); |
Mark Brown | 07ed873 | 2012-06-18 21:08:44 +0100 | [diff] [blame] | 220 | extern int arizona_set_fll(struct arizona_fll *fll, int source, |
| 221 | unsigned int Fref, unsigned int Fout); |
| 222 | |
Mark Brown | 5b2eec3 | 2012-07-04 17:32:05 +0100 | [diff] [blame] | 223 | extern int arizona_init_dai(struct arizona_priv *priv, int dai); |
| 224 | |
Mark Brown | bc9ab6d | 2013-01-04 19:31:00 +0000 | [diff] [blame] | 225 | int arizona_set_output_mode(struct snd_soc_codec *codec, int output, |
| 226 | bool diff); |
| 227 | |
Mark Brown | 07ed873 | 2012-06-18 21:08:44 +0100 | [diff] [blame] | 228 | #endif |