Lines Matching +full:port +full:- +full:line +full:- +full:mapping
5 * SPDX-License-Identifier: Apache-2.0
35 * @brief Structure mapping the GPIO registers.
57 * @brief Structure mapping the PINT registers.
78 * This structure is included by all the per-port private configuration.
105 static int gpio_lpc11u6x_pin_configure(const struct device *port, in gpio_lpc11u6x_pin_configure() argument
108 const struct gpio_lpc11u6x_config *config = port->config; in gpio_lpc11u6x_pin_configure()
110 (config->shared->gpio_base + LPC11U6X_GPIO_REGS); in gpio_lpc11u6x_pin_configure()
111 uint8_t port_num = config->port_num; in gpio_lpc11u6x_pin_configure()
115 if (pin >= config->ngpios) { in gpio_lpc11u6x_pin_configure()
116 return -EINVAL; in gpio_lpc11u6x_pin_configure()
120 * PIO0_4 and PIO0_5 are "true" open drain pins muxed with the I2C port in gpio_lpc11u6x_pin_configure()
122 * and with no pull-down or pull-up resistor enabled. in gpio_lpc11u6x_pin_configure()
127 return -EINVAL; in gpio_lpc11u6x_pin_configure()
131 * For PIO0_0 and PIO0_[10-15] function 1 enables GPIO mode. For all in gpio_lpc11u6x_pin_configure()
145 return -ENOTSUP; in gpio_lpc11u6x_pin_configure()
164 config->iocon_base[offset] = func; in gpio_lpc11u6x_pin_configure()
168 gpio_regs->set[port_num] |= BIT(pin); in gpio_lpc11u6x_pin_configure()
172 gpio_regs->clr[port_num] |= BIT(pin); in gpio_lpc11u6x_pin_configure()
176 * TODO: maybe configure the STARTERP0 register to allow wake-up from in gpio_lpc11u6x_pin_configure()
177 * deep-sleep or power-down modes. in gpio_lpc11u6x_pin_configure()
181 WRITE_BIT(gpio_regs->dir[port_num], pin, flags & GPIO_OUTPUT); in gpio_lpc11u6x_pin_configure()
186 static int gpio_lpc11u6x_port_get_raw(const struct device *port, in gpio_lpc11u6x_port_get_raw() argument
189 const struct gpio_lpc11u6x_config *config = port->config; in gpio_lpc11u6x_port_get_raw()
191 (config->shared->gpio_base + LPC11U6X_GPIO_REGS); in gpio_lpc11u6x_port_get_raw()
193 *value = gpio_regs->pin[config->port_num]; in gpio_lpc11u6x_port_get_raw()
198 static int gpio_lpc11u6x_port_set_masked_raw(const struct device *port, in gpio_lpc11u6x_port_set_masked_raw() argument
202 const struct gpio_lpc11u6x_config *config = port->config; in gpio_lpc11u6x_port_set_masked_raw()
204 (config->shared->gpio_base + LPC11U6X_GPIO_REGS); in gpio_lpc11u6x_port_set_masked_raw()
205 uint8_t port_num = config->port_num; in gpio_lpc11u6x_port_set_masked_raw()
208 orig_mask = gpio_regs->mask[port_num]; in gpio_lpc11u6x_port_set_masked_raw()
210 gpio_regs->mask[port_num] = ~mask; in gpio_lpc11u6x_port_set_masked_raw()
213 gpio_regs->mpin[port_num] = value; in gpio_lpc11u6x_port_set_masked_raw()
216 gpio_regs->mask[port_num] = orig_mask; in gpio_lpc11u6x_port_set_masked_raw()
222 static int gpio_lpc11u6x_port_set_bits_raw(const struct device *port, in gpio_lpc11u6x_port_set_bits_raw() argument
225 const struct gpio_lpc11u6x_config *config = port->config; in gpio_lpc11u6x_port_set_bits_raw()
227 (config->shared->gpio_base + LPC11U6X_GPIO_REGS); in gpio_lpc11u6x_port_set_bits_raw()
229 gpio_regs->set[config->port_num] = pins; in gpio_lpc11u6x_port_set_bits_raw()
234 static int gpio_lpc11u6x_port_clear_bits_raw(const struct device *port, in gpio_lpc11u6x_port_clear_bits_raw() argument
237 const struct gpio_lpc11u6x_config *config = port->config; in gpio_lpc11u6x_port_clear_bits_raw()
239 (config->shared->gpio_base + LPC11U6X_GPIO_REGS); in gpio_lpc11u6x_port_clear_bits_raw()
241 gpio_regs->clr[config->port_num] = pins; in gpio_lpc11u6x_port_clear_bits_raw()
246 static int gpio_lpc11u6x_port_toggle_bits(const struct device *port, in gpio_lpc11u6x_port_toggle_bits() argument
249 const struct gpio_lpc11u6x_config *config = port->config; in gpio_lpc11u6x_port_toggle_bits()
251 (config->shared->gpio_base + LPC11U6X_GPIO_REGS); in gpio_lpc11u6x_port_toggle_bits()
253 gpio_regs->not[config->port_num] = pins; in gpio_lpc11u6x_port_toggle_bits()
259 * @brief Attach a free interrupt line to a GPIO.
262 * @param intpin GPIO port and pin numbers encoded into a value compatible
266 * @retval -EBUSY All the interrupt lines are already attached.
272 int ret = -EBUSY; in pintsel_attach()
274 (uint32_t *) (shared->syscon_base + LPC11U6X_PINTSEL_REGS); in pintsel_attach()
276 for (irq = 0; irq < shared->nirqs; irq++) { in pintsel_attach()
295 * @brief Detach an interrupt line from a GPIO.
298 * @param intpin GPIO port and pin numbers encoded into a value compatible
302 * @retval -EINVAL No attached interrupt found for the requested GPIO.
309 (uint32_t *) (shared->syscon_base + LPC11U6X_PINTSEL_REGS); in pintsel_detach()
311 for (irq = 0; irq < shared->nirqs; irq++) { in pintsel_detach()
317 return -EINVAL; in pintsel_detach()
320 static int gpio_lpc11u6x_pin_interrupt_configure(const struct device *port, in gpio_lpc11u6x_pin_interrupt_configure() argument
325 const struct gpio_lpc11u6x_config *config = port->config; in gpio_lpc11u6x_pin_interrupt_configure()
327 (config->shared->gpio_base + LPC11U6X_PINT_REGS); in gpio_lpc11u6x_pin_interrupt_configure()
331 if (pin >= config->ngpios) { in gpio_lpc11u6x_pin_interrupt_configure()
332 return -EINVAL; in gpio_lpc11u6x_pin_interrupt_configure()
338 * line. in gpio_lpc11u6x_pin_interrupt_configure()
340 if (config->port_num == 2 && pin > 7) { in gpio_lpc11u6x_pin_interrupt_configure()
341 return -ENOTSUP; in gpio_lpc11u6x_pin_interrupt_configure()
345 * Convert the requested GPIO port and pin numbers into a value in gpio_lpc11u6x_pin_interrupt_configure()
350 if (config->port_num == 1) { in gpio_lpc11u6x_pin_interrupt_configure()
352 } else if (config->port_num == 2) { in gpio_lpc11u6x_pin_interrupt_configure()
357 irq = pintsel_detach(config->shared, intpin); in gpio_lpc11u6x_pin_interrupt_configure()
359 irq = pintsel_attach(config->shared, intpin); in gpio_lpc11u6x_pin_interrupt_configure()
367 pint_regs->isel &= ~BIT(irq); in gpio_lpc11u6x_pin_interrupt_configure()
368 pint_regs->cienr |= BIT(irq); in gpio_lpc11u6x_pin_interrupt_configure()
369 pint_regs->cienf |= BIT(irq); in gpio_lpc11u6x_pin_interrupt_configure()
373 pint_regs->isel &= ~BIT(irq); in gpio_lpc11u6x_pin_interrupt_configure()
376 pint_regs->sienf |= BIT(irq); in gpio_lpc11u6x_pin_interrupt_configure()
378 pint_regs->cienf |= BIT(irq); in gpio_lpc11u6x_pin_interrupt_configure()
381 pint_regs->sienr |= BIT(irq); in gpio_lpc11u6x_pin_interrupt_configure()
383 pint_regs->cienr |= BIT(irq); in gpio_lpc11u6x_pin_interrupt_configure()
388 pint_regs->isel |= BIT(irq); in gpio_lpc11u6x_pin_interrupt_configure()
391 pint_regs->cienf |= BIT(irq); in gpio_lpc11u6x_pin_interrupt_configure()
393 pint_regs->sienf |= BIT(irq); in gpio_lpc11u6x_pin_interrupt_configure()
396 pint_regs->sienr |= BIT(irq); in gpio_lpc11u6x_pin_interrupt_configure()
399 return -ENOTSUP; in gpio_lpc11u6x_pin_interrupt_configure()
403 pint_regs->ist |= BIT(irq); in gpio_lpc11u6x_pin_interrupt_configure()
408 static int gpio_lpc11u6x_manage_callback(const struct device *port, in gpio_lpc11u6x_manage_callback() argument
411 struct gpio_lpc11u6x_data *data = port->data; in gpio_lpc11u6x_manage_callback()
413 return gpio_manage_callback(&data->cb_list, cb, set); in gpio_lpc11u6x_manage_callback()
420 return -ENOTSUP; in gpio_lpc11u6x_get_pending_int()
428 (shared->gpio_base + LPC11U6X_PINT_REGS); in gpio_lpc11u6x_isr()
430 (uint32_t *) (shared->syscon_base + LPC11U6X_PINTSEL_REGS); in gpio_lpc11u6x_isr()
433 const struct device *port; in gpio_lpc11u6x_isr() local
436 for (irq = 0; irq < shared->nirqs; irq++) { in gpio_lpc11u6x_isr()
439 if ((pint_regs->ist & BIT(irq)) == 0) { in gpio_lpc11u6x_isr()
444 pint_regs->ist |= BIT(irq); in gpio_lpc11u6x_isr()
449 * port and pin numbers from this "intpin" value and store them in gpio_lpc11u6x_isr()
456 pins[1] |= BIT(intpin - 24); in gpio_lpc11u6x_isr()
458 pins[2] |= BIT(intpin - 56); in gpio_lpc11u6x_isr()
461 /* For each port with active pins, fire the GPIO interrupt callbacks. */ in gpio_lpc11u6x_isr()
464 port = DEVICE_DT_GET(DT_NODELABEL(gpio0)); in gpio_lpc11u6x_isr()
465 data = port->data; in gpio_lpc11u6x_isr()
466 gpio_fire_callbacks(&data->cb_list, port, pins[0]); in gpio_lpc11u6x_isr()
471 port = DEVICE_DT_GET(DT_NODELABEL(gpio1)); in gpio_lpc11u6x_isr()
472 data = port->data; in gpio_lpc11u6x_isr()
473 gpio_fire_callbacks(&data->cb_list, port, pins[1]); in gpio_lpc11u6x_isr()
478 port = DEVICE_DT_GET(DT_NODELABEL(gpio2)); in gpio_lpc11u6x_isr()
479 data = port->data; in gpio_lpc11u6x_isr()
480 gpio_fire_callbacks(&data->cb_list, port, pins[2]); in gpio_lpc11u6x_isr()
520 const struct gpio_lpc11u6x_config *config = dev->config; in gpio_lpc11u6x_init()
529 if (!device_is_ready(config->shared->clock_dev)) { in gpio_lpc11u6x_init()
530 return -ENODEV; in gpio_lpc11u6x_init()
534 ret = clock_control_on(config->shared->clock_dev, config->shared->clock_subsys); in gpio_lpc11u6x_init()