mfd: wm831x: Add basic device tree binding
Subsystems (4)
PATCH v3 1/3 mfd: wm831x: Add basic device tree binding
Add the basic ability to register the device through device tree, more work is needed to get each individual sub-driver functioning correctly but this is enough to get the device to probe from device tree.
---
No changes since v2.
drivers/mfd/wm831x-core.c | 32 +++++++++++++++++++++++++++++++- drivers/mfd/wm831x-i2c.c | 9 ++++++++- drivers/mfd/wm831x-irq.c | 6 +++--- drivers/mfd/wm831x-spi.c | 6 +++++- include/linux/mfd/wm831x/core.h | 15 +++++++++++++++ 5 files changed, 62 insertions(+), 6 deletions(-)
drivers/mfd/wm831x-core.c +31 -1
@@ -19,6 +19,8 @@#include <linux/mfd/core.h> #include <linux/slab.h> #include <linux/err.h> +#include <linux/of.h> +#include <linux/of_device.h> #include <linux/mfd/wm831x/core.h> #include <linux/mfd/wm831x/pdata.h>
@@ -1613,6 +1615,31 @@ struct regmap_config wm831x_regmap_config = { };EXPORT_SYMBOL_GPL (wm831x_regmap_config); +#ifdef CONFIG_OF +const struct of_device_id wm831x_of_match[] = { + { .compatible ="wlf,wm8310" , .data = (void *)WM8310 }, + { .compatible ="wlf,wm8311" , .data = (void *)WM8311 }, + { .compatible ="wlf,wm8312" , .data = (void *)WM8312 }, + { .compatible ="wlf,wm8320" , .data = (void *)WM8320 }, + { .compatible ="wlf,wm8321" , .data = (void *)WM8321 }, + { .compatible ="wlf,wm8325" , .data = (void *)WM8325 }, + { .compatible ="wlf,wm8326" , .data = (void *)WM8326 }, + { }, +}; +EXPORT_SYMBOL_GPL (wm831x_of_match); + +int wm831x_of_get_type (struct device *dev) +{ +const struct of_device_id *id =of_match_device (wm831x_of_match, dev); + +if (id) +return (unsigned long )id->data; +else +return 0 ; +} +EXPORT_SYMBOL_GPL (wm831x_of_get_type); +#endif +/* * Instantiate the generic non-control parts of the device. */
@@ -1628,7 +1655,10 @@ int wm831x_device_init(struct wm831x *wm831x, unsigned long id, int irq)dev_set_drvdata (wm831x->dev, wm831x);if (pdata) - wm831x->soft_shutdown = pdata->soft_shutdown; +memcpy (&wm831x->pdata, pdata,sizeof (*pdata)); + pdata = &wm831x->pdata; + + wm831x->soft_shutdown = pdata->soft_shutdown; ret =wm831x_reg_read (wm831x,WM831X_PARENT_ID );if (ret <0 ) {
drivers/mfd/wm831x-i2c.c +8 -1
@@ -28,8 +28,14 @@ static int wm831x_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *id) {struct wm831x *wm831x; +enum wm831x_parent type;int ret; +if (i2c->dev.of_node) + type = (enum wm831x_parent )wm831x_of_get_type (&i2c->dev); +else + type = (enum wm831x_parent )id->driver_data; + wm831x =devm_kzalloc (&i2c->dev,sizeof (struct wm831x ),GFP_KERNEL );if (wm831x ==NULL )return -ENOMEM ;
@@ -45,7 +51,7 @@ static int wm831x_i2c_probe(struct i2c_client *i2c,return ret; } -return wm831x_device_init (wm831x, id->driver_data, i2c->irq); +return wm831x_device_init (wm831x, type, i2c->irq); }static int wm831x_i2c_remove (struct i2c_client *i2c)
@@ -94,6 +100,7 @@ static struct i2c_driver wm831x_i2c_driver = { .driver = { .name = "wm831x", .pm = &wm831x_pm_ops, + .of_match_table = of_match_ptr(wm831x_of_match), }, .probe = wm831x_i2c_probe, .remove = wm831x_i2c_remove,
drivers/mfd/wm831x-irq.c +3 -3
@@ -564,7 +564,7 @@ static const struct irq_domain_ops wm831x_irq_domain_ops = {int wm831x_irq_init (struct wm831x *wm831x,int irq) { -struct wm831x_pdata *pdata =dev_get_platdata (wm831x->dev); +struct wm831x_pdata *pdata = &wm831x->pdata;struct irq_domain *domain;int i, ret, irq_base;
@@ -579,7 +579,7 @@ int wm831x_irq_init(struct wm831x *wm831x, int irq) }/* Try to dynamically allocate IRQs if no base is specified */ -if (pdata && pdata->irq_base) { +if (pdata->irq_base) { irq_base =irq_alloc_descs (pdata->irq_base,0 ,WM831X_NUM_IRQS ,0 );if (irq_base <0 ) {
@@ -608,7 +608,7 @@ int wm831x_irq_init(struct wm831x *wm831x, int irq)return -EINVAL ; } -if (pdata && pdata->irq_cmos) +if (pdata->irq_cmos) i =0 ;else i =WM831X_IRQ_OD ;
drivers/mfd/wm831x-spi.c +5 -1
@@ -28,7 +28,10 @@ static int wm831x_spi_probe(struct spi_device *spi)enum wm831x_parent type;int ret; - type = (enum wm831x_parent )id->driver_data; +if (spi->dev.of_node) + type = (enum wm831x_parent )wm831x_of_get_type (&spi->dev); +else + type = (enum wm831x_parent )id->driver_data; wm831x =devm_kzalloc (&spi->dev,sizeof (struct wm831x ),GFP_KERNEL );if (wm831x ==NULL )
@@ -97,6 +100,7 @@ static struct spi_driver wm831x_spi_driver = { .driver = { .name = "wm831x", .pm = &wm831x_spi_pm, + .of_match_table = of_match_ptr(wm831x_of_match), }, .id_table = wm831x_spi_ids, .probe = wm831x_spi_probe,
include/linux/mfd/wm831x/core.h +15 -0
@@ -21,6 +21,8 @@#include <linux/list.h> #include <linux/regmap.h> #include <linux/mfd/wm831x/auxadc.h> +#include <linux/mfd/wm831x/pdata.h> +#include <linux/of.h> /* * Register values.
@@ -367,6 +369,8 @@ struct wm831x {struct regmap *regmap; +struct wm831x_pdata pdata; +int irq;/* Our chip IRQ */ struct mutex irq_lock;struct irq_domain *irq_domain;
@@ -427,4 +431,15 @@ static inline int wm831x_irq(struct wm831x *wm831x, int irq)extern struct regmap_config wm831x_regmap_config; +extern const struct of_device_id wm831x_of_match[]; + +#ifdef CONFIG_OF +int wm831x_of_get_type (struct device *dev); +#else +static inline int wm831x_of_get_type (struct device *dev) +{ +return 0 ; +} +#endif +#endif
Signature · 1 line
2.1.4
PATCH v3 2/3 gpio: wm831x: Add basic device tree support
Now the wm831x-core has basic DT support we can update this driver to allow use of the GPIOs within a device tree system.
---
No changes since v2.
drivers/gpio/gpio-wm831x.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/gpio/gpio-wm831x.c +4 -1
@@ -264,7 +264,7 @@ static const struct gpio_chip template_chip = {static int wm831x_gpio_probe (struct platform_device *pdev) {struct wm831x *wm831x =dev_get_drvdata (pdev->dev.parent); -struct wm831x_pdata *pdata =dev_get_platdata (wm831x->dev); +struct wm831x_pdata *pdata = &wm831x->pdata;struct wm831x_gpio *wm831x_gpio;int ret;
@@ -281,6 +281,9 @@ static int wm831x_gpio_probe(struct platform_device *pdev) wm831x_gpio->gpio_chip.base = pdata->gpio_base; else wm831x_gpio->gpio_chip.base = -1; +#ifdef CONFIG_OF_GPIO + wm831x_gpio->gpio_chip.of_node = wm831x->dev->of_node; +#endif ret =devm_gpiochip_add_data (&pdev->dev, &wm831x_gpio->gpio_chip, wm831x_gpio);
Signature · 1 line
2.1.4
Re: [PATCH v3 2/3] gpio: wm831x: Add basic device tree support
Quoted 5 lines · Charles Keepax
Now the wm831x-core has basic DT support we can update this driver to allow use of the GPIOs within a device tree system.
Signed-off-by Charles Keepax <[email protected]>Acked-by Linus Walleij <[email protected]>
Patch applied.
Yours,
Linus Walleij
Re: [PATCH v3 2/3] gpio: wm831x: Add basic device tree support
Quoted 11 lines · Linus Walleij
Quoted 5 lines · Charles Keepax
Now the wm831x-core has basic DT support we can update this driver to allow use of the GPIOs within a device tree system.
Signed-off-by Charles Keepax <[email protected]>Acked-by Linus Walleij <[email protected]>Patch applied.
This needs to go through Lee's tree with the patch above it has a build dependency on it.
Thanks,
Charles
PATCH v3 3/3 mfd: wm831x: Add device tree binding document
In reply to Charles KeepaxAdd a device tree binding document for the wm831x series of PMICs. Currently only support for the registering the device and the GPIOs are actually implemented in the driver.
---
Changes since v2:
- Flesh the binding some more with some additional features of the device, although these are not yet implemented in the code.
Documentation/devicetree/bindings/mfd/wm831x.txt | 81 ++++++++++++++++++++++++ MAINTAINERS | 1 + 2 files changed, 82 insertions(+) create mode 100644 Documentation/devicetree/bindings/mfd/wm831x.txt
Documentation/devicetree/bindings/mfd/wm831x.txt new file +81 -0
@@ -0,0 +1,81 @@ +Cirrus Logic/Wolfson Microelectronics wm831x PMICs + +System PMICs with a wide range of additional features. + +Required properties: + + - compatible : One of the following chip-specific strings: + "wlf,wm8310" + "wlf,wm8311" + "wlf,wm8312" + "wlf,wm8320" + "wlf,wm8321" + "wlf,wm8325" + "wlf,wm8326" + + - reg : I2C slave address when connected using I2C, chip select number + when using SPI. + + - gpio-controller : Indicates this device is a GPIO controller. + - #gpio-cells : Must be 2. The first cell is the pin number and the + second cell is used to specify optional parameters (currently unused). + + - interrupts : The interrupt line the /IRQ signal for the device is + connected to. + - interrupt-parent : The parent interrupt controller. + + - interrupt-controller : wm831x devices contain interrupt controllers and + may provide interrupt services to other devices. + - #interrupt-cells: Must be 2. The first cell is the IRQ number, and the + second cell is the flags, encoded as the trigger masks from + Documentation/devicetree/bindings/interrupt-controller/interrupts.txt + +Optional sub-nodes: + - regulators : Contains sub-nodes for each of the regulators supplied by + the device. The regulators are bound using their names listed below: + + dcdc1 : DCDC1 + dcdc2 : DCDC2 + dcdc3 : DCDC3 + dcdc4 : DCDC3 + isink1 : ISINK1 + isink2 : ISINK2 + ldo1 : LDO1 + ldo2 : LDO2 + ldo3 : LDO3 + ldo4 : LDO4 + ldo5 : LDO5 + ldo7 : LDO7 + ldo11 : LDO11 + + The bindings details of each regulator can be found in: + Documentation/devicetree/bindings/regulator/regulator.txt + +Example: + +wm8310: pmic@36 { + compatible = "wlf,wm8310"; + reg = <0x36>; + + gpio-controller; + #gpio-cells = <2>; + + interrupts = <347>; + interrupt-parent = <&gic>; + + interrupt-controller; + #interrupt-cells = <2>; + + regulators { + dcdc1: dcdc1 { + regulator-name = "DCDC1"; + regulator-min-microvolt = <600000>; + regulator-max-microvolt = <600000>; + }; + ldo1: ldo1 { + regulator-name = "LDO1"; + regulator-min-microvolt = <1700000>; + regulator-max-microvolt = <1700000>; + }; + }; +};
MAINTAINERS +1 -0
@@ -13363,6 +13363,7 @@ F: Documentation/hwmon/wm83?? F: Documentation/devicetree/bindings/extcon/extcon-arizona.txt F: Documentation/devicetree/bindings/regulator/arizona-regulator.txt F: Documentation/devicetree/bindings/mfd/arizona.txt +F: Documentation/devicetree/bindings/mfd/wm831x.txt F: arch/arm/mach-s3c64xx/mach-crag6410* F: drivers/clk/clk-wm83*.c F: drivers/extcon/extcon-arizona.c
Signature · 1 line
2.1.4
Re: [PATCH v3 3/3] mfd: wm831x: Add device tree binding document
Quoted 33 lines · Charles Keepax
Add a device tree binding document for the wm831x series of PMICs. Currently only support for the registering the device and the GPIOs are actually implemented in the driver.
Signed-off-by Charles Keepax <[email protected]>---
Changes since v2:
- Flesh the binding some more with some additional features of the device, although these are not yet implemented in the code.Documentation/devicetree/bindings/mfd/wm831x.txt | 81 ++++++++++++++++++++++++ MAINTAINERS | 1 + 2 files changed, 82 insertions(+) create mode 100644 Documentation/devicetree/bindings/mfd/wm831x.txtDocumentation/devicetree/bindings/mfd/wm831x.txt new file +11
-0@@ -0,0 +1,81 @@ +Cirrus Logic/Wolfson Microelectronics wm831x PMICs + +System PMICs with a wide range of additional features. + +Required properties: + + - compatible : One of the following chip-specific strings: + "wlf,wm8310" + "wlf,wm8311" + "wlf,wm8312" + "wlf,wm8320"
Documentation/devicetree/bindings/mfd/wm831x.txt line 21
Quoted 10 lines
Documentation/devicetree/bindings/mfd/wm831x.txt new file +10
-0+ "wlf,wm8321" + "wlf,wm8325" + "wlf,wm8326" + + - reg : I2C slave address when connected using I2C, chip select number + when using SPI. + + - gpio-controller : Indicates this device is a GPIO controller. + - #gpio-cells : Must be 2. The first cell is the pin number and the + second cell is used to specify optional parameters (currently unused).
Then why not "must be 1", if the second cell is unused?
Documentation/devicetree/bindings/mfd/wm831x.txt line 24
Quoted 2 lines
Documentation/devicetree/bindings/mfd/wm831x.txt new file +2
-0+ - interrupts : The interrupt line the /IRQ signal for the device is + connected to.
What's with the '/'?
Documentation/devicetree/bindings/mfd/wm831x.txt line 31
Quoted 7 lines
Documentation/devicetree/bindings/mfd/wm831x.txt new file +7
-0+ - interrupt-parent : The parent interrupt controller. + + - interrupt-controller : wm831x devices contain interrupt controllers and + may provide interrupt services to other devices. + - #interrupt-cells: Must be 2. The first cell is the IRQ number, and the + second cell is the flags, encoded as the trigger masks from + Documentation/devicetree/bindings/interrupt-controller/interrupts.txt
Please use the succinct "../../" format.
Quoted 10 lines
Documentation/devicetree/bindings/mfd/wm831x.txt new file +10
-0+Optional sub-nodes: + - regulators : Contains sub-nodes for each of the regulators supplied by + the device. The regulators are bound using their names listed below: + + dcdc1 : DCDC1 + dcdc2 : DCDC2 + dcdc3 : DCDC3 + dcdc4 : DCDC3 + isink1 : ISINK1 + isink2 : ISINK2
Documentation/devicetree/bindings/mfd/wm831x.txt line 52
Quoted 10 lines
Documentation/devicetree/bindings/mfd/wm831x.txt new file +10
-0+ ldo1 : LDO1 + ldo2 : LDO2 + ldo3 : LDO3 + ldo4 : LDO4 + ldo5 : LDO5 + ldo7 : LDO7 + ldo11 : LDO11 + + The bindings details of each regulator can be found in: + Documentation/devicetree/bindings/regulator/regulator.txt
As above.
Quoted 40 lines
Documentation/devicetree/bindings/mfd/wm831x.txt new file +28
-0+Example: + +wm8310: pmic@36 { + compatible = "wlf,wm8310"; + reg = <0x36>; + + gpio-controller; + #gpio-cells = <2>; + + interrupts = <347>; + interrupt-parent = <&gic>; + + interrupt-controller; + #interrupt-cells = <2>; + + regulators { + dcdc1: dcdc1 { + regulator-name = "DCDC1"; + regulator-min-microvolt = <600000>; + regulator-max-microvolt = <600000>; + }; + ldo1: ldo1 { + regulator-name = "LDO1"; + regulator-min-microvolt = <1700000>; + regulator-max-microvolt = <1700000>; + }; + }; +};MAINTAINERS +1
-0@@ -13363,6 +13363,7 @@ F: Documentation/hwmon/wm83?? F: Documentation/devicetree/bindings/extcon/extcon-arizona.txt F: Documentation/devicetree/bindings/regulator/arizona-regulator.txt F: Documentation/devicetree/bindings/mfd/arizona.txt +F: Documentation/devicetree/bindings/mfd/wm831x.txt F: arch/arm/mach-s3c64xx/mach-crag6410* F: drivers/clk/clk-wm83*.c F: drivers/extcon/extcon-arizona.c
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/3] mfd: wm831x: Add device tree binding document
Quoted 39 lines · Lee Jones
Quoted 37 lines · Charles Keepax
Add a device tree binding document for the wm831x series of PMICs. Currently only support for the registering the device and the GPIOs are actually implemented in the driver.
Signed-off-by Charles Keepax <[email protected]>---
Changes since v2:
- Flesh the binding some more with some additional features of the device, although these are not yet implemented in the code.Documentation/devicetree/bindings/mfd/wm831x.txt | 81 ++++++++++++++++++++++++ MAINTAINERS | 1 + 2 files changed, 82 insertions(+) create mode 100644 Documentation/devicetree/bindings/mfd/wm831x.txtDocumentation/devicetree/bindings/mfd/wm831x.txt new file +15
-0@@ -0,0 +1,81 @@ +Cirrus Logic/Wolfson Microelectronics wm831x PMICs + +System PMICs with a wide range of additional features. + +Required properties: + + - compatible : One of the following chip-specific strings: + "wlf,wm8310" + "wlf,wm8311" + "wlf,wm8312" + "wlf,wm8320" + "wlf,wm8321" + "wlf,wm8325" + "wlf,wm8326" +
Quoted 9 lines
Documentation/devicetree/bindings/mfd/wm831x.txt line 21
Quoted 6 lines
Documentation/devicetree/bindings/mfd/wm831x.txt new file +6
-0+ - reg : I2C slave address when connected using I2C, chip select number + when using SPI. + + - gpio-controller : Indicates this device is a GPIO controller. + - #gpio-cells : Must be 2. The first cell is the pin number and the + second cell is used to specify optional parameters (currently unused).Then why not "must be 1", if the second cell is unused?
I believe it is generally advised to use at least 2 cells for GPIOs and since there is a reasonable chance someone might add flags later seems better have it in the binding already.
Quoted 4 lines
Documentation/devicetree/bindings/mfd/wm831x.txt line 24
Quoted 2 lines
Documentation/devicetree/bindings/mfd/wm831x.txt new file +2
-0+ - interrupts : The interrupt line the /IRQ signal for the device is + connected to.What's with the '/'?
Active low, but will remove.
Quoted 10 lines
Documentation/devicetree/bindings/mfd/wm831x.txt line 31
Quoted 8 lines
Documentation/devicetree/bindings/mfd/wm831x.txt new file +7
-0+ - interrupt-parent : The parent interrupt controller. + + - interrupt-controller : wm831x devices contain interrupt controllers and + may provide interrupt services to other devices. + - #interrupt-cells: Must be 2. The first cell is the IRQ number, and the + second cell is the flags, encoded as the trigger masks from + Documentation/devicetree/bindings/interrupt-controller/interrupts.txtPlease use the succinct "../../" format.
Can do.
Thanks,
Charles
Quoted 43 lines · Charles Keepax
Add the basic ability to register the device through device tree, more work is needed to get each individual sub-driver functioning correctly but this is enough to get the device to probe from device tree.
Signed-off-by Charles Keepax <[email protected]>---
No changes since v2.
drivers/mfd/wm831x-core.c | 32 +++++++++++++++++++++++++++++++- drivers/mfd/wm831x-i2c.c | 9 ++++++++- drivers/mfd/wm831x-irq.c | 6 +++--- drivers/mfd/wm831x-spi.c | 6 +++++- include/linux/mfd/wm831x/core.h | 15 +++++++++++++++ 5 files changed, 62 insertions(+), 6 deletions(-)drivers/mfd/wm831x-core.c +12
-0@@ -19,6 +19,8 @@#include <linux/mfd/core.h> #include <linux/slab.h> #include <linux/err.h> +#include <linux/of.h> +#include <linux/of_device.h> #include <linux/mfd/wm831x/core.h> #include <linux/mfd/wm831x/pdata.h> @@ -1613,6 +1615,31 @@ struct regmap_config wm831x_regmap_config = { };EXPORT_SYMBOL_GPL (wm831x_regmap_config); +#ifdef CONFIG_OF +const struct of_device_id wm831x_of_match[] = { + { .compatible ="wlf,wm8310" , .data = (void *)WM8310 }, + { .compatible ="wlf,wm8311" , .data = (void *)WM8311 }, + { .compatible ="wlf,wm8312" , .data = (void *)WM8312 }, + { .compatible ="wlf,wm8320" , .data = (void *)WM8320 }, + { .compatible ="wlf,wm8321" , .data = (void *)WM8321 }, + { .compatible ="wlf,wm8325" , .data = (void *)WM8325 }, + { .compatible ="wlf,wm8326" , .data = (void *)WM8326 }, + { },
drivers/mfd/wm831x-core.c struct regmap_config wm831x_regmap_config = { · line 1637
Quoted 10 lines
drivers/mfd/wm831x-core.c +10
-0+}; +EXPORT_SYMBOL_GPL (wm831x_of_match); + +int wm831x_of_get_type (struct device *dev) +{ +const struct of_device_id *id =of_match_device (wm831x_of_match, dev); + +if (id) +return (unsigned long )id->data; +else
This is not possible.
drivers/mfd/wm831x-core.c struct regmap_config wm831x_regmap_config = { · line 1640
Quoted 3 lines
drivers/mfd/wm831x-core.c +3
-0+return 0 ; +} +EXPORT_SYMBOL_GPL (wm831x_of_get_type);
No need for this function and certainly no requirement to export it.
drivers/mfd/wm831x-core.c int wm831x_device_init(struct wm831x *wm831x, unsigned long id, int irq)
Quoted 6 lines
drivers/mfd/wm831x-core.c +2
-0+#endif +/* * Instantiate the generic non-control parts of the device. */ @@ -1628,7 +1655,10 @@ int wm831x_device_init(struct wm831x *wm831x, unsigned long id, int irq)
You can expand 'id' to 'type' now.
drivers/mfd/wm831x-core.c int wm831x_device_init(struct wm831x *wm831x, unsigned long id, int irq) · line 1659
Quoted 6 lines
drivers/mfd/wm831x-core.c +2
-1dev_set_drvdata (wm831x->dev, wm831x);if (pdata) - wm831x->soft_shutdown = pdata->soft_shutdown; +memcpy (&wm831x->pdata, pdata,sizeof (*pdata)); + pdata = &wm831x->pdata;
We normally deal with pdata in .probe().
It makes sense to group it with your 'get_type' code.
Quoted 9 lines
drivers/mfd/wm831x-core.c +1
-0+ wm831x->soft_shutdown = pdata->soft_shutdown; ret =wm831x_reg_read (wm831x,WM831X_PARENT_ID );if (ret <0 ) {drivers/mfd/wm831x-i2c.c +0
-0
drivers/mfd/wm831x-i2c.c static int wm831x_i2c_probe(struct i2c_client *i2c, · line 35
Quoted 8 lines
drivers/mfd/wm831x-i2c.c +3
-0@@ -28,8 +28,14 @@ static int wm831x_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *id) {struct wm831x *wm831x; +enum wm831x_parent type;int ret; +if (i2c->dev.of_node) + type = (enum wm831x_parent )wm831x_of_get_type (&i2c->dev);
Move the 'get_type' code here instead and store the type into device data i.e. wm831x.
Quoted 104 lines
drivers/mfd/wm831x-i2c.c +5
-1+else + type = (enum wm831x_parent )id->driver_data; + wm831x =devm_kzalloc (&i2c->dev,sizeof (struct wm831x ),GFP_KERNEL );if (wm831x ==NULL )return -ENOMEM ;@@ -45,7 +51,7 @@ static int wm831x_i2c_probe(struct i2c_client *i2c,return ret; } -return wm831x_device_init (wm831x, id->driver_data, i2c->irq); +return wm831x_device_init (wm831x, type, i2c->irq); }static int wm831x_i2c_remove (struct i2c_client *i2c)@@ -94,6 +100,7 @@ static struct i2c_driver wm831x_i2c_driver = { .driver = { .name = "wm831x", .pm = &wm831x_pm_ops, + .of_match_table = of_match_ptr(wm831x_of_match), }, .probe = wm831x_i2c_probe, .remove = wm831x_i2c_remove,drivers/mfd/wm831x-irq.c +3
-3@@ -564,7 +564,7 @@ static const struct irq_domain_ops wm831x_irq_domain_ops = {int wm831x_irq_init (struct wm831x *wm831x,int irq) { -struct wm831x_pdata *pdata =dev_get_platdata (wm831x->dev); +struct wm831x_pdata *pdata = &wm831x->pdata;struct irq_domain *domain;int i, ret, irq_base;@@ -579,7 +579,7 @@ int wm831x_irq_init(struct wm831x *wm831x, int irq) }/* Try to dynamically allocate IRQs if no base is specified */ -if (pdata && pdata->irq_base) { +if (pdata->irq_base) { irq_base =irq_alloc_descs (pdata->irq_base,0 ,WM831X_NUM_IRQS ,0 );if (irq_base <0 ) {@@ -608,7 +608,7 @@ int wm831x_irq_init(struct wm831x *wm831x, int irq)return -EINVAL ; } -if (pdata && pdata->irq_cmos) +if (pdata->irq_cmos) i =0 ;else i =WM831X_IRQ_OD ;drivers/mfd/wm831x-spi.c +5
-1@@ -28,7 +28,10 @@ static int wm831x_spi_probe(struct spi_device *spi)enum wm831x_parent type;int ret; - type = (enum wm831x_parent )id->driver_data; +if (spi->dev.of_node) + type = (enum wm831x_parent )wm831x_of_get_type (&spi->dev); +else + type = (enum wm831x_parent )id->driver_data; wm831x =devm_kzalloc (&spi->dev,sizeof (struct wm831x ),GFP_KERNEL );if (wm831x ==NULL )@@ -97,6 +100,7 @@ static struct spi_driver wm831x_spi_driver = { .driver = { .name = "wm831x", .pm = &wm831x_spi_pm, + .of_match_table = of_match_ptr(wm831x_of_match), }, .id_table = wm831x_spi_ids, .probe = wm831x_spi_probe,include/linux/mfd/wm831x/core.h +4
-0@@ -21,6 +21,8 @@#include <linux/list.h> #include <linux/regmap.h> #include <linux/mfd/wm831x/auxadc.h> +#include <linux/mfd/wm831x/pdata.h> +#include <linux/of.h> /* * Register values. @@ -367,6 +369,8 @@ struct wm831x {struct regmap *regmap; +struct wm831x_pdata pdata; +int irq;/* Our chip IRQ */ struct mutex irq_lock;struct irq_domain *irq_domain;@@ -427,4 +431,15 @@ static inline int wm831x_irq(struct wm831x *wm831x, int irq)extern struct regmap_config wm831x_regmap_config;
include/linux/mfd/wm831x/core.h static inline int wm831x_irq(struct wm831x *wm831x, int irq) · line 443
Quoted 10 lines
include/linux/mfd/wm831x/core.h +10
-0+extern const struct of_device_id wm831x_of_match[]; + +#ifdef CONFIG_OF +int wm831x_of_get_type (struct device *dev); +#else +static inline int wm831x_of_get_type (struct device *dev) +{ +return 0 ; +} +#endif
No need.
Quoted 1 line
include/linux/mfd/wm831x/core.h +0
-0#endif
Signature · 4 lines
Lee Jones Linaro STMicroelectronics Landing Team Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog