Lines Matching +full:wui +full:- +full:maps
4 * SPDX-License-Identifier: Apache-2.0
12 #include <zephyr/dt-bindings/gpio/nuvoton-npcx-gpio.h>
36 /* Mapping table between gpio bits and wui */
50 ((struct gpio_reg *)((const struct gpio_npcx_config *)(dev)->config)->base)
64 const struct gpio_npcx_config *const config = dev->config; in npcx_gpio_enable_io_pads()
65 const struct npcx_wui *io_wui = &config->wui_maps[pin]; in npcx_gpio_enable_io_pads()
67 if (io_wui->table == NPCX_MIWU_TABLE_NONE) { in npcx_gpio_enable_io_pads()
68 LOG_ERR("Cannot enable GPIO(%x, %d) pad", config->port, pin); in npcx_gpio_enable_io_pads()
83 const struct gpio_npcx_config *const config = dev->config; in npcx_gpio_disable_io_pads()
84 const struct npcx_wui *io_wui = &config->wui_maps[pin]; in npcx_gpio_disable_io_pads()
86 if (io_wui->table == NPCX_MIWU_TABLE_NONE) { in npcx_gpio_disable_io_pads()
87 LOG_ERR("Cannot disable GPIO(%x, %d) pad", config->port, pin); in npcx_gpio_disable_io_pads()
104 const struct gpio_npcx_config *const config = dev->config; in gpio_npcx_config()
105 const struct npcx_lvol *lvol = &config->lvol_maps[pin]; in gpio_npcx_config()
111 return -ENOTSUP; in gpio_npcx_config()
117 return -ENOTSUP; in gpio_npcx_config()
126 inst->PDIR &= ~mask; in gpio_npcx_config()
129 /* Does this IO pad support low-voltage input (1.8V) detection? */ in gpio_npcx_config()
130 if (lvol->ctrl != NPCX_DT_LVOL_CTRL_NONE) { in gpio_npcx_config()
134 * If this IO pad is configured for low-voltage input detection, in gpio_npcx_config()
135 * the related drive type must select to open-drain also. in gpio_npcx_config()
139 npcx_lvol_set_detect_level(lvol->ctrl, lvol->bit, true); in gpio_npcx_config()
141 npcx_lvol_set_detect_level(lvol->ctrl, lvol->bit, false); in gpio_npcx_config()
145 /* Select open drain 0:push-pull 1:open-drain */ in gpio_npcx_config()
147 inst->PTYPE |= mask; in gpio_npcx_config()
149 inst->PTYPE &= ~mask; in gpio_npcx_config()
152 /* Select pull-up/down of GPIO 0:pull-up 1:pull-down */ in gpio_npcx_config()
154 inst->PPUD &= ~mask; in gpio_npcx_config()
155 inst->PPULL |= mask; in gpio_npcx_config()
157 inst->PPUD |= mask; in gpio_npcx_config()
158 inst->PPULL |= mask; in gpio_npcx_config()
161 inst->PPULL &= ~mask; in gpio_npcx_config()
166 inst->PDOUT |= mask; in gpio_npcx_config()
168 inst->PDOUT &= ~mask; in gpio_npcx_config()
173 inst->PDIR |= mask; in gpio_npcx_config()
183 const struct gpio_npcx_config *const config = port->config; in gpio_npcx_pin_get_config()
184 const struct npcx_lvol *lvol = &config->lvol_maps[pin]; in gpio_npcx_pin_get_config()
190 if (inst->PDIR & mask) { in gpio_npcx_pin_get_config()
193 /* 0:push-pull 1:open-drain */ in gpio_npcx_pin_get_config()
194 if (inst->PTYPE & mask) { in gpio_npcx_pin_get_config()
199 if (inst->PDOUT & mask) { in gpio_npcx_pin_get_config()
208 if (inst->PPULL & mask) { in gpio_npcx_pin_get_config()
209 /* 0:pull-up 1:pull-down */ in gpio_npcx_pin_get_config()
210 if (inst->PPUD & mask) { in gpio_npcx_pin_get_config()
218 /* Enable low-voltage detection? */ in gpio_npcx_pin_get_config()
219 if (lvol->ctrl != NPCX_DT_LVOL_CTRL_NONE && in gpio_npcx_pin_get_config()
220 npcx_lvol_get_detect_level(lvol->ctrl, lvol->bit)) { in gpio_npcx_pin_get_config()
236 *value = inst->PDIN; in gpio_npcx_port_get_raw()
246 uint8_t out = inst->PDOUT; in gpio_npcx_port_set_masked_raw()
248 inst->PDOUT = ((out & ~mask) | (value & mask)); in gpio_npcx_port_set_masked_raw()
259 inst->PDOUT |= mask; in gpio_npcx_port_set_bits_raw()
270 inst->PDOUT &= ~mask; in gpio_npcx_port_clear_bits_raw()
281 inst->PDOUT ^= mask; in gpio_npcx_port_toggle_bits()
291 const struct gpio_npcx_config *const config = dev->config; in gpio_npcx_pin_interrupt_configure()
293 if (config->wui_maps[pin].table == NPCX_MIWU_TABLE_NONE) { in gpio_npcx_pin_interrupt_configure()
294 LOG_ERR("Cannot configure GPIO(%x, %d)", config->port, pin); in gpio_npcx_pin_interrupt_configure()
295 return -EINVAL; in gpio_npcx_pin_interrupt_configure()
299 config->port, pin, config->wui_maps[pin].table, in gpio_npcx_pin_interrupt_configure()
300 config->wui_maps[pin].group, in gpio_npcx_pin_interrupt_configure()
301 config->wui_maps[pin].bit); in gpio_npcx_pin_interrupt_configure()
304 npcx_miwu_irq_disable(&config->wui_maps[pin]); in gpio_npcx_pin_interrupt_configure()
307 npcx_miwu_irq_enable(&config->wui_maps[pin]); in gpio_npcx_pin_interrupt_configure()
312 /* Disable irq of wake-up input io-pads before configuring them */ in gpio_npcx_pin_interrupt_configure()
313 npcx_miwu_irq_disable(&config->wui_maps[pin]); in gpio_npcx_pin_interrupt_configure()
337 return -EINVAL; in gpio_npcx_pin_interrupt_configure()
341 ret = npcx_miwu_interrupt_configure(&config->wui_maps[pin], in gpio_npcx_pin_interrupt_configure()
349 npcx_miwu_irq_enable(&config->wui_maps[pin]); in gpio_npcx_pin_interrupt_configure()
358 const struct gpio_npcx_config *const config = dev->config; in gpio_npcx_manage_callback()
360 int pin = find_lsb_set(callback->pin_mask) - 1; in gpio_npcx_manage_callback()
364 return -EINVAL; in gpio_npcx_manage_callback()
368 if (config->wui_maps[pin].table == NPCX_MIWU_TABLE_NONE) { in gpio_npcx_manage_callback()
369 LOG_ERR("Cannot manage GPIO(%x, %d) callback!", config->port, in gpio_npcx_manage_callback()
371 return -EINVAL; in gpio_npcx_manage_callback()
374 /* Initialize WUI information in unused bits field */ in gpio_npcx_manage_callback()
375 npcx_miwu_init_gpio_callback(miwu_cb, &config->wui_maps[pin], in gpio_npcx_manage_callback()
376 config->port); in gpio_npcx_manage_callback()
416 "size of prop. wui-maps must equal to pin number!"); \
418 "size of prop. lvol-maps must equal to pin number!"); \