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

Linhua Xu posted 6 patches 2 years, 5 months ago
There is a newer version of this series
[PATCH 3/6] pinctrl: sprd: Modify pull-up parameters
Posted by Linhua Xu 2 years, 5 months ago
From: Linhua Xu <Linhua.Xu@unisoc.com>

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@unisoc.com>
---
 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
Re: [PATCH 3/6] pinctrl: sprd: Modify pull-up parameters
Posted by Andy Shevchenko 2 years, 5 months ago
On Fri, Aug 25, 2023 at 11:18:23AM +0800, Linhua Xu wrote:
> From: Linhua Xu <Linhua.Xu@unisoc.com>
> 
> 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.

...

> -					if (arg == 20000)
> -					else if (arg == 4700)

> +					if (arg == 3)
> +					else if (arg == 2)
> +					else if (arg == 1)

This will break existing users. What's wrong with leaving this as is
and adding 1.8kOhm?

-- 
With Best Regards,
Andy Shevchenko