1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Copyright (C) Marvell International Ltd. and its affiliates
6 #ifndef _DDR_TOPOLOGY_DEF_H
7 #define _DDR_TOPOLOGY_DEF_H
9 #include "ddr3_training_ip_def.h"
10 #include "mv_ddr_topology.h"
11 #include "mv_ddr_spd.h"
12 #include "ddr3_logging_def.h"
14 #define MV_DDR_MAX_BUS_NUM 9
15 #define MV_DDR_MAX_IFACE_NUM 1
18 /* Chip Select (CS) bitmask (bits 0-CS0, bit 1- CS1 ...) */
22 * mirror enable/disable
23 * (bits 0-CS0 mirroring, bit 1- CS1 mirroring ...)
25 int mirror_enable_bitmask;
27 /* DQS Swap (polarity) - true if enable */
30 /* CK swap (polarity) - true if enable */
35 /* bus configuration */
36 struct bus_params as_bus_params[MV_DDR_MAX_BUS_NUM];
39 enum mv_ddr_speed_bin speed_bin_index;
41 /* sdram device width */
42 enum mv_ddr_dev_width bus_width;
44 /* total sdram capacity per die, megabits */
45 enum mv_ddr_die_capacity memory_size;
47 /* The DDR frequency for each interfaces */
48 enum mv_ddr_freq memory_freq;
51 * delay CAS Write Latency
52 * - 0 for using default value (jedec suggested)
58 * - 0 for using default value (jedec suggested)
62 /* operation temperature */
63 enum mv_ddr_temperature interface_temp;
65 /* 2T vs 1T mode (by default computed from number of CSs) */
66 enum mv_ddr_timing timing;
69 /* memory electrical configuration */
70 struct mv_ddr_mem_edata {
71 enum mv_ddr_rtt_nom_park_evalue rtt_nom;
72 enum mv_ddr_rtt_nom_park_evalue rtt_park[MAX_CS_NUM];
73 enum mv_ddr_rtt_wr_evalue rtt_wr[MAX_CS_NUM];
74 enum mv_ddr_dic_evalue dic;
77 /* phy electrical configuration */
78 struct mv_ddr_phy_edata {
79 enum mv_ddr_ohm_evalue drv_data_p;
80 enum mv_ddr_ohm_evalue drv_data_n;
81 enum mv_ddr_ohm_evalue drv_ctrl_p;
82 enum mv_ddr_ohm_evalue drv_ctrl_n;
83 enum mv_ddr_ohm_evalue odt_p[MAX_CS_NUM];
84 enum mv_ddr_ohm_evalue odt_n[MAX_CS_NUM];
87 /* mac electrical configuration */
88 struct mv_ddr_mac_edata {
89 enum mv_ddr_odt_cfg_evalue odt_cfg_pat;
90 enum mv_ddr_odt_cfg_evalue odt_cfg_wr;
91 enum mv_ddr_odt_cfg_evalue odt_cfg_rd;
95 struct mv_ddr_mem_edata mem_edata;
96 struct mv_ddr_phy_edata phy_edata;
97 struct mv_ddr_mac_edata mac_edata;
100 struct mv_ddr_topology_map {
101 /* debug level configuration */
102 enum mv_ddr_debug_level debug_level;
104 /* Number of interfaces (default is 12) */
107 /* Controller configuration per interface */
108 struct if_params interface_params[MV_DDR_MAX_IFACE_NUM];
110 /* Bit mask for active buses */
113 /* source of ddr configuration data */
114 enum mv_ddr_cfg_src cfg_src;
117 union mv_ddr_spd_data spd_data;
119 /* timing parameters */
120 unsigned int timing_data[MV_DDR_TDATA_LAST];
122 /* electrical configuration */
123 struct mv_ddr_edata edata;
125 /* electrical parameters */
126 unsigned int electrical_data[MV_DDR_EDATA_LAST];
129 enum mv_ddr_iface_mode {
134 enum mv_ddr_iface_state {
135 MV_DDR_IFACE_NRDY, /* not ready */
136 MV_DDR_IFACE_INIT, /* init'd */
137 MV_DDR_IFACE_RDY, /* ready */
138 MV_DDR_IFACE_DNE /* does not exist */
141 enum mv_ddr_validation {
148 struct mv_ddr_iface {
149 /* base addr of ap ddr interface belongs to */
150 unsigned int ap_base;
152 /* ddr interface id */
155 /* ddr interface state */
156 enum mv_ddr_iface_state state;
158 /* ddr interface mode (rar enabled/disabled) */
159 enum mv_ddr_iface_mode iface_mode;
161 /* ddr interface base address */
162 unsigned long long iface_base_addr;
164 /* ddr interface size - ddr flow will update this parameter */
165 unsigned long long iface_byte_size;
167 /* ddr i2c spd data address */
168 unsigned int spd_data_addr;
170 /* ddr i2c spd page 0 select address */
171 unsigned int spd_page_sel_addr;
173 /* ddr interface validation mode */
174 enum mv_ddr_validation validation;
176 /* ddr interface topology map */
177 struct mv_ddr_topology_map tm;
180 struct mv_ddr_iface *mv_ddr_iface_get(void);
182 /* DDR3 training global configuration parameters */
183 struct tune_train_params {
201 #endif /* _DDR_TOPOLOGY_DEF_H */