Skip to contentSkip to conversation

Base support for Freescale i.MX51 SoC platform

PATCH Superseded Amit Kucheria 7 participants 40 messages Feb 3, 2010 – Feb 5, 2010

Subsystems (5)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 cover Base support for Freescale i.MX51 SoC platform

This series of patches adds basic support for i.MX5 family to the kernel. The target device is the i.MX51-based Babbage board (v2.5+) since that is the hardware I have access to.

This is a result of dropping a lot of functionality from the existing Freescale codebase that is shipping as part of the Ubuntu ARM enablement. A lot of the code was refactored to use facilities that were already available upstream in arch/arm/plat-mxc/. The hope is to get this base port into mainline and then start working on mainlining the drivers.

With regards to the splitting of the patches, I felt that the following patchset made it easy to review code. But if this is not acceptable and some of these patches need to be merged into a single patch, I can do that too.

Changelog:

V1: Initial submission of base port
V2: - Split core code enabling i.MX51 and the babbage board
- Refactor timer code to use version 1 or 2 of timer (patch by Sascha)
- Fixes from review of V1

Regards,
Amit

Amit Kucheria (9):
arm: mxc: TrustZone interrupt controller (TZIC) for i.MX5 family
mxc: Fix Drive Strength Field in the IOMUX controller
mxc: changes to common plat-mxc code to add support for i.MX5
mxc: Core support for i.MX5 series of processors from Freescale
mxc: enable support for Freescale i.MX5 series of processors
mxc: Add support for the Babbage board
fec: Add LAN8700 phy support
fec: Add ARCH_MX5 as a dependency
mxc: Add imx51_defconfig

Rob Herring (1):
fec: fix uninitialized rx buffer usage

Sascha Hauer (1):
mxc timer: refactor timer code to use timer versions

 arch/arm/Makefile                            |    1 +
 arch/arm/configs/imx51_defconfig             | 1286 ++++++++++++++++++++++++++
 arch/arm/mach-mx5/Kconfig                    |   17 +
 arch/arm/mach-mx5/Makefile                   |    9 +
 arch/arm/mach-mx5/Makefile.boot              |    3 +
 arch/arm/mach-mx5/board-mx51_babbage.c       |   99 ++
 arch/arm/mach-mx5/clock.c                    |  848 +++++++++++++++++
 arch/arm/mach-mx5/cpu.c                      |   45 +
 arch/arm/mach-mx5/crm_regs.h                 |  583 ++++++++++++
 arch/arm/mach-mx5/devices.c                  |   96 ++
 arch/arm/mach-mx5/devices.h                  |    4 +
 arch/arm/mach-mx5/mm.c                       |   88 ++
 arch/arm/plat-mxc/Kconfig                    |   16 +
 arch/arm/plat-mxc/Makefile                   |    3 +
 arch/arm/plat-mxc/include/mach/common.h      |    6 +
 arch/arm/plat-mxc/include/mach/debug-macro.S |    9 +
 arch/arm/plat-mxc/include/mach/entry-macro.S |   34 +-
 arch/arm/plat-mxc/include/mach/hardware.h    |    4 +
 arch/arm/plat-mxc/include/mach/iomux-mx51.h  |  340 +++++++
 arch/arm/plat-mxc/include/mach/iomux-v3.h    |    8 +-
 arch/arm/plat-mxc/include/mach/irqs.h        |    9 +-
 arch/arm/plat-mxc/include/mach/memory.h      |    3 +
 arch/arm/plat-mxc/include/mach/mx51.h        |  454 +++++++++
 arch/arm/plat-mxc/include/mach/mxc.h         |   13 +
 arch/arm/plat-mxc/include/mach/timex.h       |    2 +
 arch/arm/plat-mxc/time.c                     |   23 +-
 arch/arm/plat-mxc/tzic.c                     |  182 ++++
 drivers/net/Kconfig                          |    3 +-
 drivers/net/fec.c                            |   78 +-
 29 files changed, 4222 insertions(+), 44 deletions(-)
 create mode 100644 arch/arm/configs/imx51_defconfig
 create mode 100644 arch/arm/mach-mx5/Kconfig
 create mode 100644 arch/arm/mach-mx5/Makefile
 create mode 100644 arch/arm/mach-mx5/Makefile.boot
 create mode 100644 arch/arm/mach-mx5/board-mx51_babbage.c
 create mode 100644 arch/arm/mach-mx5/clock.c
 create mode 100644 arch/arm/mach-mx5/cpu.c
 create mode 100644 arch/arm/mach-mx5/crm_regs.h
 create mode 100644 arch/arm/mach-mx5/devices.c
 create mode 100644 arch/arm/mach-mx5/devices.h
 create mode 100644 arch/arm/mach-mx5/mm.c
 create mode 100644 arch/arm/plat-mxc/include/mach/iomux-mx51.h
 create mode 100644 arch/arm/plat-mxc/include/mach/mx51.h
 create mode 100644 arch/arm/plat-mxc/tzic.c
#1 lore raw

PATCH v2 1/11 arm: mxc: TrustZone interrupt controller (TZIC) for i.MX5 family

Freescale i.MX51 processor uses a new interrupt controller. Add driver for TrustZone Interrupt Controller

---
 arch/arm/plat-mxc/Kconfig  |    8 ++
 arch/arm/plat-mxc/Makefile |    3 +
 arch/arm/plat-mxc/tzic.c   |  182 ++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 193 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/plat-mxc/tzic.c
arch/arm/plat-mxc/Kconfig +8 -0
index 8b0a1ee..59558c4 100644
@@ -62,6 +62,14 @@ config MXC_IRQ_PRIOR
 	  requirements for timing.
 	  Say N here, unless you have a specialized requirement.
 
+config MXC_TZIC
+	bool "Enable TrustZone Interrupt Controller"
+	depends on ARCH_MX51
+	help
+	  This will be automatically selected for all processors
+	  containing this interrupt controller.
+	  Say N here only if you are really sure.
+
 config MXC_PWM
 	tristate "Enable PWM driver"
 	depends on ARCH_MXC
arch/arm/plat-mxc/Makefile +3 -0
index 996cbac..0202ad9 100644
@@ -5,6 +5,9 @@
 # Common support
 obj-y := irq.o clock.o gpio.o time.o devices.o cpu.o system.o
 
+# MX51 uses the TZIC interrupt controller, older platforms use AVIC (irq.o)
+obj-$(CONFIG_MXC_TZIC) += tzic.o
+
 obj-$(CONFIG_ARCH_MX1) += iomux-mx1-mx2.o dma-mx1-mx2.o
 obj-$(CONFIG_ARCH_MX2) += iomux-mx1-mx2.o dma-mx1-mx2.o
 obj-$(CONFIG_ARCH_MXC_IOMUX_V3) += iomux-v3.o
arch/arm/plat-mxc/tzic.c new file +182 -0

182 lines not on this page · raw message

Signature · 1 line
1.6.3.3
#2 lore raw

PATCH v2 2/11 mxc timer: refactor timer code to use timer versions

From: Sascha Hauer <[email protected]>

Refactor the timer code into version 1 and version 2.

Essentially there are 2 versions of the timer hardware. Version 1 is found on MX1/MXL and MX21. Version 2 is found on MX25, MX27, MX31, MX35, MX37, MX51, and future parts.

---
 arch/arm/plat-mxc/time.c |   19 +++++++++++--------
 1 files changed, 11 insertions(+), 8 deletions(-)
arch/arm/plat-mxc/time.c +11 -8
index 844567e..7d6499e 100644
@@ -57,6 +57,9 @@
 #define MX3_TCN			0x24
 #define MX3_TCMP		0x10
 
+#define timer_is_v1()	(cpu_is_mx1() || cpu_is_mx27())
+#define timer_is_v2()	(cpu_is_mx3() || cpu_is_mx25())
+
 static struct clock_event_device clockevent_mxc;
 static enum clock_event_mode clockevent_mode = CLOCK_EVT_MODE_UNUSED;
 
@@ -66,7 +69,7 @@ static inline void gpt_irq_disable(void)
 {
 	unsigned int tmp;
 
-	if (cpu_is_mx3() || cpu_is_mx25())
+	if (timer_is_v2())
 		__raw_writel(0, timer_base + MX3_IR);
 	else {
 		tmp = __raw_readl(timer_base + MXC_TCTL);
@@ -76,7 +79,7 @@ static inline void gpt_irq_disable(void)
 
 static inline void gpt_irq_enable(void)
 {
-	if (cpu_is_mx3() || cpu_is_mx25())
+	if (timer_is_v2())
 		__raw_writel(1<<0, timer_base + MX3_IR);
 	else {
 		__raw_writel(__raw_readl(timer_base + MXC_TCTL) | MX1_2_TCTL_IRQEN,
@@ -90,7 +93,7 @@ static void gpt_irq_acknowledge(void)
 		__raw_writel(0, timer_base + MX1_2_TSTAT);
 	if (cpu_is_mx2())
 		__raw_writel(MX2_TSTAT_CAPT | MX2_TSTAT_COMP, timer_base + MX1_2_TSTAT);
-	if (cpu_is_mx3() || cpu_is_mx25())
+	if (timer_is_v2())
 		__raw_writel(MX3_TSTAT_OF1, timer_base + MX3_TSTAT);
 }
 
@@ -117,7 +120,7 @@ static int __init mxc_clocksource_init(struct clk *timer_clk)
 {
 	unsigned int c = clk_get_rate(timer_clk);
 
-	if (cpu_is_mx3() || cpu_is_mx25())
+	if (timer_is_v2())
 		clocksource_mxc.read = mx3_get_cycles;
 
 	clocksource_mxc.mult = clocksource_hz2mult(c,
@@ -180,7 +183,7 @@ static void mxc_set_mode(enum clock_event_mode mode,
 
 	if (mode != clockevent_mode) {
 		/* Set event time into far-far future */
-		if (cpu_is_mx3() || cpu_is_mx25())
+		if (timer_is_v2())
 			__raw_writel(__raw_readl(timer_base + MX3_TCN) - 3,
 					timer_base + MX3_TCMP);
 		else
@@ -233,7 +236,7 @@ static irqreturn_t mxc_timer_interrupt(int irq, void *dev_id)
 	struct clock_event_device *evt = &clockevent_mxc;
 	uint32_t tstat;
 
-	if (cpu_is_mx3() || cpu_is_mx25())
+	if (timer_is_v2())
 		tstat = __raw_readl(timer_base + MX3_TSTAT);
 	else
 		tstat = __raw_readl(timer_base + MX1_2_TSTAT);
@@ -264,7 +267,7 @@ static int __init mxc_clockevent_init(struct clk *timer_clk)
 {
 	unsigned int c = clk_get_rate(timer_clk);
 
-	if (cpu_is_mx3() || cpu_is_mx25())
+	if (timer_is_v2())
 		clockevent_mxc.set_next_event = mx3_set_next_event;
 
 	clockevent_mxc.mult = div_sc(c, NSEC_PER_SEC,
@@ -296,7 +299,7 @@ void __init mxc_timer_init(struct clk *timer_clk, void __iomem *base, int irq)
 	__raw_writel(0, timer_base + MXC_TCTL);
 	__raw_writel(0, timer_base + MXC_TPRER); /* see datasheet note */
 
-	if (cpu_is_mx3() || cpu_is_mx25())
+	if (timer_is_v2())
 		tctl_val = MX3_TCTL_CLK_IPG | MX3_TCTL_FRR | MX3_TCTL_WAITEN | MXC_TCTL_TEN;
 	else
 		tctl_val = MX1_2_TCTL_FRR | MX1_2_TCTL_CLK_PCLK1 | MXC_TCTL_TEN;
Signature · 1 line
1.6.3.3
#3 lore raw

PATCH v2 3/11 mxc: Fix Drive Strength Field in the IOMUX controller

i.MX51 defines 4 values:

00: Low Drive Strength
01: Medium Drive Strength
10: High Drive Strength
11: Max Drive Strength

---
 arch/arm/plat-mxc/include/mach/iomux-v3.h |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)
arch/arm/plat-mxc/include/mach/iomux-v3.h +5 -3
index 1deda01..f2f73d3 100644
@@ -81,11 +81,13 @@ struct pad_desc {
 
 #define PAD_CTL_ODE			(1 << 3)
 
-#define PAD_CTL_DSE_STANDARD		(0 << 1)
-#define PAD_CTL_DSE_HIGH		(1 << 1)
-#define PAD_CTL_DSE_MAX			(2 << 1)
+#define PAD_CTL_DSE_LOW			(0 << 1)
+#define PAD_CTL_DSE_MED			(1 << 1)
+#define PAD_CTL_DSE_HIGH		(2 << 1)
+#define PAD_CTL_DSE_MAX			(3 << 1)
 
 #define PAD_CTL_SRE_FAST		(1 << 0)
+#define PAD_CTL_SRE_SLOW		(0 << 0)
 
 /*
  * setups a single pad in the iomuxer
Signature · 1 line
1.6.3.3
#4 lore raw

PATCH v2 4/11 mxc: changes to common plat-mxc code to add support for i.MX5

Changes separted to help in the review process

---
 arch/arm/plat-mxc/include/mach/common.h      |    4 +++
 arch/arm/plat-mxc/include/mach/debug-macro.S |    9 +++++++
 arch/arm/plat-mxc/include/mach/entry-macro.S |   34 +++++++++++++++++++++++++-
 arch/arm/plat-mxc/include/mach/hardware.h    |    4 +++
 arch/arm/plat-mxc/include/mach/irqs.h        |    9 ++++++-
 arch/arm/plat-mxc/include/mach/memory.h      |    3 ++
 arch/arm/plat-mxc/include/mach/mxc.h         |   13 ++++++++++
 arch/arm/plat-mxc/include/mach/timex.h       |    2 +
 arch/arm/plat-mxc/time.c                     |    6 ++--
 9 files changed, 79 insertions(+), 5 deletions(-)
arch/arm/plat-mxc/include/mach/common.h +4 -0
index 286cb9b..5250a3f 100644
@@ -20,8 +20,10 @@ extern void mx25_map_io(void);
 extern void mx27_map_io(void);
 extern void mx31_map_io(void);
 extern void mx35_map_io(void);
+extern void mx51_map_io(void);
 extern void mxc91231_map_io(void);
 extern void mxc_init_irq(void __iomem *);
+extern void tzic_init_irq(void __iomem *);
 extern void mx1_init_irq(void);
 extern void mx21_init_irq(void);
 extern void mx25_init_irq(void);
@@ -36,6 +38,8 @@ extern int mx25_clocks_init(unsigned long fref);
 extern int mx27_clocks_init(unsigned long fref);
 extern int mx31_clocks_init(unsigned long fref);
 extern int mx35_clocks_init(void);
+extern int mx51_clocks_init(unsigned long ckil, unsigned long osc,
+			unsigned long ckih1, unsigned long ckih2);
 extern int mxc91231_clocks_init(unsigned long fref);
 extern int mxc_register_gpios(void);
 extern int mxc_register_device(struct platform_device *pdev, void *data);
arch/arm/plat-mxc/include/mach/debug-macro.S +9 -0
index 15b2b14..9fe7300 100644
@@ -44,6 +44,15 @@
 #define UART_VADDR	AIPS1_IO_ADDRESS(UART1_BASE_ADDR)
 #endif
 
+#ifdef CONFIG_ARCH_MX5
+#ifdef UART_PADDR
+#error "CONFIG_DEBUG_LL is incompatible with multiple archs"
+#endif
+#include <mach/mx51.h>
+#define UART_PADDR	UART1_BASE_ADDR
+#define UART_VADDR	AIPS1_IO_ADDRESS(UART1_BASE_ADDR)
+#endif
+
 #ifdef CONFIG_ARCH_MXC91231
 #ifdef UART_PADDR
 #error "CONFIG_DEBUG_LL is incompatible with multiple archs"
arch/arm/plat-mxc/include/mach/entry-macro.S +33 -1
index 7cf290e..aeb0869 100644
@@ -1,6 +1,6 @@
 /*
  *  Copyright (C) 2007 Lennert Buytenhek <[email protected]>
- *  Copyright 2004-2007 Freescale Semiconductor, Inc. All Rights Reserved.
+ *  Copyright 2004-2009 Freescale Semiconductor, Inc. All Rights Reserved.
  */
 
 /*
@@ -18,11 +18,16 @@
 	.endm
 
 	.macro  get_irqnr_preamble, base, tmp
+#ifndef CONFIG_MXC_TZIC
 	ldr	\base, =avic_base
 	ldr	\base, [\base]
 #ifdef CONFIG_MXC_IRQ_PRIOR
 	ldr	r4, [\base, #AVIC_NIMASK]
 #endif
+#elif defined CONFIG_MXC_TZIC
+	ldr	\base, =tzic_base
+	ldr	\base, [\base]
+#endif /* CONFIG_MXC_TZIC */
 	.endm
 
 	.macro  arch_ret_to_user, tmp1, tmp2
@@ -32,6 +37,7 @@
 	@ and returns its number in irqnr
 	@ and returns if an interrupt occured in irqstat
 	.macro	get_irqnr_and_base, irqnr, irqstat, base, tmp
+#ifndef CONFIG_MXC_TZIC
 	@ Load offset & priority of the highest priority
 	@ interrupt pending from AVIC_NIVECSR
 	ldr	\irqstat, [\base, #0x40]
@@ -45,6 +51,32 @@
 	strne	\tmp, [\base, #AVIC_NIMASK]
 	streq	r4, [\base, #AVIC_NIMASK]
 #endif
+#elif defined CONFIG_MXC_TZIC
+	@ Load offset & priority of the highest priority
+	@ interrupt pending.
+	@ 0xD80 is HIPND0 register
+	mov     \irqnr, #0
+	mov     \irqstat, #0x0D80
+1000:
+	ldr     \tmp,   [\irqstat, \base]
+	cmp     \tmp, #0
+	bne     1001f
+	addeq   \irqnr, \irqnr, #32
+	addeq   \irqstat, \irqstat, #4
+	cmp     \irqnr, #128
+	blo     1000b
+	b       2001f
+1001:	mov     \irqstat, #1
+1002:	tst     \tmp, \irqstat
+	bne     2002f
+	movs    \tmp, \tmp, lsr #1
+	addne   \irqnr, \irqnr, #1
+	bne     1002b
+2001:
+	mov  \irqnr, #0
+2002:
+	movs \irqnr, \irqnr
+#endif
 	.endm
 
 	@ irq priority table (not used)
arch/arm/plat-mxc/include/mach/hardware.h +4 -0
index 78db754..55ebe88 100644
@@ -22,6 +22,10 @@
 
 #include <asm/sizes.h>
 
+#ifdef CONFIG_ARCH_MX5
+#include <mach/mx51.h>
+#endif
+
 #ifdef CONFIG_ARCH_MX3
 #include <mach/mx3x.h>
 #include <mach/mx31.h>
arch/arm/plat-mxc/include/mach/irqs.h +8 -1
index ead9d59..24c066e 100644
@@ -12,9 +12,13 @@
 #define __ASM_ARCH_MXC_IRQS_H__
 
 /*
- * So far all i.MX SoCs have 64 internal interrupts
+ * SoCs with TZIC interrupt controller have 128 IRQs, those with AVIC have 64
  */
+#ifdef CONFIG_MXC_TZIC
+#define MXC_INTERNAL_IRQS	128
+#else
 #define MXC_INTERNAL_IRQS	64
+#endif
 
 #define MXC_GPIO_IRQ_START	MXC_INTERNAL_IRQS
 
@@ -26,6 +30,8 @@
 #define MXC_GPIO_IRQS		(32 * 3)
 #elif defined CONFIG_ARCH_MX25
 #define MXC_GPIO_IRQS		(32 * 4)
+#elif defined CONFIG_ARCH_MX5
+#define MXC_GPIO_IRQS		(32 * 4)
 #elif defined CONFIG_ARCH_MXC91231
 #define MXC_GPIO_IRQS		(32 * 4)
 #endif
@@ -46,6 +52,7 @@
 #else
 #define MX3_IPU_IRQS 0
 #endif
+/* REVISIT: Add IPU irqs on IMX51 */
 
 #define NR_IRQS			(MXC_IPU_IRQ_START + MX3_IPU_IRQS)
 
arch/arm/plat-mxc/include/mach/memory.h +3 -0
index d3afafd..e46626e 100644
@@ -27,6 +27,9 @@
 #elif defined CONFIG_ARCH_MXC91231
 #define PHYS_OFFSET		UL(0x90000000)
 #endif
+#ifdef CONFIG_ARCH_MX5
+#define PHYS_OFFSET             UL(0x90000000)
+#endif
 
 #if defined(CONFIG_MX1_VIDEO)
 /*
arch/arm/plat-mxc/include/mach/mxc.h +13 -0
index 5199053..555e5f8 100644
@@ -30,6 +30,7 @@
 #define MXC_CPU_MX27		27
 #define MXC_CPU_MX31		31
 #define MXC_CPU_MX35		35
+#define MXC_CPU_MX51		51
 #define MXC_CPU_MXC91231	91231
 
 #ifndef __ASSEMBLY__
@@ -108,6 +109,18 @@ extern unsigned int __mxc_cpu_type;
 # define cpu_is_mx35()		(0)
 #endif
 
+#ifdef CONFIG_ARCH_MX5
+# ifdef mxc_cpu_type
+#  undef mxc_cpu_type
+#  define mxc_cpu_type __mxc_cpu_type
+# else
+#  define mxc_cpu_type MXC_CPU_MX51
+# endif
+# define cpu_is_mx51()		(mxc_cpu_type == MXC_CPU_MX51)
+#else
+# define cpu_is_mx51()		(0)
+#endif
+
 #ifdef CONFIG_ARCH_MXC91231
 # ifdef mxc_cpu_type
 #  undef mxc_cpu_type
arch/arm/plat-mxc/include/mach/timex.h +2 -0
index 527a6c2..024416e 100644
@@ -28,6 +28,8 @@
 #define CLOCK_TICK_RATE		16625000
 #elif defined CONFIG_ARCH_MX25
 #define CLOCK_TICK_RATE		16000000
+#elif defined CONFIG_ARCH_MX5
+#define CLOCK_TICK_RATE		8000000
 #elif defined CONFIG_ARCH_MXC91231
 #define CLOCK_TICK_RATE		13000000
 #endif
arch/arm/plat-mxc/time.c +3 -3
index 7d6499e..2ba8b29 100644
@@ -32,7 +32,7 @@
 
 /* defines common for all i.MX */
 #define MXC_TCTL		0x00
-#define MXC_TCTL_TEN		(1 << 0)
+#define MXC_TCTL_TEN		(1 << 0) /* Enable module */
 #define MXC_TPRER		0x04
 
 /* MX1, MX21, MX27 */
@@ -48,7 +48,7 @@
 #define MX2_TSTAT_COMP		(1 << 0)
 
 /* MX31, MX35, MX25, MXC91231 */
-#define MX3_TCTL_WAITEN		(1 << 3)
+#define MX3_TCTL_WAITEN		(1 << 3) /* Wait enable mode */
 #define MX3_TCTL_CLK_IPG	(1 << 6)
 #define MX3_TCTL_FRR		(1 << 9)
 #define MX3_IR			0x0c
@@ -58,7 +58,7 @@
 #define MX3_TCMP		0x10
 
 #define timer_is_v1()	(cpu_is_mx1() || cpu_is_mx27())
-#define timer_is_v2()	(cpu_is_mx3() || cpu_is_mx25())
+#define timer_is_v2()	(cpu_is_mx3() || cpu_is_mx25() || cpu_is_mx51())
 
 static struct clock_event_device clockevent_mxc;
 static enum clock_event_mode clockevent_mode = CLOCK_EVT_MODE_UNUSED;
Signature · 1 line
1.6.3.3
#5 lore raw

PATCH v2 5/11 mxc: Core support for i.MX5 series of processors from Freescale

From: Amit Kucheria <[email protected]>

Add basic clock support, cpu identification, I/O mapping and serial port.

---
 arch/arm/mach-mx5/clock.c                    |  848 ++++++++++++++++++++++++++
 arch/arm/mach-mx5/cpu.c                      |   45 ++
 arch/arm/mach-mx5/crm_regs.h                 |  583 ++++++++++++++++++
 arch/arm/mach-mx5/devices.c                  |   96 +++
 arch/arm/mach-mx5/devices.h                  |    4 +
 arch/arm/mach-mx5/mm.c                       |   88 +++
 arch/arm/plat-mxc/include/mach/common.h      |    1 +
 arch/arm/plat-mxc/include/mach/debug-macro.S |    4 +-
 arch/arm/plat-mxc/include/mach/iomux-mx51.h  |  340 +++++++++++
 arch/arm/plat-mxc/include/mach/mx51.h        |  454 ++++++++++++++
 10 files changed, 2461 insertions(+), 2 deletions(-)
 create mode 100644 arch/arm/mach-mx5/clock.c
 create mode 100644 arch/arm/mach-mx5/cpu.c
 create mode 100644 arch/arm/mach-mx5/crm_regs.h
 create mode 100644 arch/arm/mach-mx5/devices.c
 create mode 100644 arch/arm/mach-mx5/devices.h
 create mode 100644 arch/arm/mach-mx5/mm.c
 create mode 100644 arch/arm/plat-mxc/include/mach/iomux-mx51.h
 create mode 100644 arch/arm/plat-mxc/include/mach/mx51.h
arch/arm/mach-mx5/clock.c new file +848 -0
new file mode 100644
index 0000000..595f966
@@ -0,0 +1,848 @@
+/*
+ * Copyright 2008-2010 Freescale Semiconductor, Inc. All Rights Reserved.
+ * Copyright (C) 2009-2010 Amit Kucheria <[email protected]>
+ *
+ * The code contained herein is licensed under the GNU General Public
+ * License. You may obtain a copy of the GNU General Public License
+ * Version 2 or later at the following locations:
+ *
+ * http://www.opensource.org/licenses/gpl-license.html
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+
+#include <linux/mm.h>
+#include <linux/delay.h>
+#include <linux/clk.h>
+#include <linux/io.h>
+
+#include <asm/clkdev.h>
+
+#include <mach/hardware.h>
+#include <mach/common.h>
+#include <mach/clock.h>
+
+#include "crm_regs.h"
+
+static void __iomem *pll_base[] = {
+	MX51_DPLL1_BASE,
+	MX51_DPLL2_BASE,
+	MX51_DPLL3_BASE,
+};
+
+/* External clock values passed-in by the board code */
+static unsigned long external_high_reference, external_low_reference;
+static unsigned long oscillator_reference, ckih2_reference;
+
+static struct clk osc_clk;
+static struct clk pll1_main_clk;
+static struct clk pll1_sw_clk;
+static struct clk pll2_sw_clk;
+static struct clk pll3_sw_clk;
+static struct clk lp_apm_clk;
+static struct clk periph_apm_clk;
+static struct clk ahb_clk;
+static struct clk ipg_clk;
+
+#define MAX_DPLL_WAIT_TRIES	1000 /* 1000 * udelay(1) = 1ms */
+
+static int _clk_ccgr_enable(struct clk *clk)
+{
+	u32 reg;
+
+	reg = __raw_readl(clk->enable_reg);
+	reg |= MXC_CCM_CCGRx_MOD_ON << clk->enable_shift;
+	__raw_writel(reg, clk->enable_reg);
+
+	return 0;
+}
+
+static void _clk_ccgr_disable(struct clk *clk)
+{
+	u32 reg;
+	reg = __raw_readl(clk->enable_reg);
+	reg &= ~(MXC_CCM_CCGRx_MOD_OFF << clk->enable_shift);
+	__raw_writel(reg, clk->enable_reg);
+
+}
+
+static void _clk_ccgr_disable_inwait(struct clk *clk)
+{
+	u32 reg;
+
+	reg = __raw_readl(clk->enable_reg);
+	reg &= ~(MXC_CCM_CCGRx_CG_MASK << clk->enable_shift);
+	reg |= MXC_CCM_CCGRx_MOD_IDLE << clk->enable_shift;
+	__raw_writel(reg, clk->enable_reg);
+}
+
+/*
+ * For the 4-to-1 muxed input clock
+ */
+static inline u32 _get_mux(struct clk *parent, struct clk *m0,
+			   struct clk *m1, struct clk *m2, struct clk *m3)
+{
+	if (parent == m0)
+		return 0;
+	else if (parent == m1)
+		return 1;
+	else if (parent == m2)
+		return 2;
+	else if (parent == m3)
+		return 3;
+	else
+		BUG();
+
+	return -EINVAL;
+}
+
+static inline void __iomem *_get_pll_base(struct clk *pll)
+{
+	if (pll == &pll1_main_clk)
+		return pll_base[0];
+	else if (pll == &pll2_sw_clk)
+		return pll_base[1];
+	else if (pll == &pll3_sw_clk)
+		return pll_base[2];
+	else
+		BUG();
+
+	return NULL;
+}
+
+static unsigned long clk_pll_get_rate(struct clk *clk)
+{
+	long mfi, mfn, mfd, pdf, ref_clk, mfn_abs;
+	unsigned long dp_op, dp_mfd, dp_mfn, dp_ctl, pll_hfsm, dbl;
+	void __iomem *pllbase;
+	s64 temp;
+	unsigned long parent_rate;
+
+	parent_rate = clk_get_rate(clk->parent);
+
+	pllbase = _get_pll_base(clk);
+
+	dp_ctl = __raw_readl(pllbase + MXC_PLL_DP_CTL);
+	pll_hfsm = dp_ctl & MXC_PLL_DP_CTL_HFSM;
+	dbl = dp_ctl & MXC_PLL_DP_CTL_DPDCK0_2_EN;
+
+	if (pll_hfsm == 0) {
+		dp_op = __raw_readl(pllbase + MXC_PLL_DP_OP);
+		dp_mfd = __raw_readl(pllbase + MXC_PLL_DP_MFD);
+		dp_mfn = __raw_readl(pllbase + MXC_PLL_DP_MFN);
+	} else {
+		dp_op = __raw_readl(pllbase + MXC_PLL_DP_HFS_OP);
+		dp_mfd = __raw_readl(pllbase + MXC_PLL_DP_HFS_MFD);
+		dp_mfn = __raw_readl(pllbase + MXC_PLL_DP_HFS_MFN);
+	}
+	pdf = dp_op & MXC_PLL_DP_OP_PDF_MASK;
+	mfi = (dp_op & MXC_PLL_DP_OP_MFI_MASK) >> MXC_PLL_DP_OP_MFI_OFFSET;
+	mfi = (mfi <= 5) ? 5 : mfi;
+	mfd = dp_mfd & MXC_PLL_DP_MFD_MASK;
+	mfn = mfn_abs = dp_mfn & MXC_PLL_DP_MFN_MASK;
+	/* Sign extend to 32-bits */
+	if (mfn >= 0x04000000) {
+		mfn |= 0xFC000000;
+		mfn_abs = -mfn;
+	}
+
+	ref_clk = 2 * parent_rate;
+	if (dbl != 0)
+		ref_clk *= 2;
+
+	ref_clk /= (pdf + 1);
+	temp = (u64) ref_clk * mfn_abs;
+	do_div(temp, mfd + 1);
+	if (mfn < 0)
+		temp = -temp;
+	temp = (ref_clk * mfi) + temp;
+
+	return temp;
+}
+
+static int _clk_pll_set_rate(struct clk *clk, unsigned long rate)
+{
+	u32 reg;
+	void __iomem *pllbase;
+
+	long mfi, pdf, mfn, mfd = 999999;
+	s64 temp64;
+	unsigned long quad_parent_rate;
+	unsigned long pll_hfsm, dp_ctl;
+	unsigned long parent_rate;
+
+	parent_rate = clk_get_rate(clk->parent);
+
+	pllbase = _get_pll_base(clk);
+
+	quad_parent_rate = 4 * parent_rate;
+	pdf = mfi = -1;
+	while (++pdf < 16 && mfi < 5)
+		mfi = rate * (pdf+1) / quad_parent_rate;
+	if (mfi > 15)
+		return -1;
+	pdf--;
+
+	temp64 = rate * (pdf+1) - quad_parent_rate * mfi;
+	do_div(temp64, quad_parent_rate/1000000);
+	mfn = (long)temp64;
+
+	dp_ctl = __raw_readl(pllbase + MXC_PLL_DP_CTL);
+	/* use dpdck0_2 */
+	__raw_writel(dp_ctl | 0x1000L, pllbase + MXC_PLL_DP_CTL);
+	pll_hfsm = dp_ctl & MXC_PLL_DP_CTL_HFSM;
+	if (pll_hfsm == 0) {
+		reg = mfi << 4 | pdf;
+		__raw_writel(reg, pllbase + MXC_PLL_DP_OP);
+		__raw_writel(mfd, pllbase + MXC_PLL_DP_MFD);
+		__raw_writel(mfn, pllbase + MXC_PLL_DP_MFN);
+	} else {
+		reg = mfi << 4 | pdf;
+		__raw_writel(reg, pllbase + MXC_PLL_DP_HFS_OP);
+		__raw_writel(mfd, pllbase + MXC_PLL_DP_HFS_MFD);
+		__raw_writel(mfn, pllbase + MXC_PLL_DP_HFS_MFN);
+	}
+
+	return 0;
+}
+
+static int _clk_pll_enable(struct clk *clk)
+{
+	u32 reg;
+	void __iomem *pllbase;
+	int i = 0;
+
+	pllbase = _get_pll_base(clk);
+	reg = __raw_readl(pllbase + MXC_PLL_DP_CTL) | MXC_PLL_DP_CTL_UPEN;
+	__raw_writel(reg, pllbase + MXC_PLL_DP_CTL);
+
+	/* Wait for lock */
+	while ((!(__raw_readl(pllbase + MXC_PLL_DP_CTL) & MXC_PLL_DP_CTL_LRF))
+		&& i < MAX_DPLL_WAIT_TRIES) {
+		i++;
+		udelay(1);
+	}
+
+	if (i == MAX_DPLL_WAIT_TRIES) {
+		printk(KERN_ERR "MX5: pll locking failed\n");
+		return -EINVAL;
+	}
+
+	return 0;
+}
+
+static void _clk_pll_disable(struct clk *clk)
+{
+	u32 reg;
+	void __iomem *pllbase;
+
+	pllbase = _get_pll_base(clk);
+	reg = __raw_readl(pllbase + MXC_PLL_DP_CTL) & ~MXC_PLL_DP_CTL_UPEN;
+	__raw_writel(reg, pllbase + MXC_PLL_DP_CTL);
+}
+
+static int _clk_pll1_sw_set_parent(struct clk *clk, struct clk *parent)
+{
+	u32 reg;
+
+	reg = __raw_readl(MXC_CCM_CCSR);
+
+	/* When switching from pll_main_clk to a bypass clock, first select a
+	   multiplexed clock in 'step_sel', then shift the glitchless mux
+	   'pll1_sw_clk_sel'.
+	   When switching back, do it in reverse order
+	*/
+	if (parent == &pll1_main_clk) {
+		/* Switch to pll1_main_clk */
+		reg &= ~MXC_CCM_CCSR_PLL1_SW_CLK_SEL;
+		__raw_writel(reg, MXC_CCM_CCSR);
+		/* step_clk mux switched to lp_apm, to save power. */
+		reg = __raw_readl(MXC_CCM_CCSR);
+		reg = (reg & ~MXC_CCM_CCSR_STEP_SEL_MASK) |
+			(MXC_CCM_CCSR_STEP_SEL_LP_APM <<
+				MXC_CCM_CCSR_STEP_SEL_OFFSET);
+	} else {
+		if (parent == &lp_apm_clk) {
+			reg = (reg & ~MXC_CCM_CCSR_STEP_SEL_MASK) |
+				(MXC_CCM_CCSR_STEP_SEL_LP_APM <<
+					MXC_CCM_CCSR_STEP_SEL_OFFSET);
+		} else  if (parent == &pll2_sw_clk) {
+			reg = (reg & ~MXC_CCM_CCSR_STEP_SEL_MASK) |
+				(MXC_CCM_CCSR_STEP_SEL_PLL2_DIVIDED <<
+					MXC_CCM_CCSR_STEP_SEL_OFFSET);
+		} else  if (parent == &pll3_sw_clk) {
+			reg = (reg & ~MXC_CCM_CCSR_STEP_SEL_MASK) |
+				(MXC_CCM_CCSR_STEP_SEL_PLL3_DIVIDED <<
+					MXC_CCM_CCSR_STEP_SEL_OFFSET);
+		} else
+			return -EINVAL;
+
+		__raw_writel(reg, MXC_CCM_CCSR);
+		/* Switch to step_clk */
+		reg = __raw_readl(MXC_CCM_CCSR);
+		reg |= MXC_CCM_CCSR_PLL1_SW_CLK_SEL;
+	}
+	__raw_writel(reg, MXC_CCM_CCSR);
+	return 0;
+}
+
+static unsigned long clk_pll1_sw_get_rate(struct clk *clk)
+{
+	u32 reg, div;
+	unsigned long parent_rate;
+
+	parent_rate = clk_get_rate(clk->parent);
+
+	div = 1;
+	reg = __raw_readl(MXC_CCM_CCSR);
+
+	if (clk->parent == &pll2_sw_clk) {
+		div = ((reg & MXC_CCM_CCSR_PLL2_PODF_MASK) >>
+		       MXC_CCM_CCSR_PLL2_PODF_OFFSET) + 1;
+	} else if (clk->parent == &pll3_sw_clk) {
+		div = ((reg & MXC_CCM_CCSR_PLL3_PODF_MASK) >>
+		       MXC_CCM_CCSR_PLL3_PODF_OFFSET) + 1;
+	}
+	return parent_rate / div;
+}
+
+static int _clk_pll2_sw_set_parent(struct clk *clk, struct clk *parent)
+{
+	u32 reg;
+
+	reg = __raw_readl(MXC_CCM_CCSR);
+
+	if (parent == &pll2_sw_clk)
+		reg &= ~MXC_CCM_CCSR_PLL2_SW_CLK_SEL;
+	else
+		reg |= MXC_CCM_CCSR_PLL2_SW_CLK_SEL;
+
+	__raw_writel(reg, MXC_CCM_CCSR);
+	return 0;
+}
+
+static int _clk_lp_apm_set_parent(struct clk *clk, struct clk *parent)
+{
+	u32 reg;
+
+	if (parent == &osc_clk)
+		reg = __raw_readl(MXC_CCM_CCSR) & ~MXC_CCM_CCSR_LP_APM_SEL;
+	else
+		return -EINVAL;
+
+	__raw_writel(reg, MXC_CCM_CCSR);
+
+	return 0;
+}
+
+static unsigned long clk_arm_get_rate(struct clk *clk)
+{
+	u32 cacrr, div;
+	unsigned long parent_rate;
+
+	parent_rate = clk_get_rate(clk->parent);
+	cacrr = __raw_readl(MXC_CCM_CACRR);
+	div = (cacrr & MXC_CCM_CACRR_ARM_PODF_MASK) + 1;
+
+	return parent_rate / div;
+}
+
+static int _clk_periph_apm_set_parent(struct clk *clk, struct clk *parent)
+{
+	u32 reg, mux;
+	int i = 0;
+
+	mux = _get_mux(parent, &pll1_sw_clk, &pll3_sw_clk, &lp_apm_clk, NULL);
+
+	reg = __raw_readl(MXC_CCM_CBCMR) & ~MXC_CCM_CBCMR_PERIPH_CLK_SEL_MASK;
+	reg |= mux << MXC_CCM_CBCMR_PERIPH_CLK_SEL_OFFSET;
+	__raw_writel(reg, MXC_CCM_CBCMR);
+
+	/* Wait for lock */
+	while ((__raw_readl(MXC_CCM_CDHIPR) & MXC_CCM_CDHIPR_PERIPH_CLK_SEL_BUSY)
+		&& i < MAX_DPLL_WAIT_TRIES) {
+		i++;
+		udelay(1);
+	}
+
+	if (i == MAX_DPLL_WAIT_TRIES) {
+		printk(KERN_ERR "MX5: Set parent for periph_apm clock failed\n");
+		return -EINVAL;
+	}
+
+	return 0;
+}
+
+static unsigned long clk_main_bus_get_rate(struct clk *clk)
+{
+	return clk_get_rate(clk->parent);
+}
+
+static int _clk_main_bus_set_parent(struct clk *clk, struct clk *parent)
+{
+	u32 reg;
+
+	reg = __raw_readl(MXC_CCM_CBCDR);
+
+	if (parent == &pll2_sw_clk)
+		reg &= ~MXC_CCM_CBCDR_PERIPH_CLK_SEL;
+	else if (parent == &periph_apm_clk)
+		reg |= MXC_CCM_CBCDR_PERIPH_CLK_SEL;
+	else
+		return -EINVAL;
+
+	__raw_writel(reg, MXC_CCM_CBCDR);
+
+	return 0;
+}
+
+static struct clk main_bus_clk = {
+	.parent = &pll2_sw_clk,
+	.set_parent = _clk_main_bus_set_parent,
+	.get_rate = clk_main_bus_get_rate,
+};
+
+static unsigned long clk_ahb_get_rate(struct clk *clk)
+{
+	u32 reg, div;
+	unsigned long parent_rate;
+
+	parent_rate = clk_get_rate(clk->parent);
+
+	reg = __raw_readl(MXC_CCM_CBCDR);
+	div = ((reg & MXC_CCM_CBCDR_AHB_PODF_MASK) >>
+	       MXC_CCM_CBCDR_AHB_PODF_OFFSET) + 1;
+	return parent_rate / div;
+}
+
+
+static int _clk_ahb_set_rate(struct clk *clk, unsigned long rate)
+{
+	u32 reg, div;
+	unsigned long parent_rate;
+	int i = 0;
+
+	parent_rate = clk_get_rate(clk->parent);
+
+	div = parent_rate / rate;
+	if (div > 8 || div < 1 || ((parent_rate / div) != rate))
+		return -EINVAL;
+
+	reg = __raw_readl(MXC_CCM_CBCDR);
+	reg &= ~MXC_CCM_CBCDR_AHB_PODF_MASK;
+	reg |= (div - 1) << MXC_CCM_CBCDR_AHB_PODF_OFFSET;
+	__raw_writel(reg, MXC_CCM_CBCDR);
+
+	/* Wait for lock */
+	while ((__raw_readl(MXC_CCM_CDHIPR) & MXC_CCM_CDHIPR_AHB_PODF_BUSY)
+		&& i < MAX_DPLL_WAIT_TRIES) {
+		i++;
+		udelay(1);
+	}
+
+	if (i == MAX_DPLL_WAIT_TRIES) {
+		printk(KERN_ERR "MX5: clk_ahb_set_rate failed\n");
+		return -EINVAL;
+	}
+
+	return 0;
+}
+
+static unsigned long _clk_ahb_round_rate(struct clk *clk,
+						unsigned long rate)
+{
+	u32 div;
+	unsigned long parent_rate;
+
+	parent_rate = clk_get_rate(clk->parent);
+
+	div = parent_rate / rate;
+	if (div > 8)
+		div = 8;
+	else if (div == 0)
+		div++;
+	return parent_rate / div;
+}
+
+
+static int _clk_max_enable(struct clk *clk)
+{
+	u32 reg;
+
+	_clk_ccgr_enable(clk);
+
+	/* Handshake with MAX when LPM is entered. */
+	reg = __raw_readl(MXC_CCM_CLPCR);
+	reg &= ~MXC_CCM_CLPCR_BYPASS_MAX_LPM_HS;
+	__raw_writel(reg, MXC_CCM_CLPCR);
+
+	return 0;
+}
+
+static void _clk_max_disable(struct clk *clk)
+{
+	u32 reg;
+
+	_clk_ccgr_disable_inwait(clk);
+
+	/* No Handshake with MAX when LPM is entered as its disabled. */
+	reg = __raw_readl(MXC_CCM_CLPCR);
+	reg |= MXC_CCM_CLPCR_BYPASS_MAX_LPM_HS;
+	__raw_writel(reg, MXC_CCM_CLPCR);
+}
+
+static unsigned long clk_ipg_get_rate(struct clk *clk)
+{
+	u32 reg, div;
+	unsigned long parent_rate;
+
+	parent_rate = clk_get_rate(clk->parent);
+
+	reg = __raw_readl(MXC_CCM_CBCDR);
+	div = ((reg & MXC_CCM_CBCDR_IPG_PODF_MASK) >>
+	       MXC_CCM_CBCDR_IPG_PODF_OFFSET) + 1;
+
+	return parent_rate / div;
+}
+
+static unsigned long clk_ipg_per_get_rate(struct clk *clk)
+{
+	u32 reg, prediv1, prediv2, podf;
+	unsigned long parent_rate;
+
+	parent_rate = clk_get_rate(clk->parent);
+
+	if (clk->parent == &main_bus_clk || clk->parent == &lp_apm_clk) {
+		/* the main_bus_clk is the one before the DVFS engine */
+		reg = __raw_readl(MXC_CCM_CBCDR);
+		prediv1 = ((reg & MXC_CCM_CBCDR_PERCLK_PRED1_MASK) >>
+			   MXC_CCM_CBCDR_PERCLK_PRED1_OFFSET) + 1;
+		prediv2 = ((reg & MXC_CCM_CBCDR_PERCLK_PRED2_MASK) >>
+			   MXC_CCM_CBCDR_PERCLK_PRED2_OFFSET) + 1;
+		podf = ((reg & MXC_CCM_CBCDR_PERCLK_PODF_MASK) >>
+			MXC_CCM_CBCDR_PERCLK_PODF_OFFSET) + 1;
+		return parent_rate / (prediv1 * prediv2 * podf);
+	} else if (clk->parent == &ipg_clk) {
+		return parent_rate;
+	} else {
+		BUG();
+	}
+}
+
+static int _clk_ipg_per_set_parent(struct clk *clk, struct clk *parent)
+{
+	u32 reg;
+
+	reg = __raw_readl(MXC_CCM_CBCMR);
+
+	reg &= ~MXC_CCM_CBCMR_PERCLK_LP_APM_CLK_SEL;
+	reg &= ~MXC_CCM_CBCMR_PERCLK_IPG_CLK_SEL;
+
+	if (parent == &ipg_clk)
+		reg |= MXC_CCM_CBCMR_PERCLK_IPG_CLK_SEL;
+	else if (parent == &lp_apm_clk)
+		reg |= MXC_CCM_CBCMR_PERCLK_LP_APM_CLK_SEL;
+	else if (parent != &main_bus_clk)
+		return -EINVAL;
+
+	__raw_writel(reg, MXC_CCM_CBCMR);
+
+	return 0;
+}
+
+static unsigned long clk_uart_get_rate(struct clk *clk)
+{
+	u32 reg, prediv, podf;
+	unsigned long parent_rate;
+
+	parent_rate = clk_get_rate(clk->parent);
+
+	reg = __raw_readl(MXC_CCM_CSCDR1);
+	prediv = ((reg & MXC_CCM_CSCDR1_UART_CLK_PRED_MASK) >>
+		  MXC_CCM_CSCDR1_UART_CLK_PRED_OFFSET) + 1;
+	podf = ((reg & MXC_CCM_CSCDR1_UART_CLK_PODF_MASK) >>
+		MXC_CCM_CSCDR1_UART_CLK_PODF_OFFSET) + 1;
+
+	return parent_rate / (prediv * podf);
+}
+
+static int _clk_uart_set_parent(struct clk *clk, struct clk *parent)
+{
+	u32 reg, mux;
+
+	mux = _get_mux(parent, &pll1_sw_clk, &pll2_sw_clk, &pll3_sw_clk,
+		       &lp_apm_clk);
+	reg = __raw_readl(MXC_CCM_CSCMR1) & ~MXC_CCM_CSCMR1_UART_CLK_SEL_MASK;
+	reg |= mux << MXC_CCM_CSCMR1_UART_CLK_SEL_OFFSET;
+	__raw_writel(reg, MXC_CCM_CSCMR1);
+
+	return 0;
+}
+
+static unsigned long get_high_reference_clock_rate(struct clk *clk)
+{
+	return external_high_reference;
+}
+
+static unsigned long get_low_reference_clock_rate(struct clk *clk)
+{
+	return external_low_reference;
+}
+
+static unsigned long get_oscillator_reference_clock_rate(struct clk *clk)
+{
+	return oscillator_reference;
+}
+
+static unsigned long get_ckih2_reference_clock_rate(struct clk *clk)
+{
+	return ckih2_reference;
+}
+
+/* External high frequency clock */
+static struct clk ckih_clk = {
+	.get_rate = get_high_reference_clock_rate,
+};
+
+static struct clk ckih2_clk = {
+	.get_rate = get_ckih2_reference_clock_rate,
+};
+
+static struct clk osc_clk = {
+	.get_rate = get_oscillator_reference_clock_rate,
+};
+
+/* External low frequency (32kHz) clock */
+static struct clk ckil_clk = {
+	.get_rate = get_low_reference_clock_rate,
+};
+
+static struct clk pll1_main_clk = {
+	.parent = &osc_clk,
+	.get_rate = clk_pll_get_rate,
+	.enable = _clk_pll_enable,
+	.disable = _clk_pll_disable,
+};
+
+/* Clock tree block diagram (WIP):
+ * 	CCM: Clock Controller Module
+ *
+ * PLL output -> |
+ *               | CCM Switcher -> CCM_CLK_ROOT_GEN ->
+ * PLL bypass -> |
+ *
+ */
+
+/* PLL1 SW supplies to ARM core */
+static struct clk pll1_sw_clk = {
+	.parent = &pll1_main_clk,
+	.set_parent = _clk_pll1_sw_set_parent,
+	.get_rate = clk_pll1_sw_get_rate,
+};
+
+/* PLL2 SW supplies to AXI/AHB/IP buses */
+static struct clk pll2_sw_clk = {
+	.parent = &osc_clk,
+	.get_rate = clk_pll_get_rate,
+	.set_rate = _clk_pll_set_rate,
+	.set_parent = _clk_pll2_sw_set_parent,
+	.enable = _clk_pll_enable,
+	.disable = _clk_pll_disable,
+};
+
+/* PLL3 SW supplies to serial clocks like USB, SSI, etc. */
+static struct clk pll3_sw_clk = {
+	.parent = &osc_clk,
+	.set_rate = _clk_pll_set_rate,
+	.get_rate = clk_pll_get_rate,
+	.enable = _clk_pll_enable,
+	.disable = _clk_pll_disable,
+};
+
+/* Low-power Audio Playback Mode clock */
+static struct clk lp_apm_clk = {
+	.parent = &osc_clk,
+	.set_parent = _clk_lp_apm_set_parent,
+};
+
+static struct clk periph_apm_clk = {
+	.parent = &pll1_sw_clk,
+	.set_parent = _clk_periph_apm_set_parent,
+};
+
+static struct clk cpu_clk = {
+	.parent = &pll1_sw_clk,
+	.get_rate = clk_arm_get_rate,
+};
+
+static struct clk ahb_clk = {
+	.parent = &main_bus_clk,
+	.get_rate = clk_ahb_get_rate,
+	.set_rate = _clk_ahb_set_rate,
+	.round_rate = _clk_ahb_round_rate,
+};
+
+/* Main IP interface clock for access to registers */
+static struct clk ipg_clk = {
+	.parent = &ahb_clk,
+	.get_rate = clk_ipg_get_rate,
+};
+
+static struct clk ipg_perclk = {
+	.parent = &lp_apm_clk,
+	.get_rate = clk_ipg_per_get_rate,
+	.set_parent = _clk_ipg_per_set_parent,
+};
+
+static struct clk uart_root_clk = {
+	.parent = &pll2_sw_clk,
+	.get_rate = clk_uart_get_rate,
+	.set_parent = _clk_uart_set_parent,
+};
+
+static struct clk ahb_max_clk = {
+	.parent = &ahb_clk,
+	.enable_reg = MXC_CCM_CCGR0,
+	.enable_shift = MXC_CCM_CCGRx_CG14_OFFSET,
+	.enable = _clk_max_enable,
+	.disable = _clk_max_disable,
+};
+
+static struct clk aips_tz1_clk = {
+	.parent = &ahb_clk,
+	.secondary = &ahb_max_clk,
+	.enable_reg = MXC_CCM_CCGR0,
+	.enable_shift = MXC_CCM_CCGRx_CG12_OFFSET,
+	.enable = _clk_ccgr_enable,
+	.disable = _clk_ccgr_disable_inwait,
+};
+
+static struct clk aips_tz2_clk = {
+	.parent = &ahb_clk,
+	.secondary = &ahb_max_clk,
+	.enable_reg = MXC_CCM_CCGR0,
+	.enable_shift = MXC_CCM_CCGRx_CG13_OFFSET,
+	.enable = _clk_ccgr_enable,
+	.disable = _clk_ccgr_disable_inwait,
+};
+
+static struct clk gpt_32k_clk = {
+	.id = 0,
+	.parent = &ckil_clk,
+};
+
+#define DEFINE_CLOCK(name, i, er, es, gr, sr, p, s)	\
+	static struct clk name = {			\
+		.id		= i,			\
+		.enable_reg	= er,			\
+		.enable_shift	= es,			\
+		.get_rate	= gr,			\
+		.set_rate	= sr,			\
+		.enable		= _clk_ccgr_enable,	\
+		.disable	= _clk_ccgr_disable,	\
+		.parent		= p,			\
+		.secondary	= s,			\
+	}
+
+/* DEFINE_CLOCK(name, id, enable_reg, enable_shift,
+   get_rate, set_rate, parent, secondary); */
+
+/* Shared peripheral bus arbiter */
+DEFINE_CLOCK(spba_clk, 0, MXC_CCM_CCGR5, MXC_CCM_CCGRx_CG0_OFFSET,
+	NULL,  NULL, &ipg_clk, NULL);
+
+/* UART */
+DEFINE_CLOCK(uart1_clk, 0, MXC_CCM_CCGR1, MXC_CCM_CCGRx_CG4_OFFSET,
+	NULL,  NULL, &uart_root_clk, NULL);
+DEFINE_CLOCK(uart2_clk, 1, MXC_CCM_CCGR1, MXC_CCM_CCGRx_CG6_OFFSET,
+	NULL,  NULL, &uart_root_clk, NULL);
+DEFINE_CLOCK(uart3_clk, 2, MXC_CCM_CCGR1, MXC_CCM_CCGRx_CG8_OFFSET,
+	NULL,  NULL, &uart_root_clk, NULL);
+DEFINE_CLOCK(uart1_ipg_clk, 0, MXC_CCM_CCGR1, MXC_CCM_CCGRx_CG3_OFFSET,
+	NULL,  NULL, &ipg_clk, &aips_tz1_clk);
+DEFINE_CLOCK(uart2_ipg_clk, 1, MXC_CCM_CCGR1, MXC_CCM_CCGRx_CG5_OFFSET,
+	NULL,  NULL, &ipg_clk, &aips_tz1_clk);
+DEFINE_CLOCK(uart3_ipg_clk, 2, MXC_CCM_CCGR1, MXC_CCM_CCGRx_CG7_OFFSET,
+	NULL,  NULL, &ipg_clk, &spba_clk);
+
+/* GPT */
+DEFINE_CLOCK(gpt_clk, 0, MXC_CCM_CCGR2, MXC_CCM_CCGRx_CG9_OFFSET,
+	NULL,  NULL, &ipg_perclk, NULL);
+DEFINE_CLOCK(gpt_ipg_clk, 0, MXC_CCM_CCGR2, MXC_CCM_CCGRx_CG10_OFFSET,
+	NULL,  NULL, &ipg_clk, NULL);
+
+/* FEC */
+DEFINE_CLOCK(fec_clk, 0, MXC_CCM_CCGR2, MXC_CCM_CCGRx_CG12_OFFSET,
+	NULL,  NULL, &ipg_clk, NULL);
+
+#define _REGISTER_CLOCK(d, n, c) \
+       { \
+		.dev_id = d, \
+		.con_id = n, \
+		.clk = &c,   \
+       },
+
+static struct clk_lookup lookups[] __initdata = {
+	_REGISTER_CLOCK("imx-uart.0", NULL, uart1_clk)
+	_REGISTER_CLOCK("imx-uart.1", NULL, uart2_clk)
+	_REGISTER_CLOCK("imx-uart.2", NULL, uart3_clk)
+	_REGISTER_CLOCK(NULL, "gpt", gpt_clk)
+	_REGISTER_CLOCK("fec.0", NULL, fec_clk)
+};
+
+static void clk_tree_init(void)
+{
+	u32 reg;
+
+	ipg_perclk.set_parent(&ipg_perclk, &lp_apm_clk);
+
+	/*
+	 * Initialise the IPG PER CLK dividers to 3. IPG_PER_CLK should be at
+	 * 8MHz, its derived from lp_apm.
+	 * FIXME: Verify if true for all boards
+	 */
+	reg = __raw_readl(MXC_CCM_CBCDR);
+	reg &= ~MXC_CCM_CBCDR_PERCLK_PRED1_MASK;
+	reg &= ~MXC_CCM_CBCDR_PERCLK_PRED2_MASK;
+	reg &= ~MXC_CCM_CBCDR_PERCLK_PODF_MASK;
+	reg |= (2 << MXC_CCM_CBCDR_PERCLK_PRED1_OFFSET);
+	__raw_writel(reg, MXC_CCM_CBCDR);
+
+	/* set parent for pll1, pll2 and pll3 */
+	pll1_main_clk.parent = &osc_clk;
+	pll2_sw_clk.parent = &osc_clk;
+	pll3_sw_clk.parent = &osc_clk;
+
+	/* set ipg_perclk parent */
+	ipg_perclk.parent = &lp_apm_clk;
+	reg = __raw_readl(MXC_CCM_CBCMR);
+	if ((reg & MXC_CCM_CBCMR_PERCLK_IPG_CLK_SEL) != 0) {
+		ipg_perclk.parent = &ipg_clk;
+	} else {
+		if ((reg & MXC_CCM_CBCMR_PERCLK_LP_APM_CLK_SEL) == 0)
+			ipg_perclk.parent = &main_bus_clk;
+	}
+}
+
+int __init mx51_clocks_init(unsigned long ckil, unsigned long osc,
+			unsigned long ckih1, unsigned long ckih2)
+{
+	int i;
+
+	external_low_reference = ckil;
+	external_high_reference = ckih1;
+	ckih2_reference = ckih2;
+	oscillator_reference = osc;
+
+	for (i = 0; i < ARRAY_SIZE(lookups); i++)
+		clkdev_add(&lookups[i]);
+
+	clk_tree_init();
+
+	clk_enable(&cpu_clk);
+	clk_enable(&main_bus_clk);
+
+	/* System timer */
+	mxc_timer_init(&gpt_clk, MX51_IO_ADDRESS(MX51_GPT1_BASE_ADDR),
+		MX51_MXC_INT_GPT);
+	return 0;
+}
arch/arm/mach-mx5/cpu.c new file +45 -0

45 lines not on this page · raw message

arch/arm/mach-mx5/crm_regs.h new file +583 -0

583 lines not on this page · raw message

arch/arm/mach-mx5/devices.c new file +96 -0

96 lines not on this page · raw message

arch/arm/mach-mx5/devices.h new file +4 -0
new file mode 100644
index 0000000..f339ab8
@@ -0,0 +1,4 @@
+extern struct platform_device mxc_uart_device0;
+extern struct platform_device mxc_uart_device1;
+extern struct platform_device mxc_uart_device2;
+extern struct platform_device mxc_fec_device;
arch/arm/mach-mx5/mm.c new file +88 -0

88 lines not on this page · raw message

arch/arm/plat-mxc/include/mach/common.h +1 -0
index 5250a3f..0a25576 100644
@@ -30,6 +30,7 @@ extern void mx25_init_irq(void);
 extern void mx27_init_irq(void);
 extern void mx31_init_irq(void);
 extern void mx35_init_irq(void);
+extern void mx51_init_irq(void);
 extern void mxc91231_init_irq(void);
 extern void mxc_timer_init(struct clk *timer_clk, void __iomem *, int);
 extern int mx1_clocks_init(unsigned long fref);
arch/arm/plat-mxc/include/mach/debug-macro.S +2 -2
index 9fe7300..9d41bfd 100644
@@ -49,8 +49,8 @@
 #error "CONFIG_DEBUG_LL is incompatible with multiple archs"
 #endif
 #include <mach/mx51.h>
-#define UART_PADDR	UART1_BASE_ADDR
-#define UART_VADDR	AIPS1_IO_ADDRESS(UART1_BASE_ADDR)
+#define UART_PADDR	MX51_UART1_BASE_ADDR
+#define UART_VADDR	MX51_AIPS1_IO_ADDRESS(MX51_UART1_BASE_ADDR)
 #endif
 
 #ifdef CONFIG_ARCH_MXC91231
arch/arm/plat-mxc/include/mach/iomux-mx51.h new file +340 -0

340 lines not on this page · raw message

arch/arm/plat-mxc/include/mach/mx51.h new file +454 -0

454 lines not on this page · raw message

Signature · 1 line
1.6.3.3
#6 lore raw

PATCH v2 6/11 mxc: enable support for Freescale i.MX5 series of processors

Kconfig and Makefiles to enable Freescale i.MX51 processor. Separated to help ease the review process.

---
 arch/arm/Makefile               |    1 +
 arch/arm/mach-mx5/Kconfig       |   11 +++++++++++
 arch/arm/mach-mx5/Makefile      |    7 +++++++
 arch/arm/mach-mx5/Makefile.boot |    3 +++
 arch/arm/plat-mxc/Kconfig       |    8 ++++++++
 5 files changed, 30 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/mach-mx5/Kconfig
 create mode 100644 arch/arm/mach-mx5/Makefile
 create mode 100644 arch/arm/mach-mx5/Makefile.boot
arch/arm/Makefile +1 -0
index 9e75825..52232d2 100644
@@ -146,6 +146,7 @@ machine-$(CONFIG_ARCH_MX1)		:= mx1
 machine-$(CONFIG_ARCH_MX2)		:= mx2
 machine-$(CONFIG_ARCH_MX25)		:= mx25
 machine-$(CONFIG_ARCH_MX3)		:= mx3
+machine-$(CONFIG_ARCH_MX5)		:= mx5
 machine-$(CONFIG_ARCH_MXC91231)		:= mxc91231
 machine-$(CONFIG_ARCH_NETX)		:= netx
 machine-$(CONFIG_ARCH_NOMADIK)		:= nomadik
arch/arm/mach-mx5/Kconfig new file +11 -0
new file mode 100644
index 0000000..ccd96fd
@@ -0,0 +1,11 @@
+if ARCH_MX5
+
+config ARCH_MX51
+	bool
+	default y
+	select MXC_TZIC
+	select ARCH_MXC_IOMUX_V3
+
+comment "MX5 platforms:"
+
+endif
arch/arm/mach-mx5/Makefile new file +7 -0
new file mode 100644
index 0000000..d74ce4f
@@ -0,0 +1,7 @@
+#
+# Makefile for the linux kernel.
+#
+
+# Object file lists.
+obj-y   := cpu.o mm.o clock.o devices.o
+
arch/arm/mach-mx5/Makefile.boot new file +3 -0
new file mode 100644
index 0000000..9939a19
@@ -0,0 +1,3 @@
+   zreladdr-y	:= 0x90008000
+params_phys-y	:= 0x90000100
+initrd_phys-y	:= 0x90800000
arch/arm/plat-mxc/Kconfig +8 -0
index 59558c4..cea51a0 100644
@@ -41,6 +41,13 @@ config ARCH_MXC91231
 	help
 	  This enables support for systems based on the Freescale MXC91231 family
 
+config ARCH_MX5
+	bool "MX5-based"
+	select CPU_V7
+	select COMMON_CLKDEV
+	help
+	  This enables support for systems based on the Freescale i.MX51 family
+
 endchoice
 
 source "arch/arm/mach-mx1/Kconfig"
@@ -48,6 +55,7 @@ source "arch/arm/mach-mx2/Kconfig"
 source "arch/arm/mach-mx3/Kconfig"
 source "arch/arm/mach-mx25/Kconfig"
 source "arch/arm/mach-mxc91231/Kconfig"
+source "arch/arm/mach-mx5/Kconfig"
 
 endmenu
 
Signature · 1 line
1.6.3.3
#7 lore raw

PATCH v2 7/11 mxc: Add support for the Babbage board

Babbage is a reference board from Freescale for their i.MX51 SoC.

Boot tested on a Babbage2.5 board

---
 arch/arm/mach-mx5/Kconfig               |    6 ++
 arch/arm/mach-mx5/Makefile              |    2 +
 arch/arm/mach-mx5/board-mx51_babbage.c  |   99 +++++++++++++++++++++++++++++++
 arch/arm/plat-mxc/include/mach/common.h |    1 +
 4 files changed, 108 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/mach-mx5/board-mx51_babbage.c
arch/arm/mach-mx5/Kconfig +6 -0
index ccd96fd..80a749c 100644
@@ -8,4 +8,10 @@ config ARCH_MX51
 
 comment "MX5 platforms:"
 
+config MACH_MX51_BABBAGE
+	bool "Support MX51 BABBAGE platforms"
+	help
+	  Include support for MX51 Babbage platform. This includes specific
+	  configurations for the board and its peripherals.
+
 endif
arch/arm/mach-mx5/Makefile +2 -0
index d74ce4f..e4cf91f 100644
@@ -5,3 +5,5 @@
 # Object file lists.
 obj-y   := cpu.o mm.o clock.o devices.o
 
+obj-$(CONFIG_MACH_MX51_BABBAGE) += board-mx51_babbage.o
+
arch/arm/mach-mx5/board-mx51_babbage.c new file +99 -0

99 lines not on this page · raw message

arch/arm/plat-mxc/include/mach/common.h +1 -0
index 0a25576..33d4496 100644
@@ -21,6 +21,7 @@ extern void mx27_map_io(void);
 extern void mx31_map_io(void);
 extern void mx35_map_io(void);
 extern void mx51_map_io(void);
+extern void mx51_babbage_io_init(void);
 extern void mxc91231_map_io(void);
 extern void mxc_init_irq(void __iomem *);
 extern void tzic_init_irq(void __iomem *);
Signature · 1 line
1.6.3.3
#8 lore raw

PATCH v2 8/11 fec: fix uninitialized rx buffer usage

From: Rob Herring <[email protected]>

The fec driver was enabling receive buffer descriptor without allocating the buffers. Make sure the buffer descriptors are initialized to not start receiving packets.

Open also calls fec_restart after the rx buffers are allocated. With the code in fec_restart, it zeroes out the buffer descriptors that have just been setup.

Cc David S. Miller <[email protected]>
Cc netdev at vger.kernel.org
---
 drivers/net/fec.c |   57 +++++++++++++++++++++++++++--------------------------
 1 files changed, 29 insertions(+), 28 deletions(-)
drivers/net/fec.c +29 -28
index 16a1d58..9a8743d 100644
@@ -1658,6 +1658,7 @@ static int fec_enet_init(struct net_device *dev, int index)
 {
 	struct fec_enet_private *fep = netdev_priv(dev);
 	struct bufdesc *cbd_base;
+	struct bufdesc *bdp;
 	int i;
 
 	/* Allocate memory for buffer descriptors. */
@@ -1710,6 +1711,34 @@ static int fec_enet_init(struct net_device *dev, int index)
 	/* Set MII speed to 2.5 MHz */
 	fep->phy_speed = ((((clk_get_rate(fep->clk) / 2 + 4999999)
 					/ 2500000) / 2) & 0x3F) << 1;
+
+	/* Initialize the receive buffer descriptors. */
+	bdp = fep->rx_bd_base;
+	for (i = 0; i < RX_RING_SIZE; i++) {
+
+		/* Initialize the BD for every fragment in the page. */
+		bdp->cbd_sc = 0;
+		bdp++;
+	}
+
+	/* Set the last buffer to wrap */
+	bdp--;
+	bdp->cbd_sc |= BD_SC_WRAP;
+
+	/* ...and the same for transmit */
+	bdp = fep->tx_bd_base;
+	for (i = 0; i < TX_RING_SIZE; i++) {
+
+		/* Initialize the BD for every fragment in the page. */
+		bdp->cbd_sc = 0;
+		bdp->cbd_bufaddr = 0;
+		bdp++;
+	}
+
+	/* Set the last buffer to wrap */
+	bdp--;
+	bdp->cbd_sc |= BD_SC_WRAP;
+
 	fec_restart(dev, 0);
 
 	/* Queue up command to detect the PHY and initialize the
@@ -1730,7 +1759,6 @@ static void
 fec_restart(struct net_device *dev, int duplex)
 {
 	struct fec_enet_private *fep = netdev_priv(dev);
-	struct bufdesc *bdp;
 	int i;
 
 	/* Whack a reset.  We should wait for this. */
@@ -1768,33 +1796,6 @@ fec_restart(struct net_device *dev, int duplex)
 		}
 	}
 
-	/* Initialize the receive buffer descriptors. */
-	bdp = fep->rx_bd_base;
-	for (i = 0; i < RX_RING_SIZE; i++) {
-
-		/* Initialize the BD for every fragment in the page. */
-		bdp->cbd_sc = BD_ENET_RX_EMPTY;
-		bdp++;
-	}
-
-	/* Set the last buffer to wrap */
-	bdp--;
-	bdp->cbd_sc |= BD_SC_WRAP;
-
-	/* ...and the same for transmit */
-	bdp = fep->tx_bd_base;
-	for (i = 0; i < TX_RING_SIZE; i++) {
-
-		/* Initialize the BD for every fragment in the page. */
-		bdp->cbd_sc = 0;
-		bdp->cbd_bufaddr = 0;
-		bdp++;
-	}
-
-	/* Set the last buffer to wrap */
-	bdp--;
-	bdp->cbd_sc |= BD_SC_WRAP;
-
 	/* Enable MII mode */
 	if (duplex) {
 		/* MII enable / FD enable */
Signature · 1 line
1.6.3.3
#9 lore raw

PATCH v2 9/11 fec: Add LAN8700 phy support

The i.MX51 babbage board has a FEC ethernet controller with this phy.

In the long term we should resurrect the phylib patches for fec.

Cc David S. Miller <[email protected]>
Cc netdev at vger.kernel.org
---
 drivers/net/fec.c |   21 +++++++++++++++++++++
 1 files changed, 21 insertions(+), 0 deletions(-)
drivers/net/fec.c +21 -0
index 9a8743d..5d0d332 100644
@@ -1128,6 +1128,26 @@ static phy_info_t phy_info_dp83848= {
 	},
 };
 
+static phy_info_t phy_info_lan8700 = {
+	0x0007C0C,
+	"LAN8700",
+	(const phy_cmd_t []) { /* config */
+		{ mk_mii_read(MII_REG_CR), mii_parse_cr },
+		{ mk_mii_read(MII_REG_ANAR), mii_parse_anar },
+		{ mk_mii_end, }
+	},
+	(const phy_cmd_t []) { /* startup */
+		{ mk_mii_write(MII_REG_CR, 0x1200), NULL }, /* autonegotiate */
+		{ mk_mii_read(MII_REG_SR), mii_parse_sr },
+		{ mk_mii_end, }
+	},
+	(const phy_cmd_t []) { /* act_int */
+		{ mk_mii_end, }
+	},
+	(const phy_cmd_t []) { /* shutdown */
+		{ mk_mii_end, }
+	},
+};
 /* ------------------------------------------------------------------------- */
 
 static phy_info_t const * const phy_info[] = {
@@ -1137,6 +1157,7 @@ static phy_info_t const * const phy_info[] = {
 	&phy_info_am79c874,
 	&phy_info_ks8721bl,
 	&phy_info_dp83848,
+	&phy_info_lan8700,
 	NULL
 };
 
Signature · 1 line
1.6.3.3
#10 lore raw

PATCH v2 10/11 fec: Add ARCH_MX5 as a dependency

i.MX51 babbage board has a FEC ethernet controller

Cc David S. Miller <[email protected]>
Cc netdev at vger.kernel.org
---
 drivers/net/Kconfig |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
drivers/net/Kconfig +2 -1
index dd9a09c..515658e 100644
@@ -1883,7 +1883,8 @@ config 68360_ENET
 
 config FEC
 	bool "FEC ethernet controller (of ColdFire and some i.MX CPUs)"
-	depends on M523x || M527x || M5272 || M528x || M520x || M532x || MACH_MX27 || ARCH_MX35 || ARCH_MX25
+	depends on M523x || M527x || M5272 || M528x || M520x || M532x || \
+		MACH_MX27 || ARCH_MX35 || ARCH_MX25 || ARCH_MX5
 	help
 	  Say Y here if you want to use the built-in 10/100 Fast ethernet
 	  controller on some Motorola ColdFire and Freescale i.MX processors.
Signature · 1 line
1.6.3.3
#11 lore raw

PATCH v2 11/11 mxc: Add imx51_defconfig

This config is used to test the base support for i.MX51 processors on the Babbage board

---
 arch/arm/configs/imx51_defconfig | 1286 ++++++++++++++++++++++++++++++++++++++
 1 files changed, 1286 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/configs/imx51_defconfig
arch/arm/configs/imx51_defconfig new file +1286 -0
new file mode 100644
index 0000000..c88e952
@@ -0,0 +1,1286 @@
+#
+# Automatically generated make config: don't edit
+# Linux kernel version: 2.6.33-rc6
+# Tue Feb  2 15:20:48 2010
+#
+CONFIG_ARM=y
+CONFIG_SYS_SUPPORTS_APM_EMULATION=y
+CONFIG_GENERIC_GPIO=y
+CONFIG_GENERIC_TIME=y
+CONFIG_GENERIC_CLOCKEVENTS=y
+CONFIG_GENERIC_HARDIRQS=y
+CONFIG_STACKTRACE_SUPPORT=y
+CONFIG_HAVE_LATENCYTOP_SUPPORT=y
+CONFIG_LOCKDEP_SUPPORT=y
+CONFIG_TRACE_IRQFLAGS_SUPPORT=y
+CONFIG_HARDIRQS_SW_RESEND=y
+CONFIG_GENERIC_IRQ_PROBE=y
+CONFIG_RWSEM_GENERIC_SPINLOCK=y
+CONFIG_GENERIC_HWEIGHT=y
+CONFIG_GENERIC_CALIBRATE_DELAY=y
+CONFIG_ARCH_MTD_XIP=y
+CONFIG_GENERIC_HARDIRQS_NO__DO_IRQ=y
+CONFIG_VECTORS_BASE=0xffff0000
+CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
+CONFIG_CONSTRUCTORS=y
+
+#
+# General setup
+#
+CONFIG_EXPERIMENTAL=y
+CONFIG_BROKEN_ON_SMP=y
+CONFIG_INIT_ENV_ARG_LIMIT=32
+CONFIG_LOCALVERSION=""
+# CONFIG_LOCALVERSION_AUTO is not set
+CONFIG_HAVE_KERNEL_GZIP=y
+CONFIG_HAVE_KERNEL_LZO=y
+CONFIG_KERNEL_GZIP=y
+# CONFIG_KERNEL_BZIP2 is not set
+# CONFIG_KERNEL_LZMA is not set
+# CONFIG_KERNEL_LZO is not set
+CONFIG_SWAP=y
+CONFIG_SYSVIPC=y
+CONFIG_SYSVIPC_SYSCTL=y
+# CONFIG_POSIX_MQUEUE is not set
+# CONFIG_BSD_PROCESS_ACCT is not set
+# CONFIG_TASKSTATS is not set
+# CONFIG_AUDIT is not set
+
+#
+# RCU Subsystem
+#
+CONFIG_TREE_RCU=y
+# CONFIG_TREE_PREEMPT_RCU is not set
+# CONFIG_TINY_RCU is not set
+# CONFIG_RCU_TRACE is not set
+CONFIG_RCU_FANOUT=32
+# CONFIG_RCU_FANOUT_EXACT is not set
+# CONFIG_TREE_RCU_TRACE is not set
+# CONFIG_IKCONFIG is not set
+CONFIG_LOG_BUF_SHIFT=18
+# CONFIG_GROUP_SCHED is not set
+# CONFIG_CGROUPS is not set
+# CONFIG_SYSFS_DEPRECATED_V2 is not set
+CONFIG_RELAY=y
+# CONFIG_NAMESPACES is not set
+# CONFIG_BLK_DEV_INITRD is not set
+CONFIG_CC_OPTIMIZE_FOR_SIZE=y
+CONFIG_SYSCTL=y
+CONFIG_ANON_INODES=y
+CONFIG_EMBEDDED=y
+CONFIG_UID16=y
+CONFIG_SYSCTL_SYSCALL=y
+CONFIG_KALLSYMS=y
+# CONFIG_KALLSYMS_ALL is not set
+# CONFIG_KALLSYMS_EXTRA_PASS is not set
+CONFIG_HOTPLUG=y
+CONFIG_PRINTK=y
+CONFIG_BUG=y
+CONFIG_ELF_CORE=y
+CONFIG_BASE_FULL=y
+CONFIG_FUTEX=y
+CONFIG_EPOLL=y
+CONFIG_SIGNALFD=y
+CONFIG_TIMERFD=y
+CONFIG_EVENTFD=y
+CONFIG_SHMEM=y
+CONFIG_AIO=y
+
+#
+# Kernel Performance Events And Counters
+#
+CONFIG_VM_EVENT_COUNTERS=y
+# CONFIG_SLUB_DEBUG is not set
+# CONFIG_COMPAT_BRK is not set
+# CONFIG_SLAB is not set
+CONFIG_SLUB=y
+# CONFIG_SLOB is not set
+# CONFIG_PROFILING is not set
+CONFIG_HAVE_OPROFILE=y
+# CONFIG_KPROBES is not set
+CONFIG_HAVE_KPROBES=y
+CONFIG_HAVE_KRETPROBES=y
+CONFIG_HAVE_CLK=y
+
+#
+# GCOV-based kernel profiling
+#
+# CONFIG_GCOV_KERNEL is not set
+# CONFIG_SLOW_WORK is not set
+CONFIG_HAVE_GENERIC_DMA_COHERENT=y
+CONFIG_RT_MUTEXES=y
+CONFIG_BASE_SMALL=0
+CONFIG_MODULES=y
+# CONFIG_MODULE_FORCE_LOAD is not set
+CONFIG_MODULE_UNLOAD=y
+# CONFIG_MODULE_FORCE_UNLOAD is not set
+CONFIG_MODVERSIONS=y
+CONFIG_MODULE_SRCVERSION_ALL=y
+CONFIG_BLOCK=y
+# CONFIG_LBDAF is not set
+# CONFIG_BLK_DEV_BSG is not set
+# CONFIG_BLK_DEV_INTEGRITY is not set
+
+#
+# IO Schedulers
+#
+CONFIG_IOSCHED_NOOP=y
+CONFIG_IOSCHED_DEADLINE=y
+CONFIG_IOSCHED_CFQ=y
+# CONFIG_DEFAULT_DEADLINE is not set
+CONFIG_DEFAULT_CFQ=y
+# CONFIG_DEFAULT_NOOP is not set
+CONFIG_DEFAULT_IOSCHED="cfq"
+# CONFIG_INLINE_SPIN_TRYLOCK is not set
+# CONFIG_INLINE_SPIN_TRYLOCK_BH is not set
+# CONFIG_INLINE_SPIN_LOCK is not set
+# CONFIG_INLINE_SPIN_LOCK_BH is not set
+# CONFIG_INLINE_SPIN_LOCK_IRQ is not set
+# CONFIG_INLINE_SPIN_LOCK_IRQSAVE is not set
+CONFIG_INLINE_SPIN_UNLOCK=y
+# CONFIG_INLINE_SPIN_UNLOCK_BH is not set
+CONFIG_INLINE_SPIN_UNLOCK_IRQ=y
+# CONFIG_INLINE_SPIN_UNLOCK_IRQRESTORE is not set
+# CONFIG_INLINE_READ_TRYLOCK is not set
+# CONFIG_INLINE_READ_LOCK is not set
+# CONFIG_INLINE_READ_LOCK_BH is not set
+# CONFIG_INLINE_READ_LOCK_IRQ is not set
+# CONFIG_INLINE_READ_LOCK_IRQSAVE is not set
+CONFIG_INLINE_READ_UNLOCK=y
+# CONFIG_INLINE_READ_UNLOCK_BH is not set
+CONFIG_INLINE_READ_UNLOCK_IRQ=y
+# CONFIG_INLINE_READ_UNLOCK_IRQRESTORE is not set
+# CONFIG_INLINE_WRITE_TRYLOCK is not set
+# CONFIG_INLINE_WRITE_LOCK is not set
+# CONFIG_INLINE_WRITE_LOCK_BH is not set
+# CONFIG_INLINE_WRITE_LOCK_IRQ is not set
+# CONFIG_INLINE_WRITE_LOCK_IRQSAVE is not set
+CONFIG_INLINE_WRITE_UNLOCK=y
+# CONFIG_INLINE_WRITE_UNLOCK_BH is not set
+CONFIG_INLINE_WRITE_UNLOCK_IRQ=y
+# CONFIG_INLINE_WRITE_UNLOCK_IRQRESTORE is not set
+# CONFIG_MUTEX_SPIN_ON_OWNER is not set
+CONFIG_FREEZER=y
+
+#
+# System Type
+#
+CONFIG_MMU=y
+# CONFIG_ARCH_AAEC2000 is not set
+# CONFIG_ARCH_INTEGRATOR is not set
+# CONFIG_ARCH_REALVIEW is not set
+# CONFIG_ARCH_VERSATILE is not set
+# CONFIG_ARCH_AT91 is not set
+# CONFIG_ARCH_CLPS711X is not set
+# CONFIG_ARCH_GEMINI is not set
+# CONFIG_ARCH_EBSA110 is not set
+# CONFIG_ARCH_EP93XX is not set
+# CONFIG_ARCH_FOOTBRIDGE is not set
+CONFIG_ARCH_MXC=y
+# CONFIG_ARCH_STMP3XXX is not set
+# CONFIG_ARCH_NETX is not set
+# CONFIG_ARCH_H720X is not set
+# CONFIG_ARCH_NOMADIK is not set
+# CONFIG_ARCH_IOP13XX is not set
+# CONFIG_ARCH_IOP32X is not set
+# CONFIG_ARCH_IOP33X is not set
+# CONFIG_ARCH_IXP23XX is not set
+# CONFIG_ARCH_IXP2000 is not set
+# CONFIG_ARCH_IXP4XX is not set
+# CONFIG_ARCH_L7200 is not set
+# CONFIG_ARCH_DOVE is not set
+# CONFIG_ARCH_KIRKWOOD is not set
+# CONFIG_ARCH_LOKI is not set
+# CONFIG_ARCH_MV78XX0 is not set
+# CONFIG_ARCH_ORION5X is not set
+# CONFIG_ARCH_MMP is not set
+# CONFIG_ARCH_KS8695 is not set
+# CONFIG_ARCH_NS9XXX is not set
+# CONFIG_ARCH_W90X900 is not set
+# CONFIG_ARCH_PNX4008 is not set
+# CONFIG_ARCH_PXA is not set
+# CONFIG_ARCH_MSM is not set
+# CONFIG_ARCH_RPC is not set
+# CONFIG_ARCH_SA1100 is not set
+# CONFIG_ARCH_S3C2410 is not set
+# CONFIG_ARCH_S3C64XX is not set
+# CONFIG_ARCH_S5PC1XX is not set
+# CONFIG_ARCH_SHARK is not set
+# CONFIG_ARCH_LH7A40X is not set
+# CONFIG_ARCH_U300 is not set
+# CONFIG_ARCH_DAVINCI is not set
+# CONFIG_ARCH_OMAP is not set
+# CONFIG_ARCH_BCMRING is not set
+# CONFIG_ARCH_U8500 is not set
+
+#
+# Freescale MXC Implementations
+#
+# CONFIG_ARCH_MX1 is not set
+# CONFIG_ARCH_MX2 is not set
+# CONFIG_ARCH_MX25 is not set
+# CONFIG_ARCH_MX3 is not set
+# CONFIG_ARCH_MXC91231 is not set
+CONFIG_ARCH_MX5=y
+CONFIG_ARCH_MX51=y
+
+#
+# MX5 platforms:
+#
+CONFIG_MACH_MX51_BABBAGE=y
+# CONFIG_MXC_IRQ_PRIOR is not set
+CONFIG_MXC_TZIC=y
+# CONFIG_MXC_PWM is not set
+CONFIG_ARCH_MXC_IOMUX_V3=y
+
+#
+# Processor Type
+#
+CONFIG_CPU_32v6K=y
+CONFIG_CPU_V7=y
+CONFIG_CPU_32v7=y
+CONFIG_CPU_ABRT_EV7=y
+CONFIG_CPU_PABRT_V7=y
+CONFIG_CPU_CACHE_V7=y
+CONFIG_CPU_CACHE_VIPT=y
+CONFIG_CPU_COPY_V6=y
+CONFIG_CPU_TLB_V7=y
+CONFIG_CPU_HAS_ASID=y
+CONFIG_CPU_CP15=y
+CONFIG_CPU_CP15_MMU=y
+
+#
+# Processor Features
+#
+CONFIG_ARM_THUMB=y
+# CONFIG_ARM_THUMBEE is not set
+# CONFIG_CPU_ICACHE_DISABLE is not set
+# CONFIG_CPU_DCACHE_DISABLE is not set
+# CONFIG_CPU_BPREDICT_DISABLE is not set
+CONFIG_HAS_TLS_REG=y
+CONFIG_ARM_L1_CACHE_SHIFT=5
+# CONFIG_ARM_ERRATA_430973 is not set
+# CONFIG_ARM_ERRATA_458693 is not set
+# CONFIG_ARM_ERRATA_460075 is not set
+CONFIG_COMMON_CLKDEV=y
+
+#
+# Bus support
+#
+# CONFIG_PCI_SYSCALL is not set
+# CONFIG_ARCH_SUPPORTS_MSI is not set
+# CONFIG_PCCARD is not set
+
+#
+# Kernel Features
+#
+CONFIG_TICK_ONESHOT=y
+CONFIG_NO_HZ=y
+CONFIG_HIGH_RES_TIMERS=y
+CONFIG_GENERIC_CLOCKEVENTS_BUILD=y
+CONFIG_VMSPLIT_3G=y
+# CONFIG_VMSPLIT_2G is not set
+# CONFIG_VMSPLIT_1G is not set
+CONFIG_PAGE_OFFSET=0xC0000000
+# CONFIG_PREEMPT_NONE is not set
+CONFIG_PREEMPT_VOLUNTARY=y
+# CONFIG_PREEMPT is not set
+CONFIG_HZ=100
+# CONFIG_THUMB2_KERNEL is not set
+CONFIG_AEABI=y
+# CONFIG_OABI_COMPAT is not set
+# CONFIG_ARCH_SPARSEMEM_DEFAULT is not set
+# CONFIG_ARCH_SELECT_MEMORY_MODEL is not set
+# CONFIG_HIGHMEM is not set
+CONFIG_SELECT_MEMORY_MODEL=y
+CONFIG_FLATMEM_MANUAL=y
+# CONFIG_DISCONTIGMEM_MANUAL is not set
+# CONFIG_SPARSEMEM_MANUAL is not set
+CONFIG_FLATMEM=y
+CONFIG_FLAT_NODE_MEM_MAP=y
+CONFIG_PAGEFLAGS_EXTENDED=y
+CONFIG_SPLIT_PTLOCK_CPUS=4
+# CONFIG_PHYS_ADDR_T_64BIT is not set
+CONFIG_ZONE_DMA_FLAG=0
+CONFIG_VIRT_TO_BUS=y
+# CONFIG_KSM is not set
+CONFIG_DEFAULT_MMAP_MIN_ADDR=32768
+CONFIG_ALIGNMENT_TRAP=y
+# CONFIG_UACCESS_WITH_MEMCPY is not set
+
+#
+# Boot options
+#
+CONFIG_ZBOOT_ROM_TEXT=0
+CONFIG_ZBOOT_ROM_BSS=0
+CONFIG_CMDLINE="noinitrd console=ttymxc0,115200 root=/dev/nfs nfsroot=192.168.0.101:/shared/nfs ip=dhcp"
+# CONFIG_XIP_KERNEL is not set
+# CONFIG_KEXEC is not set
+
+#
+# CPU Power Management
+#
+# CONFIG_CPU_IDLE is not set
+
+#
+# Floating point emulation
+#
+
+#
+# At least one emulation must be selected
+#
+CONFIG_VFP=y
+CONFIG_VFPv3=y
+CONFIG_NEON=y
+
+#
+# Userspace binary formats
+#
+CONFIG_BINFMT_ELF=y
+# CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set
+CONFIG_HAVE_AOUT=y
+# CONFIG_BINFMT_AOUT is not set
+CONFIG_BINFMT_MISC=m
+
+#
+# Power management options
+#
+CONFIG_PM=y
+CONFIG_PM_DEBUG=y
+# CONFIG_PM_VERBOSE is not set
+CONFIG_CAN_PM_TRACE=y
+CONFIG_PM_SLEEP=y
+CONFIG_SUSPEND=y
+CONFIG_PM_TEST_SUSPEND=y
+CONFIG_SUSPEND_FREEZER=y
+# CONFIG_APM_EMULATION is not set
+# CONFIG_PM_RUNTIME is not set
+CONFIG_ARCH_SUSPEND_POSSIBLE=y
+CONFIG_NET=y
+
+#
+# Networking options
+#
+CONFIG_PACKET=y
+CONFIG_PACKET_MMAP=y
+CONFIG_UNIX=y
+# CONFIG_NET_KEY is not set
+CONFIG_INET=y
+# CONFIG_IP_MULTICAST is not set
+# CONFIG_IP_ADVANCED_ROUTER is not set
+CONFIG_IP_FIB_HASH=y
+CONFIG_IP_PNP=y
+CONFIG_IP_PNP_DHCP=y
+# CONFIG_IP_PNP_BOOTP is not set
+# CONFIG_IP_PNP_RARP is not set
+# CONFIG_NET_IPIP is not set
+# CONFIG_NET_IPGRE is not set
+# CONFIG_ARPD is not set
+# CONFIG_SYN_COOKIES is not set
+# CONFIG_INET_AH is not set
+# CONFIG_INET_ESP is not set
+# CONFIG_INET_IPCOMP is not set
+# CONFIG_INET_XFRM_TUNNEL is not set
+# CONFIG_INET_TUNNEL is not set
+# CONFIG_INET_XFRM_MODE_TRANSPORT is not set
+# CONFIG_INET_XFRM_MODE_TUNNEL is not set
+# CONFIG_INET_XFRM_MODE_BEET is not set
+# CONFIG_INET_LRO is not set
+CONFIG_INET_DIAG=y
+CONFIG_INET_TCP_DIAG=y
+# CONFIG_TCP_CONG_ADVANCED is not set
+CONFIG_TCP_CONG_CUBIC=y
+CONFIG_DEFAULT_TCP_CONG="cubic"
+# CONFIG_TCP_MD5SIG is not set
+# CONFIG_IPV6 is not set
+# CONFIG_NETWORK_SECMARK is not set
+# CONFIG_NETFILTER is not set
+# CONFIG_IP_DCCP is not set
+# CONFIG_IP_SCTP is not set
+# CONFIG_RDS is not set
+# CONFIG_TIPC is not set
+# CONFIG_ATM is not set
+# CONFIG_BRIDGE is not set
+# CONFIG_NET_DSA is not set
+# CONFIG_VLAN_8021Q is not set
+# CONFIG_DECNET is not set
+# CONFIG_LLC2 is not set
+# CONFIG_IPX is not set
+# CONFIG_ATALK is not set
+# CONFIG_X25 is not set
+# CONFIG_LAPB is not set
+# CONFIG_ECONET is not set
+# CONFIG_WAN_ROUTER is not set
+# CONFIG_PHONET is not set
+# CONFIG_IEEE802154 is not set
+# CONFIG_NET_SCHED is not set
+# CONFIG_DCB is not set
+
+#
+# Network testing
+#
+# CONFIG_NET_PKTGEN is not set
+# CONFIG_HAMRADIO is not set
+# CONFIG_CAN is not set
+# CONFIG_IRDA is not set
+# CONFIG_BT is not set
+# CONFIG_AF_RXRPC is not set
+# CONFIG_WIRELESS is not set
+# CONFIG_WIMAX is not set
+# CONFIG_RFKILL is not set
+# CONFIG_NET_9P is not set
+
+#
+# Device Drivers
+#
+
+#
+# Generic Driver Options
+#
+CONFIG_UEVENT_HELPER_PATH=""
+# CONFIG_STANDALONE is not set
+CONFIG_PREVENT_FIRMWARE_BUILD=y
+CONFIG_FW_LOADER=y
+CONFIG_FIRMWARE_IN_KERNEL=y
+CONFIG_EXTRA_FIRMWARE=""
+# CONFIG_DEBUG_DRIVER is not set
+# CONFIG_DEBUG_DEVRES is not set
+# CONFIG_SYS_HYPERVISOR is not set
+CONFIG_CONNECTOR=y
+CONFIG_PROC_EVENTS=y
+# CONFIG_MTD is not set
+# CONFIG_PARPORT is not set
+CONFIG_BLK_DEV=y
+# CONFIG_BLK_DEV_COW_COMMON is not set
+CONFIG_BLK_DEV_LOOP=y
+# CONFIG_BLK_DEV_CRYPTOLOOP is not set
+# CONFIG_BLK_DEV_DRBD is not set
+# CONFIG_BLK_DEV_NBD is not set
+CONFIG_BLK_DEV_RAM=y
+CONFIG_BLK_DEV_RAM_COUNT=16
+CONFIG_BLK_DEV_RAM_SIZE=65536
+# CONFIG_BLK_DEV_XIP is not set
+# CONFIG_CDROM_PKTCDVD is not set
+# CONFIG_ATA_OVER_ETH is not set
+# CONFIG_MG_DISK is not set
+# CONFIG_MISC_DEVICES is not set
+CONFIG_HAVE_IDE=y
+# CONFIG_IDE is not set
+
+#
+# SCSI device support
+#
+# CONFIG_RAID_ATTRS is not set
+CONFIG_SCSI=y
+CONFIG_SCSI_DMA=y
+# CONFIG_SCSI_TGT is not set
+# CONFIG_SCSI_NETLINK is not set
+# CONFIG_SCSI_PROC_FS is not set
+
+#
+# SCSI support type (disk, tape, CD-ROM)
+#
+CONFIG_BLK_DEV_SD=y
+# CONFIG_CHR_DEV_ST is not set
+# CONFIG_CHR_DEV_OSST is not set
+# CONFIG_BLK_DEV_SR is not set
+# CONFIG_CHR_DEV_SG is not set
+# CONFIG_CHR_DEV_SCH is not set
+CONFIG_SCSI_MULTI_LUN=y
+CONFIG_SCSI_CONSTANTS=y
+CONFIG_SCSI_LOGGING=y
+CONFIG_SCSI_SCAN_ASYNC=y
+CONFIG_SCSI_WAIT_SCAN=m
+
+#
+# SCSI Transports
+#
+# CONFIG_SCSI_SPI_ATTRS is not set
+# CONFIG_SCSI_FC_ATTRS is not set
+# CONFIG_SCSI_ISCSI_ATTRS is not set
+# CONFIG_SCSI_SAS_LIBSAS is not set
+# CONFIG_SCSI_SRP_ATTRS is not set
+# CONFIG_SCSI_LOWLEVEL is not set
+# CONFIG_SCSI_DH is not set
+# CONFIG_SCSI_OSD_INITIATOR is not set
+CONFIG_ATA=m
+# CONFIG_ATA_NONSTANDARD is not set
+CONFIG_ATA_VERBOSE_ERROR=y
+CONFIG_SATA_PMP=y
+CONFIG_ATA_SFF=y
+# CONFIG_SATA_MV is not set
+# CONFIG_PATA_PLATFORM is not set
+# CONFIG_MD is not set
+CONFIG_NETDEVICES=y
+# CONFIG_DUMMY is not set
+# CONFIG_BONDING is not set
+# CONFIG_MACVLAN is not set
+# CONFIG_EQUALIZER is not set
+# CONFIG_TUN is not set
+# CONFIG_VETH is not set
+CONFIG_PHYLIB=y
+
+#
+# MII PHY device drivers
+#
+CONFIG_MARVELL_PHY=y
+CONFIG_DAVICOM_PHY=y
+CONFIG_QSEMI_PHY=y
+CONFIG_LXT_PHY=y
+CONFIG_CICADA_PHY=y
+CONFIG_VITESSE_PHY=y
+CONFIG_SMSC_PHY=y
+CONFIG_BROADCOM_PHY=y
+CONFIG_ICPLUS_PHY=y
+CONFIG_REALTEK_PHY=y
+CONFIG_NATIONAL_PHY=y
+CONFIG_STE10XP=y
+CONFIG_LSI_ET1011C_PHY=y
+CONFIG_FIXED_PHY=y
+CONFIG_MDIO_BITBANG=y
+CONFIG_MDIO_GPIO=y
+CONFIG_NET_ETHERNET=y
+CONFIG_MII=m
+# CONFIG_AX88796 is not set
+# CONFIG_SMC91X is not set
+# CONFIG_DM9000 is not set
+# CONFIG_ETHOC is not set
+# CONFIG_SMC911X is not set
+# CONFIG_SMSC911X is not set
+# CONFIG_DNET is not set
+# CONFIG_IBM_NEW_EMAC_ZMII is not set
+# CONFIG_IBM_NEW_EMAC_RGMII is not set
+# CONFIG_IBM_NEW_EMAC_TAH is not set
+# CONFIG_IBM_NEW_EMAC_EMAC4 is not set
+# CONFIG_IBM_NEW_EMAC_NO_FLOW_CTRL is not set
+# CONFIG_IBM_NEW_EMAC_MAL_CLR_ICINTSTAT is not set
+# CONFIG_IBM_NEW_EMAC_MAL_COMMON_ERR is not set
+# CONFIG_B44 is not set
+# CONFIG_KS8842 is not set
+# CONFIG_KS8851_MLL is not set
+CONFIG_FEC=y
+# CONFIG_FEC2 is not set
+# CONFIG_NETDEV_1000 is not set
+# CONFIG_NETDEV_10000 is not set
+# CONFIG_WLAN is not set
+
+#
+# Enable WiMAX (Networking options) to see the WiMAX drivers
+#
+# CONFIG_WAN is not set
+# CONFIG_PPP is not set
+# CONFIG_SLIP is not set
+# CONFIG_NETCONSOLE is not set
+# CONFIG_NETPOLL is not set
+# CONFIG_NET_POLL_CONTROLLER is not set
+# CONFIG_ISDN is not set
+# CONFIG_PHONE is not set
+
+#
+# Input device support
+#
+CONFIG_INPUT=y
+CONFIG_INPUT_FF_MEMLESS=m
+# CONFIG_INPUT_POLLDEV is not set
+# CONFIG_INPUT_SPARSEKMAP is not set
+
+#
+# Userland interfaces
+#
+CONFIG_INPUT_MOUSEDEV=y
+# CONFIG_INPUT_MOUSEDEV_PSAUX is not set
+CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024
+CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
+# CONFIG_INPUT_JOYDEV is not set
+CONFIG_INPUT_EVDEV=y
+CONFIG_INPUT_EVBUG=m
+
+#
+# Input Device Drivers
+#
+CONFIG_INPUT_KEYBOARD=y
+# CONFIG_KEYBOARD_ADP5588 is not set
+CONFIG_KEYBOARD_ATKBD=y
+# CONFIG_QT2160 is not set
+# CONFIG_KEYBOARD_LKKBD is not set
+# CONFIG_KEYBOARD_GPIO is not set
+# CONFIG_KEYBOARD_MATRIX is not set
+# CONFIG_KEYBOARD_LM8323 is not set
+# CONFIG_KEYBOARD_MAX7359 is not set
+# CONFIG_KEYBOARD_NEWTON is not set
+# CONFIG_KEYBOARD_OPENCORES is not set
+# CONFIG_KEYBOARD_STOWAWAY is not set
+# CONFIG_KEYBOARD_SUNKBD is not set
+# CONFIG_KEYBOARD_XTKBD is not set
+CONFIG_INPUT_MOUSE=y
+CONFIG_MOUSE_PS2=m
+CONFIG_MOUSE_PS2_ALPS=y
+CONFIG_MOUSE_PS2_LOGIPS2PP=y
+CONFIG_MOUSE_PS2_SYNAPTICS=y
+CONFIG_MOUSE_PS2_TRACKPOINT=y
+CONFIG_MOUSE_PS2_ELANTECH=y
+# CONFIG_MOUSE_PS2_SENTELIC is not set
+# CONFIG_MOUSE_PS2_TOUCHKIT is not set
+# CONFIG_MOUSE_SERIAL is not set
+# CONFIG_MOUSE_VSXXXAA is not set
+# CONFIG_MOUSE_GPIO is not set
+# CONFIG_MOUSE_SYNAPTICS_I2C is not set
+# CONFIG_INPUT_JOYSTICK is not set
+# CONFIG_INPUT_TABLET is not set
+# CONFIG_INPUT_TOUCHSCREEN is not set
+# CONFIG_INPUT_MISC is not set
+
+#
+# Hardware I/O ports
+#
+CONFIG_SERIO=y
+CONFIG_SERIO_SERPORT=m
+CONFIG_SERIO_LIBPS2=y
+# CONFIG_SERIO_RAW is not set
+# CONFIG_SERIO_ALTERA_PS2 is not set
+# CONFIG_GAMEPORT is not set
+
+#
+# Character devices
+#
+CONFIG_VT=y
+CONFIG_CONSOLE_TRANSLATIONS=y
+CONFIG_VT_CONSOLE=y
+CONFIG_HW_CONSOLE=y
+CONFIG_VT_HW_CONSOLE_BINDING=y
+# CONFIG_DEVKMEM is not set
+# CONFIG_SERIAL_NONSTANDARD is not set
+
+#
+# Serial drivers
+#
+# CONFIG_SERIAL_8250 is not set
+
+#
+# Non-8250 serial port support
+#
+CONFIG_SERIAL_IMX=y
+CONFIG_SERIAL_IMX_CONSOLE=y
+CONFIG_SERIAL_CORE=y
+CONFIG_SERIAL_CORE_CONSOLE=y
+CONFIG_UNIX98_PTYS=y
+# CONFIG_DEVPTS_MULTIPLE_INSTANCES is not set
+# CONFIG_LEGACY_PTYS is not set
+# CONFIG_IPMI_HANDLER is not set
+CONFIG_HW_RANDOM=y
+# CONFIG_HW_RANDOM_TIMERIOMEM is not set
+# CONFIG_R3964 is not set
+# CONFIG_RAW_DRIVER is not set
+# CONFIG_TCG_TPM is not set
+CONFIG_I2C=y
+CONFIG_I2C_BOARDINFO=y
+# CONFIG_I2C_COMPAT is not set
+CONFIG_I2C_CHARDEV=m
+# CONFIG_I2C_HELPER_AUTO is not set
+
+#
+# I2C Algorithms
+#
+CONFIG_I2C_ALGOBIT=m
+CONFIG_I2C_ALGOPCF=m
+CONFIG_I2C_ALGOPCA=m
+
+#
+# I2C Hardware Bus support
+#
+
+#
+# I2C system bus drivers (mostly embedded / system-on-chip)
+#
+# CONFIG_I2C_DESIGNWARE is not set
+# CONFIG_I2C_GPIO is not set
+# CONFIG_I2C_IMX is not set
+# CONFIG_I2C_OCORES is not set
+# CONFIG_I2C_SIMTEC is not set
+
+#
+# External I2C/SMBus adapter drivers
+#
+# CONFIG_I2C_PARPORT_LIGHT is not set
+# CONFIG_I2C_TAOS_EVM is not set
+
+#
+# Other I2C/SMBus bus drivers
+#
+# CONFIG_I2C_PCA_PLATFORM is not set
+# CONFIG_I2C_STUB is not set
+
+#
+# Miscellaneous I2C Chip support
+#
+# CONFIG_SENSORS_TSL2550 is not set
+# CONFIG_I2C_DEBUG_CORE is not set
+# CONFIG_I2C_DEBUG_ALGO is not set
+# CONFIG_I2C_DEBUG_BUS is not set
+# CONFIG_I2C_DEBUG_CHIP is not set
+# CONFIG_SPI is not set
+
+#
+# PPS support
+#
+# CONFIG_PPS is not set
+CONFIG_ARCH_REQUIRE_GPIOLIB=y
+CONFIG_GPIOLIB=y
+# CONFIG_DEBUG_GPIO is not set
+CONFIG_GPIO_SYSFS=y
+
+#
+# Memory mapped GPIO expanders:
+#
+
+#
+# I2C GPIO expanders:
+#
+# CONFIG_GPIO_MAX732X is not set
+# CONFIG_GPIO_PCA953X is not set
+# CONFIG_GPIO_PCF857X is not set
+# CONFIG_GPIO_ADP5588 is not set
+
+#
+# PCI GPIO expanders:
+#
+
+#
+# SPI GPIO expanders:
+#
+
+#
+# AC97 GPIO expanders:
+#
+# CONFIG_W1 is not set
+# CONFIG_POWER_SUPPLY is not set
+# CONFIG_HWMON is not set
+# CONFIG_THERMAL is not set
+# CONFIG_WATCHDOG is not set
+CONFIG_SSB_POSSIBLE=y
+
+#
+# Sonics Silicon Backplane
+#
+# CONFIG_SSB is not set
+
+#
+# Multifunction device drivers
+#
+# CONFIG_MFD_CORE is not set
+# CONFIG_MFD_SM501 is not set
+# CONFIG_MFD_ASIC3 is not set
+# CONFIG_HTC_EGPIO is not set
+# CONFIG_HTC_PASIC3 is not set
+# CONFIG_TPS65010 is not set
+# CONFIG_TWL4030_CORE is not set
+# CONFIG_MFD_TMIO is not set
+# CONFIG_MFD_T7L66XB is not set
+# CONFIG_MFD_TC6387XB is not set
+# CONFIG_MFD_TC6393XB is not set
+# CONFIG_PMIC_DA903X is not set
+# CONFIG_PMIC_ADP5520 is not set
+# CONFIG_MFD_WM8400 is not set
+# CONFIG_MFD_WM831X is not set
+# CONFIG_MFD_WM8350_I2C is not set
+# CONFIG_MFD_PCF50633 is not set
+# CONFIG_AB3100_CORE is not set
+# CONFIG_MFD_88PM8607 is not set
+# CONFIG_REGULATOR is not set
+# CONFIG_MEDIA_SUPPORT is not set
+
+#
+# Graphics support
+#
+# CONFIG_VGASTATE is not set
+# CONFIG_VIDEO_OUTPUT_CONTROL is not set
+# CONFIG_FB is not set
+# CONFIG_BACKLIGHT_LCD_SUPPORT is not set
+
+#
+# Display device support
+#
+# CONFIG_DISPLAY_SUPPORT is not set
+
+#
+# Console display driver support
+#
+# CONFIG_VGA_CONSOLE is not set
+CONFIG_DUMMY_CONSOLE=y
+# CONFIG_SOUND is not set
+# CONFIG_HID_SUPPORT is not set
+# CONFIG_USB_SUPPORT is not set
+CONFIG_MMC=y
+# CONFIG_MMC_DEBUG is not set
+# CONFIG_MMC_UNSAFE_RESUME is not set
+
+#
+# MMC/SD/SDIO Card Drivers
+#
+CONFIG_MMC_BLOCK=m
+CONFIG_MMC_BLOCK_BOUNCE=y
+# CONFIG_SDIO_UART is not set
+# CONFIG_MMC_TEST is not set
+
+#
+# MMC/SD/SDIO Host Controller Drivers
+#
+CONFIG_MMC_SDHCI=m
+# CONFIG_MMC_SDHCI_PLTFM is not set
+# CONFIG_MMC_AT91 is not set
+# CONFIG_MMC_ATMELMCI is not set
+# CONFIG_MMC_MXC is not set
+# CONFIG_MEMSTICK is not set
+CONFIG_NEW_LEDS=y
+CONFIG_LEDS_CLASS=m
+
+#
+# LED drivers
+#
+# CONFIG_LEDS_PCA9532 is not set
+# CONFIG_LEDS_GPIO is not set
+# CONFIG_LEDS_LP3944 is not set
+# CONFIG_LEDS_PCA955X is not set
+# CONFIG_LEDS_BD2802 is not set
+# CONFIG_LEDS_LT3593 is not set
+
+#
+# LED Triggers
+#
+# CONFIG_LEDS_TRIGGERS is not set
+# CONFIG_ACCESSIBILITY is not set
+CONFIG_RTC_LIB=y
+CONFIG_RTC_CLASS=y
+CONFIG_RTC_HCTOSYS=y
+CONFIG_RTC_HCTOSYS_DEVICE="rtc0"
+# CONFIG_RTC_DEBUG is not set
+
+#
+# RTC interfaces
+#
+CONFIG_RTC_INTF_SYSFS=y
+CONFIG_RTC_INTF_PROC=y
+CONFIG_RTC_INTF_DEV=y
+CONFIG_RTC_INTF_DEV_UIE_EMUL=y
+# CONFIG_RTC_DRV_TEST is not set
+
+#
+# I2C RTC drivers
+#
+# CONFIG_RTC_DRV_DS1307 is not set
+# CONFIG_RTC_DRV_DS1374 is not set
+# CONFIG_RTC_DRV_DS1672 is not set
+# CONFIG_RTC_DRV_MAX6900 is not set
+# CONFIG_RTC_DRV_RS5C372 is not set
+# CONFIG_RTC_DRV_ISL1208 is not set
+# CONFIG_RTC_DRV_X1205 is not set
+# CONFIG_RTC_DRV_PCF8563 is not set
+# CONFIG_RTC_DRV_PCF8583 is not set
+# CONFIG_RTC_DRV_M41T80 is not set
+# CONFIG_RTC_DRV_BQ32K is not set
+# CONFIG_RTC_DRV_S35390A is not set
+# CONFIG_RTC_DRV_FM3130 is not set
+# CONFIG_RTC_DRV_RX8581 is not set
+# CONFIG_RTC_DRV_RX8025 is not set
+
+#
+# SPI RTC drivers
+#
+
+#
+# Platform RTC drivers
+#
+# CONFIG_RTC_DRV_CMOS is not set
+# CONFIG_RTC_DRV_DS1286 is not set
+# CONFIG_RTC_DRV_DS1511 is not set
+# CONFIG_RTC_DRV_DS1553 is not set
+# CONFIG_RTC_DRV_DS1742 is not set
+# CONFIG_RTC_DRV_STK17TA8 is not set
+# CONFIG_RTC_DRV_M48T86 is not set
+# CONFIG_RTC_DRV_M48T35 is not set
+# CONFIG_RTC_DRV_M48T59 is not set
+# CONFIG_RTC_DRV_MSM6242 is not set
+# CONFIG_RTC_MXC is not set
+# CONFIG_RTC_DRV_BQ4802 is not set
+# CONFIG_RTC_DRV_RP5C01 is not set
+# CONFIG_RTC_DRV_V3020 is not set
+
+#
+# on-CPU RTC drivers
+#
+# CONFIG_DMADEVICES is not set
+# CONFIG_AUXDISPLAY is not set
+# CONFIG_UIO is not set
+
+#
+# TI VLYNQ
+#
+# CONFIG_STAGING is not set
+
+#
+# File systems
+#
+CONFIG_EXT2_FS=y
+CONFIG_EXT2_FS_XATTR=y
+CONFIG_EXT2_FS_POSIX_ACL=y
+CONFIG_EXT2_FS_SECURITY=y
+# CONFIG_EXT2_FS_XIP is not set
+CONFIG_EXT3_FS=y
+CONFIG_EXT3_DEFAULTS_TO_ORDERED=y
+CONFIG_EXT3_FS_XATTR=y
+CONFIG_EXT3_FS_POSIX_ACL=y
+CONFIG_EXT3_FS_SECURITY=y
+CONFIG_EXT4_FS=y
+CONFIG_EXT4_FS_XATTR=y
+CONFIG_EXT4_FS_POSIX_ACL=y
+CONFIG_EXT4_FS_SECURITY=y
+# CONFIG_EXT4_DEBUG is not set
+CONFIG_JBD=y
+# CONFIG_JBD_DEBUG is not set
+CONFIG_JBD2=y
+# CONFIG_JBD2_DEBUG is not set
+CONFIG_FS_MBCACHE=y
+# CONFIG_REISERFS_FS is not set
+# CONFIG_JFS_FS is not set
+CONFIG_FS_POSIX_ACL=y
+# CONFIG_XFS_FS is not set
+# CONFIG_OCFS2_FS is not set
+# CONFIG_BTRFS_FS is not set
+# CONFIG_NILFS2_FS is not set
+CONFIG_FILE_LOCKING=y
+CONFIG_FSNOTIFY=y
+CONFIG_DNOTIFY=y
+CONFIG_INOTIFY=y
+CONFIG_INOTIFY_USER=y
+CONFIG_QUOTA=y
+CONFIG_QUOTA_NETLINK_INTERFACE=y
+# CONFIG_PRINT_QUOTA_WARNING is not set
+# CONFIG_QFMT_V1 is not set
+# CONFIG_QFMT_V2 is not set
+CONFIG_QUOTACTL=y
+CONFIG_AUTOFS_FS=y
+CONFIG_AUTOFS4_FS=y
+CONFIG_FUSE_FS=y
+# CONFIG_CUSE is not set
+
+#
+# Caches
+#
+# CONFIG_FSCACHE is not set
+
+#
+# CD-ROM/DVD Filesystems
+#
+CONFIG_ISO9660_FS=m
+CONFIG_JOLIET=y
+CONFIG_ZISOFS=y
+CONFIG_UDF_FS=m
+CONFIG_UDF_NLS=y
+
+#
+# DOS/FAT/NT Filesystems
+#
+CONFIG_FAT_FS=y
+CONFIG_MSDOS_FS=m
+CONFIG_VFAT_FS=y
+CONFIG_FAT_DEFAULT_CODEPAGE=437
+CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
+# CONFIG_NTFS_FS is not set
+
+#
+# Pseudo filesystems
+#
+CONFIG_PROC_FS=y
+CONFIG_PROC_SYSCTL=y
+CONFIG_PROC_PAGE_MONITOR=y
+CONFIG_SYSFS=y
+# CONFIG_TMPFS is not set
+# CONFIG_HUGETLB_PAGE is not set
+CONFIG_CONFIGFS_FS=m
+CONFIG_MISC_FILESYSTEMS=y
+# CONFIG_ADFS_FS is not set
+# CONFIG_AFFS_FS is not set
+# CONFIG_ECRYPT_FS is not set
+# CONFIG_HFS_FS is not set
+# CONFIG_HFSPLUS_FS is not set
+# CONFIG_BEFS_FS is not set
+# CONFIG_BFS_FS is not set
+# CONFIG_EFS_FS is not set
+# CONFIG_CRAMFS is not set
+# CONFIG_SQUASHFS is not set
+# CONFIG_VXFS_FS is not set
+# CONFIG_MINIX_FS is not set
+# CONFIG_OMFS_FS is not set
+# CONFIG_HPFS_FS is not set
+# CONFIG_QNX4FS_FS is not set
+# CONFIG_ROMFS_FS is not set
+# CONFIG_SYSV_FS is not set
+# CONFIG_UFS_FS is not set
+CONFIG_NETWORK_FILESYSTEMS=y
+CONFIG_NFS_FS=y
+CONFIG_NFS_V3=y
+CONFIG_NFS_V3_ACL=y
+CONFIG_NFS_V4=y
+# CONFIG_NFS_V4_1 is not set
+CONFIG_ROOT_NFS=y
+# CONFIG_NFSD is not set
+CONFIG_LOCKD=y
+CONFIG_LOCKD_V4=y
+CONFIG_NFS_ACL_SUPPORT=y
+CONFIG_NFS_COMMON=y
+CONFIG_SUNRPC=y
+CONFIG_SUNRPC_GSS=y
+CONFIG_RPCSEC_GSS_KRB5=y
+# CONFIG_RPCSEC_GSS_SPKM3 is not set
+# CONFIG_SMB_FS is not set
+# CONFIG_CIFS is not set
+# CONFIG_NCP_FS is not set
+# CONFIG_CODA_FS is not set
+# CONFIG_AFS_FS is not set
+
+#
+# Partition Types
+#
+# CONFIG_PARTITION_ADVANCED is not set
+CONFIG_MSDOS_PARTITION=y
+CONFIG_NLS=y
+CONFIG_NLS_DEFAULT="cp437"
+CONFIG_NLS_CODEPAGE_437=y
+# CONFIG_NLS_CODEPAGE_737 is not set
+# CONFIG_NLS_CODEPAGE_775 is not set
+# CONFIG_NLS_CODEPAGE_850 is not set
+# CONFIG_NLS_CODEPAGE_852 is not set
+# CONFIG_NLS_CODEPAGE_855 is not set
+# CONFIG_NLS_CODEPAGE_857 is not set
+# CONFIG_NLS_CODEPAGE_860 is not set
+# CONFIG_NLS_CODEPAGE_861 is not set
+# CONFIG_NLS_CODEPAGE_862 is not set
+# CONFIG_NLS_CODEPAGE_863 is not set
+# CONFIG_NLS_CODEPAGE_864 is not set
+# CONFIG_NLS_CODEPAGE_865 is not set
+# CONFIG_NLS_CODEPAGE_866 is not set
+# CONFIG_NLS_CODEPAGE_869 is not set
+# CONFIG_NLS_CODEPAGE_936 is not set
+# CONFIG_NLS_CODEPAGE_950 is not set
+# CONFIG_NLS_CODEPAGE_932 is not set
+# CONFIG_NLS_CODEPAGE_949 is not set
+# CONFIG_NLS_CODEPAGE_874 is not set
+# CONFIG_NLS_ISO8859_8 is not set
+# CONFIG_NLS_CODEPAGE_1250 is not set
+# CONFIG_NLS_CODEPAGE_1251 is not set
+CONFIG_NLS_ASCII=y
+CONFIG_NLS_ISO8859_1=m
+# CONFIG_NLS_ISO8859_2 is not set
+# CONFIG_NLS_ISO8859_3 is not set
+# CONFIG_NLS_ISO8859_4 is not set
+# CONFIG_NLS_ISO8859_5 is not set
+# CONFIG_NLS_ISO8859_6 is not set
+# CONFIG_NLS_ISO8859_7 is not set
+# CONFIG_NLS_ISO8859_9 is not set
+# CONFIG_NLS_ISO8859_13 is not set
+# CONFIG_NLS_ISO8859_14 is not set
+CONFIG_NLS_ISO8859_15=m
+# CONFIG_NLS_KOI8_R is not set
+# CONFIG_NLS_KOI8_U is not set
+CONFIG_NLS_UTF8=y
+# CONFIG_DLM is not set
+
+#
+# Kernel hacking
+#
+# CONFIG_PRINTK_TIME is not set
+CONFIG_ENABLE_WARN_DEPRECATED=y
+CONFIG_ENABLE_MUST_CHECK=y
+CONFIG_FRAME_WARN=1024
+CONFIG_MAGIC_SYSRQ=y
+# CONFIG_STRIP_ASM_SYMS is not set
+# CONFIG_UNUSED_SYMBOLS is not set
+CONFIG_DEBUG_FS=y
+# CONFIG_HEADERS_CHECK is not set
+CONFIG_DEBUG_KERNEL=y
+# CONFIG_DEBUG_SHIRQ is not set
+# CONFIG_DETECT_SOFTLOCKUP is not set
+# CONFIG_DETECT_HUNG_TASK is not set
+# CONFIG_SCHED_DEBUG is not set
+# CONFIG_SCHEDSTATS is not set
+# CONFIG_TIMER_STATS is not set
+# CONFIG_DEBUG_OBJECTS is not set
+# CONFIG_DEBUG_KMEMLEAK is not set
+# CONFIG_DEBUG_RT_MUTEXES is not set
+# CONFIG_RT_MUTEX_TESTER is not set
+# CONFIG_DEBUG_SPINLOCK is not set
+# CONFIG_DEBUG_MUTEXES is not set
+# CONFIG_DEBUG_LOCK_ALLOC is not set
+# CONFIG_PROVE_LOCKING is not set
+# CONFIG_LOCK_STAT is not set
+# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
+# CONFIG_DEBUG_LOCKING_API_SELFTESTS is not set
+# CONFIG_DEBUG_KOBJECT is not set
+# CONFIG_DEBUG_BUGVERBOSE is not set
+# CONFIG_DEBUG_INFO is not set
+# CONFIG_DEBUG_VM is not set
+# CONFIG_DEBUG_WRITECOUNT is not set
+# CONFIG_DEBUG_MEMORY_INIT is not set
+# CONFIG_DEBUG_LIST is not set
+# CONFIG_DEBUG_SG is not set
+# CONFIG_DEBUG_NOTIFIERS is not set
+# CONFIG_DEBUG_CREDENTIALS is not set
+CONFIG_FRAME_POINTER=y
+# CONFIG_BOOT_PRINTK_DELAY is not set
+# CONFIG_RCU_TORTURE_TEST is not set
+# CONFIG_RCU_CPU_STALL_DETECTOR is not set
+# CONFIG_BACKTRACE_SELF_TEST is not set
+# CONFIG_DEBUG_BLOCK_EXT_DEVT is not set
+# CONFIG_DEBUG_FORCE_WEAK_PER_CPU is not set
+# CONFIG_FAULT_INJECTION is not set
+# CONFIG_LATENCYTOP is not set
+# CONFIG_SYSCTL_SYSCALL_CHECK is not set
+# CONFIG_PAGE_POISONING is not set
+CONFIG_HAVE_FUNCTION_TRACER=y
+CONFIG_TRACING_SUPPORT=y
+# CONFIG_FTRACE is not set
+# CONFIG_DYNAMIC_DEBUG is not set
+# CONFIG_SAMPLES is not set
+CONFIG_HAVE_ARCH_KGDB=y
+# CONFIG_KGDB is not set
+# CONFIG_ARM_UNWIND is not set
+# CONFIG_DEBUG_USER is not set
+# CONFIG_DEBUG_ERRORS is not set
+# CONFIG_DEBUG_STACK_USAGE is not set
+CONFIG_DEBUG_LL=y
+CONFIG_EARLY_PRINTK=y
+# CONFIG_DEBUG_ICEDCC is not set
+# CONFIG_OC_ETM is not set
+
+#
+# Security options
+#
+CONFIG_KEYS=y
+# CONFIG_KEYS_DEBUG_PROC_KEYS is not set
+# CONFIG_SECURITY is not set
+CONFIG_SECURITYFS=y
+# CONFIG_DEFAULT_SECURITY_SELINUX is not set
+# CONFIG_DEFAULT_SECURITY_SMACK is not set
+# CONFIG_DEFAULT_SECURITY_TOMOYO is not set
+CONFIG_DEFAULT_SECURITY_DAC=y
+CONFIG_DEFAULT_SECURITY=""
+CONFIG_CRYPTO=y
+
+#
+# Crypto core or helper
+#
+CONFIG_CRYPTO_ALGAPI=y
+CONFIG_CRYPTO_ALGAPI2=y
+CONFIG_CRYPTO_AEAD2=y
+CONFIG_CRYPTO_BLKCIPHER=y
+CONFIG_CRYPTO_BLKCIPHER2=y
+CONFIG_CRYPTO_HASH=y
+CONFIG_CRYPTO_HASH2=y
+CONFIG_CRYPTO_RNG2=y
+CONFIG_CRYPTO_PCOMP=y
+CONFIG_CRYPTO_MANAGER=y
+CONFIG_CRYPTO_MANAGER2=y
+# CONFIG_CRYPTO_GF128MUL is not set
+# CONFIG_CRYPTO_NULL is not set
+CONFIG_CRYPTO_WORKQUEUE=y
+# CONFIG_CRYPTO_CRYPTD is not set
+# CONFIG_CRYPTO_AUTHENC is not set
+# CONFIG_CRYPTO_TEST is not set
+
+#
+# Authenticated Encryption with Associated Data
+#
+# CONFIG_CRYPTO_CCM is not set
+# CONFIG_CRYPTO_GCM is not set
+# CONFIG_CRYPTO_SEQIV is not set
+
+#
+# Block modes
+#
+CONFIG_CRYPTO_CBC=y
+# CONFIG_CRYPTO_CTR is not set
+# CONFIG_CRYPTO_CTS is not set
+# CONFIG_CRYPTO_ECB is not set
+# CONFIG_CRYPTO_LRW is not set
+# CONFIG_CRYPTO_PCBC is not set
+# CONFIG_CRYPTO_XTS is not set
+
+#
+# Hash modes
+#
+# CONFIG_CRYPTO_HMAC is not set
+# CONFIG_CRYPTO_XCBC is not set
+# CONFIG_CRYPTO_VMAC is not set
+
+#
+# Digest
+#
+CONFIG_CRYPTO_CRC32C=m
+# CONFIG_CRYPTO_GHASH is not set
+# CONFIG_CRYPTO_MD4 is not set
+CONFIG_CRYPTO_MD5=y
+# CONFIG_CRYPTO_MICHAEL_MIC is not set
+# CONFIG_CRYPTO_RMD128 is not set
+# CONFIG_CRYPTO_RMD160 is not set
+# CONFIG_CRYPTO_RMD256 is not set
+# CONFIG_CRYPTO_RMD320 is not set
+# CONFIG_CRYPTO_SHA1 is not set
+# CONFIG_CRYPTO_SHA256 is not set
+# CONFIG_CRYPTO_SHA512 is not set
+# CONFIG_CRYPTO_TGR192 is not set
+# CONFIG_CRYPTO_WP512 is not set
+
+#
+# Ciphers
+#
+# CONFIG_CRYPTO_AES is not set
+# CONFIG_CRYPTO_ANUBIS is not set
+# CONFIG_CRYPTO_ARC4 is not set
+# CONFIG_CRYPTO_BLOWFISH is not set
+# CONFIG_CRYPTO_CAMELLIA is not set
+# CONFIG_CRYPTO_CAST5 is not set
+# CONFIG_CRYPTO_CAST6 is not set
+CONFIG_CRYPTO_DES=y
+# CONFIG_CRYPTO_FCRYPT is not set
+# CONFIG_CRYPTO_KHAZAD is not set
+# CONFIG_CRYPTO_SALSA20 is not set
+# CONFIG_CRYPTO_SEED is not set
+# CONFIG_CRYPTO_SERPENT is not set
+# CONFIG_CRYPTO_TEA is not set
+# CONFIG_CRYPTO_TWOFISH is not set
+
+#
+# Compression
+#
+CONFIG_CRYPTO_DEFLATE=y
+# CONFIG_CRYPTO_ZLIB is not set
+CONFIG_CRYPTO_LZO=y
+
+#
+# Random Number Generation
+#
+# CONFIG_CRYPTO_ANSI_CPRNG is not set
+# CONFIG_CRYPTO_HW is not set
+# CONFIG_BINARY_PRINTF is not set
+
+#
+# Library routines
+#
+CONFIG_BITREVERSE=y
+CONFIG_RATIONAL=y
+CONFIG_GENERIC_FIND_LAST_BIT=y
+CONFIG_CRC_CCITT=m
+CONFIG_CRC16=y
+CONFIG_CRC_T10DIF=y
+CONFIG_CRC_ITU_T=m
+CONFIG_CRC32=y
+CONFIG_CRC7=m
+CONFIG_LIBCRC32C=m
+CONFIG_ZLIB_INFLATE=y
+CONFIG_ZLIB_DEFLATE=y
+CONFIG_LZO_COMPRESS=y
+CONFIG_LZO_DECOMPRESS=y
+CONFIG_HAS_IOMEM=y
+CONFIG_HAS_IOPORT=y
+CONFIG_HAS_DMA=y
+CONFIG_NLATTR=y
Signature · 1 line
1.6.3.3
maintainer
#12 lore raw

Re: [PATCHv2 11/11] mxc: Add imx51_defconfig

Hi Amit,

Quoted 8 lines · Amit Kucheria

This config is used to test the base support for i.MX51 processors on the Babbage board

---
 arch/arm/configs/imx51_defconfig | 1286 ++++++++++++++++++++++++++++++++++++++
 1 files changed, 1286 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/configs/imx51_defconfig

Can you rename this to mx51_defconfig? All other i.MX defconfigs begin with mx.

Sascha

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

Re: [PATCHv2 08/11] fec: fix uninitialized rx buffer usage

In reply to Amit Kucheria
Quoted 9 lines · Amit Kucheria

From: Rob Herring <[email protected]>

The fec driver was enabling receive buffer descriptor without allocating the buffers. Make sure the buffer descriptors are initialized to not start receiving packets.

Open also calls fec_restart after the rx buffers are allocated. With the code in fec_restart, it zeroes out the buffer descriptors that have just been setup.

fec related patches 8 & 9 look okay to me.

g.

Signature · 2 lines
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.
#14 lore raw

Re: [PATCHv2 08/11] fec: fix uninitialized rx buffer usage

Quoted 12 lines · Grant Likely
Quoted 9 lines · Amit Kucheria

From: Rob Herring <[email protected]>

The fec driver was enabling receive buffer descriptor without allocating the buffers. Make sure the buffer descriptors are initialized to not start receiving packets.

Open also calls fec_restart after the rx buffers are allocated. With the code in fec_restart, it zeroes out the buffer descriptors that have just been setup.

Quoted 7 lines

fec related patches 8 & 9 look okay to me.

g.

--
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.

Can I take that as an Acked-by?

#15 lore raw

Re: [PATCHv2 08/11] fec: fix uninitialized rx buffer usage

Quoted 15 lines · Amit Kucheria
Quoted 14 lines · Grant Likely
Quoted 9 lines · Amit Kucheria

From: Rob Herring <[email protected]>

The fec driver was enabling receive buffer descriptor without allocating the buffers. Make sure the buffer descriptors are initialized to not start receiving packets.

Open also calls fec_restart after the rx buffers are allocated. With the code in fec_restart, it zeroes out the buffer descriptors that have just been setup.

fec related patches 8 & 9 look okay to me.

Quoted 7 lines
Quoted 5 lines

g.

--
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.

Can I take that as an Acked-by?

of course.

g.

#16 lore raw

Re: [PATCHv2 08/11] fec: fix uninitialized rx buffer usage

Quoted 11 lines · Grant Likely
Quoted 7 lines · Amit Kucheria
Quoted 4 lines · Grant Likely

fec related patches 8 & 9 look okay to me.

g.

Can I take that as an Acked-by?

of course.

BTW, since these 2 patches are essentially independent, you may find it easier to get all the patches merged if you post the FEC changes in a separate patch series.

g.

maintainer
#17 lore raw

Re: [PATCHv2 07/11] mxc: Add support for the Babbage board

In reply to Amit Kucheria

arch/arm/mach-mx5/board-mx51_babbage.c

Quoted 39 lines · Amit Kucheria

Babbage is a reference board from Freescale for their i.MX51 SoC.

Boot tested on a Babbage2.5 board

---
 arch/arm/mach-mx5/Kconfig               |    6 ++
 arch/arm/mach-mx5/Makefile              |    2 +
 arch/arm/mach-mx5/board-mx51_babbage.c  |   99 +++++++++++++++++++++++++++++++
 arch/arm/plat-mxc/include/mach/common.h |    1 +
 4 files changed, 108 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/mach-mx5/board-mx51_babbage.c
arch/arm/mach-mx5/Kconfig +6 -0
index ccd96fd..80a749c 100644
@@ -8,4 +8,10 @@ config ARCH_MX51
 
 comment "MX5 platforms:"
 
+config MACH_MX51_BABBAGE
+	bool "Support MX51 BABBAGE platforms"
+	help
+	  Include support for MX51 Babbage platform. This includes specific
+	  configurations for the board and its peripherals.
+
 endif
arch/arm/mach-mx5/Makefile +2 -0
index d74ce4f..e4cf91f 100644
@@ -5,3 +5,5 @@
 # Object file lists.
 obj-y   := cpu.o mm.o clock.o devices.o
 
+obj-$(CONFIG_MACH_MX51_BABBAGE) += board-mx51_babbage.o
+
arch/arm/mach-mx5/board-mx51_babbage.c +0 -0

Uwe started to rename the board files on other i.MX platforms to mach-*.c. Can you do the same please?

Quoted 22 lines

new file mode 100644
index 0000000..6cd0e14

arch/arm/mach-mx5/board-mx51_babbage.c new file +17 -0
@@ -0,0 +1,99 @@
+/*
+ * Copyright 2009 Freescale Semiconductor, Inc. All Rights Reserved.
+ * Copyright (C) 2009-2010 Amit Kucheria <[email protected]>
+ *
+ * The code contained herein is licensed under the GNU General Public
+ * License. You may obtain a copy of the GNU General Public License
+ * Version 2 or later at the following locations:
+ *
+ * http://www.opensource.org/licenses/gpl-license.html
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+
+#include <linux/init.h>
+#include <linux/platform_device.h>
+
+#include <mach/common.h>
+#include <mach/hardware.h>

arch/arm/mach-mx5/board-mx51_babbage.c line 27

Quoted 10 lines
arch/arm/mach-mx5/board-mx51_babbage.c new file +10 -0
+#include <mach/imx-uart.h>
+#include <mach/iomux-mx51.h>
+
+#include <asm/irq.h>
+#include <asm/setup.h>
+#include <asm/mach-types.h>
+#include <asm/mach/arch.h>
+#include <asm/mach/time.h>
+
+#include "crm_regs.h"

Is this needed?

Quoted 77 lines
arch/arm/mach-mx5/board-mx51_babbage.c new file +72 -0
+#include "devices.h"
+
+static struct platform_device *devices[] __initdata = {
+	&mxc_fec_device,
+};
+
+static struct pad_desc mx51babbage_pads[] = {
+	/* UART1 */
+	MX51_BABBAGE_PAD_UART1_RXD__UART1_RXD,
+	MX51_BABBAGE_PAD_UART1_TXD__UART1_TXD,
+	MX51_BABBAGE_PAD_UART1_RTS__UART1_RTS,
+	MX51_BABBAGE_PAD_UART1_CTS__UART1_CTS,
+
+	/* UART2 */
+	MX51_BABBAGE_PAD_UART2_RXD__UART2_RXD,
+	MX51_BABBAGE_PAD_UART2_TXD__UART2_TXD,
+
+	/* UART3 */
+	MX51_BABBAGE_PAD_EIM_D25__UART3_RXD,
+	MX51_BABBAGE_PAD_EIM_D26__UART3_TXD,
+	MX51_BABBAGE_PAD_EIM_D27__UART3_RTS,
+	MX51_BABBAGE_PAD_EIM_D24__UART3_CTS,
+};
+
+/* Serial ports */
+#if defined(CONFIG_SERIAL_IMX) || defined(CONFIG_SERIAL_IMX_MODULE)
+static struct imxuart_platform_data uart_pdata = {
+	.flags = IMXUART_HAVE_RTSCTS,
+};
+
+static inline void mxc_init_imx_uart(void)
+{
+	mxc_register_device(&mxc_uart_device0, &uart_pdata);
+	mxc_register_device(&mxc_uart_device1, &uart_pdata);
+	mxc_register_device(&mxc_uart_device2, &uart_pdata);
+}
+#else /* !SERIAL_IMX */
+static inline void mxc_init_imx_uart(void)
+{
+}
+#endif /* SERIAL_IMX */
+
+/*
+ * Board specific initialization.
+ */
+static void __init mxc_board_init(void)
+{
+	mxc_iomux_v3_setup_multiple_pads(mx51babbage_pads,
+					ARRAY_SIZE(mx51babbage_pads));
+	mxc_init_imx_uart();
+	platform_add_devices(devices, ARRAY_SIZE(devices));
+}
+
+static void __init mx51_babbage_timer_init(void)
+{
+	mx51_clocks_init(32768, 24000000, 22579200, 24576000);
+}
+
+static struct sys_timer mxc_timer = {
+	.init	= mx51_babbage_timer_init,
+};
+
+MACHINE_START(MX51_BABBAGE, "Freescale MX51 Babbage Board")
+	/* Maintainer: Amit Kucheria <[email protected]> */
+	.phys_io = MX51_AIPS1_BASE_ADDR,
+	.io_pg_offst = ((MX51_AIPS1_BASE_ADDR_VIRT) >> 18) & 0xfffc,
+	.boot_params = PHYS_OFFSET + 0x100,
+	.map_io = mx51_map_io,
+	.init_irq = mx51_init_irq,
+	.init_machine = mxc_board_init,
+	.timer = &mxc_timer,
+MACHINE_END
arch/arm/plat-mxc/include/mach/common.h +0 -0
index 0a25576..33d4496 100644

arch/arm/plat-mxc/include/mach/common.h extern void mx27_map_io(void); · line 24

Quoted 4 lines
arch/arm/plat-mxc/include/mach/common.h +1 -0
@@ -21,6 +21,7 @@ extern void mx27_map_io(void);
 extern void mx31_map_io(void);
 extern void mx35_map_io(void);
 extern void mx51_map_io(void);
+extern void mx51_babbage_io_init(void);

Is this function used anywhere? I hope not...

Sascha

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

Re: [PATCHv2 05/11] mxc: Core support for i.MX5 series of processors from Freescale

In reply to Amit Kucheria
Quoted 245 lines · Amit Kucheria

From: Amit Kucheria <[email protected]>

Add basic clock support, cpu identification, I/O mapping and serial port.

---

?arch/arm/mach-mx5/clock.c ? ? ? ? ? ? ? ? ? ?| ?848 ++++++++++++++++++++++++++
?arch/arm/mach-mx5/cpu.c ? ? ? ? ? ? ? ? ? ? ?| ? 45 ++
?arch/arm/mach-mx5/crm_regs.h ? ? ? ? ? ? ? ? | ?583 ++++++++++++++++++
?arch/arm/mach-mx5/devices.c ? ? ? ? ? ? ? ? ?| ? 96 +++
?arch/arm/mach-mx5/devices.h ? ? ? ? ? ? ? ? ?| ? ?4 +
?arch/arm/mach-mx5/mm.c ? ? ? ? ? ? ? ? ? ? ? | ? 88 +++
?arch/arm/plat-mxc/include/mach/common.h ? ? ?| ? ?1 +
?arch/arm/plat-mxc/include/mach/debug-macro.S | ? ?4 +-
?arch/arm/plat-mxc/include/mach/iomux-mx51.h ?| ?340 +++++++++++
?arch/arm/plat-mxc/include/mach/mx51.h ? ? ? ?| ?454 ++++++++++++++

?10 files changed, 2461 insertions(+), 2 deletions(-) ?create mode 100644 arch/arm/mach-mx5/clock.c
?create mode 100644 arch/arm/mach-mx5/cpu.c
?create mode 100644 arch/arm/mach-mx5/crm_regs.h ?create mode 100644 arch/arm/mach-mx5/devices.c ?create mode 100644 arch/arm/mach-mx5/devices.h ?create mode 100644 arch/arm/mach-mx5/mm.c
?create mode 100644 arch/arm/plat-mxc/include/mach/iomux-mx51.h ?create mode 100644 arch/arm/plat-mxc/include/mach/mx51.h

arch/arm/mach-mx5/clock.c new file +213 -0
new file mode 100644
index 0000000..595f966
@@ -0,0 +1,848 @@
+/*
+ * Copyright 2008-2010 Freescale Semiconductor, Inc. All Rights Reserved.
+ * Copyright (C) 2009-2010 Amit Kucheria <[email protected]>
+ *
+ * The code contained herein is licensed under the GNU General Public
+ * License. You may obtain a copy of the GNU General Public License
+ * Version 2 or later at the following locations:
+ *
+ * http://www.opensource.org/licenses/gpl-license.html
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+
+#include <linux/mm.h>
+#include <linux/delay.h>
+#include <linux/clk.h>
+#include <linux/io.h>
+
+#include <asm/clkdev.h>
+
+#include <mach/hardware.h>
+#include <mach/common.h>
+#include <mach/clock.h>
+
+#include "crm_regs.h"
+
+static void __iomem *pll_base[] = {
+ ? ? ? MX51_DPLL1_BASE,
+ ? ? ? MX51_DPLL2_BASE,
+ ? ? ? MX51_DPLL3_BASE,
+};
+
+/* External clock values passed-in by the board code */
+static unsigned long external_high_reference, external_low_reference;
+static unsigned long oscillator_reference, ckih2_reference;
+
+static struct clk osc_clk;
+static struct clk pll1_main_clk;
+static struct clk pll1_sw_clk;
+static struct clk pll2_sw_clk;
+static struct clk pll3_sw_clk;
+static struct clk lp_apm_clk;
+static struct clk periph_apm_clk;
+static struct clk ahb_clk;
+static struct clk ipg_clk;
+
+#define MAX_DPLL_WAIT_TRIES ? ?1000 /* 1000 * udelay(1) = 1ms */
+
+static int _clk_ccgr_enable(struct clk *clk)
+{
+ ? ? ? u32 reg;
+
+ ? ? ? reg = __raw_readl(clk->enable_reg);
+ ? ? ? reg |= MXC_CCM_CCGRx_MOD_ON << clk->enable_shift;
+ ? ? ? __raw_writel(reg, clk->enable_reg);
+
+ ? ? ? return 0;
+}
+
+static void _clk_ccgr_disable(struct clk *clk)
+{
+ ? ? ? u32 reg;
+ ? ? ? reg = __raw_readl(clk->enable_reg);
+ ? ? ? reg &= ~(MXC_CCM_CCGRx_MOD_OFF << clk->enable_shift);
+ ? ? ? __raw_writel(reg, clk->enable_reg);
+
+}
+
+static void _clk_ccgr_disable_inwait(struct clk *clk)
+{
+ ? ? ? u32 reg;
+
+ ? ? ? reg = __raw_readl(clk->enable_reg);
+ ? ? ? reg &= ~(MXC_CCM_CCGRx_CG_MASK << clk->enable_shift);
+ ? ? ? reg |= MXC_CCM_CCGRx_MOD_IDLE << clk->enable_shift;
+ ? ? ? __raw_writel(reg, clk->enable_reg);
+}
+
+/*
+ * For the 4-to-1 muxed input clock
+ */
+static inline u32 _get_mux(struct clk *parent, struct clk *m0,
+ ? ? ? ? ? ? ? ? ? ? ? ? ?struct clk *m1, struct clk *m2, struct clk *m3)
+{
+ ? ? ? if (parent == m0)
+ ? ? ? ? ? ? ? return 0;
+ ? ? ? else if (parent == m1)
+ ? ? ? ? ? ? ? return 1;
+ ? ? ? else if (parent == m2)
+ ? ? ? ? ? ? ? return 2;
+ ? ? ? else if (parent == m3)
+ ? ? ? ? ? ? ? return 3;
+ ? ? ? else
+ ? ? ? ? ? ? ? BUG();
+
+ ? ? ? return -EINVAL;
+}
+
+static inline void __iomem *_get_pll_base(struct clk *pll)
+{
+ ? ? ? if (pll == &pll1_main_clk)
+ ? ? ? ? ? ? ? return pll_base[0];
+ ? ? ? else if (pll == &pll2_sw_clk)
+ ? ? ? ? ? ? ? return pll_base[1];
+ ? ? ? else if (pll == &pll3_sw_clk)
+ ? ? ? ? ? ? ? return pll_base[2];
+ ? ? ? else
+ ? ? ? ? ? ? ? BUG();
+
+ ? ? ? return NULL;
+}
+
+static unsigned long clk_pll_get_rate(struct clk *clk)
+{
+ ? ? ? long mfi, mfn, mfd, pdf, ref_clk, mfn_abs;
+ ? ? ? unsigned long dp_op, dp_mfd, dp_mfn, dp_ctl, pll_hfsm, dbl;
+ ? ? ? void __iomem *pllbase;
+ ? ? ? s64 temp;
+ ? ? ? unsigned long parent_rate;
+
+ ? ? ? parent_rate = clk_get_rate(clk->parent);
+
+ ? ? ? pllbase = _get_pll_base(clk);
+
+ ? ? ? dp_ctl = __raw_readl(pllbase + MXC_PLL_DP_CTL);
+ ? ? ? pll_hfsm = dp_ctl & MXC_PLL_DP_CTL_HFSM;
+ ? ? ? dbl = dp_ctl & MXC_PLL_DP_CTL_DPDCK0_2_EN;
+
+ ? ? ? if (pll_hfsm == 0) {
+ ? ? ? ? ? ? ? dp_op = __raw_readl(pllbase + MXC_PLL_DP_OP);
+ ? ? ? ? ? ? ? dp_mfd = __raw_readl(pllbase + MXC_PLL_DP_MFD);
+ ? ? ? ? ? ? ? dp_mfn = __raw_readl(pllbase + MXC_PLL_DP_MFN);
+ ? ? ? } else {
+ ? ? ? ? ? ? ? dp_op = __raw_readl(pllbase + MXC_PLL_DP_HFS_OP);
+ ? ? ? ? ? ? ? dp_mfd = __raw_readl(pllbase + MXC_PLL_DP_HFS_MFD);
+ ? ? ? ? ? ? ? dp_mfn = __raw_readl(pllbase + MXC_PLL_DP_HFS_MFN);
+ ? ? ? }
+ ? ? ? pdf = dp_op & MXC_PLL_DP_OP_PDF_MASK;
+ ? ? ? mfi = (dp_op & MXC_PLL_DP_OP_MFI_MASK) >> MXC_PLL_DP_OP_MFI_OFFSET;
+ ? ? ? mfi = (mfi <= 5) ? 5 : mfi;
+ ? ? ? mfd = dp_mfd & MXC_PLL_DP_MFD_MASK;
+ ? ? ? mfn = mfn_abs = dp_mfn & MXC_PLL_DP_MFN_MASK;
+ ? ? ? /* Sign extend to 32-bits */
+ ? ? ? if (mfn >= 0x04000000) {
+ ? ? ? ? ? ? ? mfn |= 0xFC000000;
+ ? ? ? ? ? ? ? mfn_abs = -mfn;
+ ? ? ? }
+
+ ? ? ? ref_clk = 2 * parent_rate;
+ ? ? ? if (dbl != 0)
+ ? ? ? ? ? ? ? ref_clk *= 2;
+
+ ? ? ? ref_clk /= (pdf + 1);
+ ? ? ? temp = (u64) ref_clk * mfn_abs;
+ ? ? ? do_div(temp, mfd + 1);
+ ? ? ? if (mfn < 0)
+ ? ? ? ? ? ? ? temp = -temp;
+ ? ? ? temp = (ref_clk * mfi) + temp;
+
+ ? ? ? return temp;
+}
+
+static int _clk_pll_set_rate(struct clk *clk, unsigned long rate)
+{
+ ? ? ? u32 reg;
+ ? ? ? void __iomem *pllbase;
+
+ ? ? ? long mfi, pdf, mfn, mfd = 999999;
+ ? ? ? s64 temp64;
+ ? ? ? unsigned long quad_parent_rate;
+ ? ? ? unsigned long pll_hfsm, dp_ctl;
+ ? ? ? unsigned long parent_rate;
+
+ ? ? ? parent_rate = clk_get_rate(clk->parent);
+
+ ? ? ? pllbase = _get_pll_base(clk);
+
+ ? ? ? quad_parent_rate = 4 * parent_rate;
+ ? ? ? pdf = mfi = -1;
+ ? ? ? while (++pdf < 16 && mfi < 5)
+ ? ? ? ? ? ? ? mfi = rate * (pdf+1) / quad_parent_rate;
+ ? ? ? if (mfi > 15)
+ ? ? ? ? ? ? ? return -1;
+ ? ? ? pdf--;
+
+ ? ? ? temp64 = rate * (pdf+1) - quad_parent_rate * mfi;
+ ? ? ? do_div(temp64, quad_parent_rate/1000000);
+ ? ? ? mfn = (long)temp64;
+
+ ? ? ? dp_ctl = __raw_readl(pllbase + MXC_PLL_DP_CTL);
+ ? ? ? /* use dpdck0_2 */
+ ? ? ? __raw_writel(dp_ctl | 0x1000L, pllbase + MXC_PLL_DP_CTL);
+ ? ? ? pll_hfsm = dp_ctl & MXC_PLL_DP_CTL_HFSM;
+ ? ? ? if (pll_hfsm == 0) {
+ ? ? ? ? ? ? ? reg = mfi << 4 | pdf;
+ ? ? ? ? ? ? ? __raw_writel(reg, pllbase + MXC_PLL_DP_OP);
+ ? ? ? ? ? ? ? __raw_writel(mfd, pllbase + MXC_PLL_DP_MFD);
+ ? ? ? ? ? ? ? __raw_writel(mfn, pllbase + MXC_PLL_DP_MFN);
+ ? ? ? } else {
+ ? ? ? ? ? ? ? reg = mfi << 4 | pdf;
+ ? ? ? ? ? ? ? __raw_writel(reg, pllbase + MXC_PLL_DP_HFS_OP);
+ ? ? ? ? ? ? ? __raw_writel(mfd, pllbase + MXC_PLL_DP_HFS_MFD);
+ ? ? ? ? ? ? ? __raw_writel(mfn, pllbase + MXC_PLL_DP_HFS_MFN);
+ ? ? ? }
+
+ ? ? ? return 0;
+}
+
+static int _clk_pll_enable(struct clk *clk)
+{
+ ? ? ? u32 reg;
+ ? ? ? void __iomem *pllbase;
+ ? ? ? int i = 0;
+

arch/arm/mach-mx5/clock.c line 223

Quoted 10 lines
arch/arm/mach-mx5/clock.c new file +10 -0
+ ? ? ? pllbase = _get_pll_base(clk);
+ ? ? ? reg = __raw_readl(pllbase + MXC_PLL_DP_CTL) | MXC_PLL_DP_CTL_UPEN;
+ ? ? ? __raw_writel(reg, pllbase + MXC_PLL_DP_CTL);
+
+ ? ? ? /* Wait for lock */
+ ? ? ? while ((!(__raw_readl(pllbase + MXC_PLL_DP_CTL) & MXC_PLL_DP_CTL_LRF))
+ ? ? ? ? ? ? ? && i < MAX_DPLL_WAIT_TRIES) {
+ ? ? ? ? ? ? ? i++;
+ ? ? ? ? ? ? ? udelay(1);
+ ? ? ? }

Mmm... this really hurts my eyes:

	do {
		v = __raw_readl(pllbase + MXC_PLL_DP_CTL)
		if (v & MXC_PLL_DP_CTL_LRF)
			break;
		
		udelay(1);
	} while (++i < MAX_DPLL_WAIT_TRIES);
Quoted 20 lines
arch/arm/mach-mx5/clock.c new file +20 -0
+
+ ? ? ? if (i == MAX_DPLL_WAIT_TRIES) {
+ ? ? ? ? ? ? ? printk(KERN_ERR "MX5: pll locking failed\n");
+ ? ? ? ? ? ? ? return -EINVAL;
+ ? ? ? }
+
+ ? ? ? return 0;
+}
+
+static void _clk_pll_disable(struct clk *clk)
+{
+ ? ? ? u32 reg;
+ ? ? ? void __iomem *pllbase;
+
+ ? ? ? pllbase = _get_pll_base(clk);
+ ? ? ? reg = __raw_readl(pllbase + MXC_PLL_DP_CTL) & ~MXC_PLL_DP_CTL_UPEN;
+ ? ? ? __raw_writel(reg, pllbase + MXC_PLL_DP_CTL);
+}
+
+static int _clk_pll1_sw_set_parent(struct clk *clk, struct clk *parent)

arch/arm/mach-mx5/clock.c line 253

Quoted 10 lines
arch/arm/mach-mx5/clock.c new file +10 -0
+{
+ ? ? ? u32 reg;
+
+ ? ? ? reg = __raw_readl(MXC_CCM_CCSR);
+
+ ? ? ? /* When switching from pll_main_clk to a bypass clock, first select a
+ ? ? ? ? ?multiplexed clock in 'step_sel', then shift the glitchless mux
+ ? ? ? ? ?'pll1_sw_clk_sel'.
+ ? ? ? ? ?When switching back, do it in reverse order
+ ? ? ? */

comment style ... not sure if this leaks apw's checkscripts, heh :)

Quoted 14 lines
arch/arm/mach-mx5/clock.c new file +14 -0
+ ? ? ? if (parent == &pll1_main_clk) {
+ ? ? ? ? ? ? ? /* Switch to pll1_main_clk */
+ ? ? ? ? ? ? ? reg &= ~MXC_CCM_CCSR_PLL1_SW_CLK_SEL;
+ ? ? ? ? ? ? ? __raw_writel(reg, MXC_CCM_CCSR);
+ ? ? ? ? ? ? ? /* step_clk mux switched to lp_apm, to save power. */
+ ? ? ? ? ? ? ? reg = __raw_readl(MXC_CCM_CCSR);
+ ? ? ? ? ? ? ? reg = (reg & ~MXC_CCM_CCSR_STEP_SEL_MASK) |
+ ? ? ? ? ? ? ? ? ? ? ? (MXC_CCM_CCSR_STEP_SEL_LP_APM <<
+ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? MXC_CCM_CCSR_STEP_SEL_OFFSET);
+ ? ? ? } else {
+ ? ? ? ? ? ? ? if (parent == &lp_apm_clk) {
+ ? ? ? ? ? ? ? ? ? ? ? reg = (reg & ~MXC_CCM_CCSR_STEP_SEL_MASK) |
+ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? (MXC_CCM_CCSR_STEP_SEL_LP_APM <<
+ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? MXC_CCM_CCSR_STEP_SEL_OFFSET);

arch/arm/mach-mx5/clock.c line 277

Quoted 10 lines
arch/arm/mach-mx5/clock.c new file +10 -0
+ ? ? ? ? ? ? ? } else ?if (parent == &pll2_sw_clk) {
+ ? ? ? ? ? ? ? ? ? ? ? reg = (reg & ~MXC_CCM_CCSR_STEP_SEL_MASK) |
+ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? (MXC_CCM_CCSR_STEP_SEL_PLL2_DIVIDED <<
+ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? MXC_CCM_CCSR_STEP_SEL_OFFSET);
+ ? ? ? ? ? ? ? } else ?if (parent == &pll3_sw_clk) {
+ ? ? ? ? ? ? ? ? ? ? ? reg = (reg & ~MXC_CCM_CCSR_STEP_SEL_MASK) |
+ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? (MXC_CCM_CCSR_STEP_SEL_PLL3_DIVIDED <<
+ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? MXC_CCM_CCSR_STEP_SEL_OFFSET);
+ ? ? ? ? ? ? ? } else
+ ? ? ? ? ? ? ? ? ? ? ? return -EINVAL;

Again, hurts my eyes:

		if (...)
			step = MXC_CCM_CCSR_STEP_SEL_LP_APM;
		else if (...)
			step = MXC_CCM_CCSR_STEP_SEL_PLL2_DIVIDED;
		else if (...)
			step = ...

		reg &= ~MXC_CCM_CCSR_STEP_SEL_MASK;
		reg |= step << MXC_CCM_CCSR_STEP_SEL_OFFSET;
		...
Quoted 153 lines
arch/arm/mach-mx5/clock.c new file +153 -0
+
+ ? ? ? ? ? ? ? __raw_writel(reg, MXC_CCM_CCSR);
+ ? ? ? ? ? ? ? /* Switch to step_clk */
+ ? ? ? ? ? ? ? reg = __raw_readl(MXC_CCM_CCSR);
+ ? ? ? ? ? ? ? reg |= MXC_CCM_CCSR_PLL1_SW_CLK_SEL;
+ ? ? ? }
+ ? ? ? __raw_writel(reg, MXC_CCM_CCSR);
+ ? ? ? return 0;
+}
+
+static unsigned long clk_pll1_sw_get_rate(struct clk *clk)
+{
+ ? ? ? u32 reg, div;
+ ? ? ? unsigned long parent_rate;
+
+ ? ? ? parent_rate = clk_get_rate(clk->parent);
+
+ ? ? ? div = 1;
+ ? ? ? reg = __raw_readl(MXC_CCM_CCSR);
+
+ ? ? ? if (clk->parent == &pll2_sw_clk) {
+ ? ? ? ? ? ? ? div = ((reg & MXC_CCM_CCSR_PLL2_PODF_MASK) >>
+ ? ? ? ? ? ? ? ? ? ? ?MXC_CCM_CCSR_PLL2_PODF_OFFSET) + 1;
+ ? ? ? } else if (clk->parent == &pll3_sw_clk) {
+ ? ? ? ? ? ? ? div = ((reg & MXC_CCM_CCSR_PLL3_PODF_MASK) >>
+ ? ? ? ? ? ? ? ? ? ? ?MXC_CCM_CCSR_PLL3_PODF_OFFSET) + 1;
+ ? ? ? }
+ ? ? ? return parent_rate / div;
+}
+
+static int _clk_pll2_sw_set_parent(struct clk *clk, struct clk *parent)
+{
+ ? ? ? u32 reg;
+
+ ? ? ? reg = __raw_readl(MXC_CCM_CCSR);
+
+ ? ? ? if (parent == &pll2_sw_clk)
+ ? ? ? ? ? ? ? reg &= ~MXC_CCM_CCSR_PLL2_SW_CLK_SEL;
+ ? ? ? else
+ ? ? ? ? ? ? ? reg |= MXC_CCM_CCSR_PLL2_SW_CLK_SEL;
+
+ ? ? ? __raw_writel(reg, MXC_CCM_CCSR);
+ ? ? ? return 0;
+}
+
+static int _clk_lp_apm_set_parent(struct clk *clk, struct clk *parent)
+{
+ ? ? ? u32 reg;
+
+ ? ? ? if (parent == &osc_clk)
+ ? ? ? ? ? ? ? reg = __raw_readl(MXC_CCM_CCSR) & ~MXC_CCM_CCSR_LP_APM_SEL;
+ ? ? ? else
+ ? ? ? ? ? ? ? return -EINVAL;
+
+ ? ? ? __raw_writel(reg, MXC_CCM_CCSR);
+
+ ? ? ? return 0;
+}
+
+static unsigned long clk_arm_get_rate(struct clk *clk)
+{
+ ? ? ? u32 cacrr, div;
+ ? ? ? unsigned long parent_rate;
+
+ ? ? ? parent_rate = clk_get_rate(clk->parent);
+ ? ? ? cacrr = __raw_readl(MXC_CCM_CACRR);
+ ? ? ? div = (cacrr & MXC_CCM_CACRR_ARM_PODF_MASK) + 1;
+
+ ? ? ? return parent_rate / div;
+}
+
+static int _clk_periph_apm_set_parent(struct clk *clk, struct clk *parent)
+{
+ ? ? ? u32 reg, mux;
+ ? ? ? int i = 0;
+
+ ? ? ? mux = _get_mux(parent, &pll1_sw_clk, &pll3_sw_clk, &lp_apm_clk, NULL);
+
+ ? ? ? reg = __raw_readl(MXC_CCM_CBCMR) & ~MXC_CCM_CBCMR_PERIPH_CLK_SEL_MASK;
+ ? ? ? reg |= mux << MXC_CCM_CBCMR_PERIPH_CLK_SEL_OFFSET;
+ ? ? ? __raw_writel(reg, MXC_CCM_CBCMR);
+
+ ? ? ? /* Wait for lock */
+ ? ? ? while ((__raw_readl(MXC_CCM_CDHIPR) & MXC_CCM_CDHIPR_PERIPH_CLK_SEL_BUSY)
+ ? ? ? ? ? ? ? && i < MAX_DPLL_WAIT_TRIES) {
+ ? ? ? ? ? ? ? i++;
+ ? ? ? ? ? ? ? udelay(1);
+ ? ? ? }
+
+ ? ? ? if (i == MAX_DPLL_WAIT_TRIES) {
+ ? ? ? ? ? ? ? printk(KERN_ERR "MX5: Set parent for periph_apm clock failed\n");
+ ? ? ? ? ? ? ? return -EINVAL;
+ ? ? ? }
+
+ ? ? ? return 0;
+}
+
+static unsigned long clk_main_bus_get_rate(struct clk *clk)
+{
+ ? ? ? return clk_get_rate(clk->parent);
+}
+
+static int _clk_main_bus_set_parent(struct clk *clk, struct clk *parent)
+{
+ ? ? ? u32 reg;
+
+ ? ? ? reg = __raw_readl(MXC_CCM_CBCDR);
+
+ ? ? ? if (parent == &pll2_sw_clk)
+ ? ? ? ? ? ? ? reg &= ~MXC_CCM_CBCDR_PERIPH_CLK_SEL;
+ ? ? ? else if (parent == &periph_apm_clk)
+ ? ? ? ? ? ? ? reg |= MXC_CCM_CBCDR_PERIPH_CLK_SEL;
+ ? ? ? else
+ ? ? ? ? ? ? ? return -EINVAL;
+
+ ? ? ? __raw_writel(reg, MXC_CCM_CBCDR);
+
+ ? ? ? return 0;
+}
+
+static struct clk main_bus_clk = {
+ ? ? ? .parent = &pll2_sw_clk,
+ ? ? ? .set_parent = _clk_main_bus_set_parent,
+ ? ? ? .get_rate = clk_main_bus_get_rate,
+};
+
+static unsigned long clk_ahb_get_rate(struct clk *clk)
+{
+ ? ? ? u32 reg, div;
+ ? ? ? unsigned long parent_rate;
+
+ ? ? ? parent_rate = clk_get_rate(clk->parent);
+
+ ? ? ? reg = __raw_readl(MXC_CCM_CBCDR);
+ ? ? ? div = ((reg & MXC_CCM_CBCDR_AHB_PODF_MASK) >>
+ ? ? ? ? ? ? ?MXC_CCM_CBCDR_AHB_PODF_OFFSET) + 1;
+ ? ? ? return parent_rate / div;
+}
+
+
+static int _clk_ahb_set_rate(struct clk *clk, unsigned long rate)
+{
+ ? ? ? u32 reg, div;
+ ? ? ? unsigned long parent_rate;
+ ? ? ? int i = 0;
+
+ ? ? ? parent_rate = clk_get_rate(clk->parent);
+
+ ? ? ? div = parent_rate / rate;
+ ? ? ? if (div > 8 || div < 1 || ((parent_rate / div) != rate))
+ ? ? ? ? ? ? ? return -EINVAL;
+
+ ? ? ? reg = __raw_readl(MXC_CCM_CBCDR);

arch/arm/mach-mx5/clock.c line 440

Quoted 10 lines
arch/arm/mach-mx5/clock.c new file +10 -0
+ ? ? ? reg &= ~MXC_CCM_CBCDR_AHB_PODF_MASK;
+ ? ? ? reg |= (div - 1) << MXC_CCM_CBCDR_AHB_PODF_OFFSET;
+ ? ? ? __raw_writel(reg, MXC_CCM_CBCDR);
+
+ ? ? ? /* Wait for lock */
+ ? ? ? while ((__raw_readl(MXC_CCM_CDHIPR) & MXC_CCM_CDHIPR_AHB_PODF_BUSY)
+ ? ? ? ? ? ? ? && i < MAX_DPLL_WAIT_TRIES) {
+ ? ? ? ? ? ? ? i++;
+ ? ? ? ? ? ? ? udelay(1);
+ ? ? ? }

Provided this loop sequence appears so many times here, maybe we can just invent a static inline function for this, e.g. dpll_wait_flags(register, flags)

Quoted 75 lines
arch/arm/mach-mx5/clock.c new file +75 -0
+
+ ? ? ? if (i == MAX_DPLL_WAIT_TRIES) {
+ ? ? ? ? ? ? ? printk(KERN_ERR "MX5: clk_ahb_set_rate failed\n");
+ ? ? ? ? ? ? ? return -EINVAL;
+ ? ? ? }
+
+ ? ? ? return 0;
+}
+
+static unsigned long _clk_ahb_round_rate(struct clk *clk,
+ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? unsigned long rate)
+{
+ ? ? ? u32 div;
+ ? ? ? unsigned long parent_rate;
+
+ ? ? ? parent_rate = clk_get_rate(clk->parent);
+
+ ? ? ? div = parent_rate / rate;
+ ? ? ? if (div > 8)
+ ? ? ? ? ? ? ? div = 8;
+ ? ? ? else if (div == 0)
+ ? ? ? ? ? ? ? div++;
+ ? ? ? return parent_rate / div;
+}
+
+
+static int _clk_max_enable(struct clk *clk)
+{
+ ? ? ? u32 reg;
+
+ ? ? ? _clk_ccgr_enable(clk);
+
+ ? ? ? /* Handshake with MAX when LPM is entered. */
+ ? ? ? reg = __raw_readl(MXC_CCM_CLPCR);
+ ? ? ? reg &= ~MXC_CCM_CLPCR_BYPASS_MAX_LPM_HS;
+ ? ? ? __raw_writel(reg, MXC_CCM_CLPCR);
+
+ ? ? ? return 0;
+}
+
+static void _clk_max_disable(struct clk *clk)
+{
+ ? ? ? u32 reg;
+
+ ? ? ? _clk_ccgr_disable_inwait(clk);
+
+ ? ? ? /* No Handshake with MAX when LPM is entered as its disabled. */
+ ? ? ? reg = __raw_readl(MXC_CCM_CLPCR);
+ ? ? ? reg |= MXC_CCM_CLPCR_BYPASS_MAX_LPM_HS;
+ ? ? ? __raw_writel(reg, MXC_CCM_CLPCR);
+}
+
+static unsigned long clk_ipg_get_rate(struct clk *clk)
+{
+ ? ? ? u32 reg, div;
+ ? ? ? unsigned long parent_rate;
+
+ ? ? ? parent_rate = clk_get_rate(clk->parent);
+
+ ? ? ? reg = __raw_readl(MXC_CCM_CBCDR);
+ ? ? ? div = ((reg & MXC_CCM_CBCDR_IPG_PODF_MASK) >>
+ ? ? ? ? ? ? ?MXC_CCM_CBCDR_IPG_PODF_OFFSET) + 1;
+
+ ? ? ? return parent_rate / div;
+}
+
+static unsigned long clk_ipg_per_get_rate(struct clk *clk)
+{
+ ? ? ? u32 reg, prediv1, prediv2, podf;
+ ? ? ? unsigned long parent_rate;
+
+ ? ? ? parent_rate = clk_get_rate(clk->parent);
+
+ ? ? ? if (clk->parent == &main_bus_clk || clk->parent == &lp_apm_clk) {
+ ? ? ? ? ? ? ? /* the main_bus_clk is the one before the DVFS engine */

arch/arm/mach-mx5/clock.c line 525

Quoted 10 lines
arch/arm/mach-mx5/clock.c new file +10 -0
+ ? ? ? ? ? ? ? reg = __raw_readl(MXC_CCM_CBCDR);
+ ? ? ? ? ? ? ? prediv1 = ((reg & MXC_CCM_CBCDR_PERCLK_PRED1_MASK) >>
+ ? ? ? ? ? ? ? ? ? ? ? ? ?MXC_CCM_CBCDR_PERCLK_PRED1_OFFSET) + 1;
+ ? ? ? ? ? ? ? prediv2 = ((reg & MXC_CCM_CBCDR_PERCLK_PRED2_MASK) >>
+ ? ? ? ? ? ? ? ? ? ? ? ? ?MXC_CCM_CBCDR_PERCLK_PRED2_OFFSET) + 1;
+ ? ? ? ? ? ? ? podf = ((reg & MXC_CCM_CBCDR_PERCLK_PODF_MASK) >>
+ ? ? ? ? ? ? ? ? ? ? ? MXC_CCM_CBCDR_PERCLK_PODF_OFFSET) + 1;
+ ? ? ? ? ? ? ? return parent_rate / (prediv1 * prediv2 * podf);
+ ? ? ? } else if (clk->parent == &ipg_clk) {
+ ? ? ? ? ? ? ? return parent_rate;

unnecessary braces

arch/arm/mach-mx5/clock.c line 527

Quoted 2 lines
arch/arm/mach-mx5/clock.c new file +2 -0
+ ? ? ? } else {
+ ? ? ? ? ? ? ? BUG();

ditto

Quoted 80 lines
arch/arm/mach-mx5/clock.c new file +80 -0
+ ? ? ? }
+}
+
+static int _clk_ipg_per_set_parent(struct clk *clk, struct clk *parent)
+{
+ ? ? ? u32 reg;
+
+ ? ? ? reg = __raw_readl(MXC_CCM_CBCMR);
+
+ ? ? ? reg &= ~MXC_CCM_CBCMR_PERCLK_LP_APM_CLK_SEL;
+ ? ? ? reg &= ~MXC_CCM_CBCMR_PERCLK_IPG_CLK_SEL;
+
+ ? ? ? if (parent == &ipg_clk)
+ ? ? ? ? ? ? ? reg |= MXC_CCM_CBCMR_PERCLK_IPG_CLK_SEL;
+ ? ? ? else if (parent == &lp_apm_clk)
+ ? ? ? ? ? ? ? reg |= MXC_CCM_CBCMR_PERCLK_LP_APM_CLK_SEL;
+ ? ? ? else if (parent != &main_bus_clk)
+ ? ? ? ? ? ? ? return -EINVAL;
+
+ ? ? ? __raw_writel(reg, MXC_CCM_CBCMR);
+
+ ? ? ? return 0;
+}
+
+static unsigned long clk_uart_get_rate(struct clk *clk)
+{
+ ? ? ? u32 reg, prediv, podf;
+ ? ? ? unsigned long parent_rate;
+
+ ? ? ? parent_rate = clk_get_rate(clk->parent);
+
+ ? ? ? reg = __raw_readl(MXC_CCM_CSCDR1);
+ ? ? ? prediv = ((reg & MXC_CCM_CSCDR1_UART_CLK_PRED_MASK) >>
+ ? ? ? ? ? ? ? ? MXC_CCM_CSCDR1_UART_CLK_PRED_OFFSET) + 1;
+ ? ? ? podf = ((reg & MXC_CCM_CSCDR1_UART_CLK_PODF_MASK) >>
+ ? ? ? ? ? ? ? MXC_CCM_CSCDR1_UART_CLK_PODF_OFFSET) + 1;
+
+ ? ? ? return parent_rate / (prediv * podf);
+}
+
+static int _clk_uart_set_parent(struct clk *clk, struct clk *parent)
+{
+ ? ? ? u32 reg, mux;
+
+ ? ? ? mux = _get_mux(parent, &pll1_sw_clk, &pll2_sw_clk, &pll3_sw_clk,
+ ? ? ? ? ? ? ? ? ? ? ?&lp_apm_clk);
+ ? ? ? reg = __raw_readl(MXC_CCM_CSCMR1) & ~MXC_CCM_CSCMR1_UART_CLK_SEL_MASK;
+ ? ? ? reg |= mux << MXC_CCM_CSCMR1_UART_CLK_SEL_OFFSET;
+ ? ? ? __raw_writel(reg, MXC_CCM_CSCMR1);
+
+ ? ? ? return 0;
+}
+
+static unsigned long get_high_reference_clock_rate(struct clk *clk)
+{
+ ? ? ? return external_high_reference;
+}
+
+static unsigned long get_low_reference_clock_rate(struct clk *clk)
+{
+ ? ? ? return external_low_reference;
+}
+
+static unsigned long get_oscillator_reference_clock_rate(struct clk *clk)
+{
+ ? ? ? return oscillator_reference;
+}
+
+static unsigned long get_ckih2_reference_clock_rate(struct clk *clk)
+{
+ ? ? ? return ckih2_reference;
+}
+
+/* External high frequency clock */
+static struct clk ckih_clk = {
+ ? ? ? .get_rate = get_high_reference_clock_rate,
+};
+
+static struct clk ckih2_clk = {
+ ? ? ? .get_rate = get_ckih2_reference_clock_rate,

arch/arm/mach-mx5/clock.c line 617

Quoted 10 lines
arch/arm/mach-mx5/clock.c new file +10 -0
+};
+
+static struct clk osc_clk = {
+ ? ? ? .get_rate = get_oscillator_reference_clock_rate,
+};
+
+/* External low frequency (32kHz) clock */
+static struct clk ckil_clk = {
+ ? ? ? .get_rate = get_low_reference_clock_rate,
+};

That's why Jerremy is coming up with a clk_fixed, to address exactly such awkward situations :)

Quoted 294 lines
arch/arm/mach-mx5/clock.c new file +231 -0
+
+static struct clk pll1_main_clk = {
+ ? ? ? .parent = &osc_clk,
+ ? ? ? .get_rate = clk_pll_get_rate,
+ ? ? ? .enable = _clk_pll_enable,
+ ? ? ? .disable = _clk_pll_disable,
+};
+
+/* Clock tree block diagram (WIP):
+ * ? ? CCM: Clock Controller Module
+ *
+ * PLL output -> |
+ * ? ? ? ? ? ? ? | CCM Switcher -> CCM_CLK_ROOT_GEN ->
+ * PLL bypass -> |
+ *
+ */
+
+/* PLL1 SW supplies to ARM core */
+static struct clk pll1_sw_clk = {
+ ? ? ? .parent = &pll1_main_clk,
+ ? ? ? .set_parent = _clk_pll1_sw_set_parent,
+ ? ? ? .get_rate = clk_pll1_sw_get_rate,
+};
+
+/* PLL2 SW supplies to AXI/AHB/IP buses */
+static struct clk pll2_sw_clk = {
+ ? ? ? .parent = &osc_clk,
+ ? ? ? .get_rate = clk_pll_get_rate,
+ ? ? ? .set_rate = _clk_pll_set_rate,
+ ? ? ? .set_parent = _clk_pll2_sw_set_parent,
+ ? ? ? .enable = _clk_pll_enable,
+ ? ? ? .disable = _clk_pll_disable,
+};
+
+/* PLL3 SW supplies to serial clocks like USB, SSI, etc. */
+static struct clk pll3_sw_clk = {
+ ? ? ? .parent = &osc_clk,
+ ? ? ? .set_rate = _clk_pll_set_rate,
+ ? ? ? .get_rate = clk_pll_get_rate,
+ ? ? ? .enable = _clk_pll_enable,
+ ? ? ? .disable = _clk_pll_disable,
+};
+
+/* Low-power Audio Playback Mode clock */
+static struct clk lp_apm_clk = {
+ ? ? ? .parent = &osc_clk,
+ ? ? ? .set_parent = _clk_lp_apm_set_parent,
+};
+
+static struct clk periph_apm_clk = {
+ ? ? ? .parent = &pll1_sw_clk,
+ ? ? ? .set_parent = _clk_periph_apm_set_parent,
+};
+
+static struct clk cpu_clk = {
+ ? ? ? .parent = &pll1_sw_clk,
+ ? ? ? .get_rate = clk_arm_get_rate,
+};
+
+static struct clk ahb_clk = {
+ ? ? ? .parent = &main_bus_clk,
+ ? ? ? .get_rate = clk_ahb_get_rate,
+ ? ? ? .set_rate = _clk_ahb_set_rate,
+ ? ? ? .round_rate = _clk_ahb_round_rate,
+};
+
+/* Main IP interface clock for access to registers */
+static struct clk ipg_clk = {
+ ? ? ? .parent = &ahb_clk,
+ ? ? ? .get_rate = clk_ipg_get_rate,
+};
+
+static struct clk ipg_perclk = {
+ ? ? ? .parent = &lp_apm_clk,
+ ? ? ? .get_rate = clk_ipg_per_get_rate,
+ ? ? ? .set_parent = _clk_ipg_per_set_parent,
+};
+
+static struct clk uart_root_clk = {
+ ? ? ? .parent = &pll2_sw_clk,
+ ? ? ? .get_rate = clk_uart_get_rate,
+ ? ? ? .set_parent = _clk_uart_set_parent,
+};
+
+static struct clk ahb_max_clk = {
+ ? ? ? .parent = &ahb_clk,
+ ? ? ? .enable_reg = MXC_CCM_CCGR0,
+ ? ? ? .enable_shift = MXC_CCM_CCGRx_CG14_OFFSET,
+ ? ? ? .enable = _clk_max_enable,
+ ? ? ? .disable = _clk_max_disable,
+};
+
+static struct clk aips_tz1_clk = {
+ ? ? ? .parent = &ahb_clk,
+ ? ? ? .secondary = &ahb_max_clk,
+ ? ? ? .enable_reg = MXC_CCM_CCGR0,
+ ? ? ? .enable_shift = MXC_CCM_CCGRx_CG12_OFFSET,
+ ? ? ? .enable = _clk_ccgr_enable,
+ ? ? ? .disable = _clk_ccgr_disable_inwait,
+};
+
+static struct clk aips_tz2_clk = {
+ ? ? ? .parent = &ahb_clk,
+ ? ? ? .secondary = &ahb_max_clk,
+ ? ? ? .enable_reg = MXC_CCM_CCGR0,
+ ? ? ? .enable_shift = MXC_CCM_CCGRx_CG13_OFFSET,
+ ? ? ? .enable = _clk_ccgr_enable,
+ ? ? ? .disable = _clk_ccgr_disable_inwait,
+};
+
+static struct clk gpt_32k_clk = {
+ ? ? ? .id = 0,
+ ? ? ? .parent = &ckil_clk,
+};
+
+#define DEFINE_CLOCK(name, i, er, es, gr, sr, p, s) ? ?\
+ ? ? ? static struct clk name = { ? ? ? ? ? ? ? ? ? ? ?\
+ ? ? ? ? ? ? ? .id ? ? ? ? ? ? = i, ? ? ? ? ? ? ? ? ? ?\
+ ? ? ? ? ? ? ? .enable_reg ? ? = er, ? ? ? ? ? ? ? ? ? \
+ ? ? ? ? ? ? ? .enable_shift ? = es, ? ? ? ? ? ? ? ? ? \
+ ? ? ? ? ? ? ? .get_rate ? ? ? = gr, ? ? ? ? ? ? ? ? ? \
+ ? ? ? ? ? ? ? .set_rate ? ? ? = sr, ? ? ? ? ? ? ? ? ? \
+ ? ? ? ? ? ? ? .enable ? ? ? ? = _clk_ccgr_enable, ? ? \
+ ? ? ? ? ? ? ? .disable ? ? ? ?= _clk_ccgr_disable, ? ?\
+ ? ? ? ? ? ? ? .parent ? ? ? ? = p, ? ? ? ? ? ? ? ? ? ?\
+ ? ? ? ? ? ? ? .secondary ? ? ?= s, ? ? ? ? ? ? ? ? ? ?\
+ ? ? ? }
+
+/* DEFINE_CLOCK(name, id, enable_reg, enable_shift,
+ ? get_rate, set_rate, parent, secondary); */
+
+/* Shared peripheral bus arbiter */
+DEFINE_CLOCK(spba_clk, 0, MXC_CCM_CCGR5, MXC_CCM_CCGRx_CG0_OFFSET,
+ ? ? ? NULL, ?NULL, &ipg_clk, NULL);
+
+/* UART */
+DEFINE_CLOCK(uart1_clk, 0, MXC_CCM_CCGR1, MXC_CCM_CCGRx_CG4_OFFSET,
+ ? ? ? NULL, ?NULL, &uart_root_clk, NULL);
+DEFINE_CLOCK(uart2_clk, 1, MXC_CCM_CCGR1, MXC_CCM_CCGRx_CG6_OFFSET,
+ ? ? ? NULL, ?NULL, &uart_root_clk, NULL);
+DEFINE_CLOCK(uart3_clk, 2, MXC_CCM_CCGR1, MXC_CCM_CCGRx_CG8_OFFSET,
+ ? ? ? NULL, ?NULL, &uart_root_clk, NULL);
+DEFINE_CLOCK(uart1_ipg_clk, 0, MXC_CCM_CCGR1, MXC_CCM_CCGRx_CG3_OFFSET,
+ ? ? ? NULL, ?NULL, &ipg_clk, &aips_tz1_clk);
+DEFINE_CLOCK(uart2_ipg_clk, 1, MXC_CCM_CCGR1, MXC_CCM_CCGRx_CG5_OFFSET,
+ ? ? ? NULL, ?NULL, &ipg_clk, &aips_tz1_clk);
+DEFINE_CLOCK(uart3_ipg_clk, 2, MXC_CCM_CCGR1, MXC_CCM_CCGRx_CG7_OFFSET,
+ ? ? ? NULL, ?NULL, &ipg_clk, &spba_clk);
+
+/* GPT */
+DEFINE_CLOCK(gpt_clk, 0, MXC_CCM_CCGR2, MXC_CCM_CCGRx_CG9_OFFSET,
+ ? ? ? NULL, ?NULL, &ipg_perclk, NULL);
+DEFINE_CLOCK(gpt_ipg_clk, 0, MXC_CCM_CCGR2, MXC_CCM_CCGRx_CG10_OFFSET,
+ ? ? ? NULL, ?NULL, &ipg_clk, NULL);
+
+/* FEC */
+DEFINE_CLOCK(fec_clk, 0, MXC_CCM_CCGR2, MXC_CCM_CCGRx_CG12_OFFSET,
+ ? ? ? NULL, ?NULL, &ipg_clk, NULL);
+
+#define _REGISTER_CLOCK(d, n, c) \
+ ? ? ? { \
+ ? ? ? ? ? ? ? .dev_id = d, \
+ ? ? ? ? ? ? ? .con_id = n, \
+ ? ? ? ? ? ? ? .clk = &c, ? \
+ ? ? ? },
+
+static struct clk_lookup lookups[] __initdata = {
+ ? ? ? _REGISTER_CLOCK("imx-uart.0", NULL, uart1_clk)
+ ? ? ? _REGISTER_CLOCK("imx-uart.1", NULL, uart2_clk)
+ ? ? ? _REGISTER_CLOCK("imx-uart.2", NULL, uart3_clk)
+ ? ? ? _REGISTER_CLOCK(NULL, "gpt", gpt_clk)
+ ? ? ? _REGISTER_CLOCK("fec.0", NULL, fec_clk)
+};
+
+static void clk_tree_init(void)
+{
+ ? ? ? u32 reg;
+
+ ? ? ? ipg_perclk.set_parent(&ipg_perclk, &lp_apm_clk);
+
+ ? ? ? /*
+ ? ? ? ?* Initialise the IPG PER CLK dividers to 3. IPG_PER_CLK should be at
+ ? ? ? ?* 8MHz, its derived from lp_apm.
+ ? ? ? ?* FIXME: Verify if true for all boards
+ ? ? ? ?*/
+ ? ? ? reg = __raw_readl(MXC_CCM_CBCDR);
+ ? ? ? reg &= ~MXC_CCM_CBCDR_PERCLK_PRED1_MASK;
+ ? ? ? reg &= ~MXC_CCM_CBCDR_PERCLK_PRED2_MASK;
+ ? ? ? reg &= ~MXC_CCM_CBCDR_PERCLK_PODF_MASK;
+ ? ? ? reg |= (2 << MXC_CCM_CBCDR_PERCLK_PRED1_OFFSET);
+ ? ? ? __raw_writel(reg, MXC_CCM_CBCDR);
+
+ ? ? ? /* set parent for pll1, pll2 and pll3 */
+ ? ? ? pll1_main_clk.parent = &osc_clk;
+ ? ? ? pll2_sw_clk.parent = &osc_clk;
+ ? ? ? pll3_sw_clk.parent = &osc_clk;
+
+ ? ? ? /* set ipg_perclk parent */
+ ? ? ? ipg_perclk.parent = &lp_apm_clk;
+ ? ? ? reg = __raw_readl(MXC_CCM_CBCMR);
+ ? ? ? if ((reg & MXC_CCM_CBCMR_PERCLK_IPG_CLK_SEL) != 0) {
+ ? ? ? ? ? ? ? ipg_perclk.parent = &ipg_clk;
+ ? ? ? } else {
+ ? ? ? ? ? ? ? if ((reg & MXC_CCM_CBCMR_PERCLK_LP_APM_CLK_SEL) == 0)
+ ? ? ? ? ? ? ? ? ? ? ? ipg_perclk.parent = &main_bus_clk;
+ ? ? ? }
+}
+
+int __init mx51_clocks_init(unsigned long ckil, unsigned long osc,
+ ? ? ? ? ? ? ? ? ? ? ? unsigned long ckih1, unsigned long ckih2)
+{
+ ? ? ? int i;
+
+ ? ? ? external_low_reference = ckil;
+ ? ? ? external_high_reference = ckih1;
+ ? ? ? ckih2_reference = ckih2;
+ ? ? ? oscillator_reference = osc;
+
+ ? ? ? for (i = 0; i < ARRAY_SIZE(lookups); i++)
+ ? ? ? ? ? ? ? clkdev_add(&lookups[i]);
+
+ ? ? ? clk_tree_init();
+
+ ? ? ? clk_enable(&cpu_clk);
+ ? ? ? clk_enable(&main_bus_clk);
+
+ ? ? ? /* System timer */
+ ? ? ? mxc_timer_init(&gpt_clk, MX51_IO_ADDRESS(MX51_GPT1_BASE_ADDR),
+ ? ? ? ? ? ? ? MX51_MXC_INT_GPT);
+ ? ? ? return 0;
+}
arch/arm/mach-mx5/cpu.c new file +45 -0
new file mode 100644
index 0000000..93f1d5a
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2008-2009 Freescale Semiconductor, Inc. All Rights Reserved.
+ *
+ * The code contained herein is licensed under the GNU General Public
+ * License. You may obtain a copy of the GNU General Public License
+ * Version 2 or later at the following locations:
+ *
+ * http://www.opensource.org/licenses/gpl-license.html
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ * This file contains the CPU initialization code.
+ */
+
+#include <linux/types.h>
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <mach/hardware.h>
+#include <asm/io.h>
+
+static int __init post_cpu_init(void)
+{
+ ? ? ? unsigned int reg;
+ ? ? ? void __iomem *base;
+
+ ? ? ? if (cpu_is_mx51()) {
+ ? ? ? ? ? ? ? base = MX51_IO_ADDRESS(MX51_AIPS1_BASE_ADDR);
+ ? ? ? ? ? ? ? __raw_writel(0x0, base + 0x40);
+ ? ? ? ? ? ? ? __raw_writel(0x0, base + 0x44);
+ ? ? ? ? ? ? ? __raw_writel(0x0, base + 0x48);
+ ? ? ? ? ? ? ? __raw_writel(0x0, base + 0x4C);
+ ? ? ? ? ? ? ? reg = __raw_readl(base + 0x50) & 0x00FFFFFF;
+ ? ? ? ? ? ? ? __raw_writel(reg, base + 0x50);
+
+ ? ? ? ? ? ? ? base = MX51_IO_ADDRESS(MX51_AIPS2_BASE_ADDR);
+ ? ? ? ? ? ? ? __raw_writel(0x0, base + 0x40);
+ ? ? ? ? ? ? ? __raw_writel(0x0, base + 0x44);
+ ? ? ? ? ? ? ? __raw_writel(0x0, base + 0x48);
+ ? ? ? ? ? ? ? __raw_writel(0x0, base + 0x4C);
+ ? ? ? ? ? ? ? reg = __raw_readl(base + 0x50) & 0x00FFFFFF;
+ ? ? ? ? ? ? ? __raw_writel(reg, base + 0x50);
+ ? ? ? }
+ ? ? ? return 0;
+}
+
+postcore_initcall(post_cpu_init);
arch/arm/mach-mx5/crm_regs.h new file +6 -0
new file mode 100644
index 0000000..c776b9a
@@ -0,0 +1,583 @@
+/*
+ * Copyright 2008-2009 Freescale Semiconductor, Inc. All Rights Reserved.
+ *
+ * The code contained herein is licensed under the GNU General Public
+ * License. You may obtain a copy of the GNU General Public License
+ * Version 2 or later at the following locations:

arch/arm/mach-mx5/crm_regs.h line 16

Quoted 10 lines
arch/arm/mach-mx5/crm_regs.h new file +10 -0
+ *
+ * http://www.opensource.org/licenses/gpl-license.html
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+#ifndef __ARCH_ARM_MACH_MX51_CRM_REGS_H__
+#define __ARCH_ARM_MACH_MX51_CRM_REGS_H__
+
+#define MX51_CCM_BASE ? ? ? ? ?MX51_IO_ADDRESS(MX51_CCM_BASE_ADDR)
+#define MX51_DPLL1_BASE ? ? ? ? ? ? ? ?MX51_IO_ADDRESS(MX51_PLL1_BASE_ADDR)
+#define MX51_DPLL2_BASE ? ? ? ? ? ? ? ?MX51_IO_ADDRESS(MX51_PLL2_BASE_ADDR)

.... skipping register definitions ....

Quoted 173 lines
arch/arm/mach-mx5/crm_regs.h new file +4 -0
+#define MXC_SRPGC_EMI_PUPSCR ? (MXC_SRPGC_EMI_BASE + 0x4)
+#define MXC_SRPGC_EMI_PDNSCR ? (MXC_SRPGC_EMI_BASE + 0x8)
+
+#endif ? ? ? ? ? ? ? ? ? ? ? ? /* __ARCH_ARM_MACH_MX51_CRM_REGS_H__ */
arch/arm/mach-mx5/devices.c new file +96 -0
new file mode 100644
index 0000000..55eb089
@@ -0,0 +1,96 @@
+/*
+ * Copyright 2009 Amit Kucheria <[email protected]>
+ *
+ * The code contained herein is licensed under the GNU General Public
+ * License. You may obtain a copy of the GNU General Public License
+ * Version 2 or later at the following locations:
+ *
+ * http://www.opensource.org/licenses/gpl-license.html
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+
+#include <linux/platform_device.h>
+#include <mach/hardware.h>
+#include <mach/imx-uart.h>
+
+static struct resource uart0[] = {
+ ? ? ? {
+ ? ? ? ? ? ? ? .start = MX51_UART1_BASE_ADDR,
+ ? ? ? ? ? ? ? .end = MX51_UART1_BASE_ADDR + 0x0B5,
+ ? ? ? ? ? ? ? .flags = IORESOURCE_MEM,
+ ? ? ? }, {
+ ? ? ? ? ? ? ? .start = MX51_MXC_INT_UART1,
+ ? ? ? ? ? ? ? .end = MX51_MXC_INT_UART1,
+ ? ? ? ? ? ? ? .flags = IORESOURCE_IRQ,
+ ? ? ? },
+};
+
+struct platform_device mxc_uart_device0 = {
+ ? ? ? .name = "imx-uart",
+ ? ? ? .id = 0,
+ ? ? ? .resource = uart0,
+ ? ? ? .num_resources = ARRAY_SIZE(uart0),
+};
+
+static struct resource uart1[] = {
+ ? ? ? {
+ ? ? ? ? ? ? ? .start = MX51_UART2_BASE_ADDR,
+ ? ? ? ? ? ? ? .end = MX51_UART2_BASE_ADDR + 0x0B5,
+ ? ? ? ? ? ? ? .flags = IORESOURCE_MEM,
+ ? ? ? }, {
+ ? ? ? ? ? ? ? .start = MX51_MXC_INT_UART2,
+ ? ? ? ? ? ? ? .end = MX51_MXC_INT_UART2,
+ ? ? ? ? ? ? ? .flags = IORESOURCE_IRQ,
+ ? ? ? },
+};
+
+struct platform_device mxc_uart_device1 = {
+ ? ? ? .name = "imx-uart",
+ ? ? ? .id = 1,
+ ? ? ? .resource = uart1,
+ ? ? ? .num_resources = ARRAY_SIZE(uart1),
+};
+
+static struct resource uart2[] = {
+ ? ? ? {
+ ? ? ? ? ? ? ? .start = MX51_UART3_BASE_ADDR,
+ ? ? ? ? ? ? ? .end = MX51_UART3_BASE_ADDR + 0x0B5,
+ ? ? ? ? ? ? ? .flags = IORESOURCE_MEM,
+ ? ? ? }, {
+ ? ? ? ? ? ? ? .start = MX51_MXC_INT_UART3,
+ ? ? ? ? ? ? ? .end = MX51_MXC_INT_UART3,
+ ? ? ? ? ? ? ? .flags = IORESOURCE_IRQ,
+ ? ? ? },
+};
+
+struct platform_device mxc_uart_device2 = {
+ ? ? ? .name = "imx-uart",
+ ? ? ? .id = 2,
+ ? ? ? .resource = uart2,
+ ? ? ? .num_resources = ARRAY_SIZE(uart2),
+};
+
+static struct resource mxc_fec_resources[] = {
+ ? ? ? {
+ ? ? ? ? ? ? ? .start ?= MX51_MXC_FEC_BASE_ADDR,
+ ? ? ? ? ? ? ? .end ? ?= MX51_MXC_FEC_BASE_ADDR + 0xfff,
+ ? ? ? ? ? ? ? .flags ?= IORESOURCE_MEM,
+ ? ? ? }, {
+ ? ? ? ? ? ? ? .start ?= MX51_MXC_INT_FEC,
+ ? ? ? ? ? ? ? .end ? ?= MX51_MXC_INT_FEC,
+ ? ? ? ? ? ? ? .flags ?= IORESOURCE_IRQ,
+ ? ? ? },
+};
+
+struct platform_device mxc_fec_device = {
+ ? ? ? .name = "fec",
+ ? ? ? .id = 0,
+ ? ? ? .num_resources = ARRAY_SIZE(mxc_fec_resources),
+ ? ? ? .resource = mxc_fec_resources,
+};
+
+/* Dummy definition to allow compiling in AVIC and TZIC simultaneously */
+int __init mxc_register_gpios(void)
+{
+ ? ? ? return 0;
+}
arch/arm/mach-mx5/devices.h new file +4 -0
new file mode 100644
index 0000000..f339ab8
@@ -0,0 +1,4 @@
+extern struct platform_device mxc_uart_device0;
+extern struct platform_device mxc_uart_device1;
+extern struct platform_device mxc_uart_device2;
+extern struct platform_device mxc_fec_device;
arch/arm/mach-mx5/mm.c new file +51 -0
new file mode 100644
index 0000000..d66c31a
@@ -0,0 +1,88 @@
+/*
+ * Copyright 2008-2009 Freescale Semiconductor, Inc. All Rights Reserved.
+ *
+ * The code contained herein is licensed under the GNU General Public
+ * License. ?You may obtain a copy of the GNU General Public License
+ * Version 2 or later at the following locations:
+ *
+ * http://www.opensource.org/licenses/gpl-license.html
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ * Create static mapping between physical to virtual memory.
+ */
+
+#include <linux/mm.h>
+#include <linux/init.h>
+
+#include <asm/mach/map.h>
+
+#include <mach/hardware.h>
+#include <mach/common.h>
+#include <mach/iomux-v3.h>
+
+/*
+ * Define the MX51 memory map.
+ */
+static struct map_desc mxc_io_desc[] __initdata = {
+ ? ? ? {
+ ? ? ? ?.virtual = MX51_IRAM_BASE_ADDR_VIRT,
+ ? ? ? ?.pfn = __phys_to_pfn(MX51_IRAM_BASE_ADDR),
+ ? ? ? ?.length = MX51_IRAM_SIZE,
+ ? ? ? ?.type = MT_DEVICE},
+ ? ? ? {
+ ? ? ? ?.virtual = MX51_DEBUG_BASE_ADDR_VIRT,
+ ? ? ? ?.pfn = __phys_to_pfn(MX51_DEBUG_BASE_ADDR),
+ ? ? ? ?.length = MX51_DEBUG_SIZE,
+ ? ? ? ?.type = MT_DEVICE},
+ ? ? ? {
+ ? ? ? ?.virtual = MX51_TZIC_BASE_ADDR_VIRT,
+ ? ? ? ?.pfn = __phys_to_pfn(MX51_TZIC_BASE_ADDR),
+ ? ? ? ?.length = MX51_TZIC_SIZE,
+ ? ? ? ?.type = MT_DEVICE},
+ ? ? ? {
+ ? ? ? ?.virtual = MX51_AIPS1_BASE_ADDR_VIRT,
+ ? ? ? ?.pfn = __phys_to_pfn(MX51_AIPS1_BASE_ADDR),
+ ? ? ? ?.length = MX51_AIPS1_SIZE,
+ ? ? ? ?.type = MT_DEVICE},
+ ? ? ? {
+ ? ? ? ?.virtual = MX51_SPBA0_BASE_ADDR_VIRT,
+ ? ? ? ?.pfn = __phys_to_pfn(MX51_SPBA0_BASE_ADDR),
+ ? ? ? ?.length = MX51_SPBA0_SIZE,
+ ? ? ? ?.type = MT_DEVICE},

arch/arm/mach-mx5/mm.c line 61

Quoted 10 lines
arch/arm/mach-mx5/mm.c new file +10 -0
+ ? ? ? {
+ ? ? ? ?.virtual = MX51_AIPS2_BASE_ADDR_VIRT,
+ ? ? ? ?.pfn = __phys_to_pfn(MX51_AIPS2_BASE_ADDR),
+ ? ? ? ?.length = MX51_AIPS2_SIZE,
+ ? ? ? ?.type = MT_DEVICE},
+ ? ? ? {
+ ? ? ? ?.virtual = MX51_NFC_AXI_BASE_ADDR_VIRT,
+ ? ? ? ?.pfn = __phys_to_pfn(MX51_NFC_AXI_BASE_ADDR),
+ ? ? ? ?.length = MX51_NFC_AXI_SIZE,
+ ? ? ? ?.type = MT_DEVICE},

Weird alignment, guess due to leading white spaces?

.... skipping the rest ....

#19 lore raw

Re: [PATCHv2 05/11] mxc: Core support for i.MX5 series of processors from Freescale

Quoted 262 lines · Eric Miao
Quoted 245 lines · Amit Kucheria

From: Amit Kucheria <[email protected]>

Add basic clock support, cpu identification, I/O mapping and serial port.

---

?arch/arm/mach-mx5/clock.c ? ? ? ? ? ? ? ? ? ?| ?848 ++++++++++++++++++++++++++
?arch/arm/mach-mx5/cpu.c ? ? ? ? ? ? ? ? ? ? ?| ? 45 ++
?arch/arm/mach-mx5/crm_regs.h ? ? ? ? ? ? ? ? | ?583 ++++++++++++++++++
?arch/arm/mach-mx5/devices.c ? ? ? ? ? ? ? ? ?| ? 96 +++
?arch/arm/mach-mx5/devices.h ? ? ? ? ? ? ? ? ?| ? ?4 +
?arch/arm/mach-mx5/mm.c ? ? ? ? ? ? ? ? ? ? ? | ? 88 +++
?arch/arm/plat-mxc/include/mach/common.h ? ? ?| ? ?1 +
?arch/arm/plat-mxc/include/mach/debug-macro.S | ? ?4 +-
?arch/arm/plat-mxc/include/mach/iomux-mx51.h ?| ?340 +++++++++++
?arch/arm/plat-mxc/include/mach/mx51.h ? ? ? ?| ?454 ++++++++++++++

?10 files changed, 2461 insertions(+), 2 deletions(-) ?create mode 100644 arch/arm/mach-mx5/clock.c
?create mode 100644 arch/arm/mach-mx5/cpu.c
?create mode 100644 arch/arm/mach-mx5/crm_regs.h ?create mode 100644 arch/arm/mach-mx5/devices.c ?create mode 100644 arch/arm/mach-mx5/devices.h ?create mode 100644 arch/arm/mach-mx5/mm.c
?create mode 100644 arch/arm/plat-mxc/include/mach/iomux-mx51.h ?create mode 100644 arch/arm/plat-mxc/include/mach/mx51.h

arch/arm/mach-mx5/clock.c new file +213 -0
new file mode 100644
index 0000000..595f966
@@ -0,0 +1,848 @@
+/*
+ * Copyright 2008-2010 Freescale Semiconductor, Inc. All Rights Reserved.
+ * Copyright (C) 2009-2010 Amit Kucheria <[email protected]>
+ *
+ * The code contained herein is licensed under the GNU General Public
+ * License. You may obtain a copy of the GNU General Public License
+ * Version 2 or later at the following locations:
+ *
+ * http://www.opensource.org/licenses/gpl-license.html
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+
+#include <linux/mm.h>
+#include <linux/delay.h>
+#include <linux/clk.h>
+#include <linux/io.h>
+
+#include <asm/clkdev.h>
+
+#include <mach/hardware.h>
+#include <mach/common.h>
+#include <mach/clock.h>
+
+#include "crm_regs.h"
+
+static void __iomem *pll_base[] = {
+ ? ? ? MX51_DPLL1_BASE,
+ ? ? ? MX51_DPLL2_BASE,
+ ? ? ? MX51_DPLL3_BASE,
+};
+
+/* External clock values passed-in by the board code */
+static unsigned long external_high_reference, external_low_reference;
+static unsigned long oscillator_reference, ckih2_reference;
+
+static struct clk osc_clk;
+static struct clk pll1_main_clk;
+static struct clk pll1_sw_clk;
+static struct clk pll2_sw_clk;
+static struct clk pll3_sw_clk;
+static struct clk lp_apm_clk;
+static struct clk periph_apm_clk;
+static struct clk ahb_clk;
+static struct clk ipg_clk;
+
+#define MAX_DPLL_WAIT_TRIES ? ?1000 /* 1000 * udelay(1) = 1ms */
+
+static int _clk_ccgr_enable(struct clk *clk)
+{
+ ? ? ? u32 reg;
+
+ ? ? ? reg = __raw_readl(clk->enable_reg);
+ ? ? ? reg |= MXC_CCM_CCGRx_MOD_ON << clk->enable_shift;
+ ? ? ? __raw_writel(reg, clk->enable_reg);
+
+ ? ? ? return 0;
+}
+
+static void _clk_ccgr_disable(struct clk *clk)
+{
+ ? ? ? u32 reg;
+ ? ? ? reg = __raw_readl(clk->enable_reg);
+ ? ? ? reg &= ~(MXC_CCM_CCGRx_MOD_OFF << clk->enable_shift);
+ ? ? ? __raw_writel(reg, clk->enable_reg);
+
+}
+
+static void _clk_ccgr_disable_inwait(struct clk *clk)
+{
+ ? ? ? u32 reg;
+
+ ? ? ? reg = __raw_readl(clk->enable_reg);
+ ? ? ? reg &= ~(MXC_CCM_CCGRx_CG_MASK << clk->enable_shift);
+ ? ? ? reg |= MXC_CCM_CCGRx_MOD_IDLE << clk->enable_shift;
+ ? ? ? __raw_writel(reg, clk->enable_reg);
+}
+
+/*
+ * For the 4-to-1 muxed input clock
+ */
+static inline u32 _get_mux(struct clk *parent, struct clk *m0,
+ ? ? ? ? ? ? ? ? ? ? ? ? ?struct clk *m1, struct clk *m2, struct clk *m3)
+{
+ ? ? ? if (parent == m0)
+ ? ? ? ? ? ? ? return 0;
+ ? ? ? else if (parent == m1)
+ ? ? ? ? ? ? ? return 1;
+ ? ? ? else if (parent == m2)
+ ? ? ? ? ? ? ? return 2;
+ ? ? ? else if (parent == m3)
+ ? ? ? ? ? ? ? return 3;
+ ? ? ? else
+ ? ? ? ? ? ? ? BUG();
+
+ ? ? ? return -EINVAL;
+}
+
+static inline void __iomem *_get_pll_base(struct clk *pll)
+{
+ ? ? ? if (pll == &pll1_main_clk)
+ ? ? ? ? ? ? ? return pll_base[0];
+ ? ? ? else if (pll == &pll2_sw_clk)
+ ? ? ? ? ? ? ? return pll_base[1];
+ ? ? ? else if (pll == &pll3_sw_clk)
+ ? ? ? ? ? ? ? return pll_base[2];
+ ? ? ? else
+ ? ? ? ? ? ? ? BUG();
+
+ ? ? ? return NULL;
+}
+
+static unsigned long clk_pll_get_rate(struct clk *clk)
+{
+ ? ? ? long mfi, mfn, mfd, pdf, ref_clk, mfn_abs;
+ ? ? ? unsigned long dp_op, dp_mfd, dp_mfn, dp_ctl, pll_hfsm, dbl;
+ ? ? ? void __iomem *pllbase;
+ ? ? ? s64 temp;
+ ? ? ? unsigned long parent_rate;
+
+ ? ? ? parent_rate = clk_get_rate(clk->parent);
+
+ ? ? ? pllbase = _get_pll_base(clk);
+
+ ? ? ? dp_ctl = __raw_readl(pllbase + MXC_PLL_DP_CTL);
+ ? ? ? pll_hfsm = dp_ctl & MXC_PLL_DP_CTL_HFSM;
+ ? ? ? dbl = dp_ctl & MXC_PLL_DP_CTL_DPDCK0_2_EN;
+
+ ? ? ? if (pll_hfsm == 0) {
+ ? ? ? ? ? ? ? dp_op = __raw_readl(pllbase + MXC_PLL_DP_OP);
+ ? ? ? ? ? ? ? dp_mfd = __raw_readl(pllbase + MXC_PLL_DP_MFD);
+ ? ? ? ? ? ? ? dp_mfn = __raw_readl(pllbase + MXC_PLL_DP_MFN);
+ ? ? ? } else {
+ ? ? ? ? ? ? ? dp_op = __raw_readl(pllbase + MXC_PLL_DP_HFS_OP);
+ ? ? ? ? ? ? ? dp_mfd = __raw_readl(pllbase + MXC_PLL_DP_HFS_MFD);
+ ? ? ? ? ? ? ? dp_mfn = __raw_readl(pllbase + MXC_PLL_DP_HFS_MFN);
+ ? ? ? }
+ ? ? ? pdf = dp_op & MXC_PLL_DP_OP_PDF_MASK;
+ ? ? ? mfi = (dp_op & MXC_PLL_DP_OP_MFI_MASK) >> MXC_PLL_DP_OP_MFI_OFFSET;
+ ? ? ? mfi = (mfi <= 5) ? 5 : mfi;
+ ? ? ? mfd = dp_mfd & MXC_PLL_DP_MFD_MASK;
+ ? ? ? mfn = mfn_abs = dp_mfn & MXC_PLL_DP_MFN_MASK;
+ ? ? ? /* Sign extend to 32-bits */
+ ? ? ? if (mfn >= 0x04000000) {
+ ? ? ? ? ? ? ? mfn |= 0xFC000000;
+ ? ? ? ? ? ? ? mfn_abs = -mfn;
+ ? ? ? }
+
+ ? ? ? ref_clk = 2 * parent_rate;
+ ? ? ? if (dbl != 0)
+ ? ? ? ? ? ? ? ref_clk *= 2;
+
+ ? ? ? ref_clk /= (pdf + 1);
+ ? ? ? temp = (u64) ref_clk * mfn_abs;
+ ? ? ? do_div(temp, mfd + 1);
+ ? ? ? if (mfn < 0)
+ ? ? ? ? ? ? ? temp = -temp;
+ ? ? ? temp = (ref_clk * mfi) + temp;
+
+ ? ? ? return temp;
+}
+
+static int _clk_pll_set_rate(struct clk *clk, unsigned long rate)
+{
+ ? ? ? u32 reg;
+ ? ? ? void __iomem *pllbase;
+
+ ? ? ? long mfi, pdf, mfn, mfd = 999999;
+ ? ? ? s64 temp64;
+ ? ? ? unsigned long quad_parent_rate;
+ ? ? ? unsigned long pll_hfsm, dp_ctl;
+ ? ? ? unsigned long parent_rate;
+
+ ? ? ? parent_rate = clk_get_rate(clk->parent);
+
+ ? ? ? pllbase = _get_pll_base(clk);
+
+ ? ? ? quad_parent_rate = 4 * parent_rate;
+ ? ? ? pdf = mfi = -1;
+ ? ? ? while (++pdf < 16 && mfi < 5)
+ ? ? ? ? ? ? ? mfi = rate * (pdf+1) / quad_parent_rate;
+ ? ? ? if (mfi > 15)
+ ? ? ? ? ? ? ? return -1;
+ ? ? ? pdf--;
+
+ ? ? ? temp64 = rate * (pdf+1) - quad_parent_rate * mfi;
+ ? ? ? do_div(temp64, quad_parent_rate/1000000);
+ ? ? ? mfn = (long)temp64;
+
+ ? ? ? dp_ctl = __raw_readl(pllbase + MXC_PLL_DP_CTL);
+ ? ? ? /* use dpdck0_2 */
+ ? ? ? __raw_writel(dp_ctl | 0x1000L, pllbase + MXC_PLL_DP_CTL);
+ ? ? ? pll_hfsm = dp_ctl & MXC_PLL_DP_CTL_HFSM;
+ ? ? ? if (pll_hfsm == 0) {
+ ? ? ? ? ? ? ? reg = mfi << 4 | pdf;
+ ? ? ? ? ? ? ? __raw_writel(reg, pllbase + MXC_PLL_DP_OP);
+ ? ? ? ? ? ? ? __raw_writel(mfd, pllbase + MXC_PLL_DP_MFD);
+ ? ? ? ? ? ? ? __raw_writel(mfn, pllbase + MXC_PLL_DP_MFN);
+ ? ? ? } else {
+ ? ? ? ? ? ? ? reg = mfi << 4 | pdf;
+ ? ? ? ? ? ? ? __raw_writel(reg, pllbase + MXC_PLL_DP_HFS_OP);
+ ? ? ? ? ? ? ? __raw_writel(mfd, pllbase + MXC_PLL_DP_HFS_MFD);
+ ? ? ? ? ? ? ? __raw_writel(mfn, pllbase + MXC_PLL_DP_HFS_MFN);
+ ? ? ? }
+
+ ? ? ? return 0;
+}
+
+static int _clk_pll_enable(struct clk *clk)
+{
+ ? ? ? u32 reg;
+ ? ? ? void __iomem *pllbase;
+ ? ? ? int i = 0;
+

arch/arm/mach-mx5/clock.c line 223

Quoted 10 lines
arch/arm/mach-mx5/clock.c new file +10 -0
+ ? ? ? pllbase = _get_pll_base(clk);
+ ? ? ? reg = __raw_readl(pllbase + MXC_PLL_DP_CTL) | MXC_PLL_DP_CTL_UPEN;
+ ? ? ? __raw_writel(reg, pllbase + MXC_PLL_DP_CTL);
+
+ ? ? ? /* Wait for lock */
+ ? ? ? while ((!(__raw_readl(pllbase + MXC_PLL_DP_CTL) & MXC_PLL_DP_CTL_LRF))
+ ? ? ? ? ? ? ? && i < MAX_DPLL_WAIT_TRIES) {
+ ? ? ? ? ? ? ? i++;
+ ? ? ? ? ? ? ? udelay(1);
+ ? ? ? }

Mmm... this really hurts my eyes:

Quoted 7 lines
	do {
		v = __raw_readl(pllbase + MXC_PLL_DP_CTL)
		if (v & MXC_PLL_DP_CTL_LRF)
			break;
		
		udelay(1);
	} while (++i < MAX_DPLL_WAIT_TRIES);

(Shrug) I picked it up from OMAP code. But your style is better.

Quoted 24 lines
Quoted 24 lines
arch/arm/mach-mx5/clock.c new file +24 -0
+
+ ? ? ? if (i == MAX_DPLL_WAIT_TRIES) {
+ ? ? ? ? ? ? ? printk(KERN_ERR "MX5: pll locking failed\n");
+ ? ? ? ? ? ? ? return -EINVAL;
+ ? ? ? }
+
+ ? ? ? return 0;
+}
+
+static void _clk_pll_disable(struct clk *clk)
+{
+ ? ? ? u32 reg;
+ ? ? ? void __iomem *pllbase;
+
+ ? ? ? pllbase = _get_pll_base(clk);
+ ? ? ? reg = __raw_readl(pllbase + MXC_PLL_DP_CTL) & ~MXC_PLL_DP_CTL_UPEN;
+ ? ? ? __raw_writel(reg, pllbase + MXC_PLL_DP_CTL);
+}
+
+static int _clk_pll1_sw_set_parent(struct clk *clk, struct clk *parent)
+{
+ ? ? ? u32 reg;
+
+ ? ? ? reg = __raw_readl(MXC_CCM_CCSR);
Quoted 8 lines

arch/arm/mach-mx5/clock.c line 253

Quoted 6 lines
arch/arm/mach-mx5/clock.c new file +6 -0
+
+ ? ? ? /* When switching from pll_main_clk to a bypass clock, first select a
+ ? ? ? ? ?multiplexed clock in 'step_sel', then shift the glitchless mux
+ ? ? ? ? ?'pll1_sw_clk_sel'.
+ ? ? ? ? ?When switching back, do it in reverse order
+ ? ? ? */

comment style ... not sure if this leaks apw's checkscripts, heh :)

The patch was checkpatch approved ;)
But will fix.

Quoted 27 lines
Quoted 14 lines
arch/arm/mach-mx5/clock.c new file +14 -0
+ ? ? ? if (parent == &pll1_main_clk) {
+ ? ? ? ? ? ? ? /* Switch to pll1_main_clk */
+ ? ? ? ? ? ? ? reg &= ~MXC_CCM_CCSR_PLL1_SW_CLK_SEL;
+ ? ? ? ? ? ? ? __raw_writel(reg, MXC_CCM_CCSR);
+ ? ? ? ? ? ? ? /* step_clk mux switched to lp_apm, to save power. */
+ ? ? ? ? ? ? ? reg = __raw_readl(MXC_CCM_CCSR);
+ ? ? ? ? ? ? ? reg = (reg & ~MXC_CCM_CCSR_STEP_SEL_MASK) |
+ ? ? ? ? ? ? ? ? ? ? ? (MXC_CCM_CCSR_STEP_SEL_LP_APM <<
+ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? MXC_CCM_CCSR_STEP_SEL_OFFSET);
+ ? ? ? } else {
+ ? ? ? ? ? ? ? if (parent == &lp_apm_clk) {
+ ? ? ? ? ? ? ? ? ? ? ? reg = (reg & ~MXC_CCM_CCSR_STEP_SEL_MASK) |
+ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? (MXC_CCM_CCSR_STEP_SEL_LP_APM <<
+ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? MXC_CCM_CCSR_STEP_SEL_OFFSET);

arch/arm/mach-mx5/clock.c line 277

Quoted 10 lines
arch/arm/mach-mx5/clock.c new file +10 -0
+ ? ? ? ? ? ? ? } else ?if (parent == &pll2_sw_clk) {
+ ? ? ? ? ? ? ? ? ? ? ? reg = (reg & ~MXC_CCM_CCSR_STEP_SEL_MASK) |
+ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? (MXC_CCM_CCSR_STEP_SEL_PLL2_DIVIDED <<
+ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? MXC_CCM_CCSR_STEP_SEL_OFFSET);
+ ? ? ? ? ? ? ? } else ?if (parent == &pll3_sw_clk) {
+ ? ? ? ? ? ? ? ? ? ? ? reg = (reg & ~MXC_CCM_CCSR_STEP_SEL_MASK) |
+ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? (MXC_CCM_CCSR_STEP_SEL_PLL3_DIVIDED <<
+ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? MXC_CCM_CCSR_STEP_SEL_OFFSET);
+ ? ? ? ? ? ? ? } else
+ ? ? ? ? ? ? ? ? ? ? ? return -EINVAL;

Again, hurts my eyes:

Quoted 10 lines
		if (...)
			step = MXC_CCM_CCSR_STEP_SEL_LP_APM;
		else if (...)
			step = MXC_CCM_CCSR_STEP_SEL_PLL2_DIVIDED;
		else if (...)
			step = ...

		reg &= ~MXC_CCM_CCSR_STEP_SEL_MASK;
		reg |= step << MXC_CCM_CCSR_STEP_SEL_OFFSET;
		...

Fixed.

Quoted 158 lines
Quoted 158 lines
arch/arm/mach-mx5/clock.c new file +158 -0
+
+ ? ? ? ? ? ? ? __raw_writel(reg, MXC_CCM_CCSR);
+ ? ? ? ? ? ? ? /* Switch to step_clk */
+ ? ? ? ? ? ? ? reg = __raw_readl(MXC_CCM_CCSR);
+ ? ? ? ? ? ? ? reg |= MXC_CCM_CCSR_PLL1_SW_CLK_SEL;
+ ? ? ? }
+ ? ? ? __raw_writel(reg, MXC_CCM_CCSR);
+ ? ? ? return 0;
+}
+
+static unsigned long clk_pll1_sw_get_rate(struct clk *clk)
+{
+ ? ? ? u32 reg, div;
+ ? ? ? unsigned long parent_rate;
+
+ ? ? ? parent_rate = clk_get_rate(clk->parent);
+
+ ? ? ? div = 1;
+ ? ? ? reg = __raw_readl(MXC_CCM_CCSR);
+
+ ? ? ? if (clk->parent == &pll2_sw_clk) {
+ ? ? ? ? ? ? ? div = ((reg & MXC_CCM_CCSR_PLL2_PODF_MASK) >>
+ ? ? ? ? ? ? ? ? ? ? ?MXC_CCM_CCSR_PLL2_PODF_OFFSET) + 1;
+ ? ? ? } else if (clk->parent == &pll3_sw_clk) {
+ ? ? ? ? ? ? ? div = ((reg & MXC_CCM_CCSR_PLL3_PODF_MASK) >>
+ ? ? ? ? ? ? ? ? ? ? ?MXC_CCM_CCSR_PLL3_PODF_OFFSET) + 1;
+ ? ? ? }
+ ? ? ? return parent_rate / div;
+}
+
+static int _clk_pll2_sw_set_parent(struct clk *clk, struct clk *parent)
+{
+ ? ? ? u32 reg;
+
+ ? ? ? reg = __raw_readl(MXC_CCM_CCSR);
+
+ ? ? ? if (parent == &pll2_sw_clk)
+ ? ? ? ? ? ? ? reg &= ~MXC_CCM_CCSR_PLL2_SW_CLK_SEL;
+ ? ? ? else
+ ? ? ? ? ? ? ? reg |= MXC_CCM_CCSR_PLL2_SW_CLK_SEL;
+
+ ? ? ? __raw_writel(reg, MXC_CCM_CCSR);
+ ? ? ? return 0;
+}
+
+static int _clk_lp_apm_set_parent(struct clk *clk, struct clk *parent)
+{
+ ? ? ? u32 reg;
+
+ ? ? ? if (parent == &osc_clk)
+ ? ? ? ? ? ? ? reg = __raw_readl(MXC_CCM_CCSR) & ~MXC_CCM_CCSR_LP_APM_SEL;
+ ? ? ? else
+ ? ? ? ? ? ? ? return -EINVAL;
+
+ ? ? ? __raw_writel(reg, MXC_CCM_CCSR);
+
+ ? ? ? return 0;
+}
+
+static unsigned long clk_arm_get_rate(struct clk *clk)
+{
+ ? ? ? u32 cacrr, div;
+ ? ? ? unsigned long parent_rate;
+
+ ? ? ? parent_rate = clk_get_rate(clk->parent);
+ ? ? ? cacrr = __raw_readl(MXC_CCM_CACRR);
+ ? ? ? div = (cacrr & MXC_CCM_CACRR_ARM_PODF_MASK) + 1;
+
+ ? ? ? return parent_rate / div;
+}
+
+static int _clk_periph_apm_set_parent(struct clk *clk, struct clk *parent)
+{
+ ? ? ? u32 reg, mux;
+ ? ? ? int i = 0;
+
+ ? ? ? mux = _get_mux(parent, &pll1_sw_clk, &pll3_sw_clk, &lp_apm_clk, NULL);
+
+ ? ? ? reg = __raw_readl(MXC_CCM_CBCMR) & ~MXC_CCM_CBCMR_PERIPH_CLK_SEL_MASK;
+ ? ? ? reg |= mux << MXC_CCM_CBCMR_PERIPH_CLK_SEL_OFFSET;
+ ? ? ? __raw_writel(reg, MXC_CCM_CBCMR);
+
+ ? ? ? /* Wait for lock */
+ ? ? ? while ((__raw_readl(MXC_CCM_CDHIPR) & MXC_CCM_CDHIPR_PERIPH_CLK_SEL_BUSY)
+ ? ? ? ? ? ? ? && i < MAX_DPLL_WAIT_TRIES) {
+ ? ? ? ? ? ? ? i++;
+ ? ? ? ? ? ? ? udelay(1);
+ ? ? ? }
+
+ ? ? ? if (i == MAX_DPLL_WAIT_TRIES) {
+ ? ? ? ? ? ? ? printk(KERN_ERR "MX5: Set parent for periph_apm clock failed\n");
+ ? ? ? ? ? ? ? return -EINVAL;
+ ? ? ? }
+
+ ? ? ? return 0;
+}
+
+static unsigned long clk_main_bus_get_rate(struct clk *clk)
+{
+ ? ? ? return clk_get_rate(clk->parent);
+}
+
+static int _clk_main_bus_set_parent(struct clk *clk, struct clk *parent)
+{
+ ? ? ? u32 reg;
+
+ ? ? ? reg = __raw_readl(MXC_CCM_CBCDR);
+
+ ? ? ? if (parent == &pll2_sw_clk)
+ ? ? ? ? ? ? ? reg &= ~MXC_CCM_CBCDR_PERIPH_CLK_SEL;
+ ? ? ? else if (parent == &periph_apm_clk)
+ ? ? ? ? ? ? ? reg |= MXC_CCM_CBCDR_PERIPH_CLK_SEL;
+ ? ? ? else
+ ? ? ? ? ? ? ? return -EINVAL;
+
+ ? ? ? __raw_writel(reg, MXC_CCM_CBCDR);
+
+ ? ? ? return 0;
+}
+
+static struct clk main_bus_clk = {
+ ? ? ? .parent = &pll2_sw_clk,
+ ? ? ? .set_parent = _clk_main_bus_set_parent,
+ ? ? ? .get_rate = clk_main_bus_get_rate,
+};
+
+static unsigned long clk_ahb_get_rate(struct clk *clk)
+{
+ ? ? ? u32 reg, div;
+ ? ? ? unsigned long parent_rate;
+
+ ? ? ? parent_rate = clk_get_rate(clk->parent);
+
+ ? ? ? reg = __raw_readl(MXC_CCM_CBCDR);
+ ? ? ? div = ((reg & MXC_CCM_CBCDR_AHB_PODF_MASK) >>
+ ? ? ? ? ? ? ?MXC_CCM_CBCDR_AHB_PODF_OFFSET) + 1;
+ ? ? ? return parent_rate / div;
+}
+
+
+static int _clk_ahb_set_rate(struct clk *clk, unsigned long rate)
+{
+ ? ? ? u32 reg, div;
+ ? ? ? unsigned long parent_rate;
+ ? ? ? int i = 0;
+
+ ? ? ? parent_rate = clk_get_rate(clk->parent);
+
+ ? ? ? div = parent_rate / rate;
+ ? ? ? if (div > 8 || div < 1 || ((parent_rate / div) != rate))
+ ? ? ? ? ? ? ? return -EINVAL;
+
+ ? ? ? reg = __raw_readl(MXC_CCM_CBCDR);
+ ? ? ? reg &= ~MXC_CCM_CBCDR_AHB_PODF_MASK;
+ ? ? ? reg |= (div - 1) << MXC_CCM_CBCDR_AHB_PODF_OFFSET;
+ ? ? ? __raw_writel(reg, MXC_CCM_CBCDR);
+
+ ? ? ? /* Wait for lock */
Quoted 8 lines

arch/arm/mach-mx5/clock.c line 440

Quoted 5 lines
arch/arm/mach-mx5/clock.c new file +5 -0
+ ? ? ? while ((__raw_readl(MXC_CCM_CDHIPR) & MXC_CCM_CDHIPR_AHB_PODF_BUSY)
+ ? ? ? ? ? ? ? && i < MAX_DPLL_WAIT_TRIES) {
+ ? ? ? ? ? ? ? i++;
+ ? ? ? ? ? ? ? udelay(1);
+ ? ? ? }

Provided this loop sequence appears so many times here, maybe we can just invent a static inline function for this, e.g. dpll_wait_flags(register, flags)

Will investigate.

Quoted 178 lines
Quoted 75 lines
arch/arm/mach-mx5/clock.c new file +75 -0
+
+ ? ? ? if (i == MAX_DPLL_WAIT_TRIES) {
+ ? ? ? ? ? ? ? printk(KERN_ERR "MX5: clk_ahb_set_rate failed\n");
+ ? ? ? ? ? ? ? return -EINVAL;
+ ? ? ? }
+
+ ? ? ? return 0;
+}
+
+static unsigned long _clk_ahb_round_rate(struct clk *clk,
+ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? unsigned long rate)
+{
+ ? ? ? u32 div;
+ ? ? ? unsigned long parent_rate;
+
+ ? ? ? parent_rate = clk_get_rate(clk->parent);
+
+ ? ? ? div = parent_rate / rate;
+ ? ? ? if (div > 8)
+ ? ? ? ? ? ? ? div = 8;
+ ? ? ? else if (div == 0)
+ ? ? ? ? ? ? ? div++;
+ ? ? ? return parent_rate / div;
+}
+
+
+static int _clk_max_enable(struct clk *clk)
+{
+ ? ? ? u32 reg;
+
+ ? ? ? _clk_ccgr_enable(clk);
+
+ ? ? ? /* Handshake with MAX when LPM is entered. */
+ ? ? ? reg = __raw_readl(MXC_CCM_CLPCR);
+ ? ? ? reg &= ~MXC_CCM_CLPCR_BYPASS_MAX_LPM_HS;
+ ? ? ? __raw_writel(reg, MXC_CCM_CLPCR);
+
+ ? ? ? return 0;
+}
+
+static void _clk_max_disable(struct clk *clk)
+{
+ ? ? ? u32 reg;
+
+ ? ? ? _clk_ccgr_disable_inwait(clk);
+
+ ? ? ? /* No Handshake with MAX when LPM is entered as its disabled. */
+ ? ? ? reg = __raw_readl(MXC_CCM_CLPCR);
+ ? ? ? reg |= MXC_CCM_CLPCR_BYPASS_MAX_LPM_HS;
+ ? ? ? __raw_writel(reg, MXC_CCM_CLPCR);
+}
+
+static unsigned long clk_ipg_get_rate(struct clk *clk)
+{
+ ? ? ? u32 reg, div;
+ ? ? ? unsigned long parent_rate;
+
+ ? ? ? parent_rate = clk_get_rate(clk->parent);
+
+ ? ? ? reg = __raw_readl(MXC_CCM_CBCDR);
+ ? ? ? div = ((reg & MXC_CCM_CBCDR_IPG_PODF_MASK) >>
+ ? ? ? ? ? ? ?MXC_CCM_CBCDR_IPG_PODF_OFFSET) + 1;
+
+ ? ? ? return parent_rate / div;
+}
+
+static unsigned long clk_ipg_per_get_rate(struct clk *clk)
+{
+ ? ? ? u32 reg, prediv1, prediv2, podf;
+ ? ? ? unsigned long parent_rate;
+
+ ? ? ? parent_rate = clk_get_rate(clk->parent);
+
+ ? ? ? if (clk->parent == &main_bus_clk || clk->parent == &lp_apm_clk) {
+ ? ? ? ? ? ? ? /* the main_bus_clk is the one before the DVFS engine */

arch/arm/mach-mx5/clock.c line 525

Quoted 10 lines
arch/arm/mach-mx5/clock.c new file +10 -0
+ ? ? ? ? ? ? ? reg = __raw_readl(MXC_CCM_CBCDR);
+ ? ? ? ? ? ? ? prediv1 = ((reg & MXC_CCM_CBCDR_PERCLK_PRED1_MASK) >>
+ ? ? ? ? ? ? ? ? ? ? ? ? ?MXC_CCM_CBCDR_PERCLK_PRED1_OFFSET) + 1;
+ ? ? ? ? ? ? ? prediv2 = ((reg & MXC_CCM_CBCDR_PERCLK_PRED2_MASK) >>
+ ? ? ? ? ? ? ? ? ? ? ? ? ?MXC_CCM_CBCDR_PERCLK_PRED2_OFFSET) + 1;
+ ? ? ? ? ? ? ? podf = ((reg & MXC_CCM_CBCDR_PERCLK_PODF_MASK) >>
+ ? ? ? ? ? ? ? ? ? ? ? MXC_CCM_CBCDR_PERCLK_PODF_OFFSET) + 1;
+ ? ? ? ? ? ? ? return parent_rate / (prediv1 * prediv2 * podf);
+ ? ? ? } else if (clk->parent == &ipg_clk) {
+ ? ? ? ? ? ? ? return parent_rate;

unnecessary braces

arch/arm/mach-mx5/clock.c line 527

Quoted 2 lines
arch/arm/mach-mx5/clock.c new file +2 -0
+ ? ? ? } else {
+ ? ? ? ? ? ? ? BUG();

ditto

Quoted 85 lines
arch/arm/mach-mx5/clock.c new file +85 -0
+ ? ? ? }
+}
+
+static int _clk_ipg_per_set_parent(struct clk *clk, struct clk *parent)
+{
+ ? ? ? u32 reg;
+
+ ? ? ? reg = __raw_readl(MXC_CCM_CBCMR);
+
+ ? ? ? reg &= ~MXC_CCM_CBCMR_PERCLK_LP_APM_CLK_SEL;
+ ? ? ? reg &= ~MXC_CCM_CBCMR_PERCLK_IPG_CLK_SEL;
+
+ ? ? ? if (parent == &ipg_clk)
+ ? ? ? ? ? ? ? reg |= MXC_CCM_CBCMR_PERCLK_IPG_CLK_SEL;
+ ? ? ? else if (parent == &lp_apm_clk)
+ ? ? ? ? ? ? ? reg |= MXC_CCM_CBCMR_PERCLK_LP_APM_CLK_SEL;
+ ? ? ? else if (parent != &main_bus_clk)
+ ? ? ? ? ? ? ? return -EINVAL;
+
+ ? ? ? __raw_writel(reg, MXC_CCM_CBCMR);
+
+ ? ? ? return 0;
+}
+
+static unsigned long clk_uart_get_rate(struct clk *clk)
+{
+ ? ? ? u32 reg, prediv, podf;
+ ? ? ? unsigned long parent_rate;
+
+ ? ? ? parent_rate = clk_get_rate(clk->parent);
+
+ ? ? ? reg = __raw_readl(MXC_CCM_CSCDR1);
+ ? ? ? prediv = ((reg & MXC_CCM_CSCDR1_UART_CLK_PRED_MASK) >>
+ ? ? ? ? ? ? ? ? MXC_CCM_CSCDR1_UART_CLK_PRED_OFFSET) + 1;
+ ? ? ? podf = ((reg & MXC_CCM_CSCDR1_UART_CLK_PODF_MASK) >>
+ ? ? ? ? ? ? ? MXC_CCM_CSCDR1_UART_CLK_PODF_OFFSET) + 1;
+
+ ? ? ? return parent_rate / (prediv * podf);
+}
+
+static int _clk_uart_set_parent(struct clk *clk, struct clk *parent)
+{
+ ? ? ? u32 reg, mux;
+
+ ? ? ? mux = _get_mux(parent, &pll1_sw_clk, &pll2_sw_clk, &pll3_sw_clk,
+ ? ? ? ? ? ? ? ? ? ? ?&lp_apm_clk);
+ ? ? ? reg = __raw_readl(MXC_CCM_CSCMR1) & ~MXC_CCM_CSCMR1_UART_CLK_SEL_MASK;
+ ? ? ? reg |= mux << MXC_CCM_CSCMR1_UART_CLK_SEL_OFFSET;
+ ? ? ? __raw_writel(reg, MXC_CCM_CSCMR1);
+
+ ? ? ? return 0;
+}
+
+static unsigned long get_high_reference_clock_rate(struct clk *clk)
+{
+ ? ? ? return external_high_reference;
+}
+
+static unsigned long get_low_reference_clock_rate(struct clk *clk)
+{
+ ? ? ? return external_low_reference;
+}
+
+static unsigned long get_oscillator_reference_clock_rate(struct clk *clk)
+{
+ ? ? ? return oscillator_reference;
+}
+
+static unsigned long get_ckih2_reference_clock_rate(struct clk *clk)
+{
+ ? ? ? return ckih2_reference;
+}
+
+/* External high frequency clock */
+static struct clk ckih_clk = {
+ ? ? ? .get_rate = get_high_reference_clock_rate,
+};
+
+static struct clk ckih2_clk = {
+ ? ? ? .get_rate = get_ckih2_reference_clock_rate,
+};
+
+static struct clk osc_clk = {
+ ? ? ? .get_rate = get_oscillator_reference_clock_rate,
+};
Quoted 8 lines

arch/arm/mach-mx5/clock.c line 617

Quoted 5 lines
arch/arm/mach-mx5/clock.c new file +5 -0
+
+/* External low frequency (32kHz) clock */
+static struct clk ckil_clk = {
+ ? ? ? .get_rate = get_low_reference_clock_rate,
+};

That's why Jerremy is coming up with a clk_fixed, to address exactly such awkward situations :)

Heh, yes :)

Quoted 484 lines
Quoted 294 lines
arch/arm/mach-mx5/clock.c new file +231 -0
+
+static struct clk pll1_main_clk = {
+ ? ? ? .parent = &osc_clk,
+ ? ? ? .get_rate = clk_pll_get_rate,
+ ? ? ? .enable = _clk_pll_enable,
+ ? ? ? .disable = _clk_pll_disable,
+};
+
+/* Clock tree block diagram (WIP):
+ * ? ? CCM: Clock Controller Module
+ *
+ * PLL output -> |
+ * ? ? ? ? ? ? ? | CCM Switcher -> CCM_CLK_ROOT_GEN ->
+ * PLL bypass -> |
+ *
+ */
+
+/* PLL1 SW supplies to ARM core */
+static struct clk pll1_sw_clk = {
+ ? ? ? .parent = &pll1_main_clk,
+ ? ? ? .set_parent = _clk_pll1_sw_set_parent,
+ ? ? ? .get_rate = clk_pll1_sw_get_rate,
+};
+
+/* PLL2 SW supplies to AXI/AHB/IP buses */
+static struct clk pll2_sw_clk = {
+ ? ? ? .parent = &osc_clk,
+ ? ? ? .get_rate = clk_pll_get_rate,
+ ? ? ? .set_rate = _clk_pll_set_rate,
+ ? ? ? .set_parent = _clk_pll2_sw_set_parent,
+ ? ? ? .enable = _clk_pll_enable,
+ ? ? ? .disable = _clk_pll_disable,
+};
+
+/* PLL3 SW supplies to serial clocks like USB, SSI, etc. */
+static struct clk pll3_sw_clk = {
+ ? ? ? .parent = &osc_clk,
+ ? ? ? .set_rate = _clk_pll_set_rate,
+ ? ? ? .get_rate = clk_pll_get_rate,
+ ? ? ? .enable = _clk_pll_enable,
+ ? ? ? .disable = _clk_pll_disable,
+};
+
+/* Low-power Audio Playback Mode clock */
+static struct clk lp_apm_clk = {
+ ? ? ? .parent = &osc_clk,
+ ? ? ? .set_parent = _clk_lp_apm_set_parent,
+};
+
+static struct clk periph_apm_clk = {
+ ? ? ? .parent = &pll1_sw_clk,
+ ? ? ? .set_parent = _clk_periph_apm_set_parent,
+};
+
+static struct clk cpu_clk = {
+ ? ? ? .parent = &pll1_sw_clk,
+ ? ? ? .get_rate = clk_arm_get_rate,
+};
+
+static struct clk ahb_clk = {
+ ? ? ? .parent = &main_bus_clk,
+ ? ? ? .get_rate = clk_ahb_get_rate,
+ ? ? ? .set_rate = _clk_ahb_set_rate,
+ ? ? ? .round_rate = _clk_ahb_round_rate,
+};
+
+/* Main IP interface clock for access to registers */
+static struct clk ipg_clk = {
+ ? ? ? .parent = &ahb_clk,
+ ? ? ? .get_rate = clk_ipg_get_rate,
+};
+
+static struct clk ipg_perclk = {
+ ? ? ? .parent = &lp_apm_clk,
+ ? ? ? .get_rate = clk_ipg_per_get_rate,
+ ? ? ? .set_parent = _clk_ipg_per_set_parent,
+};
+
+static struct clk uart_root_clk = {
+ ? ? ? .parent = &pll2_sw_clk,
+ ? ? ? .get_rate = clk_uart_get_rate,
+ ? ? ? .set_parent = _clk_uart_set_parent,
+};
+
+static struct clk ahb_max_clk = {
+ ? ? ? .parent = &ahb_clk,
+ ? ? ? .enable_reg = MXC_CCM_CCGR0,
+ ? ? ? .enable_shift = MXC_CCM_CCGRx_CG14_OFFSET,
+ ? ? ? .enable = _clk_max_enable,
+ ? ? ? .disable = _clk_max_disable,
+};
+
+static struct clk aips_tz1_clk = {
+ ? ? ? .parent = &ahb_clk,
+ ? ? ? .secondary = &ahb_max_clk,
+ ? ? ? .enable_reg = MXC_CCM_CCGR0,
+ ? ? ? .enable_shift = MXC_CCM_CCGRx_CG12_OFFSET,
+ ? ? ? .enable = _clk_ccgr_enable,
+ ? ? ? .disable = _clk_ccgr_disable_inwait,
+};
+
+static struct clk aips_tz2_clk = {
+ ? ? ? .parent = &ahb_clk,
+ ? ? ? .secondary = &ahb_max_clk,
+ ? ? ? .enable_reg = MXC_CCM_CCGR0,
+ ? ? ? .enable_shift = MXC_CCM_CCGRx_CG13_OFFSET,
+ ? ? ? .enable = _clk_ccgr_enable,
+ ? ? ? .disable = _clk_ccgr_disable_inwait,
+};
+
+static struct clk gpt_32k_clk = {
+ ? ? ? .id = 0,
+ ? ? ? .parent = &ckil_clk,
+};
+
+#define DEFINE_CLOCK(name, i, er, es, gr, sr, p, s) ? ?\
+ ? ? ? static struct clk name = { ? ? ? ? ? ? ? ? ? ? ?\
+ ? ? ? ? ? ? ? .id ? ? ? ? ? ? = i, ? ? ? ? ? ? ? ? ? ?\
+ ? ? ? ? ? ? ? .enable_reg ? ? = er, ? ? ? ? ? ? ? ? ? \
+ ? ? ? ? ? ? ? .enable_shift ? = es, ? ? ? ? ? ? ? ? ? \
+ ? ? ? ? ? ? ? .get_rate ? ? ? = gr, ? ? ? ? ? ? ? ? ? \
+ ? ? ? ? ? ? ? .set_rate ? ? ? = sr, ? ? ? ? ? ? ? ? ? \
+ ? ? ? ? ? ? ? .enable ? ? ? ? = _clk_ccgr_enable, ? ? \
+ ? ? ? ? ? ? ? .disable ? ? ? ?= _clk_ccgr_disable, ? ?\
+ ? ? ? ? ? ? ? .parent ? ? ? ? = p, ? ? ? ? ? ? ? ? ? ?\
+ ? ? ? ? ? ? ? .secondary ? ? ?= s, ? ? ? ? ? ? ? ? ? ?\
+ ? ? ? }
+
+/* DEFINE_CLOCK(name, id, enable_reg, enable_shift,
+ ? get_rate, set_rate, parent, secondary); */
+
+/* Shared peripheral bus arbiter */
+DEFINE_CLOCK(spba_clk, 0, MXC_CCM_CCGR5, MXC_CCM_CCGRx_CG0_OFFSET,
+ ? ? ? NULL, ?NULL, &ipg_clk, NULL);
+
+/* UART */
+DEFINE_CLOCK(uart1_clk, 0, MXC_CCM_CCGR1, MXC_CCM_CCGRx_CG4_OFFSET,
+ ? ? ? NULL, ?NULL, &uart_root_clk, NULL);
+DEFINE_CLOCK(uart2_clk, 1, MXC_CCM_CCGR1, MXC_CCM_CCGRx_CG6_OFFSET,
+ ? ? ? NULL, ?NULL, &uart_root_clk, NULL);
+DEFINE_CLOCK(uart3_clk, 2, MXC_CCM_CCGR1, MXC_CCM_CCGRx_CG8_OFFSET,
+ ? ? ? NULL, ?NULL, &uart_root_clk, NULL);
+DEFINE_CLOCK(uart1_ipg_clk, 0, MXC_CCM_CCGR1, MXC_CCM_CCGRx_CG3_OFFSET,
+ ? ? ? NULL, ?NULL, &ipg_clk, &aips_tz1_clk);
+DEFINE_CLOCK(uart2_ipg_clk, 1, MXC_CCM_CCGR1, MXC_CCM_CCGRx_CG5_OFFSET,
+ ? ? ? NULL, ?NULL, &ipg_clk, &aips_tz1_clk);
+DEFINE_CLOCK(uart3_ipg_clk, 2, MXC_CCM_CCGR1, MXC_CCM_CCGRx_CG7_OFFSET,
+ ? ? ? NULL, ?NULL, &ipg_clk, &spba_clk);
+
+/* GPT */
+DEFINE_CLOCK(gpt_clk, 0, MXC_CCM_CCGR2, MXC_CCM_CCGRx_CG9_OFFSET,
+ ? ? ? NULL, ?NULL, &ipg_perclk, NULL);
+DEFINE_CLOCK(gpt_ipg_clk, 0, MXC_CCM_CCGR2, MXC_CCM_CCGRx_CG10_OFFSET,
+ ? ? ? NULL, ?NULL, &ipg_clk, NULL);
+
+/* FEC */
+DEFINE_CLOCK(fec_clk, 0, MXC_CCM_CCGR2, MXC_CCM_CCGRx_CG12_OFFSET,
+ ? ? ? NULL, ?NULL, &ipg_clk, NULL);
+
+#define _REGISTER_CLOCK(d, n, c) \
+ ? ? ? { \
+ ? ? ? ? ? ? ? .dev_id = d, \
+ ? ? ? ? ? ? ? .con_id = n, \
+ ? ? ? ? ? ? ? .clk = &c, ? \
+ ? ? ? },
+
+static struct clk_lookup lookups[] __initdata = {
+ ? ? ? _REGISTER_CLOCK("imx-uart.0", NULL, uart1_clk)
+ ? ? ? _REGISTER_CLOCK("imx-uart.1", NULL, uart2_clk)
+ ? ? ? _REGISTER_CLOCK("imx-uart.2", NULL, uart3_clk)
+ ? ? ? _REGISTER_CLOCK(NULL, "gpt", gpt_clk)
+ ? ? ? _REGISTER_CLOCK("fec.0", NULL, fec_clk)
+};
+
+static void clk_tree_init(void)
+{
+ ? ? ? u32 reg;
+
+ ? ? ? ipg_perclk.set_parent(&ipg_perclk, &lp_apm_clk);
+
+ ? ? ? /*
+ ? ? ? ?* Initialise the IPG PER CLK dividers to 3. IPG_PER_CLK should be at
+ ? ? ? ?* 8MHz, its derived from lp_apm.
+ ? ? ? ?* FIXME: Verify if true for all boards
+ ? ? ? ?*/
+ ? ? ? reg = __raw_readl(MXC_CCM_CBCDR);
+ ? ? ? reg &= ~MXC_CCM_CBCDR_PERCLK_PRED1_MASK;
+ ? ? ? reg &= ~MXC_CCM_CBCDR_PERCLK_PRED2_MASK;
+ ? ? ? reg &= ~MXC_CCM_CBCDR_PERCLK_PODF_MASK;
+ ? ? ? reg |= (2 << MXC_CCM_CBCDR_PERCLK_PRED1_OFFSET);
+ ? ? ? __raw_writel(reg, MXC_CCM_CBCDR);
+
+ ? ? ? /* set parent for pll1, pll2 and pll3 */
+ ? ? ? pll1_main_clk.parent = &osc_clk;
+ ? ? ? pll2_sw_clk.parent = &osc_clk;
+ ? ? ? pll3_sw_clk.parent = &osc_clk;
+
+ ? ? ? /* set ipg_perclk parent */
+ ? ? ? ipg_perclk.parent = &lp_apm_clk;
+ ? ? ? reg = __raw_readl(MXC_CCM_CBCMR);
+ ? ? ? if ((reg & MXC_CCM_CBCMR_PERCLK_IPG_CLK_SEL) != 0) {
+ ? ? ? ? ? ? ? ipg_perclk.parent = &ipg_clk;
+ ? ? ? } else {
+ ? ? ? ? ? ? ? if ((reg & MXC_CCM_CBCMR_PERCLK_LP_APM_CLK_SEL) == 0)
+ ? ? ? ? ? ? ? ? ? ? ? ipg_perclk.parent = &main_bus_clk;
+ ? ? ? }
+}
+
+int __init mx51_clocks_init(unsigned long ckil, unsigned long osc,
+ ? ? ? ? ? ? ? ? ? ? ? unsigned long ckih1, unsigned long ckih2)
+{
+ ? ? ? int i;
+
+ ? ? ? external_low_reference = ckil;
+ ? ? ? external_high_reference = ckih1;
+ ? ? ? ckih2_reference = ckih2;
+ ? ? ? oscillator_reference = osc;
+
+ ? ? ? for (i = 0; i < ARRAY_SIZE(lookups); i++)
+ ? ? ? ? ? ? ? clkdev_add(&lookups[i]);
+
+ ? ? ? clk_tree_init();
+
+ ? ? ? clk_enable(&cpu_clk);
+ ? ? ? clk_enable(&main_bus_clk);
+
+ ? ? ? /* System timer */
+ ? ? ? mxc_timer_init(&gpt_clk, MX51_IO_ADDRESS(MX51_GPT1_BASE_ADDR),
+ ? ? ? ? ? ? ? MX51_MXC_INT_GPT);
+ ? ? ? return 0;
+}
arch/arm/mach-mx5/cpu.c new file +45 -0
new file mode 100644
index 0000000..93f1d5a
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2008-2009 Freescale Semiconductor, Inc. All Rights Reserved.
+ *
+ * The code contained herein is licensed under the GNU General Public
+ * License. You may obtain a copy of the GNU General Public License
+ * Version 2 or later at the following locations:
+ *
+ * http://www.opensource.org/licenses/gpl-license.html
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ * This file contains the CPU initialization code.
+ */
+
+#include <linux/types.h>
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <mach/hardware.h>
+#include <asm/io.h>
+
+static int __init post_cpu_init(void)
+{
+ ? ? ? unsigned int reg;
+ ? ? ? void __iomem *base;
+
+ ? ? ? if (cpu_is_mx51()) {
+ ? ? ? ? ? ? ? base = MX51_IO_ADDRESS(MX51_AIPS1_BASE_ADDR);
+ ? ? ? ? ? ? ? __raw_writel(0x0, base + 0x40);
+ ? ? ? ? ? ? ? __raw_writel(0x0, base + 0x44);
+ ? ? ? ? ? ? ? __raw_writel(0x0, base + 0x48);
+ ? ? ? ? ? ? ? __raw_writel(0x0, base + 0x4C);
+ ? ? ? ? ? ? ? reg = __raw_readl(base + 0x50) & 0x00FFFFFF;
+ ? ? ? ? ? ? ? __raw_writel(reg, base + 0x50);
+
+ ? ? ? ? ? ? ? base = MX51_IO_ADDRESS(MX51_AIPS2_BASE_ADDR);
+ ? ? ? ? ? ? ? __raw_writel(0x0, base + 0x40);
+ ? ? ? ? ? ? ? __raw_writel(0x0, base + 0x44);
+ ? ? ? ? ? ? ? __raw_writel(0x0, base + 0x48);
+ ? ? ? ? ? ? ? __raw_writel(0x0, base + 0x4C);
+ ? ? ? ? ? ? ? reg = __raw_readl(base + 0x50) & 0x00FFFFFF;
+ ? ? ? ? ? ? ? __raw_writel(reg, base + 0x50);
+ ? ? ? }
+ ? ? ? return 0;
+}
+
+postcore_initcall(post_cpu_init);
arch/arm/mach-mx5/crm_regs.h new file +6 -0
new file mode 100644
index 0000000..c776b9a
@@ -0,0 +1,583 @@
+/*
+ * Copyright 2008-2009 Freescale Semiconductor, Inc. All Rights Reserved.
+ *
+ * The code contained herein is licensed under the GNU General Public
+ * License. You may obtain a copy of the GNU General Public License
+ * Version 2 or later at the following locations:

arch/arm/mach-mx5/crm_regs.h line 16

Quoted 10 lines
arch/arm/mach-mx5/crm_regs.h new file +10 -0
+ *
+ * http://www.opensource.org/licenses/gpl-license.html
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+#ifndef __ARCH_ARM_MACH_MX51_CRM_REGS_H__
+#define __ARCH_ARM_MACH_MX51_CRM_REGS_H__
+
+#define MX51_CCM_BASE ? ? ? ? ?MX51_IO_ADDRESS(MX51_CCM_BASE_ADDR)
+#define MX51_DPLL1_BASE ? ? ? ? ? ? ? ?MX51_IO_ADDRESS(MX51_PLL1_BASE_ADDR)
+#define MX51_DPLL2_BASE ? ? ? ? ? ? ? ?MX51_IO_ADDRESS(MX51_PLL2_BASE_ADDR)

.... skipping register definitions ....

Quoted 177 lines
arch/arm/mach-mx5/crm_regs.h new file +4 -0
+#define MXC_SRPGC_EMI_PUPSCR ? (MXC_SRPGC_EMI_BASE + 0x4)
+#define MXC_SRPGC_EMI_PDNSCR ? (MXC_SRPGC_EMI_BASE + 0x8)
+
+#endif ? ? ? ? ? ? ? ? ? ? ? ? /* __ARCH_ARM_MACH_MX51_CRM_REGS_H__ */
arch/arm/mach-mx5/devices.c new file +96 -0
new file mode 100644
index 0000000..55eb089
@@ -0,0 +1,96 @@
+/*
+ * Copyright 2009 Amit Kucheria <[email protected]>
+ *
+ * The code contained herein is licensed under the GNU General Public
+ * License. You may obtain a copy of the GNU General Public License
+ * Version 2 or later at the following locations:
+ *
+ * http://www.opensource.org/licenses/gpl-license.html
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+
+#include <linux/platform_device.h>
+#include <mach/hardware.h>
+#include <mach/imx-uart.h>
+
+static struct resource uart0[] = {
+ ? ? ? {
+ ? ? ? ? ? ? ? .start = MX51_UART1_BASE_ADDR,
+ ? ? ? ? ? ? ? .end = MX51_UART1_BASE_ADDR + 0x0B5,
+ ? ? ? ? ? ? ? .flags = IORESOURCE_MEM,
+ ? ? ? }, {
+ ? ? ? ? ? ? ? .start = MX51_MXC_INT_UART1,
+ ? ? ? ? ? ? ? .end = MX51_MXC_INT_UART1,
+ ? ? ? ? ? ? ? .flags = IORESOURCE_IRQ,
+ ? ? ? },
+};
+
+struct platform_device mxc_uart_device0 = {
+ ? ? ? .name = "imx-uart",
+ ? ? ? .id = 0,
+ ? ? ? .resource = uart0,
+ ? ? ? .num_resources = ARRAY_SIZE(uart0),
+};
+
+static struct resource uart1[] = {
+ ? ? ? {
+ ? ? ? ? ? ? ? .start = MX51_UART2_BASE_ADDR,
+ ? ? ? ? ? ? ? .end = MX51_UART2_BASE_ADDR + 0x0B5,
+ ? ? ? ? ? ? ? .flags = IORESOURCE_MEM,
+ ? ? ? }, {
+ ? ? ? ? ? ? ? .start = MX51_MXC_INT_UART2,
+ ? ? ? ? ? ? ? .end = MX51_MXC_INT_UART2,
+ ? ? ? ? ? ? ? .flags = IORESOURCE_IRQ,
+ ? ? ? },
+};
+
+struct platform_device mxc_uart_device1 = {
+ ? ? ? .name = "imx-uart",
+ ? ? ? .id = 1,
+ ? ? ? .resource = uart1,
+ ? ? ? .num_resources = ARRAY_SIZE(uart1),
+};
+
+static struct resource uart2[] = {
+ ? ? ? {
+ ? ? ? ? ? ? ? .start = MX51_UART3_BASE_ADDR,
+ ? ? ? ? ? ? ? .end = MX51_UART3_BASE_ADDR + 0x0B5,
+ ? ? ? ? ? ? ? .flags = IORESOURCE_MEM,
+ ? ? ? }, {
+ ? ? ? ? ? ? ? .start = MX51_MXC_INT_UART3,
+ ? ? ? ? ? ? ? .end = MX51_MXC_INT_UART3,
+ ? ? ? ? ? ? ? .flags = IORESOURCE_IRQ,
+ ? ? ? },
+};
+
+struct platform_device mxc_uart_device2 = {
+ ? ? ? .name = "imx-uart",
+ ? ? ? .id = 2,
+ ? ? ? .resource = uart2,
+ ? ? ? .num_resources = ARRAY_SIZE(uart2),
+};
+
+static struct resource mxc_fec_resources[] = {
+ ? ? ? {
+ ? ? ? ? ? ? ? .start ?= MX51_MXC_FEC_BASE_ADDR,
+ ? ? ? ? ? ? ? .end ? ?= MX51_MXC_FEC_BASE_ADDR + 0xfff,
+ ? ? ? ? ? ? ? .flags ?= IORESOURCE_MEM,
+ ? ? ? }, {
+ ? ? ? ? ? ? ? .start ?= MX51_MXC_INT_FEC,
+ ? ? ? ? ? ? ? .end ? ?= MX51_MXC_INT_FEC,
+ ? ? ? ? ? ? ? .flags ?= IORESOURCE_IRQ,
+ ? ? ? },
+};
+
+struct platform_device mxc_fec_device = {
+ ? ? ? .name = "fec",
+ ? ? ? .id = 0,
+ ? ? ? .num_resources = ARRAY_SIZE(mxc_fec_resources),
+ ? ? ? .resource = mxc_fec_resources,
+};
+
+/* Dummy definition to allow compiling in AVIC and TZIC simultaneously */
+int __init mxc_register_gpios(void)
+{
+ ? ? ? return 0;
+}
arch/arm/mach-mx5/devices.h new file +4 -0
new file mode 100644
index 0000000..f339ab8
@@ -0,0 +1,4 @@
+extern struct platform_device mxc_uart_device0;
+extern struct platform_device mxc_uart_device1;
+extern struct platform_device mxc_uart_device2;
+extern struct platform_device mxc_fec_device;
arch/arm/mach-mx5/mm.c new file +55 -0
new file mode 100644
index 0000000..d66c31a
@@ -0,0 +1,88 @@
+/*
+ * Copyright 2008-2009 Freescale Semiconductor, Inc. All Rights Reserved.
+ *
+ * The code contained herein is licensed under the GNU General Public
+ * License. ?You may obtain a copy of the GNU General Public License
+ * Version 2 or later at the following locations:
+ *
+ * http://www.opensource.org/licenses/gpl-license.html
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ * Create static mapping between physical to virtual memory.
+ */
+
+#include <linux/mm.h>
+#include <linux/init.h>
+
+#include <asm/mach/map.h>
+
+#include <mach/hardware.h>
+#include <mach/common.h>
+#include <mach/iomux-v3.h>
+
+/*
+ * Define the MX51 memory map.
+ */
+static struct map_desc mxc_io_desc[] __initdata = {
+ ? ? ? {
+ ? ? ? ?.virtual = MX51_IRAM_BASE_ADDR_VIRT,
+ ? ? ? ?.pfn = __phys_to_pfn(MX51_IRAM_BASE_ADDR),
+ ? ? ? ?.length = MX51_IRAM_SIZE,
+ ? ? ? ?.type = MT_DEVICE},
+ ? ? ? {
+ ? ? ? ?.virtual = MX51_DEBUG_BASE_ADDR_VIRT,
+ ? ? ? ?.pfn = __phys_to_pfn(MX51_DEBUG_BASE_ADDR),
+ ? ? ? ?.length = MX51_DEBUG_SIZE,
+ ? ? ? ?.type = MT_DEVICE},
+ ? ? ? {
+ ? ? ? ?.virtual = MX51_TZIC_BASE_ADDR_VIRT,
+ ? ? ? ?.pfn = __phys_to_pfn(MX51_TZIC_BASE_ADDR),
+ ? ? ? ?.length = MX51_TZIC_SIZE,
+ ? ? ? ?.type = MT_DEVICE},
+ ? ? ? {
+ ? ? ? ?.virtual = MX51_AIPS1_BASE_ADDR_VIRT,
+ ? ? ? ?.pfn = __phys_to_pfn(MX51_AIPS1_BASE_ADDR),
+ ? ? ? ?.length = MX51_AIPS1_SIZE,
+ ? ? ? ?.type = MT_DEVICE},
+ ? ? ? {
+ ? ? ? ?.virtual = MX51_SPBA0_BASE_ADDR_VIRT,
+ ? ? ? ?.pfn = __phys_to_pfn(MX51_SPBA0_BASE_ADDR),
+ ? ? ? ?.length = MX51_SPBA0_SIZE,
+ ? ? ? ?.type = MT_DEVICE},
+ ? ? ? {
+ ? ? ? ?.virtual = MX51_AIPS2_BASE_ADDR_VIRT,
+ ? ? ? ?.pfn = __phys_to_pfn(MX51_AIPS2_BASE_ADDR),
+ ? ? ? ?.length = MX51_AIPS2_SIZE,
Quoted 8 lines

arch/arm/mach-mx5/mm.c line 61

Quoted 6 lines
arch/arm/mach-mx5/mm.c new file +6 -0
+ ? ? ? ?.type = MT_DEVICE},
+ ? ? ? {
+ ? ? ? ?.virtual = MX51_NFC_AXI_BASE_ADDR_VIRT,
+ ? ? ? ?.pfn = __phys_to_pfn(MX51_NFC_AXI_BASE_ADDR),
+ ? ? ? ?.length = MX51_NFC_AXI_SIZE,
+ ? ? ? ?.type = MT_DEVICE},

Weird alignment, guess due to leading white spaces?

Fixed.

Quoted 2 lines

.... skipping the rest ....

Thanks for the review.

/Amit

Signature · 3 lines
----------------------------------------------------------------------
Amit Kucheria, Kernel Engineer || amit.kucheria at canonical.com
----------------------------------------------------------------------
#20 lore raw

Re: [PATCHv2 05/11] mxc: Core support for i.MX5 series of processors from Freescale

In reply to Amit Kucheria
Quoted 11 lines · Amit Kucheria
arch/arm/mach-mx5/clock.c new file +11 -0
+static int _clk_pll_set_rate(struct clk *clk, unsigned long rate)
+{
+	u32 reg;
+	void __iomem *pllbase;
+
+	long mfi, pdf, mfn, mfd = 999999;
+	s64 temp64;
+	unsigned long quad_parent_rate;
+	unsigned long pll_hfsm, dp_ctl;
+	unsigned long parent_rate;
+

arch/arm/mach-mx5/clock.c line 182

Quoted 10 lines
arch/arm/mach-mx5/clock.c new file +10 -0
+	parent_rate = clk_get_rate(clk->parent);
+
+	pllbase = _get_pll_base(clk);
+
+	quad_parent_rate = 4 * parent_rate;
+	pdf = mfi = -1;
+	while (++pdf < 16 && mfi < 5)
+		mfi = rate * (pdf+1) / quad_parent_rate;
+	if (mfi > 15)
+		return -1;

Why not "return -EPERM" since what you're actually saying here by returning -1 is "Permission Denied"? If you didn't mean "Permission Denied", then don't use return -1.

maintainer
#21 lore raw

Re: [PATCHv2 05/11] mxc: Core support for i.MX5 series of processors from Freescale

In reply to Amit Kucheria

arch/arm/mach-mx5/clock.c

Quoted 27 lines · Amit Kucheria

From: Amit Kucheria <[email protected]>

Add basic clock support, cpu identification, I/O mapping and serial port.

---
 arch/arm/mach-mx5/clock.c                    |  848 ++++++++++++++++++++++++++
 arch/arm/mach-mx5/cpu.c                      |   45 ++
 arch/arm/mach-mx5/crm_regs.h                 |  583 ++++++++++++++++++
 arch/arm/mach-mx5/devices.c                  |   96 +++
 arch/arm/mach-mx5/devices.h                  |    4 +
 arch/arm/mach-mx5/mm.c                       |   88 +++
 arch/arm/plat-mxc/include/mach/common.h      |    1 +
 arch/arm/plat-mxc/include/mach/debug-macro.S |    4 +-
 arch/arm/plat-mxc/include/mach/iomux-mx51.h  |  340 +++++++++++
 arch/arm/plat-mxc/include/mach/mx51.h        |  454 ++++++++++++++
 10 files changed, 2461 insertions(+), 2 deletions(-)
 create mode 100644 arch/arm/mach-mx5/clock.c
 create mode 100644 arch/arm/mach-mx5/cpu.c
 create mode 100644 arch/arm/mach-mx5/crm_regs.h
 create mode 100644 arch/arm/mach-mx5/devices.c
 create mode 100644 arch/arm/mach-mx5/devices.h
 create mode 100644 arch/arm/mach-mx5/mm.c
 create mode 100644 arch/arm/plat-mxc/include/mach/iomux-mx51.h
 create mode 100644 arch/arm/plat-mxc/include/mach/mx51.h
arch/arm/mach-mx5/clock.c +0 -0

Can we rename this file to clock-mx51.c? We made this mistake on other i.MX platforms and ended with a clock.c and a clock-mx35.c in the same directory.

Quoted 101 lines

new file mode 100644
index 0000000..595f966

arch/arm/mach-mx5/clock.c new file +96 -0
@@ -0,0 +1,848 @@
+/*
+ * Copyright 2008-2010 Freescale Semiconductor, Inc. All Rights Reserved.
+ * Copyright (C) 2009-2010 Amit Kucheria <[email protected]>
+ *
+ * The code contained herein is licensed under the GNU General Public
+ * License. You may obtain a copy of the GNU General Public License
+ * Version 2 or later at the following locations:
+ *
+ * http://www.opensource.org/licenses/gpl-license.html
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+
+#include <linux/mm.h>
+#include <linux/delay.h>
+#include <linux/clk.h>
+#include <linux/io.h>
+
+#include <asm/clkdev.h>
+
+#include <mach/hardware.h>
+#include <mach/common.h>
+#include <mach/clock.h>
+
+#include "crm_regs.h"
+
+static void __iomem *pll_base[] = {
+	MX51_DPLL1_BASE,
+	MX51_DPLL2_BASE,
+	MX51_DPLL3_BASE,
+};
+
+/* External clock values passed-in by the board code */
+static unsigned long external_high_reference, external_low_reference;
+static unsigned long oscillator_reference, ckih2_reference;
+
+static struct clk osc_clk;
+static struct clk pll1_main_clk;
+static struct clk pll1_sw_clk;
+static struct clk pll2_sw_clk;
+static struct clk pll3_sw_clk;
+static struct clk lp_apm_clk;
+static struct clk periph_apm_clk;
+static struct clk ahb_clk;
+static struct clk ipg_clk;
+
+#define MAX_DPLL_WAIT_TRIES	1000 /* 1000 * udelay(1) = 1ms */
+
+static int _clk_ccgr_enable(struct clk *clk)
+{
+	u32 reg;
+
+	reg = __raw_readl(clk->enable_reg);
+	reg |= MXC_CCM_CCGRx_MOD_ON << clk->enable_shift;
+	__raw_writel(reg, clk->enable_reg);
+
+	return 0;
+}
+
+static void _clk_ccgr_disable(struct clk *clk)
+{
+	u32 reg;
+	reg = __raw_readl(clk->enable_reg);
+	reg &= ~(MXC_CCM_CCGRx_MOD_OFF << clk->enable_shift);
+	__raw_writel(reg, clk->enable_reg);
+
+}
+
+static void _clk_ccgr_disable_inwait(struct clk *clk)
+{
+	u32 reg;
+
+	reg = __raw_readl(clk->enable_reg);
+	reg &= ~(MXC_CCM_CCGRx_CG_MASK << clk->enable_shift);
+	reg |= MXC_CCM_CCGRx_MOD_IDLE << clk->enable_shift;
+	__raw_writel(reg, clk->enable_reg);
+}
+
+/*
+ * For the 4-to-1 muxed input clock
+ */
+static inline u32 _get_mux(struct clk *parent, struct clk *m0,
+			   struct clk *m1, struct clk *m2, struct clk *m3)
+{
+	if (parent == m0)
+		return 0;
+	else if (parent == m1)
+		return 1;
+	else if (parent == m2)
+		return 2;
+	else if (parent == m3)
+		return 3;
+	else
+		BUG();
+
+	return -EINVAL;
+}

arch/arm/mach-mx5/clock.c line 106

Quoted 10 lines
arch/arm/mach-mx5/clock.c new file +10 -0
+
+static inline void __iomem *_get_pll_base(struct clk *pll)
+{
+	if (pll == &pll1_main_clk)
+		return pll_base[0];
+	else if (pll == &pll2_sw_clk)
+		return pll_base[1];
+	else if (pll == &pll3_sw_clk)
+		return pll_base[2];
+	else

I see no purpose for the pll_base[] array. It is used only here and you can return the values directly.

Quoted 159 lines
arch/arm/mach-mx5/clock.c new file +159 -0
+		BUG();
+
+	return NULL;
+}
+
+static unsigned long clk_pll_get_rate(struct clk *clk)
+{
+	long mfi, mfn, mfd, pdf, ref_clk, mfn_abs;
+	unsigned long dp_op, dp_mfd, dp_mfn, dp_ctl, pll_hfsm, dbl;
+	void __iomem *pllbase;
+	s64 temp;
+	unsigned long parent_rate;
+
+	parent_rate = clk_get_rate(clk->parent);
+
+	pllbase = _get_pll_base(clk);
+
+	dp_ctl = __raw_readl(pllbase + MXC_PLL_DP_CTL);
+	pll_hfsm = dp_ctl & MXC_PLL_DP_CTL_HFSM;
+	dbl = dp_ctl & MXC_PLL_DP_CTL_DPDCK0_2_EN;
+
+	if (pll_hfsm == 0) {
+		dp_op = __raw_readl(pllbase + MXC_PLL_DP_OP);
+		dp_mfd = __raw_readl(pllbase + MXC_PLL_DP_MFD);
+		dp_mfn = __raw_readl(pllbase + MXC_PLL_DP_MFN);
+	} else {
+		dp_op = __raw_readl(pllbase + MXC_PLL_DP_HFS_OP);
+		dp_mfd = __raw_readl(pllbase + MXC_PLL_DP_HFS_MFD);
+		dp_mfn = __raw_readl(pllbase + MXC_PLL_DP_HFS_MFN);
+	}
+	pdf = dp_op & MXC_PLL_DP_OP_PDF_MASK;
+	mfi = (dp_op & MXC_PLL_DP_OP_MFI_MASK) >> MXC_PLL_DP_OP_MFI_OFFSET;
+	mfi = (mfi <= 5) ? 5 : mfi;
+	mfd = dp_mfd & MXC_PLL_DP_MFD_MASK;
+	mfn = mfn_abs = dp_mfn & MXC_PLL_DP_MFN_MASK;
+	/* Sign extend to 32-bits */
+	if (mfn >= 0x04000000) {
+		mfn |= 0xFC000000;
+		mfn_abs = -mfn;
+	}
+
+	ref_clk = 2 * parent_rate;
+	if (dbl != 0)
+		ref_clk *= 2;
+
+	ref_clk /= (pdf + 1);
+	temp = (u64) ref_clk * mfn_abs;
+	do_div(temp, mfd + 1);
+	if (mfn < 0)
+		temp = -temp;
+	temp = (ref_clk * mfi) + temp;
+
+	return temp;
+}
+
+static int _clk_pll_set_rate(struct clk *clk, unsigned long rate)
+{
+	u32 reg;
+	void __iomem *pllbase;
+
+	long mfi, pdf, mfn, mfd = 999999;
+	s64 temp64;
+	unsigned long quad_parent_rate;
+	unsigned long pll_hfsm, dp_ctl;
+	unsigned long parent_rate;
+
+	parent_rate = clk_get_rate(clk->parent);
+
+	pllbase = _get_pll_base(clk);
+
+	quad_parent_rate = 4 * parent_rate;
+	pdf = mfi = -1;
+	while (++pdf < 16 && mfi < 5)
+		mfi = rate * (pdf+1) / quad_parent_rate;
+	if (mfi > 15)
+		return -1;
+	pdf--;
+
+	temp64 = rate * (pdf+1) - quad_parent_rate * mfi;
+	do_div(temp64, quad_parent_rate/1000000);
+	mfn = (long)temp64;
+
+	dp_ctl = __raw_readl(pllbase + MXC_PLL_DP_CTL);
+	/* use dpdck0_2 */
+	__raw_writel(dp_ctl | 0x1000L, pllbase + MXC_PLL_DP_CTL);
+	pll_hfsm = dp_ctl & MXC_PLL_DP_CTL_HFSM;
+	if (pll_hfsm == 0) {
+		reg = mfi << 4 | pdf;
+		__raw_writel(reg, pllbase + MXC_PLL_DP_OP);
+		__raw_writel(mfd, pllbase + MXC_PLL_DP_MFD);
+		__raw_writel(mfn, pllbase + MXC_PLL_DP_MFN);
+	} else {
+		reg = mfi << 4 | pdf;
+		__raw_writel(reg, pllbase + MXC_PLL_DP_HFS_OP);
+		__raw_writel(mfd, pllbase + MXC_PLL_DP_HFS_MFD);
+		__raw_writel(mfn, pllbase + MXC_PLL_DP_HFS_MFN);
+	}
+
+	return 0;
+}
+
+static int _clk_pll_enable(struct clk *clk)
+{
+	u32 reg;
+	void __iomem *pllbase;
+	int i = 0;
+
+	pllbase = _get_pll_base(clk);
+	reg = __raw_readl(pllbase + MXC_PLL_DP_CTL) | MXC_PLL_DP_CTL_UPEN;
+	__raw_writel(reg, pllbase + MXC_PLL_DP_CTL);
+
+	/* Wait for lock */
+	while ((!(__raw_readl(pllbase + MXC_PLL_DP_CTL) & MXC_PLL_DP_CTL_LRF))
+		&& i < MAX_DPLL_WAIT_TRIES) {
+		i++;
+		udelay(1);
+	}
+
+	if (i == MAX_DPLL_WAIT_TRIES) {
+		printk(KERN_ERR "MX5: pll locking failed\n");
+		return -EINVAL;
+	}
+
+	return 0;
+}
+
+static void _clk_pll_disable(struct clk *clk)
+{
+	u32 reg;
+	void __iomem *pllbase;
+
+	pllbase = _get_pll_base(clk);
+	reg = __raw_readl(pllbase + MXC_PLL_DP_CTL) & ~MXC_PLL_DP_CTL_UPEN;
+	__raw_writel(reg, pllbase + MXC_PLL_DP_CTL);
+}
+
+static int _clk_pll1_sw_set_parent(struct clk *clk, struct clk *parent)
+{
+	u32 reg;
+
+	reg = __raw_readl(MXC_CCM_CCSR);
+
+	/* When switching from pll_main_clk to a bypass clock, first select a
+	   multiplexed clock in 'step_sel', then shift the glitchless mux
+	   'pll1_sw_clk_sel'.
+	   When switching back, do it in reverse order
+	*/
+	if (parent == &pll1_main_clk) {
+		/* Switch to pll1_main_clk */
+		reg &= ~MXC_CCM_CCSR_PLL1_SW_CLK_SEL;
+		__raw_writel(reg, MXC_CCM_CCSR);
+		/* step_clk mux switched to lp_apm, to save power. */
+		reg = __raw_readl(MXC_CCM_CCSR);
+		reg = (reg & ~MXC_CCM_CCSR_STEP_SEL_MASK) |
+			(MXC_CCM_CCSR_STEP_SEL_LP_APM <<
+				MXC_CCM_CCSR_STEP_SEL_OFFSET);
+	} else {
+		if (parent == &lp_apm_clk) {
+			reg = (reg & ~MXC_CCM_CCSR_STEP_SEL_MASK) |

arch/arm/mach-mx5/clock.c line 275

Quoted 10 lines
arch/arm/mach-mx5/clock.c new file +10 -0
+				(MXC_CCM_CCSR_STEP_SEL_LP_APM <<
+					MXC_CCM_CCSR_STEP_SEL_OFFSET);
+		} else  if (parent == &pll2_sw_clk) {
+			reg = (reg & ~MXC_CCM_CCSR_STEP_SEL_MASK) |
+				(MXC_CCM_CCSR_STEP_SEL_PLL2_DIVIDED <<
+					MXC_CCM_CCSR_STEP_SEL_OFFSET);
+		} else  if (parent == &pll3_sw_clk) {
+			reg = (reg & ~MXC_CCM_CCSR_STEP_SEL_MASK) |
+				(MXC_CCM_CCSR_STEP_SEL_PLL3_DIVIDED <<
+					MXC_CCM_CCSR_STEP_SEL_OFFSET);

Can we write this as

			reg &= ~MXC_CCM_CCSR_STEP_SEL_MASK;
			reg |= MXC_CCM_CCSR_STEP_SEL_PLL3_DIVIDED <<
					MXC_CCM_CCSR_STEP_SEL_OFFSET;

At least for me this is much easier to read. Also, the &= part can be outside the if clause.

Quoted 20 lines
arch/arm/mach-mx5/clock.c new file +20 -0
+		} else
+			return -EINVAL;
+
+		__raw_writel(reg, MXC_CCM_CCSR);
+		/* Switch to step_clk */
+		reg = __raw_readl(MXC_CCM_CCSR);
+		reg |= MXC_CCM_CCSR_PLL1_SW_CLK_SEL;
+	}
+	__raw_writel(reg, MXC_CCM_CCSR);
+	return 0;
+}
+
+static unsigned long clk_pll1_sw_get_rate(struct clk *clk)
+{
+	u32 reg, div;
+	unsigned long parent_rate;
+
+	parent_rate = clk_get_rate(clk->parent);
+
+	div = 1;

arch/arm/mach-mx5/clock.c line 305

Quoted 10 lines
arch/arm/mach-mx5/clock.c new file +10 -0
+	reg = __raw_readl(MXC_CCM_CCSR);
+
+	if (clk->parent == &pll2_sw_clk) {
+		div = ((reg & MXC_CCM_CCSR_PLL2_PODF_MASK) >>
+		       MXC_CCM_CCSR_PLL2_PODF_OFFSET) + 1;
+	} else if (clk->parent == &pll3_sw_clk) {
+		div = ((reg & MXC_CCM_CCSR_PLL3_PODF_MASK) >>
+		       MXC_CCM_CCSR_PLL3_PODF_OFFSET) + 1;
+	}
+	return parent_rate / div;

This will return parent rate if the parent is not pll2_sw_clk and not pll3_sw_clk. Is this intended? If yes, you could write

	} else
		div = 1;

to emphasize this is not an accident.

arch/arm/mach-mx5/clock.c line 317

Quoted 12 lines
arch/arm/mach-mx5/clock.c new file +12 -0
+}
+
+static int _clk_pll2_sw_set_parent(struct clk *clk, struct clk *parent)
+{
+	u32 reg;
+
+	reg = __raw_readl(MXC_CCM_CCSR);
+
+	if (parent == &pll2_sw_clk)
+		reg &= ~MXC_CCM_CCSR_PLL2_SW_CLK_SEL;
+	else
+		reg |= MXC_CCM_CCSR_PLL2_SW_CLK_SEL;

What's the other clock in the else part? I think there is a check missing.

Quoted 51 lines
arch/arm/mach-mx5/clock.c new file +51 -0
+
+	__raw_writel(reg, MXC_CCM_CCSR);
+	return 0;
+}
+
+static int _clk_lp_apm_set_parent(struct clk *clk, struct clk *parent)
+{
+	u32 reg;
+
+	if (parent == &osc_clk)
+		reg = __raw_readl(MXC_CCM_CCSR) & ~MXC_CCM_CCSR_LP_APM_SEL;
+	else
+		return -EINVAL;
+
+	__raw_writel(reg, MXC_CCM_CCSR);
+
+	return 0;
+}
+
+static unsigned long clk_arm_get_rate(struct clk *clk)
+{
+	u32 cacrr, div;
+	unsigned long parent_rate;
+
+	parent_rate = clk_get_rate(clk->parent);
+	cacrr = __raw_readl(MXC_CCM_CACRR);
+	div = (cacrr & MXC_CCM_CACRR_ARM_PODF_MASK) + 1;
+
+	return parent_rate / div;
+}
+
+static int _clk_periph_apm_set_parent(struct clk *clk, struct clk *parent)
+{
+	u32 reg, mux;
+	int i = 0;
+
+	mux = _get_mux(parent, &pll1_sw_clk, &pll3_sw_clk, &lp_apm_clk, NULL);
+
+	reg = __raw_readl(MXC_CCM_CBCMR) & ~MXC_CCM_CBCMR_PERIPH_CLK_SEL_MASK;
+	reg |= mux << MXC_CCM_CBCMR_PERIPH_CLK_SEL_OFFSET;
+	__raw_writel(reg, MXC_CCM_CBCMR);
+
+	/* Wait for lock */
+	while ((__raw_readl(MXC_CCM_CDHIPR) & MXC_CCM_CDHIPR_PERIPH_CLK_SEL_BUSY)
+		&& i < MAX_DPLL_WAIT_TRIES) {
+		i++;
+		udelay(1);
+	}
+
+	if (i == MAX_DPLL_WAIT_TRIES) {
+		printk(KERN_ERR "MX5: Set parent for periph_apm clock failed\n");

arch/arm/mach-mx5/clock.c line 378

Quoted 10 lines
arch/arm/mach-mx5/clock.c new file +10 -0
+		return -EINVAL;
+	}
+
+	return 0;
+}
+
+static unsigned long clk_main_bus_get_rate(struct clk *clk)
+{
+	return clk_get_rate(clk->parent);
+}

The generic code will automatically return the parent rate if the get_rate field is set to NULL.

Quoted 19 lines
arch/arm/mach-mx5/clock.c new file +19 -0
+
+static int _clk_main_bus_set_parent(struct clk *clk, struct clk *parent)
+{
+	u32 reg;
+
+	reg = __raw_readl(MXC_CCM_CBCDR);
+
+	if (parent == &pll2_sw_clk)
+		reg &= ~MXC_CCM_CBCDR_PERIPH_CLK_SEL;
+	else if (parent == &periph_apm_clk)
+		reg |= MXC_CCM_CBCDR_PERIPH_CLK_SEL;
+	else
+		return -EINVAL;
+
+	__raw_writel(reg, MXC_CCM_CBCDR);
+
+	return 0;
+}
+

[snip]

arch/arm/mach-mx5/clock.c line 796

Quoted 6 lines
arch/arm/mach-mx5/clock.c new file +6 -0
+
+static void clk_tree_init(void)
+{
+	u32 reg;
+
+	ipg_perclk.set_parent(&ipg_perclk, &lp_apm_clk);

Something is wrong here. Here you set the ipg_perclk parent. _clk_ipg_per_set_parent will then set the MXC_CCM_CBCMR_PERCLK_IPG_CLK_SEL and MXC_CCM_CBCMR_PERCLK_LP_APM_CLK_SEL bits accordingly...

Quoted 17 lines
arch/arm/mach-mx5/clock.c new file +17 -0
+
+	/*
+	 * Initialise the IPG PER CLK dividers to 3. IPG_PER_CLK should be at
+	 * 8MHz, its derived from lp_apm.
+	 * FIXME: Verify if true for all boards
+	 */
+	reg = __raw_readl(MXC_CCM_CBCDR);
+	reg &= ~MXC_CCM_CBCDR_PERCLK_PRED1_MASK;
+	reg &= ~MXC_CCM_CBCDR_PERCLK_PRED2_MASK;
+	reg &= ~MXC_CCM_CBCDR_PERCLK_PODF_MASK;
+	reg |= (2 << MXC_CCM_CBCDR_PERCLK_PRED1_OFFSET);
+	__raw_writel(reg, MXC_CCM_CBCDR);
+
+	/* set parent for pll1, pll2 and pll3 */
+	pll1_main_clk.parent = &osc_clk;
+	pll2_sw_clk.parent = &osc_clk;
+	pll3_sw_clk.parent = &osc_clk;

arch/arm/mach-mx5/clock.c line 823

Quoted 10 lines
arch/arm/mach-mx5/clock.c new file +10 -0
+
+	/* set ipg_perclk parent */
+	ipg_perclk.parent = &lp_apm_clk;
+	reg = __raw_readl(MXC_CCM_CBCMR);
+	if ((reg & MXC_CCM_CBCMR_PERCLK_IPG_CLK_SEL) != 0) {
+		ipg_perclk.parent = &ipg_clk;
+	} else {
+		if ((reg & MXC_CCM_CBCMR_PERCLK_LP_APM_CLK_SEL) == 0)
+			ipg_perclk.parent = &main_bus_clk;
+	}

...And here you set the parent according to the register bits. What's the intention here? Do you want to keep the bootloader settings or do you want to overwrite them with a known value?

Quoted 46 lines
arch/arm/mach-mx5/clock.c new file +25 -0
+}
+
+int __init mx51_clocks_init(unsigned long ckil, unsigned long osc,
+			unsigned long ckih1, unsigned long ckih2)
+{
+	int i;
+
+	external_low_reference = ckil;
+	external_high_reference = ckih1;
+	ckih2_reference = ckih2;
+	oscillator_reference = osc;
+
+	for (i = 0; i < ARRAY_SIZE(lookups); i++)
+		clkdev_add(&lookups[i]);
+
+	clk_tree_init();
+
+	clk_enable(&cpu_clk);
+	clk_enable(&main_bus_clk);
+
+	/* System timer */
+	mxc_timer_init(&gpt_clk, MX51_IO_ADDRESS(MX51_GPT1_BASE_ADDR),
+		MX51_MXC_INT_GPT);
+	return 0;
+}
arch/arm/mach-mx5/cpu.c new file +15 -0
new file mode 100644
index 0000000..93f1d5a
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2008-2009 Freescale Semiconductor, Inc. All Rights Reserved.
+ *
+ * The code contained herein is licensed under the GNU General Public
+ * License. You may obtain a copy of the GNU General Public License
+ * Version 2 or later at the following locations:
+ *
+ * http://www.opensource.org/licenses/gpl-license.html
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ * This file contains the CPU initialization code.
+ */
+
+#include <linux/types.h>
+#include <linux/kernel.h>

arch/arm/mach-mx5/cpu.c line 25

Quoted 10 lines
arch/arm/mach-mx5/cpu.c new file +10 -0
+#include <linux/init.h>
+#include <mach/hardware.h>
+#include <asm/io.h>
+
+static int __init post_cpu_init(void)
+{
+	unsigned int reg;
+	void __iomem *base;
+
+	if (cpu_is_mx51()) {
	if (!cpu_is_mx51())
		return 0;

please. This way we have one indention level more in case this function gets more complicated.

Quoted 25 lines
arch/arm/mach-mx5/cpu.c new file +20 -0
+		base = MX51_IO_ADDRESS(MX51_AIPS1_BASE_ADDR);
+		__raw_writel(0x0, base + 0x40);
+		__raw_writel(0x0, base + 0x44);
+		__raw_writel(0x0, base + 0x48);
+		__raw_writel(0x0, base + 0x4C);
+		reg = __raw_readl(base + 0x50) & 0x00FFFFFF;
+		__raw_writel(reg, base + 0x50);
+
+		base = MX51_IO_ADDRESS(MX51_AIPS2_BASE_ADDR);
+		__raw_writel(0x0, base + 0x40);
+		__raw_writel(0x0, base + 0x44);
+		__raw_writel(0x0, base + 0x48);
+		__raw_writel(0x0, base + 0x4C);
+		reg = __raw_readl(base + 0x50) & 0x00FFFFFF;
+		__raw_writel(reg, base + 0x50);
+	}
+	return 0;
+}
+
+postcore_initcall(post_cpu_init);
arch/arm/mach-mx5/crm_regs.h new file +0 -0
new file mode 100644
index 0000000..c776b9a

[snip]

Quoted 15 lines
arch/arm/mach-mx5/devices.c new file +9 -0
new file mode 100644
index 0000000..55eb089
@@ -0,0 +1,96 @@
+/*
+ * Copyright 2009 Amit Kucheria <[email protected]>
+ *
+ * The code contained herein is licensed under the GNU General Public
+ * License. You may obtain a copy of the GNU General Public License
+ * Version 2 or later at the following locations:
+ *
+ * http://www.opensource.org/licenses/gpl-license.html
+ * http://www.gnu.org/copyleft/gpl.html

arch/arm/mach-mx5/devices.c line 19

Quoted 10 lines
arch/arm/mach-mx5/devices.c new file +10 -0
+ */
+
+#include <linux/platform_device.h>
+#include <mach/hardware.h>
+#include <mach/imx-uart.h>
+
+static struct resource uart0[] = {
+	{
+		.start = MX51_UART1_BASE_ADDR,
+		.end = MX51_UART1_BASE_ADDR + 0x0B5,

You can safely write MX51_UART1_BASE_ADDR + 0xfff here because that's the register space this device actually has. The last register in the datasheet is 0xb4 anyway and with 32bit register accesses the correct value here would be 0xb7.

Quoted 266 lines
arch/arm/mach-mx5/devices.c new file +77 -0
+		.flags = IORESOURCE_MEM,
+	}, {
+		.start = MX51_MXC_INT_UART1,
+		.end = MX51_MXC_INT_UART1,
+		.flags = IORESOURCE_IRQ,
+	},
+};
+
+struct platform_device mxc_uart_device0 = {
+	.name = "imx-uart",
+	.id = 0,
+	.resource = uart0,
+	.num_resources = ARRAY_SIZE(uart0),
+};
+
+static struct resource uart1[] = {
+	{
+		.start = MX51_UART2_BASE_ADDR,
+		.end = MX51_UART2_BASE_ADDR + 0x0B5,
+		.flags = IORESOURCE_MEM,
+	}, {
+		.start = MX51_MXC_INT_UART2,
+		.end = MX51_MXC_INT_UART2,
+		.flags = IORESOURCE_IRQ,
+	},
+};
+
+struct platform_device mxc_uart_device1 = {
+	.name = "imx-uart",
+	.id = 1,
+	.resource = uart1,
+	.num_resources = ARRAY_SIZE(uart1),
+};
+
+static struct resource uart2[] = {
+	{
+		.start = MX51_UART3_BASE_ADDR,
+		.end = MX51_UART3_BASE_ADDR + 0x0B5,
+		.flags = IORESOURCE_MEM,
+	}, {
+		.start = MX51_MXC_INT_UART3,
+		.end = MX51_MXC_INT_UART3,
+		.flags = IORESOURCE_IRQ,
+	},
+};
+
+struct platform_device mxc_uart_device2 = {
+	.name = "imx-uart",
+	.id = 2,
+	.resource = uart2,
+	.num_resources = ARRAY_SIZE(uart2),
+};
+
+static struct resource mxc_fec_resources[] = {
+	{
+		.start	= MX51_MXC_FEC_BASE_ADDR,
+		.end	= MX51_MXC_FEC_BASE_ADDR + 0xfff,
+		.flags	= IORESOURCE_MEM,
+	}, {
+		.start	= MX51_MXC_INT_FEC,
+		.end	= MX51_MXC_INT_FEC,
+		.flags	= IORESOURCE_IRQ,
+	},
+};
+
+struct platform_device mxc_fec_device = {
+	.name = "fec",
+	.id = 0,
+	.num_resources = ARRAY_SIZE(mxc_fec_resources),
+	.resource = mxc_fec_resources,
+};
+
+/* Dummy definition to allow compiling in AVIC and TZIC simultaneously */
+int __init mxc_register_gpios(void)
+{
+	return 0;
+}
arch/arm/mach-mx5/devices.h new file +4 -0
new file mode 100644
index 0000000..f339ab8
@@ -0,0 +1,4 @@
+extern struct platform_device mxc_uart_device0;
+extern struct platform_device mxc_uart_device1;
+extern struct platform_device mxc_uart_device2;
+extern struct platform_device mxc_fec_device;
arch/arm/mach-mx5/mm.c new file +88 -0
new file mode 100644
index 0000000..d66c31a
@@ -0,0 +1,88 @@
+/*
+ * Copyright 2008-2009 Freescale Semiconductor, Inc. All Rights Reserved.
+ *
+ * The code contained herein is licensed under the GNU General Public
+ * License.  You may obtain a copy of the GNU General Public License
+ * Version 2 or later at the following locations:
+ *
+ * http://www.opensource.org/licenses/gpl-license.html
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ * Create static mapping between physical to virtual memory.
+ */
+
+#include <linux/mm.h>
+#include <linux/init.h>
+
+#include <asm/mach/map.h>
+
+#include <mach/hardware.h>
+#include <mach/common.h>
+#include <mach/iomux-v3.h>
+
+/*
+ * Define the MX51 memory map.
+ */
+static struct map_desc mxc_io_desc[] __initdata = {
+	{
+	 .virtual = MX51_IRAM_BASE_ADDR_VIRT,
+	 .pfn = __phys_to_pfn(MX51_IRAM_BASE_ADDR),
+	 .length = MX51_IRAM_SIZE,
+	 .type = MT_DEVICE},
+	{
+	 .virtual = MX51_DEBUG_BASE_ADDR_VIRT,
+	 .pfn = __phys_to_pfn(MX51_DEBUG_BASE_ADDR),
+	 .length = MX51_DEBUG_SIZE,
+	 .type = MT_DEVICE},
+	{
+	 .virtual = MX51_TZIC_BASE_ADDR_VIRT,
+	 .pfn = __phys_to_pfn(MX51_TZIC_BASE_ADDR),
+	 .length = MX51_TZIC_SIZE,
+	 .type = MT_DEVICE},
+	{
+	 .virtual = MX51_AIPS1_BASE_ADDR_VIRT,
+	 .pfn = __phys_to_pfn(MX51_AIPS1_BASE_ADDR),
+	 .length = MX51_AIPS1_SIZE,
+	 .type = MT_DEVICE},
+	{
+	 .virtual = MX51_SPBA0_BASE_ADDR_VIRT,
+	 .pfn = __phys_to_pfn(MX51_SPBA0_BASE_ADDR),
+	 .length = MX51_SPBA0_SIZE,
+	 .type = MT_DEVICE},
+	{
+	 .virtual = MX51_AIPS2_BASE_ADDR_VIRT,
+	 .pfn = __phys_to_pfn(MX51_AIPS2_BASE_ADDR),
+	 .length = MX51_AIPS2_SIZE,
+	 .type = MT_DEVICE},
+	{
+	 .virtual = MX51_NFC_AXI_BASE_ADDR_VIRT,
+	 .pfn = __phys_to_pfn(MX51_NFC_AXI_BASE_ADDR),
+	 .length = MX51_NFC_AXI_SIZE,
+	 .type = MT_DEVICE},
+};
+
+/*
+ * This function initializes the memory map. It is called during the
+ * system startup to create static physical to virtual memory mappings
+ * for the IO modules.
+ */
+void __init mx51_map_io(void)
+{
+	u32 tzic_addr;
+
+	if (mx51_revision() < MX51_CHIP_REV_2_0)
+		tzic_addr = 0x8FFFC000;
+	else
+		tzic_addr = 0xE0003000;
+	mxc_io_desc[2].pfn =  __phys_to_pfn(tzic_addr);
+
+	mxc_set_cpu_type(MXC_CPU_MX51);
+	mxc_iomux_v3_init(MX51_IO_ADDRESS(MX51_IOMUXC_BASE_ADDR));
+	mxc_arch_reset_init(MX51_IO_ADDRESS(MX51_WDOG_BASE_ADDR));
+	iotable_init(mxc_io_desc, ARRAY_SIZE(mxc_io_desc));
+}
+
+void __init mx51_init_irq(void)
+{
+	tzic_init_irq(MX51_IO_ADDRESS(MX51_TZIC_BASE_ADDR));
+}
arch/arm/plat-mxc/include/mach/common.h +1 -0
index 5250a3f..0a25576 100644
@@ -30,6 +30,7 @@ extern void mx25_init_irq(void);
 extern void mx27_init_irq(void);
 extern void mx31_init_irq(void);
 extern void mx35_init_irq(void);
+extern void mx51_init_irq(void);
 extern void mxc91231_init_irq(void);
 extern void mxc_timer_init(struct clk *timer_clk, void __iomem *, int);
 extern int mx1_clocks_init(unsigned long fref);
arch/arm/plat-mxc/include/mach/debug-macro.S +2 -2
index 9fe7300..9d41bfd 100644
@@ -49,8 +49,8 @@
 #error "CONFIG_DEBUG_LL is incompatible with multiple archs"
 #endif
 #include <mach/mx51.h>
-#define UART_PADDR	UART1_BASE_ADDR
-#define UART_VADDR	AIPS1_IO_ADDRESS(UART1_BASE_ADDR)
+#define UART_PADDR	MX51_UART1_BASE_ADDR
+#define UART_VADDR	MX51_AIPS1_IO_ADDRESS(MX51_UART1_BASE_ADDR)
 #endif
 
 #ifdef CONFIG_ARCH_MXC91231
arch/arm/plat-mxc/include/mach/iomux-mx51.h new file +52 -0
new file mode 100644
index 0000000..14df0f5
@@ -0,0 +1,340 @@
+/*
+ * Copyright 2009 Amit Kucheria <[email protected]> All Rights Reserved.
+ *
+ * The code contained herein is licensed under the GNU General Public
+ * License. You may obtain a copy of the GNU General Public License
+ * Version 2 or later at the following locations:
+ *
+ * http://www.opensource.org/licenses/gpl-license.html
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+
+#ifndef __MACH_IOMUX_MX51_H__
+#define __MACH_IOMUX_MX51_H__
+
+#include <mach/iomux-v3.h>
+
+/*
+ * various IOMUX alternate output functions (1-7)
+ */
+typedef enum iomux_config {
+	IOMUX_CONFIG_ALT0,
+	IOMUX_CONFIG_ALT1,
+	IOMUX_CONFIG_ALT2,
+	IOMUX_CONFIG_ALT3,
+	IOMUX_CONFIG_ALT4,
+	IOMUX_CONFIG_ALT5,
+	IOMUX_CONFIG_ALT6,
+	IOMUX_CONFIG_ALT7,
+	IOMUX_CONFIG_GPIO,	/* added to help user use GPIO mode */
+	IOMUX_CONFIG_SION = 0x1 << 4,	/* LOOPBACK:MUX SION bit */
+} iomux_pin_cfg_t;
+
+/* Pad control groupings */
+#define MX51_UART1_PAD_CTRL	(PAD_CTL_HYS | PAD_CTL_PKE | PAD_CTL_PUE | \
+				PAD_CTL_DSE_HIGH)
+#define MX51_UART2_PAD_CTRL	(PAD_CTL_PKE | PAD_CTL_PUE | PAD_CTL_DSE_HIGH | \
+				PAD_CTL_SRE_FAST)
+#define MX51_UART3_PAD_CTRL	(PAD_CTL_PKE | PAD_CTL_DSE_HIGH | \
+				PAD_CTL_SRE_FAST)
+
+/*
+ * The naming convention for the pad modes is MX51_PAD_<padname>__<padmode>
+ * If <padname> or <padmode> refers to a GPIO, it is named
+ * GPIO_<unit>_<num> see also iomux-v3.h
+ */
+
+/* REVISIT: This was converted using scripts from existing Freescale code to
+ * this form used upstream. Need to verify the name format.
+ */
+
+/*						PAD      MUX   ALT INPSE PATH PADCTRL */
+

arch/arm/plat-mxc/include/mach/iomux-mx51.h line 62

Quoted 10 lines
arch/arm/plat-mxc/include/mach/iomux-mx51.h new file +10 -0
+
+/* UART1 */
+#define MX51_BABBAGE_PAD_UART1_RXD__UART1_RXD	\
+	IOMUX_PAD(0x618, 0x228,	IOMUX_CONFIG_ALT0, 0x9e4, 0, MX51_UART1_PAD_CTRL | PAD_CTL_SRE_FAST)
+#define MX51_BABBAGE_PAD_UART1_TXD__UART1_TXD	\
+	IOMUX_PAD(0x61C, 0x22C, IOMUX_CONFIG_ALT0, 0x0, 0, MX51_UART1_PAD_CTRL | PAD_CTL_SRE_FAST)
+#define MX51_BABBAGE_PAD_UART1_RTS__UART1_RTS	\
+	IOMUX_PAD(0x620, 0x230, IOMUX_CONFIG_ALT0, 0x9e0, 0, MX51_UART1_PAD_CTRL)
+#define MX51_BABBAGE_PAD_UART1_CTS__UART1_CTS	\
+	IOMUX_PAD(0x624, 0x234, IOMUX_CONFIG_ALT0, 0x0, 0, MX51_UART1_PAD_CTRL)

I remember last time I said that you should move these macros here. I think the situation is like this:

1) These are either known good values for the uart pins and therefore shouldn't have BABBAGE in their name.
2) There is something babbage specific in them, in this case they should be in the board specific file.

I vote for 1) here.

arch/arm/plat-mxc/include/mach/iomux-mx51.h line 75

Quoted 13 lines
arch/arm/plat-mxc/include/mach/iomux-mx51.h new file +13 -0
+
+/* UART2 */
+#define MX51_BABBAGE_PAD_UART2_RXD__UART2_RXD	IOMUX_PAD(0x628, 0x238, IOMUX_CONFIG_ALT0, 0x9ec, 2, MX51_UART2_PAD_CTRL)
+#define MX51_BABBAGE_PAD_UART2_TXD__UART2_TXD	IOMUX_PAD(0x62C, 0x23C, IOMUX_CONFIG_ALT0, 0x0, 0, MX51_UART2_PAD_CTRL)
+
+/* UART3 */
+#define MX51_BABBAGE_PAD_EIM_D25__UART3_RXD	IOMUX_PAD(0x414, 0x080, IOMUX_CONFIG_ALT3, 0x9f4, 0, MX51_UART3_PAD_CTRL)
+#define MX51_BABBAGE_PAD_EIM_D26__UART3_TXD	IOMUX_PAD(0x418, 0x084, IOMUX_CONFIG_ALT3, 0x0, 0, MX51_UART3_PAD_CTRL)
+#define MX51_BABBAGE_PAD_EIM_D27__UART3_RTS	IOMUX_PAD(0x41c, 0x088, IOMUX_CONFIG_ALT3, 0x9f0, 0, MX51_UART3_PAD_CTRL)
+#define MX51_BABBAGE_PAD_EIM_D24__UART3_CTS	IOMUX_PAD(0x410, 0x07c, IOMUX_CONFIG_ALT3, 0x0, 0, MX51_UART3_PAD_CTRL)
+
+#define MX51_BABBAGE_PAD_GPIO_1_8__GPIO1_8	IOMUX_PAD(0x814, 0x3E8, 0, 0x0, 1, (PAD_CTL_SRE_SLOW | PAD_CTL_DSE_MED | PAD_CTL_PUS_100K_UP |  PAD_CTL_HYS))
+

ditto

Sascha

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

Re: [PATCHv2 05/11] mxc: Core support for i.MX5 series of processors from Freescale

Quoted 27 lines · Sascha Hauer
Quoted 26 lines · Amit Kucheria

From: Amit Kucheria <[email protected]>

Add basic clock support, cpu identification, I/O mapping and serial port.

---
 arch/arm/mach-mx5/clock.c                    |  848 ++++++++++++++++++++++++++
 arch/arm/mach-mx5/cpu.c                      |   45 ++
 arch/arm/mach-mx5/crm_regs.h                 |  583 ++++++++++++++++++
 arch/arm/mach-mx5/devices.c                  |   96 +++
 arch/arm/mach-mx5/devices.h                  |    4 +
 arch/arm/mach-mx5/mm.c                       |   88 +++
 arch/arm/plat-mxc/include/mach/common.h      |    1 +
 arch/arm/plat-mxc/include/mach/debug-macro.S |    4 +-
 arch/arm/plat-mxc/include/mach/iomux-mx51.h  |  340 +++++++++++
 arch/arm/plat-mxc/include/mach/mx51.h        |  454 ++++++++++++++
 10 files changed, 2461 insertions(+), 2 deletions(-)
 create mode 100644 arch/arm/mach-mx5/clock.c
 create mode 100644 arch/arm/mach-mx5/cpu.c
 create mode 100644 arch/arm/mach-mx5/crm_regs.h
 create mode 100644 arch/arm/mach-mx5/devices.c
 create mode 100644 arch/arm/mach-mx5/devices.h
 create mode 100644 arch/arm/mach-mx5/mm.c
 create mode 100644 arch/arm/plat-mxc/include/mach/iomux-mx51.h
 create mode 100644 arch/arm/plat-mxc/include/mach/mx51.h
Quoted 5 lines

arch/arm/mach-mx5/clock.c

Quoted 1 line
arch/arm/mach-mx5/clock.c +0 -0

Can we rename this file to clock-mx51.c? We made this mistake on other i.MX platforms and ended with a clock.c and a clock-mx35.c in the same directory.

Will fix.

Quoted 106 lines
Quoted 106 lines

new file mode 100644
index 0000000..595f966

arch/arm/mach-mx5/clock.c new file +101 -0
@@ -0,0 +1,848 @@
+/*
+ * Copyright 2008-2010 Freescale Semiconductor, Inc. All Rights Reserved.
+ * Copyright (C) 2009-2010 Amit Kucheria <[email protected]>
+ *
+ * The code contained herein is licensed under the GNU General Public
+ * License. You may obtain a copy of the GNU General Public License
+ * Version 2 or later at the following locations:
+ *
+ * http://www.opensource.org/licenses/gpl-license.html
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+
+#include <linux/mm.h>
+#include <linux/delay.h>
+#include <linux/clk.h>
+#include <linux/io.h>
+
+#include <asm/clkdev.h>
+
+#include <mach/hardware.h>
+#include <mach/common.h>
+#include <mach/clock.h>
+
+#include "crm_regs.h"
+
+static void __iomem *pll_base[] = {
+	MX51_DPLL1_BASE,
+	MX51_DPLL2_BASE,
+	MX51_DPLL3_BASE,
+};
+
+/* External clock values passed-in by the board code */
+static unsigned long external_high_reference, external_low_reference;
+static unsigned long oscillator_reference, ckih2_reference;
+
+static struct clk osc_clk;
+static struct clk pll1_main_clk;
+static struct clk pll1_sw_clk;
+static struct clk pll2_sw_clk;
+static struct clk pll3_sw_clk;
+static struct clk lp_apm_clk;
+static struct clk periph_apm_clk;
+static struct clk ahb_clk;
+static struct clk ipg_clk;
+
+#define MAX_DPLL_WAIT_TRIES	1000 /* 1000 * udelay(1) = 1ms */
+
+static int _clk_ccgr_enable(struct clk *clk)
+{
+	u32 reg;
+
+	reg = __raw_readl(clk->enable_reg);
+	reg |= MXC_CCM_CCGRx_MOD_ON << clk->enable_shift;
+	__raw_writel(reg, clk->enable_reg);
+
+	return 0;
+}
+
+static void _clk_ccgr_disable(struct clk *clk)
+{
+	u32 reg;
+	reg = __raw_readl(clk->enable_reg);
+	reg &= ~(MXC_CCM_CCGRx_MOD_OFF << clk->enable_shift);
+	__raw_writel(reg, clk->enable_reg);
+
+}
+
+static void _clk_ccgr_disable_inwait(struct clk *clk)
+{
+	u32 reg;
+
+	reg = __raw_readl(clk->enable_reg);
+	reg &= ~(MXC_CCM_CCGRx_CG_MASK << clk->enable_shift);
+	reg |= MXC_CCM_CCGRx_MOD_IDLE << clk->enable_shift;
+	__raw_writel(reg, clk->enable_reg);
+}
+
+/*
+ * For the 4-to-1 muxed input clock
+ */
+static inline u32 _get_mux(struct clk *parent, struct clk *m0,
+			   struct clk *m1, struct clk *m2, struct clk *m3)
+{
+	if (parent == m0)
+		return 0;
+	else if (parent == m1)
+		return 1;
+	else if (parent == m2)
+		return 2;
+	else if (parent == m3)
+		return 3;
+	else
+		BUG();
+
+	return -EINVAL;
+}
+
+static inline void __iomem *_get_pll_base(struct clk *pll)
+{
+	if (pll == &pll1_main_clk)
+		return pll_base[0];
Quoted 8 lines

arch/arm/mach-mx5/clock.c line 106

Quoted 5 lines
arch/arm/mach-mx5/clock.c new file +5 -0
+	else if (pll == &pll2_sw_clk)
+		return pll_base[1];
+	else if (pll == &pll3_sw_clk)
+		return pll_base[2];
+	else

I see no purpose for the pll_base[] array. It is used only here and you can return the values directly.

Fixed.

Quoted 172 lines
Quoted 159 lines
arch/arm/mach-mx5/clock.c new file +159 -0
+		BUG();
+
+	return NULL;
+}
+
+static unsigned long clk_pll_get_rate(struct clk *clk)
+{
+	long mfi, mfn, mfd, pdf, ref_clk, mfn_abs;
+	unsigned long dp_op, dp_mfd, dp_mfn, dp_ctl, pll_hfsm, dbl;
+	void __iomem *pllbase;
+	s64 temp;
+	unsigned long parent_rate;
+
+	parent_rate = clk_get_rate(clk->parent);
+
+	pllbase = _get_pll_base(clk);
+
+	dp_ctl = __raw_readl(pllbase + MXC_PLL_DP_CTL);
+	pll_hfsm = dp_ctl & MXC_PLL_DP_CTL_HFSM;
+	dbl = dp_ctl & MXC_PLL_DP_CTL_DPDCK0_2_EN;
+
+	if (pll_hfsm == 0) {
+		dp_op = __raw_readl(pllbase + MXC_PLL_DP_OP);
+		dp_mfd = __raw_readl(pllbase + MXC_PLL_DP_MFD);
+		dp_mfn = __raw_readl(pllbase + MXC_PLL_DP_MFN);
+	} else {
+		dp_op = __raw_readl(pllbase + MXC_PLL_DP_HFS_OP);
+		dp_mfd = __raw_readl(pllbase + MXC_PLL_DP_HFS_MFD);
+		dp_mfn = __raw_readl(pllbase + MXC_PLL_DP_HFS_MFN);
+	}
+	pdf = dp_op & MXC_PLL_DP_OP_PDF_MASK;
+	mfi = (dp_op & MXC_PLL_DP_OP_MFI_MASK) >> MXC_PLL_DP_OP_MFI_OFFSET;
+	mfi = (mfi <= 5) ? 5 : mfi;
+	mfd = dp_mfd & MXC_PLL_DP_MFD_MASK;
+	mfn = mfn_abs = dp_mfn & MXC_PLL_DP_MFN_MASK;
+	/* Sign extend to 32-bits */
+	if (mfn >= 0x04000000) {
+		mfn |= 0xFC000000;
+		mfn_abs = -mfn;
+	}
+
+	ref_clk = 2 * parent_rate;
+	if (dbl != 0)
+		ref_clk *= 2;
+
+	ref_clk /= (pdf + 1);
+	temp = (u64) ref_clk * mfn_abs;
+	do_div(temp, mfd + 1);
+	if (mfn < 0)
+		temp = -temp;
+	temp = (ref_clk * mfi) + temp;
+
+	return temp;
+}
+
+static int _clk_pll_set_rate(struct clk *clk, unsigned long rate)
+{
+	u32 reg;
+	void __iomem *pllbase;
+
+	long mfi, pdf, mfn, mfd = 999999;
+	s64 temp64;
+	unsigned long quad_parent_rate;
+	unsigned long pll_hfsm, dp_ctl;
+	unsigned long parent_rate;
+
+	parent_rate = clk_get_rate(clk->parent);
+
+	pllbase = _get_pll_base(clk);
+
+	quad_parent_rate = 4 * parent_rate;
+	pdf = mfi = -1;
+	while (++pdf < 16 && mfi < 5)
+		mfi = rate * (pdf+1) / quad_parent_rate;
+	if (mfi > 15)
+		return -1;
+	pdf--;
+
+	temp64 = rate * (pdf+1) - quad_parent_rate * mfi;
+	do_div(temp64, quad_parent_rate/1000000);
+	mfn = (long)temp64;
+
+	dp_ctl = __raw_readl(pllbase + MXC_PLL_DP_CTL);
+	/* use dpdck0_2 */
+	__raw_writel(dp_ctl | 0x1000L, pllbase + MXC_PLL_DP_CTL);
+	pll_hfsm = dp_ctl & MXC_PLL_DP_CTL_HFSM;
+	if (pll_hfsm == 0) {
+		reg = mfi << 4 | pdf;
+		__raw_writel(reg, pllbase + MXC_PLL_DP_OP);
+		__raw_writel(mfd, pllbase + MXC_PLL_DP_MFD);
+		__raw_writel(mfn, pllbase + MXC_PLL_DP_MFN);
+	} else {
+		reg = mfi << 4 | pdf;
+		__raw_writel(reg, pllbase + MXC_PLL_DP_HFS_OP);
+		__raw_writel(mfd, pllbase + MXC_PLL_DP_HFS_MFD);
+		__raw_writel(mfn, pllbase + MXC_PLL_DP_HFS_MFN);
+	}
+
+	return 0;
+}
+
+static int _clk_pll_enable(struct clk *clk)
+{
+	u32 reg;
+	void __iomem *pllbase;
+	int i = 0;
+
+	pllbase = _get_pll_base(clk);
+	reg = __raw_readl(pllbase + MXC_PLL_DP_CTL) | MXC_PLL_DP_CTL_UPEN;
+	__raw_writel(reg, pllbase + MXC_PLL_DP_CTL);
+
+	/* Wait for lock */
+	while ((!(__raw_readl(pllbase + MXC_PLL_DP_CTL) & MXC_PLL_DP_CTL_LRF))
+		&& i < MAX_DPLL_WAIT_TRIES) {
+		i++;
+		udelay(1);
+	}
+
+	if (i == MAX_DPLL_WAIT_TRIES) {
+		printk(KERN_ERR "MX5: pll locking failed\n");
+		return -EINVAL;
+	}
+
+	return 0;
+}
+
+static void _clk_pll_disable(struct clk *clk)
+{
+	u32 reg;
+	void __iomem *pllbase;
+
+	pllbase = _get_pll_base(clk);
+	reg = __raw_readl(pllbase + MXC_PLL_DP_CTL) & ~MXC_PLL_DP_CTL_UPEN;
+	__raw_writel(reg, pllbase + MXC_PLL_DP_CTL);
+}
+
+static int _clk_pll1_sw_set_parent(struct clk *clk, struct clk *parent)
+{
+	u32 reg;
+
+	reg = __raw_readl(MXC_CCM_CCSR);
+
+	/* When switching from pll_main_clk to a bypass clock, first select a
+	   multiplexed clock in 'step_sel', then shift the glitchless mux
+	   'pll1_sw_clk_sel'.
+	   When switching back, do it in reverse order
+	*/
+	if (parent == &pll1_main_clk) {
+		/* Switch to pll1_main_clk */
+		reg &= ~MXC_CCM_CCSR_PLL1_SW_CLK_SEL;
+		__raw_writel(reg, MXC_CCM_CCSR);
+		/* step_clk mux switched to lp_apm, to save power. */
+		reg = __raw_readl(MXC_CCM_CCSR);
+		reg = (reg & ~MXC_CCM_CCSR_STEP_SEL_MASK) |
+			(MXC_CCM_CCSR_STEP_SEL_LP_APM <<
+				MXC_CCM_CCSR_STEP_SEL_OFFSET);
+	} else {
+		if (parent == &lp_apm_clk) {
+			reg = (reg & ~MXC_CCM_CCSR_STEP_SEL_MASK) |

arch/arm/mach-mx5/clock.c line 275

Quoted 10 lines
arch/arm/mach-mx5/clock.c new file +10 -0
+				(MXC_CCM_CCSR_STEP_SEL_LP_APM <<
+					MXC_CCM_CCSR_STEP_SEL_OFFSET);
+		} else  if (parent == &pll2_sw_clk) {
+			reg = (reg & ~MXC_CCM_CCSR_STEP_SEL_MASK) |
+				(MXC_CCM_CCSR_STEP_SEL_PLL2_DIVIDED <<
+					MXC_CCM_CCSR_STEP_SEL_OFFSET);
+		} else  if (parent == &pll3_sw_clk) {
+			reg = (reg & ~MXC_CCM_CCSR_STEP_SEL_MASK) |
+				(MXC_CCM_CCSR_STEP_SEL_PLL3_DIVIDED <<
+					MXC_CCM_CCSR_STEP_SEL_OFFSET);

Can we write this as

Quoted 6 lines
			reg &= ~MXC_CCM_CCSR_STEP_SEL_MASK;
			reg |= MXC_CCM_CCSR_STEP_SEL_PLL3_DIVIDED <<
					MXC_CCM_CCSR_STEP_SEL_OFFSET;

At least for me this is much easier to read. Also, the &= part can be outside the if clause.

Fixed per Eric's comments

Quoted 34 lines
Quoted 20 lines
arch/arm/mach-mx5/clock.c new file +20 -0
+		} else
+			return -EINVAL;
+
+		__raw_writel(reg, MXC_CCM_CCSR);
+		/* Switch to step_clk */
+		reg = __raw_readl(MXC_CCM_CCSR);
+		reg |= MXC_CCM_CCSR_PLL1_SW_CLK_SEL;
+	}
+	__raw_writel(reg, MXC_CCM_CCSR);
+	return 0;
+}
+
+static unsigned long clk_pll1_sw_get_rate(struct clk *clk)
+{
+	u32 reg, div;
+	unsigned long parent_rate;
+
+	parent_rate = clk_get_rate(clk->parent);
+
+	div = 1;

arch/arm/mach-mx5/clock.c line 305

Quoted 10 lines
arch/arm/mach-mx5/clock.c new file +10 -0
+	reg = __raw_readl(MXC_CCM_CCSR);
+
+	if (clk->parent == &pll2_sw_clk) {
+		div = ((reg & MXC_CCM_CCSR_PLL2_PODF_MASK) >>
+		       MXC_CCM_CCSR_PLL2_PODF_OFFSET) + 1;
+	} else if (clk->parent == &pll3_sw_clk) {
+		div = ((reg & MXC_CCM_CCSR_PLL3_PODF_MASK) >>
+		       MXC_CCM_CCSR_PLL3_PODF_OFFSET) + 1;
+	}
+	return parent_rate / div;

This will return parent rate if the parent is not pll2_sw_clk and not pll3_sw_clk. Is this intended? If yes, you could write

Quoted 4 lines
	} else
		div = 1;

to emphasize this is not an accident.

Fixed.

Quoted 7 lines
Quoted 7 lines
arch/arm/mach-mx5/clock.c new file +7 -0
+}
+
+static int _clk_pll2_sw_set_parent(struct clk *clk, struct clk *parent)
+{
+	u32 reg;
+
+	reg = __raw_readl(MXC_CCM_CCSR);
Quoted 8 lines

arch/arm/mach-mx5/clock.c line 317

Quoted 5 lines
arch/arm/mach-mx5/clock.c new file +5 -0
+
+	if (parent == &pll2_sw_clk)
+		reg &= ~MXC_CCM_CCSR_PLL2_SW_CLK_SEL;
+	else
+		reg |= MXC_CCM_CCSR_PLL2_SW_CLK_SEL;

What's the other clock in the else part? I think there is a check missing.

The other clock is the external pll2 bypass clock. And the reference manual indicates that the bit should only be enabled for testing.

Quoted 56 lines
Quoted 56 lines
arch/arm/mach-mx5/clock.c new file +56 -0
+
+	__raw_writel(reg, MXC_CCM_CCSR);
+	return 0;
+}
+
+static int _clk_lp_apm_set_parent(struct clk *clk, struct clk *parent)
+{
+	u32 reg;
+
+	if (parent == &osc_clk)
+		reg = __raw_readl(MXC_CCM_CCSR) & ~MXC_CCM_CCSR_LP_APM_SEL;
+	else
+		return -EINVAL;
+
+	__raw_writel(reg, MXC_CCM_CCSR);
+
+	return 0;
+}
+
+static unsigned long clk_arm_get_rate(struct clk *clk)
+{
+	u32 cacrr, div;
+	unsigned long parent_rate;
+
+	parent_rate = clk_get_rate(clk->parent);
+	cacrr = __raw_readl(MXC_CCM_CACRR);
+	div = (cacrr & MXC_CCM_CACRR_ARM_PODF_MASK) + 1;
+
+	return parent_rate / div;
+}
+
+static int _clk_periph_apm_set_parent(struct clk *clk, struct clk *parent)
+{
+	u32 reg, mux;
+	int i = 0;
+
+	mux = _get_mux(parent, &pll1_sw_clk, &pll3_sw_clk, &lp_apm_clk, NULL);
+
+	reg = __raw_readl(MXC_CCM_CBCMR) & ~MXC_CCM_CBCMR_PERIPH_CLK_SEL_MASK;
+	reg |= mux << MXC_CCM_CBCMR_PERIPH_CLK_SEL_OFFSET;
+	__raw_writel(reg, MXC_CCM_CBCMR);
+
+	/* Wait for lock */
+	while ((__raw_readl(MXC_CCM_CDHIPR) & MXC_CCM_CDHIPR_PERIPH_CLK_SEL_BUSY)
+		&& i < MAX_DPLL_WAIT_TRIES) {
+		i++;
+		udelay(1);
+	}
+
+	if (i == MAX_DPLL_WAIT_TRIES) {
+		printk(KERN_ERR "MX5: Set parent for periph_apm clock failed\n");
+		return -EINVAL;
+	}
+
+	return 0;
+}
Quoted 8 lines

arch/arm/mach-mx5/clock.c line 378

Quoted 5 lines
arch/arm/mach-mx5/clock.c new file +5 -0
+
+static unsigned long clk_main_bus_get_rate(struct clk *clk)
+{
+	return clk_get_rate(clk->parent);
+}

The generic code will automatically return the parent rate if the get_rate field is set to NULL.

OK. removing...

Quoted 56 lines
Quoted 19 lines
arch/arm/mach-mx5/clock.c new file +19 -0
+
+static int _clk_main_bus_set_parent(struct clk *clk, struct clk *parent)
+{
+	u32 reg;
+
+	reg = __raw_readl(MXC_CCM_CBCDR);
+
+	if (parent == &pll2_sw_clk)
+		reg &= ~MXC_CCM_CBCDR_PERIPH_CLK_SEL;
+	else if (parent == &periph_apm_clk)
+		reg |= MXC_CCM_CBCDR_PERIPH_CLK_SEL;
+	else
+		return -EINVAL;
+
+	__raw_writel(reg, MXC_CCM_CBCDR);
+
+	return 0;
+}
+

[snip]

arch/arm/mach-mx5/clock.c line 796

Quoted 6 lines
arch/arm/mach-mx5/clock.c new file +6 -0
+
+static void clk_tree_init(void)
+{
+	u32 reg;
+
+	ipg_perclk.set_parent(&ipg_perclk, &lp_apm_clk);

Something is wrong here. Here you set the ipg_perclk parent. _clk_ipg_per_set_parent will then set the MXC_CCM_CBCMR_PERCLK_IPG_CLK_SEL and MXC_CCM_CBCMR_PERCLK_LP_APM_CLK_SEL bits accordingly...

Quoted 23 lines
arch/arm/mach-mx5/clock.c new file +23 -0
+
+	/*
+	 * Initialise the IPG PER CLK dividers to 3. IPG_PER_CLK should be at
+	 * 8MHz, its derived from lp_apm.
+	 * FIXME: Verify if true for all boards
+	 */
+	reg = __raw_readl(MXC_CCM_CBCDR);
+	reg &= ~MXC_CCM_CBCDR_PERCLK_PRED1_MASK;
+	reg &= ~MXC_CCM_CBCDR_PERCLK_PRED2_MASK;
+	reg &= ~MXC_CCM_CBCDR_PERCLK_PODF_MASK;
+	reg |= (2 << MXC_CCM_CBCDR_PERCLK_PRED1_OFFSET);
+	__raw_writel(reg, MXC_CCM_CBCDR);
+
+	/* set parent for pll1, pll2 and pll3 */
+	pll1_main_clk.parent = &osc_clk;
+	pll2_sw_clk.parent = &osc_clk;
+	pll3_sw_clk.parent = &osc_clk;
+
+	/* set ipg_perclk parent */
+	ipg_perclk.parent = &lp_apm_clk;
+	reg = __raw_readl(MXC_CCM_CBCMR);
+	if ((reg & MXC_CCM_CBCMR_PERCLK_IPG_CLK_SEL) != 0) {
+		ipg_perclk.parent = &ipg_clk;
Quoted 8 lines

arch/arm/mach-mx5/clock.c line 823

Quoted 4 lines
arch/arm/mach-mx5/clock.c new file +4 -0
+	} else {
+		if ((reg & MXC_CCM_CBCMR_PERCLK_LP_APM_CLK_SEL) == 0)
+			ipg_perclk.parent = &main_bus_clk;
+	}

...And here you set the parent according to the register bits. What's the intention here? Do you want to keep the bootloader settings or do you want to overwrite them with a known value?

It does look pointless. Infact, since MXC_CCM_CBCMR_PERCLK_LP_APM_CLK_SEL is set because of the call on the top, this entire if statement does nothing new.

Quoted 60 lines
Quoted 46 lines
arch/arm/mach-mx5/clock.c new file +25 -0
+}
+
+int __init mx51_clocks_init(unsigned long ckil, unsigned long osc,
+			unsigned long ckih1, unsigned long ckih2)
+{
+	int i;
+
+	external_low_reference = ckil;
+	external_high_reference = ckih1;
+	ckih2_reference = ckih2;
+	oscillator_reference = osc;
+
+	for (i = 0; i < ARRAY_SIZE(lookups); i++)
+		clkdev_add(&lookups[i]);
+
+	clk_tree_init();
+
+	clk_enable(&cpu_clk);
+	clk_enable(&main_bus_clk);
+
+	/* System timer */
+	mxc_timer_init(&gpt_clk, MX51_IO_ADDRESS(MX51_GPT1_BASE_ADDR),
+		MX51_MXC_INT_GPT);
+	return 0;
+}
arch/arm/mach-mx5/cpu.c new file +15 -0
new file mode 100644
index 0000000..93f1d5a
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2008-2009 Freescale Semiconductor, Inc. All Rights Reserved.
+ *
+ * The code contained herein is licensed under the GNU General Public
+ * License. You may obtain a copy of the GNU General Public License
+ * Version 2 or later at the following locations:
+ *
+ * http://www.opensource.org/licenses/gpl-license.html
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ * This file contains the CPU initialization code.
+ */
+
+#include <linux/types.h>
+#include <linux/kernel.h>

arch/arm/mach-mx5/cpu.c line 25

Quoted 10 lines
arch/arm/mach-mx5/cpu.c new file +10 -0
+#include <linux/init.h>
+#include <mach/hardware.h>
+#include <asm/io.h>
+
+static int __init post_cpu_init(void)
+{
+	unsigned int reg;
+	void __iomem *base;
+
+	if (cpu_is_mx51()) {
	if (!cpu_is_mx51())
		return 0;
Quoted 3 lines

please. This way we have one indention level more in case this function gets more complicated.

Neat. Fixed.

Quoted 50 lines
Quoted 25 lines
arch/arm/mach-mx5/cpu.c new file +20 -0
+		base = MX51_IO_ADDRESS(MX51_AIPS1_BASE_ADDR);
+		__raw_writel(0x0, base + 0x40);
+		__raw_writel(0x0, base + 0x44);
+		__raw_writel(0x0, base + 0x48);
+		__raw_writel(0x0, base + 0x4C);
+		reg = __raw_readl(base + 0x50) & 0x00FFFFFF;
+		__raw_writel(reg, base + 0x50);
+
+		base = MX51_IO_ADDRESS(MX51_AIPS2_BASE_ADDR);
+		__raw_writel(0x0, base + 0x40);
+		__raw_writel(0x0, base + 0x44);
+		__raw_writel(0x0, base + 0x48);
+		__raw_writel(0x0, base + 0x4C);
+		reg = __raw_readl(base + 0x50) & 0x00FFFFFF;
+		__raw_writel(reg, base + 0x50);
+	}
+	return 0;
+}
+
+postcore_initcall(post_cpu_init);
arch/arm/mach-mx5/crm_regs.h new file +0 -0
new file mode 100644
index 0000000..c776b9a

[snip]

Quoted 22 lines
arch/arm/mach-mx5/devices.c new file +16 -0
new file mode 100644
index 0000000..55eb089
@@ -0,0 +1,96 @@
+/*
+ * Copyright 2009 Amit Kucheria <[email protected]>
+ *
+ * The code contained herein is licensed under the GNU General Public
+ * License. You may obtain a copy of the GNU General Public License
+ * Version 2 or later at the following locations:
+ *
+ * http://www.opensource.org/licenses/gpl-license.html
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+
+#include <linux/platform_device.h>
+#include <mach/hardware.h>
+#include <mach/imx-uart.h>
+
+static struct resource uart0[] = {
Quoted 8 lines

arch/arm/mach-mx5/devices.c line 19

Quoted 3 lines
arch/arm/mach-mx5/devices.c new file +3 -0
+	{
+		.start = MX51_UART1_BASE_ADDR,
+		.end = MX51_UART1_BASE_ADDR + 0x0B5,

You can safely write MX51_UART1_BASE_ADDR + 0xfff here because that's the register space this device actually has. The last register in the datasheet is 0xb4 anyway and with 32bit register accesses the correct value here would be 0xb7.

Oops. Fixed.

Quoted 280 lines
Quoted 266 lines
arch/arm/mach-mx5/devices.c new file +77 -0
+		.flags = IORESOURCE_MEM,
+	}, {
+		.start = MX51_MXC_INT_UART1,
+		.end = MX51_MXC_INT_UART1,
+		.flags = IORESOURCE_IRQ,
+	},
+};
+
+struct platform_device mxc_uart_device0 = {
+	.name = "imx-uart",
+	.id = 0,
+	.resource = uart0,
+	.num_resources = ARRAY_SIZE(uart0),
+};
+
+static struct resource uart1[] = {
+	{
+		.start = MX51_UART2_BASE_ADDR,
+		.end = MX51_UART2_BASE_ADDR + 0x0B5,
+		.flags = IORESOURCE_MEM,
+	}, {
+		.start = MX51_MXC_INT_UART2,
+		.end = MX51_MXC_INT_UART2,
+		.flags = IORESOURCE_IRQ,
+	},
+};
+
+struct platform_device mxc_uart_device1 = {
+	.name = "imx-uart",
+	.id = 1,
+	.resource = uart1,
+	.num_resources = ARRAY_SIZE(uart1),
+};
+
+static struct resource uart2[] = {
+	{
+		.start = MX51_UART3_BASE_ADDR,
+		.end = MX51_UART3_BASE_ADDR + 0x0B5,
+		.flags = IORESOURCE_MEM,
+	}, {
+		.start = MX51_MXC_INT_UART3,
+		.end = MX51_MXC_INT_UART3,
+		.flags = IORESOURCE_IRQ,
+	},
+};
+
+struct platform_device mxc_uart_device2 = {
+	.name = "imx-uart",
+	.id = 2,
+	.resource = uart2,
+	.num_resources = ARRAY_SIZE(uart2),
+};
+
+static struct resource mxc_fec_resources[] = {
+	{
+		.start	= MX51_MXC_FEC_BASE_ADDR,
+		.end	= MX51_MXC_FEC_BASE_ADDR + 0xfff,
+		.flags	= IORESOURCE_MEM,
+	}, {
+		.start	= MX51_MXC_INT_FEC,
+		.end	= MX51_MXC_INT_FEC,
+		.flags	= IORESOURCE_IRQ,
+	},
+};
+
+struct platform_device mxc_fec_device = {
+	.name = "fec",
+	.id = 0,
+	.num_resources = ARRAY_SIZE(mxc_fec_resources),
+	.resource = mxc_fec_resources,
+};
+
+/* Dummy definition to allow compiling in AVIC and TZIC simultaneously */
+int __init mxc_register_gpios(void)
+{
+	return 0;
+}
arch/arm/mach-mx5/devices.h new file +4 -0
new file mode 100644
index 0000000..f339ab8
@@ -0,0 +1,4 @@
+extern struct platform_device mxc_uart_device0;
+extern struct platform_device mxc_uart_device1;
+extern struct platform_device mxc_uart_device2;
+extern struct platform_device mxc_fec_device;
arch/arm/mach-mx5/mm.c new file +88 -0
new file mode 100644
index 0000000..d66c31a
@@ -0,0 +1,88 @@
+/*
+ * Copyright 2008-2009 Freescale Semiconductor, Inc. All Rights Reserved.
+ *
+ * The code contained herein is licensed under the GNU General Public
+ * License.  You may obtain a copy of the GNU General Public License
+ * Version 2 or later at the following locations:
+ *
+ * http://www.opensource.org/licenses/gpl-license.html
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ * Create static mapping between physical to virtual memory.
+ */
+
+#include <linux/mm.h>
+#include <linux/init.h>
+
+#include <asm/mach/map.h>
+
+#include <mach/hardware.h>
+#include <mach/common.h>
+#include <mach/iomux-v3.h>
+
+/*
+ * Define the MX51 memory map.
+ */
+static struct map_desc mxc_io_desc[] __initdata = {
+	{
+	 .virtual = MX51_IRAM_BASE_ADDR_VIRT,
+	 .pfn = __phys_to_pfn(MX51_IRAM_BASE_ADDR),
+	 .length = MX51_IRAM_SIZE,
+	 .type = MT_DEVICE},
+	{
+	 .virtual = MX51_DEBUG_BASE_ADDR_VIRT,
+	 .pfn = __phys_to_pfn(MX51_DEBUG_BASE_ADDR),
+	 .length = MX51_DEBUG_SIZE,
+	 .type = MT_DEVICE},
+	{
+	 .virtual = MX51_TZIC_BASE_ADDR_VIRT,
+	 .pfn = __phys_to_pfn(MX51_TZIC_BASE_ADDR),
+	 .length = MX51_TZIC_SIZE,
+	 .type = MT_DEVICE},
+	{
+	 .virtual = MX51_AIPS1_BASE_ADDR_VIRT,
+	 .pfn = __phys_to_pfn(MX51_AIPS1_BASE_ADDR),
+	 .length = MX51_AIPS1_SIZE,
+	 .type = MT_DEVICE},
+	{
+	 .virtual = MX51_SPBA0_BASE_ADDR_VIRT,
+	 .pfn = __phys_to_pfn(MX51_SPBA0_BASE_ADDR),
+	 .length = MX51_SPBA0_SIZE,
+	 .type = MT_DEVICE},
+	{
+	 .virtual = MX51_AIPS2_BASE_ADDR_VIRT,
+	 .pfn = __phys_to_pfn(MX51_AIPS2_BASE_ADDR),
+	 .length = MX51_AIPS2_SIZE,
+	 .type = MT_DEVICE},
+	{
+	 .virtual = MX51_NFC_AXI_BASE_ADDR_VIRT,
+	 .pfn = __phys_to_pfn(MX51_NFC_AXI_BASE_ADDR),
+	 .length = MX51_NFC_AXI_SIZE,
+	 .type = MT_DEVICE},
+};
+
+/*
+ * This function initializes the memory map. It is called during the
+ * system startup to create static physical to virtual memory mappings
+ * for the IO modules.
+ */
+void __init mx51_map_io(void)
+{
+	u32 tzic_addr;
+
+	if (mx51_revision() < MX51_CHIP_REV_2_0)
+		tzic_addr = 0x8FFFC000;
+	else
+		tzic_addr = 0xE0003000;
+	mxc_io_desc[2].pfn =  __phys_to_pfn(tzic_addr);
+
+	mxc_set_cpu_type(MXC_CPU_MX51);
+	mxc_iomux_v3_init(MX51_IO_ADDRESS(MX51_IOMUXC_BASE_ADDR));
+	mxc_arch_reset_init(MX51_IO_ADDRESS(MX51_WDOG_BASE_ADDR));
+	iotable_init(mxc_io_desc, ARRAY_SIZE(mxc_io_desc));
+}
+
+void __init mx51_init_irq(void)
+{
+	tzic_init_irq(MX51_IO_ADDRESS(MX51_TZIC_BASE_ADDR));
+}
arch/arm/plat-mxc/include/mach/common.h +1 -0
index 5250a3f..0a25576 100644
@@ -30,6 +30,7 @@ extern void mx25_init_irq(void);
 extern void mx27_init_irq(void);
 extern void mx31_init_irq(void);
 extern void mx35_init_irq(void);
+extern void mx51_init_irq(void);
 extern void mxc91231_init_irq(void);
 extern void mxc_timer_init(struct clk *timer_clk, void __iomem *, int);
 extern int mx1_clocks_init(unsigned long fref);
arch/arm/plat-mxc/include/mach/debug-macro.S +2 -2
index 9fe7300..9d41bfd 100644
@@ -49,8 +49,8 @@
 #error "CONFIG_DEBUG_LL is incompatible with multiple archs"
 #endif
 #include <mach/mx51.h>
-#define UART_PADDR	UART1_BASE_ADDR
-#define UART_VADDR	AIPS1_IO_ADDRESS(UART1_BASE_ADDR)
+#define UART_PADDR	MX51_UART1_BASE_ADDR
+#define UART_VADDR	MX51_AIPS1_IO_ADDRESS(MX51_UART1_BASE_ADDR)
 #endif
 
 #ifdef CONFIG_ARCH_MXC91231
arch/arm/plat-mxc/include/mach/iomux-mx51.h new file +52 -0
new file mode 100644
index 0000000..14df0f5
@@ -0,0 +1,340 @@
+/*
+ * Copyright 2009 Amit Kucheria <[email protected]> All Rights Reserved.
+ *
+ * The code contained herein is licensed under the GNU General Public
+ * License. You may obtain a copy of the GNU General Public License
+ * Version 2 or later at the following locations:
+ *
+ * http://www.opensource.org/licenses/gpl-license.html
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+
+#ifndef __MACH_IOMUX_MX51_H__
+#define __MACH_IOMUX_MX51_H__
+
+#include <mach/iomux-v3.h>
+
+/*
+ * various IOMUX alternate output functions (1-7)
+ */
+typedef enum iomux_config {
+	IOMUX_CONFIG_ALT0,
+	IOMUX_CONFIG_ALT1,
+	IOMUX_CONFIG_ALT2,
+	IOMUX_CONFIG_ALT3,
+	IOMUX_CONFIG_ALT4,
+	IOMUX_CONFIG_ALT5,
+	IOMUX_CONFIG_ALT6,
+	IOMUX_CONFIG_ALT7,
+	IOMUX_CONFIG_GPIO,	/* added to help user use GPIO mode */
+	IOMUX_CONFIG_SION = 0x1 << 4,	/* LOOPBACK:MUX SION bit */
+} iomux_pin_cfg_t;
+
+/* Pad control groupings */
+#define MX51_UART1_PAD_CTRL	(PAD_CTL_HYS | PAD_CTL_PKE | PAD_CTL_PUE | \
+				PAD_CTL_DSE_HIGH)
+#define MX51_UART2_PAD_CTRL	(PAD_CTL_PKE | PAD_CTL_PUE | PAD_CTL_DSE_HIGH | \
+				PAD_CTL_SRE_FAST)
+#define MX51_UART3_PAD_CTRL	(PAD_CTL_PKE | PAD_CTL_DSE_HIGH | \
+				PAD_CTL_SRE_FAST)
+
+/*
+ * The naming convention for the pad modes is MX51_PAD_<padname>__<padmode>
+ * If <padname> or <padmode> refers to a GPIO, it is named
+ * GPIO_<unit>_<num> see also iomux-v3.h
+ */
+
+/* REVISIT: This was converted using scripts from existing Freescale code to
+ * this form used upstream. Need to verify the name format.
+ */
+
+/*						PAD      MUX   ALT INPSE PATH PADCTRL */
+

arch/arm/plat-mxc/include/mach/iomux-mx51.h line 62

Quoted 10 lines
arch/arm/plat-mxc/include/mach/iomux-mx51.h new file +10 -0
+
+/* UART1 */
+#define MX51_BABBAGE_PAD_UART1_RXD__UART1_RXD	\
+	IOMUX_PAD(0x618, 0x228,	IOMUX_CONFIG_ALT0, 0x9e4, 0, MX51_UART1_PAD_CTRL | PAD_CTL_SRE_FAST)
+#define MX51_BABBAGE_PAD_UART1_TXD__UART1_TXD	\
+	IOMUX_PAD(0x61C, 0x22C, IOMUX_CONFIG_ALT0, 0x0, 0, MX51_UART1_PAD_CTRL | PAD_CTL_SRE_FAST)
+#define MX51_BABBAGE_PAD_UART1_RTS__UART1_RTS	\
+	IOMUX_PAD(0x620, 0x230, IOMUX_CONFIG_ALT0, 0x9e0, 0, MX51_UART1_PAD_CTRL)
+#define MX51_BABBAGE_PAD_UART1_CTS__UART1_CTS	\
+	IOMUX_PAD(0x624, 0x234, IOMUX_CONFIG_ALT0, 0x0, 0, MX51_UART1_PAD_CTRL)

I remember last time I said that you should move these macros here. I think the situation is like this:

Quoted 6 lines

1) These are either known good values for the uart pins and therefore shouldn't have BABBAGE in their name.
2) There is something babbage specific in them, in this case they should be in the board specific file.

I vote for 1) here.

At the moment, I only have a babbage for testing. So I don't know if these are globally good values. But I'll change 'em since that is the only board we support for now.

Quoted 16 lines

arch/arm/plat-mxc/include/mach/iomux-mx51.h line 75

Quoted 13 lines
arch/arm/plat-mxc/include/mach/iomux-mx51.h new file +13 -0
+
+/* UART2 */
+#define MX51_BABBAGE_PAD_UART2_RXD__UART2_RXD	IOMUX_PAD(0x628, 0x238, IOMUX_CONFIG_ALT0, 0x9ec, 2, MX51_UART2_PAD_CTRL)
+#define MX51_BABBAGE_PAD_UART2_TXD__UART2_TXD	IOMUX_PAD(0x62C, 0x23C, IOMUX_CONFIG_ALT0, 0x0, 0, MX51_UART2_PAD_CTRL)
+
+/* UART3 */
+#define MX51_BABBAGE_PAD_EIM_D25__UART3_RXD	IOMUX_PAD(0x414, 0x080, IOMUX_CONFIG_ALT3, 0x9f4, 0, MX51_UART3_PAD_CTRL)
+#define MX51_BABBAGE_PAD_EIM_D26__UART3_TXD	IOMUX_PAD(0x418, 0x084, IOMUX_CONFIG_ALT3, 0x0, 0, MX51_UART3_PAD_CTRL)
+#define MX51_BABBAGE_PAD_EIM_D27__UART3_RTS	IOMUX_PAD(0x41c, 0x088, IOMUX_CONFIG_ALT3, 0x9f0, 0, MX51_UART3_PAD_CTRL)
+#define MX51_BABBAGE_PAD_EIM_D24__UART3_CTS	IOMUX_PAD(0x410, 0x07c, IOMUX_CONFIG_ALT3, 0x0, 0, MX51_UART3_PAD_CTRL)
+
+#define MX51_BABBAGE_PAD_GPIO_1_8__GPIO1_8	IOMUX_PAD(0x814, 0x3E8, 0, 0x0, 1, (PAD_CTL_SRE_SLOW | PAD_CTL_DSE_MED | PAD_CTL_PUS_100K_UP |  PAD_CTL_HYS))
+

ditto

Quoted 7 lines

Sascha

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

Thanks for the review. An updated patchset coming up.

Regards,
Amit

Signature · 3 lines
----------------------------------------------------------------------
Amit Kucheria, Kernel Engineer || amit.kucheria at canonical.com
----------------------------------------------------------------------
#23 lore raw

Re: [PATCHv2 05/11] mxc: Core support for i.MX5 series of processors from Freescale

In reply to Amit Kucheria
Quoted 1 line · Amit Kucheria
arch/arm/mach-mx5/clock.c +0 -0

[...]

arch/arm/mach-mx5/clock.c line 790

Quoted 7 lines
arch/arm/mach-mx5/clock.c +7 -0
+static struct clk_lookup lookups[] __initdata = {
+	_REGISTER_CLOCK("imx-uart.0", NULL, uart1_clk)
+	_REGISTER_CLOCK("imx-uart.1", NULL, uart2_clk)
+	_REGISTER_CLOCK("imx-uart.2", NULL, uart3_clk)
+	_REGISTER_CLOCK(NULL, "gpt", gpt_clk)
+	_REGISTER_CLOCK("fec.0", NULL, fec_clk)
+};

This shouldn't be __initdata. clk_get() uses this, and modules may use clk_get().

Rabin

#24 lore raw

Re: [PATCHv2 04/11] mxc: changes to common plat-mxc code to add support for i.MX5

In reply to Amit Kucheria
Quoted 81 lines · Amit Kucheria

Changes separted to help in the review process

---

?arch/arm/plat-mxc/include/mach/common.h ? ? ?| ? ?4 +++
?arch/arm/plat-mxc/include/mach/debug-macro.S | ? ?9 +++++++
?arch/arm/plat-mxc/include/mach/entry-macro.S | ? 34 +++++++++++++++++++++++++-
?arch/arm/plat-mxc/include/mach/hardware.h ? ?| ? ?4 +++
?arch/arm/plat-mxc/include/mach/irqs.h ? ? ? ?| ? ?9 ++++++-
?arch/arm/plat-mxc/include/mach/memory.h ? ? ?| ? ?3 ++
?arch/arm/plat-mxc/include/mach/mxc.h ? ? ? ? | ? 13 ++++++++++
?arch/arm/plat-mxc/include/mach/timex.h ? ? ? | ? ?2 +
?arch/arm/plat-mxc/time.c ? ? ? ? ? ? ? ? ? ? | ? ?6 ++--

?9 files changed, 79 insertions(+), 5 deletions(-)

arch/arm/plat-mxc/include/mach/common.h +4 -0
index 286cb9b..5250a3f 100644
@@ -20,8 +20,10 @@ extern void mx25_map_io(void);
 ?extern void mx27_map_io(void);
 ?extern void mx31_map_io(void);
 ?extern void mx35_map_io(void);
+extern void mx51_map_io(void);
 ?extern void mxc91231_map_io(void);
 ?extern void mxc_init_irq(void __iomem *);
+extern void tzic_init_irq(void __iomem *);
 ?extern void mx1_init_irq(void);
 ?extern void mx21_init_irq(void);
 ?extern void mx25_init_irq(void);
@@ -36,6 +38,8 @@ extern int mx25_clocks_init(unsigned long fref);
 ?extern int mx27_clocks_init(unsigned long fref);
 ?extern int mx31_clocks_init(unsigned long fref);
 ?extern int mx35_clocks_init(void);
+extern int mx51_clocks_init(unsigned long ckil, unsigned long osc,
+ ? ? ? ? ? ? ? ? ? ? ? unsigned long ckih1, unsigned long ckih2);
 ?extern int mxc91231_clocks_init(unsigned long fref);
 ?extern int mxc_register_gpios(void);
 ?extern int mxc_register_device(struct platform_device *pdev, void *data);
arch/arm/plat-mxc/include/mach/debug-macro.S +0 -0
index 15b2b14..9fe7300 100644
@@ -44,6 +44,15 @@
 ?#define UART_VADDR ? ? AIPS1_IO_ADDRESS(UART1_BASE_ADDR)

?#endif

arch/arm/plat-mxc/include/mach/debug-macro.S +9 -0
+#ifdef CONFIG_ARCH_MX5
+#ifdef UART_PADDR
+#error "CONFIG_DEBUG_LL is incompatible with multiple archs"
+#endif
+#include <mach/mx51.h>
+#define UART_PADDR ? ? UART1_BASE_ADDR
+#define UART_VADDR ? ? AIPS1_IO_ADDRESS(UART1_BASE_ADDR)
+#endif
+

?#ifdef CONFIG_ARCH_MXC91231
?#ifdef UART_PADDR
?#error "CONFIG_DEBUG_LL is incompatible with multiple archs"

arch/arm/plat-mxc/include/mach/entry-macro.S +0 -0
index 7cf290e..aeb0869 100644
@@ -1,6 +1,6 @@

?/*
?* ?Copyright (C) 2007 Lennert Buytenhek <[email protected]>
- * ?Copyright 2004-2007 Freescale Semiconductor, Inc. All Rights Reserved.
+ * ?Copyright 2004-2009 Freescale Semiconductor, Inc. All Rights Reserved. ?*/

?/*

arch/arm/plat-mxc/include/mach/entry-macro.S +0 -0
@@ -18,11 +18,16 @@

? ? ? ?.endm

? ? ? ?.macro ?get_irqnr_preamble, base, tmp
+#ifndef CONFIG_MXC_TZIC
? ? ? ?ldr ? ? \base, =avic_base
? ? ? ?ldr ? ? \base, [\base]
?#ifdef CONFIG_MXC_IRQ_PRIOR
? ? ? ?ldr ? ? r4, [\base, #AVIC_NIMASK]
?#endif

arch/arm/plat-mxc/include/mach/entry-macro.S line 30

Quoted 4 lines
arch/arm/plat-mxc/include/mach/entry-macro.S +4 -0
+#elif defined CONFIG_MXC_TZIC
+ ? ? ? ldr ? ? \base, =tzic_base
+ ? ? ? ldr ? ? \base, [\base]
+#endif /* CONFIG_MXC_TZIC */

Mmm.... this should be something that we really need to get rid of, it just makes a single kernel for both TZIC and AVIC together impossible, if that's so designed by HW, I'm thinking about keeping this into plat-mxc/ is a good way to go ...

Sascha, you have any better idea? Provided the other file debug-macro.S in the same directory already seems to break the support for multiple arches?

Quoted 193 lines

? ? ? ?.endm

? ? ? ?.macro ?arch_ret_to_user, tmp1, tmp2

arch/arm/plat-mxc/include/mach/entry-macro.S +0 -0
@@ -32,6 +37,7 @@

? ? ? ?@ and returns its number in irqnr
? ? ? ?@ and returns if an interrupt occured in irqstat ? ? ? ?.macro ?get_irqnr_and_base, irqnr, irqstat, base, tmp +#ifndef CONFIG_MXC_TZIC
? ? ? ?@ Load offset & priority of the highest priority ? ? ? ?@ interrupt pending from AVIC_NIVECSR
? ? ? ?ldr ? ? \irqstat, [\base, #0x40]

arch/arm/plat-mxc/include/mach/entry-macro.S +0 -0
@@ -45,6 +51,32 @@

? ? ? ?strne ? \tmp, [\base, #AVIC_NIMASK]
? ? ? ?streq ? r4, [\base, #AVIC_NIMASK]
?#endif

arch/arm/plat-mxc/include/mach/entry-macro.S +26 -0
+#elif defined CONFIG_MXC_TZIC
+ ? ? ? @ Load offset & priority of the highest priority
+ ? ? ? @ interrupt pending.
+ ? ? ? @ 0xD80 is HIPND0 register
+ ? ? ? mov ? ? \irqnr, #0
+ ? ? ? mov ? ? \irqstat, #0x0D80
+1000:
+ ? ? ? ldr ? ? \tmp, ? [\irqstat, \base]
+ ? ? ? cmp ? ? \tmp, #0
+ ? ? ? bne ? ? 1001f
+ ? ? ? addeq ? \irqnr, \irqnr, #32
+ ? ? ? addeq ? \irqstat, \irqstat, #4
+ ? ? ? cmp ? ? \irqnr, #128
+ ? ? ? blo ? ? 1000b
+ ? ? ? b ? ? ? 2001f
+1001: ?mov ? ? \irqstat, #1
+1002: ?tst ? ? \tmp, \irqstat
+ ? ? ? bne ? ? 2002f
+ ? ? ? movs ? ?\tmp, \tmp, lsr #1
+ ? ? ? addne ? \irqnr, \irqnr, #1
+ ? ? ? bne ? ? 1002b
+2001:
+ ? ? ? mov ?\irqnr, #0
+2002:
+ ? ? ? movs \irqnr, \irqnr
+#endif

? ? ? ?.endm

? ? ? ?@ irq priority table (not used)

arch/arm/plat-mxc/include/mach/hardware.h +0 -0
index 78db754..55ebe88 100644
@@ -22,6 +22,10 @@
 

?#include <asm/sizes.h>

arch/arm/plat-mxc/include/mach/hardware.h +4 -0
+#ifdef CONFIG_ARCH_MX5
+#include <mach/mx51.h>
+#endif
+

?#ifdef CONFIG_ARCH_MX3
?#include <mach/mx3x.h>
?#include <mach/mx31.h>

arch/arm/plat-mxc/include/mach/irqs.h +0 -0
index ead9d59..24c066e 100644
@@ -12,9 +12,13 @@

?#define __ASM_ARCH_MXC_IRQS_H__

?/*
- * So far all i.MX SoCs have 64 internal interrupts
+ * SoCs with TZIC interrupt controller have 128 IRQs, those with AVIC have 64 ?*/

arch/arm/plat-mxc/include/mach/irqs.h +3 -0
+#ifdef CONFIG_MXC_TZIC
+#define MXC_INTERNAL_IRQS ? ? ?128
+#else

?#define MXC_INTERNAL_IRQS ? ? ?64
+#endif

?#define MXC_GPIO_IRQ_START ? ? MXC_INTERNAL_IRQS

arch/arm/plat-mxc/include/mach/irqs.h +0 -0
@@ -26,6 +30,8 @@
 ?#define MXC_GPIO_IRQS ? ? ? ? ?(32 * 3)

?#elif defined CONFIG_ARCH_MX25
?#define MXC_GPIO_IRQS ? ? ? ? ?(32 * 4)

arch/arm/plat-mxc/include/mach/irqs.h +2 -0
+#elif defined CONFIG_ARCH_MX5
+#define MXC_GPIO_IRQS ? ? ? ? ?(32 * 4)

?#elif defined CONFIG_ARCH_MXC91231
?#define MXC_GPIO_IRQS ? ? ? ? ?(32 * 4)
?#endif

arch/arm/plat-mxc/include/mach/irqs.h +0 -0
@@ -46,6 +52,7 @@

?#else
?#define MX3_IPU_IRQS 0
?#endif
+/* REVISIT: Add IPU irqs on IMX51 */

?#define NR_IRQS ? ? ? ? ? ? ? ? ? ? ? ?(MXC_IPU_IRQ_START + MX3_IPU_IRQS)

arch/arm/plat-mxc/include/mach/memory.h +0 -0
index d3afafd..e46626e 100644
@@ -27,6 +27,9 @@

?#elif defined CONFIG_ARCH_MXC91231
?#define PHYS_OFFSET ? ? ? ? ? ?UL(0x90000000)
?#endif

arch/arm/plat-mxc/include/mach/memory.h +3 -0
+#ifdef CONFIG_ARCH_MX5
+#define PHYS_OFFSET ? ? ? ? ? ? UL(0x90000000)
+#endif

?#if defined(CONFIG_MX1_VIDEO)
?/*

arch/arm/plat-mxc/include/mach/mxc.h +0 -0
index 5199053..555e5f8 100644
@@ -30,6 +30,7 @@

?#define MXC_CPU_MX27 ? ? ? ? ? 27
?#define MXC_CPU_MX31 ? ? ? ? ? 31
?#define MXC_CPU_MX35 ? ? ? ? ? 35
+#define MXC_CPU_MX51 ? ? ? ? ? 51
?#define MXC_CPU_MXC91231 ? ? ? 91231

?#ifndef __ASSEMBLY__

arch/arm/plat-mxc/include/mach/mxc.h +0 -0
@@ -108,6 +109,18 @@ extern unsigned int __mxc_cpu_type;
 ?# define cpu_is_mx35() ? ? ? ? (0)

?#endif

arch/arm/plat-mxc/include/mach/mxc.h +12 -0
+#ifdef CONFIG_ARCH_MX5
+# ifdef mxc_cpu_type
+# ?undef mxc_cpu_type
+# ?define mxc_cpu_type __mxc_cpu_type
+# else
+# ?define mxc_cpu_type MXC_CPU_MX51
+# endif
+# define cpu_is_mx51() ? ? ? ? (mxc_cpu_type == MXC_CPU_MX51)
+#else
+# define cpu_is_mx51() ? ? ? ? (0)
+#endif
+

?#ifdef CONFIG_ARCH_MXC91231
?# ifdef mxc_cpu_type
?# ?undef mxc_cpu_type

arch/arm/plat-mxc/include/mach/timex.h +0 -0
index 527a6c2..024416e 100644
@@ -28,6 +28,8 @@

?#define CLOCK_TICK_RATE ? ? ? ? ? ? ? ?16625000
?#elif defined CONFIG_ARCH_MX25
?#define CLOCK_TICK_RATE ? ? ? ? ? ? ? ?16000000

arch/arm/plat-mxc/include/mach/timex.h +2 -0
+#elif defined CONFIG_ARCH_MX5
+#define CLOCK_TICK_RATE ? ? ? ? ? ? ? ?8000000

?#elif defined CONFIG_ARCH_MXC91231
?#define CLOCK_TICK_RATE ? ? ? ? ? ? ? ?13000000
?#endif

arch/arm/plat-mxc/time.c +0 -0
index 7d6499e..2ba8b29 100644
@@ -32,7 +32,7 @@
 

?/* defines common for all i.MX */
?#define MXC_TCTL ? ? ? ? ? ? ? 0x00

arch/arm/plat-mxc/time.c +1 -1
-#define MXC_TCTL_TEN ? ? ? ? ? (1 << 0)
+#define MXC_TCTL_TEN ? ? ? ? ? (1 << 0) /* Enable module */

?#define MXC_TPRER ? ? ? ? ? ? ?0x04

?/* MX1, MX21, MX27 */

arch/arm/plat-mxc/time.c +0 -0
@@ -48,7 +48,7 @@
 ?#define MX2_TSTAT_COMP ? ? ? ? (1 << 0)
 

?/* MX31, MX35, MX25, MXC91231 */

arch/arm/plat-mxc/time.c +1 -1
-#define MX3_TCTL_WAITEN ? ? ? ? ? ? ? ?(1 << 3)
+#define MX3_TCTL_WAITEN ? ? ? ? ? ? ? ?(1 << 3) /* Wait enable mode */

?#define MX3_TCTL_CLK_IPG ? ? ? (1 << 6)
?#define MX3_TCTL_FRR ? ? ? ? ? (1 << 9)
?#define MX3_IR ? ? ? ? ? ? ? ? 0x0c

arch/arm/plat-mxc/time.c +0 -0
@@ -58,7 +58,7 @@

?#define MX3_TCMP ? ? ? ? ? ? ? 0x10

?#define timer_is_v1() ?(cpu_is_mx1() || cpu_is_mx27())

arch/arm/plat-mxc/time.c +1 -1
-#define timer_is_v2() ?(cpu_is_mx3() || cpu_is_mx25())
+#define timer_is_v2() ?(cpu_is_mx3() || cpu_is_mx25() || cpu_is_mx51())

?static struct clock_event_device clockevent_mxc;
?static enum clock_event_mode clockevent_mode = CLOCK_EVT_MODE_UNUSED; --
1.6.3.3

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

maintainer
#25 lore raw

Re: [PATCHv2 04/11] mxc: changes to common plat-mxc code to add support for i.MX5

Quoted 9 lines · Eric Miao

Mmm.... this should be something that we really need to get rid of, it just makes a single kernel for both TZIC and AVIC together impossible, if that's so designed by HW, I'm thinking about keeping this into plat-mxc/ is a good way to go ...

Sascha, you have any better idea? Provided the other file debug-macro.S in the same directory already seems to break the support for multiple arches?

I have the following patch which I'm not sure I like better. It can support both irq controller types and does not add overhead if only one of them is compiled in. It might need some refactoring to fit into Amits patch stack.

Sascha

commit c30ed01dcd257bba813b27a423bc54d5f32fc878

Author: Sascha Hauer <[email protected]>
Date:   Tue Nov 17 16:23:24 2009 +0100

MXC tzic support

arch/arm/plat-mxc/Kconfig +3 -0
index ebe4b8c..377f792 100644
@@ -84,4 +84,7 @@ config ARCH_MXC_IOMUX_V3
 config ARCH_MXC_AVIC
 	bool
 
+config ARCH_MXC_TZIC
+	bool
+
 endif
arch/arm/plat-mxc/Makefile +1 -0
index 325d9da..37ce6ec 100644
@@ -9,4 +9,5 @@ obj-$(CONFIG_ARCH_MX1) += iomux-mx1-mx2.o dma-mx1-mx2.o
 obj-$(CONFIG_ARCH_MX2) += iomux-mx1-mx2.o dma-mx1-mx2.o
 obj-$(CONFIG_ARCH_MXC_IOMUX_V3) += iomux-v3.o
 obj-$(CONFIG_MXC_PWM)  += pwm.o
+obj-$(CONFIG_ARCH_MXC_TZIC) += tzic.o
 obj-$(CONFIG_ARCH_MXC_AVIC) += irq.o
arch/arm/plat-mxc/cpu.c +1 -0
index b073b7d..d46325e 100644
@@ -11,4 +11,5 @@ void mxc_set_cpu_type(unsigned int type)
 }
 
 void __iomem *mxc_irq_base;
+int mxc_irq_controller_type;
 
arch/arm/plat-mxc/include/mach/common.h +1 -1
index 286cb9b..d395763 100644
@@ -44,5 +44,5 @@ extern void mxc_arch_reset_init(void __iomem *);
 extern void mxc91231_power_off(void);
 extern void mxc91231_arch_reset(int, const char *);
 extern void mxc91231_prepare_idle(void);
-
+extern void tzic_init_irq(void __iomem *);
 #endif
arch/arm/plat-mxc/include/mach/entry-macro.S +54 -4

76 lines not on this page · raw message

arch/arm/plat-mxc/include/mach/mxc.h +4 -0
index b64a269..6cf0f98 100644
@@ -129,8 +129,12 @@ extern unsigned int __mxc_cpu_type;
 #define cpu_is_mx3()	(cpu_is_mx31() || cpu_is_mx35() || cpu_is_mxc91231())
 #define cpu_is_mx2()	(cpu_is_mx21() || cpu_is_mx27())
 
+#define	MXC_IRQ_TYPE_AVIC	1
+#define	MXC_IRQ_TYPE_TZIC	2
+
 #ifndef __ASSEMBLY__
 extern void __iomem *mxc_irq_base;
+extern int mxc_irq_controller_type;
 #endif
 
 #endif /*  __ASM_ARCH_MXC_H__ */
arch/arm/plat-mxc/irq.c +1 -0
index 4855a65..3e7ac84 100644
@@ -116,6 +116,7 @@ void __init mxc_init_irq(void __iomem *irqbase)
 	int i;
 
 	mxc_irq_base = irqbase;
+	mxc_irq_controller_type = MXC_IRQ_TYPE_AVIC;
 
 	/* put the AVIC into the reset value with
 	 * all interrupts disabled
arch/arm/plat-mxc/tzic.c new file +104 -0

104 lines not on this page · raw message

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

Re: [PATCHv2 04/11] mxc: changes to common plat-mxc code to add support for i.MX5

Quoted 7 lines · Sascha Hauer
Quoted 6 lines · Eric Miao

Mmm.... this should be something that we really need to get rid of, it just makes a single kernel for both TZIC and AVIC together impossible, if that's so designed by HW, I'm thinking about keeping this into plat-mxc/ is a good way to go ...

Quoted 8 lines
Quoted 3 lines

Sascha, you have any better idea? Provided the other file debug-macro.S in the same directory already seems to break the support for multiple arches?

I have the following patch which I'm not sure I like better. It can support both irq controller types and does not add overhead if only one of them is compiled in. It might need some refactoring to fit into Amits patch stack.

Is co-existence of TZIC and AVIC a blocker to merging i.MX5 code? I've already made changes so that i.MX5 doesn't explode if AVIC is compiled in.

Admittedly the assembly is a bit hard to rid, but we can fix in another set of patches geared towards unification of an i.MX kernel. IMHO, making these changes along with introducing a new SoC will make things a bit hard to follow/merge.

Regards,
Amit

Quoted 281 lines

Sascha

commit c30ed01dcd257bba813b27a423bc54d5f32fc878

Author: Sascha Hauer <[email protected]>
Date:   Tue Nov 17 16:23:24 2009 +0100

MXC tzic support

arch/arm/plat-mxc/Kconfig +3 -0
index ebe4b8c..377f792 100644
@@ -84,4 +84,7 @@ config ARCH_MXC_IOMUX_V3
 config ARCH_MXC_AVIC
 	bool
 
+config ARCH_MXC_TZIC
+	bool
+
 endif
arch/arm/plat-mxc/Makefile +1 -0
index 325d9da..37ce6ec 100644
@@ -9,4 +9,5 @@ obj-$(CONFIG_ARCH_MX1) += iomux-mx1-mx2.o dma-mx1-mx2.o
 obj-$(CONFIG_ARCH_MX2) += iomux-mx1-mx2.o dma-mx1-mx2.o
 obj-$(CONFIG_ARCH_MXC_IOMUX_V3) += iomux-v3.o
 obj-$(CONFIG_MXC_PWM)  += pwm.o
+obj-$(CONFIG_ARCH_MXC_TZIC) += tzic.o
 obj-$(CONFIG_ARCH_MXC_AVIC) += irq.o
arch/arm/plat-mxc/cpu.c +1 -0
index b073b7d..d46325e 100644
@@ -11,4 +11,5 @@ void mxc_set_cpu_type(unsigned int type)
 }
 
 void __iomem *mxc_irq_base;
+int mxc_irq_controller_type;
 
arch/arm/plat-mxc/include/mach/common.h +1 -1
index 286cb9b..d395763 100644
@@ -44,5 +44,5 @@ extern void mxc_arch_reset_init(void __iomem *);
 extern void mxc91231_power_off(void);
 extern void mxc91231_arch_reset(int, const char *);
 extern void mxc91231_prepare_idle(void);
-
+extern void tzic_init_irq(void __iomem *);
 #endif
arch/arm/plat-mxc/include/mach/entry-macro.S +54 -4
index 55375df..049f740 100644
@@ -13,6 +13,9 @@
 
 #define AVIC_NIMASK	0x04
 
+#define TZIC_HIPND0 0xd80
+
+
 	@ this macro disables fast irq (not implemented)
 	.macro	disable_fiq
 	.endm
@@ -28,10 +31,35 @@
 	.macro  arch_ret_to_user, tmp1, tmp2
 	.endm
 
-	@ this macro checks which interrupt occured
-	@ and returns its number in irqnr
-	@ and returns if an interrupt occured in irqstat
-	.macro	get_irqnr_and_base, irqnr, irqstat, base, tmp
+	.macro	tzic_get_irqnr_and_base, irqnr, irqstat, base, tmp
+
+	@ Load offset & priority of the highest priority
+	@ interrupt pending.
+	ldr     \irqnr, =0
+	ldr     \irqstat, =TZIC_HIPND0
+1000:
+	ldr     \tmp,   [\base, \irqstat]
+	cmp     \tmp, #0
+	bne     1001f
+	addeq   \irqnr, \irqnr, #32
+	addeq   \irqstat, \irqstat, #4
+	cmp     \irqnr, #128
+	blo     1000b
+	b       2001f
+1001:	ldr     \irqstat, =1
+1002:	tst     \tmp, \irqstat
+	bne     2002f
+	movs    \irqstat, \irqstat, lsl #1
+	addne   \irqnr, \irqnr, #1
+	bne     1002b
+2001:
+	ldr  \irqnr, =0
+2002:
+	movs \irqnr, \irqnr
+	.endm
+
+	.macro	avic_get_irqnr_and_base, irqnr, irqstat, base, tmp
+
 	@ Load offset & priority of the highest priority
 	@ interrupt pending from AVIC_NIVECSR
 	ldr	\irqstat, [\base, #0x40]
@@ -47,6 +75,28 @@
 #endif
 	.endm
 
+	.macro get_irqnr_and_base, irqnr, irqstat, base, tmp
+#if defined CONFIG_ARCH_MXC_TZIC && defined CONFIG_ARCH_MXC_AVIC
+	ldr	\tmp, =mxc_irq_controller_type
+	ldr	\tmp, [\tmp]
+	cmp	\tmp, #MXC_IRQ_TYPE_AVIC
+	beq	3001f
+
+	tzic_get_irqnr_and_base \irqnr, \irqstat, \base, \tmp
+	b	3002f
+3001:
+	avic_get_irqnr_and_base \irqnr, \irqstat, \base, \tmp
+3002:
+
+#elif defined CONFIG_ARCH_MXC_TZIC
+	tzic_get_irqnr_and_base \irqnr, \irqstat, \base, \tmp
+#elif defined CONFIG_ARCH_MXC_AVIC
+	avic_get_irqnr_and_base \irqnr, \irqstat, \base, \tmp
+#else
+#error no tzic and no avic?
+#endif
+	.endm
+
 	@ irq priority table (not used)
 	.macro	irq_prio_table
 	.endm
arch/arm/plat-mxc/include/mach/mxc.h +4 -0
index b64a269..6cf0f98 100644
@@ -129,8 +129,12 @@ extern unsigned int __mxc_cpu_type;
 #define cpu_is_mx3()	(cpu_is_mx31() || cpu_is_mx35() || cpu_is_mxc91231())
 #define cpu_is_mx2()	(cpu_is_mx21() || cpu_is_mx27())
 
+#define	MXC_IRQ_TYPE_AVIC	1
+#define	MXC_IRQ_TYPE_TZIC	2
+
 #ifndef __ASSEMBLY__
 extern void __iomem *mxc_irq_base;
+extern int mxc_irq_controller_type;
 #endif
 
 #endif /*  __ASM_ARCH_MXC_H__ */
arch/arm/plat-mxc/irq.c +1 -0
index 4855a65..3e7ac84 100644
@@ -116,6 +116,7 @@ void __init mxc_init_irq(void __iomem *irqbase)
 	int i;
 
 	mxc_irq_base = irqbase;
+	mxc_irq_controller_type = MXC_IRQ_TYPE_AVIC;
 
 	/* put the AVIC into the reset value with
 	 * all interrupts disabled
arch/arm/plat-mxc/tzic.c new file +104 -0
new file mode 100644
index 0000000..2d14af4
@@ -0,0 +1,104 @@
+/*
+ *  Copyright 2004-2008 Freescale Semiconductor, Inc. All Rights Reserved.
+ */
+
+/*
+ * The code contained herein is licensed under the GNU General Public
+ * License. You may obtain a copy of the GNU General Public License
+ * Version 2 or later at the following locations:
+ *
+ * http://www.opensource.org/licenses/gpl-license.html
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+
+#include <linux/module.h>
+#include <linux/moduleparam.h>
+#include <linux/init.h>
+#include <linux/device.h>
+#include <linux/errno.h>
+#include <linux/io.h>
+#include <asm/irq.h>
+#include <asm/mach/irq.h>
+#include <mach/common.h>
+#include <mach/hardware.h>
+
+extern void __iomem *mxc_irq_base;
+extern int mxc_irq_controller_type;
+
+#define TZIC_INTCNTL            0x0000	/* control register */
+#define TZIC_INTTYPE            0x0004	/* Controller type register */
+#define TZIC_IMPID              0x0008	/* Distributor Implementer Identification Register */
+#define TZIC_PRIOMASK           0x000c	/* Priority Mask Reg */
+#define TZIC_SYNCCTRL           0x0010	/* Synchronizer Control register */
+#define TZIC_DSMINT             0x0014	/* DSM interrupt Holdoffregister */
+#define TZIC_INTSEC0            0x0080	/* interrupt security register 0 */
+#define TZIC_ENSET0             0x0100	/* Enable Set Register 0 */
+#define TZIC_ENCLEAR0           0x0180	/* Enable Clear Register 0 */
+#define TZIC_SRCSET0            0x0200	/* Source Set Register 0 */
+#define TZIC_SRCCLAR0           0x0280	/* Source Clear Register 0 */
+#define TZIC_PRIORITY0          0x0400	/* Priority Register 0 */
+#define TZIC_PND0               0x0d00	/* Pending Register 0 */
+#define TZIC_HIPND0             0x0d80	/* High Priority Pending Register */
+#define TZIC_WAKEUP0            0x0e00	/* Wakeup Config Register */
+#define TZIC_SWINT              0x0f00	/* Software Interrupt Rigger Register */
+#define TZIC_ID0                0x0fd0	/* Indentification Register 0 */
+
+static void mxc_mask_irq(unsigned int irq)
+{
+	int index, off;
+
+	index = irq >> 5;
+	off = irq & 0x1F;
+	__raw_writel(1 << off, mxc_irq_base + TZIC_ENCLEAR0 + (index << 2));
+}
+
+static void mxc_unmask_irq(unsigned int irq)
+{
+	int index, off;
+
+	index = irq >> 5;
+	off = irq & 0x1F;
+	__raw_writel(1 << off, mxc_irq_base + TZIC_ENSET0 + (index << 2));
+}
+
+static struct irq_chip mxc_tzic_chip = {
+	.name = "MXC_TZIC",
+	.ack = mxc_mask_irq,
+	.mask = mxc_mask_irq,
+	.unmask = mxc_unmask_irq,
+};
+
+void __init tzic_init_irq(void __iomem *base)
+{
+	int i;
+
+	mxc_irq_base = base;
+	mxc_irq_controller_type = MXC_IRQ_TYPE_TZIC;
+
+	/* put the TZIC into the reset value with
+	 * all interrupts disabled
+	 */
+	__raw_readl(mxc_irq_base + TZIC_INTCNTL);
+
+	__raw_writel(0x80010001, mxc_irq_base + TZIC_INTCNTL);
+	__raw_readl(mxc_irq_base + TZIC_INTCNTL);
+	__raw_writel(0x1f, mxc_irq_base + TZIC_PRIOMASK);
+	__raw_readl(mxc_irq_base + TZIC_PRIOMASK);
+	__raw_writel(0x02, mxc_irq_base + TZIC_SYNCCTRL);
+	__raw_readl(mxc_irq_base + TZIC_SYNCCTRL);
+
+	for (i = 0; i < 4; i++)
+		__raw_writel(0xffffffff, mxc_irq_base + TZIC_INTSEC0 + i * 4);
+
+	/* disable all interrupts */
+	for (i = 0; i < 4; i++)
+		__raw_writel(0xffffffff, mxc_irq_base + TZIC_ENCLEAR0 + i * 4);
+
+	for (i = 0; i < 128; i++) {
+		set_irq_chip(i, &mxc_tzic_chip);
+		set_irq_handler(i, handle_level_irq);
+		set_irq_flags(i, IRQF_VALID);
+	}
+
+	printk(KERN_INFO "MXC IRQ initialized\n");
+}
Signature · 4 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
Signature · 3 lines
----------------------------------------------------------------------
Amit Kucheria, Kernel Engineer || amit.kucheria at canonical.com
----------------------------------------------------------------------
#27 lore raw

Re: [PATCHv2 04/11] mxc: changes to common plat-mxc code to add support for i.MX5

Quoted 17 lines · Amit Kucheria
Quoted 7 lines · Sascha Hauer
Quoted 6 lines · Eric Miao

Mmm.... this should be something that we really need to get rid of, it just makes a single kernel for both TZIC and AVIC together impossible, if that's so designed by HW, I'm thinking about keeping this into plat-mxc/ is a good way to go ...

Quoted 8 lines
Quoted 3 lines

Sascha, you have any better idea? Provided the other file debug-macro.S in the same directory already seems to break the support for multiple arches?

I have the following patch which I'm not sure I like better. It can support both irq controller types and does not add overhead if only one of them is compiled in. It might need some refactoring to fit into Amits patch stack.

Quoted 8 lines

Is co-existence of TZIC and AVIC a blocker to merging i.MX5 code? I've already made changes so that i.MX5 doesn't explode if AVIC is compiled in.

Admittedly the assembly is a bit hard to rid, but we can fix in another set of patches geared towards unification of an i.MX kernel. IMHO, making these changes along with introducing a new SoC will make things a bit hard to follow/merge.

I personally don't feel that's a hard requirement, as long as it can be fixed.

#28 lore raw

Re: [PATCHv2 04/11] mxc: changes to common plat-mxc code to add support for i.MX5

In reply to Amit Kucheria
Quoted 1 line · Amit Kucheria

Changes separted to help in the review process

<soapbox>Commit log needs to talk about what the patch is, not how it has changed. Please state what the patch does and why. It is also helpful to have testing information. The goal is to make it easy for both patch reviewers on the mailing list *and* people looking at the commit in git after it is merged. This commit message doesn't provide the reader with any helpful information.

Patch version/review information like your comment above typically goes below the '---' line.</soapbox>

g.

Signature · 2 lines
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.
#29 lore raw

Re: [PATCHv2 03/11] mxc: Fix Drive Strength Field in the IOMUX controller

In reply to Amit Kucheria
Quoted 18 lines · Amit Kucheria

i.MX51 defines 4 values:

00: Low Drive Strength
01: Medium Drive Strength
10: High Drive Strength
11: Max Drive Strength

---
?arch/arm/plat-mxc/include/mach/iomux-v3.h | ? ?8 +++++--- ?1 files changed, 5 insertions(+), 3 deletions(-)

arch/arm/plat-mxc/include/mach/iomux-v3.h +0 -0
index 1deda01..f2f73d3 100644
@@ -81,11 +81,13 @@ struct pad_desc {
 

arch/arm/plat-mxc/include/mach/iomux-v3.h struct pad_desc { · line 88

Quoted 10 lines
arch/arm/plat-mxc/include/mach/iomux-v3.h +4 -3
 ?#define PAD_CTL_ODE ? ? ? ? ? ? ? ? ? ?(1 << 3)
 
-#define PAD_CTL_DSE_STANDARD ? ? ? ? ? (0 << 1)
-#define PAD_CTL_DSE_HIGH ? ? ? ? ? ? ? (1 << 1)
-#define PAD_CTL_DSE_MAX ? ? ? ? ? ? ? ? ? ? ? ?(2 << 1)
+#define PAD_CTL_DSE_LOW ? ? ? ? ? ? ? ? ? ? ? ?(0 << 1)
+#define PAD_CTL_DSE_MED ? ? ? ? ? ? ? ? ? ? ? ?(1 << 1)
+#define PAD_CTL_DSE_HIGH ? ? ? ? ? ? ? (2 << 1)
+#define PAD_CTL_DSE_MAX ? ? ? ? ? ? ? ? ? ? ? ?(3 << 1)
 

I'm seeing some changes in recent kernel with introduction of PAD_CTL_DRV_*, which also affects mx3, think it's a tough problem to keep backward compatibility
now, one way out is to introduce maybe PAD_CTL_DRV_EXTREME specifically for imx51.

Quoted 14 lines
arch/arm/plat-mxc/include/mach/iomux-v3.h +1 -0
 ?#define PAD_CTL_SRE_FAST ? ? ? ? ? ? ? (1 << 0)
+#define PAD_CTL_SRE_SLOW ? ? ? ? ? ? ? (0 << 0)
 

?/*
?* setups a single pad in the iomuxer
--
1.6.3.3

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

maintainer
#30 lore raw

Re: [PATCHv2 03/11] mxc: Fix Drive Strength Field in the IOMUX controller

Quoted 22 lines · Eric Miao
Quoted 20 lines · Amit Kucheria

i.MX51 defines 4 values:

00: Low Drive Strength
01: Medium Drive Strength
10: High Drive Strength
11: Max Drive Strength

---
?arch/arm/plat-mxc/include/mach/iomux-v3.h | ? ?8 +++++--- ?1 files changed, 5 insertions(+), 3 deletions(-)

arch/arm/plat-mxc/include/mach/iomux-v3.h +0 -0
index 1deda01..f2f73d3 100644
@@ -81,11 +81,13 @@ struct pad_desc {
 
 ?#define PAD_CTL_ODE ? ? ? ? ? ? ? ? ? ?(1 << 3)
 
Quoted 14 lines

arch/arm/plat-mxc/include/mach/iomux-v3.h struct pad_desc { · line 88

Quoted 8 lines
arch/arm/plat-mxc/include/mach/iomux-v3.h +4 -3
-#define PAD_CTL_DSE_STANDARD ? ? ? ? ? (0 << 1)
-#define PAD_CTL_DSE_HIGH ? ? ? ? ? ? ? (1 << 1)
-#define PAD_CTL_DSE_MAX ? ? ? ? ? ? ? ? ? ? ? ?(2 << 1)
+#define PAD_CTL_DSE_LOW ? ? ? ? ? ? ? ? ? ? ? ?(0 << 1)
+#define PAD_CTL_DSE_MED ? ? ? ? ? ? ? ? ? ? ? ?(1 << 1)
+#define PAD_CTL_DSE_HIGH ? ? ? ? ? ? ? (2 << 1)
+#define PAD_CTL_DSE_MAX ? ? ? ? ? ? ? ? ? ? ? ?(3 << 1)
 

I'm seeing some changes in recent kernel with introduction of PAD_CTL_DRV_*, which also affects mx3, think it's a tough problem to keep backward compatibility
now, one way out is to introduce maybe PAD_CTL_DRV_EXTREME specifically for imx51.

Given that the values are the same on i.MX3 and i.MX51 we could also do a

#define PAD_CTL_DSE(x) ((x) << 1)

and add a comment for allowed values 0..2 for i.MX3 and 0..3 for i.MX51.

Sascha

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

Re: [PATCHv2 03/11] mxc: Fix Drive Strength Field in the IOMUX controller

In reply to Amit Kucheria
Quoted 20 lines · Amit Kucheria

i.MX51 defines 4 values:

00: Low Drive Strength
01: Medium Drive Strength
10: High Drive Strength
11: Max Drive Strength

---
?arch/arm/plat-mxc/include/mach/iomux-v3.h | ? ?8 +++++--- ?1 files changed, 5 insertions(+), 3 deletions(-)

arch/arm/plat-mxc/include/mach/iomux-v3.h +0 -0
index 1deda01..f2f73d3 100644
@@ -81,11 +81,13 @@ struct pad_desc {
 
 ?#define PAD_CTL_ODE ? ? ? ? ? ? ? ? ? ?(1 << 3)
 

arch/arm/plat-mxc/include/mach/iomux-v3.h struct pad_desc { · line 90

Quoted 10 lines
arch/arm/plat-mxc/include/mach/iomux-v3.h +5 -3
-#define PAD_CTL_DSE_STANDARD ? ? ? ? ? (0 << 1)
-#define PAD_CTL_DSE_HIGH ? ? ? ? ? ? ? (1 << 1)
-#define PAD_CTL_DSE_MAX ? ? ? ? ? ? ? ? ? ? ? ?(2 << 1)
+#define PAD_CTL_DSE_LOW ? ? ? ? ? ? ? ? ? ? ? ?(0 << 1)
+#define PAD_CTL_DSE_MED ? ? ? ? ? ? ? ? ? ? ? ?(1 << 1)
+#define PAD_CTL_DSE_HIGH ? ? ? ? ? ? ? (2 << 1)
+#define PAD_CTL_DSE_MAX ? ? ? ? ? ? ? ? ? ? ? ?(3 << 1)
 
 ?#define PAD_CTL_SRE_FAST ? ? ? ? ? ? ? (1 << 0)
+#define PAD_CTL_SRE_SLOW ? ? ? ? ? ? ? (0 << 0)

Shouldn't the addition/change of #defines be done in patches that actually use them?

It would also help to include in the commit description what the impact of the change in values is. The description as written doesn't really give any indication on why the patch is important, which makes it hard to review.

g.

Signature · 2 lines
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.
#32 lore raw

Re: [PATCHv2 03/11] mxc: Fix Drive Strength Field in the IOMUX controller

Quoted 30 lines · Grant Likely
Quoted 28 lines · Amit Kucheria

i.MX51 defines 4 values:

00: Low Drive Strength
01: Medium Drive Strength
10: High Drive Strength
11: Max Drive Strength

---
?arch/arm/plat-mxc/include/mach/iomux-v3.h | ? ?8 +++++--- ?1 files changed, 5 insertions(+), 3 deletions(-)

arch/arm/plat-mxc/include/mach/iomux-v3.h +4 -3
index 1deda01..f2f73d3 100644
@@ -81,11 +81,13 @@ struct pad_desc {
 
 ?#define PAD_CTL_ODE ? ? ? ? ? ? ? ? ? ?(1 << 3)
 
-#define PAD_CTL_DSE_STANDARD ? ? ? ? ? (0 << 1)
-#define PAD_CTL_DSE_HIGH ? ? ? ? ? ? ? (1 << 1)
-#define PAD_CTL_DSE_MAX ? ? ? ? ? ? ? ? ? ? ? ?(2 << 1)
+#define PAD_CTL_DSE_LOW ? ? ? ? ? ? ? ? ? ? ? ?(0 << 1)
+#define PAD_CTL_DSE_MED ? ? ? ? ? ? ? ? ? ? ? ?(1 << 1)
+#define PAD_CTL_DSE_HIGH ? ? ? ? ? ? ? (2 << 1)
+#define PAD_CTL_DSE_MAX ? ? ? ? ? ? ? ? ? ? ? ?(3 << 1)
 
Quoted 5 lines

arch/arm/plat-mxc/include/mach/iomux-v3.h struct pad_desc { · line 90

Quoted 2 lines
arch/arm/plat-mxc/include/mach/iomux-v3.h +1 -0
 ?#define PAD_CTL_SRE_FAST ? ? ? ? ? ? ? (1 << 0)
+#define PAD_CTL_SRE_SLOW ? ? ? ? ? ? ? (0 << 0)

Shouldn't the addition/change of #defines be done in patches that actually use them?

I'll merge it into patch 5 that adds the core support for i.MX5. I kept it separate because the #defines are a (standalone) property of the IOMUX controller regardless of whether they are used by i.MX5 or not.

Thanks for all the reviews.

/Amit

Signature · 3 lines
-------------------------------------------------------------------------
Amit Kucheria,				 Kernel Developer, Verdurent
-------------------------------------------------------------------------
Acked-by on v2 2/11
#33 lore raw

Re: [PATCHv2 02/11] mxc timer: refactor timer code to use timer versions

In reply to Amit Kucheria
Quoted 23 lines · Amit Kucheria

From: Sascha Hauer <[email protected]>

Refactor the timer code into version 1 and version 2.

Essentially there are 2 versions of the timer hardware. Version 1 is found on MX1/MXL and MX21. Version 2 is found on MX25, MX27, MX31, MX35, MX37, MX51, and future parts.

---
?arch/arm/plat-mxc/time.c | ? 19 +++++++++++-------- ?1 files changed, 11 insertions(+), 8 deletions(-)

arch/arm/plat-mxc/time.c +0 -0
index 844567e..7d6499e 100644
@@ -57,6 +57,9 @@

?#define MX3_TCN ? ? ? ? ? ? ? ? ? ? ? ?0x24
?#define MX3_TCMP ? ? ? ? ? ? ? 0x10

arch/arm/plat-mxc/time.c

Quoted 2 lines
arch/arm/plat-mxc/time.c +2 -0
+#define timer_is_v1() ?(cpu_is_mx1() || cpu_is_mx27())
+#define timer_is_v2() ?(cpu_is_mx3() || cpu_is_mx25())

Just from a defensive programming standpoint, it may be better to define timer_is_v2() as (!timer_is_v1()). I assume future parts are more likely to be v2, and doing it that way means one less place in the code to modify when new parts appear.

Otherwise,

#34 lore raw

Re: [PATCHv2 01/11] arm: mxc: TrustZone interrupt controller (TZIC) for i.MX5 family

In reply to Amit Kucheria

Hi Amit,

Just some nit-picking review comments, see below:

Quoted 19 lines · Amit Kucheria

Freescale i.MX51 processor uses a new interrupt controller. Add driver for TrustZone Interrupt Controller

---

?arch/arm/plat-mxc/Kconfig ?| ? ?8 ++
?arch/arm/plat-mxc/Makefile | ? ?3 +
?arch/arm/plat-mxc/tzic.c ? | ?182 ++++++++++++++++++++++++++++++++++++++++++++

?3 files changed, 193 insertions(+), 0 deletions(-) ?create mode 100644 arch/arm/plat-mxc/tzic.c

arch/arm/plat-mxc/Kconfig +0 -0
index 8b0a1ee..59558c4 100644
@@ -62,6 +62,14 @@ config MXC_IRQ_PRIOR

? ? ? ? ?requirements for timing.
? ? ? ? ?Say N here, unless you have a specialized requirement.

Quoted 3 lines

+config MXC_TZIC
+ ? ? ? bool "Enable TrustZone Interrupt Controller"
+ ? ? ? depends on ARCH_MX51

This is the first patch of the base port, yet I cannot find any reference to this ARCH_MX51, did you miss something?

Quoted 65 lines

+ ? ? ? help
+ ? ? ? ? This will be automatically selected for all processors
+ ? ? ? ? containing this interrupt controller.
+ ? ? ? ? Say N here only if you are really sure.
+
?config MXC_PWM
? ? ? ?tristate "Enable PWM driver"
? ? ? ?depends on ARCH_MXC

arch/arm/plat-mxc/Makefile +0 -0
index 996cbac..0202ad9 100644
@@ -5,6 +5,9 @@

?# Common support
?obj-y := irq.o clock.o gpio.o time.o devices.o cpu.o system.o

arch/arm/plat-mxc/Makefile +3 -0
+# MX51 uses the TZIC interrupt controller, older platforms use AVIC (irq.o)
+obj-$(CONFIG_MXC_TZIC) += tzic.o
+

?obj-$(CONFIG_ARCH_MX1) += iomux-mx1-mx2.o dma-mx1-mx2.o ?obj-$(CONFIG_ARCH_MX2) += iomux-mx1-mx2.o dma-mx1-mx2.o ?obj-$(CONFIG_ARCH_MXC_IOMUX_V3) += iomux-v3.o

arch/arm/plat-mxc/tzic.c new file +37 -0
new file mode 100644
index 0000000..00cb0ad
@@ -0,0 +1,182 @@
+/*
+ * Copyright 2004-2009 Freescale Semiconductor, Inc. All Rights Reserved.
+ *
+ * The code contained herein is licensed under the GNU General Public
+ * License. You may obtain a copy of the GNU General Public License
+ * Version 2 or later at the following locations:
+ *
+ * http://www.opensource.org/licenses/gpl-license.html
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+
+#include <linux/module.h>
+#include <linux/moduleparam.h>
+#include <linux/init.h>
+#include <linux/device.h>
+#include <linux/errno.h>
+#include <linux/io.h>
+
+#include <asm/mach/irq.h>
+
+#include <mach/hardware.h>
+
+/*
+ *****************************************
+ * TZIC Registers ? ? ? ? ? ? ? ? ? ? ? ?*
+ *****************************************
+ */
+
+#define TZIC_INTCNTL ? ? ? ? ? ?0x0000 /* Control register */
+#define TZIC_INTTYPE ? ? ? ? ? ?0x0004 /* Controller Type register */
+#define TZIC_IMPID ? ? ? ? ? ? ?0x0008 /* Distributor Implementer Identification */
+#define TZIC_PRIOMASK ? ? ? ? ? 0x000C /* Priority Mask Reg */
+#define TZIC_SYNCCTRL ? ? ? ? ? 0x0010 /* Synchronizer Control register */
+#define TZIC_DSMINT ? ? ? ? ? ? 0x0014 /* DSM interrupt Holdoffregister */
+#define TZIC_INTSEC0 ? ? ? ? ? ?0x0080 /* Interrupt Security register 0 */
+#define TZIC_ENSET0 ? ? ? ? ? ? 0x0100 /* Enable Set Register 0 */
+#define TZIC_ENCLEAR0 ? ? ? ? ? 0x0180 /* Enable Clear Register 0 */

arch/arm/plat-mxc/tzic.c line 47

Quoted 10 lines
arch/arm/plat-mxc/tzic.c new file +10 -0
+#define TZIC_SRCSET0 ? ? ? ? ? ?0x0200 /* Source Set Register 0 */
+#define TZIC_SRCCLAR0 ? ? ? ? ? 0x0280 /* Source Clear Register 0 */
+#define TZIC_PRIORITY0 ? ? ? ? ?0x0400 /* Priority Register 0 */
+#define TZIC_PND0 ? ? ? ? ? ? ? 0x0D00 /* Pending Register 0 */
+#define TZIC_HIPND0 ? ? ? ? ? ? 0x0D80 /* High Priority Pending Register */
+#define TZIC_WAKEUP0 ? ? ? ? ? ?0x0E00 /* Wakeup Config Register */
+#define TZIC_SWINT ? ? ? ? ? ? ?0x0F00 /* Software Interrupt Rigger Register */
+#define TZIC_ID0 ? ? ? ? ? ? ? ?0x0FD0 /* Indentification Register 0 */
+
+void __iomem *tzic_base;

This can just be made to 'static' if it's not used elsewhere, and I'm wondering if it's neater to define them as:

#define TZIC_INTCNTL (tzic_base + 0x0000)

so to make the code below short and handy.

arch/arm/plat-mxc/tzic.c line 50

Quoted 3 lines
arch/arm/plat-mxc/tzic.c new file +3 -0
+
+/*
+ * Disable interrupt number "irq" in the TZIC

I don't think this follows kernel API doc exactly, you may want to have a look into Documentation/kernel-doc-nano-HOWTO.txt.

arch/arm/plat-mxc/tzic.c

Quoted 10 lines
arch/arm/plat-mxc/tzic.c new file +10 -0
+ *
+ * @param ?irq ? ? ? ? ?interrupt source number
+ */
+static void tzic_mask_irq(unsigned int irq)
+{
+ ? ? ? int index, off;
+
+ ? ? ? index = irq >> 5;
+ ? ? ? off = irq & 0x1F;
+ ? ? ? __raw_writel(1 << off, tzic_base + TZIC_ENCLEAR0 + (index << 2));

I'll normally define TZIC_ENCLEAR0 then as:

#define TZIC_ENCLEAR(i) (0x0180 + ((i) << 2))

so the above can be written as:

	__raw_writel(1 << off, tzic_base + TZIC_ENCLEAR(index));

or by including tzic_base into TZIC_*, simply as:

	__raw_writel(1 << off, TZIC_ENCLEAR(index));
Quoted 57 lines
arch/arm/plat-mxc/tzic.c new file +57 -0
+}
+
+/*
+ * Enable interrupt number "irq" in the TZIC
+ *
+ * @param ?irq ? ? ? ? ?interrupt source number
+ */
+static void tzic_unmask_irq(unsigned int irq)
+{
+ ? ? ? int index, off;
+
+ ? ? ? index = irq >> 5;
+ ? ? ? off = irq & 0x1F;
+ ? ? ? __raw_writel(1 << off, tzic_base + TZIC_ENSET0 + (index << 2));
+}
+
+static unsigned int wakeup_intr[4];
+
+/*
+ * Set interrupt number "irq" in the TZIC as a wake-up source.
+ *
+ * @param ?irq ? ? ? ? ?interrupt source number
+ * @param ?enable ? ? ? enable as wake-up if equal to non-zero
+ * ? ? ? ? ? ? ? ? ? ? disble as wake-up if equal to zero
+ *
+ * @return ? ? ? This function returns 0 on success.
+ */
+static int tzic_set_wake_irq(unsigned int irq, unsigned int enable)
+{
+ ? ? ? unsigned int index, off;
+
+ ? ? ? index = irq >> 5;
+ ? ? ? off = irq & 0x1F;
+
+ ? ? ? if (index > 3)
+ ? ? ? ? ? ? ? return -EINVAL;
+
+ ? ? ? if (enable)
+ ? ? ? ? ? ? ? wakeup_intr[index] |= (1 << off);
+ ? ? ? else
+ ? ? ? ? ? ? ? wakeup_intr[index] &= ~(1 << off);
+
+ ? ? ? return 0;
+}
+
+static struct irq_chip mxc_tzic_chip = {
+ ? ? ? .name = "MXC_TZIC",
+ ? ? ? .ack = tzic_mask_irq,
+ ? ? ? .mask = tzic_mask_irq,
+ ? ? ? .unmask = tzic_unmask_irq,
+ ? ? ? .set_wake = tzic_set_wake_irq,
+};
+
+/*
+ * This function initializes the TZIC hardware and disables all the
+ * interrupts. It registers the interrupt enable and disable functions
+ * to the kernel for each interrupt source.

arch/arm/plat-mxc/tzic.c

Quoted 10 lines
arch/arm/plat-mxc/tzic.c new file +10 -0
+ */
+void __init tzic_init_irq(void __iomem *irqbase)
+{
+ ? ? ? int i;
+
+ ? ? ? tzic_base = irqbase;
+ ? ? ? /* put the TZIC into the reset value with
+ ? ? ? ?* all interrupts disabled
+ ? ? ? ?*/
+ ? ? ? i = __raw_readl(tzic_base + TZIC_INTCNTL);

Mixing the use of 'i' as both a signed counter and register value might not be a good idea, provided it's not guaranteed from theory that 'i' as an integer could not be sufficient to hold the value returned from __raw_readl()

arch/arm/plat-mxc/tzic.c line 134

Quoted 7 lines
arch/arm/plat-mxc/tzic.c new file +7 -0
+
+ ? ? ? __raw_writel(0x80010001, tzic_base + TZIC_INTCNTL);
+ ? ? ? i = __raw_readl(tzic_base + TZIC_INTCNTL);
+ ? ? ? __raw_writel(0x1f, tzic_base + TZIC_PRIOMASK);
+ ? ? ? i = __raw_readl(tzic_base + TZIC_PRIOMASK);
+ ? ? ? __raw_writel(0x02, tzic_base + TZIC_SYNCCTRL);
+ ? ? ? i = __raw_readl(tzic_base + TZIC_SYNCCTRL);

Are these read-back really necessary? We can start without them and add them later if they do cause issues.

Quoted 7 lines
arch/arm/plat-mxc/tzic.c new file +7 -0
+
+ ? ? ? for (i = 0; i < 4; i++)
+ ? ? ? ? ? ? ? __raw_writel(0xFFFFFFFF, tzic_base + TZIC_INTSEC0 + i * 4);
+
+ ? ? ? /* disable all interrupts */
+ ? ? ? for (i = 0; i < 4; i++)
+ ? ? ? ? ? ? ? __raw_writel(0xFFFFFFFF, tzic_base + TZIC_ENCLEAR0 + i * 4);

arch/arm/plat-mxc/tzic.c line 151

Quoted 10 lines
arch/arm/plat-mxc/tzic.c new file +10 -0
+
+ ? ? ? /* all IRQ no FIQ Warning :: No selection */
+
+ ? ? ? for (i = 0; i < MXC_INTERNAL_IRQS; i++) {
+ ? ? ? ? ? ? ? set_irq_chip(i, &mxc_tzic_chip);
+ ? ? ? ? ? ? ? set_irq_handler(i, handle_level_irq);
+ ? ? ? ? ? ? ? set_irq_flags(i, IRQF_VALID);
+ ? ? ? }
+
+ ? ? ? printk(KERN_INFO "TrustZone Interrupt Controller (TZIC) initialized\n");

You may want to use pr_info() for short.

Quoted 7 lines
arch/arm/plat-mxc/tzic.c new file +7 -0
+}
+
+/*
+ * enable wakeup interrupt
+ *
+ * @param is_idle ? ? ? ? ? ? ?1 if called in idle loop (ENSET register);
+ * ? ? ? ? ? ? ? ? ? ? ? ? ? ? 0 to be used when called from low power entry

arch/arm/plat-mxc/tzic.c

Quoted 10 lines
arch/arm/plat-mxc/tzic.c new file +10 -0
+ * @return ? ? ? ? ? ? ? ? ? ? 0 if successful; non-zero otherwise
+ *
+ */
+int tzic_enable_wake(int is_idle)
+{
+ ? ? ? unsigned int i, v;
+
+ ? ? ? __raw_writel(1, tzic_base + TZIC_DSMINT);
+ ? ? ? if (unlikely(__raw_readl(tzic_base + TZIC_DSMINT) == 0))
+ ? ? ? ? ? ? ? return -EAGAIN;

Looks like an unnecessary read-back provided the silicon is sane enough.

arch/arm/plat-mxc/tzic.c line 180

Quoted 12 lines
arch/arm/plat-mxc/tzic.c new file +12 -0
+
+ ? ? ? if (likely(is_idle)) {
+ ? ? ? ? ? ? ? for (i = 0; i < 4; i++) {
+ ? ? ? ? ? ? ? ? ? ? ? v = __raw_readl(tzic_base + TZIC_ENSET0 + i * 4);
+ ? ? ? ? ? ? ? ? ? ? ? __raw_writel(v, tzic_base + TZIC_WAKEUP0 + i * 4);
+ ? ? ? ? ? ? ? }
+ ? ? ? } else {
+ ? ? ? ? ? ? ? for (i = 0; i < 4; i++) {
+ ? ? ? ? ? ? ? ? ? ? ? v = wakeup_intr[i];
+ ? ? ? ? ? ? ? ? ? ? ? __raw_writel(v, tzic_base + TZIC_WAKEUP0 + i * 4);
+ ? ? ? ? ? ? ? }
+ ? ? ? }

Or could be simplified to:

	for (i = 0; i < 4; i++) {
		v = is_idle ? __raw_readl(TZIC_ENSET(i)) : wakeup_intr[i];
		__raw_writel(v, TZIC_WAKEUP(i));
	}

but just nit-picking comments, so it's up to you.

arch/arm/plat-mxc/tzic.c line 182

Quoted 2 lines
arch/arm/plat-mxc/tzic.c new file +2 -0
+ ? ? ? return 0;
+}

Mmmm.... this being called elsewhere, I'm thinking about making this a sys_device and having this called within sysdev_class.suspend() to make this file rather self-contained.

maintainer
#35 lore raw

Re: [PATCHv2 01/11] arm: mxc: TrustZone interrupt controller (TZIC) for i.MX5 family

Quoted 102 lines · Eric Miao

Hi Amit,

Just some nit-picking review comments, see below:

Quoted 19 lines · Amit Kucheria

Freescale i.MX51 processor uses a new interrupt controller. Add driver for TrustZone Interrupt Controller

---

?arch/arm/plat-mxc/Kconfig ?| ? ?8 ++
?arch/arm/plat-mxc/Makefile | ? ?3 +
?arch/arm/plat-mxc/tzic.c ? | ?182 ++++++++++++++++++++++++++++++++++++++++++++

?3 files changed, 193 insertions(+), 0 deletions(-) ?create mode 100644 arch/arm/plat-mxc/tzic.c

arch/arm/plat-mxc/Kconfig +0 -0
index 8b0a1ee..59558c4 100644
@@ -62,6 +62,14 @@ config MXC_IRQ_PRIOR

? ? ? ? ?requirements for timing.
? ? ? ? ?Say N here, unless you have a specialized requirement.

Quoted 3 lines

+config MXC_TZIC
+ ? ? ? bool "Enable TrustZone Interrupt Controller"
+ ? ? ? depends on ARCH_MX51

This is the first patch of the base port, yet I cannot find any reference to this ARCH_MX51, did you miss something?

Quoted 70 lines

+ ? ? ? help
+ ? ? ? ? This will be automatically selected for all processors
+ ? ? ? ? containing this interrupt controller.
+ ? ? ? ? Say N here only if you are really sure.
+
?config MXC_PWM
? ? ? ?tristate "Enable PWM driver"
? ? ? ?depends on ARCH_MXC

arch/arm/plat-mxc/Makefile +0 -0
index 996cbac..0202ad9 100644
@@ -5,6 +5,9 @@

?# Common support
?obj-y := irq.o clock.o gpio.o time.o devices.o cpu.o system.o

arch/arm/plat-mxc/Makefile +3 -0
+# MX51 uses the TZIC interrupt controller, older platforms use AVIC (irq.o)
+obj-$(CONFIG_MXC_TZIC) += tzic.o
+

?obj-$(CONFIG_ARCH_MX1) += iomux-mx1-mx2.o dma-mx1-mx2.o ?obj-$(CONFIG_ARCH_MX2) += iomux-mx1-mx2.o dma-mx1-mx2.o ?obj-$(CONFIG_ARCH_MXC_IOMUX_V3) += iomux-v3.o

arch/arm/plat-mxc/tzic.c new file +42 -0
new file mode 100644
index 0000000..00cb0ad
@@ -0,0 +1,182 @@
+/*
+ * Copyright 2004-2009 Freescale Semiconductor, Inc. All Rights Reserved.
+ *
+ * The code contained herein is licensed under the GNU General Public
+ * License. You may obtain a copy of the GNU General Public License
+ * Version 2 or later at the following locations:
+ *
+ * http://www.opensource.org/licenses/gpl-license.html
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+
+#include <linux/module.h>
+#include <linux/moduleparam.h>
+#include <linux/init.h>
+#include <linux/device.h>
+#include <linux/errno.h>
+#include <linux/io.h>
+
+#include <asm/mach/irq.h>
+
+#include <mach/hardware.h>
+
+/*
+ *****************************************
+ * TZIC Registers ? ? ? ? ? ? ? ? ? ? ? ?*
+ *****************************************
+ */
+
+#define TZIC_INTCNTL ? ? ? ? ? ?0x0000 /* Control register */
+#define TZIC_INTTYPE ? ? ? ? ? ?0x0004 /* Controller Type register */
+#define TZIC_IMPID ? ? ? ? ? ? ?0x0008 /* Distributor Implementer Identification */
+#define TZIC_PRIOMASK ? ? ? ? ? 0x000C /* Priority Mask Reg */
+#define TZIC_SYNCCTRL ? ? ? ? ? 0x0010 /* Synchronizer Control register */
+#define TZIC_DSMINT ? ? ? ? ? ? 0x0014 /* DSM interrupt Holdoffregister */
+#define TZIC_INTSEC0 ? ? ? ? ? ?0x0080 /* Interrupt Security register 0 */
+#define TZIC_ENSET0 ? ? ? ? ? ? 0x0100 /* Enable Set Register 0 */
+#define TZIC_ENCLEAR0 ? ? ? ? ? 0x0180 /* Enable Clear Register 0 */
+#define TZIC_SRCSET0 ? ? ? ? ? ?0x0200 /* Source Set Register 0 */
+#define TZIC_SRCCLAR0 ? ? ? ? ? 0x0280 /* Source Clear Register 0 */
+#define TZIC_PRIORITY0 ? ? ? ? ?0x0400 /* Priority Register 0 */
+#define TZIC_PND0 ? ? ? ? ? ? ? 0x0D00 /* Pending Register 0 */
+#define TZIC_HIPND0 ? ? ? ? ? ? 0x0D80 /* High Priority Pending Register */
Quoted 8 lines

arch/arm/plat-mxc/tzic.c line 47

Quoted 5 lines
arch/arm/plat-mxc/tzic.c new file +5 -0
+#define TZIC_WAKEUP0 ? ? ? ? ? ?0x0E00 /* Wakeup Config Register */
+#define TZIC_SWINT ? ? ? ? ? ? ?0x0F00 /* Software Interrupt Rigger Register */
+#define TZIC_ID0 ? ? ? ? ? ? ? ?0x0FD0 /* Indentification Register 0 */
+
+void __iomem *tzic_base;

This can just be made to 'static' if it's not used elsewhere, and I'm wondering if it's neater to define them as:

It is used in entry-macro.S for the irq controller base. We should add a comment to make this clear.

Sascha

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

Re: [PATCHv2 01/11] arm: mxc: TrustZone interrupt controller (TZIC) for i.MX5 family

In reply to Eric Miao
Quoted 25 lines · Eric Miao

Hi Amit,

Just some nit-picking review comments, see below:

Quoted 19 lines · Amit Kucheria

Freescale i.MX51 processor uses a new interrupt controller. Add driver for TrustZone Interrupt Controller

---

?arch/arm/plat-mxc/Kconfig ?| ? ?8 ++
?arch/arm/plat-mxc/Makefile | ? ?3 +
?arch/arm/plat-mxc/tzic.c ? | ?182 ++++++++++++++++++++++++++++++++++++++++++++

?3 files changed, 193 insertions(+), 0 deletions(-) ?create mode 100644 arch/arm/plat-mxc/tzic.c

arch/arm/plat-mxc/Kconfig +0 -0
index 8b0a1ee..59558c4 100644
@@ -62,6 +62,14 @@ config MXC_IRQ_PRIOR

? ? ? ? ?requirements for timing.
? ? ? ? ?Say N here, unless you have a specialized requirement.

Quoted 6 lines
Quoted 3 lines

+config MXC_TZIC
+ ? ? ? bool "Enable TrustZone Interrupt Controller"
+ ? ? ? depends on ARCH_MX51

This is the first patch of the base port, yet I cannot find any reference to this ARCH_MX51, did you miss something?

ARCH_MX51 is only introduced in the later patches that add the core i.MX5 code. Since TZIC is not inherently dependent on i.MX5 (it's merely the first processor to use it), I thought of splitting it out as a separate patch.

Does this break the sanctity of one self-contained change?

Quoted 79 lines
Quoted 65 lines

+ ? ? ? help
+ ? ? ? ? This will be automatically selected for all processors
+ ? ? ? ? containing this interrupt controller.
+ ? ? ? ? Say N here only if you are really sure.
+
?config MXC_PWM
? ? ? ?tristate "Enable PWM driver"
? ? ? ?depends on ARCH_MXC

arch/arm/plat-mxc/Makefile +0 -0
index 996cbac..0202ad9 100644
@@ -5,6 +5,9 @@

?# Common support
?obj-y := irq.o clock.o gpio.o time.o devices.o cpu.o system.o

arch/arm/plat-mxc/Makefile +3 -0
+# MX51 uses the TZIC interrupt controller, older platforms use AVIC (irq.o)
+obj-$(CONFIG_MXC_TZIC) += tzic.o
+

?obj-$(CONFIG_ARCH_MX1) += iomux-mx1-mx2.o dma-mx1-mx2.o ?obj-$(CONFIG_ARCH_MX2) += iomux-mx1-mx2.o dma-mx1-mx2.o ?obj-$(CONFIG_ARCH_MXC_IOMUX_V3) += iomux-v3.o

arch/arm/plat-mxc/tzic.c new file +37 -0
new file mode 100644
index 0000000..00cb0ad
@@ -0,0 +1,182 @@
+/*
+ * Copyright 2004-2009 Freescale Semiconductor, Inc. All Rights Reserved.
+ *
+ * The code contained herein is licensed under the GNU General Public
+ * License. You may obtain a copy of the GNU General Public License
+ * Version 2 or later at the following locations:
+ *
+ * http://www.opensource.org/licenses/gpl-license.html
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+
+#include <linux/module.h>
+#include <linux/moduleparam.h>
+#include <linux/init.h>
+#include <linux/device.h>
+#include <linux/errno.h>
+#include <linux/io.h>
+
+#include <asm/mach/irq.h>
+
+#include <mach/hardware.h>
+
+/*
+ *****************************************
+ * TZIC Registers ? ? ? ? ? ? ? ? ? ? ? ?*
+ *****************************************
+ */
+
+#define TZIC_INTCNTL ? ? ? ? ? ?0x0000 /* Control register */
+#define TZIC_INTTYPE ? ? ? ? ? ?0x0004 /* Controller Type register */
+#define TZIC_IMPID ? ? ? ? ? ? ?0x0008 /* Distributor Implementer Identification */
+#define TZIC_PRIOMASK ? ? ? ? ? 0x000C /* Priority Mask Reg */
+#define TZIC_SYNCCTRL ? ? ? ? ? 0x0010 /* Synchronizer Control register */
+#define TZIC_DSMINT ? ? ? ? ? ? 0x0014 /* DSM interrupt Holdoffregister */
+#define TZIC_INTSEC0 ? ? ? ? ? ?0x0080 /* Interrupt Security register 0 */
+#define TZIC_ENSET0 ? ? ? ? ? ? 0x0100 /* Enable Set Register 0 */
+#define TZIC_ENCLEAR0 ? ? ? ? ? 0x0180 /* Enable Clear Register 0 */

arch/arm/plat-mxc/tzic.c line 47

Quoted 10 lines
arch/arm/plat-mxc/tzic.c new file +10 -0
+#define TZIC_SRCSET0 ? ? ? ? ? ?0x0200 /* Source Set Register 0 */
+#define TZIC_SRCCLAR0 ? ? ? ? ? 0x0280 /* Source Clear Register 0 */
+#define TZIC_PRIORITY0 ? ? ? ? ?0x0400 /* Priority Register 0 */
+#define TZIC_PND0 ? ? ? ? ? ? ? 0x0D00 /* Pending Register 0 */
+#define TZIC_HIPND0 ? ? ? ? ? ? 0x0D80 /* High Priority Pending Register */
+#define TZIC_WAKEUP0 ? ? ? ? ? ?0x0E00 /* Wakeup Config Register */
+#define TZIC_SWINT ? ? ? ? ? ? ?0x0F00 /* Software Interrupt Rigger Register */
+#define TZIC_ID0 ? ? ? ? ? ? ? ?0x0FD0 /* Indentification Register 0 */
+
+void __iomem *tzic_base;

This can just be made to 'static' if it's not used elsewhere, and I'm wondering if it's neater to define them as:

Quoted 3 lines

#define TZIC_INTCNTL (tzic_base + 0x0000)

so to make the code below short and handy.

tzic_base is actually used in entry-macro.S in patch 0004. I've tried to follow AVIC's way of doing things.

Quoted 6 lines

arch/arm/plat-mxc/tzic.c line 50

Quoted 3 lines
arch/arm/plat-mxc/tzic.c new file +3 -0
+
+/*
+ * Disable interrupt number "irq" in the TZIC

I don't think this follows kernel API doc exactly, you may want to have a look into Documentation/kernel-doc-nano-HOWTO.txt.

OK.

Quoted 15 lines

arch/arm/plat-mxc/tzic.c

Quoted 10 lines
arch/arm/plat-mxc/tzic.c new file +10 -0
+ *
+ * @param ?irq ? ? ? ? ?interrupt source number
+ */
+static void tzic_mask_irq(unsigned int irq)
+{
+ ? ? ? int index, off;
+
+ ? ? ? index = irq >> 5;
+ ? ? ? off = irq & 0x1F;
+ ? ? ? __raw_writel(1 << off, tzic_base + TZIC_ENCLEAR0 + (index << 2));

I'll normally define TZIC_ENCLEAR0 then as:

#define TZIC_ENCLEAR(i) (0x0180 + ((i) << 2))

Quoted 7 lines

so the above can be written as:

	__raw_writel(1 << off, tzic_base + TZIC_ENCLEAR(index));

or by including tzic_base into TZIC_*, simply as:

	__raw_writel(1 << off, TZIC_ENCLEAR(index));

OK.

Quoted 64 lines
Quoted 64 lines
arch/arm/plat-mxc/tzic.c new file +64 -0
+}
+
+/*
+ * Enable interrupt number "irq" in the TZIC
+ *
+ * @param ?irq ? ? ? ? ?interrupt source number
+ */
+static void tzic_unmask_irq(unsigned int irq)
+{
+ ? ? ? int index, off;
+
+ ? ? ? index = irq >> 5;
+ ? ? ? off = irq & 0x1F;
+ ? ? ? __raw_writel(1 << off, tzic_base + TZIC_ENSET0 + (index << 2));
+}
+
+static unsigned int wakeup_intr[4];
+
+/*
+ * Set interrupt number "irq" in the TZIC as a wake-up source.
+ *
+ * @param ?irq ? ? ? ? ?interrupt source number
+ * @param ?enable ? ? ? enable as wake-up if equal to non-zero
+ * ? ? ? ? ? ? ? ? ? ? disble as wake-up if equal to zero
+ *
+ * @return ? ? ? This function returns 0 on success.
+ */
+static int tzic_set_wake_irq(unsigned int irq, unsigned int enable)
+{
+ ? ? ? unsigned int index, off;
+
+ ? ? ? index = irq >> 5;
+ ? ? ? off = irq & 0x1F;
+
+ ? ? ? if (index > 3)
+ ? ? ? ? ? ? ? return -EINVAL;
+
+ ? ? ? if (enable)
+ ? ? ? ? ? ? ? wakeup_intr[index] |= (1 << off);
+ ? ? ? else
+ ? ? ? ? ? ? ? wakeup_intr[index] &= ~(1 << off);
+
+ ? ? ? return 0;
+}
+
+static struct irq_chip mxc_tzic_chip = {
+ ? ? ? .name = "MXC_TZIC",
+ ? ? ? .ack = tzic_mask_irq,
+ ? ? ? .mask = tzic_mask_irq,
+ ? ? ? .unmask = tzic_unmask_irq,
+ ? ? ? .set_wake = tzic_set_wake_irq,
+};
+
+/*
+ * This function initializes the TZIC hardware and disables all the
+ * interrupts. It registers the interrupt enable and disable functions
+ * to the kernel for each interrupt source.
+ */
+void __init tzic_init_irq(void __iomem *irqbase)
+{
+ ? ? ? int i;
+
+ ? ? ? tzic_base = irqbase;
+ ? ? ? /* put the TZIC into the reset value with
Quoted 8 lines

arch/arm/plat-mxc/tzic.c line 127

Quoted 3 lines
arch/arm/plat-mxc/tzic.c new file +3 -0
+ ? ? ? ?* all interrupts disabled
+ ? ? ? ?*/
+ ? ? ? i = __raw_readl(tzic_base + TZIC_INTCNTL);

Mixing the use of 'i' as both a signed counter and register value might not be a good idea, provided it's not guaranteed from theory that 'i' as an integer could not be sufficient to hold the value returned from __raw_readl()

Fair enough.

Quoted 10 lines

arch/arm/plat-mxc/tzic.c line 134

Quoted 7 lines
arch/arm/plat-mxc/tzic.c new file +7 -0
+
+ ? ? ? __raw_writel(0x80010001, tzic_base + TZIC_INTCNTL);
+ ? ? ? i = __raw_readl(tzic_base + TZIC_INTCNTL);
+ ? ? ? __raw_writel(0x1f, tzic_base + TZIC_PRIOMASK);
+ ? ? ? i = __raw_readl(tzic_base + TZIC_PRIOMASK);
+ ? ? ? __raw_writel(0x02, tzic_base + TZIC_SYNCCTRL);
+ ? ? ? i = __raw_readl(tzic_base + TZIC_SYNCCTRL);

Are these read-back really necessary? We can start without them and add them later if they do cause issues.

Can anybody from Freescale comment whether the read-back is necessary?

I'll remove it for now to see what happens in my testing.

Quoted 11 lines
Quoted 11 lines
arch/arm/plat-mxc/tzic.c new file +11 -0
+
+ ? ? ? for (i = 0; i < 4; i++)
+ ? ? ? ? ? ? ? __raw_writel(0xFFFFFFFF, tzic_base + TZIC_INTSEC0 + i * 4);
+
+ ? ? ? /* disable all interrupts */
+ ? ? ? for (i = 0; i < 4; i++)
+ ? ? ? ? ? ? ? __raw_writel(0xFFFFFFFF, tzic_base + TZIC_ENCLEAR0 + i * 4);
+
+ ? ? ? /* all IRQ no FIQ Warning :: No selection */
+
+ ? ? ? for (i = 0; i < MXC_INTERNAL_IRQS; i++) {
Quoted 8 lines

arch/arm/plat-mxc/tzic.c line 151

Quoted 6 lines
arch/arm/plat-mxc/tzic.c new file +6 -0
+ ? ? ? ? ? ? ? set_irq_chip(i, &mxc_tzic_chip);
+ ? ? ? ? ? ? ? set_irq_handler(i, handle_level_irq);
+ ? ? ? ? ? ? ? set_irq_flags(i, IRQF_VALID);
+ ? ? ? }
+
+ ? ? ? printk(KERN_INFO "TrustZone Interrupt Controller (TZIC) initialized\n");

You may want to use pr_info() for short.

OK

Quoted 11 lines
Quoted 11 lines
arch/arm/plat-mxc/tzic.c new file +11 -0
+}
+
+/*
+ * enable wakeup interrupt
+ *
+ * @param is_idle ? ? ? ? ? ? ?1 if called in idle loop (ENSET register);
+ * ? ? ? ? ? ? ? ? ? ? ? ? ? ? 0 to be used when called from low power entry
+ * @return ? ? ? ? ? ? ? ? ? ? 0 if successful; non-zero otherwise
+ *
+ */
+int tzic_enable_wake(int is_idle)
Quoted 8 lines

arch/arm/plat-mxc/tzic.c line 168

Quoted 6 lines
arch/arm/plat-mxc/tzic.c new file +6 -0
+{
+ ? ? ? unsigned int i, v;
+
+ ? ? ? __raw_writel(1, tzic_base + TZIC_DSMINT);
+ ? ? ? if (unlikely(__raw_readl(tzic_base + TZIC_DSMINT) == 0))
+ ? ? ? ? ? ? ? return -EAGAIN;

Looks like an unnecessary read-back provided the silicon is sane enough.

Again, Dinh/Rob can you comment?

Quoted 13 lines

arch/arm/plat-mxc/tzic.c line 180

Quoted 12 lines
arch/arm/plat-mxc/tzic.c new file +12 -0
+
+ ? ? ? if (likely(is_idle)) {
+ ? ? ? ? ? ? ? for (i = 0; i < 4; i++) {
+ ? ? ? ? ? ? ? ? ? ? ? v = __raw_readl(tzic_base + TZIC_ENSET0 + i * 4);
+ ? ? ? ? ? ? ? ? ? ? ? __raw_writel(v, tzic_base + TZIC_WAKEUP0 + i * 4);
+ ? ? ? ? ? ? ? }
+ ? ? ? } else {
+ ? ? ? ? ? ? ? for (i = 0; i < 4; i++) {
+ ? ? ? ? ? ? ? ? ? ? ? v = wakeup_intr[i];
+ ? ? ? ? ? ? ? ? ? ? ? __raw_writel(v, tzic_base + TZIC_WAKEUP0 + i * 4);
+ ? ? ? ? ? ? ? }
+ ? ? ? }
Quoted 6 lines

Or could be simplified to:

	for (i = 0; i < 4; i++) {
		v = is_idle ? __raw_readl(TZIC_ENSET(i)) : wakeup_intr[i];
		__raw_writel(v, TZIC_WAKEUP(i));
	}

OK

Quoted 8 lines

but just nit-picking comments, so it's up to you.

arch/arm/plat-mxc/tzic.c line 182

Quoted 2 lines
arch/arm/plat-mxc/tzic.c new file +2 -0
+ ? ? ? return 0;
+}

Mmmm.... this being called elsewhere, I'm thinking about making this a sys_device and having this called within sysdev_class.suspend() to make this file rather self-contained.

That is the idea once the base port is upstream.

Thanks for the review.

/Amit

Signature · 3 lines
----------------------------------------------------------------------
Amit Kucheria, Kernel Engineer || amit.kucheria at canonical.com
----------------------------------------------------------------------
#37 lore raw

Re: [PATCHv2 01/11] arm: mxc: TrustZone interrupt controller (TZIC) for i.MX5 family

Quoted 33 lines · Amit Kucheria
Quoted 25 lines · Eric Miao

Hi Amit,

Just some nit-picking review comments, see below:

Quoted 19 lines · Amit Kucheria

Freescale i.MX51 processor uses a new interrupt controller. Add driver for TrustZone Interrupt Controller

---

?arch/arm/plat-mxc/Kconfig ?| ? ?8 ++
?arch/arm/plat-mxc/Makefile | ? ?3 +
?arch/arm/plat-mxc/tzic.c ? | ?182 ++++++++++++++++++++++++++++++++++++++++++++

?3 files changed, 193 insertions(+), 0 deletions(-) ?create mode 100644 arch/arm/plat-mxc/tzic.c

arch/arm/plat-mxc/Kconfig +0 -0
index 8b0a1ee..59558c4 100644
@@ -62,6 +62,14 @@ config MXC_IRQ_PRIOR

? ? ? ? ?requirements for timing.
? ? ? ? ?Say N here, unless you have a specialized requirement.

Quoted 6 lines
Quoted 3 lines

+config MXC_TZIC
+ ? ? ? bool "Enable TrustZone Interrupt Controller"
+ ? ? ? depends on ARCH_MX51

This is the first patch of the base port, yet I cannot find any reference to this ARCH_MX51, did you miss something?

Quoted 6 lines

ARCH_MX51 is only introduced in the later patches that add the core i.MX5 code. Since TZIC is not inherently dependent on i.MX5 (it's merely the first processor to use it), I thought of splitting it out as a separate patch.

Does this break the sanctity of one self-contained change?

This breaks git-bisect, we may want a buildable kernel every commit if possible.

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

+ ? ? ? help
+ ? ? ? ? This will be automatically selected for all processors
+ ? ? ? ? containing this interrupt controller.
+ ? ? ? ? Say N here only if you are really sure.
+

...

Quoted 3 lines

Thanks for the review.

No problem, dude.

#38 lore raw

Re: [PATCHv2 01/11] arm: mxc: TrustZone interrupt controller (TZIC) for i.MX5 family

Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
Quoted 3 lines

+config MXC_TZIC
+ ? ? ? bool "Enable TrustZone Interrupt Controller"
+ ? ? ? depends on ARCH_MX51

This is the first patch of the base port, yet I cannot find any reference to this ARCH_MX51, did you miss something?

Quoted 9 lines
Quoted 6 lines

ARCH_MX51 is only introduced in the later patches that add the core i.MX5 code. Since TZIC is not inherently dependent on i.MX5 (it's merely the first processor to use it), I thought of splitting it out as a separate patch.

Does this break the sanctity of one self-contained change?

This breaks git-bisect, we may want a buildable kernel every commit if possible.

Hmm... you may safely ignore this, it's not going to break the build since it won't be selected without ARCH_MX51 being defined.

#39 lore raw

RE: [PATCHv2 01/11] arm: mxc: TrustZone interrupt controller (TZIC) for i.MX5 family

In reply to Amit Kucheria

-----Original Message-----
From: Amit Kucheria [mailto:amit.kucheria at canonical.com]
Sent: Wednesday, February 03, 2010 7:24 AM
To: Eric Miao
Cc: List Linux Kernel; linux at arm.linux.org.uk; Nguyen Dinh-R00091; s.hauer at pengutronix.de; grant.likely at secretlab.ca; Herring Robert-RA7055; linux-arm-kernel at lists.infradead.org; daniel at caiaq.de; bryan.wu at canonical.com; valentin.longchamp at epfl.ch
Subject: Re: [PATCHv2 01/11] arm: mxc: TrustZone interrupt controller (TZIC) for i.MX5 family

Quoted 26 lines · Eric Miao

Hi Amit,

Just some nit-picking review comments, see below:

Quoted 20 lines · Amit Kucheria

Freescale i.MX51 processor uses a new interrupt controller. Add driver for TrustZone Interrupt Controller

---

?arch/arm/plat-mxc/Kconfig ?| ? ?8 ++
?arch/arm/plat-mxc/Makefile | ? ?3 +
?arch/arm/plat-mxc/tzic.c ? | ?182 

++++++++++++++++++++++++++++++++++++++++++++
?3 files changed, 193 insertions(+), 0 deletions(-) ?create mode 100644 arch/arm/plat-mxc/tzic.c

arch/arm/plat-mxc/Kconfig +0 -0
index 8b0a1ee..59558c4 100644
@@ -62,6 +62,14 @@ config MXC_IRQ_PRIOR

? ? ? ? ?requirements for timing.
? ? ? ? ?Say N here, unless you have a specialized requirement.

Quoted 6 lines
Quoted 3 lines

+config MXC_TZIC
+ ? ? ? bool "Enable TrustZone Interrupt Controller"
+ ? ? ? depends on ARCH_MX51

This is the first patch of the base port, yet I cannot find any reference to this ARCH_MX51, did you miss something?

ARCH_MX51 is only introduced in the later patches that add the core i.MX5 code. Since TZIC is not inherently dependent on i.MX5 (it's merely the first processor to use it), I thought of splitting it out as a separate patch.

Does this break the sanctity of one self-contained change?

Quoted 81 lines
Quoted 67 lines

+ ? ? ? help
+ ? ? ? ? This will be automatically selected for all processors
+ ? ? ? ? containing this interrupt controller.
+ ? ? ? ? Say N here only if you are really sure.
+
?config MXC_PWM
? ? ? ?tristate "Enable PWM driver"
? ? ? ?depends on ARCH_MXC

arch/arm/plat-mxc/Makefile +0 -0
index 996cbac..0202ad9 100644
@@ -5,6 +5,9 @@

?# Common support
?obj-y := irq.o clock.o gpio.o time.o devices.o cpu.o system.o

arch/arm/plat-mxc/Makefile +4 -0
+# MX51 uses the TZIC interrupt controller, older platforms use AVIC 
+(irq.o)
+obj-$(CONFIG_MXC_TZIC) += tzic.o
+

?obj-$(CONFIG_ARCH_MX1) += iomux-mx1-mx2.o dma-mx1-mx2.o ?obj-$(CONFIG_ARCH_MX2) += iomux-mx1-mx2.o dma-mx1-mx2.o ?obj-$(CONFIG_ARCH_MXC_IOMUX_V3) += iomux-v3.o diff --git a/arch/arm/plat-mxc/tzic.c b/arch/arm/plat-mxc/tzic.c new file mode 100644 index 0000000..00cb0ad

arch/arm/plat-mxc/tzic.c new file +39 -0
@@ -0,0 +1,182 @@
+/*
+ * Copyright 2004-2009 Freescale Semiconductor, Inc. All Rights Reserved.
+ *
+ * The code contained herein is licensed under the GNU General 
+Public
+ * License. You may obtain a copy of the GNU General Public License
+ * Version 2 or later at the following locations:
+ *
+ * http://www.opensource.org/licenses/gpl-license.html
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+
+#include <linux/module.h>
+#include <linux/moduleparam.h>
+#include <linux/init.h>
+#include <linux/device.h>
+#include <linux/errno.h>
+#include <linux/io.h>
+
+#include <asm/mach/irq.h>
+
+#include <mach/hardware.h>
+
+/*
+ *****************************************
+ * TZIC Registers ? ? ? ? ? ? ? ? ? ? ? ?*
+ *****************************************
+ */
+
+#define TZIC_INTCNTL ? ? ? ? ? ?0x0000 /* Control register */ 
+#define TZIC_INTTYPE ? ? ? ? ? ?0x0004 /* Controller Type register 
+*/ #define TZIC_IMPID ? ? ? ? ? ? ?0x0008 /* Distributor 
+Implementer Identification */ #define TZIC_PRIOMASK ? ? ? ? ? 
+0x000C /* Priority Mask Reg */ #define TZIC_SYNCCTRL ? ? ? ? ? 
+0x0010 /* Synchronizer Control register */ #define TZIC_DSMINT ? ? ? ? ? ? 
+0x0014 /* DSM interrupt Holdoffregister */ #define TZIC_INTSEC0 ? ? ? ? ? ?
+0x0080 /* Interrupt Security register 0 */ #define TZIC_ENSET0 ? ? ? ? ? ? 
+0x0100 /* Enable Set Register 0 */ #define TZIC_ENCLEAR0 ? ? ? ? ? 
+0x0180 /* Enable Clear Register 0 */ #define TZIC_SRCSET0 ? ? ? ? ? ?

arch/arm/plat-mxc/tzic.c line 49

Quoted 10 lines
arch/arm/plat-mxc/tzic.c new file +10 -0
+0x0200 /* Source Set Register 0 */ #define TZIC_SRCCLAR0 ? ? ? ? ? 
+0x0280 /* Source Clear Register 0 */ #define TZIC_PRIORITY0 ? ? ? ? ?
+0x0400 /* Priority Register 0 */ #define TZIC_PND0 ? ? ? ? ? ? ? 
+0x0D00 /* Pending Register 0 */ #define TZIC_HIPND0 ? ? ? ? ? ? 
+0x0D80 /* High Priority Pending Register */ #define TZIC_WAKEUP0 ? ? ? ? ? ?
+0x0E00 /* Wakeup Config Register */ #define TZIC_SWINT ? ? ? ? ? ? ?
+0x0F00 /* Software Interrupt Rigger Register */ #define TZIC_ID0 ? ? ? ? ? ? ? ?
+0x0FD0 /* Indentification Register 0 */
+
+void __iomem *tzic_base;

This can just be made to 'static' if it's not used elsewhere, and I'm wondering if it's neater to define them as:

Quoted 3 lines

#define TZIC_INTCNTL (tzic_base + 0x0000)

so to make the code below short and handy.

tzic_base is actually used in entry-macro.S in patch 0004. I've tried to follow AVIC's way of doing things.

Quoted 6 lines

arch/arm/plat-mxc/tzic.c line 50

Quoted 3 lines
arch/arm/plat-mxc/tzic.c new file +3 -0
+
+/*
+ * Disable interrupt number "irq" in the TZIC

I don't think this follows kernel API doc exactly, you may want to have a look into Documentation/kernel-doc-nano-HOWTO.txt.

OK.

Quoted 14 lines

arch/arm/plat-mxc/tzic.c line 61

Quoted 9 lines
arch/arm/plat-mxc/tzic.c new file +9 -0
+ *
+ * @param ?irq ? ? ? ? ?interrupt source number  */ static void 
+tzic_mask_irq(unsigned int irq) {
+ ? ? ? int index, off;
+
+ ? ? ? index = irq >> 5;
+ ? ? ? off = irq & 0x1F;
+ ? ? ? __raw_writel(1 << off, tzic_base + TZIC_ENCLEAR0 + (index << 
+ 2));

I'll normally define TZIC_ENCLEAR0 then as:

#define TZIC_ENCLEAR(i) (0x0180 + ((i) << 2))

Quoted 7 lines

so the above can be written as:

	__raw_writel(1 << off, tzic_base + TZIC_ENCLEAR(index));

or by including tzic_base into TZIC_*, simply as:

	__raw_writel(1 << off, TZIC_ENCLEAR(index));

OK.

Quoted 62 lines
Quoted 62 lines
arch/arm/plat-mxc/tzic.c new file +62 -0
+}
+
+/*
+ * Enable interrupt number "irq" in the TZIC
+ *
+ * @param ?irq ? ? ? ? ?interrupt source number  */ static void 
+tzic_unmask_irq(unsigned int irq) {
+ ? ? ? int index, off;
+
+ ? ? ? index = irq >> 5;
+ ? ? ? off = irq & 0x1F;
+ ? ? ? __raw_writel(1 << off, tzic_base + TZIC_ENSET0 + (index << 
+2)); }
+
+static unsigned int wakeup_intr[4];
+
+/*
+ * Set interrupt number "irq" in the TZIC as a wake-up source.
+ *
+ * @param ?irq ? ? ? ? ?interrupt source number
+ * @param ?enable ? ? ? enable as wake-up if equal to non-zero
+ * ? ? ? ? ? ? ? ? ? ? disble as wake-up if equal to zero
+ *
+ * @return ? ? ? This function returns 0 on success.
+ */
+static int tzic_set_wake_irq(unsigned int irq, unsigned int enable) 
+{
+ ? ? ? unsigned int index, off;
+
+ ? ? ? index = irq >> 5;
+ ? ? ? off = irq & 0x1F;
+
+ ? ? ? if (index > 3)
+ ? ? ? ? ? ? ? return -EINVAL;
+
+ ? ? ? if (enable)
+ ? ? ? ? ? ? ? wakeup_intr[index] |= (1 << off);
+ ? ? ? else
+ ? ? ? ? ? ? ? wakeup_intr[index] &= ~(1 << off);
+
+ ? ? ? return 0;
+}
+
+static struct irq_chip mxc_tzic_chip = {
+ ? ? ? .name = "MXC_TZIC",
+ ? ? ? .ack = tzic_mask_irq,
+ ? ? ? .mask = tzic_mask_irq,
+ ? ? ? .unmask = tzic_unmask_irq,
+ ? ? ? .set_wake = tzic_set_wake_irq, };
+
+/*
+ * This function initializes the TZIC hardware and disables all the
+ * interrupts. It registers the interrupt enable and disable 
+functions
+ * to the kernel for each interrupt source.
+ */
+void __init tzic_init_irq(void __iomem *irqbase) {
+ ? ? ? int i;
+
+ ? ? ? tzic_base = irqbase;
+ ? ? ? /* put the TZIC into the reset value with
+ ? ? ? ?* all interrupts disabled
Quoted 8 lines

arch/arm/plat-mxc/tzic.c line 125

Quoted 2 lines
arch/arm/plat-mxc/tzic.c new file +2 -0
+ ? ? ? ?*/
+ ? ? ? i = __raw_readl(tzic_base + TZIC_INTCNTL);

Mixing the use of 'i' as both a signed counter and register value might not be a good idea, provided it's not guaranteed from theory that 'i' as an integer could not be sufficient to hold the value returned from
__raw_readl()

Fair enough.

Quoted 10 lines

arch/arm/plat-mxc/tzic.c line 132

Quoted 7 lines
arch/arm/plat-mxc/tzic.c new file +7 -0
+
+ ? ? ? __raw_writel(0x80010001, tzic_base + TZIC_INTCNTL);
+ ? ? ? i = __raw_readl(tzic_base + TZIC_INTCNTL);
+ ? ? ? __raw_writel(0x1f, tzic_base + TZIC_PRIOMASK);
+ ? ? ? i = __raw_readl(tzic_base + TZIC_PRIOMASK);
+ ? ? ? __raw_writel(0x02, tzic_base + TZIC_SYNCCTRL);
+ ? ? ? i = __raw_readl(tzic_base + TZIC_SYNCCTRL);

Are these read-back really necessary? We can start without them and add them later if they do cause issues.

Can anybody from Freescale comment whether the read-back is necessary?

I'll remove it for now to see what happens in my testing.

[Dinh] - This piece of code was taken from our silicon validation code where it was check the values of the read-backs. The read-backs can be removed.

Quoted 14 lines
Quoted 14 lines
arch/arm/plat-mxc/tzic.c new file +14 -0
+
+ ? ? ? for (i = 0; i < 4; i++)
+ ? ? ? ? ? ? ? __raw_writel(0xFFFFFFFF, tzic_base + TZIC_INTSEC0 + 
+ i * 4);
+
+ ? ? ? /* disable all interrupts */
+ ? ? ? for (i = 0; i < 4; i++)
+ ? ? ? ? ? ? ? __raw_writel(0xFFFFFFFF, tzic_base + TZIC_ENCLEAR0 + 
+ i * 4);
+
+ ? ? ? /* all IRQ no FIQ Warning :: No selection */
+
+ ? ? ? for (i = 0; i < MXC_INTERNAL_IRQS; i++) {
+ ? ? ? ? ? ? ? set_irq_chip(i, &mxc_tzic_chip);
Quoted 8 lines

arch/arm/plat-mxc/tzic.c line 152

Quoted 6 lines
arch/arm/plat-mxc/tzic.c new file +6 -0
+ ? ? ? ? ? ? ? set_irq_handler(i, handle_level_irq);
+ ? ? ? ? ? ? ? set_irq_flags(i, IRQF_VALID);
+ ? ? ? }
+
+ ? ? ? printk(KERN_INFO "TrustZone Interrupt Controller (TZIC) 
+ initialized\n");

You may want to use pr_info() for short.

OK

Quoted 13 lines
Quoted 13 lines
arch/arm/plat-mxc/tzic.c new file +13 -0
+}
+
+/*
+ * enable wakeup interrupt
+ *
+ * @param is_idle ? ? ? ? ? ? ?1 if called in idle loop (ENSET 
+register);
+ * ? ? ? ? ? ? ? ? ? ? ? ? ? ? 0 to be used when called from low 
+power entry
+ * @return ? ? ? ? ? ? ? ? ? ? 0 if successful; non-zero otherwise
+ *
+ */
+int tzic_enable_wake(int is_idle)
Quoted 8 lines

arch/arm/plat-mxc/tzic.c line 171

Quoted 6 lines
arch/arm/plat-mxc/tzic.c new file +6 -0
+{
+ ? ? ? unsigned int i, v;
+
+ ? ? ? __raw_writel(1, tzic_base + TZIC_DSMINT);
+ ? ? ? if (unlikely(__raw_readl(tzic_base + TZIC_DSMINT) == 0))
+ ? ? ? ? ? ? ? return -EAGAIN;

Looks like an unnecessary read-back provided the silicon is sane enough.

Again, Dinh/Rob can you comment?

[Dinh] - Can be removed.

Quoted 16 lines
Quoted 5 lines
arch/arm/plat-mxc/tzic.c new file +5 -0
+
+ ? ? ? if (likely(is_idle)) {
+ ? ? ? ? ? ? ? for (i = 0; i < 4; i++) {
+ ? ? ? ? ? ? ? ? ? ? ? v = __raw_readl(tzic_base + TZIC_ENSET0 + i 
+ * 4);

arch/arm/plat-mxc/tzic.c

Quoted 10 lines
arch/arm/plat-mxc/tzic.c new file +10 -0
+ ? ? ? ? ? ? ? ? ? ? ? __raw_writel(v, tzic_base + TZIC_WAKEUP0 + i 
+ * 4);
+ ? ? ? ? ? ? ? }
+ ? ? ? } else {
+ ? ? ? ? ? ? ? for (i = 0; i < 4; i++) {
+ ? ? ? ? ? ? ? ? ? ? ? v = wakeup_intr[i];
+ ? ? ? ? ? ? ? ? ? ? ? __raw_writel(v, tzic_base + TZIC_WAKEUP0 + i 
+ * 4);
+ ? ? ? ? ? ? ? }
+ ? ? ? }
Quoted 6 lines

Or could be simplified to:

	for (i = 0; i < 4; i++) {
		v = is_idle ? __raw_readl(TZIC_ENSET(i)) : wakeup_intr[i];
		__raw_writel(v, TZIC_WAKEUP(i));
	}

OK

Quoted 8 lines

but just nit-picking comments, so it's up to you.

Quoted 2 lines

+ ? ? ? return 0;
+}

Mmmm.... this being called elsewhere, I'm thinking about making this a sys_device and having this called within sysdev_class.suspend() to make this file rather self-contained.

That is the idea once the base port is upstream.

Thanks for the review.

/Amit
--
----------------------------------------------------------------------
Amit Kucheria, Kernel Engineer || amit.kucheria at canonical.com
----------------------------------------------------------------------