xref: /aosp_15_r20/external/coreboot/src/vendorcode/mediatek/mt8192/include/dramc_common.h (revision b9411a12aaaa7e1e6a6fb7c5e057f44ee179a49c)
1 /* SPDX-License-Identifier: BSD-3-Clause */
2 
3 #ifndef _DRAMC_COMMON_H_
4 #define _DRAMC_COMMON_H_
5 
6 #define __ETT__ 0
7 
8 //#include <console/console.h>
9 #include <delay.h>
10 #include <device/mmio.h>
11 #include <stdint.h>
12 #include <types.h>
13 #include <reg.h>
14 #include <string.h>
15 #include <soc/dramc_common.h>
16 #include <timer.h>
17 #include <print.h>
18 
19 #include "dramc_register.h"
20 #include "dramc_pi_api.h"
21 #include "dramc_int_slt.h"
22 
23 #if FOR_DV_SIMULATION_USED == 1
24 #include "dramc_dv_init.h"
25 #endif
26 
27 /***********************************************************************/
28 /*                  Public Types                                       */
29 /***********************************************************************/
30 
31 /*------------------------------------------------------------*/
32 /*                  macros, defines, typedefs, enums          */
33 /*------------------------------------------------------------*/
34 /************************** Common Macro *********************/
35 #define dsb()		asm volatile("dsb sy" : : : "memory")
36 
37 #define DRV_Reg32(x)		read32((const void *)((u64)(x)))
38 #define DRV_WriteReg32(x, y)	write32((void *)((u64)(x)), (y))
39 
40 #define mcDELAY_US(x)       udelay(x)
41 #define mcDELAY_MS(x)       udelay(x*1000)
42 #define mcDELAY_XUS(x)      udelay(x)
43 #define mcDELAY_XNS(x)      udelay(1)
44 
45 /**********************************************/
46 /* Priority of debug log                      */
47 /*--------------------------------------------*/
48 /* msg: High                       */
49 /* msg2: Medium High               */
50 /* msg3: Medium Low                */
51 /* msg4: Low                       */
52 /**********************************************/
53 
54 #define CALIBRATION_LOG		1
55 
56 #if CALIBRATION_LOG
57 #define msg(_x_...)	{ print(_x_); }
58 #define msg2(_x_...)	{ if (0) { print(_x_); } }
59 #define err(_x_...) 	{ print(_x_); }
60 #else
61 #define msg(_x_...)
62 #define msg2(_x_...)
63 #define err(_x_...)
64 #endif
65 
66 #define info(_x_...) msg(_x_)
67 
68 #define msg3(_x_...) { if (0) { print(_x_); } }
69 #define msg4(_x_...)
70 #define msg5(_x_...)
71 #define jv_msg(_x_...) { if (0) { print(_x_); } }
72 #if EYESCAN_LOG
73 #define eye_msg(_x_...) { print(_x_); }
74 #else
75 #define eye_msg(_x_...) //{ print(_x_); }
76 #endif
77 
78 #define time_msg(_x_...)
79 #define reg_msg(_x_...)
80 #define mcFPRINTF(_x_...)
81 
82 #ifndef ARRAY_SIZE
83 #define ARRAY_SIZE(x)    (sizeof (x) / sizeof (x[0]))
84 #endif
85 
86 #define enter_function() \
87 	( { msg("enter %s\n", __FUNCTION__); } )
88 
89 #define exit_function() \
90 	( { msg("exit %s\n", __FUNCTION__); } )
91 
92 extern int dump_log;
93 #endif   // _DRAMC_COMMON_H_
94