mfd/regulator: tps65090: add DT support and suspend/resume cleanups
Subsystems (3)
v2 cover mfd/regulator: tps65090: add DT support and suspend/resume cleanups
The patch series add DT support on TPS65090 device.
Also remove the suspend/resume implementation as it duplicates with irq_suspend/irq_resume().
Changes from V1:
- Remove non-required code from the change for checking the match.
- Remove pdata allocation on mfd driver.
- renames some of the property as suggested by Stephen.
- Rebased the changes on 20130128.
Laxman Dewangan (4):
mfd: tps65090: add DT support for tps65090
regulator: tps65090: add DT support
mfd: tps65090: Pass irq domain when adding mfd sub devices
mfd: tps65090: remove suspend/resume callbacks
.../devicetree/bindings/regulator/tps65090.txt | 122 ++++++++++++++++++++ drivers/mfd/tps65090.c | 47 +++----- drivers/regulator/tps65090-regulator.c | 106 ++++++++++++++++- 3 files changed, 243 insertions(+), 32 deletions(-) create mode 100644 Documentation/devicetree/bindings/regulator/tps65090.txt
PATCH v2 1/4 mfd: tps65090: add DT support for tps65090
Add device tree support for the TI PMIC TPS65090. The device can be registered through platform or DT.
Add device tree binding document for this device.
---
Changes from V1:
- Remove non-required code from the change for checking the match.
- Remove pdata allocation on mfd driver.
- renames some of the property as suggested by Stephen.
- Rebased the changes on 20130128.
.../devicetree/bindings/regulator/tps65090.txt | 122 ++++++++++++++++++++ drivers/mfd/tps65090.c | 22 +++- 2 files changed, 141 insertions(+), 3 deletions(-) create mode 100644 Documentation/devicetree/bindings/regulator/tps65090.txt
Documentation/devicetree/bindings/regulator/tps65090.txt new file +122 -0
@@ -0,0 +1,122 @@ +TPS65090 regulators + +Required properties: +- compatible: "ti,tps65090" +- reg: I2C slave address +- interrupts: the interrupt outputs of the controller +- regulators: A node that houses a sub-node for each regulator within the + device. Each sub-node is identified using the node's name, with valid + values listed below. The content of each sub-node is defined by the + standard binding for regulators; see regulator.txt. + dcdc[1-3], fet[1-7] and ldo[1-2] respectively. +- vsys[1-3]-supply: The input supply for DCDC[1-3] respectively. +- infet[1-7]-supply: The input supply for FET[1-7] respectively. +- vsys-l[1-2]-supply: The input supply for LDO[1-2] respectively. + +Optional properties: +- ti,enable-ext-control: This is applicable for DCDC1, DCDC2 and DCDC3. + If DCDCs are externally controlled then this property should be there. +- "dcdc-ext-control-gpios: This is applicable for DCDC1, DCDC2 and DCDC3. + If DCDCs are externally controlled and if it is from GPIO then GPIO + number should be provided. If it is externally controlled and no GPIO + entry then driver will just configure this rails as external control + and will not provide any enable/disable APIs. + +Each regulator is defined using the standard binding for regulators. + +Example: + + tps65090@48 { + compatible = "ti,tps65090"; + reg = <0x48>; + interrupts = <0 88 0x4>; + + vsys1-supply = <&some_reg>; + vsys2-supply = <&some_reg>; + vsys3-supply = <&some_reg>; + infet1-supply = <&some_reg>; + infet2-supply = <&some_reg>; + infet3-supply = <&some_reg>; + infet4-supply = <&some_reg>; + infet5-supply = <&some_reg>; + infet6-supply = <&some_reg>; + infet7-supply = <&some_reg>; + vsys_l1-supply = <&some_reg>; + vsys_l2-supply = <&some_reg>; + + regulators { + dcdc1 { + regulator-name = "dcdc1"; + regulator-boot-on; + regulator-always-on; + ti,enable-ext-control; + dcdc-ext-control-gpios = <&gpio 10 0>; + }; + + dcdc2 { + regulator-name = "dcdc2"; + regulator-boot-on; + regulator-always-on; + }; + + dcdc3 { + regulator-name = "dcdc3"; + regulator-boot-on; + regulator-always-on; + }; + + fet1 { + regulator-name = "fet1"; + regulator-boot-on; + regulator-always-on; + }; + + fet2 { + regulator-name = "fet2"; + regulator-boot-on; + regulator-always-on; + }; + + fet3 { + regulator-name = "fet3"; + regulator-boot-on; + regulator-always-on; + }; + + fet4 { + regulator-name = "fet4"; + regulator-boot-on; + regulator-always-on; + }; + + fet5 { + regulator-name = "fet5"; + regulator-boot-on; + regulator-always-on; + }; + + fet6 { + regulator-name = "fet6"; + regulator-boot-on; + regulator-always-on; + }; + + fet7 { + regulator-name = "fet7"; + regulator-boot-on; + regulator-always-on; + }; + + ldo1 { + regulator-name = "ldo1"; + regulator-boot-on; + regulator-always-on; + }; + + ldo2 { + regulator-name = "ldo2"; + regulator-boot-on; + regulator-always-on; + }; + }; + };
drivers/mfd/tps65090.c +19 -3
@@ -25,6 +25,8 @@#include <linux/i2c.h> #include <linux/mfd/core.h> #include <linux/mfd/tps65090.h> +#include <linux/of.h> +#include <linux/of_device.h> #include <linux/err.h> #define NUM_INT_REG 2
@@ -148,18 +150,31 @@ static const struct regmap_config tps65090_regmap_config = { .volatile_reg = is_volatile_reg, }; +#ifdef CONFIG_OF +static const struct of_device_id tps65090_of_match[] = { + { .compatible ="ti,tps65090" ,}, + {}, +}; +MODULE_DEVICE_TABLE (of, tps65090_of_match); +#endif +static int tps65090_i2c_probe (struct i2c_client *client,const struct i2c_device_id *id) {struct tps65090_platform_data *pdata = client->dev.platform_data; +int irq_base =0 ;struct tps65090 *tps65090;int ret; -if (!pdata) { -dev_err (&client->dev,"tps65090 requires platform data\n" ); +if (!pdata && !client->dev.of_node) { +dev_err (&client->dev, +"tps65090 requires platform data or of_node\n" );return -EINVAL ; } +if (pdata) + irq_base = pdata->irq_base; + tps65090 =devm_kzalloc (&client->dev,sizeof (*tps65090),GFP_KERNEL );if (!tps65090) {dev_err (&client->dev,"mem alloc for tps65090 failed\n" );
@@ -178,7 +193,7 @@ static int tps65090_i2c_probe(struct i2c_client *client,if (client->irq) { ret =regmap_add_irq_chip (tps65090->rmap, client->irq, -IRQF_ONESHOT |IRQF_TRIGGER_LOW , pdata->irq_base, +IRQF_ONESHOT |IRQF_TRIGGER_LOW , irq_base, &tps65090_irq_chip, &tps65090->irq_data);if (ret) { dev_err(&client->dev,
@@ -247,6 +262,7 @@ static struct i2c_driver tps65090_driver = { .driver = { .name = "tps65090", .owner = THIS_MODULE, + .of_match_table = of_match_ptr(tps65090_of_match), .pm = &tps65090_pm_ops, }, .probe = tps65090_i2c_probe,
Signature · 1 line
1.7.1.1
PATCH v2 2/4 regulator: tps65090: add DT support
In reply to Laxman DewanganAdd DT support for TI PMIC tps65090 regulator driver. The DT of this device have node regulator and all regulator's node of this device is added under this node.
The device tree binding document has the required information for adding this device on DTS file.
---
Changes from V1:
- Allocate pdata here.
- Changes to reflect the renames of the property as suggested by Stephen.
- Rebased the changes on 20130128.
drivers/regulator/tps65090-regulator.c | 106 ++++++++++++++++++++++++++++++-- 1 files changed, 101 insertions(+), 5 deletions(-)
drivers/regulator/tps65090-regulator.c +101 -5
@@ -19,11 +19,13 @@#include <linux/module.h> #include <linux/init.h> #include <linux/gpio.h> +#include <linux/of_gpio.h> #include <linux/slab.h> #include <linux/err.h> #include <linux/platform_device.h> #include <linux/regulator/driver.h> #include <linux/regulator/machine.h> +#include <linux/regulator/of_regulator.h> #include <linux/mfd/tps65090.h> struct tps65090_regulator {
@@ -67,8 +69,8 @@ static struct regulator_desc tps65090_regulator_desc[] = {tps65090_REG_DESC (FET5 ,"infet5" ,0x13 , tps65090_reg_contol_ops),tps65090_REG_DESC (FET6 ,"infet6" ,0x14 , tps65090_reg_contol_ops),tps65090_REG_DESC (FET7 ,"infet7" ,0x15 , tps65090_reg_contol_ops), -tps65090_REG_DESC (LDO1 ,"vsys_l1" ,0 , tps65090_ldo_ops), - tps65090_REG_DESC(LDO2, "vsys_l2", 0, tps65090_ldo_ops), +tps65090_REG_DESC (LDO1 ,"vsys-l1" ,0 , tps65090_ldo_ops), + tps65090_REG_DESC(LDO2, "vsys-l2", 0, tps65090_ldo_ops), };static inline bool is_dcdc (int id)
@@ -138,6 +140,92 @@ static void tps65090_configure_regulator_config( } } +#ifdef CONFIG_OF +static struct of_regulator_match tps65090_matches[] = { + { .name ="dcdc1" , }, + { .name ="dcdc2" , }, + { .name ="dcdc3" , }, + { .name ="fet1" , }, + { .name ="fet2" , }, + { .name ="fet3" , }, + { .name ="fet4" , }, + { .name ="fet5" , }, + { .name ="fet6" , }, + { .name ="fet7" , }, + { .name ="ldo1" , }, + { .name ="ldo2" , }, +}; + +static struct tps65090_platform_data *tps65090_parse_dt_reg_data ( +struct platform_device *pdev, +struct of_regulator_match **tps65090_reg_matches) +{ +struct tps65090_platform_data *tps65090_pdata; +struct device_node *np = pdev->dev.parent->of_node; +struct device_node *regulators; +int idx =0 , ret; +struct tps65090_regulator_plat_data *reg_pdata; + + tps65090_pdata =devm_kzalloc (&pdev->dev,sizeof (*tps65090_pdata), +GFP_KERNEL ); +if (!tps65090_pdata) { +dev_err (&pdev->dev,"Memory alloc for tps65090_pdata failed\n" ); +return ERR_PTR (-ENOMEM ); + } + + reg_pdata =devm_kzalloc (&pdev->dev,TPS65090_REGULATOR_MAX * +sizeof (*reg_pdata),GFP_KERNEL ); +if (!reg_pdata) { +dev_err (&pdev->dev,"Memory alloc for reg_pdata failed\n" ); +return ERR_PTR (-ENOMEM ); + } + + regulators =of_find_node_by_name (np,"regulators" ); +if (!regulators) { +dev_err (&pdev->dev,"regulator node not found\n" ); +return ERR_PTR (-ENODEV ); + } + + ret =of_regulator_match (pdev->dev.parent, regulators, tps65090_matches, +ARRAY_SIZE (tps65090_matches)); +if (ret <0 ) { +dev_err (&pdev->dev, +"Error parsing regulator init data: %d\n" , ret); +return ERR_PTR (ret); + } + + *tps65090_reg_matches = tps65090_matches; +for (idx =0 ; idx <ARRAY_SIZE (tps65090_matches); idx++) { +struct regulator_init_data *ri_data; +struct tps65090_regulator_plat_data *rpdata; + + rpdata = ®_pdata[idx]; + ri_data = tps65090_matches[idx].init_data; +if (!ri_data || !tps65090_matches[idx].of_node) +continue ; + + rpdata->reg_init_data = ri_data; + rpdata->enable_ext_control =of_property_read_bool ( + tps65090_matches[idx].of_node, +"ti,enable-ext-control" ); +if (rpdata->enable_ext_control) + rpdata->gpio =of_get_named_gpio (np, +"dcdc-ext-control-gpios" ,0 ); + + tps65090_pdata->reg_pdata[idx] = rpdata; + } +return tps65090_pdata; +} +#else +static inline struct tps65090_platform_data *tps65090_parse_dt_reg_data ( +struct platform_device *pdev, +struct of_regulator_match **tps65090_reg_matches) +{ + *tps65090_reg_matches =NULL ; +return NULL ; +} +#endif +static int tps65090_regulator_probe (struct platform_device *pdev) {struct tps65090 *tps65090_mfd =dev_get_drvdata (pdev->dev.parent);
@@ -147,15 +235,19 @@ static int tps65090_regulator_probe(struct platform_device *pdev)struct tps65090_regulator_plat_data *tps_pdata;struct tps65090_regulator *pmic;struct tps65090_platform_data *tps65090_pdata; +struct of_regulator_match *tps65090_reg_matches =NULL ;int num;int ret;dev_dbg (&pdev->dev,"Probing regulator\n" ); tps65090_pdata =dev_get_platdata (pdev->dev.parent); -if (!tps65090_pdata) { +if (!tps65090_pdata && tps65090_mfd->dev->of_node) + tps65090_pdata =tps65090_parse_dt_reg_data (pdev, + &tps65090_reg_matches); +if (IS_ERR_OR_NULL (tps65090_pdata)) {dev_err (&pdev->dev,"Platform data missing\n" ); -return -EINVAL ; +return tps65090_pdata ?PTR_ERR (tps65090_pdata) : -EINVAL ; } pmic = devm_kzalloc(&pdev->dev, TPS65090_REGULATOR_MAX * sizeof(*pmic),
@@ -192,13 +284,17 @@ static int tps65090_regulator_probe(struct platform_device *pdev) } } - config.dev = &pdev->dev; + config.dev = pdev->dev.parent; config.driver_data = ri; config.regmap = tps65090_mfd->rmap;if (tps_pdata) config.init_data = tps_pdata->reg_init_data;else config.init_data =NULL ; +if (tps65090_reg_matches) + config.of_node = tps65090_reg_matches[num].of_node; +else + config.of_node =NULL ; rdev =regulator_register (ri->desc, &config);if (IS_ERR (rdev)) {
Signature · 1 line
1.7.1.1
Re: [PATCH V2 2/4] regulator: tps65090: add DT support
Quoted 3 lines · Laxman Dewangan
Add DT support for TI PMIC tps65090 regulator driver. The DT of this device have node regulator and all regulator's node of this device is added under this node.
There doesn't seem to be any dependency on the rest of the series so I went ahead and applied this, thanks.
PATCH v2 3/4 mfd: tps65090: Pass irq domain when adding mfd sub devices
In reply to Laxman DewanganWhen device is get added through DT then irq_base is 0 (zero) and in this case regmap_irq_chip_get_base() generates warning. The interrupt of this device get added through irq_domain_add_linear() when irq_base is 0.
Hence pass the irq domain in place of base_irq when calling mfd_add_devices().
---
Changes from V1:
- No change.
drivers/mfd/tps65090.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/mfd/tps65090.c +1 -1
@@ -204,7 +204,7 @@ static int tps65090_i2c_probe(struct i2c_client *client, ret =mfd_add_devices (tps65090->dev,-1 , tps65090s,ARRAY_SIZE (tps65090s),NULL , -regmap_irq_chip_get_base (tps65090->irq_data),NULL ); +0 ,regmap_irq_get_domain (tps65090->irq_data));if (ret) {dev_err (&client->dev,"add mfd devices failed with err: %d\n" , ret);
Signature · 1 line
1.7.1.1
PATCH v2 4/4 mfd: tps65090: remove suspend/resume callbacks
In reply to Laxman DewanganThe tps65090 mfd driver implement the suspend/resume callbacks which just disable and enable irqs in suspend/resume respectively.
This operation is already done in irq suspend and irq_resume and hence it is not require to implement the same in the driver.
Remove this non-require code.
---
Changes from V1:
- No change.
drivers/mfd/tps65090.c | 23 ----------------------- 1 files changed, 0 insertions(+), 23 deletions(-)
drivers/mfd/tps65090.c +0 -23
@@ -230,28 +230,6 @@ static int tps65090_i2c_remove(struct i2c_client *client)return 0 ; } -#ifdef CONFIG_PM_SLEEP -static int tps65090_suspend (struct device *dev) -{ -struct i2c_client *client =to_i2c_client (dev); -if (client->irq) -disable_irq (client->irq); -return 0 ; -} - -static int tps65090_resume (struct device *dev) -{ -struct i2c_client *client =to_i2c_client (dev); -if (client->irq) -enable_irq (client->irq); -return 0 ; -} -#endif - -static const struct dev_pm_ops tps65090_pm_ops = { -SET_SYSTEM_SLEEP_PM_OPS (tps65090_suspend, tps65090_resume) -}; -static const struct i2c_device_id tps65090_id_table[] = { {"tps65090" ,0 }, { },
@@ -263,7 +241,6 @@ static struct i2c_driver tps65090_driver = { .name = "tps65090", .owner = THIS_MODULE, .of_match_table = of_match_ptr(tps65090_of_match), - .pm = &tps65090_pm_ops, }, .probe = tps65090_i2c_probe, .remove = tps65090_i2c_remove,
Signature · 1 line
1.7.1.1