2020-03-25 08:26:19

by Baolin Wang

[permalink] [raw]
Subject: [PATCH 1/2] pinctrl: sprd: Use the correct pin output configuration

From: Linhua Xu <[email protected]>

The Spreadtrum pin controller did not supply registers to set high level
or low level for output mode, instead we should let the pin controller
current configuration drive values on the line. So we should use the
PIN_CONFIG_OUTPUT_ENABLE configuration to enable or disable the output
mode.

[Baolin Wang changes the commit message]
Fixes: 41d32cfce1ae ("pinctrl: sprd: Add Spreadtrum pin control driver")
Signed-off-by: Linhua Xu <[email protected]>
Signed-off-by: Baolin Wang <[email protected]>
---
drivers/pinctrl/sprd/pinctrl-sprd.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/pinctrl/sprd/pinctrl-sprd.c b/drivers/pinctrl/sprd/pinctrl-sprd.c
index ea04bac..8e39610 100644
--- a/drivers/pinctrl/sprd/pinctrl-sprd.c
+++ b/drivers/pinctrl/sprd/pinctrl-sprd.c
@@ -464,7 +464,7 @@ static int sprd_pinconf_get(struct pinctrl_dev *pctldev, unsigned int pin_id,
case PIN_CONFIG_INPUT_ENABLE:
arg = (reg >> SLEEP_INPUT_SHIFT) & SLEEP_INPUT_MASK;
break;
- case PIN_CONFIG_OUTPUT:
+ case PIN_CONFIG_OUTPUT_ENABLE:
arg = reg & SLEEP_OUTPUT_MASK;
break;
case PIN_CONFIG_DRIVE_STRENGTH:
@@ -635,9 +635,13 @@ static int sprd_pinconf_set(struct pinctrl_dev *pctldev, unsigned int pin_id,
shift = SLEEP_INPUT_SHIFT;
}
break;
- case PIN_CONFIG_OUTPUT:
+ case PIN_CONFIG_OUTPUT_ENABLE:
if (is_sleep_config == true) {
- val |= SLEEP_OUTPUT;
+ if (arg > 0)
+ val |= SLEEP_OUTPUT;
+ else
+ val &= ~SLEEP_OUTPUT;
+
mask = SLEEP_OUTPUT_MASK;
shift = SLEEP_OUTPUT_SHIFT;
}
--
1.9.1


2020-03-25 08:26:24

by Baolin Wang

[permalink] [raw]
Subject: [PATCH 2/2] pinctrl: sprd: Add pin high impedance mode support

From: Linhua Xu <[email protected]>

For Spreadtrum pin controller, it will be the high impedance
mode if disable input and output mode for a pin. Thus add
PIN_CONFIG_BIAS_HIGH_IMPEDANCE configuration to support it.

Signed-off-by: Linhua Xu <[email protected]>
Signed-off-by: Baolin Wang <[email protected]>
---
drivers/pinctrl/sprd/pinctrl-sprd.c | 12 ++++++++++++
1 file changed, 12 insertions(+)

diff --git a/drivers/pinctrl/sprd/pinctrl-sprd.c b/drivers/pinctrl/sprd/pinctrl-sprd.c
index 8e39610..48cbf2a 100644
--- a/drivers/pinctrl/sprd/pinctrl-sprd.c
+++ b/drivers/pinctrl/sprd/pinctrl-sprd.c
@@ -467,6 +467,12 @@ static int sprd_pinconf_get(struct pinctrl_dev *pctldev, unsigned int pin_id,
case PIN_CONFIG_OUTPUT_ENABLE:
arg = reg & SLEEP_OUTPUT_MASK;
break;
+ case PIN_CONFIG_BIAS_HIGH_IMPEDANCE:
+ if ((reg & SLEEP_OUTPUT) || (reg & SLEEP_INPUT))
+ return -EINVAL;
+
+ arg = 1;
+ break;
case PIN_CONFIG_DRIVE_STRENGTH:
arg = (reg >> DRIVE_STRENGTH_SHIFT) &
DRIVE_STRENGTH_MASK;
@@ -646,6 +652,12 @@ static int sprd_pinconf_set(struct pinctrl_dev *pctldev, unsigned int pin_id,
shift = SLEEP_OUTPUT_SHIFT;
}
break;
+ case PIN_CONFIG_BIAS_HIGH_IMPEDANCE:
+ if (is_sleep_config == true) {
+ val = shift = 0;
+ mask = SLEEP_OUTPUT | SLEEP_INPUT;
+ }
+ break;
case PIN_CONFIG_DRIVE_STRENGTH:
if (arg < 2 || arg > 60)
return -EINVAL;
--
1.9.1

2020-03-27 21:09:12

by Linus Walleij

[permalink] [raw]
Subject: Re: [PATCH 1/2] pinctrl: sprd: Use the correct pin output configuration

On Wed, Mar 25, 2020 at 9:25 AM Baolin Wang <[email protected]> wrote:

> From: Linhua Xu <[email protected]>
>
> The Spreadtrum pin controller did not supply registers to set high level
> or low level for output mode, instead we should let the pin controller
> current configuration drive values on the line. So we should use the
> PIN_CONFIG_OUTPUT_ENABLE configuration to enable or disable the output
> mode.
>
> [Baolin Wang changes the commit message]
> Fixes: 41d32cfce1ae ("pinctrl: sprd: Add Spreadtrum pin control driver")
> Signed-off-by: Linhua Xu <[email protected]>
> Signed-off-by: Baolin Wang <[email protected]>

Patch applied.

Yours,
Linus Walleij

2020-03-27 21:12:55

by Linus Walleij

[permalink] [raw]
Subject: Re: [PATCH 2/2] pinctrl: sprd: Add pin high impedance mode support

On Wed, Mar 25, 2020 at 9:25 AM Baolin Wang <[email protected]> wrote:

> From: Linhua Xu <[email protected]>
>
> For Spreadtrum pin controller, it will be the high impedance
> mode if disable input and output mode for a pin. Thus add
> PIN_CONFIG_BIAS_HIGH_IMPEDANCE configuration to support it.
>
> Signed-off-by: Linhua Xu <[email protected]>
> Signed-off-by: Baolin Wang <[email protected]>

Patch applied! Nice engineering here, figuring out the right
fit for pin control configs, thanks folks!

Yours,
Linus Walleij