Lines Matching +full:meson +full:- +full:gpio
1 // SPDX-License-Identifier: GPL-2.0-only
38 #define REG_EDGE_POL_EDGE(params, x) BIT((params)->edge_single_offset + (x))
39 #define REG_EDGE_POL_LOW(params, x) BIT((params)->pol_low_offset + (x))
40 #define REG_BOTH_EDGE(params, x) BIT((params)->edge_both_offset + (x))
162 { .compatible = "amlogic,meson8-gpio-intc", .data = &meson8_params },
163 { .compatible = "amlogic,meson8b-gpio-intc", .data = &meson8b_params },
164 { .compatible = "amlogic,meson-gxbb-gpio-intc", .data = &gxbb_params },
165 { .compatible = "amlogic,meson-gxl-gpio-intc", .data = &gxl_params },
166 { .compatible = "amlogic,meson-axg-gpio-intc", .data = &axg_params },
167 { .compatible = "amlogic,meson-g12a-gpio-intc", .data = &axg_params },
168 { .compatible = "amlogic,meson-sm1-gpio-intc", .data = &sm1_params },
169 { .compatible = "amlogic,meson-a1-gpio-intc", .data = &a1_params },
170 { .compatible = "amlogic,meson-s4-gpio-intc", .data = &s4_params },
171 { .compatible = "amlogic,c3-gpio-intc", .data = &c3_params },
172 { .compatible = "amlogic,t7-gpio-intc", .data = &t7_params },
190 raw_spin_lock_irqsave(&ctl->lock, flags); in meson_gpio_irq_update_bits()
192 tmp = readl_relaxed(ctl->base + reg); in meson_gpio_irq_update_bits()
195 writel_relaxed(tmp, ctl->base + reg); in meson_gpio_irq_update_bits()
197 raw_spin_unlock_irqrestore(&ctl->lock, flags); in meson_gpio_irq_update_bits()
214 ctl->params->pin_sel_mask << bit_offset, in meson8_gpio_irq_sel_pin()
229 ctl->params->pin_sel_mask << bit_offset, in meson_a1_gpio_irq_sel_pin()
247 raw_spin_lock_irqsave(&ctl->lock, flags); in meson_gpio_irq_request_channel()
250 idx = find_first_zero_bit(ctl->channel_map, ctl->params->nr_channels); in meson_gpio_irq_request_channel()
251 if (idx >= ctl->params->nr_channels) { in meson_gpio_irq_request_channel()
252 raw_spin_unlock_irqrestore(&ctl->lock, flags); in meson_gpio_irq_request_channel()
254 return -ENOSPC; in meson_gpio_irq_request_channel()
258 set_bit(idx, ctl->channel_map); in meson_gpio_irq_request_channel()
260 raw_spin_unlock_irqrestore(&ctl->lock, flags); in meson_gpio_irq_request_channel()
266 ctl->params->ops.gpio_irq_sel_pin(ctl, idx, hwirq); in meson_gpio_irq_request_channel()
274 *channel_hwirq = &(ctl->channel_irqs[idx]); in meson_gpio_irq_request_channel()
276 pr_debug("hwirq %lu assigned to channel %d - irq %u\n", in meson_gpio_irq_request_channel()
286 return channel_hwirq - ctl->channel_irqs; in meson_gpio_irq_get_channel_idx()
296 clear_bit(idx, ctl->channel_map); in meson_gpio_irq_release_channel()
306 params = ctl->params; in meson8_gpio_irq_set_type()
323 if (!params->support_edge_both) in meson8_gpio_irq_set_type()
324 return -EINVAL; in meson8_gpio_irq_set_type()
342 * gpio irq relative registers for s4
343 * -PADCTRL_GPIO_IRQ_CTRL0
345 * bit[12-23]: single edge trigger
346 * bit[0-11]: polarity trigger
348 * -PADCTRL_GPIO_IRQ_CTRL[X]
349 * bit[0-16]: 7 bits to choose gpio source for irq line 2*[X] - 2
350 * bit[16-22]:7 bits to choose gpio source for irq line 2*[X] - 1
351 * where X = 1-6
353 * -PADCTRL_GPIO_IRQ_CTRL[7]
354 * bit[0-11]: both edge trigger
369 val |= BIT(ctl->params->edge_both_offset + idx); in meson_s4_gpio_irq_set_type()
371 BIT(ctl->params->edge_both_offset + idx), val); in meson_s4_gpio_irq_set_type()
376 val |= BIT(ctl->params->pol_low_offset + idx); in meson_s4_gpio_irq_set_type()
379 val |= BIT(ctl->params->edge_single_offset + idx); in meson_s4_gpio_irq_set_type()
406 struct meson_gpio_irq_controller *ctl = data->domain->host_data; in meson_gpio_irq_set_type()
410 ret = ctl->params->ops.gpio_irq_set_type(ctl, type, channel_hwirq); in meson_gpio_irq_set_type()
419 .name = "meson-gpio-irqchip",
436 if (is_of_node(fwspec->fwnode) && fwspec->param_count == 2) { in meson_gpio_irq_domain_translate()
437 *hwirq = fwspec->param[0]; in meson_gpio_irq_domain_translate()
438 *type = fwspec->param[1]; in meson_gpio_irq_domain_translate()
442 return -EINVAL; in meson_gpio_irq_domain_translate()
452 fwspec.fwnode = domain->parent->fwnode; in meson_gpio_irq_allocate_gic_irq()
467 struct meson_gpio_irq_controller *ctl = domain->host_data; in meson_gpio_irq_domain_alloc()
474 return -EINVAL; in meson_gpio_irq_domain_alloc()
502 struct meson_gpio_irq_controller *ctl = domain->host_data; in meson_gpio_irq_domain_free()
530 return -ENODEV; in meson_gpio_irq_parse_dt()
532 ctl->params = match->data; in meson_gpio_irq_parse_dt()
535 "amlogic,channel-interrupts", in meson_gpio_irq_parse_dt()
536 ctl->channel_irqs, in meson_gpio_irq_parse_dt()
537 ctl->params->nr_channels, in meson_gpio_irq_parse_dt()
538 ctl->params->nr_channels); in meson_gpio_irq_parse_dt()
540 pr_err("can't get %d channel interrupts\n", ctl->params->nr_channels); in meson_gpio_irq_parse_dt()
544 ctl->params->ops.gpio_irq_init(ctl); in meson_gpio_irq_parse_dt()
557 return -ENODEV; in meson_gpio_irq_of_init()
563 return -ENXIO; in meson_gpio_irq_of_init()
568 return -ENOMEM; in meson_gpio_irq_of_init()
570 raw_spin_lock_init(&ctl->lock); in meson_gpio_irq_of_init()
572 ctl->base = of_iomap(node, 0); in meson_gpio_irq_of_init()
573 if (!ctl->base) { in meson_gpio_irq_of_init()
574 ret = -ENOMEM; in meson_gpio_irq_of_init()
583 ctl->params->nr_hwirq, in meson_gpio_irq_of_init()
589 ret = -ENODEV; in meson_gpio_irq_of_init()
593 pr_info("%d to %d gpio interrupt mux initialized\n", in meson_gpio_irq_of_init()
594 ctl->params->nr_hwirq, ctl->params->nr_channels); in meson_gpio_irq_of_init()
599 iounmap(ctl->base); in meson_gpio_irq_of_init()
607 IRQCHIP_MATCH("amlogic,meson-gpio-intc", meson_gpio_irq_of_init)
611 MODULE_DESCRIPTION("Meson GPIO Interrupt Multiplexer driver");
613 MODULE_ALIAS("platform:meson-gpio-intc");