summaryrefslogtreecommitdiff
path: root/soc/mediatek/mt8183/README.md
blob: 7233a0719fe8db0bd3fc78b4de2b26b85bbdf5dc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# Firmware list

- drame.elf

# `dram.elf` Introduction

`dram.elf` is one ELF format file which is used for calibration.
The `dram.elf` is loaded at the first bootup. It will do DRAM
full calibration, and save calibration parameters to NAND/NOR (or EMMC)
for faster bootup after the first bootup.

## Who uses it

coreboot loads `dram.elf` at the first time bootup if no DRAM parameters have
been cached.


## How to load `dram.elf`

coreboot locates `dram.elf` file, and locates the entry point `_start`,
then it passes DRAM struct `param`, and calls `_start(&param)` to execute
`dram.elf` flow.

## Parameters

```
struct dramc_param {
    struct dramc_param_header header; // see below
    void (*do_putc)(unsigned char c);
    struct sdram_params freq_params[DRAM_DFS_SHU_MAX];    // see below
};
```

Below shows the internal structure of `dramc_param`:

```
struct dramc_param_header {
    u16 status;     /* DRAMC_PARAM_STATUS_CODES, update in the dram blob */
    u32 magic;      /* DRAMC_PARAM_HEADER_MAGIC */
    u16 version;    /* DRAMC_PARAM_HEADER_VERSION, update in the coreboot */
    u16 size;       /* size of whole dramc_param, update in the coreboot */
I   u16 config;     /* DRAMC_PARAM_CONFIG, used for blob */
    u16 flags;      /* DRAMC_PARAM_FLAGS, update in the dram blob */
    u32 checksum;   /* checksum of dramc_datas, update in the coreboot */
};

struct sdram_params {
    u16 source;
    u16 frequency;       /* DRAM frequency */
    u8 rank_num;         /* DRAM rank number */
    u16 ddr_geometry;    /* DRAMC_PARAM_GEOMETRY_TYPE */
    u8 wr_level[CHANNEL_MAX][RANK_MAX][DQS_NUMBER_LP4];

    /* DUTY */
    s8 duty_clk_delay[CHANNEL_MAX];
    s8 duty_dqs_delay[CHANNEL_MAX][DQS_NUMBER_LP4];

    /* CBT */
    u8 cbt_final_vref[CHANNEL_MAX][RANK_MAX];
    u8 cbt_clk_dly[CHANNEL_MAX][RANK_MAX];
    u8 cbt_cmd_dly[CHANNEL_MAX][RANK_MAX];
    u8 cbt_cs_dly[CHANNEL_MAX][RANK_MAX];
    u8 cbt_ca_perbit_delay[CHANNEL_MAX][RANK_MAX][DQS_BIT_NUMBER];

    /* Gating */
    u8 gating2T[CHANNEL_MAX][RANK_MAX][DQS_NUMBER_LP4];
    u8 gating05T[CHANNEL_MAX][RANK_MAX][DQS_NUMBER_LP4];
    u8 gating_fine_tune[CHANNEL_MAX][RANK_MAX][DQS_NUMBER_LP4];
    u8 gating_pass_count[CHANNEL_MAX][RANK_MAX][DQS_NUMBER_LP4];

    /* TX perbit */
    u8 tx_vref[CHANNEL_MAX][RANK_MAX];
    u16 tx_center_min[CHANNEL_MAX][RANK_MAX][DQS_NUMBER_LP4];
    u16 tx_center_max[CHANNEL_MAX][RANK_MAX][DQS_NUMBER_LP4];
    u16 tx_win_center[CHANNEL_MAX][RANK_MAX][DQ_DATA_WIDTH_LP4];
    u16 tx_first_pass[CHANNEL_MAX][RANK_MAX][DQ_DATA_WIDTH_LP4];
    u16 tx_last_pass[CHANNEL_MAX][RANK_MAX][DQ_DATA_WIDTH_LP4];

    /* datlat */
    u8 rx_datlat[CHANNEL_MAX][RANK_MAX];

    /* RX perbit */
    u8 rx_vref[CHANNEL_MAX];
    s16 rx_firspass[CHANNEL_MAX][RANK_MAX][DQ_DATA_WIDTH_LP4];
    u8 rx_lastpass[CHANNEL_MAX][RANK_MAX][DQ_DATA_WIDTH_LP4];

    u32 emi_cona_val;
    u32 emi_conh_val;
    u32 emi_conf_val;
    u32 chn_emi_cona_val[CHANNEL_MAX];
    u32 cbt_mode_extern;
    u32 delay_cell_unit;
};
```

## Output of `dram.elf`

`dram.elf` will set suitable dramc settings, and save the DRAM parameters
to NAND/NOR (or EMMC) in the specified section: `RW_DDR_TRAINING`.

## Return Values

- 0   : means successful.
- < 0 : means failed.

## Version

```
$ strings dram.elf | grep "firmware version"
MediaTek DRAM firmware version: 1.5.0
```