[ARM] tegra:cardhu: Filling power rails details.
[linux-2.6.git] / arch / arm / mach-tegra / board-cardhu-power.c
1 /*
2  * arch/arm/mach-tegra/board-cardhu-power.c
3  *
4  * Copyright (C) 2011 NVIDIA, Inc.
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18  * 02111-1307, USA
19  */
20 #include <linux/i2c.h>
21 #include <linux/pda_power.h>
22 #include <linux/platform_device.h>
23 #include <linux/resource.h>
24 #include <linux/regulator/machine.h>
25 #include <linux/mfd/tps6591x.h>
26 #include <linux/gpio.h>
27 #include <mach/suspend.h>
28 #include <linux/io.h>
29
30 #include <mach/iomap.h>
31 #include <mach/irqs.h>
32
33 #include "gpio-names.h"
34 #include "board-cardhu.h"
35 #include "power.h"
36 #include "wakeups-t3.h"
37
38 #ifdef CONFIG_MFD_TPS6591X
39 static struct regulator_consumer_supply tps6591x_vdd1_supply[] = {
40         REGULATOR_SUPPLY("vdd_core", NULL),
41         REGULATOR_SUPPLY("en_vddio_ddr_1v2", NULL),
42 };
43
44 static struct regulator_consumer_supply tps6591x_vdd2_supply[] = {
45         REGULATOR_SUPPLY("vdd_gen1v5", NULL),
46         REGULATOR_SUPPLY("vcore_lcd", NULL),
47         REGULATOR_SUPPLY("track_ldo1", NULL),
48         REGULATOR_SUPPLY("external_ldo_1v2", NULL),
49         REGULATOR_SUPPLY("vcore_cam1", NULL),
50         REGULATOR_SUPPLY("vcore_cam2", NULL),
51 };
52
53 static struct regulator_consumer_supply tps6591x_vddctrl_supply[] = {
54         REGULATOR_SUPPLY("vdd_cpu_pmu", NULL),
55 };
56
57 static struct regulator_consumer_supply tps6591x_vio_supply[] = {
58         REGULATOR_SUPPLY("avdd_hdmi_pll", NULL),
59         REGULATOR_SUPPLY("avdd_usb_pll", NULL),
60         REGULATOR_SUPPLY("avdd_osc", NULL),
61         REGULATOR_SUPPLY("vddio_sys", NULL),
62         REGULATOR_SUPPLY("vddio_sdmmc4", NULL),
63         REGULATOR_SUPPLY("vdd1v8_satelite", NULL),
64         REGULATOR_SUPPLY("vddio_uart", NULL),
65         REGULATOR_SUPPLY("vddio_audio", NULL),
66         REGULATOR_SUPPLY("vddio_bb", NULL),
67         REGULATOR_SUPPLY("vddio_lcd_pmu", NULL),
68         REGULATOR_SUPPLY("vddio_cam", NULL),
69         REGULATOR_SUPPLY("vddio_vi", NULL),
70         REGULATOR_SUPPLY("ldo6", NULL),
71         REGULATOR_SUPPLY("ldo7", NULL),
72         REGULATOR_SUPPLY("ldo8", NULL),
73         REGULATOR_SUPPLY("vcore_audio", NULL),
74         REGULATOR_SUPPLY("avcore_audio", NULL),
75         REGULATOR_SUPPLY("vddio_sdmmc3", NULL),
76         REGULATOR_SUPPLY("vcore1_lpddr2", NULL),
77         REGULATOR_SUPPLY("vcom_1v8", NULL),
78         REGULATOR_SUPPLY("pmuio_1v8", NULL),
79         REGULATOR_SUPPLY("avdd_ic_usb", NULL),
80 };
81
82 static struct regulator_consumer_supply tps6591x_ldo1_supply[] = {
83         REGULATOR_SUPPLY("avdd_pexb", NULL),
84         REGULATOR_SUPPLY("vdd_pexb", NULL),
85         REGULATOR_SUPPLY("avdd_pex_pll", NULL),
86         REGULATOR_SUPPLY("avdd_pexa", NULL),
87         REGULATOR_SUPPLY("vdd_pexa", NULL),
88 };
89
90 static struct regulator_consumer_supply tps6591x_ldo2_supply[] = {
91         REGULATOR_SUPPLY("avdd_sata", NULL),
92         REGULATOR_SUPPLY("vdd_sata", NULL),
93         REGULATOR_SUPPLY("avdd_sata_pll", NULL),
94         REGULATOR_SUPPLY("avdd_plle", NULL),
95 };
96
97 static struct regulator_consumer_supply tps6591x_ldo3_supply[] = {
98         REGULATOR_SUPPLY("vddio_sdmmc1", NULL),
99 };
100
101 static struct regulator_consumer_supply tps6591x_ldo4_supply[] = {
102         REGULATOR_SUPPLY("vdd_rtc", NULL),
103 };
104
105 static struct regulator_consumer_supply tps6591x_ldo5_supply[] = {
106         REGULATOR_SUPPLY("avdd_vdac", NULL),
107 };
108 static struct regulator_consumer_supply tps6591x_ldo6_supply[] = {
109         REGULATOR_SUPPLY("avdd_dsi_csi", NULL),
110 };
111 static struct regulator_consumer_supply tps6591x_ldo7_supply[] = {
112         REGULATOR_SUPPLY("avdd_plla_p_c_s", NULL),
113         REGULATOR_SUPPLY("avdd_pllm", NULL),
114         REGULATOR_SUPPLY("avdd_pllu_d", NULL),
115         REGULATOR_SUPPLY("avdd_pllu_d2", NULL),
116         REGULATOR_SUPPLY("avdd_pllx", NULL),
117 };
118
119 static struct regulator_consumer_supply tps6591x_ldo8_supply[] = {
120         REGULATOR_SUPPLY("vdd_ddr_hs", NULL),
121 };
122
123 #define REGULATOR_INIT(_id, _minmv, _maxmv)                             \
124         {                                                               \
125                 .constraints = {                                        \
126                         .min_uV = (_minmv)*1000,                        \
127                         .max_uV = (_maxmv)*1000,                        \
128                         .valid_modes_mask = (REGULATOR_MODE_NORMAL |    \
129                                              REGULATOR_MODE_STANDBY),   \
130                         .valid_ops_mask = (REGULATOR_CHANGE_MODE |      \
131                                            REGULATOR_CHANGE_STATUS |    \
132                                            REGULATOR_CHANGE_VOLTAGE),   \
133                 },                                                      \
134                 .num_consumer_supplies = ARRAY_SIZE(tps6591x_##_id##_supply),\
135                 .consumer_supplies = tps6591x_##_id##_supply,           \
136         }
137
138 #define REGULATOR_INIT_SUPPLY(_id, _minmv, _maxmv, _supply_reg)         \
139         {                                                               \
140                 .constraints = {                                        \
141                         .min_uV = (_minmv)*1000,                        \
142                         .max_uV = (_maxmv)*1000,                        \
143                         .valid_modes_mask = (REGULATOR_MODE_NORMAL |    \
144                                              REGULATOR_MODE_STANDBY),   \
145                         .valid_ops_mask = (REGULATOR_CHANGE_MODE |      \
146                                            REGULATOR_CHANGE_STATUS |    \
147                                            REGULATOR_CHANGE_VOLTAGE),   \
148                 },                                                      \
149                 .num_consumer_supplies = ARRAY_SIZE(tps6591x_##_id##_supply),\
150                 .consumer_supplies = tps6591x_##_id##_supply,           \
151                 .supply_regulator = tps6591x_rails(_supply_reg),        \
152         }
153
154 static struct regulator_init_data vdd1_data = REGULATOR_INIT(vdd1, 600, 1500);
155 static struct regulator_init_data vdd2_data = REGULATOR_INIT(vdd2, 600, 1500);
156 static struct regulator_init_data vddctrl_data = REGULATOR_INIT(vddctrl, 600,
157                                                 1400);
158 static struct regulator_init_data vio_data = REGULATOR_INIT(vio, 1500, 3300);
159 static struct regulator_init_data ldo1_data = REGULATOR_INIT_SUPPLY(ldo1,
160                                                 1000, 3300, VDD_2);
161 static struct regulator_init_data ldo2_data = REGULATOR_INIT_SUPPLY(ldo2,
162                                                 1000, 3300, VDD_2);
163 static struct regulator_init_data ldo3_data = REGULATOR_INIT(ldo3, 1000, 3300);
164 static struct regulator_init_data ldo4_data = REGULATOR_INIT(ldo4, 1000, 3300);
165 static struct regulator_init_data ldo5_data = REGULATOR_INIT(ldo5, 1000, 3300);
166 static struct regulator_init_data ldo6_data = REGULATOR_INIT_SUPPLY(ldo6,
167                                                 1000, 3300, VIO);
168 static struct regulator_init_data ldo7_data = REGULATOR_INIT_SUPPLY(ldo7,
169                                                 1000, 3300, VIO);
170 static struct regulator_init_data ldo8_data = REGULATOR_INIT_SUPPLY(ldo8,
171                                                 1000, 3300, VIO);
172
173 static struct tps6591x_rtc_platform_data rtc_data = {
174         .irq = TEGRA_NR_IRQS + TPS6591X_INT_RTC_ALARM,
175 };
176
177 #define TPS_REG(_id, _data)                     \
178         {                                       \
179                 .id     = TPS6591X_ID_##_id,    \
180                 .name   = "tps6591x-regulator", \
181                 .platform_data  = _data,        \
182         }
183
184 static struct tps6591x_subdev_info tps_devs[] = {
185         TPS_REG(VIO, &vio_data),
186         TPS_REG(VDD_1, &vdd1_data),
187         TPS_REG(VDD_2, &vdd2_data),
188         TPS_REG(VDDCTRL, &vddctrl_data),
189         TPS_REG(LDO_1, &ldo1_data),
190         TPS_REG(LDO_2, &ldo2_data),
191         TPS_REG(LDO_3, &ldo3_data),
192         TPS_REG(LDO_4, &ldo4_data),
193         TPS_REG(LDO_5, &ldo5_data),
194         TPS_REG(LDO_6, &ldo6_data),
195         TPS_REG(LDO_7, &ldo7_data),
196         TPS_REG(LDO_8, &ldo8_data),
197         {
198                 .id     = 0,
199                 .name   = "tps6591x-rtc",
200                 .platform_data = &rtc_data,
201         },
202 };
203
204 static struct tps6591x_platform_data tps_platform = {
205         .irq_base       = TEGRA_NR_IRQS,
206         .num_subdevs    = ARRAY_SIZE(tps_devs),
207         .subdevs        = tps_devs,
208         .gpio_base      = TPS6591X_GPIO_BASE,
209 };
210
211 static struct i2c_board_info __initdata cardhu_regulators[] = {
212         {
213                 I2C_BOARD_INFO("tps6591x", 0x2D),
214                 .irq            = INT_EXTERNAL_PMU,
215                 .platform_data  = &tps_platform,
216         },
217 };
218
219 int __init cardhu_regulator_init(void)
220 {
221         i2c_register_board_info(4, cardhu_regulators, 1);
222         return 0;
223 }
224 #else
225 int __init cardhu_regulator_init(void)
226 {
227         return 0;
228 }
229 #endif
230
231 static struct tegra_suspend_platform_data cardhu_suspend_data = {
232         .cpu_timer      = 2000,
233         .cpu_off_timer  = 0,
234         .suspend_mode   = TEGRA_SUSPEND_NONE,
235         .core_timer     = 0x7e7e,
236         .core_off_timer = 0,
237         .separate_req   = true,
238         .corereq_high   = false,
239         .sysclkreq_high = true,
240         .wake_enb       = 0,
241         .wake_high      = 0,
242         .wake_low       = 0,
243         .wake_any       = 0,
244 };
245
246 int __init cardhu_suspend_init(void)
247 {
248         tegra_init_suspend(&cardhu_suspend_data);
249         return 0;
250 }