[uClinux-dev] NXP LPC22XX patch

Brandon Fosdick brandon at teslamotors.com
Tue Jan 16 16:03:05 EST 2007


I finally have an LPC2294 booting. It's not pretty, but it works. 
Attached is the diff against dist-test-20070108 using `diff -uprN`. Let 
me know if you need a diff with different options.

All of the changes are to the 2.6.x kernel...
-Various comment and help-text fixups to various files
-Minor changes to config defaults for LPC22XX
-UART0 can now be used as a console device (use SERIAL_LPC22XX_CONSOLE)
-arch/arm/kernel/entry-armv.S:
--Use 'ldr' instead of 'b' for interrupt vector table
--('b' can't jump far enough to get out of the flash address space)
-arch/arm/kernel/head-nommu.S:
--Fixed machine type lookup (no longer hard-coded for Atmel)
--Remap interrupt vector table according to VECTORS_BASE (LPC22XX only)
-arch/arm/kernel/traps.c
--Don't copy interrupt vector stubs on LPC22XX
-include/asm-arm/arch-lpc22xx/lpc22xx.h
--new register/bit defines

BTW, arch/arm/kernel/head-nommu.S is a bit ugly now and prolly shouldn't 
have cpu-specific defines in it. The alternative is to blow away the old 
'b'-based vector table (its not needed), but that's a bit drastic w/o 
any feedback. Thoughts and suggestions are welcome.


______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
______________________________________________________________________
-------------- next part --------------
diff -uprN uClinux-dist-test.orig/linux-2.6.x/arch/arm/configs/lpc22xx_defconfig uClinux-dist-test/linux-2.6.x/arch/arm/configs/lpc22xx_defconfig
--- uClinux-dist-test.orig/linux-2.6.x/arch/arm/configs/lpc22xx_defconfig	2006-11-29 18:18:22.000000000 -0800
+++ uClinux-dist-test/linux-2.6.x/arch/arm/configs/lpc22xx_defconfig	2007-01-16 10:46:48.000000000 -0800
@@ -11,6 +11,7 @@ CONFIG_UID16=y
 CONFIG_RWSEM_GENERIC_SPINLOCK=y
 CONFIG_GENERIC_CALIBRATE_DELAY=y
 CONFIG_GENERIC_IOMAP=y
+CONFIG_VECTORS_BASE=0x40000000
 
 #
 # Code maturity level options
@@ -75,7 +76,7 @@ CONFIG_CC_ALIGN_JUMPS=0
 # CONFIG_ARCH_ATMEL is not set
 # CONFIG_ARCH_S3C3410 is not set
 # CONFIG_ARCH_ESPD_4510B is not set
-CONFIG_ARCH_LPC22xx=y
+CONFIG_ARCH_LPC22XX=y
 # CONFIG_ARCH_S3C44B0 is not set
 # CONFIG_ARCH_P2001 is not set
 CONFIG_SET_MEM_PARAM=y
@@ -97,7 +98,7 @@ CONFIG_LPC22xx_Fosc=10000000
 # Processor Type
 #
 CONFIG_CPU_32=y
-CONFIG_CPU_LPC22xx=y
+CONFIG_CPU_LPC22XX=y
 CONFIG_CPU_32v4=y
 
 #
diff -uprN uClinux-dist-test.orig/linux-2.6.x/arch/arm/Kconfig uClinux-dist-test/linux-2.6.x/arch/arm/Kconfig
--- uClinux-dist-test.orig/linux-2.6.x/arch/arm/Kconfig	2006-11-29 18:02:59.000000000 -0800
+++ uClinux-dist-test/linux-2.6.x/arch/arm/Kconfig	2007-01-16 10:46:48.000000000 -0800
@@ -101,7 +101,7 @@ config ARCH_MTD_XIP
 	bool
 
 config VECTORS_BASE
-	hex
+	hex "Location of the interrupt vector table"
 	default 0xffff0000 if MMU || CPU_HIGH_VECTOR
 	default DRAM_BASE if REMAP_VECTORS_TO_RAM
 	default 0x00000000
@@ -395,11 +395,11 @@ config ARCH_P2001
 	  The LPEC P2001 evaluation board has an P2001 processor from
 	  MAZ Brandenburg GmbH, which is based an ARM9TDMI processor core.
 
-config ARCH_LPC22xx
-	bool "Philips LPC22xx"
+config ARCH_LPC22XX
+	bool "NXP LPC22XX Family"
 	depends on !MMU
 	help
-	  Philips LPC22xx series are based on ARM7TDMI-S core,
+	  NXP LPC22xx series are based on ARM7TDMI-S core,
 	  housed in LQFP144 packages, equipped with 
 	  16/64KB on-chip RAM and up to 256KB of on-chip Flash, 
 	  operating at up to 60MHz together with 
diff -uprN uClinux-dist-test.orig/linux-2.6.x/arch/arm/kernel/entry-armv.S uClinux-dist-test/linux-2.6.x/arch/arm/kernel/entry-armv.S
--- uClinux-dist-test.orig/linux-2.6.x/arch/arm/kernel/entry-armv.S	2006-11-29 18:03:00.000000000 -0800
+++ uClinux-dist-test/linux-2.6.x/arch/arm/kernel/entry-armv.S	2007-01-16 10:46:48.000000000 -0800
@@ -1065,6 +1065,7 @@ __stubs_end:
 
 	.globl	__vectors_start
 __vectors_start:
+#ifndef CONFIG_ARCH_LPC22XX
 	swi	SYS_ERROR0
 	b	vector_und + stubs_offset
 	ldr	pc, .LCvswi + stubs_offset
@@ -1074,6 +1075,33 @@ __vectors_start:
 	b	vector_irq + stubs_offset
 	b	vector_fiq + stubs_offset
 
+#else // CONFIG_ARCH_LPC22XX
+/*  !!! The regular branch instruction doesn't have enough range to
+    !!! jump to stubs that aren't stored in the internal Flash
+*/
+	swi	SYS_ERROR0
+	ldr	pc, undefAddr
+	ldr	pc, swiAddr
+	ldr	pc, prefetchAbortAddr
+	ldr	pc, dataAbortAddr
+	ldr	pc, addrAbortAddr
+	ldr	pc, irqAddr
+	ldr	pc, fiqAddr
+
+/*  Can't use the regulr PC-relative syntax above becuase that places 
+    the data after __vectors_end, and trap_init() only copies 
+    from __vectors_start to __vectors_end.
+*/
+undefAddr:	.word	vector_und
+swiAddr:	.word	vector_swi
+prefetchAbortAddr: .word	vector_pabt
+dataAbortAddr:	.word	vector_dabt
+addrAbortAddr:	.word	vector_addrexcptn
+irqAddr:	.word	vector_irq
+fiqAddr:	.word	vector_fiq
+
+#endif // CONFIG_ARCH_LPC22XX
+
 	.globl	__vectors_end
 __vectors_end:
 
diff -uprN uClinux-dist-test.orig/linux-2.6.x/arch/arm/kernel/head-common.S uClinux-dist-test/linux-2.6.x/arch/arm/kernel/head-common.S
--- uClinux-dist-test.orig/linux-2.6.x/arch/arm/kernel/head-common.S	2006-06-28 00:22:16.000000000 -0700
+++ uClinux-dist-test/linux-2.6.x/arch/arm/kernel/head-common.S	2007-01-16 10:46:48.000000000 -0800
@@ -52,6 +52,7 @@ __mmap_switched:
 	str	r1, [r5]			@ Save machine type
 	bic	r4, r0, #CR_A			@ Clear 'A' bit
 	stmia	r6, {r0, r4}			@ Save control register values
+
 	b	start_kernel
 
 /*
@@ -170,8 +171,8 @@ ENTRY(lookup_processor_type)
 	ldmfd	sp!, {r4 - r7, 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.
+ * Look in include/asm-arm/procinfo.h and include/asm-arm/mach/arch.h for
+ * more information about the __proc_info and machine_desc structures.
  */
 	.long	__proc_info_begin
 	.long	__proc_info_end
@@ -187,6 +188,7 @@ ENTRY(lookup_processor_type)
  *
  *  r1 = machine architecture number
  * Returns:
+ *  r1 = machine architecture number (preserved)
  *  r3, r4, r6 corrupted
  *  r5 = mach_info pointer in physical address space
  */
diff -uprN uClinux-dist-test.orig/linux-2.6.x/arch/arm/kernel/head-nommu.S uClinux-dist-test/linux-2.6.x/arch/arm/kernel/head-nommu.S
--- uClinux-dist-test.orig/linux-2.6.x/arch/arm/kernel/head-nommu.S	2006-12-12 05:33:07.000000000 -0800
+++ uClinux-dist-test/linux-2.6.x/arch/arm/kernel/head-nommu.S	2007-01-16 10:46:48.000000000 -0800
@@ -21,6 +21,7 @@
 #include <asm/asm-offsets.h>
 #include <asm/thread_info.h>
 #include <asm/system.h>
+#include <asm/arch/hardware.h>
 
 /*
  * Kernel startup entry point.
@@ -38,27 +39,25 @@
 	.type	stext, %function
 ENTRY(stext)
 
-#if 1
-	@ FIXME
-	mov	r1, #MACH_TYPE_ATMEL
-#endif
+	msr	cpsr_c, #(PSR_F_BIT | PSR_I_BIT | SVC_MODE)	// SVC mode with IRQs disabled
 
-	msr	cpsr_c, #PSR_F_BIT | PSR_I_BIT | SVC_MODE @ ensure svc mode
-						@ and irqs disabled
 #ifndef CONFIG_CPU_CP15
 	ldr	r9, =CONFIG_PROCESSOR_ID
 #else
 	mrc	p15, 0, r9, c0, c0		@ get processor id
 #endif
-	bl	__lookup_processor_type		@ r5=procinfo r9=cpuid
+
+	bl	__lookup_processor_type	@ r5=procinfo r9=cpuid
 	movs	r10, r5				@ invalid processor (r5=0)?
 	beq	__error_p				@ yes, error 'p'
+
+	ldr	r1, =machine_arch_type	// Find the machine type
 	bl	__lookup_machine_type		@ r5=machinfo
+
 	movs	r8, r5				@ invalid machine (r5=0)?
 	beq	__error_a			@ yes, error 'a'
 
-	ldr	r13, __switch_data		@ address to jump to after
-						@ the initialization is done
+	// Use the return address to do a jump after return
 	adr	lr, __after_proc_init		@ return (PIC) address
 	add	pc, r10, #PROCINFO_INITFUNC
 
@@ -91,8 +90,25 @@ __after_proc_init:
 	mcr	p15, 0, r0, c1, c0, 0		@ write control reg
 #endif /* CONFIG_CPU_CP15 */
 
-	mov	pc, r13				@ clear the BSS and jump
-						@ to start_kernel
+/*	Remap the interrupt vector table on LPC22XX family processors
+	if CONFIG_VECTORS_BASE has been set to something other than the default
+*/
+#if defined(CONFIG_ARCH_LPC22XX) && (CONFIG_VECTORS_BASE != 0x7FFFE008)
+# if CONFIG_VECTORS_BASE == 0x00000000
+	mov	r3, #MEMMAP_USER_FLASH	//Map interrupt vectors to internal Flash
+# else
+#  if CONFIG_VECTORS_BASE == 0x40000000
+	mov	r3, #MEMMAP_USER_RAM	//Map interrupt vectors to internal RAM
+#  else
+	mov	r3, #MEMMAP_EXT_MEM		//Map interrupt vectors to external RAM
+#  endif
+# endif
+	ldr	r2, =REG_MEMMAP			//Remap the interrupt vector table
+	str	r3, [r2]
+#endif
+
+	ldr	pc, __switch_data	// Clear BSS and jump to start_kernel
+
 	.ltorg
 
 #include "head-common.S"
diff -uprN uClinux-dist-test.orig/linux-2.6.x/arch/arm/kernel/traps.c uClinux-dist-test/linux-2.6.x/arch/arm/kernel/traps.c
--- uClinux-dist-test.orig/linux-2.6.x/arch/arm/kernel/traps.c	2006-11-29 18:03:00.000000000 -0800
+++ uClinux-dist-test/linux-2.6.x/arch/arm/kernel/traps.c	2007-01-16 10:46:48.000000000 -0800
@@ -706,6 +706,7 @@ void __init trap_init(void)
 	 * are visible to the instruction stream.
 	 */
 	memcpy((void *)vectors, __vectors_start, __vectors_end - __vectors_start);
+#ifndef CONFIG_ARCH_LPC22XX
 	memcpy((void *)vectors + 0x200, __stubs_start, __stubs_end - __stubs_start);
 	memcpy((void *)vectors + 0x1000 - kuser_sz, __kuser_helper_start, kuser_sz);
 
@@ -715,6 +716,7 @@ void __init trap_init(void)
 	 */
 	memcpy((void *)KERN_SIGRETURN_CODE, sigreturn_codes,
 	       sizeof(sigreturn_codes));
+#endif // CONFIG_ARCH_LPC22XX
 
 	flush_icache_range(vectors, vectors + PAGE_SIZE);
 	modify_domain(DOMAIN_USER, DOMAIN_CLIENT);
diff -uprN uClinux-dist-test.orig/linux-2.6.x/arch/arm/mach-lpc22xx/arch.c uClinux-dist-test/linux-2.6.x/arch/arm/mach-lpc22xx/arch.c
--- uClinux-dist-test.orig/linux-2.6.x/arch/arm/mach-lpc22xx/arch.c	2006-12-12 05:25:14.000000000 -0800
+++ uClinux-dist-test/linux-2.6.x/arch/arm/mach-lpc22xx/arch.c	2007-01-16 10:46:48.000000000 -0800
@@ -35,13 +35,17 @@
 #include <linux/root_dev.h>
 #include <linux/initrd.h>
 
-
 extern void __init lpc22xx_init_irq(void);
 
+void __init lpc22xx_init_machine(void)
+{
+}
+
 extern struct sys_timer lpc22xx_timer;
 
-MACHINE_START(LPC22xx, "LPC22xx, PHILIPS ELECTRONICS Co., Ltd.")
-	MAINTAINER(" Lucy Wang <mcu.china at philips.com>")
-	INITIRQ(lpc22xx_init_irq)
+MACHINE_START(LPC22XX, "LPC22xx, PHILIPS ELECTRONICS Co., Ltd.")
+/*	MAINTAINER(" Lucy Wang <mcu.china at philips.com>")    */
+	.init_irq = lpc22xx_init_irq,
 	.timer	= &lpc22xx_timer,
+	.init_machine = lpc22xx_init_machine
 MACHINE_END
diff -uprN uClinux-dist-test.orig/linux-2.6.x/arch/arm/mach-lpc22xx/drivers/console.c uClinux-dist-test/linux-2.6.x/arch/arm/mach-lpc22xx/drivers/console.c
--- uClinux-dist-test.orig/linux-2.6.x/arch/arm/mach-lpc22xx/drivers/console.c	1969-12-31 16:00:00.000000000 -0800
+++ uClinux-dist-test/linux-2.6.x/arch/arm/mach-lpc22xx/drivers/console.c	2007-01-16 10:51:57.000000000 -0800
@@ -0,0 +1,59 @@
+/*  Filename: arch/arm/mach-lpc2xx/drivers/console.c
+    Console driver for LPC22XX
+    
+    Created Jan 12, 2007    Brandon Fosdick <brandon at teslamotors.com>
+*/
+
+#include <linux/init.h>
+#include <linux/console.h>
+#include <linux/serial_reg.h>
+#include <asm/arch/hardware.h>
+
+static void lpc22xx_uart_putc(const char c)
+{
+	while (!(U0LSR & UART_LSR_THRE)) {}	/* Wait for the buffer to clear */
+	U0THR = c;
+}
+
+void lpc22xx_console_write(struct console *co, const char *b, unsigned count)
+{
+	while(count) {
+		lpc22xx_uart_putc(*b);
+		if (*b == '\n')
+			lpc22xx_uart_putc('\r');
+		++b;
+		--count;
+	}
+}
+
+static int __init lpc22xx_console_setup(struct console *co, char *options)
+{       
+#define SERIAL_BAUD_RATE        97      /* 60mHz / 4 / 16 / 9600 baud	*/
+#define UART_LCR_NO_PARITY (0 & UART_LCR_PARITY)
+#define UART_LCR_1_STOP	(0 & UART_LCR_STOP)
+
+	PINSEL0 |= 0x05;	/*	Enable the pins for UART0	*/
+	/*	9600 8N1	*/
+	U0LCR = UART_LCR_DLAB | UART_LCR_NO_PARITY | UART_LCR_1_STOP | UART_LCR_WLEN8;
+	U0DLL = SERIAL_BAUD_RATE & 0xff;
+	U0DLM = (SERIAL_BAUD_RATE >> 8) & 0xff;
+	U0LCR &= ~UART_LCR_DLAB;
+
+	return 0;
+}
+
+struct console lpc22xx_con_driver = {
+	.name           = "ttyS",
+	.write          = lpc22xx_console_write,
+	.setup          = lpc22xx_console_setup,
+	.flags          = CON_PRINTBUFFER,
+	.index          = -1,
+};      
+
+static int __init lpc22xx_console_init(void) 
+{                               
+	register_console(&lpc22xx_con_driver);
+	return 0;       
+}                               
+
+console_initcall(lpc22xx_console_init);
diff -uprN uClinux-dist-test.orig/linux-2.6.x/arch/arm/mach-lpc22xx/drivers/Kconfig uClinux-dist-test/linux-2.6.x/arch/arm/mach-lpc22xx/drivers/Kconfig
--- uClinux-dist-test.orig/linux-2.6.x/arch/arm/mach-lpc22xx/drivers/Kconfig	1969-12-31 16:00:00.000000000 -0800
+++ uClinux-dist-test/linux-2.6.x/arch/arm/mach-lpc22xx/drivers/Kconfig	2007-01-12 11:14:48.000000000 -0800
@@ -0,0 +1,15 @@
+menu "LPC22XX Driver Options" 
+
+config SERIAL_LPC22XX
+	bool 'LPC22XX Serial Support'
+	default y
+	help
+	NXP LPC22XX chips have built-in serial controllers
+
+config SERIAL_LPC22XX_CONSOLE
+	bool 'LPC22XX Serial Console Support'
+	depends on SERIAL_LPC22XX
+	help
+	Use UART0 as a serial console
+	
+endmenu
diff -uprN uClinux-dist-test.orig/linux-2.6.x/arch/arm/mach-lpc22xx/drivers/Makefile uClinux-dist-test/linux-2.6.x/arch/arm/mach-lpc22xx/drivers/Makefile
--- uClinux-dist-test.orig/linux-2.6.x/arch/arm/mach-lpc22xx/drivers/Makefile	1969-12-31 16:00:00.000000000 -0800
+++ uClinux-dist-test/linux-2.6.x/arch/arm/mach-lpc22xx/drivers/Makefile	2007-01-12 12:29:29.000000000 -0800
@@ -0,0 +1,7 @@
+#
+# Makefile for the linux kernel.
+#
+
+# Object file lists.
+
+obj-$(CONFIG_SERIAL_LPC22XX_CONSOLE)	+= console.o
diff -uprN uClinux-dist-test.orig/linux-2.6.x/arch/arm/mach-lpc22xx/Kconfig uClinux-dist-test/linux-2.6.x/arch/arm/mach-lpc22xx/Kconfig
--- uClinux-dist-test.orig/linux-2.6.x/arch/arm/mach-lpc22xx/Kconfig	2005-07-13 19:04:06.000000000 -0700
+++ uClinux-dist-test/linux-2.6.x/arch/arm/mach-lpc22xx/Kconfig	2007-01-16 11:03:27.000000000 -0800
@@ -1,10 +1,16 @@
-#       linux/arch/arm/mach-lpc22xx/Kconfig	
+#	linux/arch/arm/mach-lpc22xx/Kconfig	
 #	Copyright (C) 2004 Philips Semiconductors
 #
 
 
 menu "LPC22xx Options"
-	depends on ARCH_LPC22xx
+	depends on ARCH_LPC22XX
+
+config MACH_LPC22XX
+	bool
+	default y
+	help
+		Phillips LPC22XX Family
 
 config ARCH_SUPPORTS_BIG_ENDIAN
     bool "Default Big Endian mode"
@@ -36,9 +42,11 @@ config SKIP_DUMP_CPU_INFO
 	recognition instructions which uses MMU features.
 
 config REMAP_VECTORS_TO_RAM
-	bool "Remap Vectors to ram"
-	default y
+	bool "Remap Vectors to external RAM"
+	default n
 	help
 	LPC22xx suppports ROM and RAM remap function. 
 
+source "arch/arm/mach-lpc22xx/drivers/Kconfig"
+
 endmenu
diff -uprN uClinux-dist-test.orig/linux-2.6.x/arch/arm/mach-lpc22xx/Makefile uClinux-dist-test/linux-2.6.x/arch/arm/mach-lpc22xx/Makefile
--- uClinux-dist-test.orig/linux-2.6.x/arch/arm/mach-lpc22xx/Makefile	2005-11-03 23:15:25.000000000 -0800
+++ uClinux-dist-test/linux-2.6.x/arch/arm/mach-lpc22xx/Makefile	2007-01-16 10:54:37.000000000 -0800
@@ -5,4 +5,5 @@
 # Object file lists.
 
 obj-y		+= arch.o irq.o time.o
+obj-y		+= drivers/
 extra-y		+= head.o
diff -uprN uClinux-dist-test.orig/linux-2.6.x/arch/arm/mach-lpc22xx/Makefile.boot uClinux-dist-test/linux-2.6.x/arch/arm/mach-lpc22xx/Makefile.boot
--- uClinux-dist-test.orig/linux-2.6.x/arch/arm/mach-lpc22xx/Makefile.boot	1969-12-31 16:00:00.000000000 -0800
+++ uClinux-dist-test/linux-2.6.x/arch/arm/mach-lpc22xx/Makefile.boot	2007-01-16 10:46:48.000000000 -0800
@@ -0,0 +1,4 @@
+   zreladdr-y	:= 0x00000000
+params_phys-y	:= 0x00000100
+initrd_phys-y	:= 0x00800000
+
diff -uprN uClinux-dist-test.orig/linux-2.6.x/arch/arm/Makefile uClinux-dist-test/linux-2.6.x/arch/arm/Makefile
--- uClinux-dist-test.orig/linux-2.6.x/arch/arm/Makefile	2006-11-29 18:02:59.000000000 -0800
+++ uClinux-dist-test/linux-2.6.x/arch/arm/Makefile	2007-01-16 11:05:02.000000000 -0800
@@ -87,7 +87,7 @@ CHECKFLAGS	+= -D__arm__
 
 #Default value
 head-y		:= arch/arm/kernel/head$(MMUEXT).o arch/arm/kernel/init_task.o
-textofs-y	:= 0x00008000
+textofs-y	:= 0x00000000
 
  machine-$(CONFIG_ARCH_RPC)	   := rpc
  machine-$(CONFIG_ARCH_EBSA110)	   := ebsa110
@@ -139,8 +139,8 @@ textaddr-$(CONFIG_ARCH_S3C24A0)	   := 0x
 endif
  machine-$(CONFIG_ARCH_P2001)	   := p2001
 textaddr-$(CONFIG_ARCH_P2001)	   := 0x40100000
- machine-$(CONFIG_ARCH_LPC22xx)	   := lpc22xx
-textaddr-$(CONFIG_ARCH_LPC22xx)	   := 0x81008000
+ machine-$(CONFIG_ARCH_LPC22XX)	   := lpc22xx
+textaddr-$(CONFIG_ARCH_LPC22XX)	   := 0x81008000
  machine-$(CONFIG_ARCH_REALVIEW)   := realview
  machine-$(CONFIG_ARCH_AT91)       := at91rm9200
  machine-$(CONFIG_ARCH_EP93XX)     := ep93xx
diff -uprN uClinux-dist-test.orig/linux-2.6.x/arch/arm/mm/Kconfig uClinux-dist-test/linux-2.6.x/arch/arm/mm/Kconfig
--- uClinux-dist-test.orig/linux-2.6.x/arch/arm/mm/Kconfig	2006-11-29 18:19:15.000000000 -0800
+++ uClinux-dist-test/linux-2.6.x/arch/arm/mm/Kconfig	2007-01-16 11:06:04.000000000 -0800
@@ -58,14 +58,15 @@ config CPU_ARM710
 	  Say Y if you want support for the ARM710 processor.
 	  Otherwise, say N.
 
-# LPC22xx
-config CPU_LPC22xx
-	bool "Support LPC22xx/ARM7TDMI processor" if !ARCH_LPC22xx
-	depends on ARCH_LPC22xx
-	default y if ARCH_LPC22xx
+# NXP LPC22xx
+config CPU_LPC22XX
+	bool "Support LPC22xx/ARM7TDMI processor" if !ARCH_LPC22XX
+	depends on ARCH_LPC22XX
+	default y if ARCH_LPC22XX
 	select CPU_32v4
+	select CPU_ARM7TDMI
 	help
-	  A Philips 32-bit RISC microprocessor based on ARM7TDMI-S core.
+		A Philips 32-bit RISC microprocessor based on ARM7TDMI-S core.
 
 # ARM720T
 config CPU_ARM720T
diff -uprN uClinux-dist-test.orig/linux-2.6.x/arch/arm/mm/Makefile uClinux-dist-test/linux-2.6.x/arch/arm/mm/Makefile
--- uClinux-dist-test.orig/linux-2.6.x/arch/arm/mm/Makefile	2006-12-12 05:39:23.000000000 -0800
+++ uClinux-dist-test/linux-2.6.x/arch/arm/mm/Makefile	2007-01-16 11:06:27.000000000 -0800
@@ -45,7 +45,7 @@ obj-$(CONFIG_CPU_TLB_V4WBI)	+= tlb-v4wbi
 obj-$(CONFIG_CPU_TLB_V6)	+= tlb-v6.o
 
 obj-$(CONFIG_CPU_S3C4510B)	+= proc-s3c4510b.o
-obj-$(CONFIG_CPU_LPC22xx)	+= proc-lpc22xx.o
+obj-$(CONFIG_CPU_LPC22XX)	+= proc-lpc22xx.o
 obj-$(CONFIG_CPU_ARM610)	+= proc-arm6_7.o
 obj-$(CONFIG_CPU_ARM710)	+= proc-arm6_7.o
 obj-$(CONFIG_CPU_ARM7TDMI)	+= proc-arm7tdmi.o
diff -uprN uClinux-dist-test.orig/linux-2.6.x/drivers/serial/8250.c uClinux-dist-test/linux-2.6.x/drivers/serial/8250.c
--- uClinux-dist-test.orig/linux-2.6.x/drivers/serial/8250.c	2006-12-04 19:45:43.000000000 -0800
+++ uClinux-dist-test/linux-2.6.x/drivers/serial/8250.c	2007-01-16 10:46:48.000000000 -0800
@@ -945,7 +945,7 @@ static void autoconfig(struct uart_8250_
 #endif
 		scratch3 = serial_inp(up, UART_IER);
 		serial_outp(up, UART_IER, scratch);
-#ifdef CONFIG_ARCH_LPC22xx
+#ifdef CONFIG_ARCH_LPC22XX
 		if (scratch2 != 0 || scratch3&0x07 != 0x07) {
 #else
 		if (scratch2 != 0 || scratch3 != 0x0F) {
diff -uprN uClinux-dist-test.orig/linux-2.6.x/include/asm-arm/arch-lpc22xx/entry-macro.S uClinux-dist-test/linux-2.6.x/include/asm-arm/arch-lpc22xx/entry-macro.S
--- uClinux-dist-test.orig/linux-2.6.x/include/asm-arm/arch-lpc22xx/entry-macro.S	2005-07-13 19:04:07.000000000 -0700
+++ uClinux-dist-test/linux-2.6.x/include/asm-arm/arch-lpc22xx/entry-macro.S	2007-01-16 10:46:48.000000000 -0800
@@ -7,9 +7,12 @@
  *  included in the arch/armnommu/kernel/entry.S
  *  
  */
+ 
+ #include "irqs.h"
+ 
 .EQU	VICIrqStatus,	0xFFFFF000
 
-#if defined(CONFIG_ARCH_LPC22xx)
+#if defined(CONFIG_ARCH_LPC22XX)
         .macro  disable_fiq
         .endm
 
diff -uprN uClinux-dist-test.orig/linux-2.6.x/include/asm-arm/arch-lpc22xx/keyboard.h uClinux-dist-test/linux-2.6.x/include/asm-arm/arch-lpc22xx/keyboard.h
--- uClinux-dist-test.orig/linux-2.6.x/include/asm-arm/arch-lpc22xx/keyboard.h	2005-07-13 19:04:07.000000000 -0700
+++ uClinux-dist-test/linux-2.6.x/include/asm-arm/arch-lpc22xx/keyboard.h	2007-01-16 10:46:48.000000000 -0800
@@ -4,8 +4,8 @@
  *  Copyright (C) 2004 Philips Semiconductors
  *
  */
-#ifndef __ASM_ARMNOMMU_ARCH_LPC22xx_KEYBOARD_H
-#define __ASM_ARMNOMMU_ARCH_LPC22xx_KEYBOARD_H
+#ifndef __ASM_ARMNOMMU_ARCH_LPC22XX_KEYBOARD_H
+#define __ASM_ARMNOMMU_ARCH_LPC22XX_KEYBOARD_H
 
 #define kbd_setkeycode(sc,kc) (-EINVAL)
 #define kbd_getkeycode(sc) (-EINVAL)
@@ -16,4 +16,4 @@
 #define kbd_enable_irq()
 #define kbd_disable_irq()
 
-#endif /* __ASM_ARMNOMMU_ARCH_LPC22xx_KEYBOARD_H */
+#endif /* __ASM_ARMNOMMU_ARCH_LPC22XX_KEYBOARD_H */
diff -uprN uClinux-dist-test.orig/linux-2.6.x/include/asm-arm/arch-lpc22xx/lpc22xx.h uClinux-dist-test/linux-2.6.x/include/asm-arm/arch-lpc22xx/lpc22xx.h
--- uClinux-dist-test.orig/linux-2.6.x/include/asm-arm/arch-lpc22xx/lpc22xx.h	2005-10-02 21:10:25.000000000 -0700
+++ uClinux-dist-test/linux-2.6.x/include/asm-arm/arch-lpc22xx/lpc22xx.h	2007-01-16 10:46:48.000000000 -0800
@@ -1,6 +1,6 @@
 
-#ifndef __ASM_ARCH_LPC22xx_H
-#define __ASM_ARCH_LPC22xx_H
+#ifndef __ASM_ARCH_LPC22XX_H
+#define __ASM_ARCH_LPC22XX_H
 
 /* EXTERNAL MEMORY CONTROLLER (EMC) */
 #define BCFG0           (*((volatile unsigned int *) 0xFFE00000))       /* lpc22xx only */
@@ -11,13 +11,18 @@
 /* External Interrupts */
 #define EXTINT          (*((volatile unsigned char *) 0xE01FC140))
 #define EXTWAKE         (*((volatile unsigned char *) 0xE01FC144))
-#ifdef  CONFIG_ARCH_LPC22xx
+#ifdef  CONFIG_ARCH_LPC22XX
 #define EXTMODE         (*((volatile unsigned char *) 0xE01FC148))      /* no in lpc210x*/
 #define EXTPOLAR        (*((volatile unsigned char *) 0xE01FC14C))      /* no in lpc210x*/
 #endif
 
 /* SMemory mapping control. */
 #define MEMMAP          (*((volatile unsigned char *) 0xE01FC040))
+/* SMemory mapping control registers */
+#define MEMMAP_BOOT	0
+#define MEMMAP_USER_FLASH	1
+#define MEMMAP_USER_RAM	2
+#define MEMMAP_EXT_MEM	3
 
 /* Phase Locked Loop (PLL) */
 #define PLLCON          (*((volatile unsigned char *) 0xE01FC080))
@@ -82,14 +87,15 @@
 #define VICVectCntl15   (*((volatile unsigned long *) 0xFFFFF23C))
 
 /* Pin Connect Block */
-#define PINSEL0         (*((volatile unsigned long *) 0xE002C000))
+#define REG_PINSEL0		0xE002C000
+#define PINSEL0			(*((volatile unsigned long *) REG_PINSEL0))
 #define PINSEL1         (*((volatile unsigned long *) 0xE002C004))
-#ifdef CONFIG_ARCH_LPC22xx
+#ifdef CONFIG_ARCH_LPC22XX
 #define PINSEL2         (*((volatile unsigned long *) 0xE002C014))      /* no in lpc210x*/
 #endif
 
 /* General Purpose Input/Output (GPIO) */
-#ifndef CONFIG_ARCH_LPC22xx
+#ifndef CONFIG_ARCH_LPC22XX
 
 #define IOPIN           (*((volatile unsigned long *) 0xE0028000))      /* lpc210x only */
 #define IOSET           (*((volatile unsigned long *) 0xE0028004))      /* lpc210x only */
@@ -98,7 +104,7 @@
 
 #endif
 
-#ifdef CONFIG_ARCH_LPC22xx
+#ifdef CONFIG_ARCH_LPC22XX
 #define IO0PIN          (*((volatile unsigned long *) 0xE0028000))      /* no in lpc210x*/
 #define IO0SET          (*((volatile unsigned long *) 0xE0028004))      /* no in lpc210x*/
 #define IO0DIR          (*((volatile unsigned long *) 0xE0028008))      /* no in lpc210x*/
@@ -110,7 +116,7 @@
 #define IO1CLR          (*((volatile unsigned long *) 0xE002801C))      /* no in lpc210x*/
 #endif
 
-#ifdef CONFIG_ARCH_LPC22xx
+#ifdef CONFIG_ARCH_LPC22XX
 
 #define IO2PIN          (*((volatile unsigned long *) 0xE0028020))      /* lpc22xx only */
 #define IO2SET          (*((volatile unsigned long *) 0xE0028024))      /* lpc22xx only */
@@ -125,16 +131,21 @@
 #endif
 
 /* Universal Asynchronous Receiver Transmitter 0 (UART0) */
+#define REG_U0THR		0xE000C000
+#define REG_U0LCR		0xE000C00C
+#define REG_U0DLL		0xE000C000
+#define REG_U0DLM		0xE000C004
+
 #define U0RBR           (*((volatile unsigned char *) 0xE000C000))
-#define U0THR           (*((volatile unsigned char *) 0xE000C000))
+#define U0THR			(*((volatile unsigned char *) REG_U0THR))
 #define U0IER           (*((volatile unsigned char *) 0xE000C004))
 #define U0IIR           (*((volatile unsigned char *) 0xE000C008))
 #define U0FCR           (*((volatile unsigned char *) 0xE000C008))
-#define U0LCR           (*((volatile unsigned char *) 0xE000C00C))
+#define U0LCR			(*((volatile unsigned char *) REG_U0LCR))
 #define U0LSR           (*((volatile unsigned char *) 0xE000C014))
 #define U0SCR           (*((volatile unsigned char *) 0xE000C01C))
-#define U0DLL           (*((volatile unsigned char *) 0xE000C000))
-#define U0DLM           (*((volatile unsigned char *) 0xE000C004))
+#define U0DLL			(*((volatile unsigned char *) REG_U0DLL))
+#define U0DLM			(*((volatile unsigned char *) REG_U0DLM))
 
 /* Universal Asynchronous Receiver Transmitter 1 (UART1) */
 #define U1RBR           (*((volatile unsigned char *) 0xE0010000))
@@ -167,7 +178,7 @@
 #define SPI_SPCCR       (*((volatile unsigned char *) 0xE002000C))
 #define SPI_SPINT       (*((volatile unsigned char *) 0xE002001C))
 
-#ifdef CONFIG_ARCH_LPC22xx
+#ifdef CONFIG_ARCH_LPC22XX
 #define S0PCR           (*((volatile unsigned char *) 0xE0020000))      /* no in lpc210x*/
 #define S0PSR           (*((volatile unsigned char *) 0xE0020004))      /* no in lpc210x*/
 #define S0PDR           (*((volatile unsigned char *) 0xE0020008))      /* no in lpc210x*/
@@ -301,7 +312,7 @@
 #define CAN5TDA3        (*((volatile unsigned long *) 0xE0054058))      /* lpc2119\lpc2129\lpc2292\lpc2294 only */
 #define CAN5TDB3        (*((volatile unsigned long *) 0xE005405C))      /* lpc2119\lpc2129\lpc2292\lpc2294 only */
 
-#ifdef CONFIG_ARCH_LPC22xx 
+#ifdef CONFIG_ARCH_LPC22XX 
 #define CAN6MOD         (*((volatile unsigned long *) 0xE0058000))      /* lpc2292\lpc2294 only */
 #define CAN6CMR         (*((volatile unsigned long *) 0xE0058004))      /* lpc2292\lpc2294 only */
 #define CAN6GSR         (*((volatile unsigned long *) 0xE0058008))      /* lpc2292\lpc2294 only */
diff -uprN uClinux-dist-test.orig/linux-2.6.x/include/asm-arm/arch-lpc22xx/uncompress.h uClinux-dist-test/linux-2.6.x/include/asm-arm/arch-lpc22xx/uncompress.h
--- uClinux-dist-test.orig/linux-2.6.x/include/asm-arm/arch-lpc22xx/uncompress.h	1969-12-31 16:00:00.000000000 -0800
+++ uClinux-dist-test/linux-2.6.x/include/asm-arm/arch-lpc22xx/uncompress.h	2007-01-16 12:48:24.000000000 -0800
@@ -0,0 +1,26 @@
+/*
+ * linux/include/asm-arm/arch-lpc22xx/uncompress.h
+ *
+ * Created Jan 04, 2007 Brandon Fosdick <brandon at teslamotors.com>
+ */
+
+#include <asm/arch/lpc22xx.h>	/* For U0LSR	*/
+#include <linux/serial_reg.h>	/* For UART_LSR_THRE	*/
+
+#ifndef LPC22XX_UNCOMPRESSH
+#define LPC22XX_UNCOMPRESSH
+
+#define	TX_DONE	(U0LSR & UART_LSR_THRE)
+
+static void putc(char c)
+{
+	while (!TX_DONE) {}	/* Wait for the buffer to clear */
+	U0THR = 'e';
+}
+
+static void flush(void) {}
+
+#define arch_decomp_setup()
+#define arch_decomp_wdog()
+
+#endif	//LPC22XX_UNCOMPRESSH
diff -uprN uClinux-dist-test.orig/vendors/Philips/LPC22xx/config.linux-2.6.x uClinux-dist-test/vendors/Philips/LPC22xx/config.linux-2.6.x
--- uClinux-dist-test.orig/vendors/Philips/LPC22xx/config.linux-2.6.x	2007-01-07 21:10:40.000000000 -0800
+++ uClinux-dist-test/vendors/Philips/LPC22xx/config.linux-2.6.x	2007-01-16 11:16:52.000000000 -0800
@@ -133,10 +133,13 @@ CONFIG_LPC22xx_Fosc=10000000
 # Processor Type
 #
 CONFIG_CPU_32=y
-# CONFIG_CPU_ARM7TDMI is not set
+CONFIG_CPU_ARM7TDMI=y
 CONFIG_CPU_LPC22xx=y
 # CONFIG_CPU_ARM9TDMI is not set
 CONFIG_CPU_32v4=y
+CONFIG_CPU_32v4T=y
+CONFIG_CPU_ABRT_LV4T=y
+CONFIG_CPU_CACHE_V4=y
 
 #
 # Processor Features


More information about the uClinux-dev mailing list