* [PATCH 0/5] regulator: add support for syr82x to fan53555 @ 2014-09-14 19:23 Heiko Stuebner 2014-09-14 19:23 ` [PATCH 1/5] regulator: fan53555: enable vin supply Heiko Stuebner ` (4 more replies) 0 siblings, 5 replies; 14+ messages in thread From: Heiko Stuebner @ 2014-09-14 19:23 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. 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 -- 2.0.1 ^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH 1/5] regulator: fan53555: enable vin supply 2014-09-14 19:23 [PATCH 0/5] regulator: add support for syr82x to fan53555 Heiko Stuebner @ 2014-09-14 19:23 ` Heiko Stuebner [not found] ` <1410722585-13393-2-git-send-email-heiko-4mtYJXux2i+zQB+pC5nmwQ@public.gmane.org> 2014-09-14 19:23 ` [PATCH 2/5] regulator: fan53555: set regulator name from constraints name Heiko Stuebner ` (3 subsequent siblings) 4 siblings, 1 reply; 14+ messages in thread From: Heiko Stuebner @ 2014-09-14 19:23 UTC (permalink / raw) To: broonie Cc: linux-kernel, linux-rockchip, devicetree, robh+dt, pawel.moll, mark.rutland, ijc+devicetree, galak, Heiko Stuebner The regulator can be supplied by a parent regulator through its vin pin, so add the supply_name for it. Signed-off-by: Heiko Stuebner <heiko@sntech.de> --- drivers/regulator/fan53555.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/regulator/fan53555.c b/drivers/regulator/fan53555.c index 714fd9a..c912ba7 100644 --- a/drivers/regulator/fan53555.c +++ b/drivers/regulator/fan53555.c @@ -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; -- 2.0.1 ^ permalink raw reply related [flat|nested] 14+ messages in thread
[parent not found: <1410722585-13393-2-git-send-email-heiko-4mtYJXux2i+zQB+pC5nmwQ@public.gmane.org>]
* Re: [PATCH 1/5] regulator: fan53555: enable vin supply [not found] ` <1410722585-13393-2-git-send-email-heiko-4mtYJXux2i+zQB+pC5nmwQ@public.gmane.org> @ 2014-09-15 21:49 ` Mark Brown 0 siblings, 0 replies; 14+ messages in thread From: Mark Brown @ 2014-09-15 21:49 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: 190 bytes --] On Sun, Sep 14, 2014 at 09:23:01PM +0200, Heiko Stuebner wrote: > The regulator can be supplied by a parent regulator through its vin pin, > so add the supply_name for it. Applied, thanks. [-- Attachment #2: Digital signature --] [-- Type: application/pgp-signature, Size: 473 bytes --] ^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH 2/5] regulator: fan53555: set regulator name from constraints name 2014-09-14 19:23 [PATCH 0/5] regulator: add support for syr82x to fan53555 Heiko Stuebner 2014-09-14 19:23 ` [PATCH 1/5] regulator: fan53555: enable vin supply Heiko Stuebner @ 2014-09-14 19:23 ` Heiko Stuebner [not found] ` <1410722585-13393-3-git-send-email-heiko-4mtYJXux2i+zQB+pC5nmwQ@public.gmane.org> [not found] ` <1410722585-13393-1-git-send-email-heiko-4mtYJXux2i+zQB+pC5nmwQ@public.gmane.org> ` (2 subsequent siblings) 4 siblings, 1 reply; 14+ messages in thread From: Heiko Stuebner @ 2014-09-14 19:23 UTC (permalink / raw) To: broonie Cc: linux-kernel, linux-rockchip, devicetree, robh+dt, pawel.moll, mark.rutland, ijc+devicetree, galak, 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. Signed-off-by: Heiko Stuebner <heiko@sntech.de> --- drivers/regulator/fan53555.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/regulator/fan53555.c b/drivers/regulator/fan53555.c index c912ba7..d143790 100644 --- a/drivers/regulator/fan53555.c +++ b/drivers/regulator/fan53555.c @@ -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; -- 2.0.1 ^ permalink raw reply related [flat|nested] 14+ messages in thread
[parent not found: <1410722585-13393-3-git-send-email-heiko-4mtYJXux2i+zQB+pC5nmwQ@public.gmane.org>]
* Re: [PATCH 2/5] regulator: fan53555: set regulator name from constraints name [not found] ` <1410722585-13393-3-git-send-email-heiko-4mtYJXux2i+zQB+pC5nmwQ@public.gmane.org> @ 2014-09-15 16:59 ` Mark Brown 2014-09-15 22:08 ` Heiko Stübner 0 siblings, 1 reply; 14+ messages in thread From: Mark Brown @ 2014-09-15 16:59 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: 470 bytes --] On Sun, Sep 14, 2014 at 09:23:02PM +0200, Heiko Stuebner wrote: > 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. [-- Attachment #2: Digital signature --] [-- Type: application/pgp-signature, Size: 473 bytes --] ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 2/5] regulator: fan53555: set regulator name from constraints name 2014-09-15 16:59 ` Mark Brown @ 2014-09-15 22:08 ` Heiko Stübner 2014-09-15 22:36 ` Mark Brown 0 siblings, 1 reply; 14+ messages in thread From: Heiko Stübner @ 2014-09-15 22:08 UTC (permalink / raw) To: Mark Brown Cc: linux-kernel, linux-rockchip, devicetree, robh+dt, pawel.moll, mark.rutland, ijc+devicetree, galak [-- Attachment #1: Type: text/plain, Size: 719 bytes --] Am Montag, 15. September 2014, 09:59:23 schrieb Mark Brown: > On Sun, Sep 14, 2014 at 09:23:02PM +0200, Heiko Stuebner wrote: > > 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 [-- Attachment #2: This is a digitally signed message part. --] [-- Type: application/pgp-signature, Size: 490 bytes --] ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 2/5] regulator: fan53555: set regulator name from constraints name 2014-09-15 22:08 ` Heiko Stübner @ 2014-09-15 22:36 ` Mark Brown 0 siblings, 0 replies; 14+ messages in thread From: Mark Brown @ 2014-09-15 22:36 UTC (permalink / raw) To: Heiko Stübner Cc: linux-kernel, linux-rockchip, devicetree, robh+dt, pawel.moll, mark.rutland, ijc+devicetree, galak [-- Attachment #1: Type: text/plain, Size: 273 bytes --] On Tue, Sep 16, 2014 at 12:08:12AM +0200, Heiko Stübner wrote: > 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. [-- Attachment #2: Digital signature --] [-- Type: application/pgp-signature, Size: 473 bytes --] ^ permalink raw reply [flat|nested] 14+ messages in thread
[parent not found: <1410722585-13393-1-git-send-email-heiko-4mtYJXux2i+zQB+pC5nmwQ@public.gmane.org>]
* [PATCH 3/5] dt-bindings: add devicetree bindings for Fairchild FAN53555 regulators [not found] ` <1410722585-13393-1-git-send-email-heiko-4mtYJXux2i+zQB+pC5nmwQ@public.gmane.org> @ 2014-09-14 19:23 ` Heiko Stuebner 2014-09-15 21:54 ` Mark Brown 0 siblings, 1 reply; 14+ messages in thread From: Heiko Stuebner @ 2014-09-14 19:23 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 Document the regulator and add a fairchild vendor-prefix. Signed-off-by: Heiko Stuebner <heiko-4mtYJXux2i+zQB+pC5nmwQ@public.gmane.org> --- .../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 diff --git a/Documentation/devicetree/bindings/regulator/fan53555.txt b/Documentation/devicetree/bindings/regulator/fan53555.txt new file mode 100644 index 0000000..2484497 --- /dev/null +++ b/Documentation/devicetree/bindings/regulator/fan53555.txt @@ -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>; + }; 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 -- 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] 14+ messages in thread
* Re: [PATCH 3/5] dt-bindings: add devicetree bindings for Fairchild FAN53555 regulators 2014-09-14 19:23 ` [PATCH 3/5] dt-bindings: add devicetree bindings for Fairchild FAN53555 regulators Heiko Stuebner @ 2014-09-15 21:54 ` Mark Brown 2014-09-15 22:14 ` Heiko Stübner 0 siblings, 1 reply; 14+ messages in thread From: Mark Brown @ 2014-09-15 21:54 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: 335 bytes --] On Sun, Sep 14, 2014 at 09:23:03PM +0200, Heiko Stuebner wrote: > +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? [-- Attachment #2: Digital signature --] [-- Type: application/pgp-signature, Size: 473 bytes --] ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 3/5] dt-bindings: add devicetree bindings for Fairchild FAN53555 regulators 2014-09-15 21:54 ` Mark Brown @ 2014-09-15 22:14 ` Heiko Stübner 2014-09-15 22:25 ` Mark Brown 0 siblings, 1 reply; 14+ messages in thread From: Heiko Stübner @ 2014-09-15 22:14 UTC (permalink / raw) To: Mark Brown Cc: linux-kernel, linux-rockchip, devicetree, robh+dt, pawel.moll, mark.rutland, ijc+devicetree, galak [-- Attachment #1: Type: text/plain, Size: 619 bytes --] Am Montag, 15. September 2014, 14:54:10 schrieb Mark Brown: > On Sun, Sep 14, 2014 at 09:23:03PM +0200, Heiko Stuebner wrote: > > +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. [-- Attachment #2: This is a digitally signed message part. --] [-- Type: application/pgp-signature, Size: 490 bytes --] ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 3/5] dt-bindings: add devicetree bindings for Fairchild FAN53555 regulators 2014-09-15 22:14 ` Heiko Stübner @ 2014-09-15 22:25 ` Mark Brown 0 siblings, 0 replies; 14+ messages in thread From: Mark Brown @ 2014-09-15 22:25 UTC (permalink / raw) To: Heiko Stübner Cc: linux-kernel, linux-rockchip, devicetree, robh+dt, pawel.moll, mark.rutland, ijc+devicetree, galak [-- Attachment #1: Type: text/plain, Size: 660 bytes --] On Tue, Sep 16, 2014 at 12:14:43AM +0200, Heiko Stübner wrote: > Am Montag, 15. September 2014, 14:54:10 schrieb Mark Brown: > > 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. [-- Attachment #2: Digital signature --] [-- Type: application/pgp-signature, Size: 473 bytes --] ^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH 4/5] regulator: fan53555: add devicetree support 2014-09-14 19:23 [PATCH 0/5] regulator: add support for syr82x to fan53555 Heiko Stuebner ` (2 preceding siblings ...) [not found] ` <1410722585-13393-1-git-send-email-heiko-4mtYJXux2i+zQB+pC5nmwQ@public.gmane.org> @ 2014-09-14 19:23 ` Heiko Stuebner 2014-09-14 19:23 ` [PATCH 5/5] regulator: fan53555: add support for Silergy SYR82x regulators Heiko Stuebner 4 siblings, 0 replies; 14+ messages in thread From: Heiko Stuebner @ 2014-09-14 19:23 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 | 53 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/drivers/regulator/fan53555.c b/drivers/regulator/fan53555.c index d143790..0ec1762 100644 --- a/drivers/regulator/fan53555.c +++ b/drivers/regulator/fan53555.c @@ -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, -- 2.0.1 ^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 5/5] regulator: fan53555: add support for Silergy SYR82x regulators 2014-09-14 19:23 [PATCH 0/5] regulator: add support for syr82x to fan53555 Heiko Stuebner ` (3 preceding siblings ...) 2014-09-14 19:23 ` [PATCH 4/5] regulator: fan53555: add devicetree support Heiko Stuebner @ 2014-09-14 19:23 ` Heiko Stuebner 2014-09-15 22:27 ` Mark Brown 4 siblings, 1 reply; 14+ messages in thread From: Heiko Stuebner @ 2014-09-14 19:23 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 | 112 +++++++++++++++++---- 3 files changed, 95 insertions(+), 20 deletions(-) diff --git a/Documentation/devicetree/bindings/regulator/fan53555.txt b/Documentation/devicetree/bindings/regulator/fan53555.txt index 2484497..b26f278 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 0ec1762..89bfd0d 100644 --- a/drivers/regulator/fan53555.c +++ b/drivers/regulator/fan53555.c @@ -19,6 +19,7 @@ #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> @@ -51,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, @@ -61,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; @@ -149,6 +160,47 @@ static struct regulator_ops fan53555_regulator_ops = { .get_mode = fan53555_get_mode, }; +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]\n 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]\n 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: @@ -158,6 +210,7 @@ static int fan53555_device_setup(struct fan53555_device_info *di, struct fan53555_platform_data *pdata) { unsigned int reg, data, mask; + int ret = 0; /* Setup voltage control register */ switch (pdata->sleep_vsel_id) { @@ -173,24 +226,22 @@ 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; } + if (ret < 0) + return ret; + /* Init slew rate */ if (pdata->slew_rate & 0x7) di->slew_rate = pdata->slew_rate; @@ -272,6 +323,21 @@ static struct fan53555_platform_data *fan53555_parse_dt(struct device *dev, return pdata; } +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, + }, + { } +}; +MODULE_DEVICE_TABLE(of, fan53555_dt_ids); + static int fan53555_regulator_probe(struct i2c_client *client, const struct i2c_device_id *id) { @@ -296,6 +362,19 @@ static int fan53555_regulator_probe(struct i2c_client *client, if (!di) return -ENOMEM; + 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 { + di->vendor = id->driver_data; + } + di->regmap = devm_regmap_init_i2c(client, &fan53555_regmap_config); if (IS_ERR(di->regmap)) { dev_err(&client->dev, "Failed to allocate regmap!\n"); @@ -341,14 +420,9 @@ 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}, + { .name = "fan53555", .driver_data = FAN53555_VENDOR_FAIRCHILD }, + { .name = "syr82x", .driver_data = FAN53555_VENDOR_SILERGY }, { }, }; -- 2.0.1 ^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [PATCH 5/5] regulator: fan53555: add support for Silergy SYR82x regulators 2014-09-14 19:23 ` [PATCH 5/5] regulator: fan53555: add support for Silergy SYR82x regulators Heiko Stuebner @ 2014-09-15 22:27 ` Mark Brown 0 siblings, 0 replies; 14+ messages in thread From: Mark Brown @ 2014-09-15 22:27 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: 294 bytes --] On Sun, Sep 14, 2014 at 09:23:05PM +0200, Heiko Stuebner wrote: > 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. [-- Attachment #2: Digital signature --] [-- Type: application/pgp-signature, Size: 473 bytes --] ^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2014-09-15 22:36 UTC | newest] Thread overview: 14+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2014-09-14 19:23 [PATCH 0/5] regulator: add support for syr82x to fan53555 Heiko Stuebner 2014-09-14 19:23 ` [PATCH 1/5] regulator: fan53555: enable vin supply Heiko Stuebner [not found] ` <1410722585-13393-2-git-send-email-heiko-4mtYJXux2i+zQB+pC5nmwQ@public.gmane.org> 2014-09-15 21:49 ` Mark Brown 2014-09-14 19:23 ` [PATCH 2/5] regulator: fan53555: set regulator name from constraints name Heiko Stuebner [not found] ` <1410722585-13393-3-git-send-email-heiko-4mtYJXux2i+zQB+pC5nmwQ@public.gmane.org> 2014-09-15 16:59 ` Mark Brown 2014-09-15 22:08 ` Heiko Stübner 2014-09-15 22:36 ` Mark Brown [not found] ` <1410722585-13393-1-git-send-email-heiko-4mtYJXux2i+zQB+pC5nmwQ@public.gmane.org> 2014-09-14 19:23 ` [PATCH 3/5] dt-bindings: add devicetree bindings for Fairchild FAN53555 regulators Heiko Stuebner 2014-09-15 21:54 ` Mark Brown 2014-09-15 22:14 ` Heiko Stübner 2014-09-15 22:25 ` Mark Brown 2014-09-14 19:23 ` [PATCH 4/5] regulator: fan53555: add devicetree support Heiko Stuebner 2014-09-14 19:23 ` [PATCH 5/5] regulator: fan53555: add support for Silergy SYR82x regulators Heiko Stuebner 2014-09-15 22:27 ` 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).