aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mfd
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/mfd')
-rw-r--r--drivers/mfd/twl-core.c136
-rw-r--r--drivers/mfd/twl4030-irq.c18
-rw-r--r--drivers/mfd/twl4030-power.c68
3 files changed, 116 insertions, 106 deletions
diff --git a/drivers/mfd/twl-core.c b/drivers/mfd/twl-core.c
index 44714f5cf495..9021f44de2a4 100644
--- a/drivers/mfd/twl-core.c
+++ b/drivers/mfd/twl-core.c
@@ -1,5 +1,6 @@
1/* 1/*
2 * twl4030_core.c - driver for TWL4030/TPS659x0 PM and audio CODEC devices 2 * twl_core.c - driver for TWL4030/TWL5030/TWL60X0/TPS659x0 PM
3 * and audio CODEC devices
3 * 4 *
4 * Copyright (C) 2005-2006 Texas Instruments, Inc. 5 * Copyright (C) 2005-2006 Texas Instruments, Inc.
5 * 6 *
@@ -55,7 +56,7 @@
55 * (and associated registers). 56 * (and associated registers).
56 */ 57 */
57 58
58#define DRIVER_NAME "twl4030" 59#define DRIVER_NAME "twl"
59 60
60#if defined(CONFIG_TWL4030_BCI_BATTERY) || \ 61#if defined(CONFIG_TWL4030_BCI_BATTERY) || \
61 defined(CONFIG_TWL4030_BCI_BATTERY_MODULE) 62 defined(CONFIG_TWL4030_BCI_BATTERY_MODULE)
@@ -125,7 +126,7 @@
125/* Last - for index max*/ 126/* Last - for index max*/
126#define TWL4030_MODULE_LAST TWL4030_MODULE_SECURED_REG 127#define TWL4030_MODULE_LAST TWL4030_MODULE_SECURED_REG
127 128
128#define TWL4030_NUM_SLAVES 4 129#define TWL_NUM_SLAVES 4
129 130
130#if defined(CONFIG_INPUT_TWL4030_PWRBUTTON) \ 131#if defined(CONFIG_INPUT_TWL4030_PWRBUTTON) \
131 || defined(CONFIG_INPUT_TWL4030_PWBUTTON_MODULE) 132 || defined(CONFIG_INPUT_TWL4030_PWBUTTON_MODULE)
@@ -134,6 +135,13 @@
134#define twl_has_pwrbutton() false 135#define twl_has_pwrbutton() false
135#endif 136#endif
136 137
138#define SUB_CHIP_ID0 0
139#define SUB_CHIP_ID1 1
140#define SUB_CHIP_ID2 2
141#define SUB_CHIP_ID3 3
142
143#define TWL_MODULE_LAST TWL4030_MODULE_LAST
144
137/* Base Address defns for twl4030_map[] */ 145/* Base Address defns for twl4030_map[] */
138 146
139/* subchip/slave 0 - USB ID */ 147/* subchip/slave 0 - USB ID */
@@ -201,7 +209,7 @@
201static bool inuse; 209static bool inuse;
202 210
203/* Structure for each TWL4030 Slave */ 211/* Structure for each TWL4030 Slave */
204struct twl4030_client { 212struct twl_client {
205 struct i2c_client *client; 213 struct i2c_client *client;
206 u8 address; 214 u8 address;
207 215
@@ -212,16 +220,16 @@ struct twl4030_client {
212 struct mutex xfer_lock; 220 struct mutex xfer_lock;
213}; 221};
214 222
215static struct twl4030_client twl4030_modules[TWL4030_NUM_SLAVES]; 223static struct twl_client twl_modules[TWL_NUM_SLAVES];
216 224
217 225
218/* mapping the module id to slave id and base address */ 226/* mapping the module id to slave id and base address */
219struct twl4030mapping { 227struct twl_mapping {
220 unsigned char sid; /* Slave ID */ 228 unsigned char sid; /* Slave ID */
221 unsigned char base; /* base address */ 229 unsigned char base; /* base address */
222}; 230};
223 231
224static struct twl4030mapping twl4030_map[TWL4030_MODULE_LAST + 1] = { 232static struct twl_mapping twl4030_map[TWL4030_MODULE_LAST + 1] = {
225 /* 233 /*
226 * NOTE: don't change this table without updating the 234 * NOTE: don't change this table without updating the
227 * <linux/i2c/twl4030.h> defines for TWL4030_MODULE_* 235 * <linux/i2c/twl4030.h> defines for TWL4030_MODULE_*
@@ -262,7 +270,7 @@ static struct twl4030mapping twl4030_map[TWL4030_MODULE_LAST + 1] = {
262/* Exported Functions */ 270/* Exported Functions */
263 271
264/** 272/**
265 * twl4030_i2c_write - Writes a n bit register in TWL4030 273 * twl_i2c_write - Writes a n bit register in TWL4030/TWL5030/TWL60X0
266 * @mod_no: module number 274 * @mod_no: module number
267 * @value: an array of num_bytes+1 containing data to write 275 * @value: an array of num_bytes+1 containing data to write
268 * @reg: register address (just offset will do) 276 * @reg: register address (just offset will do)
@@ -273,19 +281,19 @@ static struct twl4030mapping twl4030_map[TWL4030_MODULE_LAST + 1] = {
273 * 281 *
274 * Returns the result of operation - 0 is success 282 * Returns the result of operation - 0 is success
275 */ 283 */
276int twl4030_i2c_write(u8 mod_no, u8 *value, u8 reg, unsigned num_bytes) 284int twl_i2c_write(u8 mod_no, u8 *value, u8 reg, unsigned num_bytes)
277{ 285{
278 int ret; 286 int ret;
279 int sid; 287 int sid;
280 struct twl4030_client *twl; 288 struct twl_client *twl;
281 struct i2c_msg *msg; 289 struct i2c_msg *msg;
282 290
283 if (unlikely(mod_no > TWL4030_MODULE_LAST)) { 291 if (unlikely(mod_no > TWL_MODULE_LAST)) {
284 pr_err("%s: invalid module number %d\n", DRIVER_NAME, mod_no); 292 pr_err("%s: invalid module number %d\n", DRIVER_NAME, mod_no);
285 return -EPERM; 293 return -EPERM;
286 } 294 }
287 sid = twl4030_map[mod_no].sid; 295 sid = twl4030_map[mod_no].sid;
288 twl = &twl4030_modules[sid]; 296 twl = &twl_modules[sid];
289 297
290 if (unlikely(!inuse)) { 298 if (unlikely(!inuse)) {
291 pr_err("%s: client %d is not initialized\n", DRIVER_NAME, sid); 299 pr_err("%s: client %d is not initialized\n", DRIVER_NAME, sid);
@@ -318,10 +326,10 @@ int twl4030_i2c_write(u8 mod_no, u8 *value, u8 reg, unsigned num_bytes)
318 return 0; 326 return 0;
319 } 327 }
320} 328}
321EXPORT_SYMBOL(twl4030_i2c_write); 329EXPORT_SYMBOL(twl_i2c_write);
322 330
323/** 331/**
324 * twl4030_i2c_read - Reads a n bit register in TWL4030 332 * twl_i2c_read - Reads a n bit register in TWL4030/TWL5030/TWL60X0
325 * @mod_no: module number 333 * @mod_no: module number
326 * @value: an array of num_bytes containing data to be read 334 * @value: an array of num_bytes containing data to be read
327 * @reg: register address (just offset will do) 335 * @reg: register address (just offset will do)
@@ -329,20 +337,20 @@ EXPORT_SYMBOL(twl4030_i2c_write);
329 * 337 *
330 * Returns result of operation - num_bytes is success else failure. 338 * Returns result of operation - num_bytes is success else failure.
331 */ 339 */
332int twl4030_i2c_read(u8 mod_no, u8 *value, u8 reg, unsigned num_bytes) 340int twl_i2c_read(u8 mod_no, u8 *value, u8 reg, unsigned num_bytes)
333{ 341{
334 int ret; 342 int ret;
335 u8 val; 343 u8 val;
336 int sid; 344 int sid;
337 struct twl4030_client *twl; 345 struct twl_client *twl;
338 struct i2c_msg *msg; 346 struct i2c_msg *msg;
339 347
340 if (unlikely(mod_no > TWL4030_MODULE_LAST)) { 348 if (unlikely(mod_no > TWL_MODULE_LAST)) {
341 pr_err("%s: invalid module number %d\n", DRIVER_NAME, mod_no); 349 pr_err("%s: invalid module number %d\n", DRIVER_NAME, mod_no);
342 return -EPERM; 350 return -EPERM;
343 } 351 }
344 sid = twl4030_map[mod_no].sid; 352 sid = twl4030_map[mod_no].sid;
345 twl = &twl4030_modules[sid]; 353 twl = &twl_modules[sid];
346 354
347 if (unlikely(!inuse)) { 355 if (unlikely(!inuse)) {
348 pr_err("%s: client %d is not initialized\n", DRIVER_NAME, sid); 356 pr_err("%s: client %d is not initialized\n", DRIVER_NAME, sid);
@@ -377,40 +385,40 @@ int twl4030_i2c_read(u8 mod_no, u8 *value, u8 reg, unsigned num_bytes)
377 return 0; 385 return 0;
378 } 386 }
379} 387}
380EXPORT_SYMBOL(twl4030_i2c_read); 388EXPORT_SYMBOL(twl_i2c_read);
381 389
382/** 390/**
383 * twl4030_i2c_write_u8 - Writes a 8 bit register in TWL4030 391 * twl_i2c_write_u8 - Writes a 8 bit register in TWL4030/TWL5030/TWL60X0
384 * @mod_no: module number 392 * @mod_no: module number
385 * @value: the value to be written 8 bit 393 * @value: the value to be written 8 bit
386 * @reg: register address (just offset will do) 394 * @reg: register address (just offset will do)
387 * 395 *
388 * Returns result of operation - 0 is success 396 * Returns result of operation - 0 is success
389 */ 397 */
390int twl4030_i2c_write_u8(u8 mod_no, u8 value, u8 reg) 398int twl_i2c_write_u8(u8 mod_no, u8 value, u8 reg)
391{ 399{
392 400
393 /* 2 bytes offset 1 contains the data offset 0 is used by i2c_write */ 401 /* 2 bytes offset 1 contains the data offset 0 is used by i2c_write */
394 u8 temp_buffer[2] = { 0 }; 402 u8 temp_buffer[2] = { 0 };
395 /* offset 1 contains the data */ 403 /* offset 1 contains the data */
396 temp_buffer[1] = value; 404 temp_buffer[1] = value;
397 return twl4030_i2c_write(mod_no, temp_buffer, reg, 1); 405 return twl_i2c_write(mod_no, temp_buffer, reg, 1);
398} 406}
399EXPORT_SYMBOL(twl4030_i2c_write_u8); 407EXPORT_SYMBOL(twl_i2c_write_u8);
400 408
401/** 409/**
402 * twl4030_i2c_read_u8 - Reads a 8 bit register from TWL4030 410 * twl_i2c_read_u8 - Reads a 8 bit register from TWL4030/TWL5030/TWL60X0
403 * @mod_no: module number 411 * @mod_no: module number
404 * @value: the value read 8 bit 412 * @value: the value read 8 bit
405 * @reg: register address (just offset will do) 413 * @reg: register address (just offset will do)
406 * 414 *
407 * Returns result of operation - 0 is success 415 * Returns result of operation - 0 is success
408 */ 416 */
409int twl4030_i2c_read_u8(u8 mod_no, u8 *value, u8 reg) 417int twl_i2c_read_u8(u8 mod_no, u8 *value, u8 reg)
410{ 418{
411 return twl4030_i2c_read(mod_no, value, reg, 1); 419 return twl_i2c_read(mod_no, value, reg, 1);
412} 420}
413EXPORT_SYMBOL(twl4030_i2c_read_u8); 421EXPORT_SYMBOL(twl_i2c_read_u8);
414 422
415/*----------------------------------------------------------------------*/ 423/*----------------------------------------------------------------------*/
416 424
@@ -420,7 +428,7 @@ add_numbered_child(unsigned chip, const char *name, int num,
420 bool can_wakeup, int irq0, int irq1) 428 bool can_wakeup, int irq0, int irq1)
421{ 429{
422 struct platform_device *pdev; 430 struct platform_device *pdev;
423 struct twl4030_client *twl = &twl4030_modules[chip]; 431 struct twl_client *twl = &twl_modules[chip];
424 int status; 432 int status;
425 433
426 pdev = platform_device_alloc(name, num); 434 pdev = platform_device_alloc(name, num);
@@ -515,23 +523,24 @@ add_children(struct twl4030_platform_data *pdata, unsigned long features)
515 pdata->bci, sizeof(*pdata->bci), 523 pdata->bci, sizeof(*pdata->bci),
516 false, 524 false,
517 /* irq0 = CHG_PRES, irq1 = BCI */ 525 /* irq0 = CHG_PRES, irq1 = BCI */
518 pdata->irq_base + 8 + 1, pdata->irq_base + 2); 526 pdata->irq_base + BCI_PRES_INTR_OFFSET,
527 pdata->irq_base + BCI_INTR_OFFSET);
519 if (IS_ERR(child)) 528 if (IS_ERR(child))
520 return PTR_ERR(child); 529 return PTR_ERR(child);
521 } 530 }
522 531
523 if (twl_has_gpio() && pdata->gpio) { 532 if (twl_has_gpio() && pdata->gpio) {
524 child = add_child(1, "twl4030_gpio", 533 child = add_child(SUB_CHIP_ID1, "twl4030_gpio",
525 pdata->gpio, sizeof(*pdata->gpio), 534 pdata->gpio, sizeof(*pdata->gpio),
526 false, pdata->irq_base + 0, 0); 535 false, pdata->irq_base + GPIO_INTR_OFFSET, 0);
527 if (IS_ERR(child)) 536 if (IS_ERR(child))
528 return PTR_ERR(child); 537 return PTR_ERR(child);
529 } 538 }
530 539
531 if (twl_has_keypad() && pdata->keypad) { 540 if (twl_has_keypad() && pdata->keypad) {
532 child = add_child(2, "twl4030_keypad", 541 child = add_child(SUB_CHIP_ID2, "twl4030_keypad",
533 pdata->keypad, sizeof(*pdata->keypad), 542 pdata->keypad, sizeof(*pdata->keypad),
534 true, pdata->irq_base + 1, 0); 543 true, pdata->irq_base + KEYPAD_INTR_OFFSET, 0);
535 if (IS_ERR(child)) 544 if (IS_ERR(child))
536 return PTR_ERR(child); 545 return PTR_ERR(child);
537 } 546 }
@@ -539,7 +548,7 @@ add_children(struct twl4030_platform_data *pdata, unsigned long features)
539 if (twl_has_madc() && pdata->madc) { 548 if (twl_has_madc() && pdata->madc) {
540 child = add_child(2, "twl4030_madc", 549 child = add_child(2, "twl4030_madc",
541 pdata->madc, sizeof(*pdata->madc), 550 pdata->madc, sizeof(*pdata->madc),
542 true, pdata->irq_base + 3, 0); 551 true, pdata->irq_base + MADC_INTR_OFFSET, 0);
543 if (IS_ERR(child)) 552 if (IS_ERR(child))
544 return PTR_ERR(child); 553 return PTR_ERR(child);
545 } 554 }
@@ -554,7 +563,7 @@ add_children(struct twl4030_platform_data *pdata, unsigned long features)
554 */ 563 */
555 child = add_child(3, "twl4030_rtc", 564 child = add_child(3, "twl4030_rtc",
556 NULL, 0, 565 NULL, 0,
557 true, pdata->irq_base + 8 + 3, 0); 566 true, pdata->irq_base + RTC_INTR_OFFSET, 0);
558 if (IS_ERR(child)) 567 if (IS_ERR(child))
559 return PTR_ERR(child); 568 return PTR_ERR(child);
560 } 569 }
@@ -604,7 +613,8 @@ add_children(struct twl4030_platform_data *pdata, unsigned long features)
604 pdata->usb, sizeof(*pdata->usb), 613 pdata->usb, sizeof(*pdata->usb),
605 true, 614 true,
606 /* irq0 = USB_PRES, irq1 = USB */ 615 /* irq0 = USB_PRES, irq1 = USB */
607 pdata->irq_base + 8 + 2, pdata->irq_base + 4); 616 pdata->irq_base + USB_PRES_INTR_OFFSET,
617 pdata->irq_base + USB_INTR_OFFSET);
608 618
609 if (IS_ERR(child)) 619 if (IS_ERR(child))
610 return PTR_ERR(child); 620 return PTR_ERR(child);
@@ -724,7 +734,7 @@ static inline int __init protect_pm_master(void)
724{ 734{
725 int e = 0; 735 int e = 0;
726 736
727 e = twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, KEY_LOCK, 737 e = twl_i2c_write_u8(TWL_MODULE_PM_MASTER, KEY_LOCK,
728 R_PROTECT_KEY); 738 R_PROTECT_KEY);
729 return e; 739 return e;
730} 740}
@@ -733,9 +743,9 @@ static inline int __init unprotect_pm_master(void)
733{ 743{
734 int e = 0; 744 int e = 0;
735 745
736 e |= twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, KEY_UNLOCK1, 746 e |= twl_i2c_write_u8(TWL_MODULE_PM_MASTER, KEY_UNLOCK1,
737 R_PROTECT_KEY); 747 R_PROTECT_KEY);
738 e |= twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, KEY_UNLOCK2, 748 e |= twl_i2c_write_u8(TWL_MODULE_PM_MASTER, KEY_UNLOCK2,
739 R_PROTECT_KEY); 749 R_PROTECT_KEY);
740 return e; 750 return e;
741} 751}
@@ -755,7 +765,7 @@ static void clocks_init(struct device *dev,
755 osc = clk_get(dev, "osc_sys_ck"); 765 osc = clk_get(dev, "osc_sys_ck");
756 766
757 if (IS_ERR(osc)) { 767 if (IS_ERR(osc)) {
758 printk(KERN_WARNING "Skipping twl4030 internal clock init and " 768 printk(KERN_WARNING "Skipping twl internal clock init and "
759 "using bootloader value (unknown osc rate)\n"); 769 "using bootloader value (unknown osc rate)\n");
760 return; 770 return;
761 } 771 }
@@ -769,7 +779,7 @@ static void clocks_init(struct device *dev,
769 */ 779 */
770 osc = ERR_PTR(-EIO); 780 osc = ERR_PTR(-EIO);
771 781
772 printk(KERN_WARNING "Skipping twl4030 internal clock init and " 782 printk(KERN_WARNING "Skipping twl internal clock init and "
773 "using bootloader value (unknown osc rate)\n"); 783 "using bootloader value (unknown osc rate)\n");
774 784
775 return; 785 return;
@@ -793,7 +803,7 @@ static void clocks_init(struct device *dev,
793 803
794 e |= unprotect_pm_master(); 804 e |= unprotect_pm_master();
795 /* effect->MADC+USB ck en */ 805 /* effect->MADC+USB ck en */
796 e |= twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, ctrl, R_CFG_BOOT); 806 e |= twl_i2c_write_u8(TWL_MODULE_PM_MASTER, ctrl, R_CFG_BOOT);
797 e |= protect_pm_master(); 807 e |= protect_pm_master();
798 808
799 if (e < 0) 809 if (e < 0)
@@ -806,7 +816,7 @@ int twl_init_irq(int irq_num, unsigned irq_base, unsigned irq_end);
806int twl_exit_irq(void); 816int twl_exit_irq(void);
807int twl_init_chip_irq(const char *chip); 817int twl_init_chip_irq(const char *chip);
808 818
809static int twl4030_remove(struct i2c_client *client) 819static int twl_remove(struct i2c_client *client)
810{ 820{
811 unsigned i; 821 unsigned i;
812 int status; 822 int status;
@@ -815,12 +825,12 @@ static int twl4030_remove(struct i2c_client *client)
815 if (status < 0) 825 if (status < 0)
816 return status; 826 return status;
817 827
818 for (i = 0; i < TWL4030_NUM_SLAVES; i++) { 828 for (i = 0; i < TWL_NUM_SLAVES; i++) {
819 struct twl4030_client *twl = &twl4030_modules[i]; 829 struct twl_client *twl = &twl_modules[i];
820 830
821 if (twl->client && twl->client != client) 831 if (twl->client && twl->client != client)
822 i2c_unregister_device(twl->client); 832 i2c_unregister_device(twl->client);
823 twl4030_modules[i].client = NULL; 833 twl_modules[i].client = NULL;
824 } 834 }
825 inuse = false; 835 inuse = false;
826 return 0; 836 return 0;
@@ -828,7 +838,7 @@ static int twl4030_remove(struct i2c_client *client)
828 838
829/* NOTE: this driver only handles a single twl4030/tps659x0 chip */ 839/* NOTE: this driver only handles a single twl4030/tps659x0 chip */
830static int __init 840static int __init
831twl4030_probe(struct i2c_client *client, const struct i2c_device_id *id) 841twl_probe(struct i2c_client *client, const struct i2c_device_id *id)
832{ 842{
833 int status; 843 int status;
834 unsigned i; 844 unsigned i;
@@ -849,8 +859,8 @@ twl4030_probe(struct i2c_client *client, const struct i2c_device_id *id)
849 return -EBUSY; 859 return -EBUSY;
850 } 860 }
851 861
852 for (i = 0; i < TWL4030_NUM_SLAVES; i++) { 862 for (i = 0; i < TWL_NUM_SLAVES; i++) {
853 struct twl4030_client *twl = &twl4030_modules[i]; 863 struct twl_client *twl = &twl_modules[i];
854 864
855 twl->address = client->addr + i; 865 twl->address = client->addr + i;
856 if (i == 0) 866 if (i == 0)
@@ -889,11 +899,11 @@ twl4030_probe(struct i2c_client *client, const struct i2c_device_id *id)
889 status = add_children(pdata, id->driver_data); 899 status = add_children(pdata, id->driver_data);
890fail: 900fail:
891 if (status < 0) 901 if (status < 0)
892 twl4030_remove(client); 902 twl_remove(client);
893 return status; 903 return status;
894} 904}
895 905
896static const struct i2c_device_id twl4030_ids[] = { 906static const struct i2c_device_id twl_ids[] = {
897 { "twl4030", TWL4030_VAUX2 }, /* "Triton 2" */ 907 { "twl4030", TWL4030_VAUX2 }, /* "Triton 2" */
898 { "twl5030", 0 }, /* T2 updated */ 908 { "twl5030", 0 }, /* T2 updated */
899 { "twl5031", TWL5031 }, /* TWL5030 updated */ 909 { "twl5031", TWL5031 }, /* TWL5030 updated */
@@ -902,28 +912,28 @@ static const struct i2c_device_id twl4030_ids[] = {
902 { "tps65920", TPS_SUBSET }, /* fewer LDOs; no codec or charger */ 912 { "tps65920", TPS_SUBSET }, /* fewer LDOs; no codec or charger */
903 { /* end of list */ }, 913 { /* end of list */ },
904}; 914};
905MODULE_DEVICE_TABLE(i2c, twl4030_ids); 915MODULE_DEVICE_TABLE(i2c, twl_ids);
906 916
907/* One Client Driver , 4 Clients */ 917/* One Client Driver , 4 Clients */
908static struct i2c_driver twl4030_driver = { 918static struct i2c_driver twl_driver = {
909 .driver.name = DRIVER_NAME, 919 .driver.name = DRIVER_NAME,
910 .id_table = twl4030_ids, 920 .id_table = twl_ids,
911 .probe = twl4030_probe, 921 .probe = twl_probe,
912 .remove = twl4030_remove, 922 .remove = twl_remove,
913}; 923};
914 924
915static int __init twl4030_init(void) 925static int __init twl_init(void)
916{ 926{
917 return i2c_add_driver(&twl4030_driver); 927 return i2c_add_driver(&twl_driver);
918} 928}
919subsys_initcall(twl4030_init); 929subsys_initcall(twl_init);
920 930
921static void __exit twl4030_exit(void) 931static void __exit twl_exit(void)
922{ 932{
923 i2c_del_driver(&twl4030_driver); 933 i2c_del_driver(&twl_driver);
924} 934}
925module_exit(twl4030_exit); 935module_exit(twl_exit);
926 936
927MODULE_AUTHOR("Texas Instruments, Inc."); 937MODULE_AUTHOR("Texas Instruments, Inc.");
928MODULE_DESCRIPTION("I2C Core interface for TWL4030"); 938MODULE_DESCRIPTION("I2C Core interface for TWL");
929MODULE_LICENSE("GPL"); 939MODULE_LICENSE("GPL");
diff --git a/drivers/mfd/twl4030-irq.c b/drivers/mfd/twl4030-irq.c
index c4528db549c6..5a62cf916987 100644
--- a/drivers/mfd/twl4030-irq.c
+++ b/drivers/mfd/twl4030-irq.c
@@ -296,7 +296,7 @@ static int twl4030_irq_thread(void *data)
296 /* Wait for IRQ, then read PIH irq status (also blocking) */ 296 /* Wait for IRQ, then read PIH irq status (also blocking) */
297 wait_for_completion_interruptible(&irq_event); 297 wait_for_completion_interruptible(&irq_event);
298 298
299 ret = twl4030_i2c_read_u8(TWL4030_MODULE_PIH, &pih_isr, 299 ret = twl_i2c_read_u8(TWL4030_MODULE_PIH, &pih_isr,
300 REG_PIH_ISR_P1); 300 REG_PIH_ISR_P1);
301 if (ret) { 301 if (ret) {
302 pr_warning("twl4030: I2C error %d reading PIH ISR\n", 302 pr_warning("twl4030: I2C error %d reading PIH ISR\n",
@@ -396,7 +396,7 @@ static int twl4030_init_sih_modules(unsigned line)
396 if (sih->irq_lines <= line) 396 if (sih->irq_lines <= line)
397 continue; 397 continue;
398 398
399 status = twl4030_i2c_write(sih->module, buf, 399 status = twl_i2c_write(sih->module, buf,
400 sih->mask[line].imr_offset, sih->bytes_ixr); 400 sih->mask[line].imr_offset, sih->bytes_ixr);
401 if (status < 0) 401 if (status < 0)
402 pr_err("twl4030: err %d initializing %s %s\n", 402 pr_err("twl4030: err %d initializing %s %s\n",
@@ -410,7 +410,7 @@ static int twl4030_init_sih_modules(unsigned line)
410 * And for PWR_INT it's not documented... 410 * And for PWR_INT it's not documented...
411 */ 411 */
412 if (sih->set_cor) { 412 if (sih->set_cor) {
413 status = twl4030_i2c_write_u8(sih->module, 413 status = twl_i2c_write_u8(sih->module,
414 TWL4030_SIH_CTRL_COR_MASK, 414 TWL4030_SIH_CTRL_COR_MASK,
415 sih->control_offset); 415 sih->control_offset);
416 if (status < 0) 416 if (status < 0)
@@ -438,14 +438,14 @@ static int twl4030_init_sih_modules(unsigned line)
438 * uncommon with PWR_INT.PWRON. 438 * uncommon with PWR_INT.PWRON.
439 */ 439 */
440 for (j = 0; j < 2; j++) { 440 for (j = 0; j < 2; j++) {
441 status = twl4030_i2c_read(sih->module, rxbuf, 441 status = twl_i2c_read(sih->module, rxbuf,
442 sih->mask[line].isr_offset, sih->bytes_ixr); 442 sih->mask[line].isr_offset, sih->bytes_ixr);
443 if (status < 0) 443 if (status < 0)
444 pr_err("twl4030: err %d initializing %s %s\n", 444 pr_err("twl4030: err %d initializing %s %s\n",
445 status, sih->name, "ISR"); 445 status, sih->name, "ISR");
446 446
447 if (!sih->set_cor) 447 if (!sih->set_cor)
448 status = twl4030_i2c_write(sih->module, buf, 448 status = twl_i2c_write(sih->module, buf,
449 sih->mask[line].isr_offset, 449 sih->mask[line].isr_offset,
450 sih->bytes_ixr); 450 sih->bytes_ixr);
451 /* else COR=1 means read sufficed. 451 /* else COR=1 means read sufficed.
@@ -514,7 +514,7 @@ static void twl4030_sih_do_mask(struct work_struct *work)
514 return; 514 return;
515 515
516 /* write the whole mask ... simpler than subsetting it */ 516 /* write the whole mask ... simpler than subsetting it */
517 status = twl4030_i2c_write(sih->module, imr.bytes, 517 status = twl_i2c_write(sih->module, imr.bytes,
518 sih->mask[irq_line].imr_offset, sih->bytes_ixr); 518 sih->mask[irq_line].imr_offset, sih->bytes_ixr);
519 if (status) 519 if (status)
520 pr_err("twl4030: %s, %s --> %d\n", __func__, 520 pr_err("twl4030: %s, %s --> %d\n", __func__,
@@ -545,7 +545,7 @@ static void twl4030_sih_do_edge(struct work_struct *work)
545 * any processor on the other IRQ line, EDR registers are 545 * any processor on the other IRQ line, EDR registers are
546 * shared. 546 * shared.
547 */ 547 */
548 status = twl4030_i2c_read(sih->module, bytes + 1, 548 status = twl_i2c_read(sih->module, bytes + 1,
549 sih->edr_offset, sih->bytes_edr); 549 sih->edr_offset, sih->bytes_edr);
550 if (status) { 550 if (status) {
551 pr_err("twl4030: %s, %s --> %d\n", __func__, 551 pr_err("twl4030: %s, %s --> %d\n", __func__,
@@ -579,7 +579,7 @@ static void twl4030_sih_do_edge(struct work_struct *work)
579 } 579 }
580 580
581 /* Write */ 581 /* Write */
582 status = twl4030_i2c_write(sih->module, bytes, 582 status = twl_i2c_write(sih->module, bytes,
583 sih->edr_offset, sih->bytes_edr); 583 sih->edr_offset, sih->bytes_edr);
584 if (status) 584 if (status)
585 pr_err("twl4030: %s, %s --> %d\n", __func__, 585 pr_err("twl4030: %s, %s --> %d\n", __func__,
@@ -664,7 +664,7 @@ static inline int sih_read_isr(const struct sih *sih)
664 /* FIXME need retry-on-error ... */ 664 /* FIXME need retry-on-error ... */
665 665
666 isr.word = 0; 666 isr.word = 0;
667 status = twl4030_i2c_read(sih->module, isr.bytes, 667 status = twl_i2c_read(sih->module, isr.bytes,
668 sih->mask[irq_line].isr_offset, sih->bytes_ixr); 668 sih->mask[irq_line].isr_offset, sih->bytes_ixr);
669 669
670 return (status < 0) ? status : le32_to_cpu(isr.word); 670 return (status < 0) ? status : le32_to_cpu(isr.word);
diff --git a/drivers/mfd/twl4030-power.c b/drivers/mfd/twl4030-power.c
index 424b255d6f92..0815292fdafc 100644
--- a/drivers/mfd/twl4030-power.c
+++ b/drivers/mfd/twl4030-power.c
@@ -131,11 +131,11 @@ static int __init twl4030_write_script_byte(u8 address, u8 byte)
131{ 131{
132 int err; 132 int err;
133 133
134 err = twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, address, 134 err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, address,
135 R_MEMORY_ADDRESS); 135 R_MEMORY_ADDRESS);
136 if (err) 136 if (err)
137 goto out; 137 goto out;
138 err = twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, byte, 138 err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, byte,
139 R_MEMORY_DATA); 139 R_MEMORY_DATA);
140out: 140out:
141 return err; 141 return err;
@@ -192,18 +192,18 @@ static int __init twl4030_config_wakeup3_sequence(u8 address)
192 u8 data; 192 u8 data;
193 193
194 /* Set SLEEP to ACTIVE SEQ address for P3 */ 194 /* Set SLEEP to ACTIVE SEQ address for P3 */
195 err = twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, address, 195 err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, address,
196 R_SEQ_ADD_S2A3); 196 R_SEQ_ADD_S2A3);
197 if (err) 197 if (err)
198 goto out; 198 goto out;
199 199
200 /* P3 LVL_WAKEUP should be on LEVEL */ 200 /* P3 LVL_WAKEUP should be on LEVEL */
201 err = twl4030_i2c_read_u8(TWL4030_MODULE_PM_MASTER, &data, 201 err = twl_i2c_read_u8(TWL4030_MODULE_PM_MASTER, &data,
202 R_P3_SW_EVENTS); 202 R_P3_SW_EVENTS);
203 if (err) 203 if (err)
204 goto out; 204 goto out;
205 data |= LVL_WAKEUP; 205 data |= LVL_WAKEUP;
206 err = twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, data, 206 err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, data,
207 R_P3_SW_EVENTS); 207 R_P3_SW_EVENTS);
208out: 208out:
209 if (err) 209 if (err)
@@ -217,42 +217,42 @@ static int __init twl4030_config_wakeup12_sequence(u8 address)
217 u8 data; 217 u8 data;
218 218
219 /* Set SLEEP to ACTIVE SEQ address for P1 and P2 */ 219 /* Set SLEEP to ACTIVE SEQ address for P1 and P2 */
220 err = twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, address, 220 err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, address,
221 R_SEQ_ADD_S2A12); 221 R_SEQ_ADD_S2A12);
222 if (err) 222 if (err)
223 goto out; 223 goto out;
224 224
225 /* P1/P2 LVL_WAKEUP should be on LEVEL */ 225 /* P1/P2 LVL_WAKEUP should be on LEVEL */
226 err = twl4030_i2c_read_u8(TWL4030_MODULE_PM_MASTER, &data, 226 err = twl_i2c_read_u8(TWL4030_MODULE_PM_MASTER, &data,
227 R_P1_SW_EVENTS); 227 R_P1_SW_EVENTS);
228 if (err) 228 if (err)
229 goto out; 229 goto out;
230 230
231 data |= LVL_WAKEUP; 231 data |= LVL_WAKEUP;
232 err = twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, data, 232 err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, data,
233 R_P1_SW_EVENTS); 233 R_P1_SW_EVENTS);
234 if (err) 234 if (err)
235 goto out; 235 goto out;
236 236
237 err = twl4030_i2c_read_u8(TWL4030_MODULE_PM_MASTER, &data, 237 err = twl_i2c_read_u8(TWL4030_MODULE_PM_MASTER, &data,
238 R_P2_SW_EVENTS); 238 R_P2_SW_EVENTS);
239 if (err) 239 if (err)
240 goto out; 240 goto out;
241 241
242 data |= LVL_WAKEUP; 242 data |= LVL_WAKEUP;
243 err = twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, data, 243 err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, data,
244 R_P2_SW_EVENTS); 244 R_P2_SW_EVENTS);
245 if (err) 245 if (err)
246 goto out; 246 goto out;
247 247
248 if (machine_is_omap_3430sdp() || machine_is_omap_ldp()) { 248 if (machine_is_omap_3430sdp() || machine_is_omap_ldp()) {
249 /* Disabling AC charger effect on sleep-active transitions */ 249 /* Disabling AC charger effect on sleep-active transitions */
250 err = twl4030_i2c_read_u8(TWL4030_MODULE_PM_MASTER, &data, 250 err = twl_i2c_read_u8(TWL4030_MODULE_PM_MASTER, &data,
251 R_CFG_P1_TRANSITION); 251 R_CFG_P1_TRANSITION);
252 if (err) 252 if (err)
253 goto out; 253 goto out;
254 data &= ~(1<<1); 254 data &= ~(1<<1);
255 err = twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, data , 255 err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, data ,
256 R_CFG_P1_TRANSITION); 256 R_CFG_P1_TRANSITION);
257 if (err) 257 if (err)
258 goto out; 258 goto out;
@@ -270,7 +270,7 @@ static int __init twl4030_config_sleep_sequence(u8 address)
270 int err; 270 int err;
271 271
272 /* Set ACTIVE to SLEEP SEQ address in T2 memory*/ 272 /* Set ACTIVE to SLEEP SEQ address in T2 memory*/
273 err = twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, address, 273 err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, address,
274 R_SEQ_ADD_A2S); 274 R_SEQ_ADD_A2S);
275 275
276 if (err) 276 if (err)
@@ -285,41 +285,41 @@ static int __init twl4030_config_warmreset_sequence(u8 address)
285 u8 rd_data; 285 u8 rd_data;
286 286
287 /* Set WARM RESET SEQ address for P1 */ 287 /* Set WARM RESET SEQ address for P1 */
288 err = twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, address, 288 err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, address,
289 R_SEQ_ADD_WARM); 289 R_SEQ_ADD_WARM);
290 if (err) 290 if (err)
291 goto out; 291 goto out;
292 292
293 /* P1/P2/P3 enable WARMRESET */ 293 /* P1/P2/P3 enable WARMRESET */
294 err = twl4030_i2c_read_u8(TWL4030_MODULE_PM_MASTER, &rd_data, 294 err = twl_i2c_read_u8(TWL4030_MODULE_PM_MASTER, &rd_data,
295 R_P1_SW_EVENTS); 295 R_P1_SW_EVENTS);
296 if (err) 296 if (err)
297 goto out; 297 goto out;
298 298
299 rd_data |= ENABLE_WARMRESET; 299 rd_data |= ENABLE_WARMRESET;
300 err = twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, rd_data, 300 err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, rd_data,
301 R_P1_SW_EVENTS); 301 R_P1_SW_EVENTS);
302 if (err) 302 if (err)
303 goto out; 303 goto out;
304 304
305 err = twl4030_i2c_read_u8(TWL4030_MODULE_PM_MASTER, &rd_data, 305 err = twl_i2c_read_u8(TWL4030_MODULE_PM_MASTER, &rd_data,
306 R_P2_SW_EVENTS); 306 R_P2_SW_EVENTS);
307 if (err) 307 if (err)
308 goto out; 308 goto out;
309 309
310 rd_data |= ENABLE_WARMRESET; 310 rd_data |= ENABLE_WARMRESET;
311 err = twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, rd_data, 311 err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, rd_data,
312 R_P2_SW_EVENTS); 312 R_P2_SW_EVENTS);
313 if (err) 313 if (err)
314 goto out; 314 goto out;
315 315
316 err = twl4030_i2c_read_u8(TWL4030_MODULE_PM_MASTER, &rd_data, 316 err = twl_i2c_read_u8(TWL4030_MODULE_PM_MASTER, &rd_data,
317 R_P3_SW_EVENTS); 317 R_P3_SW_EVENTS);
318 if (err) 318 if (err)
319 goto out; 319 goto out;
320 320
321 rd_data |= ENABLE_WARMRESET; 321 rd_data |= ENABLE_WARMRESET;
322 err = twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, rd_data, 322 err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, rd_data,
323 R_P3_SW_EVENTS); 323 R_P3_SW_EVENTS);
324out: 324out:
325 if (err) 325 if (err)
@@ -344,8 +344,8 @@ static int __init twl4030_configure_resource(struct twl4030_resconfig *rconfig)
344 rconfig_addr = res_config_addrs[rconfig->resource]; 344 rconfig_addr = res_config_addrs[rconfig->resource];
345 345
346 /* Set resource group */ 346 /* Set resource group */
347 err = twl4030_i2c_read_u8(TWL4030_MODULE_PM_RECEIVER, &grp, 347 err = twl_i2c_read_u8(TWL4030_MODULE_PM_RECEIVER, &grp,
348 rconfig_addr + DEV_GRP_OFFSET); 348 rconfig_addr + DEV_GRP_OFFSET);
349 if (err) { 349 if (err) {
350 pr_err("TWL4030 Resource %d group could not be read\n", 350 pr_err("TWL4030 Resource %d group could not be read\n",
351 rconfig->resource); 351 rconfig->resource);
@@ -355,8 +355,8 @@ static int __init twl4030_configure_resource(struct twl4030_resconfig *rconfig)
355 if (rconfig->devgroup != TWL4030_RESCONFIG_UNDEF) { 355 if (rconfig->devgroup != TWL4030_RESCONFIG_UNDEF) {
356 grp &= ~DEV_GRP_MASK; 356 grp &= ~DEV_GRP_MASK;
357 grp |= rconfig->devgroup << DEV_GRP_SHIFT; 357 grp |= rconfig->devgroup << DEV_GRP_SHIFT;
358 err = twl4030_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, 358 err = twl_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER,
359 grp, rconfig_addr + DEV_GRP_OFFSET); 359 grp, rconfig_addr + DEV_GRP_OFFSET);
360 if (err < 0) { 360 if (err < 0) {
361 pr_err("TWL4030 failed to program devgroup\n"); 361 pr_err("TWL4030 failed to program devgroup\n");
362 return err; 362 return err;
@@ -364,7 +364,7 @@ static int __init twl4030_configure_resource(struct twl4030_resconfig *rconfig)
364 } 364 }
365 365
366 /* Set resource types */ 366 /* Set resource types */
367 err = twl4030_i2c_read_u8(TWL4030_MODULE_PM_RECEIVER, &type, 367 err = twl_i2c_read_u8(TWL4030_MODULE_PM_RECEIVER, &type,
368 rconfig_addr + TYPE_OFFSET); 368 rconfig_addr + TYPE_OFFSET);
369 if (err < 0) { 369 if (err < 0) {
370 pr_err("TWL4030 Resource %d type could not be read\n", 370 pr_err("TWL4030 Resource %d type could not be read\n",
@@ -382,7 +382,7 @@ static int __init twl4030_configure_resource(struct twl4030_resconfig *rconfig)
382 type |= rconfig->type2 << TYPE2_SHIFT; 382 type |= rconfig->type2 << TYPE2_SHIFT;
383 } 383 }
384 384
385 err = twl4030_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, 385 err = twl_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER,
386 type, rconfig_addr + TYPE_OFFSET); 386 type, rconfig_addr + TYPE_OFFSET);
387 if (err < 0) { 387 if (err < 0) {
388 pr_err("TWL4030 failed to program resource type\n"); 388 pr_err("TWL4030 failed to program resource type\n");
@@ -390,8 +390,8 @@ static int __init twl4030_configure_resource(struct twl4030_resconfig *rconfig)
390 } 390 }
391 391
392 /* Set remap states */ 392 /* Set remap states */
393 err = twl4030_i2c_read_u8(TWL4030_MODULE_PM_RECEIVER, &remap, 393 err = twl_i2c_read_u8(TWL4030_MODULE_PM_RECEIVER, &remap,
394 rconfig_addr + REMAP_OFFSET); 394 rconfig_addr + REMAP_OFFSET);
395 if (err < 0) { 395 if (err < 0) {
396 pr_err("TWL4030 Resource %d remap could not be read\n", 396 pr_err("TWL4030 Resource %d remap could not be read\n",
397 rconfig->resource); 397 rconfig->resource);
@@ -408,9 +408,9 @@ static int __init twl4030_configure_resource(struct twl4030_resconfig *rconfig)
408 remap |= rconfig->remap_off << SLEEP_STATE_SHIFT; 408 remap |= rconfig->remap_off << SLEEP_STATE_SHIFT;
409 } 409 }
410 410
411 err = twl4030_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, 411 err = twl_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER,
412 remap, 412 remap,
413 rconfig_addr + REMAP_OFFSET); 413 rconfig_addr + REMAP_OFFSET);
414 if (err < 0) { 414 if (err < 0) {
415 pr_err("TWL4030 failed to program remap\n"); 415 pr_err("TWL4030 failed to program remap\n");
416 return err; 416 return err;
@@ -468,12 +468,12 @@ void __init twl4030_power_init(struct twl4030_power_data *twl4030_scripts)
468 struct twl4030_resconfig *resconfig; 468 struct twl4030_resconfig *resconfig;
469 u8 address = twl4030_start_script_address; 469 u8 address = twl4030_start_script_address;
470 470
471 err = twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, R_KEY_1, 471 err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, R_KEY_1,
472 R_PROTECT_KEY); 472 R_PROTECT_KEY);
473 if (err) 473 if (err)
474 goto unlock; 474 goto unlock;
475 475
476 err = twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, R_KEY_2, 476 err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, R_KEY_2,
477 R_PROTECT_KEY); 477 R_PROTECT_KEY);
478 if (err) 478 if (err)
479 goto unlock; 479 goto unlock;
@@ -496,7 +496,7 @@ void __init twl4030_power_init(struct twl4030_power_data *twl4030_scripts)
496 } 496 }
497 } 497 }
498 498
499 err = twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, 0, R_PROTECT_KEY); 499 err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, 0, R_PROTECT_KEY);
500 if (err) 500 if (err)
501 pr_err("TWL4030 Unable to relock registers\n"); 501 pr_err("TWL4030 Unable to relock registers\n");
502 return; 502 return;