ARM: tegra: dalmore: fix power tree entry
[linux-3.10.git] / arch / arm / mach-tegra / board-dalmore-power.c
1 /*
2  * arch/arm/mach-tegra/board-dalmore-power.c
3  *
4  * Copyright (C) 2012 NVIDIA Corporation.
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 along
16  * with this program; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
18  */
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/io.h>
25 #include <linux/regulator/machine.h>
26 #include <linux/regulator/driver.h>
27 #include <linux/regulator/fixed.h>
28 #include <linux/mfd/max77663-core.h>
29 #include <linux/mfd/tps65090.h>
30 #include <linux/regulator/max77663-regulator.h>
31 #include <linux/regulator/tps65090-regulator.h>
32 #include <linux/regulator/tps51632-regulator.h>
33
34 #include <asm/mach-types.h>
35
36 #include <mach/iomap.h>
37 #include <mach/irqs.h>
38 #include <mach/gpio-tegra.h>
39
40 #include "pm.h"
41 #include "board.h"
42 #include "board-dalmore.h"
43
44 #define PMC_CTRL                0x0
45 #define PMC_CTRL_INTR_LOW       (1 << 17)
46
47 /*TPS65090 consumer rails */
48 static struct regulator_consumer_supply tps65090_dcdc1_supply[] = {
49         REGULATOR_SUPPLY("vdd_sys_5v0", NULL),
50         REGULATOR_SUPPLY("vdd_spk", NULL),
51         REGULATOR_SUPPLY("vdd_sys_modem_5v0", NULL),
52         REGULATOR_SUPPLY("vdd_sys_cam_5v0", NULL),
53 };
54
55 static struct regulator_consumer_supply tps65090_dcdc2_supply[] = {
56         REGULATOR_SUPPLY("vdd_sys_3v3", NULL),
57         REGULATOR_SUPPLY("vddio_hv", "tegradc.1"),
58         REGULATOR_SUPPLY("vdd_sys_ds_3v3", NULL),
59         REGULATOR_SUPPLY("vdd_sys_nfc_3v3", NULL),
60         REGULATOR_SUPPLY("vdd_hv_nfc_3v3", NULL),
61         REGULATOR_SUPPLY("vdd_sys_cam_3v3", NULL),
62         REGULATOR_SUPPLY("vdd_sys_sensor_3v3", NULL),
63         REGULATOR_SUPPLY("vdd_sys_audio_3v3", NULL),
64         REGULATOR_SUPPLY("vdd_sys_dtv_3v3", NULL),
65         REGULATOR_SUPPLY("vcc", "0-007c"),
66         REGULATOR_SUPPLY("vcc", "0-0030"),
67 };
68
69 static struct regulator_consumer_supply tps65090_dcdc3_supply[] = {
70         REGULATOR_SUPPLY("vdd_ao", NULL),
71 };
72
73 static struct regulator_consumer_supply tps65090_ldo1_supply[] = {
74         REGULATOR_SUPPLY("vdd_sby_5v0", NULL),
75 };
76
77 static struct regulator_consumer_supply tps65090_ldo2_supply[] = {
78         REGULATOR_SUPPLY("vdd_sby_3v3", NULL),
79 };
80
81 static struct regulator_consumer_supply tps65090_fet1_supply[] = {
82         REGULATOR_SUPPLY("vdd_lcd_bl", NULL),
83 };
84
85 static struct regulator_consumer_supply tps65090_fet3_supply[] = {
86         REGULATOR_SUPPLY("vdd_modem_3v3", NULL),
87 };
88
89 static struct regulator_consumer_supply tps65090_fet4_supply[] = {
90         REGULATOR_SUPPLY("avdd_lcd", NULL),
91         REGULATOR_SUPPLY("vdd_ts_3v3", NULL),
92 };
93
94 static struct regulator_consumer_supply tps65090_fet5_supply[] = {
95         REGULATOR_SUPPLY("vdd_lvds", NULL),
96 };
97
98 static struct regulator_consumer_supply tps65090_fet6_supply[] = {
99         REGULATOR_SUPPLY("vdd_sd_slot", "sdhci-tegra.2"),
100 };
101
102 static struct regulator_consumer_supply tps65090_fet7_supply[] = {
103         REGULATOR_SUPPLY("vdd_com_3v3", NULL),
104         REGULATOR_SUPPLY("vdd_gps_3v3", NULL),
105 };
106
107 #define TPS65090_PDATA_INIT(_id, _name, _supply_reg,                    \
108                 _always_on, _boot_on, _apply_uV, _en_ext_ctrl, _gpio)   \
109 static struct regulator_init_data ri_data_##_name =                     \
110 {                                                                       \
111         .supply_regulator = _supply_reg,                                \
112         .constraints = {                                                \
113                 .name = tps65090_rails(_id),                            \
114                 .valid_modes_mask = (REGULATOR_MODE_NORMAL |            \
115                                      REGULATOR_MODE_STANDBY),           \
116                 .valid_ops_mask = (REGULATOR_CHANGE_MODE |              \
117                                    REGULATOR_CHANGE_STATUS |            \
118                                    REGULATOR_CHANGE_VOLTAGE),           \
119                 .always_on = _always_on,                                \
120                 .boot_on = _boot_on,                                    \
121                 .apply_uV = _apply_uV,                                  \
122         },                                                              \
123         .num_consumer_supplies =                                        \
124                 ARRAY_SIZE(tps65090_##_name##_supply),                  \
125         .consumer_supplies = tps65090_##_name##_supply,                 \
126 };                                                                      \
127 static struct tps65090_regulator_platform_data                          \
128                         tps65090_regulator_pdata_##_name =              \
129 {                                                                       \
130         .id = TPS65090_REGULATOR_##_id,                                 \
131         .enable_ext_control = _en_ext_ctrl,                             \
132         .gpio = _gpio,                                                  \
133         .reg_init_data = &ri_data_##_name ,                             \
134 }
135
136 TPS65090_PDATA_INIT(DCDC1, dcdc1, NULL, 1, 1, 0, false, -1);
137 TPS65090_PDATA_INIT(DCDC2, dcdc2, NULL, 1, 1, 0, false, -1);
138 TPS65090_PDATA_INIT(DCDC3, dcdc3, NULL, 1, 1, 0, false, -1);
139 TPS65090_PDATA_INIT(LDO1, ldo1, NULL, 1, 1, 0, false, -1);
140 TPS65090_PDATA_INIT(LDO2, ldo2, NULL, 1, 1, 0, false, -1);
141 TPS65090_PDATA_INIT(FET1, fet1, NULL, 0, 0, 0, false, -1);
142 TPS65090_PDATA_INIT(FET3, fet3, tps65090_rails(DCDC2), 0, 0, 0, false, -1);
143 TPS65090_PDATA_INIT(FET4, fet4, tps65090_rails(DCDC2), 0, 0, 0, false, -1);
144 TPS65090_PDATA_INIT(FET5, fet5, tps65090_rails(DCDC2), 0, 0, 0, false, -1);
145 TPS65090_PDATA_INIT(FET6, fet6, tps65090_rails(DCDC2), 0, 0, 0, false, -1);
146 TPS65090_PDATA_INIT(FET7, fet7, tps65090_rails(DCDC2), 0, 0, 0, false, -1);
147
148 #define ADD_TPS65090_REG(_name) (&tps65090_regulator_pdata_##_name)
149 static struct tps65090_regulator_platform_data *tps65090_reg_pdata[] = {
150         ADD_TPS65090_REG(dcdc1),
151         ADD_TPS65090_REG(dcdc2),
152         ADD_TPS65090_REG(dcdc3),
153         ADD_TPS65090_REG(ldo1),
154         ADD_TPS65090_REG(ldo2),
155         ADD_TPS65090_REG(fet1),
156         ADD_TPS65090_REG(fet3),
157         ADD_TPS65090_REG(fet4),
158         ADD_TPS65090_REG(fet5),
159         ADD_TPS65090_REG(fet6),
160         ADD_TPS65090_REG(fet7),
161 };
162
163 static struct tps65090_platform_data tps65090_pdata = {
164         .irq_base = -1,
165         .num_reg_pdata =  ARRAY_SIZE(tps65090_reg_pdata),
166         .reg_pdata = tps65090_reg_pdata
167 };
168
169 /* MAX77663 consumer rails */
170 static struct regulator_consumer_supply max77663_sd0_supply[] = {
171         REGULATOR_SUPPLY("vdd_core", NULL),
172 };
173
174 static struct regulator_consumer_supply max77663_sd1_supply[] = {
175         REGULATOR_SUPPLY("vddio_ddr", NULL),
176         REGULATOR_SUPPLY("vddio_ddr0", NULL),
177         REGULATOR_SUPPLY("vddio_ddr1", NULL),
178 };
179
180 static struct regulator_consumer_supply max77663_sd2_supply[] = {
181         REGULATOR_SUPPLY("avdd_usb_pll", "tegra-ehci.0"),
182         REGULATOR_SUPPLY("avdd_usb_pll", "tegra-ehci.1"),
183         REGULATOR_SUPPLY("vddio_cam", "tegrra_camera"),
184         REGULATOR_SUPPLY("avdd_osc", NULL),
185         REGULATOR_SUPPLY("vddio_sys", NULL),
186         REGULATOR_SUPPLY("vddio_sdmmc", "sdhci-tegra.0"),
187         REGULATOR_SUPPLY("vddio_sdmmc", "sdhci-tegra.3"),
188         REGULATOR_SUPPLY("vdd_emmc", NULL),
189         REGULATOR_SUPPLY("vddio_audio", NULL),
190         REGULATOR_SUPPLY("avdd_audio_1v8", NULL),
191         REGULATOR_SUPPLY("vdd_audio_1v8", NULL),
192         REGULATOR_SUPPLY("vddio_modem", NULL),
193         REGULATOR_SUPPLY("vddio_modem_1v8", NULL),
194         REGULATOR_SUPPLY("vddio_bb", NULL),
195         REGULATOR_SUPPLY("vddio_bb_1v8", NULL),
196         REGULATOR_SUPPLY("vddio_uart", NULL),
197         REGULATOR_SUPPLY("vddio_gmi", NULL),
198         REGULATOR_SUPPLY("vdd_sensor_1v8", NULL),
199         REGULATOR_SUPPLY("vdd_mic_1v8", NULL),
200         REGULATOR_SUPPLY("vdd_nfc_1v8", NULL),
201         REGULATOR_SUPPLY("vdd_ds_1v8", NULL),
202         REGULATOR_SUPPLY("vdd_ts_1v8", NULL),
203         REGULATOR_SUPPLY("vdd_spi_1v8", NULL),
204         REGULATOR_SUPPLY("dvdd_lcd", NULL),
205         REGULATOR_SUPPLY("vdd_com_1v8", NULL),
206         REGULATOR_SUPPLY("vddio_com_1v8", NULL),
207         REGULATOR_SUPPLY("vdd_gps_1v8", NULL),
208         REGULATOR_SUPPLY("vdd_dtv_1v8", NULL),
209 };
210
211 static struct regulator_consumer_supply max77663_sd3_supply[] = {
212         REGULATOR_SUPPLY("vcore_emmc", NULL),
213 };
214
215 static struct regulator_consumer_supply max77663_ldo0_supply[] = {
216         REGULATOR_SUPPLY("avdd_plla_p_c", NULL),
217         REGULATOR_SUPPLY("avdd_pllx", NULL),
218         REGULATOR_SUPPLY("avdd_plle", NULL),
219         REGULATOR_SUPPLY("avdd_pllm", NULL),
220         REGULATOR_SUPPLY("avdd_pllu", NULL),
221         REGULATOR_SUPPLY("avdd_csi_dsi_pll", "tegradc.0"),
222         REGULATOR_SUPPLY("avdd_csi_dsi_pll", "tegradc.1"),
223         REGULATOR_SUPPLY("avdd_csi_dsi_pll", "tegra_camera"),
224 };
225
226 static struct regulator_consumer_supply max77663_ldo1_supply[] = {
227         REGULATOR_SUPPLY("vdd_ddr_hs", NULL),
228 };
229
230 static struct regulator_consumer_supply max77663_ldo2_supply[] = {
231         REGULATOR_SUPPLY("vdd_sensor_2v85", NULL),
232         REGULATOR_SUPPLY("vdd_als", NULL),
233         REGULATOR_SUPPLY("vdd", "1-004c"),
234 };
235
236 static struct regulator_consumer_supply max77663_ldo3_supply[] = {
237         REGULATOR_SUPPLY("avdd_hdmi_pll", "tegradc.1"),
238         REGULATOR_SUPPLY("avdd_usb_pll", "tegra-ehci.2"),
239         REGULATOR_SUPPLY("avddio_usb", "tegra-ehci.2"),
240 };
241
242 static struct regulator_consumer_supply max77663_ldo4_supply[] = {
243         REGULATOR_SUPPLY("vdd_rtc", NULL),
244 };
245
246 static struct regulator_consumer_supply max77663_ldo5_supply[] = {
247         REGULATOR_SUPPLY("avdd_dsi_csi", "tegradc.0"),
248         REGULATOR_SUPPLY("avdd_dsi_csi", "tegradc.1"),
249         REGULATOR_SUPPLY("avdd_dsi_csi", "tegra_camera"),
250         REGULATOR_SUPPLY("vddio_hsic", "tegra-ehci.0"),
251         REGULATOR_SUPPLY("vddio_hsic", "tegra-ehci.1"),
252         REGULATOR_SUPPLY("vddio_bb_hsic", NULL),
253 };
254
255 static struct regulator_consumer_supply max77663_ldo6_supply[] = {
256         REGULATOR_SUPPLY("vddio_sdmmc", "sdhci-tegra.2"),
257 };
258
259 /* FIXME!! Put the device address of camera */
260 static struct regulator_consumer_supply max77663_ldo7_supply[] = {
261         REGULATOR_SUPPLY("avdd_cam1", NULL),
262         REGULATOR_SUPPLY("avdd_2v8_cam_af", NULL),
263 };
264
265 /* FIXME!! Put the device address of camera */
266 static struct regulator_consumer_supply max77663_ldo8_supply[] = {
267         REGULATOR_SUPPLY("avdd_cam2", NULL),
268 };
269
270 static struct max77663_regulator_fps_cfg max77663_fps_cfgs[] = {
271         {
272                 .src = FPS_SRC_0,
273                 .en_src = FPS_EN_SRC_EN0,
274                 .time_period = FPS_TIME_PERIOD_DEF,
275         },
276         {
277                 .src = FPS_SRC_1,
278                 .en_src = FPS_EN_SRC_EN1,
279                 .time_period = FPS_TIME_PERIOD_DEF,
280         },
281         {
282                 .src = FPS_SRC_2,
283                 .en_src = FPS_EN_SRC_EN0,
284                 .time_period = FPS_TIME_PERIOD_DEF,
285         },
286 };
287
288 #define MAX77663_PDATA_INIT(_rid, _id, _min_uV, _max_uV, _supply_reg,   \
289                 _always_on, _boot_on, _apply_uV,                        \
290                 _fps_src, _fps_pu_period, _fps_pd_period, _flags)       \
291         static struct regulator_init_data max77663_regulator_idata_##_id = {   \
292                 .supply_regulator = _supply_reg,                        \
293                 .constraints = {                                        \
294                         .name = max77663_rails(_id),                    \
295                         .min_uV = _min_uV,                              \
296                         .max_uV = _max_uV,                              \
297                         .valid_modes_mask = (REGULATOR_MODE_NORMAL |    \
298                                              REGULATOR_MODE_STANDBY),   \
299                         .valid_ops_mask = (REGULATOR_CHANGE_MODE |      \
300                                            REGULATOR_CHANGE_STATUS |    \
301                                            REGULATOR_CHANGE_VOLTAGE),   \
302                         .always_on = _always_on,                        \
303                         .boot_on = _boot_on,                            \
304                         .apply_uV = _apply_uV,                          \
305                 },                                                      \
306                 .num_consumer_supplies =                                \
307                         ARRAY_SIZE(max77663_##_id##_supply),            \
308                 .consumer_supplies = max77663_##_id##_supply,           \
309         };                                                              \
310 static struct max77663_regulator_platform_data max77663_regulator_pdata_##_id =\
311 {                                                                       \
312                 .reg_init_data = &max77663_regulator_idata_##_id,       \
313                 .id = MAX77663_REGULATOR_ID_##_rid,                     \
314                 .fps_src = _fps_src,                                    \
315                 .fps_pu_period = _fps_pu_period,                        \
316                 .fps_pd_period = _fps_pd_period,                        \
317                 .fps_cfgs = max77663_fps_cfgs,                          \
318                 .flags = _flags,                                        \
319         }
320
321 MAX77663_PDATA_INIT(SD0, sd0,  900000, 1400000, tps65090_rails(DCDC3), 1, 1, 0,
322                     FPS_SRC_1, -1, -1, SD_FSRADE_DISABLE);
323
324 MAX77663_PDATA_INIT(SD1, sd1,  1200000, 1200000, tps65090_rails(DCDC3), 1, 1, 1,
325                     FPS_SRC_1, -1, -1, SD_FSRADE_DISABLE);
326
327 MAX77663_PDATA_INIT(SD2, sd2,  1800000, 1800000, tps65090_rails(DCDC3), 1, 1, 1,
328                     FPS_SRC_0, -1, -1, 0);
329
330 MAX77663_PDATA_INIT(SD3, sd3,  2850000, 2850000, tps65090_rails(DCDC3), 1, 1, 1,
331                     FPS_SRC_NONE, -1, -1, 0);
332
333 MAX77663_PDATA_INIT(LDO0, ldo0, 1050000, 1050000, max77663_rails(sd2), 1, 1, 1,
334                     FPS_SRC_1, -1, -1, 0);
335
336 MAX77663_PDATA_INIT(LDO1, ldo1, 1050000, 1050000, max77663_rails(sd2), 0, 0, 1,
337                     FPS_SRC_NONE, -1, -1, 0);
338
339 MAX77663_PDATA_INIT(LDO2, ldo2, 2850000, 2850000, tps65090_rails(DCDC2), 1, 1,
340                     1, FPS_SRC_1, -1, -1, 0);
341
342 MAX77663_PDATA_INIT(LDO3, ldo3, 1050000, 1050000, max77663_rails(sd2), 1, 1, 1,
343                     FPS_SRC_NONE, -1, -1, 0);
344
345 MAX77663_PDATA_INIT(LDO4, ldo4, 1100000, 1100000, tps65090_rails(DCDC2), 1, 1,
346                     1, FPS_SRC_NONE, -1, -1, LDO4_EN_TRACKING);
347
348 MAX77663_PDATA_INIT(LDO5, ldo5, 1200000, 1200000, max77663_rails(sd2), 0, 1, 1,
349                     FPS_SRC_NONE, -1, -1, 0);
350
351 MAX77663_PDATA_INIT(LDO6, ldo6, 1800000, 3300000, tps65090_rails(DCDC2), 0, 0, 0,
352                     FPS_SRC_NONE, -1, -1, 0);
353
354 MAX77663_PDATA_INIT(LDO7, ldo7, 2800000, 2800000, tps65090_rails(DCDC2), 0, 0, 1,
355                     FPS_SRC_NONE, -1, -1, 0);
356
357 MAX77663_PDATA_INIT(LDO8, ldo8, 2800000, 2800000, tps65090_rails(DCDC2), 0, 1, 1,
358                     FPS_SRC_1, -1, -1, 0);
359
360 #define MAX77663_REG(_id, _data) (&max77663_regulator_pdata_##_data)
361
362 static struct max77663_regulator_platform_data *max77663_reg_pdata[] = {
363         MAX77663_REG(SD0, sd0),
364         MAX77663_REG(SD1, sd1),
365         MAX77663_REG(SD2, sd2),
366         MAX77663_REG(SD3, sd3),
367         MAX77663_REG(LDO0, ldo0),
368         MAX77663_REG(LDO1, ldo1),
369         MAX77663_REG(LDO2, ldo2),
370         MAX77663_REG(LDO3, ldo3),
371         MAX77663_REG(LDO4, ldo4),
372         MAX77663_REG(LDO5, ldo5),
373         MAX77663_REG(LDO6, ldo6),
374         MAX77663_REG(LDO7, ldo7),
375         MAX77663_REG(LDO8, ldo8),
376 };
377
378 static struct max77663_gpio_config max77663_gpio_cfgs[] = {
379         {
380                 .gpio = MAX77663_GPIO0,
381                 .dir = GPIO_DIR_OUT,
382                 .dout = GPIO_DOUT_LOW,
383                 .out_drv = GPIO_OUT_DRV_PUSH_PULL,
384                 .alternate = GPIO_ALT_DISABLE,
385         },
386         {
387                 .gpio = MAX77663_GPIO1,
388                 .dir = GPIO_DIR_IN,
389                 .dout = GPIO_DOUT_HIGH,
390                 .out_drv = GPIO_OUT_DRV_OPEN_DRAIN,
391                 .pull_up = GPIO_PU_ENABLE,
392                 .alternate = GPIO_ALT_DISABLE,
393         },
394         {
395                 .gpio = MAX77663_GPIO2,
396                 .dir = GPIO_DIR_OUT,
397                 .dout = GPIO_DOUT_HIGH,
398                 .out_drv = GPIO_OUT_DRV_OPEN_DRAIN,
399                 .pull_up = GPIO_PU_ENABLE,
400                 .alternate = GPIO_ALT_DISABLE,
401         },
402         {
403                 .gpio = MAX77663_GPIO3,
404                 .dir = GPIO_DIR_OUT,
405                 .dout = GPIO_DOUT_HIGH,
406                 .out_drv = GPIO_OUT_DRV_OPEN_DRAIN,
407                 .pull_up = GPIO_PU_ENABLE,
408                 .alternate = GPIO_ALT_DISABLE,
409         },
410         {
411                 .gpio = MAX77663_GPIO4,
412                 .dir = GPIO_DIR_OUT,
413                 .dout = GPIO_DOUT_HIGH,
414                 .out_drv = GPIO_OUT_DRV_PUSH_PULL,
415                 .alternate = GPIO_ALT_ENABLE,
416         },
417         {
418                 .gpio = MAX77663_GPIO5,
419                 .dir = GPIO_DIR_OUT,
420                 .dout = GPIO_DOUT_LOW,
421                 .out_drv = GPIO_OUT_DRV_PUSH_PULL,
422                 .alternate = GPIO_ALT_DISABLE,
423         },
424         {
425                 .gpio = MAX77663_GPIO6,
426                 .dir = GPIO_DIR_OUT,
427                 .dout = GPIO_DOUT_LOW,
428                 .out_drv = GPIO_OUT_DRV_OPEN_DRAIN,
429                 .alternate = GPIO_ALT_DISABLE,
430         },
431         {
432                 .gpio = MAX77663_GPIO7,
433                 .dir = GPIO_DIR_OUT,
434                 .dout = GPIO_DOUT_LOW,
435                 .out_drv = GPIO_OUT_DRV_OPEN_DRAIN,
436                 .alternate = GPIO_ALT_DISABLE,
437         },
438 };
439
440 static struct max77663_platform_data max77663_pdata = {
441         .irq_base       = MAX77663_IRQ_BASE,
442         .gpio_base      = MAX77663_GPIO_BASE,
443
444         .num_gpio_cfgs  = ARRAY_SIZE(max77663_gpio_cfgs),
445         .gpio_cfgs      = max77663_gpio_cfgs,
446
447         .regulator_pdata = max77663_reg_pdata,
448         .num_regulator_pdata = ARRAY_SIZE(max77663_reg_pdata),
449
450         .rtc_i2c_addr   = 0x68,
451
452         .use_power_off  = false,
453 };
454
455 /* EN_AVDD_USB_HDMI From PMU GP1 */
456 static struct regulator_consumer_supply fixed_reg_avdd_usb_hdmi_supply[] = {
457         REGULATOR_SUPPLY("avdd_hdmi", "tegradc.1"),
458         REGULATOR_SUPPLY("avdd_usb", "tegra-ehci.0"),
459         REGULATOR_SUPPLY("avdd_usb", "tegra-ehci.1"),
460         REGULATOR_SUPPLY("avdd_usb", "tegra-ehci.2"),
461         REGULATOR_SUPPLY("hvdd_usb", "tegra-ehci.2"),
462 };
463
464 /* EN_CAM_1v8 From PMU GP5 */
465 static struct regulator_consumer_supply fixed_reg_en_1v8_cam_supply[] = {
466         REGULATOR_SUPPLY("dvdd_cam", NULL),
467         REGULATOR_SUPPLY("vdd_cam_1v8", NULL),
468 };
469
470
471 static struct regulator_consumer_supply fixed_reg_vdd_hdmi_5v0_supply[] = {
472         REGULATOR_SUPPLY("vdd_hdmi_5v0", "tegradc.1"),
473 };
474
475 /* EN_USB1_VBUS From TEGRA GPIO PN4 PR3(T30) */
476 static struct regulator_consumer_supply fixed_reg_usb1_vbus_supply[] = {
477         REGULATOR_SUPPLY("usb_vbus", "tegra-ehci.0"),
478 };
479
480 #ifdef CONFIG_ARCH_TEGRA_11x_SOC
481 /* EN_3V3_FUSE From TEGRA GPIO PX4 */
482 static struct regulator_consumer_supply fixed_reg_vpp_fuse_supply[] = {
483         REGULATOR_SUPPLY("vpp_fuse", NULL),
484 };
485
486 /* EN_USB3_VBUS From TEGRA GPIO PM5 */
487 static struct regulator_consumer_supply fixed_reg_usb3_vbus_supply[] = {
488         REGULATOR_SUPPLY("usb_vbus", "tegra-ehci.2"),
489 };
490 #endif
491
492 /* Macro for defining fixed regulator sub device data */
493 #define FIXED_SUPPLY(_name) "fixed_reg_"#_name
494 #define FIXED_REG(_id, _var, _name, _in_supply, _always_on, _boot_on,   \
495         _gpio_nr, _open_drain, _active_high, _boot_state, _millivolts)  \
496         static struct regulator_init_data ri_data_##_var =              \
497         {                                                               \
498                 .supply_regulator = _in_supply,                         \
499                 .num_consumer_supplies =                                \
500                         ARRAY_SIZE(fixed_reg_##_name##_supply),         \
501                 .consumer_supplies = fixed_reg_##_name##_supply,        \
502                 .constraints = {                                        \
503                         .valid_modes_mask = (REGULATOR_MODE_NORMAL |    \
504                                         REGULATOR_MODE_STANDBY),        \
505                         .valid_ops_mask = (REGULATOR_CHANGE_MODE |      \
506                                         REGULATOR_CHANGE_STATUS |       \
507                                         REGULATOR_CHANGE_VOLTAGE),      \
508                         .always_on = _always_on,                        \
509                         .boot_on = _boot_on,                            \
510                 },                                                      \
511         };                                                              \
512         static struct fixed_voltage_config fixed_reg_##_var##_pdata =   \
513         {                                                               \
514                 .supply_name = FIXED_SUPPLY(_name),                     \
515                 .microvolts = _millivolts * 1000,                       \
516                 .gpio = _gpio_nr,                                       \
517                 .gpio_is_open_drain = _open_drain,                      \
518                 .enable_high = _active_high,                            \
519                 .enabled_at_boot = _boot_state,                         \
520                 .init_data = &ri_data_##_var,                           \
521         };                                                              \
522         static struct platform_device fixed_reg_##_var##_dev = {        \
523                 .name = "reg-fixed-voltage",                            \
524                 .id = _id,                                              \
525                 .dev = {                                                \
526                         .platform_data = &fixed_reg_##_var##_pdata,     \
527                 },                                                      \
528         }
529
530 FIXED_REG(1,    avdd_usb_hdmi,  avdd_usb_hdmi,
531         tps65090_rails(DCDC2),  0,      0,
532         MAX77663_GPIO_BASE + MAX77663_GPIO1,    true,   true,   1,      3300);
533
534 FIXED_REG(2,    en_1v8_cam,     en_1v8_cam,
535         max77663_rails(sd2),    0,      0,
536         MAX77663_GPIO_BASE + MAX77663_GPIO5,    false,  true,   0,      1800);
537
538 FIXED_REG(3,    vdd_hdmi_5v0,   vdd_hdmi_5v0,
539         tps65090_rails(DCDC1),  0,      0,
540         TEGRA_GPIO_PK1, false,  true,   0,      5000);
541
542 #ifdef CONFIG_ARCH_TEGRA_11x_SOC
543 FIXED_REG(4,    vpp_fuse,       vpp_fuse,
544         max77663_rails(sd2),    0,      0,
545         TEGRA_GPIO_PX4, false,  true,   0,      3300);
546
547 FIXED_REG(5,    usb1_vbus,      usb1_vbus,
548         tps65090_rails(DCDC1),  0,      0,
549         TEGRA_GPIO_PN4, true,   true,   0,      5000);
550
551 FIXED_REG(6,    usb3_vbus,      usb3_vbus,
552         tps65090_rails(DCDC1),  0,      0,
553         TEGRA_GPIO_PK6, true,   true,   0,      5000);
554 #else
555 FIXED_REG(4,    usb1_vbus,      usb1_vbus,
556         tps65090_rails(DCDC1),  0,      0,
557         TEGRA_GPIO_PR3, true,   true,   0,      5000);
558 #endif
559 /*
560  * Creating the fixed regulator device tables
561  */
562
563 #define ADD_FIXED_REG(_name)    (&fixed_reg_##_name##_dev)
564
565 #define E1612_COMMON_FIXED_REG                  \
566         ADD_FIXED_REG(avdd_usb_hdmi),           \
567         ADD_FIXED_REG(en_1v8_cam),              \
568         ADD_FIXED_REG(vdd_hdmi_5v0),
569
570 #ifdef CONFIG_ARCH_TEGRA_11x_SOC
571 #define E1612_T114_FIXED_REG                    \
572         ADD_FIXED_REG(vpp_fuse),                \
573         ADD_FIXED_REG(usb1_vbus),               \
574         ADD_FIXED_REG(usb3_vbus),
575 #endif
576
577 #ifdef CONFIG_ARCH_TEGRA_3x_SOC
578 #define E1612_T30_FIXED_REG                     \
579         ADD_FIXED_REG(usb1_vbus),
580 #endif
581
582 /* Gpio switch regulator platform data for Dalmore E1612 */
583 static struct platform_device *fixed_reg_devs_a00[] = {
584 #ifdef CONFIG_ARCH_TEGRA_11x_SOC
585         E1612_T114_FIXED_REG
586 #endif
587 #ifdef CONFIG_ARCH_TEGRA_3x_SOC
588         E1612_T30_FIXED_REG
589 #endif
590         E1612_COMMON_FIXED_REG
591
592 };
593
594 static struct i2c_board_info __initdata max77663_regulators[] = {
595         {
596                 /* The I2C address was determined by OTP factory setting */
597                 I2C_BOARD_INFO("max77663", 0x3c),
598                 .irq            = INT_EXTERNAL_PMU,
599                 .platform_data  = &max77663_pdata,
600         },
601 };
602
603 static struct i2c_board_info __initdata tps65090_regulators[] = {
604         {
605                 I2C_BOARD_INFO("tps65090", 0x48),
606                 .platform_data  = &tps65090_pdata,
607         },
608 };
609
610 /* TPS51632 DC-DC converter */
611 static struct regulator_consumer_supply tps51632_dcdc_supply[] = {
612         REGULATOR_SUPPLY("vdd_cpu", NULL),
613 };
614
615 static struct regulator_init_data tps51632_init_data = {
616         .constraints = {                                                \
617                 .min_uV = 500000,                                       \
618                 .max_uV = 1520000,                                      \
619                 .valid_modes_mask = (REGULATOR_MODE_NORMAL |            \
620                                         REGULATOR_MODE_STANDBY),        \
621                 .valid_ops_mask = (REGULATOR_CHANGE_MODE |              \
622                                         REGULATOR_CHANGE_STATUS |       \
623                                         REGULATOR_CHANGE_VOLTAGE),      \
624                 .always_on = 1,                                         \
625                 .boot_on =  1,                                          \
626                 .apply_uV = 0,                                          \
627         },                                                              \
628         .num_consumer_supplies = ARRAY_SIZE(tps51632_dcdc_supply),      \
629                 .consumer_supplies = tps51632_dcdc_supply,              \
630 };
631
632 static struct tps51632_regulator_platform_data tps51632_pdata = {
633         .reg_init_data = &tps51632_init_data,           \
634         .enable_pwm = false,                            \
635         .max_voltage_uV = 1520000,                      \
636         .base_voltage_uV = 500000,                      \
637         .slew_rate_uv_per_us = 6000,                    \
638 };
639
640 static struct i2c_board_info __initdata tps51632_boardinfo[] = {
641         {
642                 I2C_BOARD_INFO("tps51632", 0x43),
643                 .platform_data  = &tps51632_pdata,
644         },
645 };
646
647 static int ac_online(void)
648 {
649         return 1;
650 }
651
652 static struct resource dalmore_pda_resources[] = {
653         [0] = {
654                 .name   = "ac",
655         },
656 };
657
658 static struct pda_power_pdata dalmore_pda_data = {
659         .is_ac_online   = ac_online,
660 };
661
662 static struct platform_device dalmore_pda_power_device = {
663         .name           = "pda-power",
664         .id             = -1,
665         .resource       = dalmore_pda_resources,
666         .num_resources  = ARRAY_SIZE(dalmore_pda_resources),
667         .dev    = {
668                 .platform_data  = &dalmore_pda_data,
669         },
670 };
671
672 static struct tegra_suspend_platform_data dalmore_suspend_data = {
673         .cpu_timer      = 2000,
674         .cpu_off_timer  = 0,
675         .suspend_mode   = TEGRA_SUSPEND_NONE,
676         .core_timer     = 0x7e7e,
677         .core_off_timer = 0,
678         .corereq_high   = false,
679         .sysclkreq_high = true,
680 };
681
682 static int __init dalmore_max77663_regulator_init(void)
683 {
684         void __iomem *pmc = IO_ADDRESS(TEGRA_PMC_BASE);
685         u32 pmc_ctrl;
686
687         /* configure the power management controller to trigger PMU
688          * interrupts when low */
689         pmc_ctrl = readl(pmc + PMC_CTRL);
690         writel(pmc_ctrl | PMC_CTRL_INTR_LOW, pmc + PMC_CTRL);
691
692         i2c_register_board_info(4, max77663_regulators,
693                                 ARRAY_SIZE(max77663_regulators));
694
695         return 0;
696 }
697
698 static int __init dalmore_fixed_regulator_init(void)
699 {
700         if (!machine_is_dalmore())
701                 return 0;
702
703         return platform_add_devices(fixed_reg_devs_a00,
704                                 ARRAY_SIZE(fixed_reg_devs_a00));
705 }
706 subsys_initcall_sync(dalmore_fixed_regulator_init);
707
708 int __init dalmore_regulator_init(void)
709 {
710         i2c_register_board_info(4, tps65090_regulators,
711                                 ARRAY_SIZE(tps65090_regulators));
712
713         dalmore_max77663_regulator_init();
714         i2c_register_board_info(4, tps51632_boardinfo, 1);
715         platform_device_register(&dalmore_pda_power_device);
716         return 0;
717 }
718
719 int __init dalmore_suspend_init(void)
720 {
721         tegra_init_suspend(&dalmore_suspend_data);
722         return 0;
723 }
724