* [PATCH V2 0/4] regulator: tps62360: support dts and enable for tegra-cardhu @ 2012-05-10 20:49 Laxman Dewangan 2012-05-10 20:49 ` [PATCH V2 1/4] regulator: tps62360: make init_data of platform data to pointer Laxman Dewangan ` (3 more replies) 0 siblings, 4 replies; 6+ messages in thread From: Laxman Dewangan @ 2012-05-10 20:49 UTC (permalink / raw) To: grant.likely, rob.herring, linux, lrg, broonie, swarren, olof Cc: devicetree-discuss, linux-doc, linux-kernel, linux-tegra, Laxman Dewangan Add support for dt on regulator device tps62360. Also enable this regulator for Nvidia's Tegra platform - cardhu. This series: - Make the regulator_init_data as pointer type from platform data. - enable config variable in tegra defconfig - add entry for tps62360 in dts file of tegra-cardhu. Changes from V1: Patch 2 did not compile when not defining CONFIG_OF. Fixed it. Laxman Dewangan (4): regulator: tps62360: make init_data of platform data to pointer. Make the regulator init data as pointer type in platform. regulator: tps62360: add dt support Ad dt support. ARM: tegra: config: enable REGULATOR_TPS62360 ARM: dt: tegra: cardhu: register core regulator tps62360 .../bindings/regulator/tps62360-regulator.txt | 45 ++++++++++++ arch/arm/boot/dts/tegra-cardhu.dts | 14 ++++ arch/arm/configs/tegra_defconfig | 1 + drivers/regulator/tps62360-regulator.c | 74 +++++++++++++++++++- include/linux/regulator/tps62360.h | 4 +- 5 files changed, 133 insertions(+), 5 deletions(-) create mode 100644 Documentation/devicetree/bindings/regulator/tps62360-regulator.txt ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH V2 1/4] regulator: tps62360: make init_data of platform data to pointer. 2012-05-10 20:49 [PATCH V2 0/4] regulator: tps62360: support dts and enable for tegra-cardhu Laxman Dewangan @ 2012-05-10 20:49 ` Laxman Dewangan 2012-05-10 20:49 ` [PATCH V2 2/4] regulator: tps62360: add dt support Laxman Dewangan ` (2 subsequent siblings) 3 siblings, 0 replies; 6+ messages in thread From: Laxman Dewangan @ 2012-05-10 20:49 UTC (permalink / raw) To: grant.likely, rob.herring, linux, lrg, broonie, swarren, olof Cc: devicetree-discuss, linux-doc, linux-kernel, linux-tegra, Laxman Dewangan Convert platform data member regulator_init_data to pointer type. This will avoid the copy of entire regualator init data into platform data member when adding dt support and it can be achieve by simple assignment: pdata->init_data = of_get_regulator_init_data(dev, dev->of_node); Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com> --- No change from V1. drivers/regulator/tps62360-regulator.c | 2 +- include/linux/regulator/tps62360.h | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/regulator/tps62360-regulator.c b/drivers/regulator/tps62360-regulator.c index 97fd98b..3506900 100644 --- a/drivers/regulator/tps62360-regulator.c +++ b/drivers/regulator/tps62360-regulator.c @@ -408,7 +408,7 @@ static int __devinit tps62360_probe(struct i2c_client *client, } config.dev = &client->dev; - config.init_data = &pdata->reg_init_data; + config.init_data = pdata->reg_init_data; config.driver_data = tps; /* Register the regulators */ diff --git a/include/linux/regulator/tps62360.h b/include/linux/regulator/tps62360.h index 6a5c1b2..5e11d50 100644 --- a/include/linux/regulator/tps62360.h +++ b/include/linux/regulator/tps62360.h @@ -26,8 +26,6 @@ #ifndef __LINUX_REGULATOR_TPS62360_H #define __LINUX_REGULATOR_TPS62360_H -#include <linux/regulator/machine.h> - /* * struct tps62360_regulator_platform_data - tps62360 regulator platform data. * @@ -44,7 +42,7 @@ * @vsel1_def_state: Default state of vsel1. 1 if it is high else 0. */ struct tps62360_regulator_platform_data { - struct regulator_init_data reg_init_data; + struct regulator_init_data *reg_init_data; bool en_force_pwm; bool en_discharge; bool en_internal_pulldn; -- 1.7.1.1 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH V2 2/4] regulator: tps62360: add dt support 2012-05-10 20:49 [PATCH V2 0/4] regulator: tps62360: support dts and enable for tegra-cardhu Laxman Dewangan 2012-05-10 20:49 ` [PATCH V2 1/4] regulator: tps62360: make init_data of platform data to pointer Laxman Dewangan @ 2012-05-10 20:49 ` Laxman Dewangan 2012-05-10 22:32 ` Grant Likely 2012-05-10 20:49 ` [PATCH V2 3/4] ARM: tegra: config: enable REGULATOR_TPS62360 Laxman Dewangan 2012-05-10 20:49 ` [PATCH V2 4/4] ARM: dt: tegra: cardhu: register core regulator tps62360 Laxman Dewangan 3 siblings, 1 reply; 6+ messages in thread From: Laxman Dewangan @ 2012-05-10 20:49 UTC (permalink / raw) To: grant.likely, rob.herring, linux, lrg, broonie, swarren, olof Cc: devicetree-discuss, linux-doc, linux-kernel, linux-tegra, Laxman Dewangan Add dt support for the pmu device tps62360 and Add binding documentation with example. With this patch driver will support both device-tree and non-device tree registration. Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com> --- Changes from V1: Fixed possible build error in non devicetree. .../bindings/regulator/tps62360-regulator.txt | 45 ++++++++++++ drivers/regulator/tps62360-regulator.c | 74 +++++++++++++++++++- 2 files changed, 118 insertions(+), 1 deletions(-) create mode 100644 Documentation/devicetree/bindings/regulator/tps62360-regulator.txt diff --git a/Documentation/devicetree/bindings/regulator/tps62360-regulator.txt b/Documentation/devicetree/bindings/regulator/tps62360-regulator.txt new file mode 100644 index 0000000..e337cd6 --- /dev/null +++ b/Documentation/devicetree/bindings/regulator/tps62360-regulator.txt @@ -0,0 +1,45 @@ +TPS62360 Voltage regulators + +Required properties: +- compatible: Must be one of the following. + "ti,tps62360" + "ti,tps62361", + "ti,tps62362", + "ti,tps62363", +- reg: I2C slave address + +Optional properties: +- ti,enable-force-pwm: Enable fore PWM mode. This is boolean value. +- ti,enable-vout-discharge: Enable output discharge. This is boolean value. +- ti,enable-pull-down: Enable pull down. This is boolean value. +- ti,vsel0-gpio: GPIO for controlling VSEL0 line. + If this property is missing, then assume that there is no GPIO + for vsel0 control. +- ti,vsel1-gpio: Gpio for controlling VSEL1 line. + If this property is missing, then assume that there is no GPIO + for vsel1 control. +- ti,vsel0-state-high: Inital state of vsel0 input is high. + If this property is missing, then assume the state as low (0). +- ti,vsel1-state-high: Inital state of vsel1 input is high. + If this property is missing, then assume the state as low (0). + +Any property defined as part of the core regulator binding, defined in +regulator.txt, can also be used. + +Example: + + abc: tps62360 { + compatible = "ti,tps62361"; + reg = <0x60>; + regulator-name = "tps62361-vout"; + regulator-min-microvolt = <500000>; + regulator-max-microvolt = <1500000>; + regulator-boot-on + ti,vsel0-gpio = <&gpio1 16 0>; + ti,vsel1-gpio = <&gpio1 17 0>; + ti,vsel0-state-high; + ti,vsel1-state-high; + ti,enable-pull-down; + ti,enable-force-pwm; + ti,enable-vout-discharge; + }; diff --git a/drivers/regulator/tps62360-regulator.c b/drivers/regulator/tps62360-regulator.c index 3506900..9985303 100644 --- a/drivers/regulator/tps62360-regulator.c +++ b/drivers/regulator/tps62360-regulator.c @@ -26,6 +26,10 @@ #include <linux/module.h> #include <linux/init.h> #include <linux/err.h> +#include <linux/of.h> +#include <linux/of_device.h> +#include <linux/of_gpio.h> +#include <linux/regulator/of_regulator.h> #include <linux/platform_device.h> #include <linux/regulator/driver.h> #include <linux/regulator/machine.h> @@ -297,6 +301,58 @@ static const struct regmap_config tps62360_regmap_config = { .cache_type = REGCACHE_RBTREE, }; +static struct tps62360_regulator_platform_data * + of_get_tps62360_platform_data(struct device *dev) +{ + struct tps62360_regulator_platform_data *pdata; + struct device_node *np = dev->of_node; + + pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL); + if (!pdata) { + dev_err(dev, "Memory alloc failed for platform data\n"); + return NULL; + } + + pdata->reg_init_data = of_get_regulator_init_data(dev, dev->of_node); + if (!pdata->reg_init_data) { + dev_err(dev, "Not able to get OF regulator init data\n"); + return NULL; + } + + pdata->vsel0_gpio = of_get_named_gpio(np, "vsel0-gpio", 0); + pdata->vsel1_gpio = of_get_named_gpio(np, "vsel1_gpio", 0); + + if (of_find_property(np, "ti,vsel0-state-high", NULL)) + pdata->vsel0_def_state = 1; + + if (of_find_property(np, "ti,vsel1-state-high", NULL)) + pdata->vsel1_def_state = 1; + + if (of_find_property(np, "ti,enable-pull-down", NULL)) + pdata->en_internal_pulldn = true; + + if (of_find_property(np, "ti,enable-force-pwm", NULL)) + pdata->en_force_pwm = true; + + if (of_find_property(np, "ti,enable-vout-discharge", NULL)) + pdata->en_discharge = true; + + return pdata; +} + +#if defined(CONFIG_OF) +static const struct of_device_id tps62360_of_match[] = { + { .compatible = "ti,tps62360", .data = (void *)TPS62360}, + { .compatible = "ti,tps62361", .data = (void *)TPS62361}, + { .compatible = "ti,tps62362", .data = (void *)TPS62362}, + { .compatible = "ti,tps62363", .data = (void *)TPS62363}, + {}, +} +MODULE_DEVICE_TABLE(of, tps62360_of_match); +#else +#define tps62360_of_match NULL +#endif + static int __devinit tps62360_probe(struct i2c_client *client, const struct i2c_device_id *id) { @@ -306,8 +362,23 @@ static int __devinit tps62360_probe(struct i2c_client *client, struct tps62360_chip *tps; int ret; int i; + int chip_id; pdata = client->dev.platform_data; + chip_id = id->driver_data; + + if (client->dev.of_node) { + const struct of_device_id *match; + match = of_match_device(tps62360_of_match, &client->dev); + if (!match) { + dev_err(&client->dev, "Error: No device match found\n"); + return -ENODEV; + } + chip_id = (int)match->data; + if (!pdata) + pdata = of_get_tps62360_platform_data(&client->dev); + } + if (!pdata) { dev_err(&client->dev, "%s(): Platform data not found\n", __func__); @@ -328,7 +399,7 @@ static int __devinit tps62360_probe(struct i2c_client *client, tps->vsel1_gpio = pdata->vsel1_gpio; tps->dev = &client->dev; - switch (id->driver_data) { + switch (chip_id) { case TPS62360: case TPS62362: tps->voltage_base = TPS62360_BASE_VOLTAGE; @@ -484,6 +555,7 @@ static struct i2c_driver tps62360_i2c_driver = { .driver = { .name = "tps62360", .owner = THIS_MODULE, + .of_match_table = tps62360_of_match, }, .probe = tps62360_probe, .remove = __devexit_p(tps62360_remove), -- 1.7.1.1 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH V2 2/4] regulator: tps62360: add dt support 2012-05-10 20:49 ` [PATCH V2 2/4] regulator: tps62360: add dt support Laxman Dewangan @ 2012-05-10 22:32 ` Grant Likely 0 siblings, 0 replies; 6+ messages in thread From: Grant Likely @ 2012-05-10 22:32 UTC (permalink / raw) To: rob.herring, linux, lrg, broonie, swarren, olof Cc: devicetree-discuss, linux-doc, linux-kernel, linux-tegra, Laxman Dewangan On Fri, 11 May 2012 02:19:37 +0530, Laxman Dewangan <ldewangan@nvidia.com> wrote: > Add dt support for the pmu device tps62360 and > Add binding documentation with example. > With this patch driver will support both device-tree and > non-device tree registration. > > Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com> > --- > Changes from V1: > Fixed possible build error in non devicetree. Minor comments below... > > .../bindings/regulator/tps62360-regulator.txt | 45 ++++++++++++ > drivers/regulator/tps62360-regulator.c | 74 +++++++++++++++++++- > 2 files changed, 118 insertions(+), 1 deletions(-) > create mode 100644 Documentation/devicetree/bindings/regulator/tps62360-regulator.txt > > diff --git a/Documentation/devicetree/bindings/regulator/tps62360-regulator.txt b/Documentation/devicetree/bindings/regulator/tps62360-regulator.txt > new file mode 100644 > index 0000000..e337cd6 > --- /dev/null > +++ b/Documentation/devicetree/bindings/regulator/tps62360-regulator.txt > @@ -0,0 +1,45 @@ > +TPS62360 Voltage regulators > + > +Required properties: > +- compatible: Must be one of the following. > + "ti,tps62360" > + "ti,tps62361", > + "ti,tps62362", > + "ti,tps62363", > +- reg: I2C slave address > + > +Optional properties: > +- ti,enable-force-pwm: Enable fore PWM mode. This is boolean value. typo ----------------------------^^^^ > +- ti,enable-vout-discharge: Enable output discharge. This is boolean value. > +- ti,enable-pull-down: Enable pull down. This is boolean value. > +- ti,vsel0-gpio: GPIO for controlling VSEL0 line. > + If this property is missing, then assume that there is no GPIO > + for vsel0 control. > +- ti,vsel1-gpio: Gpio for controlling VSEL1 line. > + If this property is missing, then assume that there is no GPIO > + for vsel1 control. > +- ti,vsel0-state-high: Inital state of vsel0 input is high. > + If this property is missing, then assume the state as low (0). > +- ti,vsel1-state-high: Inital state of vsel1 input is high. > + If this property is missing, then assume the state as low (0). > + > +Any property defined as part of the core regulator binding, defined in > +regulator.txt, can also be used. > + > +Example: > + > + abc: tps62360 { > + compatible = "ti,tps62361"; > + reg = <0x60>; > + regulator-name = "tps62361-vout"; > + regulator-min-microvolt = <500000>; > + regulator-max-microvolt = <1500000>; > + regulator-boot-on > + ti,vsel0-gpio = <&gpio1 16 0>; > + ti,vsel1-gpio = <&gpio1 17 0>; > + ti,vsel0-state-high; > + ti,vsel1-state-high; > + ti,enable-pull-down; > + ti,enable-force-pwm; > + ti,enable-vout-discharge; > + }; > diff --git a/drivers/regulator/tps62360-regulator.c b/drivers/regulator/tps62360-regulator.c > index 3506900..9985303 100644 > --- a/drivers/regulator/tps62360-regulator.c > +++ b/drivers/regulator/tps62360-regulator.c > @@ -26,6 +26,10 @@ > #include <linux/module.h> > #include <linux/init.h> > #include <linux/err.h> > +#include <linux/of.h> > +#include <linux/of_device.h> > +#include <linux/of_gpio.h> > +#include <linux/regulator/of_regulator.h> > #include <linux/platform_device.h> > #include <linux/regulator/driver.h> > #include <linux/regulator/machine.h> > @@ -297,6 +301,58 @@ static const struct regmap_config tps62360_regmap_config = { > .cache_type = REGCACHE_RBTREE, > }; > > +static struct tps62360_regulator_platform_data * > + of_get_tps62360_platform_data(struct device *dev) > +{ > + struct tps62360_regulator_platform_data *pdata; > + struct device_node *np = dev->of_node; > + > + pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL); > + if (!pdata) { > + dev_err(dev, "Memory alloc failed for platform data\n"); > + return NULL; > + } > + > + pdata->reg_init_data = of_get_regulator_init_data(dev, dev->of_node); > + if (!pdata->reg_init_data) { > + dev_err(dev, "Not able to get OF regulator init data\n"); > + return NULL; > + } > + > + pdata->vsel0_gpio = of_get_named_gpio(np, "vsel0-gpio", 0); > + pdata->vsel1_gpio = of_get_named_gpio(np, "vsel1_gpio", 0); typo --------------------------------------------------^^^ Otherwise looks good to me. g. ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH V2 3/4] ARM: tegra: config: enable REGULATOR_TPS62360 2012-05-10 20:49 [PATCH V2 0/4] regulator: tps62360: support dts and enable for tegra-cardhu Laxman Dewangan 2012-05-10 20:49 ` [PATCH V2 1/4] regulator: tps62360: make init_data of platform data to pointer Laxman Dewangan 2012-05-10 20:49 ` [PATCH V2 2/4] regulator: tps62360: add dt support Laxman Dewangan @ 2012-05-10 20:49 ` Laxman Dewangan 2012-05-10 20:49 ` [PATCH V2 4/4] ARM: dt: tegra: cardhu: register core regulator tps62360 Laxman Dewangan 3 siblings, 0 replies; 6+ messages in thread From: Laxman Dewangan @ 2012-05-10 20:49 UTC (permalink / raw) To: grant.likely, rob.herring, linux, lrg, broonie, swarren, olof Cc: devicetree-discuss, linux-doc, linux-kernel, linux-tegra, Laxman Dewangan Enable regulator REGULATOR_TPS62360 for the core power of cardhu. Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com> --- No change from V1. arch/arm/configs/tegra_defconfig | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/arch/arm/configs/tegra_defconfig b/arch/arm/configs/tegra_defconfig index 7a90abb..415ada1 100644 --- a/arch/arm/configs/tegra_defconfig +++ b/arch/arm/configs/tegra_defconfig @@ -114,6 +114,7 @@ CONFIG_REGULATOR=y CONFIG_REGULATOR_FIXED_VOLTAGE=y CONFIG_REGULATOR_VIRTUAL_CONSUMER=y CONFIG_REGULATOR_GPIO=y +CONFIG_REGULATOR_TPS62360=y CONFIG_REGULATOR_TPS6586X=y CONFIG_SOUND=y CONFIG_SND=y -- 1.7.1.1 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH V2 4/4] ARM: dt: tegra: cardhu: register core regulator tps62360 2012-05-10 20:49 [PATCH V2 0/4] regulator: tps62360: support dts and enable for tegra-cardhu Laxman Dewangan ` (2 preceding siblings ...) 2012-05-10 20:49 ` [PATCH V2 3/4] ARM: tegra: config: enable REGULATOR_TPS62360 Laxman Dewangan @ 2012-05-10 20:49 ` Laxman Dewangan 3 siblings, 0 replies; 6+ messages in thread From: Laxman Dewangan @ 2012-05-10 20:49 UTC (permalink / raw) To: grant.likely, rob.herring, linux, lrg, broonie, swarren, olof Cc: devicetree-discuss, linux-doc, linux-kernel, linux-tegra, Laxman Dewangan Add device info for the core regulator tps62360 in tegra-cardhu dts file. Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com> --- No change from V1. arch/arm/boot/dts/tegra-cardhu.dts | 14 ++++++++++++++ 1 files changed, 14 insertions(+), 0 deletions(-) diff --git a/arch/arm/boot/dts/tegra-cardhu.dts b/arch/arm/boot/dts/tegra-cardhu.dts index facb950..19b6e93 100644 --- a/arch/arm/boot/dts/tegra-cardhu.dts +++ b/arch/arm/boot/dts/tegra-cardhu.dts @@ -123,6 +123,20 @@ micdet-delay = <100>; gpio-cfg = <0xffffffff 0xffffffff 0 0xffffffff 0xffffffff>; }; + + tps62360 { + compatible = "ti,tps62361"; + reg = <0x60>; + + regulator-name = "tps62361-vout"; + regulator-min-microvolt = <500000>; + regulator-max-microvolt = <1500000>; + regulator-boot-on; + regulator-always-on; + ti,vsel0-state-high; + ti,vsel1-state-high; + }; + }; sdhci@78000000 { -- 1.7.1.1 ^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2012-05-10 22:32 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2012-05-10 20:49 [PATCH V2 0/4] regulator: tps62360: support dts and enable for tegra-cardhu Laxman Dewangan 2012-05-10 20:49 ` [PATCH V2 1/4] regulator: tps62360: make init_data of platform data to pointer Laxman Dewangan 2012-05-10 20:49 ` [PATCH V2 2/4] regulator: tps62360: add dt support Laxman Dewangan 2012-05-10 22:32 ` Grant Likely 2012-05-10 20:49 ` [PATCH V2 3/4] ARM: tegra: config: enable REGULATOR_TPS62360 Laxman Dewangan 2012-05-10 20:49 ` [PATCH V2 4/4] ARM: dt: tegra: cardhu: register core regulator tps62360 Laxman Dewangan
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).