common: socinfo: Use JTAD_ID register for device identification
authorLokesh Vutla <lokeshvutla@ti.com>
Fri, 17 Apr 2020 09:56:45 +0000 (15:26 +0530)
committerLokesh Vutla <lokeshvutla@ti.com>
Tue, 21 Apr 2020 05:20:37 +0000 (10:50 +0530)
JTAG ID register is defined by IEEE 1149.1 for device identification.
Use this JTAG ID register for identifying AM65x[0] and J721E[1] devices
instead of using SoC specific registers. While at it rename AM654 to
AM65x as specified in TRM.

[0] http://www.ti.com/lit/ug/spruid7e/spruid7e.pdf
[1] http://www.ti.com/lit/ug/spruil1a/spruil1a.pdf

Reported-by: Grygorii Strashko <grygorii.strashko@ti.com>
Signed-off-by: Lokesh Vutla <lokeshvutla@ti.com>
common/socinfo.c
include/socinfo.h

index cad05a52b091da3d5618f82b357b3061af0de747..d20478aef771b044f14bebc9b333bcbd6f85d654 100644 (file)
@@ -68,7 +68,7 @@
 #define JTAG_ID_VARIANT_SHIFT  28
 #define JTAG_ID_VARIANT_MASK   (0xf << 28)
 #define JTAG_ID_PARTNO_SHIFT   12
-#define JTAG_ID_PARTNO_MASK    (0x7ff << 1)
+#define JTAG_ID_PARTNO_MASK    (0xffff << 12)
 
 #define CTRLMMR_WKUP_DIE_ID0   0x43000020
 #define CTRLMMR_WKUP_DIE_ID1   0x43000024
 
 struct k3conf_soc_info soc_info;
 
-static const char soc_name[K3_MAX + 1][SOC_NAME_MAX_LENGTH] = {
-       [AM654] = "AM654",
-       [J721E] = "J721E",
-       [K3_MAX] = "UNKNOWN"
-};
-
 static const char soc_revision[REV_PG_MAX + 1][SOC_REVISION_MAX_LENGTH] = {
        [REV_SR1_0] = "1.0",
        [REV_SR2_0] = "2.0",
@@ -147,33 +141,43 @@ static void j721e_init(void)
 
 int soc_init(uint32_t host_id)
 {
+       char *name;
+
        memset(&soc_info, 0, sizeof(soc_info));
 
-       soc_info.soc = (mmio_read_32(CTRLMMR_WKUP_JTAG_DEVICE_ID) &
-                       DEVICE_ID_FAMILY_MASK) >> DEVICE_ID_FAMILY_SHIFT;
+       soc_info.soc = (mmio_read_32(CTRLMMR_WKUP_JTAG_ID) &
+                       JTAG_ID_PARTNO_MASK) >> JTAG_ID_PARTNO_SHIFT;
        soc_info.rev = (mmio_read_32(CTRLMMR_WKUP_JTAG_ID) &
                        JTAG_ID_VARIANT_MASK) >> JTAG_ID_VARIANT_SHIFT;
 
-       if (soc_info.soc > K3_MAX || !soc_name[soc_info.soc]) {
+       switch (soc_info.soc) {
+       case AM65X:
+               name = "AM65x";
+               break;
+       case J721E:
+               name = "J721E";
+               break;
+       default:
                fprintf(stderr, "Unknown Silicon %d\n", soc_info.soc);
                return -1;
-       }
+       };
+
        if (soc_info.rev > REV_PG_MAX) {
                fprintf(stderr, "Unknown Silicon revision %d for SoC %s\n",
-                       soc_info.rev, soc_name[soc_info.soc]);
+                       soc_info.rev, name);
                return -1;
        }
 
        strncpy(soc_info.soc_full_name, "", sizeof(soc_info.soc_full_name));
-       strcat(soc_info.soc_full_name, soc_name[soc_info.soc]);
+       strcat(soc_info.soc_full_name, name);
        strcat(soc_info.soc_full_name, " SR");
        strcat(soc_info.soc_full_name, soc_revision[soc_info.rev]);
 
        soc_info.host_id = host_id;
 
-       if (soc_info.soc == AM654 && soc_info.rev == REV_SR1_0)
+       if (soc_info.soc == AM65X && soc_info.rev == REV_SR1_0)
                am654_init();
-       else if (soc_info.soc == AM654 && soc_info.rev == REV_SR2_0)
+       else if (soc_info.soc == AM65X && soc_info.rev == REV_SR2_0)
                am654_sr2_init();
        else if (soc_info.soc == J721E)
                j721e_init();
@@ -193,5 +197,5 @@ int soc_is_j721e(void)
 
 int soc_is_am654(void)
 {
-       return soc_info.soc == AM654;
+       return soc_info.soc == AM65X;
 }
index b65e9a95753ebb55db586620ac369566d146c190..da23111433754dbee34a3e8da60e79d74b51266e 100644 (file)
 #define SOC_REVISION_MAX_LENGTH                        5
 #define SOC_FULL_NAME_MAX_LENGTH               20
 
-typedef enum {
-       AM654 = 2,
-       J721E = 4,
-       K3_MAX
-} k3_soc;
+#define AM65X  0xbb5a
+#define J721E  0xbb64
 
 typedef enum {
        REV_SR1_0,
@@ -56,7 +53,7 @@ typedef enum {
 } k3_soc_rev;
 
 struct k3conf_soc_info {
-       k3_soc soc;
+       uint16_t soc;
        k3_soc_rev rev;
        char soc_full_name[SOC_FULL_NAME_MAX_LENGTH];
        uint8_t host_id;