Skip to contentSkip to conversation

add armv7m cache support

PATCH Superseded Vikas Manocha 3 participants 6 messages Mar 14, 2017 – Mar 17, 2017

Subsystems (3)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v3 cover add armv7m cache support

This patchset adds armv7m instruction/data caches support & enable it for stm32f7.

Changed in v3:
- uint32 replcaed with u32.
- multiple read of hardware register replaced with single.
- pointers replaced with macros for base address.
- register names added as comment for system control block registers.

Changed in v2:
- changed strucures for memory mapped cache registers to macros
- added lines better readability.
- replaced magic numbers with macros.

Vikas Manocha (2):
armv7m: add instruction & data cache support
stm32f7: enable instruction & data cache

 arch/arm/cpu/armv7m/Makefile      |   2 +-
 arch/arm/cpu/armv7m/cache.c       | 291 ++++++++++++++++++++++++++++++++++++++
 arch/arm/include/asm/armv7m.h     |  26 +++-
 arch/arm/lib/Makefile             |   2 +
 arch/arm/mach-stm32/stm32f7/soc.c |   2 +
 include/configs/stm32f746-disco.h |   4 +-
 6 files changed, 321 insertions(+), 6 deletions(-)
 create mode 100644 arch/arm/cpu/armv7m/cache.c
Signature · 1 line
1.9.1
#1 lore raw

PATCH v3 1/2 armv7m: add instruction & data cache support

This patch adds armv7m instruction & data cache support.

cc Christophe KERELLO <[email protected]>

---

Changed in v3:
- uint32 replcaed with u32.
- multiple read of hardware register replaced with single.
- pointers replaced with macros for base address.
- register names added as comment for system control block registers.

Changed in v2:
- changed strucures for memory mapped cache registers to macros
- added lines better readability.
- replaced magic numbers with macros.

 arch/arm/cpu/armv7m/Makefile  |   2 +-
 arch/arm/cpu/armv7m/cache.c   | 291 ++++++++++++++++++++++++++++++++++++++++++
 arch/arm/include/asm/armv7m.h |  26 +++-
 arch/arm/lib/Makefile         |   2 +
 4 files changed, 318 insertions(+), 3 deletions(-)
 create mode 100644 arch/arm/cpu/armv7m/cache.c
arch/arm/cpu/armv7m/Makefile +1 -1
index aff60e8..41efe11 100644
@@ -6,4 +6,4 @@
 #
 
 extra-y := start.o
-obj-y += cpu.o
+obj-y += cpu.o cache.o
arch/arm/cpu/armv7m/cache.c new file +291 -0

291 lines not on this page · raw message

arch/arm/include/asm/armv7m.h +24 -2
index 54d8a2b..ebf0f17 100644
@@ -16,8 +16,15 @@
 .thumb
 #endif
 
-#define V7M_SCB_BASE		0xE000ED00
-#define V7M_MPU_BASE		0xE000ED90
+/* armv7m fixed base addresses */
+#define V7M_SCS_BASE		0xE000E000
+#define V7M_NVIC_BASE		(V7M_SCS_BASE + 0x0100)
+#define V7M_SCB_BASE		(V7M_SCS_BASE + 0x0D00)
+#define V7M_PROC_FTR_BASE	(V7M_SCS_BASE + 0x0D78)
+#define V7M_MPU_BASE		(V7M_SCS_BASE + 0x0D90)
+#define V7M_FPU_BASE		(V7M_SCS_BASE + 0x0F30)
+#define V7M_CACHE_MAINT_BASE	(V7M_SCS_BASE + 0x0F50)
+#define V7M_ACCESS_CNTL_BASE	(V7M_SCS_BASE + 0x0F90)
 
 #define V7M_SCB_VTOR		0x08
 
@@ -27,6 +34,18 @@ struct v7m_scb {
 	uint32_t icsr;		/* Interrupt Control and State Register */
 	uint32_t vtor;		/* Vector Table Offset Register */
 	uint32_t aircr;		/* App Interrupt and Reset Control Register */
+	uint32_t scr;		/* offset 0x10: System Control Register */
+	uint32_t ccr;		/* offset 0x14: Config and Control Register */
+	uint32_t shpr1;		/* offset 0x18: System Handler Priority Reg 1 */
+	uint32_t shpr2;		/* offset 0x1c: System Handler Priority Reg 2 */
+	uint32_t shpr3;		/* offset 0x20: System Handler Priority Reg 3 */
+	uint32_t shcrs;		/* offset 0x24: System Handler Control State */
+	uint32_t cfsr;		/* offset 0x28: Configurable Fault Status Reg */
+	uint32_t hfsr;		/* offset 0x2C: HardFault Status Register */
+	uint32_t res;		/* offset 0x30: reserved */
+	uint32_t mmar;		/* offset 0x34: MemManage Fault Address Reg */
+	uint32_t bfar;		/* offset 0x38: BusFault Address Reg */
+	uint32_t afsr;		/* offset 0x3C: Auxiliary Fault Status Reg */
 };
 #define V7M_SCB				((struct v7m_scb *)V7M_SCB_BASE)
 
@@ -39,6 +58,9 @@ struct v7m_scb {
 
 #define V7M_ICSR_VECTACT_MSK		0xFF
 
+#define V7M_CCR_DCACHE			16
+#define V7M_CCR_ICACHE			17
+
 struct v7m_mpu {
 	uint32_t type;		/* Type Register */
 	uint32_t ctrl;		/* Control Register */
arch/arm/lib/Makefile +2 -0
index 166fa9e..52b36b3 100644
@@ -55,8 +55,10 @@ endif
 
 obj-y	+= cache.o
 ifndef CONFIG_ARM64
+ifndef CONFIG_CPU_V7M
 obj-y	+= cache-cp15.o
 endif
+endif
 
 obj-y	+= psci-dt.o
 
Signature · 1 line
1.9.1
#2 lore raw

PATCH v3 1/2 armv7m: add instruction & data cache support

Quoted 17 lines · Vikas Manocha

This patch adds armv7m instruction & data cache support.

cc Christophe KERELLO <[email protected]>

---

Changed in v3:
- uint32 replcaed with u32.
- multiple read of hardware register replaced with single.
- pointers replaced with macros for base address.
- register names added as comment for system control block registers.

Changed in v2:
- changed strucures for memory mapped cache registers to macros
- added lines better readability.
- replaced magic numbers with macros.

Quoted 6 lines
 arch/arm/cpu/armv7m/Makefile  |   2 +-
 arch/arm/cpu/armv7m/cache.c   | 291 ++++++++++++++++++++++++++++++++++++++++++
 arch/arm/include/asm/armv7m.h |  26 +++-
 arch/arm/lib/Makefile         |   2 +
 4 files changed, 318 insertions(+), 3 deletions(-)
 create mode 100644 arch/arm/cpu/armv7m/cache.c

Please address comments on V2 before sending V3 ...

Signature · 2 lines
Best regards,
Marek Vasut
#3 lore raw

PATCH v3 1/2 armv7m: add instruction & data cache support

In reply to Vikas Manocha

Hi Vikas,

Quoted 41 lines · Vikas Manocha

This patch adds armv7m instruction & data cache support.

cc Christophe KERELLO <[email protected]>

---

Changed in v3:
- uint32 replcaed with u32.
- multiple read of hardware register replaced with single.
- pointers replaced with macros for base address.
- register names added as comment for system control block registers.

Changed in v2:
- changed strucures for memory mapped cache registers to macros
- added lines better readability.
- replaced magic numbers with macros.

 arch/arm/cpu/armv7m/Makefile  |   2 +-
 arch/arm/cpu/armv7m/cache.c   | 291 ++++++++++++++++++++++++++++++++++++++++++
 arch/arm/include/asm/armv7m.h |  26 +++-
 arch/arm/lib/Makefile         |   2 +
 4 files changed, 318 insertions(+), 3 deletions(-)
 create mode 100644 arch/arm/cpu/armv7m/cache.c
arch/arm/cpu/armv7m/Makefile +1 -1
index aff60e8..41efe11 100644
@@ -6,4 +6,4 @@
 #
 
 extra-y := start.o
-obj-y += cpu.o
+obj-y += cpu.o cache.o
arch/arm/cpu/armv7m/cache.c new file +1 -0
new file mode 100644
index 0000000..9021525
@@ -0,0 +1,291 @@
+/*

arch/arm/cpu/armv7m/cache.c line 11

Quoted 10 lines
arch/arm/cpu/armv7m/cache.c new file +10 -0
+ * (C) Copyright 2017
+ * Vikas Manocha, ST Micoelectronics, vikas.manocha at st.com.
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#include <common.h>
+#include <asm/armv7m.h>
+#include <asm/io.h>
+#include <errno.h>

put this one below common.h

Quoted 21 lines
arch/arm/cpu/armv7m/cache.c new file +21 -0
+
+/* Cache maintenance operation registers */
+
+#define IC_IALLU               (V7M_CACHE_MAINT_BASE + 0x00)
+#define INVAL_ICACHE_POU       0
+#define IC_IMVALU              (V7M_CACHE_MAINT_BASE + 0x08)
+#define DC_IMVAC               (V7M_CACHE_MAINT_BASE + 0x0C)
+#define DC_ISW                 (V7M_CACHE_MAINT_BASE + 0x10)
+#define DC_CMVAU               (V7M_CACHE_MAINT_BASE + 0x14)
+#define DC_CMVAC               (V7M_CACHE_MAINT_BASE + 0x18)
+#define DC_CSW                 (V7M_CACHE_MAINT_BASE + 0x1C)
+#define DC_CIMVAC              (V7M_CACHE_MAINT_BASE + 0x20)
+#define DC_CISW                        (V7M_CACHE_MAINT_BASE + 0x24)
+#define WAYS_SHIFT             30
+#define SETS_SHIFT             5
+
+/* armv7m processor feature registers */
+
+#define CLIDR                  (V7M_PROC_FTR_BASE + 0x00)
+#define CTR                    (V7M_PROC_FTR_BASE + 0x04)
+#define CCSIDR                 (V7M_PROC_FTR_BASE + 0x08)

arch/arm/cpu/armv7m/cache.c line 42

Quoted 10 lines
arch/arm/cpu/armv7m/cache.c new file +10 -0
+#define MASK_NUM_WAYS          GENMASK(12, 3)
+#define MASK_NUM_SETS          GENMASK(27, 13)
+#define CLINE_SIZE_MASK                GENMASK(2, 0)
+#define NUM_WAYS_SHIFT         3
+#define NUM_SETS_SHIFT         13
+#define CSSELR                 (V7M_PROC_FTR_BASE + 0x0C)
+#define SEL_I_OR_D             BIT(0)
+
+enum cache_type {
+       DCACHE = 0,

Do you need the =0 ?

arch/arm/cpu/armv7m/cache.c line 55

Quoted 13 lines
arch/arm/cpu/armv7m/cache.c new file +13 -0
+       ICACHE,
+};
+
+/* PoU : Point of Unification, Poc: Point of Coherency */
+enum cache_action {
+       INVALIDATE_POU,         /* for i-cache invalidate by address */
+       INVALIDATE_POC,         /* for d-cache invalidate by address */
+       INVALIDATE_SET_WAY,     /* for d-cache invalidate by sets/ways */
+       FLUSH_POU,
+       FLUSH_POC,
+       FLUSH_SET_WAY,
+       FLUSH_INVAL_POC,
+       FLUSH_INVAL_SET_WAY,

Can you add comments for the rest?

arch/arm/cpu/armv7m/cache.c line 66

Quoted 11 lines
arch/arm/cpu/armv7m/cache.c new file +11 -0
+};
+
+#ifndef CONFIG_SYS_DCACHE_OFF
+struct dcache_config {
+       u32 ways;
+       u32 sets;
+};
+
+static void get_cache_ways_sets(struct dcache_config *cache)
+{
+       u32 cache_size_id = readl(CCSIDR);

blank line here

arch/arm/cpu/armv7m/cache.c line 71

Quoted 5 lines
arch/arm/cpu/armv7m/cache.c new file +5 -0
+       cache->ways = (cache_size_id & MASK_NUM_WAYS) >> NUM_WAYS_SHIFT;
+       cache->sets = (cache_size_id & MASK_NUM_SETS) >> NUM_SETS_SHIFT;
+}
+
+static u32 *get_action_reg_set_ways(enum cache_action action)

Can you please add a function comment? What does this return?

arch/arm/cpu/armv7m/cache.c line 75

Quoted 4 lines
arch/arm/cpu/armv7m/cache.c new file +4 -0
+{
+       switch (action) {
+       case INVALIDATE_SET_WAY:
+               return (u32 *)DC_ISW;

Can you drop these casts by using a C structure or by putting thecast in the #define?

Quoted 22 lines
arch/arm/cpu/armv7m/cache.c new file +22 -0
+       case FLUSH_SET_WAY:
+               return (u32 *)DC_CSW;
+       case FLUSH_INVAL_SET_WAY:
+               return (u32 *)DC_CISW;
+       default:
+               break;
+       };
+
+       return NULL;
+}
+
+static u32 *get_action_reg_range(enum cache_action action)
+{
+       switch (action) {
+       case INVALIDATE_POU:
+               return (u32 *)IC_IMVALU;
+       case INVALIDATE_POC:
+               return (u32 *)DC_IMVAC;
+       case FLUSH_POU:
+               return (u32 *)DC_CMVAU;
+       case FLUSH_POC:
+               return (u32 *)DC_CMVAC;

arch/arm/cpu/armv7m/cache.c line 107

Quoted 10 lines
arch/arm/cpu/armv7m/cache.c new file +10 -0
+       case FLUSH_INVAL_POC:
+               return (u32 *)DC_CIMVAC;
+       default:
+               break;
+       }
+
+       return NULL;
+}
+
+static u32 get_cline_size(enum cache_type type)

Why u32? Should it be uint or ulong?

Quoted 9 lines
arch/arm/cpu/armv7m/cache.c new file +9 -0
+{
+       u32 size;
+
+       if (type == DCACHE)
+               clrbits_le32(CSSELR, BIT(SEL_I_OR_D));
+       else if (type == ICACHE)
+               setbits_le32(CSSELR, BIT(SEL_I_OR_D));
+       dsb();
+

arch/arm/cpu/armv7m/cache.c line 126

Quoted 10 lines
arch/arm/cpu/armv7m/cache.c new file +10 -0
+       size = readl(CCSIDR) & CLINE_SIZE_MASK;
+       /* Size enocoded as 2 less than log(no_of_words_in_cache_line) base 2 */
+       size = 1 << (size + 2);
+       debug("cache line size is %d\n", size);
+
+       return size;
+}
+
+static __attribute__((unused)) int action_cache_range(enum cache_action action,
+                    u32 start_addr, int64_t size)

Function comment.

Can you use __used ?

Quoted 20 lines
arch/arm/cpu/armv7m/cache.c new file +20 -0
+{
+       u32 cline_size;
+       u32 *action_reg;
+       enum cache_type type;
+
+       action_reg = get_action_reg_range(action);
+       if (!action_reg)
+               return -EINVAL;
+       if (action == INVALIDATE_POU)
+               type = ICACHE;
+       else
+               type = DCACHE;
+
+       /* Cache line size is minium size for the cache action */
+       cline_size = get_cline_size(type);
+       /* Align start address to cache line boundary */
+       start_addr &= ~(cline_size - 1);
+       do {
+               writel(start_addr, action_reg);
+               size -= cline_size;

arch/arm/cpu/armv7m/cache.c line 156

Quoted 10 lines
arch/arm/cpu/armv7m/cache.c new file +10 -0
+               start_addr += cline_size;
+       } while (size > cline_size);
+       dsb();
+       isb();
+       debug("cache action on range done\n");
+
+       return 0;
+}
+
+static int action_dcache_all(enum cache_action action)

Function comment.

Regards,
Simon

#4 lore raw

PATCH v3 1/2 armv7m: add instruction & data cache support

Thanks Simon,

Quoted 48 lines · Simon Glass

Hi Vikas,

Quoted 45 lines · Vikas Manocha

This patch adds armv7m instruction & data cache support.

cc Christophe KERELLO <[email protected]>

---

Changed in v3:
- uint32 replcaed with u32.
- multiple read of hardware register replaced with single.
- pointers replaced with macros for base address.
- register names added as comment for system control block registers.

Changed in v2:
- changed strucures for memory mapped cache registers to macros
- added lines better readability.
- replaced magic numbers with macros.

 arch/arm/cpu/armv7m/Makefile  |   2 +-
 arch/arm/cpu/armv7m/cache.c   | 291 ++++++++++++++++++++++++++++++++++++++++++
 arch/arm/include/asm/armv7m.h |  26 +++-
 arch/arm/lib/Makefile         |   2 +
 4 files changed, 318 insertions(+), 3 deletions(-)
 create mode 100644 arch/arm/cpu/armv7m/cache.c
arch/arm/cpu/armv7m/Makefile +1 -1
index aff60e8..41efe11 100644
@@ -6,4 +6,4 @@
 #
 
 extra-y := start.o
-obj-y += cpu.o
+obj-y += cpu.o cache.o
arch/arm/cpu/armv7m/cache.c new file +5 -0
new file mode 100644
index 0000000..9021525
@@ -0,0 +1,291 @@
+/*
+ * (C) Copyright 2017
+ * Vikas Manocha, ST Micoelectronics, vikas.manocha at st.com.
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
Quoted 8 lines

arch/arm/cpu/armv7m/cache.c line 11

Quoted 6 lines
arch/arm/cpu/armv7m/cache.c new file +6 -0
+ */
+
+#include <common.h>
+#include <asm/armv7m.h>
+#include <asm/io.h>
+#include <errno.h>

put this one below common.h

oh yes, ok.

Quoted 26 lines
Quoted 26 lines
arch/arm/cpu/armv7m/cache.c new file +25 -0
+
+/* Cache maintenance operation registers */
+
+#define IC_IALLU               (V7M_CACHE_MAINT_BASE + 0x00)
+#define INVAL_ICACHE_POU       0
+#define IC_IMVALU              (V7M_CACHE_MAINT_BASE + 0x08)
+#define DC_IMVAC               (V7M_CACHE_MAINT_BASE + 0x0C)
+#define DC_ISW                 (V7M_CACHE_MAINT_BASE + 0x10)
+#define DC_CMVAU               (V7M_CACHE_MAINT_BASE + 0x14)
+#define DC_CMVAC               (V7M_CACHE_MAINT_BASE + 0x18)
+#define DC_CSW                 (V7M_CACHE_MAINT_BASE + 0x1C)
+#define DC_CIMVAC              (V7M_CACHE_MAINT_BASE + 0x20)
+#define DC_CISW                        (V7M_CACHE_MAINT_BASE + 0x24)
+#define WAYS_SHIFT             30
+#define SETS_SHIFT             5
+
+/* armv7m processor feature registers */
+
+#define CLIDR                  (V7M_PROC_FTR_BASE + 0x00)
+#define CTR                    (V7M_PROC_FTR_BASE + 0x04)
+#define CCSIDR                 (V7M_PROC_FTR_BASE + 0x08)
+#define MASK_NUM_WAYS          GENMASK(12, 3)
+#define MASK_NUM_SETS          GENMASK(27, 13)
+#define CLINE_SIZE_MASK                GENMASK(2, 0)
+#define NUM_WAYS_SHIFT         3
Quoted 8 lines

arch/arm/cpu/armv7m/cache.c line 42

Quoted 6 lines
arch/arm/cpu/armv7m/cache.c new file +6 -0
+#define NUM_SETS_SHIFT         13
+#define CSSELR                 (V7M_PROC_FTR_BASE + 0x0C)
+#define SEL_I_OR_D             BIT(0)
+
+enum cache_type {
+       DCACHE = 0,

Do you need the =0 ?

No :-), thanks.

Quoted 16 lines
Quoted 4 lines
arch/arm/cpu/armv7m/cache.c new file +3 -0
+       ICACHE,
+};
+

arch/arm/cpu/armv7m/cache.c line 55

Quoted 10 lines
arch/arm/cpu/armv7m/cache.c new file +10 -0
+/* PoU : Point of Unification, Poc: Point of Coherency */
+enum cache_action {
+       INVALIDATE_POU,         /* for i-cache invalidate by address */
+       INVALIDATE_POC,         /* for d-cache invalidate by address */
+       INVALIDATE_SET_WAY,     /* for d-cache invalidate by sets/ways */
+       FLUSH_POU,
+       FLUSH_POC,
+       FLUSH_SET_WAY,
+       FLUSH_INVAL_POC,
+       FLUSH_INVAL_SET_WAY,

Can you add comments for the rest?

sure.

Quoted 14 lines

arch/arm/cpu/armv7m/cache.c line 66

Quoted 12 lines
arch/arm/cpu/armv7m/cache.c new file +11 -0
+};
+
+#ifndef CONFIG_SYS_DCACHE_OFF
+struct dcache_config {
+       u32 ways;
+       u32 sets;
+};
+
+static void get_cache_ways_sets(struct dcache_config *cache)
+{
+       u32 cache_size_id = readl(CCSIDR);

blank line here

ok.

Quoted 8 lines

arch/arm/cpu/armv7m/cache.c line 71

Quoted 6 lines
arch/arm/cpu/armv7m/cache.c new file +5 -0
+       cache->ways = (cache_size_id & MASK_NUM_WAYS) >> NUM_WAYS_SHIFT;
+       cache->sets = (cache_size_id & MASK_NUM_SETS) >> NUM_SETS_SHIFT;
+}
+
+static u32 *get_action_reg_set_ways(enum cache_action action)

Can you please add a function comment? What does this return?

this function returns the io register to perform required cache action like clean or clean & invalidate by sets/ways. The procedure to perform on these io register is same for cleaning & clean/invalidate.

I will add the comment in code.

Quoted 8 lines

arch/arm/cpu/armv7m/cache.c line 75

Quoted 5 lines
arch/arm/cpu/armv7m/cache.c new file +4 -0
+{
+       switch (action) {
+       case INVALIDATE_SET_WAY:
+               return (u32 *)DC_ISW;

Can you drop these casts by using a C structure or by putting thecast in the #define?

C structures was the first choice but they were removed after v1 as per review comment & replaced with #defines. ok for the casting in #defines.

Quoted 27 lines
Quoted 27 lines
arch/arm/cpu/armv7m/cache.c new file +26 -0
+       case FLUSH_SET_WAY:
+               return (u32 *)DC_CSW;
+       case FLUSH_INVAL_SET_WAY:
+               return (u32 *)DC_CISW;
+       default:
+               break;
+       };
+
+       return NULL;
+}
+
+static u32 *get_action_reg_range(enum cache_action action)
+{
+       switch (action) {
+       case INVALIDATE_POU:
+               return (u32 *)IC_IMVALU;
+       case INVALIDATE_POC:
+               return (u32 *)DC_IMVAC;
+       case FLUSH_POU:
+               return (u32 *)DC_CMVAU;
+       case FLUSH_POC:
+               return (u32 *)DC_CMVAC;
+       case FLUSH_INVAL_POC:
+               return (u32 *)DC_CIMVAC;
+       default:
+               break;
Quoted 8 lines

arch/arm/cpu/armv7m/cache.c line 107

Quoted 6 lines
arch/arm/cpu/armv7m/cache.c new file +6 -0
+       }
+
+       return NULL;
+}
+
+static u32 get_cline_size(enum cache_type type)

Why u32? Should it be uint or ulong?

armv7m is 32bit arch, cacheline size (32 bytes for cortex M7) can never be more than u32. Please let me know if i am missing something.

Quoted 14 lines
Quoted 14 lines
arch/arm/cpu/armv7m/cache.c new file +13 -0
+{
+       u32 size;
+
+       if (type == DCACHE)
+               clrbits_le32(CSSELR, BIT(SEL_I_OR_D));
+       else if (type == ICACHE)
+               setbits_le32(CSSELR, BIT(SEL_I_OR_D));
+       dsb();
+
+       size = readl(CCSIDR) & CLINE_SIZE_MASK;
+       /* Size enocoded as 2 less than log(no_of_words_in_cache_line) base 2 */
+       size = 1 << (size + 2);
+       debug("cache line size is %d\n", size);
Quoted 8 lines

arch/arm/cpu/armv7m/cache.c line 126

Quoted 6 lines
arch/arm/cpu/armv7m/cache.c new file +6 -0
+
+       return size;
+}
+
+static __attribute__((unused)) int action_cache_range(enum cache_action action,
+                    u32 start_addr, int64_t size)

Function comment.

this function is to perform the required action like invalidate/clean on a range of cache addresses. I will add comment.

Quoted 2 lines

Can you use __used ?

I figured these attribute will not be required after using the cache prototypes of common.h like invalidate_dcache_range().

Quoted 25 lines
Quoted 25 lines
arch/arm/cpu/armv7m/cache.c new file +24 -0
+{
+       u32 cline_size;
+       u32 *action_reg;
+       enum cache_type type;
+
+       action_reg = get_action_reg_range(action);
+       if (!action_reg)
+               return -EINVAL;
+       if (action == INVALIDATE_POU)
+               type = ICACHE;
+       else
+               type = DCACHE;
+
+       /* Cache line size is minium size for the cache action */
+       cline_size = get_cline_size(type);
+       /* Align start address to cache line boundary */
+       start_addr &= ~(cline_size - 1);
+       do {
+               writel(start_addr, action_reg);
+               size -= cline_size;
+               start_addr += cline_size;
+       } while (size > cline_size);
+       dsb();
+       isb();
Quoted 8 lines

arch/arm/cpu/armv7m/cache.c line 156

Quoted 6 lines
arch/arm/cpu/armv7m/cache.c new file +6 -0
+       debug("cache action on range done\n");
+
+       return 0;
+}
+
+static int action_dcache_all(enum cache_action action)

Function comment.

this function is to perform the required action like invalidate/clean on all cached addresses. I will add comment for it.

Cheers,
Vikas

Quoted 5 lines

Regards,
Simon
.

#5 lore raw

PATCH v3 2/2 stm32f7: enable instruction & data cache

In reply to Vikas Manocha

It also enables commands for cache enable/disable/status.

cc Christophe KERELLO <[email protected]>

---

Changed in v3: None
Changed in v2: None

 arch/arm/mach-stm32/stm32f7/soc.c | 2 ++
 include/configs/stm32f746-disco.h | 4 +---
 2 files changed, 3 insertions(+), 3 deletions(-)
arch/arm/mach-stm32/stm32f7/soc.c +2 -0
index 8baee99..ca54603 100644
@@ -60,6 +60,8 @@ int arch_cpu_init(void)
 		 (V7M_MPU_RASR_XN_ENABLE
 			 | V7M_MPU_RASR_AP_RW_RW
 			 | 0x01 << V7M_MPU_RASR_TEX_SHIFT
+			 | 0x01 << V7M_MPU_RASR_B_SHIFT
+			 | 0x01 << V7M_MPU_RASR_C_SHIFT
 			 | V7M_MPU_RASR_SIZE_8MB
 			 | V7M_MPU_RASR_EN)
 			 , &V7M_MPU->rasr
include/configs/stm32f746-disco.h +1 -3
index ae3211a..9e9406a 100644
@@ -14,9 +14,6 @@
 #define CONFIG_SYS_INIT_SP_ADDR		0x20050000
 #define CONFIG_SYS_TEXT_BASE		0x08000000
 
-#define CONFIG_SYS_ICACHE_OFF
-#define CONFIG_SYS_DCACHE_OFF
-
 /*
  * Configuration of the external SDRAM memory
  */
@@ -82,4 +79,5 @@
 #define CONFIG_CMDLINE_EDITING
 
 #define CONFIG_CMD_MEM
+#define CONFIG_CMD_CACHE
 #endif /* __CONFIG_H */
Signature · 1 line
1.9.1