arm64: zynqmp: Modify chip_id routine to get either idcode or version
authorSiva Durga Prasad Paladugu <siva.durga.paladugu@xilinx.com>
Tue, 25 Jul 2017 06:21:36 +0000 (11:51 +0530)
committerMichal Simek <michal.simek@xilinx.com>
Wed, 2 Aug 2017 07:11:52 +0000 (09:11 +0200)
This patch modifies the chip_id routine to get either idcode or
silicon version based on the argument received.

Signed-off-by: Siva Durga Prasad Paladugu <sivadur@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
arch/arm/include/asm/arch-zynqmp/sys_proto.h
board/xilinx/zynqmp/zynqmp.c

index 3d7fad7731151e718bc19aee85c9c2b3cb202f30..cef4bd6bd465c987d6cb121c747d488964524bb6 100644 (file)
 
 #define PAYLOAD_ARG_CNT                5
 
+#define ZYNQMP_CSU_SILICON_VER_MASK    0xF
+
+enum {
+       IDCODE,
+       VERSION,
+};
+
+enum {
+       ZYNQMP_SILICON_V1,
+       ZYNQMP_SILICON_V2,
+       ZYNQMP_SILICON_V3,
+       ZYNQMP_SILICON_V4,
+};
+
 enum {
        TCM_LOCK,
        TCM_SPLIT,
index 5b1852a8cec32f628a03e9a65b3bf2944bcaf513..5958350a0098369bd6d42e2c2fc5b7447e9280da 100644 (file)
@@ -76,13 +76,14 @@ static const struct {
        },
 };
 
-static int chip_id(void)
+static int chip_id(unsigned char id)
 {
        struct pt_regs regs;
        regs.regs[0] = ZYNQMP_SIP_SVC_CSU_DMA_CHIPID;
        regs.regs[1] = 0;
        regs.regs[2] = 0;
        regs.regs[3] = 0;
+       int val = -EINVAL;
 
        smc_call(&regs);
 
@@ -92,19 +93,31 @@ static int chip_id(void)
         * regs[0][63:32] = CSU.IDCODE register
         * regs[1][31:0]  = CSU.version register
         */
-       regs.regs[0] = upper_32_bits(regs.regs[0]);
-       regs.regs[0] &= ZYNQMP_CSU_IDCODE_DEVICE_CODE_MASK |
-                       ZYNQMP_CSU_IDCODE_SVD_MASK;
-       regs.regs[0] >>= ZYNQMP_CSU_IDCODE_SVD_SHIFT;
+       switch (id) {
+       case IDCODE:
+               regs.regs[0] = upper_32_bits(regs.regs[0]);
+               regs.regs[0] &= ZYNQMP_CSU_IDCODE_DEVICE_CODE_MASK |
+                               ZYNQMP_CSU_IDCODE_SVD_MASK;
+               regs.regs[0] >>= ZYNQMP_CSU_IDCODE_SVD_SHIFT;
+               val = regs.regs[0];
+               break;
+       case VERSION:
+               regs.regs[1] = lower_32_bits(regs.regs[1]);
+               regs.regs[1] &= ZYNQMP_CSU_SILICON_VER_MASK;
+               val = regs.regs[1];
+               break;
+       default:
+               printf("%s, Invalid Req:0x%x\n", __func__, id);
+       }
 
-       return regs.regs[0];
+       return val;
 }
 
 static char *zynqmp_get_silicon_idcode_name(void)
 {
        uint32_t i, id;
 
-       id = chip_id();
+       id = chip_id(IDCODE);
        for (i = 0; i < ARRAY_SIZE(zynqmp_devices); i++) {
                if (zynqmp_devices[i].id == id)
                        return zynqmp_devices[i].name;