bk://bk.arm.linux.org.uk/linux-2.6-rmk
rmk@flint.arm.linux.org.uk|ChangeSet|20050119211555|54812 rmk

# This is a BitKeeper generated diff -Nru style patch.
#
# ChangeSet
#   2005/01/19 21:15:55+00:00 rmk@flint.arm.linux.org.uk 
#   [ARM] Clean up lookup of processor and machine types.
#   
#   Rather than having an assembly and C version performing the same
#   lookup, re-use the assembly version with a C wrapper around it.
#   This removes the duplication.
#   
#   Signed-off-by: Russell King <rmk@arm.linux.org.uk>
# 
# arch/arm/kernel/setup.c
#   2005/01/19 21:11:10+00:00 rmk@flint.arm.linux.org.uk +13 -22
#   Rather than reimplement looking up processor and architecture types,
#   use the head.S assembly versions instead.  This means one place for
#   performing this function, rather than two.
# 
# arch/arm/kernel/head.S
#   2005/01/19 21:11:10+00:00 rmk@flint.arm.linux.org.uk +23 -4
#   Add C API versions of __lookup_{processor,machine}_type
# 
# ChangeSet
#   2005/01/18 17:37:16+00:00 jelenz@edu.rmk.(none) 
#   [ARM PATCH] 2417/1: update collie to use scoop driver
#   
#   Patch from John Lenz
#   
#   Update collie machine to use the new scoop driver written
#   by Richard Purdie.
#   
#   Signed-off-by: John Lenz
#   Signed-off-by: Russell King
# 
# include/asm-arm/arch-sa1100/collie.h
#   2005/01/18 00:00:00+00:00 jelenz@edu.rmk.(none) +11 -48
#   [PATCH] 2417/1: update collie to use scoop driver
# 
# arch/arm/mach-sa1100/collie.c
#   2005/01/18 00:00:00+00:00 jelenz@edu.rmk.(none) +26 -30
#   [PATCH] 2417/1: update collie to use scoop driver
# 
# arch/arm/Kconfig
#   2005/01/18 00:00:00+00:00 jelenz@edu.rmk.(none) +1 -1
#   [PATCH] 2417/1: update collie to use scoop driver
# 
# ChangeSet
#   2005/01/18 12:46:32+00:00 rmk@flint.arm.linux.org.uk 
#   [ARM] Add CPU number to cache information lines.
# 
# arch/arm/kernel/setup.c
#   2005/01/18 12:41:20+00:00 rmk@flint.arm.linux.org.uk +9 -9
#   Add CPU number to cache information lines.
# 
# ChangeSet
#   2005/01/15 17:59:46-08:00 akpm@bix.(none) 
#   Merge bix.(none):/usr/src/bk25 into bix.(none):/usr/src/bk-arm
# 
# MAINTAINERS
#   2005/01/15 17:59:40-08:00 akpm@bix.(none) +0 -0
#   Auto merged
# 
# ChangeSet
#   2005/01/13 16:36:43-08:00 akpm@bix.(none) 
#   Merge bk://bk.arm.linux.org.uk/linux-2.6-rmk
#   into bix.(none):/usr/src/bk-arm
# 
# MAINTAINERS
#   2005/01/13 16:36:39-08:00 akpm@bix.(none) +0 -0
#   Auto merged
# 
# ChangeSet
#   2005/01/13 16:33:42-08:00 akpm@bix.(none) 
#   Merge bix.(none):/usr/src/bk25 into bix.(none):/usr/src/bk-arm
# 
# MAINTAINERS
#   2005/01/13 16:33:38-08:00 akpm@bix.(none) +0 -0
#   Auto merged
# 
# CREDITS
#   2005/01/13 16:33:38-08:00 akpm@bix.(none) +0 -0
#   Auto merged
# 
# ChangeSet
#   2005/01/12 12:14:51-08:00 akpm@bix.(none) 
#   Merge bk://bk.arm.linux.org.uk/linux-2.6-rmk
#   into bix.(none):/usr/src/bk-arm
# 
# MAINTAINERS
#   2005/01/12 12:14:47-08:00 akpm@bix.(none) +0 -0
#   Auto merged
# 
# ChangeSet
#   2005/01/11 21:32:02-08:00 akpm@bix.(none) 
#   Merge bk://bk.arm.linux.org.uk/linux-2.6-rmk
#   into bix.(none):/usr/src/bk-arm
# 
# CREDITS
#   2005/01/11 21:31:56-08:00 akpm@bix.(none) +0 -0
#   Auto merged
# 
# ChangeSet
#   2005/01/11 11:47:36-08:00 akpm@bix.(none) 
#   Merge bix.(none):/usr/src/bk25 into bix.(none):/usr/src/bk-arm
# 
# MAINTAINERS
#   2005/01/11 11:47:31-08:00 akpm@bix.(none) +0 -0
#   Auto merged
# 
# ChangeSet
#   2005/01/10 20:25:29-08:00 akpm@bix.(none) 
#   Merge bix.(none):/usr/src/bk25 into bix.(none):/usr/src/bk-arm
# 
# MAINTAINERS
#   2005/01/10 20:25:24-08:00 akpm@bix.(none) +0 -0
#   Auto merged
# 
# ChangeSet
#   2005/01/10 14:38:10-08:00 akpm@bix.(none) 
#   Merge bk://bk.arm.linux.org.uk/linux-2.6-rmk
#   into bix.(none):/usr/src/bk-arm
# 
# MAINTAINERS
#   2005/01/10 14:38:06-08:00 akpm@bix.(none) +0 -0
#   Auto merged
# 
diff -Nru a/arch/arm/Kconfig b/arch/arm/Kconfig
--- a/arch/arm/Kconfig	2005-01-19 14:01:34 -08:00
+++ b/arch/arm/Kconfig	2005-01-19 14:01:34 -08:00
@@ -236,7 +236,7 @@
 
 config SHARP_SCOOP
 	bool
-	depends on PXA_SHARPSL
+	depends on PXA_SHARPSL || SA1100_COLLIE
 	default y
 
 config FORCE_MAX_ZONEORDER
diff -Nru a/arch/arm/kernel/head.S b/arch/arm/kernel/head.S
--- a/arch/arm/kernel/head.S	2005-01-19 14:01:34 -08:00
+++ b/arch/arm/kernel/head.S	2005-01-19 14:01:34 -08:00
@@ -406,7 +406,7 @@
  * calculate the offset.
  *
  * Returns:
- *	r3, r6 corrupted
+ *	r3, r4, r6 corrupted
  *	r5 = proc_info pointer in physical address space
  *	r9 = cpuid
  */
@@ -418,9 +418,9 @@
 	add	r5, r5, r3			@ convert virt addresses to
 	add	r6, r6, r3			@ physical address space
 	mrc	p15, 0, r9, c0, c0		@ get processor id
-1:	ldmia	r5, {r3, r10}			@ value, mask
-	and	r10, r10, r9			@ mask wanted bits
-	teq	r3, r10
+1:	ldmia	r5, {r3, r4}			@ value, mask
+	and	r4, r4, r9			@ mask wanted bits
+	teq	r3, r4
 	beq	2f
 	add	r5, r5, #PROC_INFO_SZ		@ sizeof(proc_info_list)
 	cmp	r5, r6
@@ -429,6 +429,15 @@
 2:	mov	pc, lr
 
 /*
+ * This provides a C-API version of the above function.
+ */
+ENTRY(lookup_processor_type)
+	stmfd	sp!, {r4 - r6, r9, lr}
+	bl	__lookup_processor_type
+	mov	r0, r5
+	ldmfd	sp!, {r4 - r6, r9, pc}
+
+/*
  * Look in include/asm-arm/procinfo.h and arch/arm/kernel/arch.[ch] for
  * more information about the __proc_info and __arch_info structures.
  */
@@ -464,3 +473,13 @@
 	blt	1b
 	mov	r5, #0				@ unknown machine
 2:	mov	pc, lr
+
+/*
+ * This provides a C-API version of the above function.
+ */
+ENTRY(lookup_machine_type)
+	stmfd	sp!, {r4 - r6, lr}
+	mov	r1, r0
+	bl	__lookup_machine_type
+	mov	r0, r5
+	ldmfd	sp!, {r4 - r6, pc}
diff -Nru a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
--- a/arch/arm/kernel/setup.c	2005-01-19 14:01:34 -08:00
+++ b/arch/arm/kernel/setup.c	2005-01-19 14:01:34 -08:00
@@ -221,12 +221,12 @@
 #define CACHE_M(y)	((y) & (1 << 2))
 #define CACHE_LINE(y)	((y) & 3)
 
-static inline void dump_cache(const char *prefix, unsigned int cache)
+static inline void dump_cache(const char *prefix, int cpu, unsigned int cache)
 {
 	unsigned int mult = 2 + (CACHE_M(cache) ? 1 : 0);
 
-	printk("%s: %d bytes, associativity %d, %d byte lines, %d sets\n",
-		prefix,
+	printk("CPU%u: %s: %d bytes, associativity %d, %d byte lines, %d sets\n",
+		cpu, prefix,
 		mult << (8 + CACHE_SIZE(cache)),
 		(mult << CACHE_ASSOC(cache)) >> 1,
 		8 << CACHE_LINE(cache),
@@ -234,18 +234,18 @@
 			CACHE_LINE(cache)));
 }
 
-static void __init dump_cpu_info(void)
+static void __init dump_cpu_info(int cpu)
 {
 	unsigned int info = read_cpuid(CPUID_CACHETYPE);
 
 	if (info != processor_id) {
-		printk("CPU: D %s %s cache\n", cache_is_vivt() ? "VIVT" : "VIPT",
+		printk("CPU%u: D %s %s cache\n", cpu, cache_is_vivt() ? "VIVT" : "VIPT",
 		       cache_types[CACHE_TYPE(info)]);
 		if (CACHE_S(info)) {
-			dump_cache("CPU: I cache", CACHE_ISIZE(info));
-			dump_cache("CPU: D cache", CACHE_DSIZE(info));
+			dump_cache("I cache", cpu, CACHE_ISIZE(info));
+			dump_cache("D cache", cpu, CACHE_DSIZE(info));
 		} else {
-			dump_cache("CPU: cache", CACHE_ISIZE(info));
+			dump_cache("cache", cpu, CACHE_ISIZE(info));
 		}
 	}
 }
@@ -267,9 +267,15 @@
 	return cpu_arch;
 }
 
+/*
+ * These functions re-use the assembly code in head.S, which
+ * already provide the required functionality.
+ */
+extern struct proc_info_list *lookup_processor_type(void);
+extern struct machine_desc *lookup_machine_type(unsigned int);
+
 static void __init setup_processor(void)
 {
-	extern struct proc_info_list __proc_info_begin, __proc_info_end;
 	struct proc_info_list *list;
 
 	/*
@@ -277,15 +283,8 @@
 	 * types.  The linker builds this table for us from the
 	 * entries in arch/arm/mm/proc-*.S
 	 */
-	for (list = &__proc_info_begin; list < &__proc_info_end ; list++)
-		if ((processor_id & list->cpu_mask) == list->cpu_val)
-			break;
-
-	/*
-	 * If processor type is unrecognised, then we
-	 * can do nothing...
-	 */
-	if (list >= &__proc_info_end) {
+	list = lookup_processor_type();
+	if (!list) {
 		printk("CPU configuration botched (ID %08x), unable "
 		       "to continue.\n", processor_id);
 		while (1);
@@ -310,7 +309,7 @@
 	       cpu_name, processor_id, (int)processor_id & 15,
 	       proc_arch[cpu_architecture()]);
 
-	dump_cpu_info();
+	dump_cpu_info(smp_processor_id());
 
 	sprintf(system_utsname.machine, "%s%c", list->arch_name, ENDIANNESS);
 	sprintf(elf_platform, "%s%c", list->elf_name, ENDIANNESS);
@@ -321,22 +320,14 @@
 
 static struct machine_desc * __init setup_machine(unsigned int nr)
 {
-	extern struct machine_desc __arch_info_begin, __arch_info_end;
 	struct machine_desc *list;
 
 	/*
-	 * locate architecture in the list of supported architectures.
-	 */
-	for (list = &__arch_info_begin; list < &__arch_info_end; list++)
-		if (list->nr == nr)
-			break;
-
-	/*
-	 * If the architecture type is not recognised, then we
-	 * can co nothing...
+	 * locate machine in the list of supported machines.
 	 */
-	if (list >= &__arch_info_end) {
-		printk("Architecture configuration botched (nr %d), unable "
+	list = lookup_machine_type(nr);
+	if (!list) {
+		printk("Machine configuration botched (nr %d), unable "
 		       "to continue.\n", nr);
 		while (1);
 	}
diff -Nru a/arch/arm/mach-sa1100/collie.c b/arch/arm/mach-sa1100/collie.c
--- a/arch/arm/mach-sa1100/collie.c	2005-01-19 14:01:34 -08:00
+++ b/arch/arm/mach-sa1100/collie.c	2005-01-19 14:01:34 -08:00
@@ -37,36 +37,34 @@
 #include <asm/mach/map.h>
 #include <asm/mach/serial_sa1100.h>
 
+#include <asm/hardware/scoop.h>
 #include <asm/hardware/locomo.h>
 
 #include "generic.h"
 
-static void __init scoop_init(void)
-{
+static struct resource collie_scoop_resources[] = {
+	[0] = {
+		.start		= 0x40800000,
+		.end		= 0x40800fff,
+		.flags		= IORESOURCE_MEM,
+	},
+};
 
-#define	COLLIE_SCP_INIT_DATA(adr,dat)	(((adr)<<16)|(dat))
-#define	COLLIE_SCP_INIT_DATA_END	((unsigned long)-1)
-	static const unsigned long scp_init[] = {
-		COLLIE_SCP_INIT_DATA(COLLIE_SCP_MCR, 0x0140),	// 00
-		COLLIE_SCP_INIT_DATA(COLLIE_SCP_MCR, 0x0100),
-		COLLIE_SCP_INIT_DATA(COLLIE_SCP_CDR, 0x0000),	// 04
-		COLLIE_SCP_INIT_DATA(COLLIE_SCP_CPR, 0x0000),	// 0C
-		COLLIE_SCP_INIT_DATA(COLLIE_SCP_CCR, 0x0000),	// 10
-		COLLIE_SCP_INIT_DATA(COLLIE_SCP_IMR, 0x0000),	// 18
-		COLLIE_SCP_INIT_DATA(COLLIE_SCP_IRM, 0x00FF),	// 14
-		COLLIE_SCP_INIT_DATA(COLLIE_SCP_ISR, 0x0000),	// 1C
-		COLLIE_SCP_INIT_DATA(COLLIE_SCP_IRM, 0x0000),
-		COLLIE_SCP_INIT_DATA(COLLIE_SCP_GPCR, COLLIE_SCP_IO_DIR),	// 20
-		COLLIE_SCP_INIT_DATA(COLLIE_SCP_GPWR, COLLIE_SCP_IO_OUT),	// 24
-		COLLIE_SCP_INIT_DATA_END
-	};
-	int i;
-	for (i = 0; scp_init[i] != COLLIE_SCP_INIT_DATA_END; i++) {
-		int adr = scp_init[i] >> 16;
-		COLLIE_SCP_REG(adr) = scp_init[i] & 0xFFFF;
-	}
+static struct scoop_config collie_scoop_setup = {
+	.io_dir 	= COLLIE_SCOOP_IO_DIR,
+	.io_out		= COLLIE_SCOOP_IO_OUT,
+};
+
+static struct platform_device colliescoop_device = {
+	.name		= "sharp-scoop",
+	.id		= -1,
+	.dev		= {
+ 		.platform_data	= &collie_scoop_setup,
+	},
+	.num_resources	= ARRAY_SIZE(collie_scoop_resources),
+	.resource	= collie_scoop_resources,
+};
 
-}
 
 static struct resource locomo_resources[] = {
 	[0] = {
@@ -90,6 +88,7 @@
 
 static struct platform_device *devices[] __initdata = {
 	&locomo_device,
+	&colliescoop_device,
 };
 
 static struct mtd_partition collie_partitions[] = {
@@ -111,11 +110,11 @@
 
 static void collie_set_vpp(int vpp)
 {
-	COLLIE_SCP_REG_GPCR |= COLLIE_SCP_VPEN;
+	write_scoop_reg(SCOOP_GPCR, read_scoop_reg(SCOOP_GPCR) | COLLIE_SCP_VPEN);
 	if (vpp) {
-		COLLIE_SCP_REG_GPWR |= COLLIE_SCP_VPEN;
+		write_scoop_reg(SCOOP_GPWR, read_scoop_reg(SCOOP_GPWR) | COLLIE_SCP_VPEN);
 	} else {
-		COLLIE_SCP_REG_GPWR &= ~COLLIE_SCP_VPEN;
+		write_scoop_reg(SCOOP_GPWR, read_scoop_reg(SCOOP_GPWR) & ~COLLIE_SCP_VPEN);
 	}
 }
 
@@ -160,8 +159,6 @@
 	GPDR |= GPIO_32_768kHz;
 	TUCR  = TUCR_32_768kHz;
 
-	scoop_init();
-
 	ret = platform_add_devices(devices, ARRAY_SIZE(devices));
 	if (ret) {
 		printk(KERN_WARNING "collie: Unable to register LoCoMo device\n");
@@ -175,7 +172,6 @@
 	/* virtual     physical    length      type */
 	{0xe8000000, 0x00000000, 0x02000000, MT_DEVICE},	/* 32M main flash (cs0) */
 	{0xea000000, 0x08000000, 0x02000000, MT_DEVICE},	/* 32M boot flash (cs1) */
-	{0xf0000000, 0x40000000, 0x01000000, MT_DEVICE},	/* 16M LOCOMO  & SCOOP (cs4) */
 };
 
 static void __init collie_map_io(void)
diff -Nru a/include/asm-arm/arch-sa1100/collie.h b/include/asm-arm/arch-sa1100/collie.h
--- a/include/asm-arm/arch-sa1100/collie.h	2005-01-19 14:01:34 -08:00
+++ b/include/asm-arm/arch-sa1100/collie.h	2005-01-19 14:01:34 -08:00
@@ -15,57 +15,20 @@
 
 #include <linux/config.h>
 
-#define CF_BUF_CTRL_BASE 0xF0800000
-#define	COLLIE_SCP_REG(adr) (*(volatile unsigned short*)(CF_BUF_CTRL_BASE+(adr)))
-#define	COLLIE_SCP_MCR	0x00
-#define	COLLIE_SCP_CDR	0x04
-#define	COLLIE_SCP_CSR	0x08
-#define	COLLIE_SCP_CPR	0x0C
-#define	COLLIE_SCP_CCR	0x10
-#define	COLLIE_SCP_IRR	0x14
-#define	COLLIE_SCP_IRM	0x14
-#define	COLLIE_SCP_IMR	0x18
-#define	COLLIE_SCP_ISR	0x1C
-#define	COLLIE_SCP_GPCR	0x20
-#define	COLLIE_SCP_GPWR	0x24
-#define	COLLIE_SCP_GPRR	0x28
-#define	COLLIE_SCP_REG_MCR	COLLIE_SCP_REG(COLLIE_SCP_MCR)
-#define	COLLIE_SCP_REG_CDR	COLLIE_SCP_REG(COLLIE_SCP_CDR)
-#define	COLLIE_SCP_REG_CSR	COLLIE_SCP_REG(COLLIE_SCP_CSR)
-#define	COLLIE_SCP_REG_CPR	COLLIE_SCP_REG(COLLIE_SCP_CPR)
-#define	COLLIE_SCP_REG_CCR	COLLIE_SCP_REG(COLLIE_SCP_CCR)
-#define	COLLIE_SCP_REG_IRR	COLLIE_SCP_REG(COLLIE_SCP_IRR)
-#define	COLLIE_SCP_REG_IRM	COLLIE_SCP_REG(COLLIE_SCP_IRM)
-#define	COLLIE_SCP_REG_IMR	COLLIE_SCP_REG(COLLIE_SCP_IMR)
-#define	COLLIE_SCP_REG_ISR	COLLIE_SCP_REG(COLLIE_SCP_ISR)
-#define	COLLIE_SCP_REG_GPCR	COLLIE_SCP_REG(COLLIE_SCP_GPCR)
-#define	COLLIE_SCP_REG_GPWR	COLLIE_SCP_REG(COLLIE_SCP_GPWR)
-#define	COLLIE_SCP_REG_GPRR	COLLIE_SCP_REG(COLLIE_SCP_GPRR)
+#define COLLIE_SCP_CHARGE_ON	SCOOP_GPCR_PA11
+#define COLLIE_SCP_DIAG_BOOT1	SCOOP_GPCR_PA12
+#define COLLIE_SCP_DIAG_BOOT2	SCOOP_GPCR_PA13
+#define COLLIE_SCP_MUTE_L	SCOOP_GPCR_PA14
+#define COLLIE_SCP_MUTE_R	SCOOP_GPCR_PA15
+#define COLLIE_SCP_5VON		SCOOP_GPCR_PA16
+#define COLLIE_SCP_AMP_ON	SCOOP_GPCR_PA17
+#define COLLIE_SCP_VPEN		SCOOP_GPCR_PA18
+#define COLLIE_SCP_LB_VOL_CHG	SCOOP_GPCR_PA19
 
-#define COLLIE_SCP_GPCR_PA19	( 1 << 9 )
-#define COLLIE_SCP_GPCR_PA18	( 1 << 8 )
-#define COLLIE_SCP_GPCR_PA17	( 1 << 7 )
-#define COLLIE_SCP_GPCR_PA16	( 1 << 6 )
-#define COLLIE_SCP_GPCR_PA15	( 1 << 5 )
-#define COLLIE_SCP_GPCR_PA14	( 1 << 4 )
-#define COLLIE_SCP_GPCR_PA13	( 1 << 3 )
-#define COLLIE_SCP_GPCR_PA12	( 1 << 2 )
-#define COLLIE_SCP_GPCR_PA11	( 1 << 1 )
-
-#define COLLIE_SCP_CHARGE_ON	COLLIE_SCP_GPCR_PA11
-#define COLLIE_SCP_DIAG_BOOT1	COLLIE_SCP_GPCR_PA12
-#define COLLIE_SCP_DIAG_BOOT2	COLLIE_SCP_GPCR_PA13
-#define COLLIE_SCP_MUTE_L	COLLIE_SCP_GPCR_PA14
-#define COLLIE_SCP_MUTE_R	COLLIE_SCP_GPCR_PA15
-#define COLLIE_SCP_5VON	COLLIE_SCP_GPCR_PA16
-#define COLLIE_SCP_AMP_ON	COLLIE_SCP_GPCR_PA17
-#define COLLIE_SCP_VPEN	COLLIE_SCP_GPCR_PA18
-#define COLLIE_SCP_LB_VOL_CHG	COLLIE_SCP_GPCR_PA19
-
-#define COLLIE_SCP_IO_DIR	( COLLIE_SCP_CHARGE_ON | COLLIE_SCP_MUTE_L | COLLIE_SCP_MUTE_R | \
+#define COLLIE_SCOOP_IO_DIR	( COLLIE_SCP_CHARGE_ON | COLLIE_SCP_MUTE_L | COLLIE_SCP_MUTE_R | \
 				COLLIE_SCP_5VON | COLLIE_SCP_AMP_ON | COLLIE_SCP_VPEN | \
 				COLLIE_SCP_LB_VOL_CHG )
-#define COLLIE_SCP_IO_OUT	( COLLIE_SCP_MUTE_L | COLLIE_SCP_MUTE_R | COLLIE_SCP_VPEN | \
+#define COLLIE_SCOOP_IO_OUT	( COLLIE_SCP_MUTE_L | COLLIE_SCP_MUTE_R | COLLIE_SCP_VPEN | \
 				COLLIE_SCP_CHARGE_ON )
 
 /* GPIOs for which the generic definition doesn't say much */
