ARM: tegra: Increase enable time of LDO6
[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-2013 NVIDIA Corporation. All rights reserved.
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/tps51632-regulator.h>
33 #include <linux/gpio.h>
34 #include <linux/interrupt.h>
35 #include <linux/regulator/userspace-consumer.h>
36 #include <linux/pid_thermal_gov.h>
37 #include <linux/tegra-soc.h>
38
39 #include <asm/mach-types.h>
40 #include <linux/power/sbs-battery.h>
41
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-pmu-defines.h"
50 #include "board.h"
51 #include "gpio-names.h"
52 #include "board-common.h"
53 #include "board-dalmore.h"
54 #include "tegra_cl_dvfs.h"
55 #include "devices.h"
56 #include "tegra11_soctherm.h"
57 #include "iomap.h"
58 #include "tegra3_tsensor.h"
59
60 #define PMC_CTRL                0x0
61 #define PMC_CTRL_INTR_LOW       (1 << 17)
62 #define TPS65090_CHARGER_INT    TEGRA_GPIO_PJ0
63 #define POWER_CONFIG2   0x02
64
65 /*TPS65090 consumer rails */
66 static struct regulator_consumer_supply tps65090_dcdc1_supply[] = {
67         REGULATOR_SUPPLY("vdd_sys_5v0", NULL),
68         REGULATOR_SUPPLY("vdd_spk", NULL),
69         REGULATOR_SUPPLY("vdd_sys_modem_5v0", NULL),
70         REGULATOR_SUPPLY("vdd_sys_cam_5v0", NULL),
71 };
72
73 static struct regulator_consumer_supply tps65090_dcdc2_supply[] = {
74         REGULATOR_SUPPLY("vdd_sys_3v3", NULL),
75         REGULATOR_SUPPLY("vddio_hv", "tegradc.1"),
76         REGULATOR_SUPPLY("pwrdet_hv", NULL),
77         REGULATOR_SUPPLY("vdd_sys_ds_3v3", NULL),
78         REGULATOR_SUPPLY("avdd", "0-0028"),
79         REGULATOR_SUPPLY("vdd_sys_cam_3v3", NULL),
80         REGULATOR_SUPPLY("vdd_sys_sensor_3v3", NULL),
81         REGULATOR_SUPPLY("vdd_sys_audio_3v3", NULL),
82         REGULATOR_SUPPLY("vdd_sys_dtv_3v3", NULL),
83         REGULATOR_SUPPLY("vcc", "0-007c"),
84         REGULATOR_SUPPLY("vcc", "0-0030"),
85         REGULATOR_SUPPLY("vin", "2-0030"),
86 };
87
88 static struct regulator_consumer_supply tps65090_dcdc3_supply[] = {
89         REGULATOR_SUPPLY("vdd_ao", NULL),
90 };
91
92 static struct regulator_consumer_supply tps65090_ldo1_supply[] = {
93         REGULATOR_SUPPLY("vdd_sby_5v0", NULL),
94 };
95
96 static struct regulator_consumer_supply tps65090_ldo2_supply[] = {
97         REGULATOR_SUPPLY("vdd_sby_3v3", NULL),
98 };
99
100 static struct regulator_consumer_supply tps65090_fet1_supply[] = {
101         REGULATOR_SUPPLY("vdd_lcd_bl", NULL),
102 };
103
104 static struct regulator_consumer_supply tps65090_fet3_supply[] = {
105         REGULATOR_SUPPLY("vdd_modem_3v3", NULL),
106 };
107
108 static struct regulator_consumer_supply tps65090_fet4_supply[] = {
109         REGULATOR_SUPPLY("avdd_lcd", NULL),
110         REGULATOR_SUPPLY("avdd", "spi3.2"),
111 };
112
113 static struct regulator_consumer_supply tps65090_fet5_supply[] = {
114         REGULATOR_SUPPLY("vdd_lvds", NULL),
115 };
116
117 static struct regulator_consumer_supply tps65090_fet6_supply[] = {
118         REGULATOR_SUPPLY("vddio_sd_slot", "sdhci-tegra.2"),
119 };
120
121 static struct regulator_consumer_supply tps65090_fet7_supply[] = {
122         REGULATOR_SUPPLY("avdd", "bcm4329_wlan.1"),
123         REGULATOR_SUPPLY("avdd", "reg-userspace-consumer.2"),
124         REGULATOR_SUPPLY("avdd", "bluedroid_pm.0"),
125 };
126
127 #define tps65090_rails(id) "tps65090-"#id
128 #define TPS65090_PDATA_INIT(_id, _name, _supply_reg,                    \
129         _always_on, _boot_on, _apply_uV, _en_ext_ctrl, _gpio, _wait_to) \
130 static struct regulator_init_data ri_data_##_name =                     \
131 {                                                                       \
132         .supply_regulator = _supply_reg,                                \
133         .constraints = {                                                \
134                 .name = tps65090_rails(_id),                            \
135                 .valid_modes_mask = (REGULATOR_MODE_NORMAL |            \
136                                      REGULATOR_MODE_STANDBY),           \
137                 .valid_ops_mask = (REGULATOR_CHANGE_MODE |              \
138                                    REGULATOR_CHANGE_STATUS |            \
139                                    REGULATOR_CHANGE_VOLTAGE),           \
140                 .always_on = _always_on,                                \
141                 .boot_on = _boot_on,                                    \
142                 .apply_uV = _apply_uV,                                  \
143         },                                                              \
144         .num_consumer_supplies =                                        \
145                 ARRAY_SIZE(tps65090_##_name##_supply),                  \
146         .consumer_supplies = tps65090_##_name##_supply,                 \
147 };                                                                      \
148 static struct tps65090_regulator_plat_data                              \
149                         tps65090_regulator_pdata_##_name =              \
150 {                                                                       \
151         .enable_ext_control = _en_ext_ctrl,                             \
152         .gpio = _gpio,                                                  \
153         .reg_init_data = &ri_data_##_name ,                             \
154         .wait_timeout_us = _wait_to,                                    \
155 }
156
157 TPS65090_PDATA_INIT(DCDC1, dcdc1, NULL, 1, 1, 0, true, -1, -1);
158 TPS65090_PDATA_INIT(DCDC2, dcdc2, NULL, 1, 1, 0, true, -1, -1);
159 TPS65090_PDATA_INIT(DCDC3, dcdc3, NULL, 1, 1, 0, true, -1, -1);
160 TPS65090_PDATA_INIT(LDO1, ldo1, NULL, 1, 1, 0, false, -1, -1);
161 TPS65090_PDATA_INIT(LDO2, ldo2, NULL, 1, 1, 0, false, -1, -1);
162 TPS65090_PDATA_INIT(FET1, fet1, NULL, 0, 0, 0, false, -1, 800);
163 TPS65090_PDATA_INIT(FET3, fet3, tps65090_rails(DCDC2), 0, 0, 0, false, -1, 0);
164 TPS65090_PDATA_INIT(FET4, fet4, tps65090_rails(DCDC2), 0, 0, 0, false, -1, 0);
165 TPS65090_PDATA_INIT(FET5, fet5, tps65090_rails(DCDC2), 0, 0, 0, false, -1, 0);
166 TPS65090_PDATA_INIT(FET6, fet6, tps65090_rails(DCDC2), 0, 0, 0, false, -1, 0);
167 TPS65090_PDATA_INIT(FET7, fet7, tps65090_rails(DCDC2), 0, 0, 0, false, -1, 0);
168
169 static struct tps65090_charger_data bcharger_pdata = {
170         .irq_base = TPS65090_TEGRA_IRQ_BASE,
171 };
172
173 #define ADD_TPS65090_REG(_name) (&tps65090_regulator_pdata_##_name)
174 static struct tps65090_platform_data tps65090_pdata = {
175         .irq_base = TPS65090_TEGRA_IRQ_BASE,
176         .reg_pdata = {
177                         ADD_TPS65090_REG(dcdc1),
178                         ADD_TPS65090_REG(dcdc2),
179                         ADD_TPS65090_REG(dcdc3),
180                         ADD_TPS65090_REG(fet1),
181                         NULL,
182                         ADD_TPS65090_REG(fet3),
183                         ADD_TPS65090_REG(fet4),
184                         ADD_TPS65090_REG(fet5),
185                         ADD_TPS65090_REG(fet6),
186                         ADD_TPS65090_REG(fet7),
187                         ADD_TPS65090_REG(ldo1),
188                         ADD_TPS65090_REG(ldo2),
189                 },
190         .charger_pdata = &bcharger_pdata,
191 };
192
193 /* MAX77663 consumer rails */
194 static struct regulator_consumer_supply max77663_sd0_supply[] = {
195         REGULATOR_SUPPLY("vdd_core", NULL),
196         REGULATOR_SUPPLY("vdd_core", "sdhci-tegra.0"),
197         REGULATOR_SUPPLY("vdd_core", "sdhci-tegra.2"),
198         REGULATOR_SUPPLY("vdd_core", "sdhci-tegra.3"),
199 };
200
201 static struct regulator_consumer_supply max77663_sd1_supply[] = {
202         REGULATOR_SUPPLY("vddio_ddr", NULL),
203         REGULATOR_SUPPLY("vddio_ddr0", NULL),
204         REGULATOR_SUPPLY("vddio_ddr1", NULL),
205 };
206
207 static struct regulator_consumer_supply max77663_sd2_supply[] = {
208         REGULATOR_SUPPLY("avdd_usb_pll", "tegra-udc.0"),
209         REGULATOR_SUPPLY("avdd_usb_pll", "tegra-ehci.0"),
210         REGULATOR_SUPPLY("avdd_usb_pll", "tegra-ehci.1"),
211         REGULATOR_SUPPLY("vddio_cam", "vi"),
212         REGULATOR_SUPPLY("pwrdet_cam", NULL),
213         REGULATOR_SUPPLY("avdd_osc", NULL),
214         REGULATOR_SUPPLY("vddio_sys", NULL),
215         REGULATOR_SUPPLY("vddio_sdmmc", "sdhci-tegra.0"),
216         REGULATOR_SUPPLY("pwrdet_sdmmc1", NULL),
217         REGULATOR_SUPPLY("vddio_sdmmc", "sdhci-tegra.3"),
218         REGULATOR_SUPPLY("pwrdet_sdmmc4", NULL),
219         REGULATOR_SUPPLY("vdd_emmc", NULL),
220         REGULATOR_SUPPLY("vddio_audio", NULL),
221         REGULATOR_SUPPLY("pwrdet_audio", NULL),
222         REGULATOR_SUPPLY("avdd_audio_1v8", NULL),
223         REGULATOR_SUPPLY("vdd_audio_1v8", NULL),
224         REGULATOR_SUPPLY("vddio_modem", NULL),
225         REGULATOR_SUPPLY("vddio_modem_1v8", NULL),
226         REGULATOR_SUPPLY("vddio_bb", NULL),
227         REGULATOR_SUPPLY("pwrdet_bb", NULL),
228         REGULATOR_SUPPLY("vddio_bb_1v8", NULL),
229         REGULATOR_SUPPLY("vddio_uart", NULL),
230         REGULATOR_SUPPLY("pwrdet_uart", NULL),
231         REGULATOR_SUPPLY("vddio_gmi", NULL),
232         REGULATOR_SUPPLY("pwrdet_nand", NULL),
233         REGULATOR_SUPPLY("vdd_sensor_1v8", NULL),
234         REGULATOR_SUPPLY("vdd_mic_1v8", NULL),
235         REGULATOR_SUPPLY("dvdd", "0-0028"),
236         REGULATOR_SUPPLY("vdd_ds_1v8", NULL),
237         REGULATOR_SUPPLY("vdd_spi_1v8", NULL),
238         REGULATOR_SUPPLY("dvdd_lcd", NULL),
239         REGULATOR_SUPPLY("vdd_com_1v8", NULL),
240         REGULATOR_SUPPLY("dvdd", "bcm4329_wlan.1"),
241         REGULATOR_SUPPLY("dvdd", "reg-userspace-consumer.2"),
242         REGULATOR_SUPPLY("dvdd", "bluedroid_pm.0"),
243         REGULATOR_SUPPLY("vdd_dtv_1v8", NULL),
244         REGULATOR_SUPPLY("vlogic", "0-0069"),
245         REGULATOR_SUPPLY("vid", "0-000d"),
246         REGULATOR_SUPPLY("vddio", "0-0078"),
247 };
248
249 static struct regulator_consumer_supply max77663_sd3_supply[] = {
250         REGULATOR_SUPPLY("vcore_emmc", NULL),
251 };
252
253 static struct regulator_consumer_supply max77663_ldo0_supply[] = {
254         REGULATOR_SUPPLY("avdd_plla_p_c", NULL),
255         REGULATOR_SUPPLY("avdd_pllx", NULL),
256         REGULATOR_SUPPLY("avdd_plle", NULL),
257         REGULATOR_SUPPLY("avdd_pllm", NULL),
258         REGULATOR_SUPPLY("avdd_pllu", NULL),
259         REGULATOR_SUPPLY("avdd_csi_dsi_pll", "tegradc.0"),
260         REGULATOR_SUPPLY("avdd_csi_dsi_pll", "tegradc.1"),
261         REGULATOR_SUPPLY("avdd_csi_dsi_pll", "vi"),
262 };
263
264 static struct regulator_consumer_supply max77663_ldo1_supply[] = {
265         REGULATOR_SUPPLY("vdd_ddr_hs", NULL),
266 };
267
268 static struct regulator_consumer_supply max77663_ldo2_supply[] = {
269         REGULATOR_SUPPLY("vdd_sensor_2v85", NULL),
270         REGULATOR_SUPPLY("vdd_als", NULL),
271         REGULATOR_SUPPLY("vdd", "0-0048"),
272         REGULATOR_SUPPLY("vdd", "0-004c"),
273         REGULATOR_SUPPLY("vdd", "0-0069"),
274         REGULATOR_SUPPLY("vdd", "0-000d"),
275         REGULATOR_SUPPLY("vdd", "0-0078"),
276 };
277
278 static struct regulator_consumer_supply max77663_ldo3_supply[] = {
279         REGULATOR_SUPPLY("avdd_hdmi_pll", "tegradc.1"),
280         REGULATOR_SUPPLY("avdd_usb_pll", "tegra-ehci.2"),
281         REGULATOR_SUPPLY("avddio_usb", "tegra-ehci.2"),
282 };
283
284 static struct regulator_consumer_supply max77663_ldo4_supply[] = {
285         REGULATOR_SUPPLY("vdd_rtc", NULL),
286 };
287
288 static struct regulator_consumer_supply max77663_ldo5_supply[] = {
289         REGULATOR_SUPPLY("avdd_dsi_csi", "tegradc.0"),
290         REGULATOR_SUPPLY("avdd_dsi_csi", "tegradc.1"),
291         REGULATOR_SUPPLY("avdd_dsi_csi", "vi"),
292         REGULATOR_SUPPLY("vddio_hsic", "tegra-ehci.1"),
293         REGULATOR_SUPPLY("vddio_hsic", "tegra-ehci.2"),
294         REGULATOR_SUPPLY("vddio_hsic", "tegra-xhci"),
295         REGULATOR_SUPPLY("pwrdet_mipi", NULL),
296         REGULATOR_SUPPLY("vddio_bb_hsic", NULL),
297 };
298
299 static struct regulator_consumer_supply max77663_ldo6_supply[] = {
300         REGULATOR_SUPPLY("vddio_sdmmc", "sdhci-tegra.2"),
301         REGULATOR_SUPPLY("pwrdet_sdmmc3", NULL),
302 };
303
304 /* FIXME!! Put the device address of camera */
305 static struct regulator_consumer_supply max77663_ldo7_supply[] = {
306         REGULATOR_SUPPLY("avdd_cam1", NULL),
307         REGULATOR_SUPPLY("avdd_2v8_cam_af", NULL),
308         REGULATOR_SUPPLY("vana", "2-0036"),
309 };
310
311 /* FIXME!! Put the device address of camera */
312 static struct regulator_consumer_supply max77663_ldo8_supply[] = {
313         REGULATOR_SUPPLY("avdd_cam2", NULL),
314         REGULATOR_SUPPLY("avdd", "2-0010"),
315 };
316
317 static struct max77663_regulator_fps_cfg max77663_fps_cfgs[] = {
318         {
319                 .src = FPS_SRC_0,
320                 .en_src = FPS_EN_SRC_EN0,
321                 .time_period = FPS_TIME_PERIOD_DEF,
322         },
323         {
324                 .src = FPS_SRC_1,
325                 .en_src = FPS_EN_SRC_EN1,
326                 .time_period = FPS_TIME_PERIOD_DEF,
327         },
328         {
329                 .src = FPS_SRC_2,
330                 .en_src = FPS_EN_SRC_EN0,
331                 .time_period = FPS_TIME_PERIOD_DEF,
332         },
333 };
334
335 #define MAX77663_PDATA_INIT(_rid, _id, _min_uV, _max_uV, _supply_reg,   \
336                 _always_on, _boot_on, _apply_uV,                        \
337                 _fps_src, _fps_pu_period, _fps_pd_period, _flags)       \
338         static struct regulator_init_data max77663_regulator_idata_##_id = {   \
339                 .supply_regulator = _supply_reg,                        \
340                 .constraints = {                                        \
341                         .name = max77663_rails(_id),                    \
342                         .min_uV = _min_uV,                              \
343                         .max_uV = _max_uV,                              \
344                         .valid_modes_mask = (REGULATOR_MODE_NORMAL |    \
345                                              REGULATOR_MODE_STANDBY),   \
346                         .valid_ops_mask = (REGULATOR_CHANGE_MODE |      \
347                                            REGULATOR_CHANGE_STATUS |    \
348                                            REGULATOR_CHANGE_VOLTAGE),   \
349                         .always_on = _always_on,                        \
350                         .boot_on = _boot_on,                            \
351                         .apply_uV = _apply_uV,                          \
352                 },                                                      \
353                 .num_consumer_supplies =                                \
354                         ARRAY_SIZE(max77663_##_id##_supply),            \
355                 .consumer_supplies = max77663_##_id##_supply,           \
356         };                                                              \
357 static struct max77663_regulator_platform_data max77663_regulator_pdata_##_id =\
358 {                                                                       \
359                 .reg_init_data = &max77663_regulator_idata_##_id,       \
360                 .id = MAX77663_REGULATOR_ID_##_rid,                     \
361                 .fps_src = _fps_src,                                    \
362                 .fps_pu_period = _fps_pu_period,                        \
363                 .fps_pd_period = _fps_pd_period,                        \
364                 .fps_cfgs = max77663_fps_cfgs,                          \
365                 .flags = _flags,                                        \
366         }
367
368 MAX77663_PDATA_INIT(SD0, sd0,  900000, 1400000, tps65090_rails(DCDC3), 1, 1, 0,
369                     FPS_SRC_1, -1, -1, SD_FSRADE_DISABLE);
370
371 MAX77663_PDATA_INIT(SD1, sd1,  1200000, 1200000, tps65090_rails(DCDC3), 1, 1, 1,
372                     FPS_SRC_1, -1, -1, SD_FSRADE_DISABLE);
373
374 MAX77663_PDATA_INIT(SD2, sd2,  1800000, 1800000, tps65090_rails(DCDC3), 1, 1, 1,
375                     FPS_SRC_0, -1, -1, 0);
376
377 MAX77663_PDATA_INIT(SD3, sd3,  2850000, 2850000, tps65090_rails(DCDC3), 1, 1, 1,
378                     FPS_SRC_NONE, -1, -1, 0);
379
380 MAX77663_PDATA_INIT(LDO0, ldo0, 1050000, 1050000, max77663_rails(sd2), 1, 1, 1,
381                     FPS_SRC_1, -1, -1, 0);
382
383 MAX77663_PDATA_INIT(LDO1, ldo1, 1050000, 1050000, max77663_rails(sd2), 0, 0, 1,
384                     FPS_SRC_NONE, -1, -1, 0);
385
386 MAX77663_PDATA_INIT(LDO2, ldo2, 2850000, 2850000, tps65090_rails(DCDC2), 1, 1,
387                     1, FPS_SRC_1, -1, -1, 0);
388
389 MAX77663_PDATA_INIT(LDO3, ldo3, 1050000, 1050000, max77663_rails(sd2), 1, 1, 1,
390                     FPS_SRC_NONE, -1, -1, 0);
391
392 MAX77663_PDATA_INIT(LDO4, ldo4, 1100000, 1100000, tps65090_rails(DCDC2), 1, 1,
393                     1, FPS_SRC_NONE, -1, -1, LDO4_EN_TRACKING);
394
395 MAX77663_PDATA_INIT(LDO5, ldo5, 1200000, 1200000, max77663_rails(sd2), 0, 1, 1,
396                     FPS_SRC_NONE, -1, -1, 0);
397
398 MAX77663_PDATA_INIT(LDO6, ldo6, 1800000, 3300000, tps65090_rails(DCDC2), 0, 0, 0,
399                     FPS_SRC_NONE, -1, -1, 0);
400
401 MAX77663_PDATA_INIT(LDO7, ldo7, 2800000, 2800000, tps65090_rails(DCDC2), 0, 0, 1,
402                     FPS_SRC_NONE, -1, -1, 0);
403
404 MAX77663_PDATA_INIT(LDO8, ldo8, 2800000, 2800000, tps65090_rails(DCDC2), 0, 1, 1,
405                     FPS_SRC_1, -1, -1, 0);
406
407 #define MAX77663_REG(_id, _data) (&max77663_regulator_pdata_##_data)
408
409 static struct max77663_regulator_platform_data *max77663_reg_pdata[] = {
410         MAX77663_REG(SD0, sd0),
411         MAX77663_REG(SD1, sd1),
412         MAX77663_REG(SD2, sd2),
413         MAX77663_REG(SD3, sd3),
414         MAX77663_REG(LDO0, ldo0),
415         MAX77663_REG(LDO1, ldo1),
416         MAX77663_REG(LDO2, ldo2),
417         MAX77663_REG(LDO3, ldo3),
418         MAX77663_REG(LDO4, ldo4),
419         MAX77663_REG(LDO5, ldo5),
420         MAX77663_REG(LDO6, ldo6),
421         MAX77663_REG(LDO7, ldo7),
422         MAX77663_REG(LDO8, ldo8),
423 };
424
425 static struct max77663_gpio_config max77663_gpio_cfgs[] = {
426         {
427                 .gpio = MAX77663_GPIO0,
428                 .dir = GPIO_DIR_OUT,
429                 .dout = GPIO_DOUT_LOW,
430                 .out_drv = GPIO_OUT_DRV_PUSH_PULL,
431                 .alternate = GPIO_ALT_DISABLE,
432         },
433         {
434                 .gpio = MAX77663_GPIO1,
435                 .dir = GPIO_DIR_IN,
436                 .dout = GPIO_DOUT_HIGH,
437                 .out_drv = GPIO_OUT_DRV_OPEN_DRAIN,
438                 .pull_up = GPIO_PU_ENABLE,
439                 .alternate = GPIO_ALT_DISABLE,
440         },
441         {
442                 .gpio = MAX77663_GPIO2,
443                 .dir = GPIO_DIR_OUT,
444                 .dout = GPIO_DOUT_HIGH,
445                 .out_drv = GPIO_OUT_DRV_OPEN_DRAIN,
446                 .pull_up = GPIO_PU_ENABLE,
447                 .alternate = GPIO_ALT_DISABLE,
448         },
449         {
450                 .gpio = MAX77663_GPIO3,
451                 .dir = GPIO_DIR_OUT,
452                 .dout = GPIO_DOUT_HIGH,
453                 .out_drv = GPIO_OUT_DRV_OPEN_DRAIN,
454                 .pull_up = GPIO_PU_ENABLE,
455                 .alternate = GPIO_ALT_DISABLE,
456         },
457         {
458                 .gpio = MAX77663_GPIO4,
459                 .dir = GPIO_DIR_OUT,
460                 .dout = GPIO_DOUT_HIGH,
461                 .out_drv = GPIO_OUT_DRV_PUSH_PULL,
462                 .alternate = GPIO_ALT_ENABLE,
463         },
464         {
465                 .gpio = MAX77663_GPIO5,
466                 .dir = GPIO_DIR_OUT,
467                 .dout = GPIO_DOUT_LOW,
468                 .out_drv = GPIO_OUT_DRV_PUSH_PULL,
469                 .alternate = GPIO_ALT_DISABLE,
470         },
471         {
472                 .gpio = MAX77663_GPIO6,
473                 .dir = GPIO_DIR_OUT,
474                 .dout = GPIO_DOUT_LOW,
475                 .out_drv = GPIO_OUT_DRV_OPEN_DRAIN,
476                 .alternate = GPIO_ALT_DISABLE,
477         },
478         {
479                 .gpio = MAX77663_GPIO7,
480                 .dir = GPIO_DIR_OUT,
481                 .dout = GPIO_DOUT_LOW,
482                 .out_drv = GPIO_OUT_DRV_OPEN_DRAIN,
483                 .alternate = GPIO_ALT_DISABLE,
484         },
485 };
486
487 static struct max77663_platform_data max77663_pdata = {
488         .irq_base       = MAX77663_IRQ_BASE,
489         .gpio_base      = MAX77663_GPIO_BASE,
490
491         .num_gpio_cfgs  = ARRAY_SIZE(max77663_gpio_cfgs),
492         .gpio_cfgs      = max77663_gpio_cfgs,
493
494         .regulator_pdata = max77663_reg_pdata,
495         .num_regulator_pdata = ARRAY_SIZE(max77663_reg_pdata),
496
497         .rtc_i2c_addr   = 0x68,
498
499         .use_power_off  = false,
500 };
501
502 static struct i2c_board_info __initdata max77663_regulators[] = {
503         {
504                 /* The I2C address was determined by OTP factory setting */
505                 I2C_BOARD_INFO("max77663", 0x3c),
506                 .irq            = INT_EXTERNAL_PMU,
507                 .platform_data  = &max77663_pdata,
508         },
509 };
510
511 static struct i2c_board_info __initdata tps65090_regulators[] = {
512         {
513                 I2C_BOARD_INFO("tps65090", 0x48),
514                 .platform_data  = &tps65090_pdata,
515         },
516 };
517
518 /************************ Palmas based regulator ****************/
519 static struct regulator_consumer_supply palmas_smps12_supply[] = {
520         REGULATOR_SUPPLY("vddio_ddr3l", NULL),
521         REGULATOR_SUPPLY("vcore_ddr3l", NULL),
522         REGULATOR_SUPPLY("vref2_ddr3l", NULL),
523 };
524
525 #define palmas_smps3_supply max77663_sd2_supply
526 #define palmas_smps45_supply max77663_sd0_supply
527 #define palmas_smps457_supply max77663_sd0_supply
528
529 static struct regulator_consumer_supply palmas_smps8_supply[] = {
530         REGULATOR_SUPPLY("avdd_plla_p_c", NULL),
531         REGULATOR_SUPPLY("avdd_pllm", NULL),
532         REGULATOR_SUPPLY("avdd_pllu", NULL),
533         REGULATOR_SUPPLY("avdd_pllx", NULL),
534         REGULATOR_SUPPLY("vdd_ddr_hs", NULL),
535         REGULATOR_SUPPLY("avdd_plle", NULL),
536         REGULATOR_SUPPLY("avdd_csi_dsi_pll", "tegradc.0"),
537         REGULATOR_SUPPLY("avdd_csi_dsi_pll", "tegradc.1"),
538         REGULATOR_SUPPLY("avdd_csi_dsi_pll", "vi"),
539         REGULATOR_SUPPLY("avdd_hdmi_pll", "tegradc.1"),
540         REGULATOR_SUPPLY("avdd_usb_pll", "tegra-ehci.2"),
541         REGULATOR_SUPPLY("avddio_usb", "tegra-ehci.2"),
542         REGULATOR_SUPPLY("avddio_usb", "tegra-xhci"),
543         REGULATOR_SUPPLY("avdd_usb_pll", "tegra-xhci"),
544 };
545
546 static struct regulator_consumer_supply palmas_smps8_config2_supply[] = {
547         REGULATOR_SUPPLY("avdd_plla_p_c", NULL),
548         REGULATOR_SUPPLY("avdd_pllm", NULL),
549         REGULATOR_SUPPLY("avdd_pllu", NULL),
550         REGULATOR_SUPPLY("avdd_pllx", NULL),
551         REGULATOR_SUPPLY("vdd_ddr_hs", NULL),
552         REGULATOR_SUPPLY("avdd_plle", NULL),
553         REGULATOR_SUPPLY("avdd_csi_dsi_pll", "tegradc.0"),
554         REGULATOR_SUPPLY("avdd_csi_dsi_pll", "tegradc.1"),
555         REGULATOR_SUPPLY("avdd_csi_dsi_pll", "vi"),
556 };
557
558 static struct regulator_consumer_supply palmas_smps9_supply[] = {
559         REGULATOR_SUPPLY("vddio_sd_slot", "sdhci-tegra.3"),
560 };
561
562 #define palmas_ldo1_supply max77663_ldo7_supply
563
564 static struct regulator_consumer_supply palmas_ldo1_config2_supply[] = {
565         REGULATOR_SUPPLY("avddio_usb", "tegra-ehci.2"),
566         REGULATOR_SUPPLY("avddio_usb", "tegra-xhci"),
567 };
568
569 #define palmas_ldo2_supply max77663_ldo8_supply
570
571 /* FIXME!! Put the device address of camera */
572 static struct regulator_consumer_supply palmas_ldo2_config2_supply[] = {
573         REGULATOR_SUPPLY("avdd_cam1", NULL),
574         REGULATOR_SUPPLY("avdd_2v8_cam_af", NULL),
575         REGULATOR_SUPPLY("avdd_cam2", NULL),
576         REGULATOR_SUPPLY("vana", "2-0036"),
577         REGULATOR_SUPPLY("vana", "2-0010"),
578         REGULATOR_SUPPLY("vana_imx132", "2-0036"),
579         REGULATOR_SUPPLY("avdd", "2-0010"),
580 };
581
582 #define palmas_ldo3_supply max77663_ldo5_supply
583
584 static struct regulator_consumer_supply palmas_ldo4_supply[] = {
585         REGULATOR_SUPPLY("vpp_fuse", NULL),
586 };
587
588 static struct regulator_consumer_supply palmas_ldo4_config2_supply[] = {
589         REGULATOR_SUPPLY("vpp_fuse", NULL),
590         REGULATOR_SUPPLY("avdd_usb_pll", "tegra-ehci.2"),
591         REGULATOR_SUPPLY("avdd_usb_pll", "tegra-xhci"),
592 };
593
594 #define palmas_ldo6_supply max77663_ldo2_supply
595
596 static struct regulator_consumer_supply palmas_ldo7_supply[] = {
597         REGULATOR_SUPPLY("vdd_af_cam1", NULL),
598         REGULATOR_SUPPLY("vdd", "2-000e"),
599 };
600
601 #define palmas_ldo8_supply max77663_ldo4_supply
602 #define palmas_ldo9_supply max77663_ldo6_supply
603
604 static struct regulator_consumer_supply palmas_ldoln_supply[] = {
605         REGULATOR_SUPPLY("hvdd_usb", "tegra-ehci.2"),
606         REGULATOR_SUPPLY("hvdd_usb", "tegra-xhci"),
607 };
608
609 static struct regulator_consumer_supply palmas_ldoln_fab05_supply[] = {
610         REGULATOR_SUPPLY("avdd_hdmi", "tegradc.1"),
611 };
612
613 static struct regulator_consumer_supply palmas_ldousb_supply[] = {
614         REGULATOR_SUPPLY("avdd_usb", "tegra-udc.0"),
615         REGULATOR_SUPPLY("avdd_usb", "tegra-ehci.0"),
616         REGULATOR_SUPPLY("avdd_usb", "tegra-ehci.1"),
617         REGULATOR_SUPPLY("avdd_usb", "tegra-ehci.2"),
618         REGULATOR_SUPPLY("avdd_hdmi", "tegradc.1"),
619 };
620
621 static struct regulator_consumer_supply palmas_ldousb_fab05_supply[] = {
622         REGULATOR_SUPPLY("hvdd_usb", "tegra-ehci.2"),
623         REGULATOR_SUPPLY("hvdd_usb", "tegra-xhci"),
624         REGULATOR_SUPPLY("avdd_usb", "tegra-udc.0"),
625         REGULATOR_SUPPLY("avdd_usb", "tegra-ehci.0"),
626         REGULATOR_SUPPLY("avdd_usb", "tegra-ehci.1"),
627         REGULATOR_SUPPLY("avdd_usb", "tegra-ehci.2"),
628 };
629
630 static struct regulator_consumer_supply palmas_regen1_supply[] = {
631 };
632
633 static struct regulator_consumer_supply palmas_regen2_supply[] = {
634 };
635
636 PALMAS_REGS_PDATA(smps12, 1350,  1350, tps65090_rails(DCDC3), 1, 1, 0, NORMAL,
637         0, 0, 0, 0, 0);
638 PALMAS_REGS_PDATA(smps3, 1800,  1800, tps65090_rails(DCDC3), 0, 0, 0, NORMAL,
639         0, 0, 0, 0, 0);
640 PALMAS_REGS_PDATA(smps45, 900,  1400, tps65090_rails(DCDC2), 1, 1, 0, NORMAL,
641         0, PALMAS_EXT_CONTROL_NSLEEP, 0, 0, 0);
642 PALMAS_REGS_PDATA(smps457, 900,  1400, tps65090_rails(DCDC2), 1, 1, 0, NORMAL,
643         0, PALMAS_EXT_CONTROL_NSLEEP, 0, 0, 0);
644 PALMAS_REGS_PDATA(smps8, 1050,  1050, tps65090_rails(DCDC2), 0, 1, 1, NORMAL,
645         0, PALMAS_EXT_CONTROL_NSLEEP, 0, 0, 0);
646 PALMAS_REGS_PDATA(smps8_config2, 1050,  1050, tps65090_rails(DCDC2), 0, 1, 1,
647         NORMAL, 0, PALMAS_EXT_CONTROL_NSLEEP, 0, 0, 0);
648 PALMAS_REGS_PDATA(smps9, 2800,  2800, tps65090_rails(DCDC2), 1, 0, 0, NORMAL,
649         0, 0, 0, 0, 0);
650 PALMAS_REGS_PDATA(ldo1, 2800,  2800, tps65090_rails(DCDC2), 0, 0, 1, 0,
651         0, 0, 0, 0, 0);
652 PALMAS_REGS_PDATA(ldo1_config2, 1200,  1200, tps65090_rails(DCDC2), 0, 0, 1, 0,
653         1, 0, 0, 0, 0);
654 PALMAS_REGS_PDATA(ldo2, 2800,  2800, tps65090_rails(DCDC2), 0, 0, 1, 0,
655         0, 0, 0, 0, 0);
656 PALMAS_REGS_PDATA(ldo2_config2, 2800,  2800, tps65090_rails(DCDC2), 0, 0, 1, 0,
657         0, 0, 0, 0, 0);
658 PALMAS_REGS_PDATA(ldo3, 1200,  1200, palmas_rails(smps3), 0, 0, 1, 0,
659         0, 0, 0, 0, 0);
660 PALMAS_REGS_PDATA(ldo4_config2, 1200,  1200, tps65090_rails(DCDC2), 0, 0, 1, 0,
661         0, 0, 0, 0, 0);
662 PALMAS_REGS_PDATA(ldo4, 1800,  1800, tps65090_rails(DCDC2), 0, 0, 0, 0,
663         0, 0, 0, 0, 0);
664 PALMAS_REGS_PDATA(ldo6, 2850,  2850, tps65090_rails(DCDC2), 0, 0, 1, 0,
665         0, 0, 0, 0, 0);
666 PALMAS_REGS_PDATA(ldo7, 2800,  2800, tps65090_rails(DCDC2), 0, 0, 1, 0,
667         0, 0, 0, 0, 0);
668 PALMAS_REGS_PDATA(ldo8, 900,  900, tps65090_rails(DCDC3), 1, 1, 1, 0,
669         0, 0, 0, 0, 0);
670 PALMAS_REGS_PDATA(ldo9, 1800,  3300, palmas_rails(smps9), 0, 0, 1, 0,
671         1, 0, 0, 0, 0);
672 PALMAS_REGS_PDATA(ldoln, 3300, 3300, tps65090_rails(DCDC1), 0, 0, 1, 0,
673         0, 0, 0, 0, 0);
674 PALMAS_REGS_PDATA(ldoln_fab05, 3300, 3300, tps65090_rails(DCDC1), 0, 0, 1, 0,
675         0, 0, 0, 0, 0);
676 PALMAS_REGS_PDATA(ldousb, 3300,  3300, tps65090_rails(DCDC1), 0, 0, 1, 0,
677         0, 0, 0, 0, 0);
678 PALMAS_REGS_PDATA(ldousb_fab05, 3300,  3300, tps65090_rails(DCDC1), 0, 0, 1, 0,
679         0, 0, 0, 0, 0);
680 PALMAS_REGS_PDATA(regen1, 3300,  3300, NULL, 1, 1, 0, 0,
681         0, 0, 0, 0, 0);
682 PALMAS_REGS_PDATA(regen2, 5000,  5000, NULL, 1, 1, 0, 0,
683         0, 0, 0, 0, 0);
684
685 #define PALMAS_REG_PDATA(_sname) &reg_idata_##_sname
686
687 static struct regulator_init_data *dalmore_e1611_reg_data[PALMAS_NUM_REGS] = {
688         PALMAS_REG_PDATA(smps12),
689         NULL,
690         PALMAS_REG_PDATA(smps3),
691         PALMAS_REG_PDATA(smps45),
692         PALMAS_REG_PDATA(smps457),
693         NULL,
694         NULL,
695         PALMAS_REG_PDATA(smps8),
696         PALMAS_REG_PDATA(smps9),
697         NULL,
698         NULL,
699         PALMAS_REG_PDATA(ldo1),
700         PALMAS_REG_PDATA(ldo2),
701         PALMAS_REG_PDATA(ldo3),
702         PALMAS_REG_PDATA(ldo4),
703         NULL,
704         PALMAS_REG_PDATA(ldo6),
705         PALMAS_REG_PDATA(ldo7),
706         PALMAS_REG_PDATA(ldo8),
707         PALMAS_REG_PDATA(ldo9),
708         NULL,
709         NULL,
710         NULL,
711         NULL,
712         NULL,
713         PALMAS_REG_PDATA(ldoln),
714         PALMAS_REG_PDATA(ldousb),
715         PALMAS_REG_PDATA(regen1),
716         PALMAS_REG_PDATA(regen2),
717         NULL,
718         NULL,
719         NULL,
720 };
721
722 #define PALMAS_REG_INIT_DATA(_sname) &reg_init_data_##_sname
723 static struct palmas_reg_init *dalmore_e1611_reg_init[PALMAS_NUM_REGS] = {
724         PALMAS_REG_INIT_DATA(smps12),
725         NULL,
726         PALMAS_REG_INIT_DATA(smps3),
727         PALMAS_REG_INIT_DATA(smps45),
728         PALMAS_REG_INIT_DATA(smps457),
729         NULL,
730         NULL,
731         PALMAS_REG_INIT_DATA(smps8),
732         PALMAS_REG_INIT_DATA(smps9),
733         NULL,
734         NULL,
735         PALMAS_REG_INIT_DATA(ldo1),
736         PALMAS_REG_INIT_DATA(ldo2),
737         PALMAS_REG_INIT_DATA(ldo3),
738         PALMAS_REG_INIT_DATA(ldo4),
739         NULL,
740         PALMAS_REG_INIT_DATA(ldo6),
741         PALMAS_REG_INIT_DATA(ldo7),
742         PALMAS_REG_INIT_DATA(ldo8),
743         PALMAS_REG_INIT_DATA(ldo9),
744         NULL,
745         NULL,
746         NULL,
747         NULL,
748         NULL,
749         PALMAS_REG_INIT_DATA(ldoln),
750         PALMAS_REG_INIT_DATA(ldousb),
751         PALMAS_REG_INIT_DATA(regen1),
752         PALMAS_REG_INIT_DATA(regen2),
753         NULL,
754         NULL,
755         NULL,
756 };
757
758 static struct palmas_pmic_platform_data pmic_platform = {
759         .disable_smps10_boost_suspend = false,
760 };
761
762 static struct palmas_rtc_platform_data rtc_platform = {
763         .backup_battery_chargeable = true,
764         .backup_battery_charge_high_current = true,
765 };
766
767 static struct palmas_pinctrl_config palmas_pincfg[] = {
768         PALMAS_PINMUX("powergood", "powergood", NULL, NULL),
769         PALMAS_PINMUX("vac", "vac", NULL, NULL),
770         PALMAS_PINMUX("gpio0", "gpio", NULL, NULL),
771         PALMAS_PINMUX("gpio1", "gpio", NULL, NULL),
772         PALMAS_PINMUX("gpio2", "gpio", NULL, NULL),
773         PALMAS_PINMUX("gpio3", "gpio", NULL, NULL),
774         PALMAS_PINMUX("gpio4", "gpio", NULL, NULL),
775         PALMAS_PINMUX("gpio5", "gpio", NULL, NULL),
776         PALMAS_PINMUX("gpio6", "gpio", NULL, NULL),
777         PALMAS_PINMUX("gpio7", "gpio", NULL, NULL),
778 };
779
780 static struct palmas_pinctrl_platform_data palmas_pinctrl_pdata = {
781         .pincfg = palmas_pincfg,
782         .num_pinctrl = ARRAY_SIZE(palmas_pincfg),
783         .dvfs1_enable = true,
784         .dvfs2_enable = false,
785 };
786
787 static struct palmas_platform_data palmas_pdata = {
788         .gpio_base = PALMAS_TEGRA_GPIO_BASE,
789         .irq_base = PALMAS_TEGRA_IRQ_BASE,
790         .pmic_pdata = &pmic_platform,
791         .rtc_pdata = &rtc_platform,
792         .pinctrl_pdata = &palmas_pinctrl_pdata,
793         #ifndef CONFIG_ANDROID
794         .long_press_delay = PALMAS_LONG_PRESS_KEY_TIME_8SECONDS,
795         #else
796         /* Retaining default value, 12 Seconds */
797         .long_press_delay = PALMAS_LONG_PRESS_KEY_TIME_DEFAULT,
798         #endif
799 };
800
801 static struct i2c_board_info palma_device[] = {
802         {
803                 I2C_BOARD_INFO("tps65913", 0x58),
804                 .irq            = INT_EXTERNAL_PMU,
805                 .platform_data  = &palmas_pdata,
806         },
807 };
808
809 /* EN_AVDD_USB_HDMI From PMU GP1 */
810 static struct regulator_consumer_supply fixed_reg_avdd_usb_hdmi_supply[] = {
811         REGULATOR_SUPPLY("avdd_hdmi", "tegradc.1"),
812         REGULATOR_SUPPLY("avdd_usb", "tegra-udc.0"),
813         REGULATOR_SUPPLY("avdd_usb", "tegra-ehci.0"),
814         REGULATOR_SUPPLY("avdd_usb", "tegra-ehci.1"),
815         REGULATOR_SUPPLY("avdd_usb", "tegra-ehci.2"),
816         REGULATOR_SUPPLY("hvdd_usb", "tegra-ehci.2"),
817 };
818
819 /* EN_CAM_1v8 From PMU GP5 */
820 static struct regulator_consumer_supply fixed_reg_en_1v8_cam_supply[] = {
821         REGULATOR_SUPPLY("vi2c", "2-0030"),
822         REGULATOR_SUPPLY("vif", "2-0036"),
823         REGULATOR_SUPPLY("dovdd", "2-0010"),
824         REGULATOR_SUPPLY("dvdd", "2-0010"),
825         REGULATOR_SUPPLY("vdd_i2c", "2-000e"),
826 };
827
828 /* EN_CAM_1v8 on e1611 From PMU GP6 */
829 static struct regulator_consumer_supply fixed_reg_en_1v8_cam_e1611_supply[] = {
830         REGULATOR_SUPPLY("vi2c", "2-0030"),
831         REGULATOR_SUPPLY("vif", "2-0036"),
832         REGULATOR_SUPPLY("dovdd", "2-0010"),
833         REGULATOR_SUPPLY("dvdd", "2-0010"),
834         REGULATOR_SUPPLY("vdd_i2c", "2-000e"),
835 };
836
837 static struct regulator_consumer_supply fixed_reg_vdd_hdmi_5v0_supply[] = {
838         REGULATOR_SUPPLY("vdd_hdmi_5v0", "tegradc.1"),
839 };
840
841 static struct regulator_consumer_supply fixed_reg_lcd_bl_en_supply[] = {
842         REGULATOR_SUPPLY("vdd_lcd_bl_en", NULL),
843 };
844
845 /* EN_USB1_VBUS From TEGRA GPIO PN4 PR3(T30) */
846 static struct regulator_consumer_supply fixed_reg_usb1_vbus_supply[] = {
847         REGULATOR_SUPPLY("usb_vbus", "tegra-ehci.0"),
848         REGULATOR_SUPPLY("usb_vbus", "tegra-otg"),
849 };
850
851 /* EN_3V3_FUSE From TEGRA GPIO PX4 */
852 static struct regulator_consumer_supply fixed_reg_vpp_fuse_supply[] = {
853         REGULATOR_SUPPLY("vpp_fuse", NULL),
854 };
855
856 /* EN_USB3_VBUS From TEGRA GPIO PM5 */
857 static struct regulator_consumer_supply fixed_reg_usb3_vbus_supply[] = {
858         REGULATOR_SUPPLY("usb_vbus", "tegra-ehci.2"),
859         REGULATOR_SUPPLY("usb_vbus", "tegra-xhci"),
860 };
861
862 /* EN_1V8_TS From TEGRA_GPIO_PH5 */
863 static struct regulator_consumer_supply fixed_reg_dvdd_ts_supply[] = {
864         REGULATOR_SUPPLY("dvdd", "spi3.2"),
865 };
866
867 /* EN_AVDD_HDMI_PLL From TEGRA_GPIO_PO1 */
868 static struct regulator_consumer_supply fixed_reg_avdd_hdmi_pll_supply[] = {
869         REGULATOR_SUPPLY("avdd_hdmi_pll", "tegradc.1"),
870 };
871
872 /* Macro for defining fixed regulator sub device data */
873 #define FIXED_SUPPLY(_name) "fixed_reg_"#_name
874 #define FIXED_REG(_id, _var, _name, _in_supply, _always_on, _boot_on,   \
875         _gpio_nr, _open_drain, _active_high, _boot_state, _millivolts)  \
876         static struct regulator_init_data ri_data_##_var =              \
877         {                                                               \
878                 .supply_regulator = _in_supply,                         \
879                 .num_consumer_supplies =                                \
880                         ARRAY_SIZE(fixed_reg_##_name##_supply),         \
881                 .consumer_supplies = fixed_reg_##_name##_supply,        \
882                 .constraints = {                                        \
883                         .valid_modes_mask = (REGULATOR_MODE_NORMAL |    \
884                                         REGULATOR_MODE_STANDBY),        \
885                         .valid_ops_mask = (REGULATOR_CHANGE_MODE |      \
886                                         REGULATOR_CHANGE_STATUS |       \
887                                         REGULATOR_CHANGE_VOLTAGE),      \
888                         .always_on = _always_on,                        \
889                         .boot_on = _boot_on,                            \
890                 },                                                      \
891         };                                                              \
892         static struct fixed_voltage_config fixed_reg_##_var##_pdata =   \
893         {                                                               \
894                 .supply_name = FIXED_SUPPLY(_name),                     \
895                 .microvolts = _millivolts * 1000,                       \
896                 .gpio = _gpio_nr,                                       \
897                 .gpio_is_open_drain = _open_drain,                      \
898                 .enable_high = _active_high,                            \
899                 .enabled_at_boot = _boot_state,                         \
900                 .init_data = &ri_data_##_var,                           \
901         };                                                              \
902         static struct platform_device fixed_reg_##_var##_dev = {        \
903                 .name = "reg-fixed-voltage",                            \
904                 .id = _id,                                              \
905                 .dev = {                                                \
906                         .platform_data = &fixed_reg_##_var##_pdata,     \
907                 },                                                      \
908         }
909
910 FIXED_REG(1,    avdd_usb_hdmi,  avdd_usb_hdmi,
911         tps65090_rails(DCDC2),  0,      0,
912         MAX77663_GPIO_BASE + MAX77663_GPIO1,    true,   true,   1,      3300);
913
914 FIXED_REG(2,    en_1v8_cam,     en_1v8_cam,
915         max77663_rails(sd2),    0,      0,
916         MAX77663_GPIO_BASE + MAX77663_GPIO5,    false,  true,   0,      1800);
917
918 FIXED_REG(3,    vdd_hdmi_5v0,   vdd_hdmi_5v0,
919         tps65090_rails(DCDC1),  0,      0,
920         TEGRA_GPIO_PK1, false,  true,   0,      5000);
921
922 FIXED_REG(4,    vpp_fuse,       vpp_fuse,
923         max77663_rails(sd2),    0,      0,
924         TEGRA_GPIO_PX4, false,  true,   0,      3300);
925
926 FIXED_REG(5,    usb1_vbus,      usb1_vbus,
927         tps65090_rails(DCDC1),  0,      0,
928         TEGRA_GPIO_PN4, true,   true,   0,      5000);
929
930 FIXED_REG(6,    usb3_vbus,      usb3_vbus,
931         tps65090_rails(DCDC1),  0,      0,
932         TEGRA_GPIO_PK6, true,   true,   0,      5000);
933
934 FIXED_REG(7,    en_1v8_cam_e1611,       en_1v8_cam_e1611,
935         palmas_rails(smps3),    0,      0,
936         PALMAS_TEGRA_GPIO_BASE + PALMAS_GPIO6,  false,  true,   0,      1800);
937
938 FIXED_REG(8,    dvdd_ts,        dvdd_ts,
939         palmas_rails(smps3),    0,      0,
940         TEGRA_GPIO_PH5, false,  false,  1,      1800);
941
942 FIXED_REG(9,    lcd_bl_en,      lcd_bl_en,
943         NULL,   0,      0,
944         TEGRA_GPIO_PH2, false,  true,   0,      5000);
945
946 FIXED_REG(10,   avdd_hdmi_pll,  avdd_hdmi_pll,
947         palmas_rails(ldo3),     0,      0,
948         TEGRA_GPIO_PO1, false,  true,   1,      1200);
949 /*
950  * Creating the fixed regulator device tables
951  */
952
953 #define ADD_FIXED_REG(_name)    (&fixed_reg_##_name##_dev)
954
955 #define DALMORE_COMMON_FIXED_REG                \
956         ADD_FIXED_REG(usb1_vbus),               \
957         ADD_FIXED_REG(usb3_vbus),               \
958         ADD_FIXED_REG(vdd_hdmi_5v0),            \
959         ADD_FIXED_REG(lcd_bl_en),
960
961 #define E1612_FIXED_REG                         \
962         ADD_FIXED_REG(avdd_usb_hdmi),           \
963         ADD_FIXED_REG(en_1v8_cam),              \
964         ADD_FIXED_REG(vpp_fuse),                \
965
966 #define E1611_FIXED_REG                         \
967         ADD_FIXED_REG(en_1v8_cam_e1611), \
968         ADD_FIXED_REG(dvdd_ts),
969
970 #define DALMORE_POWER_CONFIG_2                  \
971         ADD_FIXED_REG(avdd_hdmi_pll),
972
973 /* Gpio switch regulator platform data for Dalmore E1611 */
974 static struct platform_device *fixed_reg_devs_e1611_a00[] = {
975         DALMORE_COMMON_FIXED_REG
976         E1611_FIXED_REG
977 };
978
979 /* Gpio switch regulator platform data for Dalmore E1612 */
980 static struct platform_device *fixed_reg_devs_e1612_a00[] = {
981         DALMORE_COMMON_FIXED_REG
982         E1612_FIXED_REG
983 };
984
985 static struct platform_device *fixed_reg_devs_dalmore_config2[] = {
986         DALMORE_POWER_CONFIG_2
987 };
988
989 static void set_dalmore_power_fab05(void)
990 {
991         dalmore_e1611_reg_data[PALMAS_REG_LDOLN] =
992                                 PALMAS_REG_PDATA(ldoln_fab05);
993         dalmore_e1611_reg_init[PALMAS_REG_LDOLN] =
994                                 PALMAS_REG_INIT_DATA(ldoln_fab05);
995         dalmore_e1611_reg_data[PALMAS_REG_LDOUSB] =
996                                 PALMAS_REG_PDATA(ldousb_fab05);
997         dalmore_e1611_reg_init[PALMAS_REG_LDOUSB] =
998                                 PALMAS_REG_INIT_DATA(ldousb_fab05);
999         return;
1000 }
1001
1002 static void set_dalmore_power_config2(void)
1003 {
1004         dalmore_e1611_reg_data[PALMAS_REG_SMPS8] =
1005                                 PALMAS_REG_PDATA(smps8_config2);
1006         dalmore_e1611_reg_init[PALMAS_REG_SMPS8] =
1007                                 PALMAS_REG_INIT_DATA(smps8_config2);
1008         dalmore_e1611_reg_data[PALMAS_REG_LDO1] =
1009                                 PALMAS_REG_PDATA(ldo1_config2);
1010         dalmore_e1611_reg_init[PALMAS_REG_LDO1] =
1011                                 PALMAS_REG_INIT_DATA(ldo1_config2);
1012         dalmore_e1611_reg_data[PALMAS_REG_LDO2] =
1013                                 PALMAS_REG_PDATA(ldo2_config2);
1014         dalmore_e1611_reg_init[PALMAS_REG_LDO2] =
1015                                 PALMAS_REG_INIT_DATA(ldo2_config2);
1016         dalmore_e1611_reg_data[PALMAS_REG_LDO4] =
1017                                 PALMAS_REG_PDATA(ldo4_config2);
1018         dalmore_e1611_reg_init[PALMAS_REG_LDO4] =
1019                                 PALMAS_REG_INIT_DATA(ldo4_config2);
1020         return;
1021 }
1022
1023 int __init dalmore_palmas_regulator_init(void)
1024 {
1025         void __iomem *pmc = IO_ADDRESS(TEGRA_PMC_BASE);
1026         u32 pmc_ctrl;
1027         u8 power_config;
1028         struct board_info board_info;
1029         int i;
1030
1031         tegra_get_board_info(&board_info);
1032
1033         /* TPS65913: Normal state of INT request line is LOW.
1034          * configure the power management controller to trigger PMU
1035          * interrupts when HIGH.
1036          */
1037         pmc_ctrl = readl(pmc + PMC_CTRL);
1038         writel(pmc_ctrl | PMC_CTRL_INTR_LOW, pmc + PMC_CTRL);
1039
1040         /* Enable regulator full constraints */
1041         regulator_has_full_constraints();
1042
1043         reg_idata_ldo6.constraints.enable_time = 1000;
1044
1045         /* Tracking configuration */
1046         reg_init_data_ldo8.config_flags =
1047                         PALMAS_REGULATOR_CONFIG_TRACKING_ENABLE |
1048                         PALMAS_REGULATOR_CONFIG_SUSPEND_TRACKING_DISABLE;
1049
1050         power_config = get_power_config();
1051         if (board_info.fab == BOARD_FAB_A05) {
1052                 set_dalmore_power_config2();
1053                 set_dalmore_power_fab05();
1054         } else if (power_config & POWER_CONFIG2) {
1055                 set_dalmore_power_config2();
1056         }
1057
1058         for (i = 0; i < PALMAS_NUM_REGS ; i++) {
1059                 pmic_platform.reg_data[i] = dalmore_e1611_reg_data[i];
1060                 pmic_platform.reg_init[i] = dalmore_e1611_reg_init[i];
1061         }
1062
1063         i2c_register_board_info(4, palma_device,
1064                         ARRAY_SIZE(palma_device));
1065         return 0;
1066 }
1067
1068 static int ac_online(void)
1069 {
1070         return 1;
1071 }
1072
1073 static struct resource dalmore_pda_resources[] = {
1074         [0] = {
1075                 .name   = "ac",
1076         },
1077 };
1078
1079 static struct pda_power_pdata dalmore_pda_data = {
1080         .is_ac_online   = ac_online,
1081 };
1082
1083 static struct platform_device dalmore_pda_power_device = {
1084         .name           = "pda-power",
1085         .id             = -1,
1086         .resource       = dalmore_pda_resources,
1087         .num_resources  = ARRAY_SIZE(dalmore_pda_resources),
1088         .dev    = {
1089                 .platform_data  = &dalmore_pda_data,
1090         },
1091 };
1092
1093 static struct tegra_suspend_platform_data dalmore_suspend_data = {
1094         .cpu_timer      = 500,
1095         .cpu_off_timer  = 300,
1096         .suspend_mode   = TEGRA_SUSPEND_LP0,
1097         .core_timer     = 0x157e,
1098         .core_off_timer = 2000,
1099         .corereq_high   = true,
1100         .sysclkreq_high = true,
1101         .cpu_lp2_min_residency = 1000,
1102         .min_residency_crail = 20000,
1103 #ifdef CONFIG_TEGRA_LP1_LOW_COREVOLTAGE
1104         .lp1_lowvolt_support = false,
1105         .i2c_base_addr = 0,
1106         .pmuslave_addr = 0,
1107         .core_reg_addr = 0,
1108         .lp1_core_volt_low_cold = 0,
1109         .lp1_core_volt_low = 0,
1110         .lp1_core_volt_high = 0,
1111 #endif
1112         .usb_vbus_internal_wake = true,
1113         .usb_id_internal_wake = true,
1114 };
1115 #ifdef CONFIG_ARCH_TEGRA_HAS_CL_DVFS
1116 /* board parameters for cpu dfll */
1117 static struct tegra_cl_dvfs_cfg_param dalmore_cl_dvfs_param = {
1118         .sample_rate = 12500,
1119
1120         .force_mode = TEGRA_CL_DVFS_FORCE_FIXED,
1121         .cf = 10,
1122         .ci = 0,
1123         .cg = 2,
1124
1125         .droop_cut_value = 0xF,
1126         .droop_restore_ramp = 0x0,
1127         .scale_out_ramp = 0x0,
1128 };
1129 #endif
1130
1131 /* TPS51632: fixed 10mV steps from 600mV to 1400mV, with offset 0x23 */
1132 #define PMU_CPU_VDD_MAP_SIZE ((1400000 - 600000) / 10000 + 1)
1133 static struct voltage_reg_map pmu_cpu_vdd_map[PMU_CPU_VDD_MAP_SIZE];
1134 static inline void fill_reg_map(void)
1135 {
1136         int i;
1137         for (i = 0; i < PMU_CPU_VDD_MAP_SIZE; i++) {
1138                 pmu_cpu_vdd_map[i].reg_value = i + 0x23;
1139                 pmu_cpu_vdd_map[i].reg_uV = 600000 + 10000 * i;
1140         }
1141 }
1142
1143 #ifdef CONFIG_ARCH_TEGRA_HAS_CL_DVFS
1144 static struct tegra_cl_dvfs_platform_data dalmore_cl_dvfs_data = {
1145         .dfll_clk_name = "dfll_cpu",
1146         .pmu_if = TEGRA_CL_DVFS_PMU_I2C,
1147         .u.pmu_i2c = {
1148                 .fs_rate = 400000,
1149                 .slave_addr = 0x86,
1150                 .reg = 0x00,
1151         },
1152         .vdd_map = pmu_cpu_vdd_map,
1153         .vdd_map_size = PMU_CPU_VDD_MAP_SIZE,
1154
1155         .cfg_param = &dalmore_cl_dvfs_param,
1156 };
1157
1158 static int __init dalmore_cl_dvfs_init(void)
1159 {
1160         fill_reg_map();
1161         if (tegra_revision < TEGRA_REVISION_A02)
1162                 dalmore_cl_dvfs_data.flags = TEGRA_CL_DVFS_FLAGS_I2C_WAIT_QUIET;
1163         tegra_cl_dvfs_device.dev.platform_data = &dalmore_cl_dvfs_data;
1164         platform_device_register(&tegra_cl_dvfs_device);
1165
1166         return 0;
1167 }
1168 #endif
1169
1170 static int __init dalmore_max77663_regulator_init(void)
1171 {
1172         struct board_info board_info;
1173         void __iomem *pmc = IO_ADDRESS(TEGRA_PMC_BASE);
1174         u32 pmc_ctrl;
1175
1176         tegra_get_board_info(&board_info);
1177         if (board_info.fab < BOARD_FAB_A02)
1178                 max77663_regulator_pdata_ldo4.flags = 0;
1179
1180         /* configure the power management controller to trigger PMU
1181          * interrupts when low */
1182         pmc_ctrl = readl(pmc + PMC_CTRL);
1183         writel(pmc_ctrl | PMC_CTRL_INTR_LOW, pmc + PMC_CTRL);
1184
1185         i2c_register_board_info(4, max77663_regulators,
1186                                 ARRAY_SIZE(max77663_regulators));
1187
1188         return 0;
1189 }
1190
1191 static struct regulator_bulk_data dalmore_gps_regulator_supply[] = {
1192         [0] = {
1193                 .supply = "avdd",
1194         },
1195         [1] = {
1196                 .supply = "dvdd",
1197         },
1198 };
1199
1200 static struct regulator_userspace_consumer_data dalmore_gps_regulator_pdata = {
1201         .num_supplies   = ARRAY_SIZE(dalmore_gps_regulator_supply),
1202         .supplies       = dalmore_gps_regulator_supply,
1203 };
1204
1205 static struct platform_device dalmore_gps_regulator_device = {
1206         .name   = "reg-userspace-consumer",
1207         .id     = 2,
1208         .dev    = {
1209                         .platform_data = &dalmore_gps_regulator_pdata,
1210         },
1211 };
1212
1213 static int __init dalmore_fixed_regulator_init(void)
1214 {
1215         struct board_info board_info;
1216         u8 power_config;
1217
1218         if (!of_machine_is_compatible("nvidia,dalmore"))
1219                 return 0;
1220
1221         power_config = get_power_config();
1222         tegra_get_board_info(&board_info);
1223
1224         /* Fab05 and power-type2 have the same fixed regs */
1225         if (board_info.fab == BOARD_FAB_A05 || power_config & POWER_CONFIG2)
1226                 platform_add_devices(fixed_reg_devs_dalmore_config2,
1227                                 ARRAY_SIZE(fixed_reg_devs_dalmore_config2));
1228
1229         if (board_info.board_id == BOARD_E1611 ||
1230                 board_info.board_id == BOARD_P2454)
1231                 return platform_add_devices(fixed_reg_devs_e1611_a00,
1232                                 ARRAY_SIZE(fixed_reg_devs_e1611_a00));
1233         else
1234                 return platform_add_devices(fixed_reg_devs_e1612_a00,
1235                                 ARRAY_SIZE(fixed_reg_devs_e1612_a00));
1236 }
1237 subsys_initcall_sync(dalmore_fixed_regulator_init);
1238
1239 static void dalmore_tps65090_init(void)
1240 {
1241         int err;
1242
1243         err = gpio_request(TPS65090_CHARGER_INT, "CHARGER_INT");
1244         if (err < 0) {
1245                 pr_err("%s: gpio_request failed %d\n", __func__, err);
1246                 goto fail_init_irq;
1247         }
1248
1249         err = gpio_direction_input(TPS65090_CHARGER_INT);
1250         if (err < 0) {
1251                 pr_err("%s: gpio_direction_input failed %d\n", __func__, err);
1252                 goto fail_init_irq;
1253         }
1254
1255         tps65090_regulators[0].irq = gpio_to_irq(TPS65090_CHARGER_INT);
1256 fail_init_irq:
1257         i2c_register_board_info(4, tps65090_regulators,
1258                         ARRAY_SIZE(tps65090_regulators));
1259         return;
1260 }
1261
1262 int __init dalmore_regulator_init(void)
1263 {
1264         struct board_info board_info;
1265
1266         dalmore_tps65090_init();
1267 #ifdef CONFIG_ARCH_TEGRA_HAS_CL_DVFS
1268         dalmore_cl_dvfs_init();
1269 #endif
1270         tegra_get_board_info(&board_info);
1271         if (board_info.board_id == BOARD_E1611 ||
1272                 board_info.board_id == BOARD_P2454)
1273                 dalmore_palmas_regulator_init();
1274         else
1275                 dalmore_max77663_regulator_init();
1276
1277         platform_device_register(&dalmore_pda_power_device);
1278         platform_device_register(&dalmore_gps_regulator_device);
1279         return 0;
1280 }
1281
1282 int __init dalmore_suspend_init(void)
1283 {
1284         tegra_init_suspend(&dalmore_suspend_data);
1285         /* Enable dalmore USB wake for VBUS/ID without using PMIC */
1286         tegra_set_usb_vbus_internal_wake(
1287                 dalmore_suspend_data.usb_vbus_internal_wake);
1288         tegra_set_usb_id_internal_wake(
1289                 dalmore_suspend_data.usb_id_internal_wake);
1290         return 0;
1291 }
1292
1293 int __init dalmore_edp_init(void)
1294 {
1295         unsigned int regulator_mA;
1296
1297         regulator_mA = get_maximum_cpu_current_supported();
1298         if (!regulator_mA)
1299                 regulator_mA = 15000;
1300
1301         pr_info("%s: CPU regulator %d mA\n", __func__, regulator_mA);
1302         tegra_init_cpu_edp_limits(regulator_mA);
1303
1304         regulator_mA = get_maximum_core_current_supported();
1305         if (!regulator_mA)
1306                 regulator_mA = 4000;
1307
1308         pr_info("%s: core regulator %d mA\n", __func__, regulator_mA);
1309         tegra_init_core_edp_limits(regulator_mA);
1310
1311         return 0;
1312 }
1313
1314 static struct pid_thermal_gov_params soctherm_pid_params = {
1315         .max_err_temp = 9000,
1316         .max_err_gain = 1000,
1317
1318         .gain_p = 1000,
1319         .gain_d = 0,
1320
1321         .up_compensation = 20,
1322         .down_compensation = 20,
1323 };
1324
1325 static struct thermal_zone_params soctherm_tzp = {
1326         .governor_name = "pid_thermal_gov",
1327         .governor_params = &soctherm_pid_params,
1328 };
1329
1330 static struct tegra_tsensor_pmu_data tpdata_palmas = {
1331         .reset_tegra = 1,
1332         .pmu_16bit_ops = 0,
1333         .controller_type = 0,
1334         .pmu_i2c_addr = 0x58,
1335         .i2c_controller_id = 4,
1336         .poweroff_reg_addr = 0xa0,
1337         .poweroff_reg_data = 0x0,
1338 };
1339
1340 static struct tegra_tsensor_pmu_data tpdata_max77663 = {
1341         .reset_tegra = 1,
1342         .pmu_16bit_ops = 0,
1343         .controller_type = 0,
1344         .pmu_i2c_addr = 0x3c,
1345         .i2c_controller_id = 4,
1346         .poweroff_reg_addr = 0x41,
1347         .poweroff_reg_data = 0x80,
1348 };
1349
1350 static struct soctherm_platform_data dalmore_soctherm_data = {
1351         .therm = {
1352                 [THERM_CPU] = {
1353                         .zone_enable = true,
1354                         .passive_delay = 1000,
1355                         .hotspot_offset = 6000,
1356                         .num_trips = 3,
1357                         .trips = {
1358                                 {
1359                                         .cdev_type = "tegra-balanced",
1360                                         .trip_temp = 90000,
1361                                         .trip_type = THERMAL_TRIP_PASSIVE,
1362                                         .upper = THERMAL_NO_LIMIT,
1363                                         .lower = THERMAL_NO_LIMIT,
1364                                 },
1365                                 {
1366                                         .cdev_type = "tegra-heavy",
1367                                         .trip_temp = 100000,
1368                                         .trip_type = THERMAL_TRIP_HOT,
1369                                         .upper = THERMAL_NO_LIMIT,
1370                                         .lower = THERMAL_NO_LIMIT,
1371                                 },
1372                                 {
1373                                         .cdev_type = "tegra-shutdown",
1374                                         .trip_temp = 102000,
1375                                         .trip_type = THERMAL_TRIP_CRITICAL,
1376                                         .upper = THERMAL_NO_LIMIT,
1377                                         .lower = THERMAL_NO_LIMIT,
1378                                 },
1379                         },
1380                         .tzp = &soctherm_tzp,
1381                 },
1382                 [THERM_GPU] = {
1383                         .zone_enable = true,
1384                         .passive_delay = 1000,
1385                         .hotspot_offset = 6000,
1386                         .num_trips = 3,
1387                         .trips = {
1388                                 {
1389                                         .cdev_type = "tegra-balanced",
1390                                         .trip_temp = 90000,
1391                                         .trip_type = THERMAL_TRIP_PASSIVE,
1392                                         .upper = THERMAL_NO_LIMIT,
1393                                         .lower = THERMAL_NO_LIMIT,
1394                                 },
1395                                 {
1396                                         .cdev_type = "tegra-heavy",
1397                                         .trip_temp = 100000,
1398                                         .trip_type = THERMAL_TRIP_HOT,
1399                                         .upper = THERMAL_NO_LIMIT,
1400                                         .lower = THERMAL_NO_LIMIT,
1401                                 },
1402                                 {
1403                                         .cdev_type = "tegra-shutdown",
1404                                         .trip_temp = 102000,
1405                                         .trip_type = THERMAL_TRIP_CRITICAL,
1406                                         .upper = THERMAL_NO_LIMIT,
1407                                         .lower = THERMAL_NO_LIMIT,
1408                                 },
1409                         },
1410                         .tzp = &soctherm_tzp,
1411                 },
1412                 [THERM_PLL] = {
1413                         .zone_enable = true,
1414                 },
1415         },
1416         .throttle = {
1417                 [THROTTLE_HEAVY] = {
1418                         .priority = 100,
1419                         .devs = {
1420                                 [THROTTLE_DEV_CPU] = {
1421                                         .enable = true,
1422                                         .depth = 80,
1423                                 },
1424                                 [THROTTLE_DEV_GPU] = {
1425                                         .enable = true,
1426                                         .depth = 80,
1427                                 },
1428                         },
1429                 },
1430         },
1431         .tshut_pmu_trip_data = &tpdata_palmas,
1432 };
1433
1434 int __init dalmore_soctherm_init(void)
1435 {
1436         struct board_info board_info;
1437
1438         tegra_get_board_info(&board_info);
1439         if (!(board_info.board_id == BOARD_E1611 ||
1440                 board_info.board_id == BOARD_P2454))
1441                 dalmore_soctherm_data.tshut_pmu_trip_data = &tpdata_max77663;
1442
1443         tegra_platform_edp_init(dalmore_soctherm_data.therm[THERM_CPU].trips,
1444                         &dalmore_soctherm_data.therm[THERM_CPU].num_trips,
1445                         6000); /* edp temperature margin */
1446         tegra_add_tj_trips(dalmore_soctherm_data.therm[THERM_CPU].trips,
1447                         &dalmore_soctherm_data.therm[THERM_CPU].num_trips);
1448
1449         return tegra11_soctherm_init(&dalmore_soctherm_data);
1450 }