zephyr/drivers/pinctrl/pinctrl_rpi_pico.c
Yiding Jia eb351436ad drivers: pinctrl: rp2040: oe-override option
This change adds the device tree property for specifying oe-override
(output-enable override behavior), as well as defines for possible values
of the property.

RP2040 GPIOs can be configured to automatically invert the output-enable
signal from the selected peripheral function. This is useful for tasks like
writing efficient PIO code, such as in the i2c example in the rp2040
datasheet.


Signed-off-by: Yiding Jia <yiding.jia@gmail.com>
2024-08-07 07:16:28 -04:00

36 lines
932 B
C

/*
* Copyright (c) 2021 Yonatan Schachter
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <zephyr/drivers/pinctrl.h>
/* pico-sdk includes */
#include <hardware/gpio.h>
static void pinctrl_configure_pin(const pinctrl_soc_pin_t *pin)
{
gpio_init(pin->pin_num);
gpio_set_function(pin->pin_num, pin->alt_func);
gpio_set_pulls(pin->pin_num, pin->pullup, pin->pulldown);
gpio_set_drive_strength(pin->pin_num, pin->drive_strength);
gpio_set_slew_rate(pin->pin_num, (pin->slew_rate ?
GPIO_SLEW_RATE_FAST : GPIO_SLEW_RATE_SLOW));
gpio_set_input_hysteresis_enabled(pin->pin_num, pin->schmitt_enable);
gpio_set_input_enabled(pin->pin_num, pin->input_enable);
gpio_set_oeover(pin->pin_num, pin->oe_override);
}
int pinctrl_configure_pins(const pinctrl_soc_pin_t *pins, uint8_t pin_cnt,
uintptr_t reg)
{
ARG_UNUSED(reg);
for (uint8_t i = 0U; i < pin_cnt; i++) {
pinctrl_configure_pin(pins++);
}
return 0;
}