coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
sdram.c File Reference
#include <device/mmio.h>
#include <console/console.h>
#include <delay.h>
#include <soc/addressmap.h>
#include <soc/clock.h>
#include <soc/sdram.h>
#include <soc/grf.h>
#include <soc/soc.h>
#include <soc/pmu.h>
#include <types.h>
Include dependency graph for sdram.c:

Go to the source code of this file.

Data Structures

struct  rk3288_ddr_pctl_regs
 
struct  rk3288_ddr_publ_datx
 
struct  rk3288_ddr_publ_regs
 
struct  rk3288_msch_regs
 

Macros

#define DFI_INIT_START   (1 << 0)
 
#define DFI_DRAM_CLK_SR_EN   (1 << 0)
 
#define DFI_DRAM_CLK_DPD_EN   (1 << 1)
 
#define DFI_PARITY_INTR_EN   (1 << 0)
 
#define DFI_PARITY_EN   (1 << 1)
 
#define TLP_RESP_TIME(n)   (n << 16)
 
#define LP_SR_EN   (1 << 8)
 
#define LP_PD_EN   (1 << 0)
 
#define TCTRL_DELAY_TIME(n)   (n << 0)
 
#define TPHY_WRDATA_TIME(n)   (n << 0)
 
#define TPHY_RDLAT_TIME(n)   (n << 0)
 
#define TDRAM_CLK_DIS_TIME(n)   (n << 0)
 
#define TDRAM_CLK_EN_TIME(n)   (n << 0)
 
#define RANK0_ODT_WRITE_SEL   (1 << 3)
 
#define RANK1_ODT_WRITE_SEL   (1 << 11)
 
#define ODT_LEN_BL8_W(n)   (n<<16)
 
#define ACDLLCR_DLLDIS   (1 << 31)
 
#define ACDLLCR_DLLSRST   (1 << 30)
 
#define DXDLLCR_DLLDIS   (1 << 31)
 
#define DXDLLCR_DLLSRST   (1 << 30)
 
#define DLLGCR_SBIAS   (1 << 30)
 
#define DQSRTT   (1 << 9)
 
#define DQRTT   (1 << 10)
 
#define PIR_INIT   (1 << 0)
 
#define PIR_DLLSRST   (1 << 1)
 
#define PIR_DLLLOCK   (1 << 2)
 
#define PIR_ZCAL   (1 << 3)
 
#define PIR_ITMSRST   (1 << 4)
 
#define PIR_DRAMRST   (1 << 5)
 
#define PIR_DRAMINIT   (1 << 6)
 
#define PIR_QSTRN   (1 << 7)
 
#define PIR_RVTRN   (1 << 8)
 
#define PIR_ICPC   (1 << 16)
 
#define PIR_DLLBYP   (1 << 17)
 
#define PIR_CTLDINIT   (1 << 18)
 
#define PIR_CLRSR   (1 << 28)
 
#define PIR_LOCKBYP   (1 << 29)
 
#define PIR_ZCALBYP   (1 << 30)
 
#define PIR_INITBYP   (1u << 31)
 
#define PGCR_DFTLMT(n)   ((n) << 3)
 
#define PGCR_DFTCMP(n)   ((n) << 2)
 
#define PGCR_DQSCFG(n)   ((n) << 1)
 
#define PGCR_ITMDMD(n)   ((n) << 0)
 
#define PGSR_IDONE   (1 << 0)
 
#define PGSR_DLDONE   (1 << 1)
 
#define PGSR_ZCDONE   (1 << 2)
 
#define PGSR_DIDONE   (1 << 3)
 
#define PGSR_DTDONE   (1 << 4)
 
#define PGSR_DTERR   (1 << 5)
 
#define PGSR_DTIERR   (1 << 6)
 
#define PGSR_DFTERR   (1 << 7)
 
#define PGSR_RVERR   (1 << 8)
 
#define PGSR_RVEIRR   (1 << 9)
 
#define PRT_ITMSRST(n)   ((n) << 18)
 
#define PRT_DLLLOCK(n)   ((n) << 6)
 
#define PRT_DLLSRST(n)   ((n) << 0)
 
#define PRT_DINIT0(n)   ((n) << 0)
 
#define PRT_DINIT1(n)   ((n) << 19)
 
#define PRT_DINIT2(n)   ((n) << 0)
 
#define PRT_DINIT3(n)   ((n) << 17)
 
#define DDRMD_LPDDR   0
 
#define DDRMD_DDR   1
 
#define DDRMD_DDR2   2
 
#define DDRMD_DDR3   3
 
#define DDRMD_LPDDR2_LPDDR3   4
 
#define DDRMD_MSK   (7 << 0)
 
#define DDRMD_CFG(n)   ((n) << 0)
 
#define PDQ_MSK   (7 << 4)
 
#define PDQ_CFG(n)   ((n) << 4)
 
#define DQSNRES_MSK   (0x0f << 8)
 
#define DQSNRES_CFG(n)   ((n) << 8)
 
#define DQSRES_MSK   (0x0f << 4)
 
#define DQSRES_CFG(n)   ((n) << 4)
 
#define TDQSCKMAX_VAL(n)   (((n) >> 27) & 7)
 
#define TDQSCK_VAL(n)   (((n) >> 24) & 7)
 
#define DQSGX_MSK   (0x07 << 5)
 
#define DQSGX_CFG(n)   ((n) << 5)
 
#define DQSGE_MSK   (0x07 << 8)
 
#define DQSGE_CFG(n)   ((n) << 8)
 
#define INIT_STATE   (0)
 
#define CFG_STATE   (1)
 
#define GO_STATE   (2)
 
#define SLEEP_STATE   (3)
 
#define WAKEUP_STATE   (4)
 
#define LP_TRIG_VAL(n)   (((n) >> 4) & 7)
 
#define PCTL_STAT_MSK   (7)
 
#define INIT_MEM   (0)
 
#define CONF   (1)
 
#define CONF_REQ   (2)
 
#define ACCESS   (3)
 
#define ACCESS_REQ   (4)
 
#define LOW_POWER   (5)
 
#define LOW_POWER_ENTRY_REQ   (6)
 
#define LOW_POWER_EXIT_REQ   (7)
 
#define PD_OUTPUT(n)   ((n) << 0)
 
#define PU_OUTPUT(n)   ((n) << 5)
 
#define PD_ONDIE(n)   ((n) << 10)
 
#define PU_ONDIE(n)   ((n) << 15)
 
#define ZDEN(n)   ((n) << 28)
 
#define SBIAS_BYPASS   (1 << 23)
 
#define MDDR_LPDDR2_CLK_STOP_IDLE(n)   ((n) << 24)
 
#define PD_IDLE(n)   ((n) << 8)
 
#define MDDR_EN   (2 << 22)
 
#define LPDDR2_EN   (3 << 22)
 
#define DDR2_EN   (0 << 5)
 
#define DDR3_EN   (1 << 5)
 
#define LPDDR2_S2   (0 << 6)
 
#define LPDDR2_S4   (1 << 6)
 
#define MDDR_LPDDR2_BL_2   (0 << 20)
 
#define MDDR_LPDDR2_BL_4   (1 << 20)
 
#define MDDR_LPDDR2_BL_8   (2 << 20)
 
#define MDDR_LPDDR2_BL_16   (3 << 20)
 
#define DDR2_DDR3_BL_4   (0)
 
#define DDR2_DDR3_BL_8   (1)
 
#define TFAW_CFG(n)   (((n)-4) << 18)
 
#define PD_EXIT_SLOW   (0 << 17)
 
#define PD_EXIT_FAST   (1 << 17)
 
#define PD_TYPE(n)   ((n) << 16)
 
#define BURSTLENGTH_CFG(n)   (((n) >> 1) << 20)
 
#define POWER_UP_START   (1 << 0)
 
#define POWER_UP_DONE   (1 << 0)
 
#define DESELECT_CMD   (0)
 
#define PREA_CMD   (1)
 
#define REF_CMD   (2)
 
#define MRS_CMD   (3)
 
#define ZQCS_CMD   (4)
 
#define ZQCL_CMD   (5)
 
#define RSTL_CMD   (6)
 
#define MRR_CMD   (8)
 
#define DPDE_CMD   (9)
 
#define LPDDR2_MA(n)   (((n) & 0xff) << 4)
 
#define LPDDR2_OP(n)   (((n) & 0xff) << 12)
 
#define START_CMD   (1u << 31)
 
#define BUSWRTORD(n)   ((n) << 4)
 
#define BUSRDTOWR(n)   ((n) << 2)
 
#define BUSRDTORD(n)   ((n) << 0)
 
#define MSCH_MAINDDR3(ch, n)
 
#define PCTL_LPDDR3_ODT_EN(ch, n)
 
#define PCTL_BST_DISABLE(ch, n)
 
#define PUBL_LPDDR3_EN(ch, n)
 
#define DDR3_DLL_ENABLE   (0)
 
#define DDR3_DLL_DISABLE   (1)
 
#define SYS_REG_ENC_ROW_3_4(n, ch)   ((n) << (30 + (ch)))
 
#define SYS_REG_DEC_ROW_3_4(n, ch)   ((n >> (30 + ch)) & 0x1)
 
#define SYS_REG_ENC_CHINFO(ch)   (1 << (28 + (ch)))
 
#define SYS_REG_ENC_DDRTYPE(n)   ((n) << 13)
 
#define SYS_REG_ENC_NUM_CH(n)   (((n) - 1) << 12)
 
#define SYS_REG_DEC_NUM_CH(n)   (1 + ((n >> 12) & 0x1))
 
#define SYS_REG_ENC_RANK(n, ch)   (((n) - 1) << (11 + ((ch) * 16)))
 
#define SYS_REG_DEC_RANK(n, ch)   (1 + ((n >> (11 + 16 * ch)) & 0x1))
 
#define SYS_REG_ENC_COL(n, ch)   (((n) - 9) << (9 + ((ch) * 16)))
 
#define SYS_REG_DEC_COL(n, ch)   (9 + ((n >> (9 + 16 * ch)) & 0x3))
 
#define SYS_REG_ENC_BK(n, ch)
 
#define SYS_REG_DEC_BK(n, ch)   (3 - ((n >> (8 + 16 * ch)) & 0x1))
 
#define SYS_REG_ENC_CS0_ROW(n, ch)   (((n) - 13) << (6 + ((ch) * 16)))
 
#define SYS_REG_DEC_CS0_ROW(n, ch)   (13 + ((n >> (6 + 16 * ch)) & 0x3))
 
#define SYS_REG_ENC_CS1_ROW(n, ch)   (((n) - 13) << (4 + ((ch) * 16)))
 
#define SYS_REG_DEC_CS1_ROW(n, ch)   (13 + ((n >> (4 + 16 * ch)) & 0x3))
 
#define SYS_REG_ENC_BW(n, ch)   ((2 >> (n)) << (2 + ((ch) * 16)))
 
#define SYS_REG_DEC_BW(n, ch)   (2 >> ((n >> (2 + 16 * ch)) & 0x3))
 
#define SYS_REG_ENC_DBW(n, ch)   ((2 >> (n)) << (0 + ((ch) * 16)))
 
#define SYS_REG_DEC_DBW(n, ch)   (2 >> ((n >> (0 + 16 * ch)) & 0x3))
 

Functions

 check_member (rk3288_ddr_pctl_regs, iptr, 0x03fc)
 
 check_member (rk3288_ddr_publ_regs, datx8[3].dxdqstr, 0x0294)
 
 check_member (rk3288_msch_regs, devtodev, 0x003c)
 
static void copy_to_reg (u32 *dest, const u32 *src, u32 n)
 
static void phy_pctrl_reset (struct rk3288_ddr_publ_regs *ddr_publ_regs, u32 channel)
 
static void phy_dll_bypass_set (struct rk3288_ddr_publ_regs *ddr_publ_regs, u32 freq)
 
static void dfi_cfg (struct rk3288_ddr_pctl_regs *ddr_pctl_regs, u32 dramtype)
 
static void pctl_cfg (u32 channel, const struct rk3288_sdram_params *sdram_params)
 
static void phy_cfg (u32 channel, const struct rk3288_sdram_params *sdram_params)
 
static void phy_init (struct rk3288_ddr_publ_regs *ddr_publ_regs)
 
static void send_command (struct rk3288_ddr_pctl_regs *ddr_pctl_regs, u32 rank, u32 cmd, u32 arg)
 
static void memory_init (struct rk3288_ddr_publ_regs *ddr_publ_regs, u32 dramtype)
 
static void move_to_config_state (struct rk3288_ddr_publ_regs *ddr_publ_regs, struct rk3288_ddr_pctl_regs *ddr_pctl_regs)
 
static void set_bandwidth_ratio (u32 channel, u32 n)
 
static int data_training (u32 channel, const struct rk3288_sdram_params *sdram_params)
 
static void move_to_access_state (u32 chnum)
 
static void dram_cfg_rbc (u32 chnum, const struct rk3288_sdram_params *sdram_params)
 
static void dram_all_config (const struct rk3288_sdram_params *sdram_params)
 
void sdram_init (const struct rk3288_sdram_params *sdram_params)
 
size_t sdram_size_mb (void)
 

Variables

static struct rk3288_ddr_pctl_regs *const rk3288_ddr_pctl [2]
 
static struct rk3288_ddr_publ_regs *const rk3288_ddr_publ [2]
 
static struct rk3288_msch_regs *const rk3288_msch [2]
 

Macro Definition Documentation

◆ ACCESS

#define ACCESS   (3)

Definition at line 372 of file sdram.c.

◆ ACCESS_REQ

#define ACCESS_REQ   (4)

Definition at line 373 of file sdram.c.

◆ ACDLLCR_DLLDIS

#define ACDLLCR_DLLDIS   (1 << 31)

Definition at line 269 of file sdram.c.

◆ ACDLLCR_DLLSRST

#define ACDLLCR_DLLSRST   (1 << 30)

Definition at line 270 of file sdram.c.

◆ BURSTLENGTH_CFG

#define BURSTLENGTH_CFG (   n)    (((n) >> 1) << 20)

Definition at line 407 of file sdram.c.

◆ BUSRDTORD

#define BUSRDTORD (   n)    ((n) << 0)

Definition at line 434 of file sdram.c.

◆ BUSRDTOWR

#define BUSRDTOWR (   n)    ((n) << 2)

Definition at line 433 of file sdram.c.

◆ BUSWRTORD

#define BUSWRTORD (   n)    ((n) << 4)

Definition at line 432 of file sdram.c.

◆ CFG_STATE

#define CFG_STATE   (1)

Definition at line 361 of file sdram.c.

◆ CONF

#define CONF   (1)

Definition at line 370 of file sdram.c.

◆ CONF_REQ

#define CONF_REQ   (2)

Definition at line 371 of file sdram.c.

◆ DDR2_DDR3_BL_4

#define DDR2_DDR3_BL_4   (0)

Definition at line 401 of file sdram.c.

◆ DDR2_DDR3_BL_8

#define DDR2_DDR3_BL_8   (1)

Definition at line 402 of file sdram.c.

◆ DDR2_EN

#define DDR2_EN   (0 << 5)

Definition at line 393 of file sdram.c.

◆ DDR3_DLL_DISABLE

#define DDR3_DLL_DISABLE   (1)

Definition at line 450 of file sdram.c.

◆ DDR3_DLL_ENABLE

#define DDR3_DLL_ENABLE   (0)

Definition at line 449 of file sdram.c.

◆ DDR3_EN

#define DDR3_EN   (1 << 5)

Definition at line 394 of file sdram.c.

◆ DDRMD_CFG

#define DDRMD_CFG (   n)    ((n) << 0)

Definition at line 339 of file sdram.c.

◆ DDRMD_DDR

#define DDRMD_DDR   1

Definition at line 334 of file sdram.c.

◆ DDRMD_DDR2

#define DDRMD_DDR2   2

Definition at line 335 of file sdram.c.

◆ DDRMD_DDR3

#define DDRMD_DDR3   3

Definition at line 336 of file sdram.c.

◆ DDRMD_LPDDR

#define DDRMD_LPDDR   0

Definition at line 333 of file sdram.c.

◆ DDRMD_LPDDR2_LPDDR3

#define DDRMD_LPDDR2_LPDDR3   4

Definition at line 337 of file sdram.c.

◆ DDRMD_MSK

#define DDRMD_MSK   (7 << 0)

Definition at line 338 of file sdram.c.

◆ DESELECT_CMD

#define DESELECT_CMD   (0)

Definition at line 416 of file sdram.c.

◆ DFI_DRAM_CLK_DPD_EN

#define DFI_DRAM_CLK_DPD_EN   (1 << 1)

Definition at line 235 of file sdram.c.

◆ DFI_DRAM_CLK_SR_EN

#define DFI_DRAM_CLK_SR_EN   (1 << 0)

Definition at line 234 of file sdram.c.

◆ DFI_INIT_START

#define DFI_INIT_START   (1 << 0)

Definition at line 231 of file sdram.c.

◆ DFI_PARITY_EN

#define DFI_PARITY_EN   (1 << 1)

Definition at line 239 of file sdram.c.

◆ DFI_PARITY_INTR_EN

#define DFI_PARITY_INTR_EN   (1 << 0)

Definition at line 238 of file sdram.c.

◆ DLLGCR_SBIAS

#define DLLGCR_SBIAS   (1 << 30)

Definition at line 277 of file sdram.c.

◆ DPDE_CMD

#define DPDE_CMD   (9)

Definition at line 424 of file sdram.c.

◆ DQRTT

#define DQRTT   (1 << 10)

Definition at line 281 of file sdram.c.

◆ DQSGE_CFG

#define DQSGE_CFG (   n)    ((n) << 8)

Definition at line 357 of file sdram.c.

◆ DQSGE_MSK

#define DQSGE_MSK   (0x07 << 8)

Definition at line 356 of file sdram.c.

◆ DQSGX_CFG

#define DQSGX_CFG (   n)    ((n) << 5)

Definition at line 355 of file sdram.c.

◆ DQSGX_MSK

#define DQSGX_MSK   (0x07 << 5)

Definition at line 354 of file sdram.c.

◆ DQSNRES_CFG

#define DQSNRES_CFG (   n)    ((n) << 8)

Definition at line 345 of file sdram.c.

◆ DQSNRES_MSK

#define DQSNRES_MSK   (0x0f << 8)

Definition at line 344 of file sdram.c.

◆ DQSRES_CFG

#define DQSRES_CFG (   n)    ((n) << 4)

Definition at line 347 of file sdram.c.

◆ DQSRES_MSK

#define DQSRES_MSK   (0x0f << 4)

Definition at line 346 of file sdram.c.

◆ DQSRTT

#define DQSRTT   (1 << 9)

Definition at line 280 of file sdram.c.

◆ DXDLLCR_DLLDIS

#define DXDLLCR_DLLDIS   (1 << 31)

Definition at line 273 of file sdram.c.

◆ DXDLLCR_DLLSRST

#define DXDLLCR_DLLSRST   (1 << 30)

Definition at line 274 of file sdram.c.

◆ GO_STATE

#define GO_STATE   (2)

Definition at line 362 of file sdram.c.

◆ INIT_MEM

#define INIT_MEM   (0)

Definition at line 369 of file sdram.c.

◆ INIT_STATE

#define INIT_STATE   (0)

Definition at line 360 of file sdram.c.

◆ LOW_POWER

#define LOW_POWER   (5)

Definition at line 374 of file sdram.c.

◆ LOW_POWER_ENTRY_REQ

#define LOW_POWER_ENTRY_REQ   (6)

Definition at line 375 of file sdram.c.

◆ LOW_POWER_EXIT_REQ

#define LOW_POWER_EXIT_REQ   (7)

Definition at line 376 of file sdram.c.

◆ LP_PD_EN

#define LP_PD_EN   (1 << 0)

Definition at line 244 of file sdram.c.

◆ LP_SR_EN

#define LP_SR_EN   (1 << 8)

Definition at line 243 of file sdram.c.

◆ LP_TRIG_VAL

#define LP_TRIG_VAL (   n)    (((n) >> 4) & 7)

Definition at line 367 of file sdram.c.

◆ LPDDR2_EN

#define LPDDR2_EN   (3 << 22)

Definition at line 392 of file sdram.c.

◆ LPDDR2_MA

#define LPDDR2_MA (   n)    (((n) & 0xff) << 4)

Definition at line 426 of file sdram.c.

◆ LPDDR2_OP

#define LPDDR2_OP (   n)    (((n) & 0xff) << 12)

Definition at line 427 of file sdram.c.

◆ LPDDR2_S2

#define LPDDR2_S2   (0 << 6)

Definition at line 395 of file sdram.c.

◆ LPDDR2_S4

#define LPDDR2_S4   (1 << 6)

Definition at line 396 of file sdram.c.

◆ MDDR_EN

#define MDDR_EN   (2 << 22)

Definition at line 391 of file sdram.c.

◆ MDDR_LPDDR2_BL_16

#define MDDR_LPDDR2_BL_16   (3 << 20)

Definition at line 400 of file sdram.c.

◆ MDDR_LPDDR2_BL_2

#define MDDR_LPDDR2_BL_2   (0 << 20)

Definition at line 397 of file sdram.c.

◆ MDDR_LPDDR2_BL_4

#define MDDR_LPDDR2_BL_4   (1 << 20)

Definition at line 398 of file sdram.c.

◆ MDDR_LPDDR2_BL_8

#define MDDR_LPDDR2_BL_8   (2 << 20)

Definition at line 399 of file sdram.c.

◆ MDDR_LPDDR2_CLK_STOP_IDLE

#define MDDR_LPDDR2_CLK_STOP_IDLE (   n)    ((n) << 24)

Definition at line 389 of file sdram.c.

◆ MRR_CMD

#define MRR_CMD   (8)

Definition at line 423 of file sdram.c.

◆ MRS_CMD

#define MRS_CMD   (3)

Definition at line 419 of file sdram.c.

◆ MSCH_MAINDDR3

#define MSCH_MAINDDR3 (   ch,
 
)
Value:
(((n) << (3 + (ch))) \
| ((1 << (3 + (ch))) << 16))
static struct dramc_channel const ch[2]

Definition at line 437 of file sdram.c.

◆ ODT_LEN_BL8_W

#define ODT_LEN_BL8_W (   n)    (n<<16)

Definition at line 266 of file sdram.c.

◆ PCTL_BST_DISABLE

#define PCTL_BST_DISABLE (   ch,
 
)
Value:
RK_CLRSETBITS(1 << (9 + (3 * (ch))), \
(n) << (9 + (3 * (ch))))
#define RK_CLRSETBITS(clr, set)
Definition: soc.h:8

Definition at line 443 of file sdram.c.

◆ PCTL_LPDDR3_ODT_EN

#define PCTL_LPDDR3_ODT_EN (   ch,
 
)
Value:
RK_CLRSETBITS(1 << (10 + (3 * (ch))), \
(n) << (10 + (3 * (ch))))

Definition at line 441 of file sdram.c.

◆ PCTL_STAT_MSK

#define PCTL_STAT_MSK   (7)

Definition at line 368 of file sdram.c.

◆ PD_EXIT_FAST

#define PD_EXIT_FAST   (1 << 17)

Definition at line 405 of file sdram.c.

◆ PD_EXIT_SLOW

#define PD_EXIT_SLOW   (0 << 17)

Definition at line 404 of file sdram.c.

◆ PD_IDLE

#define PD_IDLE (   n)    ((n) << 8)

Definition at line 390 of file sdram.c.

◆ PD_ONDIE

#define PD_ONDIE (   n)    ((n) << 10)

Definition at line 381 of file sdram.c.

◆ PD_OUTPUT

#define PD_OUTPUT (   n)    ((n) << 0)

Definition at line 379 of file sdram.c.

◆ PD_TYPE

#define PD_TYPE (   n)    ((n) << 16)

Definition at line 406 of file sdram.c.

◆ PDQ_CFG

#define PDQ_CFG (   n)    ((n) << 4)

Definition at line 341 of file sdram.c.

◆ PDQ_MSK

#define PDQ_MSK   (7 << 4)

Definition at line 340 of file sdram.c.

◆ PGCR_DFTCMP

#define PGCR_DFTCMP (   n)    ((n) << 2)

Definition at line 303 of file sdram.c.

◆ PGCR_DFTLMT

#define PGCR_DFTLMT (   n)    ((n) << 3)

Definition at line 302 of file sdram.c.

◆ PGCR_DQSCFG

#define PGCR_DQSCFG (   n)    ((n) << 1)

Definition at line 304 of file sdram.c.

◆ PGCR_ITMDMD

#define PGCR_ITMDMD (   n)    ((n) << 0)

Definition at line 305 of file sdram.c.

◆ PGSR_DFTERR

#define PGSR_DFTERR   (1 << 7)

Definition at line 315 of file sdram.c.

◆ PGSR_DIDONE

#define PGSR_DIDONE   (1 << 3)

Definition at line 311 of file sdram.c.

◆ PGSR_DLDONE

#define PGSR_DLDONE   (1 << 1)

Definition at line 309 of file sdram.c.

◆ PGSR_DTDONE

#define PGSR_DTDONE   (1 << 4)

Definition at line 312 of file sdram.c.

◆ PGSR_DTERR

#define PGSR_DTERR   (1 << 5)

Definition at line 313 of file sdram.c.

◆ PGSR_DTIERR

#define PGSR_DTIERR   (1 << 6)

Definition at line 314 of file sdram.c.

◆ PGSR_IDONE

#define PGSR_IDONE   (1 << 0)

Definition at line 308 of file sdram.c.

◆ PGSR_RVEIRR

#define PGSR_RVEIRR   (1 << 9)

Definition at line 317 of file sdram.c.

◆ PGSR_RVERR

#define PGSR_RVERR   (1 << 8)

Definition at line 316 of file sdram.c.

◆ PGSR_ZCDONE

#define PGSR_ZCDONE   (1 << 2)

Definition at line 310 of file sdram.c.

◆ PIR_CLRSR

#define PIR_CLRSR   (1 << 28)

Definition at line 296 of file sdram.c.

◆ PIR_CTLDINIT

#define PIR_CTLDINIT   (1 << 18)

Definition at line 295 of file sdram.c.

◆ PIR_DLLBYP

#define PIR_DLLBYP   (1 << 17)

Definition at line 294 of file sdram.c.

◆ PIR_DLLLOCK

#define PIR_DLLLOCK   (1 << 2)

Definition at line 286 of file sdram.c.

◆ PIR_DLLSRST

#define PIR_DLLSRST   (1 << 1)

Definition at line 285 of file sdram.c.

◆ PIR_DRAMINIT

#define PIR_DRAMINIT   (1 << 6)

Definition at line 290 of file sdram.c.

◆ PIR_DRAMRST

#define PIR_DRAMRST   (1 << 5)

Definition at line 289 of file sdram.c.

◆ PIR_ICPC

#define PIR_ICPC   (1 << 16)

Definition at line 293 of file sdram.c.

◆ PIR_INIT

#define PIR_INIT   (1 << 0)

Definition at line 284 of file sdram.c.

◆ PIR_INITBYP

#define PIR_INITBYP   (1u << 31)

Definition at line 299 of file sdram.c.

◆ PIR_ITMSRST

#define PIR_ITMSRST   (1 << 4)

Definition at line 288 of file sdram.c.

◆ PIR_LOCKBYP

#define PIR_LOCKBYP   (1 << 29)

Definition at line 297 of file sdram.c.

◆ PIR_QSTRN

#define PIR_QSTRN   (1 << 7)

Definition at line 291 of file sdram.c.

◆ PIR_RVTRN

#define PIR_RVTRN   (1 << 8)

Definition at line 292 of file sdram.c.

◆ PIR_ZCAL

#define PIR_ZCAL   (1 << 3)

Definition at line 287 of file sdram.c.

◆ PIR_ZCALBYP

#define PIR_ZCALBYP   (1 << 30)

Definition at line 298 of file sdram.c.

◆ POWER_UP_DONE

#define POWER_UP_DONE   (1 << 0)

Definition at line 413 of file sdram.c.

◆ POWER_UP_START

#define POWER_UP_START   (1 << 0)

Definition at line 410 of file sdram.c.

◆ PREA_CMD

#define PREA_CMD   (1)

Definition at line 417 of file sdram.c.

◆ PRT_DINIT0

#define PRT_DINIT0 (   n)    ((n) << 0)

Definition at line 325 of file sdram.c.

◆ PRT_DINIT1

#define PRT_DINIT1 (   n)    ((n) << 19)

Definition at line 326 of file sdram.c.

◆ PRT_DINIT2

#define PRT_DINIT2 (   n)    ((n) << 0)

Definition at line 329 of file sdram.c.

◆ PRT_DINIT3

#define PRT_DINIT3 (   n)    ((n) << 17)

Definition at line 330 of file sdram.c.

◆ PRT_DLLLOCK

#define PRT_DLLLOCK (   n)    ((n) << 6)

Definition at line 321 of file sdram.c.

◆ PRT_DLLSRST

#define PRT_DLLSRST (   n)    ((n) << 0)

Definition at line 322 of file sdram.c.

◆ PRT_ITMSRST

#define PRT_ITMSRST (   n)    ((n) << 18)

Definition at line 320 of file sdram.c.

◆ PU_ONDIE

#define PU_ONDIE (   n)    ((n) << 15)

Definition at line 382 of file sdram.c.

◆ PU_OUTPUT

#define PU_OUTPUT (   n)    ((n) << 5)

Definition at line 380 of file sdram.c.

◆ PUBL_LPDDR3_EN

#define PUBL_LPDDR3_EN (   ch,
 
)
Value:
RK_CLRSETBITS(1 << (8 + (3 * (ch))), \
(n) << (8 + (3 * (ch))))

Definition at line 445 of file sdram.c.

◆ RANK0_ODT_WRITE_SEL

#define RANK0_ODT_WRITE_SEL   (1 << 3)

Definition at line 262 of file sdram.c.

◆ RANK1_ODT_WRITE_SEL

#define RANK1_ODT_WRITE_SEL   (1 << 11)

Definition at line 263 of file sdram.c.

◆ REF_CMD

#define REF_CMD   (2)

Definition at line 418 of file sdram.c.

◆ RSTL_CMD

#define RSTL_CMD   (6)

Definition at line 422 of file sdram.c.

◆ SBIAS_BYPASS

#define SBIAS_BYPASS   (1 << 23)

Definition at line 386 of file sdram.c.

◆ SLEEP_STATE

#define SLEEP_STATE   (3)

Definition at line 363 of file sdram.c.

◆ START_CMD

#define START_CMD   (1u << 31)

Definition at line 429 of file sdram.c.

◆ SYS_REG_DEC_BK

#define SYS_REG_DEC_BK (   n,
  ch 
)    (3 - ((n >> (8 + 16 * ch)) & 0x1))

Definition at line 486 of file sdram.c.

◆ SYS_REG_DEC_BW

#define SYS_REG_DEC_BW (   n,
  ch 
)    (2 >> ((n >> (2 + 16 * ch)) & 0x3))

Definition at line 492 of file sdram.c.

◆ SYS_REG_DEC_COL

#define SYS_REG_DEC_COL (   n,
  ch 
)    (9 + ((n >> (9 + 16 * ch)) & 0x3))

Definition at line 483 of file sdram.c.

◆ SYS_REG_DEC_CS0_ROW

#define SYS_REG_DEC_CS0_ROW (   n,
  ch 
)    (13 + ((n >> (6 + 16 * ch)) & 0x3))

Definition at line 488 of file sdram.c.

◆ SYS_REG_DEC_CS1_ROW

#define SYS_REG_DEC_CS1_ROW (   n,
  ch 
)    (13 + ((n >> (4 + 16 * ch)) & 0x3))

Definition at line 490 of file sdram.c.

◆ SYS_REG_DEC_DBW

#define SYS_REG_DEC_DBW (   n,
  ch 
)    (2 >> ((n >> (0 + 16 * ch)) & 0x3))

Definition at line 494 of file sdram.c.

◆ SYS_REG_DEC_NUM_CH

#define SYS_REG_DEC_NUM_CH (   n)    (1 + ((n >> 12) & 0x1))

Definition at line 479 of file sdram.c.

◆ SYS_REG_DEC_RANK

#define SYS_REG_DEC_RANK (   n,
  ch 
)    (1 + ((n >> (11 + 16 * ch)) & 0x1))

Definition at line 481 of file sdram.c.

◆ SYS_REG_DEC_ROW_3_4

#define SYS_REG_DEC_ROW_3_4 (   n,
  ch 
)    ((n >> (30 + ch)) & 0x1)

Definition at line 475 of file sdram.c.

◆ SYS_REG_ENC_BK

#define SYS_REG_ENC_BK (   n,
  ch 
)
Value:
(((n) == 3 ? 0 : 1) \
<< (8 + ((ch) * 16)))

Definition at line 484 of file sdram.c.

◆ SYS_REG_ENC_BW

#define SYS_REG_ENC_BW (   n,
  ch 
)    ((2 >> (n)) << (2 + ((ch) * 16)))

Definition at line 491 of file sdram.c.

◆ SYS_REG_ENC_CHINFO

#define SYS_REG_ENC_CHINFO (   ch)    (1 << (28 + (ch)))

Definition at line 476 of file sdram.c.

◆ SYS_REG_ENC_COL

#define SYS_REG_ENC_COL (   n,
  ch 
)    (((n) - 9) << (9 + ((ch) * 16)))

Definition at line 482 of file sdram.c.

◆ SYS_REG_ENC_CS0_ROW

#define SYS_REG_ENC_CS0_ROW (   n,
  ch 
)    (((n) - 13) << (6 + ((ch) * 16)))

Definition at line 487 of file sdram.c.

◆ SYS_REG_ENC_CS1_ROW

#define SYS_REG_ENC_CS1_ROW (   n,
  ch 
)    (((n) - 13) << (4 + ((ch) * 16)))

Definition at line 489 of file sdram.c.

◆ SYS_REG_ENC_DBW

#define SYS_REG_ENC_DBW (   n,
  ch 
)    ((2 >> (n)) << (0 + ((ch) * 16)))

Definition at line 493 of file sdram.c.

◆ SYS_REG_ENC_DDRTYPE

#define SYS_REG_ENC_DDRTYPE (   n)    ((n) << 13)

Definition at line 477 of file sdram.c.

◆ SYS_REG_ENC_NUM_CH

#define SYS_REG_ENC_NUM_CH (   n)    (((n) - 1) << 12)

Definition at line 478 of file sdram.c.

◆ SYS_REG_ENC_RANK

#define SYS_REG_ENC_RANK (   n,
  ch 
)    (((n) - 1) << (11 + ((ch) * 16)))

Definition at line 480 of file sdram.c.

◆ SYS_REG_ENC_ROW_3_4

#define SYS_REG_ENC_ROW_3_4 (   n,
  ch 
)    ((n) << (30 + (ch)))

Definition at line 474 of file sdram.c.

◆ TCTRL_DELAY_TIME

#define TCTRL_DELAY_TIME (   n)    (n << 0)

Definition at line 247 of file sdram.c.

◆ TDQSCK_VAL

#define TDQSCK_VAL (   n)    (((n) >> 24) & 7)

Definition at line 351 of file sdram.c.

◆ TDQSCKMAX_VAL

#define TDQSCKMAX_VAL (   n)    (((n) >> 27) & 7)

Definition at line 350 of file sdram.c.

◆ TDRAM_CLK_DIS_TIME

#define TDRAM_CLK_DIS_TIME (   n)    (n << 0)

Definition at line 256 of file sdram.c.

◆ TDRAM_CLK_EN_TIME

#define TDRAM_CLK_EN_TIME (   n)    (n << 0)

Definition at line 259 of file sdram.c.

◆ TFAW_CFG

#define TFAW_CFG (   n)    (((n)-4) << 18)

Definition at line 403 of file sdram.c.

◆ TLP_RESP_TIME

#define TLP_RESP_TIME (   n)    (n << 16)

Definition at line 242 of file sdram.c.

◆ TPHY_RDLAT_TIME

#define TPHY_RDLAT_TIME (   n)    (n << 0)

Definition at line 253 of file sdram.c.

◆ TPHY_WRDATA_TIME

#define TPHY_WRDATA_TIME (   n)    (n << 0)

Definition at line 250 of file sdram.c.

◆ WAKEUP_STATE

#define WAKEUP_STATE   (4)

Definition at line 364 of file sdram.c.

◆ ZDEN

#define ZDEN (   n)    ((n) << 28)

Definition at line 383 of file sdram.c.

◆ ZQCL_CMD

#define ZQCL_CMD   (5)

Definition at line 421 of file sdram.c.

◆ ZQCS_CMD

#define ZQCS_CMD   (4)

Definition at line 420 of file sdram.c.

Function Documentation

◆ check_member() [1/3]

check_member ( rk3288_ddr_pctl_regs  ,
iptr  ,
0x03fc   
)

◆ check_member() [2/3]

check_member ( rk3288_ddr_publ_regs  ,
datx8.  dxdqstr[3],
0x0294   
)

◆ check_member() [3/3]

check_member ( rk3288_msch_regs  ,
devtodev  ,
0x003c   
)

◆ copy_to_reg()

static void copy_to_reg ( u32 dest,
const u32 src,
u32  n 
)
static

Definition at line 496 of file sdram.c.

References write32().

Referenced by pctl_cfg(), and phy_cfg().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ data_training()

◆ dfi_cfg()

◆ dram_all_config()

static void dram_all_config ( const struct rk3288_sdram_params sdram_params)
static

◆ dram_cfg_rbc()

static void dram_cfg_rbc ( u32  chnum,
const struct rk3288_sdram_params sdram_params 
)
static

Definition at line 912 of file sdram.c.

References clrbits32, clrsetbits32, rk3288_ddr_publ_regs::dcr, rk3288_msch_regs::ddrconf, PDQ_CFG, PDQ_MSK, rk3288_ddr_publ, rk3288_msch, and write32().

Referenced by dram_all_config().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ memory_init()

static void memory_init ( struct rk3288_ddr_publ_regs ddr_publ_regs,
u32  dramtype 
)
static

Definition at line 710 of file sdram.c.

References DDR3, rk3288_ddr_publ_regs::pgsr, PGSR_DLDONE, PGSR_IDONE, rk3288_ddr_publ_regs::pir, PIR_CLRSR, PIR_DRAMINIT, PIR_DRAMRST, PIR_ICPC, PIR_INIT, PIR_LOCKBYP, PIR_ZCALBYP, read32(), setbits32, and udelay().

Referenced by fsp_debug_before_memory_init(), and sdram_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ move_to_access_state()

static void move_to_access_state ( u32  chnum)
static

Definition at line 867 of file sdram.c.

References __fallthrough, ACCESS, CFG_STATE, CONF, GO_STATE, INIT_MEM, LOW_POWER, LP_TRIG_VAL, PCTL_STAT_MSK, rk3288_ddr_publ_regs::pgsr, PGSR_DLDONE, read32(), rk3288_ddr_pctl, rk3288_ddr_publ, rk3288_ddr_pctl_regs::sctl, rk3288_ddr_pctl_regs::stat, WAKEUP_STATE, and write32().

Referenced by sdram_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ move_to_config_state()

static void move_to_config_state ( struct rk3288_ddr_publ_regs ddr_publ_regs,
struct rk3288_ddr_pctl_regs ddr_pctl_regs 
)
static

Definition at line 723 of file sdram.c.

References __fallthrough, ACCESS, CFG_STATE, CONF, INIT_MEM, LOW_POWER, PCTL_STAT_MSK, rk3288_ddr_publ_regs::pgsr, PGSR_DLDONE, read32(), rk3288_ddr_pctl_regs::sctl, rk3288_ddr_pctl_regs::stat, WAKEUP_STATE, and write32().

Referenced by sdram_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pctl_cfg()

◆ phy_cfg()

◆ phy_dll_bypass_set()

static void phy_dll_bypass_set ( struct rk3288_ddr_publ_regs ddr_publ_regs,
u32  freq 
)
static

◆ phy_init()

static void phy_init ( struct rk3288_ddr_publ_regs ddr_publ_regs)
static

Definition at line 690 of file sdram.c.

References rk3288_ddr_publ_regs::pgsr, PGSR_DLDONE, PGSR_IDONE, PGSR_ZCDONE, rk3288_ddr_publ_regs::pir, PIR_CLRSR, PIR_DLLLOCK, PIR_DLLSRST, PIR_INIT, PIR_ITMSRST, PIR_ZCAL, read32(), setbits32, and udelay().

Referenced by sdram_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ phy_pctrl_reset()

static void phy_pctrl_reset ( struct rk3288_ddr_publ_regs ddr_publ_regs,
u32  channel 
)
static

Definition at line 506 of file sdram.c.

References rk3288_ddr_publ_regs::acdllcr, ACDLLCR_DLLSRST, clrbits32, rk3288_ddr_publ_regs::datx8, rk3288_ddr_publ_datx::dxdllcr, DXDLLCR_DLLSRST, rkclk_ddr_reset(), setbits32, and udelay().

Referenced by sdram_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sdram_init()

◆ sdram_size_mb()

size_t sdram_size_mb ( void  )

◆ send_command()

static void send_command ( struct rk3288_ddr_pctl_regs ddr_pctl_regs,
u32  rank,
u32  cmd,
u32  arg 
)
static

Definition at line 701 of file sdram.c.

References arg, rk3288_ddr_pctl_regs::mcmd, read32(), START_CMD, udelay(), and write32().

Referenced by data_training(), and sdram_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_bandwidth_ratio()

static void set_bandwidth_ratio ( u32  channel,
u32  n 
)
static

Variable Documentation

◆ rk3288_ddr_pctl

struct rk3288_ddr_pctl_regs* const rk3288_ddr_pctl[2]
static
Initial value:
= {
(void *)DDR_PCTL0_BASE, (void *)DDR_PCTL1_BASE}
#define DDR_PCTL0_BASE
Definition: addressmap.h:36
#define DDR_PCTL1_BASE
Definition: addressmap.h:37

Definition at line 223 of file sdram.c.

Referenced by data_training(), move_to_access_state(), pctl_cfg(), sdram_init(), and set_bandwidth_ratio().

◆ rk3288_ddr_publ

struct rk3288_ddr_publ_regs* const rk3288_ddr_publ[2]
static
Initial value:
= {
(void *)DDR_PUBL0_BASE, (void *)DDR_PUBL1_BASE}
#define DDR_PUBL1_BASE
Definition: addressmap.h:39
#define DDR_PUBL0_BASE
Definition: addressmap.h:38

Definition at line 225 of file sdram.c.

Referenced by data_training(), dram_cfg_rbc(), move_to_access_state(), phy_cfg(), sdram_init(), and set_bandwidth_ratio().

◆ rk3288_msch

struct rk3288_msch_regs* const rk3288_msch[2]
static
Initial value:
= {
(void *)SERVICE_BUS_BASE, (void *)SERVICE_BUS_BASE + 0x80}
#define SERVICE_BUS_BASE
Definition: addressmap.h:78

Definition at line 227 of file sdram.c.

Referenced by dram_cfg_rbc(), phy_cfg(), and set_bandwidth_ratio().