Lines Matching +full:gpio +full:- +full:n
4 * SPDX-License-Identifier: Apache-2.0
13 #include <zephyr/drivers/gpio.h>
17 #include <zephyr/drivers/gpio/gpio_cmsdk_ahb.h>
20 #include <zephyr/drivers/gpio/gpio_utils.h>
23 * @brief GPIO driver for ARM CMSDK AHB GPIO
33 /* GPIO Clock control in Active State */
35 /* GPIO Clock control in Sleep State */
37 /* GPIO Clock control in Deep Sleep State */
51 const struct gpio_cmsdk_ahb_cfg * const cfg = dev->config; in gpio_cmsdk_ahb_port_get_raw()
53 *value = cfg->port->data; in gpio_cmsdk_ahb_port_get_raw()
62 const struct gpio_cmsdk_ahb_cfg * const cfg = dev->config; in gpio_cmsdk_ahb_port_set_masked_raw()
64 cfg->port->dataout = (cfg->port->dataout & ~mask) | (mask & value); in gpio_cmsdk_ahb_port_set_masked_raw()
72 const struct gpio_cmsdk_ahb_cfg * const cfg = dev->config; in gpio_cmsdk_ahb_port_set_bits_raw()
74 cfg->port->dataout |= mask; in gpio_cmsdk_ahb_port_set_bits_raw()
82 const struct gpio_cmsdk_ahb_cfg * const cfg = dev->config; in gpio_cmsdk_ahb_port_clear_bits_raw()
84 cfg->port->dataout &= ~mask; in gpio_cmsdk_ahb_port_clear_bits_raw()
92 const struct gpio_cmsdk_ahb_cfg * const cfg = dev->config; in gpio_cmsdk_ahb_port_toggle_bits()
94 cfg->port->dataout ^= mask; in gpio_cmsdk_ahb_port_toggle_bits()
102 const struct gpio_cmsdk_ahb_cfg * const cfg = dev->config; in cmsdk_ahb_gpio_config()
105 return -ENOTSUP; in cmsdk_ahb_gpio_config()
109 return -ENOTSUP; in cmsdk_ahb_gpio_config()
113 return -ENOTSUP; in cmsdk_ahb_gpio_config()
119 * 0 - Input in cmsdk_ahb_gpio_config()
120 * 1 - Output in cmsdk_ahb_gpio_config()
128 cfg->port->outenableset = mask; in cmsdk_ahb_gpio_config()
130 cfg->port->outenableclr = mask; in cmsdk_ahb_gpio_config()
133 cfg->port->altfuncclr = mask; in cmsdk_ahb_gpio_config()
159 const struct gpio_cmsdk_ahb_cfg * const cfg = dev->config; in gpio_cmsdk_ahb_pin_interrupt_configure()
162 return -ENOTSUP; in gpio_cmsdk_ahb_pin_interrupt_configure()
169 return -ENOTSUP; in gpio_cmsdk_ahb_pin_interrupt_configure()
173 cfg->port->intenclr = BIT(pin); in gpio_cmsdk_ahb_pin_interrupt_configure()
176 cfg->port->inttypeset = BIT(pin); in gpio_cmsdk_ahb_pin_interrupt_configure()
179 cfg->port->inttypeclr = BIT(pin); in gpio_cmsdk_ahb_pin_interrupt_configure()
184 cfg->port->intpolset = BIT(pin); in gpio_cmsdk_ahb_pin_interrupt_configure()
186 cfg->port->intpolclr = BIT(pin); in gpio_cmsdk_ahb_pin_interrupt_configure()
188 cfg->port->intclear = BIT(pin); in gpio_cmsdk_ahb_pin_interrupt_configure()
189 cfg->port->intenset = BIT(pin); in gpio_cmsdk_ahb_pin_interrupt_configure()
197 const struct gpio_cmsdk_ahb_cfg * const cfg = dev->config; in gpio_cmsdk_ahb_isr()
198 struct gpio_cmsdk_ahb_dev_data *data = dev->data; in gpio_cmsdk_ahb_isr()
201 int_stat = cfg->port->intstatus; in gpio_cmsdk_ahb_isr()
204 cfg->port->intclear = int_stat; in gpio_cmsdk_ahb_isr()
206 gpio_fire_callbacks(&data->gpio_cb, dev, int_stat); in gpio_cmsdk_ahb_isr()
214 struct gpio_cmsdk_ahb_dev_data *data = dev->data; in gpio_cmsdk_ahb_manage_callback()
216 return gpio_manage_callback(&data->gpio_cb, callback, set); in gpio_cmsdk_ahb_manage_callback()
219 static DEVICE_API(gpio, gpio_cmsdk_ahb_drv_api_funcs) = {
231 * @brief Initialization function of GPIO
238 const struct gpio_cmsdk_ahb_cfg * const cfg = dev->config; in gpio_cmsdk_ahb_init()
245 return -ENODEV; in gpio_cmsdk_ahb_init()
249 clock_control_on(clk, (clock_control_subsys_t) &cfg->gpio_cc_as); in gpio_cmsdk_ahb_init()
250 clock_control_off(clk, (clock_control_subsys_t) &cfg->gpio_cc_ss); in gpio_cmsdk_ahb_init()
251 clock_control_off(clk, (clock_control_subsys_t) &cfg->gpio_cc_dss); in gpio_cmsdk_ahb_init()
255 cfg->gpio_config_func(dev); in gpio_cmsdk_ahb_init()
260 #define CMSDK_AHB_GPIO_DEVICE(n) \ argument
261 static void gpio_cmsdk_port_##n##_config_func(const struct device *dev); \
263 static const struct gpio_cmsdk_ahb_cfg gpio_cmsdk_port_##n##_config = { \
265 .port_pin_mask = GPIO_PORT_PIN_MASK_FROM_DT_INST(n), \
267 .port = ((volatile struct gpio_cmsdk_ahb *)DT_INST_REG_ADDR(n)),\
268 .gpio_config_func = gpio_cmsdk_port_##n##_config_func, \
270 .device = DT_INST_REG_ADDR(n),}, \
272 .device = DT_INST_REG_ADDR(n),}, \
274 .device = DT_INST_REG_ADDR(n),}, \
277 static struct gpio_cmsdk_ahb_dev_data gpio_cmsdk_port_##n##_data; \
279 DEVICE_DT_INST_DEFINE(n, \
282 &gpio_cmsdk_port_##n##_data, \
283 &gpio_cmsdk_port_## n ##_config, \
287 static void gpio_cmsdk_port_##n##_config_func(const struct device *dev) \
289 IRQ_CONNECT(DT_INST_IRQN(n), \
290 DT_INST_IRQ(n, priority), \
292 DEVICE_DT_INST_GET(n), 0); \
294 irq_enable(DT_INST_IRQN(n)); \