Lines Matching +full:in +full:- +full:trig +full:- +full:gpios
4 * SPDX-License-Identifier: Apache-2.0
12 #include <zephyr/dt-bindings/interrupt-controller/infineon-xmc4xxx-intc.h>
17 /* In Infineon XMC4XXX SoCs, gpio interrupts are triggered via an Event Request Unit (ERU) */
18 /* module. A subset of the GPIOs are connected to the ERU. The ERU monitors edge triggers */
24 /* unset on a negative edge (or vice-versa depending on the configuration). The value of */
28 /* The ERU configurations for supported port/pin combinations are stored in a devicetree file */
29 /* dts/arm/infineon/xmc4xxx_x_x-intc.dtsi. The configurations are stored in the opaque array */
30 /* uint16 port_line_mapping[]. The bitfields for the opaque entries are defined in */
31 /* dt-bindings/interrupt-controller/infineon-xmc4xxx-intc.h. */
56 enum gpio_int_trig trig, in intc_xmc4xxx_gpio_enable_interrupt() argument
60 struct intc_xmc4xxx_data *data = dev->data; in intc_xmc4xxx_gpio_enable_interrupt()
61 const struct intc_xmc4xxx_config *config = dev->config; in intc_xmc4xxx_gpio_enable_interrupt()
62 int ret = -ENOTSUP; in intc_xmc4xxx_gpio_enable_interrupt()
80 cb = &data->cb[line]; in intc_xmc4xxx_gpio_enable_interrupt()
81 if (cb->fn) { in intc_xmc4xxx_gpio_enable_interrupt()
84 ret = -EBUSY; in intc_xmc4xxx_gpio_enable_interrupt()
91 if (trig == GPIO_INT_TRIG_HIGH) { in intc_xmc4xxx_gpio_enable_interrupt()
93 } else if (trig == GPIO_INT_TRIG_LOW) { in intc_xmc4xxx_gpio_enable_interrupt()
95 } else if (trig == GPIO_INT_TRIG_BOTH) { in intc_xmc4xxx_gpio_enable_interrupt()
98 return -EINVAL; in intc_xmc4xxx_gpio_enable_interrupt()
101 cb->port_id = port_id; in intc_xmc4xxx_gpio_enable_interrupt()
102 cb->pin = pin; in intc_xmc4xxx_gpio_enable_interrupt()
103 cb->mode = mode; in intc_xmc4xxx_gpio_enable_interrupt()
104 cb->fn = fn; in intc_xmc4xxx_gpio_enable_interrupt()
105 cb->data = user_data; in intc_xmc4xxx_gpio_enable_interrupt()
116 eru = config->eru_regs[line >> 2]; in intc_xmc4xxx_gpio_enable_interrupt()
131 if ((ret == 0 && trig == GPIO_INT_TRIG_LOW) || in intc_xmc4xxx_gpio_enable_interrupt()
132 (ret == 1 && trig == GPIO_INT_TRIG_HIGH)) { in intc_xmc4xxx_gpio_enable_interrupt()
133 eru->EXICON_b[eru_ch].FL = 1; in intc_xmc4xxx_gpio_enable_interrupt()
147 const struct intc_xmc4xxx_config *config = dev->config; in intc_xmc4xxx_gpio_disable_interrupt()
148 struct intc_xmc4xxx_data *data = dev->data; in intc_xmc4xxx_gpio_disable_interrupt()
151 for (int line = 0; line < ARRAY_SIZE(data->cb); line++) { in intc_xmc4xxx_gpio_disable_interrupt()
154 cb = &data->cb[line]; in intc_xmc4xxx_gpio_disable_interrupt()
156 if (cb->fn && cb->port_id == port_id && cb->pin == pin) { in intc_xmc4xxx_gpio_disable_interrupt()
157 XMC_ERU_t *eru = config->eru_regs[line >> 2]; in intc_xmc4xxx_gpio_disable_interrupt()
159 cb->fn = NULL; in intc_xmc4xxx_gpio_disable_interrupt()
161 eru->EXICON_b[eru_ch].PE = 0; in intc_xmc4xxx_gpio_disable_interrupt()
163 eru->EXICON_b[eru_ch].FL = 0; in intc_xmc4xxx_gpio_disable_interrupt()
164 /* no need to clear other variables in cb*/ in intc_xmc4xxx_gpio_disable_interrupt()
168 return -EINVAL; in intc_xmc4xxx_gpio_disable_interrupt()
175 struct intc_xmc4xxx_data *data = dev->data; in intc_xmc4xxx_isr()
176 const struct intc_xmc4xxx_config *config = dev->config; in intc_xmc4xxx_isr()
177 struct isr_cb *cb = &data->cb[line]; in intc_xmc4xxx_isr()
178 XMC_ERU_t *eru = config->eru_regs[line >> 2]; in intc_xmc4xxx_isr()
181 /* The callback function may actually disable the interrupt and set cb->fn = NULL */ in intc_xmc4xxx_isr()
182 /* as is done in tests/drivers/gpio/gpio_api_1pin. Assume that the callback function */ in intc_xmc4xxx_isr()
184 /* in the same callback which could potentially set cb->fn again. */ in intc_xmc4xxx_isr()
185 while (cb->fn) { in intc_xmc4xxx_isr()
186 cb->fn(cb->data, cb->pin); in intc_xmc4xxx_isr()
188 if (cb->mode == GPIO_INT_MODE_LEVEL && eru->EXICON_b[eru_ch].FL == 1) { in intc_xmc4xxx_isr()
204 /* connect irqs only if they defined by name in the dts */ in intc_xmc4xxx_init()