@@ -128,12 +128,12 @@ static int gpio_rpi_configure(const struct device *dev,
128
128
struct gpio_rpi_data * data = dev -> data ;
129
129
130
130
if (flags == GPIO_DISCONNECTED ) {
131
- gpio_disable_pulls (pin );
131
+ gpio_disable_pulls (pin + offset );
132
132
/* This is almost the opposite of the Pico SDK's gpio_set_function. */
133
- hw_write_masked (& pads_bank0_hw -> io [pin ], PADS_BANK0_GPIO0_OD_BITS ,
133
+ hw_write_masked (& pads_bank0_hw -> io [pin + offset ], PADS_BANK0_GPIO0_OD_BITS ,
134
134
PADS_BANK0_GPIO0_IE_BITS | PADS_BANK0_GPIO0_OD_BITS );
135
135
#ifdef CONFIG_SOC_SERIES_RP2350
136
- hw_set_bits (& pads_bank0_hw -> io [pin ], PADS_BANK0_GPIO0_ISO_BITS );
136
+ hw_set_bits (& pads_bank0_hw -> io [pin + offset ], PADS_BANK0_GPIO0_ISO_BITS );
137
137
#endif
138
138
return 0 ;
139
139
}
@@ -205,7 +205,7 @@ static int gpio_rpi_get_config(const struct device *dev, gpio_pin_t pin, gpio_fl
205
205
}
206
206
}
207
207
208
- if (pads_bank0_hw -> io [pin ] & PADS_BANK0_GPIO0_IE_BITS ) {
208
+ if (pads_bank0_hw -> io [pin + offset ] & PADS_BANK0_GPIO0_IE_BITS ) {
209
209
* flags |= GPIO_INPUT ;
210
210
}
211
211
@@ -340,14 +340,16 @@ static uint32_t gpio_rpi_get_pending_int(const struct device *dev)
340
340
static int gpio_rpi_port_get_direction (const struct device * port , gpio_port_pins_t map ,
341
341
gpio_port_pins_t * inputs , gpio_port_pins_t * outputs )
342
342
{
343
+ const int offset = GPIO_RPI_PINS_PER_PORT * PORT_NO (port );
344
+
343
345
/* The Zephyr API considers a disconnected pin to be neither an input nor output.
344
346
* Since we disable both OE and IE for disconnected pins clear the mask bits.
345
347
*/
346
348
for (int pin = 0 ; pin < NUM_BANK0_GPIOS ; pin ++ ) {
347
- if (pads_bank0_hw -> io [pin ] & PADS_BANK0_GPIO0_OD_BITS ) {
349
+ if (pads_bank0_hw -> io [pin + offset ] & PADS_BANK0_GPIO0_OD_BITS ) {
348
350
map &= ~BIT (pin );
349
351
}
350
- if (inputs && (pads_bank0_hw -> io [pin ] & PADS_BANK0_GPIO0_IE_BITS )) {
352
+ if (inputs && (pads_bank0_hw -> io [pin + offset ] & PADS_BANK0_GPIO0_IE_BITS )) {
351
353
* inputs |= BIT (pin );
352
354
}
353
355
}
0 commit comments