1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
2 | /* |
3 | * Arizona MFD internals |
4 | * |
5 | * Copyright 2012 Wolfson Microelectronics plc |
6 | * |
7 | * Author: Mark Brown <broonie@opensource.wolfsonmicro.com> |
8 | */ |
9 | |
10 | #ifndef _WM_ARIZONA_CORE_H |
11 | #define _WM_ARIZONA_CORE_H |
12 | |
13 | #include <linux/clk.h> |
14 | #include <linux/interrupt.h> |
15 | #include <linux/notifier.h> |
16 | #include <linux/regmap.h> |
17 | #include <linux/regulator/consumer.h> |
18 | #include <linux/mfd/arizona/pdata.h> |
19 | |
20 | #define ARIZONA_MAX_CORE_SUPPLIES 2 |
21 | |
22 | enum { |
23 | ARIZONA_MCLK1, |
24 | ARIZONA_MCLK2, |
25 | ARIZONA_NUM_MCLK |
26 | }; |
27 | |
28 | enum arizona_type { |
29 | WM5102 = 1, |
30 | WM5110 = 2, |
31 | WM8997 = 3, |
32 | WM8280 = 4, |
33 | WM8998 = 5, |
34 | WM1814 = 6, |
35 | WM1831 = 7, |
36 | CS47L24 = 8, |
37 | }; |
38 | |
39 | #define ARIZONA_IRQ_GP1 0 |
40 | #define ARIZONA_IRQ_GP2 1 |
41 | #define ARIZONA_IRQ_GP3 2 |
42 | #define ARIZONA_IRQ_GP4 3 |
43 | #define ARIZONA_IRQ_GP5_FALL 4 |
44 | #define ARIZONA_IRQ_GP5_RISE 5 |
45 | #define ARIZONA_IRQ_JD_FALL 6 |
46 | #define ARIZONA_IRQ_JD_RISE 7 |
47 | #define ARIZONA_IRQ_DSP1_RAM_RDY 8 |
48 | #define ARIZONA_IRQ_DSP2_RAM_RDY 9 |
49 | #define ARIZONA_IRQ_DSP3_RAM_RDY 10 |
50 | #define ARIZONA_IRQ_DSP4_RAM_RDY 11 |
51 | #define ARIZONA_IRQ_DSP_IRQ1 12 |
52 | #define ARIZONA_IRQ_DSP_IRQ2 13 |
53 | #define ARIZONA_IRQ_DSP_IRQ3 14 |
54 | #define ARIZONA_IRQ_DSP_IRQ4 15 |
55 | #define ARIZONA_IRQ_DSP_IRQ5 16 |
56 | #define ARIZONA_IRQ_DSP_IRQ6 17 |
57 | #define ARIZONA_IRQ_DSP_IRQ7 18 |
58 | #define ARIZONA_IRQ_DSP_IRQ8 19 |
59 | #define ARIZONA_IRQ_SPK_OVERHEAT_WARN 20 |
60 | #define ARIZONA_IRQ_SPK_OVERHEAT 21 |
61 | #define ARIZONA_IRQ_MICDET 22 |
62 | #define ARIZONA_IRQ_HPDET 23 |
63 | #define ARIZONA_IRQ_WSEQ_DONE 24 |
64 | #define ARIZONA_IRQ_DRC2_SIG_DET 25 |
65 | #define ARIZONA_IRQ_DRC1_SIG_DET 26 |
66 | #define ARIZONA_IRQ_ASRC2_LOCK 27 |
67 | #define ARIZONA_IRQ_ASRC1_LOCK 28 |
68 | #define ARIZONA_IRQ_UNDERCLOCKED 29 |
69 | #define ARIZONA_IRQ_OVERCLOCKED 30 |
70 | #define ARIZONA_IRQ_FLL2_LOCK 31 |
71 | #define ARIZONA_IRQ_FLL1_LOCK 32 |
72 | #define ARIZONA_IRQ_CLKGEN_ERR 33 |
73 | #define ARIZONA_IRQ_CLKGEN_ERR_ASYNC 34 |
74 | #define ARIZONA_IRQ_ASRC_CFG_ERR 35 |
75 | #define ARIZONA_IRQ_AIF3_ERR 36 |
76 | #define ARIZONA_IRQ_AIF2_ERR 37 |
77 | #define ARIZONA_IRQ_AIF1_ERR 38 |
78 | #define ARIZONA_IRQ_CTRLIF_ERR 39 |
79 | #define ARIZONA_IRQ_MIXER_DROPPED_SAMPLES 40 |
80 | #define ARIZONA_IRQ_ASYNC_CLK_ENA_LOW 41 |
81 | #define ARIZONA_IRQ_SYSCLK_ENA_LOW 42 |
82 | #define ARIZONA_IRQ_ISRC1_CFG_ERR 43 |
83 | #define ARIZONA_IRQ_ISRC2_CFG_ERR 44 |
84 | #define ARIZONA_IRQ_BOOT_DONE 45 |
85 | #define ARIZONA_IRQ_DCS_DAC_DONE 46 |
86 | #define ARIZONA_IRQ_DCS_HP_DONE 47 |
87 | #define ARIZONA_IRQ_FLL2_CLOCK_OK 48 |
88 | #define ARIZONA_IRQ_FLL1_CLOCK_OK 49 |
89 | #define ARIZONA_IRQ_MICD_CLAMP_RISE 50 |
90 | #define ARIZONA_IRQ_MICD_CLAMP_FALL 51 |
91 | #define ARIZONA_IRQ_HP3R_DONE 52 |
92 | #define ARIZONA_IRQ_HP3L_DONE 53 |
93 | #define ARIZONA_IRQ_HP2R_DONE 54 |
94 | #define ARIZONA_IRQ_HP2L_DONE 55 |
95 | #define ARIZONA_IRQ_HP1R_DONE 56 |
96 | #define ARIZONA_IRQ_HP1L_DONE 57 |
97 | #define ARIZONA_IRQ_ISRC3_CFG_ERR 58 |
98 | #define ARIZONA_IRQ_DSP_SHARED_WR_COLL 59 |
99 | #define ARIZONA_IRQ_SPK_SHUTDOWN 60 |
100 | #define ARIZONA_IRQ_SPK1R_SHORT 61 |
101 | #define ARIZONA_IRQ_SPK1L_SHORT 62 |
102 | #define ARIZONA_IRQ_HP3R_SC_NEG 63 |
103 | #define ARIZONA_IRQ_HP3R_SC_POS 64 |
104 | #define ARIZONA_IRQ_HP3L_SC_NEG 65 |
105 | #define ARIZONA_IRQ_HP3L_SC_POS 66 |
106 | #define ARIZONA_IRQ_HP2R_SC_NEG 67 |
107 | #define ARIZONA_IRQ_HP2R_SC_POS 68 |
108 | #define ARIZONA_IRQ_HP2L_SC_NEG 69 |
109 | #define ARIZONA_IRQ_HP2L_SC_POS 70 |
110 | #define ARIZONA_IRQ_HP1R_SC_NEG 71 |
111 | #define ARIZONA_IRQ_HP1R_SC_POS 72 |
112 | #define ARIZONA_IRQ_HP1L_SC_NEG 73 |
113 | #define ARIZONA_IRQ_HP1L_SC_POS 74 |
114 | |
115 | #define ARIZONA_NUM_IRQ 75 |
116 | |
117 | struct snd_soc_dapm_context; |
118 | |
119 | struct arizona { |
120 | struct regmap *regmap; |
121 | struct device *dev; |
122 | |
123 | enum arizona_type type; |
124 | unsigned int rev; |
125 | |
126 | int num_core_supplies; |
127 | struct regulator_bulk_data core_supplies[ARIZONA_MAX_CORE_SUPPLIES]; |
128 | struct regulator *dcvdd; |
129 | bool has_fully_powered_off; |
130 | |
131 | struct arizona_pdata pdata; |
132 | |
133 | unsigned int external_dcvdd:1; |
134 | |
135 | int irq; |
136 | struct irq_domain *virq; |
137 | struct regmap_irq_chip_data *aod_irq_chip; |
138 | struct regmap_irq_chip_data *irq_chip; |
139 | |
140 | bool hpdet_clamp; |
141 | unsigned int hp_ena; |
142 | |
143 | struct mutex clk_lock; |
144 | int clk32k_ref; |
145 | |
146 | struct clk *mclk[ARIZONA_NUM_MCLK]; |
147 | |
148 | bool ctrlif_error; |
149 | |
150 | struct snd_soc_dapm_context *dapm; |
151 | |
152 | int tdm_width[ARIZONA_MAX_AIF]; |
153 | int tdm_slots[ARIZONA_MAX_AIF]; |
154 | |
155 | uint16_t dac_comp_coeff; |
156 | uint8_t dac_comp_enabled; |
157 | struct mutex dac_comp_lock; |
158 | |
159 | struct blocking_notifier_head notifier; |
160 | }; |
161 | |
162 | static inline int arizona_call_notifiers(struct arizona *arizona, |
163 | unsigned long event, |
164 | void *data) |
165 | { |
166 | return blocking_notifier_call_chain(nh: &arizona->notifier, val: event, v: data); |
167 | } |
168 | |
169 | int arizona_clk32k_enable(struct arizona *arizona); |
170 | int arizona_clk32k_disable(struct arizona *arizona); |
171 | |
172 | int arizona_request_irq(struct arizona *arizona, int irq, char *name, |
173 | irq_handler_t handler, void *data); |
174 | void arizona_free_irq(struct arizona *arizona, int irq, void *data); |
175 | int arizona_set_irq_wake(struct arizona *arizona, int irq, int on); |
176 | |
177 | #ifdef CONFIG_MFD_WM5102 |
178 | int wm5102_patch(struct arizona *arizona); |
179 | #else |
180 | static inline int wm5102_patch(struct arizona *arizona) |
181 | { |
182 | return 0; |
183 | } |
184 | #endif |
185 | |
186 | int wm5110_patch(struct arizona *arizona); |
187 | int cs47l24_patch(struct arizona *arizona); |
188 | int wm8997_patch(struct arizona *arizona); |
189 | int wm8998_patch(struct arizona *arizona); |
190 | |
191 | #endif |
192 | |