aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mfd
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/mfd')
-rw-r--r--drivers/mfd/Kconfig3
-rw-r--r--drivers/mfd/jz4740-adc.c2
-rw-r--r--drivers/mfd/max8997.c5
-rw-r--r--drivers/mfd/menelaus.c2
-rw-r--r--drivers/mfd/omap-usb-host.c2
-rw-r--r--drivers/mfd/tps65910-irq.c2
-rw-r--r--drivers/mfd/twl4030-madc.c5
-rw-r--r--drivers/mfd/twl6040-core.c67
-rw-r--r--drivers/mfd/wm831x-core.c437
-rw-r--r--drivers/mfd/wm831x-i2c.c76
-rw-r--r--drivers/mfd/wm831x-spi.c204
-rw-r--r--drivers/mfd/wm8350-gpio.c4
-rw-r--r--drivers/mfd/wm8400-core.c106
-rw-r--r--drivers/mfd/wm8994-core.c205
14 files changed, 593 insertions, 527 deletions
diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index 21574bdf485..a67adcbd0fa 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -404,6 +404,7 @@ config MFD_WM831X_I2C
404 bool "Support Wolfson Microelectronics WM831x/2x PMICs with I2C" 404 bool "Support Wolfson Microelectronics WM831x/2x PMICs with I2C"
405 select MFD_CORE 405 select MFD_CORE
406 select MFD_WM831X 406 select MFD_WM831X
407 select REGMAP_I2C
407 depends on I2C=y && GENERIC_HARDIRQS 408 depends on I2C=y && GENERIC_HARDIRQS
408 help 409 help
409 Support for the Wolfson Microelecronics WM831x and WM832x PMICs 410 Support for the Wolfson Microelecronics WM831x and WM832x PMICs
@@ -415,6 +416,7 @@ config MFD_WM831X_SPI
415 bool "Support Wolfson Microelectronics WM831x/2x PMICs with SPI" 416 bool "Support Wolfson Microelectronics WM831x/2x PMICs with SPI"
416 select MFD_CORE 417 select MFD_CORE
417 select MFD_WM831X 418 select MFD_WM831X
419 select REGMAP_SPI
418 depends on SPI_MASTER && GENERIC_HARDIRQS 420 depends on SPI_MASTER && GENERIC_HARDIRQS
419 help 421 help
420 Support for the Wolfson Microelecronics WM831x and WM832x PMICs 422 Support for the Wolfson Microelecronics WM831x and WM832x PMICs
@@ -488,6 +490,7 @@ config MFD_WM8350_I2C
488config MFD_WM8994 490config MFD_WM8994
489 bool "Support Wolfson Microelectronics WM8994" 491 bool "Support Wolfson Microelectronics WM8994"
490 select MFD_CORE 492 select MFD_CORE
493 select REGMAP_I2C
491 depends on I2C=y && GENERIC_HARDIRQS 494 depends on I2C=y && GENERIC_HARDIRQS
492 help 495 help
493 The WM8994 is a highly integrated hi-fi CODEC designed for 496 The WM8994 is a highly integrated hi-fi CODEC designed for
diff --git a/drivers/mfd/jz4740-adc.c b/drivers/mfd/jz4740-adc.c
index 21131c7b0f1..563654c9b19 100644
--- a/drivers/mfd/jz4740-adc.c
+++ b/drivers/mfd/jz4740-adc.c
@@ -273,7 +273,7 @@ static int __devinit jz4740_adc_probe(struct platform_device *pdev)
273 ct->regs.ack = JZ_REG_ADC_STATUS; 273 ct->regs.ack = JZ_REG_ADC_STATUS;
274 ct->chip.irq_mask = irq_gc_mask_set_bit; 274 ct->chip.irq_mask = irq_gc_mask_set_bit;
275 ct->chip.irq_unmask = irq_gc_mask_clr_bit; 275 ct->chip.irq_unmask = irq_gc_mask_clr_bit;
276 ct->chip.irq_ack = irq_gc_ack; 276 ct->chip.irq_ack = irq_gc_ack_set_bit;
277 277
278 irq_setup_generic_chip(gc, IRQ_MSK(5), 0, 0, IRQ_NOPROBE | IRQ_LEVEL); 278 irq_setup_generic_chip(gc, IRQ_MSK(5), 0, 0, IRQ_NOPROBE | IRQ_LEVEL);
279 279
diff --git a/drivers/mfd/max8997.c b/drivers/mfd/max8997.c
index 5d1fca0277e..f83103b8970 100644
--- a/drivers/mfd/max8997.c
+++ b/drivers/mfd/max8997.c
@@ -135,10 +135,13 @@ static int max8997_i2c_probe(struct i2c_client *i2c,
135 max8997->dev = &i2c->dev; 135 max8997->dev = &i2c->dev;
136 max8997->i2c = i2c; 136 max8997->i2c = i2c;
137 max8997->type = id->driver_data; 137 max8997->type = id->driver_data;
138 max8997->irq = i2c->irq;
138 139
139 if (!pdata) 140 if (!pdata)
140 goto err; 141 goto err;
141 142
143 max8997->irq_base = pdata->irq_base;
144 max8997->ono = pdata->ono;
142 max8997->wakeup = pdata->wakeup; 145 max8997->wakeup = pdata->wakeup;
143 146
144 mutex_init(&max8997->iolock); 147 mutex_init(&max8997->iolock);
@@ -152,6 +155,8 @@ static int max8997_i2c_probe(struct i2c_client *i2c,
152 155
153 pm_runtime_set_active(max8997->dev); 156 pm_runtime_set_active(max8997->dev);
154 157
158 max8997_irq_init(max8997);
159
155 mfd_add_devices(max8997->dev, -1, max8997_devs, 160 mfd_add_devices(max8997->dev, -1, max8997_devs,
156 ARRAY_SIZE(max8997_devs), 161 ARRAY_SIZE(max8997_devs),
157 NULL, 0); 162 NULL, 0);
diff --git a/drivers/mfd/menelaus.c b/drivers/mfd/menelaus.c
index 9cee8e7f0bc..af5d9d06137 100644
--- a/drivers/mfd/menelaus.c
+++ b/drivers/mfd/menelaus.c
@@ -44,7 +44,7 @@
44 44
45#include <asm/mach/irq.h> 45#include <asm/mach/irq.h>
46 46
47#include <mach/gpio.h> 47#include <asm/gpio.h>
48#include <plat/menelaus.h> 48#include <plat/menelaus.h>
49 49
50#define DRIVER_NAME "menelaus" 50#define DRIVER_NAME "menelaus"
diff --git a/drivers/mfd/omap-usb-host.c b/drivers/mfd/omap-usb-host.c
index 29601e7d606..86e14583a08 100644
--- a/drivers/mfd/omap-usb-host.c
+++ b/drivers/mfd/omap-usb-host.c
@@ -17,6 +17,7 @@
17 * along with this program. If not, see <http://www.gnu.org/licenses/>. 17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */ 18 */
19#include <linux/kernel.h> 19#include <linux/kernel.h>
20#include <linux/module.h>
20#include <linux/types.h> 21#include <linux/types.h>
21#include <linux/slab.h> 22#include <linux/slab.h>
22#include <linux/delay.h> 23#include <linux/delay.h>
@@ -676,7 +677,6 @@ static void usbhs_omap_tll_init(struct device *dev, u8 tll_channel_count)
676 | OMAP_TLL_CHANNEL_CONF_ULPINOBITSTUFF 677 | OMAP_TLL_CHANNEL_CONF_ULPINOBITSTUFF
677 | OMAP_TLL_CHANNEL_CONF_ULPIDDRMODE); 678 | OMAP_TLL_CHANNEL_CONF_ULPIDDRMODE);
678 679
679 reg |= (1 << (i + 1));
680 } else 680 } else
681 continue; 681 continue;
682 682
diff --git a/drivers/mfd/tps65910-irq.c b/drivers/mfd/tps65910-irq.c
index 2bfad5c86cc..a56be931551 100644
--- a/drivers/mfd/tps65910-irq.c
+++ b/drivers/mfd/tps65910-irq.c
@@ -178,8 +178,10 @@ int tps65910_irq_init(struct tps65910 *tps65910, int irq,
178 switch (tps65910_chip_id(tps65910)) { 178 switch (tps65910_chip_id(tps65910)) {
179 case TPS65910: 179 case TPS65910:
180 tps65910->irq_num = TPS65910_NUM_IRQ; 180 tps65910->irq_num = TPS65910_NUM_IRQ;
181 break;
181 case TPS65911: 182 case TPS65911:
182 tps65910->irq_num = TPS65911_NUM_IRQ; 183 tps65910->irq_num = TPS65911_NUM_IRQ;
184 break;
183 } 185 }
184 186
185 /* Register with genirq */ 187 /* Register with genirq */
diff --git a/drivers/mfd/twl4030-madc.c b/drivers/mfd/twl4030-madc.c
index b5d598c3aa7..7cbf2aa9e64 100644
--- a/drivers/mfd/twl4030-madc.c
+++ b/drivers/mfd/twl4030-madc.c
@@ -510,8 +510,9 @@ int twl4030_madc_conversion(struct twl4030_madc_request *req)
510 u8 ch_msb, ch_lsb; 510 u8 ch_msb, ch_lsb;
511 int ret; 511 int ret;
512 512
513 if (!req) 513 if (!req || !twl4030_madc)
514 return -EINVAL; 514 return -EINVAL;
515
515 mutex_lock(&twl4030_madc->lock); 516 mutex_lock(&twl4030_madc->lock);
516 if (req->method < TWL4030_MADC_RT || req->method > TWL4030_MADC_SW2) { 517 if (req->method < TWL4030_MADC_RT || req->method > TWL4030_MADC_SW2) {
517 ret = -EINVAL; 518 ret = -EINVAL;
@@ -706,6 +707,8 @@ static int __devinit twl4030_madc_probe(struct platform_device *pdev)
706 if (!madc) 707 if (!madc)
707 return -ENOMEM; 708 return -ENOMEM;
708 709
710 madc->dev = &pdev->dev;
711
709 /* 712 /*
710 * Phoenix provides 2 interrupt lines. The first one is connected to 713 * Phoenix provides 2 interrupt lines. The first one is connected to
711 * the OMAP. The other one can be connected to the other processor such 714 * the OMAP. The other one can be connected to the other processor such
diff --git a/drivers/mfd/twl6040-core.c b/drivers/mfd/twl6040-core.c
index 24d436c2fe4..268f80fd043 100644
--- a/drivers/mfd/twl6040-core.c
+++ b/drivers/mfd/twl6040-core.c
@@ -34,7 +34,7 @@
34#include <linux/mfd/core.h> 34#include <linux/mfd/core.h>
35#include <linux/mfd/twl6040.h> 35#include <linux/mfd/twl6040.h>
36 36
37static struct platform_device *twl6040_dev; 37#define VIBRACTRL_MEMBER(reg) ((reg == TWL6040_REG_VIBCTLL) ? 0 : 1)
38 38
39int twl6040_reg_read(struct twl6040 *twl6040, unsigned int reg) 39int twl6040_reg_read(struct twl6040 *twl6040, unsigned int reg)
40{ 40{
@@ -42,10 +42,16 @@ int twl6040_reg_read(struct twl6040 *twl6040, unsigned int reg)
42 u8 val = 0; 42 u8 val = 0;
43 43
44 mutex_lock(&twl6040->io_mutex); 44 mutex_lock(&twl6040->io_mutex);
45 ret = twl_i2c_read_u8(TWL_MODULE_AUDIO_VOICE, &val, reg); 45 /* Vibra control registers from cache */
46 if (ret < 0) { 46 if (unlikely(reg == TWL6040_REG_VIBCTLL ||
47 mutex_unlock(&twl6040->io_mutex); 47 reg == TWL6040_REG_VIBCTLR)) {
48 return ret; 48 val = twl6040->vibra_ctrl_cache[VIBRACTRL_MEMBER(reg)];
49 } else {
50 ret = twl_i2c_read_u8(TWL_MODULE_AUDIO_VOICE, &val, reg);
51 if (ret < 0) {
52 mutex_unlock(&twl6040->io_mutex);
53 return ret;
54 }
49 } 55 }
50 mutex_unlock(&twl6040->io_mutex); 56 mutex_unlock(&twl6040->io_mutex);
51 57
@@ -59,6 +65,9 @@ int twl6040_reg_write(struct twl6040 *twl6040, unsigned int reg, u8 val)
59 65
60 mutex_lock(&twl6040->io_mutex); 66 mutex_lock(&twl6040->io_mutex);
61 ret = twl_i2c_write_u8(TWL_MODULE_AUDIO_VOICE, val, reg); 67 ret = twl_i2c_write_u8(TWL_MODULE_AUDIO_VOICE, val, reg);
68 /* Cache the vibra control registers */
69 if (reg == TWL6040_REG_VIBCTLL || reg == TWL6040_REG_VIBCTLR)
70 twl6040->vibra_ctrl_cache[VIBRACTRL_MEMBER(reg)] = val;
62 mutex_unlock(&twl6040->io_mutex); 71 mutex_unlock(&twl6040->io_mutex);
63 72
64 return ret; 73 return ret;
@@ -203,11 +212,11 @@ static irqreturn_t twl6040_naudint_handler(int irq, void *data)
203 if (intid & TWL6040_THINT) { 212 if (intid & TWL6040_THINT) {
204 status = twl6040_reg_read(twl6040, TWL6040_REG_STATUS); 213 status = twl6040_reg_read(twl6040, TWL6040_REG_STATUS);
205 if (status & TWL6040_TSHUTDET) { 214 if (status & TWL6040_TSHUTDET) {
206 dev_warn(&twl6040_dev->dev, 215 dev_warn(twl6040->dev,
207 "Thermal shutdown, powering-off"); 216 "Thermal shutdown, powering-off");
208 twl6040_power(twl6040, 0); 217 twl6040_power(twl6040, 0);
209 } else { 218 } else {
210 dev_warn(&twl6040_dev->dev, 219 dev_warn(twl6040->dev,
211 "Leaving thermal shutdown, powering-on"); 220 "Leaving thermal shutdown, powering-on");
212 twl6040_power(twl6040, 1); 221 twl6040_power(twl6040, 1);
213 } 222 }
@@ -227,7 +236,7 @@ static int twl6040_power_up_completion(struct twl6040 *twl6040,
227 if (!time_left) { 236 if (!time_left) {
228 intid = twl6040_reg_read(twl6040, TWL6040_REG_INTID); 237 intid = twl6040_reg_read(twl6040, TWL6040_REG_INTID);
229 if (!(intid & TWL6040_READYINT)) { 238 if (!(intid & TWL6040_READYINT)) {
230 dev_err(&twl6040_dev->dev, 239 dev_err(twl6040->dev,
231 "timeout waiting for READYINT\n"); 240 "timeout waiting for READYINT\n");
232 return -ETIMEDOUT; 241 return -ETIMEDOUT;
233 } 242 }
@@ -255,7 +264,7 @@ int twl6040_power(struct twl6040 *twl6040, int on)
255 /* wait for power-up completion */ 264 /* wait for power-up completion */
256 ret = twl6040_power_up_completion(twl6040, naudint); 265 ret = twl6040_power_up_completion(twl6040, naudint);
257 if (ret) { 266 if (ret) {
258 dev_err(&twl6040_dev->dev, 267 dev_err(twl6040->dev,
259 "automatic power-down failed\n"); 268 "automatic power-down failed\n");
260 twl6040->power_count = 0; 269 twl6040->power_count = 0;
261 goto out; 270 goto out;
@@ -264,7 +273,7 @@ int twl6040_power(struct twl6040 *twl6040, int on)
264 /* use manual power-up sequence */ 273 /* use manual power-up sequence */
265 ret = twl6040_power_up(twl6040); 274 ret = twl6040_power_up(twl6040);
266 if (ret) { 275 if (ret) {
267 dev_err(&twl6040_dev->dev, 276 dev_err(twl6040->dev,
268 "manual power-up failed\n"); 277 "manual power-up failed\n");
269 twl6040->power_count = 0; 278 twl6040->power_count = 0;
270 goto out; 279 goto out;
@@ -276,7 +285,7 @@ int twl6040_power(struct twl6040 *twl6040, int on)
276 } else { 285 } else {
277 /* already powered-down */ 286 /* already powered-down */
278 if (!twl6040->power_count) { 287 if (!twl6040->power_count) {
279 dev_err(&twl6040_dev->dev, 288 dev_err(twl6040->dev,
280 "device is already powered-off\n"); 289 "device is already powered-off\n");
281 ret = -EPERM; 290 ret = -EPERM;
282 goto out; 291 goto out;
@@ -326,7 +335,7 @@ int twl6040_set_pll(struct twl6040 *twl6040, int pll_id,
326 lppllctl &= ~TWL6040_LPLLFIN; 335 lppllctl &= ~TWL6040_LPLLFIN;
327 break; 336 break;
328 default: 337 default:
329 dev_err(&twl6040_dev->dev, 338 dev_err(twl6040->dev,
330 "freq_out %d not supported\n", freq_out); 339 "freq_out %d not supported\n", freq_out);
331 ret = -EINVAL; 340 ret = -EINVAL;
332 goto pll_out; 341 goto pll_out;
@@ -347,7 +356,7 @@ int twl6040_set_pll(struct twl6040 *twl6040, int pll_id,
347 hppllctl); 356 hppllctl);
348 break; 357 break;
349 default: 358 default:
350 dev_err(&twl6040_dev->dev, 359 dev_err(twl6040->dev,
351 "freq_in %d not supported\n", freq_in); 360 "freq_in %d not supported\n", freq_in);
352 ret = -EINVAL; 361 ret = -EINVAL;
353 goto pll_out; 362 goto pll_out;
@@ -356,7 +365,7 @@ int twl6040_set_pll(struct twl6040 *twl6040, int pll_id,
356 case TWL6040_SYSCLK_SEL_HPPLL: 365 case TWL6040_SYSCLK_SEL_HPPLL:
357 /* high-performance PLL can provide only 19.2 MHz */ 366 /* high-performance PLL can provide only 19.2 MHz */
358 if (freq_out != 19200000) { 367 if (freq_out != 19200000) {
359 dev_err(&twl6040_dev->dev, 368 dev_err(twl6040->dev,
360 "freq_out %d not supported\n", freq_out); 369 "freq_out %d not supported\n", freq_out);
361 ret = -EINVAL; 370 ret = -EINVAL;
362 goto pll_out; 371 goto pll_out;
@@ -389,7 +398,7 @@ int twl6040_set_pll(struct twl6040 *twl6040, int pll_id,
389 TWL6040_HPLLENA; 398 TWL6040_HPLLENA;
390 break; 399 break;
391 default: 400 default:
392 dev_err(&twl6040_dev->dev, 401 dev_err(twl6040->dev,
393 "freq_in %d not supported\n", freq_in); 402 "freq_in %d not supported\n", freq_in);
394 ret = -EINVAL; 403 ret = -EINVAL;
395 goto pll_out; 404 goto pll_out;
@@ -406,7 +415,7 @@ int twl6040_set_pll(struct twl6040 *twl6040, int pll_id,
406 twl6040_reg_write(twl6040, TWL6040_REG_LPPLLCTL, lppllctl); 415 twl6040_reg_write(twl6040, TWL6040_REG_LPPLLCTL, lppllctl);
407 break; 416 break;
408 default: 417 default:
409 dev_err(&twl6040_dev->dev, "unknown pll id %d\n", pll_id); 418 dev_err(twl6040->dev, "unknown pll id %d\n", pll_id);
410 ret = -EINVAL; 419 ret = -EINVAL;
411 goto pll_out; 420 goto pll_out;
412 } 421 }
@@ -435,6 +444,18 @@ unsigned int twl6040_get_sysclk(struct twl6040 *twl6040)
435} 444}
436EXPORT_SYMBOL(twl6040_get_sysclk); 445EXPORT_SYMBOL(twl6040_get_sysclk);
437 446
447/* Get the combined status of the vibra control register */
448int twl6040_get_vibralr_status(struct twl6040 *twl6040)
449{
450 u8 status;
451
452 status = twl6040->vibra_ctrl_cache[0] | twl6040->vibra_ctrl_cache[1];
453 status &= (TWL6040_VIBENA | TWL6040_VIBSEL);
454
455 return status;
456}
457EXPORT_SYMBOL(twl6040_get_vibralr_status);
458
438static struct resource twl6040_vibra_rsrc[] = { 459static struct resource twl6040_vibra_rsrc[] = {
439 { 460 {
440 .flags = IORESOURCE_IRQ, 461 .flags = IORESOURCE_IRQ,
@@ -471,9 +492,7 @@ static int __devinit twl6040_probe(struct platform_device *pdev)
471 492
472 platform_set_drvdata(pdev, twl6040); 493 platform_set_drvdata(pdev, twl6040);
473 494
474 twl6040_dev = pdev;
475 twl6040->dev = &pdev->dev; 495 twl6040->dev = &pdev->dev;
476 twl6040->audpwron = pdata->audpwron_gpio;
477 twl6040->irq = pdata->naudint_irq; 496 twl6040->irq = pdata->naudint_irq;
478 twl6040->irq_base = pdata->irq_base; 497 twl6040->irq_base = pdata->irq_base;
479 498
@@ -483,6 +502,12 @@ static int __devinit twl6040_probe(struct platform_device *pdev)
483 502
484 twl6040->rev = twl6040_reg_read(twl6040, TWL6040_REG_ASICREV); 503 twl6040->rev = twl6040_reg_read(twl6040, TWL6040_REG_ASICREV);
485 504
505 /* ERRATA: Automatic power-up is not possible in ES1.0 */
506 if (twl6040_get_revid(twl6040) > TWL6040_REV_ES1_0)
507 twl6040->audpwron = pdata->audpwron_gpio;
508 else
509 twl6040->audpwron = -EINVAL;
510
486 if (gpio_is_valid(twl6040->audpwron)) { 511 if (gpio_is_valid(twl6040->audpwron)) {
487 ret = gpio_request(twl6040->audpwron, "audpwron"); 512 ret = gpio_request(twl6040->audpwron, "audpwron");
488 if (ret) 513 if (ret)
@@ -493,10 +518,6 @@ static int __devinit twl6040_probe(struct platform_device *pdev)
493 goto gpio2_err; 518 goto gpio2_err;
494 } 519 }
495 520
496 /* ERRATA: Automatic power-up is not possible in ES1.0 */
497 if (twl6040->rev == TWL6040_REV_ES1_0)
498 twl6040->audpwron = -EINVAL;
499
500 /* codec interrupt */ 521 /* codec interrupt */
501 ret = twl6040_irq_init(twl6040); 522 ret = twl6040_irq_init(twl6040);
502 if (ret) 523 if (ret)
@@ -566,7 +587,6 @@ gpio2_err:
566gpio1_err: 587gpio1_err:
567 platform_set_drvdata(pdev, NULL); 588 platform_set_drvdata(pdev, NULL);
568 kfree(twl6040); 589 kfree(twl6040);
569 twl6040_dev = NULL;
570 return ret; 590 return ret;
571} 591}
572 592
@@ -586,7 +606,6 @@ static int __devexit twl6040_remove(struct platform_device *pdev)
586 mfd_remove_devices(&pdev->dev); 606 mfd_remove_devices(&pdev->dev);
587 platform_set_drvdata(pdev, NULL); 607 platform_set_drvdata(pdev, NULL);
588 kfree(twl6040); 608 kfree(twl6040);
589 twl6040_dev = NULL;
590 609
591 return 0; 610 return 0;
592} 611}
diff --git a/drivers/mfd/wm831x-core.c b/drivers/mfd/wm831x-core.c
index 282e76ab678..0a2b8d41a70 100644
--- a/drivers/mfd/wm831x-core.c
+++ b/drivers/mfd/wm831x-core.c
@@ -18,12 +18,14 @@
18#include <linux/delay.h> 18#include <linux/delay.h>
19#include <linux/mfd/core.h> 19#include <linux/mfd/core.h>
20#include <linux/slab.h> 20#include <linux/slab.h>
21#include <linux/err.h>
21 22
22#include <linux/mfd/wm831x/core.h> 23#include <linux/mfd/wm831x/core.h>
23#include <linux/mfd/wm831x/pdata.h> 24#include <linux/mfd/wm831x/pdata.h>
24#include <linux/mfd/wm831x/irq.h> 25#include <linux/mfd/wm831x/irq.h>
25#include <linux/mfd/wm831x/auxadc.h> 26#include <linux/mfd/wm831x/auxadc.h>
26#include <linux/mfd/wm831x/otp.h> 27#include <linux/mfd/wm831x/otp.h>
28#include <linux/mfd/wm831x/pmu.h>
27#include <linux/mfd/wm831x/regulator.h> 29#include <linux/mfd/wm831x/regulator.h>
28 30
29/* Current settings - values are 2*2^(reg_val/4) microamps. These are 31/* Current settings - values are 2*2^(reg_val/4) microamps. These are
@@ -160,27 +162,350 @@ int wm831x_reg_unlock(struct wm831x *wm831x)
160} 162}
161EXPORT_SYMBOL_GPL(wm831x_reg_unlock); 163EXPORT_SYMBOL_GPL(wm831x_reg_unlock);
162 164
163static int wm831x_read(struct wm831x *wm831x, unsigned short reg, 165static bool wm831x_reg_readable(struct device *dev, unsigned int reg)
164 int bytes, void *dest)
165{ 166{
166 int ret, i; 167 switch (reg) {
167 u16 *buf = dest; 168 case WM831X_RESET_ID:
168 169 case WM831X_REVISION:
169 BUG_ON(bytes % 2); 170 case WM831X_PARENT_ID:
170 BUG_ON(bytes <= 0); 171 case WM831X_SYSVDD_CONTROL:
172 case WM831X_THERMAL_MONITORING:
173 case WM831X_POWER_STATE:
174 case WM831X_WATCHDOG:
175 case WM831X_ON_PIN_CONTROL:
176 case WM831X_RESET_CONTROL:
177 case WM831X_CONTROL_INTERFACE:
178 case WM831X_SECURITY_KEY:
179 case WM831X_SOFTWARE_SCRATCH:
180 case WM831X_OTP_CONTROL:
181 case WM831X_GPIO_LEVEL:
182 case WM831X_SYSTEM_STATUS:
183 case WM831X_ON_SOURCE:
184 case WM831X_OFF_SOURCE:
185 case WM831X_SYSTEM_INTERRUPTS:
186 case WM831X_INTERRUPT_STATUS_1:
187 case WM831X_INTERRUPT_STATUS_2:
188 case WM831X_INTERRUPT_STATUS_3:
189 case WM831X_INTERRUPT_STATUS_4:
190 case WM831X_INTERRUPT_STATUS_5:
191 case WM831X_IRQ_CONFIG:
192 case WM831X_SYSTEM_INTERRUPTS_MASK:
193 case WM831X_INTERRUPT_STATUS_1_MASK:
194 case WM831X_INTERRUPT_STATUS_2_MASK:
195 case WM831X_INTERRUPT_STATUS_3_MASK:
196 case WM831X_INTERRUPT_STATUS_4_MASK:
197 case WM831X_INTERRUPT_STATUS_5_MASK:
198 case WM831X_RTC_WRITE_COUNTER:
199 case WM831X_RTC_TIME_1:
200 case WM831X_RTC_TIME_2:
201 case WM831X_RTC_ALARM_1:
202 case WM831X_RTC_ALARM_2:
203 case WM831X_RTC_CONTROL:
204 case WM831X_RTC_TRIM:
205 case WM831X_TOUCH_CONTROL_1:
206 case WM831X_TOUCH_CONTROL_2:
207 case WM831X_TOUCH_DATA_X:
208 case WM831X_TOUCH_DATA_Y:
209 case WM831X_TOUCH_DATA_Z:
210 case WM831X_AUXADC_DATA:
211 case WM831X_AUXADC_CONTROL:
212 case WM831X_AUXADC_SOURCE:
213 case WM831X_COMPARATOR_CONTROL:
214 case WM831X_COMPARATOR_1:
215 case WM831X_COMPARATOR_2:
216 case WM831X_COMPARATOR_3:
217 case WM831X_COMPARATOR_4:
218 case WM831X_GPIO1_CONTROL:
219 case WM831X_GPIO2_CONTROL:
220 case WM831X_GPIO3_CONTROL:
221 case WM831X_GPIO4_CONTROL:
222 case WM831X_GPIO5_CONTROL:
223 case WM831X_GPIO6_CONTROL:
224 case WM831X_GPIO7_CONTROL:
225 case WM831X_GPIO8_CONTROL:
226 case WM831X_GPIO9_CONTROL:
227 case WM831X_GPIO10_CONTROL:
228 case WM831X_GPIO11_CONTROL:
229 case WM831X_GPIO12_CONTROL:
230 case WM831X_GPIO13_CONTROL:
231 case WM831X_GPIO14_CONTROL:
232 case WM831X_GPIO15_CONTROL:
233 case WM831X_GPIO16_CONTROL:
234 case WM831X_CHARGER_CONTROL_1:
235 case WM831X_CHARGER_CONTROL_2:
236 case WM831X_CHARGER_STATUS:
237 case WM831X_BACKUP_CHARGER_CONTROL:
238 case WM831X_STATUS_LED_1:
239 case WM831X_STATUS_LED_2:
240 case WM831X_CURRENT_SINK_1:
241 case WM831X_CURRENT_SINK_2:
242 case WM831X_DCDC_ENABLE:
243 case WM831X_LDO_ENABLE:
244 case WM831X_DCDC_STATUS:
245 case WM831X_LDO_STATUS:
246 case WM831X_DCDC_UV_STATUS:
247 case WM831X_LDO_UV_STATUS:
248 case WM831X_DC1_CONTROL_1:
249 case WM831X_DC1_CONTROL_2:
250 case WM831X_DC1_ON_CONFIG:
251 case WM831X_DC1_SLEEP_CONTROL:
252 case WM831X_DC1_DVS_CONTROL:
253 case WM831X_DC2_CONTROL_1:
254 case WM831X_DC2_CONTROL_2:
255 case WM831X_DC2_ON_CONFIG:
256 case WM831X_DC2_SLEEP_CONTROL:
257 case WM831X_DC2_DVS_CONTROL:
258 case WM831X_DC3_CONTROL_1:
259 case WM831X_DC3_CONTROL_2:
260 case WM831X_DC3_ON_CONFIG:
261 case WM831X_DC3_SLEEP_CONTROL:
262 case WM831X_DC4_CONTROL:
263 case WM831X_DC4_SLEEP_CONTROL:
264 case WM831X_EPE1_CONTROL:
265 case WM831X_EPE2_CONTROL:
266 case WM831X_LDO1_CONTROL:
267 case WM831X_LDO1_ON_CONTROL:
268 case WM831X_LDO1_SLEEP_CONTROL:
269 case WM831X_LDO2_CONTROL:
270 case WM831X_LDO2_ON_CONTROL:
271 case WM831X_LDO2_SLEEP_CONTROL:
272 case WM831X_LDO3_CONTROL:
273 case WM831X_LDO3_ON_CONTROL:
274 case WM831X_LDO3_SLEEP_CONTROL:
275 case WM831X_LDO4_CONTROL:
276 case WM831X_LDO4_ON_CONTROL:
277 case WM831X_LDO4_SLEEP_CONTROL:
278 case WM831X_LDO5_CONTROL:
279 case WM831X_LDO5_ON_CONTROL:
280 case WM831X_LDO5_SLEEP_CONTROL:
281 case WM831X_LDO6_CONTROL:
282 case WM831X_LDO6_ON_CONTROL:
283 case WM831X_LDO6_SLEEP_CONTROL:
284 case WM831X_LDO7_CONTROL:
285 case WM831X_LDO7_ON_CONTROL:
286 case WM831X_LDO7_SLEEP_CONTROL:
287 case WM831X_LDO8_CONTROL:
288 case WM831X_LDO8_ON_CONTROL:
289 case WM831X_LDO8_SLEEP_CONTROL:
290 case WM831X_LDO9_CONTROL:
291 case WM831X_LDO9_ON_CONTROL:
292 case WM831X_LDO9_SLEEP_CONTROL:
293 case WM831X_LDO10_CONTROL:
294 case WM831X_LDO10_ON_CONTROL:
295 case WM831X_LDO10_SLEEP_CONTROL:
296 case WM831X_LDO11_ON_CONTROL:
297 case WM831X_LDO11_SLEEP_CONTROL:
298 case WM831X_POWER_GOOD_SOURCE_1:
299 case WM831X_POWER_GOOD_SOURCE_2:
300 case WM831X_CLOCK_CONTROL_1:
301 case WM831X_CLOCK_CONTROL_2:
302 case WM831X_FLL_CONTROL_1:
303 case WM831X_FLL_CONTROL_2:
304 case WM831X_FLL_CONTROL_3:
305 case WM831X_FLL_CONTROL_4:
306 case WM831X_FLL_CONTROL_5:
307 case WM831X_UNIQUE_ID_1:
308 case WM831X_UNIQUE_ID_2:
309 case WM831X_UNIQUE_ID_3:
310 case WM831X_UNIQUE_ID_4:
311 case WM831X_UNIQUE_ID_5:
312 case WM831X_UNIQUE_ID_6:
313 case WM831X_UNIQUE_ID_7:
314 case WM831X_UNIQUE_ID_8:
315 case WM831X_FACTORY_OTP_ID:
316 case WM831X_FACTORY_OTP_1:
317 case WM831X_FACTORY_OTP_2:
318 case WM831X_FACTORY_OTP_3:
319 case WM831X_FACTORY_OTP_4:
320 case WM831X_FACTORY_OTP_5:
321 case WM831X_CUSTOMER_OTP_ID:
322 case WM831X_DC1_OTP_CONTROL:
323 case WM831X_DC2_OTP_CONTROL:
324 case WM831X_DC3_OTP_CONTROL:
325 case WM831X_LDO1_2_OTP_CONTROL:
326 case WM831X_LDO3_4_OTP_CONTROL:
327 case WM831X_LDO5_6_OTP_CONTROL:
328 case WM831X_LDO7_8_OTP_CONTROL:
329 case WM831X_LDO9_10_OTP_CONTROL:
330 case WM831X_LDO11_EPE_CONTROL:
331 case WM831X_GPIO1_OTP_CONTROL:
332 case WM831X_GPIO2_OTP_CONTROL:
333 case WM831X_GPIO3_OTP_CONTROL:
334 case WM831X_GPIO4_OTP_CONTROL:
335 case WM831X_GPIO5_OTP_CONTROL:
336 case WM831X_GPIO6_OTP_CONTROL:
337 case WM831X_DBE_CHECK_DATA:
338 return true;
339 default:
340 return false;
341 }
342}
171 343
172 ret = wm831x->read_dev(wm831x, reg, bytes, dest); 344static bool wm831x_reg_writeable(struct device *dev, unsigned int reg)
173 if (ret < 0) 345{
174 return ret; 346 struct wm831x *wm831x = dev_get_drvdata(dev);
175 347
176 for (i = 0; i < bytes / 2; i++) { 348 if (wm831x_reg_locked(wm831x, reg))
177 buf[i] = be16_to_cpu(buf[i]); 349 return false;
178 350
179 dev_vdbg(wm831x->dev, "Read %04x from R%d(0x%x)\n", 351 switch (reg) {
180 buf[i], reg + i, reg + i); 352 case WM831X_SYSVDD_CONTROL:
353 case WM831X_THERMAL_MONITORING:
354 case WM831X_POWER_STATE:
355 case WM831X_WATCHDOG:
356 case WM831X_ON_PIN_CONTROL:
357 case WM831X_RESET_CONTROL:
358 case WM831X_CONTROL_INTERFACE:
359 case WM831X_SECURITY_KEY:
360 case WM831X_SOFTWARE_SCRATCH:
361 case WM831X_OTP_CONTROL:
362 case WM831X_GPIO_LEVEL:
363 case WM831X_INTERRUPT_STATUS_1:
364 case WM831X_INTERRUPT_STATUS_2:
365 case WM831X_INTERRUPT_STATUS_3:
366 case WM831X_INTERRUPT_STATUS_4:
367 case WM831X_INTERRUPT_STATUS_5:
368 case WM831X_IRQ_CONFIG:
369 case WM831X_SYSTEM_INTERRUPTS_MASK:
370 case WM831X_INTERRUPT_STATUS_1_MASK:
371 case WM831X_INTERRUPT_STATUS_2_MASK:
372 case WM831X_INTERRUPT_STATUS_3_MASK:
373 case WM831X_INTERRUPT_STATUS_4_MASK:
374 case WM831X_INTERRUPT_STATUS_5_MASK:
375 case WM831X_RTC_TIME_1:
376 case WM831X_RTC_TIME_2:
377 case WM831X_RTC_ALARM_1:
378 case WM831X_RTC_ALARM_2:
379 case WM831X_RTC_CONTROL:
380 case WM831X_RTC_TRIM:
381 case WM831X_TOUCH_CONTROL_1:
382 case WM831X_TOUCH_CONTROL_2:
383 case WM831X_AUXADC_CONTROL:
384 case WM831X_AUXADC_SOURCE:
385 case WM831X_COMPARATOR_CONTROL:
386 case WM831X_COMPARATOR_1:
387 case WM831X_COMPARATOR_2:
388 case WM831X_COMPARATOR_3:
389 case WM831X_COMPARATOR_4:
390 case WM831X_GPIO1_CONTROL:
391 case WM831X_GPIO2_CONTROL:
392 case WM831X_GPIO3_CONTROL:
393 case WM831X_GPIO4_CONTROL:
394 case WM831X_GPIO5_CONTROL:
395 case WM831X_GPIO6_CONTROL:
396 case WM831X_GPIO7_CONTROL:
397 case WM831X_GPIO8_CONTROL:
398 case WM831X_GPIO9_CONTROL:
399 case WM831X_GPIO10_CONTROL:
400 case WM831X_GPIO11_CONTROL:
401 case WM831X_GPIO12_CONTROL:
402 case WM831X_GPIO13_CONTROL:
403 case WM831X_GPIO14_CONTROL:
404 case WM831X_GPIO15_CONTROL:
405 case WM831X_GPIO16_CONTROL:
406 case WM831X_CHARGER_CONTROL_1:
407 case WM831X_CHARGER_CONTROL_2:
408 case WM831X_CHARGER_STATUS:
409 case WM831X_BACKUP_CHARGER_CONTROL:
410 case WM831X_STATUS_LED_1:
411 case WM831X_STATUS_LED_2:
412 case WM831X_CURRENT_SINK_1:
413 case WM831X_CURRENT_SINK_2:
414 case WM831X_DCDC_ENABLE:
415 case WM831X_LDO_ENABLE:
416 case WM831X_DC1_CONTROL_1:
417 case WM831X_DC1_CONTROL_2:
418 case WM831X_DC1_ON_CONFIG:
419 case WM831X_DC1_SLEEP_CONTROL:
420 case WM831X_DC1_DVS_CONTROL:
421 case WM831X_DC2_CONTROL_1:
422 case WM831X_DC2_CONTROL_2:
423 case WM831X_DC2_ON_CONFIG:
424 case WM831X_DC2_SLEEP_CONTROL:
425 case WM831X_DC2_DVS_CONTROL:
426 case WM831X_DC3_CONTROL_1:
427 case WM831X_DC3_CONTROL_2:
428 case WM831X_DC3_ON_CONFIG:
429 case WM831X_DC3_SLEEP_CONTROL:
430 case WM831X_DC4_CONTROL:
431 case WM831X_DC4_SLEEP_CONTROL:
432 case WM831X_EPE1_CONTROL:
433 case WM831X_EPE2_CONTROL:
434 case WM831X_LDO1_CONTROL:
435 case WM831X_LDO1_ON_CONTROL:
436 case WM831X_LDO1_SLEEP_CONTROL:
437 case WM831X_LDO2_CONTROL:
438 case WM831X_LDO2_ON_CONTROL:
439 case WM831X_LDO2_SLEEP_CONTROL:
440 case WM831X_LDO3_CONTROL:
441 case WM831X_LDO3_ON_CONTROL:
442 case WM831X_LDO3_SLEEP_CONTROL:
443 case WM831X_LDO4_CONTROL:
444 case WM831X_LDO4_ON_CONTROL:
445 case WM831X_LDO4_SLEEP_CONTROL:
446 case WM831X_LDO5_CONTROL:
447 case WM831X_LDO5_ON_CONTROL:
448 case WM831X_LDO5_SLEEP_CONTROL:
449 case WM831X_LDO6_CONTROL:
450 case WM831X_LDO6_ON_CONTROL:
451 case WM831X_LDO6_SLEEP_CONTROL:
452 case WM831X_LDO7_CONTROL:
453 case WM831X_LDO7_ON_CONTROL:
454 case WM831X_LDO7_SLEEP_CONTROL:
455 case WM831X_LDO8_CONTROL:
456 case WM831X_LDO8_ON_CONTROL:
457 case WM831X_LDO8_SLEEP_CONTROL:
458 case WM831X_LDO9_CONTROL:
459 case WM831X_LDO9_ON_CONTROL:
460 case WM831X_LDO9_SLEEP_CONTROL:
461 case WM831X_LDO10_CONTROL:
462 case WM831X_LDO10_ON_CONTROL:
463 case WM831X_LDO10_SLEEP_CONTROL:
464 case WM831X_LDO11_ON_CONTROL:
465 case WM831X_LDO11_SLEEP_CONTROL:
466 case WM831X_POWER_GOOD_SOURCE_1:
467 case WM831X_POWER_GOOD_SOURCE_2:
468 case WM831X_CLOCK_CONTROL_1:
469 case WM831X_CLOCK_CONTROL_2:
470 case WM831X_FLL_CONTROL_1:
471 case WM831X_FLL_CONTROL_2:
472 case WM831X_FLL_CONTROL_3:
473 case WM831X_FLL_CONTROL_4:
474 case WM831X_FLL_CONTROL_5:
475 return true;
476 default:
477 return false;
181 } 478 }
479}
182 480
183 return 0; 481static bool wm831x_reg_volatile(struct device *dev, unsigned int reg)
482{
483 switch (reg) {
484 case WM831X_SYSTEM_STATUS:
485 case WM831X_ON_SOURCE:
486 case WM831X_OFF_SOURCE:
487 case WM831X_GPIO_LEVEL:
488 case WM831X_SYSTEM_INTERRUPTS:
489 case WM831X_INTERRUPT_STATUS_1:
490 case WM831X_INTERRUPT_STATUS_2:
491 case WM831X_INTERRUPT_STATUS_3:
492 case WM831X_INTERRUPT_STATUS_4:
493 case WM831X_INTERRUPT_STATUS_5:
494 case WM831X_RTC_TIME_1:
495 case WM831X_RTC_TIME_2:
496 case WM831X_TOUCH_DATA_X:
497 case WM831X_TOUCH_DATA_Y:
498 case WM831X_TOUCH_DATA_Z:
499 case WM831X_AUXADC_DATA:
500 case WM831X_CHARGER_STATUS:
501 case WM831X_DCDC_STATUS:
502 case WM831X_LDO_STATUS:
503 case WM831X_DCDC_UV_STATUS:
504 case WM831X_LDO_UV_STATUS:
505 return true;
506 default:
507 return false;
508 }
184} 509}
185 510
186/** 511/**
@@ -191,14 +516,10 @@ static int wm831x_read(struct wm831x *wm831x, unsigned short reg,
191 */ 516 */
192int wm831x_reg_read(struct wm831x *wm831x, unsigned short reg) 517int wm831x_reg_read(struct wm831x *wm831x, unsigned short reg)
193{ 518{
194 unsigned short val; 519 unsigned int val;
195 int ret; 520 int ret;
196 521
197 mutex_lock(&wm831x->io_lock); 522 ret = regmap_read(wm831x->regmap, reg, &val);
198
199 ret = wm831x_read(wm831x, reg, 2, &val);
200
201 mutex_unlock(&wm831x->io_lock);
202 523
203 if (ret < 0) 524 if (ret < 0)
204 return ret; 525 return ret;
@@ -218,15 +539,7 @@ EXPORT_SYMBOL_GPL(wm831x_reg_read);
218int wm831x_bulk_read(struct wm831x *wm831x, unsigned short reg, 539int wm831x_bulk_read(struct wm831x *wm831x, unsigned short reg,
219 int count, u16 *buf) 540 int count, u16 *buf)
220{ 541{
221 int ret; 542 return regmap_bulk_read(wm831x->regmap, reg, buf, count);
222
223 mutex_lock(&wm831x->io_lock);
224
225 ret = wm831x_read(wm831x, reg, count * 2, buf);
226
227 mutex_unlock(&wm831x->io_lock);
228
229 return ret;
230} 543}
231EXPORT_SYMBOL_GPL(wm831x_bulk_read); 544EXPORT_SYMBOL_GPL(wm831x_bulk_read);
232 545
@@ -234,7 +547,7 @@ static int wm831x_write(struct wm831x *wm831x, unsigned short reg,
234 int bytes, void *src) 547 int bytes, void *src)
235{ 548{
236 u16 *buf = src; 549 u16 *buf = src;
237 int i; 550 int i, ret;
238 551
239 BUG_ON(bytes % 2); 552 BUG_ON(bytes % 2);
240 BUG_ON(bytes <= 0); 553 BUG_ON(bytes <= 0);
@@ -245,11 +558,10 @@ static int wm831x_write(struct wm831x *wm831x, unsigned short reg,
245 558
246 dev_vdbg(wm831x->dev, "Write %04x to R%d(0x%x)\n", 559 dev_vdbg(wm831x->dev, "Write %04x to R%d(0x%x)\n",
247 buf[i], reg + i, reg + i); 560 buf[i], reg + i, reg + i);
248 561 ret = regmap_write(wm831x->regmap, reg + i, buf[i]);
249 buf[i] = cpu_to_be16(buf[i]);
250 } 562 }
251 563
252 return wm831x->write_dev(wm831x, reg, bytes, src); 564 return 0;
253} 565}
254 566
255/** 567/**
@@ -286,20 +598,14 @@ int wm831x_set_bits(struct wm831x *wm831x, unsigned short reg,
286 unsigned short mask, unsigned short val) 598 unsigned short mask, unsigned short val)
287{ 599{
288 int ret; 600 int ret;
289 u16 r;
290 601
291 mutex_lock(&wm831x->io_lock); 602 mutex_lock(&wm831x->io_lock);
292 603
293 ret = wm831x_read(wm831x, reg, 2, &r); 604 if (!wm831x_reg_locked(wm831x, reg))
294 if (ret < 0) 605 ret = regmap_update_bits(wm831x->regmap, reg, mask, val);
295 goto out; 606 else
296 607 ret = -EPERM;
297 r &= ~mask;
298 r |= val & mask;
299
300 ret = wm831x_write(wm831x, reg, 2, &r);
301 608
302out:
303 mutex_unlock(&wm831x->io_lock); 609 mutex_unlock(&wm831x->io_lock);
304 610
305 return ret; 611 return ret;
@@ -1292,6 +1598,19 @@ static struct mfd_cell backlight_devs[] = {
1292 }, 1598 },
1293}; 1599};
1294 1600
1601struct regmap_config wm831x_regmap_config = {
1602 .reg_bits = 16,
1603 .val_bits = 16,
1604
1605 .cache_type = REGCACHE_RBTREE,
1606
1607 .max_register = WM831X_DBE_CHECK_DATA,
1608 .readable_reg = wm831x_reg_readable,
1609 .writeable_reg = wm831x_reg_writeable,
1610 .volatile_reg = wm831x_reg_volatile,
1611};
1612EXPORT_SYMBOL_GPL(wm831x_regmap_config);
1613
1295/* 1614/*
1296 * Instantiate the generic non-control parts of the device. 1615 * Instantiate the generic non-control parts of the device.
1297 */ 1616 */
@@ -1305,11 +1624,12 @@ int wm831x_device_init(struct wm831x *wm831x, unsigned long id, int irq)
1305 mutex_init(&wm831x->io_lock); 1624 mutex_init(&wm831x->io_lock);
1306 mutex_init(&wm831x->key_lock); 1625 mutex_init(&wm831x->key_lock);
1307 dev_set_drvdata(wm831x->dev, wm831x); 1626 dev_set_drvdata(wm831x->dev, wm831x);
1627 wm831x->soft_shutdown = pdata->soft_shutdown;
1308 1628
1309 ret = wm831x_reg_read(wm831x, WM831X_PARENT_ID); 1629 ret = wm831x_reg_read(wm831x, WM831X_PARENT_ID);
1310 if (ret < 0) { 1630 if (ret < 0) {
1311 dev_err(wm831x->dev, "Failed to read parent ID: %d\n", ret); 1631 dev_err(wm831x->dev, "Failed to read parent ID: %d\n", ret);
1312 goto err; 1632 goto err_regmap;
1313 } 1633 }
1314 switch (ret) { 1634 switch (ret) {
1315 case 0x6204: 1635 case 0x6204:
@@ -1318,20 +1638,20 @@ int wm831x_device_init(struct wm831x *wm831x, unsigned long id, int irq)
1318 default: 1638 default:
1319 dev_err(wm831x->dev, "Device is not a WM831x: ID %x\n", ret); 1639 dev_err(wm831x->dev, "Device is not a WM831x: ID %x\n", ret);
1320 ret = -EINVAL; 1640 ret = -EINVAL;
1321 goto err; 1641 goto err_regmap;
1322 } 1642 }
1323 1643
1324 ret = wm831x_reg_read(wm831x, WM831X_REVISION); 1644 ret = wm831x_reg_read(wm831x, WM831X_REVISION);
1325 if (ret < 0) { 1645 if (ret < 0) {
1326 dev_err(wm831x->dev, "Failed to read revision: %d\n", ret); 1646 dev_err(wm831x->dev, "Failed to read revision: %d\n", ret);
1327 goto err; 1647 goto err_regmap;
1328 } 1648 }
1329 rev = (ret & WM831X_PARENT_REV_MASK) >> WM831X_PARENT_REV_SHIFT; 1649 rev = (ret & WM831X_PARENT_REV_MASK) >> WM831X_PARENT_REV_SHIFT;
1330 1650
1331 ret = wm831x_reg_read(wm831x, WM831X_RESET_ID); 1651 ret = wm831x_reg_read(wm831x, WM831X_RESET_ID);
1332 if (ret < 0) { 1652 if (ret < 0) {
1333 dev_err(wm831x->dev, "Failed to read device ID: %d\n", ret); 1653 dev_err(wm831x->dev, "Failed to read device ID: %d\n", ret);
1334 goto err; 1654 goto err_regmap;
1335 } 1655 }
1336 1656
1337 /* Some engineering samples do not have the ID set, rely on 1657 /* Some engineering samples do not have the ID set, rely on
@@ -1406,7 +1726,7 @@ int wm831x_device_init(struct wm831x *wm831x, unsigned long id, int irq)
1406 default: 1726 default:
1407 dev_err(wm831x->dev, "Unknown WM831x device %04x\n", ret); 1727 dev_err(wm831x->dev, "Unknown WM831x device %04x\n", ret);
1408 ret = -EINVAL; 1728 ret = -EINVAL;
1409 goto err; 1729 goto err_regmap;
1410 } 1730 }
1411 1731
1412 /* This will need revisiting in future but is OK for all 1732 /* This will need revisiting in future but is OK for all
@@ -1420,7 +1740,7 @@ int wm831x_device_init(struct wm831x *wm831x, unsigned long id, int irq)
1420 ret = wm831x_reg_read(wm831x, WM831X_SECURITY_KEY); 1740 ret = wm831x_reg_read(wm831x, WM831X_SECURITY_KEY);
1421 if (ret < 0) { 1741 if (ret < 0) {
1422 dev_err(wm831x->dev, "Failed to read security key: %d\n", ret); 1742 dev_err(wm831x->dev, "Failed to read security key: %d\n", ret);
1423 goto err; 1743 goto err_regmap;
1424 } 1744 }
1425 if (ret != 0) { 1745 if (ret != 0) {
1426 dev_warn(wm831x->dev, "Security key had non-zero value %x\n", 1746 dev_warn(wm831x->dev, "Security key had non-zero value %x\n",
@@ -1433,7 +1753,7 @@ int wm831x_device_init(struct wm831x *wm831x, unsigned long id, int irq)
1433 ret = pdata->pre_init(wm831x); 1753 ret = pdata->pre_init(wm831x);
1434 if (ret != 0) { 1754 if (ret != 0) {
1435 dev_err(wm831x->dev, "pre_init() failed: %d\n", ret); 1755 dev_err(wm831x->dev, "pre_init() failed: %d\n", ret);
1436 goto err; 1756 goto err_regmap;
1437 } 1757 }
1438 } 1758 }
1439 1759
@@ -1456,7 +1776,7 @@ int wm831x_device_init(struct wm831x *wm831x, unsigned long id, int irq)
1456 1776
1457 ret = wm831x_irq_init(wm831x, irq); 1777 ret = wm831x_irq_init(wm831x, irq);
1458 if (ret != 0) 1778 if (ret != 0)
1459 goto err; 1779 goto err_regmap;
1460 1780
1461 wm831x_auxadc_init(wm831x); 1781 wm831x_auxadc_init(wm831x);
1462 1782
@@ -1552,8 +1872,9 @@ int wm831x_device_init(struct wm831x *wm831x, unsigned long id, int irq)
1552 1872
1553err_irq: 1873err_irq:
1554 wm831x_irq_exit(wm831x); 1874 wm831x_irq_exit(wm831x);
1555err: 1875err_regmap:
1556 mfd_remove_devices(wm831x->dev); 1876 mfd_remove_devices(wm831x->dev);
1877 regmap_exit(wm831x->regmap);
1557 kfree(wm831x); 1878 kfree(wm831x);
1558 return ret; 1879 return ret;
1559} 1880}
@@ -1565,6 +1886,7 @@ void wm831x_device_exit(struct wm831x *wm831x)
1565 if (wm831x->irq_base) 1886 if (wm831x->irq_base)
1566 free_irq(wm831x->irq_base + WM831X_IRQ_AUXADC_DATA, wm831x); 1887 free_irq(wm831x->irq_base + WM831X_IRQ_AUXADC_DATA, wm831x);
1567 wm831x_irq_exit(wm831x); 1888 wm831x_irq_exit(wm831x);
1889 regmap_exit(wm831x->regmap);
1568 kfree(wm831x); 1890 kfree(wm831x);
1569} 1891}
1570 1892
@@ -1604,6 +1926,15 @@ int wm831x_device_suspend(struct wm831x *wm831x)
1604 return 0; 1926 return 0;
1605} 1927}
1606 1928
1929void wm831x_device_shutdown(struct wm831x *wm831x)
1930{
1931 if (wm831x->soft_shutdown) {
1932 dev_info(wm831x->dev, "Initiating shutdown...\n");
1933 wm831x_set_bits(wm831x, WM831X_POWER_STATE, WM831X_CHIP_ON, 0);
1934 }
1935}
1936EXPORT_SYMBOL_GPL(wm831x_device_shutdown);
1937
1607MODULE_DESCRIPTION("Core support for the WM831X AudioPlus PMIC"); 1938MODULE_DESCRIPTION("Core support for the WM831X AudioPlus PMIC");
1608MODULE_LICENSE("GPL"); 1939MODULE_LICENSE("GPL");
1609MODULE_AUTHOR("Mark Brown"); 1940MODULE_AUTHOR("Mark Brown");
diff --git a/drivers/mfd/wm831x-i2c.c b/drivers/mfd/wm831x-i2c.c
index a06cbc73971..ac8da1d439d 100644
--- a/drivers/mfd/wm831x-i2c.c
+++ b/drivers/mfd/wm831x-i2c.c
@@ -18,67 +18,17 @@
18#include <linux/delay.h> 18#include <linux/delay.h>
19#include <linux/mfd/core.h> 19#include <linux/mfd/core.h>
20#include <linux/slab.h> 20#include <linux/slab.h>
21#include <linux/err.h>
22#include <linux/regmap.h>
21 23
22#include <linux/mfd/wm831x/core.h> 24#include <linux/mfd/wm831x/core.h>
23#include <linux/mfd/wm831x/pdata.h> 25#include <linux/mfd/wm831x/pdata.h>
24 26
25static int wm831x_i2c_read_device(struct wm831x *wm831x, unsigned short reg,
26 int bytes, void *dest)
27{
28 struct i2c_client *i2c = wm831x->control_data;
29 int ret;
30 u16 r = cpu_to_be16(reg);
31
32 ret = i2c_master_send(i2c, (unsigned char *)&r, 2);
33 if (ret < 0)
34 return ret;
35 if (ret != 2)
36 return -EIO;
37
38 ret = i2c_master_recv(i2c, dest, bytes);
39 if (ret < 0)
40 return ret;
41 if (ret != bytes)
42 return -EIO;
43 return 0;
44}
45
46/* Currently we allocate the write buffer on the stack; this is OK for
47 * small writes - if we need to do large writes this will need to be
48 * revised.
49 */
50static int wm831x_i2c_write_device(struct wm831x *wm831x, unsigned short reg,
51 int bytes, void *src)
52{
53 struct i2c_client *i2c = wm831x->control_data;
54 struct i2c_msg xfer[2];
55 int ret;
56
57 reg = cpu_to_be16(reg);
58
59 xfer[0].addr = i2c->addr;
60 xfer[0].flags = 0;
61 xfer[0].len = 2;
62 xfer[0].buf = (char *)&reg;
63
64 xfer[1].addr = i2c->addr;
65 xfer[1].flags = I2C_M_NOSTART;
66 xfer[1].len = bytes;
67 xfer[1].buf = (char *)src;
68
69 ret = i2c_transfer(i2c->adapter, xfer, 2);
70 if (ret < 0)
71 return ret;
72 if (ret != 2)
73 return -EIO;
74
75 return 0;
76}
77
78static int wm831x_i2c_probe(struct i2c_client *i2c, 27static int wm831x_i2c_probe(struct i2c_client *i2c,
79 const struct i2c_device_id *id) 28 const struct i2c_device_id *id)
80{ 29{
81 struct wm831x *wm831x; 30 struct wm831x *wm831x;
31 int ret;
82 32
83 wm831x = kzalloc(sizeof(struct wm831x), GFP_KERNEL); 33 wm831x = kzalloc(sizeof(struct wm831x), GFP_KERNEL);
84 if (wm831x == NULL) 34 if (wm831x == NULL)
@@ -86,9 +36,15 @@ static int wm831x_i2c_probe(struct i2c_client *i2c,
86 36
87 i2c_set_clientdata(i2c, wm831x); 37 i2c_set_clientdata(i2c, wm831x);
88 wm831x->dev = &i2c->dev; 38 wm831x->dev = &i2c->dev;
89 wm831x->control_data = i2c; 39
90 wm831x->read_dev = wm831x_i2c_read_device; 40 wm831x->regmap = regmap_init_i2c(i2c, &wm831x_regmap_config);
91 wm831x->write_dev = wm831x_i2c_write_device; 41 if (IS_ERR(wm831x->regmap)) {
42 ret = PTR_ERR(wm831x->regmap);
43 dev_err(wm831x->dev, "Failed to allocate register map: %d\n",
44 ret);
45 kfree(wm831x);
46 return ret;
47 }
92 48
93 return wm831x_device_init(wm831x, id->driver_data, i2c->irq); 49 return wm831x_device_init(wm831x, id->driver_data, i2c->irq);
94} 50}
@@ -109,6 +65,13 @@ static int wm831x_i2c_suspend(struct device *dev)
109 return wm831x_device_suspend(wm831x); 65 return wm831x_device_suspend(wm831x);
110} 66}
111 67
68static void wm831x_i2c_shutdown(struct i2c_client *i2c)
69{
70 struct wm831x *wm831x = i2c_get_clientdata(i2c);
71
72 wm831x_device_shutdown(wm831x);
73}
74
112static const struct i2c_device_id wm831x_i2c_id[] = { 75static const struct i2c_device_id wm831x_i2c_id[] = {
113 { "wm8310", WM8310 }, 76 { "wm8310", WM8310 },
114 { "wm8311", WM8311 }, 77 { "wm8311", WM8311 },
@@ -133,6 +96,7 @@ static struct i2c_driver wm831x_i2c_driver = {
133 }, 96 },
134 .probe = wm831x_i2c_probe, 97 .probe = wm831x_i2c_probe,
135 .remove = wm831x_i2c_remove, 98 .remove = wm831x_i2c_remove,
99 .shutdown = wm831x_i2c_shutdown,
136 .id_table = wm831x_i2c_id, 100 .id_table = wm831x_i2c_id,
137}; 101};
138 102
diff --git a/drivers/mfd/wm831x-spi.c b/drivers/mfd/wm831x-spi.c
index eed8e4f7a5a..8d6a9a969db 100644
--- a/drivers/mfd/wm831x-spi.c
+++ b/drivers/mfd/wm831x-spi.c
@@ -16,78 +16,19 @@
16#include <linux/module.h> 16#include <linux/module.h>
17#include <linux/pm.h> 17#include <linux/pm.h>
18#include <linux/spi/spi.h> 18#include <linux/spi/spi.h>
19#include <linux/regmap.h>
20#include <linux/err.h>
19 21
20#include <linux/mfd/wm831x/core.h> 22#include <linux/mfd/wm831x/core.h>
21 23
22static int wm831x_spi_read_device(struct wm831x *wm831x, unsigned short reg,
23 int bytes, void *dest)
24{
25 u16 tx_val;
26 u16 *d = dest;
27 int r, ret;
28
29 /* Go register at a time */
30 for (r = reg; r < reg + (bytes / 2); r++) {
31 tx_val = r | 0x8000;
32
33 ret = spi_write_then_read(wm831x->control_data,
34 (u8 *)&tx_val, 2, (u8 *)d, 2);
35 if (ret != 0)
36 return ret;
37
38 *d = be16_to_cpu(*d);
39
40 d++;
41 }
42
43 return 0;
44}
45
46static int wm831x_spi_write_device(struct wm831x *wm831x, unsigned short reg,
47 int bytes, void *src)
48{
49 struct spi_device *spi = wm831x->control_data;
50 u16 *s = src;
51 u16 data[2];
52 int ret, r;
53
54 /* Go register at a time */
55 for (r = reg; r < reg + (bytes / 2); r++) {
56 data[0] = r;
57 data[1] = *s++;
58
59 ret = spi_write(spi, (char *)&data, sizeof(data));
60 if (ret != 0)
61 return ret;
62 }
63
64 return 0;
65}
66
67static int __devinit wm831x_spi_probe(struct spi_device *spi) 24static int __devinit wm831x_spi_probe(struct spi_device *spi)
68{ 25{
26 const struct spi_device_id *id = spi_get_device_id(spi);
69 struct wm831x *wm831x; 27 struct wm831x *wm831x;
70 enum wm831x_parent type; 28 enum wm831x_parent type;
29 int ret;
71 30
72 /* Currently SPI support for ID tables is unmerged, we're faking it */ 31 type = (enum wm831x_parent)id->driver_data;
73 if (strcmp(spi->modalias, "wm8310") == 0)
74 type = WM8310;
75 else if (strcmp(spi->modalias, "wm8311") == 0)
76 type = WM8311;
77 else if (strcmp(spi->modalias, "wm8312") == 0)
78 type = WM8312;
79 else if (strcmp(spi->modalias, "wm8320") == 0)
80 type = WM8320;
81 else if (strcmp(spi->modalias, "wm8321") == 0)
82 type = WM8321;
83 else if (strcmp(spi->modalias, "wm8325") == 0)
84 type = WM8325;
85 else if (strcmp(spi->modalias, "wm8326") == 0)
86 type = WM8326;
87 else {
88 dev_err(&spi->dev, "Unknown device type\n");
89 return -EINVAL;
90 }
91 32
92 wm831x = kzalloc(sizeof(struct wm831x), GFP_KERNEL); 33 wm831x = kzalloc(sizeof(struct wm831x), GFP_KERNEL);
93 if (wm831x == NULL) 34 if (wm831x == NULL)
@@ -98,9 +39,15 @@ static int __devinit wm831x_spi_probe(struct spi_device *spi)
98 39
99 dev_set_drvdata(&spi->dev, wm831x); 40 dev_set_drvdata(&spi->dev, wm831x);
100 wm831x->dev = &spi->dev; 41 wm831x->dev = &spi->dev;
101 wm831x->control_data = spi; 42
102 wm831x->read_dev = wm831x_spi_read_device; 43 wm831x->regmap = regmap_init_spi(spi, &wm831x_regmap_config);
103 wm831x->write_dev = wm831x_spi_write_device; 44 if (IS_ERR(wm831x->regmap)) {
45 ret = PTR_ERR(wm831x->regmap);
46 dev_err(wm831x->dev, "Failed to allocate register map: %d\n",
47 ret);
48 kfree(wm831x);
49 return ret;
50 }
104 51
105 return wm831x_device_init(wm831x, type, spi->irq); 52 return wm831x_device_init(wm831x, type, spi->irq);
106} 53}
@@ -121,119 +68,50 @@ static int wm831x_spi_suspend(struct device *dev)
121 return wm831x_device_suspend(wm831x); 68 return wm831x_device_suspend(wm831x);
122} 69}
123 70
71static void wm831x_spi_shutdown(struct spi_device *spi)
72{
73 struct wm831x *wm831x = dev_get_drvdata(&spi->dev);
74
75 wm831x_device_shutdown(wm831x);
76}
77
124static const struct dev_pm_ops wm831x_spi_pm = { 78static const struct dev_pm_ops wm831x_spi_pm = {
125 .freeze = wm831x_spi_suspend, 79 .freeze = wm831x_spi_suspend,
126 .suspend = wm831x_spi_suspend, 80 .suspend = wm831x_spi_suspend,
127}; 81};
128 82
129static struct spi_driver wm8310_spi_driver = { 83static const struct spi_device_id wm831x_spi_ids[] = {
130 .driver = { 84 { "wm8310", WM8310 },
131 .name = "wm8310", 85 { "wm8311", WM8311 },
132 .bus = &spi_bus_type, 86 { "wm8312", WM8312 },
133 .owner = THIS_MODULE, 87 { "wm8320", WM8320 },
134 .pm = &wm831x_spi_pm, 88 { "wm8321", WM8321 },
135 }, 89 { "wm8325", WM8325 },
136 .probe = wm831x_spi_probe, 90 { "wm8326", WM8326 },
137 .remove = __devexit_p(wm831x_spi_remove), 91 { },
138}; 92};
93MODULE_DEVICE_TABLE(spi, wm831x_spi_id);
139 94
140static struct spi_driver wm8311_spi_driver = { 95static struct spi_driver wm831x_spi_driver = {
141 .driver = { 96 .driver = {
142 .name = "wm8311", 97 .name = "wm831x",
143 .bus = &spi_bus_type,
144 .owner = THIS_MODULE,
145 .pm = &wm831x_spi_pm,
146 },
147 .probe = wm831x_spi_probe,
148 .remove = __devexit_p(wm831x_spi_remove),
149};
150
151static struct spi_driver wm8312_spi_driver = {
152 .driver = {
153 .name = "wm8312",
154 .bus = &spi_bus_type,
155 .owner = THIS_MODULE,
156 .pm = &wm831x_spi_pm,
157 },
158 .probe = wm831x_spi_probe,
159 .remove = __devexit_p(wm831x_spi_remove),
160};
161
162static struct spi_driver wm8320_spi_driver = {
163 .driver = {
164 .name = "wm8320",
165 .bus = &spi_bus_type,
166 .owner = THIS_MODULE,
167 .pm = &wm831x_spi_pm,
168 },
169 .probe = wm831x_spi_probe,
170 .remove = __devexit_p(wm831x_spi_remove),
171};
172
173static struct spi_driver wm8321_spi_driver = {
174 .driver = {
175 .name = "wm8321",
176 .bus = &spi_bus_type,
177 .owner = THIS_MODULE,
178 .pm = &wm831x_spi_pm,
179 },
180 .probe = wm831x_spi_probe,
181 .remove = __devexit_p(wm831x_spi_remove),
182};
183
184static struct spi_driver wm8325_spi_driver = {
185 .driver = {
186 .name = "wm8325",
187 .bus = &spi_bus_type,
188 .owner = THIS_MODULE,
189 .pm = &wm831x_spi_pm,
190 },
191 .probe = wm831x_spi_probe,
192 .remove = __devexit_p(wm831x_spi_remove),
193};
194
195static struct spi_driver wm8326_spi_driver = {
196 .driver = {
197 .name = "wm8326",
198 .bus = &spi_bus_type, 98 .bus = &spi_bus_type,
199 .owner = THIS_MODULE, 99 .owner = THIS_MODULE,
200 .pm = &wm831x_spi_pm, 100 .pm = &wm831x_spi_pm,
201 }, 101 },
102 .id_table = wm831x_spi_ids,
202 .probe = wm831x_spi_probe, 103 .probe = wm831x_spi_probe,
203 .remove = __devexit_p(wm831x_spi_remove), 104 .remove = __devexit_p(wm831x_spi_remove),
105 .shutdown = wm831x_spi_shutdown,
204}; 106};
205 107
206static int __init wm831x_spi_init(void) 108static int __init wm831x_spi_init(void)
207{ 109{
208 int ret; 110 int ret;
209 111
210 ret = spi_register_driver(&wm8310_spi_driver); 112 ret = spi_register_driver(&wm831x_spi_driver);
211 if (ret != 0)
212 pr_err("Failed to register WM8310 SPI driver: %d\n", ret);
213
214 ret = spi_register_driver(&wm8311_spi_driver);
215 if (ret != 0)
216 pr_err("Failed to register WM8311 SPI driver: %d\n", ret);
217
218 ret = spi_register_driver(&wm8312_spi_driver);
219 if (ret != 0)
220 pr_err("Failed to register WM8312 SPI driver: %d\n", ret);
221
222 ret = spi_register_driver(&wm8320_spi_driver);
223 if (ret != 0)
224 pr_err("Failed to register WM8320 SPI driver: %d\n", ret);
225
226 ret = spi_register_driver(&wm8321_spi_driver);
227 if (ret != 0)
228 pr_err("Failed to register WM8321 SPI driver: %d\n", ret);
229
230 ret = spi_register_driver(&wm8325_spi_driver);
231 if (ret != 0)
232 pr_err("Failed to register WM8325 SPI driver: %d\n", ret);
233
234 ret = spi_register_driver(&wm8326_spi_driver);
235 if (ret != 0) 113 if (ret != 0)
236 pr_err("Failed to register WM8326 SPI driver: %d\n", ret); 114 pr_err("Failed to register WM831x SPI driver: %d\n", ret);
237 115
238 return 0; 116 return 0;
239} 117}
@@ -241,13 +119,7 @@ subsys_initcall(wm831x_spi_init);
241 119
242static void __exit wm831x_spi_exit(void) 120static void __exit wm831x_spi_exit(void)
243{ 121{
244 spi_unregister_driver(&wm8326_spi_driver); 122 spi_unregister_driver(&wm831x_spi_driver);
245 spi_unregister_driver(&wm8325_spi_driver);
246 spi_unregister_driver(&wm8321_spi_driver);
247 spi_unregister_driver(&wm8320_spi_driver);
248 spi_unregister_driver(&wm8312_spi_driver);
249 spi_unregister_driver(&wm8311_spi_driver);
250 spi_unregister_driver(&wm8310_spi_driver);
251} 123}
252module_exit(wm831x_spi_exit); 124module_exit(wm831x_spi_exit);
253 125
diff --git a/drivers/mfd/wm8350-gpio.c b/drivers/mfd/wm8350-gpio.c
index ebf99bef392..d584f6b4d6e 100644
--- a/drivers/mfd/wm8350-gpio.c
+++ b/drivers/mfd/wm8350-gpio.c
@@ -37,7 +37,7 @@ static int gpio_set_dir(struct wm8350 *wm8350, int gpio, int dir)
37 return ret; 37 return ret;
38} 38}
39 39
40static int gpio_set_debounce(struct wm8350 *wm8350, int gpio, int db) 40static int wm8350_gpio_set_debounce(struct wm8350 *wm8350, int gpio, int db)
41{ 41{
42 if (db == WM8350_GPIO_DEBOUNCE_ON) 42 if (db == WM8350_GPIO_DEBOUNCE_ON)
43 return wm8350_set_bits(wm8350, WM8350_GPIO_DEBOUNCE, 43 return wm8350_set_bits(wm8350, WM8350_GPIO_DEBOUNCE,
@@ -210,7 +210,7 @@ int wm8350_gpio_config(struct wm8350 *wm8350, int gpio, int dir, int func,
210 goto err; 210 goto err;
211 if (gpio_set_polarity(wm8350, gpio, pol)) 211 if (gpio_set_polarity(wm8350, gpio, pol))
212 goto err; 212 goto err;
213 if (gpio_set_debounce(wm8350, gpio, debounce)) 213 if (wm8350_gpio_set_debounce(wm8350, gpio, debounce))
214 goto err; 214 goto err;
215 if (gpio_set_dir(wm8350, gpio, dir)) 215 if (gpio_set_dir(wm8350, gpio, dir))
216 goto err; 216 goto err;
diff --git a/drivers/mfd/wm8400-core.c b/drivers/mfd/wm8400-core.c
index 597f82edaca..e06ba9440cd 100644
--- a/drivers/mfd/wm8400-core.c
+++ b/drivers/mfd/wm8400-core.c
@@ -13,11 +13,13 @@
13 */ 13 */
14 14
15#include <linux/bug.h> 15#include <linux/bug.h>
16#include <linux/err.h>
16#include <linux/i2c.h> 17#include <linux/i2c.h>
17#include <linux/kernel.h> 18#include <linux/kernel.h>
18#include <linux/mfd/core.h> 19#include <linux/mfd/core.h>
19#include <linux/mfd/wm8400-private.h> 20#include <linux/mfd/wm8400-private.h>
20#include <linux/mfd/wm8400-audio.h> 21#include <linux/mfd/wm8400-audio.h>
22#include <linux/regmap.h>
21#include <linux/slab.h> 23#include <linux/slab.h>
22 24
23static struct { 25static struct {
@@ -123,14 +125,9 @@ static int wm8400_read(struct wm8400 *wm8400, u8 reg, int num_regs, u16 *dest)
123 /* If there are any volatile reads then read back the entire block */ 125 /* If there are any volatile reads then read back the entire block */
124 for (i = reg; i < reg + num_regs; i++) 126 for (i = reg; i < reg + num_regs; i++)
125 if (reg_data[i].vol) { 127 if (reg_data[i].vol) {
126 ret = wm8400->read_dev(wm8400->io_data, reg, 128 ret = regmap_bulk_read(wm8400->regmap, reg, dest,
127 num_regs, dest); 129 num_regs);
128 if (ret != 0) 130 return ret;
129 return ret;
130 for (i = 0; i < num_regs; i++)
131 dest[i] = be16_to_cpu(dest[i]);
132
133 return 0;
134 } 131 }
135 132
136 /* Otherwise use the cache */ 133 /* Otherwise use the cache */
@@ -149,14 +146,11 @@ static int wm8400_write(struct wm8400 *wm8400, u8 reg, int num_regs,
149 for (i = 0; i < num_regs; i++) { 146 for (i = 0; i < num_regs; i++) {
150 BUG_ON(!reg_data[reg + i].writable); 147 BUG_ON(!reg_data[reg + i].writable);
151 wm8400->reg_cache[reg + i] = src[i]; 148 wm8400->reg_cache[reg + i] = src[i];
152 src[i] = cpu_to_be16(src[i]); 149 ret = regmap_write(wm8400->regmap, reg, src[i]);
150 if (ret != 0)
151 return ret;
153 } 152 }
154 153
155 /* Do the actual I/O */
156 ret = wm8400->write_dev(wm8400->io_data, reg, num_regs, src);
157 if (ret != 0)
158 return -EIO;
159
160 return 0; 154 return 0;
161} 155}
162 156
@@ -270,14 +264,14 @@ static int wm8400_init(struct wm8400 *wm8400,
270 dev_set_drvdata(wm8400->dev, wm8400); 264 dev_set_drvdata(wm8400->dev, wm8400);
271 265
272 /* Check that this is actually a WM8400 */ 266 /* Check that this is actually a WM8400 */
273 ret = wm8400->read_dev(wm8400->io_data, WM8400_RESET_ID, 1, &reg); 267 ret = regmap_read(wm8400->regmap, WM8400_RESET_ID, &i);
274 if (ret != 0) { 268 if (ret != 0) {
275 dev_err(wm8400->dev, "Chip ID register read failed\n"); 269 dev_err(wm8400->dev, "Chip ID register read failed\n");
276 return -EIO; 270 return -EIO;
277 } 271 }
278 if (be16_to_cpu(reg) != reg_data[WM8400_RESET_ID].default_val) { 272 if (i != reg_data[WM8400_RESET_ID].default_val) {
279 dev_err(wm8400->dev, "Device is not a WM8400, ID is %x\n", 273 dev_err(wm8400->dev, "Device is not a WM8400, ID is %x\n",
280 be16_to_cpu(reg)); 274 reg);
281 return -ENODEV; 275 return -ENODEV;
282 } 276 }
283 277
@@ -285,9 +279,8 @@ static int wm8400_init(struct wm8400 *wm8400,
285 * is a PMIC we can't reset it safely so initialise the register 279 * is a PMIC we can't reset it safely so initialise the register
286 * cache from the hardware. 280 * cache from the hardware.
287 */ 281 */
288 ret = wm8400->read_dev(wm8400->io_data, 0, 282 ret = regmap_raw_read(wm8400->regmap, 0, wm8400->reg_cache,
289 ARRAY_SIZE(wm8400->reg_cache), 283 ARRAY_SIZE(wm8400->reg_cache));
290 wm8400->reg_cache);
291 if (ret != 0) { 284 if (ret != 0) {
292 dev_err(wm8400->dev, "Register cache read failed\n"); 285 dev_err(wm8400->dev, "Register cache read failed\n");
293 return -EIO; 286 return -EIO;
@@ -337,60 +330,13 @@ static void wm8400_release(struct wm8400 *wm8400)
337 mfd_remove_devices(wm8400->dev); 330 mfd_remove_devices(wm8400->dev);
338} 331}
339 332
340#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) 333static const struct regmap_config wm8400_regmap_config = {
341static int wm8400_i2c_read(void *io_data, char reg, int count, u16 *dest) 334 .reg_bits = 8,
342{ 335 .val_bits = 16,
343 struct i2c_client *i2c = io_data; 336 .max_register = WM8400_REGISTER_COUNT - 1,
344 struct i2c_msg xfer[2]; 337};
345 int ret;
346
347 /* Write register */
348 xfer[0].addr = i2c->addr;
349 xfer[0].flags = 0;
350 xfer[0].len = 1;
351 xfer[0].buf = &reg;
352
353 /* Read data */
354 xfer[1].addr = i2c->addr;
355 xfer[1].flags = I2C_M_RD;
356 xfer[1].len = count * sizeof(u16);
357 xfer[1].buf = (u8 *)dest;
358
359 ret = i2c_transfer(i2c->adapter, xfer, 2);
360 if (ret == 2)
361 ret = 0;
362 else if (ret >= 0)
363 ret = -EIO;
364
365 return ret;
366}
367
368static int wm8400_i2c_write(void *io_data, char reg, int count, const u16 *src)
369{
370 struct i2c_client *i2c = io_data;
371 u8 *msg;
372 int ret;
373
374 /* We add 1 byte for device register - ideally I2C would gather. */
375 msg = kmalloc((count * sizeof(u16)) + 1, GFP_KERNEL);
376 if (msg == NULL)
377 return -ENOMEM;
378
379 msg[0] = reg;
380 memcpy(&msg[1], src, count * sizeof(u16));
381
382 ret = i2c_master_send(i2c, msg, (count * sizeof(u16)) + 1);
383
384 if (ret == (count * 2) + 1)
385 ret = 0;
386 else if (ret >= 0)
387 ret = -EIO;
388
389 kfree(msg);
390
391 return ret;
392}
393 338
339#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
394static int wm8400_i2c_probe(struct i2c_client *i2c, 340static int wm8400_i2c_probe(struct i2c_client *i2c,
395 const struct i2c_device_id *id) 341 const struct i2c_device_id *id)
396{ 342{
@@ -403,18 +349,23 @@ static int wm8400_i2c_probe(struct i2c_client *i2c,
403 goto err; 349 goto err;
404 } 350 }
405 351
406 wm8400->io_data = i2c; 352 wm8400->regmap = regmap_init_i2c(i2c, &wm8400_regmap_config);
407 wm8400->read_dev = wm8400_i2c_read; 353 if (IS_ERR(wm8400->regmap)) {
408 wm8400->write_dev = wm8400_i2c_write; 354 ret = PTR_ERR(wm8400->regmap);
355 goto struct_err;
356 }
357
409 wm8400->dev = &i2c->dev; 358 wm8400->dev = &i2c->dev;
410 i2c_set_clientdata(i2c, wm8400); 359 i2c_set_clientdata(i2c, wm8400);
411 360
412 ret = wm8400_init(wm8400, i2c->dev.platform_data); 361 ret = wm8400_init(wm8400, i2c->dev.platform_data);
413 if (ret != 0) 362 if (ret != 0)
414 goto struct_err; 363 goto map_err;
415 364
416 return 0; 365 return 0;
417 366
367map_err:
368 regmap_exit(wm8400->regmap);
418struct_err: 369struct_err:
419 kfree(wm8400); 370 kfree(wm8400);
420err: 371err:
@@ -426,6 +377,7 @@ static int wm8400_i2c_remove(struct i2c_client *i2c)
426 struct wm8400 *wm8400 = i2c_get_clientdata(i2c); 377 struct wm8400 *wm8400 = i2c_get_clientdata(i2c);
427 378
428 wm8400_release(wm8400); 379 wm8400_release(wm8400);
380 regmap_exit(wm8400->regmap);
429 kfree(wm8400); 381 kfree(wm8400);
430 382
431 return 0; 383 return 0;
diff --git a/drivers/mfd/wm8994-core.c b/drivers/mfd/wm8994-core.c
index 96479c9b172..b03be1d4e0c 100644
--- a/drivers/mfd/wm8994-core.c
+++ b/drivers/mfd/wm8994-core.c
@@ -16,9 +16,11 @@
16#include <linux/module.h> 16#include <linux/module.h>
17#include <linux/slab.h> 17#include <linux/slab.h>
18#include <linux/i2c.h> 18#include <linux/i2c.h>
19#include <linux/err.h>
19#include <linux/delay.h> 20#include <linux/delay.h>
20#include <linux/mfd/core.h> 21#include <linux/mfd/core.h>
21#include <linux/pm_runtime.h> 22#include <linux/pm_runtime.h>
23#include <linux/regmap.h>
22#include <linux/regulator/consumer.h> 24#include <linux/regulator/consumer.h>
23#include <linux/regulator/machine.h> 25#include <linux/regulator/machine.h>
24 26
@@ -29,22 +31,7 @@
29static int wm8994_read(struct wm8994 *wm8994, unsigned short reg, 31static int wm8994_read(struct wm8994 *wm8994, unsigned short reg,
30 int bytes, void *dest) 32 int bytes, void *dest)
31{ 33{
32 int ret, i; 34 return regmap_raw_read(wm8994->regmap, reg, dest, bytes);
33 u16 *buf = dest;
34
35 BUG_ON(bytes % 2);
36 BUG_ON(bytes <= 0);
37
38 ret = wm8994->read_dev(wm8994, reg, bytes, dest);
39 if (ret < 0)
40 return ret;
41
42 for (i = 0; i < bytes / 2; i++) {
43 dev_vdbg(wm8994->dev, "Read %04x from R%d(0x%x)\n",
44 be16_to_cpu(buf[i]), reg + i, reg + i);
45 }
46
47 return 0;
48} 35}
49 36
50/** 37/**
@@ -55,19 +42,15 @@ static int wm8994_read(struct wm8994 *wm8994, unsigned short reg,
55 */ 42 */
56int wm8994_reg_read(struct wm8994 *wm8994, unsigned short reg) 43int wm8994_reg_read(struct wm8994 *wm8994, unsigned short reg)
57{ 44{
58 unsigned short val; 45 unsigned int val;
59 int ret; 46 int ret;
60 47
61 mutex_lock(&wm8994->io_lock); 48 ret = regmap_read(wm8994->regmap, reg, &val);
62
63 ret = wm8994_read(wm8994, reg, 2, &val);
64
65 mutex_unlock(&wm8994->io_lock);
66 49
67 if (ret < 0) 50 if (ret < 0)
68 return ret; 51 return ret;
69 else 52 else
70 return be16_to_cpu(val); 53 return val;
71} 54}
72EXPORT_SYMBOL_GPL(wm8994_reg_read); 55EXPORT_SYMBOL_GPL(wm8994_reg_read);
73 56
@@ -82,33 +65,13 @@ EXPORT_SYMBOL_GPL(wm8994_reg_read);
82int wm8994_bulk_read(struct wm8994 *wm8994, unsigned short reg, 65int wm8994_bulk_read(struct wm8994 *wm8994, unsigned short reg,
83 int count, u16 *buf) 66 int count, u16 *buf)
84{ 67{
85 int ret; 68 return regmap_bulk_read(wm8994->regmap, reg, buf, count);
86
87 mutex_lock(&wm8994->io_lock);
88
89 ret = wm8994_read(wm8994, reg, count * 2, buf);
90
91 mutex_unlock(&wm8994->io_lock);
92
93 return ret;
94} 69}
95EXPORT_SYMBOL_GPL(wm8994_bulk_read);
96 70
97static int wm8994_write(struct wm8994 *wm8994, unsigned short reg, 71static int wm8994_write(struct wm8994 *wm8994, unsigned short reg,
98 int bytes, const void *src) 72 int bytes, const void *src)
99{ 73{
100 const u16 *buf = src; 74 return regmap_raw_write(wm8994->regmap, reg, src, bytes);
101 int i;
102
103 BUG_ON(bytes % 2);
104 BUG_ON(bytes <= 0);
105
106 for (i = 0; i < bytes / 2; i++) {
107 dev_vdbg(wm8994->dev, "Write %04x to R%d(0x%x)\n",
108 be16_to_cpu(buf[i]), reg + i, reg + i);
109 }
110
111 return wm8994->write_dev(wm8994, reg, bytes, src);
112} 75}
113 76
114/** 77/**
@@ -121,17 +84,7 @@ static int wm8994_write(struct wm8994 *wm8994, unsigned short reg,
121int wm8994_reg_write(struct wm8994 *wm8994, unsigned short reg, 84int wm8994_reg_write(struct wm8994 *wm8994, unsigned short reg,
122 unsigned short val) 85 unsigned short val)
123{ 86{
124 int ret; 87 return regmap_write(wm8994->regmap, reg, val);
125
126 val = cpu_to_be16(val);
127
128 mutex_lock(&wm8994->io_lock);
129
130 ret = wm8994_write(wm8994, reg, 2, &val);
131
132 mutex_unlock(&wm8994->io_lock);
133
134 return ret;
135} 88}
136EXPORT_SYMBOL_GPL(wm8994_reg_write); 89EXPORT_SYMBOL_GPL(wm8994_reg_write);
137 90
@@ -146,15 +99,7 @@ EXPORT_SYMBOL_GPL(wm8994_reg_write);
146int wm8994_bulk_write(struct wm8994 *wm8994, unsigned short reg, 99int wm8994_bulk_write(struct wm8994 *wm8994, unsigned short reg,
147 int count, const u16 *buf) 100 int count, const u16 *buf)
148{ 101{
149 int ret; 102 return regmap_raw_write(wm8994->regmap, reg, buf, count * sizeof(u16));
150
151 mutex_lock(&wm8994->io_lock);
152
153 ret = wm8994_write(wm8994, reg, count * 2, buf);
154
155 mutex_unlock(&wm8994->io_lock);
156
157 return ret;
158} 103}
159EXPORT_SYMBOL_GPL(wm8994_bulk_write); 104EXPORT_SYMBOL_GPL(wm8994_bulk_write);
160 105
@@ -169,28 +114,7 @@ EXPORT_SYMBOL_GPL(wm8994_bulk_write);
169int wm8994_set_bits(struct wm8994 *wm8994, unsigned short reg, 114int wm8994_set_bits(struct wm8994 *wm8994, unsigned short reg,
170 unsigned short mask, unsigned short val) 115 unsigned short mask, unsigned short val)
171{ 116{
172 int ret; 117 return regmap_update_bits(wm8994->regmap, reg, mask, val);
173 u16 r;
174
175 mutex_lock(&wm8994->io_lock);
176
177 ret = wm8994_read(wm8994, reg, 2, &r);
178 if (ret < 0)
179 goto out;
180
181 r = be16_to_cpu(r);
182
183 r &= ~mask;
184 r |= val;
185
186 r = cpu_to_be16(r);
187
188 ret = wm8994_write(wm8994, reg, 2, &r);
189
190out:
191 mutex_unlock(&wm8994->io_lock);
192
193 return ret;
194} 118}
195EXPORT_SYMBOL_GPL(wm8994_set_bits); 119EXPORT_SYMBOL_GPL(wm8994_set_bits);
196 120
@@ -243,6 +167,18 @@ static struct mfd_cell wm8994_devs[] = {
243 * and should be handled via the standard regulator API supply 167 * and should be handled via the standard regulator API supply
244 * management. 168 * management.
245 */ 169 */
170static const char *wm1811_main_supplies[] = {
171 "DBVDD1",
172 "DBVDD2",
173 "DBVDD3",
174 "DCVDD",
175 "AVDD1",
176 "AVDD2",
177 "CPVDD",
178 "SPKVDD1",
179 "SPKVDD2",
180};
181
246static const char *wm8994_main_supplies[] = { 182static const char *wm8994_main_supplies[] = {
247 "DBVDD", 183 "DBVDD",
248 "DCVDD", 184 "DCVDD",
@@ -378,6 +314,11 @@ static int wm8994_ldo_in_use(struct wm8994_pdata *pdata, int ldo)
378} 314}
379#endif 315#endif
380 316
317static struct regmap_config wm8994_regmap_config = {
318 .reg_bits = 16,
319 .val_bits = 16,
320};
321
381/* 322/*
382 * Instantiate the generic non-control parts of the device. 323 * Instantiate the generic non-control parts of the device.
383 */ 324 */
@@ -387,7 +328,6 @@ static int wm8994_device_init(struct wm8994 *wm8994, int irq)
387 const char *devname; 328 const char *devname;
388 int ret, i; 329 int ret, i;
389 330
390 mutex_init(&wm8994->io_lock);
391 dev_set_drvdata(wm8994->dev, wm8994); 331 dev_set_drvdata(wm8994->dev, wm8994);
392 332
393 /* Add the on-chip regulators first for bootstrapping */ 333 /* Add the on-chip regulators first for bootstrapping */
@@ -397,10 +337,13 @@ static int wm8994_device_init(struct wm8994 *wm8994, int irq)
397 NULL, 0); 337 NULL, 0);
398 if (ret != 0) { 338 if (ret != 0) {
399 dev_err(wm8994->dev, "Failed to add children: %d\n", ret); 339 dev_err(wm8994->dev, "Failed to add children: %d\n", ret);
400 goto err; 340 goto err_regmap;
401 } 341 }
402 342
403 switch (wm8994->type) { 343 switch (wm8994->type) {
344 case WM1811:
345 wm8994->num_supplies = ARRAY_SIZE(wm1811_main_supplies);
346 break;
404 case WM8994: 347 case WM8994:
405 wm8994->num_supplies = ARRAY_SIZE(wm8994_main_supplies); 348 wm8994->num_supplies = ARRAY_SIZE(wm8994_main_supplies);
406 break; 349 break;
@@ -409,7 +352,7 @@ static int wm8994_device_init(struct wm8994 *wm8994, int irq)
409 break; 352 break;
410 default: 353 default:
411 BUG(); 354 BUG();
412 goto err; 355 goto err_regmap;
413 } 356 }
414 357
415 wm8994->supplies = kzalloc(sizeof(struct regulator_bulk_data) * 358 wm8994->supplies = kzalloc(sizeof(struct regulator_bulk_data) *
@@ -417,10 +360,14 @@ static int wm8994_device_init(struct wm8994 *wm8994, int irq)
417 GFP_KERNEL); 360 GFP_KERNEL);
418 if (!wm8994->supplies) { 361 if (!wm8994->supplies) {
419 ret = -ENOMEM; 362 ret = -ENOMEM;
420 goto err; 363 goto err_regmap;
421 } 364 }
422 365
423 switch (wm8994->type) { 366 switch (wm8994->type) {
367 case WM1811:
368 for (i = 0; i < ARRAY_SIZE(wm1811_main_supplies); i++)
369 wm8994->supplies[i].supply = wm1811_main_supplies[i];
370 break;
424 case WM8994: 371 case WM8994:
425 for (i = 0; i < ARRAY_SIZE(wm8994_main_supplies); i++) 372 for (i = 0; i < ARRAY_SIZE(wm8994_main_supplies); i++)
426 wm8994->supplies[i].supply = wm8994_main_supplies[i]; 373 wm8994->supplies[i].supply = wm8994_main_supplies[i];
@@ -431,7 +378,7 @@ static int wm8994_device_init(struct wm8994 *wm8994, int irq)
431 break; 378 break;
432 default: 379 default:
433 BUG(); 380 BUG();
434 goto err; 381 goto err_regmap;
435 } 382 }
436 383
437 ret = regulator_bulk_get(wm8994->dev, wm8994->num_supplies, 384 ret = regulator_bulk_get(wm8994->dev, wm8994->num_supplies,
@@ -454,6 +401,13 @@ static int wm8994_device_init(struct wm8994 *wm8994, int irq)
454 goto err_enable; 401 goto err_enable;
455 } 402 }
456 switch (ret) { 403 switch (ret) {
404 case 0x1811:
405 devname = "WM1811";
406 if (wm8994->type != WM1811)
407 dev_warn(wm8994->dev, "Device registered as type %d\n",
408 wm8994->type);
409 wm8994->type = WM1811;
410 break;
457 case 0x8994: 411 case 0x8994:
458 devname = "WM8994"; 412 devname = "WM8994";
459 if (wm8994->type != WM8994) 413 if (wm8994->type != WM8994)
@@ -554,7 +508,8 @@ err_get:
554 regulator_bulk_free(wm8994->num_supplies, wm8994->supplies); 508 regulator_bulk_free(wm8994->num_supplies, wm8994->supplies);
555err_supplies: 509err_supplies:
556 kfree(wm8994->supplies); 510 kfree(wm8994->supplies);
557err: 511err_regmap:
512 regmap_exit(wm8994->regmap);
558 mfd_remove_devices(wm8994->dev); 513 mfd_remove_devices(wm8994->dev);
559 kfree(wm8994); 514 kfree(wm8994);
560 return ret; 515 return ret;
@@ -569,62 +524,15 @@ static void wm8994_device_exit(struct wm8994 *wm8994)
569 wm8994->supplies); 524 wm8994->supplies);
570 regulator_bulk_free(wm8994->num_supplies, wm8994->supplies); 525 regulator_bulk_free(wm8994->num_supplies, wm8994->supplies);
571 kfree(wm8994->supplies); 526 kfree(wm8994->supplies);
527 regmap_exit(wm8994->regmap);
572 kfree(wm8994); 528 kfree(wm8994);
573} 529}
574 530
575static int wm8994_i2c_read_device(struct wm8994 *wm8994, unsigned short reg,
576 int bytes, void *dest)
577{
578 struct i2c_client *i2c = wm8994->control_data;
579 int ret;
580 u16 r = cpu_to_be16(reg);
581
582 ret = i2c_master_send(i2c, (unsigned char *)&r, 2);
583 if (ret < 0)
584 return ret;
585 if (ret != 2)
586 return -EIO;
587
588 ret = i2c_master_recv(i2c, dest, bytes);
589 if (ret < 0)
590 return ret;
591 if (ret != bytes)
592 return -EIO;
593 return 0;
594}
595
596static int wm8994_i2c_write_device(struct wm8994 *wm8994, unsigned short reg,
597 int bytes, const void *src)
598{
599 struct i2c_client *i2c = wm8994->control_data;
600 struct i2c_msg xfer[2];
601 int ret;
602
603 reg = cpu_to_be16(reg);
604
605 xfer[0].addr = i2c->addr;
606 xfer[0].flags = 0;
607 xfer[0].len = 2;
608 xfer[0].buf = (char *)&reg;
609
610 xfer[1].addr = i2c->addr;
611 xfer[1].flags = I2C_M_NOSTART;
612 xfer[1].len = bytes;
613 xfer[1].buf = (char *)src;
614
615 ret = i2c_transfer(i2c->adapter, xfer, 2);
616 if (ret < 0)
617 return ret;
618 if (ret != 2)
619 return -EIO;
620
621 return 0;
622}
623
624static int wm8994_i2c_probe(struct i2c_client *i2c, 531static int wm8994_i2c_probe(struct i2c_client *i2c,
625 const struct i2c_device_id *id) 532 const struct i2c_device_id *id)
626{ 533{
627 struct wm8994 *wm8994; 534 struct wm8994 *wm8994;
535 int ret;
628 536
629 wm8994 = kzalloc(sizeof(struct wm8994), GFP_KERNEL); 537 wm8994 = kzalloc(sizeof(struct wm8994), GFP_KERNEL);
630 if (wm8994 == NULL) 538 if (wm8994 == NULL)
@@ -632,12 +540,18 @@ static int wm8994_i2c_probe(struct i2c_client *i2c,
632 540
633 i2c_set_clientdata(i2c, wm8994); 541 i2c_set_clientdata(i2c, wm8994);
634 wm8994->dev = &i2c->dev; 542 wm8994->dev = &i2c->dev;
635 wm8994->control_data = i2c;
636 wm8994->read_dev = wm8994_i2c_read_device;
637 wm8994->write_dev = wm8994_i2c_write_device;
638 wm8994->irq = i2c->irq; 543 wm8994->irq = i2c->irq;
639 wm8994->type = id->driver_data; 544 wm8994->type = id->driver_data;
640 545
546 wm8994->regmap = regmap_init_i2c(i2c, &wm8994_regmap_config);
547 if (IS_ERR(wm8994->regmap)) {
548 ret = PTR_ERR(wm8994->regmap);
549 dev_err(wm8994->dev, "Failed to allocate register map: %d\n",
550 ret);
551 kfree(wm8994);
552 return ret;
553 }
554
641 return wm8994_device_init(wm8994, i2c->irq); 555 return wm8994_device_init(wm8994, i2c->irq);
642} 556}
643 557
@@ -651,6 +565,7 @@ static int wm8994_i2c_remove(struct i2c_client *i2c)
651} 565}
652 566
653static const struct i2c_device_id wm8994_i2c_id[] = { 567static const struct i2c_device_id wm8994_i2c_id[] = {
568 { "wm1811", WM1811 },
654 { "wm8994", WM8994 }, 569 { "wm8994", WM8994 },
655 { "wm8958", WM8958 }, 570 { "wm8958", WM8958 },
656 { } 571 { }