738ddabd0170bd4c4117da817d016b600e625e5a
[linux-3.10.git] / arch / arm / mach-tegra / board.h
1 /*
2  * arch/arm/mach-tegra/board.h
3  *
4  * Copyright (C) 2010 Google, Inc.
5  * Copyright (c) 2011-2014, NVIDIA CORPORATION.  All rights reserved.
6  *
7  * Author:
8  *      Colin Cross <ccross@google.com>
9  *      Erik Gilling <konkers@google.com>
10  *
11  * This program is free software; you can redistribute it and/or modify it
12  * under the terms and conditions of the GNU General Public License,
13  * version 2, as published by the Free Software Foundation.
14  *
15  * This program is distributed in the hope it will be useful, but WITHOUT
16  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
17  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
18  * more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
22  */
23
24 #ifndef __MACH_TEGRA_BOARD_H
25 #define __MACH_TEGRA_BOARD_H
26
27 #include <linux/types.h>
28 #include <linux/errno.h>
29 #include <linux/power_supply.h>
30 #include <linux/memory.h>
31
32 #include <mach/tegra_smmu.h>
33
34 #ifdef CONFIG_TEGRA_NVDUMPER
35 #define NVDUMPER_RESERVED_SIZE 4096UL
36 #endif
37
38 #define ADD_FIXED_VOLTAGE_REG(_name)    (&_name##_fixed_voltage_device)
39
40 /* Macro for defining fixed voltage regulator */
41 #define FIXED_VOLTAGE_REG_INIT(_id, _name, _microvolts, _gpio,          \
42                 _startup_delay, _enable_high, _enabled_at_boot,         \
43                 _valid_ops_mask, _always_on)                            \
44         static struct regulator_init_data _name##_initdata = {          \
45                 .consumer_supplies = _name##_consumer_supply,           \
46                 .num_consumer_supplies =                                \
47                                 ARRAY_SIZE(_name##_consumer_supply),    \
48                 .constraints = {                                        \
49                         .valid_ops_mask = _valid_ops_mask ,             \
50                         .always_on = _always_on,                        \
51                 },                                                      \
52         };                                                              \
53         static struct fixed_voltage_config _name##_config = {           \
54                 .supply_name            = #_name,                       \
55                 .microvolts             = _microvolts,                  \
56                 .gpio                   = _gpio,                        \
57                 .startup_delay          = _startup_delay,               \
58                 .enable_high            = _enable_high,                 \
59                 .enabled_at_boot        = _enabled_at_boot,             \
60                 .init_data              = &_name##_initdata,            \
61         };                                                              \
62         static struct platform_device _name##_fixed_voltage_device = {  \
63                 .name                   = "reg-fixed-voltage",          \
64                 .id                     = _id,                          \
65                 .dev                    = {                             \
66                         .platform_data  = &_name##_config,              \
67                 },                                                      \
68         }
69
70 #if defined(CONFIG_TEGRA_NVMAP)
71 #define NVMAP_HEAP_CARVEOUT_IRAM_INIT   \
72         {       .name           = "iram",                                       \
73                 .usage_mask     = NVMAP_HEAP_CARVEOUT_IRAM,                     \
74                 .base           = TEGRA_IRAM_BASE + TEGRA_RESET_HANDLER_SIZE,   \
75                 .size           = TEGRA_IRAM_SIZE - TEGRA_RESET_HANDLER_SIZE,   \
76                 .buddy_size     = 0, /* no buddy allocation for IRAM */         \
77         }
78 #endif
79
80 /* This information is passed by bootloader */
81 #define COMMCHIP_DEFAULT                0
82 #define COMMCHIP_NOCHIP                 1
83 #define COMMCHIP_BROADCOM_BCM4329       2
84 #define COMMCHIP_BROADCOM_BCM4330       3
85 #define COMMCHIP_MARVELL_SD8797         4
86 #define COMMCHIP_TI_WL18XX              5
87 #define COMMCHIP_BROADCOM_BCM43241      6
88
89 struct memory_accessor;
90
91 void tegra_assert_system_reset(char mode, const char *cmd);
92
93 void __init tegra20_init_early(void);
94 void __init tegra30_init_early(void);
95 void __init tegra11x_init_early(void);
96 void __init tegra12x_init_early(void);
97 void __init tegra14x_init_early(void);
98 void __init tegra_map_common_io(void);
99 void __init tegra_reserve(unsigned long carveout_size, unsigned long fb_size,
100         unsigned long fb2_size);
101 int __init tegra_release_bootloader_fb(void);
102 void __init tegra_protected_aperture_init(unsigned long aperture);
103 int  __init tegra_init_board_info(void);
104 void __tegra_move_framebuffer(struct platform_device *pdev,
105                               phys_addr_t to, phys_addr_t from,
106                               size_t size);
107 static inline void tegra_move_framebuffer(phys_addr_t to, phys_addr_t from,
108                                           size_t size)
109 {
110         __tegra_move_framebuffer(NULL, to, from, size);
111 }
112 void __tegra_clear_framebuffer(struct platform_device *pdev,
113                                unsigned long to, unsigned long size);
114 static inline void tegra_clear_framebuffer(unsigned long to, unsigned long size)
115 {
116         __tegra_clear_framebuffer(NULL, to, size);
117 }
118 bool is_tegra_debug_uartport_hs(void);
119 int get_tegra_uart_debug_port_id(void);
120 bool is_uart_over_sd_enabled(void);
121 int get_sd_uart_port_id(void);
122 void set_sd_uart_port_id(int);
123 int __init tegra_register_fuse(void);
124
125 #ifdef CONFIG_PSTORE_RAM
126 void __init tegra_reserve_ramoops_memory(unsigned long ram_console_size);
127 #else
128 static inline void __init
129         tegra_reserve_ramoops_memory(unsigned long ram_console_size)
130 {}
131 #endif
132
133 extern phys_addr_t tegra_bootloader_fb_start;
134 extern phys_addr_t tegra_bootloader_fb_size;
135 extern phys_addr_t tegra_bootloader_fb2_start;
136 extern phys_addr_t tegra_bootloader_fb2_size;
137 extern phys_addr_t tegra_fb_start;
138 extern phys_addr_t tegra_fb_size;
139 extern phys_addr_t tegra_fb2_start;
140 extern phys_addr_t tegra_fb2_size;
141 extern phys_addr_t tegra_carveout_start;
142 extern phys_addr_t tegra_carveout_size;
143 extern phys_addr_t tegra_vpr_start;
144 extern phys_addr_t tegra_vpr_size;
145 extern phys_addr_t tegra_lp0_vec_start;
146 extern phys_addr_t tegra_lp0_vec_size;
147 #if defined(CONFIG_ARCH_TEGRA_14x_SOC)
148 extern phys_addr_t tegra_wb0_params_address;
149 extern phys_addr_t tegra_wb0_params_instances;
150 extern phys_addr_t tegra_wb0_params_block_size;
151 #endif
152 #ifdef CONFIG_TEGRA_NVDUMPER
153 extern unsigned long nvdumper_reserved;
154 #endif
155 extern bool tegra_lp0_vec_relocate;
156 extern unsigned long tegra_grhost_aperture;
157 #ifdef CONFIG_TEGRA_USE_NCT
158 /* info for NCK(NCT for Kernel) carveout area */
159 extern unsigned long tegra_nck_start;
160 extern unsigned long tegra_nck_size;
161 #endif
162
163 #ifdef CONFIG_TEGRA_IOMMU_SMMU
164 void tegra_fb_linear_set(struct iommu_linear_map *map);
165 #else
166 static inline void tegra_fb_linear_set(struct iommu_linear_map *map) {}
167 #endif
168
169 #ifdef CONFIG_NVMAP_USE_CMA_FOR_CARVEOUT
170 void carveout_linear_set(struct device *cma_dev);
171 #else
172 static inline void carveout_linear_set(struct device *cma_dev) {}
173 #endif
174
175 void tegra_init_late(void);
176
177 #ifdef CONFIG_DEBUG_FS
178 int tegra_clk_debugfs_init(void);
179 #else
180 static inline int tegra_clk_debugfs_init(void) { return 0; }
181 #endif
182
183 #if defined(CONFIG_DEBUG_FS)
184 int __init tegra_powergate_debugfs_init(void);
185 #else
186 static inline int tegra_powergate_debugfs_init(void) { return 0; }
187 #endif
188
189 int __init harmony_regulator_init(void);
190 #ifdef CONFIG_TEGRA_PCI
191 int __init harmony_pcie_init(void);
192 #else
193 static inline int harmony_pcie_init(void) { return 0; }
194 #endif
195
196 void __init tegra_paz00_wifikill_init(void);
197
198 enum board_fab {
199         BOARD_FAB_A = 0,
200         BOARD_FAB_B,
201         BOARD_FAB_C,
202         BOARD_FAB_D,
203 };
204
205 struct board_info {
206         u16 board_id;
207         u16 sku;
208         u8  fab;
209         u8  major_revision;
210         u8  minor_revision;
211 };
212
213 enum panel_type {
214         panel_type_lvds = 0,
215         panel_type_dsi,
216 };
217
218 enum touch_vendor {
219         RAYDIUM_TOUCH = 0,
220         SYNAPTIC_TOUCH,
221         MAXIM_TOUCH,
222         VENDOR_NONE,
223 };
224
225 enum touch_panel {
226         TOUCHPANEL_RESERVED = 0,
227         TOUCHPANEL_WINTEK,
228         TOUCHPANEL_TPK,
229         TOUCHPANEL_TOUCHTURNS,
230         TOUCHPANEL_THOR_WINTEK,
231         TOUCHPANEL_LOKI_WINTEK_5_66_UNLAMIN,
232         TOUCHPANEL_TN7,
233         TOUCHPANEL_TN8,
234 };
235
236 enum audio_codec_type {
237         audio_codec_none,
238         audio_codec_wm8903,
239 };
240
241 enum image_type {
242         system_image = 0,
243         rck_image,
244 };
245
246 void tegra_get_board_info(struct board_info *);
247 void tegra_get_pmu_board_info(struct board_info *bi);
248 void tegra_get_display_board_info(struct board_info *bi);
249 void tegra_get_camera_board_info(struct board_info *bi);
250 void tegra_get_io_board_info(struct board_info *bi);
251 void tegra_get_button_board_info(struct board_info *bi);
252 void tegra_get_joystick_board_info(struct board_info *bi);
253 void tegra_get_rightspeaker_board_info(struct board_info *bi);
254 void tegra_get_leftspeaker_board_info(struct board_info *bi);
255 int tegra_get_board_panel_id(void);
256 int tegra_get_touch_vendor_id(void);
257 int tegra_get_touch_panel_id(void);
258
259 int get_core_edp(void);
260 enum panel_type get_panel_type(void);
261 int tegra_get_usb_port_owner_info(void);
262 int tegra_get_modem_id(void);
263 int tegra_get_commchip_id(void);
264 u8 get_power_config(void);
265 u8 get_display_config(void);
266 enum power_supply_type get_power_supply_type(void);
267 enum audio_codec_type get_audio_codec_type(void);
268 int get_maximum_cpu_current_supported(void);
269 int get_maximum_core_current_supported(void);
270 int get_emc_max_dvfs(void);
271 int tegra_get_memory_type(void);
272 enum image_type get_tegra_image_type(void);
273 int tegra_get_cvb_alignment_uV(void);
274 int tegra_soc_device_init(const char *machine);
275 int get_pwr_i2c_clk_rate(void);
276 bool is_pmic_wdt_disabled_at_boot(void);
277
278 extern void tegra_set_usb_vbus_internal_wake(bool enable);
279 extern void tegra_set_usb_id_internal_wake(bool enable);
280 #endif