162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci * Copyright (c) 2015-2020, NVIDIA CORPORATION.  All rights reserved.
462306a36Sopenharmony_ci */
562306a36Sopenharmony_ci
662306a36Sopenharmony_ci#ifndef TEGRA210_EMC_H
762306a36Sopenharmony_ci#define TEGRA210_EMC_H
862306a36Sopenharmony_ci
962306a36Sopenharmony_ci#include <linux/clk.h>
1062306a36Sopenharmony_ci#include <linux/clk/tegra.h>
1162306a36Sopenharmony_ci#include <linux/io.h>
1262306a36Sopenharmony_ci#include <linux/platform_device.h>
1362306a36Sopenharmony_ci
1462306a36Sopenharmony_ci#define DVFS_FGCG_HIGH_SPEED_THRESHOLD				1000
1562306a36Sopenharmony_ci#define IOBRICK_DCC_THRESHOLD					2400
1662306a36Sopenharmony_ci#define DVFS_FGCG_MID_SPEED_THRESHOLD				600
1762306a36Sopenharmony_ci
1862306a36Sopenharmony_ci#define EMC_STATUS_UPDATE_TIMEOUT				1000
1962306a36Sopenharmony_ci
2062306a36Sopenharmony_ci/* register definitions */
2162306a36Sopenharmony_ci#define EMC_INTSTATUS						0x0
2262306a36Sopenharmony_ci#define EMC_INTSTATUS_CLKCHANGE_COMPLETE			BIT(4)
2362306a36Sopenharmony_ci#define EMC_DBG							0x8
2462306a36Sopenharmony_ci#define EMC_DBG_WRITE_MUX_ACTIVE				BIT(1)
2562306a36Sopenharmony_ci#define EMC_DBG_WRITE_ACTIVE_ONLY				BIT(30)
2662306a36Sopenharmony_ci#define EMC_CFG							0xc
2762306a36Sopenharmony_ci#define EMC_CFG_DRAM_CLKSTOP_PD					BIT(31)
2862306a36Sopenharmony_ci#define EMC_CFG_DRAM_CLKSTOP_SR					BIT(30)
2962306a36Sopenharmony_ci#define EMC_CFG_DRAM_ACPD					BIT(29)
3062306a36Sopenharmony_ci#define EMC_CFG_DYN_SELF_REF					BIT(28)
3162306a36Sopenharmony_ci#define EMC_PIN							0x24
3262306a36Sopenharmony_ci#define EMC_PIN_PIN_CKE						BIT(0)
3362306a36Sopenharmony_ci#define EMC_PIN_PIN_CKEB					BIT(1)
3462306a36Sopenharmony_ci#define EMC_PIN_PIN_CKE_PER_DEV					BIT(2)
3562306a36Sopenharmony_ci#define EMC_TIMING_CONTROL					0x28
3662306a36Sopenharmony_ci#define EMC_RC							0x2c
3762306a36Sopenharmony_ci#define EMC_RFC							0x30
3862306a36Sopenharmony_ci#define EMC_RAS							0x34
3962306a36Sopenharmony_ci#define EMC_RP							0x38
4062306a36Sopenharmony_ci#define EMC_R2W							0x3c
4162306a36Sopenharmony_ci#define EMC_W2R							0x40
4262306a36Sopenharmony_ci#define EMC_R2P							0x44
4362306a36Sopenharmony_ci#define EMC_W2P							0x48
4462306a36Sopenharmony_ci#define EMC_RD_RCD						0x4c
4562306a36Sopenharmony_ci#define EMC_WR_RCD						0x50
4662306a36Sopenharmony_ci#define EMC_RRD							0x54
4762306a36Sopenharmony_ci#define EMC_REXT						0x58
4862306a36Sopenharmony_ci#define EMC_WDV							0x5c
4962306a36Sopenharmony_ci#define EMC_QUSE						0x60
5062306a36Sopenharmony_ci#define EMC_QRST						0x64
5162306a36Sopenharmony_ci#define EMC_QSAFE						0x68
5262306a36Sopenharmony_ci#define EMC_RDV							0x6c
5362306a36Sopenharmony_ci#define EMC_REFRESH						0x70
5462306a36Sopenharmony_ci#define EMC_BURST_REFRESH_NUM					0x74
5562306a36Sopenharmony_ci#define EMC_PDEX2WR						0x78
5662306a36Sopenharmony_ci#define EMC_PDEX2RD						0x7c
5762306a36Sopenharmony_ci#define EMC_PCHG2PDEN						0x80
5862306a36Sopenharmony_ci#define EMC_ACT2PDEN						0x84
5962306a36Sopenharmony_ci#define EMC_AR2PDEN						0x88
6062306a36Sopenharmony_ci#define EMC_RW2PDEN						0x8c
6162306a36Sopenharmony_ci#define EMC_TXSR						0x90
6262306a36Sopenharmony_ci#define EMC_TCKE						0x94
6362306a36Sopenharmony_ci#define EMC_TFAW						0x98
6462306a36Sopenharmony_ci#define EMC_TRPAB						0x9c
6562306a36Sopenharmony_ci#define EMC_TCLKSTABLE						0xa0
6662306a36Sopenharmony_ci#define EMC_TCLKSTOP						0xa4
6762306a36Sopenharmony_ci#define EMC_TREFBW						0xa8
6862306a36Sopenharmony_ci#define EMC_TPPD						0xac
6962306a36Sopenharmony_ci#define EMC_ODT_WRITE						0xb0
7062306a36Sopenharmony_ci#define EMC_PDEX2MRR						0xb4
7162306a36Sopenharmony_ci#define EMC_WEXT						0xb8
7262306a36Sopenharmony_ci#define EMC_RFC_SLR						0xc0
7362306a36Sopenharmony_ci#define EMC_MRS_WAIT_CNT2					0xc4
7462306a36Sopenharmony_ci#define EMC_MRS_WAIT_CNT2_MRS_EXT2_WAIT_CNT_SHIFT		16
7562306a36Sopenharmony_ci#define EMC_MRS_WAIT_CNT2_MRS_EXT1_WAIT_CNT_SHIFT		0
7662306a36Sopenharmony_ci#define EMC_MRS_WAIT_CNT					0xc8
7762306a36Sopenharmony_ci#define EMC_MRS_WAIT_CNT_SHORT_WAIT_SHIFT			0
7862306a36Sopenharmony_ci#define EMC_MRS_WAIT_CNT_SHORT_WAIT_MASK			\
7962306a36Sopenharmony_ci	(0x3FF << EMC_MRS_WAIT_CNT_SHORT_WAIT_SHIFT)
8062306a36Sopenharmony_ci
8162306a36Sopenharmony_ci#define EMC_MRS							0xcc
8262306a36Sopenharmony_ci#define EMC_EMRS						0xd0
8362306a36Sopenharmony_ci#define EMC_EMRS_USE_EMRS_LONG_CNT				BIT(26)
8462306a36Sopenharmony_ci#define EMC_REF							0xd4
8562306a36Sopenharmony_ci#define  EMC_REF_REF_CMD					BIT(0)
8662306a36Sopenharmony_ci#define EMC_SELF_REF						0xe0
8762306a36Sopenharmony_ci#define EMC_MRW							0xe8
8862306a36Sopenharmony_ci#define EMC_MRW_MRW_OP_SHIFT					0
8962306a36Sopenharmony_ci#define EMC_MRW_MRW_OP_MASK					\
9062306a36Sopenharmony_ci	(0xff << EMC_MRW_MRW_OP_SHIFT)
9162306a36Sopenharmony_ci#define EMC_MRW_MRW_MA_SHIFT					16
9262306a36Sopenharmony_ci#define EMC_MRW_USE_MRW_EXT_CNT					27
9362306a36Sopenharmony_ci#define EMC_MRW_MRW_DEV_SELECTN_SHIFT				30
9462306a36Sopenharmony_ci
9562306a36Sopenharmony_ci#define EMC_MRR							0xec
9662306a36Sopenharmony_ci#define EMC_MRR_DEV_SEL_SHIFT					30
9762306a36Sopenharmony_ci#define EMC_MRR_DEV_SEL_MASK					0x3
9862306a36Sopenharmony_ci#define EMC_MRR_MA_SHIFT					16
9962306a36Sopenharmony_ci#define EMC_MRR_MA_MASK						0xff
10062306a36Sopenharmony_ci#define EMC_MRR_DATA_SHIFT					0
10162306a36Sopenharmony_ci#define EMC_MRR_DATA_MASK					0xffff
10262306a36Sopenharmony_ci
10362306a36Sopenharmony_ci#define EMC_FBIO_SPARE						0x100
10462306a36Sopenharmony_ci#define EMC_FBIO_CFG5						0x104
10562306a36Sopenharmony_ci#define EMC_FBIO_CFG5_DRAM_TYPE_SHIFT				0
10662306a36Sopenharmony_ci#define EMC_FBIO_CFG5_DRAM_TYPE_MASK				\
10762306a36Sopenharmony_ci	(0x3 << EMC_FBIO_CFG5_DRAM_TYPE_SHIFT)
10862306a36Sopenharmony_ci#define EMC_FBIO_CFG5_CMD_TX_DIS				BIT(8)
10962306a36Sopenharmony_ci
11062306a36Sopenharmony_ci#define EMC_PDEX2CKE						0x118
11162306a36Sopenharmony_ci#define EMC_CKE2PDEN						0x11c
11262306a36Sopenharmony_ci#define EMC_MPC							0x128
11362306a36Sopenharmony_ci#define EMC_EMRS2						0x12c
11462306a36Sopenharmony_ci#define EMC_EMRS2_USE_EMRS2_LONG_CNT				BIT(26)
11562306a36Sopenharmony_ci#define EMC_MRW2						0x134
11662306a36Sopenharmony_ci#define EMC_MRW3						0x138
11762306a36Sopenharmony_ci#define EMC_MRW4						0x13c
11862306a36Sopenharmony_ci#define EMC_R2R							0x144
11962306a36Sopenharmony_ci#define EMC_EINPUT						0x14c
12062306a36Sopenharmony_ci#define EMC_EINPUT_DURATION					0x150
12162306a36Sopenharmony_ci#define EMC_PUTERM_EXTRA					0x154
12262306a36Sopenharmony_ci#define EMC_TCKESR						0x158
12362306a36Sopenharmony_ci#define EMC_TPD							0x15c
12462306a36Sopenharmony_ci#define EMC_AUTO_CAL_CONFIG					0x2a4
12562306a36Sopenharmony_ci#define EMC_AUTO_CAL_CONFIG_AUTO_CAL_COMPUTE_START		BIT(0)
12662306a36Sopenharmony_ci#define EMC_AUTO_CAL_CONFIG_AUTO_CAL_MEASURE_STALL		BIT(9)
12762306a36Sopenharmony_ci#define EMC_AUTO_CAL_CONFIG_AUTO_CAL_UPDATE_STALL		BIT(10)
12862306a36Sopenharmony_ci#define EMC_AUTO_CAL_CONFIG_AUTO_CAL_ENABLE			BIT(29)
12962306a36Sopenharmony_ci#define EMC_AUTO_CAL_CONFIG_AUTO_CAL_START			BIT(31)
13062306a36Sopenharmony_ci#define EMC_EMC_STATUS						0x2b4
13162306a36Sopenharmony_ci#define EMC_EMC_STATUS_MRR_DIVLD				BIT(20)
13262306a36Sopenharmony_ci#define EMC_EMC_STATUS_TIMING_UPDATE_STALLED			BIT(23)
13362306a36Sopenharmony_ci#define EMC_EMC_STATUS_DRAM_IN_POWERDOWN_SHIFT			4
13462306a36Sopenharmony_ci#define EMC_EMC_STATUS_DRAM_IN_POWERDOWN_MASK			\
13562306a36Sopenharmony_ci	(0x3 << EMC_EMC_STATUS_DRAM_IN_POWERDOWN_SHIFT)
13662306a36Sopenharmony_ci#define EMC_EMC_STATUS_DRAM_IN_SELF_REFRESH_SHIFT		8
13762306a36Sopenharmony_ci#define EMC_EMC_STATUS_DRAM_IN_SELF_REFRESH_MASK		\
13862306a36Sopenharmony_ci	(0x3 << EMC_EMC_STATUS_DRAM_IN_SELF_REFRESH_SHIFT)
13962306a36Sopenharmony_ci
14062306a36Sopenharmony_ci#define EMC_CFG_2						0x2b8
14162306a36Sopenharmony_ci#define EMC_CFG_DIG_DLL						0x2bc
14262306a36Sopenharmony_ci#define EMC_CFG_DIG_DLL_CFG_DLL_EN				BIT(0)
14362306a36Sopenharmony_ci#define EMC_CFG_DIG_DLL_CFG_DLL_STALL_ALL_UNTIL_LOCK		BIT(1)
14462306a36Sopenharmony_ci#define EMC_CFG_DIG_DLL_CFG_DLL_STALL_ALL_TRAFFIC		BIT(3)
14562306a36Sopenharmony_ci#define EMC_CFG_DIG_DLL_CFG_DLL_STALL_RW_UNTIL_LOCK		BIT(4)
14662306a36Sopenharmony_ci#define EMC_CFG_DIG_DLL_CFG_DLL_MODE_SHIFT			6
14762306a36Sopenharmony_ci#define EMC_CFG_DIG_DLL_CFG_DLL_MODE_MASK			\
14862306a36Sopenharmony_ci	(0x3 << EMC_CFG_DIG_DLL_CFG_DLL_MODE_SHIFT)
14962306a36Sopenharmony_ci#define EMC_CFG_DIG_DLL_CFG_DLL_LOCK_LIMIT_SHIFT		8
15062306a36Sopenharmony_ci#define EMC_CFG_DIG_DLL_CFG_DLL_LOCK_LIMIT_MASK			\
15162306a36Sopenharmony_ci	(0x7 << EMC_CFG_DIG_DLL_CFG_DLL_LOCK_LIMIT_SHIFT)
15262306a36Sopenharmony_ci
15362306a36Sopenharmony_ci#define EMC_CFG_DIG_DLL_PERIOD					0x2c0
15462306a36Sopenharmony_ci#define EMC_DIG_DLL_STATUS					0x2c4
15562306a36Sopenharmony_ci#define EMC_DIG_DLL_STATUS_DLL_LOCK				BIT(15)
15662306a36Sopenharmony_ci#define EMC_DIG_DLL_STATUS_DLL_PRIV_UPDATED			BIT(17)
15762306a36Sopenharmony_ci#define EMC_DIG_DLL_STATUS_DLL_OUT_SHIFT			0
15862306a36Sopenharmony_ci#define EMC_DIG_DLL_STATUS_DLL_OUT_MASK				\
15962306a36Sopenharmony_ci	(0x7ff << EMC_DIG_DLL_STATUS_DLL_OUT_SHIFT)
16062306a36Sopenharmony_ci
16162306a36Sopenharmony_ci#define EMC_CFG_DIG_DLL_1					0x2c8
16262306a36Sopenharmony_ci#define EMC_RDV_MASK						0x2cc
16362306a36Sopenharmony_ci#define EMC_WDV_MASK						0x2d0
16462306a36Sopenharmony_ci#define EMC_RDV_EARLY_MASK					0x2d4
16562306a36Sopenharmony_ci#define EMC_RDV_EARLY						0x2d8
16662306a36Sopenharmony_ci#define EMC_AUTO_CAL_CONFIG8					0x2dc
16762306a36Sopenharmony_ci#define EMC_ZCAL_INTERVAL					0x2e0
16862306a36Sopenharmony_ci#define EMC_ZCAL_WAIT_CNT					0x2e4
16962306a36Sopenharmony_ci#define EMC_ZCAL_WAIT_CNT_ZCAL_WAIT_CNT_MASK			0x7ff
17062306a36Sopenharmony_ci#define EMC_ZCAL_WAIT_CNT_ZCAL_WAIT_CNT_SHIFT			0
17162306a36Sopenharmony_ci
17262306a36Sopenharmony_ci#define EMC_ZQ_CAL						0x2ec
17362306a36Sopenharmony_ci#define EMC_ZQ_CAL_DEV_SEL_SHIFT				30
17462306a36Sopenharmony_ci#define EMC_ZQ_CAL_LONG						BIT(4)
17562306a36Sopenharmony_ci#define EMC_ZQ_CAL_ZQ_LATCH_CMD					BIT(1)
17662306a36Sopenharmony_ci#define EMC_ZQ_CAL_ZQ_CAL_CMD					BIT(0)
17762306a36Sopenharmony_ci#define EMC_FDPD_CTRL_DQ					0x310
17862306a36Sopenharmony_ci#define EMC_FDPD_CTRL_CMD					0x314
17962306a36Sopenharmony_ci#define EMC_PMACRO_CMD_BRICK_CTRL_FDPD				0x318
18062306a36Sopenharmony_ci#define EMC_PMACRO_DATA_BRICK_CTRL_FDPD				0x31c
18162306a36Sopenharmony_ci#define EMC_PMACRO_BRICK_CTRL_RFU1				0x330
18262306a36Sopenharmony_ci#define EMC_PMACRO_BRICK_CTRL_RFU2				0x334
18362306a36Sopenharmony_ci#define EMC_TR_TIMING_0						0x3b4
18462306a36Sopenharmony_ci#define EMC_TR_CTRL_1						0x3bc
18562306a36Sopenharmony_ci#define EMC_TR_RDV						0x3c4
18662306a36Sopenharmony_ci#define EMC_STALL_THEN_EXE_AFTER_CLKCHANGE			0x3cc
18762306a36Sopenharmony_ci#define EMC_SEL_DPD_CTRL					0x3d8
18862306a36Sopenharmony_ci#define EMC_SEL_DPD_CTRL_DATA_SEL_DPD_EN			BIT(8)
18962306a36Sopenharmony_ci#define EMC_SEL_DPD_CTRL_ODT_SEL_DPD_EN				BIT(5)
19062306a36Sopenharmony_ci#define EMC_SEL_DPD_CTRL_RESET_SEL_DPD_EN			BIT(4)
19162306a36Sopenharmony_ci#define EMC_SEL_DPD_CTRL_CA_SEL_DPD_EN				BIT(3)
19262306a36Sopenharmony_ci#define EMC_SEL_DPD_CTRL_CLK_SEL_DPD_EN				BIT(2)
19362306a36Sopenharmony_ci#define EMC_PRE_REFRESH_REQ_CNT					0x3dc
19462306a36Sopenharmony_ci#define EMC_DYN_SELF_REF_CONTROL				0x3e0
19562306a36Sopenharmony_ci#define EMC_TXSRDLL						0x3e4
19662306a36Sopenharmony_ci#define EMC_CCFIFO_ADDR						0x3e8
19762306a36Sopenharmony_ci#define  EMC_CCFIFO_ADDR_STALL_BY_1 (1 << 31)
19862306a36Sopenharmony_ci#define  EMC_CCFIFO_ADDR_STALL(x) (((x) & 0x7fff) << 16)
19962306a36Sopenharmony_ci#define  EMC_CCFIFO_ADDR_OFFSET(x) ((x) & 0xffff)
20062306a36Sopenharmony_ci#define EMC_CCFIFO_DATA						0x3ec
20162306a36Sopenharmony_ci#define EMC_TR_QPOP						0x3f4
20262306a36Sopenharmony_ci#define EMC_TR_RDV_MASK						0x3f8
20362306a36Sopenharmony_ci#define EMC_TR_QSAFE						0x3fc
20462306a36Sopenharmony_ci#define EMC_TR_QRST						0x400
20562306a36Sopenharmony_ci#define EMC_ISSUE_QRST						0x428
20662306a36Sopenharmony_ci#define EMC_AUTO_CAL_CONFIG2					0x458
20762306a36Sopenharmony_ci#define EMC_AUTO_CAL_CONFIG3					0x45c
20862306a36Sopenharmony_ci#define EMC_TR_DVFS						0x460
20962306a36Sopenharmony_ci#define EMC_AUTO_CAL_CHANNEL					0x464
21062306a36Sopenharmony_ci#define EMC_IBDLY						0x468
21162306a36Sopenharmony_ci#define EMC_OBDLY						0x46c
21262306a36Sopenharmony_ci#define EMC_TXDSRVTTGEN						0x480
21362306a36Sopenharmony_ci#define EMC_WE_DURATION						0x48c
21462306a36Sopenharmony_ci#define EMC_WS_DURATION						0x490
21562306a36Sopenharmony_ci#define EMC_WEV							0x494
21662306a36Sopenharmony_ci#define EMC_WSV							0x498
21762306a36Sopenharmony_ci#define EMC_CFG_3						0x49c
21862306a36Sopenharmony_ci#define EMC_MRW6						0x4a4
21962306a36Sopenharmony_ci#define EMC_MRW7						0x4a8
22062306a36Sopenharmony_ci#define EMC_MRW8						0x4ac
22162306a36Sopenharmony_ci#define EMC_MRW9						0x4b0
22262306a36Sopenharmony_ci#define EMC_MRW10						0x4b4
22362306a36Sopenharmony_ci#define EMC_MRW11						0x4b8
22462306a36Sopenharmony_ci#define EMC_MRW12						0x4bc
22562306a36Sopenharmony_ci#define EMC_MRW13						0x4c0
22662306a36Sopenharmony_ci#define EMC_MRW14						0x4c4
22762306a36Sopenharmony_ci#define EMC_MRW15						0x4d0
22862306a36Sopenharmony_ci#define EMC_CFG_SYNC						0x4d4
22962306a36Sopenharmony_ci#define EMC_FDPD_CTRL_CMD_NO_RAMP				0x4d8
23062306a36Sopenharmony_ci#define EMC_FDPD_CTRL_CMD_NO_RAMP_CMD_DPD_NO_RAMP_ENABLE	BIT(0)
23162306a36Sopenharmony_ci#define EMC_WDV_CHK						0x4e0
23262306a36Sopenharmony_ci#define EMC_CFG_PIPE_2						0x554
23362306a36Sopenharmony_ci#define EMC_CFG_PIPE_CLK					0x558
23462306a36Sopenharmony_ci#define EMC_CFG_PIPE_CLK_CLK_ALWAYS_ON				BIT(0)
23562306a36Sopenharmony_ci#define EMC_CFG_PIPE_1						0x55c
23662306a36Sopenharmony_ci#define EMC_CFG_PIPE						0x560
23762306a36Sopenharmony_ci#define EMC_QPOP						0x564
23862306a36Sopenharmony_ci#define EMC_QUSE_WIDTH						0x568
23962306a36Sopenharmony_ci#define EMC_PUTERM_WIDTH					0x56c
24062306a36Sopenharmony_ci#define EMC_AUTO_CAL_CONFIG7					0x574
24162306a36Sopenharmony_ci#define EMC_REFCTRL2						0x580
24262306a36Sopenharmony_ci#define EMC_FBIO_CFG7						0x584
24362306a36Sopenharmony_ci#define EMC_FBIO_CFG7_CH0_ENABLE				BIT(1)
24462306a36Sopenharmony_ci#define EMC_FBIO_CFG7_CH1_ENABLE				BIT(2)
24562306a36Sopenharmony_ci#define EMC_DATA_BRLSHFT_0					0x588
24662306a36Sopenharmony_ci#define EMC_DATA_BRLSHFT_0_RANK0_BYTE7_DATA_BRLSHFT_SHIFT	21
24762306a36Sopenharmony_ci#define EMC_DATA_BRLSHFT_0_RANK0_BYTE7_DATA_BRLSHFT_MASK	\
24862306a36Sopenharmony_ci	(0x7 << EMC_DATA_BRLSHFT_0_RANK0_BYTE7_DATA_BRLSHFT_SHIFT)
24962306a36Sopenharmony_ci#define EMC_DATA_BRLSHFT_0_RANK0_BYTE6_DATA_BRLSHFT_SHIFT	18
25062306a36Sopenharmony_ci#define EMC_DATA_BRLSHFT_0_RANK0_BYTE6_DATA_BRLSHFT_MASK	\
25162306a36Sopenharmony_ci	(0x7 << EMC_DATA_BRLSHFT_0_RANK0_BYTE6_DATA_BRLSHFT_SHIFT)
25262306a36Sopenharmony_ci#define EMC_DATA_BRLSHFT_0_RANK0_BYTE5_DATA_BRLSHFT_SHIFT	15
25362306a36Sopenharmony_ci#define EMC_DATA_BRLSHFT_0_RANK0_BYTE5_DATA_BRLSHFT_MASK	\
25462306a36Sopenharmony_ci	(0x7 << EMC_DATA_BRLSHFT_0_RANK0_BYTE5_DATA_BRLSHFT_SHIFT)
25562306a36Sopenharmony_ci#define EMC_DATA_BRLSHFT_0_RANK0_BYTE4_DATA_BRLSHFT_SHIFT	12
25662306a36Sopenharmony_ci#define EMC_DATA_BRLSHFT_0_RANK0_BYTE4_DATA_BRLSHFT_MASK	\
25762306a36Sopenharmony_ci	(0x7 << EMC_DATA_BRLSHFT_0_RANK0_BYTE4_DATA_BRLSHFT_SHIFT)
25862306a36Sopenharmony_ci#define EMC_DATA_BRLSHFT_0_RANK0_BYTE3_DATA_BRLSHFT_SHIFT	9
25962306a36Sopenharmony_ci#define EMC_DATA_BRLSHFT_0_RANK0_BYTE3_DATA_BRLSHFT_MASK	\
26062306a36Sopenharmony_ci	(0x7 << EMC_DATA_BRLSHFT_0_RANK0_BYTE3_DATA_BRLSHFT_SHIFT)
26162306a36Sopenharmony_ci#define EMC_DATA_BRLSHFT_0_RANK0_BYTE2_DATA_BRLSHFT_SHIFT	6
26262306a36Sopenharmony_ci#define EMC_DATA_BRLSHFT_0_RANK0_BYTE2_DATA_BRLSHFT_MASK	\
26362306a36Sopenharmony_ci	(0x7 << EMC_DATA_BRLSHFT_0_RANK0_BYTE2_DATA_BRLSHFT_SHIFT)
26462306a36Sopenharmony_ci#define EMC_DATA_BRLSHFT_0_RANK0_BYTE1_DATA_BRLSHFT_SHIFT	3
26562306a36Sopenharmony_ci#define EMC_DATA_BRLSHFT_0_RANK0_BYTE1_DATA_BRLSHFT_MASK	\
26662306a36Sopenharmony_ci	(0x7 << EMC_DATA_BRLSHFT_0_RANK0_BYTE1_DATA_BRLSHFT_SHIFT)
26762306a36Sopenharmony_ci#define EMC_DATA_BRLSHFT_0_RANK0_BYTE0_DATA_BRLSHFT_SHIFT	0
26862306a36Sopenharmony_ci#define EMC_DATA_BRLSHFT_0_RANK0_BYTE0_DATA_BRLSHFT_MASK	\
26962306a36Sopenharmony_ci	(0x7 << EMC_DATA_BRLSHFT_0_RANK0_BYTE0_DATA_BRLSHFT_SHIFT)
27062306a36Sopenharmony_ci
27162306a36Sopenharmony_ci#define EMC_DATA_BRLSHFT_1					0x58c
27262306a36Sopenharmony_ci#define EMC_DATA_BRLSHFT_1_RANK1_BYTE7_DATA_BRLSHFT_SHIFT	21
27362306a36Sopenharmony_ci#define EMC_DATA_BRLSHFT_1_RANK1_BYTE7_DATA_BRLSHFT_MASK	\
27462306a36Sopenharmony_ci	(0x7 << EMC_DATA_BRLSHFT_1_RANK1_BYTE7_DATA_BRLSHFT_SHIFT)
27562306a36Sopenharmony_ci#define EMC_DATA_BRLSHFT_1_RANK1_BYTE6_DATA_BRLSHFT_SHIFT	18
27662306a36Sopenharmony_ci#define EMC_DATA_BRLSHFT_1_RANK1_BYTE6_DATA_BRLSHFT_MASK	\
27762306a36Sopenharmony_ci	(0x7 << EMC_DATA_BRLSHFT_1_RANK1_BYTE6_DATA_BRLSHFT_SHIFT)
27862306a36Sopenharmony_ci#define EMC_DATA_BRLSHFT_1_RANK1_BYTE5_DATA_BRLSHFT_SHIFT	15
27962306a36Sopenharmony_ci#define EMC_DATA_BRLSHFT_1_RANK1_BYTE5_DATA_BRLSHFT_MASK	\
28062306a36Sopenharmony_ci	(0x7 << EMC_DATA_BRLSHFT_1_RANK1_BYTE5_DATA_BRLSHFT_SHIFT)
28162306a36Sopenharmony_ci#define EMC_DATA_BRLSHFT_1_RANK1_BYTE4_DATA_BRLSHFT_SHIFT	12
28262306a36Sopenharmony_ci#define EMC_DATA_BRLSHFT_1_RANK1_BYTE4_DATA_BRLSHFT_MASK	\
28362306a36Sopenharmony_ci	(0x7 << EMC_DATA_BRLSHFT_1_RANK1_BYTE4_DATA_BRLSHFT_SHIFT)
28462306a36Sopenharmony_ci#define EMC_DATA_BRLSHFT_1_RANK1_BYTE3_DATA_BRLSHFT_SHIFT	9
28562306a36Sopenharmony_ci#define EMC_DATA_BRLSHFT_1_RANK1_BYTE3_DATA_BRLSHFT_MASK	\
28662306a36Sopenharmony_ci	(0x7 << EMC_DATA_BRLSHFT_1_RANK1_BYTE3_DATA_BRLSHFT_SHIFT)
28762306a36Sopenharmony_ci#define EMC_DATA_BRLSHFT_1_RANK1_BYTE2_DATA_BRLSHFT_SHIFT	6
28862306a36Sopenharmony_ci#define EMC_DATA_BRLSHFT_1_RANK1_BYTE2_DATA_BRLSHFT_MASK	\
28962306a36Sopenharmony_ci	(0x7 << EMC_DATA_BRLSHFT_1_RANK1_BYTE2_DATA_BRLSHFT_SHIFT)
29062306a36Sopenharmony_ci#define EMC_DATA_BRLSHFT_1_RANK1_BYTE1_DATA_BRLSHFT_SHIFT	3
29162306a36Sopenharmony_ci#define EMC_DATA_BRLSHFT_1_RANK1_BYTE1_DATA_BRLSHFT_MASK	\
29262306a36Sopenharmony_ci	(0x7 << EMC_DATA_BRLSHFT_1_RANK1_BYTE1_DATA_BRLSHFT_SHIFT)
29362306a36Sopenharmony_ci#define EMC_DATA_BRLSHFT_1_RANK1_BYTE0_DATA_BRLSHFT_SHIFT	0
29462306a36Sopenharmony_ci#define EMC_DATA_BRLSHFT_1_RANK1_BYTE0_DATA_BRLSHFT_MASK	\
29562306a36Sopenharmony_ci	(0x7 << EMC_DATA_BRLSHFT_1_RANK1_BYTE0_DATA_BRLSHFT_SHIFT)
29662306a36Sopenharmony_ci
29762306a36Sopenharmony_ci#define EMC_RFCPB						0x590
29862306a36Sopenharmony_ci#define EMC_DQS_BRLSHFT_0					0x594
29962306a36Sopenharmony_ci#define EMC_DQS_BRLSHFT_1					0x598
30062306a36Sopenharmony_ci#define EMC_CMD_BRLSHFT_0					0x59c
30162306a36Sopenharmony_ci#define EMC_CMD_BRLSHFT_1					0x5a0
30262306a36Sopenharmony_ci#define EMC_CMD_BRLSHFT_2					0x5a4
30362306a36Sopenharmony_ci#define EMC_CMD_BRLSHFT_3					0x5a8
30462306a36Sopenharmony_ci#define EMC_QUSE_BRLSHFT_0					0x5ac
30562306a36Sopenharmony_ci#define EMC_AUTO_CAL_CONFIG4					0x5b0
30662306a36Sopenharmony_ci#define EMC_AUTO_CAL_CONFIG5					0x5b4
30762306a36Sopenharmony_ci#define EMC_QUSE_BRLSHFT_1					0x5b8
30862306a36Sopenharmony_ci#define EMC_QUSE_BRLSHFT_2					0x5bc
30962306a36Sopenharmony_ci#define EMC_CCDMW						0x5c0
31062306a36Sopenharmony_ci#define EMC_QUSE_BRLSHFT_3					0x5c4
31162306a36Sopenharmony_ci#define EMC_AUTO_CAL_CONFIG6					0x5cc
31262306a36Sopenharmony_ci#define EMC_DLL_CFG_0						0x5e4
31362306a36Sopenharmony_ci#define EMC_DLL_CFG_1						0x5e8
31462306a36Sopenharmony_ci#define EMC_DLL_CFG_1_DDLLCAL_CTRL_START_TRIM_SHIFT		10
31562306a36Sopenharmony_ci#define EMC_DLL_CFG_1_DDLLCAL_CTRL_START_TRIM_MASK		\
31662306a36Sopenharmony_ci	(0x7ff << EMC_DLL_CFG_1_DDLLCAL_CTRL_START_TRIM_SHIFT)
31762306a36Sopenharmony_ci
31862306a36Sopenharmony_ci#define EMC_CONFIG_SAMPLE_DELAY					0x5f0
31962306a36Sopenharmony_ci#define EMC_CFG_UPDATE						0x5f4
32062306a36Sopenharmony_ci#define EMC_CFG_UPDATE_UPDATE_DLL_IN_UPDATE_SHIFT		9
32162306a36Sopenharmony_ci#define EMC_CFG_UPDATE_UPDATE_DLL_IN_UPDATE_MASK		\
32262306a36Sopenharmony_ci	(0x3 << EMC_CFG_UPDATE_UPDATE_DLL_IN_UPDATE_SHIFT)
32362306a36Sopenharmony_ci
32462306a36Sopenharmony_ci#define EMC_PMACRO_QUSE_DDLL_RANK0_0				0x600
32562306a36Sopenharmony_ci#define EMC_PMACRO_QUSE_DDLL_RANK0_1				0x604
32662306a36Sopenharmony_ci#define EMC_PMACRO_QUSE_DDLL_RANK0_2				0x608
32762306a36Sopenharmony_ci#define EMC_PMACRO_QUSE_DDLL_RANK0_3				0x60c
32862306a36Sopenharmony_ci#define EMC_PMACRO_QUSE_DDLL_RANK0_4				0x610
32962306a36Sopenharmony_ci#define EMC_PMACRO_QUSE_DDLL_RANK0_5				0x614
33062306a36Sopenharmony_ci#define EMC_PMACRO_QUSE_DDLL_RANK1_0				0x620
33162306a36Sopenharmony_ci#define EMC_PMACRO_QUSE_DDLL_RANK1_1				0x624
33262306a36Sopenharmony_ci#define EMC_PMACRO_QUSE_DDLL_RANK1_2				0x628
33362306a36Sopenharmony_ci#define EMC_PMACRO_QUSE_DDLL_RANK1_3				0x62c
33462306a36Sopenharmony_ci#define EMC_PMACRO_QUSE_DDLL_RANK1_4				0x630
33562306a36Sopenharmony_ci#define EMC_PMACRO_QUSE_DDLL_RANK1_5				0x634
33662306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_LONG_DQ_RANK0_0			0x640
33762306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_LONG_DQ_RANK0_0_OB_DDLL_LONG_DQ_RANK0_BYTE1_SHIFT \
33862306a36Sopenharmony_ci	16
33962306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_LONG_DQ_RANK0_0_OB_DDLL_LONG_DQ_RANK0_BYTE1_MASK  \
34062306a36Sopenharmony_ci	(0x3ff <<							     \
34162306a36Sopenharmony_ci	EMC_PMACRO_OB_DDLL_LONG_DQ_RANK0_0_OB_DDLL_LONG_DQ_RANK0_BYTE1_SHIFT)
34262306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_LONG_DQ_RANK0_0_OB_DDLL_LONG_DQ_RANK0_BYTE0_SHIFT \
34362306a36Sopenharmony_ci	0
34462306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_LONG_DQ_RANK0_0_OB_DDLL_LONG_DQ_RANK0_BYTE0_MASK \
34562306a36Sopenharmony_ci	(0x3ff <<							    \
34662306a36Sopenharmony_ci	EMC_PMACRO_OB_DDLL_LONG_DQ_RANK0_0_OB_DDLL_LONG_DQ_RANK0_BYTE0_SHIFT)
34762306a36Sopenharmony_ci
34862306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_LONG_DQ_RANK0_1			0x644
34962306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_LONG_DQ_RANK0_1_OB_DDLL_LONG_DQ_RANK0_BYTE3_SHIFT \
35062306a36Sopenharmony_ci	16
35162306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_LONG_DQ_RANK0_1_OB_DDLL_LONG_DQ_RANK0_BYTE3_MASK  \
35262306a36Sopenharmony_ci	(0x3ff <<							     \
35362306a36Sopenharmony_ci	EMC_PMACRO_OB_DDLL_LONG_DQ_RANK0_1_OB_DDLL_LONG_DQ_RANK0_BYTE3_SHIFT)
35462306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_LONG_DQ_RANK0_1_OB_DDLL_LONG_DQ_RANK0_BYTE2_SHIFT \
35562306a36Sopenharmony_ci	0
35662306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_LONG_DQ_RANK0_1_OB_DDLL_LONG_DQ_RANK0_BYTE2_MASK  \
35762306a36Sopenharmony_ci	(0x3ff <<							     \
35862306a36Sopenharmony_ci	EMC_PMACRO_OB_DDLL_LONG_DQ_RANK0_1_OB_DDLL_LONG_DQ_RANK0_BYTE2_SHIFT)
35962306a36Sopenharmony_ci
36062306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_LONG_DQ_RANK0_2			0x648
36162306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_LONG_DQ_RANK0_2_OB_DDLL_LONG_DQ_RANK0_BYTE5_SHIFT  \
36262306a36Sopenharmony_ci	16
36362306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_LONG_DQ_RANK0_2_OB_DDLL_LONG_DQ_RANK0_BYTE5_MASK  \
36462306a36Sopenharmony_ci	(0x3ff <<							     \
36562306a36Sopenharmony_ci	EMC_PMACRO_OB_DDLL_LONG_DQ_RANK0_2_OB_DDLL_LONG_DQ_RANK0_BYTE5_SHIFT)
36662306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_LONG_DQ_RANK0_2_OB_DDLL_LONG_DQ_RANK0_BYTE4_SHIFT \
36762306a36Sopenharmony_ci	0
36862306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_LONG_DQ_RANK0_2_OB_DDLL_LONG_DQ_RANK0_BYTE4_MASK  \
36962306a36Sopenharmony_ci	(0x3ff <<							     \
37062306a36Sopenharmony_ci	EMC_PMACRO_OB_DDLL_LONG_DQ_RANK0_2_OB_DDLL_LONG_DQ_RANK0_BYTE4_SHIFT)
37162306a36Sopenharmony_ci
37262306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_LONG_DQ_RANK0_3			0x64c
37362306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_LONG_DQ_RANK0_3_OB_DDLL_LONG_DQ_RANK0_BYTE7_SHIFT \
37462306a36Sopenharmony_ci	16
37562306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_LONG_DQ_RANK0_3_OB_DDLL_LONG_DQ_RANK0_BYTE7_MASK  \
37662306a36Sopenharmony_ci	(0x3ff <<							     \
37762306a36Sopenharmony_ci	EMC_PMACRO_OB_DDLL_LONG_DQ_RANK0_3_OB_DDLL_LONG_DQ_RANK0_BYTE7_SHIFT)
37862306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_LONG_DQ_RANK0_3_OB_DDLL_LONG_DQ_RANK0_BYTE6_SHIFT \
37962306a36Sopenharmony_ci	0
38062306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_LONG_DQ_RANK0_3_OB_DDLL_LONG_DQ_RANK0_BYTE6_MASK  \
38162306a36Sopenharmony_ci	(0x3ff <<							     \
38262306a36Sopenharmony_ci	EMC_PMACRO_OB_DDLL_LONG_DQ_RANK0_3_OB_DDLL_LONG_DQ_RANK0_BYTE6_SHIFT)
38362306a36Sopenharmony_ci
38462306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_LONG_DQ_RANK0_4			0x650
38562306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_LONG_DQ_RANK0_5			0x654
38662306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_LONG_DQ_RANK1_0			0x660
38762306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_LONG_DQ_RANK1_0_OB_DDLL_LONG_DQ_RANK1_BYTE1_SHIFT \
38862306a36Sopenharmony_ci	16
38962306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_LONG_DQ_RANK1_0_OB_DDLL_LONG_DQ_RANK1_BYTE1_MASK  \
39062306a36Sopenharmony_ci	(0x3ff <<							     \
39162306a36Sopenharmony_ci	EMC_PMACRO_OB_DDLL_LONG_DQ_RANK1_0_OB_DDLL_LONG_DQ_RANK1_BYTE1_SHIFT)
39262306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_LONG_DQ_RANK1_0_OB_DDLL_LONG_DQ_RANK1_BYTE0_SHIFT \
39362306a36Sopenharmony_ci	0
39462306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_LONG_DQ_RANK1_0_OB_DDLL_LONG_DQ_RANK1_BYTE0_MASK  \
39562306a36Sopenharmony_ci	(0x3ff <<							     \
39662306a36Sopenharmony_ci	EMC_PMACRO_OB_DDLL_LONG_DQ_RANK1_0_OB_DDLL_LONG_DQ_RANK1_BYTE0_SHIFT)
39762306a36Sopenharmony_ci
39862306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_LONG_DQ_RANK1_1			0x664
39962306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_LONG_DQ_RANK1_1_OB_DDLL_LONG_DQ_RANK1_BYTE3_SHIFT \
40062306a36Sopenharmony_ci	16
40162306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_LONG_DQ_RANK1_1_OB_DDLL_LONG_DQ_RANK1_BYTE3_MASK  \
40262306a36Sopenharmony_ci	(0x3ff <<							     \
40362306a36Sopenharmony_ci	EMC_PMACRO_OB_DDLL_LONG_DQ_RANK1_1_OB_DDLL_LONG_DQ_RANK1_BYTE3_SHIFT)
40462306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_LONG_DQ_RANK1_1_OB_DDLL_LONG_DQ_RANK1_BYTE2_SHIFT \
40562306a36Sopenharmony_ci	0
40662306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_LONG_DQ_RANK1_1_OB_DDLL_LONG_DQ_RANK1_BYTE2_MASK  \
40762306a36Sopenharmony_ci	(0x3ff <<							     \
40862306a36Sopenharmony_ci	EMC_PMACRO_OB_DDLL_LONG_DQ_RANK1_1_OB_DDLL_LONG_DQ_RANK1_BYTE2_SHIFT)
40962306a36Sopenharmony_ci
41062306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_LONG_DQ_RANK1_2			0x668
41162306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_LONG_DQ_RANK1_2_OB_DDLL_LONG_DQ_RANK1_BYTE5_SHIFT \
41262306a36Sopenharmony_ci	16
41362306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_LONG_DQ_RANK1_2_OB_DDLL_LONG_DQ_RANK1_BYTE5_MASK  \
41462306a36Sopenharmony_ci	(0x3ff <<							     \
41562306a36Sopenharmony_ci	EMC_PMACRO_OB_DDLL_LONG_DQ_RANK1_2_OB_DDLL_LONG_DQ_RANK1_BYTE5_SHIFT)
41662306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_LONG_DQ_RANK1_2_OB_DDLL_LONG_DQ_RANK1_BYTE4_SHIFT \
41762306a36Sopenharmony_ci	0
41862306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_LONG_DQ_RANK1_2_OB_DDLL_LONG_DQ_RANK1_BYTE4_MASK  \
41962306a36Sopenharmony_ci	(0x3ff <<							     \
42062306a36Sopenharmony_ci	EMC_PMACRO_OB_DDLL_LONG_DQ_RANK1_2_OB_DDLL_LONG_DQ_RANK1_BYTE4_SHIFT)
42162306a36Sopenharmony_ci
42262306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_LONG_DQ_RANK1_3			0x66c
42362306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_LONG_DQ_RANK1_3_OB_DDLL_LONG_DQ_RANK1_BYTE7_SHIFT \
42462306a36Sopenharmony_ci	16
42562306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_LONG_DQ_RANK1_3_OB_DDLL_LONG_DQ_RANK1_BYTE7_MASK  \
42662306a36Sopenharmony_ci	(0x3ff <<							     \
42762306a36Sopenharmony_ci	EMC_PMACRO_OB_DDLL_LONG_DQ_RANK1_3_OB_DDLL_LONG_DQ_RANK1_BYTE7_SHIFT)
42862306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_LONG_DQ_RANK1_3_OB_DDLL_LONG_DQ_RANK1_BYTE6_SHIFT \
42962306a36Sopenharmony_ci	0
43062306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_LONG_DQ_RANK1_3_OB_DDLL_LONG_DQ_RANK1_BYTE6_MASK  \
43162306a36Sopenharmony_ci	(0x3ff <<							     \
43262306a36Sopenharmony_ci	EMC_PMACRO_OB_DDLL_LONG_DQ_RANK1_3_OB_DDLL_LONG_DQ_RANK1_BYTE6_SHIFT)
43362306a36Sopenharmony_ci
43462306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_LONG_DQ_RANK1_4			0x670
43562306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_LONG_DQ_RANK1_5			0x674
43662306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_LONG_DQS_RANK0_0			0x680
43762306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_LONG_DQS_RANK0_1			0x684
43862306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_LONG_DQS_RANK0_2			0x688
43962306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_LONG_DQS_RANK0_3			0x68c
44062306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_LONG_DQS_RANK0_4			0x690
44162306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_LONG_DQS_RANK0_5			0x694
44262306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_LONG_DQS_RANK1_0			0x6a0
44362306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_LONG_DQS_RANK1_1			0x6a4
44462306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_LONG_DQS_RANK1_2			0x6a8
44562306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_LONG_DQS_RANK1_3			0x6ac
44662306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_LONG_DQS_RANK1_4			0x6b0
44762306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_LONG_DQS_RANK1_5			0x6b4
44862306a36Sopenharmony_ci#define EMC_PMACRO_IB_DDLL_LONG_DQS_RANK0_0			0x6c0
44962306a36Sopenharmony_ci#define EMC_PMACRO_IB_DDLL_LONG_DQS_RANK0_1			0x6c4
45062306a36Sopenharmony_ci#define EMC_PMACRO_IB_DDLL_LONG_DQS_RANK0_2			0x6c8
45162306a36Sopenharmony_ci#define EMC_PMACRO_IB_DDLL_LONG_DQS_RANK0_3			0x6cc
45262306a36Sopenharmony_ci#define EMC_PMACRO_IB_DDLL_LONG_DQS_RANK1_0			0x6e0
45362306a36Sopenharmony_ci#define EMC_PMACRO_IB_DDLL_LONG_DQS_RANK1_1			0x6e4
45462306a36Sopenharmony_ci#define EMC_PMACRO_IB_DDLL_LONG_DQS_RANK1_2			0x6e8
45562306a36Sopenharmony_ci#define EMC_PMACRO_IB_DDLL_LONG_DQS_RANK1_3			0x6ec
45662306a36Sopenharmony_ci#define EMC_PMACRO_TX_PWRD_0					0x720
45762306a36Sopenharmony_ci#define EMC_PMACRO_TX_PWRD_1					0x724
45862306a36Sopenharmony_ci#define EMC_PMACRO_TX_PWRD_2					0x728
45962306a36Sopenharmony_ci#define EMC_PMACRO_TX_PWRD_3					0x72c
46062306a36Sopenharmony_ci#define EMC_PMACRO_TX_PWRD_4					0x730
46162306a36Sopenharmony_ci#define EMC_PMACRO_TX_PWRD_5					0x734
46262306a36Sopenharmony_ci#define EMC_PMACRO_TX_SEL_CLK_SRC_0				0x740
46362306a36Sopenharmony_ci#define EMC_PMACRO_TX_SEL_CLK_SRC_1				0x744
46462306a36Sopenharmony_ci#define EMC_PMACRO_TX_SEL_CLK_SRC_3				0x74c
46562306a36Sopenharmony_ci#define EMC_PMACRO_TX_SEL_CLK_SRC_2				0x748
46662306a36Sopenharmony_ci#define EMC_PMACRO_TX_SEL_CLK_SRC_4				0x750
46762306a36Sopenharmony_ci#define EMC_PMACRO_TX_SEL_CLK_SRC_5				0x754
46862306a36Sopenharmony_ci#define EMC_PMACRO_DDLL_BYPASS					0x760
46962306a36Sopenharmony_ci#define EMC_PMACRO_DDLL_PWRD_0					0x770
47062306a36Sopenharmony_ci#define EMC_PMACRO_DDLL_PWRD_1					0x774
47162306a36Sopenharmony_ci#define EMC_PMACRO_DDLL_PWRD_2					0x778
47262306a36Sopenharmony_ci#define EMC_PMACRO_CMD_CTRL_0					0x780
47362306a36Sopenharmony_ci#define EMC_PMACRO_CMD_CTRL_1					0x784
47462306a36Sopenharmony_ci#define EMC_PMACRO_CMD_CTRL_2					0x788
47562306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_BYTE0_0		0x800
47662306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_BYTE0_1		0x804
47762306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_BYTE0_2		0x808
47862306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_BYTE0_3		0x80c
47962306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_BYTE1_0		0x810
48062306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_BYTE1_1		0x814
48162306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_BYTE1_2		0x818
48262306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_BYTE1_3		0x81c
48362306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_BYTE2_0		0x820
48462306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_BYTE2_1		0x824
48562306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_BYTE2_2		0x828
48662306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_BYTE2_3		0x82c
48762306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_BYTE3_0		0x830
48862306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_BYTE3_1		0x834
48962306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_BYTE3_2		0x838
49062306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_BYTE3_3		0x83c
49162306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_BYTE4_0		0x840
49262306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_BYTE4_1		0x844
49362306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_BYTE4_2		0x848
49462306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_BYTE4_3		0x84c
49562306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_BYTE5_0		0x850
49662306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_BYTE5_1		0x854
49762306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_BYTE5_2		0x858
49862306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_BYTE5_3		0x85c
49962306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_BYTE6_0		0x860
50062306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_BYTE6_1		0x864
50162306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_BYTE6_2		0x868
50262306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_BYTE6_3		0x86c
50362306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_BYTE7_0		0x870
50462306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_BYTE7_1		0x874
50562306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_BYTE7_2		0x878
50662306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_BYTE7_3		0x87c
50762306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_CMD0_0		0x880
50862306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_CMD0_1		0x884
50962306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_CMD0_2		0x888
51062306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_CMD0_3		0x88c
51162306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_CMD1_0		0x890
51262306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_CMD1_1		0x894
51362306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_CMD1_2		0x898
51462306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_CMD1_3		0x89c
51562306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_CMD2_0		0x8a0
51662306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_CMD2_1		0x8a4
51762306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_CMD2_2		0x8a8
51862306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_CMD2_3		0x8ac
51962306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_CMD3_0		0x8b0
52062306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_CMD3_1		0x8b4
52162306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_CMD3_2		0x8b8
52262306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_CMD3_3		0x8bc
52362306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_BYTE0_0		0x900
52462306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_BYTE0_1		0x904
52562306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_BYTE0_2		0x908
52662306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_BYTE0_3		0x90c
52762306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_BYTE1_0		0x910
52862306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_BYTE1_1		0x914
52962306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_BYTE1_2		0x918
53062306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_BYTE1_3		0x91c
53162306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_BYTE2_0		0x920
53262306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_BYTE2_1		0x924
53362306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_BYTE2_2		0x928
53462306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_BYTE2_3		0x92c
53562306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_BYTE3_0		0x930
53662306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_BYTE3_1		0x934
53762306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_BYTE3_2		0x938
53862306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_BYTE3_3		0x93c
53962306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_BYTE4_0		0x940
54062306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_BYTE4_1		0x944
54162306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_BYTE4_2		0x948
54262306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_BYTE4_3		0x94c
54362306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_BYTE5_0		0x950
54462306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_BYTE5_1		0x954
54562306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_BYTE5_2		0x958
54662306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_BYTE5_3		0x95c
54762306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_BYTE6_0		0x960
54862306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_BYTE6_1		0x964
54962306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_BYTE6_2		0x968
55062306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_BYTE6_3		0x96c
55162306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_BYTE7_0		0x970
55262306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_BYTE7_1		0x974
55362306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_BYTE7_2		0x978
55462306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_BYTE7_3		0x97c
55562306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_CMD0_0		0x980
55662306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_CMD0_1		0x984
55762306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_CMD0_2		0x988
55862306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_CMD0_3		0x98c
55962306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_CMD1_0		0x990
56062306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_CMD1_1		0x994
56162306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_CMD1_2		0x998
56262306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_CMD1_3		0x99c
56362306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_CMD2_0		0x9a0
56462306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_CMD2_1		0x9a4
56562306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_CMD2_2		0x9a8
56662306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_CMD2_3		0x9ac
56762306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_CMD3_0		0x9b0
56862306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_CMD3_1		0x9b4
56962306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_CMD3_2		0x9b8
57062306a36Sopenharmony_ci#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_CMD3_3		0x9bc
57162306a36Sopenharmony_ci#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK0_BYTE0_0		0xa00
57262306a36Sopenharmony_ci#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK0_BYTE0_1		0xa04
57362306a36Sopenharmony_ci#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK0_BYTE0_2		0xa08
57462306a36Sopenharmony_ci#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK0_BYTE1_0		0xa10
57562306a36Sopenharmony_ci#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK0_BYTE1_1		0xa14
57662306a36Sopenharmony_ci#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK0_BYTE1_2		0xa18
57762306a36Sopenharmony_ci#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK0_BYTE2_0		0xa20
57862306a36Sopenharmony_ci#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK0_BYTE2_1		0xa24
57962306a36Sopenharmony_ci#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK0_BYTE2_2		0xa28
58062306a36Sopenharmony_ci#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK0_BYTE3_0		0xa30
58162306a36Sopenharmony_ci#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK0_BYTE3_1		0xa34
58262306a36Sopenharmony_ci#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK0_BYTE3_2		0xa38
58362306a36Sopenharmony_ci#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK0_BYTE4_0		0xa40
58462306a36Sopenharmony_ci#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK0_BYTE4_1		0xa44
58562306a36Sopenharmony_ci#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK0_BYTE4_2		0xa48
58662306a36Sopenharmony_ci#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK0_BYTE5_0		0xa50
58762306a36Sopenharmony_ci#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK0_BYTE5_1		0xa54
58862306a36Sopenharmony_ci#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK0_BYTE5_2		0xa58
58962306a36Sopenharmony_ci#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK0_BYTE6_0		0xa60
59062306a36Sopenharmony_ci#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK0_BYTE6_1		0xa64
59162306a36Sopenharmony_ci#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK0_BYTE6_2		0xa68
59262306a36Sopenharmony_ci#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK0_BYTE7_0		0xa70
59362306a36Sopenharmony_ci#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK0_BYTE7_1		0xa74
59462306a36Sopenharmony_ci#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK0_BYTE7_2		0xa78
59562306a36Sopenharmony_ci#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK1_BYTE0_0		0xb00
59662306a36Sopenharmony_ci#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK1_BYTE0_1		0xb04
59762306a36Sopenharmony_ci#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK1_BYTE0_2		0xb08
59862306a36Sopenharmony_ci#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK1_BYTE1_0		0xb10
59962306a36Sopenharmony_ci#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK1_BYTE1_1		0xb14
60062306a36Sopenharmony_ci#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK1_BYTE1_2		0xb18
60162306a36Sopenharmony_ci#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK1_BYTE2_0		0xb20
60262306a36Sopenharmony_ci#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK1_BYTE2_1		0xb24
60362306a36Sopenharmony_ci#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK1_BYTE2_2		0xb28
60462306a36Sopenharmony_ci#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK1_BYTE3_0		0xb30
60562306a36Sopenharmony_ci#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK1_BYTE3_1		0xb34
60662306a36Sopenharmony_ci#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK1_BYTE3_2		0xb38
60762306a36Sopenharmony_ci#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK1_BYTE4_0		0xb40
60862306a36Sopenharmony_ci#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK1_BYTE4_1		0xb44
60962306a36Sopenharmony_ci#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK1_BYTE4_2		0xb48
61062306a36Sopenharmony_ci#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK1_BYTE5_0		0xb50
61162306a36Sopenharmony_ci#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK1_BYTE5_1		0xb54
61262306a36Sopenharmony_ci#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK1_BYTE5_2		0xb58
61362306a36Sopenharmony_ci#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK1_BYTE6_0		0xb60
61462306a36Sopenharmony_ci#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK1_BYTE6_1		0xb64
61562306a36Sopenharmony_ci#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK1_BYTE6_2		0xb68
61662306a36Sopenharmony_ci#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK1_BYTE7_0		0xb70
61762306a36Sopenharmony_ci#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK1_BYTE7_1		0xb74
61862306a36Sopenharmony_ci#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK1_BYTE7_2		0xb78
61962306a36Sopenharmony_ci#define EMC_PMACRO_IB_VREF_DQ_0					0xbe0
62062306a36Sopenharmony_ci#define EMC_PMACRO_IB_VREF_DQ_1					0xbe4
62162306a36Sopenharmony_ci#define EMC_PMACRO_IB_VREF_DQS_0				0xbf0
62262306a36Sopenharmony_ci#define EMC_PMACRO_IB_VREF_DQS_1				0xbf4
62362306a36Sopenharmony_ci#define EMC_PMACRO_DDLL_LONG_CMD_0				0xc00
62462306a36Sopenharmony_ci#define EMC_PMACRO_DDLL_LONG_CMD_1				0xc04
62562306a36Sopenharmony_ci#define EMC_PMACRO_DDLL_LONG_CMD_2				0xc08
62662306a36Sopenharmony_ci#define EMC_PMACRO_DDLL_LONG_CMD_3				0xc0c
62762306a36Sopenharmony_ci#define EMC_PMACRO_DDLL_LONG_CMD_4				0xc10
62862306a36Sopenharmony_ci#define EMC_PMACRO_DDLL_LONG_CMD_5				0xc14
62962306a36Sopenharmony_ci#define EMC_PMACRO_DDLL_SHORT_CMD_0				0xc20
63062306a36Sopenharmony_ci#define EMC_PMACRO_DDLL_SHORT_CMD_1				0xc24
63162306a36Sopenharmony_ci#define EMC_PMACRO_DDLL_SHORT_CMD_2				0xc28
63262306a36Sopenharmony_ci#define EMC_PMACRO_CFG_PM_GLOBAL_0				0xc30
63362306a36Sopenharmony_ci#define EMC_PMACRO_CFG_PM_GLOBAL_0_DISABLE_CFG_BYTE0		BIT(16)
63462306a36Sopenharmony_ci#define EMC_PMACRO_CFG_PM_GLOBAL_0_DISABLE_CFG_BYTE1		BIT(17)
63562306a36Sopenharmony_ci#define EMC_PMACRO_CFG_PM_GLOBAL_0_DISABLE_CFG_BYTE2		BIT(18)
63662306a36Sopenharmony_ci#define EMC_PMACRO_CFG_PM_GLOBAL_0_DISABLE_CFG_BYTE3		BIT(19)
63762306a36Sopenharmony_ci#define EMC_PMACRO_CFG_PM_GLOBAL_0_DISABLE_CFG_BYTE4		BIT(20)
63862306a36Sopenharmony_ci#define EMC_PMACRO_CFG_PM_GLOBAL_0_DISABLE_CFG_BYTE5		BIT(21)
63962306a36Sopenharmony_ci#define EMC_PMACRO_CFG_PM_GLOBAL_0_DISABLE_CFG_BYTE6		BIT(22)
64062306a36Sopenharmony_ci#define EMC_PMACRO_CFG_PM_GLOBAL_0_DISABLE_CFG_BYTE7		BIT(23)
64162306a36Sopenharmony_ci#define EMC_PMACRO_VTTGEN_CTRL_0				0xc34
64262306a36Sopenharmony_ci#define EMC_PMACRO_VTTGEN_CTRL_1				0xc38
64362306a36Sopenharmony_ci#define EMC_PMACRO_BG_BIAS_CTRL_0				0xc3c
64462306a36Sopenharmony_ci#define EMC_PMACRO_BG_BIAS_CTRL_0_BG_E_PWRD			BIT(0)
64562306a36Sopenharmony_ci#define EMC_PMACRO_BG_BIAS_CTRL_0_BGLP_E_PWRD			BIT(2)
64662306a36Sopenharmony_ci#define EMC_PMACRO_PAD_CFG_CTRL					0xc40
64762306a36Sopenharmony_ci#define EMC_PMACRO_ZCTRL					0xc44
64862306a36Sopenharmony_ci#define EMC_PMACRO_CMD_PAD_RX_CTRL				0xc50
64962306a36Sopenharmony_ci#define EMC_PMACRO_DATA_PAD_RX_CTRL				0xc54
65062306a36Sopenharmony_ci#define EMC_PMACRO_CMD_RX_TERM_MODE				0xc58
65162306a36Sopenharmony_ci#define EMC_PMACRO_DATA_RX_TERM_MODE				0xc5c
65262306a36Sopenharmony_ci#define EMC_PMACRO_CMD_PAD_TX_CTRL				0xc60
65362306a36Sopenharmony_ci#define EMC_PMACRO_CMD_PAD_TX_CTRL_CMD_DQ_TX_E_DCC		BIT(1)
65462306a36Sopenharmony_ci#define EMC_PMACRO_CMD_PAD_TX_CTRL_CMD_DQSP_TX_E_DCC		BIT(9)
65562306a36Sopenharmony_ci#define EMC_PMACRO_CMD_PAD_TX_CTRL_CMD_DQSN_TX_E_DCC		BIT(16)
65662306a36Sopenharmony_ci#define EMC_PMACRO_CMD_PAD_TX_CTRL_CMD_CMD_TX_E_DCC		BIT(24)
65762306a36Sopenharmony_ci#define EMC_PMACRO_CMD_PAD_TX_CTRL_CMD_DQ_TX_DRVFORCEON		BIT(26)
65862306a36Sopenharmony_ci
65962306a36Sopenharmony_ci#define EMC_PMACRO_DATA_PAD_TX_CTRL				0xc64
66062306a36Sopenharmony_ci#define EMC_PMACRO_DATA_PAD_TX_CTRL_DATA_DQ_E_IVREF		BIT(0)
66162306a36Sopenharmony_ci#define EMC_PMACRO_DATA_PAD_TX_CTRL_DATA_DQ_TX_E_DCC		BIT(1)
66262306a36Sopenharmony_ci#define EMC_PMACRO_DATA_PAD_TX_CTRL_DATA_DQS_E_IVREF		BIT(8)
66362306a36Sopenharmony_ci#define EMC_PMACRO_DATA_PAD_TX_CTRL_DATA_DQSP_TX_E_DCC		BIT(9)
66462306a36Sopenharmony_ci#define EMC_PMACRO_DATA_PAD_TX_CTRL_DATA_DQSN_TX_E_DCC		BIT(16)
66562306a36Sopenharmony_ci#define EMC_PMACRO_DATA_PAD_TX_CTRL_DATA_CMD_TX_E_DCC		BIT(24)
66662306a36Sopenharmony_ci
66762306a36Sopenharmony_ci#define EMC_PMACRO_COMMON_PAD_TX_CTRL				0xc68
66862306a36Sopenharmony_ci#define EMC_PMACRO_AUTOCAL_CFG_COMMON				0xc78
66962306a36Sopenharmony_ci#define EMC_PMACRO_AUTOCAL_CFG_COMMON_E_CAL_BYPASS_DVFS		BIT(16)
67062306a36Sopenharmony_ci#define EMC_PMACRO_VTTGEN_CTRL_2				0xcf0
67162306a36Sopenharmony_ci#define EMC_PMACRO_IB_RXRT					0xcf4
67262306a36Sopenharmony_ci#define EMC_PMACRO_TRAINING_CTRL_0				0xcf8
67362306a36Sopenharmony_ci#define EMC_PMACRO_TRAINING_CTRL_0_CH0_TRAINING_E_WRPTR		BIT(3)
67462306a36Sopenharmony_ci#define EMC_PMACRO_TRAINING_CTRL_1				0xcfc
67562306a36Sopenharmony_ci#define EMC_PMACRO_TRAINING_CTRL_1_CH1_TRAINING_E_WRPTR		BIT(3)
67662306a36Sopenharmony_ci#define EMC_TRAINING_CTRL					0xe04
67762306a36Sopenharmony_ci#define EMC_TRAINING_QUSE_CORS_CTRL				0xe0c
67862306a36Sopenharmony_ci#define EMC_TRAINING_QUSE_FINE_CTRL				0xe10
67962306a36Sopenharmony_ci#define EMC_TRAINING_QUSE_CTRL_MISC				0xe14
68062306a36Sopenharmony_ci#define EMC_TRAINING_WRITE_FINE_CTRL				0xe18
68162306a36Sopenharmony_ci#define EMC_TRAINING_WRITE_CTRL_MISC				0xe1c
68262306a36Sopenharmony_ci#define EMC_TRAINING_WRITE_VREF_CTRL				0xe20
68362306a36Sopenharmony_ci#define EMC_TRAINING_READ_FINE_CTRL				0xe24
68462306a36Sopenharmony_ci#define EMC_TRAINING_READ_CTRL_MISC				0xe28
68562306a36Sopenharmony_ci#define EMC_TRAINING_READ_VREF_CTRL				0xe2c
68662306a36Sopenharmony_ci#define EMC_TRAINING_CA_FINE_CTRL				0xe30
68762306a36Sopenharmony_ci#define EMC_TRAINING_CA_CTRL_MISC				0xe34
68862306a36Sopenharmony_ci#define EMC_TRAINING_CA_CTRL_MISC1				0xe38
68962306a36Sopenharmony_ci#define EMC_TRAINING_CA_VREF_CTRL				0xe3c
69062306a36Sopenharmony_ci#define EMC_TRAINING_SETTLE					0xe44
69162306a36Sopenharmony_ci#define EMC_TRAINING_MPC					0xe5c
69262306a36Sopenharmony_ci#define EMC_TRAINING_VREF_SETTLE				0xe6c
69362306a36Sopenharmony_ci#define EMC_TRAINING_QUSE_VREF_CTRL				0xed0
69462306a36Sopenharmony_ci#define EMC_TRAINING_OPT_DQS_IB_VREF_RANK0			0xed4
69562306a36Sopenharmony_ci#define EMC_TRAINING_OPT_DQS_IB_VREF_RANK1			0xed8
69662306a36Sopenharmony_ci
69762306a36Sopenharmony_ci#define EMC_COPY_TABLE_PARAM_PERIODIC_FIELDS			BIT(0)
69862306a36Sopenharmony_ci#define EMC_COPY_TABLE_PARAM_TRIM_REGS				BIT(1)
69962306a36Sopenharmony_ci
70062306a36Sopenharmony_cienum burst_regs_list {
70162306a36Sopenharmony_ci	EMC_RP_INDEX = 6,
70262306a36Sopenharmony_ci	EMC_R2P_INDEX = 9,
70362306a36Sopenharmony_ci	EMC_W2P_INDEX,
70462306a36Sopenharmony_ci	EMC_MRW6_INDEX = 31,
70562306a36Sopenharmony_ci	EMC_REFRESH_INDEX = 41,
70662306a36Sopenharmony_ci	EMC_PRE_REFRESH_REQ_CNT_INDEX = 43,
70762306a36Sopenharmony_ci	EMC_TRPAB_INDEX = 59,
70862306a36Sopenharmony_ci	EMC_MRW7_INDEX = 62,
70962306a36Sopenharmony_ci	EMC_FBIO_CFG5_INDEX = 65,
71062306a36Sopenharmony_ci	EMC_FBIO_CFG7_INDEX,
71162306a36Sopenharmony_ci	EMC_CFG_DIG_DLL_INDEX,
71262306a36Sopenharmony_ci	EMC_ZCAL_INTERVAL_INDEX = 139,
71362306a36Sopenharmony_ci	EMC_ZCAL_WAIT_CNT_INDEX,
71462306a36Sopenharmony_ci	EMC_MRS_WAIT_CNT_INDEX = 141,
71562306a36Sopenharmony_ci	EMC_DLL_CFG_0_INDEX = 144,
71662306a36Sopenharmony_ci	EMC_PMACRO_AUTOCAL_CFG_COMMON_INDEX = 146,
71762306a36Sopenharmony_ci	EMC_CFG_INDEX = 148,
71862306a36Sopenharmony_ci	EMC_DYN_SELF_REF_CONTROL_INDEX = 150,
71962306a36Sopenharmony_ci	EMC_PMACRO_CMD_PAD_TX_CTRL_INDEX = 161,
72062306a36Sopenharmony_ci	EMC_PMACRO_DATA_PAD_TX_CTRL_INDEX,
72162306a36Sopenharmony_ci	EMC_PMACRO_COMMON_PAD_TX_CTRL_INDEX,
72262306a36Sopenharmony_ci	EMC_PMACRO_BRICK_CTRL_RFU1_INDEX = 167,
72362306a36Sopenharmony_ci	EMC_PMACRO_BG_BIAS_CTRL_0_INDEX = 171,
72462306a36Sopenharmony_ci	EMC_MRW14_INDEX = 199,
72562306a36Sopenharmony_ci	EMC_MRW15_INDEX = 220,
72662306a36Sopenharmony_ci};
72762306a36Sopenharmony_ci
72862306a36Sopenharmony_cienum trim_regs_list {
72962306a36Sopenharmony_ci	EMC_PMACRO_OB_DDLL_LONG_DQ_RANK0_0_INDEX = 60,
73062306a36Sopenharmony_ci	EMC_PMACRO_OB_DDLL_LONG_DQ_RANK0_1_INDEX,
73162306a36Sopenharmony_ci	EMC_PMACRO_OB_DDLL_LONG_DQ_RANK0_2_INDEX,
73262306a36Sopenharmony_ci	EMC_PMACRO_OB_DDLL_LONG_DQ_RANK0_3_INDEX,
73362306a36Sopenharmony_ci	EMC_PMACRO_OB_DDLL_LONG_DQ_RANK0_4_INDEX,
73462306a36Sopenharmony_ci	EMC_PMACRO_OB_DDLL_LONG_DQ_RANK0_5_INDEX,
73562306a36Sopenharmony_ci	EMC_PMACRO_OB_DDLL_LONG_DQ_RANK1_0_INDEX,
73662306a36Sopenharmony_ci	EMC_PMACRO_OB_DDLL_LONG_DQ_RANK1_1_INDEX,
73762306a36Sopenharmony_ci	EMC_PMACRO_OB_DDLL_LONG_DQ_RANK1_2_INDEX,
73862306a36Sopenharmony_ci	EMC_PMACRO_OB_DDLL_LONG_DQ_RANK1_3_INDEX,
73962306a36Sopenharmony_ci};
74062306a36Sopenharmony_ci
74162306a36Sopenharmony_cienum burst_mc_regs_list {
74262306a36Sopenharmony_ci	MC_EMEM_ARB_MISC0_INDEX = 20,
74362306a36Sopenharmony_ci};
74462306a36Sopenharmony_ci
74562306a36Sopenharmony_cienum {
74662306a36Sopenharmony_ci	T_RP,
74762306a36Sopenharmony_ci	T_FC_LPDDR4,
74862306a36Sopenharmony_ci	T_RFC,
74962306a36Sopenharmony_ci	T_PDEX,
75062306a36Sopenharmony_ci	RL,
75162306a36Sopenharmony_ci};
75262306a36Sopenharmony_ci
75362306a36Sopenharmony_cienum {
75462306a36Sopenharmony_ci	AUTO_PD = 0,
75562306a36Sopenharmony_ci	MAN_SR  = 2,
75662306a36Sopenharmony_ci};
75762306a36Sopenharmony_ci
75862306a36Sopenharmony_cienum {
75962306a36Sopenharmony_ci	ASSEMBLY = 0,
76062306a36Sopenharmony_ci	ACTIVE,
76162306a36Sopenharmony_ci};
76262306a36Sopenharmony_ci
76362306a36Sopenharmony_cienum {
76462306a36Sopenharmony_ci	C0D0U0,
76562306a36Sopenharmony_ci	C0D0U1,
76662306a36Sopenharmony_ci	C0D1U0,
76762306a36Sopenharmony_ci	C0D1U1,
76862306a36Sopenharmony_ci	C1D0U0,
76962306a36Sopenharmony_ci	C1D0U1,
77062306a36Sopenharmony_ci	C1D1U0,
77162306a36Sopenharmony_ci	C1D1U1,
77262306a36Sopenharmony_ci	DRAM_CLKTREE_NUM,
77362306a36Sopenharmony_ci};
77462306a36Sopenharmony_ci
77562306a36Sopenharmony_ci#define VREF_REGS_PER_CHANNEL_SIZE 4
77662306a36Sopenharmony_ci#define DRAM_TIMINGS_NUM 5
77762306a36Sopenharmony_ci#define BURST_REGS_PER_CHANNEL_SIZE 8
77862306a36Sopenharmony_ci#define TRIM_REGS_PER_CHANNEL_SIZE 10
77962306a36Sopenharmony_ci#define PTFV_ARRAY_SIZE 12
78062306a36Sopenharmony_ci#define SAVE_RESTORE_MOD_REGS_SIZE 12
78162306a36Sopenharmony_ci#define TRAINING_MOD_REGS_SIZE 20
78262306a36Sopenharmony_ci#define BURST_UP_DOWN_REGS_SIZE 24
78362306a36Sopenharmony_ci#define BURST_MC_REGS_SIZE 33
78462306a36Sopenharmony_ci#define TRIM_REGS_SIZE 138
78562306a36Sopenharmony_ci#define BURST_REGS_SIZE 221
78662306a36Sopenharmony_ci
78762306a36Sopenharmony_cistruct tegra210_emc_per_channel_regs {
78862306a36Sopenharmony_ci	u16 bank;
78962306a36Sopenharmony_ci	u16 offset;
79062306a36Sopenharmony_ci};
79162306a36Sopenharmony_ci
79262306a36Sopenharmony_cistruct tegra210_emc_table_register_offsets {
79362306a36Sopenharmony_ci	u16 burst[BURST_REGS_SIZE];
79462306a36Sopenharmony_ci	u16 trim[TRIM_REGS_SIZE];
79562306a36Sopenharmony_ci	u16 burst_mc[BURST_MC_REGS_SIZE];
79662306a36Sopenharmony_ci	u16 la_scale[BURST_UP_DOWN_REGS_SIZE];
79762306a36Sopenharmony_ci	struct tegra210_emc_per_channel_regs burst_per_channel[BURST_REGS_PER_CHANNEL_SIZE];
79862306a36Sopenharmony_ci	struct tegra210_emc_per_channel_regs trim_per_channel[TRIM_REGS_PER_CHANNEL_SIZE];
79962306a36Sopenharmony_ci	struct tegra210_emc_per_channel_regs vref_per_channel[VREF_REGS_PER_CHANNEL_SIZE];
80062306a36Sopenharmony_ci};
80162306a36Sopenharmony_ci
80262306a36Sopenharmony_cistruct tegra210_emc_timing {
80362306a36Sopenharmony_ci	u32 revision;
80462306a36Sopenharmony_ci	const char dvfs_ver[60];
80562306a36Sopenharmony_ci	u32 rate;
80662306a36Sopenharmony_ci	u32 min_volt;
80762306a36Sopenharmony_ci	u32 gpu_min_volt;
80862306a36Sopenharmony_ci	const char clock_src[32];
80962306a36Sopenharmony_ci	u32 clk_src_emc;
81062306a36Sopenharmony_ci	u32 needs_training;
81162306a36Sopenharmony_ci	u32 training_pattern;
81262306a36Sopenharmony_ci	u32 trained;
81362306a36Sopenharmony_ci
81462306a36Sopenharmony_ci	u32 periodic_training;
81562306a36Sopenharmony_ci	u32 trained_dram_clktree[DRAM_CLKTREE_NUM];
81662306a36Sopenharmony_ci	u32 current_dram_clktree[DRAM_CLKTREE_NUM];
81762306a36Sopenharmony_ci	u32 run_clocks;
81862306a36Sopenharmony_ci	u32 tree_margin;
81962306a36Sopenharmony_ci
82062306a36Sopenharmony_ci	u32 num_burst;
82162306a36Sopenharmony_ci	u32 num_burst_per_ch;
82262306a36Sopenharmony_ci	u32 num_trim;
82362306a36Sopenharmony_ci	u32 num_trim_per_ch;
82462306a36Sopenharmony_ci	u32 num_mc_regs;
82562306a36Sopenharmony_ci	u32 num_up_down;
82662306a36Sopenharmony_ci	u32 vref_num;
82762306a36Sopenharmony_ci	u32 training_mod_num;
82862306a36Sopenharmony_ci	u32 dram_timing_num;
82962306a36Sopenharmony_ci
83062306a36Sopenharmony_ci	u32 ptfv_list[PTFV_ARRAY_SIZE];
83162306a36Sopenharmony_ci
83262306a36Sopenharmony_ci	u32 burst_regs[BURST_REGS_SIZE];
83362306a36Sopenharmony_ci	u32 burst_reg_per_ch[BURST_REGS_PER_CHANNEL_SIZE];
83462306a36Sopenharmony_ci	u32 shadow_regs_ca_train[BURST_REGS_SIZE];
83562306a36Sopenharmony_ci	u32 shadow_regs_quse_train[BURST_REGS_SIZE];
83662306a36Sopenharmony_ci	u32 shadow_regs_rdwr_train[BURST_REGS_SIZE];
83762306a36Sopenharmony_ci
83862306a36Sopenharmony_ci	u32 trim_regs[TRIM_REGS_SIZE];
83962306a36Sopenharmony_ci	u32 trim_perch_regs[TRIM_REGS_PER_CHANNEL_SIZE];
84062306a36Sopenharmony_ci
84162306a36Sopenharmony_ci	u32 vref_perch_regs[VREF_REGS_PER_CHANNEL_SIZE];
84262306a36Sopenharmony_ci
84362306a36Sopenharmony_ci	u32 dram_timings[DRAM_TIMINGS_NUM];
84462306a36Sopenharmony_ci	u32 training_mod_regs[TRAINING_MOD_REGS_SIZE];
84562306a36Sopenharmony_ci	u32 save_restore_mod_regs[SAVE_RESTORE_MOD_REGS_SIZE];
84662306a36Sopenharmony_ci	u32 burst_mc_regs[BURST_MC_REGS_SIZE];
84762306a36Sopenharmony_ci	u32 la_scale_regs[BURST_UP_DOWN_REGS_SIZE];
84862306a36Sopenharmony_ci
84962306a36Sopenharmony_ci	u32 min_mrs_wait;
85062306a36Sopenharmony_ci	u32 emc_mrw;
85162306a36Sopenharmony_ci	u32 emc_mrw2;
85262306a36Sopenharmony_ci	u32 emc_mrw3;
85362306a36Sopenharmony_ci	u32 emc_mrw4;
85462306a36Sopenharmony_ci	u32 emc_mrw9;
85562306a36Sopenharmony_ci	u32 emc_mrs;
85662306a36Sopenharmony_ci	u32 emc_emrs;
85762306a36Sopenharmony_ci	u32 emc_emrs2;
85862306a36Sopenharmony_ci	u32 emc_auto_cal_config;
85962306a36Sopenharmony_ci	u32 emc_auto_cal_config2;
86062306a36Sopenharmony_ci	u32 emc_auto_cal_config3;
86162306a36Sopenharmony_ci	u32 emc_auto_cal_config4;
86262306a36Sopenharmony_ci	u32 emc_auto_cal_config5;
86362306a36Sopenharmony_ci	u32 emc_auto_cal_config6;
86462306a36Sopenharmony_ci	u32 emc_auto_cal_config7;
86562306a36Sopenharmony_ci	u32 emc_auto_cal_config8;
86662306a36Sopenharmony_ci	u32 emc_cfg_2;
86762306a36Sopenharmony_ci	u32 emc_sel_dpd_ctrl;
86862306a36Sopenharmony_ci	u32 emc_fdpd_ctrl_cmd_no_ramp;
86962306a36Sopenharmony_ci	u32 dll_clk_src;
87062306a36Sopenharmony_ci	u32 clk_out_enb_x_0_clk_enb_emc_dll;
87162306a36Sopenharmony_ci	u32 latency;
87262306a36Sopenharmony_ci};
87362306a36Sopenharmony_ci
87462306a36Sopenharmony_cienum tegra210_emc_refresh {
87562306a36Sopenharmony_ci	TEGRA210_EMC_REFRESH_NOMINAL = 0,
87662306a36Sopenharmony_ci	TEGRA210_EMC_REFRESH_2X,
87762306a36Sopenharmony_ci	TEGRA210_EMC_REFRESH_4X,
87862306a36Sopenharmony_ci	TEGRA210_EMC_REFRESH_THROTTLE, /* 4x Refresh + derating. */
87962306a36Sopenharmony_ci};
88062306a36Sopenharmony_ci
88162306a36Sopenharmony_ci#define DRAM_TYPE_DDR3		0
88262306a36Sopenharmony_ci#define DRAM_TYPE_LPDDR4	1
88362306a36Sopenharmony_ci#define DRAM_TYPE_LPDDR2	2
88462306a36Sopenharmony_ci#define DRAM_TYPE_DDR2		3
88562306a36Sopenharmony_ci
88662306a36Sopenharmony_cistruct tegra210_emc {
88762306a36Sopenharmony_ci	struct tegra_mc *mc;
88862306a36Sopenharmony_ci	struct device *dev;
88962306a36Sopenharmony_ci	struct clk *clk;
89062306a36Sopenharmony_ci
89162306a36Sopenharmony_ci	/* nominal EMC frequency table */
89262306a36Sopenharmony_ci	struct tegra210_emc_timing *nominal;
89362306a36Sopenharmony_ci	/* derated EMC frequency table */
89462306a36Sopenharmony_ci	struct tegra210_emc_timing *derated;
89562306a36Sopenharmony_ci
89662306a36Sopenharmony_ci	/* currently selected table (nominal or derated) */
89762306a36Sopenharmony_ci	struct tegra210_emc_timing *timings;
89862306a36Sopenharmony_ci	unsigned int num_timings;
89962306a36Sopenharmony_ci
90062306a36Sopenharmony_ci	const struct tegra210_emc_table_register_offsets *offsets;
90162306a36Sopenharmony_ci
90262306a36Sopenharmony_ci	const struct tegra210_emc_sequence *sequence;
90362306a36Sopenharmony_ci	spinlock_t lock;
90462306a36Sopenharmony_ci
90562306a36Sopenharmony_ci	void __iomem *regs, *channel[2];
90662306a36Sopenharmony_ci	unsigned int num_channels;
90762306a36Sopenharmony_ci	unsigned int num_devices;
90862306a36Sopenharmony_ci	unsigned int dram_type;
90962306a36Sopenharmony_ci
91062306a36Sopenharmony_ci	struct tegra210_emc_timing *last;
91162306a36Sopenharmony_ci	struct tegra210_emc_timing *next;
91262306a36Sopenharmony_ci
91362306a36Sopenharmony_ci	unsigned int training_interval;
91462306a36Sopenharmony_ci	struct timer_list training;
91562306a36Sopenharmony_ci
91662306a36Sopenharmony_ci	enum tegra210_emc_refresh refresh;
91762306a36Sopenharmony_ci	unsigned int refresh_poll_interval;
91862306a36Sopenharmony_ci	struct timer_list refresh_timer;
91962306a36Sopenharmony_ci	unsigned int temperature;
92062306a36Sopenharmony_ci	atomic_t refresh_poll;
92162306a36Sopenharmony_ci
92262306a36Sopenharmony_ci	ktime_t clkchange_time;
92362306a36Sopenharmony_ci	int clkchange_delay;
92462306a36Sopenharmony_ci
92562306a36Sopenharmony_ci	unsigned long resume_rate;
92662306a36Sopenharmony_ci
92762306a36Sopenharmony_ci	struct {
92862306a36Sopenharmony_ci		struct dentry *root;
92962306a36Sopenharmony_ci		unsigned long min_rate;
93062306a36Sopenharmony_ci		unsigned long max_rate;
93162306a36Sopenharmony_ci		unsigned int temperature;
93262306a36Sopenharmony_ci	} debugfs;
93362306a36Sopenharmony_ci
93462306a36Sopenharmony_ci	struct tegra210_clk_emc_provider provider;
93562306a36Sopenharmony_ci};
93662306a36Sopenharmony_ci
93762306a36Sopenharmony_cistruct tegra210_emc_sequence {
93862306a36Sopenharmony_ci	u8 revision;
93962306a36Sopenharmony_ci	void (*set_clock)(struct tegra210_emc *emc, u32 clksrc);
94062306a36Sopenharmony_ci	u32 (*periodic_compensation)(struct tegra210_emc *emc);
94162306a36Sopenharmony_ci};
94262306a36Sopenharmony_ci
94362306a36Sopenharmony_cistatic inline void emc_writel(struct tegra210_emc *emc, u32 value,
94462306a36Sopenharmony_ci			      unsigned int offset)
94562306a36Sopenharmony_ci{
94662306a36Sopenharmony_ci	writel_relaxed(value, emc->regs + offset);
94762306a36Sopenharmony_ci}
94862306a36Sopenharmony_ci
94962306a36Sopenharmony_cistatic inline u32 emc_readl(struct tegra210_emc *emc, unsigned int offset)
95062306a36Sopenharmony_ci{
95162306a36Sopenharmony_ci	return readl_relaxed(emc->regs + offset);
95262306a36Sopenharmony_ci}
95362306a36Sopenharmony_ci
95462306a36Sopenharmony_cistatic inline void emc_channel_writel(struct tegra210_emc *emc,
95562306a36Sopenharmony_ci				      unsigned int channel,
95662306a36Sopenharmony_ci				      u32 value, unsigned int offset)
95762306a36Sopenharmony_ci{
95862306a36Sopenharmony_ci	writel_relaxed(value, emc->channel[channel] + offset);
95962306a36Sopenharmony_ci}
96062306a36Sopenharmony_ci
96162306a36Sopenharmony_cistatic inline u32 emc_channel_readl(struct tegra210_emc *emc,
96262306a36Sopenharmony_ci				    unsigned int channel, unsigned int offset)
96362306a36Sopenharmony_ci{
96462306a36Sopenharmony_ci	return readl_relaxed(emc->channel[channel] + offset);
96562306a36Sopenharmony_ci}
96662306a36Sopenharmony_ci
96762306a36Sopenharmony_cistatic inline void ccfifo_writel(struct tegra210_emc *emc, u32 value,
96862306a36Sopenharmony_ci				 unsigned int offset, u32 delay)
96962306a36Sopenharmony_ci{
97062306a36Sopenharmony_ci	writel_relaxed(value, emc->regs + EMC_CCFIFO_DATA);
97162306a36Sopenharmony_ci
97262306a36Sopenharmony_ci	value = EMC_CCFIFO_ADDR_STALL_BY_1 | EMC_CCFIFO_ADDR_STALL(delay) |
97362306a36Sopenharmony_ci		EMC_CCFIFO_ADDR_OFFSET(offset);
97462306a36Sopenharmony_ci	writel_relaxed(value, emc->regs + EMC_CCFIFO_ADDR);
97562306a36Sopenharmony_ci}
97662306a36Sopenharmony_ci
97762306a36Sopenharmony_cistatic inline u32 div_o3(u32 a, u32 b)
97862306a36Sopenharmony_ci{
97962306a36Sopenharmony_ci	u32 result = a / b;
98062306a36Sopenharmony_ci
98162306a36Sopenharmony_ci	if ((b * result) < a)
98262306a36Sopenharmony_ci		return result + 1;
98362306a36Sopenharmony_ci
98462306a36Sopenharmony_ci	return result;
98562306a36Sopenharmony_ci}
98662306a36Sopenharmony_ci
98762306a36Sopenharmony_ci/* from tegra210-emc-r21021.c */
98862306a36Sopenharmony_ciextern const struct tegra210_emc_sequence tegra210_emc_r21021;
98962306a36Sopenharmony_ci
99062306a36Sopenharmony_ciint tegra210_emc_set_refresh(struct tegra210_emc *emc,
99162306a36Sopenharmony_ci			     enum tegra210_emc_refresh refresh);
99262306a36Sopenharmony_ciu32 tegra210_emc_mrr_read(struct tegra210_emc *emc, unsigned int chip,
99362306a36Sopenharmony_ci			  unsigned int address);
99462306a36Sopenharmony_civoid tegra210_emc_do_clock_change(struct tegra210_emc *emc, u32 clksrc);
99562306a36Sopenharmony_civoid tegra210_emc_set_shadow_bypass(struct tegra210_emc *emc, int set);
99662306a36Sopenharmony_civoid tegra210_emc_timing_update(struct tegra210_emc *emc);
99762306a36Sopenharmony_ciu32 tegra210_emc_get_dll_state(struct tegra210_emc_timing *next);
99862306a36Sopenharmony_cistruct tegra210_emc_timing *tegra210_emc_find_timing(struct tegra210_emc *emc,
99962306a36Sopenharmony_ci						     unsigned long rate);
100062306a36Sopenharmony_civoid tegra210_emc_adjust_timing(struct tegra210_emc *emc,
100162306a36Sopenharmony_ci				struct tegra210_emc_timing *timing);
100262306a36Sopenharmony_ciint tegra210_emc_wait_for_update(struct tegra210_emc *emc, unsigned int channel,
100362306a36Sopenharmony_ci				 unsigned int offset, u32 bit_mask, bool state);
100462306a36Sopenharmony_ciunsigned long tegra210_emc_actual_osc_clocks(u32 in);
100562306a36Sopenharmony_ciu32 tegra210_emc_compensate(struct tegra210_emc_timing *next, u32 offset);
100662306a36Sopenharmony_civoid tegra210_emc_dll_disable(struct tegra210_emc *emc);
100762306a36Sopenharmony_civoid tegra210_emc_dll_enable(struct tegra210_emc *emc);
100862306a36Sopenharmony_ciu32 tegra210_emc_dll_prelock(struct tegra210_emc *emc, u32 clksrc);
100962306a36Sopenharmony_ciu32 tegra210_emc_dvfs_power_ramp_down(struct tegra210_emc *emc, u32 clk,
101062306a36Sopenharmony_ci				      bool flip_backward);
101162306a36Sopenharmony_ciu32 tegra210_emc_dvfs_power_ramp_up(struct tegra210_emc *emc, u32 clk,
101262306a36Sopenharmony_ci				    bool flip_backward);
101362306a36Sopenharmony_civoid tegra210_emc_reset_dram_clktree_values(struct tegra210_emc_timing *timing);
101462306a36Sopenharmony_civoid tegra210_emc_start_periodic_compensation(struct tegra210_emc *emc);
101562306a36Sopenharmony_ci
101662306a36Sopenharmony_ci#endif
1017