mfd: tps65912: Driver rewrite with DT support
Subsystems (4)
v3 cover mfd: tps65912: Driver rewrite with DT support
In an effort to cleanup this driver and add Device Tree support the driver has been rewritten based on new driver styles and modern kernel driver helpers. This has nearly halved the lines of code while keeping all previous functionality.
Platform file based initialization has been dropped as there is no examples of this use in the kernel.
v1 can be found here: [1] v2: [2]
Changes from v2:
- Split the series further into subsystems
Changes from v1:
- Split the rewrite into delete/create patches
- several small fixes as discussed in v1 thread
[1] http://www.spinics.net/lists/devicetree/msg93863.html
[2] http://www.spinics.net/lists/devicetree/msg95003.html
Andrew F. Davis (5):
Documentation: tps65912: Add DT bindings for the TPS65912 PMIC
mfd: tps65912: Remove old driver in preparation for new driver
mfd: tps65912: Add driver for the TPS65912 PMIC
regulators: tps65912: Add regulator driver for the TPS65912 PMIC
gpio: tps65912: Add GPIO driver for the TPS65912 PMIC
.../devicetree/bindings/gpio/gpio-tps65912.txt | 16 + Documentation/devicetree/bindings/mfd/tps65912.txt | 42 ++ .../bindings/regulator/tps65912-regulator.txt | 32 + drivers/gpio/Kconfig | 2 +- drivers/gpio/gpio-tps65912.c | 291 ++++---- drivers/mfd/Kconfig | 20 +- drivers/mfd/Makefile | 3 +- drivers/mfd/tps65912-core.c | 289 +++----- drivers/mfd/tps65912-i2c.c | 225 +++--- drivers/mfd/tps65912-irq.c | 217 ------ drivers/mfd/tps65912-spi.c | 226 +++--- drivers/regulator/Kconfig | 2 +- drivers/regulator/tps65912-regulator.c | 781 +++++++-------------- include/linux/mfd/tps65912.h | 255 ++++--- 14 files changed, 925 insertions(+), 1476 deletions(-) create mode 100644 Documentation/devicetree/bindings/gpio/gpio-tps65912.txt create mode 100644 Documentation/devicetree/bindings/mfd/tps65912.txt create mode 100644 Documentation/devicetree/bindings/regulator/tps65912-regulator.txt rewrite drivers/gpio/gpio-tps65912.c (68%) rewrite drivers/mfd/tps65912-core.c (96%) rewrite drivers/mfd/tps65912-i2c.c (93%) delete mode 100644 drivers/mfd/tps65912-irq.c
rewrite drivers/mfd/tps65912-spi.c (92%) rewrite drivers/regulator/tps65912-regulator.c (94%)
Signature · 1 line
1.9.1
PATCH v3 1/5 Documentation: tps65912: Add DT bindings for the TPS65912 PMIC
The TPS65912 PMIC contains several regulators and a GPIO controller. Add bindings for the TPS65912 PMIC.
--- .../devicetree/bindings/gpio/gpio-tps65912.txt | 16 +++++++++ Documentation/devicetree/bindings/mfd/tps65912.txt | 42 ++++++++++++++++++++++ .../bindings/regulator/tps65912-regulator.txt | 32 +++++++++++++++++ 3 files changed, 90 insertions(+) create mode 100644 Documentation/devicetree/bindings/gpio/gpio-tps65912.txt create mode 100644 Documentation/devicetree/bindings/mfd/tps65912.txt create mode 100644 Documentation/devicetree/bindings/regulator/tps65912-regulator.txt
Documentation/devicetree/bindings/gpio/gpio-tps65912.txt new file +16 -0
@@ -0,0 +1,16 @@ +* TPS65912 GPIO Controller bindings + +Required properties: + - compatible : Should be "ti,tps65912-gpio". + - gpio-controller : Marks the device node as a GPIO Controller. + - #gpio-cells : Should be two. The first cell is the pin number and + the second cell is used to specify flags. + See include/dt-bindings/gpio/gpio.h for possible values. + +Example: + + gpio4: tps65912_gpio { + compatible = "ti,tps65912-gpio"; + gpio-controller; + #gpio-cells = <2>; + };
Documentation/devicetree/bindings/mfd/tps65912.txt new file +42 -0
42 lines not on this page · raw message
Documentation/devicetree/bindings/regulator/tps65912-regulator.txt new file +32 -0
@@ -0,0 +1,32 @@ +* TPS65912 regulator bindings + +Required properties: + - compatible: Should be: + - "ti,tps65912-dcdc1" for DCDC1 + - "ti,tps65912-dcdc2" for DCDC2 + - "ti,tps65912-dcdc3" for DCDC3 + - "ti,tps65912-dcdc4" for DCDC4 + - "ti,tps65912-ldo1" for LDO1 + - "ti,tps65912-ldo2" for LDO2 + - "ti,tps65912-ldo3" for LDO3 + - "ti,tps65912-ldo4" for LDO4 + - "ti,tps65912-ldo5" for LDO5 + - "ti,tps65912-ldo6" for LDO6 + - "ti,tps65912-ldo7" for LDO7 + - "ti,tps65912-ldo8" for LDO8 + - "ti,tps65912-ldo9" for LDO9 + - "ti,tps65912-ldo10" for LDO10 + +Optional properties: + - Any optional property defined in ../regulator/regulator.txt + +Example: + + xyz: regulator@0 { + compatible = "ti,tps65912-dcdc1"; + regulator-name = "vdd_core"; + regulator-min-microvolt = <912000>; + regulator-max-microvolt = <1144000>; + regulator-boot-on; + regulator-always-on; + };
Signature · 1 line
1.9.1
Re: [PATCH v3 1/5] Documentation: tps65912: Add DT bindings for the TPS65912 PMIC
Quoted 4 lines · Andrew F. Davis
The TPS65912 PMIC contains several regulators and a GPIO controller. Add bindings for the TPS65912 PMIC.
Signed-off-by Andrew F. Davis <[email protected]>
For GPIO bindings.
Yours,
Linus Walleij
PATCH v3 2/5 mfd: tps65912: Remove old driver in preparation for new driver
In reply to Andrew F. DavisThe old tps65912 driver is being replaced, delete old driver.
--- drivers/gpio/Kconfig | 6 - drivers/gpio/Makefile | 1 - drivers/gpio/gpio-tps65912.c | 153 ---------- drivers/mfd/Kconfig | 26 -- drivers/mfd/Makefile | 4 - drivers/mfd/tps65912-core.c | 175 ----------- drivers/mfd/tps65912-i2c.c | 139 --------- drivers/mfd/tps65912-irq.c | 217 ------------- drivers/mfd/tps65912-spi.c | 141 --------- drivers/regulator/Kconfig | 6 - drivers/regulator/Makefile | 1 - drivers/regulator/tps65912-regulator.c | 541 --------------------------------- include/linux/mfd/tps65912.h | 328 -------------------- 13 files changed, 1738 deletions(-) delete mode 100644 drivers/gpio/gpio-tps65912.c delete mode 100644 drivers/mfd/tps65912-core.c delete mode 100644 drivers/mfd/tps65912-i2c.c delete mode 100644 drivers/mfd/tps65912-irq.c delete mode 100644 drivers/mfd/tps65912-spi.c delete mode 100644 drivers/regulator/tps65912-regulator.c delete mode 100644 include/linux/mfd/tps65912.h
drivers/gpio/Kconfig +0 -6
@@ -838,12 +838,6 @@ config GPIO_TPS65910 Select this option to enable GPIO driver for the TPS65910 chip family. -config GPIO_TPS65912 - tristate "TI TPS65912 GPIO" - depends on (MFD_TPS65912_I2C || MFD_TPS65912_SPI) - help - This driver supports TPS65912 gpio chip - config GPIO_TWL4030 tristate "TWL4030, TWL5030, and TPS659x0 GPIOs" depends on TWL4030_CORE
drivers/gpio/Makefile +0 -1
@@ -96,7 +96,6 @@ obj-$(CONFIG_GPIO_TIMBERDALE) += gpio-timberdale.o obj-$(CONFIG_GPIO_PALMAS) += gpio-palmas.o obj-$(CONFIG_GPIO_TPS6586X) += gpio-tps6586x.o obj-$(CONFIG_GPIO_TPS65910) += gpio-tps65910.o -obj-$(CONFIG_GPIO_TPS65912) += gpio-tps65912.o obj-$(CONFIG_GPIO_TS5500) += gpio-ts5500.o obj-$(CONFIG_GPIO_TWL4030) += gpio-twl4030.o obj-$(CONFIG_GPIO_TWL6040) += gpio-twl6040.o
drivers/gpio/gpio-tps65912.c deleted +0 -153
153 lines not on this page · raw message
drivers/mfd/Kconfig +0 -26
@@ -1167,32 +1167,6 @@ config MFD_TPS65910 if you say yes here you get support for the TPS65910 series of Power Management chips. -config MFD_TPS65912 - bool "TI TPS65912 Power Management chip" - depends on GPIOLIB - select MFD_CORE - help - If you say yes here you get support for the TPS65912 series of - PM chips. - -config MFD_TPS65912_I2C - bool "TI TPS65912 Power Management chip with I2C" - select MFD_CORE - select MFD_TPS65912 - depends on I2C=y && GPIOLIB - help - If you say yes here you get support for the TPS65912 series of - PM chips with I2C interface. - -config MFD_TPS65912_SPI - bool "TI TPS65912 Power Management chip with SPI" - select MFD_CORE - select MFD_TPS65912 - depends on SPI_MASTER && GPIOLIB - help - If you say yes here you get support for the TPS65912 series of - PM chips with SPI interface. - config MFD_TPS80031 bool "TI TPS80031/TPS80032 Power Management chips" depends on I2C=y
drivers/mfd/Makefile +0 -4
@@ -69,10 +69,6 @@ obj-$(CONFIG_TPS6507X) += tps6507x.o obj-$(CONFIG_MFD_TPS65217) += tps65217.o obj-$(CONFIG_MFD_TPS65218) += tps65218.o obj-$(CONFIG_MFD_TPS65910) += tps65910.o -tps65912-objs := tps65912-core.o tps65912-irq.o -obj-$(CONFIG_MFD_TPS65912) += tps65912.o -obj-$(CONFIG_MFD_TPS65912_I2C) += tps65912-i2c.o -obj-$(CONFIG_MFD_TPS65912_SPI) += tps65912-spi.o obj-$(CONFIG_MFD_TPS80031) += tps80031.o obj-$(CONFIG_MENELAUS) += menelaus.o
drivers/mfd/tps65912-core.c deleted +0 -175
175 lines not on this page · raw message
drivers/mfd/tps65912-i2c.c deleted +0 -139
139 lines not on this page · raw message
drivers/mfd/tps65912-irq.c deleted +0 -217
217 lines not on this page · raw message
drivers/mfd/tps65912-spi.c deleted +0 -141
141 lines not on this page · raw message
drivers/regulator/Kconfig +0 -6
@@ -727,12 +727,6 @@ config REGULATOR_TPS65910 help This driver supports TPS65910/TPS65911 voltage regulator chips. -config REGULATOR_TPS65912 - tristate "TI TPS65912 Power regulator" - depends on (MFD_TPS65912_I2C || MFD_TPS65912_SPI) - help - This driver supports TPS65912 voltage regulator chip. - config REGULATOR_TPS80031 tristate "TI TPS80031/TPS80032 power regualtor driver" depends on MFD_TPS80031
drivers/regulator/Makefile +0 -1
@@ -91,7 +91,6 @@ obj-$(CONFIG_REGULATOR_TPS65218) += tps65218-regulator.o obj-$(CONFIG_REGULATOR_TPS6524X) += tps6524x-regulator.o obj-$(CONFIG_REGULATOR_TPS6586X) += tps6586x-regulator.o obj-$(CONFIG_REGULATOR_TPS65910) += tps65910-regulator.o -obj-$(CONFIG_REGULATOR_TPS65912) += tps65912-regulator.o obj-$(CONFIG_REGULATOR_TPS80031) += tps80031-regulator.o obj-$(CONFIG_REGULATOR_TWL4030) += twl-regulator.o obj-$(CONFIG_REGULATOR_VEXPRESS) += vexpress.o
drivers/regulator/tps65912-regulator.c deleted +0 -541
541 lines not on this page · raw message
include/linux/mfd/tps65912.h deleted +0 -328
328 lines not on this page · raw message
Signature · 1 line
1.9.1
Re: [PATCH v3 2/5] mfd: tps65912: Remove old driver in preparation for new driver
Quoted 17 lines · Andrew F. Davis
The old tps65912 driver is being replaced, delete old driver.
Signed-off-by Andrew F. Davis <[email protected]>--- drivers/gpio/Kconfig | 6 - drivers/gpio/Makefile | 1 - drivers/gpio/gpio-tps65912.c | 153 ---------- drivers/mfd/Kconfig | 26 -- drivers/mfd/Makefile | 4 - drivers/mfd/tps65912-core.c | 175 ----------- drivers/mfd/tps65912-i2c.c | 139 --------- drivers/mfd/tps65912-irq.c | 217 ------------- drivers/mfd/tps65912-spi.c | 141 --------- drivers/regulator/Kconfig | 6 - drivers/regulator/Makefile | 1 - drivers/regulator/tps65912-regulator.c | 541 --------------------------------- include/linux/mfd/tps65912.h | 328 --------------------
Quoted 8 lines
13 files changed, 1738 deletions(-) delete mode 100644 drivers/gpio/gpio-tps65912.c delete mode 100644 drivers/mfd/tps65912-core.c delete mode 100644 drivers/mfd/tps65912-i2c.c delete mode 100644 drivers/mfd/tps65912-irq.c delete mode 100644 drivers/mfd/tps65912-spi.c delete mode 100644 drivers/regulator/tps65912-regulator.c delete mode 100644 include/linux/mfd/tps65912.h
I initially thought it was a bad idea due to bisectability blah blah blah, but as the next patch adds a completely new incarnation I thought this point to be moot.
Signature · 8 lines
Lee Jones Linaro STMicroelectronics Landing Team Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v3 2/5] mfd: tps65912: Remove old driver in preparation for new driver
In reply to Andrew F. DavisQuoted 3 lines · Andrew F. Davis
The old tps65912 driver is being replaced, delete old driver.
Signed-off-by Andrew F. Davis <[email protected]>
The merge collisions are unpredictable. Will this be merged through the MFD tree?
Yours,
Linus Walleij
PATCH v3 3/5 mfd: tps65912: Add driver for the TPS65912 PMIC
In reply to Andrew F. DavisThis patch adds support for TPS65912 mfd device. It provides communication through the I2C and SPI interfaces. It contains the following components:
- Regulators
- GPIO controller
--- drivers/mfd/Kconfig | 24 +++ drivers/mfd/Makefile | 3 + drivers/mfd/tps65912-core.c | 114 +++++++++++++ drivers/mfd/tps65912-i2c.c | 86 ++++++++++ drivers/mfd/tps65912-spi.c | 85 ++++++++++ include/linux/mfd/tps65912.h | 393 +++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 705 insertions(+) create mode 100644 drivers/mfd/tps65912-core.c create mode 100644 drivers/mfd/tps65912-i2c.c create mode 100644 drivers/mfd/tps65912-spi.c create mode 100644 include/linux/mfd/tps65912.h
drivers/mfd/Kconfig +24 -0
@@ -1167,6 +1167,30 @@ config MFD_TPS65910 if you say yes here you get support for the TPS65910 series of Power Management chips. +config MFD_TPS65912 + tristate + select REGMAP + select REGMAP_IRQ + select MFD_CORE + +config MFD_TPS65912_I2C + tristate "TI TPS65912 Power Management chip with I2C" + select MFD_TPS65912 + select REGMAP_I2C + depends on I2C + help + If you say yes here you get support for the TPS65912 series of + PM chips with I2C interface. + +config MFD_TPS65912_SPI + tristate "TI TPS65912 Power Management chip with SPI" + select MFD_TPS65912 + select REGMAP_SPI + depends on SPI_MASTER + help + If you say yes here you get support for the TPS65912 series of + PM chips with SPI interface. + config MFD_TPS80031 bool "TI TPS80031/TPS80032 Power Management chips" depends on I2C=y
drivers/mfd/Makefile +3 -0
@@ -69,6 +69,9 @@ obj-$(CONFIG_TPS6507X) += tps6507x.o obj-$(CONFIG_MFD_TPS65217) += tps65217.o obj-$(CONFIG_MFD_TPS65218) += tps65218.o obj-$(CONFIG_MFD_TPS65910) += tps65910.o +obj-$(CONFIG_MFD_TPS65912) += tps65912-core.o +obj-$(CONFIG_MFD_TPS65912_I2C) += tps65912-i2c.o +obj-$(CONFIG_MFD_TPS65912_SPI) += tps65912-spi.o obj-$(CONFIG_MFD_TPS80031) += tps80031.o obj-$(CONFIG_MENELAUS) += menelaus.o
drivers/mfd/tps65912-core.c new file +114 -0
114 lines not on this page · raw message
drivers/mfd/tps65912-i2c.c new file +86 -0
86 lines not on this page · raw message
drivers/mfd/tps65912-spi.c new file +85 -0
85 lines not on this page · raw message
include/linux/mfd/tps65912.h new file +393 -0
393 lines not on this page · raw message
Signature · 1 line
1.9.1
Re: [PATCH v3 3/5] mfd: tps65912: Add driver for the TPS65912 PMIC
Quoted 20 lines · Andrew F. Davis
This patch adds support for TPS65912 mfd device. It provides communication through the I2C and SPI interfaces. It contains the following components:
- Regulators
- GPIO controllerSigned-off-by Andrew F. Davis <[email protected]>--- drivers/mfd/Kconfig | 24 +++ drivers/mfd/Makefile | 3 + drivers/mfd/tps65912-core.c | 114 +++++++++++++ drivers/mfd/tps65912-i2c.c | 86 ++++++++++ drivers/mfd/tps65912-spi.c | 85 ++++++++++ include/linux/mfd/tps65912.h | 393 +++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 705 insertions(+) create mode 100644 drivers/mfd/tps65912-core.c create mode 100644 drivers/mfd/tps65912-i2c.c create mode 100644 drivers/mfd/tps65912-spi.c create mode 100644 include/linux/mfd/tps65912.h
[...]
drivers/mfd/tps65912-core.c line 31
Quoted 5 lines
drivers/mfd/tps65912-core.c new file +5
-0+#define TPS65912_IRQ (_name, _reg, _offset) \ + [TPS65912_IRQ_ ## _name] = { \ + .mask = TPS65912_ ## _reg ## _ ## _name, \ + .reg_offset = _offset, \ + }
I told you about this already.
If you want this set to be merged for v4.3 then you'll need commit b4fe8ba ("regmap: Add generic macro to define regmap_irq") from my tree.
[...]
drivers/mfd/tps65912-i2c.c line 75
Quoted 4 lines
drivers/mfd/tps65912-i2c.c new file +4
-0+static struct i2c_driver tps65912_i2c_driver = { + .driver = { + .name ="tps65912" , + .of_match_table = tps65912_i2c_of_match_table,
of_match_ptr()
[...]
Signature · 8 lines
Lee Jones Linaro STMicroelectronics Landing Team Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v3 3/5] mfd: tps65912: Add driver for the TPS65912 PMIC
Quoted 33 lines · Lee Jones
Quoted 20 lines · Andrew F. Davis
This patch adds support for TPS65912 mfd device. It provides communication through the I2C and SPI interfaces. It contains the following components:
- Regulators
- GPIO controllerSigned-off-by Andrew F. Davis <[email protected]>--- drivers/mfd/Kconfig | 24 +++ drivers/mfd/Makefile | 3 + drivers/mfd/tps65912-core.c | 114 +++++++++++++ drivers/mfd/tps65912-i2c.c | 86 ++++++++++ drivers/mfd/tps65912-spi.c | 85 ++++++++++ include/linux/mfd/tps65912.h | 393 +++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 705 insertions(+)create mode 100644
drivers/mfd/tps65912-core.c
create mode 100644drivers/mfd/tps65912-i2c.c
create mode 100644drivers/mfd/tps65912-spi.c
create mode 100644include/linux/mfd/tps65912.h[...]
drivers/mfd/tps65912-core.c line 31
Quoted 5 lines
drivers/mfd/tps65912-core.c new file +5
-0+#define TPS65912_IRQ (_name, _reg, _offset) \ + [TPS65912_IRQ_ ## _name] = { \ + .mask = TPS65912_ ## _reg ## _ ## _name, \ + .reg_offset = _offset, \ + }I told you about this already.
Quoted 4 lines
If you want this set to be merged for v4.3 then you'll need commit b4fe8ba ("regmap: Add generic macro to define
regmap_irq") from my tree.
You asked me to submit this to Mark Brown, I didn't realize you also wanted me to use the one in your tree. Using yours will make my lines over 80 chars and so it kind of defeats the purpose but I'll do it for v4.
Quoted 9 lines
[...]
drivers/mfd/tps65912-i2c.c line 75
Quoted 4 lines
drivers/mfd/tps65912-i2c.c new file +4
-0+static struct i2c_driver tps65912_i2c_driver = { + .driver = { + .name ="tps65912" , + .of_match_table = tps65912_i2c_of_match_table,
of_match_ptr()
Why? tps65912_i2c_of_match_table is always compiled in.
Quoted 2 lines
[...]
Re: [PATCH v3 3/5] mfd: tps65912: Add driver for the TPS65912 PMIC
Quoted 34 lines · Andrew F. Davis
Quoted 33 lines · Lee Jones
Quoted 20 lines · Andrew F. Davis
This patch adds support for TPS65912 mfd device. It provides communication through the I2C and SPI interfaces. It contains the following components:
- Regulators
- GPIO controllerSigned-off-by Andrew F. Davis <[email protected]>--- drivers/mfd/Kconfig | 24 +++ drivers/mfd/Makefile | 3 + drivers/mfd/tps65912-core.c | 114 +++++++++++++ drivers/mfd/tps65912-i2c.c | 86 ++++++++++ drivers/mfd/tps65912-spi.c | 85 ++++++++++ include/linux/mfd/tps65912.h | 393 +++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 705 insertions(+) create mode 100644 drivers/mfd/tps65912-core.c create mode 100644 drivers/mfd/tps65912-i2c.c create mode 100644 drivers/mfd/tps65912-spi.c create mode 100644 include/linux/mfd/tps65912.h[...]
drivers/mfd/tps65912-core.c line 31
Quoted 5 lines
drivers/mfd/tps65912-core.c new file +5
-0+#define TPS65912_IRQ (_name, _reg, _offset) \ + [TPS65912_IRQ_ ## _name] = { \ + .mask = TPS65912_ ## _reg ## _ ## _name, \ + .reg_offset = _offset, \ + }I told you about this already.
Quoted 8 lines
Quoted 3 lines
If you want this set to be merged for v4.3 then you'll need commit b4fe8ba ("regmap: Add generic macro to define
regmap_irq") from my tree.You asked me to submit this to Mark Brown, I didn't realize you also wanted me to use the one in your tree. Using yours will make my lines over 80 chars and so it kind of defeats the purpose but I'll do it for v4.
I asked two of you to upstream a generic incarnation of your implementation. The other guy got there first. Now I want everyone to use it instead of hand-rolling their own.
Quoted 11 lines
Quoted 9 lines
[...]
drivers/mfd/tps65912-i2c.c line 75
Quoted 4 lines
drivers/mfd/tps65912-i2c.c new file +4
-0+static struct i2c_driver tps65912_i2c_driver = { + .driver = { + .name ="tps65912" , + .of_match_table = tps65912_i2c_of_match_table,
of_match_ptr()Why?
tps65912_i2c_of_match_tableis always compiled in.
But it needn't be.
Signature · 8 lines
Lee Jones Linaro STMicroelectronics Landing Team Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v3 3/5] mfd: tps65912: Add driver for the TPS65912 PMIC
Quoted 40 lines · Lee Jones
Quoted 38 lines · Andrew F. Davis
Quoted 36 lines · Lee Jones
Quoted 20 lines · Andrew F. Davis
This patch adds support for TPS65912 mfd device. It provides communication through the I2C and SPI interfaces. It contains the following components:
- Regulators
- GPIO controllerSigned-off-by Andrew F. Davis <[email protected]>--- drivers/mfd/Kconfig | 24 +++ drivers/mfd/Makefile | 3 + drivers/mfd/tps65912-core.c | 114 +++++++++++++ drivers/mfd/tps65912-i2c.c | 86 ++++++++++ drivers/mfd/tps65912-spi.c | 85 ++++++++++ include/linux/mfd/tps65912.h | 393 +++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 705 insertions(+)create mode 100644
drivers/mfd/tps65912-core.c
create mode 100644drivers/mfd/tps65912-i2c.c
create mode 100644drivers/mfd/tps65912-spi.c
create mode 100644include/linux/mfd/tps65912.h[...]
drivers/mfd/tps65912-core.c line 31
Quoted 5 lines
drivers/mfd/tps65912-core.c new file +5
-0+#define TPS65912_IRQ (_name, _reg, _offset) \ + [TPS65912_IRQ_ ## _name] = { \ + .mask = TPS65912_ ## _reg ## _ ## _name, \ + .reg_offset = _offset, \ + }I told you about this already.
If you want this set to be merged for v4.3 then you'll need commit b4fe8ba ("regmap: Add generic macro to define
regmap_irq") from my tree.
Quoted 9 lines
Quoted 4 lines
You asked me to submit this to Mark Brown, I didn't realize you also wanted me to use the one in your tree. Using yours will make my lines over 80 chars and so it kind of defeats the purpose but I'll do it for v4.
I asked two of you to upstream a generic incarnation of your implementation. The other guy got there first. Now I want everyone to use it instead of hand-rolling their own.
Got it.
Quoted 10 lines
Quoted 10 lines
Quoted 9 lines
[...]
drivers/mfd/tps65912-i2c.c line 75
Quoted 4 lines
drivers/mfd/tps65912-i2c.c new file +4
-0+static struct i2c_driver tps65912_i2c_driver = { + .driver = { + .name ="tps65912" , + .of_match_table = tps65912_i2c_of_match_table,
of_match_ptr()
Quoted 4 lines
Quoted 1 line
Why?
tps65912_i2c_of_match_tableis always compiled in.But it needn't be.
This driver is DT only, would it make more sense to just add a dependency on CONFIG_OF in the Kconfig? I don't see many other drivers that are DT only doing this, the driver should compile just fine without OF enabled, it just wont have DT functionality, so is it really dependent on OF? The of_match_ptr(x) macro looks to be useful when the x is conditionally compiled in, but in my case the x (my of_device_id table) is always compiled. --
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v3 3/5] mfd: tps65912: Add driver for the TPS65912 PMIC
Quoted 63 lines · Andrew F. Davis
Quoted 40 lines · Lee Jones
Quoted 38 lines · Andrew F. Davis
Quoted 36 lines · Lee Jones
Quoted 20 lines · Andrew F. Davis
This patch adds support for TPS65912 mfd device. It provides communication through the I2C and SPI interfaces. It contains the following components:
- Regulators
- GPIO controllerSigned-off-by Andrew F. Davis <[email protected]>--- drivers/mfd/Kconfig | 24 +++ drivers/mfd/Makefile | 3 + drivers/mfd/tps65912-core.c | 114 +++++++++++++ drivers/mfd/tps65912-i2c.c | 86 ++++++++++ drivers/mfd/tps65912-spi.c | 85 ++++++++++ include/linux/mfd/tps65912.h | 393 +++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 705 insertions(+) create mode 100644 drivers/mfd/tps65912-core.c create mode 100644 drivers/mfd/tps65912-i2c.c create mode 100644 drivers/mfd/tps65912-spi.c create mode 100644 include/linux/mfd/tps65912.h[...]
drivers/mfd/tps65912-core.c line 31
Quoted 5 lines
drivers/mfd/tps65912-core.c new file +5
-0+#define TPS65912_IRQ (_name, _reg, _offset) \ + [TPS65912_IRQ_ ## _name] = { \ + .mask = TPS65912_ ## _reg ## _ ## _name, \ + .reg_offset = _offset, \ + }I told you about this already.
If you want this set to be merged for v4.3 then you'll need commit b4fe8ba ("regmap: Add generic macro to define
regmap_irq") from my tree.Quoted 9 lines
Quoted 4 lines
You asked me to submit this to Mark Brown, I didn't realize you also wanted me to use the one in your tree. Using yours will make my lines over 80 chars and so it kind of defeats the purpose but I'll do it for v4.
I asked two of you to upstream a generic incarnation of your implementation. The other guy got there first. Now I want everyone to use it instead of hand-rolling their own.
Got it.
Quoted 10 lines
Quoted 10 lines
Quoted 9 lines
[...]
drivers/mfd/tps65912-i2c.c line 75
Quoted 4 lines
drivers/mfd/tps65912-i2c.c new file +4
-0+static struct i2c_driver tps65912_i2c_driver = { + .driver = { + .name ="tps65912" , + .of_match_table = tps65912_i2c_of_match_table,
of_match_ptr()
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
Why?
tps65912_i2c_of_match_tableis always compiled in.But it needn't be.
This driver is DT only, would it make more sense to just add a dependency on
CONFIG_OFin theKconfig?
Yes, that is the alternitive.
Quoted 3 lines
I don't see many other drivers that are DT
only doing this, the driver should compile just fine without OF enabled, it just wont have DT functionality, so is it really dependent on OF?
Then it should be "depends on OF || COMPILE_TEST"
Quoted 2 lines
The
of_match_ptr(x)macro looks to be useful when the x is conditionally compiled in, but in my case the x (myof_device_idtable) is always compiled.
Signature · 4 lines
Lee Jones Linaro STMicroelectronics Landing Team Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog
Re: [PATCH v3 3/5] mfd: tps65912: Add driver for the TPS65912 PMIC
Quoted 73 lines · Lee Jones
Quoted 63 lines · Andrew F. Davis
Quoted 40 lines · Lee Jones
Quoted 38 lines · Andrew F. Davis
Quoted 36 lines · Lee Jones
Quoted 20 lines · Andrew F. Davis
This patch adds support for TPS65912 mfd device. It provides communication through the I2C and SPI interfaces. It contains the following components:
- Regulators
- GPIO controllerSigned-off-by Andrew F. Davis <[email protected]>--- drivers/mfd/Kconfig | 24 +++ drivers/mfd/Makefile | 3 + drivers/mfd/tps65912-core.c | 114 +++++++++++++ drivers/mfd/tps65912-i2c.c | 86 ++++++++++ drivers/mfd/tps65912-spi.c | 85 ++++++++++ include/linux/mfd/tps65912.h | 393 +++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 705 insertions(+)create mode 100644
drivers/mfd/tps65912-core.c
create mode 100644drivers/mfd/tps65912-i2c.c
create mode 100644drivers/mfd/tps65912-spi.c
create mode 100644include/linux/mfd/tps65912.h[...]
drivers/mfd/tps65912-core.c line 31
Quoted 5 lines
drivers/mfd/tps65912-core.c new file +5
-0+#define TPS65912_IRQ (_name, _reg, _offset) \ + [TPS65912_IRQ_ ## _name] = { \ + .mask = TPS65912_ ## _reg ## _ ## _name, \ + .reg_offset = _offset, \ + }I told you about this already.
If you want this set to be merged for v4.3 then you'll need commit b4fe8ba ("regmap: Add generic macro to define
regmap_irq") from my tree.Quoted 9 lines
Quoted 4 lines
You asked me to submit this to Mark Brown, I didn't realize you also wanted me to use the one in your tree. Using yours will make my lines over 80 chars and so it kind of defeats the purpose but I'll do it for v4.
I asked two of you to upstream a generic incarnation of your implementation. The other guy got there first. Now I want everyone to use it instead of hand-rolling their own.
Got it.
Quoted 10 lines
Quoted 10 lines
Quoted 9 lines
[...]
drivers/mfd/tps65912-i2c.c line 75
Quoted 4 lines
drivers/mfd/tps65912-i2c.c new file +4
-0+static struct i2c_driver tps65912_i2c_driver = { + .driver = { + .name ="tps65912" , + .of_match_table = tps65912_i2c_of_match_table,
of_match_ptr()Quoted 7 lines
Quoted 4 lines
Quoted 1 line
Why?
tps65912_i2c_of_match_tableis always compiled in.But it needn't be.
This driver is DT only, would it make more sense to just add a dependency on
CONFIG_OFin theKconfig?
Quoted 8 lines
Yes, that is the alternitive.
Quoted 3 lines
I don't see many other drivers that are DT
only doing this, the driver should compile just fine without OF enabled, it just wont have DT functionality, so is it really dependent on OF?Then it should be "depends on OF ||
COMPILE_TEST"
OK, I'll add this.
Quoted 3 lines
Quoted 2 lines
The
of_match_ptr(x)macro looks to be useful when the x is conditionally compiled in, but in my case the x (myof_device_idtable) is always compiled.
Re: [PATCH v3 3/5] mfd: tps65912: Add driver for the TPS65912 PMIC
In reply to Andrew F. DavisQuoted 21 lines · Andrew F. Davis
This patch adds support for TPS65912 mfd device. It provides communication through the I2C and SPI interfaces. It contains the following components:
- Regulators
- GPIO controllerSigned-off-by Andrew F. Davis <[email protected]>--- drivers/mfd/Kconfig | 24 +++ drivers/mfd/Makefile | 3 + drivers/mfd/tps65912-core.c | 114 +++++++++++++ drivers/mfd/tps65912-i2c.c | 86 ++++++++++ drivers/mfd/tps65912-spi.c | 85 ++++++++++ include/linux/mfd/tps65912.h | 393 +++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 705 insertions(+)create mode 100644
drivers/mfd/tps65912-core.c
create mode 100644drivers/mfd/tps65912-i2c.c
create mode 100644drivers/mfd/tps65912-spi.c
create mode 100644include/linux/mfd/tps65912.h
[...]
Quoted 6 lines
include/linux/mfd/tps65912.h new file +6
-0+ +/* +* struct tps_info - packages regulator constraints +* @id: Id of the regulator +* @name: Voltage regulator name +* @min_uV: Minimum micro volts
include/linux/mfd/tps65912.h line 354
Quoted 10 lines
include/linux/mfd/tps65912.h new file +10
-0+* @max_uV: Minimum micro volts +* +* This data is used to check the regulator voltage limits while setting. +*/ +struct tps_info { +int id; +const char *name; +int min_uV; +int max_uV; +};
Could you move structure's definitions to the corresponding c-files if they are used only locally in this files, pls?
Quoted 6 lines
include/linux/mfd/tps65912.h new file +6
-0+ +/* +* struct tps65912 - state holder for the tps65912 driver +* +* Device data may be used to access the TPS65912 chip +*/
include/linux/mfd/tps65912.h line 370
Quoted 10 lines
include/linux/mfd/tps65912.h new file +10
-0+struct tps65912 { +struct device *dev; +unsigned int id; + +/* IRQ Data */ +int irq; +struct regmap_irq_chip_data *irq_data; + +struct regulator_desc desc[TPS65912_NUM_REGULATOR ]; +struct tps_info *info[TPS65912_NUM_REGULATOR ];
seems above two field are not used (and id?).
Quoted 24 lines
include/linux/mfd/tps65912.h new file +23
-0+struct regmap *regmap; +}; + +static const struct regmap_range tps65912_yes_ranges[] = { +regmap_reg_range (TPS65912_INT_STS ,TPS65912_GPIO5 ), +}; + +static const struct regmap_access_table tps65912_volatile_table = { + .yes_ranges = tps65912_yes_ranges, + .n_yes_ranges =ARRAY_SIZE (tps65912_yes_ranges), +}; + +static const struct regmap_config tps65912_regmap_co nfig = { + .reg_bits =8 , + .val_bits =8 , + .cache_type =REGCACHE_RBTREE , + .volatile_table = &tps65912_volatile_table, +}; + +int tps65912_device_init (struct tps65912 *tps); +int tps65912_device_exit (struct tps65912 *tps); + +#endif /* __LINUX_MFD_TPS65912_H */
Signature · 2 lines
regards, -grygorii
Re: [PATCH v3 3/5] mfd: tps65912: Add driver for the TPS65912 PMIC
Quoted 36 lines · Grygorii Strashko
Quoted 21 lines · Andrew F. Davis
This patch adds support for TPS65912 mfd device. It provides communication through the I2C and SPI interfaces. It contains the following components:
- Regulators
- GPIO controllerSigned-off-by Andrew F. Davis <[email protected]>--- drivers/mfd/Kconfig | 24 +++ drivers/mfd/Makefile | 3 + drivers/mfd/tps65912-core.c | 114 +++++++++++++ drivers/mfd/tps65912-i2c.c | 86 ++++++++++ drivers/mfd/tps65912-spi.c | 85 ++++++++++ include/linux/mfd/tps65912.h | 393 +++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 705 insertions(+)create mode 100644
drivers/mfd/tps65912-core.ccreate mode 100644drivers/mfd/tps65912-i2c.ccreate mode 100644drivers/mfd/tps65912-spi.ccreate mode 100644include/linux/mfd/tps65912.h[...]
Quoted 11 lines
include/linux/mfd/tps65912.h new file +11
-0+ +/* +* struct tps_info - packages regulator constraints +* @id: Id of the regulator +* @name: Voltage regulator name +* @min_uV: Minimum micro volts +* @max_uV: Minimum micro volts +* +* This data is used to check the regulator voltage limits while setting. +*/ +struct tps_info {
Quoted 9 lines
include/linux/mfd/tps65912.h line 354
Quoted 5 lines
include/linux/mfd/tps65912.h new file +5
-0+int id; +const char *name; +int min_uV; +int max_uV; +};Could you move structure's definitions to the corresponding c-files if they are used only locally in this files, pls?
ACK
Quoted 10 lines
Quoted 10 lines
include/linux/mfd/tps65912.h new file +10
-0+ +/* +* struct tps65912 - state holder for the tps65912 driver +* +* Device data may be used to access the TPS65912 chip +*/ +struct tps65912 { +struct device *dev; +unsigned int id; +
Quoted 9 lines
include/linux/mfd/tps65912.h line 370
Quoted 6 lines
include/linux/mfd/tps65912.h new file +6
-0+/* IRQ Data */ +int irq; +struct regmap_irq_chip_data *irq_data; + +struct regulator_desc desc[TPS65912_NUM_REGULATOR ]; +struct tps_info *info[TPS65912_NUM_REGULATOR ];seems above two field are not used (and id?).
The idea was for a someday use, but because I never did that I'll remove them for now.
Thanks,
Andrew
Quoted 26 lines
Quoted 24 lines
include/linux/mfd/tps65912.h new file +23
-0+struct regmap *regmap; +}; + +static const struct regmap_range tps65912_yes_ranges[] = { +regmap_reg_range (TPS65912_INT_STS ,TPS65912_GPIO5 ), +}; + +static const struct regmap_access_table tps65912_volatile_table = { + .yes_ranges = tps65912_yes_ranges, + .n_yes_ranges =ARRAY_SIZE (tps65912_yes_ranges), +}; + +static const struct regmap_config tps65912_regmap_co nfig = { + .reg_bits =8 , + .val_bits =8 , + .cache_type =REGCACHE_RBTREE , + .volatile_table = &tps65912_volatile_table, +}; + +int tps65912_device_init (struct tps65912 *tps); +int tps65912_device_exit (struct tps65912 *tps); + +#endif /* __LINUX_MFD_TPS65912_H */
PATCH v3 4/5 regulators: tps65912: Add regulator driver for the TPS65912 PMIC
In reply to Andrew F. DavisThis patch adds support for TPS65912 PMIC regulators.
The regulators set consists of 4 DCDCs and 10 LDOs. The output voltages are configurable and are meant to supply power to the main processor and other components.
--- drivers/regulator/Kconfig | 6 + drivers/regulator/Makefile | 1 + drivers/regulator/tps65912-regulator.c | 240 +++++++++++++++++++++++++++++++++ 3 files changed, 247 insertions(+) create mode 100644 drivers/regulator/tps65912-regulator.c
drivers/regulator/Kconfig +6 -0
@@ -727,6 +727,12 @@ config REGULATOR_TPS65910 help This driver supports TPS65910/TPS65911 voltage regulator chips. +config REGULATOR_TPS65912 + tristate "TI TPS65912 Power regulator" + depends on MFD_TPS65912 + help + This driver supports TPS65912 voltage regulator chip. + config REGULATOR_TPS80031 tristate "TI TPS80031/TPS80032 power regualtor driver" depends on MFD_TPS80031
drivers/regulator/Makefile +1 -0
@@ -91,6 +91,7 @@ obj-$(CONFIG_REGULATOR_TPS65218) += tps65218-regulator.o obj-$(CONFIG_REGULATOR_TPS6524X) += tps6524x-regulator.o obj-$(CONFIG_REGULATOR_TPS6586X) += tps6586x-regulator.o obj-$(CONFIG_REGULATOR_TPS65910) += tps65910-regulator.o +obj-$(CONFIG_REGULATOR_TPS65912) += tps65912-regulator.o obj-$(CONFIG_REGULATOR_TPS80031) += tps80031-regulator.o obj-$(CONFIG_REGULATOR_TWL4030) += twl-regulator.o obj-$(CONFIG_REGULATOR_VEXPRESS) += vexpress.o
drivers/regulator/tps65912-regulator.c new file +240 -0
240 lines not on this page · raw message
Signature · 1 line
1.9.1
Mark Brown
maintainerRe: [PATCH v3 4/5] regulators: tps65912: Add regulator driver for the TPS65912 PMIC
Quoted 8 lines · Andrew F. Davis
drivers/regulator/tps65912-regulator.c new file +8
-0+static int tps65912_regulator_probe (struct platform_device *pdev) +{ +struct tps65912 *tps =dev_get_drvdata (pdev->dev.parent); +struct regulator_init_data *init_data; +const struct tps_info *template; +struct regulator_dev *rdev; +const struct of_device_id *match; +struct regulator_config config = { };
drivers/regulator/tps65912-regulator.c line 206
Quoted 10 lines
drivers/regulator/tps65912-regulator.c new file +10
-0+int id; + + match =of_match_device (tps65912_regulator_of_match_table, &pdev->dev); +if (!match) +return -ENODEV ; + + template = match->data; + id = template->id; + init_data =of_get_regulator_init_data (&pdev->dev, pdev->dev.of_node, + ®ulators[id]);
Don't open code this stuff, use the core DT matching in the regulator_desc instead.
Please also use subject lines mathcing the style for the subsystem.
Re: [PATCH v3 4/5] regulators: tps65912: Add regulator driver for the TPS65912 PMIC
Quoted 15 lines · Mark Brown
Quoted 13 lines · Andrew F. Davis
drivers/regulator/tps65912-regulator.c new file +13
-0+static int tps65912_regulator_probe (struct platform_device *pdev) +{ +struct tps65912 *tps =dev_get_drvdata (pdev->dev.parent); +struct regulator_init_data *init_data; +const struct tps_info *template; +struct regulator_dev *rdev; +const struct of_device_id *match; +struct regulator_config config = { }; +int id; + + match =of_match_device (tps65912_regulator_of_match_table, &pdev->dev); +if (!match) +return -ENODEV ;
Quoted 9 lines
drivers/regulator/tps65912-regulator.c line 206
Quoted 5 lines
drivers/regulator/tps65912-regulator.c new file +5
-0+ + template = match->data; + id = template->id; + init_data =of_get_regulator_init_data (&pdev->dev, pdev->dev.of_node, + ®ulators[id]);Don't open code this stuff, use the core DT matching in the
regulator_descinstead.
I assume you are referring to your additions in a0c7b164ad11? If so I'm not sure that will save me anything as my probe function is called with a DT match already, so no searching is needed.
Quoted 2 lines
Please also use subject lines mathcing the style for the subsystem.
I'm not sure I know what you mean? What is wrong with my subject line, it looks like the others I've looked at?
Mark Brown
maintainerRe: [PATCH v3 4/5] regulators: tps65912: Add regulator driver for the TPS65912 PMIC
Quoted 15 lines · Andrew F. Davis
Quoted 6 lines · Mark Brown
Quoted 3 lines · Andrew F. Davis
drivers/regulator/tps65912-regulator.c new file +3
-0+ match =of_match_device (tps65912_regulator_of_match_table, &pdev->dev); +if (!match) +return -ENODEV ;Quoted 7 lines
drivers/regulator/tps65912-regulator.c line 206
Quoted 4 lines
drivers/regulator/tps65912-regulator.c new file +4
-0+ template = match->data; + id = template->id; + init_data =of_get_regulator_init_data (&pdev->dev, pdev->dev.of_node, + ®ulators[id]);Don't open code this stuff, use the core DT matching in the
regulator_descinstead.
Quoted 1 line
I assume you are referring to your additions in
a0c7b164ad11? If so I'm not
Please don't refer to commits by ID only, include a human readable description of the commit for the benefit of any humans who might read your mail.
Quoted 2 lines
sure that will save me anything as my probe function is called with a DT match already, so no searching is needed.
You've not understood what that change is replacing, the code I'm quoting above is exactly that code. Check out some of the existing drivers using this API.
Quoted 4 lines
Quoted 1 line
Please also use subject lines mathcing the style for the subsystem.
I'm not sure I know what you mean? What is wrong with my subject line, it looks like the others I've looked at?
You are using "regulators:", the regulator API uses "regulator:" - this should be really clear if you do something like a git shortlog.
Re: [PATCH v3 4/5] regulators: tps65912: Add regulator driver for the TPS65912 PMIC
Quoted 16 lines · Mark Brown
Quoted 14 lines · Andrew F. Davis
Quoted 13 lines · Mark Brown
drivers/regulator/tps65912-regulator.c line 206
Quoted 8 lines · Andrew F. Davis
drivers/regulator/tps65912-regulator.c new file +7
-0+ match =of_match_device (tps65912_regulator_of_match_table, &pdev->dev); +if (!match) +return -ENODEV ; + template = match->data; + id = template->id; + init_data =of_get_regulator_init_data (&pdev->dev, pdev->dev.of_node, + ®ulators[id]);Don't open code this stuff, use the core DT matching in the
regulator_descinstead.
Quoted 6 lines
Quoted 1 line
I assume you are referring to your additions in
a0c7b164ad11? If so I'm notPlease don't refer to commits by ID only, include a human readable description of the commit for the benefit of any humans who might read your mail.
Forgot about those pesky humans :), OK, will do from now on.
Quoted 7 lines
Quoted 2 lines
sure that will save me anything as my probe function is called with a DT match already, so no searching is needed.
You've not understood what that change is replacing, the code I'm quoting above is exactly that code. Check out some of the existing drivers using this API.
Looking at other drivers that use this API they all call regulator_register in a loop in their probe, once for each possible regulator, in this case letting the API do the DT node search makes sense. My probe on the other-hand is only called when we already have a DT match, therefor searching is not necessary and all I have to do is call of_get_regulator_init_data myself on the already found DT node. No need to add node names to my regulator_desc and make the API re-search for the node.
I have further cleaned up this code to show this.
If this is acceptable, I'll push the re-spin so you can review further.
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
Please also use subject lines mathcing the style for the subsystem.
I'm not sure I know what you mean? What is wrong with my subject line, it looks like the others I've looked at?
You are using "regulators:", the regulator API uses "regulator:" - this should be really clear if you do something like a git shortlog.
Ah, slipped right past me, thanks for clarifying, fixed.
Mark Brown
maintainerRe: [PATCH v3 4/5] regulators: tps65912: Add regulator driver for the TPS65912 PMIC
Quoted 9 lines · Andrew F. Davis
Quoted 6 lines · Mark Brown
Quoted 2 lines
sure that will save me anything as my probe function is called with a DT match already, so no searching is needed.
You've not understood what that change is replacing, the code I'm quoting above is exactly that code. Check out some of the existing drivers using this API.
Quoted 7 lines
Looking at other drivers that use this API they all call
regulator_registerin a loop in their probe, once for each possible regulator, in this case letting the API do the DT node search makes sense. My probe on the other-hand is only called when we already have a DT match, therefor searching is not necessary and all I have to do is callof_get_regulator_init_datamyself on the already found DT node. No need to add node names to myregulator_descand make the API re-search for the node.
Oh, ick. The binding has a compatible string in the individual regulator bindings which is broken unless there really are lots of variants being configured via DT (which is just not the case here). It's not only more typing in the DT, it also means that we can't read back the configuration of the device unless the user goes and creates a DT which explicitly lists each regulator on the device which is unhelpful. We should be able to read back the configurations of all the regulators by simply listing the device in DT.
The fact that this is different to the bindings for other regulator drivers and requires more code ought to have been a big warning sign here :(
Re: [PATCH v3 4/5] regulators: tps65912: Add regulator driver for the TPS65912 PMIC
Quoted 18 lines · Mark Brown
Quoted 9 lines · Andrew F. Davis
Quoted 6 lines · Mark Brown
Quoted 2 lines
sure that will save me anything as my probe function is called with a DT match already, so no searching is needed.
You've not understood what that change is replacing, the code I'm quoting above is exactly that code. Check out some of the existing drivers using this API.
Quoted 7 lines
Looking at other drivers that use this API they all call
regulator_registerin a loop in their probe, once for each possible regulator, in this case letting the API do the DT node search makes sense. My probe on the other-hand is only called when we already have a DT match, therefor searching is not necessary and all I have to do is callof_get_regulator_init_datamyself on the already found DT node. No need to add node names to myregulator_descand make the API re-search for the node.
Quoted 4 lines
Oh, ick. The binding has a compatible string in the individual regulator bindings which is broken unless there really are lots of variants being configured via DT (which is just not the case here). It's not only more typing in the DT,
I don't see this, the alternative is matching to this "regulator-compatible", why not just use the existing compatible.
Quoted 6 lines
it also means that we can't read
back the configuration of the device unless the user goes and creates a DT which explicitly lists each regulator on the device which is unhelpful. We should be able to read back the configurations of all the regulators by simply listing the device in DT.
Could you expand this? I'm not sure I understand why we still cant do this using this new way.
Bindings should have compatible strings when they describe hardware like this, we can then do stuff like put the LDO and DCDC drivers in separate modules for instance, letting DT only load what we need. There are other benefits like not having to search our own DT binding for data, and we only get probed for devices in the DT.
This also eliminates the need for MFD_CORE, we just call of_platform_populate on ourself and DT helpers do the rest. Why hard code mfd_cell's and do matching when DT does the same thing.
Quoted 4 lines
The fact that this is different to the bindings for other regulator drivers and requires more code ought to have been a big warning sign here :(
The binding is the same as the new tps65218 driver, different isn't always a warning sign. And what do you mean "requires more code"? This regulator driver is smaller than almost any other. DT takes care of everything for us relating to hardware instantiation like it should.
Mark Brown
maintainerRe: [PATCH v3 4/5] regulators: tps65912: Add regulator driver for the TPS65912 PMIC
Quoted 9 lines · Andrew F. Davis
Quoted 4 lines · Mark Brown
Oh, ick. The binding has a compatible string in the individual regulator bindings which is broken unless there really are lots of variants being configured via DT (which is just not the case here). It's not only more typing in the DT,
I don't see this, the alternative is matching to this "regulator-compatible", why not just use the existing compatible.
No, you don't need to use regulator-compatible - that's deprecated. Just use the node names.
Quoted 8 lines
Quoted 5 lines
it also means that we can't read
back the configuration of the device unless the user goes and creates a DT which explicitly lists each regulator on the device which is unhelpful. We should be able to read back the configurations of all the regulators by simply listing the device in DT.Could you expand this? I'm not sure I understand why we still cant do this using this new way.
I'm not sure what there is to add... if the regulator is only instantiated when it features in the device tree then obviously it must be included in the device to be instantiated.
Quoted 5 lines
Bindings should have compatible strings when they describe hardware like this, we can then do stuff like put the LDO and DCDC drivers in separate modules for instance, letting DT only load what we need. There are other benefits like not having to search our own DT binding for data, and we only get probed for devices in the DT.
Only getting probed for device is in DT is exactly the problem here, and nothing prevents us having separate modules for things without enumerating everything in DT.
Quoted 3 lines
This also eliminates the need for
MFD_CORE, we just callof_platform_populateon ourself and DT helpers do the rest. Why hard code mfd_cell's and do matching when DT does the same thing.
Putting everything in DT means more work for people integrating the device and means that we have to have a full and complete understanding of the device at the time we write the DT, including decions about how we split the functionality of the device between subsystems.
Quoted 8 lines
Quoted 3 lines
The fact that this is different to the bindings for other regulator drivers and requires more code ought to have been a big warning sign here :(
The binding is the same as the new tps65218 driver, different isn't always a warning sign. And what do you mean "requires more code"? This regulator driver is smaller than almost any other. DT takes care of everything for us relating to hardware instantiation like it should.
That's not a new driver, it's from more than a year ago (before or about the same time the helpers got added IIRC).
Re: [PATCH v3 4/5] regulators: tps65912: Add regulator driver for the TPS65912 PMIC
Quoted 8 lines · Mark Brown
Quoted 6 lines · Andrew F. Davis
Quoted 4 lines · Mark Brown
Oh, ick. The binding has a compatible string in the individual regulator bindings which is broken unless there really are lots of variants being configured via DT (which is just not the case here). It's not only more typing in the DT,
Quoted 6 lines
Quoted 2 lines
I don't see this, the alternative is matching to this "regulator-compatible", why not just use the existing compatible.
No, you don't need to use regulator-compatible - that's deprecated. Just use the node names.
Are we sure matching on node names is a good idea? Most are just arbitrary names meant to be human readable and reference-able, giving them function may lead to confusion. This seems to be why we have "compatible", for specific identification of node function. But I'm new so maybe I'm wrong?
Quoted 6 lines
Quoted 5 lines
Quoted 5 lines
it also means that we can't read
back the configuration of the device unless the user goes and creates a DT which explicitly lists each regulator on the device which is unhelpful. We should be able to read back the configurations of all the regulators by simply listing the device in DT.
Quoted 7 lines
Quoted 2 lines
Could you expand this? I'm not sure I understand why we still cant do this using this new way.
I'm not sure what there is to add... if the regulator is only instantiated when it features in the device tree then obviously it must be included in the device to be instantiated.
This is already the case then, missing regulator nodes in old drivers will not get instantiated ether. And old drivers don't always store any more info about available regulators than mine does.
Quoted 10 lines
Quoted 5 lines
Bindings should have compatible strings when they describe hardware like this, we can then do stuff like put the LDO and DCDC drivers in separate modules for instance, letting DT only load what we need. There are other benefits like not having to search our own DT binding for data, and we only get probed for devices in the DT.
Only getting probed for device is in DT is exactly the problem here, and nothing prevents us having separate modules for things without enumerating everything in DT.
Sure, but then we have to do some fiddling with MFD_CORE to do that work, why not remove the dependency and let DT do that for DT only drivers?
Quoted 9 lines
Quoted 3 lines
This also eliminates the need for
MFD_CORE, we just callof_platform_populateon ourself and DT helpers do the rest. Why hard code mfd_cell's and do matching when DT does the same thing.Putting everything in DT means more work for people integrating the device and means that we have to have a full and complete understanding of the device at the time we write the DT, including decions about how we split the functionality of the device between subsystems.
We are not adding anything extra to the DT node, we just use the "compatible" string to identify and match the node vs. "regulator-name", or the nodes name, or whatever else has been used. The node is then just filled with the standard optional properties just like every other driver's node.
Quoted 4 lines
Quoted 3 lines
Quoted 3 lines
The fact that this is different to the bindings for other regulator drivers and requires more code ought to have been a big warning sign here :(
Quoted 8 lines
Quoted 4 lines
The binding is the same as the new tps65218 driver, different isn't always a warning sign. And what do you mean "requires more code"? This regulator driver is smaller than almost any other. DT takes care of everything for us relating to hardware instantiation like it should.
That's not a new driver, it's from more than a year ago (before or about the same time the helpers got added IIRC).
Newer than a lot, I chose to base my driver off of that not just because it is a similar TI part, but because it was the cleanest, simplest looking one IMHO. The helpers would require more code (you need to know how many regulators you have and call the helpers in a loop).
I have another PMIC I'm about to push a driver for when this gets figured out that does the same thing, and it's more important I think to do it this way for this new part. Some of the new regulators are designed without a dedicated SOC or board to power in mind, so they will have a whole bunch for different regulator types on one chip and it will be up to the designer to pick which ones to turn on and use. With this DT approach you can just list the ones you want, and we may even be able to split different types into different modules, then we can use the same regulator driver in different spins of the PMIC with more or less of that type of regulator, we just add that same node under a different parent PMIC driver.
I could use the helper with this style and save a couple lines of code if we could make regulator_of_get_init_data to also match on "compatible", it currently only matches on "regulator-compatible" or the node name. I could make this addition and send the patch if you would like to see what I have in mind.
Mark Brown
maintainerRe: [PATCH v3 4/5] regulators: tps65912: Add regulator driver for the TPS65912 PMIC
Quoted 9 lines · Andrew F. Davis
Quoted 2 lines · Mark Brown
No, you don't need to use regulator-compatible - that's deprecated. Just use the node names.
Are we sure matching on node names is a good idea? Most are just arbitrary names meant to be human readable and reference-able, giving them function may lead to confusion. This seems to be why we have "compatible", for specific identification of node function. But I'm new so maybe I'm wrong?
Yes, I'm sure. The regulators are just properties on the device, they are not devices themselves.
Quoted 7 lines
Quoted 3 lines
I'm not sure what there is to add... if the regulator is only instantiated when it features in the device tree then obviously it must be included in the device to be instantiated.
This is already the case then, missing regulator nodes in old drivers will not get instantiated ether. And old drivers don't always store any more info about available regulators than mine does.
No, well implemented older drivers will still unconditionally register everything.
Quoted 6 lines
Quoted 3 lines
Only getting probed for device is in DT is exactly the problem here, and nothing prevents us having separate modules for things without enumerating everything in DT.
Sure, but then we have to do some fiddling with
MFD_COREto do that work, why not remove the dependency and let DT do that for DT only drivers?
For the reasons I've outlined repeatedly.
Quoted 9 lines
Quoted 4 lines
Putting everything in DT means more work for people integrating the device and means that we have to have a full and complete understanding of the device at the time we write the DT, including decions about how we split the functionality of the device between subsystems.
We are not adding anything extra to the DT node, we just use the "compatible" string to identify and match the node vs. "regulator-name", or the nodes name, or whatever else has been used. The node is then just filled with the standard optional properties just like every other driver's node.
No, you are missing the point. The point is that only regulators explicitly listed in the DT will be instantiated.
Quoted 4 lines
Newer than a lot, I chose to base my driver off of that not just because it is a similar TI part, but because it was the cleanest, simplest looking one IMHO. The helpers would require more code (you need to know how many regulators you have and call the helpers in a loop).
You're talking about a trivial loop that takes perhaps a couple of lines to open and close the for loop and another line to declare an iterator variable.
Look, please stop arguing about this. There appears to be nothing special about this device that makes it different to other devices.
Quoted 10 lines
I have another PMIC I'm about to push a driver for when this gets figured out that does the same thing, and it's more important I think to do it this way for this new part. Some of the new regulators are designed without a dedicated SOC or board to power in mind, so they will have a whole bunch for different regulator types on one chip and it will be up to the designer to pick which ones to turn on and use. With this DT approach you can just list the ones you want, and we may even be able to split different types into different modules, then we can use the same regulator driver in different spins of the PMIC with more or less of that type of regulator, we just add that same node under a different parent PMIC driver.
This sounds exactly the same as the majority of PMIC drivers, there is nothing remarkable here.
Quoted 4 lines
I could use the helper with this style and save a couple lines of code if we could make
regulator_of_get_init_datato also match on "compatible", it currently only matches on "regulator-compatible" or the node name. I could make this addition and send the patch if you would like to see what I have in mind.
No, this would be broken - devices are instantiated via the driver model.
Re: [PATCH v3 4/5] regulators: tps65912: Add regulator driver for the TPS65912 PMIC
Quoted 6 lines · Mark Brown
Quoted 4 lines · Andrew F. Davis
Quoted 2 lines · Mark Brown
No, you don't need to use regulator-compatible - that's deprecated. Just use the node names.
Quoted 8 lines
Quoted 4 lines
Are we sure matching on node names is a good idea? Most are just arbitrary names meant to be human readable and reference-able, giving them function may lead to confusion. This seems to be why we have "compatible", for specific identification of node function. But I'm new so maybe I'm wrong?
Yes, I'm sure. The regulators are just properties on the device, they are not devices themselves.
OK
Quoted 11 lines
Quoted 7 lines
Quoted 3 lines
I'm not sure what there is to add... if the regulator is only instantiated when it features in the device tree then obviously it must be included in the device to be instantiated.
This is already the case then, missing regulator nodes in old drivers will not get instantiated ether. And old drivers don't always store any more info about available regulators than mine does.
No, well implemented older drivers will still unconditionally register everything.
Is this desired? If they are not in the DT could this be used to signal we don't want to register this regulator?
Quoted 14 lines
Quoted 6 lines
Quoted 3 lines
Only getting probed for device is in DT is exactly the problem here, and nothing prevents us having separate modules for things without enumerating everything in DT.
Sure, but then we have to do some fiddling with
MFD_COREto do that work, why not remove the dependency and let DT do that for DT only drivers?For the reasons I've outlined repeatedly.
Quoted 4 lines
Quoted 4 lines
Putting everything in DT means more work for people integrating the device and means that we have to have a full and complete understanding of the device at the time we write the DT, including decions about how we split the functionality of the device between subsystems.
Quoted 8 lines
Quoted 4 lines
We are not adding anything extra to the DT node, we just use the "compatible" string to identify and match the node vs. "regulator-name", or the nodes name, or whatever else has been used. The node is then just filled with the standard optional properties just like every other driver's node.
No, you are missing the point. The point is that only regulators explicitly listed in the DT will be instantiated.
Same questions as above. ^^^
Quoted 9 lines
Quoted 4 lines
Newer than a lot, I chose to base my driver off of that not just because it is a similar TI part, but because it was the cleanest, simplest looking one IMHO. The helpers would require more code (you need to know how many regulators you have and call the helpers in a loop).
You're talking about a trivial loop that takes perhaps a couple of lines to open and close the for loop and another line to declare an iterator variable.
Adding any extra code and complexity to use a helper that does something that already works with less doesn't make much sense to me, but if that's the API you want I'll use it.
Quoted 3 lines
Look, please stop arguing about this. There appears to be nothing special about this device that makes it different to other devices.
I'm sorry if I sounded overly argumentative about this, I'm just trying to make points in favor of me not having to re-write my driver.
The new framework helpers do not help my driver as it does things differently. You signed off on this different way of doing things just last year with the TPS65218.
If you no longer want it done this way then I'll go and change my driver.
Quoted 11 lines
Quoted 10 lines
I have another PMIC I'm about to push a driver for when this gets figured out that does the same thing, and it's more important I think to do it this way for this new part. Some of the new regulators are designed without a dedicated SOC or board to power in mind, so they will have a whole bunch for different regulator types on one chip and it will be up to the designer to pick which ones to turn on and use. With this DT approach you can just list the ones you want, and we may even be able to split different types into different modules, then we can use the same regulator driver in different spins of the PMIC with more or less of that type of regulator, we just add that same node under a different parent PMIC driver.
Quoted 3 lines
This sounds exactly the same as the majority of PMIC drivers, there is nothing remarkable here.
Nothing meant to be remarkable, I was pointing out uses.
Quoted 8 lines
Quoted 4 lines
I could use the helper with this style and save a couple lines of code if we could make
regulator_of_get_init_datato also match on "compatible", it currently only matches on "regulator-compatible" or the node name. I could make this addition and send the patch if you would like to see what I have in mind.No, this would be broken - devices are instantiated via the driver model.
OK
Mark Brown
maintainerRe: [PATCH v3 4/5] regulators: tps65912: Add regulator driver for the TPS65912 PMIC
Quoted 11 lines · Andrew F. Davis
Quoted 6 lines · Mark Brown
Quoted 3 lines
This is already the case then, missing regulator nodes in old drivers will not get instantiated ether. And old drivers don't always store any more info about available regulators than mine does.
No, well implemented older drivers will still unconditionally register everything.
Is this desired? If they are not in the DT could this be used to signal we don't want to register this regulator?
Yes, this is desired. The point is that there is no situation in which we do not want to register all the regulators physically present on the device.
Quoted 7 lines
Quoted 3 lines
You're talking about a trivial loop that takes perhaps a couple of lines to open and close the for loop and another line to declare an iterator variable.
Adding any extra code and complexity to use a helper that does something that already works with less doesn't make much sense to me, but if that's the API you want I'll use it.
It would take a lot less effort to implement the requested changes rather than go on and on about this. There is no meaningful complexity here, we're talking about removing code and moving some data tables from DT (where they are an ABI) to code (where they are not an ABI).
Quoted 5 lines
Quoted 2 lines
Look, please stop arguing about this. There appears to be nothing special about this device that makes it different to other devices.
I'm sorry if I sounded overly argumentative about this, I'm just trying to make points in favor of me not having to re-write my driver.
It's hardly a rewrite.
Quoted 5 lines
The new framework helpers do not help my driver as it does things differently. You signed off on this different way of doing things just last year with the TPS65218.
If you no longer want it done this way then I'll go and change my driver.
It should already be apparent that this is not a desired configuration, old drivers are never a good reason not to do the right thing on new code.
Re: [PATCH v3 4/5] regulators: tps65912: Add regulator driver for the TPS65912 PMIC
In reply to Andrew F. DavisHi Andrew,
Quoted 112 lines · Andrew F. Davis
Quoted 8 lines · Mark Brown
Quoted 6 lines · Andrew F. Davis
Quoted 4 lines · Mark Brown
Oh, ick. The binding has a compatible string in the individual regulator bindings which is broken unless there really are lots of variants being configured via DT (which is just not the case here). It's not only more typing in the DT,
Quoted 7 lines
Quoted 3 lines
I don't see this, the alternative is matching to this "regulator-compatible",
why not just use the existing compatible.No, you don't need to use regulator-compatible - that's deprecated. Just use the node names.
Are we sure matching on node names is a good idea? Most are just arbitrary names meant to be human readable and reference-able, giving them function may lead to confusion. This seems to be why we have "compatible", for specific
identification of node function. But I'm new so maybe I'm wrong?Quoted 7 lines
Quoted 6 lines
Quoted 6 lines
it also means that we can't read
back the configuration of the device unless the user goes and creates a DT which explicitly lists each regulator on the device which is unhelpful. We should be able to read back the configurations of all the
regulators by simply listing the device in DT.Quoted 8 lines
Quoted 3 lines
Could you expand this? I'm not sure I understand why we still cant do this
using this new way.I'm not sure what there is to add... if the regulator is only instantiated when it features in the device tree then obviously it must be included in the device to be instantiated.
This is already the case then, missing regulator nodes in old drivers will not
get instantiated ether. And old drivers don't always store any more info about
available regulators than mine does.Quoted 10 lines
Quoted 9 lines
Bindings should have compatible strings when they describe hardware like this,
we can then do stuff like put the LDO and DCDC drivers in separate modules for
instance, letting DT only load what we need. There are other benefits like
not having to search our own DT binding for data, and we only get probed for
devices in the DT.Quoted 4 lines
Only getting probed for device is in DT is exactly the problem here, and nothing prevents us having separate modules for things without enumerating everything in DT.
Sure, but then we have to do some fiddling with
MFD_COREto do that work, why not remove the dependency and let DT do that for DT only drivers?Quoted 10 lines
Quoted 4 lines
This also eliminates the need for
MFD_CORE, we just callof_platform_populateon ourself and DT helpers do the rest. Why hard code
mfd_cell's and do matching when DT does the same thing.Putting everything in DT means more work for people integrating the device and means that we have to have a full and complete understanding of the device at the time we write the DT, including decions about how we split the functionality of the device between subsystems.
We are not adding anything extra to the DT node, we just use the "compatible"
string to identify and match the node vs. "regulator-name", or the nodes name,
or whatever else has been used. The node is then just filled with the standard
optional properties just like every other driver's node.Quoted 11 lines
Quoted 10 lines
Quoted 3 lines
The fact that this is different to the bindings for other regulator drivers and requires more code ought to have been a big warning sign here :(
The binding is the same as the new tps65218 driver, different isn't always
a warning sign. And what do you mean "requires more code"? This regulator
driver is smaller than almost any other. DT takes care of everything for us relating to hardware instantiation like it should.Quoted 3 lines
That's not a new driver, it's from more than a year ago (before or about the same time the helpers got added IIRC).
Newer than a lot, I chose to base my driver off of that not just because it is a similar TI part, but because it was the cleanest, simplest looking one IMHO. The helpers would require more code (you need to know how many regulators you have and call the helpers in a loop).
I have another PMIC I'm about to push a driver for when this gets figured out
that does the same thing, and it's more important I think to do it this way for
this new part. Some of the new regulators are designed without a dedicated SOC or board to power in mind, so they will have a whole bunch for different
regulator types on one chip and it will be up to the designer to pick which ones
to turn on and use. With this DT approach you can just list the ones you
Quoted 9 lines
want,
and we may even be able to split different types into different modules, then
we can use the same regulator driver in different spins of the PMIC with more
or less of that type of regulator, we just add that same node under a different
parent PMIC driver.
That's all make sense only if you have all information required for driver probing in DT. But you don't, because a lot of information are still hard-coded in driver:
- regulator IDs,
- registers required to control regulator
- ranges information and etc.
So, you will not be be able to easily separate some regulator and reuse it with another PMIC.
Actually, both approaches have right to live and which one to select depends on functionality which has to be implemented by regulator driver.
For example, with this (your) approach the separate platform device will be created for each regulator, so, if needed, corresponding driver's callback (.remove/shutdown and dev_pm_ops) can be implemented individually for each regulator. Do you need this? As for me, such approach is reasonable if you have devices which represents one/two regulators max.
The disadvantage of this approach is that you need separate compatible string fore each regulator
- and this, actually, is usually banned by DT maintainers ;)
For devices, like this one (or twl, or plamas) which has dozens of regulators it simply make no sense :) Just imaging that tomorrow tps65912-1 will be released and it will be fully compatible with tps65912, but with one exception - it will have dcdc5 and all followed registers offsets will be shifted. What will you do? All this code, based on compatible strings, will not work any more.
And you will need to introduce another bunch of compatible strings..
By the way, this implementation is not optimal any way :)
- you are using compatible string to get tps65912_pmic_regs structure
- then tps65912_pmic_regs is used to get regulator ID
- and then, finally, regulator ID is used to get regulator_desc structure
And, finally, pay attention pls, that regulator_of_get_init_data() is called from from regulator_register().
So, in my opinion, the tps65217-regulator.c driver is really good example of how it could be done.
Signature · 2 lines
regards, -grygorii
Re: [PATCH v3 4/5] regulators: tps65912: Add regulator driver for the TPS65912 PMIC
Quoted 125 lines · Grygorii Strashko
Hi Andrew,
Quoted 112 lines · Andrew F. Davis
Quoted 8 lines · Mark Brown
Quoted 6 lines · Andrew F. Davis
Quoted 4 lines · Mark Brown
Oh, ick. The binding has a compatible string in the individual regulator bindings which is broken unless there really are lots of variants being configured via DT (which is just not the case here). It's not only more typing in the DT,
Quoted 7 lines
Quoted 3 lines
I don't see this, the alternative is matching to this "regulator-compatible",
why not just use the existing compatible.No, you don't need to use regulator-compatible - that's deprecated. Just use the node names.
Are we sure matching on node names is a good idea? Most are just arbitrary names meant to be human readable and reference-able, giving them function may lead to confusion. This seems to be why we have "compatible", for specific
identification of node function. But I'm new so maybe I'm wrong?Quoted 7 lines
Quoted 6 lines
Quoted 6 lines
it also means that we can't read
back the configuration of the device unless the user goes and creates a DT which explicitly lists each regulator on the device which is unhelpful. We should be able to read back the configurations of all the
regulators by simply listing the device in DT.Quoted 8 lines
Quoted 3 lines
Could you expand this? I'm not sure I understand why we still cant do this
using this new way.I'm not sure what there is to add... if the regulator is only instantiated when it features in the device tree then obviously it must be included in the device to be instantiated.
This is already the case then, missing regulator nodes in old drivers will not
get instantiated ether. And old drivers don't always store any more info about
available regulators than mine does.Quoted 10 lines
Quoted 9 lines
Bindings should have compatible strings when they describe hardware like this,
we can then do stuff like put the LDO and DCDC drivers in separate modules for
instance, letting DT only load what we need. There are other benefits like
not having to search our own DT binding for data, and we only get probed for
devices in the DT.Quoted 4 lines
Only getting probed for device is in DT is exactly the problem here, and nothing prevents us having separate modules for things without enumerating everything in DT.
Sure, but then we have to do some fiddling with
MFD_COREto do that work, why not remove the dependency and let DT do that for DT only drivers?Quoted 10 lines
Quoted 4 lines
This also eliminates the need for
MFD_CORE, we just callof_platform_populateon ourself and DT helpers do the rest. Why hard code
mfd_cell's and do matching when DT does the same thing.Putting everything in DT means more work for people integrating the device and means that we have to have a full and complete understanding of the device at the time we write the DT, including decions about how we split the functionality of the device between subsystems.
We are not adding anything extra to the DT node, we just use the "compatible"
string to identify and match the node vs. "regulator-name", or the nodes name,
or whatever else has been used. The node is then just filled with the standard
optional properties just like every other driver's node.Quoted 11 lines
Quoted 10 lines
Quoted 3 lines
The fact that this is different to the bindings for other regulator drivers and requires more code ought to have been a big warning sign here :(
The binding is the same as the new tps65218 driver, different isn't always
a warning sign. And what do you mean "requires more code"? This regulator
driver is smaller than almost any other. DT takes care of everything for us relating to hardware instantiation like it should.Quoted 3 lines
That's not a new driver, it's from more than a year ago (before or about the same time the helpers got added IIRC).
Newer than a lot, I chose to base my driver off of that not just because it is a similar TI part, but because it was the cleanest, simplest looking one IMHO. The helpers would require more code (you need to know how many regulators you have and call the helpers in a loop).
I have another PMIC I'm about to push a driver for when this gets figured out
that does the same thing, and it's more important I think to do it this way for
this new part. Some of the new regulators are designed without a dedicated SOC or board to power in mind, so they will have a whole bunch for different
regulator types on one chip and it will be up to the designer to pick which ones
to turn on and use. With this DT approach you can just list the ones youQuoted 9 lines
want,
and we may even be able to split different types into different modules, then
we can use the same regulator driver in different spins of the PMIC with more
or less of that type of regulator, we just add that same node under a different
parent PMIC driver.
Quoted 8 lines
That's all make sense only if you have all information required for driver probing in DT. But you don't, because a lot of information are still hard-coded in driver:
- regulator IDs,
- registers required to control regulator
- ranges information and etc.So, you will not be be able to easily separate some regulator and reuse it with another PMIC.
Unless we encode the needed registers/info into the DT, that info could be considered a device description if you consider each regulator to be a separate device burned onto the same silicon, much like we do with the different IPs on SOCs. It would be nice to have 100% generic regulator drivers, but the DT maintainers might not go for that :)
Quoted 7 lines
Actually, both approaches have right to live and which one to select depends on functionality which has to be implemented by regulator driver.
For example, with this (your) approach the separate platform device will be created for each regulator, so, if needed, corresponding driver's callback (.remove/shutdown anddev_pm_ops) can be implemented individually for each regulator. Do you need this? As for me, such approach is reasonable if you have devices which represents one/two regulators max.
Quoted 9 lines
The disadvantage of this approach is that you need separate compatible string fore each regulator
- and this, actually, is usually banned by DT maintainers ;)For devices, like this one (or twl, or plamas) which has dozens of regulators it simply make no sense :) Just imaging that tomorrow tps65912-1 will be released and it will be fully compatible with tps65912, but with one exception - it will have dcdc5 and all followed registers offsets will be shifted. What will you do? All this code, based on compatible strings, will not work any more.
And you will need to introduce another bunch of compatible strings..
Agree, unless we go with my above idea! :)
Quoted 5 lines
By the way, this implementation is not optimal any way :)
- you are using compatible string to gettps65912_pmic_regsstructure
- thentps65912_pmic_regsis used to get regulator ID
- and then, finally, regulator ID is used to getregulator_descstructure
Yeah, I saw that after I posted this, my new version just puts a pointer to the right regulator_desc struct in the of_device_id.data, then we can use it directly with no middle man steps, much cleaner.
Quoted 3 lines
And, finally, pay attention pls, that
regulator_of_get_init_data()is called from fromregulator_register().
Right, but only if you supply .of_match in your regulator_desc, and even then it only matches on node name, not "compatible" string, if it did I could use it to eliminate my call to of_get_regulator_init_data, the whole probe function would become about 10 lines of code :)
Quoted 3 lines
So, in my opinion, the
tps65217-regulator.cdriver is really good example of how it could be done.
Thanks, I was looking for good examples, that and rt5033 seem to be the requested style for new regulator drivers.
Signature · 1 line
Andrew F. Davis
Mark Brown
maintainerRe: [PATCH v3 4/5] regulators: tps65912: Add regulator driver for the TPS65912 PMIC
In reply to Grygorii StrashkoQuoted 2 lines · Grygorii Strashko
So, in my opinion, the
tps65217-regulator.cdriver is really good example of how it could be done.
Yes, this should be a good example to refer to.
PATCH v3 5/5 gpio: tps65912: Add GPIO driver for the TPS65912 PMIC
In reply to Andrew F. DavisThis patch adds support for the TPS65912 PMIC GPIOs.
TPS65912 has five configurable GPIOs that can be used for several purposes.
--- drivers/gpio/Kconfig | 6 ++ drivers/gpio/Makefile | 1 + drivers/gpio/gpio-tps65912.c | 138 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 145 insertions(+) create mode 100644 drivers/gpio/gpio-tps65912.c
drivers/gpio/Kconfig +6 -0
@@ -838,6 +838,12 @@ config GPIO_TPS65910 Select this option to enable GPIO driver for the TPS65910 chip family. +config GPIO_TPS65912 + tristate "TI TPS65912 GPIO" + depends on MFD_TPS65912 + help + This driver supports TPS65912 gpio chip + config GPIO_TWL4030 tristate "TWL4030, TWL5030, and TPS659x0 GPIOs" depends on TWL4030_CORE
drivers/gpio/Makefile +1 -0
@@ -96,6 +96,7 @@ obj-$(CONFIG_GPIO_TIMBERDALE) += gpio-timberdale.o obj-$(CONFIG_GPIO_PALMAS) += gpio-palmas.o obj-$(CONFIG_GPIO_TPS6586X) += gpio-tps6586x.o obj-$(CONFIG_GPIO_TPS65910) += gpio-tps65910.o +obj-$(CONFIG_GPIO_TPS65912) += gpio-tps65912.o obj-$(CONFIG_GPIO_TS5500) += gpio-ts5500.o obj-$(CONFIG_GPIO_TWL4030) += gpio-twl4030.o obj-$(CONFIG_GPIO_TWL6040) += gpio-twl6040.o
drivers/gpio/gpio-tps65912.c new file +138 -0
138 lines not on this page · raw message
Signature · 1 line
1.9.1
Re: [PATCH v3 5/5] gpio: tps65912: Add GPIO driver for the TPS65912 PMIC
Quoted 67 lines · Andrew F. Davis
This patch adds support for the TPS65912 PMIC GPIOs.
TPS65912 has five configurable GPIOs that can be used for several purposes.
Signed-off-by Andrew F. Davis <[email protected]>--- drivers/gpio/Kconfig | 6 ++ drivers/gpio/Makefile | 1 + drivers/gpio/gpio-tps65912.c | 138 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 145 insertions(+) create mode 100644 drivers/gpio/gpio-tps65912.cdrivers/gpio/Kconfig +6
-0@@ -838,6 +838,12 @@ config GPIO_TPS65910 Select this option to enable GPIO driver for the TPS65910 chip family. +config GPIO_TPS65912 + tristate "TI TPS65912 GPIO" + depends on MFD_TPS65912 + help + This driver supports TPS65912 gpio chip + config GPIO_TWL4030 tristate "TWL4030, TWL5030, and TPS659x0 GPIOs" depends on TWL4030_COREdrivers/gpio/Makefile +1
-0@@ -96,6 +96,7 @@ obj-$(CONFIG_GPIO_TIMBERDALE) += gpio-timberdale.o obj-$(CONFIG_GPIO_PALMAS) += gpio-palmas.o obj-$(CONFIG_GPIO_TPS6586X) += gpio-tps6586x.o obj-$(CONFIG_GPIO_TPS65910) += gpio-tps65910.o +obj-$(CONFIG_GPIO_TPS65912) += gpio-tps65912.o obj-$(CONFIG_GPIO_TS5500) += gpio-ts5500.o obj-$(CONFIG_GPIO_TWL4030) += gpio-twl4030.o obj-$(CONFIG_GPIO_TWL6040) += gpio-twl6040.odrivers/gpio/gpio-tps65912.c new file +19
-0@@ -0,0 +1,138 @@ +/* +* TI TPS65912x GPIO Driver +* +* Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com/ +* +* Author: Andrew F. Davis <[email protected]> +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +* +* This program is distributed "as is" WITHOUT ANY WARRANTY of any +* kind, whether expressed or implied; without even the implied warranty +* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License version 2 for more details. +* +* Based on the Arizona GPIO driver and the previous TPS65912 driver by +* Margarita Olaya Cabrera <[email protected]> +*/
drivers/gpio/gpio-tps65912.c line 29
Quoted 10 lines
drivers/gpio/gpio-tps65912.c new file +10
-0+ +#include <linux/gpio.h> +#include <linux/module.h> +#include <linux/of_device.h> + +#include <linux/mfd/tps65912.h> + +struct tps65912_gpio { +struct tps65912 *tps; +struct gpio_chip gpio_chip;
Nit: I'd suggest to put gpio_chip as the first member of your struct so that to_gpio() resolves to the same address. This may make the generated code neglectably smaller and faster.
drivers/gpio/gpio-tps65912.c line 32
Quoted 3 lines
drivers/gpio/gpio-tps65912.c new file +3
-0+}; + +#define to_gpio (gc) container_of(gc, struct tps65912_gpio, gpio_chip)
Nit2: Maybe a more specific name (like tps_gpio()) would be better? It's local to this file though, so not a big deal.
Quoted 96 lines
drivers/gpio/gpio-tps65912.c new file +96
-0+ +static int tps65912_gpio_get (struct gpio_chip *gc,unsigned offset) +{ +struct tps65912_gpio *gpio =to_gpio (gc); +int ret, val; + + ret =regmap_read (gpio->tps->regmap,TPS65912_GPIO1 + offset, &val); +if (ret <0 ) +return ret; + +return val &GPIO_STS_MASK ; +} + +static void tps65912_gpio_set (struct gpio_chip *gc,unsigned offset, +int value) +{ +struct tps65912_gpio *gpio =to_gpio (gc); + +regmap_update_bits (gpio->tps->regmap,TPS65912_GPIO1 + offset, +GPIO_SET_MASK , value ?GPIO_SET_MASK :0 ); +} + +static int tps65912_gpio_output (struct gpio_chip *gc,unsigned offset, +int value) +{ +struct tps65912_gpio *gpio =to_gpio (gc); + +/* Set the initial value */ +tps65912_gpio_set (gc, offset, value); + +return regmap_update_bits (gpio->tps->regmap,TPS65912_GPIO1 + offset, +GPIO_CFG_MASK ,GPIO_CFG_MASK ); +} + +static int tps65912_gpio_input (struct gpio_chip *gc,unsigned offset) +{ +struct tps65912_gpio *gpio =to_gpio (gc); + +return regmap_update_bits (gpio->tps->regmap,TPS65912_GPIO1 + offset, +GPIO_CFG_MASK ,0 ); +} + +static const struct of_device_id tps65912_gpio_of_match_table[] = { + { .compatible ="ti,tps65912-gpio" , }, + {/* sentinel */ }, +}; +MODULE_DEVICE_TABLE (of, tps65912_gpio_of_match_table); + +static struct gpio_chip template_chip = { + .label ="tps65912-gpio" , + .owner =THIS_MODULE , + .direction_input = tps65912_gpio_input, + .direction_output = tps65912_gpio_output, + .get = tps65912_gpio_get, + .set = tps65912_gpio_set, + .can_sleep = true, + .ngpio =5 , + .base =-1 , +}; + +static int tps65912_gpio_probe (struct platform_device *pdev) +{ +struct tps65912_gpio *gpio; +int ret; + + gpio =devm_kzalloc (&pdev->dev,sizeof (*gpio),GFP_KERNEL ); +if (!gpio) +return -ENOMEM ; + + gpio->tps =dev_get_drvdata (pdev->dev.parent); + gpio->gpio_chip = template_chip; + ret =gpiochip_add (&gpio->gpio_chip); +if (ret <0 ) { +dev_err (&pdev->dev,"Could not register gpiochip, %d\n" , ret); +return ret; + } + +platform_set_drvdata (pdev, gpio); + +return 0 ; +} + +static int tps65912_gpio_remove (struct platform_device *pdev) +{ +struct tps65912_gpio *gpio =platform_get_drvdata (pdev); + +gpiochip_remove (&gpio->gpio_chip); + +return 0 ; +} + +static struct platform_driver tps65912_gpio_driver = { + .driver = { + .name ="tps65912-gpio" , + .of_match_table = tps65912_gpio_of_match_table, + },
drivers/gpio/gpio-tps65912.c line 138
Quoted 10 lines
drivers/gpio/gpio-tps65912.c new file +10
-0+ .probe = tps65912_gpio_probe, + .remove = tps65912_gpio_remove, +}; + +module_platform_driver (tps65912_gpio_driver); + +MODULE_AUTHOR ("Andrew F. Davis <[email protected]>" ); +MODULE_DESCRIPTION ("TPS65912 GPIO driver" ); +MODULE_ALIAS ("platform:tps65912-gpio" ); +MODULE_LICENSE ("GPL v2" );
Nice and simple driver - my remarks above should not be taken as a call to re-spin, just consider them if you need to send another version of this patchset.
Re: [PATCH v3 5/5] gpio: tps65912: Add GPIO driver for the TPS65912 PMIC
Quoted 74 lines · Alexandre Courbot
Quoted 73 lines · Andrew F. Davis
This patch adds support for the TPS65912 PMIC GPIOs.
TPS65912 has five configurable GPIOs that can be used for several purposes.
Signed-off-by Andrew F. Davis <[email protected]>--- drivers/gpio/Kconfig | 6 ++ drivers/gpio/Makefile | 1 + drivers/gpio/gpio-tps65912.c | 138 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 145 insertions(+)create mode 100644
drivers/gpio/gpio-tps65912.cdrivers/gpio/Kconfig +6
-0@@ -838,6 +838,12 @@ config GPIO_TPS65910 Select this option to enable GPIO driver for the TPS65910 chip family. +config GPIO_TPS65912 + tristate "TI TPS65912 GPIO" + depends on MFD_TPS65912 + help + This driver supports TPS65912 gpio chip + config GPIO_TWL4030 tristate "TWL4030, TWL5030, and TPS659x0 GPIOs" depends on TWL4030_COREdrivers/gpio/Makefile +1
-0@@ -96,6 +96,7 @@ obj-$(CONFIG_GPIO_TIMBERDALE) += gpio-timberdale.o obj-$(CONFIG_GPIO_PALMAS) += gpio-palmas.o obj-$(CONFIG_GPIO_TPS6586X) += gpio-tps6586x.o obj-$(CONFIG_GPIO_TPS65910) += gpio-tps65910.o +obj-$(CONFIG_GPIO_TPS65912) += gpio-tps65912.o obj-$(CONFIG_GPIO_TS5500) += gpio-ts5500.o obj-$(CONFIG_GPIO_TWL4030) += gpio-twl4030.o obj-$(CONFIG_GPIO_TWL6040) += gpio-twl6040.odrivers/gpio/gpio-tps65912.c new file +25
-0@@ -0,0 +1,138 @@ +/* +* TI TPS65912x GPIO Driver +* +* Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com/ +* +* Author: Andrew F. Davis <[email protected]> +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +* +* This program is distributed "as is" WITHOUT ANY WARRANTY of any +* kind, whether expressed or implied; without even the implied warranty +* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License version 2 for more details. +* +* Based on the Arizona GPIO driver and the previous TPS65912 driver by +* Margarita Olaya Cabrera <magi-kDsPt+C1G03kYMGBc/[email protected]> +*/ + +#include <linux/gpio.h> +#include <linux/module.h> +#include <linux/of_device.h> + +#include <linux/mfd/tps65912.h>
Quoted 9 lines
drivers/gpio/gpio-tps65912.c line 29
Quoted 4 lines
drivers/gpio/gpio-tps65912.c new file +4
-0+ +struct tps65912_gpio { +struct tps65912 *tps; +struct gpio_chip gpio_chip;Nit: I'd suggest to put
gpio_chipas the first member of your struct so thatto_gpio()resolves to the same address. This may make the generated code neglectably smaller and faster.
ACK
Quoted 7 lines
drivers/gpio/gpio-tps65912.c line 32
Quoted 3 lines
drivers/gpio/gpio-tps65912.c new file +3
-0+}; + +#define to_gpio (gc) container_of(gc, struct tps65912_gpio, gpio_chip)Nit2: Maybe a more specific name (like
tps_gpio()) would be better? It's local to this file though, so not a big deal.
ACK
Quoted 111 lines
Quoted 96 lines
drivers/gpio/gpio-tps65912.c new file +96
-0+ +static int tps65912_gpio_get (struct gpio_chip *gc,unsigned offset) +{ +struct tps65912_gpio *gpio =to_gpio (gc); +int ret, val; + + ret =regmap_read (gpio->tps->regmap,TPS65912_GPIO1 + offset, &val); +if (ret <0 ) +return ret; + +return val &GPIO_STS_MASK ; +} + +static void tps65912_gpio_set (struct gpio_chip *gc,unsigned offset, +int value) +{ +struct tps65912_gpio *gpio =to_gpio (gc); + +regmap_update_bits (gpio->tps->regmap,TPS65912_GPIO1 + offset, +GPIO_SET_MASK , value ?GPIO_SET_MASK :0 ); +} + +static int tps65912_gpio_output (struct gpio_chip *gc,unsigned offset, +int value) +{ +struct tps65912_gpio *gpio =to_gpio (gc); + +/* Set the initial value */ +tps65912_gpio_set (gc, offset, value); + +return regmap_update_bits (gpio->tps->regmap,TPS65912_GPIO1 + offset, +GPIO_CFG_MASK ,GPIO_CFG_MASK ); +} + +static int tps65912_gpio_input (struct gpio_chip *gc,unsigned offset) +{ +struct tps65912_gpio *gpio =to_gpio (gc); + +return regmap_update_bits (gpio->tps->regmap,TPS65912_GPIO1 + offset, +GPIO_CFG_MASK ,0 ); +} + +static const struct of_device_id tps65912_gpio_of_match_table[] = { + { .compatible ="ti,tps65912-gpio" , }, + {/* sentinel */ }, +}; +MODULE_DEVICE_TABLE (of, tps65912_gpio_of_match_table); + +static struct gpio_chip template_chip = { + .label ="tps65912-gpio" , + .owner =THIS_MODULE , + .direction_input = tps65912_gpio_input, + .direction_output = tps65912_gpio_output, + .get = tps65912_gpio_get, + .set = tps65912_gpio_set, + .can_sleep = true, + .ngpio =5 , + .base =-1 , +}; + +static int tps65912_gpio_probe (struct platform_device *pdev) +{ +struct tps65912_gpio *gpio; +int ret; + + gpio =devm_kzalloc (&pdev->dev,sizeof (*gpio),GFP_KERNEL ); +if (!gpio) +return -ENOMEM ; + + gpio->tps =dev_get_drvdata (pdev->dev.parent); + gpio->gpio_chip = template_chip; + ret =gpiochip_add (&gpio->gpio_chip); +if (ret <0 ) { +dev_err (&pdev->dev,"Could not register gpiochip, %d\n" , ret); +return ret; + } + +platform_set_drvdata (pdev, gpio); + +return 0 ; +} + +static int tps65912_gpio_remove (struct platform_device *pdev) +{ +struct tps65912_gpio *gpio =platform_get_drvdata (pdev); + +gpiochip_remove (&gpio->gpio_chip); + +return 0 ; +} + +static struct platform_driver tps65912_gpio_driver = { + .driver = { + .name ="tps65912-gpio" , + .of_match_table = tps65912_gpio_of_match_table, + },drivers/gpio/gpio-tps65912.c line 138
Quoted 10 lines
drivers/gpio/gpio-tps65912.c new file +10
-0+ .probe = tps65912_gpio_probe, + .remove = tps65912_gpio_remove, +}; + +module_platform_driver (tps65912_gpio_driver); + +MODULE_AUTHOR ("Andrew F. Davis <[email protected]>" ); +MODULE_DESCRIPTION ("TPS65912 GPIO driver" ); +MODULE_ALIAS ("platform:tps65912-gpio" ); +MODULE_LICENSE ("GPL v2" );Nice and simple driver - my remarks above should not be taken as a call to re-spin, just consider them if you need to send another version of this patchset.
Quoted 2 lines
Reviewed-by Alexandre Courbot <[email protected]>
I'm going to have to send another spin of this patchset anyway so I'll take them.
Thanks for the review,
Andrew
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html