imx: cpu: support speed grade for i.MX8MP
[oweals/u-boot.git] / arch / arm / mach-imx / cpu.c
index 51c7c05f04dac385c1a678e0e3e04e9f7107d4ab..8217913b4a486c0c2b10678ddea38f2e976919e2 100644 (file)
@@ -92,6 +92,8 @@ static char *get_reset_cause(void)
 const char *get_imx_type(u32 imxtype)
 {
        switch (imxtype) {
+       case MXC_CPU_IMX8MP:
+               return "8MP";   /* Quad-core version of the imx8mp */
        case MXC_CPU_IMX8MN:
                return "8MNano";/* Quad-core version of the imx8mn */
        case MXC_CPU_IMX8MM:
@@ -157,7 +159,7 @@ int print_cpuinfo(void)
        int cpu_tmp, minc, maxc, ret;
 
        printf("CPU:   Freescale i.MX%s rev%d.%d",
-              get_imx_type((cpurev & 0xFF000) >> 12),
+              get_imx_type((cpurev & 0x1FF000) >> 12),
               (cpurev & 0x000F0) >> 4,
               (cpurev & 0x0000F) >> 0);
        max_freq = get_cpu_speed_grade_hz();
@@ -169,7 +171,7 @@ int print_cpuinfo(void)
        }
 #else
        printf("CPU:   Freescale i.MX%s rev%d.%d at %d MHz\n",
-               get_imx_type((cpurev & 0xFF000) >> 12),
+               get_imx_type((cpurev & 0x1FF000) >> 12),
                (cpurev & 0x000F0) >> 4,
                (cpurev & 0x0000F) >> 0,
                mxc_get_clock(MXC_ARM_CLK) / 1000000);
@@ -312,6 +314,7 @@ enum cpu_speed {
        OCOTP_TESTER3_SPEED_GRADE1,
        OCOTP_TESTER3_SPEED_GRADE2,
        OCOTP_TESTER3_SPEED_GRADE3,
+       OCOTP_TESTER3_SPEED_GRADE4,
 };
 
 u32 get_cpu_speed_grade_hz(void)
@@ -324,17 +327,28 @@ u32 get_cpu_speed_grade_hz(void)
 
        val = readl(&fuse->tester3);
        val >>= OCOTP_TESTER3_SPEED_SHIFT;
-       val &= 0x3;
+
+       if (is_imx8mn() || is_imx8mp()) {
+               val &= 0xf;
+               return 2300000000 - val * 100000000;
+       }
+
+       if (is_imx8mm())
+               val &= 0x7;
+       else
+               val &= 0x3;
 
        switch(val) {
        case OCOTP_TESTER3_SPEED_GRADE0:
                return 800000000;
        case OCOTP_TESTER3_SPEED_GRADE1:
-               return is_mx7() ? 500000000 : 1000000000;
+               return (is_mx7() ? 500000000 : (is_imx8mq() ? 1000000000 : 1200000000));
        case OCOTP_TESTER3_SPEED_GRADE2:
-               return is_mx7() ? 1000000000 : 1300000000;
+               return (is_mx7() ? 1000000000 : (is_imx8mq() ? 1300000000 : 1600000000));
        case OCOTP_TESTER3_SPEED_GRADE3:
-               return is_mx7() ? 1200000000 : 1500000000;
+               return (is_mx7() ? 1200000000 : (is_imx8mq() ? 1500000000 : 1800000000));
+       case OCOTP_TESTER3_SPEED_GRADE4:
+               return 2000000000;
        }
 
        return 0;