Skip to contentSkip to conversation

Add compatible support for RT5733

PATCH In review [email protected] 3 participants 8 messages Jun 29, 2023 – Jul 12, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

v2 cover Add compatible support for RT5733

From: ChiYuan Huang <[email protected]>

This series is to add the compatible support for rt5733 based on rt5739.

Version change listed below each comment message.

ChiYuan Huang (2):
regulator: dt-bindings: rt5739: Add compatible for rt5733
regulator: rt5739: Add DID check and compatible for rt5733

 .../bindings/regulator/richtek,rt5739.yaml    |  1 +
 drivers/regulator/rt5739.c                    | 36 +++++++++++++++----
 2 files changed, 30 insertions(+), 7 deletions(-)

base-commit: 6995e2de6891c724bfeb2db33d7b87775f913ad1

Signature · 1 line
2.40.1
#1 lore raw

PATCH v2 1/2 regulator: dt-bindings: rt5739: Add compatible for rt5733

From: ChiYuan Huang <[email protected]>

Add compatible string for rt5733.

---
 Documentation/devicetree/bindings/regulator/richtek,rt5739.yaml | 1 +
 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/regulator/richtek,rt5739.yaml +1 -0
index 358297dd3fb7..e95e046e9ed6 100644
@@ -21,6 +21,7 @@ allOf:
 properties:
   compatible:
     enum:
+      - richtek,rt5733
       - richtek,rt5739
 
   reg:
Signature · 1 line
2.40.1
#2 lore raw

PATCH v2 2/2 regulator: rt5739: Add DID check and compatible for rt5733

In reply to [email protected]

From: ChiYuan Huang <[email protected]>

Add compatible and use DID to check rt5733.

The only difference bwtween rt5733 and rt5739 is the output range and voltage step. These two chips can be distinguished from the DIE id.

---
v2:
- Remove DID check in 'set_suspend_voltage' callback, use desc member to check min/max and vsel calculation
- Use switch case to check DID for the future variation

---
 drivers/regulator/rt5739.c | 36 +++++++++++++++++++++++++++++-------
 1 file changed, 29 insertions(+), 7 deletions(-)
drivers/regulator/rt5739.c +29 -7
index 74fc5bf6d87e..ca5f9b05331c 100644
@@ -31,10 +31,17 @@
 #define RT5739_MODEVSEL1_MASK	BIT(1)
 #define RT5739_MODEVSEL0_MASK	BIT(0)
 #define RT5739_VID_MASK		GENMASK(7, 5)
+#define RT5739_DID_MASK		GENMASK(3, 0)
 #define RT5739_ACTD_MASK	BIT(7)
 #define RT5739_ENVSEL1_MASK	BIT(1)
 #define RT5739_ENVSEL0_MASK	BIT(0)
 
+#define RT5733_CHIPDIE_ID	0x1
+#define RT5733_VOLT_MINUV	270000
+#define RT5733_VOLT_MAXUV	1401250
+#define RT5733_VOLT_STPUV	6250
+#define RT5733_N_VOLTS		182
+
 #define RT5739_VOLT_MINUV	300000
 #define RT5739_VOLT_MAXUV	1300000
 #define RT5739_VOLT_STPUV	5000
@@ -93,8 +100,11 @@ static int rt5739_set_suspend_voltage(struct regulator_dev *rdev, int uV)
 	const struct regulator_desc *desc = rdev->desc;
 	struct regmap *regmap = rdev_get_regmap(rdev);
 	unsigned int reg, vsel;
+	int max_uV;
+
+	max_uV = desc->min_uV + desc->uV_step * (desc->n_voltages - 1);
 
-	if (uV < RT5739_VOLT_MINUV || uV > RT5739_VOLT_MAXUV)
+	if (uV < desc->min_uV || uV > max_uV)
 		return -EINVAL;
 
 	if (desc->vsel_reg == RT5739_REG_NSEL0)
@@ -102,7 +112,7 @@ static int rt5739_set_suspend_voltage(struct regulator_dev *rdev, int uV)
 	else
 		reg = RT5739_REG_NSEL0;
 
-	vsel = (uV - RT5739_VOLT_MINUV) / RT5739_VOLT_STPUV;
+	vsel = (uV - desc->min_uV) / desc->uV_step;
 	return regmap_write(regmap, reg, vsel);
 }
 
@@ -189,15 +199,12 @@ static unsigned int rt5739_of_map_mode(unsigned int mode)
 }
 
 static void rt5739_init_regulator_desc(struct regulator_desc *desc,
-				       bool vsel_active_high)
+				       bool vsel_active_high, u8 did)
 {
 	/* Fixed */
 	desc->name = "rt5739-regulator";
 	desc->owner = THIS_MODULE;
 	desc->ops = &rt5739_regulator_ops;
-	desc->n_voltages = RT5739_N_VOLTS;
-	desc->min_uV = RT5739_VOLT_MINUV;
-	desc->uV_step = RT5739_VOLT_STPUV;
 	desc->vsel_mask = RT5739_VSEL_MASK;
 	desc->enable_reg = RT5739_REG_CNTL2;
 	desc->active_discharge_reg = RT5739_REG_CNTL1;
@@ -213,6 +220,20 @@ static void rt5739_init_regulator_desc(struct regulator_desc *desc,
 		desc->vsel_reg = RT5739_REG_NSEL0;
 		desc->enable_mask = RT5739_ENVSEL0_MASK;
 	}
+
+	/* Assigned by CHIPDIE ID */
+	switch (did) {
+	case RT5733_CHIPDIE_ID:
+		desc->n_voltages = RT5733_N_VOLTS;
+		desc->min_uV = RT5733_VOLT_MINUV;
+		desc->uV_step = RT5733_VOLT_STPUV;
+		break;
+	default:
+		desc->n_voltages = RT5739_N_VOLTS;
+		desc->min_uV = RT5739_VOLT_MINUV;
+		desc->uV_step = RT5739_VOLT_STPUV;
+		break;
+	}
 }
 
 static const struct regmap_config rt5739_regmap_config = {
@@ -258,7 +279,7 @@ static int rt5739_probe(struct i2c_client *i2c)
 
 	vsel_acth = device_property_read_bool(dev, "richtek,vsel-active-high");
 
-	rt5739_init_regulator_desc(desc, vsel_acth);
+	rt5739_init_regulator_desc(desc, vsel_acth, vid & RT5739_DID_MASK);
 
 	cfg.dev = dev;
 	cfg.of_node = dev_of_node(dev);
@@ -271,6 +292,7 @@ static int rt5739_probe(struct i2c_client *i2c)
 }
 
 static const struct of_device_id rt5739_device_table[] = {
+	{ .compatible = "richtek,rt5733" },
 	{ .compatible = "richtek,rt5739" },
 	{ /* sentinel */ }
 };
Signature · 1 line
2.40.1
#3 lore raw
In reply to [email protected]

On Thu, Jun 29, 2023 at 10:29:54PM +0800, [email protected] wrote:
Hi,

Quoted 4 lines

From: ChiYuan Huang <[email protected]>

This series is to add the compatible support for rt5733 based on rt5739.

Sorry, not intend to ping, just want to check the current review status.

Any comment about this patch series?

Quoted 15 lines

Version change listed below each comment message.

ChiYuan Huang (2):
regulator: dt-bindings: rt5739: Add compatible for rt5733
regulator: rt5739: Add DID check and compatible for rt5733

 .../bindings/regulator/richtek,rt5739.yaml    |  1 +
 drivers/regulator/rt5739.c                    | 36 +++++++++++++++----
 2 files changed, 30 insertions(+), 7 deletions(-)

base-commit: 6995e2de6891c724bfeb2db33d7b87775f913ad1

Signature · 1 line
2.40.1
#4 lore raw
Quoted 9 lines · ChiYuan Huang

On Thu, Jun 29, 2023 at 10:29:54PM +0800, [email protected] wrote:
Hi,

Quoted 4 lines

From: ChiYuan Huang <[email protected]>

This series is to add the compatible support for rt5733 based on rt5739.

Sorry, not intend to ping, just want to check the current review status.

Any comment about this patch series?

You sent it during merge window, so what do you expect? What should happen during the merge window?

Best regards,
Krzysztof

#5 lore raw
Quoted 5 lines · Krzysztof Kozlowski
Quoted 4 lines · ChiYuan Huang

On Thu, Jun 29, 2023 at 10:29:54PM +0800, [email protected] wrote:
Hi,

Quoted 2 lines

From: ChiYuan Huang <[email protected]>

Quoted 9 lines
Quoted 5 lines
Quoted 2 lines

This series is to add the compatible support for rt5733 based on rt5739.

Sorry, not intend to ping, just want to check the current review status.

Any comment about this patch series?

You sent it during merge window, so what do you expect? What should happen during the merge window?

Since I do not know it's merge windows period, sorry to bother you guys.

Thanks for the notice.

Quoted 3 lines

Best regards,
Krzysztof

#6 lore raw
Quoted 8 lines · ChiYuan Huang
Quoted 7 lines · Krzysztof Kozlowski
Quoted 6 lines · ChiYuan Huang

On Thu, Jun 29, 2023 at 10:29:54PM +0800, [email protected] wrote:
Hi,

Quoted 4 lines

From: ChiYuan Huang <[email protected]>

This series is to add the compatible support for rt5733 based on rt5739.

Quoted 9 lines
Quoted 7 lines
Quoted 3 lines

Sorry, not intend to ping, just want to check the current review status.

Any comment about this patch series?

You sent it during merge window, so what do you expect? What should happen during the merge window?

Since I do not know it's merge windows period, sorry to bother you guys.

Release of Linux kernel (so v6.4) is the opening of merge window. You can also check here:
https://phb-crystal-ball.sipsolutions.net/

Best regards,
Krzysztof

maintainer
#7 lore raw
In reply to [email protected]
Quoted 9 lines · On Thu, 29 Jun 2023 22:29:54 +0800, [email protected] wrote:

This series is to add the compatible support for rt5733 based on rt5739.

Version change listed below each comment message.

ChiYuan Huang (2):
regulator: dt-bindings: rt5739: Add compatible for rt5733
regulator: rt5739: Add DID check and compatible for rt5733

[...]

Applied to

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git for-next

Thanks!

[1/2] regulator: dt-bindings: rt5739: Add compatible for rt5733

      commit: 8978af5ef662541bc0a5a7722ad6942cd19daed0
[2/2] regulator: rt5739: Add DID check and compatible for rt5733
      commit: 6f5e285839845729858b8f6ca7cf3dd35e1f9a29

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark