* [PATCH v2 0/4] regulator: add support for syr82x to fan53555
@ 2014-09-16 15:54 Heiko Stuebner
2014-09-16 15:54 ` [PATCH v2 1/4] regulator: fan53555: use set_ramp_delay to set the ramp up slew rate Heiko Stuebner
` (3 more replies)
0 siblings, 4 replies; 8+ messages in thread
From: Heiko Stuebner @ 2014-09-16 15:54 UTC (permalink / raw)
To: broonie
Cc: linux-kernel, linux-rockchip, devicetree, robh+dt, pawel.moll,
mark.rutland, ijc+devicetree, galak, Heiko Stuebner
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.
changes since v1:
- drop already applied vin-supply patch
- drop wrong regulator-naming patch
- add patch to generalize ramp_delay handling
Heiko Stuebner (4):
regulator: fan53555: use set_ramp_delay to set the ramp up slew rate
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 | 23 +++
.../devicetree/bindings/vendor-prefixes.txt | 2 +
drivers/regulator/fan53555.c | 191 ++++++++++++++++++---
3 files changed, 193 insertions(+), 23 deletions(-)
create mode 100644 Documentation/devicetree/bindings/regulator/fan53555.txt
--
2.0.1
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v2 1/4] regulator: fan53555: use set_ramp_delay to set the ramp up slew rate
2014-09-16 15:54 [PATCH v2 0/4] regulator: add support for syr82x to fan53555 Heiko Stuebner
@ 2014-09-16 15:54 ` Heiko Stuebner
2014-09-16 15:54 ` [PATCH v2 2/4] dt-bindings: add devicetree bindings for Fairchild FAN53555 regulators Heiko Stuebner
` (2 subsequent siblings)
3 siblings, 0 replies; 8+ messages in thread
From: Heiko Stuebner @ 2014-09-16 15:54 UTC (permalink / raw)
To: broonie
Cc: linux-kernel, linux-rockchip, devicetree, robh+dt, pawel.moll,
mark.rutland, ijc+devicetree, galak, Heiko Stuebner
The regulator constraints already provide a field for the ramp_delay, so
there is no need to set this manually. Therefore implement the set_ramp_delay
callback and convert the pdata value to the constraint value if necessary.
Signed-off-by: Heiko Stuebner <heiko@sntech.de>
---
drivers/regulator/fan53555.c | 53 +++++++++++++++++++++++++++++++++++---------
1 file changed, 42 insertions(+), 11 deletions(-)
diff --git a/drivers/regulator/fan53555.c b/drivers/regulator/fan53555.c
index c912ba7..5808435 100644
--- a/drivers/regulator/fan53555.c
+++ b/drivers/regulator/fan53555.c
@@ -135,6 +135,38 @@ static unsigned int fan53555_get_mode(struct regulator_dev *rdev)
return REGULATOR_MODE_NORMAL;
}
+static int slew_rates[] = {
+ 64000,
+ 32000,
+ 16000,
+ 8000,
+ 4000,
+ 2000,
+ 1000,
+ 500,
+};
+
+static int fan53555_set_ramp(struct regulator_dev *rdev, int ramp)
+{
+ struct fan53555_device_info *di = rdev_get_drvdata(rdev);
+ int regval = -1, i;
+
+ for (i = 0; i < ARRAY_SIZE(slew_rates); i++) {
+ if (ramp <= slew_rates[i])
+ regval = i;
+ else
+ break;
+ }
+
+ if (regval < 0) {
+ dev_err(di->dev, "unsupported ramp value %d\n", ramp);
+ return -EINVAL;
+ }
+
+ return regmap_update_bits(di->regmap, FAN53555_CONTROL,
+ CTL_SLEW_MASK, regval << CTL_SLEW_SHIFT);
+}
+
static struct regulator_ops fan53555_regulator_ops = {
.set_voltage_sel = regulator_set_voltage_sel_regmap,
.get_voltage_sel = regulator_get_voltage_sel_regmap,
@@ -146,6 +178,7 @@ static struct regulator_ops fan53555_regulator_ops = {
.is_enabled = regulator_is_enabled_regmap,
.set_mode = fan53555_set_mode,
.get_mode = fan53555_get_mode,
+ .set_ramp_delay = fan53555_set_ramp,
};
/* For 00,01,03,05 options:
@@ -156,8 +189,6 @@ static struct regulator_ops fan53555_regulator_ops = {
static int fan53555_device_setup(struct fan53555_device_info *di,
struct fan53555_platform_data *pdata)
{
- unsigned int reg, data, mask;
-
/* Setup voltage control register */
switch (pdata->sleep_vsel_id) {
case FAN53555_VSEL_ID_0:
@@ -190,15 +221,8 @@ static int fan53555_device_setup(struct fan53555_device_info *di,
"Chip ID[%d]\n not supported!\n", di->chip_id);
return -EINVAL;
}
- /* Init slew rate */
- if (pdata->slew_rate & 0x7)
- di->slew_rate = pdata->slew_rate;
- else
- di->slew_rate = FAN53555_SLEW_RATE_64MV;
- reg = FAN53555_CONTROL;
- data = di->slew_rate << CTL_SLEW_SHIFT;
- mask = CTL_SLEW_MASK;
- return regmap_update_bits(di->regmap, reg, mask, data);
+
+ return 0;
}
static int fan53555_regulator_register(struct fan53555_device_info *di,
@@ -248,6 +272,13 @@ static int fan53555_regulator_probe(struct i2c_client *client,
if (!di)
return -ENOMEM;
+ /* if no ramp constraint set, get the pdata ramp_delay */
+ if (!di->regulator->constraints.ramp_delay) {
+ int slew_idx = (pdata->slew_rate & 0x7) ? pdata->slew_rate : 0;
+
+ di->regulator->constraints.ramp_delay = slew_rates[slew_idx];
+ }
+
di->regmap = devm_regmap_init_i2c(client, &fan53555_regmap_config);
if (IS_ERR(di->regmap)) {
dev_err(&client->dev, "Failed to allocate regmap!\n");
--
2.0.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v2 2/4] dt-bindings: add devicetree bindings for Fairchild FAN53555 regulators
2014-09-16 15:54 [PATCH v2 0/4] regulator: add support for syr82x to fan53555 Heiko Stuebner
2014-09-16 15:54 ` [PATCH v2 1/4] regulator: fan53555: use set_ramp_delay to set the ramp up slew rate Heiko Stuebner
@ 2014-09-16 15:54 ` Heiko Stuebner
2014-09-16 16:55 ` Mark Brown
2014-09-16 15:54 ` [PATCH v2 3/4] regulator: fan53555: add devicetree support Heiko Stuebner
2014-09-16 15:54 ` Heiko Stuebner
3 siblings, 1 reply; 8+ messages in thread
From: Heiko Stuebner @ 2014-09-16 15:54 UTC (permalink / raw)
To: broonie
Cc: linux-kernel, linux-rockchip, devicetree, robh+dt, pawel.moll,
mark.rutland, ijc+devicetree, galak, Heiko Stuebner
Document the regulator and add a fairchild vendor-prefix.
Signed-off-by: Heiko Stuebner <heiko@sntech.de>
---
.../devicetree/bindings/regulator/fan53555.txt | 23 ++++++++++++++++++++++
.../devicetree/bindings/vendor-prefixes.txt | 1 +
2 files changed, 24 insertions(+)
create mode 100644 Documentation/devicetree/bindings/regulator/fan53555.txt
diff --git a/Documentation/devicetree/bindings/regulator/fan53555.txt b/Documentation/devicetree/bindings/regulator/fan53555.txt
new file mode 100644
index 0000000..4917564
--- /dev/null
+++ b/Documentation/devicetree/bindings/regulator/fan53555.txt
@@ -0,0 +1,23 @@
+Binding for Fairchild FAN53555 regulators
+
+Required properties:
+ - compatible: "fairchild,fan53555"
+ - reg: I2C address
+
+Optional properties:
+ - fairchild,suspend-voltage-selector: declare which of the two available
+ voltage selector registers should be used for the suspend
+ voltage. The other one is used for the runtime voltage setting
+ Possible values are either <0> or <1>
+ - 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-voltage-selector = <1>;
+ };
diff --git a/Documentation/devicetree/bindings/vendor-prefixes.txt b/Documentation/devicetree/bindings/vendor-prefixes.txt
index ac7269f..99da41b 100644
--- a/Documentation/devicetree/bindings/vendor-prefixes.txt
+++ b/Documentation/devicetree/bindings/vendor-prefixes.txt
@@ -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.
--
2.0.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v2 3/4] regulator: fan53555: add devicetree support
2014-09-16 15:54 [PATCH v2 0/4] regulator: add support for syr82x to fan53555 Heiko Stuebner
2014-09-16 15:54 ` [PATCH v2 1/4] regulator: fan53555: use set_ramp_delay to set the ramp up slew rate Heiko Stuebner
2014-09-16 15:54 ` [PATCH v2 2/4] dt-bindings: add devicetree bindings for Fairchild FAN53555 regulators Heiko Stuebner
@ 2014-09-16 15:54 ` Heiko Stuebner
2014-09-16 15:54 ` Heiko Stuebner
3 siblings, 0 replies; 8+ messages in thread
From: Heiko Stuebner @ 2014-09-16 15:54 UTC (permalink / raw)
To: broonie
Cc: linux-kernel, linux-rockchip, devicetree, robh+dt, pawel.moll,
mark.rutland, ijc+devicetree, galak, Heiko Stuebner
Add the ability to parse regulator-data from the devicetree.
Signed-off-by: Heiko Stuebner <heiko@sntech.de>
---
drivers/regulator/fan53555.c | 50 ++++++++++++++++++++++++++++++++++++++++----
1 file changed, 46 insertions(+), 4 deletions(-)
diff --git a/drivers/regulator/fan53555.c b/drivers/regulator/fan53555.c
index 5808435..fb19fae 100644
--- a/drivers/regulator/fan53555.c
+++ b/drivers/regulator/fan53555.c
@@ -18,6 +18,8 @@
#include <linux/platform_device.h>
#include <linux/regulator/driver.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>
@@ -252,9 +254,39 @@ static struct regmap_config fan53555_regmap_config = {
.val_bits = 8,
};
+static struct fan53555_platform_data *fan53555_parse_dt(struct device *dev,
+ struct device_node *np)
+{
+ struct fan53555_platform_data *pdata;
+ int ret;
+ 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-voltage-selector",
+ &tmp);
+ if (!ret)
+ pdata->sleep_vsel_id = tmp;
+
+ return pdata;
+}
+
+static const struct of_device_id fan53555_dt_ids[] = {
+ {
+ .compatible = "fairchild,fan53555",
+ },
+ { }
+};
+MODULE_DEVICE_TABLE(of, fan53555_dt_ids);
+
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 = { };
@@ -262,6 +294,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;
@@ -272,11 +307,15 @@ static int fan53555_regulator_probe(struct i2c_client *client,
if (!di)
return -ENOMEM;
- /* if no ramp constraint set, get the pdata ramp_delay */
- if (!di->regulator->constraints.ramp_delay) {
- int slew_idx = (pdata->slew_rate & 0x7) ? pdata->slew_rate : 0;
+ if (!client->dev.of_node) {
+ /* if no ramp constraint set, get the pdata ramp_delay */
+ if (!di->regulator->constraints.ramp_delay) {
+ int slew_idx = (pdata->slew_rate & 0x7)
+ ? pdata->slew_rate : 0;
- di->regulator->constraints.ramp_delay = slew_rates[slew_idx];
+ di->regulator->constraints.ramp_delay
+ = slew_rates[slew_idx];
+ }
}
di->regmap = devm_regmap_init_i2c(client, &fan53555_regmap_config);
@@ -314,6 +353,8 @@ static int fan53555_regulator_probe(struct i2c_client *client,
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");
@@ -329,6 +370,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,
--
2.0.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v2 4/4] regulator: fan53555: add support for Silergy SYR82x regulators
@ 2014-09-16 15:54 ` Heiko Stuebner
0 siblings, 0 replies; 8+ messages in thread
From: Heiko Stuebner @ 2014-09-16 15:54 UTC (permalink / raw)
To: broonie
Cc: linux-kernel, linux-rockchip, devicetree, robh+dt, pawel.moll,
mark.rutland, ijc+devicetree, galak, 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.
Signed-off-by: Heiko Stuebner <heiko@sntech.de>
---
.../devicetree/bindings/regulator/fan53555.txt | 2 +-
.../devicetree/bindings/vendor-prefixes.txt | 1 +
drivers/regulator/fan53555.c | 102 ++++++++++++++++++---
3 files changed, 89 insertions(+), 16 deletions(-)
diff --git a/Documentation/devicetree/bindings/regulator/fan53555.txt b/Documentation/devicetree/bindings/regulator/fan53555.txt
index 4917564..f426afc 100644
--- a/Documentation/devicetree/bindings/regulator/fan53555.txt
+++ b/Documentation/devicetree/bindings/regulator/fan53555.txt
@@ -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:
diff --git a/Documentation/devicetree/bindings/vendor-prefixes.txt b/Documentation/devicetree/bindings/vendor-prefixes.txt
index 99da41b..9e34820 100644
--- a/Documentation/devicetree/bindings/vendor-prefixes.txt
+++ b/Documentation/devicetree/bindings/vendor-prefixes.txt
@@ -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.
diff --git a/drivers/regulator/fan53555.c b/drivers/regulator/fan53555.c
index fb19fae..8905c9e 100644
--- a/drivers/regulator/fan53555.c
+++ b/drivers/regulator/fan53555.c
@@ -52,6 +52,11 @@
#define FAN53555_NVOLTAGES 64 /* Numbers of voltages */
+enum fan53555_vendor {
+ FAN53555_VENDOR_FAIRCHILD = 0,
+ FAN53555_VENDOR_SILERGY,
+};
+
/* IC Type */
enum {
FAN53555_CHIP_ID_00 = 0,
@@ -62,7 +67,12 @@ enum {
FAN53555_CHIP_ID_05,
};
+enum {
+ SILERGY_SYR82X = 8,
+};
+
struct fan53555_device_info {
+ enum fan53555_vendor vendor;
struct regmap *regmap;
struct device *dev;
struct regulator_desc desc;
@@ -183,6 +193,47 @@ static struct regulator_ops fan53555_regulator_ops = {
.set_ramp_delay = fan53555_set_ramp,
};
+static int fan53555_voltages_setup_fairchild(struct fan53555_device_info *di)
+{
+ /* Init voltage range and step */
+ switch (di->chip_id) {
+ case FAN53555_CHIP_ID_00:
+ case FAN53555_CHIP_ID_01:
+ case FAN53555_CHIP_ID_03:
+ case FAN53555_CHIP_ID_05:
+ di->vsel_min = 600000;
+ di->vsel_step = 10000;
+ break;
+ case FAN53555_CHIP_ID_04:
+ di->vsel_min = 603000;
+ di->vsel_step = 12826;
+ break;
+ default:
+ dev_err(di->dev,
+ "Chip ID %d not supported!\n", di->chip_id);
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
+static int fan53555_voltages_setup_silergy(struct fan53555_device_info *di)
+{
+ /* Init voltage range and step */
+ switch (di->chip_id) {
+ case SILERGY_SYR82X:
+ 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;
+ }
+
+ return 0;
+}
+
/* For 00,01,03,05 options:
* VOUT = 0.60V + NSELx * 10mV, from 0.60 to 1.23V.
* For 04 option:
@@ -191,6 +242,8 @@ static struct regulator_ops fan53555_regulator_ops = {
static int fan53555_device_setup(struct fan53555_device_info *di,
struct fan53555_platform_data *pdata)
{
+ int ret = 0;
+
/* Setup voltage control register */
switch (pdata->sleep_vsel_id) {
case FAN53555_VSEL_ID_0:
@@ -205,26 +258,21 @@ static int fan53555_device_setup(struct fan53555_device_info *di,
dev_err(di->dev, "Invalid VSEL ID!\n");
return -EINVAL;
}
- /* Init voltage range and step */
- switch (di->chip_id) {
- case FAN53555_CHIP_ID_00:
- case FAN53555_CHIP_ID_01:
- case FAN53555_CHIP_ID_03:
- case FAN53555_CHIP_ID_05:
- di->vsel_min = 600000;
- di->vsel_step = 10000;
+
+ switch (di->vendor) {
+ case FAN53555_VENDOR_FAIRCHILD:
+ ret = fan53555_voltages_setup_fairchild(di);
break;
- case FAN53555_CHIP_ID_04:
- di->vsel_min = 603000;
- di->vsel_step = 12826;
+ case FAN53555_VENDOR_SILERGY:
+ ret = fan53555_voltages_setup_silergy(di);
break;
default:
dev_err(di->dev,
- "Chip ID[%d]\n not supported!\n", di->chip_id);
+ "vendor %d not supported!\n", di->chip_id);
return -EINVAL;
}
- return 0;
+ return ret;
}
static int fan53555_regulator_register(struct fan53555_device_info *di,
@@ -278,6 +326,13 @@ static struct fan53555_platform_data *fan53555_parse_dt(struct device *dev,
static const struct of_device_id fan53555_dt_ids[] = {
{
.compatible = "fairchild,fan53555",
+ .data = (void *)FAN53555_VENDOR_FAIRCHILD
+ }, {
+ .compatible = "silergy,syr827",
+ .data = (void *)FAN53555_VENDOR_SILERGY,
+ }, {
+ .compatible = "silergy,syr828",
+ .data = (void *)FAN53555_VENDOR_SILERGY,
},
{ }
};
@@ -307,7 +362,16 @@ static int fan53555_regulator_probe(struct i2c_client *client,
if (!di)
return -ENOMEM;
- if (!client->dev.of_node) {
+ if (client->dev.of_node) {
+ const struct of_device_id *match;
+
+ match = of_match_device(of_match_ptr(fan53555_dt_ids),
+ &client->dev);
+ if (!match)
+ return -ENODEV;
+
+ di->vendor = (int) match->data;
+ } else {
/* if no ramp constraint set, get the pdata ramp_delay */
if (!di->regulator->constraints.ramp_delay) {
int slew_idx = (pdata->slew_rate & 0x7)
@@ -316,6 +380,8 @@ static int fan53555_regulator_probe(struct i2c_client *client,
di->regulator->constraints.ramp_delay
= slew_rates[slew_idx];
}
+
+ di->vendor = id->driver_data;
}
di->regmap = devm_regmap_init_i2c(client, &fan53555_regmap_config);
@@ -363,7 +429,13 @@ static int fan53555_regulator_probe(struct i2c_client *client,
}
static const struct i2c_device_id fan53555_id[] = {
- {"fan53555", -1},
+ {
+ .name = "fan53555",
+ .driver_data = FAN53555_VENDOR_FAIRCHILD
+ }, {
+ .name = "syr82x",
+ .driver_data = FAN53555_VENDOR_SILERGY
+ },
{ },
};
--
2.0.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v2 4/4] regulator: fan53555: add support for Silergy SYR82x regulators
@ 2014-09-16 15:54 ` Heiko Stuebner
0 siblings, 0 replies; 8+ messages in thread
From: Heiko Stuebner @ 2014-09-16 15:54 UTC (permalink / raw)
To: broonie-DgEjT+Ai2ygdnm+yROfE0A
Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA,
linux-rockchip-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
devicetree-u79uwXL29TY76Z2rM5mHXA,
robh+dt-DgEjT+Ai2ygdnm+yROfE0A, pawel.moll-5wv7dgnIgG8,
mark.rutland-5wv7dgnIgG8, ijc+devicetree-KcIKpvwj1kUDXYZnReoRVg,
galak-sgV2jX0FEOL9JmXXK+q4OQ, 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.
Signed-off-by: Heiko Stuebner <heiko-4mtYJXux2i+zQB+pC5nmwQ@public.gmane.org>
---
.../devicetree/bindings/regulator/fan53555.txt | 2 +-
.../devicetree/bindings/vendor-prefixes.txt | 1 +
drivers/regulator/fan53555.c | 102 ++++++++++++++++++---
3 files changed, 89 insertions(+), 16 deletions(-)
diff --git a/Documentation/devicetree/bindings/regulator/fan53555.txt b/Documentation/devicetree/bindings/regulator/fan53555.txt
index 4917564..f426afc 100644
--- a/Documentation/devicetree/bindings/regulator/fan53555.txt
+++ b/Documentation/devicetree/bindings/regulator/fan53555.txt
@@ -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:
diff --git a/Documentation/devicetree/bindings/vendor-prefixes.txt b/Documentation/devicetree/bindings/vendor-prefixes.txt
index 99da41b..9e34820 100644
--- a/Documentation/devicetree/bindings/vendor-prefixes.txt
+++ b/Documentation/devicetree/bindings/vendor-prefixes.txt
@@ -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.
diff --git a/drivers/regulator/fan53555.c b/drivers/regulator/fan53555.c
index fb19fae..8905c9e 100644
--- a/drivers/regulator/fan53555.c
+++ b/drivers/regulator/fan53555.c
@@ -52,6 +52,11 @@
#define FAN53555_NVOLTAGES 64 /* Numbers of voltages */
+enum fan53555_vendor {
+ FAN53555_VENDOR_FAIRCHILD = 0,
+ FAN53555_VENDOR_SILERGY,
+};
+
/* IC Type */
enum {
FAN53555_CHIP_ID_00 = 0,
@@ -62,7 +67,12 @@ enum {
FAN53555_CHIP_ID_05,
};
+enum {
+ SILERGY_SYR82X = 8,
+};
+
struct fan53555_device_info {
+ enum fan53555_vendor vendor;
struct regmap *regmap;
struct device *dev;
struct regulator_desc desc;
@@ -183,6 +193,47 @@ static struct regulator_ops fan53555_regulator_ops = {
.set_ramp_delay = fan53555_set_ramp,
};
+static int fan53555_voltages_setup_fairchild(struct fan53555_device_info *di)
+{
+ /* Init voltage range and step */
+ switch (di->chip_id) {
+ case FAN53555_CHIP_ID_00:
+ case FAN53555_CHIP_ID_01:
+ case FAN53555_CHIP_ID_03:
+ case FAN53555_CHIP_ID_05:
+ di->vsel_min = 600000;
+ di->vsel_step = 10000;
+ break;
+ case FAN53555_CHIP_ID_04:
+ di->vsel_min = 603000;
+ di->vsel_step = 12826;
+ break;
+ default:
+ dev_err(di->dev,
+ "Chip ID %d not supported!\n", di->chip_id);
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
+static int fan53555_voltages_setup_silergy(struct fan53555_device_info *di)
+{
+ /* Init voltage range and step */
+ switch (di->chip_id) {
+ case SILERGY_SYR82X:
+ 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;
+ }
+
+ return 0;
+}
+
/* For 00,01,03,05 options:
* VOUT = 0.60V + NSELx * 10mV, from 0.60 to 1.23V.
* For 04 option:
@@ -191,6 +242,8 @@ static struct regulator_ops fan53555_regulator_ops = {
static int fan53555_device_setup(struct fan53555_device_info *di,
struct fan53555_platform_data *pdata)
{
+ int ret = 0;
+
/* Setup voltage control register */
switch (pdata->sleep_vsel_id) {
case FAN53555_VSEL_ID_0:
@@ -205,26 +258,21 @@ static int fan53555_device_setup(struct fan53555_device_info *di,
dev_err(di->dev, "Invalid VSEL ID!\n");
return -EINVAL;
}
- /* Init voltage range and step */
- switch (di->chip_id) {
- case FAN53555_CHIP_ID_00:
- case FAN53555_CHIP_ID_01:
- case FAN53555_CHIP_ID_03:
- case FAN53555_CHIP_ID_05:
- di->vsel_min = 600000;
- di->vsel_step = 10000;
+
+ switch (di->vendor) {
+ case FAN53555_VENDOR_FAIRCHILD:
+ ret = fan53555_voltages_setup_fairchild(di);
break;
- case FAN53555_CHIP_ID_04:
- di->vsel_min = 603000;
- di->vsel_step = 12826;
+ case FAN53555_VENDOR_SILERGY:
+ ret = fan53555_voltages_setup_silergy(di);
break;
default:
dev_err(di->dev,
- "Chip ID[%d]\n not supported!\n", di->chip_id);
+ "vendor %d not supported!\n", di->chip_id);
return -EINVAL;
}
- return 0;
+ return ret;
}
static int fan53555_regulator_register(struct fan53555_device_info *di,
@@ -278,6 +326,13 @@ static struct fan53555_platform_data *fan53555_parse_dt(struct device *dev,
static const struct of_device_id fan53555_dt_ids[] = {
{
.compatible = "fairchild,fan53555",
+ .data = (void *)FAN53555_VENDOR_FAIRCHILD
+ }, {
+ .compatible = "silergy,syr827",
+ .data = (void *)FAN53555_VENDOR_SILERGY,
+ }, {
+ .compatible = "silergy,syr828",
+ .data = (void *)FAN53555_VENDOR_SILERGY,
},
{ }
};
@@ -307,7 +362,16 @@ static int fan53555_regulator_probe(struct i2c_client *client,
if (!di)
return -ENOMEM;
- if (!client->dev.of_node) {
+ if (client->dev.of_node) {
+ const struct of_device_id *match;
+
+ match = of_match_device(of_match_ptr(fan53555_dt_ids),
+ &client->dev);
+ if (!match)
+ return -ENODEV;
+
+ di->vendor = (int) match->data;
+ } else {
/* if no ramp constraint set, get the pdata ramp_delay */
if (!di->regulator->constraints.ramp_delay) {
int slew_idx = (pdata->slew_rate & 0x7)
@@ -316,6 +380,8 @@ static int fan53555_regulator_probe(struct i2c_client *client,
di->regulator->constraints.ramp_delay
= slew_rates[slew_idx];
}
+
+ di->vendor = id->driver_data;
}
di->regmap = devm_regmap_init_i2c(client, &fan53555_regmap_config);
@@ -363,7 +429,13 @@ static int fan53555_regulator_probe(struct i2c_client *client,
}
static const struct i2c_device_id fan53555_id[] = {
- {"fan53555", -1},
+ {
+ .name = "fan53555",
+ .driver_data = FAN53555_VENDOR_FAIRCHILD
+ }, {
+ .name = "syr82x",
+ .driver_data = FAN53555_VENDOR_SILERGY
+ },
{ },
};
--
2.0.1
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH v2 2/4] dt-bindings: add devicetree bindings for Fairchild FAN53555 regulators
@ 2014-09-16 16:55 ` Mark Brown
0 siblings, 0 replies; 8+ messages in thread
From: Mark Brown @ 2014-09-16 16:55 UTC (permalink / raw)
To: Heiko Stuebner
Cc: linux-kernel, linux-rockchip, devicetree, robh+dt, pawel.moll,
mark.rutland, ijc+devicetree, galak
[-- Attachment #1: Type: text/plain, Size: 646 bytes --]
On Tue, Sep 16, 2014 at 05:54:02PM +0200, Heiko Stuebner wrote:
> --- a/Documentation/devicetree/bindings/vendor-prefixes.txt
> +++ b/Documentation/devicetree/bindings/vendor-prefixes.txt
> @@ -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.
Google tells me that the stock ticker symbol for Fairchild is FCS
(sorry, should've spotted this on the previous version).
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2 2/4] dt-bindings: add devicetree bindings for Fairchild FAN53555 regulators
@ 2014-09-16 16:55 ` Mark Brown
0 siblings, 0 replies; 8+ messages in thread
From: Mark Brown @ 2014-09-16 16:55 UTC (permalink / raw)
To: Heiko Stuebner
Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA,
linux-rockchip-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
devicetree-u79uwXL29TY76Z2rM5mHXA,
robh+dt-DgEjT+Ai2ygdnm+yROfE0A, pawel.moll-5wv7dgnIgG8,
mark.rutland-5wv7dgnIgG8, ijc+devicetree-KcIKpvwj1kUDXYZnReoRVg,
galak-sgV2jX0FEOL9JmXXK+q4OQ
[-- Attachment #1: Type: text/plain, Size: 646 bytes --]
On Tue, Sep 16, 2014 at 05:54:02PM +0200, Heiko Stuebner wrote:
> --- a/Documentation/devicetree/bindings/vendor-prefixes.txt
> +++ b/Documentation/devicetree/bindings/vendor-prefixes.txt
> @@ -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.
Google tells me that the stock ticker symbol for Fairchild is FCS
(sorry, should've spotted this on the previous version).
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2014-09-16 16:56 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-16 15:54 [PATCH v2 0/4] regulator: add support for syr82x to fan53555 Heiko Stuebner
2014-09-16 15:54 ` [PATCH v2 1/4] regulator: fan53555: use set_ramp_delay to set the ramp up slew rate Heiko Stuebner
2014-09-16 15:54 ` [PATCH v2 2/4] dt-bindings: add devicetree bindings for Fairchild FAN53555 regulators Heiko Stuebner
2014-09-16 16:55 ` Mark Brown
2014-09-16 16:55 ` Mark Brown
2014-09-16 15:54 ` [PATCH v2 3/4] regulator: fan53555: add devicetree support Heiko Stuebner
2014-09-16 15:54 ` [PATCH v2 4/4] regulator: fan53555: add support for Silergy SYR82x regulators Heiko Stuebner
2014-09-16 15:54 ` Heiko Stuebner
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.