Skip to contentSkip to conversation

regulator: add support for syr82x to fan53555

PATCH Applied Heiko Stuebner 2 participants 14 messages Sep 14, 2014 – Sep 15, 2014

Subsystems (2)

v1 of 3 Applied Latest is v3 →

lore
Share & tools
lore
#0 lore raw

cover regulator: add support for syr82x to fan53555

Silergy SYR827 and SYR828 regulators use the completely same i2c interface as the fan53555 regulators - only with different voltage ranges. They are used in a some Rockchip rk3288 board designs around an act8846.

Therefore first add devicetree support for the fan53555 in general and then support for the Silgery variants.

Tested on a rk3288 based Netxeon R89 board as cpu voltage regulator.

Heiko Stuebner (5):
regulator: fan53555: enable vin supply
regulator: fan53555: set regulator name from constraints name
dt-bindings: add devicetree bindings for Fairchild FAN53555 regulators
regulator: fan53555: add devicetree support
regulator: fan53555: add support for Silergy SYR82x regulators

 .../devicetree/bindings/regulator/fan53555.txt     |  25 ++++
 .../devicetree/bindings/vendor-prefixes.txt        |   2 +
 drivers/regulator/fan53555.c                       | 161 +++++++++++++++++++--
 3 files changed, 174 insertions(+), 14 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/regulator/fan53555.txt
Signature · 1 line
2.0.1
#1 lore raw

PATCH 1/5 regulator: fan53555: enable vin supply

The regulator can be supplied by a parent regulator through its vin pin, so add the supply_name for it.

---
 drivers/regulator/fan53555.c | 1 +
 1 file changed, 1 insertion(+)
drivers/regulator/fan53555.c +1 -0
index 714fd9a..c912ba7 100644
@@ -207,6 +207,7 @@ static int fan53555_regulator_register(struct fan53555_device_info *di,
 	struct regulator_desc *rdesc = &di->desc;
 
 	rdesc->name = "fan53555-reg";
+	rdesc->supply_name = "vin";
 	rdesc->ops = &fan53555_regulator_ops;
 	rdesc->type = REGULATOR_VOLTAGE;
 	rdesc->n_voltages = FAN53555_NVOLTAGES;
Signature · 1 line
2.0.1
maintainer Applied
#2 lore raw

Re: [PATCH 1/5] regulator: fan53555: enable vin supply

Quoted 2 lines · Heiko Stuebner

The regulator can be supplied by a parent regulator through its vin pin, so add the supply_name for it.

Applied, thanks.

#3 lore raw

PATCH 2/5 regulator: fan53555: set regulator name from constraints name

In reply to Heiko Stuebner

There is a high potential of more than one of those regulators existing on a board, so name the regulator according to the name provided in the initdata instead of statically.

---
 drivers/regulator/fan53555.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/regulator/fan53555.c +6 -1
index c912ba7..d143790 100644
@@ -206,7 +206,12 @@ static int fan53555_regulator_register(struct fan53555_device_info *di,
 {
 	struct regulator_desc *rdesc = &di->desc;
 
-	rdesc->name = "fan53555-reg";
+	rdesc->name = devm_kstrdup(di->dev,
+				   di->regulator->constraints.name,
+				   GFP_KERNEL);
+	if (!rdesc->name)
+		return -ENOMEM;
+
 	rdesc->supply_name = "vin";
 	rdesc->ops = &fan53555_regulator_ops;
 	rdesc->type = REGULATOR_VOLTAGE;
Signature · 1 line
2.0.1
maintainer
#4 lore raw

Re: [PATCH 2/5] regulator: fan53555: set regulator name from constraints name

Quoted 3 lines · Heiko Stuebner

There is a high potential of more than one of those regulators existing on a board, so name the regulator according to the name provided in the initdata instead of statically.

No, this is pointless and broken. The core will already use the board-specific name to identify the regulator in diagnostics and so on, the name being supplied here is supposed to describe the regulator within the device.

#5 lore raw

Re: [PATCH 2/5] regulator: fan53555: set regulator name from constraints name

Am Montag, 15. September 2014, 09:59:23 schrieb Mark Brown:

Quoted 9 lines · Heiko Stuebner
Quoted 3 lines

There is a high potential of more than one of those regulators existing on a board, so name the regulator according to the name provided in the initdata instead of statically.

No, this is pointless and broken. The core will already use the board-specific name to identify the regulator in diagnostics and so on, the name being supplied here is supposed to describe the regulator within the device.

ok, sorry for the mess-up

I've just tested, patches 3-5 apply and work correctly without this one, so do you want to apply them like this or a resend of last 3?

Heiko

maintainer
#6 lore raw

Re: [PATCH 2/5] regulator: fan53555: set regulator name from constraints name

Quoted 2 lines · Heiko Stübner

I've just tested, patches 3-5 apply and work correctly without this one, so do you want to apply them like this or a resend of last 3?

No, please implement the changes I asked for in the DT stuff.

#7 lore raw

PATCH 3/5 dt-bindings: add devicetree bindings for Fairchild FAN53555 regulators

In reply to Heiko Stuebner

Document the regulator and add a fairchild vendor-prefix.

---
 .../devicetree/bindings/regulator/fan53555.txt     | 25 ++++++++++++++++++++++
 .../devicetree/bindings/vendor-prefixes.txt        |  1 +
 2 files changed, 26 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/regulator/fan53555.txt
Documentation/devicetree/bindings/regulator/fan53555.txt new file +25 -0
new file mode 100644
index 0000000..2484497
@@ -0,0 +1,25 @@
+Binding for Fairchild FAN53555 regulators
+
+Required properties:
+  - compatible: "fairchild,fan53555"
+  - reg: I2C address
+
+Optional properties:
+  - fairchild,suspend-regulator: regulator number to use for suspend voltages
+		possible values are either <0> or <1>
+  - fairchild,slew-rate-microvolt: slew rate to use for positive voltage
+		transistions in microvolts per us, possible values are:
+		64000, 32000, 16000, 8000, 4000, 2000, 1000, 500
+  - vin-supply: regulator supplying the vin pin
+
+Example:
+
+	regulator@40 {
+		compatible = "fairchild,fan53555";
+		regulator-name = "fan53555";
+		regulator-min-microvolt = <1000000>;
+		regulator-max-microvolt = <1800000>;
+		vin-supply = <&parent_reg>;
+		fairchild,suspend-regulator = <1>;
+		fairchild,slew-rate-microvolt = <64000>;
+	};
Documentation/devicetree/bindings/vendor-prefixes.txt +1 -0
index ac7269f..99da41b 100644
@@ -49,6 +49,7 @@ epson	Seiko Epson Corp.
 est	ESTeem Wireless Modems
 eukrea  Eukréa Electromatique
 excito	Excito
+fairchild	Fairchild Semiconductor
 fsl	Freescale Semiconductor
 GEFanuc	GE Fanuc Intelligent Platforms Embedded Systems, Inc.
 gef	GE Fanuc Intelligent Platforms Embedded Systems, Inc.
Signature · 1 line
2.0.1
maintainer
#8 lore raw

Re: [PATCH 3/5] dt-bindings: add devicetree bindings for Fairchild FAN53555 regulators

Documentation/devicetree/bindings/regulator/fan53555.txt line 9

Quoted 3 lines · Heiko Stuebner
Documentation/devicetree/bindings/regulator/fan53555.txt new file +3 -0
+Optional properties:
+  - fairchild,suspend-regulator: regulator number to use for suspend voltages
+		possible values are either <0> or <1>

I'm not sure what this means - What exactly is a "regulator" in this context? Are there really two separate regulators?

#9 lore raw

Re: [PATCH 3/5] dt-bindings: add devicetree bindings for Fairchild FAN53555 regulators

Am Montag, 15. September 2014, 14:54:10 schrieb Mark Brown:

Quoted 7 lines · Heiko Stuebner
Quoted 3 lines
(quoted diff) +2 -0
+Optional properties:
+  - fairchild,suspend-regulator: regulator number to use for suspend

voltages + possible values are either <0> or <1>

I'm not sure what this means - What exactly is a "regulator" in this context? Are there really two separate regulators?

The fan53555 has two voltage selection registers (VSEL0 and VSEL1) which can be switched through a gpio ... to use one as suspend voltage.

So it's just one regulator output but can select one of two voltages.

maintainer
#10 lore raw

Re: [PATCH 3/5] dt-bindings: add devicetree bindings for Fairchild FAN53555 regulators

Quoted 9 lines · Heiko Stübner

Am Montag, 15. September 2014, 14:54:10 schrieb Mark Brown:

Quoted 2 lines

I'm not sure what this means - What exactly is a "regulator" in this context? Are there really two separate regulators?

The fan53555 has two voltage selection registers (VSEL0 and VSEL1) which can be switched through a gpio ... to use one as suspend voltage.

So it's just one regulator output but can select one of two voltages.

OK, that's what I thought was going on - please fix this to be described in terms of voltage selector registers rather than regulators as what's there now seems confusing.

#11 lore raw

PATCH 4/5 regulator: fan53555: add devicetree support

In reply to Heiko Stuebner

Add the ability to parse regulator-data from the devicetree.

---
 drivers/regulator/fan53555.c | 53 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 53 insertions(+)
drivers/regulator/fan53555.c +53 -0
index d143790..0ec1762 100644
@@ -18,6 +18,7 @@
 #include <linux/platform_device.h>
 #include <linux/regulator/driver.h>
 #include <linux/regulator/machine.h>
+#include <linux/regulator/of_regulator.h>
 #include <linux/i2c.h>
 #include <linux/slab.h>
 #include <linux/regmap.h>
@@ -233,9 +234,48 @@ static struct regmap_config fan53555_regmap_config = {
 	.val_bits = 8,
 };
 
+static int slew_rates[] = {
+	64000,
+	32000,
+	16000,
+	 8000,
+	 4000,
+	 2000,
+	 1000,
+	  500,
+};
+
+static struct fan53555_platform_data *fan53555_parse_dt(struct device *dev,
+							struct device_node *np)
+{
+	struct fan53555_platform_data *pdata;
+	int ret, i;
+	u32 tmp;
+
+	pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
+	if (!pdata)
+		return NULL;
+
+	pdata->regulator = of_get_regulator_init_data(dev, np);
+
+	ret = of_property_read_u32(np, "fairchild,suspend-regulator", &tmp);
+	if (!ret)
+		pdata->sleep_vsel_id = tmp;
+
+	ret = of_property_read_u32(np, "fairchild,slew-rate-microvolt", &tmp);
+	if (!ret) {
+		for (i = 0; i < ARRAY_SIZE(slew_rates); i++)
+			if (slew_rates[i] == tmp)
+				pdata->slew_rate = i;
+	}
+
+	return pdata;
+}
+
 static int fan53555_regulator_probe(struct i2c_client *client,
 				const struct i2c_device_id *id)
 {
+	struct device_node *np = client->dev.of_node;
 	struct fan53555_device_info *di;
 	struct fan53555_platform_data *pdata;
 	struct regulator_config config = { };
@@ -243,6 +283,9 @@ static int fan53555_regulator_probe(struct i2c_client *client,
 	int ret;
 
 	pdata = dev_get_platdata(&client->dev);
+	if (!pdata)
+		pdata = fan53555_parse_dt(&client->dev, np);
+
 	if (!pdata || !pdata->regulator) {
 		dev_err(&client->dev, "Platform data not found!\n");
 		return -ENODEV;
@@ -283,11 +326,14 @@ static int fan53555_regulator_probe(struct i2c_client *client,
 		dev_err(&client->dev, "Failed to setup device!\n");
 		return ret;
 	}
+
 	/* Register regulator */
 	config.dev = di->dev;
 	config.init_data = di->regulator;
 	config.regmap = di->regmap;
 	config.driver_data = di;
+	config.of_node = np;
+
 	ret = fan53555_regulator_register(di, &config);
 	if (ret < 0)
 		dev_err(&client->dev, "Failed to register regulator!\n");
@@ -295,6 +341,12 @@ static int fan53555_regulator_probe(struct i2c_client *client,
 
 }
 
+static const struct of_device_id fan53555_dt_ids[] = {
+	{ .compatible = "fairchild,fan53555" },
+	{ }
+};
+MODULE_DEVICE_TABLE(of, fan53555_dt_ids);
+
 static const struct i2c_device_id fan53555_id[] = {
 	{"fan53555", -1},
 	{ },
@@ -303,6 +355,7 @@ static const struct i2c_device_id fan53555_id[] = {
 static struct i2c_driver fan53555_regulator_driver = {
 	.driver = {
 		.name = "fan53555-regulator",
+		.of_match_table = of_match_ptr(fan53555_dt_ids),
 	},
 	.probe = fan53555_regulator_probe,
 	.id_table = fan53555_id,
Signature · 1 line
2.0.1
#12 lore raw

PATCH 5/5 regulator: fan53555: add support for Silergy SYR82x regulators

In reply to Heiko Stuebner

Silergy SYR82x regulators share the exact same functionality and register layout as the Fairchild FAN53555 regulators. Therefore extend the driver to add support for them.

Both types use the same vendor id in their ID1 register, so it's not possible to distinguish them automatically.

Similarly, the types also do not match. Type 8 used by the SYR827 and SYR828 start at 712.5mV and increment in 12.5mv steps, while the FAN53555 type 8 starts at 600mV and increments in 10mV steps.

---
 .../devicetree/bindings/regulator/fan53555.txt     |   2 +-
 .../devicetree/bindings/vendor-prefixes.txt        |   1 +
 drivers/regulator/fan53555.c                       | 112 +++++++++++++++++----
 3 files changed, 95 insertions(+), 20 deletions(-)
Documentation/devicetree/bindings/regulator/fan53555.txt +1 -1
index 2484497..b26f278 100644
@@ -1,7 +1,7 @@
 Binding for Fairchild FAN53555 regulators
 
 Required properties:
-  - compatible: "fairchild,fan53555"
+  - compatible: one of "fairchild,fan53555", "silergy,syr827", "silergy,syr828"
   - reg: I2C address
 
 Optional properties:
Documentation/devicetree/bindings/vendor-prefixes.txt +1 -0
index 99da41b..9e34820 100644
@@ -125,6 +125,7 @@ sil	Silicon Image
 silabs	Silicon Laboratories
 simtek
 sii	Seiko Instruments, Inc.
+silergy	Silergy Corp.
 sirf	SiRF Technology, Inc.
 smsc	Standard Microsystems Corporation
 snps 	Synopsys, Inc.
drivers/regulator/fan53555.c +93 -19

174 lines not on this page · raw message

Signature · 1 line
2.0.1
maintainer
#13 lore raw

Re: [PATCH 5/5] regulator: fan53555: add support for Silergy SYR82x regulators

Quoted 3 lines · Heiko Stuebner

Silergy SYR82x regulators share the exact same functionality and register layout as the Fairchild FAN53555 regulators. Therefore extend the driver to add support for them.

This seems OK but depends on the previous patches.