Decoder of registers pertaining to AVS and ABB
authorBrad Griffis <bgriffis@ti.com>
Mon, 5 Aug 2019 20:07:25 +0000 (15:07 -0500)
committerBrad Griffis <bgriffis@ti.com>
Fri, 16 Aug 2019 20:32:45 +0000 (15:32 -0500)
am57xx-avs-abb-decode.dss [new file with mode: 0755]

diff --git a/am57xx-avs-abb-decode.dss b/am57xx-avs-abb-decode.dss
new file mode 100755 (executable)
index 0000000..94732cf
--- /dev/null
@@ -0,0 +1,293 @@
+/*
+ * Copyright (c) 2019, Texas Instruments Incorporated
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * *  Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ * *  Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * *  Neither the name of Texas Instruments Incorporated nor the names of
+ *    its contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+ function printRegisterValue(ds, name, addr)
+{
+       value = ds.memory.readWord(0,addr,false);
+       value_string = d2h(value);
+       file.write(name + " = 0x" + value_string + newline);
+       return value; // return the register value for interrogation
+}
+
+// helper function to create 8-digit hex numbers in ascii format
+function d2h(d) {
+       // bottom half
+       bottom = d & 0xFFFF;
+       bottom_ascii = ("0000" + bottom.toString(16)).slice(-4);
+
+       // top half
+       top = d >>> 16;  // unsigned right shift - avoids major sign issues...
+       top_ascii = ("0000" + top.toString(16)).slice(-4);
+       return (top_ascii + bottom_ascii);
+}
+
+// helper function to create decimal numbers in ascii format
+function d2d(d) {return ((+d).toString());}
+
+// Inputs:
+//   Data - 32-bit register value
+//   Upper - Highest bit to keep
+//   Lower - Lowest bit to keep
+//   (bit 0 refers to LSB, bit 31 to MSB)
+// Return: right aligned data
+function bits32(data, upper, lower)
+{
+       data = data >>> lower; // unsigned right-shift
+       upper = upper - lower;
+       bitmask =  0xFFFFFFFF >>> (31 - upper);
+       return (data & bitmask);
+}
+
+function decode_fuse_opp_vmin_reg(rail, opp, reg_addr) {
+       value = debugSessionDAP.memory.readWord(0,reg_addr,false);
+       voltage = bits32(value, 11, 0);
+       abb_en = bits32(value, 25, 25);
+       vsetabb = bits32(value, 24, 20);
+       file.write(rail + "|" + opp + "|  " + String(d2d(voltage) + " mV         ").slice(0,8) + " |");
+       if (abb_en == 1) {
+               file.write("    1    |    0x" + vsetabb.toString(16) + "   |" + newline);
+       } else {
+               file.write("    0    |     -     |" + newline);
+       }
+}
+
+function decode_ldovbb_voltage_ctrl(value) {
+       fbb_mux_ctrl = bits32(value, 10, 10);
+       fbb_vset_in = bits32(value, 9, 5);
+       fbb_vset_out = bits32(value, 4, 0);
+       if (fbb_mux_ctrl == 1) {
+               file.write(" * override value used -> 0x" + fbb_vset_out.toString(16) + newline);
+       } else {
+               file.write(" * efuse value used -> 0x" + fbb_vset_in.toString(16) + newline);
+       }
+}
+
+debugSessionDAP = ds.openSession("*","CS_DAP_DebugSS");
+debugSessionDAP.target.connect();
+
+//Build a filename that includes date/time
+var today = new Date();
+var year4digit = today.getFullYear();
+var month2digit = ("0" + (today.getMonth()+1)).slice(-2);
+var day2digit = ("0" + today.getDate()).slice(-2);
+var hour2digit = ("0" + today.getHours()).slice(-2);
+var minutes2digit = ("0" + today.getMinutes()).slice(-2);
+var seconds2digit = ("0" + today.getSeconds()).slice(-2);
+var filename_date = '_' + year4digit + '-' + month2digit + '-' + day2digit + '_' + hour2digit + minutes2digit + seconds2digit;
+var userHomeFolder = System.getProperty("user.home");
+var filename = userHomeFolder + '/Desktop/' + 'am57xx-avs-abb' + filename_date + '.txt';
+
+file = new java.io.FileWriter(filename);
+var newline = "\n";
+
+/* Check ID_CODE register (address 0x4AE0C204) to determine which
+   AM57xx variant is being used */
+try {
+       id_code = debugSessionDAP.memory.readWord(0,0x4AE0C204,false);
+} catch(ex) {
+       print("\n Trouble reading ID_CODE.\n");
+}
+
+print("ID_CODE = 0x" + d2h(id_code));
+
+// Check STD_FUSE_ID_2 register (address 0x4AE0C20C) for package type
+try {
+       fuse_id_2 = debugSessionDAP.memory.readWord(0,0x4AE0C20C,false);
+} catch(ex) {
+       print("\n Trouble reading STD_FUSE_ID_2.\n");
+}
+pkg_type = (fuse_id_2 & 0x00030000) >> 16;  // FUSE_ID_2[17:16] = pkg_type
+
+switch(id_code) {
+       case 0x0B9BC02F:
+               print("AM571x SR1.0 detected.\n");
+               file.write("AM571x SR1.0 detected" + newline);
+               device_type = 571;
+               break;
+       case 0x1B9BC02F:
+               if(pkg_type == 1) {
+                       print("AM570x SR2.0 detected.\n");
+                       file.write("AM570x SR2.0 detected" + newline);
+                       device_type = 570;
+               } else if(pkg_type == 2) {
+                       print("AM571x SR2.0 detected.\n");
+                       file.write("AM571x SR2.0 detected" + newline);
+                       device_type = 571;
+               } else
+                       print("AM571x/AM570x SR2.0 unrecognized package type\n")
+               break;
+       case 0x2B9BC02F:
+               if(pkg_type == 1) {
+                       print("AM570x SR2.1 detected.\n");
+                       file.write("AM570x SR2.1 detected" + newline);
+                       device_type = 570;
+               } else if(pkg_type == 2) {
+                       print("AM571x SR2.1 detected.\n");
+                       file.write("AM571x SR2.1 detected" + newline);
+                       device_type = 571;
+               } else
+                       print("AM571x/AM570x SR2.1 unrecognized package type\n")
+               break;
+       case 0x0B99002F:
+               print("AM572x SR1.0 detected.\n");
+               file.write("AM572x SR1.0 detected" + newline);
+               device_type = 572;
+               break;
+       case 0x1B99002F:
+               print("AM572x SR1.1 detected.\n");
+               file.write("AM572x SR1.1 detected" + newline);
+               device_type = 572;
+               break;
+       case 0x2B99002F:
+               print("AM572x SR2.0 detected.\n");
+               file.write("AM572x SR2.0 detected" + newline);
+               device_type = 572;
+               break;
+       case 0x0BB5002F:
+               print("AM574x SR1.0 detected.\n");
+               file.write("AM574x SR1.0 detected" + newline);
+               device_type = 574;
+               break;
+       default:
+               print("Unable to identify which AM57xx variant.\n");
+               debugSessionDAP.target.disconnect();
+               throw("Terminating script.\n")
+               break;
+}
+file.write(newline);
+
+if (device_type == 570) {
+       num_emifs = 1;
+} else if (device_type == 571) {
+       num_emifs = 1;
+} else if (device_type == 572) {
+       num_emifs = 2;
+} else if (device_type == 574) {
+       num_emifs = 2;
+} else {
+       throw("Error -- code shouldn't get here.")
+}
+
+// CTRL_WKUP_STD_FUSE_DIE_ID_0
+reg_val = printRegisterValue(debugSessionDAP, "CTRL_WKUP_STD_FUSE_DIE_ID_0", 0x4AE0C200);
+
+// CTRL_WKUP_STD_FUSE_DIE_ID_1
+reg_val = printRegisterValue(debugSessionDAP, "CTRL_WKUP_STD_FUSE_DIE_ID_1", 0x4AE0C208);
+
+// CTRL_WKUP_STD_FUSE_DIE_ID_2
+reg_val = printRegisterValue(debugSessionDAP, "CTRL_WKUP_STD_FUSE_DIE_ID_2", 0x4AE0C20C);
+
+// CTRL_WKUP_STD_FUSE_DIE_ID_3
+reg_val = printRegisterValue(debugSessionDAP, "CTRL_WKUP_STD_FUSE_DIE_ID_3", 0x4AE0C210);
+
+file.write(newline);
+file.write("-------+--------+-----------+---------+-----------|" + newline);
+file.write(" Rail  |  OPP   |  Voltage  |   ABB   |  ABB_LDO  |" + newline);
+file.write("-------+--------+-----------+---------+-----------|" + newline);
+// CTRL_CORE_STD_FUSE_OPP_VMIN_IVA_2
+decode_fuse_opp_vmin_reg("  IVA  ", "  NOM   ", 0x4A0025CC);
+// CTRL_CORE_STD_FUSE_OPP_VMIN_IVA_3
+decode_fuse_opp_vmin_reg("  IVA  ", "   OD   ", 0x4A0025D0);
+// CTRL_CORE_STD_FUSE_OPP_VMIN_IVA_4
+decode_fuse_opp_vmin_reg("  IVA  ", "  HIGH  ", 0x4A0025D4);
+if (device_type == 574) {
+       // CTRL_CORE_STD_FUSE_OPP_VMIN_IVA_5
+       decode_fuse_opp_vmin_reg("  IVA  ", "  PLUS  ", 0x4A0025C4);
+}
+file.write("-------+--------+-----------+---------+-----------|" + newline);
+// CTRL_CORE_STD_FUSE_OPP_VMIN_DSPEVE_2
+decode_fuse_opp_vmin_reg("  DSP  ", "  NOM   ", 0x4A0025E0);
+// CTRL_CORE_STD_FUSE_OPP_VMIN_DSPEVE_3
+decode_fuse_opp_vmin_reg("  DSP  ", "   OD   ", 0x4A0025E4);
+// CTRL_CORE_STD_FUSE_OPP_VMIN_DSPEVE_4
+decode_fuse_opp_vmin_reg("  DSP  ", "  HIGH  ", 0x4A0025E8);
+if (device_type == 574) {
+       // CTRL_CORE_STD_FUSE_OPP_VMIN_DSPEVE_5
+       decode_fuse_opp_vmin_reg("  DSP  ", "  PLUS  ", 0x4A0025D8);
+}
+file.write("-------+--------+-----------+---------+-----------|" + newline);
+// CTRL_CORE_STD_FUSE_OPP_VMIN_CORE_2
+decode_fuse_opp_vmin_reg("  VDD  ", "  NOM   ", 0x4A0025F4);
+file.write("-------+--------+-----------+---------+-----------|" + newline);
+// CTRL_CORE_STD_FUSE_OPP_VMIN_GPU_2
+decode_fuse_opp_vmin_reg("  GPU  ", "  NOM   ", 0x4A003B08);
+// CTRL_CORE_STD_FUSE_OPP_VMIN_GPU_3
+decode_fuse_opp_vmin_reg("  GPU  ", "   OD   ", 0x4A003B0C);
+// CTRL_CORE_STD_FUSE_OPP_VMIN_GPU_4
+decode_fuse_opp_vmin_reg("  GPU  ", "  HIGH  ", 0x4A003B10);
+if (device_type == 574) {
+       // CTRL_CORE_STD_FUSE_OPP_VMIN_GPU_5
+       decode_fuse_opp_vmin_reg("  GPU  ", "  PLUS  ", 0x4A003B14);
+}
+file.write("-------+--------+-----------+---------+-----------|" + newline);
+if (device_type == 574) {
+       // CTRL_CORE_STD_FUSE_OPP_VMIN_MPU_1
+       decode_fuse_opp_vmin_reg("  MPU  ", "  LOW   ", 0x4A003B1C);
+}
+// CTRL_CORE_STD_FUSE_OPP_VMIN_MPU_2
+decode_fuse_opp_vmin_reg("  MPU  ", "  NOM   ", 0x4A003B20);
+// CTRL_CORE_STD_FUSE_OPP_VMIN_MPU_3
+decode_fuse_opp_vmin_reg("  MPU  ", "   OD   ", 0x4A003B24);
+// CTRL_CORE_STD_FUSE_OPP_VMIN_MPU_4
+decode_fuse_opp_vmin_reg("  MPU  ", "  HIGH  ", 0x4A003B28);
+if (device_type == 574) {
+       // CTRL_CORE_STD_FUSE_OPP_VMIN_MPU_5
+       decode_fuse_opp_vmin_reg("  MPU  ", "  PLUS  ", 0x4A003B2C);
+}
+file.write("-------+--------+-----------+---------+-----------|" + newline);
+file.write(newline);
+
+// CTRL_CORE_LDOVBB_IVA_VOLTAGE_CTRL
+reg_val = printRegisterValue(debugSessionDAP, "CTRL_CORE_LDOVBB_IVA_VOLTAGE_CTRL", 0x4A002470);
+decode_ldovbb_voltage_ctrl(reg_val);
+file.write(newline);
+
+// CTRL_CORE_LDOVBB_DSPEVE_VOLTAGE_CTRL
+reg_val = printRegisterValue(debugSessionDAP, "CTRL_CORE_LDOVBB_DSPEVE_VOLTAGE_CTRL", 0x4A00246C);
+decode_ldovbb_voltage_ctrl(reg_val);
+file.write(newline);
+
+// CTRL_WKUP_LDOVBB_GPU_VOLTAGE_CTRL
+reg_val = printRegisterValue(debugSessionDAP, "CTRL_WKUP_LDOVBB_GPU_VOLTAGE_CTRL", 0x4AE0C154);
+decode_ldovbb_voltage_ctrl(reg_val);
+file.write(newline);
+// CTRL_WKUP_LDOVBB_MPU_VOLTAGE_CTRL
+reg_val = printRegisterValue(debugSessionDAP, "CTRL_WKUP_LDOVBB_MPU_VOLTAGE_CTRL", 0x4AE0C158);
+decode_ldovbb_voltage_ctrl(reg_val);
+file.write(newline);
+
+print("Data collection complete.");
+
+file.close();
+debugSessionDAP.target.disconnect();
+print("Created file " + filename);
\ No newline at end of file