Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
arizona.h
Go to the documentation of this file.
1 /*
2  * arizona.h - Wolfson Arizona class device shared support
3  *
4  * Copyright 2012 Wolfson Microelectronics plc
5  *
6  * Author: Mark Brown <[email protected]>
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 
20 #define ARIZONA_CLK_SYSCLK 1
21 #define ARIZONA_CLK_ASYNCCLK 2
22 #define ARIZONA_CLK_OPCLK 3
23 #define ARIZONA_CLK_ASYNC_OPCLK 4
24 
25 #define ARIZONA_CLK_SRC_MCLK1 0x0
26 #define ARIZONA_CLK_SRC_MCLK2 0x1
27 #define ARIZONA_CLK_SRC_FLL1 0x4
28 #define ARIZONA_CLK_SRC_FLL2 0x5
29 #define ARIZONA_CLK_SRC_AIF1BCLK 0x8
30 #define ARIZONA_CLK_SRC_AIF2BCLK 0x9
31 #define ARIZONA_CLK_SRC_AIF3BCLK 0xa
32 
33 #define ARIZONA_FLL_SRC_MCLK1 0
34 #define ARIZONA_FLL_SRC_MCLK2 1
35 #define ARIZONA_FLL_SRC_SLIMCLK 2
36 #define ARIZONA_FLL_SRC_FLL1 3
37 #define ARIZONA_FLL_SRC_FLL2 4
38 #define ARIZONA_FLL_SRC_AIF1BCLK 5
39 #define ARIZONA_FLL_SRC_AIF2BCLK 6
40 #define ARIZONA_FLL_SRC_AIF3BCLK 7
41 #define ARIZONA_FLL_SRC_AIF1LRCLK 8
42 #define ARIZONA_FLL_SRC_AIF2LRCLK 9
43 #define ARIZONA_FLL_SRC_AIF3LRCLK 10
44 
45 #define ARIZONA_MIXER_VOL_MASK 0x00FE
46 #define ARIZONA_MIXER_VOL_SHIFT 1
47 #define ARIZONA_MIXER_VOL_WIDTH 7
48 
49 #define ARIZONA_MAX_DAI 3
50 
51 struct arizona;
52 
54  int clk;
55 };
56 
57 struct arizona_priv {
58  struct arizona *arizona;
59  int sysclk;
60  int asyncclk;
62 };
63 
64 #define ARIZONA_NUM_MIXER_INPUTS 75
65 
66 extern const unsigned int arizona_mixer_tlv[];
69 
70 #define ARIZONA_MIXER_CONTROLS(name, base) \
71  SOC_SINGLE_RANGE_TLV(name " Input 1 Volume", base + 1, \
72  ARIZONA_MIXER_VOL_SHIFT, 0x20, 0x50, 0, \
73  arizona_mixer_tlv), \
74  SOC_SINGLE_RANGE_TLV(name " Input 2 Volume", base + 3, \
75  ARIZONA_MIXER_VOL_SHIFT, 0x20, 0x50, 0, \
76  arizona_mixer_tlv), \
77  SOC_SINGLE_RANGE_TLV(name " Input 3 Volume", base + 5, \
78  ARIZONA_MIXER_VOL_SHIFT, 0x20, 0x50, 0, \
79  arizona_mixer_tlv), \
80  SOC_SINGLE_RANGE_TLV(name " Input 4 Volume", base + 7, \
81  ARIZONA_MIXER_VOL_SHIFT, 0x20, 0x50, 0, \
82  arizona_mixer_tlv)
83 
84 #define ARIZONA_MUX_ENUM_DECL(name, reg) \
85  SOC_VALUE_ENUM_SINGLE_DECL(name, reg, 0, 0xff, \
86  arizona_mixer_texts, arizona_mixer_values)
87 
88 #define ARIZONA_MUX_CTL_DECL(name) \
89  const struct snd_kcontrol_new name##_mux = \
90  SOC_DAPM_VALUE_ENUM("Route", name##_enum)
91 
92 #define ARIZONA_MIXER_ENUMS(name, base_reg) \
93  static ARIZONA_MUX_ENUM_DECL(name##_in1_enum, base_reg); \
94  static ARIZONA_MUX_ENUM_DECL(name##_in2_enum, base_reg + 2); \
95  static ARIZONA_MUX_ENUM_DECL(name##_in3_enum, base_reg + 4); \
96  static ARIZONA_MUX_ENUM_DECL(name##_in4_enum, base_reg + 6); \
97  static ARIZONA_MUX_CTL_DECL(name##_in1); \
98  static ARIZONA_MUX_CTL_DECL(name##_in2); \
99  static ARIZONA_MUX_CTL_DECL(name##_in3); \
100  static ARIZONA_MUX_CTL_DECL(name##_in4)
101 
102 #define ARIZONA_MUX(name, ctrl) \
103  SND_SOC_DAPM_VALUE_MUX(name, SND_SOC_NOPM, 0, 0, ctrl)
104 
105 #define ARIZONA_MIXER_WIDGETS(name, name_str) \
106  ARIZONA_MUX(name_str " Input 1", &name##_in1_mux), \
107  ARIZONA_MUX(name_str " Input 2", &name##_in2_mux), \
108  ARIZONA_MUX(name_str " Input 3", &name##_in3_mux), \
109  ARIZONA_MUX(name_str " Input 4", &name##_in4_mux), \
110  SND_SOC_DAPM_MIXER(name_str " Mixer", SND_SOC_NOPM, 0, 0, NULL, 0)
111 
112 #define ARIZONA_MIXER_ROUTES(widget, name) \
113  { widget, NULL, name " Mixer" }, \
114  { name " Mixer", NULL, name " Input 1" }, \
115  { name " Mixer", NULL, name " Input 2" }, \
116  { name " Mixer", NULL, name " Input 3" }, \
117  { name " Mixer", NULL, name " Input 4" }, \
118  ARIZONA_MIXER_INPUT_ROUTES(name " Input 1"), \
119  ARIZONA_MIXER_INPUT_ROUTES(name " Input 2"), \
120  ARIZONA_MIXER_INPUT_ROUTES(name " Input 3"), \
121  ARIZONA_MIXER_INPUT_ROUTES(name " Input 4")
122 
123 extern const struct soc_enum arizona_lhpf1_mode;
124 extern const struct soc_enum arizona_lhpf2_mode;
125 extern const struct soc_enum arizona_lhpf3_mode;
126 extern const struct soc_enum arizona_lhpf4_mode;
127 
128 extern int arizona_in_ev(struct snd_soc_dapm_widget *w,
129  struct snd_kcontrol *kcontrol,
130  int event);
131 extern int arizona_out_ev(struct snd_soc_dapm_widget *w,
132  struct snd_kcontrol *kcontrol,
133  int event);
134 
135 extern int arizona_set_sysclk(struct snd_soc_codec *codec, int clk_id,
136  int source, unsigned int freq, int dir);
137 
138 extern const struct snd_soc_dai_ops arizona_dai_ops;
139 
140 #define ARIZONA_FLL_NAME_LEN 20
141 
142 struct arizona_fll {
143  struct arizona *arizona;
144  int id;
145  unsigned int base;
146  unsigned int vco_mult;
147  struct completion lock;
148  struct completion ok;
149 
152 };
153 
154 extern int arizona_init_fll(struct arizona *arizona, int id, int base,
155  int lock_irq, int ok_irq, struct arizona_fll *fll);
156 extern int arizona_set_fll(struct arizona_fll *fll, int source,
157  unsigned int Fref, unsigned int Fout);
158 
159 extern int arizona_init_dai(struct arizona_priv *priv, int dai);
160 
161 #endif