remove redundant registers
[sitara-dss-files/am57xx-dss-files.git] / am57xx-ddr.dss
1 /*
2  * Copyright (c) 2018, Texas Instruments Incorporated
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * *  Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  *
12  * *  Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  *
16  * *  Neither the name of Texas Instruments Incorporated nor the names of
17  *    its contributors may be used to endorse or promote products derived
18  *    from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  *
32  */
34 debugSessionDAP = ds.openSession("*","CS_DAP_DebugSS");
35 debugSessionDAP.target.connect();
37 /* Check ID_CODE register (address 0x4AE0C204) to determine which
38    AM57xx variant is being used */
39 try {
40         id_code = debugSessionDAP.memory.readWord(0,0x4AE0C204,false);
41 } catch(ex) {
42         print("\n Trouble reading ID_CODE.\n");
43 }
45 print("ID_CODE = 0x" + d2h(id_code));
47 // Check STD_FUSE_ID_2 register (address 0x4AE0C20C) for package type
48 try {
49         fuse_id_2 = debugSessionDAP.memory.readWord(0,0x4AE0C20C,false);
50 } catch(ex) {
51         print("\n Trouble reading STD_FUSE_ID_2.\n");
52 }
53 pkg_type = (fuse_id_2 & 0x00030000) >> 16;  // FUSE_ID_2[17:16] = pkg_type
55 switch(id_code) {
56         case 0x0B9BC02F:
57                 print("AM571x SR1.0 detected.\n");
58                 device_type = 571;
59                 break;
60         case 0x1B9BC02F:
61                 if(pkg_type == 1) {
62                         print("AM570x SR2.0 detected.\n");
63                         device_type = 570;
64                 } else if(pkg_type == 2) {
65                         print("AM571x SR2.0 detected.\n");
66                         device_type = 571;
67                 } else
68                         print("AM571x/AM570x SR2.0 unrecognized package type\n")
69                 break;
70         case 0x2B9BC02F:
71                 if(pkg_type == 1) {
72                         print("AM570x SR2.1 detected.\n");
73                         device_type = 570;
74                 } else if(pkg_type == 2) {
75                         print("AM571x SR2.1 detected.\n");
76                         device_type = 571;
77                 } else
78                         print("AM571x/AM570x SR2.1 unrecognized package type\n")
79                 break;
80         case 0x0B99002F:
81                 print("AM572x SR1.0 detected.\n");
82                 device_type = 572;
83                 break;
84         case 0x1B99002F:
85                 print("AM572x SR1.1 detected.\n");
86                 device_type = 572;
87                 break;
88         case 0x2B99002F:
89                 print("AM572x SR2.0 detected.\n");
90                 device_type = 572;
91                 break;
92         case 0x0BB5002F:
93                 print("AM574x SR1.0 detected.\n");
94                 device_type = 574;
95                 break;
96         default:
97                 print("Unable to identify which AM57xx variant.\n");
98                 debugSessionDAP.target.disconnect();
99                 throw("Terminating script.\n")
100                 break;
103 //Build a filename that includes date/time
104 var today = new Date();
105 var year4digit = today.getFullYear();
106 var month2digit = ("0" + (today.getMonth()+1)).slice(-2);
107 var day2digit = ("0" + today.getDate()).slice(-2);
108 var hour2digit = ("0" + today.getHours()).slice(-2);
109 var minutes2digit = ("0" + today.getMinutes()).slice(-2);
110 var seconds2digit = ("0" + today.getSeconds()).slice(-2);
111 var filename_date = '_' + year4digit + '-' + month2digit + '-' + day2digit + '_' + hour2digit + minutes2digit + seconds2digit;
112 var userHomeFolder = System.getProperty("user.home");
113 var filename = userHomeFolder + '/Desktop/' + 'am57xx-ddr' + filename_date + '.txt';
115 file = new java.io.FileWriter(filename);
117 if (device_type == 570) {
118         num_emifs = 1;
119 } else if (device_type == 571) {
120         num_emifs = 1;
121 } else if (device_type == 572) {
122         num_emifs = 2;
123 } else if (device_type == 574) {
124         num_emifs = 2;
125 } else {
126         throw("Error -- code shouldn't get here.")
129 // helper function to create 8-digit hex numbers in ascii format
130 function d2h(d) {
131         // bottom half
132         bottom = d & 0xFFFF;
133         bottom_ascii = ("0000" + bottom.toString(16)).slice(-4);
135         // top half
136         top = d >>> 16;  // unsigned right shift - avoids major sign issues...
137         top_ascii = ("0000" + top.toString(16)).slice(-4);
138         return (top_ascii + bottom_ascii);
141 // helper function to create decimal numbers in ascii format
142 function d2d(d) {return ((+d).toString());}
144 var newline = "\n";
146 file.write("********************** DPLL_DDR **********************" + newline + newline);
147 // CTRL_CORE_BOOTSTRAP
148 reg_val = printRegisterValue(debugSessionDAP, "CTRL_CORE_BOOTSTRAP", 0x4A0026C4);
149 speedselect_pins = (reg_val >> 8) & 3;
150 switch (speedselect_pins) {
151         case 0:
152                 file.write("  * Reserved value latched by SYSBOOT[9:8]" + newline);
153                 input_clock = 0;
154                 break;
155         case 1:
156                 file.write("  * SPEEDSELECT = 20 MHz" + newline);
157                 input_clock = 20;
158                 break;
159         case 2:
160                 file.write("  * SPEEDSELECT = 27 MHz" + newline);
161                 input_clock = 27;
162                 break;
163         case 3:
164                 file.write("  * SPEEDSELECT = 19.2 MHz" + newline);
165                 input_clock = 19.2;
166                 break;
169 // CM_CLKSEL_DPLL_DDR
170 reg_val = printRegisterValue(debugSessionDAP, "CM_CLKSEL_DPLL_DDR", 0x4A00521C);
171 dpll_mult = (reg_val >> 8) & 0x7FF;
172 file.write("  * DPLL_MULT = " + d2d(dpll_mult) + " (x" + d2d(dpll_mult) + ")" + newline);
173 dpll_div = reg_val & 0x7F;
174 file.write("  * DPLL_DIV = " + d2d(dpll_div) + " (/" + d2d(dpll_div+1) + ")" + newline);
175 f_dpll_ddr = input_clock*2*dpll_mult/(dpll_div+1);
177 // CM_DIV_M2_DPLL_DDR
178 reg_val = printRegisterValue(debugSessionDAP, "CM_DIV_M2_DPLL_DDR", 0x4A005220);
179 if (reg_val & (1<<9))  // CLKST = 1
180         file.write("  * CLKST = 1: M2 output clock enabled" + newline);
181 else
182         file.write("  * CLKST = 0: M2 output clock disabled" + newline);;
183 div_m2 = reg_val & 0x1F;
184 file.write("  * DIVHS = " + d2d(div_m2) + " (/" + d2d(div_m2) + ")" + newline);
186 // CM_DIV_H11_DPLL_DDR
187 reg_val = printRegisterValue(debugSessionDAP, "CM_DIV_H11_DPLL_DDR", 0x4A005228);
188 if (reg_val & (1<<9))  // CLKST = 1
189         file.write("  * CLKST = 1: H11 output clock enabled" + newline);
190 else
191         file.write("  * CLKST = 0: H11 output clock disabled" + newline);;
192 div_h11 = reg_val & 0x1F;
193 file.write("  * DIVHS = " + d2d(div_h11) + " (/" + d2d(div_h11) + ")" + newline);
195 file.write(newline + "DPLL_DDR Summary" + newline);
196 file.write(" -> F_input = " + d2d(input_clock) + " MHz" + newline);
197 file.write(" -> F_dpll_ddr = " + d2d(f_dpll_ddr) + " MHz" + newline);
198 file.write(" -> CLKOUT_M2 = EMIF_PHY_GCLK = " + f_dpll_ddr / 2 / div_m2 + " MHz" + newline);
199 file.write(" -> CLKOUTX2_H11 = EMIF_DLL_GCLK = " + f_dpll_ddr / div_h11 + " MHz" + newline);
201 file.write(newline);
203 file.write("********************** DMM - LISA **********************" + newline + newline);
204 reg_val = printRegisterValue(debugSessionDAP, "DMM_LISA_MAP_0", 0x4E000040);
205 decodeLisaEntry(reg_val);
206 reg_val = printRegisterValue(debugSessionDAP, "DMM_LISA_MAP_1", 0x4E000044);
207 decodeLisaEntry(reg_val);
208 reg_val = printRegisterValue(debugSessionDAP, "DMM_LISA_MAP_2", 0x4E000048);
209 decodeLisaEntry(reg_val);
210 reg_val = printRegisterValue(debugSessionDAP, "DMM_LISA_MAP_3", 0x4E00004C);
211 decodeLisaEntry(reg_val);
212 file.write(newline);
214 file.write("********************** EMIF1 **********************" + newline + newline);
216 // CTRL_CORE_CONTROL_DDRCACH1_0
217 reg_val = printRegisterValue(debugSessionDAP, "CTRL_CORE_CONTROL_DDRCACH1_0", 0x4A002E30);
218 file.write("ddr1_casn, ddr1_rasn, ddr1_rst, ddr1_wen, ddr1_csn[0], ddr1_cke, ddr1_odt[0]" + newline);
219 InterpretDdrByte(reg_val, 3, 0);
220 file.write("ddr1_a[15:0]" + newline);
221 InterpretDdrByte(reg_val, 2, 0);
222 file.write("ddr1_ba[0], ddr1_ba[1], ddr1_ba[2]" + newline);
223 InterpretDdrByte(reg_val, 1, 0);
224 file.write("ddr1_ck, ddr1_nck" + newline);
225 InterpretDdrByte(reg_val, 0, 1);
226 file.write(newline);
228 // CTRL_CORE_CONTROL_DDRCH1_0
229 reg_val = printRegisterValue(debugSessionDAP, "CTRL_CORE_CONTROL_DDRCH1_0", 0x4A002E38);
230 file.write("ddr1_d[7:0], ddr1_dqm[0]" + newline);
231 InterpretDdrByte(reg_val, 3, 0);
232 file.write("ddr1_dqs[0], ddr1_dqsn[0]" + newline);
233 InterpretDdrByte(reg_val, 2, 1);
234 file.write("ddr1_d[15:8], ddr1_dqm[1]" + newline);
235 InterpretDdrByte(reg_val, 1, 0);
236 file.write("ddr1_dqs[1], ddr1_dqsn[1]" + newline);
237 InterpretDdrByte(reg_val, 0, 1);
238 file.write(newline);
240 // CTRL_CORE_CONTROL_DDRCH1_1
241 reg_val = printRegisterValue(debugSessionDAP, "CTRL_CORE_CONTROL_DDRCH1_1", 0x4A002E3C);
242 file.write("ddr1_d[23:16], ddr1_dqm[2]" + newline);
243 InterpretDdrByte(reg_val, 3, 0);
244 file.write("ddr1_dqs[2], ddr1_dqsn[2]" + newline);
245 InterpretDdrByte(reg_val, 2, 1);
246 file.write("ddr1_d[31:24], ddr1_dqm[3]" + newline);
247 InterpretDdrByte(reg_val, 1, 0);
248 file.write("ddr1_dqs[3], ddr1_dqsn[3]" + newline);
249 InterpretDdrByte(reg_val, 0, 1);
250 file.write(newline);
252 // CTRL_CORE_CONTROL_DDRCH1_2
253 reg_val = printRegisterValue(debugSessionDAP, "CTRL_CORE_CONTROL_DDRCH1_2", 0x4A002E48);
254 file.write("ddr1_ecc_d[7:0], ddr1_dqm_ecc" + newline);
255 InterpretDdrByte(reg_val, 2, 0);
256 file.write("ddr1_dqs_ecc, ddr1_dqsn_ecc" + newline);
257 InterpretDdrByte(reg_val, 1, 1);
258 file.write(newline);
260 // CTRL_CORE_CONTROL_DDRIO_0
261 reg_val = printRegisterValue(debugSessionDAP, "CTRL_CORE_CONTROL_DDRIO_0", 0x4A002E50);
262 file.write("ddr1_d[7:0], ddr1_d[15:8]" + newline);
263 InterpretDdrVref(reg_val, 15);
264 file.write("ddr1_d[23:16], ddr1_d[31:24], ddr1_ecc_d[7:0]" + newline);
265 InterpretDdrVref(reg_val, 10);
266 file.write(newline);
268 // If EMIF1 clock is enabled, print the registers
269 reg_val = debugSessionDAP.memory.readWord(0,0x4A008B30,false);
270 reg_val = reg_val >> 16;  // Check IDLEST (bits 17:16)
271 if (reg_val == 3)
272         file.write("EMIF1 is disabled." + newline);
273 else
274         printEmifRegs(0x4C000000);
276 if (num_emifs == 2)
278         file.write("********************** EMIF2 **********************" + newline + newline);
280         // CTRL_CORE_CONTROL_DDRCACH2_0
281         reg_val = printRegisterValue(debugSessionDAP, "CTRL_CORE_CONTROL_DDRCACH2_0", 0x4A002E34);
282         file.write("ddr2_casn, ddr2_rasn, ddr2_rst, ddr2_wen, ddr2_csn[0], ddr2_cke, ddr2_odt[0]" + newline);
283         InterpretDdrByte(reg_val, 3, 0);
284         file.write("ddr2_a[15:0]" + newline);
285         InterpretDdrByte(reg_val, 2, 0);
286         file.write("ddr2_ba[0], ddr2_ba[1], ddr2_ba[2]" + newline);
287         InterpretDdrByte(reg_val, 1, 0);
288         file.write("ddr2_ck, ddr2_nck" + newline);
289         InterpretDdrByte(reg_val, 0, 1);
290         file.write(newline);
292         // CTRL_CORE_CONTROL_DDRCH2_0
293         reg_val = printRegisterValue(debugSessionDAP, "CTRL_CORE_CONTROL_DDRCH2_0", 0x4A002E40);
294         file.write("ddr2_d[7:0], ddr2_dqm[0]" + newline);
295         InterpretDdrByte(reg_val, 3, 0);
296         file.write("ddr2_dqs[0], ddr2_dqsn[0]" + newline);
297         InterpretDdrByte(reg_val, 2, 1);
298         file.write("ddr2_d[15:8], ddr2_dqm[1]" + newline);
299         InterpretDdrByte(reg_val, 1, 0);
300         file.write("ddr2_dqs[1], ddr2_dqsn[1]" + newline);
301         InterpretDdrByte(reg_val, 0, 1);
302         file.write(newline);
304         // CTRL_CORE_CONTROL_DDRCH2_1
305         reg_val = printRegisterValue(debugSessionDAP, "CTRL_CORE_CONTROL_DDRCH2_1", 0x4A002E44);
306         file.write("ddr2_d[23:16], ddr2_dqm[2]" + newline);
307         InterpretDdrByte(reg_val, 3, 0);
308         file.write("ddr2_dqs[2], ddr2_dqsn[2]" + newline);
309         InterpretDdrByte(reg_val, 2, 1);
310         file.write("ddr2_d[31:24], ddr2_dqm[3]" + newline);
311         InterpretDdrByte(reg_val, 1, 0);
312         file.write("ddr2_dqs[3], ddr2_dqsn[3]" + newline);
313         InterpretDdrByte(reg_val, 0, 1);
314         file.write(newline);
316         // CTRL_CORE_CONTROL_DDRIO_1
317         reg_val = printRegisterValue(debugSessionDAP, "CTRL_CORE_CONTROL_DDRIO_1", 0x4A002E54);
318         file.write("ddr2_d[7:0], ddr2_d[15:8]" + newline);
319         InterpretDdrVref(reg_val, 22);
320         file.write("ddr2_d[23:16], ddr2_d[31:24]" + newline);
321         InterpretDdrVref(reg_val, 17);
322         file.write(newline);
324         // If EMIF2 clock is enabled, print the registers
325         reg_val = debugSessionDAP.memory.readWord(0,0x4A008B38,false);
326         reg_val = reg_val >> 16;  // Check IDLEST (bits 17:16)
327         if (reg_val == 3)
328                 file.write("EMIF2 is disabled." + newline);
329         else
330                 printEmifRegs(0x4D000000);
334 print("Data collection complete.");
336 file.close();
337 debugSessionDAP.target.disconnect();
338 print("Created file " + filename);
340 /* value is the contents read from the register
341    byte should be 0-3 where 0 is LSB and 3 is MSB
342 */
343 function InterpretDdrByte(value, byte_num, is_differential)
345         value = value >> (8*byte_num);
346         value = value & 0xFF;
348         weak_driver = value & 3;                // Bits 1:0
349         slew_rate = (value >> 2) & 7;   // Bits 4:2
350         impedance = (value >> 5) & 7;   // Bits 7:5
352         if(is_differential)
353         {
354                 switch (weak_driver) {
355                         case 0:
356                                 file.write("  * Pull logic is disabled" + newline);
357                                 break;
358                         case 1:
359                                 file.write("  * Pull-up selected for padp, pull-down selected for padn" + newline);
360                                 break;
361                         case 2:
362                                 file.write("  * Pull-down selected for padp, pull-up selected for padn" + newline);
363                                 break;
364                         case 3:
365                                 file.write("  * Maintain the previous output value" + newline);
366                                 break;
367                 }
368         } else
369         {
370                 switch (weak_driver) {
371                         case 0:
372                                 file.write("  * Pull logic is disabled" + newline);
373                                 break;
374                         case 1:
375                                 file.write("  * Pull-up selected" + newline);
376                                 break;
377                         case 2:
378                                 file.write("  * Pull-down selected" + newline);
379                                 break;
380                         case 3:
381                                 file.write("  * Maintain the previous output value" + newline);
382                                 break;
383                 }
384         }
385         file.write("  * Slew rate is " + slew_rate + ", where 0=fastest and 7=slowest" + newline);
387                 switch (impedance) {
388                 case 0:
389                         file.write("  * Output Impedance = 80 Ohms" + newline);
390                         break;
391                 case 1:
392                         file.write("  * Output Impedance = 60 Ohms" + newline);
393                         break;
394                 case 2:
395                         file.write("  * Output Impedance = 48 Ohms" + newline);
396                         break;
397                 case 3:
398                         file.write("  * Output Impedance = 40 Ohms" + newline);
399                         break;
400                 case 4:
401                         file.write("  * Output Impedance = 34 Ohms" + newline);
402                         break;
403                 default:
404                         file.write("  * Output Impedance = Reserved" + newline);
405                         break;
406         }
409 function InterpretDdrVref(value, start_bit)
411         value = value >> start_bit;
412         value = value & 0x1F;
414         if (value & 1)
415         {
416                 file.write("  * Internal VREF enabled" + newline);
417                 if (value & 0x10) file.write("  * Capacitor between Vbias and ground" + newline);
418                 if (value & 0x08) file.write("  * Capacitor between Vbias and vdds_ddr" + newline);
419                 tap0 = (value >> 2) & 1;
420                 tap1 = (value >> 1) & 1;
421                 ddr_tap = (tap1 << 1) | tap0;
423                 switch(ddr_tap) {
424                         case 0:
425                                 file.write("  * 2-uA VREF output drive capability" + newline);
426                                 break;
427                         case 1:
428                                 file.write("  * 4-uA VREF output drive capability" + newline);
429                                 break;
430                         case 2:
431                                 file.write("  * 8-uA VREF output drive capability" + newline);
432                                 break;
433                         case 3:
434                                 file.write("  * 32-uA VREF output drive capability" + newline);
435                                 break;
436                 }
437         }
438         else
439                 file.write("  * Internal VREF disabled" + newline);
442 function printEmifRegs(baseaddr)
444         if (baseaddr == 0x4C000000) {
445                 reg_val = printRegisterValue(debugSessionDAP, "CTRL_WKUP_EMIF1_SDRAM_CONFIG_EXT", 0x4AE0C144);
446                 emif1_en_ecc = bits32(reg_val, 16, 16);
447                 file.write("  * Bit 16: EMIF1_EN_ECC = " + d2d(emif1_en_ecc) + newline);
448                 reg_val = printRegisterValue(debugSessionDAP, "EMIF_ECC_CTRL_REG", 0x4C000110);
449                 reg_ecc_en = bits32(reg_val, 31, 31);
450                 file.write("  * Bit 31: reg_ecc_en = " + d2d(reg_ecc_en) + newline);
451                 reg_ecc_addr_rgn_prot = bits32(reg_val, 30, 30);
452                 if (reg_ecc_addr_rgn_prot==0) {
453                         insideoutside = "outside";
454                 } else {
455                         insideoutside = "inside";
456                 }
457                 file.write("  * Bit 30: reg_ecc_addr_rgn_prot = " + d2d(reg_ecc_addr_rgn_prot) + newline);
458                 reg_ecc_verify_dis = bits32(reg_val, 29, 29);
459                 if (reg_ecc_verify_dis==0) {
460                         file.write("  * Bit 29: reg_ecc_verify_dis = 0, enable ECC verification on reads (normal)" + newline);
461                 } else {
462                         file.write("  * Bit 29: reg_ecc_verify_dis = 1, disable ECC verification on reads (WARNING: NOT EXPECTED)" + newline);
463                 }
464                 reg_rmw_en = bits32(reg_val, 28, 28);
465                 if (reg_rmw_en == 1) {
466                         if (device_type != 574) {
467                                 file.write("  * Bit 28: ERROR, reg_rmw_en only exists on AM574x family" + newline);
468                         }
469                 }
470                 if (reg_ecc_en==1 && reg_rmw_en==0 && device_type==574) {
471                         file.write("  * Bit 28: WARNING, reg_rmw_en is expected to be enabled when using ECC" + newline);
472                 }
473                 if (reg_ecc_en==1 && reg_rmw_en==1 && device_type==574) {
474                         file.write("  * Bit 28: reg_rmw_en=1,  this is the recommended configuration when using ECC" + newline);
475                 }
476                 reg_ecc_addr_rgn_2_en = bits32(reg_val, 1, 1);
477                 file.write("  * Bit 1: reg_ecc_addr_rgn_2_en = " + d2d(reg_ecc_addr_rgn_2_en) + newline);
478                 reg_ecc_addr_rgn_1_en = bits32(reg_val, 0, 0);
479                 file.write("  * Bit 0: reg_ecc_addr_rgn_1_en = " + d2d(reg_ecc_addr_rgn_1_en) + newline);
480                 reg_val = printRegisterValue(debugSessionDAP, "EMIF_ECC_ADDRESS_RANGE_1", 0x4C000114);
481                 reg_ecc_end_addr_1 = bits32(reg_val, 31, 16);
482                 reg_ecc_strt_addr_1 = bits32(reg_val, 15, 0);
483                 reg_val = printRegisterValue(debugSessionDAP, "EMIF_ECC_ADDRESS_RANGE_2", 0x4C000118);
484                 reg_ecc_end_addr_2 = bits32(reg_val, 31, 16);
485                 reg_ecc_strt_addr_2 = bits32(reg_val, 15, 0);
486                 if (reg_ecc_en==1) {
487                         if (reg_ecc_addr_rgn_1_en==1) {
488                                 file.write("  -> ECC Region 1 is enabled to protect " + insideoutside + " the address range 0x");
489                                 file.write(d2h((reg_ecc_strt_addr_1<<16) + 0x80000000) + " to 0x");
490                                 file.write(d2h((reg_ecc_end_addr_1<<16) + 0x8000FFFF) + newline);
491                         } else {
492                                 file.write("  -> ECC Region 1 is disabled." + newline);
493                         }
494                         if (reg_ecc_addr_rgn_2_en==1) {
495                                 file.write("  -> ECC Region 2 is enabled to protect " + insideoutside + " the address range 0x");
496                                 file.write(d2h((reg_ecc_strt_addr_2<<16) + 0x80000000) + " to 0x");
497                                 file.write(d2h((reg_ecc_end_addr_2<<16) + 0x8000FFFF) + newline);
498                         } else {
499                                 file.write("  -> ECC Region 2 is disabled." + newline);
500                         }
501                 }
502                 printRegisterValue(debugSessionDAP, "EMIF_1B_ECC_ERR_CNT", 0x4C000130);
503                 printRegisterValue(debugSessionDAP, "EMIF_1B_ECC_ERR_THRSH", 0x4C000134);
504                 printRegisterValue(debugSessionDAP, "EMIF_1B_ECC_ERR_DIST_1", 0x4C000138);
505                 printRegisterValue(debugSessionDAP, "EMIF_1B_ECC_ERR_DIST_1", 0x4C00013C);
506                 printRegisterValue(debugSessionDAP, "EMIF_2B_ECC_ERR_ADDR_LOG", 0x4C000140);
507         } else
508                 reg_val = printRegisterValue(debugSessionDAP, "CTRL_WKUP_EMIF2_SDRAM_CONFIG_EXT", 0x4AE0C148);
510         reg_val = printRegisterValue(debugSessionDAP, "EMIF_STATUS", baseaddr + 0x04);
511         file.write(newline);
513         reg_val = printRegisterValue(debugSessionDAP, "EMIF_SDRAM_CONFIG", baseaddr + 0x08);
514         reg_val = printRegisterValue(debugSessionDAP, "EMIF_SDRAM_CONFIG_2", baseaddr + 0x0C);
515         reg_val = printRegisterValue(debugSessionDAP, "EMIF_SDRAM_REFRESH_CONTROL", baseaddr + 0x10);
516         reg_val = printRegisterValue(debugSessionDAP, "EMIF_SDRAM_TIMING_1", baseaddr + 0x18);
517         reg_val = printRegisterValue(debugSessionDAP, "EMIF_SDRAM_TIMING_2", baseaddr + 0x20);
518         reg_val = printRegisterValue(debugSessionDAP, "EMIF_SDRAM_TIMING_3", baseaddr + 0x28);
519         reg_val = printRegisterValue(debugSessionDAP, "EMIF_READ_WRITE_LEVELING_RAMP_WINDOW", baseaddr + 0xD4);
520         reg_val = printRegisterValue(debugSessionDAP, "EMIF_READ_WRITE_LEVELING_RAMP_CONTROL", baseaddr + 0xD8);
521         reg_val = printRegisterValue(debugSessionDAP, "EMIF_READ_WRITE_LEVELING_CONTROL", baseaddr + 0xDC);
522         reg_val = printRegisterValue(debugSessionDAP, "EMIF_DDR_PHY_CONTROL_1", baseaddr + 0xE4);
523         file.write("  * Bits 4:0 READ_LATENCY = " + d2d(reg_val & 0x1F) + newline);
524         file.write("  * Bit 9 PHY_FAST_DLL_LOCK = " + d2d((reg_val >> 9)&1) + newline);
525         file.write("  * Bits 17:10 PHY_DLL_LOCK_DIFF = " + d2d((reg_val >> 10)&0xFF) + newline);
526         file.write("  * Bit 18 PHY_INVERT_CLKOUT = " + d2d((reg_val >> 18)&1) + newline);
527         file.write("  * Bit 19 PHY_DIS_CALIB_RST = " + d2d((reg_val >> 19)&1) + newline);
528         file.write("  * Bit 20 PHY_CLK_STALL_LEVEL = " + d2d((reg_val >> 20)&1) + newline);
529         file.write("  * Bit 21 PHY_HALF_DELAYS = " + d2d((reg_val >> 21)&1) + newline);
530         file.write("  * Bit 25 WRLVL_MASK = " + d2d((reg_val >> 25)&1) + newline);
531         file.write("  * Bit 26 RDLVLGATE_MASK = " + d2d((reg_val >> 26)&1) + newline);
532         file.write("  * Bit 27 RDLVL_MASK = " + d2d((reg_val >> 27)&1) + newline);
533         file.write(newline);
535         reg_val = printRegisterValue(debugSessionDAP, "EMIF_EXT_PHY_CONTROL_1 ", baseaddr + 0x200);
536         reg_val = printRegisterValue(debugSessionDAP, "EMIF_EXT_PHY_CONTROL_2 ", baseaddr + 0x208);
537         reg_val = printRegisterValue(debugSessionDAP, "EMIF_EXT_PHY_CONTROL_3 ", baseaddr + 0x210);
538         reg_val = printRegisterValue(debugSessionDAP, "EMIF_EXT_PHY_CONTROL_4 ", baseaddr + 0x218);
539         reg_val = printRegisterValue(debugSessionDAP, "EMIF_EXT_PHY_CONTROL_5 ", baseaddr + 0x220);
540         reg_val = printRegisterValue(debugSessionDAP, "EMIF_EXT_PHY_CONTROL_6 ", baseaddr + 0x228);
541         reg_val = printRegisterValue(debugSessionDAP, "EMIF_EXT_PHY_CONTROL_7 ", baseaddr + 0x230);
542         reg_val = printRegisterValue(debugSessionDAP, "EMIF_EXT_PHY_CONTROL_8 ", baseaddr + 0x238);
543         reg_val = printRegisterValue(debugSessionDAP, "EMIF_EXT_PHY_CONTROL_9 ", baseaddr + 0x240);
544         reg_val = printRegisterValue(debugSessionDAP, "EMIF_EXT_PHY_CONTROL_10", baseaddr + 0x248);
545         reg_val = printRegisterValue(debugSessionDAP, "EMIF_EXT_PHY_CONTROL_11", baseaddr + 0x250);
546         reg_val = printRegisterValue(debugSessionDAP, "EMIF_EXT_PHY_CONTROL_12", baseaddr + 0x258);
547         reg_val = printRegisterValue(debugSessionDAP, "EMIF_EXT_PHY_CONTROL_13", baseaddr + 0x260);
548         reg_val = printRegisterValue(debugSessionDAP, "EMIF_EXT_PHY_CONTROL_14", baseaddr + 0x268);
549         reg_val = printRegisterValue(debugSessionDAP, "EMIF_EXT_PHY_CONTROL_15", baseaddr + 0x270);
550         reg_val = printRegisterValue(debugSessionDAP, "EMIF_EXT_PHY_CONTROL_16", baseaddr + 0x278);
551         reg_val = printRegisterValue(debugSessionDAP, "EMIF_EXT_PHY_CONTROL_17", baseaddr + 0x280);
552         reg_val = printRegisterValue(debugSessionDAP, "EMIF_EXT_PHY_CONTROL_18", baseaddr + 0x288);
553         reg_val = printRegisterValue(debugSessionDAP, "EMIF_EXT_PHY_CONTROL_19", baseaddr + 0x290);
554         reg_val = printRegisterValue(debugSessionDAP, "EMIF_EXT_PHY_CONTROL_20", baseaddr + 0x298);
555         reg_val = printRegisterValue(debugSessionDAP, "EMIF_EXT_PHY_CONTROL_21", baseaddr + 0x2A0);
556         reg_val = printRegisterValue(debugSessionDAP, "EMIF_EXT_PHY_CONTROL_22", baseaddr + 0x2A8);
557         reg_val = printRegisterValue(debugSessionDAP, "EMIF_EXT_PHY_CONTROL_23", baseaddr + 0x2B0);
558         reg_val = printRegisterValue(debugSessionDAP, "EMIF_EXT_PHY_CONTROL_24", baseaddr + 0x2B8);
559         reg_val = printRegisterValue(debugSessionDAP, "EMIF_EXT_PHY_CONTROL_25", baseaddr + 0x2C0);
560         reg_val = printRegisterValue(debugSessionDAP, "EMIF_EXT_PHY_CONTROL_26", baseaddr + 0x2C8);
561         reg_val = printRegisterValue(debugSessionDAP, "EMIF_EXT_PHY_CONTROL_27", baseaddr + 0x2D0);
562         reg_val = printRegisterValue(debugSessionDAP, "EMIF_EXT_PHY_CONTROL_28", baseaddr + 0x2D8);
563         reg_val = printRegisterValue(debugSessionDAP, "EMIF_EXT_PHY_CONTROL_29", baseaddr + 0x2E0);
564         reg_val = printRegisterValue(debugSessionDAP, "EMIF_EXT_PHY_CONTROL_30", baseaddr + 0x2E8);
565         reg_val = printRegisterValue(debugSessionDAP, "EMIF_EXT_PHY_CONTROL_31", baseaddr + 0x2F0);
566         reg_val = printRegisterValue(debugSessionDAP, "EMIF_EXT_PHY_CONTROL_32", baseaddr + 0x2F8);
567         reg_val = printRegisterValue(debugSessionDAP, "EMIF_EXT_PHY_CONTROL_33", baseaddr + 0x300);
568         reg_val = printRegisterValue(debugSessionDAP, "EMIF_EXT_PHY_CONTROL_34", baseaddr + 0x308);
569         reg_val = printRegisterValue(debugSessionDAP, "EMIF_EXT_PHY_CONTROL_35", baseaddr + 0x310);
570         reg_val = printRegisterValue(debugSessionDAP, "EMIF_EXT_PHY_CONTROL_36", baseaddr + 0x318);
571         file.write(newline);
573         reg_val = printRegisterValue(debugSessionDAP, "EMIF_EXT_PHY_STATUS_1 ", baseaddr + 0x144);
574         reg_val = printRegisterValue(debugSessionDAP, "EMIF_EXT_PHY_STATUS_2 ", baseaddr + 0x148);
575         reg_val = printRegisterValue(debugSessionDAP, "EMIF_EXT_PHY_STATUS_3 ", baseaddr + 0x14C);
576         reg_val = printRegisterValue(debugSessionDAP, "EMIF_EXT_PHY_STATUS_4 ", baseaddr + 0x150);
577         reg_val = printRegisterValue(debugSessionDAP, "EMIF_EXT_PHY_STATUS_5 ", baseaddr + 0x154);
578         reg_val = printRegisterValue(debugSessionDAP, "EMIF_EXT_PHY_STATUS_6 ", baseaddr + 0x158);
579         reg_val = printRegisterValue(debugSessionDAP, "EMIF_EXT_PHY_STATUS_7 ", baseaddr + 0x15C);
580         reg_val = printRegisterValue(debugSessionDAP, "EMIF_EXT_PHY_STATUS_8 ", baseaddr + 0x160);
581         reg_val = printRegisterValue(debugSessionDAP, "EMIF_EXT_PHY_STATUS_9 ", baseaddr + 0x164);
582         reg_val = printRegisterValue(debugSessionDAP, "EMIF_EXT_PHY_STATUS_10", baseaddr + 0x168);
583         reg_val = printRegisterValue(debugSessionDAP, "EMIF_EXT_PHY_STATUS_11", baseaddr + 0x16C);
584         reg_val = printRegisterValue(debugSessionDAP, "EMIF_EXT_PHY_STATUS_12", baseaddr + 0x170);
585         reg_val = printRegisterValue(debugSessionDAP, "EMIF_EXT_PHY_STATUS_13", baseaddr + 0x174);
586         reg_val = printRegisterValue(debugSessionDAP, "EMIF_EXT_PHY_STATUS_14", baseaddr + 0x178);
587         reg_val = printRegisterValue(debugSessionDAP, "EMIF_EXT_PHY_STATUS_15", baseaddr + 0x17C);
588         reg_val = printRegisterValue(debugSessionDAP, "EMIF_EXT_PHY_STATUS_16", baseaddr + 0x180);
589         reg_val = printRegisterValue(debugSessionDAP, "EMIF_EXT_PHY_STATUS_17", baseaddr + 0x184);
590         reg_val = printRegisterValue(debugSessionDAP, "EMIF_EXT_PHY_STATUS_18", baseaddr + 0x188);
591         reg_val = printRegisterValue(debugSessionDAP, "EMIF_EXT_PHY_STATUS_19", baseaddr + 0x19C);
592         reg_val = printRegisterValue(debugSessionDAP, "EMIF_EXT_PHY_STATUS_20", baseaddr + 0x190);
593         reg_val = printRegisterValue(debugSessionDAP, "EMIF_EXT_PHY_STATUS_21", baseaddr + 0x194);
594         reg_val = printRegisterValue(debugSessionDAP, "EMIF_EXT_PHY_STATUS_22", baseaddr + 0x198);
595         reg_val = printRegisterValue(debugSessionDAP, "EMIF_EXT_PHY_STATUS_23", baseaddr + 0x19C);
596         reg_val = printRegisterValue(debugSessionDAP, "EMIF_EXT_PHY_STATUS_24", baseaddr + 0x1A0);
597         reg_val = printRegisterValue(debugSessionDAP, "EMIF_EXT_PHY_STATUS_25", baseaddr + 0x1A4);
598         reg_val = printRegisterValue(debugSessionDAP, "EMIF_EXT_PHY_STATUS_26", baseaddr + 0x1A8);
599         reg_val = printRegisterValue(debugSessionDAP, "EMIF_EXT_PHY_STATUS_27", baseaddr + 0x1AC);
600         reg_val = printRegisterValue(debugSessionDAP, "EMIF_EXT_PHY_STATUS_28", baseaddr + 0x1B0);
601         file.write(newline);
604 function printRegisterValue(ds, name, addr)
606         value = ds.memory.readWord(0,addr,false);
607         value_string = d2h(value);
608         file.write(name + " = 0x" + value_string + newline);
609         return value; // return the register value for interrogation
612 function decodeLisaEntry(lisa_val)
614         // Don't print anything for unmapped entries
615         sdrc_map = (lisa_val >> 8) & 3;
616         if ( sdrc_map == 0 )
617                 return;
619         file.write("  * System Address Mapping = 0x" + d2h(lisa_val & 0xFF000000) + newline);
620         val = (lisa_val >> 20) & 7;
621         sys_size = Math.pow(2,val)*16;
622         file.write("  * Section Size = " + d2d(sys_size) + " MB" + newline);
624         sdrc_intl = (lisa_val >> 18) & 3;
625         if ( sdrc_map == 3 )
626         {
627                 file.write("  * Mapped to EMIF1 and EMIF2: ");
628                 if ( sdrc_intl == 0 ) file.write("Illegal combo of SDRC_INTL and SDRC_MAP");
629                 if ( sdrc_intl == 1 ) file.write("128-byte interleaving");
630                 if ( sdrc_intl == 2 ) file.write("256-byte interleaving");
631                 if ( sdrc_intl == 3 ) file.write("512-byte interleaving");
632                 file.write(newline);
633         }
634         else
635                 file.write("  * Mapped to EMIF" + d2d(sdrc_map) + newline);
638 // Inputs:
639 //   Data - 32-bit register value
640 //   Upper - Highest bit to keep
641 //   Lower - Lowest bit to keep
642 //   (bit 0 refers to LSB, bit 31 to MSB)
643 // Return: right aligned data
644 function bits32(data, upper, lower)
646         data = data >>> lower; // unsigned right-shift
647         upper = upper - lower;
648         bitmask =  0xFFFFFFFF >>> (31 - upper);
649         return (data & bitmask);