Lines Matching refs:wm831x

324 static inline struct wm831x_irq_data *irq_to_wm831x_irq(struct wm831x *wm831x,  in irq_to_wm831x_irq()  argument
332 struct wm831x *wm831x = irq_data_get_irq_chip_data(data); in wm831x_irq_lock() local
334 mutex_lock(&wm831x->irq_lock); in wm831x_irq_lock()
339 struct wm831x *wm831x = irq_data_get_irq_chip_data(data); in wm831x_irq_sync_unlock() local
342 for (i = 0; i < ARRAY_SIZE(wm831x->gpio_update); i++) { in wm831x_irq_sync_unlock()
343 if (wm831x->gpio_update[i]) { in wm831x_irq_sync_unlock()
344 wm831x_set_bits(wm831x, WM831X_GPIO1_CONTROL + i, in wm831x_irq_sync_unlock()
346 wm831x->gpio_update[i]); in wm831x_irq_sync_unlock()
347 wm831x->gpio_update[i] = 0; in wm831x_irq_sync_unlock()
351 for (i = 0; i < ARRAY_SIZE(wm831x->irq_masks_cur); i++) { in wm831x_irq_sync_unlock()
354 if (wm831x->irq_masks_cur[i] != wm831x->irq_masks_cache[i]) { in wm831x_irq_sync_unlock()
355 dev_dbg(wm831x->dev, "IRQ mask sync: %x = %x\n", in wm831x_irq_sync_unlock()
357 wm831x->irq_masks_cur[i]); in wm831x_irq_sync_unlock()
359 wm831x->irq_masks_cache[i] = wm831x->irq_masks_cur[i]; in wm831x_irq_sync_unlock()
360 wm831x_reg_write(wm831x, in wm831x_irq_sync_unlock()
362 wm831x->irq_masks_cur[i]); in wm831x_irq_sync_unlock()
366 mutex_unlock(&wm831x->irq_lock); in wm831x_irq_sync_unlock()
371 struct wm831x *wm831x = irq_data_get_irq_chip_data(data); in wm831x_irq_enable() local
372 struct wm831x_irq_data *irq_data = irq_to_wm831x_irq(wm831x, in wm831x_irq_enable()
375 wm831x->irq_masks_cur[irq_data->reg - 1] &= ~irq_data->mask; in wm831x_irq_enable()
380 struct wm831x *wm831x = irq_data_get_irq_chip_data(data); in wm831x_irq_disable() local
381 struct wm831x_irq_data *irq_data = irq_to_wm831x_irq(wm831x, in wm831x_irq_disable()
384 wm831x->irq_masks_cur[irq_data->reg - 1] |= irq_data->mask; in wm831x_irq_disable()
389 struct wm831x *wm831x = irq_data_get_irq_chip_data(data); in wm831x_irq_set_type() local
411 wm831x->gpio_level_low[irq] = false; in wm831x_irq_set_type()
412 wm831x->gpio_level_high[irq] = false; in wm831x_irq_set_type()
415 wm831x->gpio_update[irq] = 0x10000 | WM831X_GPN_INT_MODE; in wm831x_irq_set_type()
418 wm831x->gpio_update[irq] = 0x10000 | WM831X_GPN_POL; in wm831x_irq_set_type()
421 wm831x->gpio_update[irq] = 0x10000; in wm831x_irq_set_type()
424 wm831x->gpio_update[irq] = 0x10000 | WM831X_GPN_POL; in wm831x_irq_set_type()
425 wm831x->gpio_level_high[irq] = true; in wm831x_irq_set_type()
428 wm831x->gpio_update[irq] = 0x10000; in wm831x_irq_set_type()
429 wm831x->gpio_level_low[irq] = true; in wm831x_irq_set_type()
451 struct wm831x *wm831x = data; in wm831x_irq_thread() local
458 primary = wm831x_reg_read(wm831x, WM831X_SYSTEM_INTERRUPTS); in wm831x_irq_thread()
460 dev_err(wm831x->dev, "Failed to read system interrupt: %d\n", in wm831x_irq_thread()
471 handle_nested_irq(irq_find_mapping(wm831x->irq_domain, in wm831x_irq_thread()
474 handle_nested_irq(irq_find_mapping(wm831x->irq_domain, in wm831x_irq_thread()
491 *status = wm831x_reg_read(wm831x, status_addr); in wm831x_irq_thread()
493 dev_err(wm831x->dev, in wm831x_irq_thread()
502 *status &= ~wm831x->irq_masks_cur[offset]; in wm831x_irq_thread()
507 wm831x_reg_write(wm831x, status_addr, *status); in wm831x_irq_thread()
511 handle_nested_irq(irq_find_mapping(wm831x->irq_domain, in wm831x_irq_thread()
518 wm831x->gpio_level_high[i - WM831X_IRQ_GPIO_1]) { in wm831x_irq_thread()
519 ret = wm831x_reg_read(wm831x, WM831X_GPIO_LEVEL); in wm831x_irq_thread()
521 handle_nested_irq(irq_find_mapping(wm831x->irq_domain, in wm831x_irq_thread()
523 ret = wm831x_reg_read(wm831x, in wm831x_irq_thread()
529 wm831x->gpio_level_low[i - WM831X_IRQ_GPIO_1]) { in wm831x_irq_thread()
530 ret = wm831x_reg_read(wm831x, WM831X_GPIO_LEVEL); in wm831x_irq_thread()
532 handle_nested_irq(irq_find_mapping(wm831x->irq_domain, in wm831x_irq_thread()
534 ret = wm831x_reg_read(wm831x, in wm831x_irq_thread()
560 int wm831x_irq_init(struct wm831x *wm831x, int irq) in wm831x_irq_init() argument
562 struct wm831x_pdata *pdata = &wm831x->pdata; in wm831x_irq_init()
566 mutex_init(&wm831x->irq_lock); in wm831x_irq_init()
569 for (i = 0; i < ARRAY_SIZE(wm831x->irq_masks_cur); i++) { in wm831x_irq_init()
570 wm831x->irq_masks_cur[i] = 0xffff; in wm831x_irq_init()
571 wm831x->irq_masks_cache[i] = 0xffff; in wm831x_irq_init()
572 wm831x_reg_write(wm831x, WM831X_INTERRUPT_STATUS_1_MASK + i, in wm831x_irq_init()
581 dev_warn(wm831x->dev, "Failed to allocate IRQs: %d\n", in wm831x_irq_init()
590 domain = irq_domain_add_legacy(wm831x->dev->of_node, in wm831x_irq_init()
594 wm831x); in wm831x_irq_init()
596 domain = irq_domain_add_linear(wm831x->dev->of_node, in wm831x_irq_init()
599 wm831x); in wm831x_irq_init()
602 dev_warn(wm831x->dev, "Failed to allocate IRQ domain\n"); in wm831x_irq_init()
611 wm831x_set_bits(wm831x, WM831X_IRQ_CONFIG, in wm831x_irq_init()
614 wm831x->irq = irq; in wm831x_irq_init()
615 wm831x->irq_domain = domain; in wm831x_irq_init()
625 dev_warn(wm831x->dev, in wm831x_irq_init()
632 "wm831x", wm831x); in wm831x_irq_init()
634 dev_err(wm831x->dev, "Failed to request IRQ %d: %d\n", in wm831x_irq_init()
639 dev_warn(wm831x->dev, in wm831x_irq_init()
644 wm831x_reg_write(wm831x, WM831X_SYSTEM_INTERRUPTS_MASK, 0); in wm831x_irq_init()
649 void wm831x_irq_exit(struct wm831x *wm831x) in wm831x_irq_exit() argument
651 if (wm831x->irq) in wm831x_irq_exit()
652 free_irq(wm831x->irq, wm831x); in wm831x_irq_exit()