Lines Matching refs:arizona

29 static int arizona_map_irq(struct arizona *arizona, int irq)  in arizona_map_irq()  argument
33 if (arizona->aod_irq_chip) { in arizona_map_irq()
34 ret = regmap_irq_get_virq(arizona->aod_irq_chip, irq); in arizona_map_irq()
39 return regmap_irq_get_virq(arizona->irq_chip, irq); in arizona_map_irq()
42 int arizona_request_irq(struct arizona *arizona, int irq, char *name, in arizona_request_irq() argument
45 irq = arizona_map_irq(arizona, irq); in arizona_request_irq()
54 void arizona_free_irq(struct arizona *arizona, int irq, void *data) in arizona_free_irq() argument
56 irq = arizona_map_irq(arizona, irq); in arizona_free_irq()
64 int arizona_set_irq_wake(struct arizona *arizona, int irq, int on) in arizona_set_irq_wake() argument
66 irq = arizona_map_irq(arizona, irq); in arizona_set_irq_wake()
76 struct arizona *arizona = data; in arizona_boot_done() local
78 dev_dbg(arizona->dev, "Boot done\n"); in arizona_boot_done()
85 struct arizona *arizona = data; in arizona_ctrlif_err() local
91 dev_err(arizona->dev, "Control interface error\n"); in arizona_ctrlif_err()
98 struct arizona *arizona = data; in arizona_irq_thread() local
103 ret = pm_runtime_resume_and_get(arizona->dev); in arizona_irq_thread()
105 dev_err(arizona->dev, "Failed to resume device: %d\n", ret); in arizona_irq_thread()
112 if (arizona->aod_irq_chip) { in arizona_irq_thread()
117 ret = regmap_read(arizona->regmap, in arizona_irq_thread()
120 dev_warn(arizona->dev, in arizona_irq_thread()
124 irq_find_mapping(arizona->virq, 0)); in arizona_irq_thread()
131 ret = regmap_read(arizona->regmap, ARIZONA_IRQ_PIN_STATUS, in arizona_irq_thread()
134 handle_nested_irq(irq_find_mapping(arizona->virq, 1)); in arizona_irq_thread()
136 dev_err(arizona->dev, in arizona_irq_thread()
144 if (!arizona->pdata.irq_gpio) { in arizona_irq_thread()
146 } else if (arizona->pdata.irq_flags & IRQF_TRIGGER_RISING && in arizona_irq_thread()
147 gpio_get_value_cansleep(arizona->pdata.irq_gpio)) { in arizona_irq_thread()
149 } else if (arizona->pdata.irq_flags & IRQF_TRIGGER_FALLING && in arizona_irq_thread()
150 !gpio_get_value_cansleep(arizona->pdata.irq_gpio)) { in arizona_irq_thread()
155 pm_runtime_mark_last_busy(arizona->dev); in arizona_irq_thread()
156 pm_runtime_put_autosuspend(arizona->dev); in arizona_irq_thread()
171 struct arizona *arizona = irq_data_get_irq_chip_data(data); in arizona_irq_set_wake() local
173 return irq_set_irq_wake(arizona->irq, on); in arizona_irq_set_wake()
189 struct arizona *data = h->host_data; in arizona_irq_map()
206 int arizona_irq_init(struct arizona *arizona) in arizona_irq_init() argument
214 arizona->ctrlif_error = true; in arizona_irq_init()
216 switch (arizona->type) { in arizona_irq_init()
222 arizona->ctrlif_error = false; in arizona_irq_init()
230 switch (arizona->rev) { in arizona_irq_init()
239 arizona->ctrlif_error = false; in arizona_irq_init()
248 arizona->ctrlif_error = false; in arizona_irq_init()
256 arizona->ctrlif_error = false; in arizona_irq_init()
265 arizona->ctrlif_error = false; in arizona_irq_init()
274 regmap_write(arizona->regmap, ARIZONA_WAKE_CONTROL, 0); in arizona_irq_init()
277 if (!arizona->pdata.irq_flags) { in arizona_irq_init()
278 irq_data = irq_get_irq_data(arizona->irq); in arizona_irq_init()
280 dev_err(arizona->dev, "Invalid IRQ: %d\n", in arizona_irq_init()
281 arizona->irq); in arizona_irq_init()
285 arizona->pdata.irq_flags = irqd_get_trigger_type(irq_data); in arizona_irq_init()
286 switch (arizona->pdata.irq_flags) { in arizona_irq_init()
296 arizona->pdata.irq_flags = IRQF_TRIGGER_LOW; in arizona_irq_init()
301 if (arizona->pdata.irq_flags & (IRQF_TRIGGER_HIGH | in arizona_irq_init()
303 ret = regmap_update_bits(arizona->regmap, ARIZONA_IRQ_CTRL_1, in arizona_irq_init()
306 dev_err(arizona->dev, "Couldn't set IRQ polarity: %d\n", in arizona_irq_init()
312 flags |= arizona->pdata.irq_flags; in arizona_irq_init()
315 arizona->virq = irq_domain_add_linear(NULL, 2, &arizona_domain_ops, in arizona_irq_init()
316 arizona); in arizona_irq_init()
317 if (!arizona->virq) { in arizona_irq_init()
318 dev_err(arizona->dev, "Failed to add core IRQ domain\n"); in arizona_irq_init()
324 virq = irq_create_mapping(arizona->virq, ARIZONA_AOD_IRQ_INDEX); in arizona_irq_init()
326 dev_err(arizona->dev, "Failed to map AOD IRQs\n"); in arizona_irq_init()
331 ret = regmap_add_irq_chip(arizona->regmap, virq, IRQF_ONESHOT, in arizona_irq_init()
332 0, aod, &arizona->aod_irq_chip); in arizona_irq_init()
334 dev_err(arizona->dev, in arizona_irq_init()
340 virq = irq_create_mapping(arizona->virq, ARIZONA_MAIN_IRQ_INDEX); in arizona_irq_init()
342 dev_err(arizona->dev, "Failed to map main IRQs\n"); in arizona_irq_init()
347 ret = regmap_add_irq_chip(arizona->regmap, virq, IRQF_ONESHOT, in arizona_irq_init()
348 0, irq, &arizona->irq_chip); in arizona_irq_init()
350 dev_err(arizona->dev, "Failed to add main IRQs: %d\n", ret); in arizona_irq_init()
355 if (arizona->pdata.irq_gpio) { in arizona_irq_init()
356 if (gpio_to_irq(arizona->pdata.irq_gpio) != arizona->irq) { in arizona_irq_init()
357 dev_warn(arizona->dev, "IRQ %d is not GPIO %d (%d)\n", in arizona_irq_init()
358 arizona->irq, arizona->pdata.irq_gpio, in arizona_irq_init()
359 gpio_to_irq(arizona->pdata.irq_gpio)); in arizona_irq_init()
360 arizona->irq = gpio_to_irq(arizona->pdata.irq_gpio); in arizona_irq_init()
363 ret = devm_gpio_request_one(arizona->dev, in arizona_irq_init()
364 arizona->pdata.irq_gpio, in arizona_irq_init()
367 dev_err(arizona->dev, in arizona_irq_init()
369 arizona->pdata.irq_gpio, ret); in arizona_irq_init()
370 arizona->pdata.irq_gpio = 0; in arizona_irq_init()
374 ret = request_threaded_irq(arizona->irq, NULL, arizona_irq_thread, in arizona_irq_init()
375 flags, "arizona", arizona); in arizona_irq_init()
378 dev_err(arizona->dev, "Failed to request primary IRQ %d: %d\n", in arizona_irq_init()
379 arizona->irq, ret); in arizona_irq_init()
384 ret = arizona_request_irq(arizona, ARIZONA_IRQ_BOOT_DONE, "Boot done", in arizona_irq_init()
385 arizona_boot_done, arizona); in arizona_irq_init()
387 dev_err(arizona->dev, "Failed to request boot done %d: %d\n", in arizona_irq_init()
388 arizona->irq, ret); in arizona_irq_init()
393 if (arizona->ctrlif_error) { in arizona_irq_init()
394 ret = arizona_request_irq(arizona, ARIZONA_IRQ_CTRLIF_ERR, in arizona_irq_init()
396 arizona_ctrlif_err, arizona); in arizona_irq_init()
398 dev_err(arizona->dev, in arizona_irq_init()
400 arizona->irq, ret); in arizona_irq_init()
408 arizona_free_irq(arizona, ARIZONA_IRQ_BOOT_DONE, arizona); in arizona_irq_init()
410 free_irq(arizona->irq, arizona); in arizona_irq_init()
412 regmap_del_irq_chip(irq_find_mapping(arizona->virq, in arizona_irq_init()
414 arizona->irq_chip); in arizona_irq_init()
416 irq_dispose_mapping(irq_find_mapping(arizona->virq, in arizona_irq_init()
419 regmap_del_irq_chip(irq_find_mapping(arizona->virq, in arizona_irq_init()
421 arizona->aod_irq_chip); in arizona_irq_init()
423 irq_dispose_mapping(irq_find_mapping(arizona->virq, in arizona_irq_init()
426 irq_domain_remove(arizona->virq); in arizona_irq_init()
431 int arizona_irq_exit(struct arizona *arizona) in arizona_irq_exit() argument
435 if (arizona->ctrlif_error) in arizona_irq_exit()
436 arizona_free_irq(arizona, ARIZONA_IRQ_CTRLIF_ERR, arizona); in arizona_irq_exit()
437 arizona_free_irq(arizona, ARIZONA_IRQ_BOOT_DONE, arizona); in arizona_irq_exit()
439 virq = irq_find_mapping(arizona->virq, ARIZONA_MAIN_IRQ_INDEX); in arizona_irq_exit()
440 regmap_del_irq_chip(virq, arizona->irq_chip); in arizona_irq_exit()
443 virq = irq_find_mapping(arizona->virq, ARIZONA_AOD_IRQ_INDEX); in arizona_irq_exit()
444 regmap_del_irq_chip(virq, arizona->aod_irq_chip); in arizona_irq_exit()
447 irq_domain_remove(arizona->virq); in arizona_irq_exit()
449 free_irq(arizona->irq, arizona); in arizona_irq_exit()