regulator: add support for syr82x to fan53555
Subsystems (2)
PATCH v3 1/3 dt-bindings: add devicetree bindings for Fairchild FAN53555 regulators
In reply to Heiko StuebnerDocument the regulator and add a fairchild vendor-prefix.
--- .../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
Documentation/devicetree/bindings/regulator/fan53555.txt new file +23 -0
@@ -0,0 +1,23 @@ +Binding for Fairchild FAN53555 regulators + +Required properties: + - compatible: "fcs,fan53555" + - reg: I2C address + +Optional properties: + - fcs,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 = "fcs,fan53555"; + regulator-name = "fan53555"; + regulator-min-microvolt = <1000000>; + regulator-max-microvolt = <1800000>; + vin-supply = <&parent_reg>; + fcs,suspend-voltage-selector = <1>; + };
Documentation/devicetree/bindings/vendor-prefixes.txt +1 -0
@@ -49,6 +49,7 @@ epson Seiko Epson Corp. est ESTeem Wireless Modems eukrea Eukréa Electromatique excito Excito +fcs 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
PATCH v3 2/3 regulator: fan53555: add devicetree support
In reply to Heiko StuebnerAdd the ability to parse regulator-data from the devicetree.
--- drivers/regulator/fan53555.c | 50 ++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 46 insertions(+), 4 deletions(-)
drivers/regulator/fan53555.c +46 -4
@@ -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,"fcs,suspend-voltage-selector" , + &tmp); +if (!ret) + pdata->sleep_vsel_id = tmp; + +return pdata; +} + +static const struct of_device_id fan53555_dt_ids[] = { + { + .compatible ="fcs,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,
Signature · 1 line
2.0.1
v3 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.
changes since v2:
- use fcs (stock symbol) as vendor prefix for Fairchild
- drop already applied ramp_delay patch changes since v1:
- drop already applied vin-supply patch
- drop wrong regulator-naming patch
- add patch to generalize ramp_delay handling
Heiko Stuebner (3):
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 | 150 ++++++++++++++++++--- 3 files changed, 157 insertions(+), 18 deletions(-) create mode 100644 Documentation/devicetree/bindings/regulator/fan53555.txt
Signature · 1 line
2.0.1
PATCH v3 3/3 regulator: fan53555: add support for Silergy SYR82x regulators
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 | 102 ++++++++++++++++++--- 3 files changed, 89 insertions(+), 16 deletions(-)
Documentation/devicetree/bindings/regulator/fan53555.txt +1 -1
@@ -1,7 +1,7 @@ Binding for Fairchild FAN53555 regulators Required properties: - - compatible: "fcs,fan53555" + - compatible: one of "fcs,fan53555", "silergy,syr827", "silergy,syr828" - reg: I2C address Optional properties:
Documentation/devicetree/bindings/vendor-prefixes.txt +1 -0
@@ -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 +87 -15
164 lines not on this page · raw message
Signature · 1 line
2.0.1
Mark Brown
maintainerQuoted 3 lines · 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.
Applied all, please use appropriate subject lines for the subsystem.