[PATCH 3/6] pinctrl: sprd: Modify pull-up parameters

From: Linhua Xu
Date: Thu Aug 24 2023 - 23:39:20 EST


From: Linhua Xu <Linhua.Xu@xxxxxxxxxx>

For UNISOC pin controller, there are three different configurations of
pull-up drive current: 1 for pull-up resistor is 20K, 2 for pull-up
resistor is 4.7K and 3 for pull-up resistor is 1.8K. Thus modify them.

Signed-off-by: Linhua Xu <Linhua.Xu@xxxxxxxxxx>
---
drivers/pinctrl/sprd/pinctrl-sprd.c | 22 ++++++++++++----------
1 file changed, 12 insertions(+), 10 deletions(-)

diff --git a/drivers/pinctrl/sprd/pinctrl-sprd.c b/drivers/pinctrl/sprd/pinctrl-sprd.c
index 6464999aaebe..6d16209a4846 100644
--- a/drivers/pinctrl/sprd/pinctrl-sprd.c
+++ b/drivers/pinctrl/sprd/pinctrl-sprd.c
@@ -69,8 +69,9 @@
#define SLEEP_PULL_UP_MASK 0x3
#define SLEEP_PULL_UP_SHIFT 2

-#define PULL_UP_4_7K (BIT(12) | BIT(7))
-#define PULL_UP_20K BIT(7)
+#define PULL_UP_WPUSP (BIT(12) | BIT(7))
+#define PULL_UP_WPUS BIT(12)
+#define PULL_UP_WPU BIT(7)
#define PULL_UP_MASK 0x43
#define PULL_UP_SHIFT 6

@@ -497,7 +498,7 @@ static int sprd_pinconf_get(struct pinctrl_dev *pctldev, unsigned int pin_id,
break;
case PIN_CONFIG_BIAS_DISABLE:
if ((reg & (SLEEP_PULL_DOWN | SLEEP_PULL_UP)) ||
- (reg & (PULL_DOWN | PULL_UP_4_7K | PULL_UP_20K)))
+ (reg & (PULL_DOWN | PULL_UP_WPUSP)))
return -EINVAL;

arg = 1;
@@ -690,15 +691,17 @@ static int sprd_pinconf_set(struct pinctrl_dev *pctldev, unsigned int pin_id,
shift = INPUT_SCHMITT_SHIFT;
break;
case PIN_CONFIG_BIAS_PULL_UP:
- if (is_sleep_config) {
+ if (is_sleep_config == true) {
val |= SLEEP_PULL_UP;
mask = SLEEP_PULL_UP_MASK;
shift = SLEEP_PULL_UP_SHIFT;
} else {
- if (arg == 20000)
- val |= PULL_UP_20K;
- else if (arg == 4700)
- val |= PULL_UP_4_7K;
+ if (arg == 3)
+ val |= PULL_UP_WPUSP;
+ else if (arg == 2)
+ val |= PULL_UP_WPUS;
+ else if (arg == 1)
+ val |= PULL_UP_WPU;

mask = PULL_UP_MASK;
shift = PULL_UP_SHIFT;
@@ -710,8 +713,7 @@ static int sprd_pinconf_set(struct pinctrl_dev *pctldev, unsigned int pin_id,
mask = SLEEP_PULL_DOWN | SLEEP_PULL_UP;
} else {
val = shift = 0;
- mask = PULL_DOWN | PULL_UP_20K |
- PULL_UP_4_7K;
+ mask = PULL_DOWN | PULL_UP_WPUSP;
}
break;
case PIN_CONFIG_SLEEP_HARDWARE_STATE:
--
2.17.1