MLK-16752 imx8mq: Add CPU rev get and use it for ROM_SW_INFO address
authorYe Li <ye.li@nxp.com>
Wed, 1 Nov 2017 10:16:31 +0000 (05:16 -0500)
committerJason Liu <jason.hui.liu@nxp.com>
Thu, 2 Nov 2017 18:37:29 +0000 (02:37 +0800)
Implement the get_cpu_rev function by reading the DIGPROG register
to get the CPU ID. Since this register is not updated for B0,
we need also check ROM version. The ROM version address is different
on B0 (0x83c) and A0 (0x800), so have to check both two.

Additional, the address for ROM_SW_INFO is changed on B0, we have to use
the CPU version to determine the address.

Signed-off-by: Ye Li <ye.li@nxp.com>
arch/arm/cpu/armv8/imx8m/soc.c
arch/arm/include/asm/arch-imx/cpu.h
arch/arm/include/asm/arch-imx8m/imx-regs.h

index f1a5fb0..645fb03 100644 (file)
@@ -205,8 +205,25 @@ struct mm_region *mem_map = imx8m_mem_map;
 
 u32 get_cpu_rev(void)
 {
-       /* TODO: */
-       return (MXC_CPU_IMX8MQ << 12) | (1 << 4);
+       u32 reg = readl((void __iomem *)DIGPROG);
+       u32 type = (reg >> 16) & 0xff;
+
+       reg &= 0xff;
+
+       if (reg == 0x10) {
+               /* For B0 chip, the DIGPROG is not updated, still TO1.0.
+                * we have to check ROM version further
+                */
+               uint32_t rom_version;
+               rom_version = readl((void __iomem *)0x800);
+               if (rom_version != 0x10) {
+                       rom_version = readl((void __iomem *)0x83c);
+                       if (rom_version >= 0x20)
+                               reg = 0x20;
+               }
+       }
+
+       return (type << 12) | reg;
 }
 
 void imx_set_wdog_powerdown(bool enable)
@@ -288,6 +305,7 @@ int arch_auxiliary_core_check_up(u32 core_id)
 enum boot_device get_boot_device(void)
 {
        struct bootrom_sw_info **p =
+               is_soc_rev(CHIP_REV_1_0)? (struct bootrom_sw_info **)ROM_SW_INFO_ADDR_A0 :
                (struct bootrom_sw_info **)ROM_SW_INFO_ADDR;
 
        enum boot_device boot_dev = SD1_BOOT;
@@ -337,6 +355,7 @@ __weak int board_mmc_get_env_dev(int devno)
 int mmc_get_env_dev(void)
 {
        struct bootrom_sw_info **p =
+               is_soc_rev(CHIP_REV_1_0)? (struct bootrom_sw_info **)ROM_SW_INFO_ADDR_A0 :
                (struct bootrom_sw_info **)ROM_SW_INFO_ADDR;
        int devno = (*p)->boot_dev_instance;
        u8 boot_type = (*p)->boot_dev_type;
index 510f2aa..594597c 100644 (file)
 #define MXC_CPU_MX7S           0x71 /* dummy ID */
 #define MXC_CPU_MX7D           0x72
 #define MXC_CPU_MX7ULP         0x81 /* Temporally hard code */
+#define MXC_CPU_IMX8MQ         0x82
 #define MXC_CPU_IMX8QM         0x91 /* dummy ID */
 #define MXC_CPU_IMX8QXP                0x92 /* dummy ID */
 #define MXC_CPU_IMX8DX         0x93 /* dummy ID */
-#define MXC_CPU_IMX8MQ         0xA1 /* dummy ID */
 #define MXC_CPU_VF610          0xF6 /* dummy ID */
 
 #define MXC_SOC_MX6            0x60
index 737a0f8..d165116 100644 (file)
@@ -277,7 +277,8 @@ struct wdog_regs {
 #define BOOT_TYPE_SPINOR       0x6
 #define BOOT_TYPE_USB          0xF
 
-#define ROM_SW_INFO_ADDR       0x000009e8
+#define ROM_SW_INFO_ADDR       0x00000968
+#define ROM_SW_INFO_ADDR_A0    0x000009e8
 
 struct bootrom_sw_info {
        u8 reserved_1;