aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-tegra/board-ventana-power.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/arm/mach-tegra/board-ventana-power.c')
-rw-r--r--arch/arm/mach-tegra/board-ventana-power.c373
1 files changed, 373 insertions, 0 deletions
diff --git a/arch/arm/mach-tegra/board-ventana-power.c b/arch/arm/mach-tegra/board-ventana-power.c
new file mode 100644
index 00000000000..e36a4e7c279
--- /dev/null
+++ b/arch/arm/mach-tegra/board-ventana-power.c
@@ -0,0 +1,373 @@
1/*
2 * Copyright (C) 2010-2012 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 <linux/io.h>
26#include <linux/power/gpio-charger.h>
27#include <linux/regulator/fixed.h>
28
29#include <mach/iomap.h>
30#include <mach/irqs.h>
31
32#include <generated/mach-types.h>
33
34#include "gpio-names.h"
35#include "fuse.h"
36#include "pm.h"
37#include "wakeups-t2.h"
38#include "board.h"
39#include "board-ventana.h"
40
41#define PMC_CTRL 0x0
42#define PMC_CTRL_INTR_LOW (1 << 17)
43
44#define CHARGING_DISABLE TEGRA_GPIO_PR6
45
46int __init ventana_charge_init(void)
47{
48 gpio_request(CHARGING_DISABLE, "chg_disable");
49 gpio_direction_output(CHARGING_DISABLE, 0);
50 tegra_gpio_enable(CHARGING_DISABLE);
51 return 0;
52}
53
54static struct regulator_consumer_supply tps658621_sm0_supply[] = {
55 REGULATOR_SUPPLY("vdd_core", NULL),
56};
57static struct regulator_consumer_supply tps658621_sm1_supply[] = {
58 REGULATOR_SUPPLY("vdd_cpu", NULL),
59};
60static struct regulator_consumer_supply tps658621_sm2_supply[] = {
61 REGULATOR_SUPPLY("vdd_sm2", NULL),
62};
63static struct regulator_consumer_supply tps658621_ldo0_supply[] = {
64 REGULATOR_SUPPLY("vdd_ldo0", NULL),
65 REGULATOR_SUPPLY("p_cam_avdd", NULL),
66};
67static struct regulator_consumer_supply tps658621_ldo1_supply[] = {
68 REGULATOR_SUPPLY("vdd_ldo1", NULL),
69 REGULATOR_SUPPLY("avdd_pll", NULL),
70};
71static struct regulator_consumer_supply tps658621_ldo2_supply[] = {
72 REGULATOR_SUPPLY("vdd_ldo2", NULL),
73 REGULATOR_SUPPLY("vdd_rtc", NULL),
74 REGULATOR_SUPPLY("vdd_aon", NULL),
75};
76static struct regulator_consumer_supply tps658621_ldo3_supply[] = {
77 REGULATOR_SUPPLY("vdd_ldo3", NULL),
78 REGULATOR_SUPPLY("avdd_usb", NULL),
79 REGULATOR_SUPPLY("avdd_usb_pll", NULL),
80};
81static struct regulator_consumer_supply tps658621_ldo4_supply[] = {
82 REGULATOR_SUPPLY("vdd_ldo4", NULL),
83 REGULATOR_SUPPLY("avdd_osc", NULL),
84 REGULATOR_SUPPLY("vddio_sys", "panjit_touch"),
85};
86static struct regulator_consumer_supply tps658621_ldo5_supply[] = {
87 REGULATOR_SUPPLY("vdd_ldo5", NULL),
88 REGULATOR_SUPPLY("vmmc", "sdhci-tegra.3"),
89};
90static struct regulator_consumer_supply tps658621_ldo6_supply[] = {
91 REGULATOR_SUPPLY("vdd_ldo6", NULL),
92 REGULATOR_SUPPLY("vcsi", "tegra_camera"),
93 REGULATOR_SUPPLY("vdd_dmic", "tegra-snd-wm8903.0"),
94 REGULATOR_SUPPLY("vdd_i2c", "3-0030"),
95 REGULATOR_SUPPLY("vdd_i2c", "6-0072"),
96 REGULATOR_SUPPLY("vdd_i2c", "7-0072"),
97};
98static struct regulator_consumer_supply tps658621_ldo7_supply[] = {
99 REGULATOR_SUPPLY("vdd_ldo7", NULL),
100 REGULATOR_SUPPLY("avdd_hdmi", NULL),
101 REGULATOR_SUPPLY("vdd_fuse", NULL),
102};
103static struct regulator_consumer_supply tps658621_ldo8_supply[] = {
104 REGULATOR_SUPPLY("vdd_ldo8", NULL),
105 REGULATOR_SUPPLY("avdd_hdmi_pll", NULL),
106};
107static struct regulator_consumer_supply tps658621_ldo9_supply[] = {
108 REGULATOR_SUPPLY("vdd_ldo9", NULL),
109 REGULATOR_SUPPLY("avdd_2v85", NULL),
110 REGULATOR_SUPPLY("vdd_ddr_rx", NULL),
111 REGULATOR_SUPPLY("vdd_spk_amp", "tegra-snd-wm8903.0"),
112};
113
114static struct tps6586x_settings sm0_config = {
115 .sm_pwm_mode = PWM_DEFAULT_VALUE,
116 .slew_rate = SLEW_RATE_3520UV_PER_SEC,
117};
118
119static struct tps6586x_settings sm1_config = {
120 /*
121 * Current TPS6586x is known for having a voltage glitch if current load
122 * changes from low to high in auto PWM/PFM mode for CPU's Vdd line.
123 */
124 .sm_pwm_mode = PWM_ONLY,
125 .slew_rate = SLEW_RATE_3520UV_PER_SEC,
126};
127
128#define REGULATOR_INIT(_id, _minmv, _maxmv, on, config) \
129 { \
130 .constraints = { \
131 .min_uV = (_minmv)*1000, \
132 .max_uV = (_maxmv)*1000, \
133 .valid_modes_mask = (REGULATOR_MODE_NORMAL | \
134 REGULATOR_MODE_STANDBY), \
135 .valid_ops_mask = (REGULATOR_CHANGE_MODE | \
136 REGULATOR_CHANGE_STATUS | \
137 REGULATOR_CHANGE_VOLTAGE), \
138 .always_on = on, \
139 .apply_uV = 1, \
140 }, \
141 .num_consumer_supplies = ARRAY_SIZE(tps658621_##_id##_supply),\
142 .consumer_supplies = tps658621_##_id##_supply, \
143 .driver_data = config, \
144 }
145
146#define ON 1
147#define OFF 0
148
149static struct regulator_init_data sm0_data = REGULATOR_INIT(sm0, 725, 1500, ON, &sm0_config);
150static struct regulator_init_data sm1_data = REGULATOR_INIT(sm1, 725, 1500, ON, &sm1_config);
151static struct regulator_init_data sm2_data = REGULATOR_INIT(sm2, 3000, 4550, ON, NULL);
152static struct regulator_init_data ldo0_data = REGULATOR_INIT(ldo0, 1250, 3300, OFF, NULL);
153static struct regulator_init_data ldo1_data = REGULATOR_INIT(ldo1, 725, 1500, ON, NULL);
154static struct regulator_init_data ldo2_data = REGULATOR_INIT(ldo2, 725, 1500, OFF, NULL);
155static struct regulator_init_data ldo3_data = REGULATOR_INIT(ldo3, 1250, 3300, OFF, NULL);
156static struct regulator_init_data ldo4_data = REGULATOR_INIT(ldo4, 1700, 2475, ON, NULL);
157static struct regulator_init_data ldo5_data = REGULATOR_INIT(ldo5, 1250, 3300, ON, NULL);
158static struct regulator_init_data ldo6_data = REGULATOR_INIT(ldo6, 1800, 1800, OFF, NULL);
159static struct regulator_init_data ldo7_data = REGULATOR_INIT(ldo7, 1250, 3300, OFF, NULL);
160static struct regulator_init_data ldo8_data = REGULATOR_INIT(ldo8, 1250, 3300, OFF, NULL);
161static struct regulator_init_data ldo9_data = REGULATOR_INIT(ldo9, 1250, 3300, ON, NULL);
162
163static struct tps6586x_rtc_platform_data rtc_data = {
164 .irq = TEGRA_NR_IRQS + TPS6586X_INT_RTC_ALM1,
165 .start = {
166 .year = 2009,
167 .month = 1,
168 .day = 1,
169 },
170 .cl_sel = TPS6586X_RTC_CL_SEL_1_5PF /* use lowest (external 20pF cap) */
171};
172
173#define TPS_REG(_id, _data) \
174 { \
175 .id = TPS6586X_ID_##_id, \
176 .name = "tps6586x-regulator", \
177 .platform_data = _data, \
178 }
179
180static struct tps6586x_subdev_info tps_devs[] = {
181 TPS_REG(SM_0, &sm0_data),
182 TPS_REG(SM_1, &sm1_data),
183 TPS_REG(SM_2, &sm2_data),
184 TPS_REG(LDO_0, &ldo0_data),
185 TPS_REG(LDO_1, &ldo1_data),
186 TPS_REG(LDO_2, &ldo2_data),
187 TPS_REG(LDO_3, &ldo3_data),
188 TPS_REG(LDO_4, &ldo4_data),
189 TPS_REG(LDO_5, &ldo5_data),
190 TPS_REG(LDO_6, &ldo6_data),
191 TPS_REG(LDO_7, &ldo7_data),
192 TPS_REG(LDO_8, &ldo8_data),
193 TPS_REG(LDO_9, &ldo9_data),
194 {
195 .id = 0,
196 .name = "tps6586x-rtc",
197 .platform_data = &rtc_data,
198 },
199};
200
201static struct tps6586x_platform_data tps_platform = {
202 .irq_base = TPS6586X_INT_BASE,
203 .num_subdevs = ARRAY_SIZE(tps_devs),
204 .subdevs = tps_devs,
205 .gpio_base = TPS6586X_GPIO_BASE,
206 .use_power_off = true,
207};
208
209static struct i2c_board_info __initdata ventana_regulators[] = {
210 {
211 I2C_BOARD_INFO("tps6586x", 0x34),
212 .irq = INT_EXTERNAL_PMU,
213 .platform_data = &tps_platform,
214 },
215};
216
217static void ventana_board_suspend(int lp_state, enum suspend_stage stg)
218{
219 if ((lp_state == TEGRA_SUSPEND_LP1) && (stg == TEGRA_SUSPEND_BEFORE_CPU))
220 tegra_console_uart_suspend();
221}
222
223static void ventana_board_resume(int lp_state, enum resume_stage stg)
224{
225 if ((lp_state == TEGRA_SUSPEND_LP1) && (stg == TEGRA_RESUME_AFTER_CPU))
226 tegra_console_uart_resume();
227}
228
229static struct tegra_suspend_platform_data ventana_suspend_data = {
230 /*
231 * Check power on time and crystal oscillator start time
232 * for appropriate settings.
233 */
234 .cpu_timer = 2000,
235 .cpu_off_timer = 100,
236 .suspend_mode = TEGRA_SUSPEND_LP0,
237 .core_timer = 0x7e7e,
238 .core_off_timer = 0xf,
239 .corereq_high = false,
240 .sysclkreq_high = true,
241 .board_suspend = ventana_board_suspend,
242 .board_resume = ventana_board_resume,
243};
244
245static struct regulator_consumer_supply pnl_pwr_consumer_supply[] = {
246 REGULATOR_SUPPLY("pnl_pwr", NULL),
247};
248
249FIXED_VOLTAGE_REG_INIT(2, pnl_pwr, 2800000, PANEL_POWER_EN_GPIO,
250 0, 1, 0, REGULATOR_CHANGE_STATUS, 0);
251
252static struct platform_device *fixed_voltage_regulators[] __initdata = {
253 ADD_FIXED_VOLTAGE_REG(pnl_pwr),
254};
255
256int __init ventana_fixed_voltage_regulator_init(void)
257{
258 int i;
259
260 for (i = 0; i < ARRAY_SIZE(fixed_voltage_regulators); ++i) {
261 struct fixed_voltage_config *fixed_voltage_regulators_pdata =
262 fixed_voltage_regulators[i]->dev.platform_data;
263 if (fixed_voltage_regulators_pdata->gpio < TEGRA_NR_GPIOS)
264 tegra_gpio_enable(fixed_voltage_regulators_pdata->gpio);
265 }
266 return platform_add_devices(fixed_voltage_regulators,
267 ARRAY_SIZE(fixed_voltage_regulators));
268}
269
270int __init ventana_regulator_init(void)
271{
272 void __iomem *pmc = IO_ADDRESS(TEGRA_PMC_BASE);
273 void __iomem *chip_id = IO_ADDRESS(TEGRA_APB_MISC_BASE) + 0x804;
274 u32 pmc_ctrl;
275 u32 minor;
276
277 minor = (readl(chip_id) >> 16) & 0xf;
278 /* A03 (but not A03p) chips do not support LP0 */
279 if (minor == 3 && !(tegra_spare_fuse(18) || tegra_spare_fuse(19)))
280 ventana_suspend_data.suspend_mode = TEGRA_SUSPEND_LP1;
281
282 /* configure the power management controller to trigger PMU
283 * interrupts when low */
284 pmc_ctrl = readl(pmc + PMC_CTRL);
285 writel(pmc_ctrl | PMC_CTRL_INTR_LOW, pmc + PMC_CTRL);
286
287 i2c_register_board_info(4, ventana_regulators, 1);
288
289// regulator_has_full_constraints();
290
291 tegra_init_suspend(&ventana_suspend_data);
292
293 ventana_fixed_voltage_regulator_init();
294
295 return 0;
296}
297
298static char *ventana_battery[] = {
299 "battery",
300};
301
302static struct gpio_charger_platform_data ventana_charger_pdata = {
303 .name = "ac",
304 .type = POWER_SUPPLY_TYPE_MAINS,
305 .gpio = AC_PRESENT_GPIO,
306 .gpio_active_low = 1,
307 .supplied_to = ventana_battery,
308 .num_supplicants = ARRAY_SIZE(ventana_battery),
309};
310
311static struct platform_device ventana_charger_device = {
312 .name = "gpio-charger",
313 .dev = {
314 .platform_data = &ventana_charger_pdata,
315 },
316};
317
318int __init ventana_charger_init(void)
319{
320 tegra_gpio_enable(AC_PRESENT_GPIO);
321 platform_device_register(&ventana_charger_device);
322 return 0;
323}
324
325static int __init ventana_pcie_init(void)
326{
327 int ret;
328
329 if (!machine_is_ventana())
330 return 0;
331
332 ret = gpio_request(TPS6586X_GPIO_BASE, "pcie_vdd");
333 if (ret < 0)
334 goto fail;
335
336 ret = gpio_direction_output(TPS6586X_GPIO_BASE, 1);
337 if (ret < 0)
338 goto fail;
339
340 gpio_export(TPS6586X_GPIO_BASE, false);
341 return 0;
342
343fail:
344 pr_err("%s: gpio_request failed #%d\n", __func__, TPS6586X_GPIO_BASE);
345 gpio_free(TPS6586X_GPIO_BASE);
346 return ret;
347}
348
349static struct regulator_consumer_supply cam1_2v8_consumer_supply[] = {
350 REGULATOR_SUPPLY("cam1_2v8", NULL),
351};
352
353static struct regulator_consumer_supply cam2_2v8_consumer_supply[] = {
354 REGULATOR_SUPPLY("cam2_2v8", NULL),
355};
356
357FIXED_VOLTAGE_REG_INIT(0, cam1_2v8, 2800000, CAM1_LDO_SHUTDN_L_GPIO,
358 0, 1, 0, REGULATOR_CHANGE_STATUS, 0);
359FIXED_VOLTAGE_REG_INIT(1, cam2_2v8, 2800000, CAM2_LDO_SHUTDN_L_GPIO,
360 0, 1, 0, REGULATOR_CHANGE_STATUS, 0);
361
362static struct platform_device *cam_fixed_voltage_regulators[] __initdata = {
363 ADD_FIXED_VOLTAGE_REG(cam1_2v8),
364 ADD_FIXED_VOLTAGE_REG(cam2_2v8),
365};
366
367int __init ventana_cam_fixed_voltage_regulator_init(void)
368{
369 return platform_add_devices(cam_fixed_voltage_regulators,
370 ARRAY_SIZE(cam_fixed_voltage_regulators));
371}
372
373late_initcall(ventana_pcie_init);