Commit e1bfe75d66f809ad61d0a6d070dc78bb05369026
Committed by
Samuel Ortiz
1 parent
7d1f9aeff1
Exists in
smarc-l5.0.0_1.0.0-ga
and in
5 other branches
mfd: arizona: Disable control interface reporting for WM5102 and WM5110
Rather than disabling the error reporting only for earlier revisions unconditionally disable it. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Showing 1 changed file with 2 additions and 16 deletions Inline Diff
drivers/mfd/arizona-irq.c
1 | /* | 1 | /* |
2 | * Arizona interrupt support | 2 | * Arizona interrupt support |
3 | * | 3 | * |
4 | * Copyright 2012 Wolfson Microelectronics plc | 4 | * Copyright 2012 Wolfson Microelectronics plc |
5 | * | 5 | * |
6 | * Author: Mark Brown <broonie@opensource.wolfsonmicro.com> | 6 | * Author: Mark Brown <broonie@opensource.wolfsonmicro.com> |
7 | * | 7 | * |
8 | * This program is free software; you can redistribute it and/or modify | 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 | 9 | * it under the terms of the GNU General Public License version 2 as |
10 | * published by the Free Software Foundation. | 10 | * published by the Free Software Foundation. |
11 | */ | 11 | */ |
12 | 12 | ||
13 | #include <linux/delay.h> | 13 | #include <linux/delay.h> |
14 | #include <linux/gpio.h> | 14 | #include <linux/gpio.h> |
15 | #include <linux/interrupt.h> | 15 | #include <linux/interrupt.h> |
16 | #include <linux/irq.h> | 16 | #include <linux/irq.h> |
17 | #include <linux/irqdomain.h> | 17 | #include <linux/irqdomain.h> |
18 | #include <linux/module.h> | 18 | #include <linux/module.h> |
19 | #include <linux/pm_runtime.h> | 19 | #include <linux/pm_runtime.h> |
20 | #include <linux/regmap.h> | 20 | #include <linux/regmap.h> |
21 | #include <linux/regulator/consumer.h> | 21 | #include <linux/regulator/consumer.h> |
22 | #include <linux/slab.h> | 22 | #include <linux/slab.h> |
23 | 23 | ||
24 | #include <linux/mfd/arizona/core.h> | 24 | #include <linux/mfd/arizona/core.h> |
25 | #include <linux/mfd/arizona/registers.h> | 25 | #include <linux/mfd/arizona/registers.h> |
26 | 26 | ||
27 | #include "arizona.h" | 27 | #include "arizona.h" |
28 | 28 | ||
29 | static int arizona_map_irq(struct arizona *arizona, int irq) | 29 | static int arizona_map_irq(struct arizona *arizona, int irq) |
30 | { | 30 | { |
31 | int ret; | 31 | int ret; |
32 | 32 | ||
33 | ret = regmap_irq_get_virq(arizona->aod_irq_chip, irq); | 33 | ret = regmap_irq_get_virq(arizona->aod_irq_chip, irq); |
34 | if (ret < 0) | 34 | if (ret < 0) |
35 | ret = regmap_irq_get_virq(arizona->irq_chip, irq); | 35 | ret = regmap_irq_get_virq(arizona->irq_chip, irq); |
36 | 36 | ||
37 | return ret; | 37 | return ret; |
38 | } | 38 | } |
39 | 39 | ||
40 | int arizona_request_irq(struct arizona *arizona, int irq, char *name, | 40 | int arizona_request_irq(struct arizona *arizona, int irq, char *name, |
41 | irq_handler_t handler, void *data) | 41 | irq_handler_t handler, void *data) |
42 | { | 42 | { |
43 | irq = arizona_map_irq(arizona, irq); | 43 | irq = arizona_map_irq(arizona, irq); |
44 | if (irq < 0) | 44 | if (irq < 0) |
45 | return irq; | 45 | return irq; |
46 | 46 | ||
47 | return request_threaded_irq(irq, NULL, handler, IRQF_ONESHOT, | 47 | return request_threaded_irq(irq, NULL, handler, IRQF_ONESHOT, |
48 | name, data); | 48 | name, data); |
49 | } | 49 | } |
50 | EXPORT_SYMBOL_GPL(arizona_request_irq); | 50 | EXPORT_SYMBOL_GPL(arizona_request_irq); |
51 | 51 | ||
52 | void arizona_free_irq(struct arizona *arizona, int irq, void *data) | 52 | void arizona_free_irq(struct arizona *arizona, int irq, void *data) |
53 | { | 53 | { |
54 | irq = arizona_map_irq(arizona, irq); | 54 | irq = arizona_map_irq(arizona, irq); |
55 | if (irq < 0) | 55 | if (irq < 0) |
56 | return; | 56 | return; |
57 | 57 | ||
58 | free_irq(irq, data); | 58 | free_irq(irq, data); |
59 | } | 59 | } |
60 | EXPORT_SYMBOL_GPL(arizona_free_irq); | 60 | EXPORT_SYMBOL_GPL(arizona_free_irq); |
61 | 61 | ||
62 | int arizona_set_irq_wake(struct arizona *arizona, int irq, int on) | 62 | int arizona_set_irq_wake(struct arizona *arizona, int irq, int on) |
63 | { | 63 | { |
64 | irq = arizona_map_irq(arizona, irq); | 64 | irq = arizona_map_irq(arizona, irq); |
65 | if (irq < 0) | 65 | if (irq < 0) |
66 | return irq; | 66 | return irq; |
67 | 67 | ||
68 | return irq_set_irq_wake(irq, on); | 68 | return irq_set_irq_wake(irq, on); |
69 | } | 69 | } |
70 | EXPORT_SYMBOL_GPL(arizona_set_irq_wake); | 70 | EXPORT_SYMBOL_GPL(arizona_set_irq_wake); |
71 | 71 | ||
72 | static irqreturn_t arizona_boot_done(int irq, void *data) | 72 | static irqreturn_t arizona_boot_done(int irq, void *data) |
73 | { | 73 | { |
74 | struct arizona *arizona = data; | 74 | struct arizona *arizona = data; |
75 | 75 | ||
76 | dev_dbg(arizona->dev, "Boot done\n"); | 76 | dev_dbg(arizona->dev, "Boot done\n"); |
77 | 77 | ||
78 | return IRQ_HANDLED; | 78 | return IRQ_HANDLED; |
79 | } | 79 | } |
80 | 80 | ||
81 | static irqreturn_t arizona_ctrlif_err(int irq, void *data) | 81 | static irqreturn_t arizona_ctrlif_err(int irq, void *data) |
82 | { | 82 | { |
83 | struct arizona *arizona = data; | 83 | struct arizona *arizona = data; |
84 | 84 | ||
85 | /* | 85 | /* |
86 | * For pretty much all potential sources a register cache sync | 86 | * For pretty much all potential sources a register cache sync |
87 | * won't help, we've just got a software bug somewhere. | 87 | * won't help, we've just got a software bug somewhere. |
88 | */ | 88 | */ |
89 | dev_err(arizona->dev, "Control interface error\n"); | 89 | dev_err(arizona->dev, "Control interface error\n"); |
90 | 90 | ||
91 | return IRQ_HANDLED; | 91 | return IRQ_HANDLED; |
92 | } | 92 | } |
93 | 93 | ||
94 | static irqreturn_t arizona_irq_thread(int irq, void *data) | 94 | static irqreturn_t arizona_irq_thread(int irq, void *data) |
95 | { | 95 | { |
96 | struct arizona *arizona = data; | 96 | struct arizona *arizona = data; |
97 | unsigned int val; | 97 | unsigned int val; |
98 | int ret; | 98 | int ret; |
99 | 99 | ||
100 | ret = pm_runtime_get_sync(arizona->dev); | 100 | ret = pm_runtime_get_sync(arizona->dev); |
101 | if (ret < 0) { | 101 | if (ret < 0) { |
102 | dev_err(arizona->dev, "Failed to resume device: %d\n", ret); | 102 | dev_err(arizona->dev, "Failed to resume device: %d\n", ret); |
103 | return IRQ_NONE; | 103 | return IRQ_NONE; |
104 | } | 104 | } |
105 | 105 | ||
106 | /* Always handle the AoD domain */ | 106 | /* Always handle the AoD domain */ |
107 | handle_nested_irq(irq_find_mapping(arizona->virq, 0)); | 107 | handle_nested_irq(irq_find_mapping(arizona->virq, 0)); |
108 | 108 | ||
109 | /* | 109 | /* |
110 | * Check if one of the main interrupts is asserted and only | 110 | * Check if one of the main interrupts is asserted and only |
111 | * check that domain if it is. | 111 | * check that domain if it is. |
112 | */ | 112 | */ |
113 | ret = regmap_read(arizona->regmap, ARIZONA_IRQ_PIN_STATUS, &val); | 113 | ret = regmap_read(arizona->regmap, ARIZONA_IRQ_PIN_STATUS, &val); |
114 | if (ret == 0 && val & ARIZONA_IRQ1_STS) { | 114 | if (ret == 0 && val & ARIZONA_IRQ1_STS) { |
115 | handle_nested_irq(irq_find_mapping(arizona->virq, 1)); | 115 | handle_nested_irq(irq_find_mapping(arizona->virq, 1)); |
116 | } else if (ret != 0) { | 116 | } else if (ret != 0) { |
117 | dev_err(arizona->dev, "Failed to read main IRQ status: %d\n", | 117 | dev_err(arizona->dev, "Failed to read main IRQ status: %d\n", |
118 | ret); | 118 | ret); |
119 | } | 119 | } |
120 | 120 | ||
121 | pm_runtime_mark_last_busy(arizona->dev); | 121 | pm_runtime_mark_last_busy(arizona->dev); |
122 | pm_runtime_put_autosuspend(arizona->dev); | 122 | pm_runtime_put_autosuspend(arizona->dev); |
123 | 123 | ||
124 | return IRQ_HANDLED; | 124 | return IRQ_HANDLED; |
125 | } | 125 | } |
126 | 126 | ||
127 | static void arizona_irq_enable(struct irq_data *data) | 127 | static void arizona_irq_enable(struct irq_data *data) |
128 | { | 128 | { |
129 | } | 129 | } |
130 | 130 | ||
131 | static void arizona_irq_disable(struct irq_data *data) | 131 | static void arizona_irq_disable(struct irq_data *data) |
132 | { | 132 | { |
133 | } | 133 | } |
134 | 134 | ||
135 | static struct irq_chip arizona_irq_chip = { | 135 | static struct irq_chip arizona_irq_chip = { |
136 | .name = "arizona", | 136 | .name = "arizona", |
137 | .irq_disable = arizona_irq_disable, | 137 | .irq_disable = arizona_irq_disable, |
138 | .irq_enable = arizona_irq_enable, | 138 | .irq_enable = arizona_irq_enable, |
139 | }; | 139 | }; |
140 | 140 | ||
141 | static int arizona_irq_map(struct irq_domain *h, unsigned int virq, | 141 | static int arizona_irq_map(struct irq_domain *h, unsigned int virq, |
142 | irq_hw_number_t hw) | 142 | irq_hw_number_t hw) |
143 | { | 143 | { |
144 | struct regmap_irq_chip_data *data = h->host_data; | 144 | struct regmap_irq_chip_data *data = h->host_data; |
145 | 145 | ||
146 | irq_set_chip_data(virq, data); | 146 | irq_set_chip_data(virq, data); |
147 | irq_set_chip_and_handler(virq, &arizona_irq_chip, handle_edge_irq); | 147 | irq_set_chip_and_handler(virq, &arizona_irq_chip, handle_edge_irq); |
148 | irq_set_nested_thread(virq, 1); | 148 | irq_set_nested_thread(virq, 1); |
149 | 149 | ||
150 | /* ARM needs us to explicitly flag the IRQ as valid | 150 | /* ARM needs us to explicitly flag the IRQ as valid |
151 | * and will set them noprobe when we do so. */ | 151 | * and will set them noprobe when we do so. */ |
152 | #ifdef CONFIG_ARM | 152 | #ifdef CONFIG_ARM |
153 | set_irq_flags(virq, IRQF_VALID); | 153 | set_irq_flags(virq, IRQF_VALID); |
154 | #else | 154 | #else |
155 | irq_set_noprobe(virq); | 155 | irq_set_noprobe(virq); |
156 | #endif | 156 | #endif |
157 | 157 | ||
158 | return 0; | 158 | return 0; |
159 | } | 159 | } |
160 | 160 | ||
161 | static struct irq_domain_ops arizona_domain_ops = { | 161 | static struct irq_domain_ops arizona_domain_ops = { |
162 | .map = arizona_irq_map, | 162 | .map = arizona_irq_map, |
163 | .xlate = irq_domain_xlate_twocell, | 163 | .xlate = irq_domain_xlate_twocell, |
164 | }; | 164 | }; |
165 | 165 | ||
166 | int arizona_irq_init(struct arizona *arizona) | 166 | int arizona_irq_init(struct arizona *arizona) |
167 | { | 167 | { |
168 | int flags = IRQF_ONESHOT; | 168 | int flags = IRQF_ONESHOT; |
169 | int ret, i; | 169 | int ret, i; |
170 | const struct regmap_irq_chip *aod, *irq; | 170 | const struct regmap_irq_chip *aod, *irq; |
171 | bool ctrlif_error = true; | 171 | bool ctrlif_error = true; |
172 | 172 | ||
173 | switch (arizona->type) { | 173 | switch (arizona->type) { |
174 | #ifdef CONFIG_MFD_WM5102 | 174 | #ifdef CONFIG_MFD_WM5102 |
175 | case WM5102: | 175 | case WM5102: |
176 | aod = &wm5102_aod; | 176 | aod = &wm5102_aod; |
177 | irq = &wm5102_irq; | 177 | irq = &wm5102_irq; |
178 | 178 | ||
179 | switch (arizona->rev) { | 179 | ctrlif_error = false; |
180 | case 0: | ||
181 | case 1: | ||
182 | ctrlif_error = false; | ||
183 | break; | ||
184 | default: | ||
185 | break; | ||
186 | } | ||
187 | break; | 180 | break; |
188 | #endif | 181 | #endif |
189 | #ifdef CONFIG_MFD_WM5110 | 182 | #ifdef CONFIG_MFD_WM5110 |
190 | case WM5110: | 183 | case WM5110: |
191 | aod = &wm5110_aod; | 184 | aod = &wm5110_aod; |
192 | irq = &wm5110_irq; | 185 | irq = &wm5110_irq; |
193 | 186 | ||
194 | switch (arizona->rev) { | 187 | ctrlif_error = false; |
195 | case 0: | ||
196 | case 1: | ||
197 | ctrlif_error = false; | ||
198 | break; | ||
199 | default: | ||
200 | break; | ||
201 | } | ||
202 | break; | 188 | break; |
203 | #endif | 189 | #endif |
204 | default: | 190 | default: |
205 | BUG_ON("Unknown Arizona class device" == NULL); | 191 | BUG_ON("Unknown Arizona class device" == NULL); |
206 | return -EINVAL; | 192 | return -EINVAL; |
207 | } | 193 | } |
208 | 194 | ||
209 | if (arizona->pdata.irq_active_high) { | 195 | if (arizona->pdata.irq_active_high) { |
210 | ret = regmap_update_bits(arizona->regmap, ARIZONA_IRQ_CTRL_1, | 196 | ret = regmap_update_bits(arizona->regmap, ARIZONA_IRQ_CTRL_1, |
211 | ARIZONA_IRQ_POL, 0); | 197 | ARIZONA_IRQ_POL, 0); |
212 | if (ret != 0) { | 198 | if (ret != 0) { |
213 | dev_err(arizona->dev, "Couldn't set IRQ polarity: %d\n", | 199 | dev_err(arizona->dev, "Couldn't set IRQ polarity: %d\n", |
214 | ret); | 200 | ret); |
215 | goto err; | 201 | goto err; |
216 | } | 202 | } |
217 | 203 | ||
218 | flags |= IRQF_TRIGGER_HIGH; | 204 | flags |= IRQF_TRIGGER_HIGH; |
219 | } else { | 205 | } else { |
220 | flags |= IRQF_TRIGGER_LOW; | 206 | flags |= IRQF_TRIGGER_LOW; |
221 | } | 207 | } |
222 | 208 | ||
223 | /* Allocate a virtual IRQ domain to distribute to the regmap domains */ | 209 | /* Allocate a virtual IRQ domain to distribute to the regmap domains */ |
224 | arizona->virq = irq_domain_add_linear(NULL, 2, &arizona_domain_ops, | 210 | arizona->virq = irq_domain_add_linear(NULL, 2, &arizona_domain_ops, |
225 | arizona); | 211 | arizona); |
226 | if (!arizona->virq) { | 212 | if (!arizona->virq) { |
227 | dev_err(arizona->dev, "Failed to add core IRQ domain\n"); | 213 | dev_err(arizona->dev, "Failed to add core IRQ domain\n"); |
228 | ret = -EINVAL; | 214 | ret = -EINVAL; |
229 | goto err; | 215 | goto err; |
230 | } | 216 | } |
231 | 217 | ||
232 | ret = regmap_add_irq_chip(arizona->regmap, | 218 | ret = regmap_add_irq_chip(arizona->regmap, |
233 | irq_create_mapping(arizona->virq, 0), | 219 | irq_create_mapping(arizona->virq, 0), |
234 | IRQF_ONESHOT, -1, aod, | 220 | IRQF_ONESHOT, -1, aod, |
235 | &arizona->aod_irq_chip); | 221 | &arizona->aod_irq_chip); |
236 | if (ret != 0) { | 222 | if (ret != 0) { |
237 | dev_err(arizona->dev, "Failed to add AOD IRQs: %d\n", ret); | 223 | dev_err(arizona->dev, "Failed to add AOD IRQs: %d\n", ret); |
238 | goto err_domain; | 224 | goto err_domain; |
239 | } | 225 | } |
240 | 226 | ||
241 | ret = regmap_add_irq_chip(arizona->regmap, | 227 | ret = regmap_add_irq_chip(arizona->regmap, |
242 | irq_create_mapping(arizona->virq, 1), | 228 | irq_create_mapping(arizona->virq, 1), |
243 | IRQF_ONESHOT, -1, irq, | 229 | IRQF_ONESHOT, -1, irq, |
244 | &arizona->irq_chip); | 230 | &arizona->irq_chip); |
245 | if (ret != 0) { | 231 | if (ret != 0) { |
246 | dev_err(arizona->dev, "Failed to add AOD IRQs: %d\n", ret); | 232 | dev_err(arizona->dev, "Failed to add AOD IRQs: %d\n", ret); |
247 | goto err_aod; | 233 | goto err_aod; |
248 | } | 234 | } |
249 | 235 | ||
250 | /* Make sure the boot done IRQ is unmasked for resumes */ | 236 | /* Make sure the boot done IRQ is unmasked for resumes */ |
251 | i = arizona_map_irq(arizona, ARIZONA_IRQ_BOOT_DONE); | 237 | i = arizona_map_irq(arizona, ARIZONA_IRQ_BOOT_DONE); |
252 | ret = request_threaded_irq(i, NULL, arizona_boot_done, IRQF_ONESHOT, | 238 | ret = request_threaded_irq(i, NULL, arizona_boot_done, IRQF_ONESHOT, |
253 | "Boot done", arizona); | 239 | "Boot done", arizona); |
254 | if (ret != 0) { | 240 | if (ret != 0) { |
255 | dev_err(arizona->dev, "Failed to request boot done %d: %d\n", | 241 | dev_err(arizona->dev, "Failed to request boot done %d: %d\n", |
256 | arizona->irq, ret); | 242 | arizona->irq, ret); |
257 | goto err_boot_done; | 243 | goto err_boot_done; |
258 | } | 244 | } |
259 | 245 | ||
260 | /* Handle control interface errors in the core */ | 246 | /* Handle control interface errors in the core */ |
261 | if (ctrlif_error) { | 247 | if (ctrlif_error) { |
262 | i = arizona_map_irq(arizona, ARIZONA_IRQ_CTRLIF_ERR); | 248 | i = arizona_map_irq(arizona, ARIZONA_IRQ_CTRLIF_ERR); |
263 | ret = request_threaded_irq(i, NULL, arizona_ctrlif_err, | 249 | ret = request_threaded_irq(i, NULL, arizona_ctrlif_err, |
264 | IRQF_ONESHOT, | 250 | IRQF_ONESHOT, |
265 | "Control interface error", arizona); | 251 | "Control interface error", arizona); |
266 | if (ret != 0) { | 252 | if (ret != 0) { |
267 | dev_err(arizona->dev, | 253 | dev_err(arizona->dev, |
268 | "Failed to request CTRLIF_ERR %d: %d\n", | 254 | "Failed to request CTRLIF_ERR %d: %d\n", |
269 | arizona->irq, ret); | 255 | arizona->irq, ret); |
270 | goto err_ctrlif; | 256 | goto err_ctrlif; |
271 | } | 257 | } |
272 | } | 258 | } |
273 | 259 | ||
274 | ret = request_threaded_irq(arizona->irq, NULL, arizona_irq_thread, | 260 | ret = request_threaded_irq(arizona->irq, NULL, arizona_irq_thread, |
275 | flags, "arizona", arizona); | 261 | flags, "arizona", arizona); |
276 | 262 | ||
277 | if (ret != 0) { | 263 | if (ret != 0) { |
278 | dev_err(arizona->dev, "Failed to request IRQ %d: %d\n", | 264 | dev_err(arizona->dev, "Failed to request IRQ %d: %d\n", |
279 | arizona->irq, ret); | 265 | arizona->irq, ret); |
280 | goto err_main_irq; | 266 | goto err_main_irq; |
281 | } | 267 | } |
282 | 268 | ||
283 | return 0; | 269 | return 0; |
284 | 270 | ||
285 | err_main_irq: | 271 | err_main_irq: |
286 | free_irq(arizona_map_irq(arizona, ARIZONA_IRQ_CTRLIF_ERR), arizona); | 272 | free_irq(arizona_map_irq(arizona, ARIZONA_IRQ_CTRLIF_ERR), arizona); |
287 | err_ctrlif: | 273 | err_ctrlif: |
288 | free_irq(arizona_map_irq(arizona, ARIZONA_IRQ_BOOT_DONE), arizona); | 274 | free_irq(arizona_map_irq(arizona, ARIZONA_IRQ_BOOT_DONE), arizona); |
289 | err_boot_done: | 275 | err_boot_done: |
290 | regmap_del_irq_chip(irq_create_mapping(arizona->virq, 1), | 276 | regmap_del_irq_chip(irq_create_mapping(arizona->virq, 1), |
291 | arizona->irq_chip); | 277 | arizona->irq_chip); |
292 | err_aod: | 278 | err_aod: |
293 | regmap_del_irq_chip(irq_create_mapping(arizona->virq, 0), | 279 | regmap_del_irq_chip(irq_create_mapping(arizona->virq, 0), |
294 | arizona->aod_irq_chip); | 280 | arizona->aod_irq_chip); |
295 | err_domain: | 281 | err_domain: |
296 | err: | 282 | err: |
297 | return ret; | 283 | return ret; |
298 | } | 284 | } |
299 | 285 | ||
300 | int arizona_irq_exit(struct arizona *arizona) | 286 | int arizona_irq_exit(struct arizona *arizona) |
301 | { | 287 | { |
302 | free_irq(arizona_map_irq(arizona, ARIZONA_IRQ_CTRLIF_ERR), arizona); | 288 | free_irq(arizona_map_irq(arizona, ARIZONA_IRQ_CTRLIF_ERR), arizona); |
303 | free_irq(arizona_map_irq(arizona, ARIZONA_IRQ_BOOT_DONE), arizona); | 289 | free_irq(arizona_map_irq(arizona, ARIZONA_IRQ_BOOT_DONE), arizona); |
304 | regmap_del_irq_chip(irq_create_mapping(arizona->virq, 1), | 290 | regmap_del_irq_chip(irq_create_mapping(arizona->virq, 1), |
305 | arizona->irq_chip); | 291 | arizona->irq_chip); |
306 | regmap_del_irq_chip(irq_create_mapping(arizona->virq, 0), | 292 | regmap_del_irq_chip(irq_create_mapping(arizona->virq, 0), |
307 | arizona->aod_irq_chip); | 293 | arizona->aod_irq_chip); |
308 | free_irq(arizona->irq, arizona); | 294 | free_irq(arizona->irq, arizona); |
309 | 295 | ||
310 | return 0; | 296 | return 0; |
311 | } | 297 | } |
312 | 298 |