ARM: tegra: dalmore: Set TPS51632 ops mode to change control mode
[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/palmas.h>
30 #include <linux/mfd/tps65090.h>
31 #include <linux/regulator/max77663-regulator.h>
32 #include <linux/regulator/tps65090-regulator.h>
33 #include <linux/regulator/tps51632-regulator.h>
34 #include <linux/gpio.h>
35 #include <linux/interrupt.h>
36 #include <linux/regulator/userspace-consumer.h>
37
38 #include <asm/mach-types.h>
39 #include <linux/power/sbs-battery.h>
40
41 #include <mach/iomap.h>
42 #include <mach/irqs.h>
43 #include <mach/edp.h>
44 #include <mach/gpio-tegra.h>
45
46 #include "cpu-tegra.h"
47 #include "pm.h"
48 #include "tegra-board-id.h"
49 #include "board.h"
50 #include "gpio-names.h"
51 #include "board-dalmore.h"
52 #include "tegra_cl_dvfs.h"
53 #include "devices.h"
54 #include "tegra11_soctherm.h"
55
56 #define PMC_CTRL                0x0
57 #define PMC_CTRL_INTR_LOW       (1 << 17)
58 #define TPS65090_CHARGER_INT    TEGRA_GPIO_PJ0
59 /*TPS65090 consumer rails */
60 static struct regulator_consumer_supply tps65090_dcdc1_supply[] = {
61         REGULATOR_SUPPLY("vdd_sys_5v0", NULL),
62         REGULATOR_SUPPLY("vdd_spk", NULL),
63         REGULATOR_SUPPLY("vdd_sys_modem_5v0", NULL),
64         REGULATOR_SUPPLY("vdd_sys_cam_5v0", NULL),
65 };
66
67 static struct regulator_consumer_supply tps65090_dcdc2_supply[] = {
68         REGULATOR_SUPPLY("vdd_sys_3v3", NULL),
69         REGULATOR_SUPPLY("vddio_hv", "tegradc.1"),
70         REGULATOR_SUPPLY("pwrdet_hv", NULL),
71         REGULATOR_SUPPLY("vdd_sys_ds_3v3", NULL),
72         REGULATOR_SUPPLY("vdd_sys_nfc_3v3", NULL),
73         REGULATOR_SUPPLY("vdd_hv_nfc_3v3", NULL),
74         REGULATOR_SUPPLY("vdd_sys_cam_3v3", NULL),
75         REGULATOR_SUPPLY("vdd_sys_sensor_3v3", NULL),
76         REGULATOR_SUPPLY("vdd_sys_audio_3v3", NULL),
77         REGULATOR_SUPPLY("vdd_sys_dtv_3v3", NULL),
78         REGULATOR_SUPPLY("vcc", "0-007c"),
79         REGULATOR_SUPPLY("vcc", "0-0030"),
80         REGULATOR_SUPPLY("vin", "2-0030"),
81 };
82
83 static struct regulator_consumer_supply tps65090_dcdc3_supply[] = {
84         REGULATOR_SUPPLY("vdd_ao", NULL),
85 };
86
87 static struct regulator_consumer_supply tps65090_ldo1_supply[] = {
88         REGULATOR_SUPPLY("vdd_sby_5v0", NULL),
89 };
90
91 static struct regulator_consumer_supply tps65090_ldo2_supply[] = {
92         REGULATOR_SUPPLY("vdd_sby_3v3", NULL),
93 };
94
95 static struct regulator_consumer_supply tps65090_fet1_supply[] = {
96         REGULATOR_SUPPLY("vdd_lcd_bl", NULL),
97 };
98
99 static struct regulator_consumer_supply tps65090_fet3_supply[] = {
100         REGULATOR_SUPPLY("vdd_modem_3v3", NULL),
101 };
102
103 static struct regulator_consumer_supply tps65090_fet4_supply[] = {
104         REGULATOR_SUPPLY("avdd_lcd", NULL),
105         REGULATOR_SUPPLY("avdd", "spi3.2"),
106 };
107
108 static struct regulator_consumer_supply tps65090_fet5_supply[] = {
109         REGULATOR_SUPPLY("vdd_lvds", NULL),
110 };
111
112 static struct regulator_consumer_supply tps65090_fet6_supply[] = {
113         REGULATOR_SUPPLY("vddio_sd_slot", "sdhci-tegra.2"),
114 };
115
116 static struct regulator_consumer_supply tps65090_fet7_supply[] = {
117         REGULATOR_SUPPLY("vdd_wifi_3v3", "bcm4329_wlan.1"),
118         REGULATOR_SUPPLY("vdd_gps_3v3", "reg-userspace-consumer.2"),
119         REGULATOR_SUPPLY("vdd_bt_3v3", "bluedroid_pm.0"),
120 };
121
122 #define TPS65090_PDATA_INIT(_id, _name, _supply_reg,                    \
123         _always_on, _boot_on, _apply_uV, _en_ext_ctrl, _gpio, _wait_to) \
124 static struct regulator_init_data ri_data_##_name =                     \
125 {                                                                       \
126         .supply_regulator = _supply_reg,                                \
127         .constraints = {                                                \
128                 .name = tps65090_rails(_id),                            \
129                 .valid_modes_mask = (REGULATOR_MODE_NORMAL |            \
130                                      REGULATOR_MODE_STANDBY),           \
131                 .valid_ops_mask = (REGULATOR_CHANGE_MODE |              \
132                                    REGULATOR_CHANGE_STATUS |            \
133                                    REGULATOR_CHANGE_VOLTAGE),           \
134                 .always_on = _always_on,                                \
135                 .boot_on = _boot_on,                                    \
136                 .apply_uV = _apply_uV,                                  \
137         },                                                              \
138         .num_consumer_supplies =                                        \
139                 ARRAY_SIZE(tps65090_##_name##_supply),                  \
140         .consumer_supplies = tps65090_##_name##_supply,                 \
141 };                                                                      \
142 static struct tps65090_regulator_platform_data                          \
143                         tps65090_regulator_pdata_##_name =              \
144 {                                                                       \
145         .id = TPS65090_REGULATOR_##_id,                                 \
146         .enable_ext_control = _en_ext_ctrl,                             \
147         .gpio = _gpio,                                                  \
148         .reg_init_data = &ri_data_##_name ,                             \
149         .wait_timeout_us = _wait_to,                                    \
150 }
151
152 TPS65090_PDATA_INIT(DCDC1, dcdc1, NULL, 1, 1, 0, false, -1, -1);
153 TPS65090_PDATA_INIT(DCDC2, dcdc2, NULL, 1, 1, 0, false, -1, -1);
154 TPS65090_PDATA_INIT(DCDC3, dcdc3, NULL, 1, 1, 0, false, -1, -1);
155 TPS65090_PDATA_INIT(LDO1, ldo1, NULL, 1, 1, 0, false, -1, -1);
156 TPS65090_PDATA_INIT(LDO2, ldo2, NULL, 1, 1, 0, false, -1, -1);
157 TPS65090_PDATA_INIT(FET1, fet1, NULL, 0, 0, 0, false, -1, 800);
158 TPS65090_PDATA_INIT(FET3, fet3, tps65090_rails(DCDC2), 0, 0, 0, false, -1, 0);
159 TPS65090_PDATA_INIT(FET4, fet4, tps65090_rails(DCDC2), 0, 0, 0, false, -1, 0);
160 TPS65090_PDATA_INIT(FET5, fet5, tps65090_rails(DCDC2), 0, 0, 0, false, -1, 0);
161 TPS65090_PDATA_INIT(FET6, fet6, tps65090_rails(DCDC2), 0, 0, 0, false, -1, 0);
162 TPS65090_PDATA_INIT(FET7, fet7, tps65090_rails(DCDC2), 0, 0, 0, false, -1, 0);
163
164 #define ADD_TPS65090_REG(_name) (&tps65090_regulator_pdata_##_name)
165 static struct tps65090_regulator_platform_data *tps65090_reg_pdata[] = {
166         ADD_TPS65090_REG(dcdc1),
167         ADD_TPS65090_REG(dcdc2),
168         ADD_TPS65090_REG(dcdc3),
169         ADD_TPS65090_REG(ldo1),
170         ADD_TPS65090_REG(ldo2),
171         ADD_TPS65090_REG(fet1),
172         ADD_TPS65090_REG(fet3),
173         ADD_TPS65090_REG(fet4),
174         ADD_TPS65090_REG(fet5),
175         ADD_TPS65090_REG(fet6),
176         ADD_TPS65090_REG(fet7),
177 };
178
179 static struct tps65090_charger_data bcharger_pdata = {
180         .irq_base = TPS65090_TEGRA_IRQ_BASE,
181         .update_status = sbs_update,
182 };
183
184 static struct tps65090_platform_data tps65090_pdata = {
185         .irq_base = TPS65090_TEGRA_IRQ_BASE,
186         .irq_flag = IRQF_ONESHOT | IRQF_TRIGGER_FALLING,
187         .num_reg_pdata =  ARRAY_SIZE(tps65090_reg_pdata),
188         .reg_pdata = tps65090_reg_pdata,
189         .charger_pdata = &bcharger_pdata,
190 };
191
192 /* MAX77663 consumer rails */
193 static struct regulator_consumer_supply max77663_sd0_supply[] = {
194         REGULATOR_SUPPLY("vdd_core", NULL),
195 };
196
197 static struct regulator_consumer_supply max77663_sd1_supply[] = {
198         REGULATOR_SUPPLY("vddio_ddr", NULL),
199         REGULATOR_SUPPLY("vddio_ddr0", NULL),
200         REGULATOR_SUPPLY("vddio_ddr1", NULL),
201 };
202
203 static struct regulator_consumer_supply max77663_sd2_supply[] = {
204         REGULATOR_SUPPLY("avdd_usb_pll", "tegra-udc.0"),
205         REGULATOR_SUPPLY("avdd_usb_pll", "tegra-ehci.0"),
206         REGULATOR_SUPPLY("avdd_usb_pll", "tegra-ehci.1"),
207         REGULATOR_SUPPLY("vddio_cam", "tegra_camera"),
208         REGULATOR_SUPPLY("pwrdet_cam", NULL),
209         REGULATOR_SUPPLY("avdd_osc", NULL),
210         REGULATOR_SUPPLY("vddio_sys", NULL),
211         REGULATOR_SUPPLY("vddio_sdmmc", "sdhci-tegra.0"),
212         REGULATOR_SUPPLY("pwrdet_sdmmc1", NULL),
213         REGULATOR_SUPPLY("vddio_sdmmc", "sdhci-tegra.3"),
214         REGULATOR_SUPPLY("pwrdet_sdmmc4", NULL),
215         REGULATOR_SUPPLY("vdd_emmc", NULL),
216         REGULATOR_SUPPLY("vddio_audio", NULL),
217         REGULATOR_SUPPLY("pwrdet_audio", NULL),
218         REGULATOR_SUPPLY("avdd_audio_1v8", NULL),
219         REGULATOR_SUPPLY("vdd_audio_1v8", NULL),
220         REGULATOR_SUPPLY("vddio_modem", NULL),
221         REGULATOR_SUPPLY("vddio_modem_1v8", NULL),
222         REGULATOR_SUPPLY("vddio_bb", NULL),
223         REGULATOR_SUPPLY("pwrdet_bb", NULL),
224         REGULATOR_SUPPLY("vddio_bb_1v8", NULL),
225         REGULATOR_SUPPLY("vddio_uart", NULL),
226         REGULATOR_SUPPLY("pwrdet_uart", NULL),
227         REGULATOR_SUPPLY("vddio_gmi", NULL),
228         REGULATOR_SUPPLY("pwrdet_nand", NULL),
229         REGULATOR_SUPPLY("vdd_sensor_1v8", NULL),
230         REGULATOR_SUPPLY("vdd_mic_1v8", NULL),
231         REGULATOR_SUPPLY("vdd_nfc_1v8", NULL),
232         REGULATOR_SUPPLY("vdd_ds_1v8", NULL),
233         REGULATOR_SUPPLY("vdd_spi_1v8", NULL),
234         REGULATOR_SUPPLY("dvdd_lcd", NULL),
235         REGULATOR_SUPPLY("vdd_com_1v8", NULL),
236         REGULATOR_SUPPLY("vddio_wifi_1v8", "bcm4329_wlan.1"),
237         REGULATOR_SUPPLY("vdd_gps_1v8", "reg-userspace-consumer.2"),
238         REGULATOR_SUPPLY("vddio_bt_1v8", "bluedroid_pm.0"),
239         REGULATOR_SUPPLY("vdd_dtv_1v8", NULL),
240         REGULATOR_SUPPLY("vlogic", "0-0069"),
241 };
242
243 static struct regulator_consumer_supply max77663_sd3_supply[] = {
244         REGULATOR_SUPPLY("vcore_emmc", NULL),
245 };
246
247 static struct regulator_consumer_supply max77663_ldo0_supply[] = {
248         REGULATOR_SUPPLY("avdd_plla_p_c", NULL),
249         REGULATOR_SUPPLY("avdd_pllx", NULL),
250         REGULATOR_SUPPLY("avdd_plle", NULL),
251         REGULATOR_SUPPLY("avdd_pllm", NULL),
252         REGULATOR_SUPPLY("avdd_pllu", NULL),
253         REGULATOR_SUPPLY("avdd_csi_dsi_pll", "tegradc.0"),
254         REGULATOR_SUPPLY("avdd_csi_dsi_pll", "tegradc.1"),
255         REGULATOR_SUPPLY("avdd_csi_dsi_pll", "tegra_camera"),
256 };
257
258 static struct regulator_consumer_supply max77663_ldo1_supply[] = {
259         REGULATOR_SUPPLY("vdd_ddr_hs", NULL),
260 };
261
262 static struct regulator_consumer_supply max77663_ldo2_supply[] = {
263         REGULATOR_SUPPLY("vdd_sensor_2v85", NULL),
264         REGULATOR_SUPPLY("vdd_als", NULL),
265         REGULATOR_SUPPLY("vdd", "0-004c"),
266         REGULATOR_SUPPLY("vdd", "0-0069"),
267 };
268
269 static struct regulator_consumer_supply max77663_ldo3_supply[] = {
270         REGULATOR_SUPPLY("avdd_hdmi_pll", "tegradc.1"),
271         REGULATOR_SUPPLY("avdd_usb_pll", "tegra-ehci.2"),
272         REGULATOR_SUPPLY("avddio_usb", "tegra-ehci.2"),
273 };
274
275 static struct regulator_consumer_supply max77663_ldo4_supply[] = {
276         REGULATOR_SUPPLY("vdd_rtc", NULL),
277 };
278
279 static struct regulator_consumer_supply max77663_ldo5_supply[] = {
280         REGULATOR_SUPPLY("avdd_dsi_csi", "tegradc.0"),
281         REGULATOR_SUPPLY("avdd_dsi_csi", "tegradc.1"),
282         REGULATOR_SUPPLY("avdd_dsi_csi", "tegra_camera"),
283         REGULATOR_SUPPLY("vddio_hsic", "tegra-ehci.1"),
284         REGULATOR_SUPPLY("vddio_hsic", "tegra-ehci.2"),
285         REGULATOR_SUPPLY("pwrdet_mipi", NULL),
286         REGULATOR_SUPPLY("vddio_bb_hsic", NULL),
287 };
288
289 static struct regulator_consumer_supply max77663_ldo6_supply[] = {
290         REGULATOR_SUPPLY("vddio_sdmmc", "sdhci-tegra.2"),
291         REGULATOR_SUPPLY("pwrdet_sdmmc3", NULL),
292 };
293
294 /* FIXME!! Put the device address of camera */
295 static struct regulator_consumer_supply max77663_ldo7_supply[] = {
296         REGULATOR_SUPPLY("avdd_cam1", NULL),
297         REGULATOR_SUPPLY("avdd_2v8_cam_af", NULL),
298         REGULATOR_SUPPLY("vana", "2-0036"),
299 };
300
301 /* FIXME!! Put the device address of camera */
302 static struct regulator_consumer_supply max77663_ldo8_supply[] = {
303         REGULATOR_SUPPLY("avdd_cam2", NULL),
304         REGULATOR_SUPPLY("avdd", "2-0010"),
305 };
306
307 static struct max77663_regulator_fps_cfg max77663_fps_cfgs[] = {
308         {
309                 .src = FPS_SRC_0,
310                 .en_src = FPS_EN_SRC_EN0,
311                 .time_period = FPS_TIME_PERIOD_DEF,
312         },
313         {
314                 .src = FPS_SRC_1,
315                 .en_src = FPS_EN_SRC_EN1,
316                 .time_period = FPS_TIME_PERIOD_DEF,
317         },
318         {
319                 .src = FPS_SRC_2,
320                 .en_src = FPS_EN_SRC_EN0,
321                 .time_period = FPS_TIME_PERIOD_DEF,
322         },
323 };
324
325 #define MAX77663_PDATA_INIT(_rid, _id, _min_uV, _max_uV, _supply_reg,   \
326                 _always_on, _boot_on, _apply_uV,                        \
327                 _fps_src, _fps_pu_period, _fps_pd_period, _flags)       \
328         static struct regulator_init_data max77663_regulator_idata_##_id = {   \
329                 .supply_regulator = _supply_reg,                        \
330                 .constraints = {                                        \
331                         .name = max77663_rails(_id),                    \
332                         .min_uV = _min_uV,                              \
333                         .max_uV = _max_uV,                              \
334                         .valid_modes_mask = (REGULATOR_MODE_NORMAL |    \
335                                              REGULATOR_MODE_STANDBY),   \
336                         .valid_ops_mask = (REGULATOR_CHANGE_MODE |      \
337                                            REGULATOR_CHANGE_STATUS |    \
338                                            REGULATOR_CHANGE_VOLTAGE),   \
339                         .always_on = _always_on,                        \
340                         .boot_on = _boot_on,                            \
341                         .apply_uV = _apply_uV,                          \
342                 },                                                      \
343                 .num_consumer_supplies =                                \
344                         ARRAY_SIZE(max77663_##_id##_supply),            \
345                 .consumer_supplies = max77663_##_id##_supply,           \
346         };                                                              \
347 static struct max77663_regulator_platform_data max77663_regulator_pdata_##_id =\
348 {                                                                       \
349                 .reg_init_data = &max77663_regulator_idata_##_id,       \
350                 .id = MAX77663_REGULATOR_ID_##_rid,                     \
351                 .fps_src = _fps_src,                                    \
352                 .fps_pu_period = _fps_pu_period,                        \
353                 .fps_pd_period = _fps_pd_period,                        \
354                 .fps_cfgs = max77663_fps_cfgs,                          \
355                 .flags = _flags,                                        \
356         }
357
358 MAX77663_PDATA_INIT(SD0, sd0,  900000, 1400000, tps65090_rails(DCDC3), 1, 1, 0,
359                     FPS_SRC_1, -1, -1, SD_FSRADE_DISABLE);
360
361 MAX77663_PDATA_INIT(SD1, sd1,  1200000, 1200000, tps65090_rails(DCDC3), 1, 1, 1,
362                     FPS_SRC_1, -1, -1, SD_FSRADE_DISABLE);
363
364 MAX77663_PDATA_INIT(SD2, sd2,  1800000, 1800000, tps65090_rails(DCDC3), 1, 1, 1,
365                     FPS_SRC_0, -1, -1, 0);
366
367 MAX77663_PDATA_INIT(SD3, sd3,  2850000, 2850000, tps65090_rails(DCDC3), 1, 1, 1,
368                     FPS_SRC_NONE, -1, -1, 0);
369
370 MAX77663_PDATA_INIT(LDO0, ldo0, 1050000, 1050000, max77663_rails(sd2), 1, 1, 1,
371                     FPS_SRC_1, -1, -1, 0);
372
373 MAX77663_PDATA_INIT(LDO1, ldo1, 1050000, 1050000, max77663_rails(sd2), 0, 0, 1,
374                     FPS_SRC_NONE, -1, -1, 0);
375
376 MAX77663_PDATA_INIT(LDO2, ldo2, 2850000, 2850000, tps65090_rails(DCDC2), 1, 1,
377                     1, FPS_SRC_1, -1, -1, 0);
378
379 MAX77663_PDATA_INIT(LDO3, ldo3, 1050000, 1050000, max77663_rails(sd2), 1, 1, 1,
380                     FPS_SRC_NONE, -1, -1, 0);
381
382 MAX77663_PDATA_INIT(LDO4, ldo4, 1100000, 1100000, tps65090_rails(DCDC2), 1, 1,
383                     1, FPS_SRC_NONE, -1, -1, 0);
384
385 MAX77663_PDATA_INIT(LDO5, ldo5, 1200000, 1200000, max77663_rails(sd2), 0, 1, 1,
386                     FPS_SRC_NONE, -1, -1, 0);
387
388 MAX77663_PDATA_INIT(LDO6, ldo6, 1800000, 3300000, tps65090_rails(DCDC2), 0, 0, 0,
389                     FPS_SRC_NONE, -1, -1, 0);
390
391 MAX77663_PDATA_INIT(LDO7, ldo7, 2800000, 2800000, tps65090_rails(DCDC2), 0, 0, 1,
392                     FPS_SRC_NONE, -1, -1, 0);
393
394 MAX77663_PDATA_INIT(LDO8, ldo8, 2800000, 2800000, tps65090_rails(DCDC2), 0, 1, 1,
395                     FPS_SRC_1, -1, -1, 0);
396
397 #define MAX77663_REG(_id, _data) (&max77663_regulator_pdata_##_data)
398
399 static struct max77663_regulator_platform_data *max77663_reg_pdata[] = {
400         MAX77663_REG(SD0, sd0),
401         MAX77663_REG(SD1, sd1),
402         MAX77663_REG(SD2, sd2),
403         MAX77663_REG(SD3, sd3),
404         MAX77663_REG(LDO0, ldo0),
405         MAX77663_REG(LDO1, ldo1),
406         MAX77663_REG(LDO2, ldo2),
407         MAX77663_REG(LDO3, ldo3),
408         MAX77663_REG(LDO4, ldo4),
409         MAX77663_REG(LDO5, ldo5),
410         MAX77663_REG(LDO6, ldo6),
411         MAX77663_REG(LDO7, ldo7),
412         MAX77663_REG(LDO8, ldo8),
413 };
414
415 static struct max77663_gpio_config max77663_gpio_cfgs[] = {
416         {
417                 .gpio = MAX77663_GPIO0,
418                 .dir = GPIO_DIR_OUT,
419                 .dout = GPIO_DOUT_LOW,
420                 .out_drv = GPIO_OUT_DRV_PUSH_PULL,
421                 .alternate = GPIO_ALT_DISABLE,
422         },
423         {
424                 .gpio = MAX77663_GPIO1,
425                 .dir = GPIO_DIR_IN,
426                 .dout = GPIO_DOUT_HIGH,
427                 .out_drv = GPIO_OUT_DRV_OPEN_DRAIN,
428                 .pull_up = GPIO_PU_ENABLE,
429                 .alternate = GPIO_ALT_DISABLE,
430         },
431         {
432                 .gpio = MAX77663_GPIO2,
433                 .dir = GPIO_DIR_OUT,
434                 .dout = GPIO_DOUT_HIGH,
435                 .out_drv = GPIO_OUT_DRV_OPEN_DRAIN,
436                 .pull_up = GPIO_PU_ENABLE,
437                 .alternate = GPIO_ALT_DISABLE,
438         },
439         {
440                 .gpio = MAX77663_GPIO3,
441                 .dir = GPIO_DIR_OUT,
442                 .dout = GPIO_DOUT_HIGH,
443                 .out_drv = GPIO_OUT_DRV_OPEN_DRAIN,
444                 .pull_up = GPIO_PU_ENABLE,
445                 .alternate = GPIO_ALT_DISABLE,
446         },
447         {
448                 .gpio = MAX77663_GPIO4,
449                 .dir = GPIO_DIR_OUT,
450                 .dout = GPIO_DOUT_HIGH,
451                 .out_drv = GPIO_OUT_DRV_PUSH_PULL,
452                 .alternate = GPIO_ALT_ENABLE,
453         },
454         {
455                 .gpio = MAX77663_GPIO5,
456                 .dir = GPIO_DIR_OUT,
457                 .dout = GPIO_DOUT_LOW,
458                 .out_drv = GPIO_OUT_DRV_PUSH_PULL,
459                 .alternate = GPIO_ALT_DISABLE,
460         },
461         {
462                 .gpio = MAX77663_GPIO6,
463                 .dir = GPIO_DIR_OUT,
464                 .dout = GPIO_DOUT_LOW,
465                 .out_drv = GPIO_OUT_DRV_OPEN_DRAIN,
466                 .alternate = GPIO_ALT_DISABLE,
467         },
468         {
469                 .gpio = MAX77663_GPIO7,
470                 .dir = GPIO_DIR_OUT,
471                 .dout = GPIO_DOUT_LOW,
472                 .out_drv = GPIO_OUT_DRV_OPEN_DRAIN,
473                 .alternate = GPIO_ALT_DISABLE,
474         },
475 };
476
477 static struct max77663_platform_data max77663_pdata = {
478         .irq_base       = MAX77663_IRQ_BASE,
479         .gpio_base      = MAX77663_GPIO_BASE,
480
481         .num_gpio_cfgs  = ARRAY_SIZE(max77663_gpio_cfgs),
482         .gpio_cfgs      = max77663_gpio_cfgs,
483
484         .regulator_pdata = max77663_reg_pdata,
485         .num_regulator_pdata = ARRAY_SIZE(max77663_reg_pdata),
486
487         .rtc_i2c_addr   = 0x68,
488
489         .use_power_off  = false,
490 };
491
492 static struct i2c_board_info __initdata max77663_regulators[] = {
493         {
494                 /* The I2C address was determined by OTP factory setting */
495                 I2C_BOARD_INFO("max77663", 0x3c),
496                 .irq            = INT_EXTERNAL_PMU,
497                 .platform_data  = &max77663_pdata,
498         },
499 };
500
501 static struct i2c_board_info __initdata tps65090_regulators[] = {
502         {
503                 I2C_BOARD_INFO("tps65090", 0x48),
504                 .platform_data  = &tps65090_pdata,
505         },
506 };
507
508 /* TPS51632 DC-DC converter */
509 static struct regulator_consumer_supply tps51632_dcdc_supply[] = {
510         REGULATOR_SUPPLY("vdd_cpu", NULL),
511 };
512
513 static struct regulator_init_data tps51632_init_data = {
514         .constraints = {                                                \
515                 .min_uV = 500000,                                       \
516                 .max_uV = 1520000,                                      \
517                 .valid_modes_mask = (REGULATOR_MODE_NORMAL |            \
518                                         REGULATOR_MODE_STANDBY),        \
519                 .valid_ops_mask = (REGULATOR_CHANGE_MODE |              \
520                                         REGULATOR_CHANGE_STATUS |       \
521                                          REGULATOR_CHANGE_CONTROL |     \
522                                         REGULATOR_CHANGE_VOLTAGE),      \
523                 .always_on = 1,                                         \
524                 .boot_on =  1,                                          \
525                 .apply_uV = 0,                                          \
526         },                                                              \
527         .num_consumer_supplies = ARRAY_SIZE(tps51632_dcdc_supply),      \
528                 .consumer_supplies = tps51632_dcdc_supply,              \
529 };
530
531 static struct tps51632_regulator_platform_data tps51632_pdata = {
532         .reg_init_data = &tps51632_init_data,           \
533         .enable_pwm = false,                            \
534         .max_voltage_uV = 1520000,                      \
535         .base_voltage_uV = 500000,                      \
536         .slew_rate_uv_per_us = 6000,                    \
537 };
538
539 static struct i2c_board_info __initdata tps51632_boardinfo[] = {
540         {
541                 I2C_BOARD_INFO("tps51632", 0x43),
542                 .platform_data  = &tps51632_pdata,
543         },
544 };
545
546 /************************ Palmas based regulator ****************/
547 static struct regulator_consumer_supply palmas_smps12_supply[] = {
548         REGULATOR_SUPPLY("vddio_ddr3l", NULL),
549         REGULATOR_SUPPLY("vcore_ddr3l", NULL),
550         REGULATOR_SUPPLY("vref2_ddr3l", NULL),
551 };
552
553 #define palmas_smps3_supply max77663_sd2_supply
554 #define palmas_smps45_supply max77663_sd0_supply
555 #define palmas_smps457_supply max77663_sd0_supply
556
557 static struct regulator_consumer_supply palmas_smps8_supply[] = {
558         REGULATOR_SUPPLY("avdd_plla_p_c", NULL),
559         REGULATOR_SUPPLY("avdd_pllm", NULL),
560         REGULATOR_SUPPLY("avdd_pllu", NULL),
561         REGULATOR_SUPPLY("avdd_pllx", NULL),
562         REGULATOR_SUPPLY("vdd_ddr_hs", NULL),
563         REGULATOR_SUPPLY("avdd_plle", NULL),
564         REGULATOR_SUPPLY("avdd_csi_dsi_pll", "tegradc.0"),
565         REGULATOR_SUPPLY("avdd_csi_dsi_pll", "tegradc.1"),
566         REGULATOR_SUPPLY("avdd_csi_dsi_pll", "tegra_camera"),
567         REGULATOR_SUPPLY("avdd_hdmi_pll", "tegradc.1"),
568         REGULATOR_SUPPLY("avdd_usb_pll", "tegra-ehci.2"),
569         REGULATOR_SUPPLY("avddio_usb", "tegra-ehci.2"),
570
571 };
572
573 static struct regulator_consumer_supply palmas_smps9_supply[] = {
574         REGULATOR_SUPPLY("vddio_sd_slot", "sdhci-tegra.3"),
575 };
576
577 #define palmas_ldo1_supply max77663_ldo7_supply
578 #define palmas_ldo2_supply max77663_ldo8_supply
579 #define palmas_ldo3_supply max77663_ldo5_supply
580
581 static struct regulator_consumer_supply palmas_ldo4_supply[] = {
582         REGULATOR_SUPPLY("vpp_fuse", NULL),
583 };
584
585 #define palmas_ldo6_supply max77663_ldo2_supply
586
587 static struct regulator_consumer_supply palmas_ldo7_supply[] = {
588         REGULATOR_SUPPLY("vdd_af_cam1", NULL),
589         REGULATOR_SUPPLY("vdd", "2-000e"),
590 };
591
592 #define palmas_ldo8_supply max77663_ldo4_supply
593 #define palmas_ldo9_supply max77663_ldo6_supply
594
595 static struct regulator_consumer_supply palmas_ldoln_supply[] = {
596         REGULATOR_SUPPLY("hvdd_usb", "tegra-ehci.2"),
597 };
598
599 static struct regulator_consumer_supply palmas_ldousb_supply[] = {
600         REGULATOR_SUPPLY("avdd_usb", "tegra-udc.0"),
601         REGULATOR_SUPPLY("avdd_usb", "tegra-ehci.0"),
602         REGULATOR_SUPPLY("avdd_usb", "tegra-ehci.1"),
603         REGULATOR_SUPPLY("avdd_usb", "tegra-ehci.2"),
604         REGULATOR_SUPPLY("avdd_hdmi", "tegradc.1"),
605 };
606
607 #define PALMAS_PDATA_INIT(_name, _minmv, _maxmv, _supply_reg, _always_on, \
608         _boot_on, _apply_uv)                                            \
609         static struct regulator_init_data reg_idata_##_name = {         \
610                 .constraints = {                                        \
611                         .name = palmas_rails(_name),                    \
612                         .min_uV = (_minmv)*1000,                        \
613                         .max_uV = (_maxmv)*1000,                        \
614                         .valid_modes_mask = (REGULATOR_MODE_NORMAL |    \
615                                         REGULATOR_MODE_STANDBY),        \
616                         .valid_ops_mask = (REGULATOR_CHANGE_MODE |      \
617                                         REGULATOR_CHANGE_STATUS |       \
618                                         REGULATOR_CHANGE_VOLTAGE),      \
619                         .always_on = _always_on,                        \
620                         .boot_on = _boot_on,                            \
621                         .apply_uV = _apply_uv,                          \
622                 },                                                      \
623                 .num_consumer_supplies =                                \
624                         ARRAY_SIZE(palmas_##_name##_supply),            \
625                 .consumer_supplies = palmas_##_name##_supply,           \
626                 .supply_regulator = _supply_reg,                        \
627         }
628
629 PALMAS_PDATA_INIT(smps12, 1350,  1350, tps65090_rails(DCDC3), 0, 0, 0);
630 PALMAS_PDATA_INIT(smps3, 1800,  1800, tps65090_rails(DCDC3), 0, 0, 0);
631 PALMAS_PDATA_INIT(smps45, 900,  1400, tps65090_rails(DCDC2), 1, 1, 0);
632 PALMAS_PDATA_INIT(smps457, 900,  1400, tps65090_rails(DCDC2), 1, 1, 0);
633 PALMAS_PDATA_INIT(smps8, 1050,  1050, tps65090_rails(DCDC2), 0, 1, 1);
634 PALMAS_PDATA_INIT(smps9, 2800,  2800, tps65090_rails(DCDC2), 1, 0, 0);
635 PALMAS_PDATA_INIT(ldo1, 2800,  2800, tps65090_rails(DCDC2), 0, 0, 1);
636 PALMAS_PDATA_INIT(ldo2, 2800,  2800, tps65090_rails(DCDC2), 0, 0, 1);
637 PALMAS_PDATA_INIT(ldo3, 1200,  1200, palmas_rails(smps3), 0, 0, 1);
638 PALMAS_PDATA_INIT(ldo4, 1800,  1800, tps65090_rails(DCDC2), 0, 0, 0);
639 PALMAS_PDATA_INIT(ldo6, 2850,  2850, tps65090_rails(DCDC2), 0, 0, 1);
640 PALMAS_PDATA_INIT(ldo7, 2800,  2800, tps65090_rails(DCDC2), 0, 0, 1);
641 PALMAS_PDATA_INIT(ldo8, 900,  900, tps65090_rails(DCDC3), 1, 1, 1);
642 PALMAS_PDATA_INIT(ldo9, 1800,  3300, palmas_rails(smps9), 0, 0, 1);
643 PALMAS_PDATA_INIT(ldoln, 3300, 3300, tps65090_rails(DCDC1), 0, 0, 1);
644 PALMAS_PDATA_INIT(ldousb, 3300,  3300, tps65090_rails(DCDC1), 0, 0, 1);
645
646 #define PALMAS_REG_PDATA(_sname) &reg_idata_##_sname
647
648 static struct regulator_init_data *dalmore_e1611_reg_data[PALMAS_NUM_REGS] = {
649         PALMAS_REG_PDATA(smps12),
650         NULL,
651         PALMAS_REG_PDATA(smps3),
652         PALMAS_REG_PDATA(smps45),
653         PALMAS_REG_PDATA(smps457),
654         NULL,
655         NULL,
656         PALMAS_REG_PDATA(smps8),
657         PALMAS_REG_PDATA(smps9),
658         NULL,
659         PALMAS_REG_PDATA(ldo1),
660         PALMAS_REG_PDATA(ldo2),
661         PALMAS_REG_PDATA(ldo3),
662         PALMAS_REG_PDATA(ldo4),
663         NULL,
664         PALMAS_REG_PDATA(ldo6),
665         PALMAS_REG_PDATA(ldo7),
666         PALMAS_REG_PDATA(ldo8),
667         PALMAS_REG_PDATA(ldo9),
668         PALMAS_REG_PDATA(ldoln),
669         PALMAS_REG_PDATA(ldousb),
670         NULL,
671         NULL,
672         NULL,
673         NULL,
674         NULL,
675 };
676
677 #define PALMAS_REG_INIT(_name, _warm_reset, _roof_floor, _mode_sleep,   \
678                 _tstep, _vsel)                                          \
679         static struct palmas_reg_init reg_init_data_##_name = {         \
680                 .warm_reset = _warm_reset,                              \
681                 .roof_floor =   _roof_floor,                            \
682                 .mode_sleep = _mode_sleep,                              \
683                 .tstep = _tstep,                                        \
684                 .vsel = _vsel,                                          \
685         }
686
687 PALMAS_REG_INIT(smps12, 0, 0, 0, 0, 0);
688 PALMAS_REG_INIT(smps123, 0, 0, 0, 0, 0);
689 PALMAS_REG_INIT(smps3, 0, 0, 0, 0, 0);
690 PALMAS_REG_INIT(smps45, 0, PALMAS_EXT_CONTROL_NSLEEP, 0, 0, 0);
691 PALMAS_REG_INIT(smps457, 0, PALMAS_EXT_CONTROL_NSLEEP, 0, 0, 0);
692 PALMAS_REG_INIT(smps6, 0, 0, 0, 0, 0);
693 PALMAS_REG_INIT(smps7, 0, 0, 0, 0, 0);
694 PALMAS_REG_INIT(smps8, 0, PALMAS_EXT_CONTROL_NSLEEP, 0, 0, 0);
695 PALMAS_REG_INIT(smps9, 0, 0, 0, 0, 0);
696 PALMAS_REG_INIT(smps10, 0, 0, 0, 0, 0);
697 PALMAS_REG_INIT(ldo1, 0, 0, 0, 0, 0);
698 PALMAS_REG_INIT(ldo2, 0, 0, 0, 0, 0);
699 PALMAS_REG_INIT(ldo3, 0, 0, 0, 0, 0);
700 PALMAS_REG_INIT(ldo4, 0, 0, 0, 0, 0);
701 PALMAS_REG_INIT(ldo5, 0, 0, 0, 0, 0);
702 PALMAS_REG_INIT(ldo6, 0, 0, 0, 0, 0);
703 PALMAS_REG_INIT(ldo7, 0, 0, 0, 0, 0);
704 PALMAS_REG_INIT(ldo8, 0, 0, 0, 0, 0);
705 PALMAS_REG_INIT(ldo9, 0, 0, 0, 0, 0);
706 PALMAS_REG_INIT(ldoln, 0, 0, 0, 0, 0);
707 PALMAS_REG_INIT(ldousb, 0, 0, 0, 0, 0);
708 PALMAS_REG_INIT(regen1, 0, 0, 0, 0, 0);
709 PALMAS_REG_INIT(regen2, 0, 0, 0, 0, 0);
710 PALMAS_REG_INIT(regen3, 0, 0, 0, 0, 0);
711 PALMAS_REG_INIT(sysen1, 0, 0, 0, 0, 0);
712 PALMAS_REG_INIT(sysen2, 0, 0, 0, 0, 0);
713
714 #define PALMAS_REG_INIT_DATA(_sname) &reg_init_data_##_sname
715 static struct palmas_reg_init *dalmore_e1611_reg_init[PALMAS_NUM_REGS] = {
716         PALMAS_REG_INIT_DATA(smps12),
717         PALMAS_REG_INIT_DATA(smps123),
718         PALMAS_REG_INIT_DATA(smps3),
719         PALMAS_REG_INIT_DATA(smps45),
720         PALMAS_REG_INIT_DATA(smps457),
721         PALMAS_REG_INIT_DATA(smps6),
722         PALMAS_REG_INIT_DATA(smps7),
723         PALMAS_REG_INIT_DATA(smps8),
724         PALMAS_REG_INIT_DATA(smps9),
725         PALMAS_REG_INIT_DATA(smps10),
726         PALMAS_REG_INIT_DATA(ldo1),
727         PALMAS_REG_INIT_DATA(ldo2),
728         PALMAS_REG_INIT_DATA(ldo3),
729         PALMAS_REG_INIT_DATA(ldo4),
730         PALMAS_REG_INIT_DATA(ldo5),
731         PALMAS_REG_INIT_DATA(ldo6),
732         PALMAS_REG_INIT_DATA(ldo7),
733         PALMAS_REG_INIT_DATA(ldo8),
734         PALMAS_REG_INIT_DATA(ldo9),
735         PALMAS_REG_INIT_DATA(ldoln),
736         PALMAS_REG_INIT_DATA(ldousb),
737         PALMAS_REG_INIT_DATA(regen1),
738         PALMAS_REG_INIT_DATA(regen2),
739         PALMAS_REG_INIT_DATA(regen3),
740         PALMAS_REG_INIT_DATA(sysen1),
741         PALMAS_REG_INIT_DATA(sysen2),
742 };
743
744 static struct palmas_pmic_platform_data pmic_platform = {
745         .enable_ldo8_tracking = true,
746         .disabe_ldo8_tracking_suspend = true,
747 };
748
749 static struct palmas_rtc_platform_data rtc_platform = {
750         .enable_charging = 1,
751         .charging_current_ua = 100,
752 };
753
754 static struct palmas_platform_data palmas_pdata = {
755         .gpio_base = PALMAS_TEGRA_GPIO_BASE,
756         .irq_base = PALMAS_TEGRA_IRQ_BASE,
757         .pmic_pdata = &pmic_platform,
758         .rtc_pdata = &rtc_platform,
759         .mux_from_pdata = true,
760         .pad1 = 0,
761         .pad2 = 0,
762         .pad3 = PALMAS_PRIMARY_SECONDARY_PAD3_DVFS1,
763         .use_power_off = true,
764 };
765
766 static struct i2c_board_info palma_device[] = {
767         {
768                 I2C_BOARD_INFO("tps65913", 0x58),
769                 .irq            = INT_EXTERNAL_PMU,
770                 .platform_data  = &palmas_pdata,
771         },
772 };
773
774 /* EN_AVDD_USB_HDMI From PMU GP1 */
775 static struct regulator_consumer_supply fixed_reg_avdd_usb_hdmi_supply[] = {
776         REGULATOR_SUPPLY("avdd_hdmi", "tegradc.1"),
777         REGULATOR_SUPPLY("avdd_usb", "tegra-udc.0"),
778         REGULATOR_SUPPLY("avdd_usb", "tegra-ehci.0"),
779         REGULATOR_SUPPLY("avdd_usb", "tegra-ehci.1"),
780         REGULATOR_SUPPLY("avdd_usb", "tegra-ehci.2"),
781         REGULATOR_SUPPLY("hvdd_usb", "tegra-ehci.2"),
782 };
783
784 /* EN_CAM_1v8 From PMU GP5 */
785 static struct regulator_consumer_supply fixed_reg_en_1v8_cam_supply[] = {
786         REGULATOR_SUPPLY("dvdd_cam", NULL),
787         REGULATOR_SUPPLY("vdd_cam_1v8", NULL),
788         REGULATOR_SUPPLY("vi2c", "2-0030"),
789         REGULATOR_SUPPLY("vif", "2-0036"),
790         REGULATOR_SUPPLY("dovdd", "2-0010"),
791         REGULATOR_SUPPLY("vdd_i2c", "2-000e"),
792 };
793
794 /* EN_CAM_1v8 on e1611 From PMU GP6 */
795 static struct regulator_consumer_supply fixed_reg_en_1v8_cam_e1611_supply[] = {
796         REGULATOR_SUPPLY("dvdd_cam", NULL),
797         REGULATOR_SUPPLY("vdd_cam_1v8", NULL),
798         REGULATOR_SUPPLY("vi2c", "2-0030"),
799         REGULATOR_SUPPLY("vif", "2-0036"),
800         REGULATOR_SUPPLY("dovdd", "2-0010"),
801         REGULATOR_SUPPLY("vdd_i2c", "2-000e"),
802 };
803
804 static struct regulator_consumer_supply fixed_reg_vdd_hdmi_5v0_supply[] = {
805         REGULATOR_SUPPLY("vdd_hdmi_5v0", "tegradc.1"),
806 };
807
808 static struct regulator_consumer_supply fixed_reg_lcd_bl_en_supply[] = {
809         REGULATOR_SUPPLY("vdd_lcd_bl_en", NULL),
810 };
811
812 /* EN_USB1_VBUS From TEGRA GPIO PN4 PR3(T30) */
813 static struct regulator_consumer_supply fixed_reg_usb1_vbus_supply[] = {
814         REGULATOR_SUPPLY("usb_vbus", "tegra-ehci.0"),
815 };
816
817 /* EN_3V3_FUSE From TEGRA GPIO PX4 */
818 static struct regulator_consumer_supply fixed_reg_vpp_fuse_supply[] = {
819         REGULATOR_SUPPLY("vpp_fuse", NULL),
820 };
821
822 /* EN_USB3_VBUS From TEGRA GPIO PM5 */
823 static struct regulator_consumer_supply fixed_reg_usb3_vbus_supply[] = {
824         REGULATOR_SUPPLY("usb_vbus", "tegra-ehci.2"),
825 };
826
827 /* EN_1V8_TS From TEGRA_GPIO_PH5 */
828 static struct regulator_consumer_supply fixed_reg_dvdd_ts_supply[] = {
829         REGULATOR_SUPPLY("dvdd", "spi3.2"),
830 };
831
832 /* Macro for defining fixed regulator sub device data */
833 #define FIXED_SUPPLY(_name) "fixed_reg_"#_name
834 #define FIXED_REG(_id, _var, _name, _in_supply, _always_on, _boot_on,   \
835         _gpio_nr, _open_drain, _active_high, _boot_state, _millivolts)  \
836         static struct regulator_init_data ri_data_##_var =              \
837         {                                                               \
838                 .supply_regulator = _in_supply,                         \
839                 .num_consumer_supplies =                                \
840                         ARRAY_SIZE(fixed_reg_##_name##_supply),         \
841                 .consumer_supplies = fixed_reg_##_name##_supply,        \
842                 .constraints = {                                        \
843                         .valid_modes_mask = (REGULATOR_MODE_NORMAL |    \
844                                         REGULATOR_MODE_STANDBY),        \
845                         .valid_ops_mask = (REGULATOR_CHANGE_MODE |      \
846                                         REGULATOR_CHANGE_STATUS |       \
847                                         REGULATOR_CHANGE_VOLTAGE),      \
848                         .always_on = _always_on,                        \
849                         .boot_on = _boot_on,                            \
850                 },                                                      \
851         };                                                              \
852         static struct fixed_voltage_config fixed_reg_##_var##_pdata =   \
853         {                                                               \
854                 .supply_name = FIXED_SUPPLY(_name),                     \
855                 .microvolts = _millivolts * 1000,                       \
856                 .gpio = _gpio_nr,                                       \
857                 .gpio_is_open_drain = _open_drain,                      \
858                 .enable_high = _active_high,                            \
859                 .enabled_at_boot = _boot_state,                         \
860                 .init_data = &ri_data_##_var,                           \
861         };                                                              \
862         static struct platform_device fixed_reg_##_var##_dev = {        \
863                 .name = "reg-fixed-voltage",                            \
864                 .id = _id,                                              \
865                 .dev = {                                                \
866                         .platform_data = &fixed_reg_##_var##_pdata,     \
867                 },                                                      \
868         }
869
870 FIXED_REG(1,    avdd_usb_hdmi,  avdd_usb_hdmi,
871         tps65090_rails(DCDC2),  0,      0,
872         MAX77663_GPIO_BASE + MAX77663_GPIO1,    true,   true,   1,      3300);
873
874 FIXED_REG(2,    en_1v8_cam,     en_1v8_cam,
875         max77663_rails(sd2),    0,      0,
876         MAX77663_GPIO_BASE + MAX77663_GPIO5,    false,  true,   0,      1800);
877
878 FIXED_REG(3,    vdd_hdmi_5v0,   vdd_hdmi_5v0,
879         tps65090_rails(DCDC1),  0,      0,
880         TEGRA_GPIO_PK1, false,  true,   0,      5000);
881
882 FIXED_REG(4,    vpp_fuse,       vpp_fuse,
883         max77663_rails(sd2),    0,      0,
884         TEGRA_GPIO_PX4, false,  true,   0,      3300);
885
886 FIXED_REG(5,    usb1_vbus,      usb1_vbus,
887         tps65090_rails(DCDC1),  0,      0,
888         TEGRA_GPIO_PN4, true,   true,   0,      5000);
889
890 FIXED_REG(6,    usb3_vbus,      usb3_vbus,
891         tps65090_rails(DCDC1),  0,      0,
892         TEGRA_GPIO_PK6, true,   true,   0,      5000);
893
894 FIXED_REG(7,    en_1v8_cam_e1611,       en_1v8_cam_e1611,
895         palmas_rails(smps3),    0,      0,
896         PALMAS_TEGRA_GPIO_BASE + PALMAS_GPIO6,  false,  true,   0,      1800);
897
898 FIXED_REG(8,    dvdd_ts,        dvdd_ts,
899         palmas_rails(smps3),    0,      0,
900         TEGRA_GPIO_PH5, false,  false,  1,      1800);
901
902 FIXED_REG(9,    lcd_bl_en,      lcd_bl_en,
903         NULL,   0,      0,
904         TEGRA_GPIO_PH2, false,  true,   0,      5000);
905 /*
906  * Creating the fixed regulator device tables
907  */
908
909 #define ADD_FIXED_REG(_name)    (&fixed_reg_##_name##_dev)
910
911 #define DALMORE_COMMON_FIXED_REG                \
912         ADD_FIXED_REG(usb1_vbus),               \
913         ADD_FIXED_REG(usb3_vbus),               \
914         ADD_FIXED_REG(vdd_hdmi_5v0),            \
915         ADD_FIXED_REG(lcd_bl_en),
916
917 #define E1612_FIXED_REG                         \
918         ADD_FIXED_REG(avdd_usb_hdmi),           \
919         ADD_FIXED_REG(en_1v8_cam),              \
920         ADD_FIXED_REG(vpp_fuse),                \
921
922 #define E1611_FIXED_REG                         \
923         ADD_FIXED_REG(en_1v8_cam_e1611), \
924         ADD_FIXED_REG(dvdd_ts),
925
926 /* Gpio switch regulator platform data for Dalmore E1611 */
927 static struct platform_device *fixed_reg_devs_e1611_a00[] = {
928         DALMORE_COMMON_FIXED_REG
929         E1611_FIXED_REG
930 };
931
932 /* Gpio switch regulator platform data for Dalmore E1612 */
933 static struct platform_device *fixed_reg_devs_e1612_a00[] = {
934         DALMORE_COMMON_FIXED_REG
935         E1612_FIXED_REG
936 };
937
938 int __init dalmore_palmas_regulator_init(void)
939 {
940         void __iomem *pmc = IO_ADDRESS(TEGRA_PMC_BASE);
941         u32 pmc_ctrl;
942         int i;
943
944         /* TPS65913: Normal state of INT request line is LOW.
945          * configure the power management controller to trigger PMU
946          * interrupts when HIGH.
947          */
948         pmc_ctrl = readl(pmc + PMC_CTRL);
949         writel(pmc_ctrl | PMC_CTRL_INTR_LOW, pmc + PMC_CTRL);
950         for (i = 0; i < PALMAS_NUM_REGS ; i++) {
951                 pmic_platform.reg_data[i] = dalmore_e1611_reg_data[i];
952                 pmic_platform.reg_init[i] = dalmore_e1611_reg_init[i];
953         }
954
955         i2c_register_board_info(4, palma_device,
956                         ARRAY_SIZE(palma_device));
957         return 0;
958 }
959
960 static int ac_online(void)
961 {
962         return 1;
963 }
964
965 static struct resource dalmore_pda_resources[] = {
966         [0] = {
967                 .name   = "ac",
968         },
969 };
970
971 static struct pda_power_pdata dalmore_pda_data = {
972         .is_ac_online   = ac_online,
973 };
974
975 static struct platform_device dalmore_pda_power_device = {
976         .name           = "pda-power",
977         .id             = -1,
978         .resource       = dalmore_pda_resources,
979         .num_resources  = ARRAY_SIZE(dalmore_pda_resources),
980         .dev    = {
981                 .platform_data  = &dalmore_pda_data,
982         },
983 };
984
985 static struct tegra_suspend_platform_data dalmore_suspend_data = {
986         .cpu_timer      = 300,
987         .cpu_off_timer  = 300,
988         .suspend_mode   = TEGRA_SUSPEND_LP0,
989         .core_timer     = 0x157e,
990         .core_off_timer = 2000,
991         .corereq_high   = true,
992         .sysclkreq_high = true,
993         .min_residency_noncpu = 600,
994         .min_residency_crail = 1000,
995 };
996 #ifdef CONFIG_ARCH_TEGRA_HAS_CL_DVFS
997 /* board parameters for cpu dfll */
998 static struct tegra_cl_dvfs_cfg_param dalmore_cl_dvfs_param = {
999         .sample_rate = 12500,
1000
1001         .force_mode = TEGRA_CL_DVFS_FORCE_FIXED,
1002         .cf = 10,
1003         .ci = 0,
1004         .cg = 2,
1005
1006         .droop_cut_value = 0xF,
1007         .droop_restore_ramp = 0x0,
1008         .scale_out_ramp = 0x0,
1009 };
1010 #endif
1011
1012 /* TPS51632: fixed 10mV steps from 600mV to 1400mV, with offset 0x23 */
1013 #define PMU_CPU_VDD_MAP_SIZE ((1400000 - 600000) / 10000 + 1)
1014 static struct voltage_reg_map pmu_cpu_vdd_map[PMU_CPU_VDD_MAP_SIZE];
1015 static inline void fill_reg_map(void)
1016 {
1017         int i;
1018         for (i = 0; i < PMU_CPU_VDD_MAP_SIZE; i++) {
1019                 pmu_cpu_vdd_map[i].reg_value = i + 0x23;
1020                 pmu_cpu_vdd_map[i].reg_uV = 600000 + 10000 * i;
1021         }
1022 }
1023
1024 #ifdef CONFIG_ARCH_TEGRA_HAS_CL_DVFS
1025 static struct tegra_cl_dvfs_platform_data dalmore_cl_dvfs_data = {
1026         .dfll_clk_name = "dfll_cpu",
1027         .pmu_if = TEGRA_CL_DVFS_PMU_I2C,
1028         .u.pmu_i2c = {
1029                 .fs_rate = 400000,
1030                 .slave_addr = 0x86,
1031                 .reg = 0x00,
1032         },
1033         .vdd_map = pmu_cpu_vdd_map,
1034         .vdd_map_size = PMU_CPU_VDD_MAP_SIZE,
1035
1036         .cfg_param = &dalmore_cl_dvfs_param,
1037 };
1038
1039 static int __init dalmore_cl_dvfs_init(void)
1040 {
1041         fill_reg_map();
1042         tegra_cl_dvfs_device.dev.platform_data = &dalmore_cl_dvfs_data;
1043         platform_device_register(&tegra_cl_dvfs_device);
1044
1045         return 0;
1046 }
1047 #endif
1048
1049 static int __init dalmore_max77663_regulator_init(void)
1050 {
1051         void __iomem *pmc = IO_ADDRESS(TEGRA_PMC_BASE);
1052         u32 pmc_ctrl;
1053
1054         /* configure the power management controller to trigger PMU
1055          * interrupts when low */
1056         pmc_ctrl = readl(pmc + PMC_CTRL);
1057         writel(pmc_ctrl | PMC_CTRL_INTR_LOW, pmc + PMC_CTRL);
1058
1059         i2c_register_board_info(4, max77663_regulators,
1060                                 ARRAY_SIZE(max77663_regulators));
1061
1062         return 0;
1063 }
1064
1065 static struct regulator_bulk_data dalmore_gps_regulator_supply[] = {
1066         [0] = {
1067                 .supply = "vdd_gps_3v3",
1068         },
1069         [1] = {
1070                 .supply = "vdd_gps_1v8",
1071         },
1072 };
1073
1074 static struct regulator_userspace_consumer_data dalmore_gps_regulator_pdata = {
1075         .num_supplies   = ARRAY_SIZE(dalmore_gps_regulator_supply),
1076         .supplies       = dalmore_gps_regulator_supply,
1077 };
1078
1079 static struct platform_device dalmore_gps_regulator_device = {
1080         .name   = "reg-userspace-consumer",
1081         .id     = 2,
1082         .dev    = {
1083                         .platform_data = &dalmore_gps_regulator_pdata,
1084         },
1085 };
1086
1087 static int __init dalmore_fixed_regulator_init(void)
1088 {
1089         struct board_info board_info;
1090
1091         if (!machine_is_dalmore())
1092                 return 0;
1093
1094         tegra_get_board_info(&board_info);
1095
1096         if (board_info.board_id == BOARD_E1611 ||
1097                 board_info.board_id == BOARD_P2454)
1098                 return platform_add_devices(fixed_reg_devs_e1611_a00,
1099                                 ARRAY_SIZE(fixed_reg_devs_e1611_a00));
1100         else
1101                 return platform_add_devices(fixed_reg_devs_e1612_a00,
1102                                 ARRAY_SIZE(fixed_reg_devs_e1612_a00));
1103 }
1104 subsys_initcall_sync(dalmore_fixed_regulator_init);
1105
1106 static void dalmore_tps65090_init(void)
1107 {
1108         int err;
1109
1110         err = gpio_request(TPS65090_CHARGER_INT, "CHARGER_INT");
1111         if (err < 0) {
1112                 pr_err("%s: gpio_request failed %d\n", __func__, err);
1113                 goto fail_init_irq;
1114         }
1115
1116         err = gpio_direction_input(TPS65090_CHARGER_INT);
1117         if (err < 0) {
1118                 pr_err("%s: gpio_direction_input failed %d\n", __func__, err);
1119                 goto fail_init_irq;
1120         }
1121
1122         tps65090_regulators[0].irq = gpio_to_irq(TPS65090_CHARGER_INT);
1123 fail_init_irq:
1124         i2c_register_board_info(4, tps65090_regulators,
1125                         ARRAY_SIZE(tps65090_regulators));
1126         return;
1127 }
1128
1129 int __init dalmore_regulator_init(void)
1130 {
1131         struct board_info board_info;
1132
1133         dalmore_tps65090_init();
1134 #ifdef CONFIG_ARCH_TEGRA_HAS_CL_DVFS
1135         dalmore_cl_dvfs_init();
1136 #endif
1137         tegra_get_board_info(&board_info);
1138         if (board_info.board_id == BOARD_E1611 ||
1139                 board_info.board_id == BOARD_P2454)
1140                 dalmore_palmas_regulator_init();
1141         else
1142                 dalmore_max77663_regulator_init();
1143
1144         i2c_register_board_info(4, tps51632_boardinfo, 1);
1145         platform_device_register(&dalmore_pda_power_device);
1146         platform_device_register(&dalmore_gps_regulator_device);
1147         return 0;
1148 }
1149
1150 int __init dalmore_suspend_init(void)
1151 {
1152         tegra_init_suspend(&dalmore_suspend_data);
1153         return 0;
1154 }
1155
1156 int __init dalmore_edp_init(void)
1157 {
1158         unsigned int regulator_mA;
1159
1160         regulator_mA = get_maximum_cpu_current_supported();
1161         if (!regulator_mA)
1162                 regulator_mA = 15000;
1163
1164         pr_info("%s: CPU regulator %d mA\n", __func__, regulator_mA);
1165         tegra_init_cpu_edp_limits(regulator_mA);
1166
1167         regulator_mA = get_maximum_core_current_supported();
1168         if (!regulator_mA)
1169                 regulator_mA = 4000;
1170
1171         pr_info("%s: core regulator %d mA\n", __func__, regulator_mA);
1172         tegra_init_core_edp_limits(regulator_mA);
1173
1174         return 0;
1175 }
1176
1177 static struct soctherm_platform_data dalmore_soctherm_data = {
1178         .soctherm_clk_rate = 136000000,
1179         .tsensor_clk_rate = 500000,
1180         .sensor_data = {
1181                 [TSENSE_CPU0] = {
1182                         .enable = true,
1183                         .tall = 16300,
1184                         .tiddq = 1,
1185                         .ten_count = 1,
1186                         .tsample = 163,
1187                         .pdiv = 10,
1188                 },
1189                 [TSENSE_CPU1] = {
1190                         .enable = true,
1191                         .tall = 16300,
1192                         .tiddq = 1,
1193                         .ten_count = 1,
1194                         .tsample = 163,
1195                         .pdiv = 10,
1196                 },
1197                 [TSENSE_CPU2] = {
1198                         .enable = true,
1199                         .tall = 16300,
1200                         .tiddq = 1,
1201                         .ten_count = 1,
1202                         .tsample = 163,
1203                         .pdiv = 10,
1204                 },
1205                 [TSENSE_CPU3] = {
1206                         .enable = true,
1207                         .tall = 16300,
1208                         .tiddq = 1,
1209                         .ten_count = 1,
1210                         .tsample = 163,
1211                         .pdiv = 10,
1212                 },
1213                 /* MEM0/MEM1 won't be used */
1214                 [TSENSE_MEM0] = {
1215                         .enable = false,
1216                 },
1217                 [TSENSE_MEM1] = {
1218                         .enable = false,
1219                 },
1220                 [TSENSE_GPU] = {
1221                         .enable = true,
1222                         .tall = 16300,
1223                         .tiddq = 1,
1224                         .ten_count = 1,
1225                         .tsample = 163,
1226                         .pdiv = 10,
1227                 },
1228                 [TSENSE_PLLX] = {
1229                         .enable = true,
1230                         .tall = 16300,
1231                         .tiddq = 1,
1232                         .ten_count = 1,
1233                         .tsample = 163,
1234                         .pdiv = 10,
1235                 },
1236         },
1237 };
1238
1239 int __init dalmore_soctherm_init(void)
1240 {
1241         return tegra11_soctherm_init(&dalmore_soctherm_data);
1242 }