Skip to contentSkip to conversation

Extend cache-l2x0 to support the 16-way PL310 (v3)

PATCH New Jason S. McMullan 3 participants 6 messages May 4, 2010 – Jul 8, 2010 Arm (32-bit)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Extend cache-l2x0 to support the 16-way PL310 (v3)

Add support for the ARM PL310 16-way cache controller.

Add support for ARM PL210 cache controllers that are not 8-way.

NEW:

Log the discovered cache controller model, its number of ways, CACHE_ID register, and AUX_CTRL register.

This version of the patch includes the changes requested by Will Deacon.

Jason S. McMullan (1):
[arm l2x0] Extend cache-l2x0 to support the 16-way PL310

 arch/arm/include/asm/hardware/cache-l2x0.h |    3 ++
 arch/arm/mm/cache-l2x0.c                   |   39 ++++++++++++++++++++++++---
 2 files changed, 37 insertions(+), 5 deletions(-)
#1 lore raw

PATCH 1/1 Extend cache-l2x0 to support the 16-way PL310 (v3)

The L310 cache controller's interface is almost identical to the L210. One major difference is that the PL310 can have up to 16 ways.

This change uses the cache's part ID and the Assciativity bits in the AUX_CTRL register to determine the number of ways.

Also prints out the # of ways, CACHE_ID and AUX_CTRL registers.

---
 arch/arm/include/asm/hardware/cache-l2x0.h |    3 ++
 arch/arm/mm/cache-l2x0.c                   |   39 ++++++++++++++++++++++++---
 2 files changed, 37 insertions(+), 5 deletions(-)
arch/arm/include/asm/hardware/cache-l2x0.h +3 -0
index cdb9022..6bcba48 100644
@@ -21,6 +21,9 @@
 #define __ASM_ARM_HARDWARE_L2X0_H
 
 #define L2X0_CACHE_ID			0x000
+#define   L2X0_CACHE_ID_PART_MASK	(0xf << 6)
+#define   L2X0_CACHE_ID_PART_L210	(1 << 6)
+#define   L2X0_CACHE_ID_PART_L310	(3 << 6)
 #define L2X0_CACHE_TYPE			0x004
 #define L2X0_CTRL			0x100
 #define L2X0_AUX_CTRL			0x104
arch/arm/mm/cache-l2x0.c +34 -5
index 21ad68b..9819869 100644
@@ -27,6 +27,7 @@
 
 static void __iomem *l2x0_base;
 static DEFINE_SPINLOCK(l2x0_lock);
+static uint32_t l2x0_way_mask;	/* Bitmask of active ways */
 
 static inline void cache_wait(void __iomem *reg, unsigned long mask)
 {
@@ -108,8 +109,8 @@ static inline void l2x0_inv_all(void)
 
 	/* invalidate all ways */
 	spin_lock_irqsave(&l2x0_lock, flags);
-	writel(0xff, l2x0_base + L2X0_INV_WAY);
-	cache_wait(l2x0_base + L2X0_INV_WAY, 0xff);
+	writel(l2x0_way_mask, l2x0_base + L2X0_INV_WAY);
+	cache_wait(l2x0_base + L2X0_INV_WAY, l2x0_way_mask);
 	cache_sync();
 	spin_unlock_irqrestore(&l2x0_lock, flags);
 }
@@ -208,9 +209,37 @@ static void l2x0_flush_range(unsigned long start, unsigned long end)
 void __init l2x0_init(void __iomem *base, __u32 aux_val, __u32 aux_mask)
 {
 	__u32 aux;
+	__u32 cache_id;
+	int ways;
+	const char *type;
 
 	l2x0_base = base;
 
+	cache_id = readl(l2x0_base + L2X0_CACHE_ID);
+	aux = readl(l2x0_base + L2X0_AUX_CTRL);
+
+	/* Determine the number of ways */
+	switch (cache_id & L2X0_CACHE_ID_PART_MASK) {
+	case L2X0_CACHE_ID_PART_L310:
+		if (aux & (1 << 16))
+			ways = 16;
+		else
+			ways = 8;
+		type = "L310";
+		break;
+	case L2X0_CACHE_ID_PART_L210:
+		ways = (aux >> 13) & 0xf;
+		type = "L210";
+		break;
+	default:
+		/* Assume unknown chips have 8 ways */
+		ways = 8;
+		type = "L2x0 series";
+		break;
+	}
+
+	l2x0_way_mask = (1 << ways) - 1;
+
 	/*
 	 * Check if l2x0 controller is already enabled.
 	 * If you are booting from non-secure mode
@@ -219,8 +248,6 @@ void __init l2x0_init(void __iomem *base, __u32 aux_val, __u32 aux_mask)
 	if (!(readl(l2x0_base + L2X0_CTRL) & 1)) {
 
 		/* l2x0 controller is disabled */
-
-		aux = readl(l2x0_base + L2X0_AUX_CTRL);
 		aux &= aux_mask;
 		aux |= aux_val;
 		writel(aux, l2x0_base + L2X0_AUX_CTRL);
@@ -236,5 +263,7 @@ void __init l2x0_init(void __iomem *base, __u32 aux_val, __u32 aux_mask)
 	outer_cache.flush_range = l2x0_flush_range;
 	outer_cache.sync = l2x0_cache_sync;
 
-	printk(KERN_INFO "L2X0 cache controller enabled\n");
+	printk(KERN_INFO "%s cache controller enabled\n", type);
+	printk(KERN_INFO "l2x0: %d ways, CACHE_ID 0x%08x, AUX_CTRL 0x%08x\n",
+			 ways, cache_id, aux);
 }
Signature · 1 line
1.7.0.4
#2 lore raw

PATCH 1/1 Extend cache-l2x0 to support the 16-way PL310 (v3)

Quoted 10 lines · Jason S. McMullan

The L310 cache controller's interface is almost identical to the L210. One major difference is that the PL310 can have up to 16 ways.

This change uses the cache's part ID and the Assciativity bits in the AUX_CTRL register to determine the number of ways.

Also prints out the # of ways, CACHE_ID and AUX_CTRL registers.

Looks fine to me.

Signature · 1 line
Catalin
#3 lore raw

PATCH 1/1 Extend cache-l2x0 to support the 16-way PL310 (v3)

In reply to Jason S. McMullan
Quoted 8 lines · Jason S. McMullan

The L310 cache controller's interface is almost identical to the L210. One major difference is that the PL310 can have up to 16 ways.

This change uses the cache's part ID and the Assciativity bits in the AUX_CTRL register to determine the number of ways.

Also prints out the # of ways, CACHE_ID and AUX_CTRL registers.

As I realized now this patch breaks l210 cache support on i.MX35. Before this patch the number of ways was hardcoded to 8. With this patch the number of ways is calculated from the L2X0_AUX_CTRL register value. Unforunately on i.MX35 the reset value of this register is some bogus value resulting in a 0-way cache. The following patch fixes it but I could also write some sane values before calling l2x0_init if that's preferred.

Sascha

commit 7cb529f07fb864816d56000374b2b4aeccba00f0

Author: Sascha Hauer <[email protected]>
Date:   Tue Jul 6 08:53:55 2010 +0200

[arm l2x0] Do not rely on reset defaults of L2X0_AUX_CTRL

On i.MX35 the L2X0_AUX_CTRL register does not have sensible reset default values. Allow them to be overwritten with the aux_val/aux_mask arguments passed to l2x0_init().

arch/arm/mm/cache-l2x0.c +3 -2
index 9819869..df49558 100644
@@ -218,6 +218,9 @@ void __init l2x0_init(void __iomem *base, __u32 aux_val, __u32 aux_mask)
 	cache_id = readl(l2x0_base + L2X0_CACHE_ID);
 	aux = readl(l2x0_base + L2X0_AUX_CTRL);
 
+	aux &= aux_mask;
+	aux |= aux_val;
+
 	/* Determine the number of ways */
 	switch (cache_id & L2X0_CACHE_ID_PART_MASK) {
 	case L2X0_CACHE_ID_PART_L310:
@@ -248,8 +251,6 @@ void __init l2x0_init(void __iomem *base, __u32 aux_val, __u32 aux_mask)
 	if (!(readl(l2x0_base + L2X0_CTRL) & 1)) {
 
 		/* l2x0 controller is disabled */
-		aux &= aux_mask;
-		aux |= aux_val;
 		writel(aux, l2x0_base + L2X0_AUX_CTRL);
 
 		l2x0_inv_all();
Signature · 4 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
#4 lore raw

PATCH 1/1 Extend cache-l2x0 to support the 16-wayPL310 (v3)

Quoted 11 lines · Sascha Hauer

commit 7cb529f07fb864816d56000374b2b4aeccba00f0

Author: Sascha Hauer <[email protected]>
Date:   Tue Jul 6 08:53:55 2010 +0200

[arm l2x0] Do not rely on reset defaults of L2X0_AUX_CTRL

On i.MX35 the L2X0_AUX_CTRL register does not have sensible reset default values. Allow them to be overwritten with the aux_val/aux_mask arguments passed to l2x0_init().

Signature · 1 line
Catalin
#5 lore raw

PATCH 1/1 Extend cache-l2x0 to support the 16-wayPL310 (v3)

Quoted 7 lines · Catalin Marinas
Quoted 6 lines · Sascha Hauer

commit 7cb529f07fb864816d56000374b2b4aeccba00f0

Author: Sascha Hauer <[email protected]>
Date:   Tue Jul 6 08:53:55 2010 +0200

[arm l2x0] Do not rely on reset defaults of L2X0_AUX_CTRL

Quoted 7 lines
Quoted 5 lines

On i.MX35 the L2X0_AUX_CTRL register does not have sensible reset default values. Allow them to be overwritten with the aux_val/aux_mask arguments passed to l2x0_init().

Ok, I put it in the patch system as 6210/1

Sascha

Signature · 4 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |