regulator: max77663: convert regulator init data to pointer
[linux-2.6.git] / arch / arm / mach-tegra / board-kai-power.c
1 /*
2  * arch/arm/mach-tegra/board-kai-power.c
3  *
4  * Copyright (C) 2012 NVIDIA, Inc.
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
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18  * 02111-1307, USA
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/regulator/machine.h>
25 #include <linux/mfd/max77663-core.h>
26 #include <linux/regulator/max77663-regulator.h>
27 #include <linux/gpio.h>
28 #include <linux/io.h>
29 #include <linux/regulator/fixed.h>
30 #include <linux/power/gpio-charger.h>
31
32 #include <asm/mach-types.h>
33
34 #include <mach/iomap.h>
35 #include <mach/irqs.h>
36 #include <mach/pinmux.h>
37 #include <mach/edp.h>
38 #include <mach/gpio-tegra.h>
39
40 #include "gpio-names.h"
41 #include "board.h"
42 #include "board-kai.h"
43 #include "pm.h"
44 #include "tegra3_tsensor.h"
45
46 #define PMC_CTRL                0x0
47 #define PMC_CTRL_INTR_LOW       (1 << 17)
48
49 static struct regulator_consumer_supply max77663_sd0_supply[] = {
50         REGULATOR_SUPPLY("vdd_cpu", NULL),
51 };
52
53 static struct regulator_consumer_supply max77663_sd1_supply[] = {
54         REGULATOR_SUPPLY("vdd_core", NULL),
55 };
56
57 static struct regulator_consumer_supply max77663_sd2_supply[] = {
58         REGULATOR_SUPPLY("vdd_gen1v8", NULL),
59         REGULATOR_SUPPLY("avdd_hdmi_pll", NULL),
60         REGULATOR_SUPPLY("avdd_usb_pll", NULL),
61         REGULATOR_SUPPLY("avdd_osc", NULL),
62         REGULATOR_SUPPLY("vddio_sys", NULL),
63         REGULATOR_SUPPLY("vddio_sdmmc", "sdhci-tegra.3"),
64         REGULATOR_SUPPLY("pwrdet_sdmmc4", NULL),
65         REGULATOR_SUPPLY("vddio_uart", NULL),
66         REGULATOR_SUPPLY("pwrdet_uart", NULL),
67         REGULATOR_SUPPLY("vddio_bb", NULL),
68         REGULATOR_SUPPLY("pwrdet_bb", NULL),
69         REGULATOR_SUPPLY("vddio_lcd_pmu", NULL),
70         REGULATOR_SUPPLY("pwrdet_lcd", NULL),
71         REGULATOR_SUPPLY("vddio_audio", NULL),
72         REGULATOR_SUPPLY("pwrdet_audio", NULL),
73         REGULATOR_SUPPLY("vddio_cam", NULL),
74         REGULATOR_SUPPLY("pwrdet_cam", NULL),
75         REGULATOR_SUPPLY("vddio_sdmmc", "sdhci-tegra.2"),
76         REGULATOR_SUPPLY("pwrdet_sdmmc3", NULL),
77         REGULATOR_SUPPLY("vddio_vi", NULL),
78         REGULATOR_SUPPLY("pwrdet_vi", NULL),
79         REGULATOR_SUPPLY("vcore_nand", NULL),
80         REGULATOR_SUPPLY("pwrdet_nand", NULL),
81 };
82
83 static struct regulator_consumer_supply max77663_sd3_supply[] = {
84         REGULATOR_SUPPLY("vdd_ddr3l_1v35", NULL),
85 };
86
87 static struct regulator_consumer_supply max77663_ldo0_supply[] = {
88         REGULATOR_SUPPLY("vdd_ddr_hs", NULL),
89 };
90
91 static struct regulator_consumer_supply max77663_ldo1_supply[] = {
92 };
93
94 static struct regulator_consumer_supply max77663_ldo2_supply[] = {
95         REGULATOR_SUPPLY("vdd_ddr_rx", NULL),
96 };
97
98 static struct regulator_consumer_supply max77663_ldo3_supply[] = {
99 };
100
101 static struct regulator_consumer_supply max77663_ldo4_supply[] = {
102         REGULATOR_SUPPLY("vdd_rtc", NULL),
103 };
104
105 static struct regulator_consumer_supply max77663_ldo5_supply[] = {
106         REGULATOR_SUPPLY("vdd_sensor_2v8", NULL),
107 };
108
109 static struct regulator_consumer_supply max77663_ldo6_supply[] = {
110         REGULATOR_SUPPLY("vddio_sdmmc", "sdhci-tegra.0"),
111         REGULATOR_SUPPLY("pwrdet_sdmmc1", NULL),
112 };
113
114 static struct regulator_consumer_supply max77663_ldo7_supply[] = {
115         REGULATOR_SUPPLY("avdd_dsi_csi", NULL),
116         REGULATOR_SUPPLY("pwrdet_mipi", NULL),
117 };
118
119 static struct regulator_consumer_supply max77663_ldo8_supply[] = {
120         REGULATOR_SUPPLY("avdd_plla_p_c_s", NULL),
121         REGULATOR_SUPPLY("avdd_pllm", NULL),
122         REGULATOR_SUPPLY("avdd_pllu_d", NULL),
123         REGULATOR_SUPPLY("avdd_pllu_d2", NULL),
124         REGULATOR_SUPPLY("avdd_pllx", NULL),
125 };
126
127 static struct max77663_regulator_fps_cfg max77663_fps_cfgs[] = {
128         {
129                 .src = FPS_SRC_0,
130                 .en_src = FPS_EN_SRC_EN0,
131                 .time_period = FPS_TIME_PERIOD_DEF,
132         },
133         {
134                 .src = FPS_SRC_1,
135                 .en_src = FPS_EN_SRC_EN1,
136                 .time_period = FPS_TIME_PERIOD_DEF,
137         },
138         {
139                 .src = FPS_SRC_2,
140                 .en_src = FPS_EN_SRC_EN0,
141                 .time_period = FPS_TIME_PERIOD_DEF,
142         },
143 };
144
145 #define MAX77663_PDATA_INIT(_id, _min_uV, _max_uV, _supply_reg,         \
146                             _always_on, _boot_on, _apply_uV,            \
147                             _init_apply, _init_enable, _init_uV,        \
148                             _fps_src, _fps_pu_period, _fps_pd_period, _flags) \
149         static struct regulator_init_data max77663_regulator_idata_##_id = {  \
150                 .supply_regulator = _supply_reg,                        \
151                 .constraints = {                                        \
152                         .name = max77663_rails(_id),                    \
153                         .min_uV = _min_uV,                              \
154                         .max_uV = _max_uV,                              \
155                         .valid_modes_mask = (REGULATOR_MODE_NORMAL |    \
156                                              REGULATOR_MODE_STANDBY),   \
157                         .valid_ops_mask = (REGULATOR_CHANGE_MODE |      \
158                                            REGULATOR_CHANGE_STATUS |    \
159                                            REGULATOR_CHANGE_VOLTAGE),   \
160                         .always_on = _always_on,                        \
161                         .boot_on = _boot_on,                            \
162                         .apply_uV = _apply_uV,                          \
163                 },                                                      \
164                 .num_consumer_supplies =                                \
165                                 ARRAY_SIZE(max77663_##_id##_supply),    \
166                 .consumer_supplies = max77663_##_id##_supply,           \
167         };                                                              \
168         static struct max77663_regulator_platform_data max77663_regulator_pdata_##_id = \
169         {                                                               \
170                 .reg_init_data = &max77663_regulator_idata_##_id,       \
171                 .init_apply = _init_apply,                              \
172                 .init_enable = _init_enable,                            \
173                 .init_uV = _init_uV,                                    \
174                 .fps_src = _fps_src,                                    \
175                 .fps_pu_period = _fps_pu_period,                        \
176                 .fps_pd_period = _fps_pd_period,                        \
177                 .fps_cfgs = max77663_fps_cfgs,                          \
178                 .flags = _flags,                                        \
179         }
180
181 MAX77663_PDATA_INIT(sd0,  600000, 3387500, NULL, 1, 0, 0,
182                     0, 0, -1, FPS_SRC_NONE, -1, -1, EN2_CTRL_SD0);
183
184 MAX77663_PDATA_INIT(sd1,  800000, 1587500, NULL, 1, 0, 0,
185                     1, 1, -1, FPS_SRC_1, FPS_POWER_PERIOD_1, FPS_POWER_PERIOD_6, 0);
186
187 MAX77663_PDATA_INIT(sd2,  1800000, 1800000, NULL, 1, 0, 0,
188                     1, 1, -1, FPS_SRC_0, -1, -1, 0);
189
190 MAX77663_PDATA_INIT(sd3,  600000, 3387500, NULL, 1, 0, 0,
191                     1, 1, -1, FPS_SRC_0, -1, -1, 0);
192
193 MAX77663_PDATA_INIT(ldo0, 800000, 2350000, max77663_rails(sd3), 1, 0, 0,
194                     1, 1, -1, FPS_SRC_1, -1, -1, 0);
195
196 MAX77663_PDATA_INIT(ldo1, 800000, 2350000, max77663_rails(sd3), 0, 0, 0,
197                     0, 0, -1, FPS_SRC_NONE, -1, -1, 0);
198
199 MAX77663_PDATA_INIT(ldo2, 800000, 3950000, NULL, 1, 0, 0,
200                     1, 1, -1, FPS_SRC_1, -1, -1, 0);
201
202 MAX77663_PDATA_INIT(ldo3, 800000, 3950000, NULL, 1, 0, 0,
203                     1, 1, -1, FPS_SRC_1, -1, -1, 0);
204
205 MAX77663_PDATA_INIT(ldo4, 800000, 1587500, NULL, 0, 0, 0,
206                     1, 1, 1000000, FPS_SRC_0, -1, -1, LDO4_EN_TRACKING);
207
208 MAX77663_PDATA_INIT(ldo5, 800000, 2800000, NULL, 0, 0, 0,
209                     1, 1, -1, FPS_SRC_NONE, -1, -1, 0);
210
211 MAX77663_PDATA_INIT(ldo6, 800000, 3950000, NULL, 0, 0, 0,
212                     0, 0, -1, FPS_SRC_NONE, -1, -1, 0);
213
214 MAX77663_PDATA_INIT(ldo7, 800000, 3950000, max77663_rails(sd3), 0, 0, 0,
215                     0, 0, -1, FPS_SRC_NONE, -1, -1, 0);
216
217 MAX77663_PDATA_INIT(ldo8, 800000, 3950000, max77663_rails(sd3), 0, 0, 0,
218                     1, 1, -1, FPS_SRC_1, -1, -1, 0);
219
220 #define MAX77663_REG(_id, _data)                                        \
221         {                                                               \
222                 .name = "max77663-regulator",                           \
223                 .id = MAX77663_REGULATOR_ID_##_id,                      \
224                 .platform_data = &max77663_regulator_pdata_##_data,     \
225                 .pdata_size = sizeof(max77663_regulator_pdata_##_data), \
226         }
227
228 #define MAX77663_RTC()                                                  \
229         {                                                               \
230                 .name = "max77663-rtc",                                 \
231                 .id = 0,                                                \
232         }
233
234 static struct mfd_cell max77663_subdevs[] = {
235         MAX77663_REG(SD0, sd0),
236         MAX77663_REG(SD1, sd1),
237         MAX77663_REG(SD2, sd2),
238         MAX77663_REG(SD3, sd3),
239         MAX77663_REG(LDO0, ldo0),
240         MAX77663_REG(LDO1, ldo1),
241         MAX77663_REG(LDO2, ldo2),
242         MAX77663_REG(LDO3, ldo3),
243         MAX77663_REG(LDO4, ldo4),
244         MAX77663_REG(LDO5, ldo5),
245         MAX77663_REG(LDO6, ldo6),
246         MAX77663_REG(LDO7, ldo7),
247         MAX77663_REG(LDO8, ldo8),
248         MAX77663_RTC(),
249 };
250
251 static struct max77663_gpio_config max77663_gpio_cfgs[] = {
252         {
253                 .gpio = MAX77663_GPIO0,
254                 .dir = GPIO_DIR_OUT,
255                 .dout = GPIO_DOUT_LOW,
256                 .out_drv = GPIO_OUT_DRV_PUSH_PULL,
257                 .alternate = GPIO_ALT_DISABLE,
258         },
259         {
260                 .gpio = MAX77663_GPIO1,
261                 .dir = GPIO_DIR_IN,
262                 .dout = GPIO_DOUT_LOW,
263                 .out_drv = GPIO_OUT_DRV_PUSH_PULL,
264                 .alternate = GPIO_ALT_DISABLE,
265         },
266         {
267                 .gpio = MAX77663_GPIO2,
268                 .dir = GPIO_DIR_OUT,
269                 .dout = GPIO_DOUT_HIGH,
270                 .out_drv = GPIO_OUT_DRV_OPEN_DRAIN,
271                 .alternate = GPIO_ALT_DISABLE,
272         },
273         {
274                 .gpio = MAX77663_GPIO3,
275                 .dir = GPIO_DIR_OUT,
276                 .dout = GPIO_DOUT_LOW,
277                 .out_drv = GPIO_OUT_DRV_OPEN_DRAIN,
278                 .alternate = GPIO_ALT_ENABLE,
279         },
280         {
281                 .gpio = MAX77663_GPIO4,
282                 .dir = GPIO_DIR_OUT,
283                 .dout = GPIO_DOUT_HIGH,
284                 .out_drv = GPIO_OUT_DRV_PUSH_PULL,
285                 .alternate = GPIO_ALT_ENABLE,
286         },
287         {
288                 .gpio = MAX77663_GPIO5,
289                 .dir = GPIO_DIR_OUT,
290                 .dout = GPIO_DOUT_LOW,
291                 .out_drv = GPIO_OUT_DRV_PUSH_PULL,
292                 .alternate = GPIO_ALT_DISABLE,
293         },
294         {
295                 .gpio = MAX77663_GPIO6,
296                 .dir = GPIO_DIR_IN,
297                 .alternate = GPIO_ALT_DISABLE,
298         },
299         {
300                 .gpio = MAX77663_GPIO7,
301                 .dir = GPIO_DIR_OUT,
302                 .dout = GPIO_DOUT_LOW,
303                 .out_drv = GPIO_OUT_DRV_OPEN_DRAIN,
304                 .alternate = GPIO_ALT_DISABLE,
305         },
306 };
307
308 static struct max77663_platform_data max7763_pdata = {
309         .irq_base       = MAX77663_IRQ_BASE,
310         .gpio_base      = MAX77663_GPIO_BASE,
311
312         .num_gpio_cfgs  = ARRAY_SIZE(max77663_gpio_cfgs),
313         .gpio_cfgs      = max77663_gpio_cfgs,
314
315         .num_subdevs    = ARRAY_SIZE(max77663_subdevs),
316         .sub_devices    = max77663_subdevs,
317
318         .rtc_i2c_addr   = 0x68,
319
320         .use_power_off  = true,
321 };
322
323 static struct i2c_board_info __initdata max77663_regulators[] = {
324         {
325                 /* The I2C address was determined by OTP factory setting */
326                 I2C_BOARD_INFO("max77663", 0x3c),
327                 .irq            = INT_EXTERNAL_PMU,
328                 .platform_data  = &max7763_pdata,
329         },
330 };
331
332 static int __init kai_max77663_regulator_init(void)
333 {
334         void __iomem *pmc = IO_ADDRESS(TEGRA_PMC_BASE);
335         u32 pmc_ctrl;
336
337         /* configure the power management controller to trigger PMU
338          * interrupts when low */
339         pmc_ctrl = readl(pmc + PMC_CTRL);
340         writel(pmc_ctrl | PMC_CTRL_INTR_LOW, pmc + PMC_CTRL);
341
342         i2c_register_board_info(4, max77663_regulators,
343                                 ARRAY_SIZE(max77663_regulators));
344
345         return 0;
346 }
347
348 static struct regulator_consumer_supply fixed_reg_en_3v3_sys_a00_supply[] = {
349         REGULATOR_SUPPLY("vdd_3v3", NULL),
350         REGULATOR_SUPPLY("vdd_3v3_devices", NULL),
351         REGULATOR_SUPPLY("debug_cons", NULL),
352         REGULATOR_SUPPLY("pwrdet_pex_ctl", NULL),
353 };
354
355 static struct regulator_consumer_supply fixed_reg_en_3v3_sys_a01_supply[] = {
356         REGULATOR_SUPPLY("vdd_3v3", NULL),
357         REGULATOR_SUPPLY("vdd_3v3_devices", NULL),
358         REGULATOR_SUPPLY("debug_cons", NULL),
359         REGULATOR_SUPPLY("pwrdet_pex_ctl", NULL),
360         REGULATOR_SUPPLY("vddio_gmi", NULL),
361 };
362
363 static struct regulator_consumer_supply fixed_reg_en_avdd_hdmi_usb_a00_supply[] = {
364         REGULATOR_SUPPLY("avdd_hdmi", NULL),
365         REGULATOR_SUPPLY("avdd_usb", NULL),
366         REGULATOR_SUPPLY("vddio_gmi", NULL),
367 };
368
369 static struct regulator_consumer_supply fixed_reg_en_avdd_hdmi_usb_a01_supply[] = {
370         REGULATOR_SUPPLY("avdd_hdmi", NULL),
371         REGULATOR_SUPPLY("avdd_usb", NULL),
372 };
373
374 static struct regulator_consumer_supply fixed_reg_en_1v8_cam_supply[] = {
375         REGULATOR_SUPPLY("vdd_1v8_cam1", NULL),
376         REGULATOR_SUPPLY("vdd_1v8_cam2", NULL),
377         REGULATOR_SUPPLY("vdd_1v8_cam3", NULL),
378 };
379
380 static struct regulator_consumer_supply fixed_reg_en_vddio_vid_supply[] = {
381         REGULATOR_SUPPLY("vdd_hdmi_con", NULL),
382 };
383
384 static struct regulator_consumer_supply fixed_reg_en_3v3_modem_supply[] = {
385         REGULATOR_SUPPLY("vdd_mini_card", NULL),
386 };
387
388 static struct regulator_consumer_supply fixed_reg_en_vdd_pnl_supply[] = {
389         REGULATOR_SUPPLY("vdd_lvds", NULL),
390         REGULATOR_SUPPLY("vdd_lcd_panel", NULL),
391         REGULATOR_SUPPLY("vdd_touch", NULL),
392         REGULATOR_SUPPLY("vddio_ts", NULL),
393 };
394
395 static struct regulator_consumer_supply fixed_reg_en_cam3_ldo_supply[] = {
396         REGULATOR_SUPPLY("vdd_cam3", NULL),
397 };
398
399 static struct regulator_consumer_supply fixed_reg_en_vdd_com_supply[] = {
400         REGULATOR_SUPPLY("vdd_com_bd", NULL),
401 };
402
403 static struct regulator_consumer_supply fixed_reg_en_vdd_sdmmc1_supply[] = {
404         REGULATOR_SUPPLY("vddio_sd_slot", "sdhci-tegra.0"),
405 };
406
407 static struct regulator_consumer_supply fixed_reg_en_3v3_fuse_supply[] = {
408         REGULATOR_SUPPLY("vdd_fuse", NULL),
409 };
410
411 static struct regulator_consumer_supply fixed_reg_cdc_en_supply[] = {
412         REGULATOR_SUPPLY("cdc_en", NULL),
413 };
414
415 /* Macro for defining fixed regulator sub device data */
416 #define FIXED_SUPPLY(_name) "fixed_reg_"#_name
417 #define FIXED_REG(_id, _var, _name, _in_supply, _always_on, _boot_on,   \
418         _gpio_nr, _active_high, _boot_state, _millivolts)       \
419         static struct regulator_init_data ri_data_##_var =              \
420         {                                                               \
421                 .supply_regulator = _in_supply,                         \
422                 .num_consumer_supplies =                                \
423                         ARRAY_SIZE(fixed_reg_##_name##_supply),         \
424                 .consumer_supplies = fixed_reg_##_name##_supply,        \
425                 .constraints = {                                        \
426                         .valid_modes_mask = (REGULATOR_MODE_NORMAL |    \
427                                         REGULATOR_MODE_STANDBY),        \
428                         .valid_ops_mask = (REGULATOR_CHANGE_MODE |      \
429                                         REGULATOR_CHANGE_STATUS |       \
430                                         REGULATOR_CHANGE_VOLTAGE),      \
431                         .always_on = _always_on,                        \
432                         .boot_on = _boot_on,                            \
433                 },                                                      \
434         };                                                              \
435         static struct fixed_voltage_config fixed_reg_##_var##_pdata =   \
436         {                                                               \
437                 .supply_name = FIXED_SUPPLY(_name),                     \
438                 .microvolts = _millivolts * 1000,                       \
439                 .gpio = _gpio_nr,                                       \
440                 .enable_high = _active_high,                            \
441                 .enabled_at_boot = _boot_state,                         \
442                 .init_data = &ri_data_##_var,                           \
443         };                                                              \
444         static struct platform_device fixed_reg_##_var##_dev = {        \
445                 .name = "reg-fixed-voltage",                            \
446                 .id = _id,                                              \
447                 .dev = {                                                \
448                         .platform_data = &fixed_reg_##_var##_pdata,     \
449                 },                                                      \
450         }
451
452
453 /* A00 specific */
454 FIXED_REG(1, en_3v3_sys_a00,    en_3v3_sys_a00,         NULL,
455         1,      0,      MAX77663_GPIO_BASE + MAX77663_GPIO3,    true,   1,      3300);
456 FIXED_REG(2, en_avdd_hdmi_usb_a00, en_avdd_hdmi_usb_a00, FIXED_SUPPLY(en_3v3_sys_a00),
457         1,      0,      MAX77663_GPIO_BASE + MAX77663_GPIO2,    true,   1,      3300);
458 FIXED_REG(3, en_1v8_cam_a00,    en_1v8_cam,             max77663_rails(sd2),
459         0,      0,      TEGRA_GPIO_PS0,                         true,   0,      1800);
460 FIXED_REG(4, en_vddio_vid_a00,  en_vddio_vid,           NULL,
461         0,      0,      TEGRA_GPIO_PB2,                         true,   0,      5000);
462 FIXED_REG(5, en_3v3_modem_a00,  en_3v3_modem,           NULL,
463         0,      1,      TEGRA_GPIO_PP0,                         true,   0,      3300);
464 FIXED_REG(6, en_vdd_pnl_a00,    en_vdd_pnl,             FIXED_SUPPLY(en_3v3_sys_a00),
465         0,      0,      TEGRA_GPIO_PW1,                         true,   0,      3300);
466 FIXED_REG(7, en_cam3_ldo_a00,   en_cam3_ldo,            FIXED_SUPPLY(en_3v3_sys_a00),
467         0,      0,      TEGRA_GPIO_PR7,                         true,   0,      3300);
468 FIXED_REG(8, en_vdd_com_a00,    en_vdd_com,             FIXED_SUPPLY(en_3v3_sys_a00),
469         1,      0,      TEGRA_GPIO_PD0,                         true,   0,      3300);
470 FIXED_REG(9,  en_vdd_sdmmc1_a00, en_vdd_sdmmc1,         FIXED_SUPPLY(en_3v3_sys_a00),
471         0,      0,      TEGRA_GPIO_PC6,                         true,   0,      3300);
472 FIXED_REG(10, en_3v3_fuse_a00,  en_3v3_fuse,            FIXED_SUPPLY(en_3v3_sys_a00),
473         0,      0,      TEGRA_GPIO_PC1,                         true,   0,      3300);
474 FIXED_REG(11, cdc_en_a00,       cdc_en,                 max77663_rails(sd2),
475         0,      1,      TEGRA_GPIO_PX2,                         true,   0,      1200);
476
477 /* A01 specific */
478 FIXED_REG(1, en_3v3_sys_a01,    en_3v3_sys_a01,         NULL,
479         1,      0,      MAX77663_GPIO_BASE + MAX77663_GPIO3,    true,   1,      3300);
480 FIXED_REG(2, en_avdd_hdmi_usb_a01, en_avdd_hdmi_usb_a01, FIXED_SUPPLY(en_3v3_sys_a01),
481         0,      0,      MAX77663_GPIO_BASE + MAX77663_GPIO2,    true,   0,      3300);
482 FIXED_REG(3, en_1v8_cam_a01,    en_1v8_cam,             max77663_rails(sd2),
483         0,      0,      TEGRA_GPIO_PS0,                         true,   0,      1800);
484 FIXED_REG(4, en_vddio_vid_a01,  en_vddio_vid,           NULL,
485         0,      0,      TEGRA_GPIO_PB2,                         true,   0,      5000);
486 FIXED_REG(5, en_3v3_modem_a01,  en_3v3_modem,           NULL,
487         0,      1,      TEGRA_GPIO_PP0,                         true,   0,      3300);
488 FIXED_REG(6, en_vdd_pnl_a01,    en_vdd_pnl,             FIXED_SUPPLY(en_3v3_sys_a01),
489         0,      1,      TEGRA_GPIO_PW1,                         true,   0,      3300);
490 FIXED_REG(7, en_cam3_ldo_a01,   en_cam3_ldo,            FIXED_SUPPLY(en_3v3_sys_a01),
491         0,      0,      TEGRA_GPIO_PR7,                         true,   0,      3300);
492 FIXED_REG(8, en_vdd_com_a01,    en_vdd_com,             FIXED_SUPPLY(en_3v3_sys_a01),
493         1,      0,      TEGRA_GPIO_PD0,                         true,   0,      3300);
494 FIXED_REG(9,  en_vdd_sdmmc1_a01, en_vdd_sdmmc1,         FIXED_SUPPLY(en_3v3_sys_a01),
495         0,      0,      TEGRA_GPIO_PC6,                         true,   0,      3300);
496 FIXED_REG(10, en_3v3_fuse_a01,  en_3v3_fuse,            FIXED_SUPPLY(en_3v3_sys_a01),
497         0,      0,      TEGRA_GPIO_PC1,                         true,   0,      3300);
498 FIXED_REG(11, cdc_en_a01,       cdc_en,                 max77663_rails(sd2),
499         0,      1,      TEGRA_GPIO_PX2,                         true,   0,      1200);
500
501 /*
502  * Creating the fixed regulator device tables
503  */
504
505 #define ADD_FIXED_REG(_name)    (&fixed_reg_##_name##_dev)
506
507 /* A00 specific */
508 #define E1565_A00_FIXED_REG \
509         ADD_FIXED_REG(en_3v3_sys_a00),          \
510         ADD_FIXED_REG(en_avdd_hdmi_usb_a00),    \
511         ADD_FIXED_REG(en_1v8_cam_a00),          \
512         ADD_FIXED_REG(en_vddio_vid_a00),        \
513         ADD_FIXED_REG(en_3v3_modem_a00),        \
514         ADD_FIXED_REG(en_vdd_pnl_a00),          \
515         ADD_FIXED_REG(en_cam3_ldo_a00),         \
516         ADD_FIXED_REG(en_vdd_com_a00),          \
517         ADD_FIXED_REG(en_vdd_sdmmc1_a00),       \
518         ADD_FIXED_REG(en_3v3_fuse_a00),         \
519         ADD_FIXED_REG(cdc_en_a00),              \
520
521 /* A01 specific */
522 #define E1565_A01_FIXED_REG \
523         ADD_FIXED_REG(en_3v3_sys_a01),          \
524         ADD_FIXED_REG(en_avdd_hdmi_usb_a01),    \
525         ADD_FIXED_REG(en_1v8_cam_a01),          \
526         ADD_FIXED_REG(en_vddio_vid_a01),        \
527         ADD_FIXED_REG(en_3v3_modem_a01),        \
528         ADD_FIXED_REG(en_vdd_pnl_a01),          \
529         ADD_FIXED_REG(en_cam3_ldo_a01),         \
530         ADD_FIXED_REG(en_vdd_com_a01),          \
531         ADD_FIXED_REG(en_vdd_sdmmc1_a01),       \
532         ADD_FIXED_REG(en_3v3_fuse_a01),         \
533         ADD_FIXED_REG(cdc_en_a01),              \
534
535 /* Gpio switch regulator platform data for Kai A00 */
536 static struct platform_device *fixed_reg_devs_a00[] = {
537         E1565_A00_FIXED_REG
538 };
539
540 /* Gpio switch regulator platform data for Kai A01 */
541 static struct platform_device *fixed_reg_devs_a01[] = {
542         E1565_A01_FIXED_REG
543 };
544
545 static int __init kai_fixed_regulator_init(void)
546 {
547         int i;
548         struct board_info board_info;
549         struct platform_device **fixed_reg_devs;
550         int nfixreg_devs;
551
552         tegra_get_board_info(&board_info);
553
554         if (board_info.fab == BOARD_FAB_A00) {
555                 fixed_reg_devs = fixed_reg_devs_a00;
556                 nfixreg_devs = ARRAY_SIZE(fixed_reg_devs_a00);
557         } else {
558                 fixed_reg_devs = fixed_reg_devs_a01;
559                 nfixreg_devs = ARRAY_SIZE(fixed_reg_devs_a01);
560         }
561
562         if (!machine_is_kai())
563                 return 0;
564
565         for (i = 0; i < nfixreg_devs; ++i) {
566                 int gpio_nr;
567                 struct fixed_voltage_config *fixed_reg_pdata =
568                         fixed_reg_devs[i]->dev.platform_data;
569                 gpio_nr = fixed_reg_pdata->gpio;
570
571         }
572
573         return platform_add_devices(fixed_reg_devs, nfixreg_devs);
574 }
575 subsys_initcall_sync(kai_fixed_regulator_init);
576
577 int __init kai_regulator_init(void)
578 {
579         void __iomem *pmc = IO_ADDRESS(TEGRA_PMC_BASE);
580         u32 pmc_ctrl;
581         int ret;
582
583         /* configure the power management controller to trigger PMU
584          * interrupts when low */
585
586         pmc_ctrl = readl(pmc + PMC_CTRL);
587         writel(pmc_ctrl | PMC_CTRL_INTR_LOW, pmc + PMC_CTRL);
588
589         ret = kai_max77663_regulator_init();
590         if (ret < 0)
591                 return ret;
592
593         return 0;
594 }
595
596 static void kai_board_suspend(int lp_state, enum suspend_stage stg)
597 {
598         if ((lp_state == TEGRA_SUSPEND_LP1) && (stg == TEGRA_SUSPEND_BEFORE_CPU))
599                 tegra_console_uart_suspend();
600 }
601
602 static void kai_board_resume(int lp_state, enum resume_stage stg)
603 {
604         if ((lp_state == TEGRA_SUSPEND_LP1) && (stg == TEGRA_RESUME_AFTER_CPU))
605                 tegra_console_uart_resume();
606 }
607
608 static struct tegra_suspend_platform_data kai_suspend_data = {
609         .cpu_timer      = 2000,
610         .cpu_off_timer  = 200,
611         .suspend_mode   = TEGRA_SUSPEND_LP0,
612         .core_timer     = 0x7e7e,
613         .core_off_timer = 0,
614         .corereq_high   = true,
615         .sysclkreq_high = true,
616         .cpu_lp2_min_residency = 2000,
617         .board_suspend = kai_board_suspend,
618         .board_resume = kai_board_resume,
619 };
620
621 int __init kai_suspend_init(void)
622 {
623         tegra_init_suspend(&kai_suspend_data);
624         return 0;
625 }
626
627 static struct tegra_tsensor_pmu_data  tpdata = {
628         .poweroff_reg_addr = 0x3F,
629         .poweroff_reg_data = 0x80,
630         .reset_tegra = 1,
631         .controller_type = 0,
632         .i2c_controller_id = 4,
633         .pinmux = 0,
634         .pmu_16bit_ops = 0,
635         .pmu_i2c_addr = 0x2D,
636 };
637
638 void __init kai_tsensor_init(void)
639 {
640         tegra3_tsensor_init(&tpdata);
641 }
642
643 #ifdef CONFIG_TEGRA_EDP_LIMITS
644
645 int __init kai_edp_init(void)
646 {
647         unsigned int regulator_mA;
648
649         regulator_mA = get_maximum_cpu_current_supported();
650         if (!regulator_mA)
651                 regulator_mA = 6000; /* regular T30/s */
652         pr_info("%s: CPU regulator %d mA\n", __func__, regulator_mA);
653
654         tegra_init_cpu_edp_limits(regulator_mA);
655         return 0;
656 }
657 #endif