Lines Matching +full:gpio +full:- +full:n

4  * SPDX-License-Identifier: Apache-2.0
11 #include <zephyr/drivers/gpio.h>
14 #include <zephyr/drivers/gpio/gpio_utils.h>
38 const struct gpio_numaker_config *config = dev->config; in gpio_numaker_configure()
39 struct gpio_numaker_data *data = dev->data; in gpio_numaker_configure()
40 GPIO_T *gpio_base = (GPIO_T *)config->reg; in gpio_numaker_configure()
42 uint32_t pinMask = BIT(pin); /* mask for pin index --> (0x01 << pin) */ in gpio_numaker_configure()
52 return -EINVAL; in gpio_numaker_configure()
55 /* Configure GPIO direction */ in gpio_numaker_configure()
67 err = -ENOTSUP; in gpio_numaker_configure()
75 /* Set Multi-function, default is GPIO */ in gpio_numaker_configure()
76 port_index = (config->reg - config->gpa_base) / config->size; in gpio_numaker_configure()
77 GPx_MFPx = ((uint32_t *)&SYS->GPA_MFP0) + port_index * 4 + (pin / 4); in gpio_numaker_configure()
80 * E.g.: SYS->GPA_MFP0 = (SYS->GPA_MFP0 & (~SYS_GPA_MFP0_PA0MFP_Msk) ) | in gpio_numaker_configure()
85 /* Set pull control as pull-up, pull-down or pull-disable */ in gpio_numaker_configure()
96 gpio_base->DOUT |= pinMask; in gpio_numaker_configure()
98 gpio_base->DOUT &= ~pinMask; in gpio_numaker_configure()
107 const struct gpio_numaker_config *config = dev->config; in gpio_numaker_port_get_raw()
108 GPIO_T *gpio_base = (GPIO_T *)config->reg; in gpio_numaker_port_get_raw()
110 /* Get raw bits of GPIO PIN data */ in gpio_numaker_port_get_raw()
111 *value = gpio_base->PIN; in gpio_numaker_port_get_raw()
118 const struct gpio_numaker_config *config = dev->config; in gpio_numaker_port_set_masked_raw()
119 GPIO_T *gpio_base = (GPIO_T *)config->reg; in gpio_numaker_port_set_masked_raw()
121 gpio_base->DOUT = (gpio_base->DOUT & ~mask) | (mask & value); in gpio_numaker_port_set_masked_raw()
128 const struct gpio_numaker_config *config = dev->config; in gpio_numaker_port_set_bits_raw()
129 GPIO_T *gpio_base = (GPIO_T *)config->reg; in gpio_numaker_port_set_bits_raw()
131 /* Set raw bits of GPIO output data */ in gpio_numaker_port_set_bits_raw()
132 gpio_base->DOUT |= mask; in gpio_numaker_port_set_bits_raw()
139 const struct gpio_numaker_config *config = dev->config; in gpio_numaker_port_clear_bits_raw()
140 GPIO_T *gpio_base = (GPIO_T *)config->reg; in gpio_numaker_port_clear_bits_raw()
142 /* Clear raw bits of GPIO data */ in gpio_numaker_port_clear_bits_raw()
143 gpio_base->DOUT &= ~mask; in gpio_numaker_port_clear_bits_raw()
150 const struct gpio_numaker_config *config = dev->config; in gpio_numaker_port_toggle_bits()
151 GPIO_T *gpio_base = (GPIO_T *)config->reg; in gpio_numaker_port_toggle_bits()
153 /* Toggle raw bits of GPIO data */ in gpio_numaker_port_toggle_bits()
154 gpio_base->DOUT ^= mask; in gpio_numaker_port_toggle_bits()
162 const struct gpio_numaker_config *config = dev->config; in gpio_numaker_pin_interrupt_configure()
163 GPIO_T *gpio_base = (GPIO_T *)config->reg; in gpio_numaker_pin_interrupt_configure()
169 gpio_base->INTSRC &= BIT(pin); in gpio_numaker_pin_interrupt_configure()
180 return -ENOTSUP; in gpio_numaker_pin_interrupt_configure()
185 return -ENOTSUP; in gpio_numaker_pin_interrupt_configure()
196 struct gpio_numaker_data *data = dev->data; in gpio_numaker_manage_callback()
198 return gpio_manage_callback(&data->callbacks, callback, set); in gpio_numaker_manage_callback()
201 static DEVICE_API(gpio, gpio_numaker_api) = {
213 const struct gpio_numaker_config *config = dev->config; in gpio_numaker_isr()
214 struct gpio_numaker_data *data = dev->data; in gpio_numaker_isr()
215 GPIO_T *gpio_base = (GPIO_T *)config->reg; in gpio_numaker_isr()
219 int_status = gpio_base->INTSRC; in gpio_numaker_isr()
222 gpio_base->INTSRC = int_status; in gpio_numaker_isr()
224 gpio_fire_callbacks(&data->callbacks, dev, int_status); in gpio_numaker_isr()
227 #define CLOCK_CTRL_INIT(n) .clk_dev = DEVICE_DT_GET(DT_PARENT(DT_INST_CLOCKS_CTLR(n))), argument
229 #define GPIO_NUMAKER_IRQ_INIT(n) \ argument
231 IRQ_CONNECT(DT_INST_IRQN(n), DT_INST_IRQ(n, priority), gpio_numaker_isr, \
232 DEVICE_DT_INST_GET(n), 0); \
234 irq_enable(DT_INST_IRQN(n)); \
237 #define GPIO_NUMAKER_DEFINE(n) \ argument
238 static const struct gpio_numaker_config gpio_numaker_config##n = { \
240 .port_pin_mask = GPIO_PORT_PIN_MASK_FROM_DT_INST(n), \
242 .reg = DT_INST_REG_ADDR(n), \
245 .clk_modidx = DT_INST_CLOCKS_CELL(n, clock_module_index), \
246 CLOCK_CTRL_INIT(n)}; \
248 static struct gpio_numaker_data gpio_numaker_data##n; \
250 static int gpio_numaker_init##n(const struct device *dev) \
252 const struct gpio_numaker_config *config = dev->config; \
259 scc_subsys.pcc.clk_modidx = config->clk_modidx; \
260 err = clock_control_on(config->clk_dev, (clock_control_subsys_t)&scc_subsys); \
262 IF_ENABLED(DT_INST_IRQ_HAS_IDX(n, 0), (GPIO_NUMAKER_IRQ_INIT(n);)) \
268 DEVICE_DT_INST_DEFINE(n, gpio_numaker_init##n, NULL, &gpio_numaker_data##n, \
269 &gpio_numaker_config##n, PRE_KERNEL_1, CONFIG_GPIO_INIT_PRIORITY, \