Skip to contentSkip to conversation

imx: fix cpu_type helper

PATCH New Peng Fan 3 participants 30 messages Apr 22, 2020 – Apr 27, 2020

Subsystems (4)
lore
Share & tools
lore

Peng Fan

author
#0 lore raw

PATCH 1/24 imx: fix cpu_type helper

i.MX8MP use 0x182 as its ID, so 0xff is not valid to get the cpu type, extend it to 0x1ff.

---
 arch/arm/include/asm/mach-imx/sys_proto.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/include/asm/mach-imx/sys_proto.h +1 -1
index 35b39b1f86..103dde4d36 100644
@@ -16,7 +16,7 @@
 #define is_soc_rev(rev) (soc_rev() == rev)
 
 /* returns MXC_CPU_ value */
-#define cpu_type(rev) (((rev) >> 12) & 0xff)
+#define cpu_type(rev) (((rev) >> 12) & 0x1ff)
 #define soc_type(rev) (((rev) >> 12) & 0xf0)
 /* both macros return/take MXC_CPU_ constants */
 #define get_cpu_type() (cpu_type(get_cpu_rev()))
Signature · 1 line
2.16.4
author
#1 lore raw

PATCH 2/24 imx8mm: Update CPU speed grading

From: Ye Li <[email protected]>

According to iMX8MM datasheet (IMX8MMIEC_Rev_D and IMX8MMCEC_Rev_D), the speed grading for imx8mm is 800Mhz, 1.2Ghz, 1.6Ghz and 1.8Ghz. Update them to get_cpu_speed_grade_hz function.

---
 arch/arm/mach-imx/cpu.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
arch/arm/mach-imx/cpu.c +3 -3
index bfa85c64c6..55e3539cff 100644
@@ -332,11 +332,11 @@ u32 get_cpu_speed_grade_hz(void)
 	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));
 	}
 
 	return 0;
Signature · 1 line
2.16.4
reviewer
#2 lore raw

PATCH 2/24 imx8mm: Update CPU speed grading

Hi Peng,

Quoted 19 lines · Peng Fan

From: Ye Li <[email protected]>

According to iMX8MM datasheet (IMX8MMIEC_Rev_D and IMX8MMCEC_Rev_D), the speed grading for imx8mm is 800Mhz, 1.2Ghz, 1.6Ghz and 1.8Ghz. Update them to get_cpu_speed_grade_hz function.

---
 arch/arm/mach-imx/cpu.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
arch/arm/mach-imx/cpu.c +0 -0
index bfa85c64c6..55e3539cff 100644
@@ -332,11 +332,11 @@ u32 get_cpu_speed_grade_hz(void)
        case OCOTP_TESTER3_SPEED_GRADE0:

arch/arm/mach-imx/cpu.c u32 get_cpu_speed_grade_hz(void) · line 339

Quoted 10 lines
arch/arm/mach-imx/cpu.c +3 -3
                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));

With new chips being introduced this approach seems to not scale well.

This code is getting hard to follow.

author
#3 lore raw

PATCH 3/24 imx8mn: Update speed grade

In reply to Peng Fan

imx8mn speed grade fuse uses new definitions as below. So have to update get_cpu_speed_grade_hz function to match it.

SPEED_GRADE[5:4]    SPEED_GRADE[3:0]    MHz
      xx                0000            2300
      xx                0001            2200
      xx                0010            2100
      xx                0011            2000
      xx                0100            1900
      xx                0101            1800
      xx                0110            1700
      xx                0111            1600
      xx                1000            1500
      xx                1001            1400
      xx                1010            1300
      xx                1011            1200
      xx                1100            1100
      xx                1101            1000
      xx                1110             900
      xx                1111             800
---
 arch/arm/mach-imx/cpu.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)
arch/arm/mach-imx/cpu.c +13 -1
index 55e3539cff..5b979cc1f5 100644
@@ -314,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)
@@ -326,7 +327,16 @@ u32 get_cpu_speed_grade_hz(void)
 
 	val = readl(&fuse->tester3);
 	val >>= OCOTP_TESTER3_SPEED_SHIFT;
-	val &= 0x3;
+
+	if (is_imx8mn()) {
+		val &= 0xf;
+		return 2300000000 - val * 100000000;
+	}
+
+	if (is_imx8mm())
+		val &= 0x7;
+	else
+		val &= 0x3;
 
 	switch(val) {
 	case OCOTP_TESTER3_SPEED_GRADE0:
@@ -337,6 +347,8 @@ u32 get_cpu_speed_grade_hz(void)
 		return (is_mx7() ? 1000000000 : (is_imx8mq() ? 1300000000 : 1600000000));
 	case OCOTP_TESTER3_SPEED_GRADE3:
 		return (is_mx7() ? 1200000000 : (is_imx8mq() ? 1500000000 : 1800000000));
+	case OCOTP_TESTER3_SPEED_GRADE4:
+		return 2000000000;
 	}
 
 	return 0;
Signature · 1 line
2.16.4
author
#4 lore raw

PATCH 4/24 imx: cpu: support speed grade for i.MX8MP

In reply to Peng Fan

i.MX8MP speed grade use same layout as i.MX8MN, so reuse it for i.MX8MP

---
 arch/arm/mach-imx/cpu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/mach-imx/cpu.c +1 -1
index 5b979cc1f5..8217913b4a 100644
@@ -328,7 +328,7 @@ u32 get_cpu_speed_grade_hz(void)
 	val = readl(&fuse->tester3);
 	val >>= OCOTP_TESTER3_SPEED_SHIFT;
 
-	if (is_imx8mn()) {
+	if (is_imx8mn() || is_imx8mp()) {
 		val &= 0xf;
 		return 2300000000 - val * 100000000;
 	}
Signature · 1 line
2.16.4
author
#5 lore raw

PATCH 5/24 imx: imx8m: add i.MX8MQ Dual and QuadLite support

In reply to Peng Fan

Add i.MX8MQ Dual and QuadLite variants.

---
 arch/arm/include/asm/arch-imx/cpu.h       |  2 ++
 arch/arm/include/asm/mach-imx/sys_proto.h |  4 +++-
 arch/arm/mach-imx/cpu.c                   |  6 +++++-
 arch/arm/mach-imx/imx8m/soc.c             | 10 +++++++++-
 4 files changed, 19 insertions(+), 3 deletions(-)
arch/arm/include/asm/arch-imx/cpu.h +2 -0
index 5ade63665a..71f0715dd1 100644
@@ -26,6 +26,8 @@
 #define MXC_CPU_MX7S		0x71 /* dummy ID */
 #define MXC_CPU_MX7D		0x72
 #define MXC_CPU_IMX8MQ		0x82
+#define MXC_CPU_IMX8MD		0x83 /* dummy ID */
+#define MXC_CPU_IMX8MQL     0x84 /* dummy ID */
 #define MXC_CPU_IMX8MM		0x85 /* dummy ID */
 #define MXC_CPU_IMX8MML		0x86 /* dummy ID */
 #define MXC_CPU_IMX8MMD		0x87 /* dummy ID */
arch/arm/include/asm/mach-imx/sys_proto.h +3 -1
index 103dde4d36..59b145bab1 100644
@@ -43,7 +43,9 @@
 
 #define is_mx7ulp() (is_cpu_type(MXC_CPU_MX7ULP))
 
-#define is_imx8mq() (is_cpu_type(MXC_CPU_IMX8MQ))
+#define is_imx8mq() (is_cpu_type(MXC_CPU_IMX8MQ) || is_cpu_type(MXC_CPU_IMX8MD) || is_cpu_type(MXC_CPU_IMX8MQL))
+#define is_imx8md() (is_cpu_type(MXC_CPU_IMX8MD))
+#define is_imx8mql() (is_cpu_type(MXC_CPU_IMX8MQL))
 #define is_imx8qm() (is_cpu_type(MXC_CPU_IMX8QM))
 #define is_imx8mm() (is_cpu_type(MXC_CPU_IMX8MM) || is_cpu_type(MXC_CPU_IMX8MML) ||\
 	is_cpu_type(MXC_CPU_IMX8MMD) || is_cpu_type(MXC_CPU_IMX8MMDL) || \
arch/arm/mach-imx/cpu.c +5 -1
index 8217913b4a..e07ca5821a 100644
@@ -109,7 +109,11 @@ const char *get_imx_type(u32 imxtype)
 	case MXC_CPU_IMX8MMSL:
 		return "8MMSL";	/* Single-core Lite version of the imx8mm */
 	case MXC_CPU_IMX8MQ:
-		return "8MQ";	/* Quad-core version of the imx8m */
+		return "8MQ";	/* Quad-core version of the imx8mq */
+	case MXC_CPU_IMX8MQL:
+		return "8MQLite";	/* Quad-core Lite version of the imx8mq */
+	case MXC_CPU_IMX8MD:
+		return "8MD";	/* Dual-core version of the imx8mq */
 	case MXC_CPU_MX7S:
 		return "7S";	/* Single-core version of the mx7 */
 	case MXC_CPU_MX7D:
arch/arm/mach-imx/imx8m/soc.c +9 -1
index 7fcbd53f30..c449b8b1ec 100644
@@ -165,7 +165,13 @@ static u32 get_cpu_variant_type(u32 type)
 
 	u32 value = readl(&fuse->tester4);
 
-	if (type == MXC_CPU_IMX8MM) {
+	if (type == MXC_CPU_IMX8MQ) {
+		if ((value & 0x3) == 0x2)
+			return MXC_CPU_IMX8MD;
+		else if (value & 0x200000)
+			return MXC_CPU_IMX8MQL;
+
+	} else if (type == MXC_CPU_IMX8MM) {
 		switch (value & 0x3) {
 		case 2:
 			if (value & 0x1c0000)
@@ -226,6 +232,8 @@ u32 get_cpu_rev(void)
 				}
 			}
 		}
+
+		type = get_cpu_variant_type(type);
 	}
 
 	return (type << 12) | reg;
Signature · 1 line
2.16.4
author
#6 lore raw

PATCH 6/24 imx: imx8m: add i.MX8MN variants support

In reply to Peng Fan

Add i.MX8MN variants support

---
 arch/arm/include/asm/arch-imx/cpu.h       |  5 +++++
 arch/arm/include/asm/mach-imx/sys_proto.h |  9 ++++++++-
 arch/arm/mach-imx/cpu.c                   | 12 +++++++++++-
 arch/arm/mach-imx/imx8m/soc.c             | 19 ++++++++++++++++++-
 4 files changed, 42 insertions(+), 3 deletions(-)
arch/arm/include/asm/arch-imx/cpu.h +5 -0
index 71f0715dd1..b52565473d 100644
@@ -35,6 +35,11 @@
 #define MXC_CPU_IMX8MMS		0x89 /* dummy ID */
 #define MXC_CPU_IMX8MMSL	0x8a /* dummy ID */
 #define MXC_CPU_IMX8MN		0x8b /* dummy ID */
+#define MXC_CPU_IMX8MND		0x8c /* dummy ID */
+#define MXC_CPU_IMX8MNS		0x8d /* dummy ID */
+#define MXC_CPU_IMX8MNL		0x8e /* dummy ID */
+#define MXC_CPU_IMX8MNDL		0x8f /* dummy ID */
+#define MXC_CPU_IMX8MNSL		0x181 /* dummy ID */
 #define MXC_CPU_IMX8MP		0x182/* dummy ID */
 #define MXC_CPU_IMX8QXP_A0	0x90 /* dummy ID */
 #define MXC_CPU_IMX8QM		0x91 /* dummy ID */
arch/arm/include/asm/mach-imx/sys_proto.h +8 -1
index 59b145bab1..a02cd40c7d 100644
@@ -55,7 +55,14 @@
 #define is_imx8mmdl() (is_cpu_type(MXC_CPU_IMX8MMDL))
 #define is_imx8mms() (is_cpu_type(MXC_CPU_IMX8MMS))
 #define is_imx8mmsl() (is_cpu_type(MXC_CPU_IMX8MMSL))
-#define is_imx8mn() (is_cpu_type(MXC_CPU_IMX8MN))
+#define is_imx8mn() (is_cpu_type(MXC_CPU_IMX8MN) || is_cpu_type(MXC_CPU_IMX8MND) || \
+	is_cpu_type(MXC_CPU_IMX8MNS) || is_cpu_type(MXC_CPU_IMX8MNL) || \
+	is_cpu_type(MXC_CPU_IMX8MNDL) || is_cpu_type(MXC_CPU_IMX8MNSL))
+#define is_imx8mnd() (is_cpu_type(MXC_CPU_IMX8MND))
+#define is_imx8mns() (is_cpu_type(MXC_CPU_IMX8MNS))
+#define is_imx8mnl() (is_cpu_type(MXC_CPU_IMX8MNL))
+#define is_imx8mndl() (is_cpu_type(MXC_CPU_IMX8MNDL))
+#define is_imx8mnsl() (is_cpu_type(MXC_CPU_IMX8MNSL))
 #define is_imx8mp() (is_cpu_type(MXC_CPU_IMX8MP))
 
 #define is_imx8qxp() (is_cpu_type(MXC_CPU_IMX8QXP))
arch/arm/mach-imx/cpu.c +11 -1
index e07ca5821a..e83f6934cd 100644
@@ -95,7 +95,17 @@ const char *get_imx_type(u32 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 */
+		return "8MNano Quad"; /* Quad-core version */
+	case MXC_CPU_IMX8MND:
+		return "8MNano Dual"; /* Dual-core version */
+	case MXC_CPU_IMX8MNS:
+		return "8MNano Solo"; /* Single-core version */
+	case MXC_CPU_IMX8MNL:
+		return "8MNano QuadLite"; /* Quad-core Lite version */
+	case MXC_CPU_IMX8MNDL:
+		return "8MNano DualLite"; /* Dual-core Lite version */
+	case MXC_CPU_IMX8MNSL:
+		return "8MNano SoloLite"; /* Single-core Lite version */
 	case MXC_CPU_IMX8MM:
 		return "8MMQ";	/* Quad-core version of the imx8mm */
 	case MXC_CPU_IMX8MML:
arch/arm/mach-imx/imx8m/soc.c +18 -1
index c449b8b1ec..871179509c 100644
@@ -188,6 +188,23 @@ static u32 get_cpu_variant_type(u32 type)
 				return MXC_CPU_IMX8MML;
 			break;
 		}
+	} else if (type == MXC_CPU_IMX8MN) {
+		switch (value & 0x3) {
+		case 2:
+			if (value & 0x1000000)
+				return MXC_CPU_IMX8MNDL;
+			else
+				return MXC_CPU_IMX8MND;
+		case 3:
+			if (value & 0x1000000)
+				return MXC_CPU_IMX8MNSL;
+			else
+				return MXC_CPU_IMX8MNS;
+		default:
+			if (value & 0x1000000)
+				return MXC_CPU_IMX8MNL;
+			break;
+		}
 	}
 
 	return type;
@@ -208,7 +225,7 @@ u32 get_cpu_rev(void)
 		return (MXC_CPU_IMX8MP << 12) | reg;
 	} else if (major_low == 0x42) {
 		/* iMX8MN */
-		return (MXC_CPU_IMX8MN << 12) | reg;
+		type = get_cpu_variant_type(MXC_CPU_IMX8MN);
 	} else if (major_low == 0x41) {
 		type = get_cpu_variant_type(MXC_CPU_IMX8MM);
 	} else {
Signature · 1 line
2.16.4
author
#7 lore raw

PATCH 7/24 imx: update is_imx6ull to include i.MX6ULZ

In reply to Peng Fan

Update is_imx6ull helper to include i.MX6ULZ SoC. i.MX6ULZ could share same macro, then we no need to add is_imx6ulz in various drivers.

---
 arch/arm/include/asm/mach-imx/sys_proto.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/include/asm/mach-imx/sys_proto.h +1 -1
index a02cd40c7d..2a997f280d 100644
@@ -37,7 +37,7 @@
 #define is_mx6sl() (is_cpu_type(MXC_CPU_MX6SL))
 #define is_mx6solo() (is_cpu_type(MXC_CPU_MX6SOLO))
 #define is_mx6ul() (is_cpu_type(MXC_CPU_MX6UL))
-#define is_mx6ull() (is_cpu_type(MXC_CPU_MX6ULL))
+#define is_mx6ull() (is_cpu_type(MXC_CPU_MX6ULL) || is_cpu_type(MXC_CPU_MX6ULZ))
 #define is_mx6ulz() (is_cpu_type(MXC_CPU_MX6ULZ))
 #define is_mx6sll() (is_cpu_type(MXC_CPU_MX6SLL))
 
Signature · 1 line
2.16.4
#8 lore raw

PATCH 7/24 imx: update is_imx6ull to include i.MX6ULZ

Am Mittwoch, 22. April 2020, 15:52:18 CEST schrieb Peng Fan:

Quoted 13 lines

Update is_imx6ull helper to include i.MX6ULZ SoC. i.MX6ULZ could share same macro, then we no need to add is_imx6ulz in various drivers.

---
 arch/arm/include/asm/mach-imx/sys_proto.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/include/asm/mach-imx/sys_proto.h +0 -0
index a02cd40c7d..2a997f280d 100644

arch/arm/include/asm/mach-imx/sys_proto.h line 40

Quoted 5 lines
arch/arm/include/asm/mach-imx/sys_proto.h +1 -1
@@ -37,7 +37,7 @@
 #define is_mx6sl() (is_cpu_type(MXC_CPU_MX6SL))
 #define is_mx6solo() (is_cpu_type(MXC_CPU_MX6SOLO))
 #define is_mx6ul() (is_cpu_type(MXC_CPU_MX6UL))
-#define is_mx6ull() (is_cpu_type(MXC_CPU_MX6ULL))
+#define is_mx6ull() (is_cpu_type(MXC_CPU_MX6ULL) || is_cpu_type(MXC_CPU_MX6ULZ))

While I probably understand your intentions, I fear that it will lead to confusion when the helper's name does not reflect that more than
one cpu type can match.
What about introducing is_mx6ulX() to signal that the last letter is "don't care"?

Best regards,
Michael

Quoted 4 lines
arch/arm/include/asm/mach-imx/sys_proto.h +0 -0
 #define is_mx6ulz() (is_cpu_type(MXC_CPU_MX6ULZ))
 #define is_mx6sll() (is_cpu_type(MXC_CPU_MX6SLL))
 
author
#9 lore raw

PATCH 7/24 imx: update is_imx6ull to include i.MX6ULZ

Quoted 19 lines

Subject: Re: [PATCH 07/24] imx: update is_imx6ull to include i.MX6ULZ

Am Mittwoch, 22. April 2020, 15:52:18 CEST schrieb Peng Fan:

Quoted 14 lines

Update is_imx6ull helper to include i.MX6ULZ SoC. i.MX6ULZ could share same macro, then we no need to add is_imx6ulz in various drivers.

---
 arch/arm/include/asm/mach-imx/sys_proto.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/include/asm/mach-imx/sys_proto.h +0 -0
index a02cd40c7d..2a997f280d 100644

arch/arm/include/asm/mach-imx/sys_proto.h line 37

Quoted 1 line
arch/arm/include/asm/mach-imx/sys_proto.h +0 -0
@@ -37,7 +37,7 @@
 #define is_mx6sl() (is_cpu_type(MXC_CPU_MX6SL))  #define

is_mx6solo()

Quoted 11 lines

arch/arm/include/asm/mach-imx/sys_proto.h line 42

Quoted 5 lines
arch/arm/include/asm/mach-imx/sys_proto.h +2 -0
 (is_cpu_type(MXC_CPU_MX6SOLO))  #define is_mx6ul()
 (is_cpu_type(MXC_CPU_MX6UL)) -#define is_mx6ull()
 (is_cpu_type(MXC_CPU_MX6ULL))
+#define is_mx6ull() (is_cpu_type(MXC_CPU_MX6ULL) ||
+is_cpu_type(MXC_CPU_MX6ULZ))

While I probably understand your intentions, I fear that it will lead to confusion when the helper's name does not reflect that more than one cpu type can match.
What about introducing is_mx6ulX() to signal that the last letter is "don't care"?

Renaming the macro needs to modify drivers using this macro, this is risk to easy break existing code.
I prefer to keep as is.

Thanks,
Peng.

Quoted 11 lines

Best regards,
Michael

Quoted 4 lines
arch/arm/include/asm/mach-imx/sys_proto.h +0 -0
 #define is_mx6ulz() (is_cpu_type(MXC_CPU_MX6ULZ))  #define

is_mx6sll() (is_cpu_type(MXC_CPU_MX6SLL))

#10 lore raw

PATCH 7/24 imx: update is_imx6ull to include i.MX6ULZ

Hi,

Am Donnerstag, 23. April 2020, 03:33:49 CEST schrieb Peng Fan:

Quoted 31 lines
Quoted 19 lines

Subject: Re: [PATCH 07/24] imx: update is_imx6ull to include i.MX6ULZ

Am Mittwoch, 22. April 2020, 15:52:18 CEST schrieb Peng Fan:

Quoted 14 lines

Update is_imx6ull helper to include i.MX6ULZ SoC. i.MX6ULZ could share same macro, then we no need to add is_imx6ulz in various drivers.

---
 arch/arm/include/asm/mach-imx/sys_proto.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/include/asm/mach-imx/sys_proto.h +0 -0
index a02cd40c7d..2a997f280d 100644

arch/arm/include/asm/mach-imx/sys_proto.h line 37

Quoted 1 line
arch/arm/include/asm/mach-imx/sys_proto.h +0 -0
@@ -37,7 +37,7 @@
 #define is_mx6sl() (is_cpu_type(MXC_CPU_MX6SL))  #define

is_mx6solo()

Quoted 11 lines

arch/arm/include/asm/mach-imx/sys_proto.h line 42

Quoted 5 lines
arch/arm/include/asm/mach-imx/sys_proto.h +2 -0
 (is_cpu_type(MXC_CPU_MX6SOLO))  #define is_mx6ul()
 (is_cpu_type(MXC_CPU_MX6UL)) -#define is_mx6ull()
 (is_cpu_type(MXC_CPU_MX6ULL))
+#define is_mx6ull() (is_cpu_type(MXC_CPU_MX6ULL) ||
+is_cpu_type(MXC_CPU_MX6ULZ))

While I probably understand your intentions, I fear that it will lead to confusion when the helper's name does not reflect that more than one cpu type can match.
What about introducing is_mx6ulX() to signal that the last letter is "don't care"?

Quoted 3 lines

Renaming the macro needs to modify drivers using this macro, this is risk to easy break existing code.
I prefer to keep as is.

but when you look at the drivers using this is_mx6ull() macro, then you'll find already a bunch of other is_mx...() macros used in addition. Then it would also be possible to add the is_mx6ulz() one - it won't make the situation worse at these points.
In my eyes, this is better than hiding two CPUs behind one macro.

Thanks,
Michael

Quoted 16 lines

Thanks,
Peng.

Quoted 11 lines

Best regards,
Michael

Quoted 4 lines
arch/arm/include/asm/mach-imx/sys_proto.h +0 -0
 #define is_mx6ulz() (is_cpu_type(MXC_CPU_MX6ULZ))  #define

is_mx6sll() (is_cpu_type(MXC_CPU_MX6SLL))

author
#11 lore raw

PATCH 7/24 imx: update is_imx6ull to include i.MX6ULZ

Quoted 41 lines

Subject: Re: [PATCH 07/24] imx: update is_imx6ull to include i.MX6ULZ

Hi,

Am Donnerstag, 23. April 2020, 03:33:49 CEST schrieb Peng Fan:

Quoted 32 lines
Quoted 20 lines

Subject: Re: [PATCH 07/24] imx: update is_imx6ull to include i.MX6ULZ

Am Mittwoch, 22. April 2020, 15:52:18 CEST schrieb Peng Fan:

Quoted 14 lines

Update is_imx6ull helper to include i.MX6ULZ SoC. i.MX6ULZ could share same macro, then we no need to add is_imx6ulz in various drivers.

---
 arch/arm/include/asm/mach-imx/sys_proto.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/include/asm/mach-imx/sys_proto.h +0 -0
index a02cd40c7d..2a997f280d 100644

arch/arm/include/asm/mach-imx/sys_proto.h line 37

Quoted 1 line
arch/arm/include/asm/mach-imx/sys_proto.h +0 -0
@@ -37,7 +37,7 @@
 #define is_mx6sl() (is_cpu_type(MXC_CPU_MX6SL))  #define

is_mx6solo()

Quoted 11 lines

arch/arm/include/asm/mach-imx/sys_proto.h line 42

Quoted 5 lines
arch/arm/include/asm/mach-imx/sys_proto.h +2 -0
 (is_cpu_type(MXC_CPU_MX6SOLO))  #define is_mx6ul()
 (is_cpu_type(MXC_CPU_MX6UL)) -#define is_mx6ull()
 (is_cpu_type(MXC_CPU_MX6ULL))
+#define is_mx6ull() (is_cpu_type(MXC_CPU_MX6ULL) ||
+is_cpu_type(MXC_CPU_MX6ULZ))

While I probably understand your intentions, I fear that it will lead to confusion when the helper's name does not reflect that more than one cpu type can match.
What about introducing is_mx6ulX() to signal that the last letter is "don't care"?

Quoted 3 lines

Renaming the macro needs to modify drivers using this macro, this is risk to easy break existing code.
I prefer to keep as is.

Quoted 5 lines

but when you look at the drivers using this is_mx6ull() macro, then you'll find already a bunch of other is_mx...() macros used in addition. Then it would also be possible to add the is_mx6ulz() one - it won't make the situation worse at these points.
In my eyes, this is better than hiding two CPUs behind one macro.

That's fine. I'll use ulx in v2.

Thanks,
Peng.

Quoted 23 lines

Thanks,
Michael

Quoted 16 lines

Thanks,
Peng.

Quoted 11 lines

Best regards,
Michael

Quoted 4 lines
arch/arm/include/asm/mach-imx/sys_proto.h +0 -0
 #define is_mx6ulz() (is_cpu_type(MXC_CPU_MX6ULZ))  #define

is_mx6sll() (is_cpu_type(MXC_CPU_MX6SLL))

author
#12 lore raw

PATCH 7/24 imx: update is_imx6ull to include i.MX6ULZ

Quoted 44 lines

Subject: RE: [PATCH 07/24] imx: update is_imx6ull to include i.MX6ULZ

Quoted 11 lines

Subject: Re: [PATCH 07/24] imx: update is_imx6ull to include i.MX6ULZ

Hi,

Am Donnerstag, 23. April 2020, 03:33:49 CEST schrieb Peng Fan:

Quoted 6 lines
Quoted 6 lines

Subject: Re: [PATCH 07/24] imx: update is_imx6ull to include i.MX6ULZ

Am Mittwoch, 22. April 2020, 15:52:18 CEST schrieb Peng Fan:

Quoted 2 lines

Update is_imx6ull helper to include i.MX6ULZ SoC. i.MX6ULZ could share same macro, then we no need to add is_imx6ulz in various

drivers.

Quoted 30 lines
Quoted 29 lines
Quoted 14 lines

arch/arm/include/asm/mach-imx/sys_proto.h line 37

Quoted 13 lines
---
 arch/arm/include/asm/mach-imx/sys_proto.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/include/asm/mach-imx/sys_proto.h +0 -0
index a02cd40c7d..2a997f280d 100644
@@ -37,7 +37,7 @@
 #define is_mx6sl() (is_cpu_type(MXC_CPU_MX6SL))  #define

is_mx6solo()

Quoted 11 lines

arch/arm/include/asm/mach-imx/sys_proto.h line 42

Quoted 5 lines
arch/arm/include/asm/mach-imx/sys_proto.h +2 -0
 (is_cpu_type(MXC_CPU_MX6SOLO))  #define is_mx6ul()
 (is_cpu_type(MXC_CPU_MX6UL)) -#define is_mx6ull()
 (is_cpu_type(MXC_CPU_MX6ULL))
+#define is_mx6ull() (is_cpu_type(MXC_CPU_MX6ULL) ||
+is_cpu_type(MXC_CPU_MX6ULZ))

While I probably understand your intentions, I fear that it will lead to confusion when the helper's name does not reflect that more than one cpu type can match.
What about introducing is_mx6ulX() to signal that the last letter is "don't care"?

Renaming the macro needs to modify drivers using this macro, this is risk to easy break existing code.
I prefer to keep as is.

Quoted 7 lines
Quoted 5 lines

but when you look at the drivers using this is_mx6ull() macro, then you'll find already a bunch of other is_mx...() macros used in addition. Then it would also be possible to add the is_mx6ulz() one - it won't make the situation worse at these points.
In my eyes, this is better than hiding two CPUs behind one macro.

That's fine. I'll use ulx in v2.

After a check, there is lots places to change. I would keep v1.

There will no more ull variants. ull is superset of ulz, only when need to handle ulz specific things, need to use is_mx6ulz.

Thanks,
Peng.

Quoted 27 lines

Thanks,
Peng.

Quoted 23 lines

Thanks,
Michael

Quoted 16 lines

Thanks,
Peng.

Quoted 11 lines

Best regards,
Michael

Quoted 4 lines
arch/arm/include/asm/mach-imx/sys_proto.h +0 -0
 #define is_mx6ulz() (is_cpu_type(MXC_CPU_MX6ULZ))  #define

is_mx6sll() (is_cpu_type(MXC_CPU_MX6SLL))

author
#13 lore raw

PATCH 8/24 imx8: move SIP macro to common header

In reply to Peng Fan

Move the SIP macro to common header and unify the name to make others could reuse them.

---
 arch/arm/mach-imx/imx8/misc.c | 8 +++-----
 include/imx_sip.h             | 5 ++++-
 2 files changed, 7 insertions(+), 6 deletions(-)
arch/arm/mach-imx/imx8/misc.c +3 -5
index 00fe4670bb..76d6571d8b 100644
@@ -2,6 +2,7 @@
 #include <common.h>
 #include <asm/arch/sci/sci.h>
 #include <asm/mach-imx/sys_proto.h>
+#include <imx_sip.h>
 
 int sc_pm_setup_uart(sc_rsrc_t uart_rsrc, sc_pm_clock_rate_t clk_rate)
 {
@@ -26,9 +27,6 @@ int sc_pm_setup_uart(sc_rsrc_t uart_rsrc, sc_pm_clock_rate_t clk_rate)
 	return 0;
 }
 
-#define FSL_SIP_BUILDINFO			0xC2000003
-#define FSL_SIP_BUILDINFO_GET_COMMITHASH	0x00
-
 void build_info(void)
 {
 	u32 seco_build = 0, seco_commit = 0;
@@ -51,8 +49,8 @@ void build_info(void)
 	}
 
 	/* Get ARM Trusted Firmware commit id */
-	atf_commit = call_imx_sip(FSL_SIP_BUILDINFO,
-				  FSL_SIP_BUILDINFO_GET_COMMITHASH, 0, 0, 0);
+	atf_commit = call_imx_sip(IMX_SIP_BUILDINFO,
+				  IMX_SIP_BUILDINFO_GET_COMMITHASH, 0, 0, 0);
 	if (atf_commit == 0xffffffff) {
 		debug("ATF does not support build info\n");
 		atf_commit = 0x30; /* Display 0 */
include/imx_sip.h +4 -1
index 139ff61b8a..26dbe0421a 100644
@@ -7,7 +7,10 @@
 #define _IMX_SIP_H_
 
 #define IMX_SIP_GPC		0xC2000000
-#define  IMX_SIP_GPC_PM_DOMAIN	0x03
+#define IMX_SIP_GPC_PM_DOMAIN	0x03
+
+#define IMX_SIP_BUILDINFO			0xC2000003
+#define IMX_SIP_BUILDINFO_GET_COMMITHASH	0x00
 
 #define IMX_SIP_SRC		0xC2000005
 #define IMX_SIP_SRC_M4_START	0x00
Signature · 1 line
2.16.4
author
#14 lore raw

PATCH 9/24 imx8m: acquire ATF commit hash

In reply to Peng Fan

Acquire ATF commit hash when booting U-Boot to make user easy to know the ATF version.

---
 arch/arm/mach-imx/imx8m/soc.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
arch/arm/mach-imx/imx8m/soc.c +24 -0
index 871179509c..8b6be7bc19 100644
@@ -425,3 +425,27 @@ void reset_cpu(ulong addr)
        }
 }
 #endif
+
+#if defined(CONFIG_ARCH_MISC_INIT)
+static void acquire_buildinfo(void)
+{
+	u64 atf_commit = 0;
+
+	/* Get ARM Trusted Firmware commit id */
+	atf_commit = call_imx_sip(IMX_SIP_BUILDINFO,
+				  IMX_SIP_BUILDINFO_GET_COMMITHASH, 0, 0, 0);
+	if (atf_commit == 0xffffffff) {
+		debug("ATF does not support build info\n");
+		atf_commit = 0x30; /* Display 0, 0 ascii is 0x30 */
+	}
+
+	printf("\n BuildInfo:\n  - ATF %s\n\n", (char *)&atf_commit);
+}
+
+int arch_misc_init(void)
+{
+	acquire_buildinfo();
+
+	return 0;
+}
+#endif
Signature · 1 line
2.16.4
author
#15 lore raw

PATCH 10/24 imx8m: update clock root and fix core_sel

In reply to Peng Fan

Update clock root table to let it be easy to configure clock at very early stage. Also the core_sel mux parent should be A53 CLK root and ARM PLL.

---
 arch/arm/include/asm/arch-imx8m/clock_imx8mm.h |   3 +-
 arch/arm/mach-imx/imx8m/clock_slice.c          | 824 ++++++++++++++++++++++++-
 2 files changed, 809 insertions(+), 18 deletions(-)
arch/arm/include/asm/arch-imx8m/clock_imx8mm.h +2 -1
index debed6bac7..84ed61d21e 100644
@@ -363,7 +363,8 @@ enum clk_root_src {
 	EXT_CLK_2,
 	EXT_CLK_3,
 	EXT_CLK_4,
-	OSC_HDMI_CLK
+	OSC_HDMI_CLK,
+	ARM_A53_ALT_CLK,
 };
 
 enum clk_ccgr_index {
arch/arm/mach-imx/imx8m/clock_slice.c +807 -17

906 lines not on this page · raw message

Signature · 1 line
2.16.4
author
#16 lore raw

PATCH 11/24 imx8mq: Enable eMMC HS400 and SD UHS mode on EVK

In reply to Peng Fan

From: Ye Li <[email protected]>

iMX8MQ EVK board has a eMMC5.0 chip and supports SD3.0, so enable the UHS and HS400 configs to enhance the eMMC/SD access.

The change also needs to set usdhc clock to 400Mhz, and add the off-on-delay-us to SD reset pin, otherwise some SD cards will fail to select UHS mode in re-initialization.

---
 arch/arm/mach-imx/imx8m/clock_imx8mq.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
arch/arm/mach-imx/imx8m/clock_imx8mq.c +2 -4
index aad9cf13ef..76104e4f92 100644
@@ -428,15 +428,13 @@ void init_clk_usdhc(u32 index)
 	case 0:
 		clock_enable(CCGR_USDHC1, 0);
 		clock_set_target_val(USDHC1_CLK_ROOT, CLK_ROOT_ON |
-				     CLK_ROOT_SOURCE_SEL(1) |
-				     CLK_ROOT_POST_DIV(CLK_ROOT_POST_DIV2));
+				     CLK_ROOT_SOURCE_SEL(1));
 		clock_enable(CCGR_USDHC1, 1);
 		return;
 	case 1:
 		clock_enable(CCGR_USDHC2, 0);
 		clock_set_target_val(USDHC2_CLK_ROOT, CLK_ROOT_ON |
-				     CLK_ROOT_SOURCE_SEL(1) |
-				     CLK_ROOT_POST_DIV(CLK_ROOT_POST_DIV2));
+				     CLK_ROOT_SOURCE_SEL(1));
 		clock_enable(CCGR_USDHC2, 1);
 		return;
 	default:
Signature · 1 line
2.16.4
author
#17 lore raw

PATCH 12/24 imx8mq: Set ARM core clock directly from ARM PLL

In reply to Peng Fan

For ARM core clock, there are two input branches, and can select via mux:
one from ARM PLL directly, second from CCM A53 clock root.

Currently we are using second branch. But IC confirmed the CCM A53 root signoff timing is 1Ghz, so we should switch to input from ARM PLL directly.

This patch fixes the CORE SEL slice configuration and switch ARM clock to ARM PLL.

---
 arch/arm/include/asm/arch-imx8m/clock_imx8mq.h |  3 +-
 arch/arm/mach-imx/imx8m/clock_imx8mq.c         | 49 +++++++++++++++++---------
 2 files changed, 35 insertions(+), 17 deletions(-)
arch/arm/include/asm/arch-imx8m/clock_imx8mq.h +2 -1
index 38a6f5966b..9dda6ddc8c 100644
@@ -153,6 +153,7 @@ enum clk_root_src {
 	EXT_CLK_3,
 	EXT_CLK_4,
 	OSC_27M_CLK,
+	ARM_A53_ALT_CLK,
 };
 
 /* CCGR index */
@@ -419,7 +420,7 @@ enum clk_src_index {
 
 enum frac_pll_out_val {
 	FRAC_PLL_OUT_1000M,
-	FRAC_PLL_OUT_1600M,
+	FRAC_PLL_OUT_800M,
 };
 
 void init_nand_clk(void);
arch/arm/mach-imx/imx8m/clock_imx8mq.c +33 -16

96 lines not on this page · raw message

Signature · 1 line
2.16.4
author
#18 lore raw

PATCH 13/24 imx8m: Dump DRAM PLL rate by clocks command

In reply to Peng Fan

From: Ye Li <[email protected]>

Add the dump of DRAM PLL into "clocks" command

---
 arch/arm/mach-imx/imx8m/clock_imx8mq.c | 2 ++
 1 file changed, 2 insertions(+)
arch/arm/mach-imx/imx8m/clock_imx8mq.c +2 -0
index fb85a8d06e..ee18cdee50 100644
@@ -762,6 +762,8 @@ static int do_imx8m_showclocks(cmd_tbl_t *cmdtp, int flag, int argc,
 
 	freq = decode_frac_pll(ARM_PLL_CLK);
 	printf("ARM_PLL    %8d MHz\n", freq / 1000000);
+	freq = decode_sscg_pll(DRAM_PLL1_CLK);
+	printf("DRAM_PLL    %8d MHz\n", freq / 1000000);
 	freq = decode_sscg_pll(SYSTEM_PLL1_800M_CLK);
 	printf("SYS_PLL1_800    %8d MHz\n", freq / 1000000);
 	freq = decode_sscg_pll(SYSTEM_PLL1_400M_CLK);
Signature · 1 line
2.16.4
author
#19 lore raw

PATCH 14/24 imx8: parser: fix 'end address' parameter of rm_find_memreg

In reply to Peng Fan

parameter 'end address' must be inclusive of address range.

Modified from Seb's downstream patch.

---
 arch/arm/mach-imx/imx8/parse-container.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/mach-imx/imx8/parse-container.c +1 -1
index b57e68e412..e192b0c6d2 100644
@@ -29,7 +29,7 @@ static int authenticate_image(struct boot_img_t *img, int image_index)
 	/* Find the memreg and set permission for seco pt */
 	err = sc_rm_find_memreg(-1, &mr,
 				img->dst & ~(CONFIG_SYS_CACHELINE_SIZE - 1),
-				ALIGN(img->dst + img->size, CONFIG_SYS_CACHELINE_SIZE));
+				ALIGN(img->dst + img->size, CONFIG_SYS_CACHELINE_SIZE) - 1);
 
 	if (err) {
 		printf("can't find memreg for image: %d, err %d\n",
Signature · 1 line
2.16.4
author
#20 lore raw

PATCH 15/24 imx8: Change to use new SECO API commands

In reply to Peng Fan

From: Ye Li <[email protected]>

Latest SCFW has removed old MISC SECO commands. So update the codes to use new SECO commands.

---
 arch/arm/mach-imx/imx8/ahab.c            | 6 +++---
 arch/arm/mach-imx/imx8/parse-container.c | 6 +++---
 2 files changed, 6 insertions(+), 6 deletions(-)
arch/arm/mach-imx/imx8/ahab.c +3 -3
index cf3c7d762a..361c578efc 100644
@@ -75,7 +75,7 @@ int authenticate_os_container(ulong addr)
 	memcpy((void *)SEC_SECURE_RAM_BASE, (const void *)addr,
 	       ALIGN(length, CONFIG_SYS_CACHELINE_SIZE));
 
-	err = sc_seco_authenticate(-1, SC_MISC_AUTH_CONTAINER,
+	err = sc_seco_authenticate(-1, SC_SECO_AUTH_CONTAINER,
 				   SECO_LOCAL_SEC_SEC_SECURE_RAM_BASE);
 	if (err) {
 		printf("Authenticate container hdr failed, return %d\n",
@@ -123,7 +123,7 @@ int authenticate_os_container(ulong addr)
 			goto exit;
 		}
 
-		err = sc_seco_authenticate(-1, SC_MISC_VERIFY_IMAGE,
+		err = sc_seco_authenticate(-1, SC_SECO_VERIFY_IMAGE,
 					   (1 << i));
 		if (err) {
 			printf("Authenticate img %d failed, return %d\n",
@@ -144,7 +144,7 @@ int authenticate_os_container(ulong addr)
 	}
 
 exit:
-	if (sc_seco_authenticate(-1, SC_MISC_REL_CONTAINER, 0) != SC_ERR_NONE)
+	if (sc_seco_authenticate(-1, SC_SECO_REL_CONTAINER, 0) != SC_ERR_NONE)
 		printf("Error: release container failed!\n");
 
 	return ret;
arch/arm/mach-imx/imx8/parse-container.c +3 -3
index e192b0c6d2..62e5b45610 100644
@@ -49,7 +49,7 @@ static int authenticate_image(struct boot_img_t *img, int image_index)
 		return -EPERM;
 	}
 
-	err = sc_seco_authenticate(-1, SC_MISC_VERIFY_IMAGE,
+	err = sc_seco_authenticate(-1, SC_SECO_VERIFY_IMAGE,
 				   1 << image_index);
 	if (err) {
 		printf("authenticate img %d failed, return %d\n",
@@ -168,7 +168,7 @@ static int read_auth_container(struct spl_image_info *spl_image,
 	memcpy((void *)SEC_SECURE_RAM_BASE, (const void *)container,
 	       ALIGN(length, CONFIG_SYS_CACHELINE_SIZE));
 
-	ret = sc_seco_authenticate(-1, SC_MISC_AUTH_CONTAINER,
+	ret = sc_seco_authenticate(-1, SC_SECO_AUTH_CONTAINER,
 				   SECO_LOCAL_SEC_SEC_SECURE_RAM_BASE);
 	if (ret) {
 		printf("authenticate container hdr failed, return %d\n", ret);
@@ -194,7 +194,7 @@ static int read_auth_container(struct spl_image_info *spl_image,
 
 end_auth:
 #ifdef CONFIG_AHAB_BOOT
-	if (sc_seco_authenticate(-1, SC_MISC_REL_CONTAINER, 0))
+	if (sc_seco_authenticate(-1, SC_SECO_REL_CONTAINER, 0))
 		printf("Error: release container failed!\n");
 #endif
 	return ret;
Signature · 1 line
2.16.4
author
#21 lore raw

PATCH 16/24 imx8: ahab: fix 'end address' parameter of rm_find_memreg

In reply to Peng Fan

parameter 'end address' must be inclusive of address range.

---
 arch/arm/mach-imx/imx8/ahab.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/mach-imx/imx8/ahab.c +1 -1
index 361c578efc..89544b3dc6 100644
@@ -97,7 +97,7 @@ int authenticate_os_container(ulong addr)
 		       img->size);
 
 		s = img->dst & ~(CONFIG_SYS_CACHELINE_SIZE - 1);
-		e = ALIGN(img->dst + img->size, CONFIG_SYS_CACHELINE_SIZE);
+		e = ALIGN(img->dst + img->size, CONFIG_SYS_CACHELINE_SIZE) - 1;
 
 		flush_dcache_range(s, e);
 
Signature · 1 line
2.16.4
author
#22 lore raw

PATCH 17/24 imx8: ahab: fix some bad debug message formating

In reply to Peng Fan

From: Seb Fagard <[email protected]>

In SPL build, the formatting '%llx' in debug() is not supported. Also, fix some misplaced parameters in printf.

---
 arch/arm/mach-imx/imx8/ahab.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
arch/arm/mach-imx/imx8/ahab.c +3 -4
index 89544b3dc6..6d25abe5ce 100644
@@ -90,8 +90,8 @@ int authenticate_os_container(ulong addr)
 					    sizeof(struct container_hdr) +
 					    i * sizeof(struct boot_img_t));
 
-		debug("img %d, dst 0x%llx, src 0x%lx, size 0x%x\n",
-		      i, img->dst, img->offset + addr, img->size);
+		debug("img %d, dst 0x%x, src 0x%x, size 0x%x\n",
+		      i, (uint32_t) img->dst, img->offset + addr, img->size);
 
 		memcpy((void *)img->dst, (const void *)(img->offset + addr),
 		       img->size);
@@ -104,8 +104,7 @@ int authenticate_os_container(ulong addr)
 		/* Find the memreg and set permission for seco pt */
 		err = sc_rm_find_memreg(-1, &mr, s, e);
 		if (err) {
-			printf("Not found memreg for image: %d, error %d\n",
-			       i, err);
+			printf("Error: can't find memreg for image load address 0x%x, error %d\n", img->dst, err);
 			ret = -ENOMEM;
 			goto exit;
 		}
Signature · 1 line
2.16.4
author
#23 lore raw

PATCH 18/24 imx8: parser: fix some bad debug message formating

In reply to Peng Fan

In SPL build, the formatting '%llx' in debug() is not supported. Also, fix some misplaced parameters in printf.

Modified from Seb Fagard's downstream patch

---
 arch/arm/mach-imx/imx8/parse-container.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
arch/arm/mach-imx/imx8/parse-container.c +5 -5
index 62e5b45610..cc8a51ad55 100644
@@ -23,8 +23,8 @@ static int authenticate_image(struct boot_img_t *img, int image_index)
 	int err;
 	int ret = 0;
 
-	debug("img %d, dst 0x%llx, src 0x%x, size 0x%x\n",
-	      image_index, img->dst, img->offset, img->size);
+	debug("img %d, dst 0x%x, src 0x%x, size 0x%x\n",
+	      image_index, (uint32_t)img->dst, img->offset, img->size);
 
 	/* Find the memreg and set permission for seco pt */
 	err = sc_rm_find_memreg(-1, &mr,
@@ -32,14 +32,14 @@ static int authenticate_image(struct boot_img_t *img, int image_index)
 				ALIGN(img->dst + img->size, CONFIG_SYS_CACHELINE_SIZE) - 1);
 
 	if (err) {
-		printf("can't find memreg for image: %d, err %d\n",
-		       image_index, err);
+		printf("can't find memreg for image %d load address 0x%x, error %d\n",
+		       image_index, img->dst & ~(CONFIG_SYS_CACHELINE_SIZE - 1), err);
 		return -ENOMEM;
 	}
 
 	err = sc_rm_get_memreg_info(-1, mr, &start, &end);
 	if (!err)
-		debug("memreg %u 0x%llx -- 0x%llx\n", mr, start, end);
+		debug("memreg %u 0x%x -- 0x%x\n", mr, start, end);
 
 	err = sc_rm_set_memreg_permissions(-1, mr,
 					   SECO_PT, SC_RM_PERM_FULL);
Signature · 1 line
2.16.4
author
#24 lore raw

PATCH 19/24 imx8mm: clock: fix fracpll decode issue

In reply to Peng Fan

From: Ye Li <[email protected]>

The fracpll decoding is using the bit definitions for int pll. Most of them are same, but the CLKE bit is different. Fix the wrong CLKE_MASK for fracpll and correct all bit definitions in fracpll decoding.

---
 arch/arm/include/asm/arch-imx8m/clock_imx8mm.h |  2 +-
 arch/arm/mach-imx/imx8m/clock_imx8mm.c         | 24 ++++++++++++------------
 2 files changed, 13 insertions(+), 13 deletions(-)
arch/arm/include/asm/arch-imx8m/clock_imx8mm.h +1 -1
index 84ed61d21e..140e8bbabd 100644
@@ -19,7 +19,7 @@
 
 #define LOCK_STATUS	BIT(31)
 #define LOCK_SEL_MASK	BIT(29)
-#define CLKE_MASK	BIT(11)
+#define CLKE_MASK	BIT(13)
 #define RST_MASK	BIT(9)
 #define BYPASS_MASK	BIT(4)
 #define	MDIV_SHIFT	12
arch/arm/mach-imx/imx8m/clock_imx8mm.c +12 -12
index c423ac0058..8c9a6b8b12 100644
@@ -447,34 +447,34 @@ static u32 decode_fracpll(enum clk_root_src frac_pll)
 	}
 
 	/* Only support SYS_XTAL 24M, PAD_CLK not take into consideration */
-	if ((pll_gnrl_ctl & INTPLL_REF_CLK_SEL_MASK) != 0)
+	if ((pll_gnrl_ctl & GENMASK(1, 0)) != 0)
 		return 0;
 
-	if ((pll_gnrl_ctl & INTPLL_RST_MASK) == 0)
+	if ((pll_gnrl_ctl & RST_MASK) == 0)
 		return 0;
 	/*
 	 * When BYPASS is equal to 1, PLL enters the bypass mode
 	 * regardless of the values of RESETB
 	 */
-	if (pll_gnrl_ctl & INTPLL_BYPASS_MASK)
+	if (pll_gnrl_ctl & BYPASS_MASK)
 		return 24000000u;
 
-	if (!(pll_gnrl_ctl & INTPLL_LOCK_MASK)) {
+	if (!(pll_gnrl_ctl & LOCK_STATUS)) {
 		puts("pll not locked\n");
 		return 0;
 	}
 
-	if (!(pll_gnrl_ctl & INTPLL_CLKE_MASK))
+	if (!(pll_gnrl_ctl & CLKE_MASK))
 		return 0;
 
-	main_div = (pll_fdiv_ctl0 & INTPLL_MAIN_DIV_MASK) >>
-		INTPLL_MAIN_DIV_SHIFT;
-	pre_div = (pll_fdiv_ctl0 & INTPLL_PRE_DIV_MASK) >>
-		INTPLL_PRE_DIV_SHIFT;
-	post_div = (pll_fdiv_ctl0 & INTPLL_POST_DIV_MASK) >>
-		INTPLL_POST_DIV_SHIFT;
+	main_div = (pll_fdiv_ctl0 & MDIV_MASK) >>
+		MDIV_SHIFT;
+	pre_div = (pll_fdiv_ctl0 & PDIV_MASK) >>
+		PDIV_SHIFT;
+	post_div = (pll_fdiv_ctl0 & SDIV_MASK) >>
+		SDIV_SHIFT;
 
-	k = pll_fdiv_ctl1 & GENMASK(15, 0);
+	k = pll_fdiv_ctl1 & KDIV_MASK;
 
 	return lldiv((main_div * 65536 + k) * 24000000ULL,
 		     65536 * pre_div * (1 << post_div));
Signature · 1 line
2.16.4
author
#25 lore raw

PATCH 20/24 imx8m: Enable WDOG_B for timeout

In reply to Peng Fan

From: Ye Li <[email protected]>

When doing reset_cpu, in normal case the WDOG_B outputs immediately after we clean WDA bit. But on mscale, the WDOG_B may be later than internal reset, and cause PMIC not reset. As we enabled the SD3.0 support, the PMIC must be reset to reset SD card.

Change the reset_cpu to enable the WDOG_B for timeout as well, and set WDOG timeout to 1s.

---
 arch/arm/mach-imx/imx8m/soc.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)
arch/arm/mach-imx/imx8m/soc.c +10 -10
index 8b6be7bc19..f10b71c345 100644
@@ -410,19 +410,19 @@ int ft_system_setup(void *blob, bd_t *bd)
 #if defined(CONFIG_SPL_BUILD) || !defined(CONFIG_SYSRESET)
 void reset_cpu(ulong addr)
 {
-       struct watchdog_regs *wdog = (struct watchdog_regs *)addr;
+	struct watchdog_regs *wdog = (struct watchdog_regs *)addr;
 
-       if (!addr)
-	       wdog = (struct watchdog_regs *)WDOG1_BASE_ADDR;
+	if (!addr)
+		wdog = (struct watchdog_regs *)WDOG1_BASE_ADDR;
 
-       /* Clear WDA to trigger WDOG_B immediately */
-       writew((WCR_WDE | WCR_SRS), &wdog->wcr);
+	/* Clear WDA to trigger WDOG_B immediately */
+	writew((SET_WCR_WT(1) | WCR_WDT | WCR_WDE | WCR_SRS), &wdog->wcr);
 
-       while (1) {
-               /*
-                * spin for .5 seconds before reset
-                */
-       }
+	while (1) {
+		/*
+		 * spin for 1 second before timeout reset
+		 */
+	}
 }
 #endif
 
Signature · 1 line
2.16.4
author
#26 lore raw

PATCH 21/24 doc: ahab: Add encrypted boot documentation for i.MX8/8x devices

In reply to Peng Fan

From: Breno Lima <[email protected]>

Add AHAB encrypted boot documentation for i.MX8/8x family devices covering the following topics:

- How to encrypt and sign the 2nd container in flash.bin image.
- How to encrypt and sign a standalone container image.

Include a CSF example to encrypt 2nd container in flash.bin image.

---
 doc/imx/ahab/csf_examples/csf_enc_boot_image.txt |  27 +++
 doc/imx/ahab/guides/mx8_mx8x_encrypted_boot.txt  | 293 +++++++++++++++++++++++
 2 files changed, 320 insertions(+)
 create mode 100644 doc/imx/ahab/csf_examples/csf_enc_boot_image.txt
 create mode 100644 doc/imx/ahab/guides/mx8_mx8x_encrypted_boot.txt
doc/imx/ahab/csf_examples/csf_enc_boot_image.txt new file +27 -0
new file mode 100644
index 0000000000..6c70db657b
@@ -0,0 +1,27 @@
+[Header]
+Target = AHAB
+Version = 1.0
+
+[Install SRK]
+# SRK table generated by srktool
+File = "./release/crts/SRK_1_2_3_4_table.bin"
+# Public key certificate in PEM format
+Source = "./release/crts/SRK1_sha384_secp384r1_v3_usr_crt.pem"
+# Index of the public key certificate within the SRK table (0 .. 3)
+Source index = 0
+# Type of SRK set (NXP or OEM)
+Source set = OEM
+# bitmask of the revoked SRKs
+Revocations = 0x0
+
+[Authenticate Data]
+# Binary to be signed generated by mkimage
+File = "flash.bin"
+# Offsets = Container header  Signature block (printed out by mkimage)
+Offsets   = 0x400             0x590
+
+[Install Secret Key]
+Key = "dek.bin"
+Key Length = 128
+#Key Identifier = 0x1234CAFE
+Image Indexes = 0xFFFFFFFE
doc/imx/ahab/guides/mx8_mx8x_encrypted_boot.txt new file +293 -0

293 lines not on this page · raw message

Signature · 1 line
2.16.4
author
#27 lore raw

PATCH 22/24 imx8: scu api: Add support for SECO manufacturing protection APIs

In reply to Peng Fan

From: Breno Lima <[email protected]>

SECO provides APIs to support CAAM manufacturing protection:

- sc_seco_get_mp_key()
- sc_seco_get_mp_sign()
- sc_seco_update_mpmr()

Add SCFW APIs support.

---
 arch/arm/include/asm/arch-imx8/sci/sci.h |  4 ++
 drivers/misc/imx8/scu_api.c              | 80 ++++++++++++++++++++++++++++++++
 2 files changed, 84 insertions(+)
arch/arm/include/asm/arch-imx8/sci/sci.h +4 -0
index 14ee6f999b..ac65f199b8 100644
@@ -122,5 +122,9 @@ void sc_seco_build_info(sc_ipc_t ipc, u32 *version, u32 *commit);
 int sc_seco_get_event(sc_ipc_t ipc, u8 idx, u32 *event);
 int sc_seco_gen_key_blob(sc_ipc_t ipc, u32 id, sc_faddr_t load_addr,
 			 sc_faddr_t export_addr, u16 max_size);
+int sc_seco_get_mp_key(sc_ipc_t ipc, sc_faddr_t dst_addr, u16 dst_size);
+int sc_seco_update_mpmr(sc_ipc_t ipc, sc_faddr_t addr, u8 size, u8 lock);
+int sc_seco_get_mp_sign(sc_ipc_t ipc, sc_faddr_t msg_addr,
+			u16 msg_size, sc_faddr_t dst_addr, u16 dst_size);
 
 #endif
drivers/misc/imx8/scu_api.c +80 -0

83 lines not on this page · raw message

Signature · 1 line
2.16.4
author
#28 lore raw

PATCH 23/24 imx8: Update SCFW API to version 1.5

In reply to Peng Fan

From: Ye Li <[email protected]>

Sync the latest SCFW API with below commit 6dcd0242ae7a53ac ("SCF-105: Revert accidental change") to add interfaces for PM resource reset and read/write SNVS security violation and tamper DGO registers.

---
 arch/arm/include/asm/arch-imx8/sci/rpc.h         | 86 ++++++++++++++++++------
 arch/arm/include/asm/arch-imx8/sci/sci.h         |  2 +
 arch/arm/include/asm/arch-imx8/sci/svc/pad/api.h |  3 +
 arch/arm/include/asm/arch-imx8/sci/types.h       |  6 ++
 drivers/misc/imx8/scu_api.c                      | 50 ++++++++++++++
 5 files changed, 126 insertions(+), 21 deletions(-)
arch/arm/include/asm/arch-imx8/sci/rpc.h +65 -21
index 8e1e9bbf43..c1a9c353ba 100644
@@ -8,6 +8,11 @@
 #define SC_RPC_H
 
 /* Note: Check SCFW API Released DOC before you want to modify something */
+/* Defines */
+
+#define SCFW_API_VERSION_MAJOR  1U
+#define SCFW_API_VERSION_MINOR  15U
+
 #define SC_RPC_VERSION          1U
 
 #define SC_RPC_MAX_MSG          8U
@@ -17,9 +22,13 @@
 #define RPC_SVC(MSG)            ((MSG)->svc)
 #define RPC_FUNC(MSG)           ((MSG)->func)
 #define RPC_R8(MSG)             ((MSG)->func)
+#define RPC_I64(MSG, IDX)       ((s64)(RPC_U32((MSG), (IDX))) << 32ULL) | \
+				  (s64)(RPC_U32((MSG), (IDX) + 4U))
 #define RPC_I32(MSG, IDX)       ((MSG)->DATA.i32[(IDX) / 4U])
 #define RPC_I16(MSG, IDX)       ((MSG)->DATA.i16[(IDX) / 2U])
 #define RPC_I8(MSG, IDX)        ((MSG)->DATA.i8[(IDX)])
+#define RPC_U64(MSG, IDX)       ((u64)(RPC_U32((MSG), (IDX))) << 32ULL) | \
+				  (u64)(RPC_U32((MSG), (IDX) + 4U))
 #define RPC_U32(MSG, IDX)       ((MSG)->DATA.u32[(IDX) / 4U])
 #define RPC_U16(MSG, IDX)       ((MSG)->DATA.u16[(IDX) / 2U])
 #define RPC_U8(MSG, IDX)        ((MSG)->DATA.u8[(IDX)])
@@ -76,6 +85,8 @@ struct sc_rpc_msg_s {
 #define PM_FUNC_REBOOT				9U
 #define PM_FUNC_REBOOT_PARTITION		12U
 #define PM_FUNC_CPU_START			11U
+#define PM_FUNC_CPU_RESET			23U
+#define PM_FUNC_RESOURCE_RESET			29U
 #define PM_FUNC_IS_PARTITION_STARTED 24U
 
 /* MISC RPC */
@@ -160,26 +171,59 @@ struct sc_rpc_msg_s {
 #define RM_FUNC_DUMP				27U
 
 /* SECO RPC */
-#define SECO_FUNC_UNKNOWN			0
-#define SECO_FUNC_IMAGE_LOAD			1U
-#define SECO_FUNC_AUTHENTICATE			2U
-#define SECO_FUNC_FORWARD_LIFECYCLE		3U
-#define SECO_FUNC_RETURN_LIFECYCLE		4U
-#define SECO_FUNC_COMMIT			5U
-#define SECO_FUNC_ATTEST_MODE			6U
-#define SECO_FUNC_ATTEST			7U
-#define SECO_FUNC_GET_ATTEST_PKEY		8U
-#define SECO_FUNC_GET_ATTEST_SIGN		9U
-#define SECO_FUNC_ATTEST_VERIFY			10U
-#define SECO_FUNC_GEN_KEY_BLOB			11U
-#define SECO_FUNC_LOAD_KEY			12U
-#define SECO_FUNC_GET_MP_KEY			13U
-#define SECO_FUNC_UPDATE_MPMR			14U
-#define SECO_FUNC_GET_MP_SIGN			15U
-#define SECO_FUNC_BUILD_INFO			16U
-#define SECO_FUNC_CHIP_INFO			17U
-#define SECO_FUNC_ENABLE_DEBUG			18U
-#define SECO_FUNC_GET_EVENT			19U
-#define SECO_FUNC_FUSE_WRITE			20U
+#define SECO_FUNC_UNKNOWN 0 /* Unknown function */
+#define SECO_FUNC_IMAGE_LOAD 1U /* Index for seco_image_load() RPC call */
+#define SECO_FUNC_AUTHENTICATE 2U /* Index for seco_authenticate() RPC call */
+#define SECO_FUNC_ENH_AUTHENTICATE 24U /* Index for sc_seco_enh_authenticate() RPC call */
+#define SECO_FUNC_FORWARD_LIFECYCLE 3U /* Index for seco_forward_lifecycle() RPC call */
+#define SECO_FUNC_RETURN_LIFECYCLE 4U /* Index for seco_return_lifecycle() RPC call */
+#define SECO_FUNC_COMMIT 5U /* Index for seco_commit() RPC call */
+#define SECO_FUNC_ATTEST_MODE 6U /* Index for seco_attest_mode() RPC call */
+#define SECO_FUNC_ATTEST 7U /* Index for seco_attest() RPC call */
+#define SECO_FUNC_GET_ATTEST_PKEY 8U /* Index for seco_get_attest_pkey() RPC call */
+#define SECO_FUNC_GET_ATTEST_SIGN 9U /* Index for seco_get_attest_sign() RPC call */
+#define SECO_FUNC_ATTEST_VERIFY 10U /* Index for seco_attest_verify() RPC call */
+#define SECO_FUNC_GEN_KEY_BLOB 11U /* Index for seco_gen_key_blob() RPC call */
+#define SECO_FUNC_LOAD_KEY 12U /* Index for seco_load_key() RPC call */
+#define SECO_FUNC_GET_MP_KEY 13U /* Index for seco_get_mp_key() RPC call */
+#define SECO_FUNC_UPDATE_MPMR 14U /* Index for seco_update_mpmr() RPC call */
+#define SECO_FUNC_GET_MP_SIGN 15U /* Index for seco_get_mp_sign() RPC call */
+#define SECO_FUNC_BUILD_INFO 16U /* Index for seco_build_info() RPC call */
+#define SECO_FUNC_CHIP_INFO 17U /* Index for seco_chip_info() RPC call */
+#define SECO_FUNC_ENABLE_DEBUG 18U /* Index for seco_enable_debug() RPC call */
+#define SECO_FUNC_GET_EVENT 19U /* Index for seco_get_event() RPC call */
+#define SECO_FUNC_FUSE_WRITE 20U /* Index for seco_fuse_write() RPC call */
+#define SECO_FUNC_PATCH 21U /* Index for sc_seco_patch() RPC call */
+#define SECO_FUNC_START_RNG 22U /* Index for sc_seco_start_rng() RPC call */
+#define SECO_FUNC_SAB_MSG 23U /* Index for sc_seco_sab_msg() RPC call */
+#define SECO_FUNC_SECVIO_ENABLE 25U /* Index for sc_seco_secvio_enable() RPC call */
+#define SECO_FUNC_SECVIO_CONFIG 26U /* Index for sc_seco_secvio_config() RPC call */
+#define SECO_FUNC_SECVIO_DGO_CONFIG 27U /* Index for sc_seco_secvio_dgo_config() RPC call */
+
+/* IRQ RPC */
+#define IRQ_FUNC_UNKNOWN 0 /* Unknown function */
+#define IRQ_FUNC_ENABLE 1U /* Index for sc_irq_enable() RPC call */
+#define IRQ_FUNC_STATUS 2U /* Index for sc_irq_status() RPC call */
+
+/* TIMER RPC */
+#define TIMER_FUNC_UNKNOWN 0 /* Unknown function */
+#define TIMER_FUNC_SET_WDOG_TIMEOUT 1U /* Index for sc_timer_set_wdog_timeout() RPC call */
+#define TIMER_FUNC_SET_WDOG_PRE_TIMEOUT 12U /* Index for sc_timer_set_wdog_pre_timeout() RPC call */
+#define TIMER_FUNC_START_WDOG 2U /* Index for sc_timer_start_wdog() RPC call */
+#define TIMER_FUNC_STOP_WDOG 3U /* Index for sc_timer_stop_wdog() RPC call */
+#define TIMER_FUNC_PING_WDOG 4U /* Index for sc_timer_ping_wdog() RPC call */
+#define TIMER_FUNC_GET_WDOG_STATUS 5U /* Index for sc_timer_get_wdog_status() RPC call */
+#define TIMER_FUNC_PT_GET_WDOG_STATUS 13U /* Index for sc_timer_pt_get_wdog_status() RPC call */
+#define TIMER_FUNC_SET_WDOG_ACTION 10U /* Index for sc_timer_set_wdog_action() RPC call */
+#define TIMER_FUNC_SET_RTC_TIME 6U /* Index for sc_timer_set_rtc_time() RPC call */
+#define TIMER_FUNC_GET_RTC_TIME 7U /* Index for sc_timer_get_rtc_time() RPC call */
+#define TIMER_FUNC_GET_RTC_SEC1970 9U /* Index for sc_timer_get_rtc_sec1970() RPC call */
+#define TIMER_FUNC_SET_RTC_ALARM 8U /* Index for sc_timer_set_rtc_alarm() RPC call */
+#define TIMER_FUNC_SET_RTC_PERIODIC_ALARM 14U /* Index for sc_timer_set_rtc_periodic_alarm() RPC call */
+#define TIMER_FUNC_CANCEL_RTC_ALARM 15U /* Index for sc_timer_cancel_rtc_alarm() RPC call */
+#define TIMER_FUNC_SET_RTC_CALB 11U /* Index for sc_timer_set_rtc_calb() RPC call */
+#define TIMER_FUNC_SET_SYSCTR_ALARM 16U /* Index for sc_timer_set_sysctr_alarm() RPC call */
+#define TIMER_FUNC_SET_SYSCTR_PERIODIC_ALARM 17U /* Index for sc_timer_set_sysctr_periodic_alarm() RPC call */
+#define TIMER_FUNC_CANCEL_SYSCTR_ALARM 18U /* Index for sc_timer_cancel_sysctr_alarm() RPC call */
 
 #endif /* SC_RPC_H */
arch/arm/include/asm/arch-imx8/sci/sci.h +2 -0
index ac65f199b8..179037ae17 100644
@@ -72,6 +72,7 @@ int sc_pm_set_clock_parent(sc_ipc_t ipc, sc_rsrc_t resource, sc_pm_clk_t clk,
 int sc_pm_cpu_start(sc_ipc_t ipc, sc_rsrc_t resource, sc_bool_t enable,
 		    sc_faddr_t address);
 sc_bool_t sc_pm_is_partition_started(sc_ipc_t ipc, sc_rm_pt_t pt);
+int sc_pm_resource_reset(sc_ipc_t ipc, sc_rsrc_t resource);
 
 /* MISC API */
 int sc_misc_set_control(sc_ipc_t ipc, sc_rsrc_t resource,
@@ -126,5 +127,6 @@ int sc_seco_get_mp_key(sc_ipc_t ipc, sc_faddr_t dst_addr, u16 dst_size);
 int sc_seco_update_mpmr(sc_ipc_t ipc, sc_faddr_t addr, u8 size, u8 lock);
 int sc_seco_get_mp_sign(sc_ipc_t ipc, sc_faddr_t msg_addr,
 			u16 msg_size, sc_faddr_t dst_addr, u16 dst_size);
+int sc_seco_secvio_dgo_config(sc_ipc_t ipc, u8 id, u8 access, u32 *data);
 
 #endif
arch/arm/include/asm/arch-imx8/sci/svc/pad/api.h +3 -0
index 905c56834e..df368e8c8b 100644
@@ -6,6 +6,9 @@
 #ifndef SC_PAD_API_H
 #define SC_PAD_API_H
 
+/* Defines for type widths */
+#define SC_PAD_MUX_W            3U    /* Width of mux parameter */
+
 /* Defines for sc_pad_config_t */
 #define SC_PAD_CONFIG_NORMAL	0U	/* Normal */
 #define SC_PAD_CONFIG_OD	1U	/* Open Drain */
arch/arm/include/asm/arch-imx8/sci/types.h +6 -0
index 9eadc88592..adfed13e33 100644
@@ -32,6 +32,7 @@ typedef u64 sc_ipc_t;
 #define SC_83MHZ         83333333U   /* 83MHz */
 #define SC_84MHZ         84375000U   /* 84.37MHz */
 #define SC_100MHZ       100000000U   /* 100MHz */
+#define SC_114MHZ       114000000U   /* 114MHz */
 #define SC_125MHZ       125000000U   /* 125MHz */
 #define SC_133MHZ       133333333U   /* 133MHz */
 #define SC_135MHZ       135000000U   /* 135MHz */
@@ -52,6 +53,7 @@ typedef u64 sc_ipc_t;
 #define SC_372MHZ       372000000U   /* 372MHz */
 #define SC_375MHZ       375000000U   /* 375MHz */
 #define SC_400MHZ       400000000U   /* 400MHz */
+#define SC_465MHZ       465000000U   /* 465MHz */
 #define SC_500MHZ       500000000U   /* 500MHz */
 #define SC_594MHZ       594000000U   /* 594MHz */
 #define SC_625MHZ       625000000U   /* 625MHz */
@@ -75,6 +77,7 @@ typedef u64 sc_ipc_t;
 #define SC_1500MHZ     1500000000U   /* 1.5GHz */
 #define SC_1600MHZ     1600000000U   /* 1.6GHz */
 #define SC_1800MHZ     1800000000U   /* 1.8GHz */
+#define SC_1860MHZ     1860000000U   /* 1.86GHz */
 #define SC_2000MHZ     2000000000U   /* 2.0GHz */
 #define SC_2112MHZ     2112000000U   /* 2.12GHz */
 
@@ -89,6 +92,7 @@ typedef u64 sc_ipc_t;
 #define SC_144MHZ       144000000U   /* 144MHz */
 #define SC_192MHZ       192000000U   /* 192MHz */
 #define SC_211MHZ       211200000U   /* 211.2MHz */
+#define SC_228MHZ       228000000U   /* 233MHz */
 #define SC_240MHZ       240000000U   /* 240MHz */
 #define SC_264MHZ       264000000U   /* 264MHz */
 #define SC_352MHZ       352000000U   /* 352MHz */
@@ -96,11 +100,13 @@ typedef u64 sc_ipc_t;
 #define SC_384MHZ       384000000U   /* 384MHz */
 #define SC_396MHZ       396000000U   /* 396MHz */
 #define SC_432MHZ       432000000U   /* 432MHz */
+#define SC_456MHZ       456000000U   /* 466MHz */
 #define SC_480MHZ       480000000U   /* 480MHz */
 #define SC_600MHZ       600000000U   /* 600MHz */
 #define SC_744MHZ       744000000U   /* 744MHz */
 #define SC_792MHZ       792000000U   /* 792MHz */
 #define SC_864MHZ       864000000U   /* 864MHz */
+#define SC_912MHZ       912000000U   /* 912MHz */
 #define SC_960MHZ       960000000U   /* 960MHz */
 #define SC_1056MHZ     1056000000U   /* 1056MHz */
 #define SC_1104MHZ     1104000000U   /* 1104MHz */
drivers/misc/imx8/scu_api.c +50 -0

59 lines not on this page · raw message

Signature · 1 line
2.16.4
author
#29 lore raw

PATCH 24/24 imx8: Configure SNVS

In reply to Peng Fan

From: Franck LENORMAND <[email protected]>

Add a module to configure the tamper and secure violation of the SNVS using the SCU API.

The module also adds some commands:
- snvs_cfg: Configure the SNVS HP and LP registers
- snvs_dgo_cfg: Configure the SNVS DGO bloc if present (8QXP)
- tamper_pin_cfg: Change the configuration of the tamper pins
- snvs_clear_status: Allow to write to LPSR and LPTDSR to clear status bits

---
 arch/arm/include/asm/arch-imx8/sci/sci.h          |   4 +
 arch/arm/include/asm/arch-imx8/snvs_security_sc.h |  11 +
 arch/arm/mach-imx/imx8/Kconfig                    |  13 +
 arch/arm/mach-imx/imx8/Makefile                   |   1 +
 arch/arm/mach-imx/imx8/snvs_security_sc.c         | 923 ++++++++++++++++++++++
 board/freescale/imx8qxp_mek/imx8qxp_mek.c         |  10 +
 drivers/misc/imx8/scu_api.c                       |  72 +-
 7 files changed, 1030 insertions(+), 4 deletions(-)
 create mode 100644 arch/arm/include/asm/arch-imx8/snvs_security_sc.h
 create mode 100644 arch/arm/mach-imx/imx8/snvs_security_sc.c
arch/arm/include/asm/arch-imx8/sci/sci.h +4 -0
index 179037ae17..05f736f14f 100644
@@ -109,6 +109,7 @@ int sc_rm_get_resource_owner(sc_ipc_t ipc, sc_rsrc_t resource,
 
 /* PAD API */
 int sc_pad_set(sc_ipc_t ipc, sc_pad_t pad, u32 val);
+int sc_pad_get(sc_ipc_t ipc, sc_pad_t pad, uint32_t *val);
 
 /* SMMU API */
 int sc_rm_set_master_sid(sc_ipc_t ipc, sc_rsrc_t resource, sc_rm_sid_t sid);
@@ -128,5 +129,8 @@ int sc_seco_update_mpmr(sc_ipc_t ipc, sc_faddr_t addr, u8 size, u8 lock);
 int sc_seco_get_mp_sign(sc_ipc_t ipc, sc_faddr_t msg_addr,
 			u16 msg_size, sc_faddr_t dst_addr, u16 dst_size);
 int sc_seco_secvio_dgo_config(sc_ipc_t ipc, u8 id, u8 access, u32 *data);
+int sc_seco_secvio_config(sc_ipc_t ipc, u8 id, u8 access,
+			  u32 *data0, u32 *data1, u32 *data2, u32 *data3,
+			  u32 *data4, u8 size);
 
 #endif
arch/arm/include/asm/arch-imx8/snvs_security_sc.h new file +11 -0
new file mode 100644
index 0000000000..0b7ded7ba6
@@ -0,0 +1,11 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright 2018 NXP
+ */
+
+#ifndef _SNVS_SECURITY_SC_H
+#define _SNVS_SECURITY_SC_H
+
+int snvs_security_sc_init(void);
+
+#endif /* _SNVS_SECURITY_SC_H */
arch/arm/mach-imx/imx8/Kconfig +13 -0
index 5827ab334f..1f8add015f 100644
@@ -90,4 +90,17 @@ source "board/toradex/apalis-imx8/Kconfig"
 source "board/toradex/colibri-imx8x/Kconfig"
 source "board/siemens/capricorn/Kconfig"
 
+config IMX_SNVS_SEC_SC
+	bool "Support SNVS configuration"
+	help
+	  Allow to configure the SNVS via SCU API to configure tampers and secure
+	  violation.
+
+config IMX_SNVS_SEC_SC_AUTO
+	bool "Support SNVS configuration command"
+	depends on IMX_SNVS_SEC_SC
+	help
+	  This configuration will apply the selected configurations automatically
+	  at boot.
+
 endif
arch/arm/mach-imx/imx8/Makefile +1 -0
index 7ffb7e95b2..bbb41adbe4 100644
@@ -11,3 +11,4 @@ obj-$(CONFIG_AHAB_BOOT) += ahab.o
 ifdef CONFIG_SPL_BUILD
 obj-$(CONFIG_SPL_LOAD_IMX_CONTAINER) += image.o parse-container.o
 endif
+obj-$(CONFIG_IMX_SNVS_SEC_SC) += snvs_security_sc.o
arch/arm/mach-imx/imx8/snvs_security_sc.c new file +923 -0

923 lines not on this page · raw message

board/freescale/imx8qxp_mek/imx8qxp_mek.c +10 -0
index b96f0da21e..93f0cd827c 100644
@@ -16,6 +16,7 @@
 #include <asm/arch/clock.h>
 #include <asm/arch/sci/sci.h>
 #include <asm/arch/imx8-pins.h>
+#include <asm/arch/snvs_security_sc.h>
 #include <asm/arch/iomux.h>
 #include <asm/arch/sys_proto.h>
 
@@ -111,6 +112,15 @@ int board_init(void)
 {
 	board_gpio_init();
 
+#ifdef CONFIG_IMX_SNVS_SEC_SC_AUTO
+	{
+		int ret = snvs_security_sc_init();
+
+		if (ret)
+			return ret;
+	}
+#endif
+
 	return 0;
 }
 
drivers/misc/imx8/scu_api.c +68 -4

90 lines not on this page · raw message

Signature · 1 line
2.16.4