drivers: gpio: rpi_pico: add missing offsets
Fixed several occurrences of offset not being calculated in case multiple GPIO ports are present. Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
This commit is contained in:
parent
b10d56e143
commit
d1fc8c7f29
1 changed files with 8 additions and 6 deletions
|
@ -128,12 +128,12 @@ static int gpio_rpi_configure(const struct device *dev,
|
|||
struct gpio_rpi_data *data = dev->data;
|
||||
|
||||
if (flags == GPIO_DISCONNECTED) {
|
||||
gpio_disable_pulls(pin);
|
||||
gpio_disable_pulls(pin + offset);
|
||||
/* This is almost the opposite of the Pico SDK's gpio_set_function. */
|
||||
hw_write_masked(&pads_bank0_hw->io[pin], PADS_BANK0_GPIO0_OD_BITS,
|
||||
hw_write_masked(&pads_bank0_hw->io[pin + offset], PADS_BANK0_GPIO0_OD_BITS,
|
||||
PADS_BANK0_GPIO0_IE_BITS | PADS_BANK0_GPIO0_OD_BITS);
|
||||
#ifdef CONFIG_SOC_SERIES_RP2350
|
||||
hw_set_bits(&pads_bank0_hw->io[pin], PADS_BANK0_GPIO0_ISO_BITS);
|
||||
hw_set_bits(&pads_bank0_hw->io[pin + offset], PADS_BANK0_GPIO0_ISO_BITS);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
@ -205,7 +205,7 @@ static int gpio_rpi_get_config(const struct device *dev, gpio_pin_t pin, gpio_fl
|
|||
}
|
||||
}
|
||||
|
||||
if (pads_bank0_hw->io[pin] & PADS_BANK0_GPIO0_IE_BITS) {
|
||||
if (pads_bank0_hw->io[pin + offset] & PADS_BANK0_GPIO0_IE_BITS) {
|
||||
*flags |= GPIO_INPUT;
|
||||
}
|
||||
|
||||
|
@ -340,14 +340,16 @@ static uint32_t gpio_rpi_get_pending_int(const struct device *dev)
|
|||
static int gpio_rpi_port_get_direction(const struct device *port, gpio_port_pins_t map,
|
||||
gpio_port_pins_t *inputs, gpio_port_pins_t *outputs)
|
||||
{
|
||||
const int offset = GPIO_RPI_PINS_PER_PORT * PORT_NO(port);
|
||||
|
||||
/* The Zephyr API considers a disconnected pin to be neither an input nor output.
|
||||
* Since we disable both OE and IE for disconnected pins clear the mask bits.
|
||||
*/
|
||||
for (int pin = 0; pin < NUM_BANK0_GPIOS; pin++) {
|
||||
if (pads_bank0_hw->io[pin] & PADS_BANK0_GPIO0_OD_BITS) {
|
||||
if (pads_bank0_hw->io[pin + offset] & PADS_BANK0_GPIO0_OD_BITS) {
|
||||
map &= ~BIT(pin);
|
||||
}
|
||||
if (inputs && (pads_bank0_hw->io[pin] & PADS_BANK0_GPIO0_IE_BITS)) {
|
||||
if (inputs && (pads_bank0_hw->io[pin + offset] & PADS_BANK0_GPIO0_IE_BITS)) {
|
||||
*inputs |= BIT(pin);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue