blob: 461f091472193d85954f5a34b15f1cc63e4c82b5 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001/* SPDX-License-Identifier: GPL-2.0 */
Stefan Roese5ffceb82015-03-26 15:36:56 +01002/*
3 * Copyright (C) Marvell International Ltd. and its affiliates
Stefan Roese5ffceb82015-03-26 15:36:56 +01004 */
5
6#ifndef _DDR_TOPOLOGY_DEF_H
7#define _DDR_TOPOLOGY_DEF_H
8
9#include "ddr3_training_ip_def.h"
Chris Packham1a07d212018-05-10 13:28:29 +120010#include "mv_ddr_topology.h"
11#include "mv_ddr_spd.h"
12#include "ddr3_logging_def.h"
Marek Behúnf8bf75f2017-06-09 19:28:40 +020013
Chris Packham4bf81db2018-12-03 14:26:49 +130014#define MV_DDR_MAX_BUS_NUM 9
15#define MV_DDR_MAX_IFACE_NUM 1
16
Moti Buskila498475e2021-02-19 17:11:19 +010017enum mv_ddr_twin_die {
18 COMBINED,
19 NOT_COMBINED,
20};
21
Stefan Roese5ffceb82015-03-26 15:36:56 +010022struct bus_params {
23 /* Chip Select (CS) bitmask (bits 0-CS0, bit 1- CS1 ...) */
24 u8 cs_bitmask;
25
26 /*
27 * mirror enable/disable
28 * (bits 0-CS0 mirroring, bit 1- CS1 mirroring ...)
29 */
30 int mirror_enable_bitmask;
31
32 /* DQS Swap (polarity) - true if enable */
33 int is_dqs_swap;
34
35 /* CK swap (polarity) - true if enable */
36 int is_ck_swap;
37};
38
39struct if_params {
40 /* bus configuration */
Chris Packham4bf81db2018-12-03 14:26:49 +130041 struct bus_params as_bus_params[MV_DDR_MAX_BUS_NUM];
Stefan Roese5ffceb82015-03-26 15:36:56 +010042
43 /* Speed Bin Table */
Chris Packham4bf81db2018-12-03 14:26:49 +130044 enum mv_ddr_speed_bin speed_bin_index;
Stefan Roese5ffceb82015-03-26 15:36:56 +010045
Chris Packham1a07d212018-05-10 13:28:29 +120046 /* sdram device width */
47 enum mv_ddr_dev_width bus_width;
Stefan Roese5ffceb82015-03-26 15:36:56 +010048
Chris Packham1a07d212018-05-10 13:28:29 +120049 /* total sdram capacity per die, megabits */
50 enum mv_ddr_die_capacity memory_size;
Stefan Roese5ffceb82015-03-26 15:36:56 +010051
52 /* The DDR frequency for each interfaces */
Chris Packham4bf81db2018-12-03 14:26:49 +130053 enum mv_ddr_freq memory_freq;
Stefan Roese5ffceb82015-03-26 15:36:56 +010054
Moti Buskila498475e2021-02-19 17:11:19 +010055 /* ddr twin-die */
56 enum mv_ddr_twin_die twin_die_combined;
57
Stefan Roese5ffceb82015-03-26 15:36:56 +010058 /*
59 * delay CAS Write Latency
60 * - 0 for using default value (jedec suggested)
61 */
62 u8 cas_wl;
63
64 /*
65 * delay CAS Latency
66 * - 0 for using default value (jedec suggested)
67 */
68 u8 cas_l;
69
70 /* operation temperature */
Chris Packham1a07d212018-05-10 13:28:29 +120071 enum mv_ddr_temperature interface_temp;
Chris Packham3a09e132018-05-10 13:28:30 +120072
73 /* 2T vs 1T mode (by default computed from number of CSs) */
74 enum mv_ddr_timing timing;
Stefan Roese5ffceb82015-03-26 15:36:56 +010075};
76
Chris Packham4bf81db2018-12-03 14:26:49 +130077/* memory electrical configuration */
78struct mv_ddr_mem_edata {
79 enum mv_ddr_rtt_nom_park_evalue rtt_nom;
80 enum mv_ddr_rtt_nom_park_evalue rtt_park[MAX_CS_NUM];
81 enum mv_ddr_rtt_wr_evalue rtt_wr[MAX_CS_NUM];
82 enum mv_ddr_dic_evalue dic;
83};
84
85/* phy electrical configuration */
86struct mv_ddr_phy_edata {
87 enum mv_ddr_ohm_evalue drv_data_p;
88 enum mv_ddr_ohm_evalue drv_data_n;
89 enum mv_ddr_ohm_evalue drv_ctrl_p;
90 enum mv_ddr_ohm_evalue drv_ctrl_n;
91 enum mv_ddr_ohm_evalue odt_p[MAX_CS_NUM];
92 enum mv_ddr_ohm_evalue odt_n[MAX_CS_NUM];
93};
94
95/* mac electrical configuration */
96struct mv_ddr_mac_edata {
97 enum mv_ddr_odt_cfg_evalue odt_cfg_pat;
98 enum mv_ddr_odt_cfg_evalue odt_cfg_wr;
99 enum mv_ddr_odt_cfg_evalue odt_cfg_rd;
100};
101
102struct mv_ddr_edata {
103 struct mv_ddr_mem_edata mem_edata;
104 struct mv_ddr_phy_edata phy_edata;
105 struct mv_ddr_mac_edata mac_edata;
106};
107
Chris Packham1a07d212018-05-10 13:28:29 +1200108struct mv_ddr_topology_map {
109 /* debug level configuration */
110 enum mv_ddr_debug_level debug_level;
111
Stefan Roese5ffceb82015-03-26 15:36:56 +0100112 /* Number of interfaces (default is 12) */
113 u8 if_act_mask;
114
115 /* Controller configuration per interface */
Chris Packham4bf81db2018-12-03 14:26:49 +1300116 struct if_params interface_params[MV_DDR_MAX_IFACE_NUM];
Stefan Roese5ffceb82015-03-26 15:36:56 +0100117
Stefan Roese5ffceb82015-03-26 15:36:56 +0100118 /* Bit mask for active buses */
Chris Packham1a07d212018-05-10 13:28:29 +1200119 u16 bus_act_mask;
120
121 /* source of ddr configuration data */
122 enum mv_ddr_cfg_src cfg_src;
123
Moti Buskila498475e2021-02-19 17:11:19 +0100124 /* ddr twin-die */
125 enum mv_ddr_twin_die twin_die_combined;
126
Chris Packham1a07d212018-05-10 13:28:29 +1200127 /* raw spd data */
128 union mv_ddr_spd_data spd_data;
129
130 /* timing parameters */
131 unsigned int timing_data[MV_DDR_TDATA_LAST];
Chris Packham4bf81db2018-12-03 14:26:49 +1300132
133 /* electrical configuration */
134 struct mv_ddr_edata edata;
135
136 /* electrical parameters */
137 unsigned int electrical_data[MV_DDR_EDATA_LAST];
Baruch Siach24a1d132020-01-20 14:20:06 +0200138
Baruch Siach4951d422021-02-19 17:11:17 +0100139 /* ODT configuration */
140 u32 odt_config;
141
Baruch Siach24a1d132020-01-20 14:20:06 +0200142 /* Clock enable mask */
143 u32 clk_enable;
Chris Packhame422adc2020-01-30 12:50:44 +1300144
145 /* Clock delay */
146 int ck_delay;
Chris Packham4bf81db2018-12-03 14:26:49 +1300147};
148
149enum mv_ddr_iface_mode {
150 MV_DDR_RAR_ENA,
151 MV_DDR_RAR_DIS,
Stefan Roese5ffceb82015-03-26 15:36:56 +0100152};
153
Chris Packham4bf81db2018-12-03 14:26:49 +1300154enum mv_ddr_iface_state {
155 MV_DDR_IFACE_NRDY, /* not ready */
156 MV_DDR_IFACE_INIT, /* init'd */
157 MV_DDR_IFACE_RDY, /* ready */
158 MV_DDR_IFACE_DNE /* does not exist */
159};
160
161enum mv_ddr_validation {
162 MV_DDR_VAL_DIS,
163 MV_DDR_VAL_RX,
164 MV_DDR_VAL_TX,
Marek Behúncd4d2cf2021-02-19 17:11:10 +0100165 MV_DDR_VAL_RX_TX,
166 MV_DDR_MEMORY_CHECK
Chris Packham4bf81db2018-12-03 14:26:49 +1300167};
168
Marek Behúnf4e62702021-02-19 17:11:16 +0100169enum mv_ddr_sscg {
170 SSCG_EN,
171 SSCG_DIS,
172};
173
Chris Packham4bf81db2018-12-03 14:26:49 +1300174struct mv_ddr_iface {
175 /* base addr of ap ddr interface belongs to */
176 unsigned int ap_base;
177
178 /* ddr interface id */
179 unsigned int id;
180
181 /* ddr interface state */
182 enum mv_ddr_iface_state state;
183
184 /* ddr interface mode (rar enabled/disabled) */
185 enum mv_ddr_iface_mode iface_mode;
186
187 /* ddr interface base address */
188 unsigned long long iface_base_addr;
189
190 /* ddr interface size - ddr flow will update this parameter */
191 unsigned long long iface_byte_size;
192
193 /* ddr i2c spd data address */
194 unsigned int spd_data_addr;
195
196 /* ddr i2c spd page 0 select address */
197 unsigned int spd_page_sel_addr;
198
199 /* ddr interface validation mode */
200 enum mv_ddr_validation validation;
201
Marek Behúnf4e62702021-02-19 17:11:16 +0100202 /* ddr interface validation mode */
203 enum mv_ddr_sscg sscg;
204
Chris Packham4bf81db2018-12-03 14:26:49 +1300205 /* ddr interface topology map */
206 struct mv_ddr_topology_map tm;
Moti Buskila498475e2021-02-19 17:11:19 +0100207
Chris Packham4bf81db2018-12-03 14:26:49 +1300208};
209
210struct mv_ddr_iface *mv_ddr_iface_get(void);
211
Stefan Roese5ffceb82015-03-26 15:36:56 +0100212/* DDR3 training global configuration parameters */
213struct tune_train_params {
214 u32 ck_delay;
Stefan Roese5ffceb82015-03-26 15:36:56 +0100215 u32 phy_reg3_val;
Chris Packham1a07d212018-05-10 13:28:29 +1200216 u32 g_zpri_data;
217 u32 g_znri_data;
218 u32 g_zpri_ctrl;
219 u32 g_znri_ctrl;
220 u32 g_zpodt_data;
221 u32 g_znodt_data;
222 u32 g_zpodt_ctrl;
223 u32 g_znodt_ctrl;
224 u32 g_dic;
225 u32 g_odt_config;
226 u32 g_rtt_nom;
227 u32 g_rtt_wr;
228 u32 g_rtt_park;
Stefan Roese5ffceb82015-03-26 15:36:56 +0100229};
230
231#endif /* _DDR_TOPOLOGY_DEF_H */