Googler | a8fd56b | 2024-10-24 14:04:51 +0800 | [diff] [blame^] | 1 | /* SPDX-License-Identifier: (GPL-2.0+ OR MIT) */ |
| 2 | /* |
| 3 | * board/amlogic/g12a_u212_v1/firmware/timing.c |
| 4 | * |
| 5 | * Copyright (C) 2020 Amlogic, Inc. All rights reserved. |
| 6 | * |
| 7 | */ |
| 8 | |
| 9 | #include <asm/arch/secure_apb.h> |
| 10 | #include <asm/arch/timing.h> |
| 11 | #include <asm/arch/ddr_define.h> |
| 12 | |
| 13 | |
| 14 | |
| 15 | /* ddr config support multiple configs for boards which use same bootloader: |
| 16 | * config steps: |
| 17 | * 1. add a new data struct in __ddr_setting[] |
| 18 | * 2. config correct board_id, ddr_type, freq, etc.. |
| 19 | */ |
| 20 | |
| 21 | |
| 22 | /* CAUTION!! */ |
| 23 | /* Confirm ddr configs with hardware designer, |
| 24 | * if you don't know how to config, then don't edit it |
| 25 | */ |
| 26 | |
| 27 | /* Key configs */ |
| 28 | /* |
| 29 | * board_id: check hardware adc config |
| 30 | * dram_rank_config: |
| 31 | * #define CONFIG_DDR_CHL_AUTO 0xF |
| 32 | * #define CONFIG_DDR0_16BIT_CH0 0x1 |
| 33 | * #define CONFIG_DDR0_16BIT_RANK01_CH0 0x4 |
| 34 | * #define CONFIG_DDR0_32BIT_RANK0_CH0 0x2 |
| 35 | * #define CONFIG_DDR0_32BIT_RANK01_CH01 0x3 |
| 36 | * #define CONFIG_DDR0_32BIT_16BIT_RANK0_CH0 0x5 |
| 37 | * #define CONFIG_DDR0_32BIT_16BIT_RANK01_CH0 0x6 |
| 38 | * DramType: |
| 39 | * #define CONFIG_DDR_TYPE_DDR3 0 |
| 40 | * #define CONFIG_DDR_TYPE_DDR4 1 |
| 41 | * #define CONFIG_DDR_TYPE_LPDDR4 2 |
| 42 | * #define CONFIG_DDR_TYPE_LPDDR3 3 |
| 43 | * DRAMFreq: |
| 44 | * {pstate0, pstate1, pstate2, pstate3} //more than one pstate means use dynamic freq |
| 45 | * |
| 46 | */ |
| 47 | |
| 48 | ddr_set_t __ddr_setting[] __attribute__ ((section(".ddr_settings"))) = { |
| 49 | { |
| 50 | // g12a 4layer 4pcs ddr4 rank01 (1320)(T204) |
| 51 | .board_id = CONFIG_BOARD_ID_MASK, |
| 52 | .version = 1, |
| 53 | .dram_rank_config = CONFIG_DDR0_32BIT_RANK01_CH0, |
| 54 | .DramType = CONFIG_DDR_TYPE_DDR4, |
| 55 | .DRAMFreq = {1320, 0, 0, 0}, |
| 56 | .ddr_rfc_type = DDR_RFC_TYPE_DDR4_2Gbx8, |
| 57 | .ddr_base_addr = CFG_DDR_BASE_ADDR, |
| 58 | .ddr_start_offset = CFG_DDR_START_OFFSET, |
| 59 | //.imem_load_addr = 0xFFFC0000, //sram |
| 60 | //.dmem_load_size = 0x1000, //4K |
| 61 | |
| 62 | .DisabledDbyte = 0xf0, |
| 63 | .Is2Ttiming = 1, |
| 64 | .HdtCtrl = 0xC8, |
| 65 | .dram_cs0_size_MB = 0xffff, |
| 66 | .dram_cs1_size_MB = 0xffff, |
| 67 | .training_SequenceCtrl = {0x31f,0x61}, //ddr3 0x21f 0x31f |
| 68 | .phy_odt_config_rank = {0x23,0x13}, //use 0x23 0x13 compatibility with 1rank and 2rank //targeting rank 0. [3:0] is used //for write ODT [7:4] is used for //read ODT |
| 69 | .dfi_odt_config = 0x0d0d, //use 0d0d compatibility with 1rank and 2rank //0808 |
| 70 | .PllBypassEn = 0, //bit0-ps0,bit1-ps1 |
| 71 | .ddr_rdbi_wr_enable = 0, |
| 72 | .clk_drv_ohm = 40, |
| 73 | .cs_drv_ohm = 40, |
| 74 | .ac_drv_ohm = 40, |
| 75 | .soc_data_drv_ohm_p = 40, |
| 76 | .soc_data_drv_ohm_n = 40, |
| 77 | .soc_data_odt_ohm_p = 80, |
| 78 | .soc_data_odt_ohm_n = 0, |
| 79 | .dram_data_drv_ohm = 34,//48, //34, //ddr4 sdram only 34 or 48, skt board use 34 better |
| 80 | .dram_data_odt_ohm = 80, //60, |
| 81 | .dram_ac_odt_ohm = 0, |
| 82 | .dram_data_wr_odt_ohm = 120, |
| 83 | .soc_clk_slew_rate = 0x3ff, |
| 84 | .soc_cs_slew_rate = 0x3ff, |
| 85 | .soc_ac_slew_rate = 0x3ff, |
| 86 | .soc_data_slew_rate = 0x2ff, |
| 87 | .vref_output_permil = 500, |
| 88 | .vref_receiver_permil = 8200/12,//700, |
| 89 | .vref_dram_permil = 9200/12,//700, |
| 90 | //.vref_reverse = 0, |
| 91 | //.ac_trace_delay = {0x0,0x0},// {0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40}, |
| 92 | .ac_trace_delay = {32+10,32,32+10,32+10,32,32,32+10,32+10,32+10,32+8}, |
| 93 | .ddr_dmc_remap = { |
| 94 | [0] = ( 5 | 7 << 5 | 8 << 10 | 9 << 15 | 10 << 20 | 11 << 25 ), |
| 95 | [1] = ( 12| 0 << 5 | 0 << 10 | 14 << 15 | 15 << 20 | 16 << 25 ), |
| 96 | [2] = ( 17| 18 << 5 | 19 << 10 | 21 << 15 | 22 << 20 | 23 << 25 ), |
| 97 | [3] = ( 24| 25 << 5 | 26 << 10 | 27 << 15 | 28 << 20 | 29 << 25 ), |
| 98 | [4] = ( 30| 13 << 5 | 20 << 10 | 6 << 15 | 0 << 20 | 0 << 25 ), |
| 99 | }, |
| 100 | .ddr_lpddr34_ca_remap = {00,00}, |
| 101 | .ddr_lpddr34_dq_remap = {00,00}, |
| 102 | .dram_rtt_nom_wr_park = {00,00}, |
| 103 | |
| 104 | /* pll ssc config: |
| 105 | * |
| 106 | * pll_ssc_mode = (1<<20) | (1<<8) | ([strength] << 4) | [mode], |
| 107 | * ppm = strength * 500 |
| 108 | * mode: 0=center, 1=up, 2=down |
| 109 | * |
| 110 | * eg: |
| 111 | * 1. config 1000ppm center ss. then mode=0, strength=2 |
| 112 | * .pll_ssc_mode = (1<<20) | (1<<8) | (2 << 4) | 0, |
| 113 | * 2. config 3000ppm down ss. then mode=2, strength=6 |
| 114 | * .pll_ssc_mode = (1<<20) | (1<<8) | (6 << 4) | 2, |
| 115 | */ |
| 116 | .pll_ssc_mode = (1<<20) | (1<<8) | (2<<4) | 0,//center_ssc_1000ppm |
| 117 | .ddr_func = DDR_FUNC | DDR_FUNC_CONFIG_DFE_FUNCTION, |
| 118 | .magic = DRAM_CFG_MAGIC, |
| 119 | .fast_boot[0] = 1, |
| 120 | .training_offset = (1<<3) | (4<<0),//read dqs offset after training,bit3=0 right move,bit3=1 left move,bit[2:0] offset step |
| 121 | }, |
| 122 | { |
| 123 | // g12a 4layer 2pcs ddr4 rank0 (1320)(U200) |
| 124 | .board_id = CONFIG_BOARD_ID_MASK, |
| 125 | .version = 1, |
| 126 | .dram_rank_config = CONFIG_DDR0_32BIT_RANK0_CH0, |
| 127 | .DramType = CONFIG_DDR_TYPE_DDR4, |
| 128 | .DRAMFreq = {1320, 0, 0, 0}, |
| 129 | .ddr_rfc_type = DDR_RFC_TYPE_DDR4_2Gbx8, |
| 130 | .ddr_base_addr = CFG_DDR_BASE_ADDR, |
| 131 | .ddr_start_offset = CFG_DDR_START_OFFSET, |
| 132 | //.imem_load_addr = 0xFFFC0000, //sram |
| 133 | //.dmem_load_size = 0x1000, //4K |
| 134 | |
| 135 | .DisabledDbyte = 0xf0, |
| 136 | .Is2Ttiming = 1, |
| 137 | .HdtCtrl = 0xC8, |
| 138 | .dram_cs0_size_MB = 0xffff, |
| 139 | .dram_cs1_size_MB = 0, |
| 140 | .training_SequenceCtrl = {0x31f,0x61}, //ddr3 0x21f 0x31f |
| 141 | .phy_odt_config_rank = {0x23,0x13}, //use 0x23 0x13 compatibility with 1rank and 2rank //targeting rank 0. [3:0] is used //for write ODT [7:4] is used for //read ODT |
| 142 | .dfi_odt_config = 0x0d0d, //use 0d0d compatibility with 1rank and 2rank //0808 |
| 143 | .PllBypassEn = 0, //bit0-ps0,bit1-ps1 |
| 144 | .ddr_rdbi_wr_enable = 0, |
| 145 | .clk_drv_ohm = 40, |
| 146 | .cs_drv_ohm = 40, |
| 147 | .ac_drv_ohm = 40, |
| 148 | .soc_data_drv_ohm_p = 40, |
| 149 | .soc_data_drv_ohm_n = 40, |
| 150 | .soc_data_odt_ohm_p = 60, |
| 151 | .soc_data_odt_ohm_n = 0, |
| 152 | .dram_data_drv_ohm = 34,//48, //34, //ddr4 sdram only 34 or 48, skt board use 34 better |
| 153 | .dram_data_odt_ohm = 60, //60, |
| 154 | .dram_ac_odt_ohm = 0, |
| 155 | .soc_clk_slew_rate = 0x3ff, |
| 156 | .soc_cs_slew_rate = 0x3ff, |
| 157 | .soc_ac_slew_rate = 0x3ff, |
| 158 | .soc_data_slew_rate = 0x2ff, |
| 159 | .vref_output_permil = 500, |
| 160 | .vref_receiver_permil = 0,//700, |
| 161 | .vref_dram_permil = 0,//700, |
| 162 | //.vref_reverse = 0, |
| 163 | //.ac_trace_delay = {0x0,0x0},// {0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40}, |
| 164 | .ac_trace_delay = {32-10,32,32,32,32,32,32,32,32,32}, |
| 165 | .ddr_dmc_remap = { |
| 166 | [0] = ( 5 | 7 << 5 | 8 << 10 | 9 << 15 | 10 << 20 | 11 << 25 ), |
| 167 | [1] = ( 12| 0 << 5 | 0 << 10 | 14 << 15 | 15 << 20 | 16 << 25 ), |
| 168 | [2] = ( 17| 18 << 5 | 19 << 10 | 21 << 15 | 22 << 20 | 23 << 25 ), |
| 169 | [3] = ( 24| 25 << 5 | 26 << 10 | 27 << 15 | 28 << 20 | 29 << 25 ), |
| 170 | [4] = ( 30| 13 << 5 | 20 << 10 | 6 << 15 | 0 << 20 | 0 << 25 ), |
| 171 | }, |
| 172 | .ddr_lpddr34_ca_remap = {00,00}, |
| 173 | .ddr_lpddr34_dq_remap = {00,00}, |
| 174 | .dram_rtt_nom_wr_park = {00,00}, |
| 175 | |
| 176 | /* pll ssc config: |
| 177 | * |
| 178 | * pll_ssc_mode = (1<<20) | (1<<8) | ([strength] << 4) | [mode], |
| 179 | * ppm = strength * 500 |
| 180 | * mode: 0=center, 1=up, 2=down |
| 181 | * |
| 182 | * eg: |
| 183 | * 1. config 1000ppm center ss. then mode=0, strength=2 |
| 184 | * .pll_ssc_mode = (1<<20) | (1<<8) | (2 << 4) | 0, |
| 185 | * 2. config 3000ppm down ss. then mode=2, strength=6 |
| 186 | * .pll_ssc_mode = (1<<20) | (1<<8) | (6 << 4) | 2, |
| 187 | */ |
| 188 | .pll_ssc_mode = (1<<20) | (1<<8) | (2<<4) | 0,//center_ssc_1000ppm |
| 189 | .ddr_func = DDR_FUNC, |
| 190 | .magic = DRAM_CFG_MAGIC, |
| 191 | .fast_boot[0] = 1, |
| 192 | }, |
| 193 | { |
| 194 | // g12a 4layer 4pcs ddr3 rank01 (912)(U212) |
| 195 | .board_id = CONFIG_BOARD_ID_MASK, |
| 196 | .version = 1, |
| 197 | .dram_rank_config = CONFIG_DDR0_32BIT_RANK01_CH0, |
| 198 | .DramType = CONFIG_DDR_TYPE_DDR3, |
| 199 | .DRAMFreq = {912, 0, 0, 0}, |
| 200 | .ddr_base_addr = CFG_DDR_BASE_ADDR, |
| 201 | .ddr_start_offset = CFG_DDR_START_OFFSET, |
| 202 | //.imem_load_addr = 0xFFFC0000, //sram |
| 203 | //.dmem_load_size = 0x1000, //4K |
| 204 | |
| 205 | .DisabledDbyte = 0xf0, |
| 206 | .Is2Ttiming = 1, |
| 207 | .HdtCtrl = 0xC8, |
| 208 | .dram_cs0_size_MB = 0xffff, |
| 209 | .dram_cs1_size_MB = 0xffff, |
| 210 | .training_SequenceCtrl = {0x31f,0}, //ddr3 0x21f 0x31f |
| 211 | .phy_odt_config_rank = {0x23,0x13}, //use 0x23 0x13 compatibility with 1rank and 2rank //targeting rank 0. [3:0] is used //for write ODT [7:4] is used for //read ODT |
| 212 | .dfi_odt_config = 0x0d0d, //use 0d0d compatibility with 1rank and 2rank //0808 |
| 213 | .PllBypassEn = 0, //bit0-ps0,bit1-ps1 |
| 214 | .ddr_rdbi_wr_enable = 0, |
| 215 | .clk_drv_ohm = 40, |
| 216 | .cs_drv_ohm = 40, |
| 217 | .ac_drv_ohm = 40, |
| 218 | .soc_data_drv_ohm_p = 34, |
| 219 | .soc_data_drv_ohm_n = 34, |
| 220 | .soc_data_odt_ohm_p = 60, //48, |
| 221 | .soc_data_odt_ohm_n = 0, |
| 222 | .dram_data_drv_ohm = 34, //ddr4 sdram only 34 or 48, skt board use 34 better |
| 223 | .dram_data_odt_ohm = 60, |
| 224 | .dram_ac_odt_ohm = 0, |
| 225 | .soc_clk_slew_rate = 0x300, |
| 226 | .soc_cs_slew_rate = 0x300, |
| 227 | .soc_ac_slew_rate = 0x300, |
| 228 | .soc_data_slew_rate = 0x200, |
| 229 | .vref_output_permil = 500, |
| 230 | .vref_receiver_permil = 500, //700, |
| 231 | .vref_dram_permil = 500, //700, |
| 232 | //.vref_reverse = 0, |
| 233 | .ac_trace_delay = {32,32,32,32,32,32,32,32,32,32}, |
| 234 | //{00,00}, |
| 235 | .ac_pinmux = {00,00}, |
| 236 | #if 1 |
| 237 | .ddr_dmc_remap = { |
| 238 | [0] = ( 5 | 7 << 5 | 8 << 10 | 9 << 15 | 10 << 20 | 11 << 25 ), |
| 239 | [1] = ( 12| 0 << 5 | 0 << 10 | 14 << 15 | 15 << 20 | 16 << 25 ), |
| 240 | [2] = ( 17| 18 << 5 | 19 << 10 | 21 << 15 | 22 << 20 | 23 << 25 ), |
| 241 | [3] = ( 24| 25 << 5 | 26 << 10 | 27 << 15 | 28 << 20 | 29 << 25 ), |
| 242 | [4] = ( 30| 13 << 5 | 20 << 10 | 6 << 15 | 0 << 20 | 0 << 25 ), |
| 243 | }, |
| 244 | #else |
| 245 | //16bit |
| 246 | .ddr_dmc_remap = { |
| 247 | [0] = ( 0 | 5 << 5 | 6<< 10 | 7 << 15 | 8 << 20 | 9 << 25 ), |
| 248 | [1] = ( 10| 0 << 5 | 0 << 10 | 14 << 15 | 15 << 20 | 16 << 25 ), |
| 249 | [2] = ( 17|( 18 << 5) |( 19 << 10) |( 20 << 15) |( 21 << 20) | (22 << 25 )), |
| 250 | [3] = ( 23| 24 << 5 | 25 << 10 | 26 << 15 | 27 << 20 | 28 << 25 ), |
| 251 | [4] = ( 29| 11<< 5 | 12 << 10 | 13<< 15 | 0 << 20 | 0 << 25 ), |
| 252 | }, |
| 253 | #endif |
| 254 | .ddr_lpddr34_ca_remap = {00,00}, |
| 255 | .ddr_lpddr34_dq_remap = {00,00}, |
| 256 | .dram_rtt_nom_wr_park = {00,00}, |
| 257 | |
| 258 | /* pll ssc config: |
| 259 | * |
| 260 | * pll_ssc_mode = (1<<20) | (1<<8) | ([strength] << 4) | [mode], |
| 261 | * ppm = strength * 500 |
| 262 | * mode: 0=center, 1=up, 2=down |
| 263 | * |
| 264 | * eg: |
| 265 | * 1. config 1000ppm center ss. then mode=0, strength=2 |
| 266 | * .pll_ssc_mode = (1<<20) | (1<<8) | (2 << 4) | 0, |
| 267 | * 2. config 3000ppm down ss. then mode=2, strength=6 |
| 268 | * .pll_ssc_mode = (1<<20) | (1<<8) | (6 << 4) | 2, |
| 269 | */ |
| 270 | .pll_ssc_mode = (1<<20) | (1<<8) | (2<<4) | 0,//center_ssc_1000ppm |
| 271 | .ddr_func = DDR_FUNC, |
| 272 | .magic = DRAM_CFG_MAGIC, |
| 273 | .fast_boot[0] = 1, |
| 274 | }, |
| 275 | { |
| 276 | // g12a 4layer 2pcs ddr3 rank0 (912) |
| 277 | .board_id = CONFIG_BOARD_ID_MASK, |
| 278 | .version = 1, |
| 279 | .dram_rank_config = CONFIG_DDR0_32BIT_RANK0_CH0, |
| 280 | .DramType = CONFIG_DDR_TYPE_DDR3, |
| 281 | .DRAMFreq = {912, 0, 0, 0}, |
| 282 | .ddr_base_addr = CFG_DDR_BASE_ADDR, |
| 283 | .ddr_start_offset = CFG_DDR_START_OFFSET, |
| 284 | //.imem_load_addr = 0xFFFC0000, //sram |
| 285 | //.dmem_load_size = 0x1000, //4K |
| 286 | |
| 287 | .DisabledDbyte = 0xf0, |
| 288 | .Is2Ttiming = 1, |
| 289 | .HdtCtrl = 0xC8, |
| 290 | .dram_cs0_size_MB = 0xffff, |
| 291 | .dram_cs1_size_MB = 0, |
| 292 | .training_SequenceCtrl = {0x31f,0}, //ddr3 0x21f 0x31f |
| 293 | .phy_odt_config_rank = {0x23,0x13}, //use 0x23 0x13 compatibility with 1rank and 2rank //targeting rank 0. [3:0] is used //for write ODT [7:4] is used for //read ODT |
| 294 | .dfi_odt_config = 0x0d0d, //use 0d0d compatibility with 1rank and 2rank //0808 |
| 295 | .PllBypassEn = 0, //bit0-ps0,bit1-ps1 |
| 296 | .ddr_rdbi_wr_enable = 0, |
| 297 | .clk_drv_ohm = 40, |
| 298 | .cs_drv_ohm = 40, |
| 299 | .ac_drv_ohm = 40, |
| 300 | .soc_data_drv_ohm_p = 34, |
| 301 | .soc_data_drv_ohm_n = 34, |
| 302 | .soc_data_odt_ohm_p = 60, //48, |
| 303 | .soc_data_odt_ohm_n = 0, |
| 304 | .dram_data_drv_ohm = 34, //ddr4 sdram only 34 or 48, skt board use 34 better |
| 305 | .dram_data_odt_ohm = 60, |
| 306 | .dram_ac_odt_ohm = 0, |
| 307 | .soc_clk_slew_rate = 0x300, |
| 308 | .soc_cs_slew_rate = 0x300, |
| 309 | .soc_ac_slew_rate = 0x300, |
| 310 | .soc_data_slew_rate = 0x200, |
| 311 | .vref_output_permil = 500, |
| 312 | .vref_receiver_permil = 500, //700, |
| 313 | .vref_dram_permil = 500, //700, |
| 314 | //.vref_reverse = 0, |
| 315 | .ac_trace_delay = {32,32,32,32,32,32,32,32,32,32}, |
| 316 | //{00,00}, |
| 317 | .ac_pinmux = {00,00}, |
| 318 | #if 1 |
| 319 | .ddr_dmc_remap = { |
| 320 | [0] = ( 5 | 7 << 5 | 8 << 10 | 9 << 15 | 10 << 20 | 11 << 25 ), |
| 321 | [1] = ( 12| 0 << 5 | 0 << 10 | 14 << 15 | 15 << 20 | 16 << 25 ), |
| 322 | [2] = ( 17| 18 << 5 | 19 << 10 | 21 << 15 | 22 << 20 | 23 << 25 ), |
| 323 | [3] = ( 24| 25 << 5 | 26 << 10 | 27 << 15 | 28 << 20 | 29 << 25 ), |
| 324 | [4] = ( 30| 13 << 5 | 20 << 10 | 6 << 15 | 0 << 20 | 0 << 25 ), |
| 325 | }, |
| 326 | #else |
| 327 | //16bit |
| 328 | .ddr_dmc_remap = { |
| 329 | [0] = ( 0 | 5 << 5 | 6<< 10 | 7 << 15 | 8 << 20 | 9 << 25 ), |
| 330 | [1] = ( 10| 0 << 5 | 0 << 10 | 14 << 15 | 15 << 20 | 16 << 25 ), |
| 331 | [2] = ( 17|( 18 << 5) |( 19 << 10) |( 20 << 15) |( 21 << 20) | (22 << 25 )), |
| 332 | [3] = ( 23| 24 << 5 | 25 << 10 | 26 << 15 | 27 << 20 | 28 << 25 ), |
| 333 | [4] = ( 29| 11<< 5 | 12 << 10 | 13<< 15 | 0 << 20 | 0 << 25 ), |
| 334 | }, |
| 335 | #endif |
| 336 | .ddr_lpddr34_ca_remap = {00,00}, |
| 337 | .ddr_lpddr34_dq_remap = {00,00}, |
| 338 | .dram_rtt_nom_wr_park = {00,00}, |
| 339 | |
| 340 | /* pll ssc config: |
| 341 | * |
| 342 | * pll_ssc_mode = (1<<20) | (1<<8) | ([strength] << 4) | [mode], |
| 343 | * ppm = strength * 500 |
| 344 | * mode: 0=center, 1=up, 2=down |
| 345 | * |
| 346 | * eg: |
| 347 | * 1. config 1000ppm center ss. then mode=0, strength=2 |
| 348 | * .pll_ssc_mode = (1<<20) | (1<<8) | (2 << 4) | 0, |
| 349 | * 2. config 3000ppm down ss. then mode=2, strength=6 |
| 350 | * .pll_ssc_mode = (1<<20) | (1<<8) | (6 << 4) | 2, |
| 351 | */ |
| 352 | .pll_ssc_mode = (1<<20) | (1<<8) | (2<<4) | 0,//center_ssc_1000ppm |
| 353 | .ddr_func = DDR_FUNC, |
| 354 | .magic = DRAM_CFG_MAGIC, |
| 355 | .fast_boot[0] = 1, |
| 356 | }, |
| 357 | { |
| 358 | /* g12a skt (u209) lpddr4 */ |
| 359 | .board_id = CONFIG_BOARD_ID_MASK, |
| 360 | .version = 1, |
| 361 | //.dram_rank_config = CONFIG_DDR0_32BIT_RANK01_CH0, |
| 362 | .dram_rank_config = CONFIG_DDR0_32BIT_RANK01_CH01, |
| 363 | .ddr_rfc_type = DDR_RFC_TYPE_LPDDR4_8Gbx1, |
| 364 | .DramType = CONFIG_DDR_TYPE_LPDDR4, |
| 365 | .DRAMFreq = {1392, 0, 0, 0}, |
| 366 | .ddr_base_addr = CFG_DDR_BASE_ADDR, |
| 367 | .ddr_start_offset = CFG_DDR_START_OFFSET, |
| 368 | //.imem_load_addr = 0xFFFC0000, //sram |
| 369 | //.dmem_load_size = 0x1000, //4K |
| 370 | |
| 371 | .DisabledDbyte = 0xf0, |
| 372 | .Is2Ttiming = 0, |
| 373 | .HdtCtrl = 0xa, |
| 374 | .dram_cs0_size_MB = 0xffff,//1024, |
| 375 | .dram_cs1_size_MB = 0xffff,//1024, |
| 376 | .training_SequenceCtrl = {0x131f,0x61}, //ddr3 0x21f 0x31f |
| 377 | .phy_odt_config_rank = {0x23,0x13}, //use 0x23 0x13 compatibility with 1rank and 2rank //targeting rank 0. [3:0] is used //for write ODT [7:4] is used for //read ODT |
| 378 | .dfi_odt_config = 0x0d0d, //use 0d0d compatibility with 1rank and 2rank //0808 |
| 379 | .PllBypassEn = 0, //bit0-ps0,bit1-ps1 |
| 380 | .ddr_rdbi_wr_enable = 0, |
| 381 | .clk_drv_ohm = 40, |
| 382 | .cs_drv_ohm = 40, |
| 383 | .ac_drv_ohm = 40, |
| 384 | .soc_data_drv_ohm_p = 40, |
| 385 | .soc_data_drv_ohm_n = 40, |
| 386 | .soc_data_odt_ohm_p = 0, |
| 387 | .soc_data_odt_ohm_n = 120, |
| 388 | .dram_data_drv_ohm = 40, //lpddr4 sdram only240/1-6 |
| 389 | .dram_data_odt_ohm = 120, |
| 390 | .dram_ac_odt_ohm = 120, |
| 391 | .lpddr4_dram_vout_voltage_1_3_2_5_setting = 1,///1, 1/3vddq 0 2/5 vddq |
| 392 | .soc_clk_slew_rate = 0x3ff,//0x253, |
| 393 | .soc_cs_slew_rate = 0x100,//0x253, |
| 394 | .soc_ac_slew_rate = 0x100,//0x253, |
| 395 | .soc_data_slew_rate = 0x1ff, |
| 396 | .vref_output_permil = 350,//200, |
| 397 | .vref_receiver_permil = 0, |
| 398 | .vref_dram_permil = 0, |
| 399 | //.vref_reverse = 0, |
| 400 | .ac_trace_delay = {00,0x0,0,0,0,0,0x0,00}, |
| 401 | .ac_pinmux = {00,00}, |
| 402 | .ddr_dmc_remap = { |
| 403 | [0] = ( 5 | 6 << 5 | 7 << 10 | 8<< 15 | 9<< 20 | 10 << 25 ), |
| 404 | [1] = ( 11| 0 << 5 | 0 << 10 | 15 << 15 | 16 << 20 | 17 << 25 ), |
| 405 | [2] = ( 18| 19 << 5 | 20 << 10 | 21 << 15 | 22 << 20 | 23 << 25 ), |
| 406 | [3] = ( 24| 25 << 5 | 26 << 10 | 27 << 15 | 28 << 20 | 29 << 25 ), |
| 407 | [4] = ( 30| 12 << 5 | 13 << 10 | 14<< 15 | 0 << 20 | 0 << 25 ), |
| 408 | }, |
| 409 | .ddr_lpddr34_ca_remap = {00,00}, |
| 410 | .ddr_lpddr34_dq_remap = {3,0,2,1,7,6,5,4, 13,12,15,14,10,8,11,9, 19,21,22,20,16,18,17,23, 26,27,25,24,31,29,30,28}, |
| 411 | .dram_rtt_nom_wr_park = {00,00}, |
| 412 | |
| 413 | /* pll ssc config: |
| 414 | * |
| 415 | * pll_ssc_mode = (1<<20) | (1<<8) | ([strength] << 4) | [mode], |
| 416 | * ppm = strength * 500 |
| 417 | * mode: 0=center, 1=up, 2=down |
| 418 | * |
| 419 | * eg: |
| 420 | * 1. config 1000ppm center ss. then mode=0, strength=2 |
| 421 | * .pll_ssc_mode = (1<<20) | (1<<8) | (2 << 4) | 0, |
| 422 | * 2. config 3000ppm down ss. then mode=2, strength=6 |
| 423 | * .pll_ssc_mode = (1<<20) | (1<<8) | (6 << 4) | 2, |
| 424 | */ |
| 425 | .pll_ssc_mode = (1<<20) | (1<<8) | (2<<4) | 0,//center_ssc_1000ppm |
| 426 | .ddr_func = DDR_FUNC, |
| 427 | .magic = DRAM_CFG_MAGIC, |
| 428 | .diagnose = CONFIG_DIAGNOSE_DISABLE, |
| 429 | }, |
| 430 | { |
| 431 | /* g12a Y2 dongle */ |
| 432 | .board_id = CONFIG_BOARD_ID_MASK, |
| 433 | .version = 1, |
| 434 | //.dram_rank_config = CONFIG_DDR0_32BIT_RANK01_CH0, |
| 435 | .dram_rank_config = CONFIG_DDR0_32BIT_RANK0_CH01, |
| 436 | .ddr_rfc_type = DDR_RFC_TYPE_LPDDR4_8Gbx1, |
| 437 | .DramType = CONFIG_DDR_TYPE_LPDDR4, |
| 438 | .DRAMFreq = {1392, 0, 0, 0}, |
| 439 | .ddr_base_addr = CFG_DDR_BASE_ADDR, |
| 440 | .ddr_start_offset = CFG_DDR_START_OFFSET, |
| 441 | //.imem_load_addr = 0xFFFC0000, //sram |
| 442 | //.dmem_load_size = 0x1000, //4K |
| 443 | |
| 444 | .DisabledDbyte = 0xf0, |
| 445 | .Is2Ttiming = 0, |
| 446 | .HdtCtrl = 0xa, |
| 447 | .dram_cs0_size_MB = 0xffff,//1024, |
| 448 | .dram_cs1_size_MB = 0,//1024, |
| 449 | .training_SequenceCtrl = {0x131f,0x61}, //ddr3 0x21f 0x31f |
| 450 | .phy_odt_config_rank = {0x23,0x13}, //use 0x23 0x13 compatibility with 1rank and 2rank //targeting rank 0. [3:0] is used //for write ODT [7:4] is used for //read ODT |
| 451 | .dfi_odt_config = 0x0d0d, //use 0d0d compatibility with 1rank and 2rank //0808 |
| 452 | .PllBypassEn = 0, //bit0-ps0,bit1-ps1 |
| 453 | .ddr_rdbi_wr_enable = 0, |
| 454 | .clk_drv_ohm = 40, |
| 455 | .cs_drv_ohm = 40, |
| 456 | .ac_drv_ohm = 40, |
| 457 | .soc_data_drv_ohm_p = 40, |
| 458 | .soc_data_drv_ohm_n = 40, |
| 459 | .soc_data_odt_ohm_p = 0, |
| 460 | .soc_data_odt_ohm_n = 120, |
| 461 | .dram_data_drv_ohm = 40, //lpddr4 sdram only240/1-6 |
| 462 | .dram_data_odt_ohm = 120, |
| 463 | .dram_ac_odt_ohm = 120, |
| 464 | .lpddr4_dram_vout_voltage_1_3_2_5_setting = 1,///1, 1/3vddq 0 2/5 vddq |
| 465 | .soc_clk_slew_rate = 0x3ff,//0x253, |
| 466 | .soc_cs_slew_rate = 0x100,//0x253, |
| 467 | .soc_ac_slew_rate = 0x100,//0x253, |
| 468 | .soc_data_slew_rate = 0x1ff, |
| 469 | .vref_output_permil = 350,//200, |
| 470 | .vref_receiver_permil = 0, |
| 471 | .vref_dram_permil = 0, |
| 472 | //.vref_reverse = 0, |
| 473 | .ac_trace_delay = {00,0x0,0,0,0,0,0x0,00}, |
| 474 | .ac_pinmux = {00,00}, |
| 475 | .ddr_dmc_remap = { |
| 476 | [0] = ( 5 | 6 << 5 | 7 << 10 | 8<< 15 | 9<< 20 | 10 << 25 ), |
| 477 | [1] = ( 11| 0 << 5 | 0 << 10 | 15 << 15 | 16 << 20 | 17 << 25 ), |
| 478 | [2] = ( 18| 19 << 5 | 20 << 10 | 21 << 15 | 22 << 20 | 23 << 25 ), |
| 479 | [3] = ( 24| 25 << 5 | 26 << 10 | 27 << 15 | 28 << 20 | 29 << 25 ), |
| 480 | [4] = ( 30| 12 << 5 | 13 << 10 | 14<< 15 | 0 << 20 | 0 << 25 ), |
| 481 | }, |
| 482 | .ddr_lpddr34_ca_remap = {00,00}, |
| 483 | .ddr_lpddr34_dq_remap = {3,0,2,1,7,6,5,4, 13,12,15,14,10,8,11,9, 19,21,22,20,16,18,17,23, 26,27,25,24,31,29,30,28}, |
| 484 | .dram_rtt_nom_wr_park = {00,00}, |
| 485 | /* pll ssc config: |
| 486 | * |
| 487 | * pll_ssc_mode = (1<<20) | (1<<8) | ([strength] << 4) | [mode], |
| 488 | * ppm = strength * 500 |
| 489 | * mode: 0=center, 1=up, 2=down |
| 490 | * |
| 491 | * eg: |
| 492 | * 1. config 1000ppm center ss. then mode=0, strength=2 |
| 493 | * .pll_ssc_mode = (1<<20) | (1<<8) | (2 << 4) | 0, |
| 494 | * 2. config 3000ppm down ss. then mode=2, strength=6 |
| 495 | * .pll_ssc_mode = (1<<20) | (1<<8) | (6 << 4) | 2, |
| 496 | */ |
| 497 | .pll_ssc_mode = (1<<20) | (1<<8) | (2<<4) | 0,//center_ssc_1000ppm |
| 498 | .ddr_func = DDR_FUNC, |
| 499 | .magic = DRAM_CFG_MAGIC, |
| 500 | }, |
| 501 | #if 0 |
| 502 | { |
| 503 | /* lpddr3 */ |
| 504 | .board_id = CONFIG_BOARD_ID_MASK, |
| 505 | .version = 1, |
| 506 | //.dram_rank_config = CONFIG_DDR0_32BIT_RANK01_CH0, |
| 507 | .dram_rank_config = CONFIG_DDR0_32BIT_RANK01_CH0, |
| 508 | .ddr_rfc_type = DDR_RFC_TYPE_LPDDR4_4Gbx1, |
| 509 | .DramType = CONFIG_DDR_TYPE_LPDDR3, |
| 510 | .DRAMFreq = {600, 0, 0, 0}, |
| 511 | .ddr_base_addr = CFG_DDR_BASE_ADDR, |
| 512 | .ddr_start_offset = CFG_DDR_START_OFFSET, |
| 513 | //.imem_load_addr = 0xFFFC0000, //sram |
| 514 | //.dmem_load_size = 0x1000, //4K |
| 515 | |
| 516 | .DisabledDbyte = 0xf0, |
| 517 | .Is2Ttiming = 0, |
| 518 | .HdtCtrl = 0xa,//0xa, |
| 519 | .dram_cs0_size_MB = 0xffff,//1024, |
| 520 | .dram_cs1_size_MB = 0xffff,//1024, |
| 521 | .training_SequenceCtrl = {0x131f,0}, //ddr3 0x21f 0x31f |
| 522 | .phy_odt_config_rank = {0x23,0x13}, //use 0x23 0x13 compatibility with 1rank and 2rank //targeting rank 0. [3:0] is used //for write ODT [7:4] is used for //read ODT |
| 523 | .dfi_odt_config = 0x0d0d, //use 0d0d compatibility with 1rank and 2rank //0808 |
| 524 | .PllBypassEn = 0, //bit0-ps0,bit1-ps1 |
| 525 | .ddr_rdbi_wr_enable = 0, |
| 526 | .pll_ssc_mode = (1<<20) | (1<<8) | (2<<4) | 0,//center_ssc_1000ppm |
| 527 | .clk_drv_ohm = 40, |
| 528 | .cs_drv_ohm = 40, |
| 529 | .ac_drv_ohm = 40, |
| 530 | .soc_data_drv_ohm_p = 40, |
| 531 | .soc_data_drv_ohm_n = 40, |
| 532 | .soc_data_odt_ohm_p = 60, |
| 533 | .soc_data_odt_ohm_n = 0, |
| 534 | .dram_data_drv_ohm = 30, // |
| 535 | .dram_data_odt_ohm = 120, |
| 536 | .dram_ac_odt_ohm = 0, |
| 537 | .soc_clk_slew_rate = 0x3ff,//0x253, |
| 538 | .soc_cs_slew_rate = 0x3ff,//0x253, |
| 539 | .soc_ac_slew_rate = 0x3ff,//0x253, |
| 540 | .soc_data_slew_rate = 0x2ff, |
| 541 | .vref_output_permil = 800,//200, |
| 542 | .vref_receiver_permil = 700,//875, //700 for drv 40 odt 60 is better ,why? |
| 543 | .vref_dram_permil = 500,//875, |
| 544 | //.vref_reverse = 0, |
| 545 | .ac_trace_delay = {0x10,0x0,0x10-6,0x10-6,0x10-6,0x0,0x0,0x0,0x0,0x0}, |
| 546 | .ac_pinmux = {00,00}, |
| 547 | .ddr_dmc_remap = { |
| 548 | [0] = ( 5 | 6 << 5 | 7 << 10 | 8<< 15 | 9<< 20 | 10 << 25 ), |
| 549 | [1] = ( 11| 29 << 5 | 0 << 10 | 15 << 15 | 16 << 20 | 17 << 25 ), |
| 550 | [2] = ( 18| 19 << 5 | 20 << 10 | 21 << 15 | 22 << 20 | 23 << 25 ), |
| 551 | [3] = ( 24| 25 << 5 | 26 << 10 | 27 << 15 | 28 << 20 | 30 << 25 ), |
| 552 | [4] = ( 31| 12 << 5 | 13 << 10 | 14<< 15 | 0 << 20 | 0 << 25 ), |
| 553 | }, |
| 554 | .ddr_lpddr34_ca_remap = {21/8,8/8,31/8,1/8},// {2,7,1,4,5,6,0,3,9,8}, |
| 555 | .ddr_lpddr34_dq_remap = {1,2,7,4,0,3,5,6, 8,12,14,9,11,10,15,13, 21,22,16,17,23,20,19,18, 31,29,26,27,30,28,25,24}, |
| 556 | //{21,22,16,17,23,20,19,18,8,12,14,9,11,10,15,13,31,29,26,27,30,28,25,24,1,2,7,4,0,3,5,6}, |
| 557 | .dram_rtt_nom_wr_park = {00,00}, |
| 558 | .ddr_func = DDR_FUNC, |
| 559 | .magic = DRAM_CFG_MAGIC, |
| 560 | .diagnose = CONFIG_DIAGNOSE_DISABLE, |
| 561 | }, |
| 562 | #endif |
| 563 | }; |
| 564 | |
| 565 | pll_set_t __pll_setting = { |
| 566 | .cpu_clk = CONFIG_CPU_CLK / 24 * 24, |
| 567 | #ifdef CONFIG_PXP_EMULATOR |
| 568 | .pxp = 1, |
| 569 | #else |
| 570 | .pxp = 0, |
| 571 | #endif |
| 572 | .spi_ctrl = 0, |
| 573 | .lCustomerID = CONFIG_AML_CUSTOMER_ID, |
| 574 | #ifdef CONFIG_DEBUG_MODE |
| 575 | .debug_mode = CONFIG_DEBUG_MODE, |
| 576 | .ddr_clk_debug = CONFIG_DDR_CLK_DEBUG, |
| 577 | .cpu_clk_debug = CONFIG_CPU_CLK_DEBUG, |
| 578 | #endif |
| 579 | }; |
| 580 | |
| 581 | ddr_reg_t __ddr_reg[] = { |
| 582 | /* demo, user defined override register */ |
| 583 | {0xaabbccdd, 0, 0, 0, 0, 0}, |
| 584 | {0x11223344, 0, 0, 0, 0, 0}, |
| 585 | {0, 0, 0, 0, 0, 0}, |
| 586 | }; |
| 587 | |
| 588 | #define VCCK_VAL CONFIG_VCCK_INIT_VOLTAGE |
| 589 | /* |
| 590 | * sm1 ac213 board share BSP code with g12a_u212_v1 |
| 591 | */ |
| 592 | #ifdef CONFIG_SM1_AC213_V1 |
| 593 | #define VDDEE_VAL CONFIG_VDDEE_INIT_VOLTAGE_SM1 |
| 594 | #else |
| 595 | #define VDDEE_VAL CONFIG_VDDEE_INIT_VOLTAGE |
| 596 | #endif |
| 597 | /* VCCK PWM table, SM1 VCCK supports 36 step voltage, g12a vcck supports 30 step voltage */ |
| 598 | #ifdef CONFIG_SM1_AC213_V1 |
| 599 | #if (VCCK_VAL == 700) |
| 600 | #define VCCK_VAL_REG 0x00220000 |
| 601 | #elif (VCCK_VAL == 710) |
| 602 | #define VCCK_VAL_REG 0x00210001 |
| 603 | #elif (VCCK_VAL == 720) |
| 604 | #define VCCK_VAL_REG 0x00200002 |
| 605 | #elif (VCCK_VAL == 730) |
| 606 | #define VCCK_VAL_REG 0x001f0003 |
| 607 | #elif (VCCK_VAL == 740) |
| 608 | #define VCCK_VAL_REG 0x001e0004 |
| 609 | #elif (VCCK_VAL == 750) |
| 610 | #define VCCK_VAL_REG 0x001d0005 |
| 611 | #elif (VCCK_VAL == 760) |
| 612 | #define VCCK_VAL_REG 0x001c0006 |
| 613 | #elif (VCCK_VAL == 770) |
| 614 | #define VCCK_VAL_REG 0x001b0007 |
| 615 | #elif (VCCK_VAL == 780) |
| 616 | #define VCCK_VAL_REG 0x001a0008 |
| 617 | #elif (VCCK_VAL == 790) |
| 618 | #define VCCK_VAL_REG 0x00190009 |
| 619 | #elif (VCCK_VAL == 800) |
| 620 | #define VCCK_VAL_REG 0x0018000a |
| 621 | #elif (VCCK_VAL == 810) |
| 622 | #define VCCK_VAL_REG 0x0017000b |
| 623 | #elif (VCCK_VAL == 820) |
| 624 | #define VCCK_VAL_REG 0x0016000c |
| 625 | #elif (VCCK_VAL == 830) |
| 626 | #define VCCK_VAL_REG 0x0015000d |
| 627 | #elif (VCCK_VAL == 840) |
| 628 | #define VCCK_VAL_REG 0x0014000e |
| 629 | #elif (VCCK_VAL == 850) |
| 630 | #define VCCK_VAL_REG 0x0013000f |
| 631 | #elif (VCCK_VAL == 860) |
| 632 | #define VCCK_VAL_REG 0x00120010 |
| 633 | #elif (VCCK_VAL == 870) |
| 634 | #define VCCK_VAL_REG 0x00110011 |
| 635 | #elif (VCCK_VAL == 880) |
| 636 | #define VCCK_VAL_REG 0x00100012 |
| 637 | #elif (VCCK_VAL == 890) |
| 638 | #define VCCK_VAL_REG 0x000f0013 |
| 639 | #elif (VCCK_VAL == 900) |
| 640 | #define VCCK_VAL_REG 0x000e0014 |
| 641 | #elif (VCCK_VAL == 910) |
| 642 | #define VCCK_VAL_REG 0x000d0015 |
| 643 | #elif (VCCK_VAL == 920) |
| 644 | #define VCCK_VAL_REG 0x000c0016 |
| 645 | #elif (VCCK_VAL == 930) |
| 646 | #define VCCK_VAL_REG 0x000b0017 |
| 647 | #elif (VCCK_VAL == 940) |
| 648 | #define VCCK_VAL_REG 0x000a0018 |
| 649 | #elif (VCCK_VAL == 950) |
| 650 | #define VCCK_VAL_REG 0x00090019 |
| 651 | #elif (VCCK_VAL == 960) |
| 652 | #define VCCK_VAL_REG 0x0008001a |
| 653 | #elif (VCCK_VAL == 970) |
| 654 | #define VCCK_VAL_REG 0x0007001b |
| 655 | #elif (VCCK_VAL == 980) |
| 656 | #define VCCK_VAL_REG 0x0006001c |
| 657 | #elif (VCCK_VAL == 990) |
| 658 | #define VCCK_VAL_REG 0x0005001d |
| 659 | #elif (VCCK_VAL == 1000) |
| 660 | #define VCCK_VAL_REG 0x0004001e |
| 661 | #elif (VCCK_VAL == 1010) |
| 662 | #define VCCK_VAL_REG 0x0003001f |
| 663 | #elif (VCCK_VAL == 1020) |
| 664 | #define VCCK_VAL_REG 0x00020020 |
| 665 | #elif (VCCK_VAL == 1030) |
| 666 | #define VCCK_VAL_REG 0x00010021 |
| 667 | #elif (VCCK_VAL == 1040) |
| 668 | #define VCCK_VAL_REG 0x00000022 |
| 669 | #else |
| 670 | #error "VCCK val out of range\n" |
| 671 | #endif |
| 672 | #else |
| 673 | #if (VCCK_VAL == 730) |
| 674 | #define VCCK_VAL_REG 0x001c0000 |
| 675 | #elif (VCCK_VAL == 740) |
| 676 | #define VCCK_VAL_REG 0x001b0001 |
| 677 | #elif (VCCK_VAL == 750) |
| 678 | #define VCCK_VAL_REG 0x001a0002 |
| 679 | #elif (VCCK_VAL == 760) |
| 680 | #define VCCK_VAL_REG 0x00190003 |
| 681 | #elif (VCCK_VAL == 770) |
| 682 | #define VCCK_VAL_REG 0x00180004 |
| 683 | #elif (VCCK_VAL == 780) |
| 684 | #define VCCK_VAL_REG 0x00170005 |
| 685 | #elif (VCCK_VAL == 790) |
| 686 | #define VCCK_VAL_REG 0x00160006 |
| 687 | #elif (VCCK_VAL == 800) |
| 688 | #define VCCK_VAL_REG 0x00150007 |
| 689 | #elif (VCCK_VAL == 810) |
| 690 | #define VCCK_VAL_REG 0x00140008 |
| 691 | #elif (VCCK_VAL == 820) |
| 692 | #define VCCK_VAL_REG 0x00130009 |
| 693 | #elif (VCCK_VAL == 830) |
| 694 | #define VCCK_VAL_REG 0x0012000a |
| 695 | #elif (VCCK_VAL == 840) |
| 696 | #define VCCK_VAL_REG 0x0011000b |
| 697 | #elif (VCCK_VAL == 850) |
| 698 | #define VCCK_VAL_REG 0x0010000c |
| 699 | #elif (VCCK_VAL == 860) |
| 700 | #define VCCK_VAL_REG 0x000f000d |
| 701 | #elif (VCCK_VAL == 870) |
| 702 | #define VCCK_VAL_REG 0x000e000e |
| 703 | #elif (VCCK_VAL == 880) |
| 704 | #define VCCK_VAL_REG 0x000d000f |
| 705 | #elif (VCCK_VAL == 890) |
| 706 | #define VCCK_VAL_REG 0x000c0010 |
| 707 | #elif (VCCK_VAL == 900) |
| 708 | #define VCCK_VAL_REG 0x000b0011 |
| 709 | #elif (VCCK_VAL == 910) |
| 710 | #define VCCK_VAL_REG 0x000a0012 |
| 711 | #elif (VCCK_VAL == 920) |
| 712 | #define VCCK_VAL_REG 0x00090013 |
| 713 | #elif (VCCK_VAL == 930) |
| 714 | #define VCCK_VAL_REG 0x00080014 |
| 715 | #elif (VCCK_VAL == 940) |
| 716 | #define VCCK_VAL_REG 0x00070015 |
| 717 | #elif (VCCK_VAL == 950) |
| 718 | #define VCCK_VAL_REG 0x00060016 |
| 719 | #elif (VCCK_VAL == 960) |
| 720 | #define VCCK_VAL_REG 0x00050017 |
| 721 | #elif (VCCK_VAL == 970) |
| 722 | #define VCCK_VAL_REG 0x00040018 |
| 723 | #elif (VCCK_VAL == 980) |
| 724 | #define VCCK_VAL_REG 0x00030019 |
| 725 | #elif (VCCK_VAL == 990) |
| 726 | #define VCCK_VAL_REG 0x0002001a |
| 727 | #elif (VCCK_VAL == 1000) |
| 728 | #define VCCK_VAL_REG 0x0001001b |
| 729 | #elif (VCCK_VAL == 1010) |
| 730 | #define VCCK_VAL_REG 0x0000001c |
| 731 | #else |
| 732 | #error "VCCK val out of range\n" |
| 733 | #endif |
| 734 | #endif |
| 735 | |
| 736 | /* VDDEE_VAL_REG0: VDDEE PWM table 0.67v-0.97v*/ |
| 737 | /* VDDEE_VAL_REG1: VDDEE PWM table 0.69v-0.89v*/ |
| 738 | #if (VDDEE_VAL == 800) |
| 739 | #define VDDEE_VAL_REG0 0x0010000c |
| 740 | #define VDDEE_VAL_REG1 0x0008000a |
| 741 | #elif (VDDEE_VAL == 810) |
| 742 | #define VDDEE_VAL_REG0 0x000f000d |
| 743 | #define VDDEE_VAL_REG1 0x0007000b |
| 744 | #elif (VDDEE_VAL == 820) |
| 745 | #define VDDEE_VAL_REG0 0x000e000e |
| 746 | #define VDDEE_VAL_REG1 0x0006000c |
| 747 | #elif (VDDEE_VAL == 830) |
| 748 | #define VDDEE_VAL_REG0 0x000d000f |
| 749 | #define VDDEE_VAL_REG1 0x0005000d |
| 750 | #elif (VDDEE_VAL == 840) |
| 751 | #define VDDEE_VAL_REG0 0x000c0010 |
| 752 | #define VDDEE_VAL_REG1 0x0004000e |
| 753 | #elif (VDDEE_VAL == 850) |
| 754 | #define VDDEE_VAL_REG0 0x000b0011 |
| 755 | #define VDDEE_VAL_REG1 0x0003000f |
| 756 | #elif (VDDEE_VAL == 860) |
| 757 | #define VDDEE_VAL_REG0 0x000a0012 |
| 758 | #define VDDEE_VAL_REG1 0x00020010 |
| 759 | #elif (VDDEE_VAL == 870) |
| 760 | #define VDDEE_VAL_REG0 0x00090013 |
| 761 | #define VDDEE_VAL_REG1 0x00010011 |
| 762 | #elif (VDDEE_VAL == 880) |
| 763 | #define VDDEE_VAL_REG0 0x00080014 |
| 764 | #define VDDEE_VAL_REG1 0x00000012 |
| 765 | #else |
| 766 | #error "VDDEE val out of range\n" |
| 767 | #endif |
| 768 | |
| 769 | /* for PWM use */ |
| 770 | /* PWM driver check http://scgit.amlogic.com:8080/#/c/38093/ */ |
| 771 | #define GPIO_O_EN_N_REG3 ((0xff634400 + (0x19 << 2))) |
| 772 | #define GPIO_O_REG3 ((0xff634400 + (0x1a << 2))) |
| 773 | #define GPIO_I_REG3 ((0xff634400 + (0x1b << 2))) |
| 774 | #define AO_PIN_MUX_REG0 ((0xff800000 + (0x05 << 2))) |
| 775 | #define AO_PIN_MUX_REG1 ((0xff800000 + (0x06 << 2))) |
| 776 | |
| 777 | bl2_reg_t __bl2_reg[] = { |
| 778 | /* demo, user defined override register */ |
| 779 | /* eg: PWM init */ |
| 780 | |
| 781 | /* PWM_AO_D */ |
| 782 | /* VCCK_VAL_REG: check PWM table */ |
| 783 | {AO_PWM_PWM_D, VCCK_VAL_REG, 0xffffffff, 0, BL2_INIT_STAGE_1, 0}, |
| 784 | {AO_PWM_MISC_REG_CD, ((1 << 23) | (1 << 1)), (0x7f << 16), 0, BL2_INIT_STAGE_1, 0}, |
| 785 | {AO_PIN_MUX_REG1, (3 << 20), (0xF << 20), 0, BL2_INIT_STAGE_1, 0}, |
| 786 | |
| 787 | /* set BOOT_9 input */ |
| 788 | //{PAD_PULL_UP_EN_REG0, 1 << 9, 1 << 9, 0, BL2_INIT_STAGE_1, 0}, |
| 789 | |
| 790 | /* PWM_AO_B */ |
| 791 | /* VDDEE init start */ |
| 792 | /* step1: CHK HW */ |
| 793 | {(uint64_t)P_ASSIST_POR_CONFIG, 7, 0, 0, BL2_INIT_STAGE_PWM_CHK_HW, 0}, |
| 794 | |
| 795 | /* step2: match PWM config */ |
| 796 | /* GPIO9[BIT7]=H use PWM_CFG0(0.67v-0.97v), =L use PWM_CFG1(0.69v-0.89v) */ |
| 797 | {0x1, PWM_CFG0, 0, 0, BL2_INIT_STAGE_PWM_CFG_GROUP, 0}, |
| 798 | {0x0, PWM_CFG1, 0, 0, BL2_INIT_STAGE_PWM_CFG_GROUP, 0}, |
| 799 | |
| 800 | /* step3: config PWM */ |
| 801 | /* VDDEE_VAL_REG0: VDDEE PWM table 0.67v-0.97v*/ |
| 802 | {AO_PWM_PWM_B, VDDEE_VAL_REG0, 0xffffffff, 0, BL2_INIT_STAGE_PWM_INIT | PWM_CFG0, 0}, |
| 803 | {AO_PWM_MISC_REG_AB, ((1 << 23) | (1 << 1)), (0x7f << 16), 0, BL2_INIT_STAGE_PWM_INIT | PWM_CFG0, 0}, |
| 804 | {AO_PIN_MUX_REG1, (3 << 16), (0xF << 16), 0, BL2_INIT_STAGE_PWM_INIT | PWM_CFG0, 0}, |
| 805 | /* VDDEE_VAL_REG1: VDDEE PWM table 0.69v-0.89v*/ |
| 806 | {AO_PWM_PWM_B, VDDEE_VAL_REG1, 0xffffffff, 0, BL2_INIT_STAGE_PWM_INIT | PWM_CFG1, 0}, |
| 807 | {AO_PWM_MISC_REG_AB, ((1 << 23) | (1 << 1)), (0x7f << 16), 0, BL2_INIT_STAGE_PWM_INIT | PWM_CFG1, 0}, |
| 808 | {AO_PIN_MUX_REG1, (3 << 16), (0xF << 16), 0, BL2_INIT_STAGE_PWM_INIT | PWM_CFG1, 0}, |
| 809 | /* VDDEE init done */ |
| 810 | /* Enable 5V_EN */ |
| 811 | {GPIO_O_EN_N_REG3, (0 << 8), (1 << 8), 0, BL2_INIT_STAGE_1, 0}, |
| 812 | {GPIO_O_REG3, (1 << 8), 0xffffffff, 0, BL2_INIT_STAGE_1, 0}, |
| 813 | /* Enable VCCK */ |
| 814 | {AO_SEC_REG0, (1 << 0), 0xffffffff, 0, BL2_INIT_STAGE_1, 0}, |
| 815 | {AO_GPIO_O, (1u << 31), 0xffffffff, 0, BL2_INIT_STAGE_1, 0}, |
| 816 | /* Init sys led*/ |
| 817 | {AO_GPIO_O_EN_N, (0 << 11), (1 << 11), 0, BL2_INIT_STAGE_1, 0}, |
| 818 | {AO_GPIO_O, (0 << 11), (1 << 11), 0, BL2_INIT_STAGE_1, 0}, |
| 819 | }; |