mfd: Refactor WM831x chip identification
Subsystems (3)
PATCH 1/4 mfd: Refactor WM831x chip identification
Better support future device revisions by moving some of the output around and making the chip ID enumeration be the value expected in the ID register.
--- drivers/mfd/wm831x-core.c | 58 ++++++++++++++------------------------------- 1 files changed, 18 insertions(+), 40 deletions(-)
drivers/mfd/wm831x-core.c +18 -40
@@ -90,9 +90,9 @@ int wm831x_isinkv_values[WM831X_ISINK_MAX_ISEL] = {EXPORT_SYMBOL_GPL (wm831x_isinkv_values);enum wm831x_parent { -WM8310 =0 , -WM8311 =1 , -WM8312 =2 , +WM8310 =0x8310 , +WM8311 =0x8311 , +WM8312 =0x8312 , };static int wm831x_reg_locked (struct wm831x *wm831x,unsigned short reg)
@@ -1282,50 +1282,28 @@ static int wm831x_device_init(struct wm831x *wm831x, unsigned long id, int irq) goto err; } +/* Some engineering samples do not have the ID set, rely on +* the device being registered correctly. +*/ +if (ret ==0 ) { +dev_info (wm831x->dev,"Device is an engineering sample\n" ); + ret = id; + } +switch (ret) { -case 0x8310 : +case WM8310 : parent =WM8310 ; -switch (rev) { -case 0 : -dev_info (wm831x->dev,"WM8310 revision %c\n" , -'A' + rev); -break ; - } +dev_info (wm831x->dev,"WM8310 revision %c\n" ,'A' + rev);break ; -case 0x8311 : +case WM8311 : parent =WM8311 ; -switch (rev) { -case 0 : -dev_info (wm831x->dev,"WM8311 revision %c\n" , -'A' + rev); -break ; - } +dev_info (wm831x->dev,"WM8311 revision %c\n" ,'A' + rev);break ; -case 0x8312 : +case WM8312 : parent =WM8312 ; -switch (rev) { -case 0 : -dev_info (wm831x->dev,"WM8312 revision %c\n" , -'A' + rev); -break ; - } -break ; - -case 0 : -/* Some engineering samples do not have the ID set, -* rely on the device being registered correctly. -* This will need revisiting for future devices with -* multiple dies. -*/ - parent = id; -switch (rev) { -case 0 : -dev_info (wm831x->dev,"WM831%d ES revision %c\n" , - parent,'A' + rev); -break ; - } +dev_info (wm831x->dev,"WM8312 revision %c\n" ,'A' + rev);break ;default :
@@ -1338,7 +1316,7 @@ static int wm831x_device_init(struct wm831x *wm831x, unsigned long id, int irq)* current parts. */ if (parent != id) -dev_warn (wm831x->dev,"Device was registered as a WM831%lu\n" , +dev_warn (wm831x->dev,"Device was registered as a WM%lx\n" , id);/* Bootstrap the user key */
Signature · 1 line
1.6.4.3
PATCH 2/4 gpiolib: Make WM831x GPIO count dynamic
This supports future devices with fewer GPIOs.
--- drivers/gpio/wm831x-gpio.c | 4 +--- drivers/mfd/wm831x-core.c | 3 +++ include/linux/mfd/wm831x/core.h | 2 ++ 3 files changed, 6 insertions(+), 3 deletions(-)
drivers/gpio/wm831x-gpio.c +1 -3
@@ -23,8 +23,6 @@#include <linux/mfd/wm831x/pdata.h> #include <linux/mfd/wm831x/gpio.h> -#define WM831X_GPIO_MAX 16 -struct wm831x_gpio {struct wm831x *wm831x;struct gpio_chip gpio_chip;
@@ -192,7 +190,7 @@ static int __devinit wm831x_gpio_probe(struct platform_device *pdev) wm831x_gpio->wm831x = wm831x; wm831x_gpio->gpio_chip = template_chip; - wm831x_gpio->gpio_chip.ngpio =WM831X_GPIO_MAX ; + wm831x_gpio->gpio_chip.ngpio = wm831x->num_gpio; wm831x_gpio->gpio_chip.dev = &pdev->dev;if (pdata && pdata->gpio_base) wm831x_gpio->gpio_chip.base = pdata->gpio_base;
drivers/mfd/wm831x-core.c +3 -0
@@ -1293,16 +1293,19 @@ static int wm831x_device_init(struct wm831x *wm831x, unsigned long id, int irq)switch (ret) {case WM8310 : parent =WM8310 ; + wm831x->num_gpio =16 ;dev_info (wm831x->dev,"WM8310 revision %c\n" ,'A' + rev);break ;case WM8311 : parent =WM8311 ; + wm831x->num_gpio =16 ;dev_info (wm831x->dev,"WM8311 revision %c\n" ,'A' + rev);break ;case WM8312 : parent =WM8312 ; + wm831x->num_gpio =16 ;dev_info (wm831x->dev,"WM8312 revision %c\n" ,'A' + rev);break ;
include/linux/mfd/wm831x/core.h +2 -0
@@ -253,6 +253,8 @@ struct wm831x {unsigned int irq_base;int irq_masks[5 ]; +int num_gpio; +struct mutex auxadc_lock;/* The WM831x has a security key blocking access to certain
Signature · 1 line
1.6.4.3
PATCH 3/4 power_supply: Factor out WM831x backup battery charger
The backup battery on WM831x is a separate IP block to the main PMU and is largely unrelated to the main supply functionality. Factor it out into a separate driver in order to reflect this and better support future hardware versions.
--- drivers/mfd/wm831x-core.c | 9 ++ drivers/power/Kconfig | 7 ++ drivers/power/Makefile | 1 + drivers/power/wm831x_backup.c | 233 +++++++++++++++++++++++++++++++++++++++++ drivers/power/wm831x_power.c | 144 +------------------------- 5 files changed, 253 insertions(+), 141 deletions(-) create mode 100644 drivers/power/wm831x_backup.c
drivers/mfd/wm831x-core.c +9 -0
@@ -794,6 +794,9 @@ static struct resource wm831x_wdt_resources[] = {static struct mfd_cell wm8310_devs[] = { { + .name ="wm831x-backup" , + }, + { .name ="wm831x-buckv" , .id =1 , .num_resources =ARRAY_SIZE (wm831x_dcdc1_resources),
@@ -947,6 +950,9 @@ static struct mfd_cell wm8310_devs[] = {static struct mfd_cell wm8311_devs[] = { { + .name ="wm831x-backup" , + }, + { .name ="wm831x-buckv" , .id =1 , .num_resources =ARRAY_SIZE (wm831x_dcdc1_resources),
@@ -1081,6 +1087,9 @@ static struct mfd_cell wm8311_devs[] = {static struct mfd_cell wm8312_devs[] = { { + .name ="wm831x-backup" , + }, + { .name ="wm831x-buckv" , .id =1 , .num_resources =ARRAY_SIZE (wm831x_dcdc1_resources),
drivers/power/Kconfig +7 -0
@@ -29,6 +29,13 @@ config APM_POWER Say Y here to enable support APM status emulation using battery class devices. +config WM831X_BACKUP + tristate "WM831X backup battery charger support" + depends on MFD_WM831X + help + Say Y here to enable support for the backup battery charger + in the Wolfson Microelectronics WM831x PMICs. + config WM831X_POWER tristate "WM831X PMU support" depends on MFD_WM831X
drivers/power/Makefile +1 -0
@@ -16,6 +16,7 @@ obj-$(CONFIG_POWER_SUPPLY) += power_supply.o obj-$(CONFIG_PDA_POWER) += pda_power.o obj-$(CONFIG_APM_POWER) += apm_power.o +obj-$(CONFIG_WM831X_BACKUP) += wm831x_backup.o obj-$(CONFIG_WM831X_POWER) += wm831x_power.o obj-$(CONFIG_WM8350_POWER) += wm8350_power.o
drivers/power/wm831x_backup.c new file +233 -0
233 lines not on this page · raw message
drivers/power/wm831x_power.c +3 -141
202 lines not on this page · raw message
Signature · 1 line
1.6.4.3
PATCH 4/4 mfd: Add support for WM8320 PMICs
The WM8320 is an integrated power management subsystem providing voltage regulators, RTC, watchdog and other functionality. The WM8320 is derived from the WM831x and therefore shares most of the driver code with the WM831x.
--- drivers/mfd/Kconfig | 6 +- drivers/mfd/wm831x-core.c | 159 +++++++++++++++++++++++++++++++++++++++ include/linux/mfd/wm831x/core.h | 1 + 3 files changed, 163 insertions(+), 3 deletions(-)
drivers/mfd/Kconfig +3 -3
@@ -171,12 +171,12 @@ config MFD_WM8400 the functionality of the device. config MFD_WM831X - tristate "Support Wolfson Microelectronics WM831x PMICs" + tristate "Support Wolfson Microelectronics WM831x/2x PMICs" select MFD_CORE depends on I2C help - Support for the Wolfson Microelecronics WM831x PMICs. This - driver provides common support for accessing the device, + Support for the Wolfson Microelecronics WM831x and WM832x PMICs. + This driver provides common support for accessing the device, additional drivers must be enabled in order to use the functionality of the device.
drivers/mfd/wm831x-core.c +159 -0
195 lines not on this page · raw message
include/linux/mfd/wm831x/core.h +1 -0
@@ -117,6 +117,7 @@#define WM831X_DC3_SLEEP_CONTROL 0x4063#define WM831X_DC4_CONTROL 0x4064#define WM831X_DC4_SLEEP_CONTROL 0x4065 +#define WM832X_DC4_SLEEP_CONTROL 0x4067#define WM831X_EPE1_CONTROL 0x4066#define WM831X_EPE2_CONTROL 0x4067#define WM831X_LDO1_CONTROL 0x4068
Signature · 1 line
1.6.4.3
Re: [PATCH 3/4] power_supply: Factor out WM831x backup battery charger
In reply to Mark BrownQuoted 7 lines · Mark Brown
The backup battery on WM831x is a separate IP block to the main PMU and is largely unrelated to the main supply functionality. Factor it out into a separate driver in order to reflect this and better support future hardware versions.
Signed-off-by Mark Brown <[email protected]>Cc Anton Vorontsov <[email protected]>
Looks good. Should I apply it, or it depends on 1/4 and 2/4?
Thanks,
Signature · 3 lines
Anton Vorontsov email: [email protected] irc://irc.freenode.net/bd2
Re: [PATCH 3/4] power_supply: Factor out WM831x backup battery charger
Quoted 1 line · Anton Vorontsov
Looks good. Should I apply it, or it depends on 1/4 and 2/4?
There should be no build time dependency so you should be able to apply it. It'd mean that the WM8320 won't get the backup battery charger instantiating until it's merged with the power tree but that's not a terribly big deal and it would avoid the possibility of any merge issues from a colliding Makefile/Kconfig change in drivers/power.
Samuel, do you have any preferences?
Re: [PATCH 3/4] power_supply: Factor out WM831x backup battery charger
Quoted 11 lines · Mark Brown
Quoted 1 line · Anton Vorontsov
Looks good. Should I apply it, or it depends on 1/4 and 2/4?
There should be no build time dependency so you should be able to apply it. It'd mean that the WM8320 won't get the backup battery charger instantiating until it's merged with the power tree but that's not a terribly big deal and it would avoid the possibility of any merge issues from a colliding Makefile/Kconfig change in
drivers/power.Samuel, do you have any preferences?
I'm fine with Anton taking it if that makes everyone's life easier. Anton, you can add my Acked-by for the mfd part, if you think that's necessary.
Cheers,
Samuel.
Signature · 2 lines
Intel Open Source Technology Centre http://oss.intel.com/
Re: [PATCH 3/4] power_supply: Factor out WM831x backup battery charger
Quoted 11 lines · Samuel Ortiz
Quoted 10 lines · Mark Brown
Quoted 1 line · Anton Vorontsov
Looks good. Should I apply it, or it depends on 1/4 and 2/4?
There should be no build time dependency so you should be able to apply it. It'd mean that the WM8320 won't get the backup battery charger instantiating until it's merged with the power tree but that's not a terribly big deal and it would avoid the possibility of any merge issues from a colliding Makefile/Kconfig change in
drivers/power.
Quoted 4 lines
Quoted 1 line
Samuel, do you have any preferences?
I'm fine with Anton taking it if that makes everyone's life easier. Anton, you can add my Acked-by for the mfd part, if you think that's necessary.
Great, thanks!
Signature · 3 lines
Anton Vorontsov email: [email protected] irc://irc.freenode.net/bd2
Hi Mark,
Quoted 3 lines · Mark Brown
Better support future device revisions by moving some of the output around and making the chip ID enumeration be the value expected in the ID register.
Patches 1,2 and 4 applied to my for-next branch, thanks a lot.
Cheers,
Samuel.
Quoted 99 lines
Signed-off-by Mark Brown <[email protected]>--- drivers/mfd/wm831x-core.c | 58 ++++++++++++++------------------------------- 1 files changed, 18 insertions(+), 40 deletions(-)drivers/mfd/wm831x-core.c +18
-40@@ -90,9 +90,9 @@ int wm831x_isinkv_values[WM831X_ISINK_MAX_ISEL] = {EXPORT_SYMBOL_GPL (wm831x_isinkv_values);enum wm831x_parent { -WM8310 =0 , -WM8311 =1 , -WM8312 =2 , +WM8310 =0x8310 , +WM8311 =0x8311 , +WM8312 =0x8312 , };static int wm831x_reg_locked (struct wm831x *wm831x,unsigned short reg)@@ -1282,50 +1282,28 @@ static int wm831x_device_init(struct wm831x *wm831x, unsigned long id, int irq) goto err; } +/* Some engineering samples do not have the ID set, rely on +* the device being registered correctly. +*/ +if (ret ==0 ) { +dev_info (wm831x->dev,"Device is an engineering sample\n" ); + ret = id; + } +switch (ret) { -case 0x8310 : +case WM8310 : parent =WM8310 ; -switch (rev) { -case 0 : -dev_info (wm831x->dev,"WM8310 revision %c\n" , -'A' + rev); -break ; - } +dev_info (wm831x->dev,"WM8310 revision %c\n" ,'A' + rev);break ; -case 0x8311 : +case WM8311 : parent =WM8311 ; -switch (rev) { -case 0 : -dev_info (wm831x->dev,"WM8311 revision %c\n" , -'A' + rev); -break ; - } +dev_info (wm831x->dev,"WM8311 revision %c\n" ,'A' + rev);break ; -case 0x8312 : +case WM8312 : parent =WM8312 ; -switch (rev) { -case 0 : -dev_info (wm831x->dev,"WM8312 revision %c\n" , -'A' + rev); -break ; - } -break ; - -case 0 : -/* Some engineering samples do not have the ID set, -* rely on the device being registered correctly. -* This will need revisiting for future devices with -* multiple dies. -*/ - parent = id; -switch (rev) { -case 0 : -dev_info (wm831x->dev,"WM831%d ES revision %c\n" , - parent,'A' + rev); -break ; - } +dev_info (wm831x->dev,"WM8312 revision %c\n" ,'A' + rev);break ;default :@@ -1338,7 +1316,7 @@ static int wm831x_device_init(struct wm831x *wm831x, unsigned long id, int irq)* current parts. */ if (parent != id) -dev_warn (wm831x->dev,"Device was registered as a WM831%lu\n" , +dev_warn (wm831x->dev,"Device was registered as a WM%lx\n" , id);/* Bootstrap the user key */ Signature · 1 line
1.6.4.3
Signature · 2 lines
Intel Open Source Technology Centre http://oss.intel.com/