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"
34 static struct i2c_board_info __initdata pmic_i2c_board_info
= {
36 .flags
= I2C_CLIENT_WAKE
,
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
)
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
;
48 omap_register_i2c_bus(bus
, clkrate
, &pmic_i2c_board_info
, 1);
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
,
59 static struct twl4030_usb_data omap3_usb_pdata
= {
60 .usb_mode
= T2_USB_MODE_ULPI
,
63 static int omap3_batt_table
[] = {
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
74 static struct twl4030_bci_platform_data omap3_bci_pdata
= {
75 .battery_tmp_tbl
= omap3_batt_table
,
76 .tblsize
= ARRAY_SIZE(omap3_batt_table
),
79 static struct twl4030_madc_platform_data omap3_madc_pdata
= {
83 static struct twl4030_codec_audio_data omap3_audio
;
85 static struct twl4030_codec_data omap3_codec_pdata
= {
86 .audio_mclk
= 26000000,
87 .audio
= &omap3_audio
,
90 static struct regulator_init_data omap4_vdac_idata
= {
94 .valid_modes_mask
= REGULATOR_MODE_NORMAL
95 | REGULATOR_MODE_STANDBY
,
96 .valid_ops_mask
= REGULATOR_CHANGE_MODE
97 | REGULATOR_CHANGE_STATUS
,
101 static struct regulator_init_data omap4_vaux2_idata
= {
106 .valid_modes_mask
= REGULATOR_MODE_NORMAL
107 | REGULATOR_MODE_STANDBY
,
108 .valid_ops_mask
= REGULATOR_CHANGE_VOLTAGE
109 | REGULATOR_CHANGE_MODE
110 | REGULATOR_CHANGE_STATUS
,
114 static struct regulator_init_data omap4_vaux3_idata
= {
119 .valid_modes_mask
= REGULATOR_MODE_NORMAL
120 | REGULATOR_MODE_STANDBY
,
121 .valid_ops_mask
= REGULATOR_CHANGE_VOLTAGE
122 | REGULATOR_CHANGE_MODE
123 | REGULATOR_CHANGE_STATUS
,
127 static struct regulator_consumer_supply omap4_vmmc_supply
[] = {
128 REGULATOR_SUPPLY("vmmc", "omap_hsmmc.0"),
131 /* VMMC1 for MMC1 card */
132 static struct regulator_init_data omap4_vmmc_idata
= {
137 .valid_modes_mask
= REGULATOR_MODE_NORMAL
138 | REGULATOR_MODE_STANDBY
,
139 .valid_ops_mask
= REGULATOR_CHANGE_VOLTAGE
140 | REGULATOR_CHANGE_MODE
141 | REGULATOR_CHANGE_STATUS
,
143 .num_consumer_supplies
= ARRAY_SIZE(omap4_vmmc_supply
),
144 .consumer_supplies
= omap4_vmmc_supply
,
147 static struct regulator_init_data omap4_vpp_idata
= {
152 .valid_modes_mask
= REGULATOR_MODE_NORMAL
153 | REGULATOR_MODE_STANDBY
,
154 .valid_ops_mask
= REGULATOR_CHANGE_VOLTAGE
155 | REGULATOR_CHANGE_MODE
156 | REGULATOR_CHANGE_STATUS
,
160 static struct regulator_init_data omap4_vana_idata
= {
164 .valid_modes_mask
= REGULATOR_MODE_NORMAL
165 | REGULATOR_MODE_STANDBY
,
166 .valid_ops_mask
= REGULATOR_CHANGE_MODE
167 | REGULATOR_CHANGE_STATUS
,
171 static struct regulator_init_data omap4_vcxio_idata
= {
175 .valid_modes_mask
= REGULATOR_MODE_NORMAL
176 | REGULATOR_MODE_STANDBY
,
177 .valid_ops_mask
= REGULATOR_CHANGE_MODE
178 | REGULATOR_CHANGE_STATUS
,
182 static struct regulator_init_data omap4_vusb_idata
= {
187 .valid_modes_mask
= REGULATOR_MODE_NORMAL
188 | REGULATOR_MODE_STANDBY
,
189 .valid_ops_mask
= REGULATOR_CHANGE_MODE
190 | REGULATOR_CHANGE_STATUS
,
194 static struct regulator_init_data omap4_clk32kg_idata
= {
196 .valid_ops_mask
= REGULATOR_CHANGE_STATUS
,
200 void __init
omap4_pmic_get_config(struct twl4030_platform_data
*pmic_data
,
201 u32 pdata_flags
, u32 regulators_flags
)
203 if (!pmic_data
->irq_base
)
204 pmic_data
->irq_base
= TWL6030_IRQ_BASE
;
205 if (!pmic_data
->irq_end
)
206 pmic_data
->irq_end
= TWL6030_IRQ_END
;
208 /* Common platform data configurations */
209 if (pdata_flags
& TWL_COMMON_PDATA_USB
&& !pmic_data
->usb
)
210 pmic_data
->usb
= &omap4_usb_pdata
;
212 /* Common regulator configurations */
213 if (regulators_flags
& TWL_COMMON_REGULATOR_VDAC
&& !pmic_data
->vdac
)
214 pmic_data
->vdac
= &omap4_vdac_idata
;
216 if (regulators_flags
& TWL_COMMON_REGULATOR_VAUX2
&& !pmic_data
->vaux2
)
217 pmic_data
->vaux2
= &omap4_vaux2_idata
;
219 if (regulators_flags
& TWL_COMMON_REGULATOR_VAUX3
&& !pmic_data
->vaux3
)
220 pmic_data
->vaux3
= &omap4_vaux3_idata
;
222 if (regulators_flags
& TWL_COMMON_REGULATOR_VMMC
&& !pmic_data
->vmmc
)
223 pmic_data
->vmmc
= &omap4_vmmc_idata
;
225 if (regulators_flags
& TWL_COMMON_REGULATOR_VPP
&& !pmic_data
->vpp
)
226 pmic_data
->vpp
= &omap4_vpp_idata
;
228 if (regulators_flags
& TWL_COMMON_REGULATOR_VANA
&& !pmic_data
->vana
)
229 pmic_data
->vana
= &omap4_vana_idata
;
231 if (regulators_flags
& TWL_COMMON_REGULATOR_VCXIO
&& !pmic_data
->vcxio
)
232 pmic_data
->vcxio
= &omap4_vcxio_idata
;
234 if (regulators_flags
& TWL_COMMON_REGULATOR_VUSB
&& !pmic_data
->vusb
)
235 pmic_data
->vusb
= &omap4_vusb_idata
;
237 if (regulators_flags
& TWL_COMMON_REGULATOR_CLK32KG
&&
239 pmic_data
->clk32kg
= &omap4_clk32kg_idata
;
242 void __init
omap3_pmic_get_config(struct twl4030_platform_data
*pmic_data
,
243 u32 pdata_flags
, u32 regulators_flags
)
245 if (!pmic_data
->irq_base
)
246 pmic_data
->irq_base
= TWL4030_IRQ_BASE
;
247 if (!pmic_data
->irq_end
)
248 pmic_data
->irq_end
= TWL4030_IRQ_END
;
250 /* Common platform data configurations */
251 if (pdata_flags
& TWL_COMMON_PDATA_USB
&& !pmic_data
->usb
)
252 pmic_data
->usb
= &omap3_usb_pdata
;
254 if (pdata_flags
& TWL_COMMON_PDATA_BCI
&& !pmic_data
->bci
)
255 pmic_data
->bci
= &omap3_bci_pdata
;
257 if (pdata_flags
& TWL_COMMON_PDATA_MADC
&& !pmic_data
->madc
)
258 pmic_data
->madc
= &omap3_madc_pdata
;
260 if (pdata_flags
& TWL_COMMON_PDATA_AUDIO
&& !pmic_data
->codec
)
261 pmic_data
->codec
= &omap3_codec_pdata
;