summaryrefslogtreecommitdiff
path: root/src/soc/mediatek/mt8196/include
diff options
context:
space:
mode:
authorJarried Lin <jarried.lin@mediatek.corp-partner.google.com>2024-11-01 15:16:51 +0800
committerYu-Ping Wu <yupingso@google.com>2024-11-13 02:27:04 +0000
commitb8724cd9a55b8f9d233f4ac3164fad7681517308 (patch)
tree0a5e960476de5dfe509b4eeb16d7712366b1bfaf /src/soc/mediatek/mt8196/include
parent2919a85be872d80d499de2c3f3421ccf83c68fd3 (diff)
soc/mediatek/mt8196: Add dram calibration support
Add support for MT8196 DRAM calibration. DRAM parameters and related constants are added in dramc_param.h and dramc_soc.h. As MT8196's dramc_param struct size is different from other MediaTek SoCs, replace the hardcoded RW_MRC_CACHE size in common code with a constant derived from chromeos.fmd. The common emi.c can be reused for MT8196 as well, so remove the duplicate mt8196/emi.{c,h}. Enable MEDIATEK_DRAM_BLOB_FAST_INIT to allow running DRAM fast calibration via the DRAM blob. Test=Build pass BUG=b:317009620 Change-Id: Ifeaf73e31b29ef376a28ca2721dba0d4866d6e8b Signed-off-by: Crystal Guo <crystal.guo@mediatek.corp-partner.google.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/85098 Reviewed-by: Yu-Ping Wu <yupingso@google.com> Reviewed-by: Yidi Lin <yidilin@google.com> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Diffstat (limited to 'src/soc/mediatek/mt8196/include')
-rw-r--r--src/soc/mediatek/mt8196/include/soc/dramc_param.h114
-rw-r--r--src/soc/mediatek/mt8196/include/soc/dramc_soc.h51
-rw-r--r--src/soc/mediatek/mt8196/include/soc/emi.h15
3 files changed, 165 insertions, 15 deletions
diff --git a/src/soc/mediatek/mt8196/include/soc/dramc_param.h b/src/soc/mediatek/mt8196/include/soc/dramc_param.h
new file mode 100644
index 0000000000..b35d518720
--- /dev/null
+++ b/src/soc/mediatek/mt8196/include/soc/dramc_param.h
@@ -0,0 +1,114 @@
+/* SPDX-License-Identifier: GPL-2.0-only OR MIT */
+
+#ifndef __SOC_MEDIATEK_MT8196_DRAMC_PARAM_H__
+#define __SOC_MEDIATEK_MT8196_DRAMC_PARAM_H__
+
+/*
+ * NOTE: This file is shared between coreboot and dram blob. Any change in this
+ * file should be synced to the other repository.
+ */
+
+#include <soc/dramc_param_common.h>
+#include <soc/dramc_soc.h>
+#include <stdint.h>
+#include <sys/types.h>
+
+#define DRAMC_PARAM_HEADER_VERSION 2
+
+struct sdram_params {
+ /* rank, cbt */
+ u32 rank_num;
+ u32 dram_cbt_mode;
+
+ u16 delay_cell_timex100;
+ u8 u18ph_dly;
+
+ /* duty */
+ s8 duty_clk_delay[CHANNEL_MAX][RANK_MAX];
+ s8 duty_dqs_delay[CHANNEL_MAX][DQS_NUMBER_LP5];
+ s8 duty_wck_delay[CHANNEL_MAX][DQS_NUMBER_LP5];
+ s8 duty_mck16x_delay[CHANNEL_MAX][DQS_NUMBER_LP5 + 1];
+ s8 duty_dq_delay[CHANNEL_MAX][DQS_NUMBER_LP5];
+ s8 duty_dqm_delay[CHANNEL_MAX][DQS_NUMBER_LP5];
+
+ /* cbt */
+ u8 cbt_final_vref[CHANNEL_MAX][RANK_MAX];
+ u8 cbt_final_range[CHANNEL_MAX][RANK_MAX];
+ s16 cbt_cmd_dly[CHANNEL_MAX];
+ u16 cbt_cs_dly[CHANNEL_MAX];
+ u8 cbt_ca_prebit_dly[CHANNEL_MAX][DQS_BIT_NUMBER];
+
+ /* write leveling */
+ u8 wr_level_pi[CHANNEL_MAX][RANK_MAX][DQS_NUMBER_LP5];
+ u8 wr_level_dly[CHANNEL_MAX][RANK_MAX][DQS_NUMBER_LP5];
+
+ /* gating */
+ u8 gating_UI[CHANNEL_MAX][RANK_MAX][DQS_NUMBER_LP5];
+ u8 gating_PI[CHANNEL_MAX][RANK_MAX][DQS_NUMBER_LP5];
+ u8 gating_pass_count[CHANNEL_MAX][RANK_MAX][DQS_NUMBER_LP5];
+ u16 wck2dqo_cnt[CHANNEL_MAX][RANK_MAX][DQS_NUMBER_LP5];
+
+ /* rx input buffer */
+ s8 dq_offc[CHANNEL_MAX][DQ_DATA_WIDTH_LP5];
+ s8 dqm_offc[CHANNEL_MAX][DQS_NUMBER_LP5];
+
+ /* tx perbit */
+ u16 tx_window_vref[CHANNEL_MAX][RANK_MAX];
+ u16 tx_window_vref_range[CHANNEL_MAX][RANK_MAX];
+ u16 tx_dq[CHANNEL_MAX][RANK_MAX][DQS_NUMBER_LP5];
+ u16 tx_dqm[CHANNEL_MAX][RANK_MAX][DQS_NUMBER_LP5];
+ u16 tx_dqm_only[CHANNEL_MAX][RANK_MAX][DQS_NUMBER_LP5];
+ u8 tx_perbit_dlyline[CHANNEL_MAX][RANK_MAX][EXT_DQ_DATA_WIDTH];
+ u16 wck2dqi_cnt0[CHANNEL_MAX][RANK_MAX];
+ u16 wck2dqi_cnt1[CHANNEL_MAX][RANK_MAX];
+
+ /* rx datlat */
+ u8 rx_datlat[CHANNEL_MAX];
+
+ /* rx perbit */
+ u8 rx_best_vref_perbyte[CHANNEL_MAX][RANK_MAX][DQS_NUMBER_LP5];
+ u8 rx_best_vref_perbit[CHANNEL_MAX][RANK_MAX][DQ_DATA_WIDTH_LP5];
+ u16 rx_perbit_dqs[CHANNEL_MAX][RANK_MAX][DQS_NUMBER_LP5];
+ u16 rx_perbit_dqm[CHANNEL_MAX][RANK_MAX][DQS_NUMBER_LP5];
+ u16 rx_perbit_dq[CHANNEL_MAX][RANK_MAX][DQ_DATA_WIDTH_LP5];
+ s16 rx_perbit_begin;
+
+ /* dvs */
+ u8 dvs_delay[CHANNEL_MAX][DQS_NUMBER_LP5];
+ u8 perbit_dcc[CHANNEL_MAX][RANK_MAX][DQ_DATA_WIDTH_LP5];
+
+ /* dcm */
+ u8 best_u[CHANNEL_MAX][RANK_MAX];
+ u8 best_l[CHANNEL_MAX][RANK_MAX];
+
+ /* Read DCA */
+ s8 rdca_u[CHANNEL_MAX][RANK_MAX];
+ s8 rdca_l[CHANNEL_MAX][RANK_MAX];
+
+ /* RDCC */
+ s8 rdcc[CHANNEL_MAX][RANK_MAX][DQS_NUMBER_LP5];
+
+ /* tx oe */
+ u8 tx_oe_dq_mck[CHANNEL_MAX][RANK_MAX][DQS_NUMBER_LP5];
+ u8 tx_oe_dq_ui[CHANNEL_MAX][RANK_MAX][DQS_NUMBER_LP5];
+ u16 tx_oe_offset[CHANNEL_MAX][RANK_MAX];
+};
+
+struct dramc_data {
+ struct ddr_base_info ddr_info;
+ struct sdram_params freq_params[DRAM_DFS_SHU_MAX];
+};
+
+struct dramc_param {
+ struct dramc_param_header header;
+ void (*do_putc)(unsigned char c);
+ struct dramc_data dramc_datas;
+};
+
+struct dramc_param *get_dramc_param_from_blob(void *blob);
+void dump_param_header(const void *blob);
+int validate_dramc_param(const void *blob);
+int is_valid_dramc_param(const void *blob);
+int initialize_dramc_param(void *blob);
+
+#endif /* __SOC_MEDIATEK_MT8196_DRAMC_PARAM_H__ */
diff --git a/src/soc/mediatek/mt8196/include/soc/dramc_soc.h b/src/soc/mediatek/mt8196/include/soc/dramc_soc.h
new file mode 100644
index 0000000000..dde00c23da
--- /dev/null
+++ b/src/soc/mediatek/mt8196/include/soc/dramc_soc.h
@@ -0,0 +1,51 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
+#ifndef __SOC_MEDIATEK_MT8196_DRAMC_SOC_H__
+#define __SOC_MEDIATEK_MT8196_DRAMC_SOC_H__
+
+#include <soc/dramc_soc_common.h>
+#include <stdint.h>
+
+typedef enum {
+ CHANNEL_A = 0,
+ CHANNEL_B,
+ CHANNEL_C,
+ CHANNEL_D,
+ CHANNEL_MAX,
+} DRAM_CHANNEL_T;
+
+typedef enum {
+ RANK_0 = 0,
+ RANK_1,
+ RANK_MAX,
+} DRAM_RANK_T;
+
+typedef enum {
+ SRAM_SHU0 = 0,
+ SRAM_SHU1,
+ SRAM_SHU2,
+ SRAM_SHU3,
+ SRAM_SHU4,
+ SRAM_SHU5,
+ SRAM_SHU6,
+ SRAM_SHU7,
+ SRAM_SHU8,
+ SRAM_SHU9,
+ SRAM_SHU10,
+ SRAM_SHU11,
+ DRAM_DFS_SRAM_MAX
+} DRAM_DFS_SRAM_SHU_T; /* DRAM SRAM RG type */
+
+typedef enum {
+ DRVP = 0,
+ DRVN,
+ ODTN,
+ IMP_DRV_MAX,
+} DRAM_IMP_DRV_T;
+
+#define DRAM_DFS_SHU_MAX DRAM_DFS_SRAM_MAX
+#define DQS_NUMBER_LP5 2
+#define DQ_DATA_WIDTH_LP5 16
+#define EXT_DQ_DATA_WIDTH 18
+
+#endif /* __SOC_MEDIATEK_MT8196_DRAMC_SOC_H__ */
diff --git a/src/soc/mediatek/mt8196/include/soc/emi.h b/src/soc/mediatek/mt8196/include/soc/emi.h
deleted file mode 100644
index 6acc0cfb46..0000000000
--- a/src/soc/mediatek/mt8196/include/soc/emi.h
+++ /dev/null
@@ -1,15 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-only */
-
-/*
- * This file is created based on MT8196 Functional Specification
- * Chapter number: 10.2
- */
-
-#ifndef SOC_MEDIATEK_MT8196_EMI_H
-#define SOC_MEDIATEK_MT8196_EMI_H
-
-#include <stddef.h>
-
-size_t sdram_size(void);
-
-#endif /* SOC_MEDIATEK_MT8196_EMI_H */