blob: 9138b4228992a36f3ed1a8e7aaa4fab60e9e190c [file] [log] [blame]
Peer Chen8d782ee2011-01-18 21:34:18 -05001/**
2 * Copyright (c) 2011 NVIDIA Corporation. All rights reserved.
3 *
4 * See file CREDITS for list of people who contributed to this
5 * project.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; either version 2 of
10 * the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
20 * MA 02111-1307 USA
21 */
22
23/*
24 * nvbctlib is a library for accessing data in BCTs from different versions
25 * of the BootROM. This provides a means for one utility program to
26 * reference data which is stored differently by different versions of chips,
27 * often with the same header file names.
28 *
29 * In essence, nvbctlib.h defines an API for selecting chip versions and
30 * accessing BCT data, and a separate source file wraps the API implementation
31 * around the header files that are unique to a chip version.
32 */
33
34#ifndef INCLUDED_NVBCTLIB_H
35#define INCLUDED_NVBCTLIB_H
36
37#include <sys/types.h>
38/*
39 * nvbct_lib_id defines tokens used for querying or setting values within, or
40 * about, the BCT. These are used to identify values within structures,
41 * sizes and other properties of structures, and values for enumerated
42 * constants.
43 */
44typedef enum {
Peer Chen7557d9b2011-02-24 09:29:23 -080045 nvbct_lib_id_none = 0,
Peer Chen8d782ee2011-01-18 21:34:18 -050046
Peer Chen7557d9b2011-02-24 09:29:23 -080047 nvbct_lib_id_crypto_hash,
48 nvbct_lib_id_random_aes_blk,
49 nvbct_lib_id_boot_data_version,
50 nvbct_lib_id_block_size_log2,
51 nvbct_lib_id_page_size_log2,
52 nvbct_lib_id_partition_size,
53 nvbct_lib_id_dev_type,
54 nvbct_lib_id_bootloader_used,
55 nvbct_lib_id_bootloaders_max,
56 nvbct_lib_id_reserved,
57 nvbct_lib_id_reserved_size,
58 nvbct_lib_id_reserved_offset,
59 nvbct_lib_id_bct_size,
60 nvbct_lib_id_hash_size,
61 nvbct_lib_id_crypto_offset,
62 nvbct_lib_id_crypto_length,
63 nvbct_lib_id_max_bct_search_blks,
64 nvbct_lib_id_num_param_sets,
Peer Chen053d5782011-03-03 10:12:58 -080065 nvbct_lib_id_dev_type_nand,
Peer Chen7557d9b2011-02-24 09:29:23 -080066 nvbct_lib_id_dev_type_sdmmc,
67 nvbct_lib_id_dev_type_spi,
Peer Chen3a834ed2011-03-04 09:30:05 -080068 nvbct_lib_id_num_sdram_sets,
Peer Chen8d782ee2011-01-18 21:34:18 -050069
Peer Chen053d5782011-03-03 10:12:58 -080070 nvbct_lib_id_nand_clock_divider,
71 nvbct_lib_id_nand_nand_timing,
72 nvbct_lib_id_nand_nand_timing2,
73 nvbct_lib_id_nand_block_size_log2,
74 nvbct_lib_id_nand_page_size_log2,
Peer Chen7557d9b2011-02-24 09:29:23 -080075 nvbct_lib_id_sdmmc_clock_divider,
76 nvbct_lib_id_sdmmc_data_width,
77 nvbct_lib_id_sdmmc_max_power_class_supported,
78 nvbct_lib_id_spiflash_read_command_type_fast,
79 nvbct_lib_id_spiflash_clock_source,
80 nvbct_lib_id_spiflash_clock_divider,
81 nvbct_lib_id_sdmmc_data_width_4bit,
82 nvbct_lib_id_sdmmc_data_width_8bit,
83 nvbct_lib_id_spi_clock_source_pllp_out0,
84 nvbct_lib_id_spi_clock_source_pllc_out0,
85 nvbct_lib_id_spi_clock_source_pllm_out0,
86 nvbct_lib_id_spi_clock_source_clockm,
Peer Chen8d782ee2011-01-18 21:34:18 -050087
Peer Chen7557d9b2011-02-24 09:29:23 -080088 nvbct_lib_id_bl_version,
89 nvbct_lib_id_bl_start_blk,
90 nvbct_lib_id_bl_start_page,
91 nvbct_lib_id_bl_length,
92 nvbct_lib_id_bl_load_addr,
93 nvbct_lib_id_bl_entry_point,
94 nvbct_lib_id_bl_attribute,
95 nvbct_lib_id_bl_crypto_hash,
Peer Chen8d782ee2011-01-18 21:34:18 -050096
Peer Chen3a834ed2011-03-04 09:30:05 -080097 nvbct_lib_id_memory_type_none,
98 nvbct_lib_id_memory_type_ddr2,
99 nvbct_lib_id_memory_type_ddr,
100 nvbct_lib_id_memory_type_lpddr2,
101 nvbct_lib_id_memory_type_lpddr,
102
103 nvbct_lib_id_sdram_memory_type,
104 nvbct_lib_id_sdram_pllm_charge_pump_setup_ctrl,
105 nvbct_lib_id_sdram_pllm_loop_filter_setup_ctrl,
106 nvbct_lib_id_sdram_pllm_input_divider,
107 nvbct_lib_id_sdram_pllm_feedback_divider,
108 nvbct_lib_id_sdram_pllm_post_divider,
109 nvbct_lib_id_sdram_pllm_stable_time,
110 nvbct_lib_id_sdram_emc_clock_divider,
111 nvbct_lib_id_sdram_emc_auto_cal_interval,
112 nvbct_lib_id_sdram_emc_auto_cal_config,
113 nvbct_lib_id_sdram_emc_auto_cal_wait,
114 nvbct_lib_id_sdram_emc_pin_program_wait,
115 nvbct_lib_id_sdram_emc_rc,
116 nvbct_lib_id_sdram_emc_rfc,
117 nvbct_lib_id_sdram_emc_ras,
118 nvbct_lib_id_sdram_emc_rp,
119 nvbct_lib_id_sdram_emc_r2w,
120 nvbct_lib_id_sdram_emc_w2r,
121 nvbct_lib_id_sdram_emc_r2p,
122 nvbct_lib_id_sdram_emc_w2p,
123 nvbct_lib_id_sdram_emc_rd_rcd,
124 nvbct_lib_id_sdram_emc_wr_rcd,
125 nvbct_lib_id_sdram_emc_rrd,
126 nvbct_lib_id_sdram_emc_rext,
127 nvbct_lib_id_sdram_emc_wdv,
128 nvbct_lib_id_sdram_emc_quse,
129 nvbct_lib_id_sdram_emc_qrst,
130 nvbct_lib_id_sdram_emc_qsafe,
131 nvbct_lib_id_sdram_emc_rdv,
132 nvbct_lib_id_sdram_emc_refresh,
133 nvbct_lib_id_sdram_emc_burst_refresh_num,
134 nvbct_lib_id_sdram_emc_pdex2wr,
135 nvbct_lib_id_sdram_emc_pdex2rd,
136 nvbct_lib_id_sdram_emc_pchg2pden,
137 nvbct_lib_id_sdram_emc_act2pden,
138 nvbct_lib_id_sdram_emc_ar2pden,
139 nvbct_lib_id_sdram_emc_rw2pden,
140 nvbct_lib_id_sdram_emc_txsr,
141 nvbct_lib_id_sdram_emc_tcke,
142 nvbct_lib_id_sdram_emc_tfaw,
143 nvbct_lib_id_sdram_emc_trpab,
144 nvbct_lib_id_sdram_emc_tclkstable,
145 nvbct_lib_id_sdram_emc_tclkstop,
146 nvbct_lib_id_sdram_emc_trefbw,
147 nvbct_lib_id_sdram_emc_quse_extra,
148 nvbct_lib_id_sdram_emc_fbio_cfg1,
149 nvbct_lib_id_sdram_emc_fbio_dqsib_dly,
150 nvbct_lib_id_sdram_emc_fbio_dqsib_dly_msb,
151 nvbct_lib_id_sdram_emc_fbio_quse_dly,
152 nvbct_lib_id_sdram_emc_fbio_quse_dly_msb,
153 nvbct_lib_id_sdram_emc_fbio_cfg5,
154 nvbct_lib_id_sdram_emc_fbio_cfg6,
155 nvbct_lib_id_sdram_emc_fbio_spare,
156 nvbct_lib_id_sdram_emc_mrs,
157 nvbct_lib_id_sdram_emc_emrs,
158 nvbct_lib_id_sdram_emc_mrw1,
159 nvbct_lib_id_sdram_emc_mrw2,
160 nvbct_lib_id_sdram_emc_mrw3,
161 nvbct_lib_id_sdram_emc_mrw_reset_command,
162 nvbct_lib_id_sdram_emc_mrw_reset_ninit_wait,
163 nvbct_lib_id_sdram_emc_adr_cfg,
164 nvbct_lib_id_sdram_emc_adr_cfg1,
165 nvbct_lib_id_sdram_mc_emem_Cfg,
166 nvbct_lib_id_sdram_mc_lowlatency_config,
167 nvbct_lib_id_sdram_emc_cfg,
168 nvbct_lib_id_sdram_emc_cfg2,
169 nvbct_lib_id_sdram_emc_dbg,
170 nvbct_lib_id_sdram_ahb_arbitration_xbar_ctrl,
171 nvbct_lib_id_sdram_emc_cfg_dig_dll,
172 nvbct_lib_id_sdram_emc_dll_xform_dqs,
173 nvbct_lib_id_sdram_emc_dll_xform_quse,
174 nvbct_lib_id_sdram_warm_boot_wait,
175 nvbct_lib_id_sdram_emc_ctt_term_ctrl,
176 nvbct_lib_id_sdram_emc_odt_write,
177 nvbct_lib_id_sdram_emc_odt_read,
178 nvbct_lib_id_sdram_emc_zcal_ref_cnt,
179 nvbct_lib_id_sdram_emc_zcal_wait_cnt,
180 nvbct_lib_id_sdram_emc_zcal_mrw_cmd,
181 nvbct_lib_id_sdram_emc_mrs_reset_dll,
182 nvbct_lib_id_sdram_emc_mrw_zq_init_dev0,
183 nvbct_lib_id_sdram_emc_mrw_zq_init_dev1,
184 nvbct_lib_id_sdram_emc_mrw_zq_init_wait,
185 nvbct_lib_id_sdram_emc_mrs_reset_dll_wait,
186 nvbct_lib_id_sdram_emc_emrs_emr2,
187 nvbct_lib_id_sdram_emc_emrs_emr3,
188 nvbct_lib_id_sdram_emc_emrs_ddr2_dll_enable,
189 nvbct_lib_id_sdram_emc_mrs_ddr2_dll_reset,
190 nvbct_lib_id_sdram_emc_emrs_ddr2_ocd_calib,
191 nvbct_lib_id_sdram_emc_ddr2_wait,
192 nvbct_lib_id_sdram_emc_cfg_clktrim0,
193 nvbct_lib_id_sdram_emc_cfg_clktrim1,
194 nvbct_lib_id_sdram_emc_cfg_clktrim2,
195 nvbct_lib_id_sdram_pmc_ddr_pwr,
196 nvbct_lib_id_sdram_apb_misc_gp_xm2cfga_pad_ctrl,
197 nvbct_lib_id_sdram_apb_misc_gp_xm2cfgc_pad_ctrl,
198 nvbct_lib_id_sdram_apb_misc_gp_xm2cfgc_pad_ctrl2,
199 nvbct_lib_id_sdram_apb_misc_gp_xm2cfgd_pad_ctrl,
200 nvbct_lib_id_sdram_apb_misc_gp_xm2cfgd_pad_ctrl2,
201 nvbct_lib_id_sdram_apb_misc_gp_xm2clkcfg_Pad_ctrl,
202 nvbct_lib_id_sdram_apb_misc_gp_xm2comp_pad_ctrl,
203 nvbct_lib_id_sdram_apb_misc_gp_xm2vttgen_pad_ctrl,
204
Peer Chen7557d9b2011-02-24 09:29:23 -0800205 nvbct_lib_id_max,
206
207 nvbct_lib_id_force32 = 0x7fffffff
Peer Chen8d782ee2011-01-18 21:34:18 -0500208
209} nvbct_lib_id;
210
Peer Chen7557d9b2011-02-24 09:29:23 -0800211typedef int (*nvbct_lib_get_dev_param)(u_int32_t set,
212 nvbct_lib_id id,
213 u_int32_t *data,
214 u_int8_t *bct);
215typedef int (*nvbct_lib_set_dev_param)(u_int32_t set,
216 nvbct_lib_id id,
217 u_int32_t data,
218 u_int8_t *bct);
219
Peer Chen3a834ed2011-03-04 09:30:05 -0800220typedef int (*nvbct_lib_get_sdram_param)(u_int32_t set,
221 nvbct_lib_id id,
222 u_int32_t *data,
223 u_int8_t *bct);
224typedef int (*nvbct_lib_set_sdram_param)(u_int32_t set,
225 nvbct_lib_id id,
226 u_int32_t data,
227 u_int8_t *bct);
228
Peer Chen8d782ee2011-01-18 21:34:18 -0500229typedef int (*nvbct_lib_get_bl_param)(u_int32_t set,
230 nvbct_lib_id id,
231 u_int32_t *data,
232 u_int8_t *bct);
233typedef int (*nvbct_lib_set_bl_param)(u_int32_t set,
234 nvbct_lib_id id,
235 u_int32_t *data,
236 u_int8_t *bct);
237
238typedef int (*nvbct_lib_get_value)(nvbct_lib_id id,
239 u_int32_t *data,
240 u_int8_t *bct);
241typedef int (*nvbct_lib_set_value)(nvbct_lib_id id,
242 u_int32_t data,
243 u_int8_t *bct);
244
245/*
246 * Note: On input, *length is the size of data. On output, *length is the
247 * actual size used.
248 */
249typedef int (*nvbct_lib_get_data)(nvbct_lib_id id,
250 u_int8_t *data,
251 u_int32_t *length,
252 u_int8_t *bct);
253typedef int (*nvbct_lib_set_data)(nvbct_lib_id id,
254 u_int8_t *data,
255 u_int32_t length,
256 u_int8_t *bct);
257
258/*
259 * Structure of function pointers used to access a specific BCT variant.
260 */
261typedef struct nvbct_lib_fns_rec
262{
Peer Chen7557d9b2011-02-24 09:29:23 -0800263 nvbct_lib_get_value get_value;
264 nvbct_lib_set_value set_value;
Peer Chen8d782ee2011-01-18 21:34:18 -0500265
Peer Chen7557d9b2011-02-24 09:29:23 -0800266 nvbct_lib_get_data get_data;
267 nvbct_lib_set_data set_data;
Peer Chen8d782ee2011-01-18 21:34:18 -0500268
Peer Chen7557d9b2011-02-24 09:29:23 -0800269 nvbct_lib_get_bl_param getbl_param;
270 nvbct_lib_set_bl_param setbl_param;
Peer Chen8d782ee2011-01-18 21:34:18 -0500271
Peer Chen7557d9b2011-02-24 09:29:23 -0800272 nvbct_lib_get_dev_param getdev_param;
273 nvbct_lib_set_dev_param setdev_param;
Peer Chen3a834ed2011-03-04 09:30:05 -0800274
275 nvbct_lib_get_sdram_param get_sdram_params;
276 nvbct_lib_set_sdram_param set_sdram_params;
Peer Chen8d782ee2011-01-18 21:34:18 -0500277} nvbct_lib_fns;
278
279void nvbct_lib_get_fns(nvbct_lib_fns *fns);
280
281#endif /* #ifndef INCLUDED_NVBCTLIB_H */