Skip to contentSkip to conversation

Support for NXP LPC2K SoCs

PATCH Superseded Ithamar R. Adema 6 participants 30 messages Mar 17, 2011 – Mar 18, 2011

Subsystems (2)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

cover Support for NXP LPC2K SoCs

The following patch series implements support for the ARM7TDMI-S based NXP LPC2K System-on-Chips, and, as first board, the EmbeddedArtists LPC2478 Developer's Kit.

This code will work on the LPC23XX and LPC24XX ranges of chips, but will need some more work for LPC21XX and LPC22XX chips.

#1 lore raw

PATCH 1/9 lpc2k: Core support

Core files (including IRQ handling) for NXP LPC2K architecture.

---
 arch/arm/Kconfig                               |   14 +++++++
 arch/arm/Makefile                              |    1 +
 arch/arm/mach-lpc2k/Kconfig                    |    5 ++
 arch/arm/mach-lpc2k/Makefile                   |    1 +
 arch/arm/mach-lpc2k/Makefile.boot              |    3 +
 arch/arm/mach-lpc2k/include/mach/debug-macro.S |   19 +++++++++
 arch/arm/mach-lpc2k/include/mach/entry-macro.S |   33 ++++++++++++++++
 arch/arm/mach-lpc2k/include/mach/hardware.h    |   23 +++++++++++
 arch/arm/mach-lpc2k/include/mach/io.h          |   18 ++++++++
 arch/arm/mach-lpc2k/include/mach/irqs.h        |   49 +++++++++++++++++++++++
 arch/arm/mach-lpc2k/include/mach/memory.h      |   15 +++++++
 arch/arm/mach-lpc2k/include/mach/system.h      |   23 +++++++++++
 arch/arm/mach-lpc2k/include/mach/timex.h       |   15 +++++++
 arch/arm/mach-lpc2k/include/mach/uncompress.h  |   50 ++++++++++++++++++++++++
 arch/arm/mach-lpc2k/irq.c                      |   17 ++++++++
 15 files changed, 286 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/mach-lpc2k/Kconfig
 create mode 100644 arch/arm/mach-lpc2k/Makefile
 create mode 100644 arch/arm/mach-lpc2k/Makefile.boot
 create mode 100644 arch/arm/mach-lpc2k/include/mach/debug-macro.S
 create mode 100644 arch/arm/mach-lpc2k/include/mach/entry-macro.S
 create mode 100644 arch/arm/mach-lpc2k/include/mach/hardware.h
 create mode 100644 arch/arm/mach-lpc2k/include/mach/io.h
 create mode 100644 arch/arm/mach-lpc2k/include/mach/irqs.h
 create mode 100644 arch/arm/mach-lpc2k/include/mach/memory.h
 create mode 100644 arch/arm/mach-lpc2k/include/mach/system.h
 create mode 100644 arch/arm/mach-lpc2k/include/mach/timex.h
 create mode 100644 arch/arm/mach-lpc2k/include/mach/uncompress.h
 create mode 100644 arch/arm/mach-lpc2k/irq.c
arch/arm/Kconfig +14 -0
index e34bf02..331540d 100644
@@ -490,6 +490,18 @@ config ARCH_LOKI
 	help
 	  Support for the Marvell Loki (88RC8480) SoC.
 
+config ARCH_LPC2K
+	bool "NXP LPC2K Family"
+	depends on !MMU
+	select CPU_ARM7TDMI
+	select ARM_VIC
+	select GENERIC_TIME
+	select GENERIC_CLOCKEVENTS
+	help
+	  Support for NXP LPC2K family of SoCs. These SoCs are based on
+	  an ARM7TDMI-S core, and have optional on-chip flash and SRAM,
+	  also UART, I2C, SPI, SSP, CAN, RTC, and other peripherals.
+
 config ARCH_LPC32XX
 	bool "NXP LPC32XX"
 	select CPU_ARM926T
@@ -928,6 +940,8 @@ source "arch/arm/mach-ks8695/Kconfig"
 
 source "arch/arm/mach-loki/Kconfig"
 
+source "arch/arm/mach-lpc2k/Kconfig"
+
 source "arch/arm/mach-lpc32xx/Kconfig"
 
 source "arch/arm/mach-msm/Kconfig"
arch/arm/Makefile +1 -0
index 5c7114b..601f52a 100644
@@ -151,6 +151,7 @@ machine-$(CONFIG_ARCH_IXP4XX)		:= ixp4xx
 machine-$(CONFIG_ARCH_KIRKWOOD)		:= kirkwood
 machine-$(CONFIG_ARCH_KS8695)		:= ks8695
 machine-$(CONFIG_ARCH_LOKI) 		:= loki
+machine-$(CONFIG_ARCH_LPC2K)		:= lpc2k
 machine-$(CONFIG_ARCH_LPC32XX)		:= lpc32xx
 machine-$(CONFIG_ARCH_MMP)		:= mmp
 machine-$(CONFIG_ARCH_MSM)		:= msm
arch/arm/mach-lpc2k/Kconfig new file +5 -0
new file mode 100644
index 0000000..fad47b8
@@ -0,0 +1,5 @@
+if ARCH_LPC2K
+
+comment "LPC2K machines"
+
+endif
arch/arm/mach-lpc2k/Makefile new file +1 -0
new file mode 100644
index 0000000..546666b
@@ -0,0 +1 @@
+obj-y	:= irq.o
arch/arm/mach-lpc2k/Makefile.boot new file +3 -0
new file mode 100644
index 0000000..8b6b745
@@ -0,0 +1,3 @@
+   zreladdr-y	:= 0xa0008000
+params_phys-y	:= 0xa0000100
+initrd_phys-y	:= 0xa1800000
arch/arm/mach-lpc2k/include/mach/debug-macro.S new file +19 -0
new file mode 100644
index 0000000..0f581d3
@@ -0,0 +1,19 @@
+/*
+ * Copyright 2011 Team Embedded VOF
+ *     Ithamar R. Adema <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+
+#include <mach/hardware.h>
+
+	.macro	addruart, rp, rv
+	ldr	\rp, =APB_UART0_BASE
+	ldr	\rv, =APB_UART0_BASE
+	.endm
+
+#define UART_SHIFT	2
+#include <asm/hardware/debug-8250.S>
arch/arm/mach-lpc2k/include/mach/entry-macro.S new file +33 -0
new file mode 100644
index 0000000..f6c7a46
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2011 Team Embedded VOF
+ *     Ithamar R. Adema <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include <mach/hardware.h>
+
+        .macro  disable_fiq
+        .endm
+
+		.macro	get_irqnr_preamble, base, tmp
+		ldr	\base, =APH_VIC_BASE
+		.endm
+
+		.macro	arch_ret_to_user, tmp1, tmp2
+		.endm
+
+		.macro get_irqnr_and_base, irqnr, irqstat, base, tmp
+		ldr	\irqstat, [\base, #0]
+		mov     \irqnr, #0
+1001:
+		tst     \irqstat, #1
+		bne     1002f
+		add     \irqnr, \irqnr, #1
+		mov     \irqstat, \irqstat, lsr #1
+		cmp     \irqnr, #32
+		bcc     1001b
+1002:
+		.endm
arch/arm/mach-lpc2k/include/mach/hardware.h new file +23 -0
new file mode 100644
index 0000000..7663e97
@@ -0,0 +1,23 @@
+/*
+ * Copyright 2011 Team Embedded VOF
+ *     Ithamar R. Adema <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef MACH_LPC2K_HARDWARE_H
+#define MACH_LPC2K_HARDWARE_H
+
+#include <asm/sizes.h>
+
+/* Default memory size if no ATAGS found */
+#define MEM_SIZE	(SZ_32M)
+
+#define APB_TIMER0_BASE		0xe0004000
+#define APB_TIMER1_BASE		0xe0008000
+#define APB_UART0_BASE		0xe000c000
+#define APH_VIC_BASE		0xfffff000
+
+#endif /* MACH_LPC2K_HARDWARE_H */
arch/arm/mach-lpc2k/include/mach/io.h new file +18 -0
new file mode 100644
index 0000000..e1a2b7f
@@ -0,0 +1,18 @@
+/*
+ * Copyright 2011 Team Embedded VOF
+ *     Ithamar R. Adema <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef MACH_LPC2K_IO_H
+#define MACH_LPC2K_IO_H
+
+#define IO_SPACE_LIMIT	0xffffffff
+
+#define __mem_pci(a)	(a)
+#define __io(a)		__typesafe_io(a)
+
+#endif /* MACH_LPC2K_IO_H */
arch/arm/mach-lpc2k/include/mach/irqs.h new file +49 -0

49 lines not on this page · raw message

arch/arm/mach-lpc2k/include/mach/memory.h new file +15 -0
new file mode 100644
index 0000000..6432147
@@ -0,0 +1,15 @@
+/*
+ * Copyright 2011 Team Embedded VOF
+ *     Ithamar R. Adema <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef MACH_LPC2K_MEMORY_H
+#define MACH_LPC2K_MEMORY_H
+
+#define PHYS_OFFSET	0xa0000000
+
+#endif /* MACH_LPC2K_MEMORY_H */
arch/arm/mach-lpc2k/include/mach/system.h new file +23 -0
new file mode 100644
index 0000000..fbbea43
@@ -0,0 +1,23 @@
+/*
+ * Copyright 2011 Team Embedded VOF
+ *     Ithamar R. Adema <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef MACH_LPC2K_SYSTEM_H
+#define MACH_LPC2K_SYSTEM_H
+
+static void arch_idle(void)
+{
+	cpu_do_idle();
+}
+
+static inline void arch_reset(char mode, const char *cmd)
+{
+	cpu_reset(0);
+}
+
+#endif /* MACH_LPC2K_SYSTEM_H */
arch/arm/mach-lpc2k/include/mach/timex.h new file +15 -0
new file mode 100644
index 0000000..ba7c8dc
@@ -0,0 +1,15 @@
+/*
+ * Copyright 2011 Team Embedded VOF
+ *     Ithamar R. Adema <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef MACH_LPC2K_TIMEX_H
+#define MACH_LPC2K_TIMEX_H
+
+#define CLOCK_TICK_RATE		(HZ * 100UL)
+
+#endif /* MACH_LPC2K_TIMEX_H */
arch/arm/mach-lpc2k/include/mach/uncompress.h new file +50 -0

50 lines not on this page · raw message

arch/arm/mach-lpc2k/irq.c new file +17 -0
new file mode 100644
index 0000000..58d291d
@@ -0,0 +1,17 @@
+/*
+ * Copyright (C) 2011 Team Embeded VOF
+ *     Ithamar R. Adema <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include <linux/module.h>
+#include <asm/hardware/vic.h>
+#include <mach/hardware.h>
+
+void __init lpc2k_init_irq(void)
+{
+	vic_init((void __iomem *)APH_VIC_BASE, 0, ~0, 0);
+}
Signature · 1 line
1.7.1
#2 lore raw

PATCH 1/9 lpc2k: Core support

Hi,

Quoted 4 lines · Ithamar R. Adema

Core files (including IRQ handling) for NXP LPC2K architecture.

---

[...]

Quoted 28 lines
arch/arm/mach-lpc2k/include/mach/entry-macro.S new file +22 -0
new file mode 100644
index 0000000..f6c7a46
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2011 Team Embedded VOF
+ *     Ithamar R. Adema <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include <mach/hardware.h>
+
+        .macro  disable_fiq
+        .endm
+
+		.macro	get_irqnr_preamble, base, tmp
+		ldr	\base, =APH_VIC_BASE
+		.endm
+
+		.macro	arch_ret_to_user, tmp1, tmp2
+		.endm
+
+		.macro get_irqnr_and_base, irqnr, irqstat, base, tmp

arch/arm/mach-lpc2k/include/mach/entry-macro.S line 32

Quoted 10 lines
arch/arm/mach-lpc2k/include/mach/entry-macro.S new file +10 -0
+		ldr	\irqstat, [\base, #0]
+		mov     \irqnr, #0
+1001:
+		tst     \irqstat, #1
+		bne     1002f
+		add     \irqnr, \irqnr, #1
+		mov     \irqstat, \irqstat, lsr #1
+		cmp     \irqnr, #32
+		bcc     1001b
+1002:

Could you adapt the code in arch/arm/include/asm/entry-macro-vic2.S for a single VIC? That eliminates the looping that you have here.

Jamie

#3 lore raw

PATCH 1/9 lpc2k: Core support

In reply to Ithamar R. Adema

Hi,

Quoted 1 line · Ithamar R. Adema

Core files (including IRQ handling) for NXP LPC2K architecture.

<snip>

Quoted 27 lines
arch/arm/Kconfig +0 -0
index e34bf02..331540d 100644
@@ -490,6 +490,18 @@ config ARCH_LOKI

? ? ? ?help
? ? ? ? ?Support for the Marvell Loki (88RC8480) SoC.

arch/arm/Kconfig +12 -0
+config ARCH_LPC2K
+ ? ? ? bool "NXP LPC2K Family"
+ ? ? ? depends on !MMU
+ ? ? ? select CPU_ARM7TDMI
+ ? ? ? select ARM_VIC
+ ? ? ? select GENERIC_TIME
+ ? ? ? select GENERIC_CLOCKEVENTS
+ ? ? ? help
+ ? ? ? ? Support for NXP LPC2K family of SoCs. These SoCs are based on
+ ? ? ? ? an ARM7TDMI-S core, and have optional on-chip flash and SRAM,
+ ? ? ? ? also UART, I2C, SPI, SSP, CAN, RTC, and other peripherals.
+

?config ARCH_LPC32XX
? ? ? ?bool "NXP LPC32XX"
? ? ? ?select CPU_ARM926T

arch/arm/Kconfig +0 -0
@@ -928,6 +940,8 @@ source "arch/arm/mach-ks8695/Kconfig"
 

?source "arch/arm/mach-loki/Kconfig"

arch/arm/Kconfig source "arch/arm/mach-ks8695/Kconfig" · line 944

Quoted 2 lines
arch/arm/Kconfig +2 -0
+source "arch/arm/mach-lpc2k/Kconfig"
+

is there any good reason why you don't add your stuff to lpc32xx?

~Vitaly

#4 lore raw

PATCH 1/9 lpc2k: Core support

Quoted 1 line · Vitaly Wool

is there any good reason why you don't add your stuff to lpc32xx?

Most of the code (interrupt controller, clocks, etc) are completely different on the ARM7TDMI based LPC2K socs compared to the ARM9 based LPC3K SoCs. One of the only things that is fairly similar is the timers block ;-)

I've looked at solutions introducing a plat-lpc directory but it ended up introducing more "red tape" then actual shared code...

Regards,

Ithamar.

#5 lore raw

PATCH 1/9 lpc2k: Core support

In reply to Ithamar R. Adema

Hi Ithamar,

Quoted 13 lines
arch/arm/mach- renamed from arch/arm/mach-lpc2k/include/mach/system.h +0 -0

lpc2k/include/mach/system.h
new file mode 100644
index 0000000..fbbea43

arch/arm/mach-lpc2k/include/mach/system.h new file +6 -0
@@ -0,0 +1,23 @@
+/*
+ * Copyright 2011 Team Embedded VOF
+ *     Ithamar R. Adema <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as

arch/arm/mach-lpc2k/include/mach/system.h line 16

Quoted 10 lines
arch/arm/mach-lpc2k/include/mach/system.h new file +10 -0
+ * published by the Free Software Foundation.
+ */
+
+#ifndef MACH_LPC2K_SYSTEM_H
+#define MACH_LPC2K_SYSTEM_H
+
+static void arch_idle(void)
+{
+	cpu_do_idle();
+}

The 24xx devices have a CPU idle down register (PCON) that will suspend the CPU clock until the next interrupt. *pcon = 1;

arch/arm/mach-lpc2k/include/mach/system.h line 21

Quoted 5 lines
arch/arm/mach-lpc2k/include/mach/system.h new file +5 -0
+
+static inline void arch_reset(char mode, const char *cmd)
+{
+	cpu_reset(0);
+}

The entire system can be reset via RESETOUT using the watchdog timer.

#6 lore raw

PATCH 1/9 lpc2k: Core support

On Thu, 2011-03-17 at 23:08 +0100, Kevin Wells wrote:
[...]

Quoted 7 lines

arch/arm/mach-lpc2k/include/mach/system.h line 16

Quoted 4 lines
arch/arm/mach-lpc2k/include/mach/system.h new file +4 -0
+static void arch_idle(void)
+{
+	cpu_do_idle();
+}

The 24xx devices have a CPU idle down register (PCON) that will suspend the CPU clock until the next interrupt. *pcon = 1;

Yes, I know, but was planning on introducing that together with suspend/resume in a next patch series. I've had it in locally already but got some interrupt disable/enable errors during exit of idle mode that need further investigation.

Quoted 7 lines

arch/arm/mach-lpc2k/include/mach/system.h line 21

Quoted 5 lines
arch/arm/mach-lpc2k/include/mach/system.h new file +5 -0
+
+static inline void arch_reset(char mode, const char *cmd)
+{
+	cpu_reset(0);
+}

The entire system can be reset via RESETOUT using the watchdog timer.

Again, was planning that for the patch set that will introduce the watchdog driver.

Regards,

Ithamar.

#7 lore raw

PATCH 2/9 lpc2k: Exception vector handling

In reply to Ithamar R. Adema

Since the LPC2K does not have an MMU (ARM7TDMI based), it expects the vectors to be stored in on-chip SRAM. However, this moves the vectors too far away from the stubs page, requiring the vector jumps to be indirect.

Since now VECTOR_BASE is below PHYS_OFFSET, do not try to reserve the vector page, as it will fail (and prevent the kernel from booting).

Also, commit 247055aa (6384/1: Remove the domain switching on ARMv6k/v7 CPUs) broke the placement of vectors in the !MMU case, so fix this too.

---
 arch/arm/Kconfig             |    1 +
 arch/arm/kernel/entry-armv.S |   18 ++++++++++++++++++
 arch/arm/kernel/traps.c      |    2 +-
 arch/arm/mm/nommu.c          |    2 ++
 4 files changed, 22 insertions(+), 1 deletions(-)
arch/arm/Kconfig +1 -0
index 331540d..9c12d71 100644
@@ -186,6 +186,7 @@ config VECTORS_BASE
 	hex
 	default 0xffff0000 if MMU || CPU_HIGH_VECTOR
 	default DRAM_BASE if REMAP_VECTORS_TO_RAM
+	default 0x40000000 if ARCH_LPC2K
 	default 0x00000000
 	help
 	  The base address of exception vectors.
arch/arm/kernel/entry-armv.S +18 -0
index e8d8856..618a971 100644
@@ -1208,6 +1208,7 @@ __stubs_end:
 
 	.globl	__vectors_start
 __vectors_start:
+#ifndef CONFIG_ARCH_LPC2K
  ARM(	swi	SYS_ERROR0	)
  THUMB(	svc	#0		)
  THUMB(	nop			)
@@ -1218,6 +1219,23 @@ __vectors_start:
 	W(b)	vector_addrexcptn + stubs_offset
 	W(b)	vector_irq + stubs_offset
 	W(b)	vector_fiq + stubs_offset
+#else /* CONFIG_ARCH_LPC2K */
+	swi	SYS_ERROR0
+	ldr	pc, .vector_und
+	ldr	pc, .vector_swi
+	ldr	pc, .vector_pabt
+	ldr	pc, .vector_dabt
+	ldr	pc, .vector_addrexcptn
+	ldr	pc, .vector_irq
+	ldr	pc, .vector_fiq
+.vector_und:		.word   vector_und
+.vector_swi:		.word   vector_swi
+.vector_pabt:		.word   vector_pabt
+.vector_dabt:		.word   vector_dabt
+.vector_addrexcptn:	.word   vector_addrexcptn
+.vector_irq:		.word   vector_irq
+.vector_fiq:		.word   vector_fiq
+#endif
 
 	.globl	__vectors_end
 __vectors_end:
arch/arm/kernel/traps.c +1 -1
index 21ac43f..639c4c8 100644
@@ -758,7 +758,7 @@ static void __init kuser_get_tls_init(unsigned long vectors)
 
 void __init early_trap_init(void)
 {
-#if defined(CONFIG_CPU_USE_DOMAINS)
+#if defined(CONFIG_CPU_USE_DOMAINS) || !defined(CONFIG_MMU)
 	unsigned long vectors = CONFIG_VECTORS_BASE;
 #else
 	unsigned long vectors = (unsigned long)vectors_page;
arch/arm/mm/nommu.c +2 -0
index 687d023..e3bec02 100644
@@ -24,7 +24,9 @@ void __init arm_mm_memblock_reserve(void)
 	 * some architectures which the DRAM is the exception vector to trap,
 	 * alloc_page breaks with error, although it is not NULL, but "0."
 	 */
+#if PHYS_OFFSET <= CONFIG_VECTORS_BASE
 	memblock_reserve(CONFIG_VECTORS_BASE, PAGE_SIZE);
+#endif
 }
 
 /*
Signature · 1 line
1.7.1
#8 lore raw

PATCH 2/9 lpc2k: Exception vector handling

Quoted 43 lines · Ithamar R. Adema

Since the LPC2K does not have an MMU (ARM7TDMI based), it expects the vectors to be stored in on-chip SRAM. However, this moves the vectors too far away from the stubs page, requiring the vector jumps to be indirect.

Since now VECTOR_BASE is below PHYS_OFFSET, do not try to reserve the vector page, as it will fail (and prevent the kernel from booting).

Also, commit 247055aa (6384/1: Remove the domain switching on ARMv6k/v7 CPUs) broke the placement of vectors in the !MMU case, so fix this too.

---
 arch/arm/Kconfig             |    1 +
 arch/arm/kernel/entry-armv.S |   18 ++++++++++++++++++
 arch/arm/kernel/traps.c      |    2 +-
 arch/arm/mm/nommu.c          |    2 ++
 4 files changed, 22 insertions(+), 1 deletions(-)
arch/arm/Kconfig +1 -0
index 331540d..9c12d71 100644
@@ -186,6 +186,7 @@ config VECTORS_BASE
 	hex
 	default 0xffff0000 if MMU || CPU_HIGH_VECTOR
 	default DRAM_BASE if REMAP_VECTORS_TO_RAM
+	default 0x40000000 if ARCH_LPC2K
 	default 0x00000000
 	help
 	  The base address of exception vectors.
arch/arm/kernel/entry-armv.S +1 -0
index e8d8856..618a971 100644
@@ -1208,6 +1208,7 @@ __stubs_end:
 
 	.globl	__vectors_start
 __vectors_start:
+#ifndef CONFIG_ARCH_LPC2K
  ARM(	swi	SYS_ERROR0	)
  THUMB(	svc	#0		)
  THUMB(	nop			)

arch/arm/kernel/entry-armv.S __vectors_start: · line 1222

Quoted 4 lines
arch/arm/kernel/entry-armv.S +1 -0
@@ -1218,6 +1219,23 @@ __vectors_start:
 	W(b)	vector_addrexcptn + stubs_offset
 	W(b)	vector_irq + stubs_offset
 	W(b)	vector_fiq + stubs_offset
+#else /* CONFIG_ARCH_LPC2K */

The description from the commit log should be repeated here.

And I wonder if this shouldn't depend on CONFIG_ARCH_LPC2K but CONFIG_MMU.

arch/arm/kernel/entry-armv.S __vectors_start: · line 1223

Quoted 1 line
arch/arm/kernel/entry-armv.S +1 -0
+	swi	SYS_ERROR0

I think arm7tdmi doesn't have thumb2, does it? If it has you need to do ARM(swi SYS_ERROR0)
THUMB(svc ..)
...

as above

Quoted 54 lines
arch/arm/kernel/entry-armv.S +15 -0
+	ldr	pc, .vector_und
+	ldr	pc, .vector_swi
+	ldr	pc, .vector_pabt
+	ldr	pc, .vector_dabt
+	ldr	pc, .vector_addrexcptn
+	ldr	pc, .vector_irq
+	ldr	pc, .vector_fiq
+.vector_und:		.word   vector_und
+.vector_swi:		.word   vector_swi
+.vector_pabt:		.word   vector_pabt
+.vector_dabt:		.word   vector_dabt
+.vector_addrexcptn:	.word   vector_addrexcptn
+.vector_irq:		.word   vector_irq
+.vector_fiq:		.word   vector_fiq
+#endif
 
 	.globl	__vectors_end
 __vectors_end:
arch/arm/kernel/traps.c +1 -1
index 21ac43f..639c4c8 100644
@@ -758,7 +758,7 @@ static void __init kuser_get_tls_init(unsigned long vectors)
 
 void __init early_trap_init(void)
 {
-#if defined(CONFIG_CPU_USE_DOMAINS)
+#if defined(CONFIG_CPU_USE_DOMAINS) || !defined(CONFIG_MMU)
 	unsigned long vectors = CONFIG_VECTORS_BASE;
 #else
 	unsigned long vectors = (unsigned long)vectors_page;
arch/arm/mm/nommu.c +2 -0
index 687d023..e3bec02 100644
@@ -24,7 +24,9 @@ void __init arm_mm_memblock_reserve(void)
 	 * some architectures which the DRAM is the exception vector to trap,
 	 * alloc_page breaks with error, although it is not NULL, but "0."
 	 */
+#if PHYS_OFFSET <= CONFIG_VECTORS_BASE
 	memblock_reserve(CONFIG_VECTORS_BASE, PAGE_SIZE);
+#endif
 }
 
 /*
Signature · 7 lines
1.7.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Signature · 2 lines
Pengutronix e.K.                           | Uwe Kleine-K?nig            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
#9 lore raw

PATCH 2/9 lpc2k: Exception vector handling

Quoted 7 lines · Uwe Kleine-K?nig
Quoted 6 lines · Ithamar R. Adema
arch/arm/kernel/entry-armv.S +0 -0
index e8d8856..618a971 100644
@@ -1208,6 +1208,7 @@ __stubs_end:
 
Quoted 12 lines

arch/arm/kernel/entry-armv.S __vectors_start: · line 1222

Quoted 11 lines
arch/arm/kernel/entry-armv.S +2 -0
 	.globl	__vectors_start
 __vectors_start:
+#ifndef CONFIG_ARCH_LPC2K
  ARM(	swi	SYS_ERROR0	)
  THUMB(	svc	#0		)
  THUMB(	nop			)
@@ -1218,6 +1219,23 @@ __vectors_start:
 	W(b)	vector_addrexcptn + stubs_offset
 	W(b)	vector_irq + stubs_offset
 	W(b)	vector_fiq + stubs_offset
+#else /* CONFIG_ARCH_LPC2K */

The description from the commit log should be repeated here.

OK, will include the description as comment there in the next version.

Quoted 2 lines

And I wonder if this shouldn't depend on CONFIG_ARCH_LPC2K but CONFIG_MMU.

Well, looking at th uClinux kernel tree, it seems this was only done for the NXP LPC2K range, so that's why I kept it under CONFIG_ARCH_LPC2K.

Quoted 7 lines

arch/arm/kernel/entry-armv.S __vectors_start: · line 1223

Quoted 1 line
arch/arm/kernel/entry-armv.S +1 -0
+	swi	SYS_ERROR0

I think arm7tdmi doesn't have thumb2, does it? If it has you need to do ARM(swi SYS_ERROR0)
THUMB(svc ..)
...

as above

Correct, the ARM7TDMI-S only supports Thumb, not Thumb2.

Thanks for reviewing!

Ithamar.

#10 lore raw

PATCH 2/9 lpc2k: Exception vector handling

Quoted 21 lines · Ithamar R. Adema
Quoted 7 lines · Uwe Kleine-K??nig
Quoted 6 lines · Ithamar R. Adema
arch/arm/kernel/entry-armv.S +0 -0
index e8d8856..618a971 100644
@@ -1208,6 +1208,7 @@ __stubs_end:
 
Quoted 12 lines

arch/arm/kernel/entry-armv.S __vectors_start: · line 1222

Quoted 11 lines
arch/arm/kernel/entry-armv.S +2 -0
  	.globl	__vectors_start
  __vectors_start:
+#ifndef CONFIG_ARCH_LPC2K
   ARM(	swi	SYS_ERROR0	)
   THUMB(	svc	#0		)
   THUMB(	nop			)
@@ -1218,6 +1219,23 @@ __vectors_start:
  	W(b)	vector_addrexcptn + stubs_offset
  	W(b)	vector_irq + stubs_offset
  	W(b)	vector_fiq + stubs_offset
+#else /* CONFIG_ARCH_LPC2K */

The description from the commit log should be repeated here.

Quoted 7 lines

OK, will include the description as comment there in the next version.

Quoted 2 lines

And I wonder if this shouldn't depend on CONFIG_ARCH_LPC2K but CONFIG_MMU.

Well, looking at th uClinux kernel tree, it seems this was only done for the NXP LPC2K range, so that's why I kept it under CONFIG_ARCH_LPC2K.

IIRC most of the non-MMU ARMs had the vectors in normal RAM, so they would end up close to the code. That is why this may have been the only one with the vectors ending up a long way away. So it is not specific to non-MMU, but one day there may be other types that need to do this too.

Regards
Greg

Quoted 23 lines
Quoted 7 lines

arch/arm/kernel/entry-armv.S __vectors_start: · line 1223

Quoted 1 line
arch/arm/kernel/entry-armv.S +1 -0
+	swi	SYS_ERROR0

I think arm7tdmi doesn't have thumb2, does it? If it has you need to do ARM(swi SYS_ERROR0)
THUMB(svc ..)
...

as above

Correct, the ARM7TDMI-S only supports Thumb, not Thumb2.

Thanks for reviewing!

Ithamar.

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

Signature · 5 lines
------------------------------------------------------------------------
Greg Ungerer  --  Principal Engineer        EMAIL:     gerg at snapgear.com
SnapGear Group, McAfee                      PHONE:       +61 7 3435 2888
8 Gardner Close                             FAX:         +61 7 3217 5323
Milton, QLD, 4064, Australia                WEB: http://www.SnapGear.com
#11 lore raw

PATCH 3/9 lpc2k: clk API

In reply to Ithamar R. Adema

Implements clock API using the CLKDEV_LOOKUP common code.

---
 arch/arm/Kconfig                              |    1 +
 arch/arm/mach-lpc2k/Makefile                  |    2 +-
 arch/arm/mach-lpc2k/clock.c                   |  355 +++++++++++++++++++++++++
 arch/arm/mach-lpc2k/include/mach/clkdev.h     |   17 ++
 arch/arm/mach-lpc2k/include/mach/hardware.h   |    1 +
 arch/arm/mach-lpc2k/include/mach/regs-clock.h |   36 +++
 6 files changed, 411 insertions(+), 1 deletions(-)
 create mode 100644 arch/arm/mach-lpc2k/clock.c
 create mode 100644 arch/arm/mach-lpc2k/include/mach/clkdev.h
 create mode 100644 arch/arm/mach-lpc2k/include/mach/regs-clock.h
arch/arm/Kconfig +1 -0
index 9c12d71..35297f9 100644
@@ -496,6 +496,7 @@ config ARCH_LPC2K
 	depends on !MMU
 	select CPU_ARM7TDMI
 	select ARM_VIC
+	select CLKDEV_LOOKUP
 	select GENERIC_TIME
 	select GENERIC_CLOCKEVENTS
 	help
arch/arm/mach-lpc2k/Makefile +1 -1
index 546666b..9eb0a6a 100644
@@ -1 +1 @@
-obj-y	:= irq.o
+obj-y	:= clock.o irq.o
arch/arm/mach-lpc2k/clock.c new file +355 -0

355 lines not on this page · raw message

arch/arm/mach-lpc2k/include/mach/clkdev.h new file +17 -0
new file mode 100644
index 0000000..92267cc
@@ -0,0 +1,17 @@
+/*
+ *  Copyright (C) 2011 Team Embedded VOF
+ *     Ithamar R. Adema <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#ifndef MACH_LPC2K_CLKDEV_H
+#define MACH_LPC2K_CLKDEV_H
+
+#define __clk_get(clk) ({ 1; })
+#define __clk_put(clk) do { } while (0)
+
+#endif /* MACH_LPC2K_CLKDEV_H */
arch/arm/mach-lpc2k/include/mach/hardware.h +1 -0
index 7663e97..ce19ff7 100644
@@ -18,6 +18,7 @@
 #define APB_TIMER0_BASE		0xe0004000
 #define APB_TIMER1_BASE		0xe0008000
 #define APB_UART0_BASE		0xe000c000
+#define APB_SCB_BASE		0xe01fc000
 #define APH_VIC_BASE		0xfffff000
 
 #endif /* MACH_LPC2K_HARDWARE_H */
arch/arm/mach-lpc2k/include/mach/regs-clock.h new file +36 -0
new file mode 100644
index 0000000..1c94582
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2011 Team Embedded VOF
+ *     Ithamar R. Adema <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef MACH_LPC2K_REGS_CLOCK_H
+#define MACH_LPC2K_REGS_CLOCK_H
+
+#define CLKSRCSEL	0x10c
+#define CLKSRC(x)	((x) & 3)
+#define PLLCON		0x080
+#define PLLCFG		0x084
+#define PLLSTAT		0x088
+#define M(x)		(((x) & 0x7fff) + 1)
+#define N(x)		((((x) >> 16) & 0xf) + 1)
+#define PLLE		(1 << 24)
+#define PLLC		(1 << 25)
+#define PLLFEED		0x08c
+
+#define CCLKCFG		0x104
+#define CCLKSEL(x)	((x) & 0xff)
+#define USBCLKCFG	0x108
+#define USBSEL(x)	((x) & 0xf)
+#define IRCTRIM		0x1a4
+#define PCLKSEL0	0x1a8
+#define PCLKSEL1	0x1ac
+
+#define PCON		0x0c0
+#define INTWAKE		0x144
+#define PCONP		0x0c4
+
+#endif /* MACH_LPC2K_REGS_CLOCK_H */
Signature · 1 line
1.7.1
#12 lore raw

PATCH 3/9 lpc2k: clk API

Quoted 4 lines
arch/arm/mach-lpc2k/clock.c new file +4 -0
+struct clk {
+	int		refcount;
+	struct clk	*parent;
+	unsigned long	rate;

arch/arm/mach-lpc2k/clock.c line 38

Quoted 10 lines
arch/arm/mach-lpc2k/clock.c new file +10 -0
+
+	u32		enable_mask;
+
+	long		(*round_rate)(struct clk *clk, unsigned long rate);
+	int		(*set_rate)(struct clk *clk, unsigned long rate);
+	unsigned long	(*get_rate)(struct clk *clk);
+	int		(*set_parent)(struct clk *clk, struct clk *parent);
+};
+
+static DEFINE_MUTEX(clocks_mutex);

I tried this lock mechanism and occasionally I get warnings when mutex checking is enabled and multiple calls occur to the clk_* functions with active clock management. Spinlocks might be better, but maybe some one else can chime in here.

Quoted 7 lines
(quoted diff) +5 -2
+
+/*-----------------------------------------------------------------------
--
+ * Standard clock functions defined in include/linux/clk.h
+ *-----------------------------------------------------------------------
--*/
+
#13 lore raw

PATCH 3/9 lpc2k: clk API

Hi Kevin,

Quoted 6 lines · Kevin Wells
Quoted 1 line

+static DEFINE_MUTEX(clocks_mutex);

I tried this lock mechanism and occasionally I get warnings when mutex checking is enabled and multiple calls occur to the clk_* functions with active clock management. Spinlocks might be better, but maybe some one else can chime in here.

Looking at the other mach-*/clock.c implementations, most seem to agree on spinlocks. Will change for v2.

Regards,

Ithamar.

#14 lore raw

PATCH 3/9 lpc2k: clk API

In reply to Ithamar R. Adema
Quoted 16 lines
arch/arm/mach-lpc2k/include/mach/regs-clock.h new file +9 -0
new file mode 100644
index 0000000..1c94582
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2011 Team Embedded VOF
+ *     Ithamar R. Adema <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+

arch/arm/mach-lpc2k/include/mach/regs-clock.h line 19

Quoted 10 lines
arch/arm/mach-lpc2k/include/mach/regs-clock.h new file +10 -0
+#ifndef MACH_LPC2K_REGS_CLOCK_H
+#define MACH_LPC2K_REGS_CLOCK_H
+
+#define CLKSRCSEL	0x10c
+#define CLKSRC(x)	((x) & 3)
+#define PLLCON		0x080
+#define PLLCFG		0x084
+#define PLLSTAT		0x088
+#define M(x)		(((x) & 0x7fff) + 1)
+#define N(x)		((((x) >> 16) & 0xf) + 1)

N has a field size of 8 bits? Mask should be 0xff

Quoted 1 line
arch/arm/mach-lpc2k/include/mach/regs-clock.h new file +1 -0
+#define PLLE		(1 << 24)
#15 lore raw

PATCH 3/9 lpc2k: clk API

Hi Kevin,

Quoted 20 lines · Kevin Wells
Quoted 20 lines
arch/arm/mach-lpc2k/include/mach/regs-clock.h new file +13 -0
new file mode 100644
index 0000000..1c94582
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2011 Team Embedded VOF
+ *     Ithamar R. Adema <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef MACH_LPC2K_REGS_CLOCK_H
+#define MACH_LPC2K_REGS_CLOCK_H
+
+#define CLKSRCSEL	0x10c
Quoted 8 lines

arch/arm/mach-lpc2k/include/mach/regs-clock.h line 19

Quoted 6 lines
arch/arm/mach-lpc2k/include/mach/regs-clock.h new file +6 -0
+#define CLKSRC(x)	((x) & 3)
+#define PLLCON		0x080
+#define PLLCFG		0x084
+#define PLLSTAT		0x088
+#define M(x)		(((x) & 0x7fff) + 1)
+#define N(x)		((((x) >> 16) & 0xf) + 1)

N has a field size of 8 bits? Mask should be 0xff

Ouch, will fix for v2 of this patchset!

Ithamar.

#16 lore raw

PATCH 4/9 lpc2k: generic time and clockevents

In reply to Ithamar R. Adema

This code was mostly "borrowed" form the lpc32xx implementation.

---
 arch/arm/mach-lpc2k/Makefile |    2 +-
 arch/arm/mach-lpc2k/time.c   |  174 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 175 insertions(+), 1 deletions(-)
 create mode 100644 arch/arm/mach-lpc2k/time.c
arch/arm/mach-lpc2k/Makefile +1 -1
index 9eb0a6a..267432c 100644
@@ -1 +1 @@
-obj-y	:= clock.o irq.o
+obj-y	:= clock.o irq.o time.o
arch/arm/mach-lpc2k/time.c new file +174 -0

174 lines not on this page · raw message

Signature · 1 line
1.7.1
#17 lore raw

PATCH 4/9 lpc2k: generic time and clockevents

Hi,

One pedantic nitpick, but otherwise looks nice to me.

Jamie

Quoted 116 lines · Ithamar R. Adema

This code was mostly "borrowed" form the lpc32xx implementation.

---
 arch/arm/mach-lpc2k/Makefile |    2 +-
 arch/arm/mach-lpc2k/time.c   |  174 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 175 insertions(+), 1 deletions(-)
 create mode 100644 arch/arm/mach-lpc2k/time.c
arch/arm/mach-lpc2k/Makefile +1 -1
index 9eb0a6a..267432c 100644
@@ -1 +1 @@
-obj-y	:= clock.o irq.o
+obj-y	:= clock.o irq.o time.o
arch/arm/mach-lpc2k/time.c new file +94 -0
new file mode 100644
index 0000000..b430f7c
@@ -0,0 +1,174 @@
+/*
+ * Copyright (C) 2011 Team Embeded VOF
+ * Copyright (C) 2009 - 2010 NXP Semiconductors
+ * Copyright (C) 2009 Fontys University of Applied Sciences, Eindhoven
+ *                    Ed Schouten <[email protected]>
+ *                    Laurens Timmermans <[email protected]>
+ *
+ * Based on timer code from plat-lpc32xx.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include <linux/module.h>
+#include <linux/interrupt.h>
+#include <linux/irq.h>
+#include <linux/time.h>
+#include <linux/err.h>
+#include <linux/clockchips.h>
+#include <linux/clk.h>
+
+#include <asm/mach/time.h>
+
+#include <mach/hardware.h>
+
+#define IR		0x00
+#define TCR		0x04
+#define TC		0x08
+#define PR		0x0c
+#define PC		0x10
+#define MCR		0x14
+#define MR0		0x18
+#define MR1		0x1c
+#define MR2		0x20
+#define CCR		0x28
+#define CR0		0x2c
+#define CR1		0x30
+#define CR2		0x34
+#define CR3		0x38
+#define EMR		0x3c
+#define CTCR		0x70
+
+#define IR_MR_SHIFT	0
+#define IR_CR_SHIFT	4
+
+#define TCR_EN		(1 << 0)
+#define TCR_RESET	(1 << 1)
+
+
+static void __iomem *timer0 = (void __iomem *)APB_TIMER0_BASE;
+static void __iomem *timer1 = (void __iomem *)APB_TIMER1_BASE;
+
+static cycle_t lpc2k_clksrc_read(struct clocksource *cs)
+{
+	return __raw_readl(timer1 + TC);
+}
+
+static struct clocksource lpc2k_clksrc = {
+	.name	= "lpc2k_clksrc",
+	.rating	= 300,
+	.read	= lpc2k_clksrc_read,
+	.mask	= CLOCKSOURCE_MASK(32),
+	.flags	= CLOCK_SOURCE_IS_CONTINUOUS,
+};
+
+static int lpc2k_clkevt_next_event(unsigned long delta,
+	struct clock_event_device *dev)
+{
+	__raw_writel(TCR_RESET, timer0 + TCR);
+	__raw_writel(delta, timer0 + PR);
+	__raw_writel(TCR_EN, timer0 + TCR);
+
+	return 0;
+}
+
+static void lpc2k_clkevt_mode(enum clock_event_mode mode,
+	struct clock_event_device *dev)
+{
+	switch (mode) {
+	case CLOCK_EVT_MODE_PERIODIC:
+		BUG();
+		break;
+
+	case CLOCK_EVT_MODE_ONESHOT:
+	case CLOCK_EVT_MODE_SHUTDOWN:
+		/*
+		 * Disable the timer. When using oneshot, we must also
+		 * disable the timer to wait for the first call to
+		 * set_next_event().
+		 */
+		__raw_writel(0, timer0 + TCR);
+		break;
+

arch/arm/mach-lpc2k/time.c line 104

Quoted 10 lines
arch/arm/mach-lpc2k/time.c new file +10 -0
+	case CLOCK_EVT_MODE_UNUSED:
+	case CLOCK_EVT_MODE_RESUME:
+		break;
+	}
+}
+
+static struct clock_event_device lpc2k_clkevt = {
+	.name		= "lpc2k_clkevt",
+	.features	= CLOCK_EVT_FEAT_ONESHOT,
+	.shift		= 32,

You shouldn't need to specify a shift if you use clockevents_calc_mult_shift() and let the core code calculate mult and shift for you.

Quoted 42 lines
arch/arm/mach-lpc2k/time.c new file +42 -0
+	.rating		= 300,
+	.set_next_event	= lpc2k_clkevt_next_event,
+	.set_mode	= lpc2k_clkevt_mode,
+};
+
+static irqreturn_t lpc2k_timer_interrupt(int irq, void *dev_id)
+{
+	struct clock_event_device *evt = &lpc2k_clkevt;
+
+	/* Clear match */
+	__raw_writel((1 << IR_MR_SHIFT), timer0 + IR);
+
+	evt->event_handler(evt);
+
+	return IRQ_HANDLED;
+}
+
+static struct irqaction lpc2k_timer_irq = {
+	.name		= "LPC2K Timer Tick",
+	.flags		= IRQF_DISABLED | IRQF_TIMER | IRQF_IRQPOLL,
+	.handler	= lpc2k_timer_interrupt,
+};
+
+/*
+ * The clock management driver isn't initialized at this point, so the
+ * clocks need to be enabled here manually and then tagged as used in
+ * the clock driver initialization
+ */
+static void __init lpc2k_timer_init(void)
+{
+	unsigned long rate;
+	struct clk *clk;
+
+	clk = clk_get(NULL, "timer1");
+	BUG_ON(IS_ERR(clk));
+
+	clk_enable(clk);
+	rate = clk_get_rate(clk);
+	clk_put(clk);
+
+	/* Initial timer setup */
+	__raw_writel(0, timer0 + TCR);

arch/arm/mach-lpc2k/time.c line 156

Quoted 10 lines
arch/arm/mach-lpc2k/time.c new file +10 -0
+	__raw_writel(1 << IR_MR_SHIFT, timer0 + IR);
+	__raw_writel(1, timer0 + MR0);
+	__raw_writel(3 << 0, timer0 + MCR);
+
+	/* Setup tick interrupt */
+	setup_irq(IRQ_LPC2K_TIMER0, &lpc2k_timer_irq);
+
+	/* Setup the clockevent structure. */
+	lpc2k_clkevt.mult = div_sc(rate, NSEC_PER_SEC,
+		lpc2k_clkevt.shift);

clockevents_calc_mult_shift() will take care of this for you.

Quoted 19 lines
arch/arm/mach-lpc2k/time.c new file +18 -1
+	lpc2k_clkevt.max_delta_ns = clockevent_delta2ns(-1,
+		&lpc2k_clkevt);
+	lpc2k_clkevt.min_delta_ns = clockevent_delta2ns(1,
+		&lpc2k_clkevt) + 1;
+	lpc2k_clkevt.cpumask = cpumask_of(0);
+	clockevents_register_device(&lpc2k_clkevt);
+
+	/* Use timer1 as clock source. */
+	__raw_writel(TCR_RESET, timer1 + TCR);
+	__raw_writel(0, timer1 + PR);
+	__raw_writel(0, timer1 + MCR);
+	__raw_writel(TCR_EN, timer1 + TCR);
+	clocksource_register_hz(&lpc2k_clksrc, rate);
+}
+
+struct sys_timer lpc2k_timer = {
+	.init		= &lpc2k_timer_init,
+};
-- 1.7.1
#18 lore raw

PATCH 4/9 lpc2k: generic time and clockevents

Quoted 1 line · Jamie Iles

One pedantic nitpick, but otherwise looks nice to me.

Thanks for reviewing, and pedantic nitpicks are always welcome ;)

Quoted 1 line · Ithamar R. Adema

[....]

Quoted 8 lines

arch/arm/mach-lpc2k/time.c line 104

Quoted 4 lines
arch/arm/mach-lpc2k/time.c new file +4 -0
+static struct clock_event_device lpc2k_clkevt = {
+	.name		= "lpc2k_clkevt",
+	.features	= CLOCK_EVT_FEAT_ONESHOT,
+	.shift		= 32,

You shouldn't need to specify a shift if you use clockevents_calc_mult_shift() and let the core code calculate mult and shift for you.

Good point, I should use that. Will include this in the next version of these patches!

Regards,

Ithamar.

#19 lore raw

PATCH 5/9 lpc2k: gpiolib

In reply to Ithamar R. Adema

gpiolib support, including gpio interrupts.

---
 arch/arm/Kconfig                            |    1 +
 arch/arm/mach-lpc2k/Makefile                |    2 +-
 arch/arm/mach-lpc2k/gpio.c                  |  265 +++++++++++++++++++++++++++
 arch/arm/mach-lpc2k/include/mach/gpio.h     |   22 +++
 arch/arm/mach-lpc2k/include/mach/hardware.h |    2 +
 arch/arm/mach-lpc2k/include/mach/irqs.h     |   69 +++++++-
 6 files changed, 359 insertions(+), 2 deletions(-)
 create mode 100644 arch/arm/mach-lpc2k/gpio.c
 create mode 100644 arch/arm/mach-lpc2k/include/mach/gpio.h
arch/arm/Kconfig +1 -0
index 35297f9..fce855d 100644
@@ -499,6 +499,7 @@ config ARCH_LPC2K
 	select CLKDEV_LOOKUP
 	select GENERIC_TIME
 	select GENERIC_CLOCKEVENTS
+	select ARCH_REQUIRE_GPIOLIB
 	help
 	  Support for NXP LPC2K family of SoCs. These SoCs are based on
 	  an ARM7TDMI-S core, and have optional on-chip flash and SRAM,
arch/arm/mach-lpc2k/Makefile +1 -1
index 267432c..89596a7 100644
@@ -1 +1 @@
-obj-y	:= clock.o irq.o time.o
+obj-y	:= clock.o irq.o gpio.o time.o
arch/arm/mach-lpc2k/gpio.c new file +265 -0

265 lines not on this page · raw message

arch/arm/mach-lpc2k/include/mach/gpio.h new file +22 -0
new file mode 100644
index 0000000..efa970a
@@ -0,0 +1,22 @@
+/*
+ *  Copyright (C) 2011 Team Embedded VOF
+ *     Ithamar R. Adema <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ */
+
+#ifndef MACH_LPC2K_GPIO_H
+#define MACH_LPC2K_GPIO_H
+
+#include <asm-generic/gpio.h>
+
+#define gpio_get_value	__gpio_get_value
+#define gpio_set_value	__gpio_set_value
+#define gpio_cansleep	__gpio_cansleep
+#define gpio_to_irq	__gpio_to_irq
+
+#endif /* MACH_LPC2K_GPIO_H */
arch/arm/mach-lpc2k/include/mach/hardware.h +2 -0
index ce19ff7..0d7c10c 100644
@@ -15,9 +15,11 @@
 /* Default memory size if no ATAGS found */
 #define MEM_SIZE	(SZ_32M)
 
+#define FAST_GPIO_BASE		0x3fffc000
 #define APB_TIMER0_BASE		0xe0004000
 #define APB_TIMER1_BASE		0xe0008000
 #define APB_UART0_BASE		0xe000c000
+#define APB_GPIO_BASE		0xe0028000
 #define APB_SCB_BASE		0xe01fc000
 #define APH_VIC_BASE		0xfffff000
 
arch/arm/mach-lpc2k/include/mach/irqs.h +68 -1

74 lines not on this page · raw message

Signature · 1 line
1.7.1
#20 lore raw

PATCH 6/9 lpc2k: multifunction pin configuration

In reply to Ithamar R. Adema

Inspired by the mfp support in PXA. Includes definition of pins for NXP LPC2468/78.

---
 arch/arm/mach-lpc2k/Makefile                   |    2 +-
 arch/arm/mach-lpc2k/include/mach/hardware.h    |    1 +
 arch/arm/mach-lpc2k/include/mach/mfp-lpc24xx.h |   98 +++++++++++
 arch/arm/mach-lpc2k/include/mach/mfp.h         |  209 ++++++++++++++++++++++++
 arch/arm/mach-lpc2k/mfp.c                      |   99 +++++++++++
 5 files changed, 408 insertions(+), 1 deletions(-)
 create mode 100644 arch/arm/mach-lpc2k/include/mach/mfp-lpc24xx.h
 create mode 100644 arch/arm/mach-lpc2k/include/mach/mfp.h
 create mode 100644 arch/arm/mach-lpc2k/mfp.c
arch/arm/mach-lpc2k/Makefile +1 -1
index 89596a7..2c50bb9 100644
@@ -1 +1 @@
-obj-y	:= clock.o irq.o gpio.o time.o
+obj-y	:= clock.o irq.o gpio.o mfp.o time.o
arch/arm/mach-lpc2k/include/mach/hardware.h +1 -0
index 0d7c10c..29c561a 100644
@@ -20,6 +20,7 @@
 #define APB_TIMER1_BASE		0xe0008000
 #define APB_UART0_BASE		0xe000c000
 #define APB_GPIO_BASE		0xe0028000
+#define APB_PINSEL_BASE		0xe002c000
 #define APB_SCB_BASE		0xe01fc000
 #define APH_VIC_BASE		0xfffff000
 
arch/arm/mach-lpc2k/include/mach/mfp-lpc24xx.h new file +98 -0

98 lines not on this page · raw message

arch/arm/mach-lpc2k/include/mach/mfp.h new file +209 -0

209 lines not on this page · raw message

arch/arm/mach-lpc2k/mfp.c new file +99 -0

99 lines not on this page · raw message

Signature · 1 line
1.7.1
#21 lore raw

PATCH 7/9 lpc2k: Add EmbeddedArtists LPC2478 Developer's Kit board

In reply to Ithamar R. Adema

Add support for EmbeddedArtists LPC2478 Developer's Kit, consisting of the LPC2478OEM board, with QVGA base board. For details, see:

http://www.embeddedartists.com/products/kits/lpc2478_kit.php

---
 arch/arm/mach-lpc2k/Kconfig           |    7 ++
 arch/arm/mach-lpc2k/Makefile          |    2 +
 arch/arm/mach-lpc2k/common.h          |   21 ++++++
 arch/arm/mach-lpc2k/mach-lpc2478oem.c |  121 +++++++++++++++++++++++++++++++++
 4 files changed, 151 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/mach-lpc2k/common.h
 create mode 100644 arch/arm/mach-lpc2k/mach-lpc2478oem.c
arch/arm/mach-lpc2k/Kconfig +7 -0
index fad47b8..162d616 100644
@@ -2,4 +2,11 @@ if ARCH_LPC2K
 
 comment "LPC2K machines"
 
+config MACH_LPC2478OEM
+	bool "Embedded Artists LPC2478 Developer's Kit"
+	help
+	  Say Y if you want the kernel to support the EmbeddedArtists
+	  LPC2478 Developer's Kit. For more hardware details, see:
+	  http://www.embeddedartists.com/products/kits/lpc2478_kit.php
+
 endif
arch/arm/mach-lpc2k/Makefile +2 -0
index 2c50bb9..a969f44 100644
@@ -1 +1,3 @@
 obj-y	:= clock.o irq.o gpio.o mfp.o time.o
+
+obj-$(CONFIG_MACH_LPC2478OEM) += mach-lpc2478oem.o
arch/arm/mach-lpc2k/common.h new file +21 -0
new file mode 100644
index 0000000..6b775d9
@@ -0,0 +1,21 @@
+/*
+ * Copyright 2011 Team Embedded VOF
+ *     Ithamar R. Adema <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef LPC2K_COMMON_H
+#define LPC2K_COMMON_H
+
+struct sys_timer;
+
+extern void lpc2k_init_clocks(unsigned long xtal, unsigned long rtc);
+extern void lpc2k_mfp_config(unsigned long *mfp_cfgs, int num);
+extern void lpc2k_init_irq(void);
+
+extern struct sys_timer lpc2k_timer;
+
+#endif /* LPC2K_COMMON_H */
arch/arm/mach-lpc2k/mach-lpc2478oem.c new file +121 -0

121 lines not on this page · raw message

Signature · 1 line
1.7.1
#22 lore raw

PATCH 7/9 lpc2k: Add EmbeddedArtists LPC2478 Developer's Kit board

arch/arm/mach-lpc2k/mach-lpc2478oem.c line 23

Quoted 4 lines
arch/arm/mach-lpc2k/mach-lpc2478oem.c new file +4 -0
+
+#define EXTPOLAR	0x14c
+
+static unsigned long mfp_cfgs[] = {

Should this be initdata?

Review

Quoted 2 lines
(quoted diff) +2 -0
+
+MACHINE_START(LPC2478OEM, "Embedded Artists LPC2478 OEM Board")

Just a nit, but the machine ID should probably be unique to this board and not the 2478, ie EA2478OEM. If someone else releases a LPC2478 based board, it can't use this same id. This would apply to the filename too (lpc2478oem.c) - the name is somewhat generic and might be better named something like plat-ea2478oem.c.

Quoted 12 lines
arch/arm/mach-lpc2k/mach-lpc2478oem.c new file +4 -1
+	.init_irq	= lpc2478oem_init_irq,
+	.timer		= &lpc2k_timer,
+	.init_machine	= lpc2478oem_init_machine,
+MACHINE_END
--

1.7.1

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

#23 lore raw

PATCH 7/9 lpc2k: Add EmbeddedArtists LPC2478 Developer's Kit board

Quoted 6 lines · Kevin Wells

arch/arm/mach-lpc2k/mach-lpc2478oem.c line 23

Quoted 4 lines
arch/arm/mach-lpc2k/mach-lpc2478oem.c new file +4 -0
+
+#define EXTPOLAR	0x14c
+
+static unsigned long mfp_cfgs[] = {

Should this be initdata?

Yes, good catch!

Quoted 7 lines
Quoted 1 line

+MACHINE_START(LPC2478OEM, "Embedded Artists LPC2478 OEM Board")

Just a nit, but the machine ID should probably be unique to this board and not the 2478, ie EA2478OEM. If someone else releases a LPC2478 based board, it can't use this same id. This would apply to the filename too (lpc2478oem.c) - the name is somewhat generic and might be better named something like plat-ea2478oem.c.

True, a more concise name there would be helpful. It is a bit of a mixture since the LPC2478OEM is just the CPU board, and the 'Developer's Kit' includes a baseboard with peripheral devices.

I'll come up with a better name for it, it will just require another board registration and update of arch/arm/tools/mach-types :(

Regards,

Ithamar.

#24 lore raw

PATCH 7/9 lpc2k: Add EmbeddedArtists LPC2478 Developer's Kit board

In reply to Ithamar R. Adema
Quoted 6 lines
arch/arm/mach-lpc2k/mach-lpc2478oem.c new file +3 -0
+static void __init lpc2478oem_init_irq(void)
+{
+	/* XXX workaround for the fact that EINT3 is connected to high-

active

(quoted diff) +1 -0
+	 * signal, but can't be disabled. As the EINT3 interrupt is also

used

arch/arm/mach-lpc2k/mach-lpc2478oem.c line 114

Quoted 8 lines
arch/arm/mach-lpc2k/mach-lpc2478oem.c new file +8 -0
+	 * for GPIO interrupts, this will cause an interrupt storm without
+	 * this setting.
+	 */
+	iowrite32(ioread32(APB_SCB_BASE + EXTPOLAR) | (1 << 3),
+		APB_SCB_BASE + EXTPOLAR);
+
+	lpc2k_init_irq();
+	lpc2k_init_clocks(12000000UL, 32768000UL);

Should the RTC clock be 32768?

Quoted 7 lines
arch/arm/mach-lpc2k/mach-lpc2478oem.c new file +7 -0
+}
+
+MACHINE_START(LPC2478OEM, "Embedded Artists LPC2478 OEM Board")
+	.init_irq	= lpc2478oem_init_irq,
+	.timer		= &lpc2k_timer,
+	.init_machine	= lpc2478oem_init_machine,
+MACHINE_END
#25 lore raw

PATCH 7/9 lpc2k: Add EmbeddedArtists LPC2478 Developer's Kit board

Quoted 3 lines · Kevin Wells
Quoted 1 line

+ lpc2k_init_clocks(12000000UL, 32768000UL);

Should the RTC clock be 32768?

Yes, it should be. Will fix.

Ithamar.

#26 lore raw

PATCH 8/9 lpc2k: Add UART, SSP, and MCI devices

In reply to Ithamar R. Adema

Adds devices for which the drivers are already in the tree. For the relevant devices, let the lpc2478oem board set them up.

---
 arch/arm/Kconfig                            |    1 +
 arch/arm/mach-lpc2k/Makefile                |    2 +-
 arch/arm/mach-lpc2k/common.h                |    4 +
 arch/arm/mach-lpc2k/devices.c               |  174 +++++++++++++++++++++++++++
 arch/arm/mach-lpc2k/include/mach/hardware.h |    6 +
 arch/arm/mach-lpc2k/mach-lpc2478oem.c       |   20 +++
 6 files changed, 206 insertions(+), 1 deletions(-)
 create mode 100644 arch/arm/mach-lpc2k/devices.c
arch/arm/Kconfig +1 -0
index fce855d..1735b02 100644
@@ -496,6 +496,7 @@ config ARCH_LPC2K
 	depends on !MMU
 	select CPU_ARM7TDMI
 	select ARM_VIC
+	select ARM_AMBA
 	select CLKDEV_LOOKUP
 	select GENERIC_TIME
 	select GENERIC_CLOCKEVENTS
arch/arm/mach-lpc2k/Makefile +1 -1
index a969f44..af6a1c2 100644
@@ -1,3 +1,3 @@
 obj-y	:= clock.o irq.o gpio.o mfp.o time.o
 
-obj-$(CONFIG_MACH_LPC2478OEM) += mach-lpc2478oem.o
+obj-$(CONFIG_MACH_LPC2478OEM) += mach-lpc2478oem.o devices.o
arch/arm/mach-lpc2k/common.h +4 -0
index 6b775d9..1d4c21e 100644
@@ -16,6 +16,10 @@ extern void lpc2k_init_clocks(unsigned long xtal, unsigned long rtc);
 extern void lpc2k_mfp_config(unsigned long *mfp_cfgs, int num);
 extern void lpc2k_init_irq(void);
 
+extern void lpc2k_add_uart(int nr);
+extern void lpc2k_add_ssp(int nr, void *platform_data);
+extern void lpc2k_add_mci(void *platform_data, int pwr_high);
+
 extern struct sys_timer lpc2k_timer;
 
 #endif /* LPC2K_COMMON_H */
arch/arm/mach-lpc2k/devices.c new file +174 -0

174 lines not on this page · raw message

arch/arm/mach-lpc2k/include/mach/hardware.h +6 -0
index 29c561a..3054a9e 100644
@@ -19,8 +19,14 @@
 #define APB_TIMER0_BASE		0xe0004000
 #define APB_TIMER1_BASE		0xe0008000
 #define APB_UART0_BASE		0xe000c000
+#define APB_UART1_BASE		0xe0010000
 #define APB_GPIO_BASE		0xe0028000
 #define APB_PINSEL_BASE		0xe002c000
+#define APB_SSP1_BASE		0xe0030000
+#define APB_SSP0_BASE		0xe0068000
+#define APB_UART2_BASE		0xe0078000
+#define APB_UART3_BASE		0xe007c000
+#define APB_MCI_BASE		0xe008c000
 #define APB_SCB_BASE		0xe01fc000
 #define APH_VIC_BASE		0xfffff000
 
arch/arm/mach-lpc2k/mach-lpc2478oem.c +20 -0
index fec98e2..9261574 100644
@@ -8,6 +8,8 @@
  */
 
 #include <linux/module.h>
+#include <linux/amba/pl022.h>
+#include <linux/amba/mmci.h>
 #include <linux/io.h>
 
 #include <asm/mach/arch.h>
@@ -95,9 +97,27 @@ static unsigned long mfp_cfgs[] = {
 	GPIO44_MCIDAT3,
 };
 
+static struct pl022_ssp_controller ssp0_plat_data = {
+	.bus_id = 0,
+	.enable_dma = 0,
+	.num_chipselect = 1,
+};
+
+static struct mmci_platform_data mci_plat_data = {
+	.ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
+	.capabilities = MMC_CAP_4_BIT_DATA,
+	.f_max = 200000,
+	.gpio_cd = -1,
+	.gpio_wp = -1,
+};
+
 void __init lpc2478oem_init_machine(void)
 {
 	lpc2k_mfp_config(mfp_cfgs, ARRAY_SIZE(mfp_cfgs));
+
+	lpc2k_add_uart(0);
+	lpc2k_add_ssp(0, &ssp0_plat_data);
+	lpc2k_add_mci(&mci_plat_data, 0 /* active low */);
 }
 
 static void __init lpc2478oem_init_irq(void)
Signature · 1 line
1.7.1
#27 lore raw

PATCH 9/9 lpc2k: defconfig for NXP LPC2K platform

In reply to Ithamar R. Adema

Add a defconfig that is setup to support booting a uClinux based system. This enables ROMFS/CRAMFS, initrd, and FLAT binaries besides the drivers for the devices added in the previous patch.

---
 arch/arm/configs/lpc2k_defconfig |   56 ++++++++++++++++++++++++++++++++++++++
 1 files changed, 56 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/configs/lpc2k_defconfig
arch/arm/configs/lpc2k_defconfig new file +56 -0
new file mode 100644
index 0000000..6278dd8
@@ -0,0 +1,56 @@
+CONFIG_EXPERIMENTAL=y
+# CONFIG_LOCALVERSION_AUTO is not set
+CONFIG_TINY_RCU=y
+# CONFIG_UTS_NS is not set
+# CONFIG_PID_NS is not set
+CONFIG_BLK_DEV_INITRD=y
+# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
+# CONFIG_COMPAT_BRK is not set
+# CONFIG_LBDAF is not set
+# CONFIG_BLK_DEV_BSG is not set
+# CONFIG_IOSCHED_DEADLINE is not set
+# CONFIG_IOSCHED_CFQ is not set
+# CONFIG_MMU is not set
+CONFIG_ARCH_LPC2K=y
+CONFIG_MACH_LPC2478OEM=y
+CONFIG_PROCESSOR_ID=0x41007700
+CONFIG_NO_HZ=y
+CONFIG_HIGH_RES_TIMERS=y
+CONFIG_PREEMPT=y
+CONFIG_AEABI=y
+CONFIG_CMDLINE="root=/dev/ram initrd=0xa1a00000,4000k console=ttyS0,115200N8 debug rw earlyprintk"
+CONFIG_BINFMT_FLAT=y
+CONFIG_BINFMT_ZFLAT=y
+CONFIG_BINFMT_SHARED_FLAT=y
+# CONFIG_SUSPEND is not set
+# CONFIG_PREVENT_FIRMWARE_BUILD is not set
+# CONFIG_FIRMWARE_IN_KERNEL is not set
+CONFIG_BLK_DEV_LOOP=y
+CONFIG_BLK_DEV_RAM=y
+# CONFIG_INPUT_MOUSEDEV_PSAUX is not set
+# CONFIG_INPUT_KEYBOARD is not set
+# CONFIG_INPUT_MOUSE is not set
+# CONFIG_SERIO is not set
+# CONFIG_LEGACY_PTYS is not set
+# CONFIG_DEVKMEM is not set
+CONFIG_SERIAL_8250=y
+CONFIG_SERIAL_8250_CONSOLE=y
+# CONFIG_HW_RANDOM is not set
+CONFIG_SPI=y
+CONFIG_SPI_PL022=y
+# CONFIG_HWMON is not set
+# CONFIG_MFD_SUPPORT is not set
+# CONFIG_HID_SUPPORT is not set
+# CONFIG_USB_SUPPORT is not set
+CONFIG_MMC=y
+CONFIG_MMC_ARMMMCI=y
+# CONFIG_DNOTIFY is not set
+# CONFIG_INOTIFY_USER is not set
+CONFIG_CRAMFS=y
+CONFIG_ROMFS_FS=y
+CONFIG_DEBUG_KERNEL=y
+# CONFIG_FTRACE is not set
+CONFIG_DEBUG_USER=y
+CONFIG_DEBUG_ERRORS=y
+CONFIG_DEBUG_LL=y
+CONFIG_EARLY_PRINTK=y
Signature · 1 line
1.7.1
#28 lore raw

cover Support for NXP LPC2K SoCs

In reply to Ithamar R. Adema
Quoted 9 lines

Subject: [PATCH 0/9] Support for NXP LPC2K SoCs

The following patch series implements support for the ARM7TDMI-S based NXP LPC2K System-on-Chips, and, as first board, the EmbeddedArtists LPC2478 Developer's Kit.

This code will work on the LPC23XX and LPC24XX ranges of chips, but will need some more work for LPC21XX and LPC22XX chips.

Excellent timing on releasing this patch series! I was 1 day into starting a new release for this! I'll happily check out your patches on our boards here..

#29 lore raw

cover Support for NXP LPC2K SoCs

In reply to Ithamar R. Adema
Quoted 6 lines · Ithamar R. Adema

The following patch series implements support for the ARM7TDMI-S based NXP LPC2K System-on-Chips, and, as first board, the EmbeddedArtists LPC2478 Developer's Kit.

This code will work on the LPC23XX and LPC24XX ranges of chips, but will need some more work for LPC21XX and LPC22XX chips.

Nice to see some more non-MMU SoC parts getting pushed towards mainline!

Regards
Greg

------------------------------------------------------------------------

Greg Ungerer  --  Principal Engineer        EMAIL:     gerg at snapgear.com
SnapGear Group, McAfee                      PHONE:       +61 7 3435 2888
8 Gardner Close                             FAX:         +61 7 3217 5323
Milton, QLD, 4064, Australia                WEB: http://www.SnapGear.com