Xi Chen | 022b1b9 | 2021-02-05 11:45:12 +0800 | [diff] [blame] | 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 | /*--------------------------------------------*/ |
Xi Chen | 16b9bee | 2021-03-12 16:53:58 +0800 | [diff] [blame] | 48 | /* msg: High */ |
| 49 | /* msg2: Medium High */ |
| 50 | /* msg3: Medium Low */ |
| 51 | /* msg4: Low */ |
Xi Chen | 022b1b9 | 2021-02-05 11:45:12 +0800 | [diff] [blame] | 52 | /**********************************************/ |
| 53 | |
| 54 | #define CALIBRATION_LOG 1 |
| 55 | |
| 56 | #if CALIBRATION_LOG |
Xi Chen | 16b9bee | 2021-03-12 16:53:58 +0800 | [diff] [blame] | 57 | #define msg(_x_...) { print(_x_); } |
Arthur Heymans | bd42906 | 2023-04-18 19:53:22 +0200 | [diff] [blame^] | 58 | #define msg2(_x_...) { if (0) { print(_x_); } } |
Xi Chen | 16b9bee | 2021-03-12 16:53:58 +0800 | [diff] [blame] | 59 | #define err(_x_...) { print(_x_); } |
Xi Chen | 022b1b9 | 2021-02-05 11:45:12 +0800 | [diff] [blame] | 60 | #else |
Xi Chen | 16b9bee | 2021-03-12 16:53:58 +0800 | [diff] [blame] | 61 | #define msg(_x_...) |
| 62 | #define msg2(_x_...) |
| 63 | #define err(_x_...) |
Xi Chen | 022b1b9 | 2021-02-05 11:45:12 +0800 | [diff] [blame] | 64 | #endif |
| 65 | |
Xi Chen | 16b9bee | 2021-03-12 16:53:58 +0800 | [diff] [blame] | 66 | #define info(_x_...) msg(_x_) |
| 67 | |
Arthur Heymans | bd42906 | 2023-04-18 19:53:22 +0200 | [diff] [blame^] | 68 | #define msg3(_x_...) { if (0) { print(_x_); } } |
Xi Chen | 16b9bee | 2021-03-12 16:53:58 +0800 | [diff] [blame] | 69 | #define msg4(_x_...) |
| 70 | #define msg5(_x_...) |
Arthur Heymans | bd42906 | 2023-04-18 19:53:22 +0200 | [diff] [blame^] | 71 | #define jv_msg(_x_...) { if (0) { print(_x_); } } |
Xi Chen | 022b1b9 | 2021-02-05 11:45:12 +0800 | [diff] [blame] | 72 | #if EYESCAN_LOG |
Xi Chen | 16b9bee | 2021-03-12 16:53:58 +0800 | [diff] [blame] | 73 | #define eye_msg(_x_...) { print(_x_); } |
Xi Chen | 022b1b9 | 2021-02-05 11:45:12 +0800 | [diff] [blame] | 74 | #else |
Xi Chen | 16b9bee | 2021-03-12 16:53:58 +0800 | [diff] [blame] | 75 | #define eye_msg(_x_...) //{ print(_x_); } |
Xi Chen | 022b1b9 | 2021-02-05 11:45:12 +0800 | [diff] [blame] | 76 | #endif |
Xi Chen | 16b9bee | 2021-03-12 16:53:58 +0800 | [diff] [blame] | 77 | |
| 78 | #define time_msg(_x_...) |
| 79 | #define reg_msg(_x_...) |
| 80 | #define mcFPRINTF(_x_...) |
Xi Chen | 022b1b9 | 2021-02-05 11:45:12 +0800 | [diff] [blame] | 81 | |
| 82 | #ifndef ARRAY_SIZE |
| 83 | #define ARRAY_SIZE(x) (sizeof (x) / sizeof (x[0])) |
| 84 | #endif |
| 85 | |
| 86 | #define enter_function() \ |
Xi Chen | 16b9bee | 2021-03-12 16:53:58 +0800 | [diff] [blame] | 87 | ( { msg("enter %s\n", __FUNCTION__); } ) |
Xi Chen | 022b1b9 | 2021-02-05 11:45:12 +0800 | [diff] [blame] | 88 | |
| 89 | #define exit_function() \ |
Xi Chen | 16b9bee | 2021-03-12 16:53:58 +0800 | [diff] [blame] | 90 | ( { msg("exit %s\n", __FUNCTION__); } ) |
Xi Chen | 022b1b9 | 2021-02-05 11:45:12 +0800 | [diff] [blame] | 91 | |
| 92 | extern int dump_log; |
| 93 | #endif // _DRAMC_COMMON_H_ |