From 996b6444023c7fa30288dcf7a64813b7d875ea3e Mon Sep 17 00:00:00 2001 From: Romain Pelletant Date: Thu, 26 Dec 2024 12:28:09 +0100 Subject: [PATCH 1/2] pinctrl: gecko: add low power support - Add low power pin configuration support in gecko Signed-off-by: Romain Pelletant --- dts/bindings/pinctrl/silabs,gecko-pinctrl.yaml | 6 ++++++ .../zephyr/dt-bindings/pinctrl/gecko-pinctrl-s1.h | 13 ++++++++++++- include/zephyr/dt-bindings/pinctrl/gecko-pinctrl.h | 13 ++++++++++++- soc/silabs/common/pinctrl_soc.h | 11 ++++++++++- 4 files changed, 40 insertions(+), 3 deletions(-) diff --git a/dts/bindings/pinctrl/silabs,gecko-pinctrl.yaml b/dts/bindings/pinctrl/silabs,gecko-pinctrl.yaml index e986c39c14dda2..3778d76af058c9 100644 --- a/dts/bindings/pinctrl/silabs,gecko-pinctrl.yaml +++ b/dts/bindings/pinctrl/silabs,gecko-pinctrl.yaml @@ -69,6 +69,12 @@ child-binding: child-binding: description: | Silabs pin controller pin configuration group. + + include: + - name: pincfg-node.yaml + property-allowlist: + - low-power-enable + properties: psels: required: true diff --git a/include/zephyr/dt-bindings/pinctrl/gecko-pinctrl-s1.h b/include/zephyr/dt-bindings/pinctrl/gecko-pinctrl-s1.h index 885c8d5747c6ed..a1d8c5a6b565e1 100644 --- a/include/zephyr/dt-bindings/pinctrl/gecko-pinctrl-s1.h +++ b/include/zephyr/dt-bindings/pinctrl/gecko-pinctrl-s1.h @@ -11,7 +11,8 @@ * organized as follows: * * - 31..24: Pin function. - * - 23..16: Reserved. + * - 23..15: Reserved. + * - 16: Low power. * - 15..8: Port for UART_RX/UART_TX functions. * - 7..0: Pin number for UART_RX/UART_TX functions. * - 15..8: Reserved for UART_LOC function. @@ -43,6 +44,16 @@ /** Mask for the pin field. */ #define GECKO_LOC_MSK 0xFFU +/** Position of low power field. */ +#define GECKO_LP_POS 16U +/** Mask for the low power field. */ +#define GECKO_LP_MSK 0x1U + +/** Input. */ +#define GECKO_LP_DISABLE 0U +/** Output. */ +#define GECKO_LP_ENABLE 1U + /** @} */ /** diff --git a/include/zephyr/dt-bindings/pinctrl/gecko-pinctrl.h b/include/zephyr/dt-bindings/pinctrl/gecko-pinctrl.h index a49f4fe793e54d..ed0cc03b2c6602 100644 --- a/include/zephyr/dt-bindings/pinctrl/gecko-pinctrl.h +++ b/include/zephyr/dt-bindings/pinctrl/gecko-pinctrl.h @@ -11,7 +11,8 @@ * organized as follows: * * - 31..24: Pin function. - * - 23..16: Reserved. + * - 23..15: Reserved. + * - 16: Low power. * - 15..8: Port for UART_RX/UART_TX functions. * - 7..0: Pin number for UART_RX/UART_TX functions. * - 15..8: Reserved for UART_LOC function. @@ -43,6 +44,16 @@ /** Mask for the pin field. */ #define GECKO_LOC_MSK 0xFFU +/** Position of low power field. */ +#define GECKO_LP_POS 16U +/** Mask for the low power field. */ +#define GECKO_LP_MSK 0x1U + +/** Input. */ +#define GECKO_LP_DISABLE 0U +/** Output. */ +#define GECKO_LP_ENABLE 1U + /** @} */ /** diff --git a/soc/silabs/common/pinctrl_soc.h b/soc/silabs/common/pinctrl_soc.h index 82592eafcf59d5..a4fe58beee4ef6 100644 --- a/soc/silabs/common/pinctrl_soc.h +++ b/soc/silabs/common/pinctrl_soc.h @@ -94,7 +94,9 @@ typedef uint32_t pinctrl_soc_pin_t; * @param prop Property name. * @param idx Property entry index. */ -#define Z_PINCTRL_STATE_PIN_INIT(node_id, prop, idx) (DT_PROP_BY_IDX(node_id, prop, idx)), +#define Z_PINCTRL_STATE_PIN_INIT(node_id, prop, idx) (DT_PROP_BY_IDX(node_id, prop, idx) | \ + ((GECKO_LP_ENABLE * DT_PROP(node_id, low_power_enable)) << GECKO_LP_POS) \ + ), /** * @brief Utility macro to initialize state pins contained in a given property. @@ -143,6 +145,13 @@ typedef uint32_t pinctrl_soc_pin_t; */ #define GECKO_GET_SPEED(pincfg) (((pincfg) >> GECKO_SPEED_POS) & GECKO_SPEED_MSK) +/** + * @brief Utility macro to obtain pin low power flag. + * + * @param pincfg Pin configuration bit field. + */ +#define GECKO_GET_LP(pincfg) (((pincfg) >> GECKO_LP_POS) & GECKO_LP_MSK) + #endif /* CONFIG_PINCTRL_SILABS_DBUS */ /** @endcond */ From f6543e8dc829283a91dde06a5b091e1f4a5c9112 Mon Sep 17 00:00:00 2001 From: Romain Pelletant Date: Thu, 2 Jan 2025 22:59:17 +0100 Subject: [PATCH 2/2] drivers: pinctrl: add low power support - Add low power pinctrl configuration support for gecko platform Signed-off-by: Romain Pelletant --- drivers/pinctrl/pinctrl_gecko.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/pinctrl/pinctrl_gecko.c b/drivers/pinctrl/pinctrl_gecko.c index db8f5523c01563..0f3805b1b3fd8b 100644 --- a/drivers/pinctrl/pinctrl_gecko.c +++ b/drivers/pinctrl/pinctrl_gecko.c @@ -33,6 +33,15 @@ int pinctrl_configure_pins(const pinctrl_soc_pin_t *pins, uint8_t pin_cnt, uintp pin_config.pin = GECKO_GET_PIN(pins[i]); loc = GECKO_GET_LOC(pins[i]); + /* Force input for low power mode */ + if (GECKO_GET_LP(pins[i]) == GECKO_LP_ENABLE) { + pin_config.mode = gpioModeInput; + pin_config.out = 0; + GPIO_PinModeSet(pin_config.port, pin_config.pin, pin_config.mode, + pin_config.out); + continue; + } + switch (GECKO_GET_FUN(pins[i])) { #ifdef CONFIG_UART_GECKO case GECKO_FUN_UART_RX: