Lines Matching +full:gpio +full:- +full:n
4 * SPDX-License-Identifier: Apache-2.0
12 #include <zephyr/drivers/gpio.h>
16 #include <zephyr/drivers/gpio/gpio_utils.h>
61 /* Helper Macros for GPIO */
63 ((const struct mss_gpio_config * const)(dev)->config)
65 ((volatile struct mss_gpio_t *)(DEV_GPIO_CFG(dev))->gpio_base_addr)
67 ((struct mss_gpio_data *)(dev)->data)
74 volatile struct mss_gpio_t *gpio = DEV_GPIO(dev); in mss_gpio_config() local
79 return -ENOTSUP; in mss_gpio_config()
84 gpio->gpio_cfg[pin] |= MSS_GPIO_OUTPUT_MODE; in mss_gpio_config()
87 gpio->gpio_out |= BIT(pin); in mss_gpio_config()
90 gpio->gpio_out &= ~BIT(pin); in mss_gpio_config()
95 gpio->gpio_cfg[pin] |= MSS_GPIO_INPUT_MODE; in mss_gpio_config()
98 return -ENOTSUP; in mss_gpio_config()
107 volatile struct mss_gpio_t *gpio = DEV_GPIO(dev); in mss_gpio_port_toggle_bits() local
109 gpio->gpio_out ^= mask; in mss_gpio_port_toggle_bits()
117 volatile struct mss_gpio_t *gpio = DEV_GPIO(dev); in mss_gpio_port_get_raw() local
119 *value = gpio->gpio_in; in mss_gpio_port_get_raw()
128 volatile struct mss_gpio_t *gpio = DEV_GPIO(dev); in mss_gpio_port_set_masked_raw() local
130 gpio->gpio_out = (gpio->gpio_out & ~mask) | (value & mask); in mss_gpio_port_set_masked_raw()
138 volatile struct mss_gpio_t *gpio = DEV_GPIO(dev); in mss_gpio_port_set_bits_raw() local
140 gpio->gpio_out |= mask; in mss_gpio_port_set_bits_raw()
148 volatile struct mss_gpio_t *gpio = DEV_GPIO(dev); in mss_gpio_port_clear_bits_raw() local
150 gpio->gpio_out &= ~mask; in mss_gpio_port_clear_bits_raw()
161 volatile struct mss_gpio_t *gpio = DEV_GPIO(dev); in mss_gpio_pin_interrupt_configure() local
163 gpio->gpio_cfg[pin] |= (MSS_GPIO_INT_ENABLE_MASK); in mss_gpio_pin_interrupt_configure()
167 gpio->gpio_cfg[pin] |= (MSS_GPIO_IRQ_EDGE_BOTH); in mss_gpio_pin_interrupt_configure()
170 gpio->gpio_cfg[pin] |= (MSS_GPIO_IRQ_EDGE_POSITIVE); in mss_gpio_pin_interrupt_configure()
173 gpio->gpio_cfg[pin] |= (MSS_GPIO_IRQ_EDGE_NEGATIVE); in mss_gpio_pin_interrupt_configure()
176 gpio->gpio_cfg[pin] |= (MSS_GPIO_IRQ_LEVEL_LOW); in mss_gpio_pin_interrupt_configure()
179 gpio->gpio_cfg[pin] |= (MSS_GPIO_IRQ_LEVEL_HIGH); in mss_gpio_pin_interrupt_configure()
182 gpio->gpio_cfg[pin] &= ~MSS_GPIO_INT_ENABLE_MASK; in mss_gpio_pin_interrupt_configure()
193 struct mss_gpio_data *data = dev->data; in mss_gpio_manage_callback()
195 return gpio_manage_callback(&data->cb, callback, set); in mss_gpio_manage_callback()
197 static DEVICE_API(gpio, mss_gpio_driver) = {
211 volatile struct mss_gpio_t *gpio = DEV_GPIO(dev); in mss_gpio_init() local
213 gpio->gpio_irq = 0xFFFFFFFFU; in mss_gpio_init()
216 /* Configure GPIO device */ in mss_gpio_init()
217 cfg->gpio_cfg_func(); in mss_gpio_init()
223 volatile struct mss_gpio_t *gpio = DEV_GPIO(dev); in mss_gpio_irq_handler() local
224 uint32_t interrupt_status = gpio->gpio_irq; in mss_gpio_irq_handler()
226 gpio->gpio_irq = gpio->gpio_irq; in mss_gpio_irq_handler()
227 struct mss_gpio_data *data = dev->data; in mss_gpio_irq_handler()
229 gpio_fire_callbacks(&data->cb, dev, interrupt_status); in mss_gpio_irq_handler()
232 #define MSS_GPIO_INIT(n) \ argument
233 static struct mss_gpio_data mss_gpio_data_##n; \
234 static void gpio_mss_gpio_cfg_func_##n(void); \
236 static const struct mss_gpio_config mss_gpio_config_##n = { \
238 .port_pin_mask = GPIO_PORT_PIN_MASK_FROM_DT_INST(n), \
240 .gpio_base_addr = DT_INST_REG_ADDR(n), \
241 .gpio_irq_base = DT_INST_IRQN(n), \
242 .gpio_cfg_func = gpio_mss_gpio_cfg_func_##n \
245 DEVICE_DT_INST_DEFINE(n, \
248 &mss_gpio_data_##n, &mss_gpio_config_##n, \
252 static void gpio_mss_gpio_cfg_func_##n(void) \
254 IRQ_CONNECT(DT_INST_IRQN(n), \
255 DT_INST_IRQ(n, priority), \
257 DEVICE_DT_INST_GET(n), \
259 irq_enable(DT_INST_IRQN(n)); \