temp revert rk change
[firefly-linux-kernel-4.4.55.git] / arch / arm / mach-tegra / board-ventana-power.c
1 /*
2  * Copyright (C) 2010 NVIDIA, Inc.
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 as
6  * published by the Free Software Foundation.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program; if not, write to the Free Software
15  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
16  * 02111-1307, USA
17  */
18 #include <linux/i2c.h>
19 #include <linux/pda_power.h>
20 #include <linux/platform_device.h>
21 #include <linux/resource.h>
22 #include <linux/regulator/machine.h>
23 #include <linux/mfd/tps6586x.h>
24 #include <linux/gpio.h>
25 #include <mach/suspend.h>
26 #include <linux/io.h>
27
28 #include <mach/iomap.h>
29 #include <mach/irqs.h>
30
31 #include "gpio-names.h"
32 #include "power.h"
33 #include "wakeups-t2.h"
34 #include "board.h"
35
36 #define PMC_CTRL                0x0
37 #define PMC_CTRL_INTR_LOW       (1 << 17)
38
39 static struct regulator_consumer_supply tps658621_sm0_supply[] = {
40         REGULATOR_SUPPLY("vdd_core", NULL),
41 };
42 static struct regulator_consumer_supply tps658621_sm1_supply[] = {
43         REGULATOR_SUPPLY("vdd_cpu", NULL),
44 };
45 static struct regulator_consumer_supply tps658621_sm2_supply[] = {
46         REGULATOR_SUPPLY("vdd_sm2", NULL),
47 };
48 static struct regulator_consumer_supply tps658621_ldo0_supply[] = {
49         REGULATOR_SUPPLY("p_cam_avdd", NULL),
50 };
51 static struct regulator_consumer_supply tps658621_ldo1_supply[] = {
52         REGULATOR_SUPPLY("avdd_pll", NULL),
53 };
54 static struct regulator_consumer_supply tps658621_ldo2_supply[] = {
55         REGULATOR_SUPPLY("vdd_rtc", NULL),
56 };
57 static struct regulator_consumer_supply tps658621_ldo3_supply[] = {
58         REGULATOR_SUPPLY("avdd_usb", NULL),
59         REGULATOR_SUPPLY("avdd_usb_pll", NULL),
60         REGULATOR_SUPPLY("avdd_lvds", NULL),
61 };
62 static struct regulator_consumer_supply tps658621_ldo4_supply[] = {
63         REGULATOR_SUPPLY("avdd_osc", NULL),
64         REGULATOR_SUPPLY("vddio_sys", "panjit_touch"),
65 };
66 static struct regulator_consumer_supply tps658621_ldo5_supply[] = {
67         REGULATOR_SUPPLY("vcore_mmc", "sdhci-tegra.1"),
68         REGULATOR_SUPPLY("vcore_mmc", "sdhci-tegra.3"),
69 };
70 static struct regulator_consumer_supply tps658621_ldo6_supply[] = {
71         REGULATOR_SUPPLY("vddio_vi", NULL),
72 };
73 static struct regulator_consumer_supply tps658621_ldo7_supply[] = {
74         REGULATOR_SUPPLY("avdd_hdmi", NULL),
75         REGULATOR_SUPPLY("vdd_fuse", NULL),
76 };
77 static struct regulator_consumer_supply tps658621_ldo8_supply[] = {
78         REGULATOR_SUPPLY("avdd_hdmi_pll", NULL),
79 };
80 static struct regulator_consumer_supply tps658621_ldo9_supply[] = {
81         REGULATOR_SUPPLY("avdd_2v85", NULL),
82         REGULATOR_SUPPLY("vdd_ddr_rx", NULL),
83         REGULATOR_SUPPLY("avdd_amp", NULL),
84 };
85
86 #define REGULATOR_INIT(_id, _minmv, _maxmv)                             \
87         {                                                               \
88                 .constraints = {                                        \
89                         .min_uV = (_minmv)*1000,                        \
90                         .max_uV = (_maxmv)*1000,                        \
91                         .valid_modes_mask = (REGULATOR_MODE_NORMAL |    \
92                                              REGULATOR_MODE_STANDBY),   \
93                         .valid_ops_mask = (REGULATOR_CHANGE_MODE |      \
94                                            REGULATOR_CHANGE_STATUS |    \
95                                            REGULATOR_CHANGE_VOLTAGE),   \
96                 },                                                      \
97                 .num_consumer_supplies = ARRAY_SIZE(tps658621_##_id##_supply),\
98                 .consumer_supplies = tps658621_##_id##_supply,          \
99         }
100
101 static struct regulator_init_data sm0_data = REGULATOR_INIT(sm0, 725, 1500);
102 static struct regulator_init_data sm1_data = REGULATOR_INIT(sm1, 725, 1500);
103 static struct regulator_init_data sm2_data = REGULATOR_INIT(sm2, 3000, 4550);
104 static struct regulator_init_data ldo0_data = REGULATOR_INIT(ldo0, 1250, 3300);
105 static struct regulator_init_data ldo1_data = REGULATOR_INIT(ldo1, 725, 1500);
106 static struct regulator_init_data ldo2_data = REGULATOR_INIT(ldo2, 725, 1500);
107 static struct regulator_init_data ldo3_data = REGULATOR_INIT(ldo3, 1250, 3300);
108 static struct regulator_init_data ldo4_data = REGULATOR_INIT(ldo4, 1700, 2475);
109 static struct regulator_init_data ldo5_data = REGULATOR_INIT(ldo5, 1250, 3300);
110 static struct regulator_init_data ldo6_data = REGULATOR_INIT(ldo6, 1250, 3300);
111 static struct regulator_init_data ldo7_data = REGULATOR_INIT(ldo7, 1250, 3300);
112 static struct regulator_init_data ldo8_data = REGULATOR_INIT(ldo8, 1250, 3300);
113 static struct regulator_init_data ldo9_data = REGULATOR_INIT(ldo9, 1250, 3300);
114
115 static struct tps6586x_rtc_platform_data rtc_data = {
116         .irq = TEGRA_NR_IRQS + TPS6586X_INT_RTC_ALM1,
117 };
118
119 #define TPS_REG(_id, _data)                     \
120         {                                       \
121                 .id = TPS6586X_ID_##_id,        \
122                 .name = "tps6586x-regulator",   \
123                 .platform_data = _data,         \
124         }
125
126 static struct tps6586x_subdev_info tps_devs[] = {
127         TPS_REG(SM_0, &sm0_data),
128         TPS_REG(SM_1, &sm1_data),
129         TPS_REG(SM_2, &sm2_data),
130         TPS_REG(LDO_0, &ldo0_data),
131         TPS_REG(LDO_1, &ldo1_data),
132         TPS_REG(LDO_2, &ldo2_data),
133         TPS_REG(LDO_3, &ldo3_data),
134         TPS_REG(LDO_4, &ldo4_data),
135         TPS_REG(LDO_5, &ldo5_data),
136         TPS_REG(LDO_6, &ldo6_data),
137         TPS_REG(LDO_7, &ldo7_data),
138         TPS_REG(LDO_8, &ldo8_data),
139         TPS_REG(LDO_9, &ldo9_data),
140         {
141                 .id     = 0,
142                 .name   = "tps6586x-rtc",
143                 .platform_data = &rtc_data,
144         },
145 };
146
147 static struct tps6586x_platform_data tps_platform = {
148         .irq_base = TEGRA_NR_IRQS,
149         .num_subdevs = ARRAY_SIZE(tps_devs),
150         .subdevs = tps_devs,
151         .gpio_base = TEGRA_NR_GPIOS,
152 };
153
154 static struct i2c_board_info __initdata ventana_regulators[] = {
155         {
156                 I2C_BOARD_INFO("tps6586x", 0x34),
157                 .irq            = INT_EXTERNAL_PMU,
158                 .platform_data  = &tps_platform,
159         },
160 };
161
162 static struct tegra_suspend_platform_data ventana_suspend_data = {
163         .cpu_timer      = 2000,
164         .cpu_off_timer  = 0,
165         .suspend_mode   = TEGRA_SUSPEND_LP1,
166         .core_timer     = 0x7e7e,
167         .core_off_timer = 0,
168         .separate_req   = true,
169         .corereq_high   = false,
170         .sysclkreq_high = true,
171         .wake_enb       = TEGRA_WAKE_GPIO_PV2,
172         .wake_high      = 0,
173         .wake_low       = TEGRA_WAKE_GPIO_PV2,
174         .wake_any       = 0,
175 };
176
177 int __init ventana_regulator_init(void)
178 {
179         void __iomem *pmc = IO_ADDRESS(TEGRA_PMC_BASE);
180         u32 pmc_ctrl;
181
182         /* configure the power management controller to trigger PMU
183          * interrupts when low */
184         pmc_ctrl = readl(pmc + PMC_CTRL);
185         writel(pmc_ctrl | PMC_CTRL_INTR_LOW, pmc + PMC_CTRL);
186         i2c_register_board_info(4, ventana_regulators, 1);
187         tegra_init_suspend(&ventana_suspend_data);
188         return 0;
189 }