• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* SPDX-License-Identifier: BSD-3-Clause */
2 
3 #ifndef __EMI_H__
4 #define __EMI_H__
5 
6 #include <dramc_top.h>
7 
8 #if __ETT__
9 #define emi_log	printf
10 #elif __FLASH_TOOL_DA__
11 #define emi_log	LOGD
12 #else
13 #define emi_log	print
14 #endif
15 
16 struct isu_info_t {
17 	unsigned int buf_size;
18 	unsigned long long buf_addr;
19 	unsigned long long ver_addr;
20 	unsigned long long con_addr;
21 };
22 
23 #define EMI_ISU_BUF_SIZE	0x800000
24 #define LAST_EMI_MAGIC_PATTERN 0x19870611
25 typedef struct {
26 	unsigned int isu_magic;
27 	unsigned int isu_ctrl;
28 	unsigned int isu_dram_type;
29 	unsigned int isu_diff_us;
30 	unsigned int isu_buf_l;
31 	unsigned int isu_buf_h;
32 	unsigned int isu_version;
33 	unsigned int snst_last;
34 	unsigned int snst_past;
35 	unsigned int os_flag_sspm;
36 	unsigned int os_flag_ap;
37 } LAST_EMI_INFO_T;
38 #define DEF_LAST_EMI LAST_EMI_INFO_T
39 
40 typedef struct {
41 	unsigned int dram_type;
42 	unsigned int ch_num;
43 	unsigned int rk_num;
44 	unsigned int bank_width[DRAMC_MAX_RK];
45 	unsigned int row_width[DRAMC_MAX_RK];
46 	unsigned int col_width[DRAMC_MAX_RK];
47 	U64 rank_size[DRAMC_MAX_RK];
48 } EMI_INFO_T;
49 
50 void emi_init(void);
51 void emi_init2(void);
52 void clr_emi_mpu_prot(void);
53 void dis_emi_apb_prot(void);
54 int get_row_width_by_emi(unsigned int rank);
55 int get_channel_nr_by_emi(void);
56 int get_rank_nr_by_emi(void);
57 void get_rank_size_by_emi(unsigned long long dram_rank_size[DRAMC_MAX_RK]);
58 void set_cen_emi_cona(unsigned int cona_val);
59 void set_cen_emi_conf(unsigned int conf_val);
60 void set_cen_emi_conh(unsigned int conh_val);
61 void set_chn_emi_cona(unsigned int cona_val);
62 void set_chn_emi_conc(unsigned int conc_val);
63 unsigned int get_cen_emi_cona(void);
64 unsigned int get_chn_emi_cona(void);
65 void enable_infra_emi_broadcast(unsigned int enable);
66 void phy_addr_to_dram_addr(dram_addr_t *dram_addr, unsigned long long phy_addr);
67 unsigned int set_emi_before_rank1_mem_test(void);
68 void restore_emi_after_rank1_mem_test(void);
69 void get_emi_isu_info(struct isu_info_t *isu_info_ptr);
70 void reserve_emi_isu_buf(void);
71 void reserve_emi_mbist_buf(void);
72 void record_emi_snst(void);
73 unsigned long long platform_memory_size(void);
74 int update_emi_setting(EMI_SETTINGS *default_emi_setting, EMI_INFO_T *emi_info);
75 //int mt_mem_init();
76 
77 #endif /* __EMI_H__ */
78 
79