9bacda51ceb8da8de740a1dc578c6fdea213db50
[linux-2.6.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-2013, 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 #ifdef CONFIG_TEGRA_NVDUMPER
33 #define NVDUMPER_RESERVED_SIZE 4096UL
34 #endif
35
36 #define ADD_FIXED_VOLTAGE_REG(_name)    (&_name##_fixed_voltage_device)
37
38 /* Macro for defining fixed voltage regulator */
39 #define FIXED_VOLTAGE_REG_INIT(_id, _name, _microvolts, _gpio,          \
40                 _startup_delay, _enable_high, _enabled_at_boot,         \
41                 _valid_ops_mask, _always_on)                            \
42         static struct regulator_init_data _name##_initdata = {          \
43                 .consumer_supplies = _name##_consumer_supply,           \
44                 .num_consumer_supplies =                                \
45                                 ARRAY_SIZE(_name##_consumer_supply),    \
46                 .constraints = {                                        \
47                         .valid_ops_mask = _valid_ops_mask ,             \
48                         .always_on = _always_on,                        \
49                 },                                                      \
50         };                                                              \
51         static struct fixed_voltage_config _name##_config = {           \
52                 .supply_name            = #_name,                       \
53                 .microvolts             = _microvolts,                  \
54                 .gpio                   = _gpio,                        \
55                 .startup_delay          = _startup_delay,               \
56                 .enable_high            = _enable_high,                 \
57                 .enabled_at_boot        = _enabled_at_boot,             \
58                 .init_data              = &_name##_initdata,            \
59         };                                                              \
60         static struct platform_device _name##_fixed_voltage_device = {  \
61                 .name                   = "reg-fixed-voltage",          \
62                 .id                     = _id,                          \
63                 .dev                    = {                             \
64                         .platform_data  = &_name##_config,              \
65                 },                                                      \
66         }
67
68 #if defined(CONFIG_TEGRA_NVMAP)
69 #define NVMAP_HEAP_CARVEOUT_IRAM_INIT   \
70         {       .name           = "iram",                                       \
71                 .usage_mask     = NVMAP_HEAP_CARVEOUT_IRAM,                     \
72                 .base           = TEGRA_IRAM_BASE + TEGRA_RESET_HANDLER_SIZE,   \
73                 .size           = TEGRA_IRAM_SIZE - TEGRA_RESET_HANDLER_SIZE,   \
74                 .buddy_size     = 0, /* no buddy allocation for IRAM */         \
75         }
76 #endif
77
78 /* This information is passed by bootloader */
79 #define COMMCHIP_DEFAULT                0
80 #define COMMCHIP_NOCHIP                 1
81 #define COMMCHIP_BROADCOM_BCM4329       2
82 #define COMMCHIP_BROADCOM_BCM4330       3
83 #define COMMCHIP_MARVELL_SD8797         4
84 #define COMMCHIP_TI_WL18XX              5
85 #define COMMCHIP_BROADCOM_BCM43241      6
86
87 struct memory_accessor;
88
89 void tegra_assert_system_reset(char mode, const char *cmd);
90 void get_mac_addr(struct memory_accessor *, void *);
91
92 void __init tegra20_init_early(void);
93 void __init tegra30_init_early(void);
94 void __init tegra11x_init_early(void);
95 void __init tegra_map_common_io(void);
96 void __init tegra_init_irq(void);
97 void __init tegra_dt_init_irq(void);
98 void __init tegra_reserve(unsigned long carveout_size, unsigned long fb_size,
99         unsigned long fb2_size);
100 void __init tegra_release_bootloader_fb(void);
101 void __init tegra_protected_aperture_init(unsigned long aperture);
102 int  __init tegra_init_board_info(void);
103 void __tegra_move_framebuffer(struct platform_device *pdev,
104                               unsigned long to, unsigned long from,
105                               unsigned long size);
106 static inline void tegra_move_framebuffer(unsigned long to, unsigned long from,
107                                           unsigned long size)
108 {
109         __tegra_move_framebuffer(NULL, to, from, size);
110 }
111 void __tegra_clear_framebuffer(struct platform_device *pdev,
112                                unsigned long to, unsigned long size);
113 static inline void tegra_clear_framebuffer(unsigned long to, unsigned long size)
114 {
115         __tegra_clear_framebuffer(NULL, to, size);
116 }
117 bool is_tegra_debug_uartport_hs(void);
118 int get_tegra_uart_debug_port_id(void);
119 int arb_lost_recovery(int scl_gpio, int sda_gpio);
120 int __init tegra_register_fuse(void);
121
122 #ifdef CONFIG_ANDROID_RAM_CONSOLE
123 void __init tegra_ram_console_debug_reserve(unsigned long ram_console_size);
124 void __init tegra_ram_console_debug_init(void);
125 #else
126 static inline void __init tegra_ram_console_debug_reserve(unsigned long ram_console_size)
127 {}
128 static inline void __init tegra_ram_console_debug_init(void)
129 {}
130 #endif
131
132 extern unsigned long tegra_bootloader_fb_start;
133 extern unsigned long tegra_bootloader_fb_size;
134 extern unsigned long tegra_bootloader_fb2_start;
135 extern unsigned long tegra_bootloader_fb2_size;
136 extern unsigned long tegra_fb_start;
137 extern unsigned long tegra_fb_size;
138 extern unsigned long tegra_fb2_start;
139 extern unsigned long tegra_fb2_size;
140 extern unsigned long tegra_carveout_start;
141 extern unsigned long tegra_carveout_size;
142 extern unsigned long tegra_vpr_start;
143 extern unsigned long tegra_vpr_size;
144 extern unsigned long tegra_lp0_vec_start;
145 extern unsigned long tegra_lp0_vec_size;
146 #ifdef CONFIG_TEGRA_NVDUMPER
147 extern unsigned long nvdumper_reserved;
148 #endif
149 extern bool tegra_lp0_vec_relocate;
150 extern unsigned long tegra_grhost_aperture;
151 #ifdef CONFIG_TEGRA_USE_NCT
152 /* info for NCK(NCT for Kernel) carveout area */
153 extern unsigned long tegra_nck_start;
154 extern unsigned long tegra_nck_size;
155 #endif
156
157 extern struct sys_timer tegra_timer;
158
159 enum board_fab {
160         BOARD_FAB_A = 0,
161         BOARD_FAB_B,
162         BOARD_FAB_C,
163         BOARD_FAB_D,
164 };
165
166 struct board_info {
167         u16 board_id;
168         u16 sku;
169         u8  fab;
170         u8  major_revision;
171         u8  minor_revision;
172 };
173
174 enum panel_type {
175         panel_type_lvds = 0,
176         panel_type_dsi,
177 };
178
179 enum audio_codec_type {
180         audio_codec_none,
181         audio_codec_wm8903,
182 };
183
184 enum image_type {
185         system_image = 0,
186         rck_image,
187 };
188
189 void tegra_get_board_info(struct board_info *);
190 void tegra_get_pmu_board_info(struct board_info *bi);
191 void tegra_get_display_board_info(struct board_info *bi);
192 void tegra_get_camera_board_info(struct board_info *bi);
193 void tegra_get_io_board_info(struct board_info *bi);
194 void tegra_get_button_board_info(struct board_info *bi);
195 void tegra_get_joystick_board_info(struct board_info *bi);
196 void tegra_get_rightspeaker_board_info(struct board_info *bi);
197 void tegra_get_leftspeaker_board_info(struct board_info *bi);
198 int tegra_get_board_panel_id(void);
199
200 int get_core_edp(void);
201 enum panel_type get_panel_type(void);
202 int tegra_get_usb_port_owner_info(void);
203 int tegra_get_modem_id(void);
204 int tegra_get_commchip_id(void);
205 u8 get_power_config(void);
206 enum power_supply_type get_power_supply_type(void);
207 enum audio_codec_type get_audio_codec_type(void);
208 int get_maximum_cpu_current_supported(void);
209 int get_maximum_core_current_supported(void);
210 int get_emc_max_dvfs(void);
211 int tegra_get_memory_type(void);
212 void tegra_enable_pinmux(void);
213 enum image_type get_tegra_image_type(void);
214 int tegra_get_cvb_alignment_uV(void);
215 int tegra_soc_device_init(const char *machine);
216 int get_pwr_i2c_clk_rate(void);
217 int tegra_get_pmic_rst_reason(void);
218 #ifdef CONFIG_ANDROID
219 bool get_androidboot_mode_charger(void);
220 #endif
221 extern void tegra_set_usb_vbus_internal_wake(bool enable);
222 extern void tegra_set_usb_id_internal_wake(bool enable);
223 #endif