diff mbox series

[V2,2/6] pinctrl: sprd: Fix the incorrect mask and shift definition

Message ID 20230908055146.18347-3-Linhua.xu@unisoc.com
State Superseded
Headers show
Series pinctrl: sprd: Modification of UNIOC Platform pinctrl Driver | expand

Commit Message

Linhua Xu Sept. 8, 2023, 5:51 a.m. UTC
From: Linhua Xu <Linhua.Xu@unisoc.com>

Pull-up and pull-down are mutually exclusive. When setting one of them,
the bit of the other needs to be clear. Now, there are cases where pull-up
and pull-down are set at the same time in the code, thus fix them.

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

Comments

Andy Shevchenko Sept. 11, 2023, 9:50 a.m. UTC | #1
On Fri, Sep 08, 2023 at 01:51:42PM +0800, Linhua Xu wrote:
> From: Linhua Xu <Linhua.Xu@unisoc.com>
> 
> Pull-up and pull-down are mutually exclusive. When setting one of them,
> the bit of the other needs to be clear. Now, there are cases where pull-up
> and pull-down are set at the same time in the code, thus fix them.

...

>  #define SLEEP_PULL_DOWN			BIT(2)
> -#define SLEEP_PULL_DOWN_MASK		0x1
> +#define SLEEP_PULL_DOWN_MASK		GENMASK(1, 0)
>  #define SLEEP_PULL_DOWN_SHIFT		2
>  
>  #define PULL_DOWN			BIT(6)
> -#define PULL_DOWN_MASK			0x1
> +#define PULL_DOWN_MASK			(GENMASK(1, 0) | BIT(6))
>  #define PULL_DOWN_SHIFT			6
>  
>  #define SLEEP_PULL_UP			BIT(3)
> -#define SLEEP_PULL_UP_MASK		0x1
> -#define SLEEP_PULL_UP_SHIFT		3
> +#define SLEEP_PULL_UP_MASK		GENMASK(1, 0)
> +#define SLEEP_PULL_UP_SHIFT		2
>  
>  #define PULL_UP_4_7K			(BIT(12) | BIT(7))
>  #define PULL_UP_20K			BIT(7)
> -#define PULL_UP_MASK			0x21
> -#define PULL_UP_SHIFT			7
> +#define PULL_UP_MASK			(GENMASK(1, 0) | BIT(6))
> +#define PULL_UP_SHIFT			6

These look strange now.

So, SLEEP MASK doesn't cover bits 2 and 3.
I believe you should have

#define SLEEP_PULL_UP_DOWN_MASK		GENMASK(3, 2)

The other even weirder with this BIT(6) there.

In the similar way:

#define PULL_UP_DOWN_MASK		GENMASK(7, 6)
Baolin Wang Sept. 12, 2023, 8:28 a.m. UTC | #2
On 9/8/2023 1:51 PM, Linhua Xu wrote:
> From: Linhua Xu <Linhua.Xu@unisoc.com>
> 
> Pull-up and pull-down are mutually exclusive. When setting one of them,
> the bit of the other needs to be clear. Now, there are cases where pull-up
> and pull-down are set at the same time in the code, thus fix them.
> 
> Signed-off-by: Linhua Xu <Linhua.Xu@unisoc.com>
> ---
>   drivers/pinctrl/sprd/pinctrl-sprd.c | 12 ++++++------
>   1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/pinctrl/sprd/pinctrl-sprd.c b/drivers/pinctrl/sprd/pinctrl-sprd.c
> index 25fb9ce9ad78..5b9126b2cde2 100644
> --- a/drivers/pinctrl/sprd/pinctrl-sprd.c
> +++ b/drivers/pinctrl/sprd/pinctrl-sprd.c
> @@ -58,21 +58,21 @@
>   #define DRIVE_STRENGTH_SHIFT		19
>   
>   #define SLEEP_PULL_DOWN			BIT(2)
> -#define SLEEP_PULL_DOWN_MASK		0x1
> +#define SLEEP_PULL_DOWN_MASK		GENMASK(1, 0)
>   #define SLEEP_PULL_DOWN_SHIFT		2
>   
>   #define PULL_DOWN			BIT(6)
> -#define PULL_DOWN_MASK			0x1
> +#define PULL_DOWN_MASK			(GENMASK(1, 0) | BIT(6))
>   #define PULL_DOWN_SHIFT			6
>   
>   #define SLEEP_PULL_UP			BIT(3)
> -#define SLEEP_PULL_UP_MASK		0x1
> -#define SLEEP_PULL_UP_SHIFT		3
> +#define SLEEP_PULL_UP_MASK		GENMASK(1, 0)
> +#define SLEEP_PULL_UP_SHIFT		2
>   
>   #define PULL_UP_4_7K			(BIT(12) | BIT(7))
>   #define PULL_UP_20K			BIT(7)
> -#define PULL_UP_MASK			0x21
> -#define PULL_UP_SHIFT			7
> +#define PULL_UP_MASK			(GENMASK(1, 0) | BIT(6))
> +#define PULL_UP_SHIFT			6

This change looks weird, BIT(6) is for PULL_DOWN. So I am curious these 
changes are backward compatibility?

Now I can not access the SPRD Spec, Chunyan, can you help to confirm 
these changes? Thanks.

>   
>   #define INPUT_SCHMITT			BIT(11)
>   #define INPUT_SCHMITT_MASK		0x1
Linus Walleij Nov. 13, 2023, 1:50 p.m. UTC | #3
On Fri, Sep 8, 2023 at 7:52 AM Linhua Xu <Linhua.xu@unisoc.com> wrote:

> From: Linhua Xu <Linhua.Xu@unisoc.com>
>
> Pull-up and pull-down are mutually exclusive. When setting one of them,
> the bit of the other needs to be clear. Now, there are cases where pull-up
> and pull-down are set at the same time in the code, thus fix them.
>
> Signed-off-by: Linhua Xu <Linhua.Xu@unisoc.com>

I'm uncertain what to do with this patch because it fixes something
while there are unaddressed review comments, I think we need
some more discussion here?

Yours,
Linus Walleij
diff mbox series

Patch

diff --git a/drivers/pinctrl/sprd/pinctrl-sprd.c b/drivers/pinctrl/sprd/pinctrl-sprd.c
index 25fb9ce9ad78..5b9126b2cde2 100644
--- a/drivers/pinctrl/sprd/pinctrl-sprd.c
+++ b/drivers/pinctrl/sprd/pinctrl-sprd.c
@@ -58,21 +58,21 @@ 
 #define DRIVE_STRENGTH_SHIFT		19
 
 #define SLEEP_PULL_DOWN			BIT(2)
-#define SLEEP_PULL_DOWN_MASK		0x1
+#define SLEEP_PULL_DOWN_MASK		GENMASK(1, 0)
 #define SLEEP_PULL_DOWN_SHIFT		2
 
 #define PULL_DOWN			BIT(6)
-#define PULL_DOWN_MASK			0x1
+#define PULL_DOWN_MASK			(GENMASK(1, 0) | BIT(6))
 #define PULL_DOWN_SHIFT			6
 
 #define SLEEP_PULL_UP			BIT(3)
-#define SLEEP_PULL_UP_MASK		0x1
-#define SLEEP_PULL_UP_SHIFT		3
+#define SLEEP_PULL_UP_MASK		GENMASK(1, 0)
+#define SLEEP_PULL_UP_SHIFT		2
 
 #define PULL_UP_4_7K			(BIT(12) | BIT(7))
 #define PULL_UP_20K			BIT(7)
-#define PULL_UP_MASK			0x21
-#define PULL_UP_SHIFT			7
+#define PULL_UP_MASK			(GENMASK(1, 0) | BIT(6))
+#define PULL_UP_SHIFT			6
 
 #define INPUT_SCHMITT			BIT(11)
 #define INPUT_SCHMITT_MASK		0x1