diff options
Diffstat (limited to 'arch/arm/mach-omap2/twl-common.c')
-rw-r--r-- | arch/arm/mach-omap2/twl-common.c | 304 |
1 files changed, 304 insertions, 0 deletions
diff --git a/arch/arm/mach-omap2/twl-common.c b/arch/arm/mach-omap2/twl-common.c new file mode 100644 index 000000000000..2543342dbccb --- /dev/null +++ b/arch/arm/mach-omap2/twl-common.c | |||
@@ -0,0 +1,304 @@ | |||
1 | /* | ||
2 | * twl-common.c | ||
3 | * | ||
4 | * Copyright (C) 2011 Texas Instruments, Inc.. | ||
5 | * Author: Peter Ujfalusi <peter.ujfalusi@ti.com> | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or | ||
8 | * modify it under the terms of the GNU General Public License | ||
9 | * version 2 as published by the Free Software Foundation. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, but | ||
12 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
14 | * General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License | ||
17 | * along with this program; if not, write to the Free Software | ||
18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | ||
19 | * 02110-1301 USA | ||
20 | * | ||
21 | */ | ||
22 | |||
23 | #include <linux/i2c.h> | ||
24 | #include <linux/i2c/twl.h> | ||
25 | #include <linux/gpio.h> | ||
26 | #include <linux/regulator/machine.h> | ||
27 | #include <linux/regulator/fixed.h> | ||
28 | |||
29 | #include <plat/i2c.h> | ||
30 | #include <plat/usb.h> | ||
31 | |||
32 | #include "twl-common.h" | ||
33 | |||
34 | static struct i2c_board_info __initdata pmic_i2c_board_info = { | ||
35 | .addr = 0x48, | ||
36 | .flags = I2C_CLIENT_WAKE, | ||
37 | }; | ||
38 | |||
39 | void __init omap_pmic_init(int bus, u32 clkrate, | ||
40 | const char *pmic_type, int pmic_irq, | ||
41 | struct twl4030_platform_data *pmic_data) | ||
42 | { | ||
43 | strncpy(pmic_i2c_board_info.type, pmic_type, | ||
44 | sizeof(pmic_i2c_board_info.type)); | ||
45 | pmic_i2c_board_info.irq = pmic_irq; | ||
46 | pmic_i2c_board_info.platform_data = pmic_data; | ||
47 | |||
48 | omap_register_i2c_bus(bus, clkrate, &pmic_i2c_board_info, 1); | ||
49 | } | ||
50 | |||
51 | static struct twl4030_usb_data omap4_usb_pdata = { | ||
52 | .phy_init = omap4430_phy_init, | ||
53 | .phy_exit = omap4430_phy_exit, | ||
54 | .phy_power = omap4430_phy_power, | ||
55 | .phy_set_clock = omap4430_phy_set_clk, | ||
56 | .phy_suspend = omap4430_phy_suspend, | ||
57 | }; | ||
58 | |||
59 | static struct twl4030_usb_data omap3_usb_pdata = { | ||
60 | .usb_mode = T2_USB_MODE_ULPI, | ||
61 | }; | ||
62 | |||
63 | static int omap3_batt_table[] = { | ||
64 | /* 0 C */ | ||
65 | 30800, 29500, 28300, 27100, | ||
66 | 26000, 24900, 23900, 22900, 22000, 21100, 20300, 19400, 18700, 17900, | ||
67 | 17200, 16500, 15900, 15300, 14700, 14100, 13600, 13100, 12600, 12100, | ||
68 | 11600, 11200, 10800, 10400, 10000, 9630, 9280, 8950, 8620, 8310, | ||
69 | 8020, 7730, 7460, 7200, 6950, 6710, 6470, 6250, 6040, 5830, | ||
70 | 5640, 5450, 5260, 5090, 4920, 4760, 4600, 4450, 4310, 4170, | ||
71 | 4040, 3910, 3790, 3670, 3550 | ||
72 | }; | ||
73 | |||
74 | static struct twl4030_bci_platform_data omap3_bci_pdata = { | ||
75 | .battery_tmp_tbl = omap3_batt_table, | ||
76 | .tblsize = ARRAY_SIZE(omap3_batt_table), | ||
77 | }; | ||
78 | |||
79 | static struct twl4030_madc_platform_data omap3_madc_pdata = { | ||
80 | .irq_line = 1, | ||
81 | }; | ||
82 | |||
83 | static struct twl4030_codec_data omap3_codec; | ||
84 | |||
85 | static struct twl4030_audio_data omap3_audio_pdata = { | ||
86 | .audio_mclk = 26000000, | ||
87 | .codec = &omap3_codec, | ||
88 | }; | ||
89 | |||
90 | static struct regulator_consumer_supply omap3_vdda_dac_supplies[] = { | ||
91 | REGULATOR_SUPPLY("vdda_dac", "omapdss_venc"), | ||
92 | }; | ||
93 | |||
94 | static struct regulator_init_data omap3_vdac_idata = { | ||
95 | .constraints = { | ||
96 | .min_uV = 1800000, | ||
97 | .max_uV = 1800000, | ||
98 | .valid_modes_mask = REGULATOR_MODE_NORMAL | ||
99 | | REGULATOR_MODE_STANDBY, | ||
100 | .valid_ops_mask = REGULATOR_CHANGE_MODE | ||
101 | | REGULATOR_CHANGE_STATUS, | ||
102 | }, | ||
103 | .num_consumer_supplies = ARRAY_SIZE(omap3_vdda_dac_supplies), | ||
104 | .consumer_supplies = omap3_vdda_dac_supplies, | ||
105 | }; | ||
106 | |||
107 | static struct regulator_consumer_supply omap3_vpll2_supplies[] = { | ||
108 | REGULATOR_SUPPLY("vdds_dsi", "omapdss"), | ||
109 | REGULATOR_SUPPLY("vdds_dsi", "omapdss_dsi1"), | ||
110 | }; | ||
111 | |||
112 | static struct regulator_init_data omap3_vpll2_idata = { | ||
113 | .constraints = { | ||
114 | .min_uV = 1800000, | ||
115 | .max_uV = 1800000, | ||
116 | .valid_modes_mask = REGULATOR_MODE_NORMAL | ||
117 | | REGULATOR_MODE_STANDBY, | ||
118 | .valid_ops_mask = REGULATOR_CHANGE_MODE | ||
119 | | REGULATOR_CHANGE_STATUS, | ||
120 | }, | ||
121 | .num_consumer_supplies = ARRAY_SIZE(omap3_vpll2_supplies), | ||
122 | .consumer_supplies = omap3_vpll2_supplies, | ||
123 | }; | ||
124 | |||
125 | static struct regulator_init_data omap4_vdac_idata = { | ||
126 | .constraints = { | ||
127 | .min_uV = 1800000, | ||
128 | .max_uV = 1800000, | ||
129 | .valid_modes_mask = REGULATOR_MODE_NORMAL | ||
130 | | REGULATOR_MODE_STANDBY, | ||
131 | .valid_ops_mask = REGULATOR_CHANGE_MODE | ||
132 | | REGULATOR_CHANGE_STATUS, | ||
133 | }, | ||
134 | }; | ||
135 | |||
136 | static struct regulator_init_data omap4_vaux2_idata = { | ||
137 | .constraints = { | ||
138 | .min_uV = 1200000, | ||
139 | .max_uV = 2800000, | ||
140 | .apply_uV = true, | ||
141 | .valid_modes_mask = REGULATOR_MODE_NORMAL | ||
142 | | REGULATOR_MODE_STANDBY, | ||
143 | .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE | ||
144 | | REGULATOR_CHANGE_MODE | ||
145 | | REGULATOR_CHANGE_STATUS, | ||
146 | }, | ||
147 | }; | ||
148 | |||
149 | static struct regulator_init_data omap4_vaux3_idata = { | ||
150 | .constraints = { | ||
151 | .min_uV = 1000000, | ||
152 | .max_uV = 3000000, | ||
153 | .apply_uV = true, | ||
154 | .valid_modes_mask = REGULATOR_MODE_NORMAL | ||
155 | | REGULATOR_MODE_STANDBY, | ||
156 | .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE | ||
157 | | REGULATOR_CHANGE_MODE | ||
158 | | REGULATOR_CHANGE_STATUS, | ||
159 | }, | ||
160 | }; | ||
161 | |||
162 | static struct regulator_consumer_supply omap4_vmmc_supply[] = { | ||
163 | REGULATOR_SUPPLY("vmmc", "omap_hsmmc.0"), | ||
164 | }; | ||
165 | |||
166 | /* VMMC1 for MMC1 card */ | ||
167 | static struct regulator_init_data omap4_vmmc_idata = { | ||
168 | .constraints = { | ||
169 | .min_uV = 1200000, | ||
170 | .max_uV = 3000000, | ||
171 | .apply_uV = true, | ||
172 | .valid_modes_mask = REGULATOR_MODE_NORMAL | ||
173 | | REGULATOR_MODE_STANDBY, | ||
174 | .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE | ||
175 | | REGULATOR_CHANGE_MODE | ||
176 | | REGULATOR_CHANGE_STATUS, | ||
177 | }, | ||
178 | .num_consumer_supplies = ARRAY_SIZE(omap4_vmmc_supply), | ||
179 | .consumer_supplies = omap4_vmmc_supply, | ||
180 | }; | ||
181 | |||
182 | static struct regulator_init_data omap4_vpp_idata = { | ||
183 | .constraints = { | ||
184 | .min_uV = 1800000, | ||
185 | .max_uV = 2500000, | ||
186 | .apply_uV = true, | ||
187 | .valid_modes_mask = REGULATOR_MODE_NORMAL | ||
188 | | REGULATOR_MODE_STANDBY, | ||
189 | .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE | ||
190 | | REGULATOR_CHANGE_MODE | ||
191 | | REGULATOR_CHANGE_STATUS, | ||
192 | }, | ||
193 | }; | ||
194 | |||
195 | static struct regulator_init_data omap4_vana_idata = { | ||
196 | .constraints = { | ||
197 | .min_uV = 2100000, | ||
198 | .max_uV = 2100000, | ||
199 | .valid_modes_mask = REGULATOR_MODE_NORMAL | ||
200 | | REGULATOR_MODE_STANDBY, | ||
201 | .valid_ops_mask = REGULATOR_CHANGE_MODE | ||
202 | | REGULATOR_CHANGE_STATUS, | ||
203 | }, | ||
204 | }; | ||
205 | |||
206 | static struct regulator_init_data omap4_vcxio_idata = { | ||
207 | .constraints = { | ||
208 | .min_uV = 1800000, | ||
209 | .max_uV = 1800000, | ||
210 | .valid_modes_mask = REGULATOR_MODE_NORMAL | ||
211 | | REGULATOR_MODE_STANDBY, | ||
212 | .valid_ops_mask = REGULATOR_CHANGE_MODE | ||
213 | | REGULATOR_CHANGE_STATUS, | ||
214 | }, | ||
215 | }; | ||
216 | |||
217 | static struct regulator_init_data omap4_vusb_idata = { | ||
218 | .constraints = { | ||
219 | .min_uV = 3300000, | ||
220 | .max_uV = 3300000, | ||
221 | .apply_uV = true, | ||
222 | .valid_modes_mask = REGULATOR_MODE_NORMAL | ||
223 | | REGULATOR_MODE_STANDBY, | ||
224 | .valid_ops_mask = REGULATOR_CHANGE_MODE | ||
225 | | REGULATOR_CHANGE_STATUS, | ||
226 | }, | ||
227 | }; | ||
228 | |||
229 | static struct regulator_init_data omap4_clk32kg_idata = { | ||
230 | .constraints = { | ||
231 | .valid_ops_mask = REGULATOR_CHANGE_STATUS, | ||
232 | }, | ||
233 | }; | ||
234 | |||
235 | void __init omap4_pmic_get_config(struct twl4030_platform_data *pmic_data, | ||
236 | u32 pdata_flags, u32 regulators_flags) | ||
237 | { | ||
238 | if (!pmic_data->irq_base) | ||
239 | pmic_data->irq_base = TWL6030_IRQ_BASE; | ||
240 | if (!pmic_data->irq_end) | ||
241 | pmic_data->irq_end = TWL6030_IRQ_END; | ||
242 | |||
243 | /* Common platform data configurations */ | ||
244 | if (pdata_flags & TWL_COMMON_PDATA_USB && !pmic_data->usb) | ||
245 | pmic_data->usb = &omap4_usb_pdata; | ||
246 | |||
247 | /* Common regulator configurations */ | ||
248 | if (regulators_flags & TWL_COMMON_REGULATOR_VDAC && !pmic_data->vdac) | ||
249 | pmic_data->vdac = &omap4_vdac_idata; | ||
250 | |||
251 | if (regulators_flags & TWL_COMMON_REGULATOR_VAUX2 && !pmic_data->vaux2) | ||
252 | pmic_data->vaux2 = &omap4_vaux2_idata; | ||
253 | |||
254 | if (regulators_flags & TWL_COMMON_REGULATOR_VAUX3 && !pmic_data->vaux3) | ||
255 | pmic_data->vaux3 = &omap4_vaux3_idata; | ||
256 | |||
257 | if (regulators_flags & TWL_COMMON_REGULATOR_VMMC && !pmic_data->vmmc) | ||
258 | pmic_data->vmmc = &omap4_vmmc_idata; | ||
259 | |||
260 | if (regulators_flags & TWL_COMMON_REGULATOR_VPP && !pmic_data->vpp) | ||
261 | pmic_data->vpp = &omap4_vpp_idata; | ||
262 | |||
263 | if (regulators_flags & TWL_COMMON_REGULATOR_VANA && !pmic_data->vana) | ||
264 | pmic_data->vana = &omap4_vana_idata; | ||
265 | |||
266 | if (regulators_flags & TWL_COMMON_REGULATOR_VCXIO && !pmic_data->vcxio) | ||
267 | pmic_data->vcxio = &omap4_vcxio_idata; | ||
268 | |||
269 | if (regulators_flags & TWL_COMMON_REGULATOR_VUSB && !pmic_data->vusb) | ||
270 | pmic_data->vusb = &omap4_vusb_idata; | ||
271 | |||
272 | if (regulators_flags & TWL_COMMON_REGULATOR_CLK32KG && | ||
273 | !pmic_data->clk32kg) | ||
274 | pmic_data->clk32kg = &omap4_clk32kg_idata; | ||
275 | } | ||
276 | |||
277 | void __init omap3_pmic_get_config(struct twl4030_platform_data *pmic_data, | ||
278 | u32 pdata_flags, u32 regulators_flags) | ||
279 | { | ||
280 | if (!pmic_data->irq_base) | ||
281 | pmic_data->irq_base = TWL4030_IRQ_BASE; | ||
282 | if (!pmic_data->irq_end) | ||
283 | pmic_data->irq_end = TWL4030_IRQ_END; | ||
284 | |||
285 | /* Common platform data configurations */ | ||
286 | if (pdata_flags & TWL_COMMON_PDATA_USB && !pmic_data->usb) | ||
287 | pmic_data->usb = &omap3_usb_pdata; | ||
288 | |||
289 | if (pdata_flags & TWL_COMMON_PDATA_BCI && !pmic_data->bci) | ||
290 | pmic_data->bci = &omap3_bci_pdata; | ||
291 | |||
292 | if (pdata_flags & TWL_COMMON_PDATA_MADC && !pmic_data->madc) | ||
293 | pmic_data->madc = &omap3_madc_pdata; | ||
294 | |||
295 | if (pdata_flags & TWL_COMMON_PDATA_AUDIO && !pmic_data->audio) | ||
296 | pmic_data->audio = &omap3_audio_pdata; | ||
297 | |||
298 | /* Common regulator configurations */ | ||
299 | if (regulators_flags & TWL_COMMON_REGULATOR_VDAC && !pmic_data->vdac) | ||
300 | pmic_data->vdac = &omap3_vdac_idata; | ||
301 | |||
302 | if (regulators_flags & TWL_COMMON_REGULATOR_VPLL2 && !pmic_data->vpll2) | ||
303 | pmic_data->vpll2 = &omap3_vpll2_idata; | ||
304 | } | ||