Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Stefan Roese | 5ffceb8 | 2015-03-26 15:36:56 +0100 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (C) Marvell International Ltd. and its affiliates |
Stefan Roese | 5ffceb8 | 2015-03-26 15:36:56 +0100 | [diff] [blame] | 4 | */ |
| 5 | |
| 6 | #ifndef _DDR_TOPOLOGY_DEF_H |
| 7 | #define _DDR_TOPOLOGY_DEF_H |
| 8 | |
| 9 | #include "ddr3_training_ip_def.h" |
Chris Packham | 1a07d21 | 2018-05-10 13:28:29 +1200 | [diff] [blame] | 10 | #include "mv_ddr_topology.h" |
| 11 | #include "mv_ddr_spd.h" |
| 12 | #include "ddr3_logging_def.h" |
Marek BehĂșn | f8bf75f | 2017-06-09 19:28:40 +0200 | [diff] [blame] | 13 | |
Chris Packham | 4bf81db | 2018-12-03 14:26:49 +1300 | [diff] [blame] | 14 | #define MV_DDR_MAX_BUS_NUM 9 |
| 15 | #define MV_DDR_MAX_IFACE_NUM 1 |
| 16 | |
Stefan Roese | 5ffceb8 | 2015-03-26 15:36:56 +0100 | [diff] [blame] | 17 | struct bus_params { |
| 18 | /* Chip Select (CS) bitmask (bits 0-CS0, bit 1- CS1 ...) */ |
| 19 | u8 cs_bitmask; |
| 20 | |
| 21 | /* |
| 22 | * mirror enable/disable |
| 23 | * (bits 0-CS0 mirroring, bit 1- CS1 mirroring ...) |
| 24 | */ |
| 25 | int mirror_enable_bitmask; |
| 26 | |
| 27 | /* DQS Swap (polarity) - true if enable */ |
| 28 | int is_dqs_swap; |
| 29 | |
| 30 | /* CK swap (polarity) - true if enable */ |
| 31 | int is_ck_swap; |
| 32 | }; |
| 33 | |
| 34 | struct if_params { |
| 35 | /* bus configuration */ |
Chris Packham | 4bf81db | 2018-12-03 14:26:49 +1300 | [diff] [blame] | 36 | struct bus_params as_bus_params[MV_DDR_MAX_BUS_NUM]; |
Stefan Roese | 5ffceb8 | 2015-03-26 15:36:56 +0100 | [diff] [blame] | 37 | |
| 38 | /* Speed Bin Table */ |
Chris Packham | 4bf81db | 2018-12-03 14:26:49 +1300 | [diff] [blame] | 39 | enum mv_ddr_speed_bin speed_bin_index; |
Stefan Roese | 5ffceb8 | 2015-03-26 15:36:56 +0100 | [diff] [blame] | 40 | |
Chris Packham | 1a07d21 | 2018-05-10 13:28:29 +1200 | [diff] [blame] | 41 | /* sdram device width */ |
| 42 | enum mv_ddr_dev_width bus_width; |
Stefan Roese | 5ffceb8 | 2015-03-26 15:36:56 +0100 | [diff] [blame] | 43 | |
Chris Packham | 1a07d21 | 2018-05-10 13:28:29 +1200 | [diff] [blame] | 44 | /* total sdram capacity per die, megabits */ |
| 45 | enum mv_ddr_die_capacity memory_size; |
Stefan Roese | 5ffceb8 | 2015-03-26 15:36:56 +0100 | [diff] [blame] | 46 | |
| 47 | /* The DDR frequency for each interfaces */ |
Chris Packham | 4bf81db | 2018-12-03 14:26:49 +1300 | [diff] [blame] | 48 | enum mv_ddr_freq memory_freq; |
Stefan Roese | 5ffceb8 | 2015-03-26 15:36:56 +0100 | [diff] [blame] | 49 | |
| 50 | /* |
| 51 | * delay CAS Write Latency |
| 52 | * - 0 for using default value (jedec suggested) |
| 53 | */ |
| 54 | u8 cas_wl; |
| 55 | |
| 56 | /* |
| 57 | * delay CAS Latency |
| 58 | * - 0 for using default value (jedec suggested) |
| 59 | */ |
| 60 | u8 cas_l; |
| 61 | |
| 62 | /* operation temperature */ |
Chris Packham | 1a07d21 | 2018-05-10 13:28:29 +1200 | [diff] [blame] | 63 | enum mv_ddr_temperature interface_temp; |
Chris Packham | 3a09e13 | 2018-05-10 13:28:30 +1200 | [diff] [blame] | 64 | |
| 65 | /* 2T vs 1T mode (by default computed from number of CSs) */ |
| 66 | enum mv_ddr_timing timing; |
Stefan Roese | 5ffceb8 | 2015-03-26 15:36:56 +0100 | [diff] [blame] | 67 | }; |
| 68 | |
Chris Packham | 4bf81db | 2018-12-03 14:26:49 +1300 | [diff] [blame] | 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; |
| 75 | }; |
| 76 | |
| 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]; |
| 85 | }; |
| 86 | |
| 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; |
| 92 | }; |
| 93 | |
| 94 | struct mv_ddr_edata { |
| 95 | struct mv_ddr_mem_edata mem_edata; |
| 96 | struct mv_ddr_phy_edata phy_edata; |
| 97 | struct mv_ddr_mac_edata mac_edata; |
| 98 | }; |
| 99 | |
Chris Packham | 1a07d21 | 2018-05-10 13:28:29 +1200 | [diff] [blame] | 100 | struct mv_ddr_topology_map { |
| 101 | /* debug level configuration */ |
| 102 | enum mv_ddr_debug_level debug_level; |
| 103 | |
Stefan Roese | 5ffceb8 | 2015-03-26 15:36:56 +0100 | [diff] [blame] | 104 | /* Number of interfaces (default is 12) */ |
| 105 | u8 if_act_mask; |
| 106 | |
| 107 | /* Controller configuration per interface */ |
Chris Packham | 4bf81db | 2018-12-03 14:26:49 +1300 | [diff] [blame] | 108 | struct if_params interface_params[MV_DDR_MAX_IFACE_NUM]; |
Stefan Roese | 5ffceb8 | 2015-03-26 15:36:56 +0100 | [diff] [blame] | 109 | |
Stefan Roese | 5ffceb8 | 2015-03-26 15:36:56 +0100 | [diff] [blame] | 110 | /* Bit mask for active buses */ |
Chris Packham | 1a07d21 | 2018-05-10 13:28:29 +1200 | [diff] [blame] | 111 | u16 bus_act_mask; |
| 112 | |
| 113 | /* source of ddr configuration data */ |
| 114 | enum mv_ddr_cfg_src cfg_src; |
| 115 | |
| 116 | /* raw spd data */ |
| 117 | union mv_ddr_spd_data spd_data; |
| 118 | |
| 119 | /* timing parameters */ |
| 120 | unsigned int timing_data[MV_DDR_TDATA_LAST]; |
Chris Packham | 4bf81db | 2018-12-03 14:26:49 +1300 | [diff] [blame] | 121 | |
| 122 | /* electrical configuration */ |
| 123 | struct mv_ddr_edata edata; |
| 124 | |
| 125 | /* electrical parameters */ |
| 126 | unsigned int electrical_data[MV_DDR_EDATA_LAST]; |
Baruch Siach | 24a1d13 | 2020-01-20 14:20:06 +0200 | [diff] [blame] | 127 | |
| 128 | /* Clock enable mask */ |
| 129 | u32 clk_enable; |
Chris Packham | e422adc | 2020-01-30 12:50:44 +1300 | [diff] [blame] | 130 | |
| 131 | /* Clock delay */ |
| 132 | int ck_delay; |
Chris Packham | 4bf81db | 2018-12-03 14:26:49 +1300 | [diff] [blame] | 133 | }; |
| 134 | |
| 135 | enum mv_ddr_iface_mode { |
| 136 | MV_DDR_RAR_ENA, |
| 137 | MV_DDR_RAR_DIS, |
Stefan Roese | 5ffceb8 | 2015-03-26 15:36:56 +0100 | [diff] [blame] | 138 | }; |
| 139 | |
Chris Packham | 4bf81db | 2018-12-03 14:26:49 +1300 | [diff] [blame] | 140 | enum mv_ddr_iface_state { |
| 141 | MV_DDR_IFACE_NRDY, /* not ready */ |
| 142 | MV_DDR_IFACE_INIT, /* init'd */ |
| 143 | MV_DDR_IFACE_RDY, /* ready */ |
| 144 | MV_DDR_IFACE_DNE /* does not exist */ |
| 145 | }; |
| 146 | |
| 147 | enum mv_ddr_validation { |
| 148 | MV_DDR_VAL_DIS, |
| 149 | MV_DDR_VAL_RX, |
| 150 | MV_DDR_VAL_TX, |
Marek BehĂșn | cd4d2cf | 2021-02-19 17:11:10 +0100 | [diff] [blame^] | 151 | MV_DDR_VAL_RX_TX, |
| 152 | MV_DDR_MEMORY_CHECK |
Chris Packham | 4bf81db | 2018-12-03 14:26:49 +1300 | [diff] [blame] | 153 | }; |
| 154 | |
| 155 | struct mv_ddr_iface { |
| 156 | /* base addr of ap ddr interface belongs to */ |
| 157 | unsigned int ap_base; |
| 158 | |
| 159 | /* ddr interface id */ |
| 160 | unsigned int id; |
| 161 | |
| 162 | /* ddr interface state */ |
| 163 | enum mv_ddr_iface_state state; |
| 164 | |
| 165 | /* ddr interface mode (rar enabled/disabled) */ |
| 166 | enum mv_ddr_iface_mode iface_mode; |
| 167 | |
| 168 | /* ddr interface base address */ |
| 169 | unsigned long long iface_base_addr; |
| 170 | |
| 171 | /* ddr interface size - ddr flow will update this parameter */ |
| 172 | unsigned long long iface_byte_size; |
| 173 | |
| 174 | /* ddr i2c spd data address */ |
| 175 | unsigned int spd_data_addr; |
| 176 | |
| 177 | /* ddr i2c spd page 0 select address */ |
| 178 | unsigned int spd_page_sel_addr; |
| 179 | |
| 180 | /* ddr interface validation mode */ |
| 181 | enum mv_ddr_validation validation; |
| 182 | |
| 183 | /* ddr interface topology map */ |
| 184 | struct mv_ddr_topology_map tm; |
| 185 | }; |
| 186 | |
| 187 | struct mv_ddr_iface *mv_ddr_iface_get(void); |
| 188 | |
Stefan Roese | 5ffceb8 | 2015-03-26 15:36:56 +0100 | [diff] [blame] | 189 | /* DDR3 training global configuration parameters */ |
| 190 | struct tune_train_params { |
| 191 | u32 ck_delay; |
Stefan Roese | 5ffceb8 | 2015-03-26 15:36:56 +0100 | [diff] [blame] | 192 | u32 phy_reg3_val; |
Chris Packham | 1a07d21 | 2018-05-10 13:28:29 +1200 | [diff] [blame] | 193 | u32 g_zpri_data; |
| 194 | u32 g_znri_data; |
| 195 | u32 g_zpri_ctrl; |
| 196 | u32 g_znri_ctrl; |
| 197 | u32 g_zpodt_data; |
| 198 | u32 g_znodt_data; |
| 199 | u32 g_zpodt_ctrl; |
| 200 | u32 g_znodt_ctrl; |
| 201 | u32 g_dic; |
| 202 | u32 g_odt_config; |
| 203 | u32 g_rtt_nom; |
| 204 | u32 g_rtt_wr; |
| 205 | u32 g_rtt_park; |
Stefan Roese | 5ffceb8 | 2015-03-26 15:36:56 +0100 | [diff] [blame] | 206 | }; |
| 207 | |
| 208 | #endif /* _DDR_TOPOLOGY_DEF_H */ |