blob: cf80f4cad7291a1677af2fe066250986c5c1b644 [file] [log] [blame]
Peter Ujfalusia53b8e32011-06-04 08:16:41 +03001/*
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>
Peter Ujfalusib22f9542011-06-07 10:26:46 +030026#include <linux/regulator/machine.h>
27#include <linux/regulator/fixed.h>
Peter Ujfalusia53b8e32011-06-04 08:16:41 +030028
29#include <plat/i2c.h>
Peter Ujfalusib22f9542011-06-07 10:26:46 +030030#include <plat/usb.h>
Peter Ujfalusia53b8e32011-06-04 08:16:41 +030031
32#include "twl-common.h"
33
34static struct i2c_board_info __initdata pmic_i2c_board_info = {
35 .addr = 0x48,
36 .flags = I2C_CLIENT_WAKE,
37};
38
39void __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}
Peter Ujfalusib22f9542011-06-07 10:26:46 +030050
51static 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
59static struct regulator_init_data omap4_vdac_idata = {
60 .constraints = {
61 .min_uV = 1800000,
62 .max_uV = 1800000,
63 .valid_modes_mask = REGULATOR_MODE_NORMAL
64 | REGULATOR_MODE_STANDBY,
65 .valid_ops_mask = REGULATOR_CHANGE_MODE
66 | REGULATOR_CHANGE_STATUS,
67 },
68};
69
70static struct regulator_init_data omap4_vaux2_idata = {
71 .constraints = {
72 .min_uV = 1200000,
73 .max_uV = 2800000,
74 .apply_uV = true,
75 .valid_modes_mask = REGULATOR_MODE_NORMAL
76 | REGULATOR_MODE_STANDBY,
77 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
78 | REGULATOR_CHANGE_MODE
79 | REGULATOR_CHANGE_STATUS,
80 },
81};
82
83static struct regulator_init_data omap4_vaux3_idata = {
84 .constraints = {
85 .min_uV = 1000000,
86 .max_uV = 3000000,
87 .apply_uV = true,
88 .valid_modes_mask = REGULATOR_MODE_NORMAL
89 | REGULATOR_MODE_STANDBY,
90 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
91 | REGULATOR_CHANGE_MODE
92 | REGULATOR_CHANGE_STATUS,
93 },
94};
95
96static struct regulator_consumer_supply omap4_vmmc_supply[] = {
97 REGULATOR_SUPPLY("vmmc", "omap_hsmmc.0"),
98};
99
100/* VMMC1 for MMC1 card */
101static struct regulator_init_data omap4_vmmc_idata = {
102 .constraints = {
103 .min_uV = 1200000,
104 .max_uV = 3000000,
105 .apply_uV = true,
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,
111 },
112 .num_consumer_supplies = ARRAY_SIZE(omap4_vmmc_supply),
113 .consumer_supplies = omap4_vmmc_supply,
114};
115
116static struct regulator_init_data omap4_vpp_idata = {
117 .constraints = {
118 .min_uV = 1800000,
119 .max_uV = 2500000,
120 .apply_uV = true,
121 .valid_modes_mask = REGULATOR_MODE_NORMAL
122 | REGULATOR_MODE_STANDBY,
123 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
124 | REGULATOR_CHANGE_MODE
125 | REGULATOR_CHANGE_STATUS,
126 },
127};
128
129static struct regulator_init_data omap4_vana_idata = {
130 .constraints = {
131 .min_uV = 2100000,
132 .max_uV = 2100000,
133 .valid_modes_mask = REGULATOR_MODE_NORMAL
134 | REGULATOR_MODE_STANDBY,
135 .valid_ops_mask = REGULATOR_CHANGE_MODE
136 | REGULATOR_CHANGE_STATUS,
137 },
138};
139
140static struct regulator_init_data omap4_vcxio_idata = {
141 .constraints = {
142 .min_uV = 1800000,
143 .max_uV = 1800000,
144 .valid_modes_mask = REGULATOR_MODE_NORMAL
145 | REGULATOR_MODE_STANDBY,
146 .valid_ops_mask = REGULATOR_CHANGE_MODE
147 | REGULATOR_CHANGE_STATUS,
148 },
149};
150
151static struct regulator_init_data omap4_vusb_idata = {
152 .constraints = {
153 .min_uV = 3300000,
154 .max_uV = 3300000,
155 .apply_uV = true,
156 .valid_modes_mask = REGULATOR_MODE_NORMAL
157 | REGULATOR_MODE_STANDBY,
158 .valid_ops_mask = REGULATOR_CHANGE_MODE
159 | REGULATOR_CHANGE_STATUS,
160 },
161};
162
163static struct regulator_init_data omap4_clk32kg_idata = {
164 .constraints = {
165 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
166 },
167};
168
169void __init omap4_pmic_get_config(struct twl4030_platform_data *pmic_data,
170 u32 pdata_flags, u32 regulators_flags)
171{
172 if (!pmic_data->irq_base)
173 pmic_data->irq_base = TWL6030_IRQ_BASE;
174 if (!pmic_data->irq_end)
175 pmic_data->irq_end = TWL6030_IRQ_END;
176
177 /* Common platform data configurations */
178 if (pdata_flags & TWL_COMMON_PDATA_USB && !pmic_data->usb)
179 pmic_data->usb = &omap4_usb_pdata;
180
181 /* Common regulator configurations */
182 if (regulators_flags & TWL_COMMON_REGULATOR_VDAC && !pmic_data->vdac)
183 pmic_data->vdac = &omap4_vdac_idata;
184
185 if (regulators_flags & TWL_COMMON_REGULATOR_VAUX2 && !pmic_data->vaux2)
186 pmic_data->vaux2 = &omap4_vaux2_idata;
187
188 if (regulators_flags & TWL_COMMON_REGULATOR_VAUX3 && !pmic_data->vaux3)
189 pmic_data->vaux3 = &omap4_vaux3_idata;
190
191 if (regulators_flags & TWL_COMMON_REGULATOR_VMMC && !pmic_data->vmmc)
192 pmic_data->vmmc = &omap4_vmmc_idata;
193
194 if (regulators_flags & TWL_COMMON_REGULATOR_VPP && !pmic_data->vpp)
195 pmic_data->vpp = &omap4_vpp_idata;
196
197 if (regulators_flags & TWL_COMMON_REGULATOR_VANA && !pmic_data->vana)
198 pmic_data->vana = &omap4_vana_idata;
199
200 if (regulators_flags & TWL_COMMON_REGULATOR_VCXIO && !pmic_data->vcxio)
201 pmic_data->vcxio = &omap4_vcxio_idata;
202
203 if (regulators_flags & TWL_COMMON_REGULATOR_VUSB && !pmic_data->vusb)
204 pmic_data->vusb = &omap4_vusb_idata;
205
206 if (regulators_flags & TWL_COMMON_REGULATOR_CLK32KG &&
207 !pmic_data->clk32kg)
208 pmic_data->clk32kg = &omap4_clk32kg_idata;
209}