ARM: tegra12: set CPU rate to 2.2GHz for sku 0x87
[linux-3.10.git] / arch / arm / mach-tegra / board-pmu-defines.h
1 /*
2  * board-pmu-defines.h: Most of macro definition used in board-xxx-power files.
3  *
4  * Copyright (c) 2013, NVIDIA Corporation. All rights reserved.
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, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
13  * more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
18  */
19
20 #ifndef _MACH_TEGRA_BOARD_PMU_DEFINES_H
21 #define _MACH_TEGRA_BOARD_PMU_DEFINES_H
22
23 #define REGULATOR_MODE_0        0
24 #define PALMAS_PDATA_INIT(_name, _minmv, _maxmv, _supply_reg,           \
25         _always_on, _boot_on, _apply_uv, _init_mode)                    \
26         static struct regulator_init_data reg_idata_##_name = {         \
27                 .constraints = {                                        \
28                         .name = palmas_rails(_name),                    \
29                         .min_uV = (_minmv)*1000,                        \
30                         .max_uV = (_maxmv)*1000,                        \
31                         .valid_modes_mask = (REGULATOR_MODE_NORMAL |    \
32                                         REGULATOR_MODE_STANDBY),        \
33                         .valid_ops_mask = (REGULATOR_CHANGE_MODE |      \
34                                         REGULATOR_CHANGE_STATUS |       \
35                                         REGULATOR_CHANGE_VOLTAGE),      \
36                         .always_on = _always_on,                        \
37                         .boot_on = _boot_on,                            \
38                         .apply_uV = _apply_uv,                          \
39                         .initial_mode = REGULATOR_MODE_##_init_mode,    \
40                 },                                                      \
41                 .num_consumer_supplies =                                \
42                         ARRAY_SIZE(palmas_##_name##_supply),            \
43                 .consumer_supplies = palmas_##_name##_supply,           \
44                 .supply_regulator = _supply_reg,                        \
45         }
46
47
48 #define PALMAS_PINMUX(_pin, _mux, _pud, _od)                            \
49 {                                                                       \
50         .pin = _pin,                                                    \
51         .function = _mux,                                               \
52         .prop_bias_pull = _pud,                                         \
53         .prop_open_drain = _od,                                         \
54 }
55
56 #define PALMAS_REGS_PDATA(_name, _minmv, _maxmv, _supply_reg,           \
57         _always_on, _boot_on, _apply_uv, _init_mode,                    \
58         _warm_reset, _roof_floor, _mode_sleep, _ramp_us, _vsel)         \
59         static struct regulator_init_data reg_idata_##_name = {         \
60                 .constraints = {                                        \
61                         .name = palmas_rails(_name),                    \
62                         .min_uV = (_minmv)*1000,                        \
63                         .max_uV = (_maxmv)*1000,                        \
64                         .valid_modes_mask = (REGULATOR_MODE_NORMAL |    \
65                                         REGULATOR_MODE_STANDBY),        \
66                         .valid_ops_mask = (REGULATOR_CHANGE_MODE |      \
67                                         REGULATOR_CHANGE_STATUS |       \
68                                         REGULATOR_CHANGE_VOLTAGE),      \
69                         .always_on = _always_on | (_roof_floor != 0),   \
70                         .boot_on = _boot_on | (_roof_floor != 0),       \
71                         .apply_uV = _apply_uv,                          \
72                         .initial_mode = REGULATOR_MODE_##_init_mode,    \
73                         .ramp_delay = _ramp_us,                         \
74                 },                                                      \
75                 .num_consumer_supplies =                                \
76                         ARRAY_SIZE(palmas_##_name##_supply),            \
77                 .consumer_supplies = palmas_##_name##_supply,           \
78                 .supply_regulator = _supply_reg,                        \
79         };                                                              \
80         static struct palmas_reg_init reg_init_data_##_name = {         \
81                 .warm_reset = _warm_reset,                              \
82                 .roof_floor = _roof_floor,                              \
83                 .mode_sleep = _mode_sleep,                              \
84                 .enable_gpio = -EINVAL,                                 \
85                 .vsel = _vsel,                                          \
86         }
87
88 #define AS3722_SUPPLY(_name) "as3722_"#_name
89 #define AMS_PDATA_INIT(_name, _supply_reg, _min_uV, _max_uV, _always_on,\
90                          _boot_on, _apply_uV, _ext_cntrl)               \
91 static struct regulator_init_data as3722_##_name##_reg_idata =          \
92 {                                                                       \
93         .supply_regulator = _supply_reg,                                \
94         .constraints = {                                                \
95                 .name = AS3722_SUPPLY(_name),                           \
96                 .min_uV = _min_uV,                                      \
97                 .max_uV = _max_uV,                                      \
98                 .valid_modes_mask = (REGULATOR_MODE_NORMAL |            \
99                                      REGULATOR_MODE_STANDBY),           \
100                 .valid_ops_mask = (REGULATOR_CHANGE_MODE |              \
101                                    REGULATOR_CHANGE_STATUS |            \
102                                    REGULATOR_CHANGE_VOLTAGE),           \
103                 .always_on = _always_on,                                \
104                 .boot_on = _boot_on,                                    \
105                 .apply_uV = _apply_uV,                                  \
106         },                                                              \
107         .num_consumer_supplies =                                        \
108                 ARRAY_SIZE(as3722_##_name##_supply),                    \
109         .consumer_supplies = as3722_##_name##_supply,                   \
110 };                                                                      \
111 static struct as3722_regulator_platform_data as3722_##_name##_reg_pdata =       \
112 {                                                                       \
113         .reg_init = &as3722_##_name##_reg_idata,                        \
114         .ext_control = _ext_cntrl                                       \
115 }                                                                       \
116
117 #define AS3722_PIN_CONTROL(_pin, _func, _bias_pull, _od, _hi_imp, _gpio_mode)  \
118         {                                                       \
119                 .pin = _pin,                                    \
120                 .function = _func,                              \
121                 .prop_bias_pull = _bias_pull,                   \
122                 .prop_open_drain = _od,                         \
123                 .prop_high_impedance = _hi_imp,                 \
124                 .prop_gpio_mode = _gpio_mode,                   \
125         }
126
127 /* Macro for defining fixed regulator sub device data */
128 #define fixed_sync_supply(_name) "fixed_reg_en_"#_name
129
130 #define FIXED_REG_DRV(_id, _drv, _var, _name, _in_supply,               \
131         _always_on, _boot_on, _gpio_nr, _open_drain,                    \
132         _active_high, _boot_state, _millivolts, _sdelay)                \
133 static struct regulator_init_data ri_data_##_var =                      \
134 {                                                                       \
135         .supply_regulator = _in_supply,                                 \
136         .num_consumer_supplies =                                        \
137                         ARRAY_SIZE(fixed_reg_en_##_name##_supply),      \
138         .consumer_supplies = fixed_reg_en_##_name##_supply,             \
139         .constraints = {                                                \
140                 .valid_modes_mask = (REGULATOR_MODE_NORMAL |            \
141                                         REGULATOR_MODE_STANDBY),        \
142                 .valid_ops_mask = (REGULATOR_CHANGE_MODE |              \
143                                         REGULATOR_CHANGE_STATUS |       \
144                                         REGULATOR_CHANGE_VOLTAGE),      \
145                 .always_on = _always_on,                                \
146                 .boot_on = _boot_on,                                    \
147         },                                                              \
148 };                                                                      \
149 static struct fixed_voltage_config fixed_reg_en_##_var##_pdata =        \
150 {                                                                       \
151         .supply_name = fixed_sync_supply(_name),                        \
152         .microvolts = _millivolts * 1000,                               \
153         .gpio = _gpio_nr,                                               \
154         .gpio_is_open_drain = _open_drain,                              \
155         .enable_high = _active_high,                                    \
156         .enabled_at_boot = _boot_state,                                 \
157         .init_data = &ri_data_##_var,                                   \
158         .startup_delay = _sdelay                                        \
159 };                                                                      \
160 static struct platform_device fixed_reg_en_##_var##_dev = {             \
161         .name = #_drv,                                                  \
162         .id = _id,                                                      \
163         .dev = {                                                        \
164                 .platform_data = &fixed_reg_en_##_var##_pdata,          \
165         },                                                              \
166 }
167
168 #define FIXED_SYNC_REG(_id, _var, _name, _in_supply,                    \
169         _always_on, _boot_on, _gpio_nr, _open_drain,                    \
170         _active_high, _boot_state, _millivolts, _sdelay)                \
171         FIXED_REG_DRV(_id, reg-fixed-sync-voltage, _var, _name,         \
172         _in_supply, _always_on, _boot_on, _gpio_nr, _open_drain,        \
173         _active_high, _boot_state, _millivolts, _sdelay)
174
175 #ifdef CONFIG_ARCH_TEGRA_HAS_CL_DVFS
176 /* Macro definition of dfll bypass device */
177 #define DFLL_BYPASS(_board, _min, _step, _size, _us_sel, _msel_gpio)           \
178 static struct regulator_init_data _board##_dfll_bypass_init_data = {           \
179         .num_consumer_supplies = ARRAY_SIZE(_board##_dfll_bypass_consumers),   \
180         .consumer_supplies = _board##_dfll_bypass_consumers,                   \
181         .constraints = {                                                       \
182                 .valid_modes_mask = (REGULATOR_MODE_IDLE |                     \
183                                 REGULATOR_MODE_NORMAL),                        \
184                 .valid_ops_mask = (REGULATOR_CHANGE_MODE |                     \
185                                 REGULATOR_CHANGE_STATUS |                      \
186                                 REGULATOR_CHANGE_VOLTAGE),                     \
187                 .min_uV = (_min),                                              \
188                 .max_uV = ((_size) - 1) * (_step) + (_min),                    \
189                 .always_on = 1,                                                \
190                 .boot_on = 1,                                                  \
191         },                                                                     \
192 };                                                                             \
193 static struct tegra_dfll_bypass_platform_data _board##_dfll_bypass_pdata = {   \
194         .reg_init_data = &_board##_dfll_bypass_init_data,                      \
195         .uV_step = (_step),                                                    \
196         .linear_min_sel = 0,                                                   \
197         .n_voltages = (_size),                                                 \
198         .voltage_time_sel = _us_sel,                                           \
199         .msel_gpio = _msel_gpio,                                               \
200 };                                                                             \
201 static struct platform_device _board##_dfll_bypass_dev = {                     \
202         .name = "tegra_dfll_bypass",                                           \
203         .id = -1,                                                              \
204         .dev = {                                                               \
205                 .platform_data = &_board##_dfll_bypass_pdata,                  \
206         },                                                                     \
207 }
208 #endif
209
210 #endif