Lines Matching +full:enable +full:- +full:output +full:- +full:pin
4 * SPDX-License-Identifier: Apache-2.0
21 ((const struct gpio_b91_config *)dev->config)->gpio_base)
24 #define GET_IRQ_NUM(dev) (((const struct gpio_b91_config *)dev->config)->irq_num)
27 #define GET_IRQ_PRIORITY(dev) (((const struct gpio_b91_config *)dev->config)->irq_priority)
29 /* Get GPIO port number: port A - 0, port B - 1, ..., port F - 5 */
30 #define GET_PORT_NUM(gpio) ((uint8_t)(((uint32_t)gpio - DT_REG_ADDR(DT_NODELABEL(gpioa))) / \
42 /* Max pin number per port (pin 0..7) */
45 /* IRQ Enable registers */
49 /* Pull-up/down resistors */
69 uint8_t ie; /* IE: input enable, high active. 1: enable, 0: disable */
70 uint8_t oen; /* OEN: output enable, low active. 0: enable, 1: disable */
71 uint8_t output; /* Output: configure GPIO output */ member
74 uint8_t actas_gpio; /* Act as GPIO: enable (1) or disable (0) GPIO function */
75 uint8_t irq_en; /* Act as GPIO: enable (1) or disable (0) GPIO function */
94 /* Set IRQ Enable bit based on IRQ number */
95 static inline void gpiob_b91_irq_en_set(const struct device *dev, gpio_pin_t pin) in gpiob_b91_irq_en_set() argument
102 BM_SET(gpio->irq_en, BIT(pin)); in gpiob_b91_irq_en_set()
104 BM_SET(reg_irq_risc0_en(GET_PORT_NUM(gpio)), BIT(pin)); in gpiob_b91_irq_en_set()
106 BM_SET(reg_irq_risc1_en(GET_PORT_NUM(gpio)), BIT(pin)); in gpiob_b91_irq_en_set()
112 /* Clear IRQ Enable bit based on IRQ number */
113 static inline void gpiob_b91_irq_en_clr(const struct device *dev, gpio_pin_t pin) in gpiob_b91_irq_en_clr() argument
119 BM_CLR(gpio->irq_en, BIT(pin)); in gpiob_b91_irq_en_clr()
121 BM_CLR(reg_irq_risc0_en(GET_PORT_NUM(gpio)), BIT(pin)); in gpiob_b91_irq_en_clr()
123 BM_CLR(reg_irq_risc1_en(GET_PORT_NUM(gpio)), BIT(pin)); in gpiob_b91_irq_en_clr()
127 /* Get IRQ Enable register value */
135 status = gpio->irq_en; in gpio_b91_irq_en_get()
161 /* Set pin's irq type */
162 void gpio_b91_irq_set(const struct device *dev, gpio_pin_t pin, in gpio_b91_irq_set() argument
186 BM_CLR(gpio->polarity, BIT(pin)); in gpio_b91_irq_set()
191 BM_SET(gpio->polarity, BIT(pin)); in gpio_b91_irq_set()
196 BM_CLR(gpio->polarity, BIT(pin)); in gpio_b91_irq_set()
201 BM_SET(gpio->polarity, BIT(pin)); in gpio_b91_irq_set()
212 /* Enable peripheral interrupt */ in gpio_b91_irq_set()
213 gpiob_b91_irq_en_set(dev, pin); in gpio_b91_irq_set()
215 /* Enable PLIC interrupt */ in gpio_b91_irq_set()
220 /* Set pin's pull-up/down resistor */
222 gpio_pin_t pin, in gpio_b91_up_down_res_set() argument
229 pin = BIT(pin); in gpio_b91_up_down_res_set()
231 analog_reg = 0x0e + (GET_PORT_NUM(gpio) << 1) + ((pin & 0xf0) ? 1 : 0); in gpio_b91_up_down_res_set()
233 if (pin & 0x11) { in gpio_b91_up_down_res_set()
236 } else if (pin & 0x22) { in gpio_b91_up_down_res_set()
239 } else if (pin & 0x44) { in gpio_b91_up_down_res_set()
242 } else if (pin & 0x88) { in gpio_b91_up_down_res_set()
252 /* Config Pin pull-up / pull-down resistors */
254 gpio_pin_t pin, in gpio_b91_config_up_down_res() argument
258 gpio_b91_up_down_res_set(gpio, pin, GPIO_PIN_PULLUP_10K); in gpio_b91_config_up_down_res()
260 gpio_b91_up_down_res_set(gpio, pin, GPIO_PIN_PULLDOWN_100K); in gpio_b91_config_up_down_res()
262 gpio_b91_up_down_res_set(gpio, pin, GPIO_PIN_UP_DOWN_FLOAT); in gpio_b91_config_up_down_res()
266 /* Config Pin In/Out direction */
268 gpio_pin_t pin, in gpio_b91_config_in_out() argument
273 /* Port C and D Input Enable registers are located in another place: analog */ in gpio_b91_config_in_out()
280 /* Enable/disable output */ in gpio_b91_config_in_out()
281 WRITE_BIT(gpio->oen, pin, ~flags & GPIO_OUTPUT); in gpio_b91_config_in_out()
283 /* Enable/disable input */ in gpio_b91_config_in_out()
287 analog_write_reg8(ie_addr, analog_read_reg8(ie_addr) | BIT(pin)); in gpio_b91_config_in_out()
289 analog_write_reg8(ie_addr, analog_read_reg8(ie_addr) & (~BIT(pin))); in gpio_b91_config_in_out()
292 /* Input Enable registers of all other ports are located in common GPIO space */ in gpio_b91_config_in_out()
293 WRITE_BIT(gpio->ie, pin, flags & GPIO_INPUT); in gpio_b91_config_in_out()
300 const struct gpio_b91_config *cfg = dev->config; in gpio_b91_init()
302 cfg->pirq_connect(); in gpio_b91_init()
309 gpio_pin_t pin, in gpio_b91_pin_configure() argument
314 /* Check input parameters: pin number */ in gpio_b91_pin_configure()
315 if (pin > PIN_NUM_MAX) { in gpio_b91_pin_configure()
316 return -ENOTSUP; in gpio_b91_pin_configure()
319 /* Check input parameters: open-source and open-drain */ in gpio_b91_pin_configure()
321 return -ENOTSUP; in gpio_b91_pin_configure()
326 return -ENOTSUP; in gpio_b91_pin_configure()
331 gpio->output |= BIT(pin); in gpio_b91_pin_configure()
333 gpio->output &= ~BIT(pin); in gpio_b91_pin_configure()
336 /* GPIO function enable */ in gpio_b91_pin_configure()
337 WRITE_BIT(gpio->actas_gpio, BIT(pin), 1); in gpio_b91_pin_configure()
339 /* Set GPIO pull-up / pull-down resistors */ in gpio_b91_pin_configure()
340 gpio_b91_config_up_down_res(gpio, pin, flags); in gpio_b91_pin_configure()
342 /* Enable/disable input/output */ in gpio_b91_pin_configure()
343 gpio_b91_config_in_out(gpio, pin, flags); in gpio_b91_pin_configure()
354 *value = gpio->input; in gpio_b91_port_get_raw()
366 gpio->output = (gpio->output & ~mask) | (value & mask); in gpio_b91_port_set_masked_raw()
377 gpio->output |= mask; in gpio_b91_port_set_bits_raw()
388 gpio->output &= ~mask; in gpio_b91_port_clear_bits_raw()
399 gpio->output ^= mask; in gpio_b91_port_toggle_bits()
409 struct gpio_b91_data *data = dev->data; in gpio_b91_irq_handler()
414 gpio_fire_callbacks(&data->callbacks, dev, status); in gpio_b91_irq_handler()
420 gpio_pin_t pin, in gpio_b91_pin_interrupt_configure() argument
428 gpiob_b91_irq_en_clr(dev, pin); in gpio_b91_pin_interrupt_configure()
433 gpio_b91_irq_set(dev, pin, INTR_HIGH_LEVEL); in gpio_b91_pin_interrupt_configure()
435 gpio_b91_irq_set(dev, pin, INTR_LOW_LEVEL); in gpio_b91_pin_interrupt_configure()
437 ret_status = -ENOTSUP; in gpio_b91_pin_interrupt_configure()
443 gpio_b91_irq_set(dev, pin, INTR_RISING_EDGE); in gpio_b91_pin_interrupt_configure()
445 gpio_b91_irq_set(dev, pin, INTR_FALLING_EDGE); in gpio_b91_pin_interrupt_configure()
447 ret_status = -ENOTSUP; in gpio_b91_pin_interrupt_configure()
452 ret_status = -ENOTSUP; in gpio_b91_pin_interrupt_configure()
464 struct gpio_b91_data *data = dev->data; in gpio_b91_manage_callback()
466 return gpio_manage_callback(&data->callbacks, callback, set); in gpio_b91_manage_callback()