4 * Copyright (C) 2011 Texas Instruments, Inc..
5 * Author: Peter Ujfalusi <peter.ujfalusi@ti.com>
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.
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.
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
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>
32 #include "twl-common.h"
35 static struct i2c_board_info __initdata pmic_i2c_board_info = {
37 .flags = I2C_CLIENT_WAKE,
40 static struct i2c_board_info __initdata omap4_i2c1_board_info[] = {
43 .flags = I2C_CLIENT_WAKE,
46 I2C_BOARD_INFO("twl6040", 0x4b),
50 void __init omap_pmic_init(int bus, u32 clkrate,
51 const char *pmic_type, int pmic_irq,
52 struct twl4030_platform_data *pmic_data)
54 strncpy(pmic_i2c_board_info.type, pmic_type,
55 sizeof(pmic_i2c_board_info.type));
56 pmic_i2c_board_info.irq = pmic_irq;
57 pmic_i2c_board_info.platform_data = pmic_data;
59 omap_register_i2c_bus(bus, clkrate, &pmic_i2c_board_info, 1);
62 void __init omap4_pmic_init(const char *pmic_type,
63 struct twl4030_platform_data *pmic_data,
64 struct twl6040_platform_data *twl6040_data, int twl6040_irq)
67 strncpy(omap4_i2c1_board_info[0].type, pmic_type,
68 sizeof(omap4_i2c1_board_info[0].type));
69 omap4_i2c1_board_info[0].irq = OMAP44XX_IRQ_SYS_1N;
70 omap4_i2c1_board_info[0].platform_data = pmic_data;
72 /* TWL6040 audio IC part */
73 omap4_i2c1_board_info[1].irq = twl6040_irq;
74 omap4_i2c1_board_info[1].platform_data = twl6040_data;
76 omap_register_i2c_bus(1, 400, omap4_i2c1_board_info, 2);
80 void __init omap_pmic_late_init(void)
82 /* Init the OMAP TWL parameters (if PMIC has been registerd) */
83 if (pmic_i2c_board_info.irq)
85 if (omap4_i2c1_board_info[0].irq)
89 #if defined(CONFIG_ARCH_OMAP3)
90 static struct twl4030_usb_data omap3_usb_pdata = {
91 .usb_mode = T2_USB_MODE_ULPI,
94 static int omap3_batt_table[] = {
96 30800, 29500, 28300, 27100,
97 26000, 24900, 23900, 22900, 22000, 21100, 20300, 19400, 18700, 17900,
98 17200, 16500, 15900, 15300, 14700, 14100, 13600, 13100, 12600, 12100,
99 11600, 11200, 10800, 10400, 10000, 9630, 9280, 8950, 8620, 8310,
100 8020, 7730, 7460, 7200, 6950, 6710, 6470, 6250, 6040, 5830,
101 5640, 5450, 5260, 5090, 4920, 4760, 4600, 4450, 4310, 4170,
102 4040, 3910, 3790, 3670, 3550
105 static struct twl4030_bci_platform_data omap3_bci_pdata = {
106 .battery_tmp_tbl = omap3_batt_table,
107 .tblsize = ARRAY_SIZE(omap3_batt_table),
110 static struct twl4030_madc_platform_data omap3_madc_pdata = {
114 static struct twl4030_codec_data omap3_codec;
116 static struct twl4030_audio_data omap3_audio_pdata = {
117 .audio_mclk = 26000000,
118 .codec = &omap3_codec,
121 static struct regulator_consumer_supply omap3_vdda_dac_supplies[] = {
122 REGULATOR_SUPPLY("vdda_dac", "omapdss_venc"),
125 static struct regulator_init_data omap3_vdac_idata = {
129 .valid_modes_mask = REGULATOR_MODE_NORMAL
130 | REGULATOR_MODE_STANDBY,
131 .valid_ops_mask = REGULATOR_CHANGE_MODE
132 | REGULATOR_CHANGE_STATUS,
134 .num_consumer_supplies = ARRAY_SIZE(omap3_vdda_dac_supplies),
135 .consumer_supplies = omap3_vdda_dac_supplies,
138 static struct regulator_consumer_supply omap3_vpll2_supplies[] = {
139 REGULATOR_SUPPLY("vdds_dsi", "omapdss"),
140 REGULATOR_SUPPLY("vdds_dsi", "omapdss_dsi.0"),
143 static struct regulator_init_data omap3_vpll2_idata = {
147 .valid_modes_mask = REGULATOR_MODE_NORMAL
148 | REGULATOR_MODE_STANDBY,
149 .valid_ops_mask = REGULATOR_CHANGE_MODE
150 | REGULATOR_CHANGE_STATUS,
152 .num_consumer_supplies = ARRAY_SIZE(omap3_vpll2_supplies),
153 .consumer_supplies = omap3_vpll2_supplies,
156 void __init omap3_pmic_get_config(struct twl4030_platform_data *pmic_data,
157 u32 pdata_flags, u32 regulators_flags)
159 if (!pmic_data->irq_base)
160 pmic_data->irq_base = TWL4030_IRQ_BASE;
161 if (!pmic_data->irq_end)
162 pmic_data->irq_end = TWL4030_IRQ_END;
164 /* Common platform data configurations */
165 if (pdata_flags & TWL_COMMON_PDATA_USB && !pmic_data->usb)
166 pmic_data->usb = &omap3_usb_pdata;
168 if (pdata_flags & TWL_COMMON_PDATA_BCI && !pmic_data->bci)
169 pmic_data->bci = &omap3_bci_pdata;
171 if (pdata_flags & TWL_COMMON_PDATA_MADC && !pmic_data->madc)
172 pmic_data->madc = &omap3_madc_pdata;
174 if (pdata_flags & TWL_COMMON_PDATA_AUDIO && !pmic_data->audio)
175 pmic_data->audio = &omap3_audio_pdata;
177 /* Common regulator configurations */
178 if (regulators_flags & TWL_COMMON_REGULATOR_VDAC && !pmic_data->vdac)
179 pmic_data->vdac = &omap3_vdac_idata;
181 if (regulators_flags & TWL_COMMON_REGULATOR_VPLL2 && !pmic_data->vpll2)
182 pmic_data->vpll2 = &omap3_vpll2_idata;
184 #endif /* CONFIG_ARCH_OMAP3 */
186 #if defined(CONFIG_ARCH_OMAP4)
187 static struct twl4030_usb_data omap4_usb_pdata = {
188 .phy_init = omap4430_phy_init,
189 .phy_exit = omap4430_phy_exit,
190 .phy_power = omap4430_phy_power,
191 .phy_set_clock = omap4430_phy_set_clk,
192 .phy_suspend = omap4430_phy_suspend,
195 static struct regulator_init_data omap4_vdac_idata = {
199 .valid_modes_mask = REGULATOR_MODE_NORMAL
200 | REGULATOR_MODE_STANDBY,
201 .valid_ops_mask = REGULATOR_CHANGE_MODE
202 | REGULATOR_CHANGE_STATUS,
206 static struct regulator_init_data omap4_vaux2_idata = {
211 .valid_modes_mask = REGULATOR_MODE_NORMAL
212 | REGULATOR_MODE_STANDBY,
213 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
214 | REGULATOR_CHANGE_MODE
215 | REGULATOR_CHANGE_STATUS,
219 static struct regulator_init_data omap4_vaux3_idata = {
224 .valid_modes_mask = REGULATOR_MODE_NORMAL
225 | REGULATOR_MODE_STANDBY,
226 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
227 | REGULATOR_CHANGE_MODE
228 | REGULATOR_CHANGE_STATUS,
232 static struct regulator_consumer_supply omap4_vmmc_supply[] = {
233 REGULATOR_SUPPLY("vmmc", "omap_hsmmc.0"),
236 /* VMMC1 for MMC1 card */
237 static struct regulator_init_data omap4_vmmc_idata = {
242 .valid_modes_mask = REGULATOR_MODE_NORMAL
243 | REGULATOR_MODE_STANDBY,
244 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
245 | REGULATOR_CHANGE_MODE
246 | REGULATOR_CHANGE_STATUS,
248 .num_consumer_supplies = ARRAY_SIZE(omap4_vmmc_supply),
249 .consumer_supplies = omap4_vmmc_supply,
252 static struct regulator_init_data omap4_vpp_idata = {
257 .valid_modes_mask = REGULATOR_MODE_NORMAL
258 | REGULATOR_MODE_STANDBY,
259 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
260 | REGULATOR_CHANGE_MODE
261 | REGULATOR_CHANGE_STATUS,
265 static struct regulator_init_data omap4_vana_idata = {
269 .valid_modes_mask = REGULATOR_MODE_NORMAL
270 | REGULATOR_MODE_STANDBY,
271 .valid_ops_mask = REGULATOR_CHANGE_MODE
272 | REGULATOR_CHANGE_STATUS,
276 static struct regulator_consumer_supply omap4_vcxio_supply[] = {
277 REGULATOR_SUPPLY("vdds_dsi", "omapdss_dss"),
278 REGULATOR_SUPPLY("vdds_dsi", "omapdss_dsi.0"),
279 REGULATOR_SUPPLY("vdds_dsi", "omapdss_dsi.1"),
282 static struct regulator_init_data omap4_vcxio_idata = {
286 .valid_modes_mask = REGULATOR_MODE_NORMAL
287 | REGULATOR_MODE_STANDBY,
288 .valid_ops_mask = REGULATOR_CHANGE_MODE
289 | REGULATOR_CHANGE_STATUS,
292 .num_consumer_supplies = ARRAY_SIZE(omap4_vcxio_supply),
293 .consumer_supplies = omap4_vcxio_supply,
296 static struct regulator_init_data omap4_vusb_idata = {
300 .valid_modes_mask = REGULATOR_MODE_NORMAL
301 | REGULATOR_MODE_STANDBY,
302 .valid_ops_mask = REGULATOR_CHANGE_MODE
303 | REGULATOR_CHANGE_STATUS,
307 static struct regulator_init_data omap4_clk32kg_idata = {
309 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
313 void __init omap4_pmic_get_config(struct twl4030_platform_data *pmic_data,
314 u32 pdata_flags, u32 regulators_flags)
316 if (!pmic_data->irq_base)
317 pmic_data->irq_base = TWL6030_IRQ_BASE;
318 if (!pmic_data->irq_end)
319 pmic_data->irq_end = TWL6030_IRQ_END;
321 /* Common platform data configurations */
322 if (pdata_flags & TWL_COMMON_PDATA_USB && !pmic_data->usb)
323 pmic_data->usb = &omap4_usb_pdata;
325 /* Common regulator configurations */
326 if (regulators_flags & TWL_COMMON_REGULATOR_VDAC && !pmic_data->vdac)
327 pmic_data->vdac = &omap4_vdac_idata;
329 if (regulators_flags & TWL_COMMON_REGULATOR_VAUX2 && !pmic_data->vaux2)
330 pmic_data->vaux2 = &omap4_vaux2_idata;
332 if (regulators_flags & TWL_COMMON_REGULATOR_VAUX3 && !pmic_data->vaux3)
333 pmic_data->vaux3 = &omap4_vaux3_idata;
335 if (regulators_flags & TWL_COMMON_REGULATOR_VMMC && !pmic_data->vmmc)
336 pmic_data->vmmc = &omap4_vmmc_idata;
338 if (regulators_flags & TWL_COMMON_REGULATOR_VPP && !pmic_data->vpp)
339 pmic_data->vpp = &omap4_vpp_idata;
341 if (regulators_flags & TWL_COMMON_REGULATOR_VANA && !pmic_data->vana)
342 pmic_data->vana = &omap4_vana_idata;
344 if (regulators_flags & TWL_COMMON_REGULATOR_VCXIO && !pmic_data->vcxio)
345 pmic_data->vcxio = &omap4_vcxio_idata;
347 if (regulators_flags & TWL_COMMON_REGULATOR_VUSB && !pmic_data->vusb)
348 pmic_data->vusb = &omap4_vusb_idata;
350 if (regulators_flags & TWL_COMMON_REGULATOR_CLK32KG &&
352 pmic_data->clk32kg = &omap4_clk32kg_idata;
354 #endif /* CONFIG_ARCH_OMAP4 */