aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mfd/twl-core.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-10-04 23:01:30 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-10-04 23:01:30 -0400
commit578f1ef91aa92beb571bfb9af8f4d18f405f3b9e (patch)
tree8ff59e772d09180b7e7f952a8c90a1bcf25e1d19 /drivers/mfd/twl-core.c
parentecefbd94b834fa32559d854646d777c56749ef1c (diff)
parent74d8378159de16a0a1d1975d4778120d263d6000 (diff)
Merge tag 'mfd-3.7-1' of git://git.kernel.org/pub/scm/linux/kernel/git/sameo/mfd-2.6
Pull MFD changes from Samuel Ortiz: "MFD bits for the 3.7 merge window. As usual we have a few new drivers: - TI LP8788 - TI OMAP USB TLL - Maxim MAX8907 - SMSC ECE1099 - Dialog Semiconductor DA9055 - A simpler syscon driver that allow us to get rid of the anatop one. Drivers are also gradually getting Device Tree and IRQ domain support. The following drivers got DT support: - palmas, 88pm860x, tc3589x and twl4030-audio And those ones now use the IRQ domain APIs: - 88pm860x, tc3589x, db8500_prcmu Also some other interesting changes: - Intel's ICH LPC now supports Lynx Point - TI's twl4030-audio added a GPO child - tps6527 enabled its backlight subdevice - The twl6030 pwm driver moved to the new PWM subsystem And finally a bunch of cleanup and casual fixes for mc13xxx, 88pm860x, palmas, ab8500, wm8994, wm5110, max8907 and the tps65xxx family." Fix up various annoying conflicts: the DT and IRQ domain support came in twice and was already in 3.6. And then it was apparently rebased. Guys, DON'T REBASE! * tag 'mfd-3.7-1' of git://git.kernel.org/pub/scm/linux/kernel/git/sameo/mfd-2.6: (89 commits) ARM: dts: Enable 88pm860x pmic mfd: 88pm860x: Move gpadc init into touch mfd: 88pm860x: Device tree support mfd: 88pm860x: Use irqdomain mfd: smsc: Add support for smsc gpio io/keypad driver backlight: tps65217_bl: Add missing platform_set_drvdata in tps65217_bl_probe mfd: DA9055 core driver mfd: tps65910: Add alarm interrupt of TPS65910 RTC to mfd device list mfd: wm5110: Add register patches for revision B mfd: wm5110: Disable control interface error report for WM5110 rev B mfd: max8907: Remove regulator-compatible from DT docs backlight: Add TPS65217 WLED driver mfd: Add backlight as subdevice to the tps65217 mfd: Provide the PRCMU with its own IRQ domain mfd: Fix max8907 sparse warning mfd: Add lp8788 mfd driver mfd: dbx500: Provide a more accurate smp_twd clock mfd: rc5t583: Fix warning messages regulator: palmas: Add DT support mfd: palmas: Change regulator defns to better suite DT ...
Diffstat (limited to 'drivers/mfd/twl-core.c')
-rw-r--r--drivers/mfd/twl-core.c156
1 files changed, 64 insertions, 92 deletions
diff --git a/drivers/mfd/twl-core.c b/drivers/mfd/twl-core.c
index 9d3a0bc1a65f..4ae642320205 100644
--- a/drivers/mfd/twl-core.c
+++ b/drivers/mfd/twl-core.c
@@ -63,70 +63,6 @@
63 63
64#define DRIVER_NAME "twl" 64#define DRIVER_NAME "twl"
65 65
66#if defined(CONFIG_KEYBOARD_TWL4030) || defined(CONFIG_KEYBOARD_TWL4030_MODULE)
67#define twl_has_keypad() true
68#else
69#define twl_has_keypad() false
70#endif
71
72#if defined(CONFIG_GPIO_TWL4030) || defined(CONFIG_GPIO_TWL4030_MODULE)
73#define twl_has_gpio() true
74#else
75#define twl_has_gpio() false
76#endif
77
78#if defined(CONFIG_REGULATOR_TWL4030) \
79 || defined(CONFIG_REGULATOR_TWL4030_MODULE)
80#define twl_has_regulator() true
81#else
82#define twl_has_regulator() false
83#endif
84
85#if defined(CONFIG_TWL4030_MADC) || defined(CONFIG_TWL4030_MADC_MODULE)
86#define twl_has_madc() true
87#else
88#define twl_has_madc() false
89#endif
90
91#ifdef CONFIG_TWL4030_POWER
92#define twl_has_power() true
93#else
94#define twl_has_power() false
95#endif
96
97#if defined(CONFIG_RTC_DRV_TWL4030) || defined(CONFIG_RTC_DRV_TWL4030_MODULE)
98#define twl_has_rtc() true
99#else
100#define twl_has_rtc() false
101#endif
102
103#if defined(CONFIG_TWL4030_USB) || defined(CONFIG_TWL4030_USB_MODULE) ||\
104 defined(CONFIG_TWL6030_USB) || defined(CONFIG_TWL6030_USB_MODULE)
105#define twl_has_usb() true
106#else
107#define twl_has_usb() false
108#endif
109
110#if defined(CONFIG_TWL4030_WATCHDOG) || \
111 defined(CONFIG_TWL4030_WATCHDOG_MODULE)
112#define twl_has_watchdog() true
113#else
114#define twl_has_watchdog() false
115#endif
116
117#if defined(CONFIG_MFD_TWL4030_AUDIO) || \
118 defined(CONFIG_MFD_TWL4030_AUDIO_MODULE)
119#define twl_has_codec() true
120#else
121#define twl_has_codec() false
122#endif
123
124#if defined(CONFIG_CHARGER_TWL4030) || defined(CONFIG_CHARGER_TWL4030_MODULE)
125#define twl_has_bci() true
126#else
127#define twl_has_bci() false
128#endif
129
130/* Triton Core internal information (BEGIN) */ 66/* Triton Core internal information (BEGIN) */
131 67
132/* Last - for index max*/ 68/* Last - for index max*/
@@ -134,13 +70,6 @@
134 70
135#define TWL_NUM_SLAVES 4 71#define TWL_NUM_SLAVES 4
136 72
137#if defined(CONFIG_INPUT_TWL4030_PWRBUTTON) \
138 || defined(CONFIG_INPUT_TWL4030_PWRBUTTON_MODULE)
139#define twl_has_pwrbutton() true
140#else
141#define twl_has_pwrbutton() false
142#endif
143
144#define SUB_CHIP_ID0 0 73#define SUB_CHIP_ID0 0
145#define SUB_CHIP_ID1 1 74#define SUB_CHIP_ID1 1
146#define SUB_CHIP_ID2 2 75#define SUB_CHIP_ID2 2
@@ -552,6 +481,38 @@ int twl_get_version(void)
552} 481}
553EXPORT_SYMBOL_GPL(twl_get_version); 482EXPORT_SYMBOL_GPL(twl_get_version);
554 483
484/**
485 * twl_get_hfclk_rate - API to get TWL external HFCLK clock rate.
486 *
487 * Api to get the TWL HFCLK rate based on BOOT_CFG register.
488 */
489int twl_get_hfclk_rate(void)
490{
491 u8 ctrl;
492 int rate;
493
494 twl_i2c_read_u8(TWL_MODULE_PM_MASTER, &ctrl, R_CFG_BOOT);
495
496 switch (ctrl & 0x3) {
497 case HFCLK_FREQ_19p2_MHZ:
498 rate = 19200000;
499 break;
500 case HFCLK_FREQ_26_MHZ:
501 rate = 26000000;
502 break;
503 case HFCLK_FREQ_38p4_MHZ:
504 rate = 38400000;
505 break;
506 default:
507 pr_err("TWL4030: HFCLK is not configured\n");
508 rate = -EINVAL;
509 break;
510 }
511
512 return rate;
513}
514EXPORT_SYMBOL_GPL(twl_get_hfclk_rate);
515
555static struct device * 516static struct device *
556add_numbered_child(unsigned chip, const char *name, int num, 517add_numbered_child(unsigned chip, const char *name, int num,
557 void *pdata, unsigned pdata_len, 518 void *pdata, unsigned pdata_len,
@@ -669,7 +630,7 @@ add_children(struct twl4030_platform_data *pdata, unsigned irq_base,
669 struct device *child; 630 struct device *child;
670 unsigned sub_chip_id; 631 unsigned sub_chip_id;
671 632
672 if (twl_has_gpio() && pdata->gpio) { 633 if (IS_ENABLED(CONFIG_GPIO_TWL4030) && pdata->gpio) {
673 child = add_child(SUB_CHIP_ID1, "twl4030_gpio", 634 child = add_child(SUB_CHIP_ID1, "twl4030_gpio",
674 pdata->gpio, sizeof(*pdata->gpio), 635 pdata->gpio, sizeof(*pdata->gpio),
675 false, irq_base + GPIO_INTR_OFFSET, 0); 636 false, irq_base + GPIO_INTR_OFFSET, 0);
@@ -677,7 +638,7 @@ add_children(struct twl4030_platform_data *pdata, unsigned irq_base,
677 return PTR_ERR(child); 638 return PTR_ERR(child);
678 } 639 }
679 640
680 if (twl_has_keypad() && pdata->keypad) { 641 if (IS_ENABLED(CONFIG_KEYBOARD_TWL4030) && pdata->keypad) {
681 child = add_child(SUB_CHIP_ID2, "twl4030_keypad", 642 child = add_child(SUB_CHIP_ID2, "twl4030_keypad",
682 pdata->keypad, sizeof(*pdata->keypad), 643 pdata->keypad, sizeof(*pdata->keypad),
683 true, irq_base + KEYPAD_INTR_OFFSET, 0); 644 true, irq_base + KEYPAD_INTR_OFFSET, 0);
@@ -685,7 +646,7 @@ add_children(struct twl4030_platform_data *pdata, unsigned irq_base,
685 return PTR_ERR(child); 646 return PTR_ERR(child);
686 } 647 }
687 648
688 if (twl_has_madc() && pdata->madc) { 649 if (IS_ENABLED(CONFIG_TWL4030_MADC) && pdata->madc) {
689 child = add_child(2, "twl4030_madc", 650 child = add_child(2, "twl4030_madc",
690 pdata->madc, sizeof(*pdata->madc), 651 pdata->madc, sizeof(*pdata->madc),
691 true, irq_base + MADC_INTR_OFFSET, 0); 652 true, irq_base + MADC_INTR_OFFSET, 0);
@@ -693,7 +654,7 @@ add_children(struct twl4030_platform_data *pdata, unsigned irq_base,
693 return PTR_ERR(child); 654 return PTR_ERR(child);
694 } 655 }
695 656
696 if (twl_has_rtc()) { 657 if (IS_ENABLED(CONFIG_RTC_DRV_TWL4030)) {
697 /* 658 /*
698 * REVISIT platform_data here currently might expose the 659 * REVISIT platform_data here currently might expose the
699 * "msecure" line ... but for now we just expect board 660 * "msecure" line ... but for now we just expect board
@@ -709,7 +670,15 @@ add_children(struct twl4030_platform_data *pdata, unsigned irq_base,
709 return PTR_ERR(child); 670 return PTR_ERR(child);
710 } 671 }
711 672
712 if (twl_has_usb() && pdata->usb && twl_class_is_4030()) { 673 if (IS_ENABLED(CONFIG_PWM_TWL6030) && twl_class_is_6030()) {
674 child = add_child(TWL6030_MODULE_ID1, "twl6030-pwm", NULL, 0,
675 false, 0, 0);
676 if (IS_ERR(child))
677 return PTR_ERR(child);
678 }
679
680 if (IS_ENABLED(CONFIG_TWL4030_USB) && pdata->usb &&
681 twl_class_is_4030()) {
713 682
714 static struct regulator_consumer_supply usb1v5 = { 683 static struct regulator_consumer_supply usb1v5 = {
715 .supply = "usb1v5", 684 .supply = "usb1v5",
@@ -723,7 +692,7 @@ add_children(struct twl4030_platform_data *pdata, unsigned irq_base,
723 }; 692 };
724 693
725 /* First add the regulators so that they can be used by transceiver */ 694 /* First add the regulators so that they can be used by transceiver */
726 if (twl_has_regulator()) { 695 if (IS_ENABLED(CONFIG_REGULATOR_TWL4030)) {
727 /* this is a template that gets copied */ 696 /* this is a template that gets copied */
728 struct regulator_init_data usb_fixed = { 697 struct regulator_init_data usb_fixed = {
729 .constraints.valid_modes_mask = 698 .constraints.valid_modes_mask =
@@ -765,18 +734,19 @@ add_children(struct twl4030_platform_data *pdata, unsigned irq_base,
765 return PTR_ERR(child); 734 return PTR_ERR(child);
766 735
767 /* we need to connect regulators to this transceiver */ 736 /* we need to connect regulators to this transceiver */
768 if (twl_has_regulator() && child) { 737 if (IS_ENABLED(CONFIG_REGULATOR_TWL4030) && child) {
769 usb1v5.dev_name = dev_name(child); 738 usb1v5.dev_name = dev_name(child);
770 usb1v8.dev_name = dev_name(child); 739 usb1v8.dev_name = dev_name(child);
771 usb3v1[0].dev_name = dev_name(child); 740 usb3v1[0].dev_name = dev_name(child);
772 } 741 }
773 } 742 }
774 if (twl_has_usb() && pdata->usb && twl_class_is_6030()) { 743 if (IS_ENABLED(CONFIG_TWL6030_USB) && pdata->usb &&
744 twl_class_is_6030()) {
775 745
776 static struct regulator_consumer_supply usb3v3; 746 static struct regulator_consumer_supply usb3v3;
777 int regulator; 747 int regulator;
778 748
779 if (twl_has_regulator()) { 749 if (IS_ENABLED(CONFIG_REGULATOR_TWL4030)) {
780 /* this is a template that gets copied */ 750 /* this is a template that gets copied */
781 struct regulator_init_data usb_fixed = { 751 struct regulator_init_data usb_fixed = {
782 .constraints.valid_modes_mask = 752 .constraints.valid_modes_mask =
@@ -813,9 +783,10 @@ add_children(struct twl4030_platform_data *pdata, unsigned irq_base,
813 if (IS_ERR(child)) 783 if (IS_ERR(child))
814 return PTR_ERR(child); 784 return PTR_ERR(child);
815 /* we need to connect regulators to this transceiver */ 785 /* we need to connect regulators to this transceiver */
816 if (twl_has_regulator() && child) 786 if (IS_ENABLED(CONFIG_REGULATOR_TWL4030) && child)
817 usb3v3.dev_name = dev_name(child); 787 usb3v3.dev_name = dev_name(child);
818 } else if (twl_has_regulator() && twl_class_is_6030()) { 788 } else if (IS_ENABLED(CONFIG_REGULATOR_TWL4030) &&
789 twl_class_is_6030()) {
819 if (features & TWL6025_SUBCLASS) 790 if (features & TWL6025_SUBCLASS)
820 child = add_regulator(TWL6025_REG_LDOUSB, 791 child = add_regulator(TWL6025_REG_LDOUSB,
821 pdata->ldousb, features); 792 pdata->ldousb, features);
@@ -827,20 +798,21 @@ add_children(struct twl4030_platform_data *pdata, unsigned irq_base,
827 return PTR_ERR(child); 798 return PTR_ERR(child);
828 } 799 }
829 800
830 if (twl_has_watchdog() && twl_class_is_4030()) { 801 if (IS_ENABLED(CONFIG_TWL4030_WATCHDOG) && twl_class_is_4030()) {
831 child = add_child(0, "twl4030_wdt", NULL, 0, false, 0, 0); 802 child = add_child(0, "twl4030_wdt", NULL, 0, false, 0, 0);
832 if (IS_ERR(child)) 803 if (IS_ERR(child))
833 return PTR_ERR(child); 804 return PTR_ERR(child);
834 } 805 }
835 806
836 if (twl_has_pwrbutton() && twl_class_is_4030()) { 807 if (IS_ENABLED(CONFIG_INPUT_TWL4030_PWRBUTTON) && twl_class_is_4030()) {
837 child = add_child(1, "twl4030_pwrbutton", 808 child = add_child(1, "twl4030_pwrbutton",
838 NULL, 0, true, irq_base + 8 + 0, 0); 809 NULL, 0, true, irq_base + 8 + 0, 0);
839 if (IS_ERR(child)) 810 if (IS_ERR(child))
840 return PTR_ERR(child); 811 return PTR_ERR(child);
841 } 812 }
842 813
843 if (twl_has_codec() && pdata->audio && twl_class_is_4030()) { 814 if (IS_ENABLED(CONFIG_MFD_TWL4030_AUDIO) && pdata->audio &&
815 twl_class_is_4030()) {
844 sub_chip_id = twl_map[TWL_MODULE_AUDIO_VOICE].sid; 816 sub_chip_id = twl_map[TWL_MODULE_AUDIO_VOICE].sid;
845 child = add_child(sub_chip_id, "twl4030-audio", 817 child = add_child(sub_chip_id, "twl4030-audio",
846 pdata->audio, sizeof(*pdata->audio), 818 pdata->audio, sizeof(*pdata->audio),
@@ -850,7 +822,7 @@ add_children(struct twl4030_platform_data *pdata, unsigned irq_base,
850 } 822 }
851 823
852 /* twl4030 regulators */ 824 /* twl4030 regulators */
853 if (twl_has_regulator() && twl_class_is_4030()) { 825 if (IS_ENABLED(CONFIG_REGULATOR_TWL4030) && twl_class_is_4030()) {
854 child = add_regulator(TWL4030_REG_VPLL1, pdata->vpll1, 826 child = add_regulator(TWL4030_REG_VPLL1, pdata->vpll1,
855 features); 827 features);
856 if (IS_ERR(child)) 828 if (IS_ERR(child))
@@ -905,7 +877,7 @@ add_children(struct twl4030_platform_data *pdata, unsigned irq_base,
905 } 877 }
906 878
907 /* maybe add LDOs that are omitted on cost-reduced parts */ 879 /* maybe add LDOs that are omitted on cost-reduced parts */
908 if (twl_has_regulator() && !(features & TPS_SUBSET) 880 if (IS_ENABLED(CONFIG_REGULATOR_TWL4030) && !(features & TPS_SUBSET)
909 && twl_class_is_4030()) { 881 && twl_class_is_4030()) {
910 child = add_regulator(TWL4030_REG_VPLL2, pdata->vpll2, 882 child = add_regulator(TWL4030_REG_VPLL2, pdata->vpll2,
911 features); 883 features);
@@ -939,7 +911,7 @@ add_children(struct twl4030_platform_data *pdata, unsigned irq_base,
939 } 911 }
940 912
941 /* twl6030 regulators */ 913 /* twl6030 regulators */
942 if (twl_has_regulator() && twl_class_is_6030() && 914 if (IS_ENABLED(CONFIG_REGULATOR_TWL4030) && twl_class_is_6030() &&
943 !(features & TWL6025_SUBCLASS)) { 915 !(features & TWL6025_SUBCLASS)) {
944 child = add_regulator(TWL6030_REG_VDD1, pdata->vdd1, 916 child = add_regulator(TWL6030_REG_VDD1, pdata->vdd1,
945 features); 917 features);
@@ -1013,7 +985,7 @@ add_children(struct twl4030_platform_data *pdata, unsigned irq_base,
1013 } 985 }
1014 986
1015 /* 6030 and 6025 share this regulator */ 987 /* 6030 and 6025 share this regulator */
1016 if (twl_has_regulator() && twl_class_is_6030()) { 988 if (IS_ENABLED(CONFIG_REGULATOR_TWL4030) && twl_class_is_6030()) {
1017 child = add_regulator(TWL6030_REG_VANA, pdata->vana, 989 child = add_regulator(TWL6030_REG_VANA, pdata->vana,
1018 features); 990 features);
1019 if (IS_ERR(child)) 991 if (IS_ERR(child))
@@ -1021,7 +993,7 @@ add_children(struct twl4030_platform_data *pdata, unsigned irq_base,
1021 } 993 }
1022 994
1023 /* twl6025 regulators */ 995 /* twl6025 regulators */
1024 if (twl_has_regulator() && twl_class_is_6030() && 996 if (IS_ENABLED(CONFIG_REGULATOR_TWL4030) && twl_class_is_6030() &&
1025 (features & TWL6025_SUBCLASS)) { 997 (features & TWL6025_SUBCLASS)) {
1026 child = add_regulator(TWL6025_REG_LDO5, pdata->ldo5, 998 child = add_regulator(TWL6025_REG_LDO5, pdata->ldo5,
1027 features); 999 features);
@@ -1080,7 +1052,7 @@ add_children(struct twl4030_platform_data *pdata, unsigned irq_base,
1080 1052
1081 } 1053 }
1082 1054
1083 if (twl_has_bci() && pdata->bci && 1055 if (IS_ENABLED(CONFIG_CHARGER_TWL4030) && pdata->bci &&
1084 !(features & (TPS_SUBSET | TWL5031))) { 1056 !(features & (TPS_SUBSET | TWL5031))) {
1085 child = add_child(3, "twl4030_bci", 1057 child = add_child(3, "twl4030_bci",
1086 pdata->bci, sizeof(*pdata->bci), false, 1058 pdata->bci, sizeof(*pdata->bci), false,
@@ -1295,7 +1267,7 @@ twl_probe(struct i2c_client *client, const struct i2c_device_id *id)
1295 } 1267 }
1296 1268
1297 /* load power event scripts */ 1269 /* load power event scripts */
1298 if (twl_has_power() && pdata->power) 1270 if (IS_ENABLED(CONFIG_TWL4030_POWER) && pdata->power)
1299 twl4030_power_init(pdata->power); 1271 twl4030_power_init(pdata->power);
1300 1272
1301 /* Maybe init the T2 Interrupt subsystem */ 1273 /* Maybe init the T2 Interrupt subsystem */