Add low_power_set_pins_low_leakage function #3049

Merged
will-v-pi merged 11 commits from low-power-pins into develop 2026-07-01 13:03:49 -05:00
will-v-pi commented 2026-06-30 09:33:12 -05:00 (Migrated from github.com)

This sets the pins to what I think is the lowest leakage state (pads_bank0 have pulls & input disabled, io_bank0 has output override set to disabled)

This sets the pins to what I think is the lowest leakage state (pads_bank0 have pulls & input disabled, io_bank0 has output override set to disabled)
Wren6991 (Migrated from github.com) reviewed 2026-06-30 09:33:12 -05:00
lurch commented 2026-06-30 09:44:38 -05:00 (Migrated from github.com)

Naive question, but do the GPIO isolation latches on RP2350 help at all?

Naive question, but do the GPIO isolation latches on RP2350 help at all?
peterharperuk (Migrated from github.com) reviewed 2026-06-30 09:44:42 -05:00
@ -224,6 +224,27 @@ int low_power_set_external_clock_source(uint src_hz, uint gpio_pin) {
}
peterharperuk (Migrated from github.com) commented 2026-06-30 09:44:42 -05:00

I wonder whether that neede to be (1ull << i)

I wonder whether that neede to be (1ull << i)
will-v-pi (Migrated from github.com) reviewed 2026-06-30 09:45:53 -05:00
@ -224,6 +224,27 @@ int low_power_set_external_clock_source(uint src_hz, uint gpio_pin) {
}
will-v-pi (Migrated from github.com) commented 2026-06-30 09:45:52 -05:00

Yes, it probably does

        if (exclude_mask & (1ull << i)) continue;
Yes, it probably does ```suggestion if (exclude_mask & (1ull << i)) continue; ```
will-v-pi commented 2026-06-30 09:57:33 -05:00 (Migrated from github.com)

Naive question, but do the GPIO isolation latches on RP2350 help at all?

As far as I understand it, the isolation latches just isolate the pads logic from the switched core until they are configured - isolation is enabled anyway when the switched core is powered off (9.7. Pad isolation latches in the datasheet)

> Naive question, but do the GPIO isolation latches on RP2350 help at all? As far as I understand it, the isolation latches just isolate the pads logic from the switched core until they are configured - isolation is enabled anyway when the switched core is powered off (9.7. Pad isolation latches in the datasheet)
lurch (Migrated from github.com) reviewed 2026-06-30 10:09:17 -05:00
@ -226,1 +226,4 @@
void low_power_set_pins_low_leakage_exclude_mask(uint32_t exclude_mask) {
for (uint i=0; i < NUM_BANK0_GPIOS; i++) {
if (exclude_mask & (1u << i)) continue;
lurch (Migrated from github.com) commented 2026-06-30 10:09:17 -05:00

I guess you could also add

if (! (include_mask >> i) ) break;

but it's probably not worth it?

I guess you _could_ also add ```c if (! (include_mask >> i) ) break; ``` but it's probably not worth it?
will-v-pi (Migrated from github.com) reviewed 2026-06-30 11:06:21 -05:00
@ -226,1 +226,4 @@
void low_power_set_pins_low_leakage_exclude_mask(uint32_t exclude_mask) {
for (uint i=0; i < NUM_BANK0_GPIOS; i++) {
if (exclude_mask & (1u << i)) continue;
will-v-pi (Migrated from github.com) commented 2026-06-30 11:06:21 -05:00

I've removed include_mask now anyway, so not worth adding it back in - generally I'd expect this function to be operating on lots of pins anyway, as opposed to the masked functions in hardware_gpio which I'd expect to be operating on a smaller set of pins

I've removed `include_mask` now anyway, so not worth adding it back in - generally I'd expect this function to be operating on lots of pins anyway, as opposed to the masked functions in `hardware_gpio` which I'd expect to be operating on a smaller set of pins
lurch (Migrated from github.com) reviewed 2026-06-30 11:56:18 -05:00
@ -130,6 +130,32 @@ typedef enum {
typedef void (*low_power_pstate_resume_func)(pstate_bitset_t *pstate);
lurch (Migrated from github.com) commented 2026-06-30 11:56:17 -05:00

I guess the GPIO_FUNC_SIO comment here needs to be updated to reflect one of the later commits?

I guess the `GPIO_FUNC_SIO` comment here needs to be updated to reflect one of the later commits?
will-v-pi (Migrated from github.com) reviewed 2026-06-30 11:58:48 -05:00
@ -130,6 +130,32 @@ typedef enum {
typedef void (*low_power_pstate_resume_func)(pstate_bitset_t *pstate);
will-v-pi (Migrated from github.com) commented 2026-06-30 11:58:47 -05:00
 * Disables pulls & inputs on the pads, and disables the IO output
```suggestion * Disables pulls & inputs on the pads, and disables the IO output ```
lurch (Migrated from github.com) reviewed 2026-06-30 11:59:38 -05:00
@ -130,6 +130,32 @@ typedef enum {
typedef void (*low_power_pstate_resume_func)(pstate_bitset_t *pstate);
lurch (Migrated from github.com) commented 2026-06-30 11:59:38 -05:00
/*! \brief  Set all pins to a low leakage state (64-bit mask version)

(just to clarify which part of it is "64-bit"?)

```suggestion /*! \brief Set all pins to a low leakage state (64-bit mask version) ``` (just to clarify which part of it is "64-bit"?)
lurch (Migrated from github.com) reviewed 2026-07-01 10:09:00 -05:00
@ -130,6 +130,32 @@ typedef enum {
typedef void (*low_power_pstate_resume_func)(pstate_bitset_t *pstate);
lurch (Migrated from github.com) commented 2026-07-01 10:09:00 -05:00
 * Does not change the state of pins in the exclude_mask.
```suggestion * Does not change the state of pins in the exclude_mask. ```
lurch (Migrated from github.com) reviewed 2026-07-01 10:12:58 -05:00
@ -127,6 +127,7 @@ int main() {
init_powman_ext_ctrl();
lurch (Migrated from github.com) commented 2026-07-01 10:12:58 -05:00

When reading isolated code like this (i.e. without referring to the doxygen), one might naively assume that it's the pins in USED_PIN_MASK that are being set to low-leakage? 🤔

low_power_set_all_pins_low_leakage_except(USED_PIN_MASK);

is maybe a bit too wordy though 😉

When reading isolated code like this (i.e. without referring to the doxygen), one might naively assume that it's the pins in `USED_PIN_MASK` that are being set to low-leakage? :thinking: ```c low_power_set_all_pins_low_leakage_except(USED_PIN_MASK); ``` is maybe a bit too wordy though :wink:
will-v-pi (Migrated from github.com) reviewed 2026-07-01 10:44:58 -05:00
@ -127,6 +127,7 @@ int main() {
init_powman_ext_ctrl();
will-v-pi (Migrated from github.com) commented 2026-07-01 10:44:58 -05:00

The function naming is up for debate, but I think that might be a bit too long - maybe low_power_set_all_pins_low_leakage instead?

The function naming is up for debate, but I think that might be a bit too long - maybe `low_power_set_all_pins_low_leakage` instead?
lurch (Migrated from github.com) reviewed 2026-07-01 10:49:10 -05:00
@ -127,6 +127,7 @@ int main() {
init_powman_ext_ctrl();
lurch (Migrated from github.com) commented 2026-07-01 10:49:10 -05:00

Yeah, that's probably better than low_power_set_most_pins_low_leakage 🤣

Yeah, that's probably better than `low_power_set_most_pins_low_leakage` :rofl:
kilograham (Migrated from github.com) reviewed 2026-07-01 11:07:20 -05:00
kilograham (Migrated from github.com) reviewed 2026-07-01 11:16:22 -05:00
@ -224,6 +224,27 @@ int low_power_set_external_clock_source(uint src_hz, uint gpio_pin) {
}
kilograham (Migrated from github.com) commented 2026-07-01 11:16:22 -05:00

i think perhaps low_power_set_pins_low_leakage_exclude_mask whilst a mouthful is probably the most consistent with other naming

i think perhaps `low_power_set_pins_low_leakage_exclude_mask` whilst a mouthful is probably the most consistent with other naming
will-v-pi (Migrated from github.com) reviewed 2026-07-01 11:19:41 -05:00
@ -224,6 +224,27 @@ int low_power_set_external_clock_source(uint src_hz, uint gpio_pin) {
}
will-v-pi (Migrated from github.com) commented 2026-07-01 11:19:41 -05:00

I will change it

I will change it
lurch (Migrated from github.com) reviewed 2026-07-01 11:45:36 -05:00
@ -224,6 +224,27 @@ int low_power_set_external_clock_source(uint src_hz, uint gpio_pin) {
}
lurch (Migrated from github.com) commented 2026-07-01 11:45:36 -05:00

OTOH, it might sound like "low leakage exclude mask" is a thing, and that's what this function is setting? 😉 But I'll stop bike-shedding and just leave it as-is.

OTOH, it might sound like "low leakage exclude mask" is a thing, and that's what this function is setting? :wink: But I'll stop bike-shedding and just leave it as-is.
kilograham (Migrated from github.com) approved these changes 2026-07-01 13:03:32 -05:00
Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
gh-raspberrypi/pico-sdk!3049
No description provided.