Add regmap support for WM831x and WM8994
Subsystems (2)
cover Add regmap support for WM831x and WM8994
This series converts the WM831x and WM8994 MFD drivers over to using the regmap API (which was merged by Linus during this merge window). As these are my main devices for use when developing regmap it would be very helpful if I could merge them via the regmap tree - does that seem sensible to you?
The second patch (adding readback info to wm831x) depends on regmap API updates that aren't in mainline yet.
Mark Brown (3):
mfd: Convert WM831x to use regmap API
mfd: Provide regmap register readback info from wm831x driver
mfd: Convert WM8994 to use new register map API
drivers/mfd/Kconfig | 3 + drivers/mfd/wm831x-core.c | 263 ++++++++++++++++++++++++++++++--------- drivers/mfd/wm831x-i2c.c | 68 ++-------- drivers/mfd/wm831x-spi.c | 60 ++------- drivers/mfd/wm8994-core.c | 178 +++++--------------------- include/linux/mfd/wm831x/core.h | 9 +- include/linux/mfd/wm8994/core.h | 9 +- 7 files changed, 272 insertions(+), 318 deletions(-)
PATCH 1/3 mfd: Convert WM831x to use regmap API
Factor out the register read/write code to use the register map API. We still need some wm831x specific code and locking in place to check that the user key is handled correctly but only on the write side, reads are not affected by the key.
--- drivers/mfd/Kconfig | 2 + drivers/mfd/wm831x-core.c | 89 ++++++++++++-------------------------- drivers/mfd/wm831x-i2c.c | 68 +++++------------------------ drivers/mfd/wm831x-spi.c | 60 +++++--------------------- include/linux/mfd/wm831x/core.h | 9 ++-- 5 files changed, 58 insertions(+), 170 deletions(-)
drivers/mfd/Kconfig +2 -0
@@ -404,6 +404,7 @@ config MFD_WM831X_I2C bool "Support Wolfson Microelectronics WM831x/2x PMICs with I2C" select MFD_CORE select MFD_WM831X + select REGMAP_I2C depends on I2C=y && GENERIC_HARDIRQS help Support for the Wolfson Microelecronics WM831x and WM832x PMICs
@@ -415,6 +416,7 @@ config MFD_WM831X_SPI bool "Support Wolfson Microelectronics WM831x/2x PMICs with SPI" select MFD_CORE select MFD_WM831X + select REGMAP_SPI depends on SPI_MASTER && GENERIC_HARDIRQS help Support for the Wolfson Microelecronics WM831x and WM832x PMICs
drivers/mfd/wm831x-core.c +28 -61
205 lines not on this page · raw message
drivers/mfd/wm831x-i2c.c +12 -56
88 lines not on this page · raw message
drivers/mfd/wm831x-spi.c +12 -48
79 lines not on this page · raw message
include/linux/mfd/wm831x/core.h +4 -5
@@ -18,6 +18,7 @@#include <linux/completion.h> #include <linux/interrupt.h> #include <linux/list.h> +#include <linux/regmap.h> /* * Register values.
@@ -361,12 +362,8 @@ struct wm831x {struct mutex io_lock;struct device *dev; -int (*read_dev)(struct wm831x *wm831x,unsigned short reg, -int bytes,void *dest); -int (*write_dev)(struct wm831x *wm831x,unsigned short reg, -int bytes,void *src); -void *control_data; +struct regmap *regmap;int irq;/* Our chip IRQ */ struct mutex irq_lock;
@@ -416,4 +413,6 @@ int wm831x_irq_init(struct wm831x *wm831x, int irq);void wm831x_irq_exit (struct wm831x *wm831x);void wm831x_auxadc_init (struct wm831x *wm831x); +extern struct regmap_config wm831x_regmap_config; +#endif
Signature · 1 line
1.7.5.4
PATCH 2/3 mfd: Provide regmap register readback info from wm831x driver
Lets us see the register map in debugfs.
--- drivers/mfd/wm831x-core.c | 182 +++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 182 insertions(+), 0 deletions(-)
drivers/mfd/wm831x-core.c +182 -0
@@ -161,6 +161,185 @@ int wm831x_reg_unlock(struct wm831x *wm831x) }EXPORT_SYMBOL_GPL (wm831x_reg_unlock); +static bool wm831x_reg_readable (struct device *dev,unsigned int reg) +{ +switch (reg) { +case WM831X_RESET_ID : +case WM831X_REVISION : +case WM831X_PARENT_ID : +case WM831X_SYSVDD_CONTROL : +case WM831X_THERMAL_MONITORING : +case WM831X_POWER_STATE : +case WM831X_WATCHDOG : +case WM831X_ON_PIN_CONTROL : +case WM831X_RESET_CONTROL : +case WM831X_CONTROL_INTERFACE : +case WM831X_SECURITY_KEY : +case WM831X_SOFTWARE_SCRATCH : +case WM831X_OTP_CONTROL : +case WM831X_GPIO_LEVEL : +case WM831X_SYSTEM_STATUS : +case WM831X_ON_SOURCE : +case WM831X_OFF_SOURCE : +case WM831X_SYSTEM_INTERRUPTS : +case WM831X_INTERRUPT_STATUS_1 : +case WM831X_INTERRUPT_STATUS_2 : +case WM831X_INTERRUPT_STATUS_3 : +case WM831X_INTERRUPT_STATUS_4 : +case WM831X_INTERRUPT_STATUS_5 : +case WM831X_IRQ_CONFIG : +case WM831X_SYSTEM_INTERRUPTS_MASK : +case WM831X_INTERRUPT_STATUS_1_MASK : +case WM831X_INTERRUPT_STATUS_2_MASK : +case WM831X_INTERRUPT_STATUS_3_MASK : +case WM831X_INTERRUPT_STATUS_4_MASK : +case WM831X_INTERRUPT_STATUS_5_MASK : +case WM831X_RTC_WRITE_COUNTER : +case WM831X_RTC_TIME_1 : +case WM831X_RTC_TIME_2 : +case WM831X_RTC_ALARM_1 : +case WM831X_RTC_ALARM_2 : +case WM831X_RTC_CONTROL : +case WM831X_RTC_TRIM : +case WM831X_TOUCH_CONTROL_1 : +case WM831X_TOUCH_CONTROL_2 : +case WM831X_TOUCH_DATA_X : +case WM831X_TOUCH_DATA_Y : +case WM831X_TOUCH_DATA_Z : +case WM831X_AUXADC_DATA : +case WM831X_AUXADC_CONTROL : +case WM831X_AUXADC_SOURCE : +case WM831X_COMPARATOR_CONTROL : +case WM831X_COMPARATOR_1 : +case WM831X_COMPARATOR_2 : +case WM831X_COMPARATOR_3 : +case WM831X_COMPARATOR_4 : +case WM831X_GPIO1_CONTROL : +case WM831X_GPIO2_CONTROL : +case WM831X_GPIO3_CONTROL : +case WM831X_GPIO4_CONTROL : +case WM831X_GPIO5_CONTROL : +case WM831X_GPIO6_CONTROL : +case WM831X_GPIO7_CONTROL : +case WM831X_GPIO8_CONTROL : +case WM831X_GPIO9_CONTROL : +case WM831X_GPIO10_CONTROL : +case WM831X_GPIO11_CONTROL : +case WM831X_GPIO12_CONTROL : +case WM831X_GPIO13_CONTROL : +case WM831X_GPIO14_CONTROL : +case WM831X_GPIO15_CONTROL : +case WM831X_GPIO16_CONTROL : +case WM831X_CHARGER_CONTROL_1 : +case WM831X_CHARGER_CONTROL_2 : +case WM831X_CHARGER_STATUS : +case WM831X_BACKUP_CHARGER_CONTROL : +case WM831X_STATUS_LED_1 : +case WM831X_STATUS_LED_2 : +case WM831X_CURRENT_SINK_1 : +case WM831X_CURRENT_SINK_2 : +case WM831X_DCDC_ENABLE : +case WM831X_LDO_ENABLE : +case WM831X_DCDC_STATUS : +case WM831X_LDO_STATUS : +case WM831X_DCDC_UV_STATUS : +case WM831X_LDO_UV_STATUS : +case WM831X_DC1_CONTROL_1 : +case WM831X_DC1_CONTROL_2 : +case WM831X_DC1_ON_CONFIG : +case WM831X_DC1_SLEEP_CONTROL : +case WM831X_DC1_DVS_CONTROL : +case WM831X_DC2_CONTROL_1 : +case WM831X_DC2_CONTROL_2 : +case WM831X_DC2_ON_CONFIG : +case WM831X_DC2_SLEEP_CONTROL : +case WM831X_DC2_DVS_CONTROL : +case WM831X_DC3_CONTROL_1 : +case WM831X_DC3_CONTROL_2 : +case WM831X_DC3_ON_CONFIG : +case WM831X_DC3_SLEEP_CONTROL : +case WM831X_DC4_CONTROL : +case WM831X_DC4_SLEEP_CONTROL : +case WM831X_EPE1_CONTROL : +case WM831X_EPE2_CONTROL : +case WM831X_LDO1_CONTROL : +case WM831X_LDO1_ON_CONTROL : +case WM831X_LDO1_SLEEP_CONTROL : +case WM831X_LDO2_CONTROL : +case WM831X_LDO2_ON_CONTROL : +case WM831X_LDO2_SLEEP_CONTROL : +case WM831X_LDO3_CONTROL : +case WM831X_LDO3_ON_CONTROL : +case WM831X_LDO3_SLEEP_CONTROL : +case WM831X_LDO4_CONTROL : +case WM831X_LDO4_ON_CONTROL : +case WM831X_LDO4_SLEEP_CONTROL : +case WM831X_LDO5_CONTROL : +case WM831X_LDO5_ON_CONTROL : +case WM831X_LDO5_SLEEP_CONTROL : +case WM831X_LDO6_CONTROL : +case WM831X_LDO6_ON_CONTROL : +case WM831X_LDO6_SLEEP_CONTROL : +case WM831X_LDO7_CONTROL : +case WM831X_LDO7_ON_CONTROL : +case WM831X_LDO7_SLEEP_CONTROL : +case WM831X_LDO8_CONTROL : +case WM831X_LDO8_ON_CONTROL : +case WM831X_LDO8_SLEEP_CONTROL : +case WM831X_LDO9_CONTROL : +case WM831X_LDO9_ON_CONTROL : +case WM831X_LDO9_SLEEP_CONTROL : +case WM831X_LDO10_CONTROL : +case WM831X_LDO10_ON_CONTROL : +case WM831X_LDO10_SLEEP_CONTROL : +case WM831X_LDO11_ON_CONTROL : +case WM831X_LDO11_SLEEP_CONTROL : +case WM831X_POWER_GOOD_SOURCE_1 : +case WM831X_POWER_GOOD_SOURCE_2 : +case WM831X_CLOCK_CONTROL_1 : +case WM831X_CLOCK_CONTROL_2 : +case WM831X_FLL_CONTROL_1 : +case WM831X_FLL_CONTROL_2 : +case WM831X_FLL_CONTROL_3 : +case WM831X_FLL_CONTROL_4 : +case WM831X_FLL_CONTROL_5 : +case WM831X_UNIQUE_ID_1 : +case WM831X_UNIQUE_ID_2 : +case WM831X_UNIQUE_ID_3 : +case WM831X_UNIQUE_ID_4 : +case WM831X_UNIQUE_ID_5 : +case WM831X_UNIQUE_ID_6 : +case WM831X_UNIQUE_ID_7 : +case WM831X_UNIQUE_ID_8 : +case WM831X_FACTORY_OTP_ID : +case WM831X_FACTORY_OTP_1 : +case WM831X_FACTORY_OTP_2 : +case WM831X_FACTORY_OTP_3 : +case WM831X_FACTORY_OTP_4 : +case WM831X_FACTORY_OTP_5 : +case WM831X_CUSTOMER_OTP_ID : +case WM831X_DC1_OTP_CONTROL : +case WM831X_DC2_OTP_CONTROL : +case WM831X_DC3_OTP_CONTROL : +case WM831X_LDO1_2_OTP_CONTROL : +case WM831X_LDO3_4_OTP_CONTROL : +case WM831X_LDO5_6_OTP_CONTROL : +case WM831X_LDO7_8_OTP_CONTROL : +case WM831X_LDO9_10_OTP_CONTROL : +case WM831X_LDO11_EPE_CONTROL : +case WM831X_GPIO1_OTP_CONTROL : +case WM831X_GPIO2_OTP_CONTROL : +case WM831X_GPIO3_OTP_CONTROL : +case WM831X_GPIO4_OTP_CONTROL : +case WM831X_GPIO5_OTP_CONTROL : +case WM831X_GPIO6_OTP_CONTROL : +case WM831X_DBE_CHECK_DATA : +return true; +default : +return false; + } +} +/** * wm831x_reg_read: Read a single WM831x register. *
@@ -1254,6 +1433,9 @@ static struct mfd_cell backlight_devs[] = {struct regmap_config wm831x_regmap_config = { .reg_bits =16 , .val_bits =16 , + + .max_register =WM831X_DBE_CHECK_DATA , + .readable_reg = wm831x_reg_readable, };EXPORT_SYMBOL_GPL (wm831x_regmap_config);
Signature · 1 line
1.7.5.4
PATCH 3/3 mfd: Convert WM8994 to use new register map API
In reply to Mark Brown--- drivers/mfd/Kconfig | 1 + drivers/mfd/wm8994-core.c | 178 +++++++------------------------------- include/linux/mfd/wm8994/core.h | 9 +-- 3 files changed, 36 insertions(+), 152 deletions(-)
drivers/mfd/Kconfig +1 -0
@@ -490,6 +490,7 @@ config MFD_WM8350_I2C config MFD_WM8994 bool "Support Wolfson Microelectronics WM8994" select MFD_CORE + select REGMAP_I2C depends on I2C=y && GENERIC_HARDIRQS help The WM8994 is a highly integrated hi-fi CODEC designed for
drivers/mfd/wm8994-core.c +33 -145
298 lines not on this page · raw message
include/linux/mfd/wm8994/core.h +2 -7
@@ -24,6 +24,7 @@ enum wm8994_type {struct regulator_dev ;struct regulator_bulk_data ; +struct regmap ;#define WM8994_NUM_GPIO_REGS 11#define WM8994_NUM_LDO_REGS 2
@@ -50,18 +51,12 @@ struct regulator_bulk_data;#define WM8994_IRQ_GPIO (x) (x + WM8994_IRQ_TEMP_WARN)struct wm8994 { -struct mutex io_lock;struct mutex irq_lock;enum wm8994_type type;struct device *dev; -int (*read_dev)(struct wm8994 *wm8994,unsigned short reg, -int bytes,void *dest); -int (*write_dev)(struct wm8994 *wm8994,unsigned short reg, -int bytes,const void *src); - -void *control_data; +struct regmap *regmap;int gpio_base;int irq_base;
Signature · 1 line
1.7.5.4
Hi Mark,
Quoted 5 lines · Mark Brown
This series converts the WM831x and WM8994 MFD drivers over to using the regmap API (which was merged by Linus during this merge window). As these are my main devices for use when developing regmap it would be very helpful if I could merge them via the regmap tree - does that seem sensible to you?
Definitely, yes. Please add my:
to it.
Cheers,
Samuel.
Signature · 2 lines
Intel Open Source Technology Centre http://oss.intel.com/