Update TPS65910 to boot using devicetree
Subsystems (6)
cover Update TPS65910 to boot using devicetree
This patch set updates the tps65910 driver to boot using devicetree.
One thing that is unfavorable is the addition of the use_dt_for_init_data flag. I added this as I wanted to split the parsing of the of nodes between the tps65910-regulator code and the main tps65910 code. This split was to maintain the list of regulator names solely inside the tps65910-regulator code as it already was.
Rhyland Klein (4):
regulator: tps65910: update type for regmap
regulator: tps65910: Add device tree bindings
mfd: tps65910: Add device-tree support
ARM: Tegra: Add support for TPS65910 PMIC
Documentation/devicetree/bindings/mfd/tps65910.txt | 132 ++++++++++++++++++++ arch/arm/boot/dts/tegra-cardhu.dts | 92 ++++++++++++++ drivers/gpio/gpio-tps65910.c | 39 ++++++- drivers/mfd/tps65910-irq.c | 21 +++- drivers/mfd/tps65910.c | 78 ++++++++++++- drivers/regulator/tps65910-regulator.c | 86 +++++++++++++- include/linux/mfd/tps65910.h | 3 +- 7 files changed, 439 insertions(+), 12 deletions(-) create mode 100644 Documentation/devicetree/bindings/mfd/tps65910.txt
PATCH 1/4 regulator: tps65910: update type for regmap
When accessing the regmap via the read/write functions, we need to use a unsigned int * instead of a u8 * otherwise corruption will occur.
--- drivers/regulator/tps65910-regulator.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/regulator/tps65910-regulator.c +1 -1
@@ -331,7 +331,7 @@ struct tps65910_reg {static inline int tps65910_read (struct tps65910_reg *pmic,u8 reg) { -u8 val; +unsigned int val;int err; err = pmic->mfd->read (pmic->mfd, reg,1 , &val);
Signature · 1 line
1.7.0.4
Re: [PATCH 1/4] regulator: tps65910: update type for regmap
drivers/regulator/tps65910-regulator.c struct tps65910_reg { · line 337
Quoted 12 lines · Rhyland Klein
When accessing the regmap via the read/write functions, we need to use a unsigned int * instead of a u8 * otherwise corruption will occur.
Signed-off-by Rhyland Klein <[email protected]>static inline int
tps65910_read(struct tps65910_reg *pmic, u8 reg){drivers/regulator/tps65910-regulator.c +1
-1-u8 val; +unsigned int val;int err; err = pmic->mfd->read (pmic->mfd, reg,1 , &val);
Ugh, this interface is just broken all round - there's absolutely no type safety here and all users of these functions will be broken (a similar issue applies on write). It's much better to fix this for 3.4 by converting the core code to use regmap_raw_ functions which take native formatted data for the device like the function driver API actually expects.
Looking at the MFD code the fix for 3.5 should at the very least involve making the functions take typed pointers, though given the way they're implemented right now with direct references in the subdevices I'd also consider just having the subdevices uses regmap directly as the wrappers are just adding an opportunity for error (the bit operations could be converted into static inlines in the header too).
Re: [PATCH 1/4] regulator: tps65910: update type for regmap
Quoted 14 lines · Mark Brown
* PGP Signed by an unknown key
Quoted 11 lines · Rhyland Klein
When accessing the regmap via the read/write functions, we need to use a unsigned int * instead of a u8 * otherwise corruption will occur.
Signed-off-by Rhyland Klein <[email protected]>static inline int
tps65910_read(struct tps65910_reg *pmic, u8 reg){drivers/regulator/tps65910-regulator.c +1
-1-u8 val; +unsigned int val;int err;
Quoted 8 lines
Quoted 1 line
err =
pmic->mfd->read(pmic->mfd, reg, 1, &val);Ugh, this interface is just broken all round - there's absolutely no type safety here and all users of these functions will be broken (a similar issue applies on write). It's much better to fix this for 3.4 by converting the core code to use
regmap_raw_functions which take native formatted data for the device like the function driver API actually expects.
Which interface are you saying is broken? The regmap interface or the one internal to the tps65910 code?
Quoted 8 lines
Looking at the MFD code the fix for 3.5 should at the very least involve making the functions take typed pointers, though given the way they're implemented right now with direct references in the subdevices I'd also consider just having the subdevices uses regmap directly as the wrappers are just adding an opportunity for error (the bit operations could be converted into static inlines in the header too).
So to be clear... Your recommendation is to change the tps65910 code to remove the common read/write callbacks and to use regmap directly in each component, and then when using regmap, do use the regmap raw functions instead of the bulkread/write?
Quoted 2 lines
* Unknown Key
*0x6E30FDDD
Thanks,
rhyland
---
nvpublic
Re: [PATCH 1/4] regulator: tps65910: update type for regmap
Quoted 36 lines · Rhyland Klein
Quoted 14 lines · Mark Brown
* PGP Signed by an unknown key
Quoted 11 lines · Rhyland Klein
When accessing the regmap via the read/write functions, we need to use a unsigned int * instead of a u8 * otherwise corruption will occur.
Signed-off-by Rhyland Klein <[email protected]>static inline int
tps65910_read(struct tps65910_reg *pmic, u8 reg){drivers/regulator/tps65910-regulator.c +1
-1-u8 val; +unsigned int val;int err;Quoted 8 lines
Quoted 1 line
err =
pmic->mfd->read(pmic->mfd, reg, 1, &val);Ugh, this interface is just broken all round - there's absolutely no type safety here and all users of these functions will be broken (a similar issue applies on write). It's much better to fix this for 3.4 by converting the core code to use
regmap_raw_functions which take native formatted data for the device like the function driver API actually expects.Which interface are you saying is broken? The regmap interface or the one internal to the tps65910 code?
Quoted 8 lines
Looking at the MFD code the fix for 3.5 should at the very least involve making the functions take typed pointers, though given the way they're implemented right now with direct references in the subdevices I'd also consider just having the subdevices uses regmap directly as the wrappers are just adding an opportunity for error (the bit operations could be converted into static inlines in the header too).
Quoted 4 lines
So to be clear... Your recommendation is to change the tps65910 code to remove the common read/write callbacks and to use regmap directly in each component, and then when using regmap, do use the regmap raw functions instead of the bulkread/write?
Looking at the code, I would think it makes more sense use regmap_read which enforces types since the tps65910 code only ever seems to use regmap to access a single register at a time. Do you agree?
-rhyland
---
nvpublic
Re: [PATCH 1/4] regulator: tps65910: update type for regmap
Quoted 4 lines · Rhyland Klein
Quoted 2 lines · Rhyland Klein
Which interface are you saying is broken? The regmap interface or the one internal to the tps65910 code?
This driver is broken.
Quoted 8 lines
Quoted 4 lines
So to be clear... Your recommendation is to change the tps65910 code to remove the common read/write callbacks and to use regmap directly in each component, and then when using regmap, do use the regmap raw functions instead of the bulkread/write?
Looking at the code, I would think it makes more sense use
regmap_readwhich enforces types since the tps65910 code only ever seems to use regmap to access a single register at a time. Do you agree?
Yes, for single register I/O the drivers should just be using the per-register APIs regmap has if they're using regmap directly. Having wrappers for this in the header would be fine also, the things that are really problematic about the current code are the void * usage and the fact that individual drivers are writing register read/write functions.
If the driver wasn't using void * this bug would've been caught by the compiler.
PATCH 2/4 regulator: tps65910: Add device tree bindings
In reply to Rhyland KleinAdd device tree bindings for TI's tps65910 pmic.
--- Documentation/devicetree/bindings/mfd/tps65910.txt | 132 ++++++++++++++++++++ 1 files changed, 132 insertions(+), 0 deletions(-) create mode 100644 Documentation/devicetree/bindings/mfd/tps65910.txt
Documentation/devicetree/bindings/mfd/tps65910.txt new file +132 -0
@@ -0,0 +1,132 @@ +TPS65910 Power Management Integrated Circuit + +Required properties: +- compatible: "ti,tps65910" or "ti,tps65911" +- reg: I2C slave address +- interrupts: the interrupt outputs of the controller +- #gpio-cells: number of cells to describe a GPIO, this should be 2. + The first cell is the GPIO number. + The second cell is used to specify additional options <unused>. +- gpio-controller: mark the device as a GPIO controller +- #interrupt-cells: the number of cells to describe an IRQ, this should be 2. + The first cell is the IRQ number. + The second cell is the flags, encoded as the trigger masks from + Documentation/devicetree/bindings/interrupts.txt +- regulators: This is the list of child nodes that specify the regulator + initialization data for defined regulators. Not all regulators for the given + device need to be present. The definition for each of these nodes is defined + using the standard binding for regulators found at + Documentation/devicetree/bindings/regulator/regulator.txt. + + The valid names for regulators are: + tps65910: vrtc, vio, vdd1, vdd2, vdd3, vdig1, vdig2, vpll, vdac, vaux1, + vaux2, vaux33, vmmc + tps65911: vrtc, vio, vdd1, vdd3, vddctrl, ldo1, ldo2, ldo3, ldo4, ldo5, + ldo6, ldo7, ldo8 + +Optional properties: +- ti,vmbch-threshold: (tps65911) main battery charged threshold + comparator. (see VMBCH_VSEL in TPS65910 datasheet) +- ti,vmbch2-threshold: (tps65911) main battery discharged threshold + comparator. (see VMBCH_VSEL in TPS65910 datasheet) +- ti,regulator-ext-sleep-control: enable external sleep + control through external inputs [0 (not enabled), 1 (EN1), 2 (EN2) or 4(EN3)] + There should be 13 entries here, one for each regulators for the chip. +- ti,en-gpio-sleep: enable sleep control for gpios + There should be 9 entries here, one for each gpio. + +Example: + + pmu: tps65910@d2 { + compatible = "ti,tps65910"; + reg = <0xd2>; + interrupt-parent = <&intc>; + interrupts = < 0 118 0x04 >; + + #gpio-cells = <2>; + gpio-controller; + + #interrupt-cells = <2>; + interrupt-controller; + + ti,vmbch-threshold = 0; + ti,vmbch2-threshold = 0; + ti,regulator-ext-sleep-control = <0 + 0 + 0x4 /* input EN3 */ + 0 + 0x1 /* input EN1 */ + 0 + 0 + 0 + 0 + 0 + 0 + 0x1 /* input EN1 */ + 0x1>; /* input EN1 */ + + ti,en-gpio-sleep = <0 0 1 0 0 0 0 0 0>; + + regulators { + vdd1_reg: vdd1 { + regulator-min-microvolt = < 600000>; + regulator-max-microvolt = <1500000>; + regulator-always-on; + regulator-boot-on; + }; + vdd2_reg: vdd2 { + regulator-min-microvolt = < 600000>; + regulator-max-microvolt = <1500000>; + regulator-always-on; + regulator-boot-on; + }; + vddctrl_reg: vddctrl { + regulator-min-microvolt = < 600000>; + regulator-max-microvolt = <1400000>; + regulator-always-on; + regulator-boot-on; + }; + vio_reg: vio { + regulator-min-microvolt = <1500000>; + regulator-max-microvolt = <1800000>; + regulator-always-on; + regulator-boot-on; + }; + ldo1_reg: ldo1 { + regulator-min-microvolt = <1000000>; + regulator-max-microvolt = <3300000>; + }; + ldo2_reg: ldo2 { + regulator-min-microvolt = <1050000>; + regulator-max-microvolt = <1050000>; + }; + ldo3_reg: ldo3 { + regulator-min-microvolt = <1000000>; + regulator-max-microvolt = <3300000>; + }; + ldo4_reg: ldo4 { + regulator-min-microvolt = <1000000>; + regulator-max-microvolt = <3300000>; + regulator-always-on; + }; + ldo5_reg: ldo5 { + regulator-min-microvolt = <1000000>; + regulator-max-microvolt = <3300000>; + }; + ldo6_reg: ldo6 { + regulator-min-microvolt = <1200000>; + regulator-max-microvolt = <1200000>; + }; + ldo7_reg: ldo7 { + regulator-min-microvolt = <1200000>; + regulator-max-microvolt = <1200000>; + regulator-always-on; + regulator-boot-on; + }; + ldo8_reg: ldo8 { + regulator-min-microvolt = <1000000>; + regulator-max-microvolt = <3300000>; + regulator-always-on; + }; + }; + };
Signature · 1 line
1.7.0.4
Re: [PATCH 2/4] regulator: tps65910: Add device tree bindings
Quoted 6 lines · Rhyland Klein
Add device tree bindings for TI's tps65910 pmic.
Signed-off-by Rhyland Klein <[email protected]>--- Documentation/devicetree/bindings/mfd/tps65910.txt | 132 ++++++++++++++++++++ 1 files changed, 132 insertions(+), 0 deletions(-)
There's no actual code changes here, this should be part of the patch adding the code, especially since there's only one patch for the code change. If there had been a series of changes it'd possibly have made sense to split the binding document but when it's just one patch it's easier to review together.
_______________________________________________
devicetree-discuss mailing list devicetree-discuss-uLR06cmDAlY/[email protected]
https://lists.ozlabs.org/listinfo/devicetree-discuss
PATCH 3/4 mfd: tps65910: Add device-tree support
In reply to Rhyland KleinAdd device tree based initialization support for TI's tps65910 pmic.
--- drivers/gpio/gpio-tps65910.c | 39 ++++++++++++++- drivers/mfd/tps65910-irq.c | 21 ++++++-- drivers/mfd/tps65910.c | 78 +++++++++++++++++++++++++++++- drivers/regulator/tps65910-regulator.c | 84 +++++++++++++++++++++++++++++++- include/linux/mfd/tps65910.h | 3 +- 5 files changed, 214 insertions(+), 11 deletions(-)
drivers/gpio/gpio-tps65910.c +37 -2
@@ -66,9 +66,38 @@ static int tps65910_gpio_input(struct gpio_chip *gc, unsigned offset) GPIO_CFG_MASK); } +#ifdef CONFIG_OF +static int tps65910_gpio_parse_dt (struct device *dev, +struct tps65910_board *board) +{ +struct device_node *np = dev->of_node; +unsigned int prop_array[TPS6591X_MAX_NUM_GPIO ]; +int idx =0 , ret; + + ret =of_property_read_u32_array (np,"ti,en-gpio-sleep" , + prop_array,TPS6591X_MAX_NUM_GPIO ); +if (!ret) +for (idx =0 ; idx <ARRAY_SIZE (prop_array); idx++) + board->en_gpio_sleep[idx] = (prop_array[idx] !=0 ); +else if (ret != -EINVAL ) { +dev_err (dev, +"error reading property ti,en-gpio-sleep: %d\n." , ret); +return ret; + } + +return 0 ; +} +#else +static int tps65910_gpio_parse_dt (struct device *dev, +struct tps65910_board *board) +{ +return 0 ; +} +#endif +void tps65910_gpio_init (struct tps65910 *tps65910,int gpio_base) { -int ret; +int ret =0 ;struct tps65910_board *board_data;if (!gpio_base)
@@ -97,7 +126,13 @@ void tps65910_gpio_init(struct tps65910 *tps65910, int gpio_base) tps65910->gpio.get = tps65910_gpio_get;/* Configure sleep control for gpios */ - board_data =dev_get_platdata (tps65910->dev); + board_data = tps65910->board_data; +if (board_data->use_dt_for_init_data && tps65910->dev->of_node) + ret =tps65910_gpio_parse_dt (tps65910->dev, board_data); + +if (ret) +return ; +if (board_data) {int i;for (i =0 ; i < tps65910->gpio.ngpio; ++i) {
drivers/mfd/tps65910-irq.c +15 -6
@@ -180,12 +180,6 @@ int tps65910_irq_init(struct tps65910 *tps65910, int irq,return -EINVAL ; } - tps65910->irq_mask =0xFFFFFF ; - -mutex_init (&tps65910->irq_lock); - tps65910->chip_irq = irq; - tps65910->irq_base = pdata->irq_base; -switch (tps65910_chip_id (tps65910)) {case TPS65910 : tps65910->irq_num =TPS65910_NUM_IRQ ;
@@ -195,6 +189,21 @@ int tps65910_irq_init(struct tps65910 *tps65910, int irq,break ; } +if (pdata->irq_base <=0 ) + pdata->irq_base =irq_alloc_descs (-1 ,0 , tps65910->irq_num,-1 ); + +if (pdata->irq_base <=0 ) { +dev_err (tps65910->dev,"Failed to allocate irq descs: %d\n" , + pdata->irq_base); +return pdata->irq_base; + } + + tps65910->irq_mask =0xFFFFFF ; + +mutex_init (&tps65910->irq_lock); + tps65910->chip_irq = irq; + tps65910->irq_base = pdata->irq_base; +/* Register with genirq */ for (cur_irq = tps65910->irq_base; cur_irq < tps65910->irq_num + tps65910->irq_base;
drivers/mfd/tps65910.c +77 -1
113 lines not on this page · raw message
drivers/regulator/tps65910-regulator.c +83 -1
108 lines not on this page · raw message
include/linux/mfd/tps65910.h +2 -1
@@ -787,13 +787,13 @@* struct tps65910_board * Board platform data may be used to initialize regulators. */ -struct tps65910_board {int gpio_base;int irq;int irq_base;int vmbch_threshold;int vmbch2_threshold; +bool use_dt_for_init_data;/* signal to parse dt for reg init data*/ bool en_gpio_sleep[TPS6591X_MAX_NUM_GPIO ];unsigned long regulator_ext_sleep_control[TPS65910_NUM_REGS ];struct regulator_init_data *tps65910_pmic_init_data[TPS65910_NUM_REGS ];
@@ -807,6 +807,7 @@ struct tps65910 {struct device *dev;struct i2c_client *i2c_client;struct regmap *regmap; +struct tps65910_board *board_data;struct mutex io_mutex;unsigned int id;int (*read)(struct tps65910 *tps65910,u8 reg,int size,void *dest);
Signature · 1 line
1.7.0.4
Re: [PATCH 3/4] mfd: tps65910: Add device-tree support
Quoted 1 line · Rhyland Klein
Add device tree based initialization support for TI's tps65910 pmic.
Actually, now I look at the larger patch this probably wants to be split up by driver and possibly split further within that.
drivers/gpio/gpio-tps65910.c void tps65910_gpio_init(struct tps65910 *tps65910, int gpio_base) · line 132
Quoted 4 lines
drivers/gpio/gpio-tps65910.c +4
-0+ board_data = tps65910->board_data; +if (board_data->use_dt_for_init_data && tps65910->dev->of_node) + ret =tps65910_gpio_parse_dt (tps65910->dev, board_data); +
This is a really odd idiom - normally the pattern for device tree support is to just go and try to use the device tree data if it's there and there's no need for any flag to say if it should be used.
Quoted 4 lines
drivers/mfd/tps65910-irq.c +4
-0+if (pdata->irq_base <=0 ) + pdata->irq_base =irq_alloc_descs (-1 ,0 , tps65910->irq_num,-1 ); + +if (pdata->irq_base <=0 ) {
drivers/mfd/tps65910-irq.c int tps65910_irq_init(struct tps65910 *tps65910, int irq, · line 205
Quoted 10 lines
drivers/mfd/tps65910-irq.c +10
-0+dev_err (tps65910->dev,"Failed to allocate irq descs: %d\n" , + pdata->irq_base); +return pdata->irq_base; + } + + tps65910->irq_mask =0xFFFFFF ; + +mutex_init (&tps65910->irq_lock); + tps65910->chip_irq = irq; + tps65910->irq_base = pdata->irq_base;
While this is needed for DT support it can be done separately and would probably be better split out into a separate patch.
drivers/mfd/tps65910.c static int tps65910_i2c_probe(struct i2c_client *i2c, · line 177
Quoted 5 lines
drivers/mfd/tps65910.c +5
-0+/* Pass of data to child devices */ +for (idx =0 ; idx <ARRAY_SIZE (tps65910s); idx++) { + tps65910s[idx].platform_data = pmic_plat_data; + tps65910s[idx].pdata_size =sizeof (*pmic_plat_data); + }
Why is this needed - can't the DT parsing just be moved where it's used?
drivers/regulator/tps65910-regulator.c static int tps65910_set_ext_sleep_config(struct tps65910_reg *pmic, · line 1125
Quoted 12 lines
drivers/regulator/tps65910-regulator.c +12
-0+for_each_child_of_node (regulators, child) { +struct regulator_init_data *init_data; + + init_data =of_get_regulator_init_data (&pdev->dev, child); +if (!init_data) { +dev_err (&pdev->dev, +"failed to parse DT for regulator %s\n" , + child->name); +return -EINVAL ; + } + +for (idx =0 ; idx < pmic->num_regulators; idx++) {
Hrm, this iteration over a group of regulators to find the relevant node by name is going to be a fairly common pattern (there's already at least one driver doing this IIRC) - we should really factor it out into common code. Please consider doing this when you resubmit.
drivers/regulator/tps65910-regulator.c static int tps65910_set_ext_sleep_config(struct tps65910_reg *pmic, · line 1129
Quoted 4 lines
drivers/regulator/tps65910-regulator.c +4
-0+if (!strcasecmp (info[idx].name, child->name)) { +if (all_data[idx]) { + dev_err(&pdev->dev, + "Duplicate Regulator Node %s\n",
Please fix the capitalisation in the error message.
drivers/regulator/tps65910-regulator.c static int tps65910_set_ext_sleep_config(struct tps65910_reg *pmic, · line 1144
Quoted 7 lines
drivers/regulator/tps65910-regulator.c +7
-0+/* Check to see if we iterated without finding its name */ +if (idx == pmic->num_regulators) { +dev_err (&pdev->dev, +"Unknown regulator node found [%s]\n" , + child->name); +return -EINVAL ; + }
It'd seem more robust to only print the warning and not return the error, that way we don't completely fail the device initialisation if there's data we don't understand.
I'm also not seeing a change here that passes the DT node to regulator_register() - you should be doing that, it's needed so consumers can bind to the regulator.
Re: [PATCH 3/4] mfd: tps65910: Add device-tree support
Quoted 8 lines · Mark Brown
* PGP Signed by an unknown key
Quoted 1 line · Rhyland Klein
Add device tree based initialization support for TI's tps65910 pmic.
Actually, now I look at the larger patch this probably wants to be split up by driver and possibly split further within that.
Quoted 9 lines
drivers/gpio/gpio-tps65910.c void tps65910_gpio_init(struct tps65910 *tps65910, int gpio_base) · line 132
Quoted 4 lines
drivers/gpio/gpio-tps65910.c +4
-0+ board_data = tps65910->board_data; +if (board_data->use_dt_for_init_data && tps65910->dev->of_node) + ret =tps65910_gpio_parse_dt (tps65910->dev, board_data); +This is a really odd idiom - normally the pattern for device tree support is to just go and try to use the device tree data if it's there and there's no need for any flag to say if it should be used.
I agree its odd. My concern was that the idiom is that is pdata assigned from board files should override dt data. At this point, we don't know where the tps65910->board_data is coming from, dt or board files. Arbitrarily using dt breaks that idiom. We could do a check like this if you prefer:
if (!(dev_get_platdata(tps65910->dev) && tps65910->dev->of_node)
i.e. if doesn't have pdata supplied from board files, but does have dt node.
Quoted 9 lines
Quoted 9 lines
drivers/mfd/tps65910-irq.c +9
-0+if (pdata->irq_base <=0 ) + pdata->irq_base =irq_alloc_descs (-1 ,0 , tps65910->irq_num,-1 ); + +if (pdata->irq_base <=0 ) { +dev_err (tps65910->dev,"Failed to allocate irq descs: %d\n" , + pdata->irq_base); +return pdata->irq_base; + } +
Quoted 9 lines
drivers/mfd/tps65910-irq.c int tps65910_irq_init(struct tps65910 *tps65910, int irq, · line 205
Quoted 5 lines
drivers/mfd/tps65910-irq.c +5
-0+ tps65910->irq_mask =0xFFFFFF ; + +mutex_init (&tps65910->irq_lock); + tps65910->chip_irq = irq; + tps65910->irq_base = pdata->irq_base;While this is needed for DT support it can be done separately and would probably be better split out into a separate patch.
ok.
Quoted 18 lines
drivers/mfd/tps65910.c static int tps65910_i2c_probe(struct i2c_client *i2c, · line 177
Quoted 5 lines
drivers/mfd/tps65910.c +5
-0+/* Pass of data to child devices */ +for (idx =0 ; idx <ARRAY_SIZE (tps65910s); idx++) { + tps65910s[idx].platform_data = pmic_plat_data; + tps65910s[idx].pdata_size =sizeof (*pmic_plat_data); + }Why is this needed - can't the DT parsing just be moved where it's used?
Quoted 9 lines
drivers/regulator/tps65910-regulator.c +9
-0+for_each_child_of_node (regulators, child) { +struct regulator_init_data *init_data; + + init_data =of_get_regulator_init_data (&pdev->dev, child); +if (!init_data) { +dev_err (&pdev->dev, +"failed to parse DT for regulator %s\n" , + child->name); +return -EINVAL ;
Quoted 8 lines
drivers/regulator/tps65910-regulator.c static int tps65910_set_ext_sleep_config(struct tps65910_reg *pmic, · line 1125
Quoted 3 lines
drivers/regulator/tps65910-regulator.c +3
-0+ } + +for (idx =0 ; idx < pmic->num_regulators; idx++) {Hrm, this iteration over a group of regulators to find the relevant node by name is going to be a fairly common pattern (there's already at least one driver doing this IIRC) - we should really factor it out into common code. Please consider doing this when you resubmit.
Ok.
Quoted 20 lines
drivers/regulator/tps65910-regulator.c static int tps65910_set_ext_sleep_config(struct tps65910_reg *pmic, · line 1129
Quoted 5 lines
drivers/regulator/tps65910-regulator.c +4
-0+if (!strcasecmp (info[idx].name, child->name)) { +if (all_data[idx]) { + dev_err(&pdev->dev, + "Duplicate Regulator Node %s\n",Please fix the capitalisation in the error message.
drivers/regulator/tps65910-regulator.c static int tps65910_set_ext_sleep_config(struct tps65910_reg *pmic, · line 1144
Quoted 7 lines
drivers/regulator/tps65910-regulator.c +7
-0+/* Check to see if we iterated without finding its name */ +if (idx == pmic->num_regulators) { +dev_err (&pdev->dev, +"Unknown regulator node found [%s]\n" , + child->name); +return -EINVAL ; + }It'd seem more robust to only print the warning and not return the error, that way we don't completely fail the device initialisation if there's data we don't understand.
Quoted 6 lines
I'm also not seeing a change here that passes the DT node to
regulator_register()- you should be doing that, it's needed so consumers can bind to the regulator.* Unknown Key
*0x6E30FDDD
Thanks,
rhyland
Re: [PATCH 3/4] mfd: tps65910: Add device-tree support
Quoted 11 lines · Rhyland Klein
Quoted 3 lines · Mark Brown
This is a really odd idiom - normally the pattern for device tree support is to just go and try to use the device tree data if it's there and there's no need for any flag to say if it should be used.
I agree its odd. My concern was that the idiom is that is pdata assigned from board files should override dt data. At this point, we don't know where the
tps65910->board_datais coming from, dt or board files. Arbitrarily using dt breaks that idiom. We could do a check like this if you prefer:
No, just prefer the DT - what you're proposing is exactly the opposite idiom to what all the other DT drivers do so we'd need to go round changing the policy globally at which point we probably want to start having helpers for this.
Re: [PATCH 3/4] mfd: tps65910: Add device-tree support
Quoted 13 lines · Mark Brown
Quoted 11 lines · Rhyland Klein
Quoted 3 lines · Mark Brown
This is a really odd idiom - normally the pattern for device tree support is to just go and try to use the device tree data if it's there and there's no need for any flag to say if it should be used.
I agree its odd. My concern was that the idiom is that is pdata assigned from board files should override dt data. At this point, we don't know where the
tps65910->board_datais coming from, dt or board files. Arbitrarily using dt breaks that idiom. We could do a check like this if you prefer:
Quoted 4 lines
No, just prefer the DT - what you're proposing is exactly the opposite idiom to what all the other DT drivers do so we'd need to go round changing the policy globally at which point we probably want to start having helpers for this.
That's not right - the idea is that pdata should override device tree so that if there's a platform where the DT is known to contain incorrect data, then some early platform code can add pdata to the device to fix the problem, and that will be used in preference to the DT data.
At least, that's the last I heard Grant say on the subject, and that's how I've been writing all the Tegra-related drivers, and I've seen others do the same for other platforms.
Re: [PATCH 3/4] mfd: tps65910: Add device-tree support
Quoted 8 lines · Stephen Warren
That's not right - the idea is that pdata should override device tree so that if there's a platform where the DT is known to contain incorrect data, then some early platform code can add pdata to the device to fix the problem, and that will be used in preference to the DT data.
At least, that's the last I heard Grant say on the subject, and that's how I've been writing all the Tegra-related drivers, and I've seen others do the same for other platforms.
Ugh, this is just leading to horrible code here (and why on earth aren't we just implementing fixups for DT data?). Though that said I don't understand why the code here isn't just checking that there's platform data rather than setting a flag that says there's platform data, the driver already needs to use the presence of platform data as a check anyway.
PATCH 4/4 ARM: Tegra: Add support for TPS65910 PMIC
In reply to Rhyland KleinAdd support for the tps65910 pmic on cardhu.
--- arch/arm/boot/dts/tegra-cardhu.dts | 92 ++++++++++++++++++++++++++++++++++++ 1 files changed, 92 insertions(+), 0 deletions(-)
arch/arm/boot/dts/tegra-cardhu.dts +92 -0
@@ -115,6 +115,98 @@ micdet-delay = <100>; gpio-cfg = <0xffffffff 0xffffffff 0 0xffffffff 0xffffffff>; }; + + pmic: tps65911@2d { + compatible = "ti,tps65911"; + reg = <0x2d>; + interrupts = < 0 118 0x04 >; + + #gpio-cells = <2>; + gpio-controller; + + #interrupt-cells = <2>; + interrupt-controller; + + ti,vmbch-threshold = <0>; + ti,vmbch2-threshold = <0>; + ti,regulator-ext-sleep-control = < 0 + 0 + 0x4 /* input EN3 */ + 0 + 0x1 /* input EN1 */ + 0 + 0 + 0 + 0 + 0 + 0 + 0x1 /* input EN1 */ + 0x1>; /* input EN1 */ + ti,en-gpio-sleep = <0 0 1 0 0 0 0 0 0>; + + regulators { + vdd1_reg: vdd1 { + regulator-min-microvolt = < 600000>; + regulator-max-microvolt = <1500000>; + regulator-always-on; + regulator-boot-on; + }; + vdd2_reg: vdd2 { + regulator-min-microvolt = < 600000>; + regulator-max-microvolt = <1500000>; + regulator-always-on; + regulator-boot-on; + }; + vddctrl_reg: vddctrl { + regulator-min-microvolt = < 600000>; + regulator-max-microvolt = <1400000>; + regulator-always-on; + regulator-boot-on; + }; + vio_reg: vio { + regulator-min-microvolt = <1500000>; + regulator-max-microvolt = <1800000>; + regulator-always-on; + regulator-boot-on; + }; + ldo1_reg: ldo1 { + regulator-min-microvolt = <1000000>; + regulator-max-microvolt = <3300000>; + }; + ldo2_reg: ldo2 { + regulator-min-microvolt = <1050000>; + regulator-max-microvolt = <1050000>; + }; + ldo3_reg: ldo3 { + regulator-min-microvolt = <1000000>; + regulator-max-microvolt = <3300000>; + }; + ldo4_reg: ldo4 { + regulator-min-microvolt = <1000000>; + regulator-max-microvolt = <3300000>; + regulator-always-on; + }; + ldo5_reg: ldo5 { + regulator-min-microvolt = <1000000>; + regulator-max-microvolt = <3300000>; + }; + ldo6_reg: ldo6 { + regulator-min-microvolt = <1200000>; + regulator-max-microvolt = <1200000>; + }; + ldo7_reg: ldo7 { + regulator-min-microvolt = <1200000>; + regulator-max-microvolt = <1200000>; + regulator-always-on; + regulator-boot-on; + }; + ldo8_reg: ldo8 { + regulator-min-microvolt = <1000000>; + regulator-max-microvolt = <3300000>; + regulator-always-on; + }; + }; + }; }; sdhci@78000000 {
Signature · 1 line
1.7.0.4