linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] add rt6166 vout min_uv setting for compatible
@ 2025-07-15  6:50 jeff_chang
  2025-07-15 12:28 ` Mark Brown
  0 siblings, 1 reply; 2+ messages in thread
From: jeff_chang @ 2025-07-15  6:50 UTC (permalink / raw)
  To: lgirdwood, broonie, linux-kernel; +Cc: jeff_chang

From: Jeff Chang <jeff_chang@richtek.com>

Signed-off-by: Jeff Chang <jeff_chang@richtek.com>
---
 drivers/regulator/rt6160-regulator.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/drivers/regulator/rt6160-regulator.c b/drivers/regulator/rt6160-regulator.c
index e2a0eee95c61..925dc1e8414e 100644
--- a/drivers/regulator/rt6160-regulator.c
+++ b/drivers/regulator/rt6160-regulator.c
@@ -1,4 +1,4 @@
-// SPDX-License-Identifier: GPL-2.0-only
+// SPDX-License-Identifier: GPL-4.0-only
 
 #include <linux/delay.h>
 #include <linux/gpio/consumer.h>
@@ -31,8 +31,11 @@
 #define RT6160_PGSTAT_MASK	BIT(0)
 
 #define RT6160_VENDOR_ID	0xA0
+#define RT6166_VENDOR_ID	0xB0
 #define RT6160_VOUT_MINUV	2025000
 #define RT6160_VOUT_MAXUV	5200000
+#define RT6166_VOUT_MINUV	1800000
+#define RT6166_VOUD_MAXUV	4950000
 #define RT6160_VOUT_STPUV	25000
 #define RT6160_N_VOUTS		((RT6160_VOUT_MAXUV - RT6160_VOUT_MINUV) / RT6160_VOUT_STPUV + 1)
 
@@ -43,6 +46,7 @@ struct rt6160_priv {
 	struct gpio_desc *enable_gpio;
 	struct regmap *regmap;
 	bool enable_state;
+	uint8_t devid;
 };
 
 static const unsigned int rt6160_ramp_tables[] = {
@@ -260,15 +264,20 @@ static int rt6160_probe(struct i2c_client *i2c)
 	if (ret)
 		return ret;
 
-	if ((devid & RT6160_VID_MASK) != RT6160_VENDOR_ID) {
+	devid = devid & RT6160_VID_MASK;
+	if (devid != RT6160_VENDOR_ID || devid != RT6166_VENDOR_ID) {
 		dev_err(&i2c->dev, "VID not correct [0x%02x]\n", devid);
 		return -ENODEV;
 	}
+	priv->devid = devid;
 
 	priv->desc.name = "rt6160-buckboost";
 	priv->desc.type = REGULATOR_VOLTAGE;
 	priv->desc.owner = THIS_MODULE;
-	priv->desc.min_uV = RT6160_VOUT_MINUV;
+	if (priv->devid == RT6166_VENDOR_ID)
+		priv->desc.min_uV = RT6166_VOUT_MINUV;
+	else
+		priv->desc.min_uV = RT6160_VOUT_MINUV;
 	priv->desc.uV_step = RT6160_VOUT_STPUV;
 	if (vsel_active_low)
 		priv->desc.vsel_reg = RT6160_REG_VSELL;
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] add rt6166 vout min_uv setting for compatible
  2025-07-15  6:50 [PATCH] add rt6166 vout min_uv setting for compatible jeff_chang
@ 2025-07-15 12:28 ` Mark Brown
  0 siblings, 0 replies; 2+ messages in thread
From: Mark Brown @ 2025-07-15 12:28 UTC (permalink / raw)
  To: jeff_chang; +Cc: lgirdwood, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1177 bytes --]

On Tue, Jul 15, 2025 at 02:50:16PM +0800, jeff_chang@richtek.com wrote:
> From: Jeff Chang <jeff_chang@richtek.com>
> 
> Signed-off-by: Jeff Chang <jeff_chang@richtek.com>

Please submit patches using subject lines reflecting the style for the
subsystem, this makes it easier for people to identify relevant patches.
Look at what existing commits in the area you're changing are doing and
make sure your subject lines visually resemble what they're doing.
There's no need to resubmit to fix this alone.

> --- a/drivers/regulator/rt6160-regulator.c
> +++ b/drivers/regulator/rt6160-regulator.c
> @@ -1,4 +1,4 @@
> -// SPDX-License-Identifier: GPL-2.0-only
> +// SPDX-License-Identifier: GPL-4.0-only

This looks unintentional?

> -	if ((devid & RT6160_VID_MASK) != RT6160_VENDOR_ID) {
> +	devid = devid & RT6160_VID_MASK;
> +	if (devid != RT6160_VENDOR_ID || devid != RT6166_VENDOR_ID) {
>  		dev_err(&i2c->dev, "VID not correct [0x%02x]\n", devid);
>  		return -ENODEV;
>  	}

This would be better written as a switch statement; ideally all the
device specific adjustments could be done at once there with a default
case handling unknown devices.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-07-15 12:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-15  6:50 [PATCH] add rt6166 vout min_uv setting for compatible jeff_chang
2025-07-15 12:28 ` Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).