ARM: tegra: loki: fix build error due to warning
[linux-3.10.git] / arch / arm / mach-tegra / board-bonaire-power.c
1 /*
2  * Copyright (C) 2011 NVIDIA, Inc.
3  * Copyright (c) 2013 NVIDIA CORPORATION. All rights reserved.
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
17  * 02111-1307, USA
18  */
19 #include <linux/i2c.h>
20 #include <linux/pda_power.h>
21 #include <linux/platform_device.h>
22 #include <linux/resource.h>
23 #include <linux/io.h>
24 #include <linux/regulator/machine.h>
25 #include <linux/gpio.h>
26 #include <linux/regulator/driver.h>
27 #include <linux/regulator/gpio-regulator.h>
28 #include <linux/regulator/fixed.h>
29
30 #include <mach/gpio-tegra.h>
31 #include <mach/irqs.h>
32 #include <mach/gpio-tegra.h>
33
34 #include "pm.h"
35 #include "board.h"
36 #include "gpio-names.h"
37 #include "iomap.h"
38
39 static int ac_online(void)
40 {
41         return 1;
42 }
43
44 static struct regulator_consumer_supply gpio_reg_sdmmc3_vdd_sel_supply[] = {
45         REGULATOR_SUPPLY("vddio_sdmmc", "sdhci-tegra.2"),
46 };
47
48 static struct gpio_regulator_state gpio_reg_sdmmc3_vdd_sel_states[] = {
49         {
50                 .gpios = 0,
51                 .value = 1800000,
52         },
53         {
54                 .gpios = 1,
55                 .value = 3300000,
56         },
57 };
58
59 static struct gpio gpio_reg_sdmmc3_vdd_sel_gpios[] = {
60         {
61                 .gpio = TEGRA_GPIO_PV1,
62                 .flags = 0,
63                 .label = "sdmmc3_vdd_sel",
64         },
65 };
66
67 #define GPIO_REG(_id, _name, _input_supply, _active_high,       \
68                 _boot_state, _delay_us, _minmv, _maxmv)         \
69         static struct regulator_init_data ri_data_##_name =     \
70 {                                                               \
71         .supply_regulator = NULL,                               \
72         .num_consumer_supplies =                                \
73                 ARRAY_SIZE(gpio_reg_##_name##_supply),          \
74         .consumer_supplies = gpio_reg_##_name##_supply,         \
75         .constraints = {                                        \
76                 .name = "gpio_reg_"#_name,                      \
77                 .min_uV = (_minmv)*1000,                        \
78                 .max_uV = (_maxmv)*1000,                        \
79                 .valid_modes_mask = (REGULATOR_MODE_NORMAL |    \
80                                 REGULATOR_MODE_STANDBY),        \
81                 .valid_ops_mask = (REGULATOR_CHANGE_MODE |      \
82                                 REGULATOR_CHANGE_STATUS |       \
83                                 REGULATOR_CHANGE_VOLTAGE),      \
84         },                                                      \
85 };                                                              \
86 static struct gpio_regulator_config gpio_reg_##_name##_pdata =  \
87 {                                                               \
88         .supply_name = "vddio_sdmmc",                           \
89         .enable_gpio = -EINVAL,                                 \
90         .enable_high = _active_high,                            \
91         .enabled_at_boot = _boot_state,                         \
92         .startup_delay = _delay_us,                             \
93         .gpios = gpio_reg_##_name##_gpios,                      \
94         .nr_gpios = ARRAY_SIZE(gpio_reg_##_name##_gpios),       \
95         .states = gpio_reg_##_name##_states,                    \
96         .nr_states = ARRAY_SIZE(gpio_reg_##_name##_states),     \
97         .type = REGULATOR_VOLTAGE,                              \
98         .init_data = &ri_data_##_name,                          \
99 };                                                              \
100 static struct platform_device gpio_reg_##_name##_dev = {        \
101         .name   = "gpio-regulator",                             \
102         .id = _id,                                              \
103         .dev    = {                                             \
104                 .platform_data = &gpio_reg_##_name##_pdata,     \
105         },                                                      \
106 }
107
108 GPIO_REG(4, sdmmc3_vdd_sel, NULL, true, true, 0, 1000, 3300);
109
110 #define ADD_GPIO_REG(_name) (&gpio_reg_##_name##_dev)
111 static struct platform_device *gpio_regs_devices[] = {
112         ADD_GPIO_REG(sdmmc3_vdd_sel),
113 };
114
115 static struct resource bonaire_pda_resources[] = {
116         [0] = {
117                 .name   = "ac",
118         },
119 };
120
121 static struct pda_power_pdata bonaire_pda_data = {
122         .is_ac_online   = ac_online,
123 };
124
125 static struct platform_device bonaire_pda_power_device = {
126         .name           = "pda-power",
127         .id             = -1,
128         .resource       = bonaire_pda_resources,
129         .num_resources  = ARRAY_SIZE(bonaire_pda_resources),
130         .dev    = {
131                 .platform_data  = &bonaire_pda_data,
132         },
133 };
134
135 static struct regulator_consumer_supply fixed_reg_en_battery_supply[] = {
136         REGULATOR_SUPPLY("vpp_fuse", NULL),
137 };
138
139 #define FIXED_SUPPLY(_name) "fixed_reg_en"#_name
140 #define FIXED_REG(_id, _var, _name, _in_supply, _always_on, _boot_on,   \
141         _gpio_nr, _open_drain, _active_high, _boot_state, _millivolts,  \
142         _sdelay)                                                        \
143         static struct regulator_init_data ri_data_##_var =              \
144         {                                                               \
145                 .supply_regulator = _in_supply,                         \
146                 .num_consumer_supplies =                                \
147                         ARRAY_SIZE(fixed_reg_en_##_name##_supply),      \
148                 .consumer_supplies = fixed_reg_en_##_name##_supply,     \
149                 .constraints = {                                        \
150                         .valid_modes_mask = (REGULATOR_MODE_NORMAL |    \
151                                         REGULATOR_MODE_STANDBY),        \
152                         .valid_ops_mask = (REGULATOR_CHANGE_MODE |      \
153                                         REGULATOR_CHANGE_STATUS |       \
154                                         REGULATOR_CHANGE_VOLTAGE),      \
155                         .always_on = _always_on,                        \
156                         .boot_on = _boot_on,                            \
157                 },                                                      \
158         };                                                              \
159         static struct fixed_voltage_config fixed_reg_en_##_var##_pdata = \
160         {                                                               \
161                 .supply_name = FIXED_SUPPLY(_name),                     \
162                 .microvolts = _millivolts * 1000,                       \
163                 .gpio = _gpio_nr,                                       \
164                 .gpio_is_open_drain = _open_drain,                      \
165                 .enable_high = _active_high,                            \
166                 .enabled_at_boot = _boot_state,                         \
167                 .init_data = &ri_data_##_var,                           \
168                 .startup_delay = _sdelay                                \
169         };                                                              \
170         static struct platform_device fixed_reg_en_##_var##_dev = {     \
171                 .name = "reg-fixed-voltage",                            \
172                 .id = _id,                                              \
173                 .dev = {                                                \
174                         .platform_data = &fixed_reg_en_##_var##_pdata,  \
175                 },                                                      \
176         }
177
178 FIXED_REG(0,    battery,        battery,
179         NULL,   0,      0,
180         -1,     false, true,    0,      3300,   0);
181
182 static struct platform_device *pfixed_reg_devs[] = {
183         &fixed_reg_en_battery_dev,
184 };
185
186 static struct tegra_suspend_platform_data bonaire_suspend_data = {
187         .cpu_timer      = 2000,
188         .cpu_off_timer  = 0,
189         .suspend_mode   = TEGRA_SUSPEND_NONE,
190         .core_timer     = 0x7e7e,
191         .core_off_timer = 0,
192         .corereq_high   = false,
193         .sysclkreq_high = true,
194 };
195
196 int __init bonaire_regulator_init(void)
197 {
198         platform_device_register(&bonaire_pda_power_device);
199         platform_add_devices(pfixed_reg_devs, ARRAY_SIZE(pfixed_reg_devs));
200         return platform_add_devices(gpio_regs_devices,
201                 ARRAY_SIZE(gpio_regs_devices));
202 }
203
204 int __init bonaire_suspend_init(void)
205 {
206         tegra_init_suspend(&bonaire_suspend_data);
207         return 0;
208 }
209
210
211 #define COSIM_SHUTDOWN_REG         0x538f0ffc
212
213 static void bonaire_power_off(void)
214 {
215         pr_err("Bonaire: Powering off the device\n");
216         writel(1, IO_ADDRESS(COSIM_SHUTDOWN_REG));
217         while (1)
218                 ;
219 }
220
221 int __init bonaire_power_off_init(void)
222 {
223         pm_power_off = bonaire_power_off;
224         return 0;
225 }