ARM: tegra: pluto/dalmore: fix sd slot power rail
[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("vddio_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-udc.0"),
182         REGULATOR_SUPPLY("avdd_usb_pll", "tegra-ehci.0"),
183         REGULATOR_SUPPLY("avdd_usb_pll", "tegra-ehci.1"),
184         REGULATOR_SUPPLY("avdd_usb_pll", "tegra-ehci.2"),
185         REGULATOR_SUPPLY("vddio_cam", "tegrra_camera"),
186         REGULATOR_SUPPLY("avdd_osc", NULL),
187         REGULATOR_SUPPLY("vddio_sys", NULL),
188         REGULATOR_SUPPLY("vddio_sdmmc", "sdhci-tegra.0"),
189         REGULATOR_SUPPLY("vddio_sdmmc", "sdhci-tegra.3"),
190         REGULATOR_SUPPLY("vdd_emmc", NULL),
191         REGULATOR_SUPPLY("vddio_audio", NULL),
192         REGULATOR_SUPPLY("avdd_audio_1v8", NULL),
193         REGULATOR_SUPPLY("vdd_audio_1v8", NULL),
194         REGULATOR_SUPPLY("vddio_modem", NULL),
195         REGULATOR_SUPPLY("vddio_modem_1v8", NULL),
196         REGULATOR_SUPPLY("vddio_bb", NULL),
197         REGULATOR_SUPPLY("vddio_bb_1v8", NULL),
198         REGULATOR_SUPPLY("vddio_uart", NULL),
199         REGULATOR_SUPPLY("vddio_gmi", NULL),
200         REGULATOR_SUPPLY("vdd_sensor_1v8", NULL),
201         REGULATOR_SUPPLY("vdd_mic_1v8", NULL),
202         REGULATOR_SUPPLY("vdd_nfc_1v8", NULL),
203         REGULATOR_SUPPLY("vdd_ds_1v8", NULL),
204         REGULATOR_SUPPLY("vdd_ts_1v8", NULL),
205         REGULATOR_SUPPLY("vdd_spi_1v8", NULL),
206         REGULATOR_SUPPLY("dvdd_lcd", NULL),
207         REGULATOR_SUPPLY("vdd_com_1v8", NULL),
208         REGULATOR_SUPPLY("vddio_com_1v8", NULL),
209         REGULATOR_SUPPLY("vdd_gps_1v8", NULL),
210         REGULATOR_SUPPLY("vdd_dtv_1v8", NULL),
211 };
212
213 static struct regulator_consumer_supply max77663_sd3_supply[] = {
214         REGULATOR_SUPPLY("vcore_emmc", NULL),
215 };
216
217 static struct regulator_consumer_supply max77663_ldo0_supply[] = {
218         REGULATOR_SUPPLY("avdd_plla_p_c", NULL),
219         REGULATOR_SUPPLY("avdd_pllx", NULL),
220         REGULATOR_SUPPLY("avdd_plle", NULL),
221         REGULATOR_SUPPLY("avdd_pllm", NULL),
222         REGULATOR_SUPPLY("avdd_pllu", NULL),
223         REGULATOR_SUPPLY("avdd_csi_dsi_pll", "tegradc.0"),
224         REGULATOR_SUPPLY("avdd_csi_dsi_pll", "tegradc.1"),
225         REGULATOR_SUPPLY("avdd_csi_dsi_pll", "tegra_camera"),
226 };
227
228 static struct regulator_consumer_supply max77663_ldo1_supply[] = {
229         REGULATOR_SUPPLY("vdd_ddr_hs", NULL),
230 };
231
232 static struct regulator_consumer_supply max77663_ldo2_supply[] = {
233         REGULATOR_SUPPLY("vdd_sensor_2v85", NULL),
234         REGULATOR_SUPPLY("vdd_als", NULL),
235         REGULATOR_SUPPLY("vdd", "1-004c"),
236 };
237
238 static struct regulator_consumer_supply max77663_ldo3_supply[] = {
239         REGULATOR_SUPPLY("avdd_hdmi_pll", "tegradc.1"),
240         REGULATOR_SUPPLY("avdd_usb_pll", "tegra-ehci.2"),
241         REGULATOR_SUPPLY("avddio_usb", "tegra-ehci.2"),
242 };
243
244 static struct regulator_consumer_supply max77663_ldo4_supply[] = {
245         REGULATOR_SUPPLY("vdd_rtc", NULL),
246 };
247
248 static struct regulator_consumer_supply max77663_ldo5_supply[] = {
249         REGULATOR_SUPPLY("avdd_dsi_csi", "tegradc.0"),
250         REGULATOR_SUPPLY("avdd_dsi_csi", "tegradc.1"),
251         REGULATOR_SUPPLY("avdd_dsi_csi", "tegra_camera"),
252         REGULATOR_SUPPLY("vddio_hsic", "tegra-ehci.0"),
253         REGULATOR_SUPPLY("vddio_hsic", "tegra-ehci.1"),
254         REGULATOR_SUPPLY("vddio_bb_hsic", NULL),
255 };
256
257 static struct regulator_consumer_supply max77663_ldo6_supply[] = {
258         REGULATOR_SUPPLY("vddio_sdmmc", "sdhci-tegra.2"),
259 };
260
261 /* FIXME!! Put the device address of camera */
262 static struct regulator_consumer_supply max77663_ldo7_supply[] = {
263         REGULATOR_SUPPLY("avdd_cam1", NULL),
264         REGULATOR_SUPPLY("avdd_2v8_cam_af", NULL),
265 };
266
267 /* FIXME!! Put the device address of camera */
268 static struct regulator_consumer_supply max77663_ldo8_supply[] = {
269         REGULATOR_SUPPLY("avdd_cam2", NULL),
270 };
271
272 static struct max77663_regulator_fps_cfg max77663_fps_cfgs[] = {
273         {
274                 .src = FPS_SRC_0,
275                 .en_src = FPS_EN_SRC_EN0,
276                 .time_period = FPS_TIME_PERIOD_DEF,
277         },
278         {
279                 .src = FPS_SRC_1,
280                 .en_src = FPS_EN_SRC_EN1,
281                 .time_period = FPS_TIME_PERIOD_DEF,
282         },
283         {
284                 .src = FPS_SRC_2,
285                 .en_src = FPS_EN_SRC_EN0,
286                 .time_period = FPS_TIME_PERIOD_DEF,
287         },
288 };
289
290 #define MAX77663_PDATA_INIT(_rid, _id, _min_uV, _max_uV, _supply_reg,   \
291                 _always_on, _boot_on, _apply_uV,                        \
292                 _fps_src, _fps_pu_period, _fps_pd_period, _flags)       \
293         static struct regulator_init_data max77663_regulator_idata_##_id = {   \
294                 .supply_regulator = _supply_reg,                        \
295                 .constraints = {                                        \
296                         .name = max77663_rails(_id),                    \
297                         .min_uV = _min_uV,                              \
298                         .max_uV = _max_uV,                              \
299                         .valid_modes_mask = (REGULATOR_MODE_NORMAL |    \
300                                              REGULATOR_MODE_STANDBY),   \
301                         .valid_ops_mask = (REGULATOR_CHANGE_MODE |      \
302                                            REGULATOR_CHANGE_STATUS |    \
303                                            REGULATOR_CHANGE_VOLTAGE),   \
304                         .always_on = _always_on,                        \
305                         .boot_on = _boot_on,                            \
306                         .apply_uV = _apply_uV,                          \
307                 },                                                      \
308                 .num_consumer_supplies =                                \
309                         ARRAY_SIZE(max77663_##_id##_supply),            \
310                 .consumer_supplies = max77663_##_id##_supply,           \
311         };                                                              \
312 static struct max77663_regulator_platform_data max77663_regulator_pdata_##_id =\
313 {                                                                       \
314                 .reg_init_data = &max77663_regulator_idata_##_id,       \
315                 .id = MAX77663_REGULATOR_ID_##_rid,                     \
316                 .fps_src = _fps_src,                                    \
317                 .fps_pu_period = _fps_pu_period,                        \
318                 .fps_pd_period = _fps_pd_period,                        \
319                 .fps_cfgs = max77663_fps_cfgs,                          \
320                 .flags = _flags,                                        \
321         }
322
323 MAX77663_PDATA_INIT(SD0, sd0,  900000, 1400000, tps65090_rails(DCDC3), 1, 1, 0,
324                     FPS_SRC_1, -1, -1, SD_FSRADE_DISABLE);
325
326 MAX77663_PDATA_INIT(SD1, sd1,  1200000, 1200000, tps65090_rails(DCDC3), 1, 1, 1,
327                     FPS_SRC_1, -1, -1, SD_FSRADE_DISABLE);
328
329 MAX77663_PDATA_INIT(SD2, sd2,  1800000, 1800000, tps65090_rails(DCDC3), 1, 1, 1,
330                     FPS_SRC_0, -1, -1, 0);
331
332 MAX77663_PDATA_INIT(SD3, sd3,  2850000, 2850000, tps65090_rails(DCDC3), 1, 1, 1,
333                     FPS_SRC_NONE, -1, -1, 0);
334
335 MAX77663_PDATA_INIT(LDO0, ldo0, 1050000, 1050000, max77663_rails(sd2), 1, 1, 1,
336                     FPS_SRC_1, -1, -1, 0);
337
338 MAX77663_PDATA_INIT(LDO1, ldo1, 1050000, 1050000, max77663_rails(sd2), 0, 0, 1,
339                     FPS_SRC_NONE, -1, -1, 0);
340
341 MAX77663_PDATA_INIT(LDO2, ldo2, 2850000, 2850000, tps65090_rails(DCDC2), 1, 1,
342                     1, FPS_SRC_1, -1, -1, 0);
343
344 MAX77663_PDATA_INIT(LDO3, ldo3, 1050000, 1050000, max77663_rails(sd2), 1, 1, 1,
345                     FPS_SRC_NONE, -1, -1, 0);
346
347 MAX77663_PDATA_INIT(LDO4, ldo4, 1100000, 1100000, tps65090_rails(DCDC2), 1, 1,
348                     1, FPS_SRC_NONE, -1, -1, 0);
349
350 MAX77663_PDATA_INIT(LDO5, ldo5, 1200000, 1200000, max77663_rails(sd2), 0, 1, 1,
351                     FPS_SRC_NONE, -1, -1, 0);
352
353 MAX77663_PDATA_INIT(LDO6, ldo6, 1800000, 3300000, tps65090_rails(DCDC2), 0, 0, 0,
354                     FPS_SRC_NONE, -1, -1, 0);
355
356 MAX77663_PDATA_INIT(LDO7, ldo7, 2800000, 2800000, tps65090_rails(DCDC2), 0, 0, 1,
357                     FPS_SRC_NONE, -1, -1, 0);
358
359 MAX77663_PDATA_INIT(LDO8, ldo8, 2800000, 2800000, tps65090_rails(DCDC2), 0, 1, 1,
360                     FPS_SRC_1, -1, -1, 0);
361
362 #define MAX77663_REG(_id, _data) (&max77663_regulator_pdata_##_data)
363
364 static struct max77663_regulator_platform_data *max77663_reg_pdata[] = {
365         MAX77663_REG(SD0, sd0),
366         MAX77663_REG(SD1, sd1),
367         MAX77663_REG(SD2, sd2),
368         MAX77663_REG(SD3, sd3),
369         MAX77663_REG(LDO0, ldo0),
370         MAX77663_REG(LDO1, ldo1),
371         MAX77663_REG(LDO2, ldo2),
372         MAX77663_REG(LDO3, ldo3),
373         MAX77663_REG(LDO4, ldo4),
374         MAX77663_REG(LDO5, ldo5),
375         MAX77663_REG(LDO6, ldo6),
376         MAX77663_REG(LDO7, ldo7),
377         MAX77663_REG(LDO8, ldo8),
378 };
379
380 static struct max77663_gpio_config max77663_gpio_cfgs[] = {
381         {
382                 .gpio = MAX77663_GPIO0,
383                 .dir = GPIO_DIR_OUT,
384                 .dout = GPIO_DOUT_LOW,
385                 .out_drv = GPIO_OUT_DRV_PUSH_PULL,
386                 .alternate = GPIO_ALT_DISABLE,
387         },
388         {
389                 .gpio = MAX77663_GPIO1,
390                 .dir = GPIO_DIR_IN,
391                 .dout = GPIO_DOUT_HIGH,
392                 .out_drv = GPIO_OUT_DRV_OPEN_DRAIN,
393                 .pull_up = GPIO_PU_ENABLE,
394                 .alternate = GPIO_ALT_DISABLE,
395         },
396         {
397                 .gpio = MAX77663_GPIO2,
398                 .dir = GPIO_DIR_OUT,
399                 .dout = GPIO_DOUT_HIGH,
400                 .out_drv = GPIO_OUT_DRV_OPEN_DRAIN,
401                 .pull_up = GPIO_PU_ENABLE,
402                 .alternate = GPIO_ALT_DISABLE,
403         },
404         {
405                 .gpio = MAX77663_GPIO3,
406                 .dir = GPIO_DIR_OUT,
407                 .dout = GPIO_DOUT_HIGH,
408                 .out_drv = GPIO_OUT_DRV_OPEN_DRAIN,
409                 .pull_up = GPIO_PU_ENABLE,
410                 .alternate = GPIO_ALT_DISABLE,
411         },
412         {
413                 .gpio = MAX77663_GPIO4,
414                 .dir = GPIO_DIR_OUT,
415                 .dout = GPIO_DOUT_HIGH,
416                 .out_drv = GPIO_OUT_DRV_PUSH_PULL,
417                 .alternate = GPIO_ALT_ENABLE,
418         },
419         {
420                 .gpio = MAX77663_GPIO5,
421                 .dir = GPIO_DIR_OUT,
422                 .dout = GPIO_DOUT_LOW,
423                 .out_drv = GPIO_OUT_DRV_PUSH_PULL,
424                 .alternate = GPIO_ALT_DISABLE,
425         },
426         {
427                 .gpio = MAX77663_GPIO6,
428                 .dir = GPIO_DIR_OUT,
429                 .dout = GPIO_DOUT_LOW,
430                 .out_drv = GPIO_OUT_DRV_OPEN_DRAIN,
431                 .alternate = GPIO_ALT_DISABLE,
432         },
433         {
434                 .gpio = MAX77663_GPIO7,
435                 .dir = GPIO_DIR_OUT,
436                 .dout = GPIO_DOUT_LOW,
437                 .out_drv = GPIO_OUT_DRV_OPEN_DRAIN,
438                 .alternate = GPIO_ALT_DISABLE,
439         },
440 };
441
442 static struct max77663_platform_data max77663_pdata = {
443         .irq_base       = MAX77663_IRQ_BASE,
444         .gpio_base      = MAX77663_GPIO_BASE,
445
446         .num_gpio_cfgs  = ARRAY_SIZE(max77663_gpio_cfgs),
447         .gpio_cfgs      = max77663_gpio_cfgs,
448
449         .regulator_pdata = max77663_reg_pdata,
450         .num_regulator_pdata = ARRAY_SIZE(max77663_reg_pdata),
451
452         .rtc_i2c_addr   = 0x68,
453
454         .use_power_off  = false,
455 };
456
457 /* EN_AVDD_USB_HDMI From PMU GP1 */
458 static struct regulator_consumer_supply fixed_reg_avdd_usb_hdmi_supply[] = {
459         REGULATOR_SUPPLY("avdd_hdmi", "tegradc.1"),
460         REGULATOR_SUPPLY("avdd_usb", "tegra-ehci.0"),
461         REGULATOR_SUPPLY("avdd_usb", "tegra-ehci.1"),
462         REGULATOR_SUPPLY("avdd_usb", "tegra-ehci.2"),
463         REGULATOR_SUPPLY("hvdd_usb", "tegra-ehci.2"),
464 };
465
466 /* EN_CAM_1v8 From PMU GP5 */
467 static struct regulator_consumer_supply fixed_reg_en_1v8_cam_supply[] = {
468         REGULATOR_SUPPLY("dvdd_cam", NULL),
469         REGULATOR_SUPPLY("vdd_cam_1v8", NULL),
470 };
471
472
473 static struct regulator_consumer_supply fixed_reg_vdd_hdmi_5v0_supply[] = {
474         REGULATOR_SUPPLY("vdd_hdmi_5v0", "tegradc.1"),
475 };
476
477 /* EN_USB1_VBUS From TEGRA GPIO PN4 PR3(T30) */
478 static struct regulator_consumer_supply fixed_reg_usb1_vbus_supply[] = {
479         REGULATOR_SUPPLY("usb_vbus", "tegra-ehci.0"),
480 };
481
482 #ifdef CONFIG_ARCH_TEGRA_11x_SOC
483 /* EN_3V3_FUSE From TEGRA GPIO PX4 */
484 static struct regulator_consumer_supply fixed_reg_vpp_fuse_supply[] = {
485         REGULATOR_SUPPLY("vpp_fuse", NULL),
486 };
487
488 /* EN_USB3_VBUS From TEGRA GPIO PM5 */
489 static struct regulator_consumer_supply fixed_reg_usb3_vbus_supply[] = {
490         REGULATOR_SUPPLY("usb_vbus", "tegra-ehci.2"),
491 };
492 #endif
493
494 /* Macro for defining fixed regulator sub device data */
495 #define FIXED_SUPPLY(_name) "fixed_reg_"#_name
496 #define FIXED_REG(_id, _var, _name, _in_supply, _always_on, _boot_on,   \
497         _gpio_nr, _open_drain, _active_high, _boot_state, _millivolts)  \
498         static struct regulator_init_data ri_data_##_var =              \
499         {                                                               \
500                 .supply_regulator = _in_supply,                         \
501                 .num_consumer_supplies =                                \
502                         ARRAY_SIZE(fixed_reg_##_name##_supply),         \
503                 .consumer_supplies = fixed_reg_##_name##_supply,        \
504                 .constraints = {                                        \
505                         .valid_modes_mask = (REGULATOR_MODE_NORMAL |    \
506                                         REGULATOR_MODE_STANDBY),        \
507                         .valid_ops_mask = (REGULATOR_CHANGE_MODE |      \
508                                         REGULATOR_CHANGE_STATUS |       \
509                                         REGULATOR_CHANGE_VOLTAGE),      \
510                         .always_on = _always_on,                        \
511                         .boot_on = _boot_on,                            \
512                 },                                                      \
513         };                                                              \
514         static struct fixed_voltage_config fixed_reg_##_var##_pdata =   \
515         {                                                               \
516                 .supply_name = FIXED_SUPPLY(_name),                     \
517                 .microvolts = _millivolts * 1000,                       \
518                 .gpio = _gpio_nr,                                       \
519                 .gpio_is_open_drain = _open_drain,                      \
520                 .enable_high = _active_high,                            \
521                 .enabled_at_boot = _boot_state,                         \
522                 .init_data = &ri_data_##_var,                           \
523         };                                                              \
524         static struct platform_device fixed_reg_##_var##_dev = {        \
525                 .name = "reg-fixed-voltage",                            \
526                 .id = _id,                                              \
527                 .dev = {                                                \
528                         .platform_data = &fixed_reg_##_var##_pdata,     \
529                 },                                                      \
530         }
531
532 FIXED_REG(1,    avdd_usb_hdmi,  avdd_usb_hdmi,
533         tps65090_rails(DCDC2),  0,      0,
534         MAX77663_GPIO_BASE + MAX77663_GPIO1,    true,   true,   1,      3300);
535
536 FIXED_REG(2,    en_1v8_cam,     en_1v8_cam,
537         max77663_rails(sd2),    0,      0,
538         MAX77663_GPIO_BASE + MAX77663_GPIO5,    false,  true,   0,      1800);
539
540 FIXED_REG(3,    vdd_hdmi_5v0,   vdd_hdmi_5v0,
541         tps65090_rails(DCDC1),  0,      0,
542         TEGRA_GPIO_PK1, false,  true,   0,      5000);
543
544 #ifdef CONFIG_ARCH_TEGRA_11x_SOC
545 FIXED_REG(4,    vpp_fuse,       vpp_fuse,
546         max77663_rails(sd2),    0,      0,
547         TEGRA_GPIO_PX4, false,  true,   0,      3300);
548
549 FIXED_REG(5,    usb1_vbus,      usb1_vbus,
550         tps65090_rails(DCDC1),  0,      0,
551         TEGRA_GPIO_PN4, true,   true,   0,      5000);
552
553 FIXED_REG(6,    usb3_vbus,      usb3_vbus,
554         tps65090_rails(DCDC1),  0,      0,
555         TEGRA_GPIO_PK6, true,   true,   0,      5000);
556 #else
557 FIXED_REG(4,    usb1_vbus,      usb1_vbus,
558         tps65090_rails(DCDC1),  0,      0,
559         TEGRA_GPIO_PR3, true,   true,   0,      5000);
560 #endif
561 /*
562  * Creating the fixed regulator device tables
563  */
564
565 #define ADD_FIXED_REG(_name)    (&fixed_reg_##_name##_dev)
566
567 #define E1612_COMMON_FIXED_REG                  \
568         ADD_FIXED_REG(avdd_usb_hdmi),           \
569         ADD_FIXED_REG(en_1v8_cam),              \
570         ADD_FIXED_REG(vdd_hdmi_5v0),
571
572 #ifdef CONFIG_ARCH_TEGRA_11x_SOC
573 #define E1612_T114_FIXED_REG                    \
574         ADD_FIXED_REG(vpp_fuse),                \
575         ADD_FIXED_REG(usb1_vbus),               \
576         ADD_FIXED_REG(usb3_vbus),
577 #endif
578
579 #ifdef CONFIG_ARCH_TEGRA_3x_SOC
580 #define E1612_T30_FIXED_REG                     \
581         ADD_FIXED_REG(usb1_vbus),
582 #endif
583
584 /* Gpio switch regulator platform data for Dalmore E1612 */
585 static struct platform_device *fixed_reg_devs_a00[] = {
586 #ifdef CONFIG_ARCH_TEGRA_11x_SOC
587         E1612_T114_FIXED_REG
588 #endif
589 #ifdef CONFIG_ARCH_TEGRA_3x_SOC
590         E1612_T30_FIXED_REG
591 #endif
592         E1612_COMMON_FIXED_REG
593
594 };
595
596 static struct i2c_board_info __initdata max77663_regulators[] = {
597         {
598                 /* The I2C address was determined by OTP factory setting */
599                 I2C_BOARD_INFO("max77663", 0x3c),
600                 .irq            = INT_EXTERNAL_PMU,
601                 .platform_data  = &max77663_pdata,
602         },
603 };
604
605 static struct i2c_board_info __initdata tps65090_regulators[] = {
606         {
607                 I2C_BOARD_INFO("tps65090", 0x48),
608                 .platform_data  = &tps65090_pdata,
609         },
610 };
611
612 /* TPS51632 DC-DC converter */
613 static struct regulator_consumer_supply tps51632_dcdc_supply[] = {
614         REGULATOR_SUPPLY("vdd_cpu", NULL),
615 };
616
617 static struct regulator_init_data tps51632_init_data = {
618         .constraints = {                                                \
619                 .min_uV = 500000,                                       \
620                 .max_uV = 1520000,                                      \
621                 .valid_modes_mask = (REGULATOR_MODE_NORMAL |            \
622                                         REGULATOR_MODE_STANDBY),        \
623                 .valid_ops_mask = (REGULATOR_CHANGE_MODE |              \
624                                         REGULATOR_CHANGE_STATUS |       \
625                                         REGULATOR_CHANGE_VOLTAGE),      \
626                 .always_on = 1,                                         \
627                 .boot_on =  1,                                          \
628                 .apply_uV = 0,                                          \
629         },                                                              \
630         .num_consumer_supplies = ARRAY_SIZE(tps51632_dcdc_supply),      \
631                 .consumer_supplies = tps51632_dcdc_supply,              \
632 };
633
634 static struct tps51632_regulator_platform_data tps51632_pdata = {
635         .reg_init_data = &tps51632_init_data,           \
636         .enable_pwm = false,                            \
637         .max_voltage_uV = 1520000,                      \
638         .base_voltage_uV = 500000,                      \
639         .slew_rate_uv_per_us = 6000,                    \
640 };
641
642 static struct i2c_board_info __initdata tps51632_boardinfo[] = {
643         {
644                 I2C_BOARD_INFO("tps51632", 0x43),
645                 .platform_data  = &tps51632_pdata,
646         },
647 };
648
649 static int ac_online(void)
650 {
651         return 1;
652 }
653
654 static struct resource dalmore_pda_resources[] = {
655         [0] = {
656                 .name   = "ac",
657         },
658 };
659
660 static struct pda_power_pdata dalmore_pda_data = {
661         .is_ac_online   = ac_online,
662 };
663
664 static struct platform_device dalmore_pda_power_device = {
665         .name           = "pda-power",
666         .id             = -1,
667         .resource       = dalmore_pda_resources,
668         .num_resources  = ARRAY_SIZE(dalmore_pda_resources),
669         .dev    = {
670                 .platform_data  = &dalmore_pda_data,
671         },
672 };
673
674 static struct tegra_suspend_platform_data dalmore_suspend_data = {
675         .cpu_timer      = 2000,
676         .cpu_off_timer  = 0,
677         .suspend_mode   = TEGRA_SUSPEND_NONE,
678         .core_timer     = 0x7e7e,
679         .core_off_timer = 0,
680         .corereq_high   = false,
681         .sysclkreq_high = true,
682 };
683
684 static int __init dalmore_max77663_regulator_init(void)
685 {
686         void __iomem *pmc = IO_ADDRESS(TEGRA_PMC_BASE);
687         u32 pmc_ctrl;
688
689         /* configure the power management controller to trigger PMU
690          * interrupts when low */
691         pmc_ctrl = readl(pmc + PMC_CTRL);
692         writel(pmc_ctrl | PMC_CTRL_INTR_LOW, pmc + PMC_CTRL);
693
694         i2c_register_board_info(4, max77663_regulators,
695                                 ARRAY_SIZE(max77663_regulators));
696
697         return 0;
698 }
699
700 static int __init dalmore_fixed_regulator_init(void)
701 {
702         if (!machine_is_dalmore())
703                 return 0;
704
705         return platform_add_devices(fixed_reg_devs_a00,
706                                 ARRAY_SIZE(fixed_reg_devs_a00));
707 }
708 subsys_initcall_sync(dalmore_fixed_regulator_init);
709
710 int __init dalmore_regulator_init(void)
711 {
712         i2c_register_board_info(4, tps65090_regulators,
713                                 ARRAY_SIZE(tps65090_regulators));
714
715         dalmore_max77663_regulator_init();
716         i2c_register_board_info(4, tps51632_boardinfo, 1);
717         platform_device_register(&dalmore_pda_power_device);
718         return 0;
719 }
720
721 int __init dalmore_suspend_init(void)
722 {
723         tegra_init_suspend(&dalmore_suspend_data);
724         return 0;
725 }
726