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