]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - sitara-dss-files/am57xx-dss-files.git/blob - am57xx-avs-abb-decode.dss
94732cf9b2d8a73898025c83d5b6bc324e137e23
[sitara-dss-files/am57xx-dss-files.git] / am57xx-avs-abb-decode.dss
1 /*
2  * Copyright (c) 2019, 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  function printRegisterValue(ds, name, addr)
35 {
36         value = ds.memory.readWord(0,addr,false);
37         value_string = d2h(value);
38         file.write(name + " = 0x" + value_string + newline);
39         return value; // return the register value for interrogation
40 }
42 // helper function to create 8-digit hex numbers in ascii format
43 function d2h(d) {
44         // bottom half
45         bottom = d & 0xFFFF;
46         bottom_ascii = ("0000" + bottom.toString(16)).slice(-4);
48         // top half
49         top = d >>> 16;  // unsigned right shift - avoids major sign issues...
50         top_ascii = ("0000" + top.toString(16)).slice(-4);
51         return (top_ascii + bottom_ascii);
52 }
54 // helper function to create decimal numbers in ascii format
55 function d2d(d) {return ((+d).toString());}
57 // Inputs:
58 //   Data - 32-bit register value
59 //   Upper - Highest bit to keep
60 //   Lower - Lowest bit to keep
61 //   (bit 0 refers to LSB, bit 31 to MSB)
62 // Return: right aligned data
63 function bits32(data, upper, lower)
64 {
65         data = data >>> lower; // unsigned right-shift
66         upper = upper - lower;
67         bitmask =  0xFFFFFFFF >>> (31 - upper);
68         return (data & bitmask);
69 }
71 function decode_fuse_opp_vmin_reg(rail, opp, reg_addr) {
72         value = debugSessionDAP.memory.readWord(0,reg_addr,false);
73         voltage = bits32(value, 11, 0);
74         abb_en = bits32(value, 25, 25);
75         vsetabb = bits32(value, 24, 20);
76         file.write(rail + "|" + opp + "|  " + String(d2d(voltage) + " mV         ").slice(0,8) + " |");
77         if (abb_en == 1) {
78                 file.write("    1    |    0x" + vsetabb.toString(16) + "   |" + newline);
79         } else {
80                 file.write("    0    |     -     |" + newline);
81         }
82 }
84 function decode_ldovbb_voltage_ctrl(value) {
85         fbb_mux_ctrl = bits32(value, 10, 10);
86         fbb_vset_in = bits32(value, 9, 5);
87         fbb_vset_out = bits32(value, 4, 0);
88         if (fbb_mux_ctrl == 1) {
89                 file.write(" * override value used -> 0x" + fbb_vset_out.toString(16) + newline);
90         } else {
91                 file.write(" * efuse value used -> 0x" + fbb_vset_in.toString(16) + newline);
92         }
93 }
95 debugSessionDAP = ds.openSession("*","CS_DAP_DebugSS");
96 debugSessionDAP.target.connect();
98 //Build a filename that includes date/time
99 var today = new Date();
100 var year4digit = today.getFullYear();
101 var month2digit = ("0" + (today.getMonth()+1)).slice(-2);
102 var day2digit = ("0" + today.getDate()).slice(-2);
103 var hour2digit = ("0" + today.getHours()).slice(-2);
104 var minutes2digit = ("0" + today.getMinutes()).slice(-2);
105 var seconds2digit = ("0" + today.getSeconds()).slice(-2);
106 var filename_date = '_' + year4digit + '-' + month2digit + '-' + day2digit + '_' + hour2digit + minutes2digit + seconds2digit;
107 var userHomeFolder = System.getProperty("user.home");
108 var filename = userHomeFolder + '/Desktop/' + 'am57xx-avs-abb' + filename_date + '.txt';
110 file = new java.io.FileWriter(filename);
111 var newline = "\n";
113 /* Check ID_CODE register (address 0x4AE0C204) to determine which
114    AM57xx variant is being used */
115 try {
116         id_code = debugSessionDAP.memory.readWord(0,0x4AE0C204,false);
117 } catch(ex) {
118         print("\n Trouble reading ID_CODE.\n");
121 print("ID_CODE = 0x" + d2h(id_code));
123 // Check STD_FUSE_ID_2 register (address 0x4AE0C20C) for package type
124 try {
125         fuse_id_2 = debugSessionDAP.memory.readWord(0,0x4AE0C20C,false);
126 } catch(ex) {
127         print("\n Trouble reading STD_FUSE_ID_2.\n");
129 pkg_type = (fuse_id_2 & 0x00030000) >> 16;  // FUSE_ID_2[17:16] = pkg_type
131 switch(id_code) {
132         case 0x0B9BC02F:
133                 print("AM571x SR1.0 detected.\n");
134                 file.write("AM571x SR1.0 detected" + newline);
135                 device_type = 571;
136                 break;
137         case 0x1B9BC02F:
138                 if(pkg_type == 1) {
139                         print("AM570x SR2.0 detected.\n");
140                         file.write("AM570x SR2.0 detected" + newline);
141                         device_type = 570;
142                 } else if(pkg_type == 2) {
143                         print("AM571x SR2.0 detected.\n");
144                         file.write("AM571x SR2.0 detected" + newline);
145                         device_type = 571;
146                 } else
147                         print("AM571x/AM570x SR2.0 unrecognized package type\n")
148                 break;
149         case 0x2B9BC02F:
150                 if(pkg_type == 1) {
151                         print("AM570x SR2.1 detected.\n");
152                         file.write("AM570x SR2.1 detected" + newline);
153                         device_type = 570;
154                 } else if(pkg_type == 2) {
155                         print("AM571x SR2.1 detected.\n");
156                         file.write("AM571x SR2.1 detected" + newline);
157                         device_type = 571;
158                 } else
159                         print("AM571x/AM570x SR2.1 unrecognized package type\n")
160                 break;
161         case 0x0B99002F:
162                 print("AM572x SR1.0 detected.\n");
163                 file.write("AM572x SR1.0 detected" + newline);
164                 device_type = 572;
165                 break;
166         case 0x1B99002F:
167                 print("AM572x SR1.1 detected.\n");
168                 file.write("AM572x SR1.1 detected" + newline);
169                 device_type = 572;
170                 break;
171         case 0x2B99002F:
172                 print("AM572x SR2.0 detected.\n");
173                 file.write("AM572x SR2.0 detected" + newline);
174                 device_type = 572;
175                 break;
176         case 0x0BB5002F:
177                 print("AM574x SR1.0 detected.\n");
178                 file.write("AM574x SR1.0 detected" + newline);
179                 device_type = 574;
180                 break;
181         default:
182                 print("Unable to identify which AM57xx variant.\n");
183                 debugSessionDAP.target.disconnect();
184                 throw("Terminating script.\n")
185                 break;
187 file.write(newline);
189 if (device_type == 570) {
190         num_emifs = 1;
191 } else if (device_type == 571) {
192         num_emifs = 1;
193 } else if (device_type == 572) {
194         num_emifs = 2;
195 } else if (device_type == 574) {
196         num_emifs = 2;
197 } else {
198         throw("Error -- code shouldn't get here.")
201 // CTRL_WKUP_STD_FUSE_DIE_ID_0
202 reg_val = printRegisterValue(debugSessionDAP, "CTRL_WKUP_STD_FUSE_DIE_ID_0", 0x4AE0C200);
204 // CTRL_WKUP_STD_FUSE_DIE_ID_1
205 reg_val = printRegisterValue(debugSessionDAP, "CTRL_WKUP_STD_FUSE_DIE_ID_1", 0x4AE0C208);
207 // CTRL_WKUP_STD_FUSE_DIE_ID_2
208 reg_val = printRegisterValue(debugSessionDAP, "CTRL_WKUP_STD_FUSE_DIE_ID_2", 0x4AE0C20C);
210 // CTRL_WKUP_STD_FUSE_DIE_ID_3
211 reg_val = printRegisterValue(debugSessionDAP, "CTRL_WKUP_STD_FUSE_DIE_ID_3", 0x4AE0C210);
213 file.write(newline);
214 file.write("-------+--------+-----------+---------+-----------|" + newline);
215 file.write(" Rail  |  OPP   |  Voltage  |   ABB   |  ABB_LDO  |" + newline);
216 file.write("-------+--------+-----------+---------+-----------|" + newline);
217 // CTRL_CORE_STD_FUSE_OPP_VMIN_IVA_2
218 decode_fuse_opp_vmin_reg("  IVA  ", "  NOM   ", 0x4A0025CC);
219 // CTRL_CORE_STD_FUSE_OPP_VMIN_IVA_3
220 decode_fuse_opp_vmin_reg("  IVA  ", "   OD   ", 0x4A0025D0);
221 // CTRL_CORE_STD_FUSE_OPP_VMIN_IVA_4
222 decode_fuse_opp_vmin_reg("  IVA  ", "  HIGH  ", 0x4A0025D4);
223 if (device_type == 574) {
224         // CTRL_CORE_STD_FUSE_OPP_VMIN_IVA_5
225         decode_fuse_opp_vmin_reg("  IVA  ", "  PLUS  ", 0x4A0025C4);
227 file.write("-------+--------+-----------+---------+-----------|" + newline);
228 // CTRL_CORE_STD_FUSE_OPP_VMIN_DSPEVE_2
229 decode_fuse_opp_vmin_reg("  DSP  ", "  NOM   ", 0x4A0025E0);
230 // CTRL_CORE_STD_FUSE_OPP_VMIN_DSPEVE_3
231 decode_fuse_opp_vmin_reg("  DSP  ", "   OD   ", 0x4A0025E4);
232 // CTRL_CORE_STD_FUSE_OPP_VMIN_DSPEVE_4
233 decode_fuse_opp_vmin_reg("  DSP  ", "  HIGH  ", 0x4A0025E8);
234 if (device_type == 574) {
235         // CTRL_CORE_STD_FUSE_OPP_VMIN_DSPEVE_5
236         decode_fuse_opp_vmin_reg("  DSP  ", "  PLUS  ", 0x4A0025D8);
238 file.write("-------+--------+-----------+---------+-----------|" + newline);
239 // CTRL_CORE_STD_FUSE_OPP_VMIN_CORE_2
240 decode_fuse_opp_vmin_reg("  VDD  ", "  NOM   ", 0x4A0025F4);
241 file.write("-------+--------+-----------+---------+-----------|" + newline);
242 // CTRL_CORE_STD_FUSE_OPP_VMIN_GPU_2
243 decode_fuse_opp_vmin_reg("  GPU  ", "  NOM   ", 0x4A003B08);
244 // CTRL_CORE_STD_FUSE_OPP_VMIN_GPU_3
245 decode_fuse_opp_vmin_reg("  GPU  ", "   OD   ", 0x4A003B0C);
246 // CTRL_CORE_STD_FUSE_OPP_VMIN_GPU_4
247 decode_fuse_opp_vmin_reg("  GPU  ", "  HIGH  ", 0x4A003B10);
248 if (device_type == 574) {
249         // CTRL_CORE_STD_FUSE_OPP_VMIN_GPU_5
250         decode_fuse_opp_vmin_reg("  GPU  ", "  PLUS  ", 0x4A003B14);
252 file.write("-------+--------+-----------+---------+-----------|" + newline);
253 if (device_type == 574) {
254         // CTRL_CORE_STD_FUSE_OPP_VMIN_MPU_1
255         decode_fuse_opp_vmin_reg("  MPU  ", "  LOW   ", 0x4A003B1C);
257 // CTRL_CORE_STD_FUSE_OPP_VMIN_MPU_2
258 decode_fuse_opp_vmin_reg("  MPU  ", "  NOM   ", 0x4A003B20);
259 // CTRL_CORE_STD_FUSE_OPP_VMIN_MPU_3
260 decode_fuse_opp_vmin_reg("  MPU  ", "   OD   ", 0x4A003B24);
261 // CTRL_CORE_STD_FUSE_OPP_VMIN_MPU_4
262 decode_fuse_opp_vmin_reg("  MPU  ", "  HIGH  ", 0x4A003B28);
263 if (device_type == 574) {
264         // CTRL_CORE_STD_FUSE_OPP_VMIN_MPU_5
265         decode_fuse_opp_vmin_reg("  MPU  ", "  PLUS  ", 0x4A003B2C);
267 file.write("-------+--------+-----------+---------+-----------|" + newline);
268 file.write(newline);
270 // CTRL_CORE_LDOVBB_IVA_VOLTAGE_CTRL
271 reg_val = printRegisterValue(debugSessionDAP, "CTRL_CORE_LDOVBB_IVA_VOLTAGE_CTRL", 0x4A002470);
272 decode_ldovbb_voltage_ctrl(reg_val);
273 file.write(newline);
275 // CTRL_CORE_LDOVBB_DSPEVE_VOLTAGE_CTRL
276 reg_val = printRegisterValue(debugSessionDAP, "CTRL_CORE_LDOVBB_DSPEVE_VOLTAGE_CTRL", 0x4A00246C);
277 decode_ldovbb_voltage_ctrl(reg_val);
278 file.write(newline);
280 // CTRL_WKUP_LDOVBB_GPU_VOLTAGE_CTRL
281 reg_val = printRegisterValue(debugSessionDAP, "CTRL_WKUP_LDOVBB_GPU_VOLTAGE_CTRL", 0x4AE0C154);
282 decode_ldovbb_voltage_ctrl(reg_val);
283 file.write(newline);
284 // CTRL_WKUP_LDOVBB_MPU_VOLTAGE_CTRL
285 reg_val = printRegisterValue(debugSessionDAP, "CTRL_WKUP_LDOVBB_MPU_VOLTAGE_CTRL", 0x4AE0C158);
286 decode_ldovbb_voltage_ctrl(reg_val);
287 file.write(newline);
289 print("Data collection complete.");
291 file.close();
292 debugSessionDAP.target.disconnect();
293 print("Created file " + filename);