From 193eeaef0c04570b80a954b58ccd98075150fb11 Mon Sep 17 00:00:00 2001 From: Mert Ekren Date: Fri, 18 Oct 2024 14:41:01 +0300 Subject: [PATCH] drivers: pinctrl: max32: fix correct configuring drive strength This commit fixes configuring pin drive strength in pinctrl driver. Previously, there was a mismatch while filling pincfg and checking pincfg drive strength field. This fix simplifies the operation and avoids gpio driver header dependency. Signed-off-by: Mert Ekren Co-Authored-By: Sadik Ozer --- drivers/pinctrl/pinctrl_max32.c | 16 +--------------- .../zephyr/dt-bindings/pinctrl/max32-pinctrl.h | 1 + 2 files changed, 2 insertions(+), 15 deletions(-) diff --git a/drivers/pinctrl/pinctrl_max32.c b/drivers/pinctrl/pinctrl_max32.c index e9fcf65aa85910..39b43b600af43d 100644 --- a/drivers/pinctrl/pinctrl_max32.c +++ b/drivers/pinctrl/pinctrl_max32.c @@ -5,7 +5,6 @@ */ #include -#include #include #include @@ -67,20 +66,7 @@ static int pinctrl_configure_pin(pinctrl_soc_pin_t soc_pin) gpio_cfg.vssel = MXC_GPIO_VSSEL_VDDIO; } - switch (pincfg & MAX32_GPIO_DRV_STRENGTH_MASK) { - case MAX32_GPIO_DRV_STRENGTH_1: - gpio_cfg.drvstr = MXC_GPIO_DRVSTR_1; - break; - case MAX32_GPIO_DRV_STRENGTH_2: - gpio_cfg.drvstr = MXC_GPIO_DRVSTR_2; - break; - case MAX32_GPIO_DRV_STRENGTH_3: - gpio_cfg.drvstr = MXC_GPIO_DRVSTR_3; - break; - default: - gpio_cfg.drvstr = MXC_GPIO_DRVSTR_0; - break; - } + gpio_cfg.drvstr = (pincfg >> MAX32_DRV_STRENGTH_SHIFT) & MAX32_DRV_STRENGTH_MASK; if (MXC_GPIO_Config(&gpio_cfg) != 0) { return -ENOTSUP; diff --git a/include/zephyr/dt-bindings/pinctrl/max32-pinctrl.h b/include/zephyr/dt-bindings/pinctrl/max32-pinctrl.h index 97a3ab76748d18..fbfaf777be5795 100644 --- a/include/zephyr/dt-bindings/pinctrl/max32-pinctrl.h +++ b/include/zephyr/dt-bindings/pinctrl/max32-pinctrl.h @@ -63,5 +63,6 @@ #define MAX32_POWER_SOURCE_SHIFT 0x04 #define MAX32_OUTPUT_HIGH_SHIFT 0x05 #define MAX32_DRV_STRENGTH_SHIFT 0x06 /* 2 bits */ +#define MAX32_DRV_STRENGTH_MASK 0x03 #endif /* ZEPHYR_INCLUDE_DT_BINDINGS_PINCTRL_MAX32_PINCTRL_H_ */