* [PATCH v2 0/8] Add support for Rockchip RK860X regulators
@ 2023-04-06 17:17 Cristian Ciocaltea
2023-04-06 17:17 ` [PATCH v2 1/8] regulator: dt-bindings: fcs,fan53555: Add support for RK860X Cristian Ciocaltea
` (8 more replies)
0 siblings, 9 replies; 13+ messages in thread
From: Cristian Ciocaltea @ 2023-04-06 17:17 UTC (permalink / raw)
To: Liam Girdwood, Mark Brown, Rob Herring, Krzysztof Kozlowski,
Heiko Stuebner, Bjorn Andersson, Joseph Chen, Ezequiel Garcia
Cc: linux-kernel, devicetree, kernel
This patch series introduces support for the Rockchip RK860X regulators,
while also providing a few fixes and improvements to the existing fan53555
driver.
RK8600/RK8601 are fully compatible with the FAN53555 regulators.
RK8602/RK8603 are a bit different, having a wider output voltage
selection range, from 0.5 V to 1.5 V in 6.25 mV steps. They are used
in the Rock 5B board to power the ARM Cortex-A76 cores and the NPU.
Changes in v2:
- Dropped the rk8601 and rk8603 entries from the device_id arrays
in PATCH 8/8 and updated the bindings accordingly in PATCH 1/8,
per Krzysztof's review
- v1: https://lore.kernel.org/lkml/20230405194721.821536-1-cristian.ciocaltea@collabora.com/
Cristian Ciocaltea (8):
regulator: dt-bindings: fcs,fan53555: Add support for RK860X
regulator: fan53555: Explicitly include bits header
regulator: fan53555: Fix wrong TCS_SLEW_MASK
regulator: fan53555: Remove unused *_SLEW_SHIFT definitions
regulator: fan53555: Make use of the bit macros
regulator: fan53555: Improve vsel_mask computation
regulator: fan53555: Use dev_err_probe
regulator: fan53555: Add support for RK860X
.../bindings/regulator/fcs,fan53555.yaml | 22 +-
drivers/regulator/fan53555.c | 203 ++++++++++++++----
2 files changed, 172 insertions(+), 53 deletions(-)
--
2.40.0
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH v2 1/8] regulator: dt-bindings: fcs,fan53555: Add support for RK860X
2023-04-06 17:17 [PATCH v2 0/8] Add support for Rockchip RK860X regulators Cristian Ciocaltea
@ 2023-04-06 17:17 ` Cristian Ciocaltea
2023-04-06 18:14 ` Krzysztof Kozlowski
2023-04-06 17:18 ` [PATCH v2 2/8] regulator: fan53555: Explicitly include bits header Cristian Ciocaltea
` (7 subsequent siblings)
8 siblings, 1 reply; 13+ messages in thread
From: Cristian Ciocaltea @ 2023-04-06 17:17 UTC (permalink / raw)
To: Liam Girdwood, Mark Brown, Rob Herring, Krzysztof Kozlowski,
Heiko Stuebner, Bjorn Andersson, Joseph Chen, Ezequiel Garcia
Cc: linux-kernel, devicetree, kernel
Add compatibles to support Rockchip RK860X regulators.
RK8600/RK8601 are pretty similar to the FAN53555 regulators, while
RK8602/RK8603 are a bit different, having a wider voltage selection
range.
Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
---
.../bindings/regulator/fcs,fan53555.yaml | 22 ++++++++++++++-----
1 file changed, 16 insertions(+), 6 deletions(-)
diff --git a/Documentation/devicetree/bindings/regulator/fcs,fan53555.yaml b/Documentation/devicetree/bindings/regulator/fcs,fan53555.yaml
index c0dbba843f70..7547c130ff7d 100644
--- a/Documentation/devicetree/bindings/regulator/fcs,fan53555.yaml
+++ b/Documentation/devicetree/bindings/regulator/fcs,fan53555.yaml
@@ -14,12 +14,22 @@ allOf:
properties:
compatible:
- enum:
- - fcs,fan53555
- - fcs,fan53526
- - silergy,syr827
- - silergy,syr828
- - tcs,tcs4525
+ oneOf:
+ - items:
+ - enum:
+ - fcs,fan53555
+ - fcs,fan53526
+ - rockchip,rk8600
+ - rockchip,rk8602
+ - silergy,syr827
+ - silergy,syr828
+ - tcs,tcs4525
+ - items:
+ - const: rockchip,rk8601
+ - const: rockchip,rk8600
+ - items:
+ - const: rockchip,rk8603
+ - const: rockchip,rk8602
reg:
maxItems: 1
--
2.40.0
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH v2 2/8] regulator: fan53555: Explicitly include bits header
2023-04-06 17:17 [PATCH v2 0/8] Add support for Rockchip RK860X regulators Cristian Ciocaltea
2023-04-06 17:17 ` [PATCH v2 1/8] regulator: dt-bindings: fcs,fan53555: Add support for RK860X Cristian Ciocaltea
@ 2023-04-06 17:18 ` Cristian Ciocaltea
2023-04-06 17:18 ` [PATCH v2 3/8] regulator: fan53555: Fix wrong TCS_SLEW_MASK Cristian Ciocaltea
` (6 subsequent siblings)
8 siblings, 0 replies; 13+ messages in thread
From: Cristian Ciocaltea @ 2023-04-06 17:18 UTC (permalink / raw)
To: Liam Girdwood, Mark Brown, Rob Herring, Krzysztof Kozlowski,
Heiko Stuebner, Bjorn Andersson, Joseph Chen, Ezequiel Garcia
Cc: linux-kernel, devicetree, kernel
Since commit f2a9eb975ab2 ("regulator: fan53555: Add support for
FAN53526") the driver makes use of the BIT() macro, but relies on the
bits header being implicitly included.
Explicitly pull the header in to avoid potential build failures in some
configurations.
While here, reorder include directives alphabetically.
Fixes: f2a9eb975ab2 ("regulator: fan53555: Add support for FAN53526")
Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
---
drivers/regulator/fan53555.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/drivers/regulator/fan53555.c b/drivers/regulator/fan53555.c
index d0c678767294..0754c370a21c 100644
--- a/drivers/regulator/fan53555.c
+++ b/drivers/regulator/fan53555.c
@@ -8,18 +8,19 @@
// Copyright (c) 2012 Marvell Technology Ltd.
// Yunfan Zhang <yfzhang@marvell.com>
+#include <linux/bits.h>
+#include <linux/err.h>
+#include <linux/i2c.h>
#include <linux/module.h>
+#include <linux/of_device.h>
#include <linux/param.h>
-#include <linux/err.h>
#include <linux/platform_device.h>
+#include <linux/regmap.h>
#include <linux/regulator/driver.h>
+#include <linux/regulator/fan53555.h>
#include <linux/regulator/machine.h>
#include <linux/regulator/of_regulator.h>
-#include <linux/of_device.h>
-#include <linux/i2c.h>
#include <linux/slab.h>
-#include <linux/regmap.h>
-#include <linux/regulator/fan53555.h>
/* Voltage setting */
#define FAN53555_VSEL0 0x00
--
2.40.0
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH v2 3/8] regulator: fan53555: Fix wrong TCS_SLEW_MASK
2023-04-06 17:17 [PATCH v2 0/8] Add support for Rockchip RK860X regulators Cristian Ciocaltea
2023-04-06 17:17 ` [PATCH v2 1/8] regulator: dt-bindings: fcs,fan53555: Add support for RK860X Cristian Ciocaltea
2023-04-06 17:18 ` [PATCH v2 2/8] regulator: fan53555: Explicitly include bits header Cristian Ciocaltea
@ 2023-04-06 17:18 ` Cristian Ciocaltea
2023-04-06 17:18 ` [PATCH v2 4/8] regulator: fan53555: Remove unused *_SLEW_SHIFT definitions Cristian Ciocaltea
` (5 subsequent siblings)
8 siblings, 0 replies; 13+ messages in thread
From: Cristian Ciocaltea @ 2023-04-06 17:18 UTC (permalink / raw)
To: Liam Girdwood, Mark Brown, Rob Herring, Krzysztof Kozlowski,
Heiko Stuebner, Bjorn Andersson, Joseph Chen, Ezequiel Garcia
Cc: linux-kernel, devicetree, kernel
The support for TCS4525 regulator has been introduced with a wrong
ramp-rate mask, which has been defined as a logical expression instead
of a bit shift operation.
For clarity, fix it using GENMASK() macro.
Fixes: 914df8faa7d6 ("regulator: fan53555: Add TCS4525 DCDC support")
Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
---
drivers/regulator/fan53555.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/regulator/fan53555.c b/drivers/regulator/fan53555.c
index 0754c370a21c..4d2104c3a077 100644
--- a/drivers/regulator/fan53555.c
+++ b/drivers/regulator/fan53555.c
@@ -61,7 +61,7 @@
#define TCS_VSEL1_MODE (1 << 6)
#define TCS_SLEW_SHIFT 3
-#define TCS_SLEW_MASK (0x3 < 3)
+#define TCS_SLEW_MASK GENMASK(4, 3)
enum fan53555_vendor {
FAN53526_VENDOR_FAIRCHILD = 0,
--
2.40.0
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH v2 4/8] regulator: fan53555: Remove unused *_SLEW_SHIFT definitions
2023-04-06 17:17 [PATCH v2 0/8] Add support for Rockchip RK860X regulators Cristian Ciocaltea
` (2 preceding siblings ...)
2023-04-06 17:18 ` [PATCH v2 3/8] regulator: fan53555: Fix wrong TCS_SLEW_MASK Cristian Ciocaltea
@ 2023-04-06 17:18 ` Cristian Ciocaltea
2023-04-06 17:18 ` [PATCH v2 5/8] regulator: fan53555: Make use of the bit macros Cristian Ciocaltea
` (4 subsequent siblings)
8 siblings, 0 replies; 13+ messages in thread
From: Cristian Ciocaltea @ 2023-04-06 17:18 UTC (permalink / raw)
To: Liam Girdwood, Mark Brown, Rob Herring, Krzysztof Kozlowski,
Heiko Stuebner, Bjorn Andersson, Joseph Chen, Ezequiel Garcia
Cc: linux-kernel, devicetree, kernel
Commit b61ac767db4d ("regulator: fan53555: Convert to use
regulator_set_ramp_delay_regmap") removed the slew_shift member from
struct fan53555_device_info, hence the {CTL,TCS}_SLEW_SHIFT definitions
remained unused. Drop them.
Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
---
drivers/regulator/fan53555.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/drivers/regulator/fan53555.c b/drivers/regulator/fan53555.c
index 4d2104c3a077..68ebcd4ccef7 100644
--- a/drivers/regulator/fan53555.c
+++ b/drivers/regulator/fan53555.c
@@ -49,7 +49,6 @@
/* Control bit definitions */
#define CTL_OUTPUT_DISCHG (1 << 7)
#define CTL_SLEW_MASK (0x7 << 4)
-#define CTL_SLEW_SHIFT 4
#define CTL_RESET (1 << 2)
#define CTL_MODE_VSEL0_MODE BIT(0)
#define CTL_MODE_VSEL1_MODE BIT(1)
@@ -60,7 +59,6 @@
#define TCS_VSEL0_MODE (1 << 7)
#define TCS_VSEL1_MODE (1 << 6)
-#define TCS_SLEW_SHIFT 3
#define TCS_SLEW_MASK GENMASK(4, 3)
enum fan53555_vendor {
--
2.40.0
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH v2 5/8] regulator: fan53555: Make use of the bit macros
2023-04-06 17:17 [PATCH v2 0/8] Add support for Rockchip RK860X regulators Cristian Ciocaltea
` (3 preceding siblings ...)
2023-04-06 17:18 ` [PATCH v2 4/8] regulator: fan53555: Remove unused *_SLEW_SHIFT definitions Cristian Ciocaltea
@ 2023-04-06 17:18 ` Cristian Ciocaltea
2023-04-06 17:18 ` [PATCH v2 6/8] regulator: fan53555: Improve vsel_mask computation Cristian Ciocaltea
` (3 subsequent siblings)
8 siblings, 0 replies; 13+ messages in thread
From: Cristian Ciocaltea @ 2023-04-06 17:18 UTC (permalink / raw)
To: Liam Girdwood, Mark Brown, Rob Herring, Krzysztof Kozlowski,
Heiko Stuebner, Bjorn Andersson, Joseph Chen, Ezequiel Garcia
Cc: linux-kernel, devicetree, kernel
For consistency and improved clarity, use BIT() and GENMASK() macros for
defining the bitfields inside the registers. No functional changes
intended.
While here, also fix DIE_{ID,REV} inconsistent indentation.
Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
---
drivers/regulator/fan53555.c | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/drivers/regulator/fan53555.c b/drivers/regulator/fan53555.c
index 68ebcd4ccef7..181e5eb00e7a 100644
--- a/drivers/regulator/fan53555.c
+++ b/drivers/regulator/fan53555.c
@@ -41,23 +41,23 @@
#define FAN53555_MONITOR 0x05
/* VSEL bit definitions */
-#define VSEL_BUCK_EN (1 << 7)
-#define VSEL_MODE (1 << 6)
+#define VSEL_BUCK_EN BIT(7)
+#define VSEL_MODE BIT(6)
/* Chip ID and Verison */
-#define DIE_ID 0x0F /* ID1 */
-#define DIE_REV 0x0F /* ID2 */
+#define DIE_ID 0x0F /* ID1 */
+#define DIE_REV 0x0F /* ID2 */
/* Control bit definitions */
-#define CTL_OUTPUT_DISCHG (1 << 7)
-#define CTL_SLEW_MASK (0x7 << 4)
-#define CTL_RESET (1 << 2)
+#define CTL_OUTPUT_DISCHG BIT(7)
+#define CTL_SLEW_MASK GENMASK(6, 4)
+#define CTL_RESET BIT(2)
#define CTL_MODE_VSEL0_MODE BIT(0)
#define CTL_MODE_VSEL1_MODE BIT(1)
#define FAN53555_NVOLTAGES 64 /* Numbers of voltages */
#define FAN53526_NVOLTAGES 128
-#define TCS_VSEL0_MODE (1 << 7)
-#define TCS_VSEL1_MODE (1 << 6)
+#define TCS_VSEL0_MODE BIT(7)
+#define TCS_VSEL1_MODE BIT(6)
#define TCS_SLEW_MASK GENMASK(4, 3)
--
2.40.0
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH v2 6/8] regulator: fan53555: Improve vsel_mask computation
2023-04-06 17:17 [PATCH v2 0/8] Add support for Rockchip RK860X regulators Cristian Ciocaltea
` (4 preceding siblings ...)
2023-04-06 17:18 ` [PATCH v2 5/8] regulator: fan53555: Make use of the bit macros Cristian Ciocaltea
@ 2023-04-06 17:18 ` Cristian Ciocaltea
2023-04-06 17:18 ` [PATCH v2 7/8] regulator: fan53555: Use dev_err_probe Cristian Ciocaltea
` (2 subsequent siblings)
8 siblings, 0 replies; 13+ messages in thread
From: Cristian Ciocaltea @ 2023-04-06 17:18 UTC (permalink / raw)
To: Liam Girdwood, Mark Brown, Rob Herring, Krzysztof Kozlowski,
Heiko Stuebner, Bjorn Andersson, Joseph Chen, Ezequiel Garcia
Cc: linux-kernel, devicetree, kernel
In preparation for introducing support for additional regulators which
do not use the maximum number of voltage selectors available for a given
mask, improve the mask computation formula by using fls().
Note fls() requires the bitops header, hence include it explicitly and
drop bits.h which is already pulled by bitops.h.
Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
---
drivers/regulator/fan53555.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/regulator/fan53555.c b/drivers/regulator/fan53555.c
index 181e5eb00e7a..39c9c29f4ff6 100644
--- a/drivers/regulator/fan53555.c
+++ b/drivers/regulator/fan53555.c
@@ -8,7 +8,7 @@
// Copyright (c) 2012 Marvell Technology Ltd.
// Yunfan Zhang <yfzhang@marvell.com>
-#include <linux/bits.h>
+#include <linux/bitops.h>
#include <linux/err.h>
#include <linux/i2c.h>
#include <linux/module.h>
@@ -486,7 +486,7 @@ static int fan53555_regulator_register(struct fan53555_device_info *di,
rdesc->min_uV = di->vsel_min;
rdesc->uV_step = di->vsel_step;
rdesc->vsel_reg = di->vol_reg;
- rdesc->vsel_mask = di->vsel_count - 1;
+ rdesc->vsel_mask = BIT(fls(di->vsel_count - 1)) - 1;
rdesc->ramp_reg = di->slew_reg;
rdesc->ramp_mask = di->slew_mask;
rdesc->ramp_delay_table = di->ramp_delay_table;
--
2.40.0
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH v2 7/8] regulator: fan53555: Use dev_err_probe
2023-04-06 17:17 [PATCH v2 0/8] Add support for Rockchip RK860X regulators Cristian Ciocaltea
` (5 preceding siblings ...)
2023-04-06 17:18 ` [PATCH v2 6/8] regulator: fan53555: Improve vsel_mask computation Cristian Ciocaltea
@ 2023-04-06 17:18 ` Cristian Ciocaltea
2023-04-06 17:18 ` [PATCH v2 8/8] regulator: fan53555: Add support for RK860X Cristian Ciocaltea
2023-04-06 21:31 ` (subset) [PATCH v2 0/8] Add support for Rockchip RK860X regulators Mark Brown
8 siblings, 0 replies; 13+ messages in thread
From: Cristian Ciocaltea @ 2023-04-06 17:18 UTC (permalink / raw)
To: Liam Girdwood, Mark Brown, Rob Herring, Krzysztof Kozlowski,
Heiko Stuebner, Bjorn Andersson, Joseph Chen, Ezequiel Garcia
Cc: linux-kernel, devicetree, kernel
Use dev_err_probe() instead of dev_err() in the probe function, which
ensures the error code is always printed and, additionally, simplifies
the code a bit.
Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
---
drivers/regulator/fan53555.c | 47 ++++++++++++++++--------------------
1 file changed, 21 insertions(+), 26 deletions(-)
diff --git a/drivers/regulator/fan53555.c b/drivers/regulator/fan53555.c
index 39c9c29f4ff6..acf14ba7aaa6 100644
--- a/drivers/regulator/fan53555.c
+++ b/drivers/regulator/fan53555.c
@@ -568,10 +568,9 @@ static int fan53555_regulator_probe(struct i2c_client *client)
if (!pdata)
pdata = fan53555_parse_dt(&client->dev, np, &di->desc);
- if (!pdata || !pdata->regulator) {
- dev_err(&client->dev, "Platform data not found!\n");
- return -ENODEV;
- }
+ if (!pdata || !pdata->regulator)
+ return dev_err_probe(&client->dev, -ENODEV,
+ "Platform data not found!\n");
di->regulator = pdata->regulator;
if (client->dev.of_node) {
@@ -580,10 +579,9 @@ static int fan53555_regulator_probe(struct i2c_client *client)
} else {
/* if no ramp constraint set, get the pdata ramp_delay */
if (!di->regulator->constraints.ramp_delay) {
- if (pdata->slew_rate >= ARRAY_SIZE(slew_rates)) {
- dev_err(&client->dev, "Invalid slew_rate\n");
- return -EINVAL;
- }
+ if (pdata->slew_rate >= ARRAY_SIZE(slew_rates))
+ return dev_err_probe(&client->dev, -EINVAL,
+ "Invalid slew_rate\n");
di->regulator->constraints.ramp_delay
= slew_rates[pdata->slew_rate];
@@ -593,34 +591,31 @@ static int fan53555_regulator_probe(struct i2c_client *client)
}
regmap = devm_regmap_init_i2c(client, &fan53555_regmap_config);
- if (IS_ERR(regmap)) {
- dev_err(&client->dev, "Failed to allocate regmap!\n");
- return PTR_ERR(regmap);
- }
+ if (IS_ERR(regmap))
+ return dev_err_probe(&client->dev, PTR_ERR(regmap),
+ "Failed to allocate regmap!\n");
+
di->dev = &client->dev;
i2c_set_clientdata(client, di);
/* Get chip ID */
ret = regmap_read(regmap, FAN53555_ID1, &val);
- if (ret < 0) {
- dev_err(&client->dev, "Failed to get chip ID!\n");
- return ret;
- }
+ if (ret < 0)
+ return dev_err_probe(&client->dev, ret, "Failed to get chip ID!\n");
+
di->chip_id = val & DIE_ID;
/* Get chip revision */
ret = regmap_read(regmap, FAN53555_ID2, &val);
- if (ret < 0) {
- dev_err(&client->dev, "Failed to get chip Rev!\n");
- return ret;
- }
+ if (ret < 0)
+ return dev_err_probe(&client->dev, ret, "Failed to get chip Rev!\n");
+
di->chip_rev = val & DIE_REV;
dev_info(&client->dev, "FAN53555 Option[%d] Rev[%d] Detected!\n",
di->chip_id, di->chip_rev);
/* Device init */
ret = fan53555_device_setup(di, pdata);
- if (ret < 0) {
- dev_err(&client->dev, "Failed to setup device!\n");
- return ret;
- }
+ if (ret < 0)
+ return dev_err_probe(&client->dev, ret, "Failed to setup device!\n");
+
/* Register regulator */
config.dev = di->dev;
config.init_data = di->regulator;
@@ -630,9 +625,9 @@ static int fan53555_regulator_probe(struct i2c_client *client)
ret = fan53555_regulator_register(di, &config);
if (ret < 0)
- dev_err(&client->dev, "Failed to register regulator!\n");
- return ret;
+ dev_err_probe(&client->dev, ret, "Failed to register regulator!\n");
+ return ret;
}
static const struct i2c_device_id fan53555_id[] = {
--
2.40.0
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH v2 8/8] regulator: fan53555: Add support for RK860X
2023-04-06 17:17 [PATCH v2 0/8] Add support for Rockchip RK860X regulators Cristian Ciocaltea
` (6 preceding siblings ...)
2023-04-06 17:18 ` [PATCH v2 7/8] regulator: fan53555: Use dev_err_probe Cristian Ciocaltea
@ 2023-04-06 17:18 ` Cristian Ciocaltea
2023-04-06 18:15 ` Krzysztof Kozlowski
2023-04-06 21:31 ` (subset) [PATCH v2 0/8] Add support for Rockchip RK860X regulators Mark Brown
8 siblings, 1 reply; 13+ messages in thread
From: Cristian Ciocaltea @ 2023-04-06 17:18 UTC (permalink / raw)
To: Liam Girdwood, Mark Brown, Rob Herring, Krzysztof Kozlowski,
Heiko Stuebner, Bjorn Andersson, Joseph Chen, Ezequiel Garcia
Cc: linux-kernel, devicetree, kernel
Extend the existing fan53555 driver to support the Rockchip RK860X
regulators.
RK8600/RK8601 are pretty similar to the FAN53555 regulators.
RK8602/RK8603 are a bit different, having a wider output voltage
selection range, from 0.5 V to 1.5 V in 6.25 mV steps. They also use
additional VSEL0/VSEL1 registers for the voltage selector, but the
enable and mode bits are still located in the original FAN53555 specific
VSEL0/VSEL1 registers.
Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
---
drivers/regulator/fan53555.c | 121 ++++++++++++++++++++++++++++++++++-
1 file changed, 118 insertions(+), 3 deletions(-)
diff --git a/drivers/regulator/fan53555.c b/drivers/regulator/fan53555.c
index acf14ba7aaa6..130f3dbe9840 100644
--- a/drivers/regulator/fan53555.c
+++ b/drivers/regulator/fan53555.c
@@ -26,6 +26,9 @@
#define FAN53555_VSEL0 0x00
#define FAN53555_VSEL1 0x01
+#define RK8602_VSEL0 0x06
+#define RK8602_VSEL1 0x07
+
#define TCS4525_VSEL0 0x11
#define TCS4525_VSEL1 0x10
#define TCS4525_TIME 0x13
@@ -55,6 +58,7 @@
#define FAN53555_NVOLTAGES 64 /* Numbers of voltages */
#define FAN53526_NVOLTAGES 128
+#define RK8602_NVOLTAGES 160
#define TCS_VSEL0_MODE BIT(7)
#define TCS_VSEL1_MODE BIT(6)
@@ -64,6 +68,8 @@
enum fan53555_vendor {
FAN53526_VENDOR_FAIRCHILD = 0,
FAN53555_VENDOR_FAIRCHILD,
+ FAN53555_VENDOR_ROCKCHIP, /* RK8600, RK8601 */
+ RK8602_VENDOR_ROCKCHIP, /* RK8602, RK8603 */
FAN53555_VENDOR_SILERGY,
FAN53526_VENDOR_TCS,
};
@@ -87,6 +93,14 @@ enum {
FAN53555_CHIP_ID_08 = 8,
};
+enum {
+ RK8600_CHIP_ID_08 = 8, /* RK8600, RK8601 */
+};
+
+enum {
+ RK8602_CHIP_ID_10 = 10, /* RK8602, RK8603 */
+};
+
enum {
TCS4525_CHIP_ID_12 = 12,
};
@@ -117,6 +131,8 @@ struct fan53555_device_info {
/* Voltage setting register */
unsigned int vol_reg;
unsigned int sleep_reg;
+ unsigned int en_reg;
+ unsigned int sleep_en_reg;
/* Voltage range and step(linear) */
unsigned int vsel_min;
unsigned int vsel_step;
@@ -159,7 +175,7 @@ static int fan53555_set_suspend_enable(struct regulator_dev *rdev)
{
struct fan53555_device_info *di = rdev_get_drvdata(rdev);
- return regmap_update_bits(rdev->regmap, di->sleep_reg,
+ return regmap_update_bits(rdev->regmap, di->sleep_en_reg,
VSEL_BUCK_EN, VSEL_BUCK_EN);
}
@@ -167,7 +183,7 @@ static int fan53555_set_suspend_disable(struct regulator_dev *rdev)
{
struct fan53555_device_info *di = rdev_get_drvdata(rdev);
- return regmap_update_bits(rdev->regmap, di->sleep_reg,
+ return regmap_update_bits(rdev->regmap, di->sleep_en_reg,
VSEL_BUCK_EN, 0);
}
@@ -317,6 +333,50 @@ static int fan53555_voltages_setup_fairchild(struct fan53555_device_info *di)
return 0;
}
+static int fan53555_voltages_setup_rockchip(struct fan53555_device_info *di)
+{
+ /* Init voltage range and step */
+ switch (di->chip_id) {
+ case RK8600_CHIP_ID_08:
+ di->vsel_min = 712500;
+ di->vsel_step = 12500;
+ break;
+ default:
+ dev_err(di->dev,
+ "Chip ID %d not supported!\n", di->chip_id);
+ return -EINVAL;
+ }
+ di->slew_reg = FAN53555_CONTROL;
+ di->slew_mask = CTL_SLEW_MASK;
+ di->ramp_delay_table = slew_rates;
+ di->n_ramp_values = ARRAY_SIZE(slew_rates);
+ di->vsel_count = FAN53555_NVOLTAGES;
+
+ return 0;
+}
+
+static int rk8602_voltages_setup_rockchip(struct fan53555_device_info *di)
+{
+ /* Init voltage range and step */
+ switch (di->chip_id) {
+ case RK8602_CHIP_ID_10:
+ di->vsel_min = 500000;
+ di->vsel_step = 6250;
+ break;
+ default:
+ dev_err(di->dev,
+ "Chip ID %d not supported!\n", di->chip_id);
+ return -EINVAL;
+ }
+ di->slew_reg = FAN53555_CONTROL;
+ di->slew_mask = CTL_SLEW_MASK;
+ di->ramp_delay_table = slew_rates;
+ di->n_ramp_values = ARRAY_SIZE(slew_rates);
+ di->vsel_count = RK8602_NVOLTAGES;
+
+ return 0;
+}
+
static int fan53555_voltages_setup_silergy(struct fan53555_device_info *di)
{
/* Init voltage range and step */
@@ -377,6 +437,7 @@ static int fan53555_device_setup(struct fan53555_device_info *di,
switch (di->vendor) {
case FAN53526_VENDOR_FAIRCHILD:
case FAN53555_VENDOR_FAIRCHILD:
+ case FAN53555_VENDOR_ROCKCHIP:
case FAN53555_VENDOR_SILERGY:
switch (pdata->sleep_vsel_id) {
case FAN53555_VSEL_ID_0:
@@ -391,6 +452,27 @@ static int fan53555_device_setup(struct fan53555_device_info *di,
dev_err(di->dev, "Invalid VSEL ID!\n");
return -EINVAL;
}
+ di->sleep_en_reg = di->sleep_reg;
+ di->en_reg = di->vol_reg;
+ break;
+ case RK8602_VENDOR_ROCKCHIP:
+ switch (pdata->sleep_vsel_id) {
+ case FAN53555_VSEL_ID_0:
+ di->sleep_reg = RK8602_VSEL0;
+ di->vol_reg = RK8602_VSEL1;
+ di->sleep_en_reg = FAN53555_VSEL0;
+ di->en_reg = FAN53555_VSEL1;
+ break;
+ case FAN53555_VSEL_ID_1:
+ di->sleep_reg = RK8602_VSEL1;
+ di->vol_reg = RK8602_VSEL0;
+ di->sleep_en_reg = FAN53555_VSEL1;
+ di->en_reg = FAN53555_VSEL0;
+ break;
+ default:
+ dev_err(di->dev, "Invalid VSEL ID!\n");
+ return -EINVAL;
+ }
break;
case FAN53526_VENDOR_TCS:
switch (pdata->sleep_vsel_id) {
@@ -406,6 +488,8 @@ static int fan53555_device_setup(struct fan53555_device_info *di,
dev_err(di->dev, "Invalid VSEL ID!\n");
return -EINVAL;
}
+ di->sleep_en_reg = di->sleep_reg;
+ di->en_reg = di->vol_reg;
break;
default:
dev_err(di->dev, "vendor %d not supported!\n", di->vendor);
@@ -427,10 +511,23 @@ static int fan53555_device_setup(struct fan53555_device_info *di,
}
break;
case FAN53555_VENDOR_FAIRCHILD:
+ case FAN53555_VENDOR_ROCKCHIP:
case FAN53555_VENDOR_SILERGY:
di->mode_reg = di->vol_reg;
di->mode_mask = VSEL_MODE;
break;
+ case RK8602_VENDOR_ROCKCHIP:
+ di->mode_mask = VSEL_MODE;
+
+ switch (pdata->sleep_vsel_id) {
+ case FAN53555_VSEL_ID_0:
+ di->mode_reg = FAN53555_VSEL1;
+ break;
+ case FAN53555_VSEL_ID_1:
+ di->mode_reg = FAN53555_VSEL0;
+ break;
+ }
+ break;
case FAN53526_VENDOR_TCS:
di->mode_reg = TCS4525_COMMAND;
@@ -456,6 +553,12 @@ static int fan53555_device_setup(struct fan53555_device_info *di,
case FAN53555_VENDOR_FAIRCHILD:
ret = fan53555_voltages_setup_fairchild(di);
break;
+ case FAN53555_VENDOR_ROCKCHIP:
+ ret = fan53555_voltages_setup_rockchip(di);
+ break;
+ case RK8602_VENDOR_ROCKCHIP:
+ ret = rk8602_voltages_setup_rockchip(di);
+ break;
case FAN53555_VENDOR_SILERGY:
ret = fan53555_voltages_setup_silergy(di);
break;
@@ -481,7 +584,7 @@ static int fan53555_regulator_register(struct fan53555_device_info *di,
rdesc->ops = &fan53555_regulator_ops;
rdesc->type = REGULATOR_VOLTAGE;
rdesc->n_voltages = di->vsel_count;
- rdesc->enable_reg = di->vol_reg;
+ rdesc->enable_reg = di->en_reg;
rdesc->enable_mask = VSEL_BUCK_EN;
rdesc->min_uV = di->vsel_min;
rdesc->uV_step = di->vsel_step;
@@ -531,6 +634,12 @@ static const struct of_device_id __maybe_unused fan53555_dt_ids[] = {
}, {
.compatible = "fcs,fan53555",
.data = (void *)FAN53555_VENDOR_FAIRCHILD
+ }, {
+ .compatible = "rockchip,rk8600",
+ .data = (void *)FAN53555_VENDOR_ROCKCHIP
+ }, {
+ .compatible = "rockchip,rk8602",
+ .data = (void *)RK8602_VENDOR_ROCKCHIP
}, {
.compatible = "silergy,syr827",
.data = (void *)FAN53555_VENDOR_SILERGY,
@@ -637,6 +746,12 @@ static const struct i2c_device_id fan53555_id[] = {
}, {
.name = "fan53555",
.driver_data = FAN53555_VENDOR_FAIRCHILD
+ }, {
+ .name = "rk8600",
+ .driver_data = FAN53555_VENDOR_ROCKCHIP
+ }, {
+ .name = "rk8602",
+ .driver_data = RK8602_VENDOR_ROCKCHIP
}, {
.name = "syr827",
.driver_data = FAN53555_VENDOR_SILERGY
--
2.40.0
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v2 1/8] regulator: dt-bindings: fcs,fan53555: Add support for RK860X
2023-04-06 17:17 ` [PATCH v2 1/8] regulator: dt-bindings: fcs,fan53555: Add support for RK860X Cristian Ciocaltea
@ 2023-04-06 18:14 ` Krzysztof Kozlowski
2023-04-06 19:17 ` Cristian Ciocaltea
0 siblings, 1 reply; 13+ messages in thread
From: Krzysztof Kozlowski @ 2023-04-06 18:14 UTC (permalink / raw)
To: Cristian Ciocaltea, Liam Girdwood, Mark Brown, Rob Herring,
Krzysztof Kozlowski, Heiko Stuebner, Bjorn Andersson,
Joseph Chen, Ezequiel Garcia
Cc: linux-kernel, devicetree, kernel
On 06/04/2023 19:17, Cristian Ciocaltea wrote:
> Add compatibles to support Rockchip RK860X regulators.
>
> RK8600/RK8601 are pretty similar to the FAN53555 regulators, while
> RK8602/RK8603 are a bit different, having a wider voltage selection
> range.
>
> Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
> ---
> .../bindings/regulator/fcs,fan53555.yaml | 22 ++++++++++++++-----
> 1 file changed, 16 insertions(+), 6 deletions(-)
>
> diff --git a/Documentation/devicetree/bindings/regulator/fcs,fan53555.yaml b/Documentation/devicetree/bindings/regulator/fcs,fan53555.yaml
> index c0dbba843f70..7547c130ff7d 100644
> --- a/Documentation/devicetree/bindings/regulator/fcs,fan53555.yaml
> +++ b/Documentation/devicetree/bindings/regulator/fcs,fan53555.yaml
> @@ -14,12 +14,22 @@ allOf:
>
> properties:
> compatible:
> - enum:
> - - fcs,fan53555
> - - fcs,fan53526
> - - silergy,syr827
> - - silergy,syr828
> - - tcs,tcs4525
> + oneOf:
> + - items:
Drop items here. It's just an enum.
> + - enum:
> + - fcs,fan53555
> + - fcs,fan53526
> + - rockchip,rk8600
> + - rockchip,rk8602
> + - silergy,syr827
> + - silergy,syr828
> + - tcs,tcs4525
> + - items:
> + - const: rockchip,rk8601
> + - const: rockchip,rk8600
> + - items:
> + - const: rockchip,rk8603
> + - const: rockchip,rk8602
>
> reg:
> maxItems: 1
Best regards,
Krzysztof
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v2 8/8] regulator: fan53555: Add support for RK860X
2023-04-06 17:18 ` [PATCH v2 8/8] regulator: fan53555: Add support for RK860X Cristian Ciocaltea
@ 2023-04-06 18:15 ` Krzysztof Kozlowski
0 siblings, 0 replies; 13+ messages in thread
From: Krzysztof Kozlowski @ 2023-04-06 18:15 UTC (permalink / raw)
To: Cristian Ciocaltea, Liam Girdwood, Mark Brown, Rob Herring,
Krzysztof Kozlowski, Heiko Stuebner, Bjorn Andersson,
Joseph Chen, Ezequiel Garcia
Cc: linux-kernel, devicetree, kernel
On 06/04/2023 19:18, Cristian Ciocaltea wrote:
> Extend the existing fan53555 driver to support the Rockchip RK860X
> regulators.
>
> RK8600/RK8601 are pretty similar to the FAN53555 regulators.
>
> RK8602/RK8603 are a bit different, having a wider output voltage
> selection range, from 0.5 V to 1.5 V in 6.25 mV steps. They also use
> additional VSEL0/VSEL1 registers for the voltage selector, but the
> enable and mode bits are still located in the original FAN53555 specific
> VSEL0/VSEL1 registers.
>
> Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
> ---
> drivers/regulator/fan53555.c | 121 ++++++++++++++++++++++++++++++++++-
> 1 file changed, 118 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/regulator/fan53555.c b/drivers/regulator/fan53555.c
> index acf14ba7aaa6..130f3dbe9840 100644
> --- a/drivers/regulator/fan53555.c
> +++ b/drivers/regulator/fan53555.c
> @@ -26,6 +26,9 @@
> #define FAN53555_VSEL0 0x00
> #define FAN53555_VSEL1 0x01
>
> +#define RK8602_VSEL0 0x06
> +#define RK8602_VSEL1 0x07
> +
> #define TCS4525_VSEL0 0x11
> #define TCS4525_VSEL1 0x10
> #define TCS4525_TIME 0x13
> @@ -55,6 +58,7 @@
>
> #define FAN53555_NVOLTAGES 64 /* Numbers of voltages */
> #define FAN53526_NVOLTAGES 128
> +#define RK8602_NVOLTAGES 160
>
> #define TCS_VSEL0_MODE BIT(7)
> #define TCS_VSEL1_MODE BIT(6)
> @@ -64,6 +68,8 @@
> enum fan53555_vendor {
> FAN53526_VENDOR_FAIRCHILD = 0,
> FAN53555_VENDOR_FAIRCHILD,
> + FAN53555_VENDOR_ROCKCHIP, /* RK8600, RK8601 */
> + RK8602_VENDOR_ROCKCHIP, /* RK8602, RK8603 */
Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Best regards,
Krzysztof
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v2 1/8] regulator: dt-bindings: fcs,fan53555: Add support for RK860X
2023-04-06 18:14 ` Krzysztof Kozlowski
@ 2023-04-06 19:17 ` Cristian Ciocaltea
0 siblings, 0 replies; 13+ messages in thread
From: Cristian Ciocaltea @ 2023-04-06 19:17 UTC (permalink / raw)
To: Krzysztof Kozlowski, Liam Girdwood, Mark Brown, Rob Herring,
Krzysztof Kozlowski, Heiko Stuebner, Bjorn Andersson,
Joseph Chen, Ezequiel Garcia
Cc: linux-kernel, devicetree, kernel
On 4/6/23 21:14, Krzysztof Kozlowski wrote:
> On 06/04/2023 19:17, Cristian Ciocaltea wrote:
>> Add compatibles to support Rockchip RK860X regulators.
>>
>> RK8600/RK8601 are pretty similar to the FAN53555 regulators, while
>> RK8602/RK8603 are a bit different, having a wider voltage selection
>> range.
>>
>> Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
>> ---
>> .../bindings/regulator/fcs,fan53555.yaml | 22 ++++++++++++++-----
>> 1 file changed, 16 insertions(+), 6 deletions(-)
>>
>> diff --git a/Documentation/devicetree/bindings/regulator/fcs,fan53555.yaml b/Documentation/devicetree/bindings/regulator/fcs,fan53555.yaml
>> index c0dbba843f70..7547c130ff7d 100644
>> --- a/Documentation/devicetree/bindings/regulator/fcs,fan53555.yaml
>> +++ b/Documentation/devicetree/bindings/regulator/fcs,fan53555.yaml
>> @@ -14,12 +14,22 @@ allOf:
>>
>> properties:
>> compatible:
>> - enum:
>> - - fcs,fan53555
>> - - fcs,fan53526
>> - - silergy,syr827
>> - - silergy,syr828
>> - - tcs,tcs4525
>> + oneOf:
>> + - items:
>
> Drop items here. It's just an enum.
Indeed, sorry, will prepare v3.
Thanks for reviewing,
Cristian
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: (subset) [PATCH v2 0/8] Add support for Rockchip RK860X regulators
2023-04-06 17:17 [PATCH v2 0/8] Add support for Rockchip RK860X regulators Cristian Ciocaltea
` (7 preceding siblings ...)
2023-04-06 17:18 ` [PATCH v2 8/8] regulator: fan53555: Add support for RK860X Cristian Ciocaltea
@ 2023-04-06 21:31 ` Mark Brown
8 siblings, 0 replies; 13+ messages in thread
From: Mark Brown @ 2023-04-06 21:31 UTC (permalink / raw)
To: Liam Girdwood, Rob Herring, Krzysztof Kozlowski, Heiko Stuebner,
Bjorn Andersson, Joseph Chen, Ezequiel Garcia,
Cristian Ciocaltea
Cc: linux-kernel, devicetree, kernel
On Thu, 06 Apr 2023 20:17:58 +0300, Cristian Ciocaltea wrote:
> This patch series introduces support for the Rockchip RK860X regulators,
> while also providing a few fixes and improvements to the existing fan53555
> driver.
>
> RK8600/RK8601 are fully compatible with the FAN53555 regulators.
>
> RK8602/RK8603 are a bit different, having a wider output voltage
> selection range, from 0.5 V to 1.5 V in 6.25 mV steps. They are used
> in the Rock 5B board to power the ARM Cortex-A76 cores and the NPU.
>
> [...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git for-next
Thanks!
[2/8] regulator: fan53555: Explicitly include bits header
commit: 4fb9a5060f73627303bc531ceaab1b19d0a24aef
[3/8] regulator: fan53555: Fix wrong TCS_SLEW_MASK
commit: c5d5b55b3c1a314137a251efc1001dfd435c6242
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
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2023-04-06 21:31 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-06 17:17 [PATCH v2 0/8] Add support for Rockchip RK860X regulators Cristian Ciocaltea
2023-04-06 17:17 ` [PATCH v2 1/8] regulator: dt-bindings: fcs,fan53555: Add support for RK860X Cristian Ciocaltea
2023-04-06 18:14 ` Krzysztof Kozlowski
2023-04-06 19:17 ` Cristian Ciocaltea
2023-04-06 17:18 ` [PATCH v2 2/8] regulator: fan53555: Explicitly include bits header Cristian Ciocaltea
2023-04-06 17:18 ` [PATCH v2 3/8] regulator: fan53555: Fix wrong TCS_SLEW_MASK Cristian Ciocaltea
2023-04-06 17:18 ` [PATCH v2 4/8] regulator: fan53555: Remove unused *_SLEW_SHIFT definitions Cristian Ciocaltea
2023-04-06 17:18 ` [PATCH v2 5/8] regulator: fan53555: Make use of the bit macros Cristian Ciocaltea
2023-04-06 17:18 ` [PATCH v2 6/8] regulator: fan53555: Improve vsel_mask computation Cristian Ciocaltea
2023-04-06 17:18 ` [PATCH v2 7/8] regulator: fan53555: Use dev_err_probe Cristian Ciocaltea
2023-04-06 17:18 ` [PATCH v2 8/8] regulator: fan53555: Add support for RK860X Cristian Ciocaltea
2023-04-06 18:15 ` Krzysztof Kozlowski
2023-04-06 21:31 ` (subset) [PATCH v2 0/8] Add support for Rockchip RK860X regulators Mark Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®