diff options
author | Jonathan Herman <hermanjl@cs.unc.edu> | 2013-01-22 10:38:37 -0500 |
---|---|---|
committer | Jonathan Herman <hermanjl@cs.unc.edu> | 2013-01-22 10:38:37 -0500 |
commit | fcc9d2e5a6c89d22b8b773a64fb4ad21ac318446 (patch) | |
tree | a57612d1888735a2ec7972891b68c1ac5ec8faea /arch/arm/mach-tegra/p852/board-p852-power.c | |
parent | 8dea78da5cee153b8af9c07a2745f6c55057fe12 (diff) |
Diffstat (limited to 'arch/arm/mach-tegra/p852/board-p852-power.c')
-rw-r--r-- | arch/arm/mach-tegra/p852/board-p852-power.c | 209 |
1 files changed, 209 insertions, 0 deletions
diff --git a/arch/arm/mach-tegra/p852/board-p852-power.c b/arch/arm/mach-tegra/p852/board-p852-power.c new file mode 100644 index 00000000000..71f6e85d25c --- /dev/null +++ b/arch/arm/mach-tegra/p852/board-p852-power.c | |||
@@ -0,0 +1,209 @@ | |||
1 | /* | ||
2 | * arch/arm/mach-tegra/p852/board-p852-power.c | ||
3 | * | ||
4 | * Copyright (c) 2010-2011, NVIDIA Corporation. | ||
5 | * | ||
6 | * This software is licensed under the terms of the GNU General Public | ||
7 | * License version 2, as published by the Free Software Foundation, and | ||
8 | * may be copied, distributed, and modified under those terms. | ||
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 | */ | ||
16 | |||
17 | #include <linux/i2c.h> | ||
18 | #include <linux/pda_power.h> | ||
19 | #include <linux/platform_device.h> | ||
20 | #include <linux/resource.h> | ||
21 | #include <linux/regulator/machine.h> | ||
22 | #include <linux/mfd/tps6586x.h> | ||
23 | #include <linux/gpio.h> | ||
24 | #include <linux/io.h> | ||
25 | #include <mach/iomap.h> | ||
26 | #include <mach/irqs.h> | ||
27 | #include "board-p852.h" | ||
28 | |||
29 | #define PMC_CTRL 0x0 | ||
30 | #define PMC_CTRL_INTR_LOW (1 << 17) | ||
31 | |||
32 | static struct regulator_consumer_supply tps658621_sm0_supply[] = { | ||
33 | REGULATOR_SUPPLY("vdd_core", NULL), | ||
34 | }; | ||
35 | static struct regulator_consumer_supply tps658621_sm1_supply[] = { | ||
36 | REGULATOR_SUPPLY("vdd_cpu", NULL), | ||
37 | }; | ||
38 | static struct regulator_consumer_supply tps658621_sm2_supply[] = { | ||
39 | REGULATOR_SUPPLY("vdd_sm2", NULL), | ||
40 | }; | ||
41 | static struct regulator_consumer_supply tps658621_ldo0_supply[] = { | ||
42 | REGULATOR_SUPPLY("vddio_pex_clk", NULL), | ||
43 | }; | ||
44 | static struct regulator_consumer_supply tps658621_ldo1_supply[] = { | ||
45 | REGULATOR_SUPPLY("avdd_pll", NULL), | ||
46 | REGULATOR_SUPPLY("avdd_plla_pc", NULL), | ||
47 | REGULATOR_SUPPLY("avdd_pllm", NULL), | ||
48 | REGULATOR_SUPPLY("avdd_pllu", NULL), | ||
49 | REGULATOR_SUPPLY("avdd_pllx6", NULL), | ||
50 | }; | ||
51 | static struct regulator_consumer_supply tps658621_ldo2_supply[] = { | ||
52 | REGULATOR_SUPPLY("vdd_rtc", NULL), | ||
53 | }; | ||
54 | static struct regulator_consumer_supply tps658621_ldo3_supply[] = { | ||
55 | REGULATOR_SUPPLY("avdd_usb", NULL), | ||
56 | REGULATOR_SUPPLY("avdd_usb_pll", NULL), | ||
57 | REGULATOR_SUPPLY("avdd_lvds", NULL), | ||
58 | }; | ||
59 | static struct regulator_consumer_supply tps658621_ldo4_supply[] = { | ||
60 | REGULATOR_SUPPLY("avdd_osc", NULL), | ||
61 | REGULATOR_SUPPLY("vddio_sys", "panjit_touch"), | ||
62 | }; | ||
63 | static struct regulator_consumer_supply tps658621_ldo5_supply[] = { | ||
64 | REGULATOR_SUPPLY("vddio_lcd", NULL), | ||
65 | }; | ||
66 | static struct regulator_consumer_supply tps658621_ldo6_supply[] = { | ||
67 | REGULATOR_SUPPLY("avdd_vdac", NULL), | ||
68 | }; | ||
69 | static struct regulator_consumer_supply tps658621_ldo7_supply[] = { | ||
70 | REGULATOR_SUPPLY("vddio_vi", NULL), | ||
71 | REGULATOR_SUPPLY("vdd_fuse", NULL), | ||
72 | REGULATOR_SUPPLY("vspi", "spi_tegra.0"), | ||
73 | }; | ||
74 | static struct regulator_consumer_supply tps658621_ldo8_supply[] = { | ||
75 | REGULATOR_SUPPLY("vddio_bb", NULL), | ||
76 | REGULATOR_SUPPLY("vmmc", "sdhci-tegra.0"), | ||
77 | REGULATOR_SUPPLY("vmmc", "sdhci-tegra.2"), | ||
78 | }; | ||
79 | static struct regulator_consumer_supply tps658621_ldo9_supply[] = { | ||
80 | REGULATOR_SUPPLY("vdd_ddr_rx", NULL), | ||
81 | REGULATOR_SUPPLY("vmmc", "sdhci-tegra.3"), | ||
82 | }; | ||
83 | |||
84 | #define REGULATOR_INIT(_id, _minmv, _maxmv) \ | ||
85 | { \ | ||
86 | .constraints = { \ | ||
87 | .min_uV = (_minmv)*1000, \ | ||
88 | .max_uV = (_maxmv)*1000, \ | ||
89 | .valid_modes_mask = (REGULATOR_MODE_NORMAL | \ | ||
90 | REGULATOR_MODE_STANDBY), \ | ||
91 | .valid_ops_mask = (REGULATOR_CHANGE_MODE | \ | ||
92 | REGULATOR_CHANGE_STATUS | \ | ||
93 | REGULATOR_CHANGE_VOLTAGE), \ | ||
94 | }, \ | ||
95 | .num_consumer_supplies = ARRAY_SIZE(tps658621_##_id##_supply),\ | ||
96 | .consumer_supplies = tps658621_##_id##_supply, \ | ||
97 | } | ||
98 | |||
99 | static struct regulator_init_data sm0_data = REGULATOR_INIT(sm0, 725, 1500); | ||
100 | static struct regulator_init_data sm1_data = REGULATOR_INIT(sm1, 725, 1500); | ||
101 | static struct regulator_init_data sm2_data = REGULATOR_INIT(sm2, 3000, 4550); | ||
102 | static struct regulator_init_data ldo0_data = REGULATOR_INIT(ldo0, 1250, 3300); | ||
103 | static struct regulator_init_data ldo1_data = REGULATOR_INIT(ldo1, 725, 1500); | ||
104 | static struct regulator_init_data ldo2_data = REGULATOR_INIT(ldo2, 725, 1225); | ||
105 | static struct regulator_init_data ldo3_data = REGULATOR_INIT(ldo3, 1250, 3300); | ||
106 | static struct regulator_init_data ldo4_data = REGULATOR_INIT(ldo4, 1700, 2475); | ||
107 | static struct regulator_init_data ldo5_data = REGULATOR_INIT(ldo5, 1250, 3300); | ||
108 | static struct regulator_init_data ldo6_data = REGULATOR_INIT(ldo6, 1250, 3300); | ||
109 | static struct regulator_init_data ldo7_data = REGULATOR_INIT(ldo7, 1250, 3300); | ||
110 | static struct regulator_init_data ldo8_data = REGULATOR_INIT(ldo8, 1250, 3300); | ||
111 | static struct regulator_init_data ldo9_data = REGULATOR_INIT(ldo9, 1250, 3300); | ||
112 | |||
113 | |||
114 | static struct tps6586x_rtc_platform_data rtc_data = { | ||
115 | .irq = TEGRA_NR_IRQS + TPS6586X_INT_RTC_ALM1, | ||
116 | .cl_sel = 0, | ||
117 | }; | ||
118 | |||
119 | |||
120 | #define TPS_REG(_id, _data) \ | ||
121 | { \ | ||
122 | .id = TPS6586X_ID_##_id, \ | ||
123 | .name = "tps6586x-regulator", \ | ||
124 | .platform_data = _data, \ | ||
125 | } | ||
126 | |||
127 | static struct tps6586x_subdev_info tps_devs[] = { | ||
128 | TPS_REG(SM_0, &sm0_data), | ||
129 | TPS_REG(SM_1, &sm1_data), | ||
130 | TPS_REG(SM_2, &sm2_data), | ||
131 | TPS_REG(LDO_0, &ldo0_data), | ||
132 | TPS_REG(LDO_1, &ldo1_data), | ||
133 | TPS_REG(LDO_2, &ldo2_data), | ||
134 | TPS_REG(LDO_3, &ldo3_data), | ||
135 | TPS_REG(LDO_4, &ldo4_data), | ||
136 | TPS_REG(LDO_5, &ldo5_data), | ||
137 | TPS_REG(LDO_6, &ldo6_data), | ||
138 | TPS_REG(LDO_7, &ldo7_data), | ||
139 | TPS_REG(LDO_8, &ldo8_data), | ||
140 | TPS_REG(LDO_9, &ldo9_data), | ||
141 | { | ||
142 | .id = 0, | ||
143 | .name = "tps6586x-rtc", | ||
144 | .platform_data = &rtc_data, | ||
145 | }, | ||
146 | }; | ||
147 | |||
148 | static struct tps6586x_platform_data tps_platform = { | ||
149 | .irq_base = TEGRA_NR_IRQS, | ||
150 | .num_subdevs = ARRAY_SIZE(tps_devs), | ||
151 | .subdevs = tps_devs, | ||
152 | .gpio_base = TEGRA_NR_GPIOS, | ||
153 | .use_power_off = true, | ||
154 | }; | ||
155 | |||
156 | static struct i2c_board_info __initdata p852_regulators[] = { | ||
157 | { | ||
158 | I2C_BOARD_INFO("tps6586x", 0x34), | ||
159 | .irq = INT_EXTERNAL_PMU, | ||
160 | .platform_data = &tps_platform, | ||
161 | }, | ||
162 | }; | ||
163 | |||
164 | static struct tegra_suspend_platform_data p852_suspend_data = { | ||
165 | .cpu_timer = 2000, | ||
166 | .cpu_off_timer = 0, | ||
167 | .suspend_mode = TEGRA_SUSPEND_LP1, | ||
168 | .core_timer = 0x7e7e, | ||
169 | .core_off_timer = 0, | ||
170 | .corereq_high = false, | ||
171 | .sysclkreq_high = true, | ||
172 | }; | ||
173 | |||
174 | static void __init tps6586x_rtc_preinit(void) | ||
175 | { | ||
176 | int i; | ||
177 | struct tps6586x_rtc_platform_data *rtc_pdata; | ||
178 | |||
179 | if (system_rev == P852_SKU23_B00 || | ||
180 | system_rev == P852_SKU23_C01 || | ||
181 | system_rev == P852_SKU13_B00 || | ||
182 | system_rev == P852_SKU5_B00 || | ||
183 | system_rev == P852_SKU5_C01) { | ||
184 | for (i = 0; i < tps_platform.num_subdevs; ++i) | ||
185 | if (!strcmp(tps_platform.subdevs[i].name, | ||
186 | "tps6586x-rtc")) | ||
187 | rtc_pdata = | ||
188 | (struct tps6586x_rtc_platform_data *) | ||
189 | (tps_platform.subdevs[i].platform_data); | ||
190 | rtc_pdata->cl_sel = TPS6586X_RTC_CL_SEL_1_5PF; | ||
191 | } | ||
192 | } | ||
193 | |||
194 | int __init p852_regulator_init(void) | ||
195 | { | ||
196 | void __iomem *pmc = IO_ADDRESS(TEGRA_PMC_BASE); | ||
197 | u32 pmc_ctrl; | ||
198 | |||
199 | /* configure the power management controller to trigger PMU | ||
200 | * interrupts when low */ | ||
201 | pmc_ctrl = readl(pmc + PMC_CTRL); | ||
202 | writel(pmc_ctrl | PMC_CTRL_INTR_LOW, pmc + PMC_CTRL); | ||
203 | i2c_register_board_info(3, p852_regulators, 1); | ||
204 | tegra_init_suspend(&p852_suspend_data); | ||
205 | |||
206 | tps6586x_rtc_preinit(); | ||
207 | |||
208 | return 0; | ||
209 | } | ||