Skip to contentSkip to conversation

pinctrl: sprd: Modification of UNIOC Platform pinctrl Driver

PATCH Superseded Linhua Xu 5 participants 22 messages Sep 8, 2023 – Nov 13, 2023 1 message not in the archive

Subsystems (3)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Linhua Xu

author
#0 lore raw

v2 cover pinctrl: sprd: Modification of UNIOC Platform pinctrl Driver

From: Linhua Xu <[email protected]>

Recently, some bugs have been discovered during use, and patch2 and patch3 are bug fixes. Also, this patchset add new features: patch1 is for compatibility with more platforms, patch4 add pinctrl support for UMS512, patch5 Increase the range of register values, patch6 add pinctrl support for UMS9621.

change in V2
-Add comment for common_pin_offset and misc_pin_offset
-Remove cast commits
-Modify the mask definition into GENMASK form
-Delete the three-speed configuration that modifies the original parameters -Add 1.8K resistor configuration
-Delete depends on OF
-Modify the format of sprd_pinctrl_of_match
-Drop trailing comma in the terminator entry
-Add bits.h header file
-Add kernel.h header file

Linhua Xu (6):
pinctrl: sprd: Modify the probe function parameters
pinctrl: sprd: Fix the incorrect mask and shift definition
pinctrl: sprd: Modify pull-up parameters
pinctrl: sprd: Add pinctrl support for UMS512
pinctrl: sprd: Increase the range of register values
pinctrl: sprd: Add pinctrl support for UMS9621

 drivers/pinctrl/sprd/Kconfig                |   22 +
 drivers/pinctrl/sprd/Makefile               |    2 +
 drivers/pinctrl/sprd/pinctrl-sprd-sc9860.c  |    7 +-
 drivers/pinctrl/sprd/pinctrl-sprd-ums512.c  |  878 +++++++++++++++
 drivers/pinctrl/sprd/pinctrl-sprd-ums9621.c | 1117 +++++++++++++++++++
 drivers/pinctrl/sprd/pinctrl-sprd.c         |   49 +-
 drivers/pinctrl/sprd/pinctrl-sprd.h         |   33 +-
 7 files changed, 2071 insertions(+), 37 deletions(-)
 create mode 100644 drivers/pinctrl/sprd/pinctrl-sprd-ums512.c
 create mode 100644 drivers/pinctrl/sprd/pinctrl-sprd-ums9621.c
Signature · 1 line
2.17.1
author
#1 lore raw

PATCH v2 1/6 pinctrl: sprd: Modify the probe function parameters

From: Linhua Xu <[email protected]>

For UNISOC pin controller, the offset values of the common register and misc register will be different. Thus put these in the probe function parameters.

---
 drivers/pinctrl/sprd/pinctrl-sprd-sc9860.c |  7 +++++-
 drivers/pinctrl/sprd/pinctrl-sprd.c        | 27 +++++++++++++---------
 drivers/pinctrl/sprd/pinctrl-sprd.h        |  3 ++-
 3 files changed, 24 insertions(+), 13 deletions(-)
drivers/pinctrl/sprd/pinctrl-sprd-sc9860.c +6 -1
index d14f382f2392..05158c71ad77 100644
@@ -10,6 +10,9 @@
 
 #include "pinctrl-sprd.h"
 
+#define	PINCTRL_REG_OFFSET		0x20
+#define	PINCTRL_REG_MISC_OFFSET		0x4020
+
 enum sprd_sc9860_pins {
 	/* pin global control register 0 */
 	SC9860_VIO28_0_IRTE = SPRD_PIN_INFO(0, GLOBAL_CTRL_PIN, 11, 1, 0),
@@ -926,7 +929,9 @@ static struct sprd_pins_info sprd_sc9860_pins_info[] = {
 static int sprd_pinctrl_probe(struct platform_device *pdev)
 {
 	return sprd_pinctrl_core_probe(pdev, sprd_sc9860_pins_info,
-				       ARRAY_SIZE(sprd_sc9860_pins_info));
+				       ARRAY_SIZE(sprd_sc9860_pins_info),
+				       PINCTRL_REG_OFFSET,
+				       PINCTRL_REG_MISC_OFFSET);
 }
 
 static const struct of_device_id sprd_pinctrl_of_match[] = {
drivers/pinctrl/sprd/pinctrl-sprd.c +16 -11
index ca9659f4e4b1..25fb9ce9ad78 100644
@@ -30,8 +30,6 @@
 #include "pinctrl-sprd.h"
 
 #define PINCTRL_BIT_MASK(width)		(~(~0UL << (width)))
-#define PINCTRL_REG_OFFSET		0x20
-#define PINCTRL_REG_MISC_OFFSET		0x4020
 #define PINCTRL_REG_LEN			0x4
 
 #define PIN_FUNC_MASK			(BIT(4) | BIT(5))
@@ -148,12 +146,16 @@ struct sprd_pinctrl_soc_info {
  * @pctl: pointer to the pinctrl handle
  * @base: base address of the controller
  * @info: pointer to SoC's pins description information
+ * @common_pin_offset: offset value of common register
+ * @misc_pin_offset: offset value of misc register
  */
 struct sprd_pinctrl {
 	struct device *dev;
 	struct pinctrl_dev *pctl;
 	void __iomem *base;
 	struct sprd_pinctrl_soc_info *info;
+	u32 common_pin_offset;
+	u32 misc_pin_offset;
 };
 
 #define SPRD_PIN_CONFIG_CONTROL		(PIN_CONFIG_END + 1)
@@ -1023,12 +1025,12 @@ static int sprd_pinctrl_add_pins(struct sprd_pinctrl *sprd_pctl,
 			ctrl_pin++;
 		} else if (pin->type == COMMON_PIN) {
 			pin->reg = (unsigned long)sprd_pctl->base +
-				PINCTRL_REG_OFFSET + PINCTRL_REG_LEN *
+				sprd_pctl->common_pin_offset + PINCTRL_REG_LEN *
 				(i - ctrl_pin);
 			com_pin++;
 		} else if (pin->type == MISC_PIN) {
 			pin->reg = (unsigned long)sprd_pctl->base +
-				PINCTRL_REG_MISC_OFFSET + PINCTRL_REG_LEN *
+				sprd_pctl->misc_pin_offset + PINCTRL_REG_LEN *
 				(i - ctrl_pin - com_pin);
 		}
 	}
@@ -1045,7 +1047,9 @@ static int sprd_pinctrl_add_pins(struct sprd_pinctrl *sprd_pctl,
 
 int sprd_pinctrl_core_probe(struct platform_device *pdev,
 			    struct sprd_pins_info *sprd_soc_pin_info,
-			    int pins_cnt)
+			    int pins_cnt,
+			    u32 common_pin_offset,
+			    u32 misc_pin_offset)
 {
 	struct sprd_pinctrl *sprd_pctl;
 	struct sprd_pinctrl_soc_info *pinctrl_info;
@@ -1069,6 +1073,8 @@ int sprd_pinctrl_core_probe(struct platform_device *pdev,
 
 	sprd_pctl->info = pinctrl_info;
 	sprd_pctl->dev = &pdev->dev;
+	sprd_pctl->common_pin_offset = common_pin_offset;
+	sprd_pctl->misc_pin_offset = misc_pin_offset;
 	platform_set_drvdata(pdev, sprd_pctl);
 
 	ret = sprd_pinctrl_add_pins(sprd_pctl, sprd_soc_pin_info, pins_cnt);
@@ -1077,12 +1083,6 @@ int sprd_pinctrl_core_probe(struct platform_device *pdev,
 		return ret;
 	}
 
-	ret = sprd_pinctrl_parse_dt(sprd_pctl);
-	if (ret) {
-		dev_err(&pdev->dev, "fail to parse dt properties\n");
-		return ret;
-	}
-
 	pin_desc = devm_kcalloc(&pdev->dev,
 				pinctrl_info->npins,
 				sizeof(struct pinctrl_pin_desc),
@@ -1100,6 +1100,11 @@ int sprd_pinctrl_core_probe(struct platform_device *pdev,
 	sprd_pinctrl_desc.name = dev_name(&pdev->dev);
 	sprd_pinctrl_desc.npins = pinctrl_info->npins;
 
+	ret = sprd_pinctrl_parse_dt(sprd_pctl);
+	if (ret) {
+		dev_err(&pdev->dev, "fail to parse dt properties\n");
+		return ret;
+	}
 	sprd_pctl->pctl = pinctrl_register(&sprd_pinctrl_desc,
 					   &pdev->dev, (void *)sprd_pctl);
 	if (IS_ERR(sprd_pctl->pctl)) {
drivers/pinctrl/sprd/pinctrl-sprd.h +2 -1
index 69544a3cd635..a696f81ce663 100644
@@ -52,7 +52,8 @@ struct sprd_pins_info {
 
 int sprd_pinctrl_core_probe(struct platform_device *pdev,
 			    struct sprd_pins_info *sprd_soc_pin_info,
-			    int pins_cnt);
+			    int pins_cnt, u32 common_pin_offset,
+			    u32 misc_pin_offset);
 int sprd_pinctrl_remove(struct platform_device *pdev);
 void sprd_pinctrl_shutdown(struct platform_device *pdev);
 
Signature · 1 line
2.17.1
#2 lore raw

Re: [PATCH V2 1/6] pinctrl: sprd: Modify the probe function parameters

Quoted 5 lines · Linhua Xu

From: Linhua Xu <[email protected]>

For UNISOC pin controller, the offset values of the common register and misc register will be different. Thus put these in the probe function parameters.

...

Quoted 1 line

+#define PINCTRL_REG_OFFSET 0x20

0x0020 to make it look as related to the other one, as they are of the same
type: register offsets.

Quoted 1 line

+#define PINCTRL_REG_MISC_OFFSET 0x4020

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#3 lore raw

Re: [PATCH V2 1/6] pinctrl: sprd: Modify the probe function parameters

In reply to Linhua Xu
Quoted 117 lines · Linhua Xu

From: Linhua Xu <[email protected]>

For UNISOC pin controller, the offset values of the common register and misc register will be different. Thus put these in the probe function parameters.

---
  drivers/pinctrl/sprd/pinctrl-sprd-sc9860.c |  7 +++++-
  drivers/pinctrl/sprd/pinctrl-sprd.c        | 27 +++++++++++++---------
  drivers/pinctrl/sprd/pinctrl-sprd.h        |  3 ++-
  3 files changed, 24 insertions(+), 13 deletions(-)
drivers/pinctrl/sprd/pinctrl-sprd-sc9860.c +6 -1
index d14f382f2392..05158c71ad77 100644
@@ -10,6 +10,9 @@
 
  #include "pinctrl-sprd.h"
 
+#define	PINCTRL_REG_OFFSET		0x20
+#define	PINCTRL_REG_MISC_OFFSET		0x4020
+
  enum sprd_sc9860_pins {
  	/* pin global control register 0 */
  	SC9860_VIO28_0_IRTE = SPRD_PIN_INFO(0, GLOBAL_CTRL_PIN, 11, 1, 0),
@@ -926,7 +929,9 @@ static struct sprd_pins_info sprd_sc9860_pins_info[] = {
  static int sprd_pinctrl_probe(struct platform_device *pdev)
  {
  	return sprd_pinctrl_core_probe(pdev, sprd_sc9860_pins_info,
-				       ARRAY_SIZE(sprd_sc9860_pins_info));
+				       ARRAY_SIZE(sprd_sc9860_pins_info),
+				       PINCTRL_REG_OFFSET,
+				       PINCTRL_REG_MISC_OFFSET);
  }
 
  static const struct of_device_id sprd_pinctrl_of_match[] = {
drivers/pinctrl/sprd/pinctrl-sprd.c +11 -11
index ca9659f4e4b1..25fb9ce9ad78 100644
@@ -30,8 +30,6 @@
  #include "pinctrl-sprd.h"
 
  #define PINCTRL_BIT_MASK(width)		(~(~0UL << (width)))
-#define PINCTRL_REG_OFFSET		0x20
-#define PINCTRL_REG_MISC_OFFSET		0x4020
  #define PINCTRL_REG_LEN			0x4
 
  #define PIN_FUNC_MASK			(BIT(4) | BIT(5))
@@ -148,12 +146,16 @@ struct sprd_pinctrl_soc_info {
   * @pctl: pointer to the pinctrl handle
   * @base: base address of the controller
   * @info: pointer to SoC's pins description information
+ * @common_pin_offset: offset value of common register
+ * @misc_pin_offset: offset value of misc register
   */
  struct sprd_pinctrl {
  	struct device *dev;
  	struct pinctrl_dev *pctl;
  	void __iomem *base;
  	struct sprd_pinctrl_soc_info *info;
+	u32 common_pin_offset;
+	u32 misc_pin_offset;
  };
 
  #define SPRD_PIN_CONFIG_CONTROL		(PIN_CONFIG_END + 1)
@@ -1023,12 +1025,12 @@ static int sprd_pinctrl_add_pins(struct sprd_pinctrl *sprd_pctl,
  			ctrl_pin++;
  		} else if (pin->type == COMMON_PIN) {
  			pin->reg = (unsigned long)sprd_pctl->base +
-				PINCTRL_REG_OFFSET + PINCTRL_REG_LEN *
+				sprd_pctl->common_pin_offset + PINCTRL_REG_LEN *
  				(i - ctrl_pin);
  			com_pin++;
  		} else if (pin->type == MISC_PIN) {
  			pin->reg = (unsigned long)sprd_pctl->base +
-				PINCTRL_REG_MISC_OFFSET + PINCTRL_REG_LEN *
+				sprd_pctl->misc_pin_offset + PINCTRL_REG_LEN *
  				(i - ctrl_pin - com_pin);
  		}
  	}
@@ -1045,7 +1047,9 @@ static int sprd_pinctrl_add_pins(struct sprd_pinctrl *sprd_pctl,
 
  int sprd_pinctrl_core_probe(struct platform_device *pdev,
  			    struct sprd_pins_info *sprd_soc_pin_info,
-			    int pins_cnt)
+			    int pins_cnt,
+			    u32 common_pin_offset,
+			    u32 misc_pin_offset)
  {
  	struct sprd_pinctrl *sprd_pctl;
  	struct sprd_pinctrl_soc_info *pinctrl_info;
@@ -1069,6 +1073,8 @@ int sprd_pinctrl_core_probe(struct platform_device *pdev,
 
  	sprd_pctl->info = pinctrl_info;
  	sprd_pctl->dev = &pdev->dev;
+	sprd_pctl->common_pin_offset = common_pin_offset;
+	sprd_pctl->misc_pin_offset = misc_pin_offset;
  	platform_set_drvdata(pdev, sprd_pctl);
 
  	ret = sprd_pinctrl_add_pins(sprd_pctl, sprd_soc_pin_info, pins_cnt);
@@ -1077,12 +1083,6 @@ int sprd_pinctrl_core_probe(struct platform_device *pdev,
  		return ret;
  	}
 
-	ret = sprd_pinctrl_parse_dt(sprd_pctl);
-	if (ret) {
-		dev_err(&pdev->dev, "fail to parse dt properties\n");
-		return ret;
-	}
-
  	pin_desc = devm_kcalloc(&pdev->dev,
  				pinctrl_info->npins,
  				sizeof(struct pinctrl_pin_desc),

drivers/pinctrl/sprd/pinctrl-sprd.c int sprd_pinctrl_core_probe(struct platform_device *pdev, · line 1107

Quoted 8 lines
drivers/pinctrl/sprd/pinctrl-sprd.c +5 -0
@@ -1100,6 +1100,11 @@ int sprd_pinctrl_core_probe(struct platform_device *pdev,
  	sprd_pinctrl_desc.name = dev_name(&pdev->dev);
  	sprd_pinctrl_desc.npins = pinctrl_info->npins;
 
+	ret = sprd_pinctrl_parse_dt(sprd_pctl);
+	if (ret) {
+		dev_err(&pdev->dev, "fail to parse dt properties\n");
+		return ret;
+	}

Why change this? If this change fixed anything, please mention it in the commit log.

Quoted 8 lines
drivers/pinctrl/sprd/pinctrl-sprd.c +0 -0
  	sprd_pctl->pctl = pinctrl_register(&sprd_pinctrl_desc,
  					   &pdev->dev, (void *)sprd_pctl);
  	if (IS_ERR(sprd_pctl->pctl)) {
drivers/pinctrl/sprd/pinctrl-sprd.h +0 -0
index 69544a3cd635..a696f81ce663 100644

drivers/pinctrl/sprd/pinctrl-sprd.h struct sprd_pins_info { · line 56

Quoted 6 lines
drivers/pinctrl/sprd/pinctrl-sprd.h +2 -1
@@ -52,7 +52,8 @@ struct sprd_pins_info {
 
  int sprd_pinctrl_core_probe(struct platform_device *pdev,
  			    struct sprd_pins_info *sprd_soc_pin_info,
-			    int pins_cnt);
+			    int pins_cnt, u32 common_pin_offset,
+			    u32 misc_pin_offset);

IMO, I don't like this modification since it lacks scalability, and just imagine that there might be more differences in SoC in the future. So adding a SoC structure in sprd_pinctrl_of_match() and parsing it in the sprd-pinctrl core seems the right way to go.

Quoted 3 lines
drivers/pinctrl/sprd/pinctrl-sprd.h +0 -0
  int sprd_pinctrl_remove(struct platform_device *pdev);
  void sprd_pinctrl_shutdown(struct platform_device *pdev);
 
author
#4 lore raw

PATCH v2 2/6 pinctrl: sprd: Fix the incorrect mask and shift definition

In reply to Linhua Xu

From: Linhua Xu <[email protected]>

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.

---
 drivers/pinctrl/sprd/pinctrl-sprd.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/pinctrl/sprd/pinctrl-sprd.c +6 -6
index 25fb9ce9ad78..5b9126b2cde2 100644
@@ -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
Signature · 1 line
2.17.1
#5 lore raw

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

Quoted 5 lines · Linhua Xu

From: Linhua Xu <[email protected]>

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.

...

Quoted 12 lines

#define SLEEP_PULL_DOWN BIT(2)

drivers/pinctrl/sprd/pinctrl-sprd.c +2 -3
-#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

drivers/pinctrl/sprd/pinctrl-sprd.c line 75

Quoted 10 lines
drivers/pinctrl/sprd/pinctrl-sprd.c +4 -3
-#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)

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#6 lore raw

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

In reply to Linhua Xu
Quoted 30 lines · Linhua Xu

From: Linhua Xu <[email protected]>

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.

---
  drivers/pinctrl/sprd/pinctrl-sprd.c | 12 ++++++------
  1 file changed, 6 insertions(+), 6 deletions(-)
drivers/pinctrl/sprd/pinctrl-sprd.c +2 -3
index 25fb9ce9ad78..5b9126b2cde2 100644
@@ -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

drivers/pinctrl/sprd/pinctrl-sprd.c line 75

Quoted 10 lines
drivers/pinctrl/sprd/pinctrl-sprd.c +4 -3
-#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.

Quoted 3 lines
drivers/pinctrl/sprd/pinctrl-sprd.c +0 -0
  #define INPUT_SCHMITT			BIT(11)
  #define INPUT_SCHMITT_MASK		0x1
#7 lore raw

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

In reply to Linhua Xu
Quoted 7 lines · Linhua Xu

From: Linhua Xu <[email protected]>

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.

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

author
#8 lore raw

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

In reply to Linhua Xu

From: Linhua Xu <[email protected]>

For UNISOC pin controller, there are three different configurations of pull-up drive current. Modify the 20K pull-up resistor configuration and add the 1.8K pull-up resistor configuration.

---
 drivers/pinctrl/sprd/pinctrl-sprd.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/pinctrl/sprd/pinctrl-sprd.c +6 -4
index 5b9126b2cde2..6c75e6b8d2ca 100644
@@ -69,7 +69,8 @@
 #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_1_8K			(BIT(12) | BIT(7))
+#define PULL_UP_4_7K			BIT(12)
 #define PULL_UP_20K			BIT(7)
 #define PULL_UP_MASK			(GENMASK(1, 0) | BIT(6))
 #define PULL_UP_SHIFT			6
@@ -499,7 +500,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_1_8K)))
 				return -EINVAL;
 
 			arg = 1;
@@ -701,6 +702,8 @@ static int sprd_pinconf_set(struct pinctrl_dev *pctldev, unsigned int pin_id,
 						val |= PULL_UP_20K;
 					else if (arg == 4700)
 						val |= PULL_UP_4_7K;
+					else if (arg == 1800)
+						val |= PULL_UP_1_8K;
 
 					mask = PULL_UP_MASK;
 					shift = PULL_UP_SHIFT;
@@ -712,8 +715,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_1_8K;
 				}
 				break;
 			case PIN_CONFIG_SLEEP_HARDWARE_STATE:
Signature · 1 line
2.17.1
#9 lore raw

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

Quoted 5 lines · Linhua Xu

From: Linhua Xu <[email protected]>

For UNISOC pin controller, there are three different configurations of pull-up drive current. Modify the 20K pull-up resistor configuration and add the 1.8K pull-up resistor configuration.

...

drivers/pinctrl/sprd/pinctrl-sprd.c line 73

Quoted 3 lines
drivers/pinctrl/sprd/pinctrl-sprd.c +2 -1
-#define PULL_UP_4_7K			(BIT(12) | BIT(7))
+#define PULL_UP_1_8K			(BIT(12) | BIT(7))
+#define PULL_UP_4_7K			BIT(12)

This looks like a real fix, please add Fixes tag and move the patch to be the first in the series.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#10 lore raw

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

In reply to Linhua Xu
Quoted 7 lines · Linhua Xu

From: Linhua Xu <[email protected]>

For UNISOC pin controller, there are three different configurations of pull-up drive current. Modify the 20K pull-up resistor configuration and add the 1.8K pull-up resistor configuration.

Please add a Fixes tag.

Quoted 19 lines
---
  drivers/pinctrl/sprd/pinctrl-sprd.c | 10 ++++++----
  1 file changed, 6 insertions(+), 4 deletions(-)
drivers/pinctrl/sprd/pinctrl-sprd.c +2 -1
index 5b9126b2cde2..6c75e6b8d2ca 100644
@@ -69,7 +69,8 @@
  #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_1_8K			(BIT(12) | BIT(7))
+#define PULL_UP_4_7K			BIT(12)
  #define PULL_UP_20K			BIT(7)
  #define PULL_UP_MASK			(GENMASK(1, 0) | BIT(6))
  #define PULL_UP_SHIFT			6

drivers/pinctrl/sprd/pinctrl-sprd.c static int sprd_pinconf_get(struct pinctrl_dev *pctldev, unsigned int pin_id, · line 503

Quoted 5 lines
drivers/pinctrl/sprd/pinctrl-sprd.c +1 -1
@@ -499,7 +500,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_1_8K)))

The math logic is correct, but the code is not readable now. Since we should mask all PULL UP configration, but the code only mask 'PULL_UP_1_8K'.

So changing to below will be more clear:
(reg & (PULL_DOWN | PULL_UP_4_7K | PULL_UP_20K | PULL_UP_1_8K)

Quoted 13 lines
drivers/pinctrl/sprd/pinctrl-sprd.c +2 -0
  				return -EINVAL;
 
  			arg = 1;
@@ -701,6 +702,8 @@ static int sprd_pinconf_set(struct pinctrl_dev *pctldev, unsigned int pin_id,
  						val |= PULL_UP_20K;
  					else if (arg == 4700)
  						val |= PULL_UP_4_7K;
+					else if (arg == 1800)
+						val |= PULL_UP_1_8K;
 
  					mask = PULL_UP_MASK;
  					shift = PULL_UP_SHIFT;

drivers/pinctrl/sprd/pinctrl-sprd.c static int sprd_pinconf_set(struct pinctrl_dev *pctldev, unsigned int pin_id, · line 718

Quoted 6 lines
drivers/pinctrl/sprd/pinctrl-sprd.c +1 -2
@@ -712,8 +715,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_1_8K;

ditto.

Quoted 3 lines
drivers/pinctrl/sprd/pinctrl-sprd.c +0 -0
  				}
  				break;
  			case PIN_CONFIG_SLEEP_HARDWARE_STATE:
author
#11 lore raw

PATCH v2 4/6 pinctrl: sprd: Add pinctrl support for UMS512

In reply to Linhua Xu

From: Linhua Xu <[email protected]>

Add the pin control driver for UNISOC UMS512 platform.

---
 drivers/pinctrl/sprd/Kconfig               |  11 +
 drivers/pinctrl/sprd/Makefile              |   1 +
 drivers/pinctrl/sprd/pinctrl-sprd-ums512.c | 878 +++++++++++++++++++++
 3 files changed, 890 insertions(+)
 create mode 100644 drivers/pinctrl/sprd/pinctrl-sprd-ums512.c
drivers/pinctrl/sprd/Kconfig +11 -0
index eef35d01b770..a2a653c63137 100644
@@ -19,3 +19,14 @@ config PINCTRL_SPRD_SC9860
 	select PINCTRL_SPRD
 	help
 	  Say Y here to enable Spreadtrum SC9860 pinctrl driver
+
+config PINCTRL_SPRD_UMS512
+	tristate "Spreadtrum ums512 pinctrl driver"
+	depends on ARCH_SPRD || COMPILE_TEST
+	select PINCTRL_SPRD
+	help
+	  Say Y here to enable Spreadtrum ums512 pinctrl driver
+	  Support pin function switching
+	  Support pin drive capability configuration
+	  Support pin pull-up and pull-down configuration
+	  Support pin pull-up and pull-down configuration during sleep
drivers/pinctrl/sprd/Makefile +1 -0
index 3d4989057739..e3509c2515c9 100644
@@ -1,3 +1,4 @@
 # SPDX-License-Identifier: GPL-2.0-only
 obj-$(CONFIG_PINCTRL_SPRD)		+= pinctrl-sprd.o
 obj-$(CONFIG_PINCTRL_SPRD_SC9860)	+= pinctrl-sprd-sc9860.o
+obj-$(CONFIG_PINCTRL_SPRD_UMS512)	+= pinctrl-sprd-ums512.o
drivers/pinctrl/sprd/pinctrl-sprd-ums512.c new file +878 -0

878 lines not on this page · raw message

Signature · 1 line
2.17.1
#12 lore raw

Re: [PATCH V2 4/6] pinctrl: sprd: Add pinctrl support for UMS512

kernel test robot noticed the following build errors:

Hi Linhua,

kernel test robot noticed the following build errors:

[auto build test ERROR on linusw-pinctrl/devel]
[also build test ERROR on linusw-pinctrl/for-next linus/master v6.5 next-20230908] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Linhua-Xu/pinctrl-sprd-Modify-the-probe-function-parameters/20230908-135519
base:   https://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-pinctrl.git devel
patch link:    https://lore.kernel.org/r/20230908055146.18347-5-Linhua.xu%40unisoc.com
patch subject: [PATCH V2 4/6] pinctrl: sprd: Add pinctrl support for UMS512
config: alpha-randconfig-r011-20230909 (https://download.01.org/0day-ci/archive/20230909/[email protected]/config)
compiler: alpha-linux-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20230909/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

drivers/pinctrl/sprd/pinctrl-sprd.c: In function 'sprd_dt_node_to_map':

>> drivers/pinctrl/sprd/pinctrl-sprd.c:287:15: error: implicit declaration of function 'pinconf_generic_parse_dt_config'; did you mean 'pinconf_generic_dump_config'? [-Werror=implicit-function-declaration]
     287 |         ret = pinconf_generic_parse_dt_config(np, pctldev, &configs,
         |               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         |               pinconf_generic_dump_config

cc1: some warnings being treated as errors

vim +287 drivers/pinctrl/sprd/pinctrl-sprd.c

41d32cfce1ae616 Baolin Wang 2017-08-17  246  
41d32cfce1ae616 Baolin Wang 2017-08-17  247  static int sprd_dt_node_to_map(struct pinctrl_dev *pctldev,
41d32cfce1ae616 Baolin Wang 2017-08-17  248  			       struct device_node *np,
41d32cfce1ae616 Baolin Wang 2017-08-17  249  			       struct pinctrl_map **map,
41d32cfce1ae616 Baolin Wang 2017-08-17  250  			       unsigned int *num_maps)
41d32cfce1ae616 Baolin Wang 2017-08-17  251  {
41d32cfce1ae616 Baolin Wang 2017-08-17  252  	struct sprd_pinctrl *pctl = pinctrl_dev_get_drvdata(pctldev);
41d32cfce1ae616 Baolin Wang 2017-08-17  253  	const struct sprd_pin_group *grp;
41d32cfce1ae616 Baolin Wang 2017-08-17  254  	unsigned long *configs = NULL;
41d32cfce1ae616 Baolin Wang 2017-08-17  255  	unsigned int num_configs = 0;
41d32cfce1ae616 Baolin Wang 2017-08-17  256  	unsigned int reserved_maps = 0;
41d32cfce1ae616 Baolin Wang 2017-08-17  257  	unsigned int reserve = 0;
41d32cfce1ae616 Baolin Wang 2017-08-17  258  	const char *function;
41d32cfce1ae616 Baolin Wang 2017-08-17  259  	enum pinctrl_map_type type;
41d32cfce1ae616 Baolin Wang 2017-08-17  260  	int ret;
41d32cfce1ae616 Baolin Wang 2017-08-17  261  
41d32cfce1ae616 Baolin Wang 2017-08-17  262  	grp = sprd_pinctrl_find_group_by_name(pctl, np->name);
41d32cfce1ae616 Baolin Wang 2017-08-17  263  	if (!grp) {
41d32cfce1ae616 Baolin Wang 2017-08-17  264  		dev_err(pctl->dev, "unable to find group for node %s\n",
41d32cfce1ae616 Baolin Wang 2017-08-17  265  			of_node_full_name(np));
41d32cfce1ae616 Baolin Wang 2017-08-17  266  		return -EINVAL;
41d32cfce1ae616 Baolin Wang 2017-08-17  267  	}
41d32cfce1ae616 Baolin Wang 2017-08-17  268  
41d32cfce1ae616 Baolin Wang 2017-08-17  269  	ret = of_property_count_strings(np, "pins");
41d32cfce1ae616 Baolin Wang 2017-08-17  270  	if (ret < 0)
41d32cfce1ae616 Baolin Wang 2017-08-17  271  		return ret;
41d32cfce1ae616 Baolin Wang 2017-08-17  272  
41d32cfce1ae616 Baolin Wang 2017-08-17  273  	if (ret == 1)
41d32cfce1ae616 Baolin Wang 2017-08-17  274  		type = PIN_MAP_TYPE_CONFIGS_PIN;
41d32cfce1ae616 Baolin Wang 2017-08-17  275  	else
41d32cfce1ae616 Baolin Wang 2017-08-17  276  		type = PIN_MAP_TYPE_CONFIGS_GROUP;
41d32cfce1ae616 Baolin Wang 2017-08-17  277  
41d32cfce1ae616 Baolin Wang 2017-08-17  278  	ret = of_property_read_string(np, "function", &function);
41d32cfce1ae616 Baolin Wang 2017-08-17  279  	if (ret < 0) {
41d32cfce1ae616 Baolin Wang 2017-08-17  280  		if (ret != -EINVAL)
41d32cfce1ae616 Baolin Wang 2017-08-17  281  			dev_err(pctl->dev,
41d32cfce1ae616 Baolin Wang 2017-08-17  282  				"%s: could not parse property function\n",
41d32cfce1ae616 Baolin Wang 2017-08-17  283  				of_node_full_name(np));
41d32cfce1ae616 Baolin Wang 2017-08-17  284  		function = NULL;
41d32cfce1ae616 Baolin Wang 2017-08-17  285  	}
41d32cfce1ae616 Baolin Wang 2017-08-17  286  
41d32cfce1ae616 Baolin Wang 2017-08-17 @287  	ret = pinconf_generic_parse_dt_config(np, pctldev, &configs,
41d32cfce1ae616 Baolin Wang 2017-08-17  288  					      &num_configs);
41d32cfce1ae616 Baolin Wang 2017-08-17  289  	if (ret < 0) {
41d32cfce1ae616 Baolin Wang 2017-08-17  290  		dev_err(pctl->dev, "%s: could not parse node property\n",
41d32cfce1ae616 Baolin Wang 2017-08-17  291  			of_node_full_name(np));
41d32cfce1ae616 Baolin Wang 2017-08-17  292  		return ret;
41d32cfce1ae616 Baolin Wang 2017-08-17  293  	}
41d32cfce1ae616 Baolin Wang 2017-08-17  294  
41d32cfce1ae616 Baolin Wang 2017-08-17  295  	*map = NULL;
41d32cfce1ae616 Baolin Wang 2017-08-17  296  	*num_maps = 0;
41d32cfce1ae616 Baolin Wang 2017-08-17  297  
41d32cfce1ae616 Baolin Wang 2017-08-17  298  	if (function != NULL)
41d32cfce1ae616 Baolin Wang 2017-08-17  299  		reserve++;
41d32cfce1ae616 Baolin Wang 2017-08-17  300  	if (num_configs)
41d32cfce1ae616 Baolin Wang 2017-08-17  301  		reserve++;
41d32cfce1ae616 Baolin Wang 2017-08-17  302  
41d32cfce1ae616 Baolin Wang 2017-08-17  303  	ret = pinctrl_utils_reserve_map(pctldev, map, &reserved_maps,
41d32cfce1ae616 Baolin Wang 2017-08-17  304  					num_maps, reserve);
41d32cfce1ae616 Baolin Wang 2017-08-17  305  	if (ret < 0)
41d32cfce1ae616 Baolin Wang 2017-08-17  306  		goto out;
41d32cfce1ae616 Baolin Wang 2017-08-17  307  
41d32cfce1ae616 Baolin Wang 2017-08-17  308  	if (function) {
41d32cfce1ae616 Baolin Wang 2017-08-17  309  		ret = pinctrl_utils_add_map_mux(pctldev, map,
41d32cfce1ae616 Baolin Wang 2017-08-17  310  						&reserved_maps, num_maps,
41d32cfce1ae616 Baolin Wang 2017-08-17  311  						grp->name, function);
41d32cfce1ae616 Baolin Wang 2017-08-17  312  		if (ret < 0)
41d32cfce1ae616 Baolin Wang 2017-08-17  313  			goto out;
41d32cfce1ae616 Baolin Wang 2017-08-17  314  	}
41d32cfce1ae616 Baolin Wang 2017-08-17  315  
41d32cfce1ae616 Baolin Wang 2017-08-17  316  	if (num_configs) {
41d32cfce1ae616 Baolin Wang 2017-08-17  317  		const char *group_or_pin;
41d32cfce1ae616 Baolin Wang 2017-08-17  318  		unsigned int pin_id;
41d32cfce1ae616 Baolin Wang 2017-08-17  319  
41d32cfce1ae616 Baolin Wang 2017-08-17  320  		if (type == PIN_MAP_TYPE_CONFIGS_PIN) {
41d32cfce1ae616 Baolin Wang 2017-08-17  321  			pin_id = grp->pins[0];
41d32cfce1ae616 Baolin Wang 2017-08-17  322  			group_or_pin = pin_get_name(pctldev, pin_id);
41d32cfce1ae616 Baolin Wang 2017-08-17  323  		} else {
41d32cfce1ae616 Baolin Wang 2017-08-17  324  			group_or_pin = grp->name;
41d32cfce1ae616 Baolin Wang 2017-08-17  325  		}
41d32cfce1ae616 Baolin Wang 2017-08-17  326  
41d32cfce1ae616 Baolin Wang 2017-08-17  327  		ret = pinctrl_utils_add_map_configs(pctldev, map,
41d32cfce1ae616 Baolin Wang 2017-08-17  328  						    &reserved_maps, num_maps,
41d32cfce1ae616 Baolin Wang 2017-08-17  329  						    group_or_pin, configs,
41d32cfce1ae616 Baolin Wang 2017-08-17  330  						    num_configs, type);
41d32cfce1ae616 Baolin Wang 2017-08-17  331  	}
41d32cfce1ae616 Baolin Wang 2017-08-17  332  
41d32cfce1ae616 Baolin Wang 2017-08-17  333  out:
41d32cfce1ae616 Baolin Wang 2017-08-17  334  	kfree(configs);
41d32cfce1ae616 Baolin Wang 2017-08-17  335  	return ret;
41d32cfce1ae616 Baolin Wang 2017-08-17  336  }
41d32cfce1ae616 Baolin Wang 2017-08-17  337  
Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
#13 lore raw

Re: [PATCH V2 4/6] pinctrl: sprd: Add pinctrl support for UMS512

In reply to Linhua Xu
Quoted 3 lines · Linhua Xu

From: Linhua Xu <[email protected]>

Add the pin control driver for UNISOC UMS512 platform.

...

Quoted 1 line

+#define PINCTRL_REG_OFFSET 0x34

0x0034

Quoted 1 line

+#define PINCTRL_REG_MISC_OFFSET 0x434

...

drivers/pinctrl/sprd/pinctrl-sprd-ums512.c line 860

Quoted 2 lines
drivers/pinctrl/sprd/pinctrl-sprd-ums512.c new file +2 -0
+static const struct of_device_id sprd_pinctrl_of_match[] = {
+	{ .compatible = "sprd,ums512-pinctrl", },

Inner comma is not needed.

Quoted 2 lines
(quoted diff) +2 -0
+	{ }
+};
Signature · 2 lines
With Best Regards,
Andy Shevchenko
author
#14 lore raw

PATCH v2 5/6 pinctrl: sprd: Increase the range of register values

In reply to Linhua Xu

From: Linhua Xu <[email protected]>

As the UNISOC pin controller version iterates, more registers are required to meet new functional requirements. Thus modify them.

---
 drivers/pinctrl/sprd/pinctrl-sprd.h | 30 +++++++++++++++--------------
 1 file changed, 16 insertions(+), 14 deletions(-)
drivers/pinctrl/sprd/pinctrl-sprd.h +16 -14
index a696f81ce663..5357874186fd 100644
@@ -7,30 +7,32 @@
 #ifndef __PINCTRL_SPRD_H__
 #define __PINCTRL_SPRD_H__
 
+#include <linux/bits.h>
+
 struct platform_device;
 
-#define NUM_OFFSET	(20)
-#define TYPE_OFFSET	(16)
-#define BIT_OFFSET	(8)
-#define WIDTH_OFFSET	(4)
+#define NUM_OFFSET	22
+#define TYPE_OFFSET	18
+#define BIT_OFFSET	10
+#define WIDTH_OFFSET	6
 
 #define SPRD_PIN_INFO(num, type, offset, width, reg)	\
-		(((num) & 0xFFF) << NUM_OFFSET |	\
-		 ((type) & 0xF) << TYPE_OFFSET |	\
-		 ((offset) & 0xFF) << BIT_OFFSET |	\
-		 ((width) & 0xF) << WIDTH_OFFSET |	\
-		 ((reg) & 0xF))
+		(((num) & GENMASK(10, 0)) << NUM_OFFSET |	\
+		 ((type) & GENMASK(3, 0)) << TYPE_OFFSET |	\
+		 ((offset) & GENMASK(7, 0)) << BIT_OFFSET |	\
+		 ((width) & GENMASK(3, 0)) << WIDTH_OFFSET |	\
+		 ((reg) & GENMASK(5, 0)))
 
 #define SPRD_PINCTRL_PIN(pin)	SPRD_PINCTRL_PIN_DATA(pin, #pin)
 
 #define SPRD_PINCTRL_PIN_DATA(a, b)				\
 	{							\
 		.name = b,					\
-		.num = (((a) >> NUM_OFFSET) & 0xfff),		\
-		.type = (((a) >> TYPE_OFFSET) & 0xf),		\
-		.bit_offset = (((a) >> BIT_OFFSET) & 0xff),	\
-		.bit_width = ((a) >> WIDTH_OFFSET & 0xf),	\
-		.reg = ((a) & 0xf)				\
+		.num = (((a) & GENMASK(31, 22)) >> NUM_OFFSET),	\
+		.type = (((a) & GENMASK(21, 18)) >> TYPE_OFFSET),	\
+		.bit_offset = (((a) & GENMASK(17, 10)) >> BIT_OFFSET),	\
+		.bit_width = (((a) & GENMASK(9, 6)) >> WIDTH_OFFSET),	\
+		.reg = ((a) & GENMASK(5, 0))				\
 	}
 
 enum pin_type {
Signature · 1 line
2.17.1
Reviewed-by on v2 5/6
#15 lore raw

Re: [PATCH V2 5/6] pinctrl: sprd: Increase the range of register values

Quoted 4 lines · Linhua Xu

From: Linhua Xu <[email protected]>

As the UNISOC pin controller version iterates, more registers are required to meet new functional requirements. Thus modify them.

LGTM,

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#16 lore raw

Re: [PATCH V2 5/6] pinctrl: sprd: Increase the range of register values

In reply to Linhua Xu
Quoted 32 lines · Linhua Xu

From: Linhua Xu <[email protected]>

As the UNISOC pin controller version iterates, more registers are required to meet new functional requirements. Thus modify them.

---
  drivers/pinctrl/sprd/pinctrl-sprd.h | 30 +++++++++++++++--------------
  1 file changed, 16 insertions(+), 14 deletions(-)
drivers/pinctrl/sprd/pinctrl-sprd.h +6 -4
index a696f81ce663..5357874186fd 100644
@@ -7,30 +7,32 @@
  #ifndef __PINCTRL_SPRD_H__
  #define __PINCTRL_SPRD_H__
 
+#include <linux/bits.h>
+
  struct platform_device;
 
-#define NUM_OFFSET	(20)
-#define TYPE_OFFSET	(16)
-#define BIT_OFFSET	(8)
-#define WIDTH_OFFSET	(4)
+#define NUM_OFFSET	22
+#define TYPE_OFFSET	18
+#define BIT_OFFSET	10
+#define WIDTH_OFFSET	6
 
  #define SPRD_PIN_INFO(num, type, offset, width, reg)	\

drivers/pinctrl/sprd/pinctrl-sprd.h line 24

Quoted 10 lines
drivers/pinctrl/sprd/pinctrl-sprd.h +5 -5
-		(((num) & 0xFFF) << NUM_OFFSET |	\
-		 ((type) & 0xF) << TYPE_OFFSET |	\
-		 ((offset) & 0xFF) << BIT_OFFSET |	\
-		 ((width) & 0xF) << WIDTH_OFFSET |	\
-		 ((reg) & 0xF))
+		(((num) & GENMASK(10, 0)) << NUM_OFFSET |	\
+		 ((type) & GENMASK(3, 0)) << TYPE_OFFSET |	\
+		 ((offset) & GENMASK(7, 0)) << BIT_OFFSET |	\
+		 ((width) & GENMASK(3, 0)) << WIDTH_OFFSET |	\
+		 ((reg) & GENMASK(5, 0)))

Can you define some readable macro for the mask bits?

Quoted 6 lines
drivers/pinctrl/sprd/pinctrl-sprd.h +0 -0
  #define SPRD_PINCTRL_PIN(pin)	SPRD_PINCTRL_PIN_DATA(pin, #pin)
 
  #define SPRD_PINCTRL_PIN_DATA(a, b)				\
  	{							\
  		.name = b,					\

drivers/pinctrl/sprd/pinctrl-sprd.h line 35

Quoted 10 lines
drivers/pinctrl/sprd/pinctrl-sprd.h +5 -5
-		.num = (((a) >> NUM_OFFSET) & 0xfff),		\
-		.type = (((a) >> TYPE_OFFSET) & 0xf),		\
-		.bit_offset = (((a) >> BIT_OFFSET) & 0xff),	\
-		.bit_width = ((a) >> WIDTH_OFFSET & 0xf),	\
-		.reg = ((a) & 0xf)				\
+		.num = (((a) & GENMASK(31, 22)) >> NUM_OFFSET),	\
+		.type = (((a) & GENMASK(21, 18)) >> TYPE_OFFSET),	\
+		.bit_offset = (((a) & GENMASK(17, 10)) >> BIT_OFFSET),	\
+		.bit_width = (((a) & GENMASK(9, 6)) >> WIDTH_OFFSET),	\
+		.reg = ((a) & GENMASK(5, 0))				\

Please keep the same logic operation as before, and you can reuse the readable macros if you defined.

Quoted 3 lines
drivers/pinctrl/sprd/pinctrl-sprd.h +0 -0
  	}
 
  enum pin_type {

A message that is not in the archive (sent off-list or not yet received): CAPjKKSrs9X2msnDg=9rC8H57Dq8FPd7SWyBsr2MCwL0FMNkHPA@mail.gmail.com

#18 lore raw

Re: [PATCH V2 5/6] pinctrl: sprd: Increase the range of register values

Quoted 55 lines · xu lh
Quoted 52 lines · Baolin Wang
Quoted 3 lines · Linhua Xu

From: Linhua Xu <[email protected]>

As the UNISOC pin controller version iterates, more registers are

required

Review

Quoted 8 lines

to meet new functional requirements. Thus modify them.

---
   drivers/pinctrl/sprd/pinctrl-sprd.h | 30 +++++++++++++++--------------
   1 file changed, 16 insertions(+), 14 deletions(-)
(quoted diff) +0 -0

b/drivers/pinctrl/sprd/pinctrl-sprd.h

Quoted 21 lines

index a696f81ce663..5357874186fd 100644

drivers/pinctrl/sprd/pinctrl-sprd.h +6 -4
@@ -7,30 +7,32 @@
   #ifndef __PINCTRL_SPRD_H__
   #define __PINCTRL_SPRD_H__
 
+#include <linux/bits.h>
+
   struct platform_device;
 
-#define NUM_OFFSET   (20)
-#define TYPE_OFFSET  (16)
-#define BIT_OFFSET   (8)
-#define WIDTH_OFFSET (4)
+#define NUM_OFFSET   22
+#define TYPE_OFFSET  18
+#define BIT_OFFSET   10
+#define WIDTH_OFFSET 6
 
   #define SPRD_PIN_INFO(num, type, offset, width, reg)        \

drivers/pinctrl/sprd/pinctrl-sprd.h line 24

Quoted 10 lines
drivers/pinctrl/sprd/pinctrl-sprd.h +5 -5
-             (((num) & 0xFFF) << NUM_OFFSET |        \
-              ((type) & 0xF) << TYPE_OFFSET |        \
-              ((offset) & 0xFF) << BIT_OFFSET |      \
-              ((width) & 0xF) << WIDTH_OFFSET |      \
-              ((reg) & 0xF))
+             (((num) & GENMASK(10, 0)) << NUM_OFFSET |       \
+              ((type) & GENMASK(3, 0)) << TYPE_OFFSET |      \
+              ((offset) & GENMASK(7, 0)) << BIT_OFFSET |     \
+              ((width) & GENMASK(3, 0)) << WIDTH_OFFSET |    \
+              ((reg) & GENMASK(5, 0)))

Can you define some readable macro for the mask bits?

Quoted 1 line

okay. Do you think the following modification is okay?

Review

Quoted 5 lines
(quoted diff) +5 -0
+#define PIN_ID         GENMASK(10, 0)
+#define PIN_TYPE       GENMASK(3, 0)
+#define FIELD_OFFSET   GENMASK(7, 0)
+#define FIELD_WIDTH    GENMASK(3, 0)
+#define PIN_REG                GENMASK(5, 0)

Looks better. To keep consistent, I perfer to something as below:
#define NUM_MASK xxx
#define TYPE_MASK xxx
#define BIT_MASK xxx
#define WIDTH_MASK xxx
#define REG_MASK xxx

author
#19 lore raw

PATCH v2 6/6 pinctrl: sprd: Add pinctrl support for UMS9621

In reply to Linhua Xu

From: Linhua Xu <[email protected]>

Add the pin control driver for UNISOC UMS9621 platform.

---
 drivers/pinctrl/sprd/Kconfig                |   11 +
 drivers/pinctrl/sprd/Makefile               |    1 +
 drivers/pinctrl/sprd/pinctrl-sprd-ums9621.c | 1117 +++++++++++++++++++
 3 files changed, 1129 insertions(+)
 create mode 100644 drivers/pinctrl/sprd/pinctrl-sprd-ums9621.c
drivers/pinctrl/sprd/Kconfig +11 -0
index a2a653c63137..b57f0555dfa6 100644
@@ -30,3 +30,14 @@ config PINCTRL_SPRD_UMS512
 	  Support pin drive capability configuration
 	  Support pin pull-up and pull-down configuration
 	  Support pin pull-up and pull-down configuration during sleep
+
+config PINCTRL_SPRD_UMS9621
+	tristate "Spreadtrum ums9621 pinctrl driver"
+	depends on ARCH_SPRD || COMPILE_TEST
+	select PINCTRL_SPRD
+	help
+	  Say Y here to enable Spreadtrum ums512 pinctrl driver
+	  Support pin function switching
+	  Support pin drive capability configuration
+	  Support pin pull-up and pull-down configuration
+	  Support pin pull-up and pull-down configuration during sleep
drivers/pinctrl/sprd/Makefile +1 -0
index e3509c2515c9..6c1946c664b7 100644
@@ -2,3 +2,4 @@
 obj-$(CONFIG_PINCTRL_SPRD)		+= pinctrl-sprd.o
 obj-$(CONFIG_PINCTRL_SPRD_SC9860)	+= pinctrl-sprd-sc9860.o
 obj-$(CONFIG_PINCTRL_SPRD_UMS512)	+= pinctrl-sprd-ums512.o
+obj-$(CONFIG_PINCTRL_SPRD_UMS9621)	+= pinctrl-sprd-ums9621.o
drivers/pinctrl/sprd/pinctrl-sprd-ums9621.c new file +1117 -0

1,117 lines not on this page · raw message

Signature · 1 line
2.17.1
#20 lore raw

Re: [PATCH V2 6/6] pinctrl: sprd: Add pinctrl support for UMS9621

Quoted 9 lines · Linhua Xu

From: Linhua Xu <[email protected]>

Add the pin control driver for UNISOC UMS9621 platform.

drivers/pinctrl/sprd/pinctrl-sprd-ums9621.c new file +5 -0
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/mod_devicetable.h>
+#include <linux/platform_device.h>
+

...

Quoted 1 line

+#define PINCTRL_REG_OFFSET 0x44

0x0044

Quoted 1 line

+#define PINCTRL_REG_MISC_OFFSET 0x444

...

drivers/pinctrl/sprd/pinctrl-sprd-ums9621.c line 1099

Quoted 2 lines
drivers/pinctrl/sprd/pinctrl-sprd-ums9621.c new file +2 -0
+static const struct of_device_id sprd_pinctrl_of_match[] = {
+	{ .compatible = "sprd,ums9621-pinctrl", },

Inner comma is not needed.

Quoted 2 lines
(quoted diff) +2 -0
+	{ }
+};
Signature · 2 lines
With Best Regards,
Andy Shevchenko
#21 lore raw
In reply to Linhua Xu
Quoted 9 lines · Linhua Xu

From: Linhua Xu <[email protected]>

Recently, some bugs have been discovered during use, and patch2 and patch3 are bug fixes. Also, this patchset add new features: patch1 is for compatibility with more platforms, patch4 add pinctrl support for UMS512, patch5 Increase the range of register values, patch6 add pinctrl support for UMS9621.

change in V2

V2 is starting to look good, please address Andy's comments, especially move the fixes first in the series so they can be queued as fixes if need be.

I would really appreciate if Baolin can review the patches as well as he knows this hardware very well and wrote the initial version.

Yours,
Linus Walleij

#22 lore raw
Quoted 10 lines · Linus Walleij
Quoted 8 lines · Linhua Xu

From: Linhua Xu <[email protected]>

Recently, some bugs have been discovered during use, and patch2 and patch3 are bug fixes. Also, this patchset add new features: patch1 is for compatibility with more platforms, patch4 add pinctrl support for UMS512, patch5 Increase the range of register values, patch6 add pinctrl support for UMS9621.

Quoted 5 lines
Quoted 1 line

change in V2

V2 is starting to look good, please address Andy's comments, especially move the fixes first in the series so they can be queued as fixes if need be.

Yes, agree. Please send the fix patches separately with proper Fixes tag.

Quoted 3 lines

I would really appreciate if Baolin can review the patches as well as he knows this hardware very well and wrote the initial version.

Sure.