Skip to contentSkip to conversation

arm: Introduce v7R support

RFC PATCH New Lokesh Vutla 4 participants 21 messages Apr 24, 2018 Arm (32-bit)

lore
Share & tools
lore
#0 lore raw

cover arm: Introduce v7R support

The Cortex-R* processors are a mid-range CPUs for use in deeply-embedded, real-time systems. It implements the ARMv7-R architecture, and includes Thumb-2 technology for optimum code density and processing throughput.

Except for MPU(Memory Protection Unit) and few CP15 registers, most of the features are compatible with v7 architecture. This series adds minimal support for v7-R architecture by reusing the v7 support. Also adding support for MPU.

Lokesh Vutla (4):
arm: v7: Update VBAR only if available
arm: Kconfig: Add entry for MMU
arm: v7R: Add support for MPU
arm: v7R: Add support for enabling caches

Michal Simek (1):
arm: v7R: Add initial support

 arch/arm/Kconfig                  |  33 ++++++++
 arch/arm/Makefile                 |   2 +
 arch/arm/cpu/armv7/Makefile       |   2 +
 arch/arm/cpu/armv7/mpu_v7r.c      | 120 ++++++++++++++++++++++++++++++
 arch/arm/cpu/armv7/start.S        |   4 +
 arch/arm/cpu/armv7m/Makefile      |   3 +-
 arch/arm/cpu/armv7m/mpu.c         |  41 +---------
 arch/arm/include/asm/armv7m_mpu.h |  69 +++++++++++++++++
 arch/arm/lib/Makefile             |   5 +-
 arch/arm/lib/cache-cp15.c         |  14 +++-
 10 files changed, 248 insertions(+), 45 deletions(-)
 create mode 100644 arch/arm/cpu/armv7/mpu_v7r.c
Signature · 1 line
2.17.0
#1 lore raw

RFC PATCH 1/5 arm: v7: Update VBAR only if available

Not all ARM V7 based cpus has VBAR for remapping vector base address. So, update VBAR only if it available.

---
 arch/arm/cpu/armv7/start.S | 2 ++
 1 file changed, 2 insertions(+)
arch/arm/cpu/armv7/start.S +2 -0
index 7e2695761e..937f7051fe 100644
@@ -73,9 +73,11 @@ switch_to_hypervisor_ret:
 	bic	r0, #CR_V		@ V = 0
 	mcr	p15, 0, r0, c1, c0, 0	@ Write CP15 SCTLR Register
 
+#ifdef CONFIG_HAS_VBAR
 	/* Set vector address in CP15 VBAR register */
 	ldr	r0, =_start
 	mcr	p15, 0, r0, c12, c0, 0	@Set VBAR
+#endif
 #endif
 
 	/* the mask ROM code should have PLL and others stable */
Signature · 1 line
2.17.0
#2 lore raw

RFC PATCH 2/5 arm: v7R: Add initial support

In reply to Lokesh Vutla

From: Michal Simek <[email protected]>

The Cortex-R* processors are a mid-range CPUs for use in deeply-embedded, real-time systems. It implements the ARMv7-R architecture, and includes Thumb-2 technology for optimum code density and processing throughput.

Except for MPU(Memory Protection Unit) and few CP15 registers, most of the features are compatible with v7 architecture. So,reuse the same armv7 folder and introduce a new config CPU_V7R in order to differentiate from v7 based platforms.

---
 arch/arm/Kconfig           | 7 +++++++
 arch/arm/Makefile          | 2 ++
 arch/arm/cpu/armv7/start.S | 2 ++
 3 files changed, 11 insertions(+)
arch/arm/Kconfig +7 -0
index 7212fc5afa..de36ab6701 100644
@@ -192,6 +192,11 @@ config CPU_V7M
 	select THUMB2_KERNEL
 	select SYS_CACHE_SHIFT_5
 
+config CPU_V7R
+	bool
+        select HAS_THUMB2
+	select SYS_CACHE_SHIFT_6
+
 config CPU_PXA
 	bool
 	select SYS_CACHE_SHIFT_5
@@ -208,6 +213,7 @@ config SYS_CPU
 	default "arm1136" if CPU_ARM1136
 	default "arm1176" if CPU_ARM1176
 	default "armv7" if CPU_V7
+        default "armv7" if CPU_V7R
 	default "armv7m" if CPU_V7M
 	default "pxa" if CPU_PXA
 	default "sa1100" if CPU_SA1100
@@ -223,6 +229,7 @@ config SYS_ARM_ARCH
 	default 6 if CPU_ARM1176
 	default 7 if CPU_V7
 	default 7 if CPU_V7M
+	default 7 if CPU_V7R
 	default 5 if CPU_PXA
 	default 4 if CPU_SA1100
 	default 8 if ARM64
arch/arm/Makefile +2 -0
index 4fa8b38397..f4bc1f250d 100644
@@ -18,6 +18,7 @@ arch-$(CONFIG_CPU_ARM1136)	=-march=armv5
 arch-$(CONFIG_CPU_ARM1176)	=-march=armv5t
 arch-$(CONFIG_CPU_V7)		=$(call cc-option, -march=armv7-a, \
 				 $(call cc-option, -march=armv7, -march=armv5))
+arch-$(CONFIG_CPU_V7R)		=-march=armv7-r
 arch-$(CONFIG_ARM64)		=-march=armv8-a
 
 # On Tegra systems we must build SPL for the armv4 core on the device
@@ -41,6 +42,7 @@ tune-$(CONFIG_CPU_PXA)		=-mcpu=xscale
 tune-$(CONFIG_CPU_ARM1136)	=
 tune-$(CONFIG_CPU_ARM1176)	=
 tune-$(CONFIG_CPU_V7)		=
+tune-$(CONFIG_CPU_V7R)		=
 tune-$(CONFIG_ARM64)		=
 
 # Evaluate tune cc-option calls now
arch/arm/cpu/armv7/start.S +2 -0
index 937f7051fe..97cd830dc5 100644
@@ -82,7 +82,9 @@ switch_to_hypervisor_ret:
 
 	/* the mask ROM code should have PLL and others stable */
 #ifndef CONFIG_SKIP_LOWLEVEL_INIT
+#ifdef CONFIG_CPU_V7
 	bl	cpu_init_cp15
+#endif
 #ifndef CONFIG_SKIP_LOWLEVEL_INIT_ONLY
 	bl	cpu_init_crit
 #endif
Signature · 1 line
2.17.0
#3 lore raw

RFC PATCH 2/5 arm: v7R: Add initial support

Quoted 24 lines · Lokesh Vutla

From: Michal Simek <[email protected]>

The Cortex-R* processors are a mid-range CPUs for use in deeply-embedded, real-time systems. It implements the ARMv7-R architecture, and includes Thumb-2 technology for optimum code density and processing throughput.

Except for MPU(Memory Protection Unit) and few CP15 registers, most of the features are compatible with v7 architecture. So,reuse the same armv7 folder and introduce a new config CPU_V7R in order to differentiate from v7 based platforms.

---
  arch/arm/Kconfig           | 7 +++++++
  arch/arm/Makefile          | 2 ++
  arch/arm/cpu/armv7/start.S | 2 ++
  3 files changed, 11 insertions(+)
arch/arm/Kconfig +0 -0
index 7212fc5afa..de36ab6701 100644

arch/arm/Kconfig config CPU_V7M · line 197

Quoted 6 lines
arch/arm/Kconfig +3 -0
@@ -192,6 +192,11 @@ config CPU_V7M
  	select THUMB2_KERNEL
  	select SYS_CACHE_SHIFT_5
 
+config CPU_V7R
+	bool
+        select HAS_THUMB2

spaces vs tabs?

arch/arm/Kconfig config SYS_CPU · line 216

Quoted 10 lines
arch/arm/Kconfig +3 -0
+	select SYS_CACHE_SHIFT_6
+
  config CPU_PXA
  	bool
  	select SYS_CACHE_SHIFT_5
@@ -208,6 +213,7 @@ config SYS_CPU
  	default "arm1136" if CPU_ARM1136
  	default "arm1176" if CPU_ARM1176
  	default "armv7" if CPU_V7
+        default "armv7" if CPU_V7R

same here

Quoted 36 lines
arch/arm/Kconfig +1 -0
  	default "armv7m" if CPU_V7M
  	default "pxa" if CPU_PXA
  	default "sa1100" if CPU_SA1100
@@ -223,6 +229,7 @@ config SYS_ARM_ARCH
  	default 6 if CPU_ARM1176
  	default 7 if CPU_V7
  	default 7 if CPU_V7M
+	default 7 if CPU_V7R
  	default 5 if CPU_PXA
  	default 4 if CPU_SA1100
  	default 8 if ARM64
arch/arm/Makefile +2 -0
index 4fa8b38397..f4bc1f250d 100644
@@ -18,6 +18,7 @@ arch-$(CONFIG_CPU_ARM1136)	=-march=armv5
  arch-$(CONFIG_CPU_ARM1176)	=-march=armv5t
  arch-$(CONFIG_CPU_V7)		=$(call cc-option, -march=armv7-a, \
  				 $(call cc-option, -march=armv7, -march=armv5))
+arch-$(CONFIG_CPU_V7R)		=-march=armv7-r
  arch-$(CONFIG_ARM64)		=-march=armv8-a
 
  # On Tegra systems we must build SPL for the armv4 core on the device
@@ -41,6 +42,7 @@ tune-$(CONFIG_CPU_PXA)		=-mcpu=xscale
  tune-$(CONFIG_CPU_ARM1136)	=
  tune-$(CONFIG_CPU_ARM1176)	=
  tune-$(CONFIG_CPU_V7)		=
+tune-$(CONFIG_CPU_V7R)		=
  tune-$(CONFIG_ARM64)		=
 
  # Evaluate tune cc-option calls now
arch/arm/cpu/armv7/start.S +0 -0
index 937f7051fe..97cd830dc5 100644

arch/arm/cpu/armv7/start.S switch_to_hypervisor_ret: · line 85

Quoted 4 lines
arch/arm/cpu/armv7/start.S +1 -0
@@ -82,7 +82,9 @@ switch_to_hypervisor_ret:
 
  	/* the mask ROM code should have PLL and others stable */
  #ifndef CONFIG_SKIP_LOWLEVEL_INIT
+#ifdef CONFIG_CPU_V7

Shouldn't this be V7A now?

Alex

Quoted 5 lines
arch/arm/cpu/armv7/start.S +1 -0
  	bl	cpu_init_cp15
+#endif
  #ifndef CONFIG_SKIP_LOWLEVEL_INIT_ONLY
  	bl	cpu_init_crit
  #endif
#4 lore raw

RFC PATCH 2/5 arm: v7R: Add initial support

Quoted 11 lines · Alexander Graf
Quoted 10 lines · Lokesh Vutla

From: Michal Simek <[email protected]>

The Cortex-R* processors are a mid-range CPUs for use in deeply-embedded, real-time systems. It implements the ARMv7-R architecture, and includes Thumb-2 technology for optimum code density and processing throughput.

Except for MPU(Memory Protection Unit) and few CP15 registers, most of the features are compatible with v7 architecture. So,reuse the same armv7 folder and introduce a new config CPU_V7R in order to differentiate from v7 based platforms.

[snip]

Quoted 10 lines

arch/arm/cpu/armv7/start.S switch_to_hypervisor_ret: · line 84

Quoted 8 lines
arch/arm/cpu/armv7/start.S +1 -0
index 937f7051fe..97cd830dc5 100644
@@ -82,7 +82,9 @@ switch_to_hypervisor_ret:
 	/* the mask ROM code should have PLL and others stable */
 #ifndef CONFIG_SKIP_LOWLEVEL_INIT
+#ifdef CONFIG_CPU_V7

Shouldn't this be V7A now?

I'm not sure if we need to add a CPU_V7A flag now. Maybe..

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180424/c6c01687/attachment.sig>
#5 lore raw

RFC PATCH 2/5 arm: v7R: Add initial support

In reply to Alexander Graf
Quoted 21 lines · Alexander Graf
Quoted 20 lines · Lokesh Vutla

From: Michal Simek <[email protected]>

The Cortex-R* processors are a mid-range CPUs for use in deeply-embedded, real-time systems. It implements the ARMv7-R architecture, and includes Thumb-2 technology for optimum code density and processing throughput.

Except for MPU(Memory Protection Unit) and few CP15 registers, most of the
features are compatible with v7 architecture. So,reuse the same armv7 folder and introduce a new config CPU_V7R in order to differentiate from v7 based platforms.

---
  arch/arm/Kconfig           | 7 +++++++
  arch/arm/Makefile          | 2 ++
  arch/arm/cpu/armv7/start.S | 2 ++

  3 files changed, 11 insertions(+)
Quoted 12 lines
Quoted 10 lines
arch/arm/Kconfig +0 -0
index 7212fc5afa..de36ab6701 100644
@@ -192,6 +192,11 @@ config CPU_V7M

      select THUMB2_KERNEL
      select SYS_CACHE_SHIFT_5
  +config CPU_V7R
+    bool
+        select HAS_THUMB2

spaces vs tabs?

will fix it in next version.

Quoted 13 lines
Quoted 11 lines

+    select SYS_CACHE_SHIFT_6
+
  config CPU_PXA
      bool
      select SYS_CACHE_SHIFT_5

arch/arm/Kconfig +0 -0
@@ -208,6 +213,7 @@ config SYS_CPU

      default "arm1136" if CPU_ARM1136
      default "arm1176" if CPU_ARM1176
      default "armv7" if CPU_V7
+        default "armv7" if CPU_V7R

same here

will fix.

Quoted 32 lines
Quoted 32 lines

      default "armv7m" if CPU_V7M
      default "pxa" if CPU_PXA
      default "sa1100" if CPU_SA1100

arch/arm/Kconfig +0 -0
@@ -223,6 +229,7 @@ config SYS_ARM_ARCH

      default 6 if CPU_ARM1176
      default 7 if CPU_V7
      default 7 if CPU_V7M
+    default 7 if CPU_V7R
      default 5 if CPU_PXA
      default 4 if CPU_SA1100
      default 8 if ARM64

arch/arm/Makefile +0 -0
index 4fa8b38397..f4bc1f250d 100644
@@ -18,6 +18,7 @@ arch-$(CONFIG_CPU_ARM1136)    =-march=armv5

  arch-$(CONFIG_CPU_ARM1176)    =-march=armv5t arch-$(CONFIG_CPU_V7)        =$(call cc-option, -march=armv7-a, \
                   $(call cc-option, -march=armv7, -march=armv5)) +arch-$(CONFIG_CPU_V7R)        =-march=armv7-r arch-$(CONFIG_ARM64)        =-march=armv8-a
    # On Tegra systems we must build SPL for the armv4 core on the device

arch/arm/Makefile +0 -0
@@ -41,6 +42,7 @@ tune-$(CONFIG_CPU_PXA)        =-mcpu=xscale

  tune-$(CONFIG_CPU_ARM1136)    =
  tune-$(CONFIG_CPU_ARM1176)    =
  tune-$(CONFIG_CPU_V7)        =
+tune-$(CONFIG_CPU_V7R)        =
  tune-$(CONFIG_ARM64)        =
    # Evaluate tune cc-option calls now

arch/arm/cpu/armv7/start.S +0 -0
index 937f7051fe..97cd830dc5 100644
Quoted 8 lines

arch/arm/cpu/armv7/start.S switch_to_hypervisor_ret: · line 84

Quoted 6 lines
arch/arm/cpu/armv7/start.S +1 -0
@@ -82,7 +82,9 @@ switch_to_hypervisor_ret:
         /* the mask ROM code should have PLL and others stable */
   #ifndef CONFIG_SKIP_LOWLEVEL_INIT
+#ifdef CONFIG_CPU_V7

Shouldn't this be V7A now?

As Tom suggested, ill not update it for now.

Thanks and regards,
Lokesh

Quoted 11 lines

Alex

Quoted 5 lines

      bl    cpu_init_cp15
+#endif
  #ifndef CONFIG_SKIP_LOWLEVEL_INIT_ONLY
      bl    cpu_init_crit
  #endif

#6 lore raw

RFC PATCH 3/5 arm: Kconfig: Add entry for MMU

In reply to Lokesh Vutla

Add a Kconfig entry for MMU and imply for all platforms using cache-cp15.c. Using imply instead of select so that MMU can be disabled by defconfigs when not needed.

---
 arch/arm/Kconfig      | 15 +++++++++++++++
 arch/arm/lib/Makefile |  6 +-----
 2 files changed, 16 insertions(+), 5 deletions(-)
arch/arm/Kconfig +15 -0
index de36ab6701..fe5bff097d 100644
@@ -74,6 +74,12 @@ config ARM_ASM_UNIFIED
 config THUMB2_KERNEL
 	bool
 
+config MMU
+	bool "MMU-based Paged Memory Management Support"
+	help
+	  Select if you want MMU-based virtualised addressing space
+	  support by paged memory management.
+
 # If set, the workarounds for these ARM errata are applied early during U-Boot
 # startup. Note that in general these options force the workarounds to be
 # applied; no CPU-type/version detection exists, unlike the similar options in
@@ -158,33 +164,40 @@ config ARM_ERRATA_855873
 config CPU_ARM720T
 	bool
 	select SYS_CACHE_SHIFT_5
+	imply MMU
 
 config CPU_ARM920T
 	bool
 	select SYS_CACHE_SHIFT_5
+	imply MMU
 
 config CPU_ARM926EJS
 	bool
 	select SYS_CACHE_SHIFT_5
+	imply MMU
 
 config CPU_ARM946ES
 	bool
 	select SYS_CACHE_SHIFT_5
+	imply MMU
 
 config CPU_ARM1136
 	bool
 	select SYS_CACHE_SHIFT_5
+	imply MMU
 
 config CPU_ARM1176
 	bool
 	select HAS_VBAR
 	select SYS_CACHE_SHIFT_5
+	imply MMU
 
 config CPU_V7
 	bool
 	select HAS_VBAR
 	select HAS_THUMB2
 	select SYS_CACHE_SHIFT_6
+	imply MMU
 
 config CPU_V7M
 	bool
@@ -200,10 +213,12 @@ config CPU_V7R
 config CPU_PXA
 	bool
 	select SYS_CACHE_SHIFT_5
+	imply MMU
 
 config CPU_SA1100
 	bool
 	select SYS_CACHE_SHIFT_5
+	imply MMU
 
 config SYS_CPU
 	default "arm720t" if CPU_ARM720T
arch/arm/lib/Makefile +1 -5
index 3d3085e917..f907adc161 100644
@@ -63,11 +63,7 @@ obj-y	+= reset.o
 endif
 
 obj-y	+= cache.o
-ifndef CONFIG_ARM64
-ifndef CONFIG_CPU_V7M
-obj-y	+= cache-cp15.o
-endif
-endif
+obj-$(CONFIG_MMU)	+= cache-cp15.o
 
 obj-y	+= psci-dt.o
 
Signature · 1 line
2.17.0
#7 lore raw

RFC PATCH 3/5 arm: Kconfig: Add entry for MMU

Quoted 87 lines · Lokesh Vutla

Add a Kconfig entry for MMU and imply for all platforms using cache-cp15.c. Using imply instead of select so that MMU can be disabled by defconfigs when not needed.

---
 arch/arm/Kconfig      | 15 +++++++++++++++
 arch/arm/lib/Makefile |  6 +-----
 2 files changed, 16 insertions(+), 5 deletions(-)
arch/arm/Kconfig +15 -0
index de36ab6701..fe5bff097d 100644
@@ -74,6 +74,12 @@ config ARM_ASM_UNIFIED
 config THUMB2_KERNEL
 	bool
 
+config MMU
+	bool "MMU-based Paged Memory Management Support"
+	help
+	  Select if you want MMU-based virtualised addressing space
+	  support by paged memory management.
+
 # If set, the workarounds for these ARM errata are applied early during U-Boot
 # startup. Note that in general these options force the workarounds to be
 # applied; no CPU-type/version detection exists, unlike the similar options in
@@ -158,33 +164,40 @@ config ARM_ERRATA_855873
 config CPU_ARM720T
 	bool
 	select SYS_CACHE_SHIFT_5
+	imply MMU
 
 config CPU_ARM920T
 	bool
 	select SYS_CACHE_SHIFT_5
+	imply MMU
 
 config CPU_ARM926EJS
 	bool
 	select SYS_CACHE_SHIFT_5
+	imply MMU
 
 config CPU_ARM946ES
 	bool
 	select SYS_CACHE_SHIFT_5
+	imply MMU
 
 config CPU_ARM1136
 	bool
 	select SYS_CACHE_SHIFT_5
+	imply MMU
 
 config CPU_ARM1176
 	bool
 	select HAS_VBAR
 	select SYS_CACHE_SHIFT_5
+	imply MMU
 
 config CPU_V7
 	bool
 	select HAS_VBAR
 	select HAS_THUMB2
 	select SYS_CACHE_SHIFT_6
+	imply MMU
 
 config CPU_V7M
 	bool
@@ -200,10 +213,12 @@ config CPU_V7R
 config CPU_PXA
 	bool
 	select SYS_CACHE_SHIFT_5
+	imply MMU
 
 config CPU_SA1100
 	bool
 	select SYS_CACHE_SHIFT_5
+	imply MMU
 
 config SYS_CPU
 	default "arm720t" if CPU_ARM720T
arch/arm/lib/Makefile +0 -0
index 3d3085e917..f907adc161 100644
@@ -63,11 +63,7 @@ obj-y	+= reset.o
 endif

arch/arm/lib/Makefile obj-y += reset.o · line 68

Quoted 10 lines
arch/arm/lib/Makefile +1 -5
 
 obj-y	+= cache.o
-ifndef CONFIG_ARM64
-ifndef CONFIG_CPU_V7M
-obj-y	+= cache-cp15.o
-endif
-endif
+obj-$(CONFIG_MMU)	+= cache-cp15.o
 
 obj-y	+= psci-dt.o

So, funny enough. We have CONFIG_MMU code in ARM today that I bet doesn't work and is just copy/pasted from the kernel and we should drop.

For right here, I think I'd rather see some CONFIG flag about CONFIG_SYS_ARM_CACHE_CP15 instead.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180424/92b418a3/attachment.sig>
#8 lore raw

RFC PATCH 3/5 arm: Kconfig: Add entry for MMU

Quoted 98 lines · Tom Rini
Quoted 96 lines · Lokesh Vutla

Add a Kconfig entry for MMU and imply for all platforms using cache-cp15.c. Using imply instead of select so that MMU can be disabled by defconfigs when not needed.

---
 arch/arm/Kconfig      | 15 +++++++++++++++
 arch/arm/lib/Makefile |  6 +-----
 2 files changed, 16 insertions(+), 5 deletions(-)
arch/arm/Kconfig +15 -0
index de36ab6701..fe5bff097d 100644
@@ -74,6 +74,12 @@ config ARM_ASM_UNIFIED
 config THUMB2_KERNEL
 	bool
 
+config MMU
+	bool "MMU-based Paged Memory Management Support"
+	help
+	  Select if you want MMU-based virtualised addressing space
+	  support by paged memory management.
+
 # If set, the workarounds for these ARM errata are applied early during U-Boot
 # startup. Note that in general these options force the workarounds to be
 # applied; no CPU-type/version detection exists, unlike the similar options in
@@ -158,33 +164,40 @@ config ARM_ERRATA_855873
 config CPU_ARM720T
 	bool
 	select SYS_CACHE_SHIFT_5
+	imply MMU
 
 config CPU_ARM920T
 	bool
 	select SYS_CACHE_SHIFT_5
+	imply MMU
 
 config CPU_ARM926EJS
 	bool
 	select SYS_CACHE_SHIFT_5
+	imply MMU
 
 config CPU_ARM946ES
 	bool
 	select SYS_CACHE_SHIFT_5
+	imply MMU
 
 config CPU_ARM1136
 	bool
 	select SYS_CACHE_SHIFT_5
+	imply MMU
 
 config CPU_ARM1176
 	bool
 	select HAS_VBAR
 	select SYS_CACHE_SHIFT_5
+	imply MMU
 
 config CPU_V7
 	bool
 	select HAS_VBAR
 	select HAS_THUMB2
 	select SYS_CACHE_SHIFT_6
+	imply MMU
 
 config CPU_V7M
 	bool
@@ -200,10 +213,12 @@ config CPU_V7R
 config CPU_PXA
 	bool
 	select SYS_CACHE_SHIFT_5
+	imply MMU
 
 config CPU_SA1100
 	bool
 	select SYS_CACHE_SHIFT_5
+	imply MMU
 
 config SYS_CPU
 	default "arm720t" if CPU_ARM720T
arch/arm/lib/Makefile +1 -5
index 3d3085e917..f907adc161 100644
@@ -63,11 +63,7 @@ obj-y	+= reset.o
 endif
 
 obj-y	+= cache.o
-ifndef CONFIG_ARM64
-ifndef CONFIG_CPU_V7M
-obj-y	+= cache-cp15.o
-endif
-endif
+obj-$(CONFIG_MMU)	+= cache-cp15.o
 
Quoted 7 lines

arch/arm/lib/Makefile obj-y += reset.o · line 68

Quoted 1 line
arch/arm/lib/Makefile +0 -0
 obj-y	+= psci-dt.o

So, funny enough. We have CONFIG_MMU code in ARM today that I bet doesn't work and is just copy/pasted from the kernel and we should drop.

For right here, I think I'd rather see some CONFIG flag about CONFIG_SYS_ARM_CACHE_CP15 instead.

Sure will update it in next version.

Thanks and regards,
Lokesh

#9 lore raw

RFC PATCH 4/5 arm: v7R: Add support for MPU

In reply to Lokesh Vutla

The Memory Protection Unit(MPU) allows to partition memory into regions and set individual protection attributes for each region. In absence of MPU a default map[1] will take effect. Add support for configuring MPU on Cortex-R, by reusing the existing support for Cortex-M processor.

[1] http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0460d/I1002400.html

---
 arch/arm/Kconfig                  |  11 +++
 arch/arm/cpu/armv7/Makefile       |   2 +
 arch/arm/cpu/armv7/mpu_v7r.c      | 109 ++++++++++++++++++++++++++++++
 arch/arm/cpu/armv7m/Makefile      |   3 +-
 arch/arm/cpu/armv7m/mpu.c         |  41 +----------
 arch/arm/include/asm/armv7m_mpu.h |  69 +++++++++++++++++++
 6 files changed, 194 insertions(+), 41 deletions(-)
 create mode 100644 arch/arm/cpu/armv7/mpu_v7r.c
arch/arm/Kconfig +11 -0
index fe5bff097d..2bbfb08578 100644
@@ -80,6 +80,15 @@ config MMU
 	  Select if you want MMU-based virtualised addressing space
 	  support by paged memory management.
 
+config ARM_MPU
+       bool 'Use the ARM v7 PMSA Compliant MPU'
+       help
+         Some ARM systems without an MMU have instead a Memory Protection
+         Unit (MPU) that defines the type and permissions for regions of
+         memory.
+         If your CPU has an MPU then you should choose 'y' here unless you
+         know that you do not want to use the MPU.
+
 # If set, the workarounds for these ARM errata are applied early during U-Boot
 # startup. Note that in general these options force the workarounds to be
 # applied; no CPU-type/version detection exists, unlike the similar options in
@@ -204,11 +213,13 @@ config CPU_V7M
 	select HAS_THUMB2
 	select THUMB2_KERNEL
 	select SYS_CACHE_SHIFT_5
+	select ARM_MPU
 
 config CPU_V7R
 	bool
         select HAS_THUMB2
 	select SYS_CACHE_SHIFT_6
+	select ARM_MPU
 
 config CPU_PXA
 	bool
arch/arm/cpu/armv7/Makefile +2 -0
index b14ee54519..1c8a5ca868 100644
@@ -12,6 +12,8 @@ obj-y	+= cache_v7.o cache_v7_asm.o
 obj-y	+= cpu.o cp15.o
 obj-y	+= syslib.o
 
+obj-$(CONFIG_ARM_MPU) += mpu_v7r.o
+
 ifneq ($(CONFIG_SKIP_LOWLEVEL_INIT),y)
 obj-y	+= lowlevel_init.o
 endif
arch/arm/cpu/armv7/mpu_v7r.c new file +109 -0

109 lines not on this page · raw message

arch/arm/cpu/armv7m/Makefile +2 -1
index 257fc7faf3..3096fa34d3 100644
@@ -6,5 +6,6 @@
 #
 
 extra-y := start.o
-obj-y += cpu.o cache.o mpu.o
+obj-y += cpu.o cache.o
+obj-$(CONFIG_ARM_MPU) += mpu.o
 obj-$(CONFIG_SYS_ARCH_TIMER) += systick-timer.o
arch/arm/cpu/armv7m/mpu.c +1 -40

53 lines not on this page · raw message

arch/arm/include/asm/armv7m_mpu.h +69 -0

79 lines not on this page · raw message

Signature · 1 line
2.17.0
#10 lore raw

RFC PATCH 4/5 arm: v7R: Add support for MPU

Quoted 7 lines · Lokesh Vutla

The Memory Protection Unit(MPU) allows to partition memory into regions and set individual protection attributes for each region. In absence of MPU a default map[1] will take effect. Add support for configuring MPU on Cortex-R, by reusing the existing support for Cortex-M processor.

[1] http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0460d/I1002400.html

Quoted 8 lines
---
 arch/arm/Kconfig                  |  11 +++
 arch/arm/cpu/armv7/Makefile       |   2 +
 arch/arm/cpu/armv7/mpu_v7r.c      | 109 ++++++++++++++++++++++++++++++
 arch/arm/cpu/armv7m/Makefile      |   3 +-
 arch/arm/cpu/armv7m/mpu.c         |  41 +----------
 arch/arm/include/asm/armv7m_mpu.h |  69 +++++++++++++++++++

How close are armv7/mpu_v7r.c and armv7m/mpu.c ? If we did some underlying work so that armv7m/ and be put into armv7/ (and we introduce CPU_V7A say, as I mentioned in another part of the thread so the Makefile isn't too ugly) could we have a single mpu.c file, cleanly?

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180424/071d8ef8/attachment.sig>
#11 lore raw

RFC PATCH 4/5 arm: v7R: Add support for MPU

Quoted 18 lines · Tom Rini
Quoted 7 lines · Lokesh Vutla

The Memory Protection Unit(MPU) allows to partition memory into regions and set individual protection attributes for each region. In absence of MPU a default map[1] will take effect. Add support for configuring MPU on Cortex-R, by reusing the existing support for Cortex-M processor.

[1] http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0460d/I1002400.html

Quoted 8 lines
---
 arch/arm/Kconfig                  |  11 +++
 arch/arm/cpu/armv7/Makefile       |   2 +
 arch/arm/cpu/armv7/mpu_v7r.c      | 109 ++++++++++++++++++++++++++++++
 arch/arm/cpu/armv7m/Makefile      |   3 +-
 arch/arm/cpu/armv7m/mpu.c         |  41 +----------
 arch/arm/include/asm/armv7m_mpu.h |  69 +++++++++++++++++++
Quoted 5 lines

How close are armv7/mpu_v7r.c and armv7m/mpu.c ? If we did some underlying work so that armv7m/ and be put into armv7/ (and we introduce CPU_V7A say, as I mentioned in another part of the thread so the Makefile isn't too ugly) could we have a single mpu.c file, cleanly?

I did start with that but found out that the way we program the mpu registers are entirely different. For v7m mmio registers are used, but for v7r system registers are used. I couldn't find a way to get a common driver for these two. If you prefer #ifdefs and merged these two, I can do it but it doesn't look clean.

Thanks and regards,
Lokesh

#12 lore raw

RFC PATCH 4/5 arm: v7R: Add support for MPU

Quoted 27 lines · Lokesh Vutla
Quoted 18 lines · Tom Rini
Quoted 7 lines · Lokesh Vutla

The Memory Protection Unit(MPU) allows to partition memory into regions and set individual protection attributes for each region. In absence of MPU a default map[1] will take effect. Add support for configuring MPU on Cortex-R, by reusing the existing support for Cortex-M processor.

[1] http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0460d/I1002400.html

Quoted 8 lines
---
 arch/arm/Kconfig                  |  11 +++
 arch/arm/cpu/armv7/Makefile       |   2 +
 arch/arm/cpu/armv7/mpu_v7r.c      | 109 ++++++++++++++++++++++++++++++
 arch/arm/cpu/armv7m/Makefile      |   3 +-
 arch/arm/cpu/armv7m/mpu.c         |  41 +----------
 arch/arm/include/asm/armv7m_mpu.h |  69 +++++++++++++++++++
Quoted 5 lines

How close are armv7/mpu_v7r.c and armv7m/mpu.c ? If we did some underlying work so that armv7m/ and be put into armv7/ (and we introduce CPU_V7A say, as I mentioned in another part of the thread so the Makefile isn't too ugly) could we have a single mpu.c file, cleanly?

Quoted 5 lines

I did start with that but found out that the way we program the mpu registers are entirely different. For v7m mmio registers are used, but for v7r system registers are used. I couldn't find a way to get a common driver for these two. If you prefer #ifdefs and merged these two, I can do it but it doesn't look clean.

OK, if it's not clean then it's not clean. But lets go for consistent file naming. And how about adding a CPU_V7A flag so that we could dump the armv7m directory in? Then mpu_v7[mr].c would make sense too.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180424/1e6ddf89/attachment.sig>
#13 lore raw

RFC PATCH 4/5 arm: v7R: Add support for MPU

Quoted 28 lines · Tom Rini
Quoted 27 lines · Lokesh Vutla
Quoted 23 lines · Tom Rini
Quoted 7 lines · Lokesh Vutla

The Memory Protection Unit(MPU) allows to partition memory into regions and set individual protection attributes for each region. In absence of MPU a default map[1] will take effect. Add support for configuring MPU on Cortex-R, by reusing the existing support for Cortex-M processor.

[1] http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0460d/I1002400.html

Quoted 8 lines
---
 arch/arm/Kconfig                  |  11 +++
 arch/arm/cpu/armv7/Makefile       |   2 +
 arch/arm/cpu/armv7/mpu_v7r.c      | 109 ++++++++++++++++++++++++++++++
 arch/arm/cpu/armv7m/Makefile      |   3 +-
 arch/arm/cpu/armv7m/mpu.c         |  41 +----------
 arch/arm/include/asm/armv7m_mpu.h |  69 +++++++++++++++++++

How close are armv7/mpu_v7r.c and armv7m/mpu.c ? If we did some underlying work so that armv7m/ and be put into armv7/ (and we introduce CPU_V7A say, as I mentioned in another part of the thread so the Makefile isn't too ugly) could we have a single mpu.c file, cleanly?

Quoted 8 lines
Quoted 5 lines

I did start with that but found out that the way we program the mpu registers are entirely different. For v7m mmio registers are used, but for v7r system registers are used. I couldn't find a way to get a common driver for these two. If you prefer #ifdefs and merged these two, I can do it but it doesn't look clean.

OK, if it's not clean then it's not clean. But lets go for consistent file naming. And how about adding a CPU_V7A flag so that we could dump

okay. Will try to create CPU_V7A flag and see how things looks like.

Thanks and regards,
Lokesh

Quoted 2 lines

the armv7m directory in? Then mpu_v7[mr].c would make sense too.

#14 lore raw

RFC PATCH 5/5 arm: v7R: Add support for enabling caches

In reply to Lokesh Vutla

Cache maintenance procedure is same for v7 and v7R processors. So re-use cache-cp15.c file except for mmu parts.

---
 arch/arm/cpu/armv7/mpu_v7r.c | 11 +++++++++++
 arch/arm/lib/Makefile        |  3 +++
 arch/arm/lib/cache-cp15.c    | 14 +++++++++++++-
 3 files changed, 27 insertions(+), 1 deletion(-)
arch/arm/cpu/armv7/mpu_v7r.c +11 -0
index 703f744b31..b998ab9320 100644
@@ -107,3 +107,14 @@ void setup_mpu_regions(struct mpu_region_config *rgns, u32 num_rgns)
 
 	icache_enable();
 }
+
+void enable_caches(void)
+{
+	/*
+	 * setup_mpu_regions() might have enabled Icache. So add a check
+	 * before enabling Icache
+	 */
+	if (!icache_status())
+		icache_enable();
+	dcache_enable();
+}
arch/arm/lib/Makefile +3 -0
index f907adc161..f8377ba18a 100644
@@ -64,6 +64,9 @@ endif
 
 obj-y	+= cache.o
 obj-$(CONFIG_MMU)	+= cache-cp15.o
+ifeq ($(CONFIG_CPU_V7R)$(CONFIG_ARM_MPU),yy)
+obj-y	+= cache-cp15.o
+endif
 
 obj-y	+= psci-dt.o
 
arch/arm/lib/cache-cp15.c +13 -1
index f0c1b03728..fea7d3fdec 100644
@@ -9,11 +9,15 @@
 #include <asm/system.h>
 #include <asm/cache.h>
 #include <linux/compiler.h>
+#ifdef CONFIG_ARM_MPU
+#include <asm/armv7m_mpu.h>
+#endif
 
 #if !(defined(CONFIG_SYS_ICACHE_OFF) && defined(CONFIG_SYS_DCACHE_OFF))
 
 DECLARE_GLOBAL_DATA_PTR;
 
+#ifdef CONFIG_MMU
 __weak void arm_init_before_mmu(void)
 {
 }
@@ -202,15 +206,23 @@ static int mmu_enabled(void)
 {
 	return get_cr() & CR_M;
 }
+#endif /* CONFIG_MMU */
 
 /* cache_bit must be either CR_I or CR_C */
 static void cache_enable(uint32_t cache_bit)
 {
 	uint32_t reg;
 
-	/* The data cache is not active unless the mmu is enabled too */
+	/* The data cache is not active unless the mmu/mpu is enabled too */
+#ifdef CONFIG_MMU
 	if ((cache_bit == CR_C) && !mmu_enabled())
 		mmu_setup();
+#elif defined(CONFIG_ARM_MPU)
+	if ((cache_bit == CR_C) && !mpu_enabled()) {
+		printf("Consider enabling MPU before enabling caches\n");
+		return;
+	}
+#endif
 	reg = get_cr();	/* get control reg. */
 	set_cr(reg | cache_bit);
 }
Signature · 1 line
2.17.0
#15 lore raw

RFC PATCH 5/5 arm: v7R: Add support for enabling caches

Quoted 3 lines · Lokesh Vutla

Cache maintenance procedure is same for v7 and v7R processors. So re-use cache-cp15.c file except for mmu parts.

I also don't like CONFIG_MMU as it's too generic of a name. Since for this part of the series we need a flag for "we have an MMU we need to fiddle", CONFIG_SYS_ARM_MMU ? Thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180424/391ded3e/attachment.sig>
#16 lore raw

RFC PATCH 5/5 arm: v7R: Add support for enabling caches

Quoted 10 lines · Tom Rini
Quoted 3 lines · Lokesh Vutla

Cache maintenance procedure is same for v7 and v7R processors. So re-use cache-cp15.c file except for mmu parts.

I also don't like CONFIG_MMU as it's too generic of a name. Since for this part of the series we need a flag for "we have an MMU we need to fiddle", CONFIG_SYS_ARM_MMU ? Thanks!

okay will make it CONFIG_SYS_ARM_MMU instead.

Thanks and regards,
Lokesh

#17 lore raw

cover arm: Introduce v7R support

In reply to Lokesh Vutla
Quoted 8 lines · Lokesh Vutla

The Cortex-R* processors are a mid-range CPUs for use in deeply-embedded, real-time systems. It implements the ARMv7-R architecture, and includes Thumb-2 technology for optimum code density and processing throughput.

Except for MPU(Memory Protection Unit) and few CP15 registers, most of the features are compatible with v7 architecture. This series adds minimal support for v7-R architecture by reusing the v7 support. Also adding support for MPU.

There's some whitespace issues that I'm sure you'll fix for the next version. One naming thing that I think needs a little work is that we say CONFIG_ARM_MPU (which is OK'ish, can we use something a little more specific? It's a V7 architectural thing, yes?) but then v7m_mpu.h, even tho we use it on both v7r and v7m as there's just a few differences. That should get consolidated, off the top of my head, to CONFIG_CPU_V7_HAS_MPU (following other things like virt) and maybe v7_mpu.h ?

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180424/d9cf2adb/attachment.sig>
#18 lore raw

cover arm: Introduce v7R support

In reply to Lokesh Vutla

Hi Lokesh,

Quoted 18 lines · Lokesh Vutla

The Cortex-R* processors are a mid-range CPUs for use in deeply-embedded, real-time systems. It implements the ARMv7-R architecture, and includes Thumb-2 technology for optimum code density and processing throughput.

Except for MPU(Memory Protection Unit) and few CP15 registers, most of the features are compatible with v7 architecture. This series adds minimal support for v7-R architecture by reusing the v7 support. Also adding support for MPU.

Lokesh Vutla (4):
arm: v7: Update VBAR only if available
arm: Kconfig: Add entry for MMU
arm: v7R: Add support for MPU
arm: v7R: Add support for enabling caches

Michal Simek (1):
arm: v7R: Add initial support

Quoted 13 lines
 arch/arm/Kconfig                  |  33 ++++++++
 arch/arm/Makefile                 |   2 +
 arch/arm/cpu/armv7/Makefile       |   2 +
 arch/arm/cpu/armv7/mpu_v7r.c      | 120 ++++++++++++++++++++++++++++++
 arch/arm/cpu/armv7/start.S        |   4 +
 arch/arm/cpu/armv7m/Makefile      |   3 +-
 arch/arm/cpu/armv7m/mpu.c         |  41 +---------
 arch/arm/include/asm/armv7m_mpu.h |  69 +++++++++++++++++
 arch/arm/lib/Makefile             |   5 +-
 arch/arm/lib/cache-cp15.c         |  14 +++-
 10 files changed, 248 insertions(+), 45 deletions(-)
 create mode 100644 arch/arm/cpu/armv7/mpu_v7r.c

I have tested your series, also wired MPU (protect one region and try to access it) and with caches on and off (running mtest to see number of iterations and improving numbers with cache on) and nothing is showing any functional fundamental problem.

Thanks,
Michal

#19 lore raw

cover arm: Introduce v7R support

Hi Michal,

Quoted 35 lines · Michal Simek

Hi Lokesh,

Quoted 18 lines · Lokesh Vutla

The Cortex-R* processors are a mid-range CPUs for use in deeply-embedded, real-time systems. It implements the ARMv7-R architecture, and includes Thumb-2 technology for optimum code density and processing throughput.

Except for MPU(Memory Protection Unit) and few CP15 registers, most of the features are compatible with v7 architecture. This series adds minimal support for v7-R architecture by reusing the v7 support. Also adding support for MPU.

Lokesh Vutla (4):
arm: v7: Update VBAR only if available
arm: Kconfig: Add entry for MMU
arm: v7R: Add support for MPU
arm: v7R: Add support for enabling caches

Michal Simek (1):
arm: v7R: Add initial support

Quoted 13 lines
 arch/arm/Kconfig                  |  33 ++++++++
 arch/arm/Makefile                 |   2 +
 arch/arm/cpu/armv7/Makefile       |   2 +
 arch/arm/cpu/armv7/mpu_v7r.c      | 120 ++++++++++++++++++++++++++++++
 arch/arm/cpu/armv7/start.S        |   4 +
 arch/arm/cpu/armv7m/Makefile      |   3 +-
 arch/arm/cpu/armv7m/mpu.c         |  41 +---------
 arch/arm/include/asm/armv7m_mpu.h |  69 +++++++++++++++++
 arch/arm/lib/Makefile             |   5 +-
 arch/arm/lib/cache-cp15.c         |  14 +++-
 10 files changed, 248 insertions(+), 45 deletions(-)
 create mode 100644 arch/arm/cpu/armv7/mpu_v7r.c
Quoted 4 lines

I have tested your series, also wired MPU (protect one region and try to access it) and with caches on and off (running mtest to see number of iterations and improving numbers with cache on) and nothing is showing any functional fundamental problem.

Thanks a lot for testing. Can I take it as your Tested-by:?

Thanks and regards,
Lokesh

#20 lore raw

cover arm: Introduce v7R support

Quoted 38 lines · Lokesh Vutla

Hi Michal,

Quoted 35 lines · Michal Simek

Hi Lokesh,

Quoted 31 lines · Lokesh Vutla

The Cortex-R* processors are a mid-range CPUs for use in deeply-embedded, real-time systems. It implements the ARMv7-R architecture, and includes Thumb-2 technology for optimum code density and processing throughput.

Except for MPU(Memory Protection Unit) and few CP15 registers, most of the features are compatible with v7 architecture. This series adds minimal support for v7-R architecture by reusing the v7 support. Also adding support for MPU.

Lokesh Vutla (4):
arm: v7: Update VBAR only if available
arm: Kconfig: Add entry for MMU
arm: v7R: Add support for MPU
arm: v7R: Add support for enabling caches

Michal Simek (1):
arm: v7R: Add initial support

 arch/arm/Kconfig                  |  33 ++++++++
 arch/arm/Makefile                 |   2 +
 arch/arm/cpu/armv7/Makefile       |   2 +
 arch/arm/cpu/armv7/mpu_v7r.c      | 120 ++++++++++++++++++++++++++++++
 arch/arm/cpu/armv7/start.S        |   4 +
 arch/arm/cpu/armv7m/Makefile      |   3 +-
 arch/arm/cpu/armv7m/mpu.c         |  41 +---------
 arch/arm/include/asm/armv7m_mpu.h |  69 +++++++++++++++++
 arch/arm/lib/Makefile             |   5 +-
 arch/arm/lib/cache-cp15.c         |  14 +++-
 10 files changed, 248 insertions(+), 45 deletions(-)
 create mode 100644 arch/arm/cpu/armv7/mpu_v7r.c
Quoted 6 lines
Quoted 4 lines

I have tested your series, also wired MPU (protect one region and try to access it) and with caches on and off (running mtest to see number of iterations and improving numbers with cache on) and nothing is showing any functional fundamental problem.

Thanks a lot for testing. Can I take it as your Tested-by:?

I didn't add it officially because I expect v1 based on comments. It means I will test v1 again and give you that.

Thanks,
Michal