Skip to contentSkip to conversation

add initial imx6q support

PATCH Superseded Shawn Guo 12 participants 69 messages Sep 6, 2011 – Sep 17, 2011

Subsystems (4)

v1 of 5 Superseded Latest is v5 →

lore
Share & tools
lore

Shawn Guo

author
#0 lore raw

cover add initial imx6q support

This patch series adds the initial support for imx6q, which is a Cortex-A9 MPCore (4 cores) SoC.

It's based on v3.1-rc4 with the patches below applied.

* [PATCH v2 0/5] Convert DEBUG_LL UART selection to a Kconfig choice
http://thread.gmane.org/gmane.linux.ports.arm.kernel/129702

* [PATCH v4 2/2] ARM: l2x0: Add OF based initialization
http://article.gmane.org/gmane.linux.kernel/1164401

* [PATCH 1/7] ARM: l2x0: add empty l2x0_of_init
http://article.gmane.org/gmane.linux.ports.arm.kernel/130878

* [RFC PATCH 0/3] Yet another GIC OF binding series
http://thread.gmane.org/gmane.linux.drivers.devicetree/7226

For suspend/resume support, it needs the following extra patches applied.

* [PATCH v2 0/2] make reinitialization of ARM core components possible
http://thread.gmane.org/gmane.linux.ports.arm.kernel/131356

* [PATCH v2 0/5] CPU PM notifiers
http://thread.gmane.org/gmane.linux.ports.arm.kernel/131212/focus=131353

Thanks.

Shawn Guo (6):
arm/imx6q: add device tree source
arm/imx6q: add core definitions and low-level debug uart arm/imx6q: add core drivers clock, gpc, mmdc and src arm/imx6q: add smp and cpu hotplug support arm/imx6q: add device tree machine support arm/imx6q: add suspend/resume support

 Documentation/devicetree/bindings/arm/fsl.txt |    6 +
 arch/arm/Kconfig                              |    2 +-
 arch/arm/Kconfig.debug                        |    7 +
 arch/arm/Makefile                             |    1 +
 arch/arm/boot/dts/imx6q-sabreauto.dts         |   49 +
 arch/arm/boot/dts/imx6q.dtsi                  |  570 +++++++
 arch/arm/mach-imx/Kconfig                     |   31 +
 arch/arm/mach-imx/Makefile                    |   11 +
 arch/arm/mach-imx/Makefile.boot               |    4 +
 arch/arm/mach-imx/clock-imx6q.c               | 1990 +++++++++++++++++++++++++
 arch/arm/mach-imx/gpc.c                       |  110 ++
 arch/arm/mach-imx/head-v7.S                   |   75 +
 arch/arm/mach-imx/hotplug.c                   |   44 +
 arch/arm/mach-imx/lluart.c                    |   33 +
 arch/arm/mach-imx/localtimer.c                |   64 +
 arch/arm/mach-imx/mach-imx6q.c                |   81 +
 arch/arm/mach-imx/mmdc.c                      |   71 +
 arch/arm/mach-imx/platsmp.c                   |   86 ++
 arch/arm/mach-imx/pm-imx6q.c                  |   63 +
 arch/arm/mach-imx/src.c                       |   52 +
 arch/arm/mm/Kconfig                           |    2 +-
 arch/arm/plat-mxc/Kconfig                     |    5 +
 arch/arm/plat-mxc/include/mach/common.h       |   28 +
 arch/arm/plat-mxc/include/mach/debug-macro.S  |    5 +
 arch/arm/plat-mxc/include/mach/entry-macro.S  |   15 +-
 arch/arm/plat-mxc/include/mach/hardware.h     |    1 +
 arch/arm/plat-mxc/include/mach/irqs.h         |    9 +-
 arch/arm/plat-mxc/include/mach/memory.h       |    3 +
 arch/arm/plat-mxc/include/mach/mx6q.h         |   29 +
 29 files changed, 3441 insertions(+), 6 deletions(-)
author
#1 lore raw

PATCH 1/6 arm/imx6q: add device tree source

It adds device tree source and documentation for imx6q platform.

---
 Documentation/devicetree/bindings/arm/fsl.txt |    6 +
 arch/arm/boot/dts/imx6q-sabreauto.dts         |   49 +++
 arch/arm/boot/dts/imx6q.dtsi                  |  570 +++++++++++++++++++++++++
 3 files changed, 625 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/arm/fsl.txt
 create mode 100644 arch/arm/boot/dts/imx6q-sabreauto.dts
 create mode 100644 arch/arm/boot/dts/imx6q.dtsi
Documentation/devicetree/bindings/arm/fsl.txt new file +6 -0
new file mode 100644
index 0000000..345bfc0
@@ -0,0 +1,6 @@
+Freescale i.MX Platforms Device Tree Bindings
+-----------------------------------------------
+
+i.MX6 Quad SABRE Automotive Board
+Required root node properties:
+    - compatible = "fsl,imx6q-sabreauto", "fsl,imx6q";
arch/arm/boot/dts/imx6q-sabreauto.dts new file +49 -0

49 lines not on this page · raw message

arch/arm/boot/dts/imx6q.dtsi new file +570 -0

570 lines not on this page · raw message

Signature · 1 line
1.7.4.1
#2 lore raw

PATCH 1/6 arm/imx6q: add device tree source

Quoted 4 lines · On Tuesday 06 September 2011 17:58:35 Shawn Guo wrote:
arch/arm/boot/dts/imx6q.dtsi new file +4 -0
+
+       aips-bus at 02000000 { /* AIPS1 */
+               compatible = "fsl,aips-bus", "simple-bus";
+               #address-cells = <1>;

arch/arm/boot/dts/imx6q.dtsi line 120

Quoted 10 lines
arch/arm/boot/dts/imx6q.dtsi new file +10 -0
+               #size-cells = <1>;
+               reg = <0x02000000 0x100000>;
+               ranges;
+
+               spba-bus at 02000000 {
+                       compatible = "fsl,spba-bus", "simple-bus";
+                       #address-cells = <1>;
+                       #size-cells = <1>;
+                       reg = <0x02000000 0x40000>;
+                       ranges;

Wouldn't it be better to have the ranges property translate bus-local addresses to global addresses, rather than having an empty ranges property?

Arnd

#3 lore raw

PATCH 1/6 arm/imx6q: add device tree source

Quoted 10 lines · Arnd Bergmann
Quoted 9 lines · On Tuesday 06 September 2011 17:58:35 Shawn Guo wrote:
arch/arm/boot/dts/imx6q.dtsi new file +9 -0
+
+       aips-bus at 02000000 { /* AIPS1 */
+               compatible = "fsl,aips-bus", "simple-bus";
+               #address-cells = <1>;
+               #size-cells = <1>;
+               reg = <0x02000000 0x100000>;
+               ranges;
+
+               spba-bus at 02000000 {
Quoted 9 lines

arch/arm/boot/dts/imx6q.dtsi line 120

Quoted 5 lines
arch/arm/boot/dts/imx6q.dtsi new file +5 -0
+                       compatible = "fsl,spba-bus", "simple-bus";
+                       #address-cells = <1>;
+                       #size-cells = <1>;
+                       reg = <0x02000000 0x40000>;
+                       ranges;

Wouldn't it be better to have the ranges property translate bus-local addresses to global addresses, rather than having an empty ranges property?

All the bus-local addresses are directly mapped into cpu address space. Looking at the i.MX Reference Manual memory map chapter, the base address of each block is given in global address other than bus address + offset. Writing a global address in device tree is relatively easy to match the addresses defined in hardware document.

Signature · 2 lines
Regards,
Shawn
author
#4 lore raw

PATCH 2/6 arm/imx6q: add core definitions and low-level debug uart

In reply to Shawn Guo

It adds the core definitions and low-level debug uart support for imx6q.

---
 arch/arm/Kconfig                             |    2 +-
 arch/arm/Kconfig.debug                       |    7 +++++
 arch/arm/Makefile                            |    1 +
 arch/arm/mach-imx/Kconfig                    |    4 +++
 arch/arm/mach-imx/Makefile                   |    2 +
 arch/arm/mach-imx/Makefile.boot              |    4 +++
 arch/arm/mach-imx/lluart.c                   |   33 ++++++++++++++++++++++++++
 arch/arm/plat-mxc/Kconfig                    |    5 ++++
 arch/arm/plat-mxc/include/mach/debug-macro.S |    5 ++++
 arch/arm/plat-mxc/include/mach/entry-macro.S |   15 +++++++++++-
 arch/arm/plat-mxc/include/mach/hardware.h    |    1 +
 arch/arm/plat-mxc/include/mach/irqs.h        |    9 ++++--
 arch/arm/plat-mxc/include/mach/memory.h      |    3 ++
 arch/arm/plat-mxc/include/mach/mx6q.h        |   29 ++++++++++++++++++++++
 14 files changed, 115 insertions(+), 5 deletions(-)
 create mode 100644 arch/arm/mach-imx/lluart.c
 create mode 100644 arch/arm/plat-mxc/include/mach/mx6q.h
arch/arm/Kconfig +1 -1
index 4ea9974..37c20a4 100644
@@ -1348,7 +1348,7 @@ config SMP
 	depends on REALVIEW_EB_ARM11MP || REALVIEW_EB_A9MP || \
 		 MACH_REALVIEW_PB11MP || MACH_REALVIEW_PBX || ARCH_OMAP4 || \
 		 ARCH_EXYNOS4 || ARCH_TEGRA || ARCH_U8500 || ARCH_VEXPRESS_CA9X4 || \
-		 ARCH_MSM_SCORPIONMP || ARCH_SHMOBILE
+		 ARCH_MSM_SCORPIONMP || ARCH_SHMOBILE || SOC_IMX6Q
 	select USE_GENERIC_SMP_HELPERS
 	select HAVE_ARM_SCU if !ARCH_MSM_SCORPIONMP
 	help
arch/arm/Kconfig.debug +7 -0
index 965d59a..68fc155 100644
@@ -155,6 +155,13 @@ choice
 		  Say Y here if you want kernel low-level debugging support
 		  on i.MX50 or i.MX53.
 
+	config DEBUG_IMX6Q_UART
+		bool "i.MX6Q Debug UART"
+		depends on SOC_IMX6Q
+		help
+		  Say Y here if you want kernel low-level debugging support
+		  on i.MX6Q.
+
 	config DEBUG_S3C_UART0
 		depends on PLAT_SAMSUNG
 		bool "Use S3C UART 0 for low-level debug"
arch/arm/Makefile +1 -0
index 70c424e..3a0bbe4 100644
@@ -159,6 +159,7 @@ machine-$(CONFIG_ARCH_MX2)		:= imx
 machine-$(CONFIG_ARCH_MX25)		:= imx
 machine-$(CONFIG_ARCH_MX3)		:= imx
 machine-$(CONFIG_ARCH_MX5)		:= mx5
+machine-$(CONFIG_ARCH_MX6)		:= imx
 machine-$(CONFIG_ARCH_MXS)		:= mxs
 machine-$(CONFIG_ARCH_NETX)		:= netx
 machine-$(CONFIG_ARCH_NOMADIK)		:= nomadik
arch/arm/mach-imx/Kconfig +4 -0
index 0519dd7..4cf5178 100644
@@ -58,6 +58,10 @@ config SOC_IMX35
 	select ARCH_MX35
 	select MXC_AVIC
 
+config SOC_IMX6Q
+	bool
+	select ARM_GIC
+	select CPU_V7
 
 if ARCH_MX1
 
arch/arm/mach-imx/Makefile +2 -0
index e9eb36d..96ecc96 100644
@@ -61,3 +61,5 @@ obj-$(CONFIG_MACH_MX35_3DS) += mach-mx35_3ds.o
 obj-$(CONFIG_MACH_EUKREA_CPUIMX35) += mach-cpuimx35.o
 obj-$(CONFIG_MACH_EUKREA_MBIMXSD35_BASEBOARD) += eukrea_mbimxsd35-baseboard.o
 obj-$(CONFIG_MACH_VPR200) += mach-vpr200.o
+
+obj-$(CONFIG_DEBUG_LL) += lluart.o
arch/arm/mach-imx/Makefile.boot +4 -0
index ebee18b..389a0e3 100644
@@ -17,3 +17,7 @@ initrd_phys-$(CONFIG_MACH_MX27)	:= 0xA0800000
 zreladdr-$(CONFIG_ARCH_MX3)	:= 0x80008000
 params_phys-$(CONFIG_ARCH_MX3)	:= 0x80000100
 initrd_phys-$(CONFIG_ARCH_MX3)	:= 0x80800000
+
+zreladdr-$(CONFIG_SOC_IMX6Q)	:= 0x10008000
+params_phys-$(CONFIG_SOC_IMX6Q)	:= 0x10000100
+initrd_phys-$(CONFIG_SOC_IMX6Q)	:= 0x10800000
arch/arm/mach-imx/lluart.c new file +33 -0
new file mode 100644
index 0000000..34205cb
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2011 Freescale Semiconductor, Inc.
+ * Copyright 2011 Linaro Ltd.
+ *
+ * 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 <asm/page.h>
+#include <asm/sizes.h>
+#include <asm/mach/map.h>
+#include <mach/hardware.h>
+
+static struct map_desc imx_lluart_desc = {
+#ifdef CONFIG_DEBUG_IMX6Q_UART
+	.virtual	= MX6Q_UART4_BASE_VADDR,
+	.pfn		= __phys_to_pfn(MX6Q_UART4_BASE_ADDR),
+	.length		= SZ_16K,
+	.type		= MT_DEVICE,
+#endif
+};
+
+void __init imx_lluart_map_io(void)
+{
+	if (imx_lluart_desc.virtual)
+		iotable_init(&imx_lluart_desc, 1);
+}
+
arch/arm/plat-mxc/Kconfig +5 -0
index a5353fc..e548f9b 100644
@@ -48,6 +48,11 @@ config ARCH_MX51
 	help
 	  This enables support for systems based on the Freescale i.MX51 family
 
+config ARCH_MX6
+	bool "i.MX6"
+	help
+	  This enables support for systems based on the Freescale i.MX6 family
+
 endchoice
 
 source "arch/arm/mach-imx/Kconfig"
arch/arm/plat-mxc/include/mach/debug-macro.S +5 -0
index 07cfdbe..471872a 100644
@@ -24,9 +24,14 @@
 #define UART_PADDR	MX51_UART1_BASE_ADDR
 #elif defined (CONFIG_DEBUG_IMX50_IMX53_UART)
 #define UART_PADDR	MX53_UART1_BASE_ADDR
+#elif defined (CONFIG_DEBUG_IMX6Q_UART)
+#define UART_PADDR	MX6Q_UART4_BASE_ADDR
+#define UART_VADDR	MX6Q_UART4_BASE_VADDR
 #endif
 
+#ifndef UART_VADDR
 #define UART_VADDR	IMX_IO_ADDRESS(UART_PADDR)
+#endif
 
 		.macro	addruart, rp, rv
 		ldr	\rp, =UART_PADDR	@ physical
arch/arm/plat-mxc/include/mach/entry-macro.S +14 -1
index 066d464..341f800 100644
@@ -1,6 +1,6 @@
 /*
  *  Copyright (C) 2007 Lennert Buytenhek <[email protected]>
- *  Copyright 2004-2009 Freescale Semiconductor, Inc. All Rights Reserved.
+ *  Copyright 2004-2011 Freescale Semiconductor, Inc. All Rights Reserved.
  */
 
 /*
@@ -11,6 +11,17 @@
 
 #include <mach/hardware.h>
 
+#ifdef CONFIG_ARM_GIC
+#include <asm/hardware/entry-macro-gic.S>
+
+	.macro	disable_fiq
+	.endm
+
+	.macro	arch_ret_to_user, tmp1, tmp2
+	.endm
+
+#else
+
 #define AVIC_NIMASK	0x04
 
 	@ this macro disables fast irq (not implemented)
@@ -78,3 +89,5 @@
 	movs \irqnr, \irqnr
 #endif
 	.endm
+
+#endif /* CONFIG_ARM_GIC */
arch/arm/plat-mxc/include/mach/hardware.h +1 -0
index a8bfd56..e1f84ce 100644
@@ -97,6 +97,7 @@
 
 #include <mach/mxc.h>
 
+#include <mach/mx6q.h>
 #include <mach/mx50.h>
 #include <mach/mx51.h>
 #include <mach/mx53.h>
arch/arm/plat-mxc/include/mach/irqs.h +6 -3
index 00e812b..3ae400f 100644
@@ -14,12 +14,15 @@
 #include <asm-generic/gpio.h>
 
 /*
- * SoCs with TZIC interrupt controller have 128 IRQs, those with AVIC have 64
+ * SoCs with AVIC interrupt controller have 64 IRQs, those with TZIC
+ * have 128, otherwise those with GIC have 160 IRQs.
  */
-#ifdef CONFIG_MXC_TZIC
+#if defined CONFIG_MXC_AVIC
+#define MXC_INTERNAL_IRQS	64
+#elif defined CONFIG_MXC_TZIC
 #define MXC_INTERNAL_IRQS	128
 #else
-#define MXC_INTERNAL_IRQS	64
+#define MXC_INTERNAL_IRQS	160
 #endif
 
 #define MXC_GPIO_IRQ_START	MXC_INTERNAL_IRQS
arch/arm/plat-mxc/include/mach/memory.h +3 -0
index 11be5cd..2b8e186 100644
@@ -19,6 +19,7 @@
 #define MX50_PHYS_OFFSET	UL(0x70000000)
 #define MX51_PHYS_OFFSET	UL(0x90000000)
 #define MX53_PHYS_OFFSET	UL(0x70000000)
+#define MX6Q_PHYS_OFFSET	UL(0x10000000)
 
 #if !defined(CONFIG_RUNTIME_PHYS_OFFSET)
 # if defined CONFIG_ARCH_MX1
@@ -37,6 +38,8 @@
 #  define PLAT_PHYS_OFFSET		MX51_PHYS_OFFSET
 # elif defined CONFIG_ARCH_MX53
 #  define PLAT_PHYS_OFFSET		MX53_PHYS_OFFSET
+# elif defined CONFIG_SOC_IMX6Q
+#  define PLAT_PHYS_OFFSET		MX6Q_PHYS_OFFSET
 # endif
 #endif
 
arch/arm/plat-mxc/include/mach/mx6q.h new file +29 -0
new file mode 100644
index 0000000..7432310
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2011 Freescale Semiconductor, Inc. All Rights Reserved.
+ * Copyright 2011 Linaro Ltd.
+ *
+ * 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_MX6Q_H__
+#define __MACH_MX6Q_H__
+
+/* static mappings */
+#define IMX6Q_VA(x)		(0xf4000000 + (x))
+
+#define MX6Q_SCU_BASE_ADDR	0x00a00000
+#define MX6Q_CCM_BASE_ADDR	0x020c4000
+#define MX6Q_ANATOP_BASE_ADDR	0x020c8000
+#define MX6Q_UART4_BASE_ADDR	0x021f0000
+
+#define MX6Q_SCU_BASE_VADDR	IMX6Q_VA(MX6Q_SCU_BASE_ADDR)
+#define MX6Q_CCM_BASE_VADDR	IMX6Q_VA(MX6Q_CCM_BASE_ADDR)
+#define MX6Q_ANATOP_BASE_VADDR	IMX6Q_VA(MX6Q_ANATOP_BASE_ADDR)
+#define MX6Q_UART4_BASE_VADDR	IMX6Q_VA(MX6Q_UART4_BASE_ADDR)
+
+#endif	/* __MACH_MX6Q_H__ */
Signature · 1 line
1.7.4.1
#5 lore raw

PATCH 2/6 arm/imx6q: add core definitions and low-level debug uart

arch/arm/plat-mxc/include/mach/mx6q.h line 5

Quoted 8 lines · On Tuesday 06 September 2011 17:58:36 Shawn Guo wrote:
arch/arm/plat-mxc/include/mach/mx6q.h new file +5 -0
@@ -0,0 +1,29 @@
+#ifndef __MACH_MX6Q_H__
+#define __MACH_MX6Q_H__
+
+/* static mappings */
+#define IMX6Q_VA(x)            (0xf4000000 + (x))

This should return a 'void __iomem *' pointer, not an integer.

arch/arm/plat-mxc/include/mach/mx6q.h line 27

Quoted 9 lines
arch/arm/plat-mxc/include/mach/mx6q.h new file +9 -0
+#define MX6Q_SCU_BASE_ADDR     0x00a00000
+#define MX6Q_CCM_BASE_ADDR     0x020c4000
+#define MX6Q_ANATOP_BASE_ADDR  0x020c8000
+#define MX6Q_UART4_BASE_ADDR   0x021f0000
+
+#define MX6Q_SCU_BASE_VADDR    IMX6Q_VA(MX6Q_SCU_BASE_ADDR)
+#define MX6Q_CCM_BASE_VADDR    IMX6Q_VA(MX6Q_CCM_BASE_ADDR)
+#define MX6Q_ANATOP_BASE_VADDR IMX6Q_VA(MX6Q_ANATOP_BASE_ADDR)
+#define MX6Q_UART4_BASE_VADDR  IMX6Q_VA(MX6Q_UART4_BASE_ADDR)

The list is reasonably short, but I think you can still try harder to remove some of the remaining elements. I can understand the need for UART4 (for ll_debug), but I don't really understand what the others are and why you cannot get the values from the device tree and ioremap them.

Maybe you can add a few comments to explain these if they are indeed necessary.

Arnd

#6 lore raw

PATCH 2/6 arm/imx6q: add core definitions and low-level debug uart

Quoted 12 lines · Arnd Bergmann

arch/arm/plat-mxc/include/mach/mx6q.h line 5

Quoted 8 lines · On Tuesday 06 September 2011 17:58:36 Shawn Guo wrote:
arch/arm/plat-mxc/include/mach/mx6q.h new file +5 -0
@@ -0,0 +1,29 @@
+#ifndef __MACH_MX6Q_H__
+#define __MACH_MX6Q_H__
+
+/* static mappings */
+#define IMX6Q_VA(x)            (0xf4000000 + (x))

This should return a 'void __iomem *' pointer, not an integer.

To pair the virtual address and physical address which is an integer, I chose to define the virtual address as integer too, and cast it to pointer when using it using helper macro IOMEM() defined in arch/arm/plat-mxc/include/mach/hardware.h.

Quoted 6 lines
Quoted 6 lines
arch/arm/plat-mxc/include/mach/mx6q.h new file +6 -0
+#define MX6Q_SCU_BASE_ADDR     0x00a00000
+#define MX6Q_CCM_BASE_ADDR     0x020c4000
+#define MX6Q_ANATOP_BASE_ADDR  0x020c8000
+#define MX6Q_UART4_BASE_ADDR   0x021f0000
+
+#define MX6Q_SCU_BASE_VADDR    IMX6Q_VA(MX6Q_SCU_BASE_ADDR)
Quoted 9 lines

arch/arm/plat-mxc/include/mach/mx6q.h line 27

Quoted 3 lines
arch/arm/plat-mxc/include/mach/mx6q.h new file +3 -0
+#define MX6Q_CCM_BASE_VADDR    IMX6Q_VA(MX6Q_CCM_BASE_ADDR)
+#define MX6Q_ANATOP_BASE_VADDR IMX6Q_VA(MX6Q_ANATOP_BASE_ADDR)
+#define MX6Q_UART4_BASE_VADDR  IMX6Q_VA(MX6Q_UART4_BASE_ADDR)

The list is reasonably short, but I think you can still try harder to remove some of the remaining elements. I can understand the need for UART4 (for ll_debug), but I don't really understand what the others are and why you cannot get the values from the device tree and ioremap them.

For SCU_BASE, the definition is actually unused, since physical base of SCU can be retrieved from coprocessor. I put them here for documentation purpose telling it's a static mapping.

For CCM and ANATOP, the static mappings are used by clock code, because "struct clk" is statically defined and initialized. They can become dynamic mapping when we migrate the clock to common framework and device tree.

Quoted 3 lines

Maybe you can add a few comments to explain these if they are indeed necessary.

Ok, will do.

Signature · 2 lines
Regards,
Shawn
#7 lore raw

PATCH 2/6 arm/imx6q: add core definitions and low-level debug uart

In reply to Shawn Guo
Quoted 96 lines · Shawn Guo

It adds the core definitions and low-level debug uart support for imx6q.

---
 arch/arm/Kconfig                             |    2 +-
 arch/arm/Kconfig.debug                       |    7 +++++
 arch/arm/Makefile                            |    1 +
 arch/arm/mach-imx/Kconfig                    |    4 +++
 arch/arm/mach-imx/Makefile                   |    2 +
 arch/arm/mach-imx/Makefile.boot              |    4 +++
 arch/arm/mach-imx/lluart.c                   |   33 ++++++++++++++++++++++++++
 arch/arm/plat-mxc/Kconfig                    |    5 ++++
 arch/arm/plat-mxc/include/mach/debug-macro.S |    5 ++++
 arch/arm/plat-mxc/include/mach/entry-macro.S |   15 +++++++++++-
 arch/arm/plat-mxc/include/mach/hardware.h    |    1 +
 arch/arm/plat-mxc/include/mach/irqs.h        |    9 ++++--
 arch/arm/plat-mxc/include/mach/memory.h      |    3 ++
 arch/arm/plat-mxc/include/mach/mx6q.h        |   29 ++++++++++++++++++++++
 14 files changed, 115 insertions(+), 5 deletions(-)
 create mode 100644 arch/arm/mach-imx/lluart.c
 create mode 100644 arch/arm/plat-mxc/include/mach/mx6q.h
arch/arm/Kconfig +1 -1
index 4ea9974..37c20a4 100644
@@ -1348,7 +1348,7 @@ config SMP
 	depends on REALVIEW_EB_ARM11MP || REALVIEW_EB_A9MP || \
 		 MACH_REALVIEW_PB11MP || MACH_REALVIEW_PBX || ARCH_OMAP4 || \
 		 ARCH_EXYNOS4 || ARCH_TEGRA || ARCH_U8500 || ARCH_VEXPRESS_CA9X4 || \
-		 ARCH_MSM_SCORPIONMP || ARCH_SHMOBILE
+		 ARCH_MSM_SCORPIONMP || ARCH_SHMOBILE || SOC_IMX6Q
 	select USE_GENERIC_SMP_HELPERS
 	select HAVE_ARM_SCU if !ARCH_MSM_SCORPIONMP
 	help
arch/arm/Kconfig.debug +7 -0
index 965d59a..68fc155 100644
@@ -155,6 +155,13 @@ choice
 		  Say Y here if you want kernel low-level debugging support
 		  on i.MX50 or i.MX53.
 
+	config DEBUG_IMX6Q_UART
+		bool "i.MX6Q Debug UART"
+		depends on SOC_IMX6Q
+		help
+		  Say Y here if you want kernel low-level debugging support
+		  on i.MX6Q.
+
 	config DEBUG_S3C_UART0
 		depends on PLAT_SAMSUNG
 		bool "Use S3C UART 0 for low-level debug"
arch/arm/Makefile +1 -0
index 70c424e..3a0bbe4 100644
@@ -159,6 +159,7 @@ machine-$(CONFIG_ARCH_MX2)		:= imx
 machine-$(CONFIG_ARCH_MX25)		:= imx
 machine-$(CONFIG_ARCH_MX3)		:= imx
 machine-$(CONFIG_ARCH_MX5)		:= mx5
+machine-$(CONFIG_ARCH_MX6)		:= imx
 machine-$(CONFIG_ARCH_MXS)		:= mxs
 machine-$(CONFIG_ARCH_NETX)		:= netx
 machine-$(CONFIG_ARCH_NOMADIK)		:= nomadik
arch/arm/mach-imx/Kconfig +4 -0
index 0519dd7..4cf5178 100644
@@ -58,6 +58,10 @@ config SOC_IMX35
 	select ARCH_MX35
 	select MXC_AVIC
 
+config SOC_IMX6Q
+	bool
+	select ARM_GIC
+	select CPU_V7
 
 if ARCH_MX1
 
arch/arm/mach-imx/Makefile +2 -0
index e9eb36d..96ecc96 100644
@@ -61,3 +61,5 @@ obj-$(CONFIG_MACH_MX35_3DS) += mach-mx35_3ds.o
 obj-$(CONFIG_MACH_EUKREA_CPUIMX35) += mach-cpuimx35.o
 obj-$(CONFIG_MACH_EUKREA_MBIMXSD35_BASEBOARD) += eukrea_mbimxsd35-baseboard.o
 obj-$(CONFIG_MACH_VPR200) += mach-vpr200.o
+
+obj-$(CONFIG_DEBUG_LL) += lluart.o
arch/arm/mach-imx/Makefile.boot +0 -0
index ebee18b..389a0e3 100644

arch/arm/mach-imx/Makefile.boot initrd_phys-$(CONFIG_MACH_MX27) := 0xA0800000 · line 23

Quoted 7 lines
arch/arm/mach-imx/Makefile.boot +4 -0
@@ -17,3 +17,7 @@ initrd_phys-$(CONFIG_MACH_MX27)	:= 0xA0800000
 zreladdr-$(CONFIG_ARCH_MX3)	:= 0x80008000
 params_phys-$(CONFIG_ARCH_MX3)	:= 0x80000100
 initrd_phys-$(CONFIG_ARCH_MX3)	:= 0x80800000
+
+zreladdr-$(CONFIG_SOC_IMX6Q)	:= 0x10008000
+params_phys-$(CONFIG_SOC_IMX6Q)	:= 0x10000100
+initrd_phys-$(CONFIG_SOC_IMX6Q)	:= 0x10800000

Do you really need params_phys and initrd_phys?

Quoted 28 lines
arch/arm/mach-imx/lluart.c new file +22 -0
new file mode 100644
index 0000000..34205cb
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2011 Freescale Semiconductor, Inc.
+ * Copyright 2011 Linaro Ltd.
+ *
+ * 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 <asm/page.h>
+#include <asm/sizes.h>
+#include <asm/mach/map.h>
+#include <mach/hardware.h>
+
+static struct map_desc imx_lluart_desc = {
+#ifdef CONFIG_DEBUG_IMX6Q_UART
+	.virtual	= MX6Q_UART4_BASE_VADDR,
+	.pfn		= __phys_to_pfn(MX6Q_UART4_BASE_ADDR),

arch/arm/mach-imx/lluart.c line 32

Quoted 10 lines
arch/arm/mach-imx/lluart.c new file +10 -0
+	.length		= SZ_16K,
+	.type		= MT_DEVICE,
+#endif
+};
+
+void __init imx_lluart_map_io(void)
+{
+	if (imx_lluart_desc.virtual)
+		iotable_init(&imx_lluart_desc, 1);
+}

I don't see yet where this is called, but I wonder what happens on a non-imx6q machine (provided it is called there).

Quoted 22 lines
arch/arm/mach-imx/lluart.c new file +1 -0
+
arch/arm/plat-mxc/Kconfig +5 -0
index a5353fc..e548f9b 100644
@@ -48,6 +48,11 @@ config ARCH_MX51
 	help
 	  This enables support for systems based on the Freescale i.MX51 family
 
+config ARCH_MX6
+	bool "i.MX6"
+	help
+	  This enables support for systems based on the Freescale i.MX6 family
+
 endchoice
 
 source "arch/arm/mach-imx/Kconfig"
arch/arm/plat-mxc/include/mach/debug-macro.S +0 -0
index 07cfdbe..471872a 100644

arch/arm/plat-mxc/include/mach/debug-macro.S line 29

Quoted 6 lines
arch/arm/plat-mxc/include/mach/debug-macro.S +3 -0
@@ -24,9 +24,14 @@
 #define UART_PADDR	MX51_UART1_BASE_ADDR
 #elif defined (CONFIG_DEBUG_IMX50_IMX53_UART)
 #define UART_PADDR	MX53_UART1_BASE_ADDR
+#elif defined (CONFIG_DEBUG_IMX6Q_UART)
+#define UART_PADDR	MX6Q_UART4_BASE_ADDR
+#define UART_VADDR	MX6Q_UART4_BASE_VADDR

You cannot use the existing IMX_IO_P2V? I'd like to have a look into it to make it usable there, too. See below.

Quoted 25 lines
arch/arm/plat-mxc/include/mach/debug-macro.S +2 -0
 #endif
 
+#ifndef UART_VADDR
 #define UART_VADDR	IMX_IO_ADDRESS(UART_PADDR)
+#endif
 
 		.macro	addruart, rp, rv
 		ldr	\rp, =UART_PADDR	@ physical
arch/arm/plat-mxc/include/mach/entry-macro.S +2 -1
index 066d464..341f800 100644
@@ -1,6 +1,6 @@
 /*
  *  Copyright (C) 2007 Lennert Buytenhek <[email protected]>
- *  Copyright 2004-2009 Freescale Semiconductor, Inc. All Rights Reserved.
+ *  Copyright 2004-2011 Freescale Semiconductor, Inc. All Rights Reserved.
  */
 
 /*
@@ -11,6 +11,17 @@
 
 #include <mach/hardware.h>
 
+#ifdef CONFIG_ARM_GIC

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

Quoted 10 lines
arch/arm/plat-mxc/include/mach/entry-macro.S +10 -0
+#include <asm/hardware/entry-macro-gic.S>
+
+	.macro	disable_fiq
+	.endm
+
+	.macro	arch_ret_to_user, tmp1, tmp2
+	.endm
+
+#else
+

hmm, this essentially means mx6 support cannot go into a kernel image for the other imx machines :-(

Quoted 32 lines
arch/arm/plat-mxc/include/mach/entry-macro.S +2 -0
 #define AVIC_NIMASK	0x04
 
 	@ this macro disables fast irq (not implemented)
@@ -78,3 +89,5 @@
 	movs \irqnr, \irqnr
 #endif
 	.endm
+
+#endif /* CONFIG_ARM_GIC */
arch/arm/plat-mxc/include/mach/hardware.h +1 -0
index a8bfd56..e1f84ce 100644
@@ -97,6 +97,7 @@
 
 #include <mach/mxc.h>
 
+#include <mach/mx6q.h>
 #include <mach/mx50.h>
 #include <mach/mx51.h>
 #include <mach/mx53.h>
arch/arm/plat-mxc/include/mach/irqs.h +2 -1
index 00e812b..3ae400f 100644
@@ -14,12 +14,15 @@
 #include <asm-generic/gpio.h>
 
 /*
- * SoCs with TZIC interrupt controller have 128 IRQs, those with AVIC have 64
+ * SoCs with AVIC interrupt controller have 64 IRQs, those with TZIC
+ * have 128, otherwise those with GIC have 160 IRQs.

arch/arm/plat-mxc/include/mach/irqs.h line 26

Quoted 10 lines
arch/arm/plat-mxc/include/mach/irqs.h +4 -2
  */
-#ifdef CONFIG_MXC_TZIC
+#if defined CONFIG_MXC_AVIC
+#define MXC_INTERNAL_IRQS	64
+#elif defined CONFIG_MXC_TZIC
 #define MXC_INTERNAL_IRQS	128
 #else
-#define MXC_INTERNAL_IRQS	64
+#define MXC_INTERNAL_IRQS	160
 #endif

This is broken. The highest number has to go to the top. Otherwise if you have an image with at least 2 of the available irq controllers your MXC_INTERNAL_IRQS is too small.

Quoted 46 lines
arch/arm/plat-mxc/include/mach/irqs.h +0 -0
 #define MXC_GPIO_IRQ_START	MXC_INTERNAL_IRQS
arch/arm/plat-mxc/include/mach/memory.h +3 -0
index 11be5cd..2b8e186 100644
@@ -19,6 +19,7 @@
 #define MX50_PHYS_OFFSET	UL(0x70000000)
 #define MX51_PHYS_OFFSET	UL(0x90000000)
 #define MX53_PHYS_OFFSET	UL(0x70000000)
+#define MX6Q_PHYS_OFFSET	UL(0x10000000)
 
 #if !defined(CONFIG_RUNTIME_PHYS_OFFSET)
 # if defined CONFIG_ARCH_MX1
@@ -37,6 +38,8 @@
 #  define PLAT_PHYS_OFFSET		MX51_PHYS_OFFSET
 # elif defined CONFIG_ARCH_MX53
 #  define PLAT_PHYS_OFFSET		MX53_PHYS_OFFSET
+# elif defined CONFIG_SOC_IMX6Q
+#  define PLAT_PHYS_OFFSET		MX6Q_PHYS_OFFSET
 # endif
 #endif
 
arch/arm/plat-mxc/include/mach/mx6q.h new file +17 -0
new file mode 100644
index 0000000..7432310
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2011 Freescale Semiconductor, Inc. All Rights Reserved.
+ * Copyright 2011 Linaro Ltd.
+ *
+ * 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_MX6Q_H__
+#define __MACH_MX6Q_H__
+
+/* static mappings */
+#define IMX6Q_VA(x)		(0xf4000000 + (x))

arch/arm/plat-mxc/include/mach/mx6q.h line 27

Quoted 10 lines
arch/arm/plat-mxc/include/mach/mx6q.h new file +10 -0
+
+#define MX6Q_SCU_BASE_ADDR	0x00a00000
+#define MX6Q_CCM_BASE_ADDR	0x020c4000
+#define MX6Q_ANATOP_BASE_ADDR	0x020c8000
+#define MX6Q_UART4_BASE_ADDR	0x021f0000
+
+#define MX6Q_SCU_BASE_VADDR	IMX6Q_VA(MX6Q_SCU_BASE_ADDR)
+#define MX6Q_CCM_BASE_VADDR	IMX6Q_VA(MX6Q_CCM_BASE_ADDR)
+#define MX6Q_ANATOP_BASE_VADDR	IMX6Q_VA(MX6Q_ANATOP_BASE_ADDR)
+#define MX6Q_UART4_BASE_VADDR	IMX6Q_VA(MX6Q_UART4_BASE_ADDR)

Depending on the sizes of these memory regions you can use the existing IMX_IO_P2V here. The conditions are:

	SCU_SIZE <= 0x200000
	CCM_SIZE <= 0x4000
	ANATOP_SIZE <= 0x28000
	UART4 <= 0x100000

hmm, looking@patch 4 SCU_BASE is determined by a coprocessor instruction?! Other than that these restrictions seem to be fulfilled.

Best regards
Uwe

Quoted 3 lines
arch/arm/plat-mxc/include/mach/mx6q.h new file +2 -0
+
+#endif	/* __MACH_MX6Q_H__ */
Signature · 2 lines
Pengutronix e.K.                           | Uwe Kleine-K?nig            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
#8 lore raw

PATCH 2/6 arm/imx6q: add core definitions and low-level debug uart

Quoted 97 lines · Uwe Kleine-K?nig
Quoted 96 lines · Shawn Guo

It adds the core definitions and low-level debug uart support for imx6q.

---
 arch/arm/Kconfig                             |    2 +-
 arch/arm/Kconfig.debug                       |    7 +++++
 arch/arm/Makefile                            |    1 +
 arch/arm/mach-imx/Kconfig                    |    4 +++
 arch/arm/mach-imx/Makefile                   |    2 +
 arch/arm/mach-imx/Makefile.boot              |    4 +++
 arch/arm/mach-imx/lluart.c                   |   33 ++++++++++++++++++++++++++
 arch/arm/plat-mxc/Kconfig                    |    5 ++++
 arch/arm/plat-mxc/include/mach/debug-macro.S |    5 ++++
 arch/arm/plat-mxc/include/mach/entry-macro.S |   15 +++++++++++-
 arch/arm/plat-mxc/include/mach/hardware.h    |    1 +
 arch/arm/plat-mxc/include/mach/irqs.h        |    9 ++++--
 arch/arm/plat-mxc/include/mach/memory.h      |    3 ++
 arch/arm/plat-mxc/include/mach/mx6q.h        |   29 ++++++++++++++++++++++
 14 files changed, 115 insertions(+), 5 deletions(-)
 create mode 100644 arch/arm/mach-imx/lluart.c
 create mode 100644 arch/arm/plat-mxc/include/mach/mx6q.h
arch/arm/Kconfig +1 -1
index 4ea9974..37c20a4 100644
@@ -1348,7 +1348,7 @@ config SMP
 	depends on REALVIEW_EB_ARM11MP || REALVIEW_EB_A9MP || \
 		 MACH_REALVIEW_PB11MP || MACH_REALVIEW_PBX || ARCH_OMAP4 || \
 		 ARCH_EXYNOS4 || ARCH_TEGRA || ARCH_U8500 || ARCH_VEXPRESS_CA9X4 || \
-		 ARCH_MSM_SCORPIONMP || ARCH_SHMOBILE
+		 ARCH_MSM_SCORPIONMP || ARCH_SHMOBILE || SOC_IMX6Q
 	select USE_GENERIC_SMP_HELPERS
 	select HAVE_ARM_SCU if !ARCH_MSM_SCORPIONMP
 	help
arch/arm/Kconfig.debug +7 -0
index 965d59a..68fc155 100644
@@ -155,6 +155,13 @@ choice
 		  Say Y here if you want kernel low-level debugging support
 		  on i.MX50 or i.MX53.
 
+	config DEBUG_IMX6Q_UART
+		bool "i.MX6Q Debug UART"
+		depends on SOC_IMX6Q
+		help
+		  Say Y here if you want kernel low-level debugging support
+		  on i.MX6Q.
+
 	config DEBUG_S3C_UART0
 		depends on PLAT_SAMSUNG
 		bool "Use S3C UART 0 for low-level debug"
arch/arm/Makefile +1 -0
index 70c424e..3a0bbe4 100644
@@ -159,6 +159,7 @@ machine-$(CONFIG_ARCH_MX2)		:= imx
 machine-$(CONFIG_ARCH_MX25)		:= imx
 machine-$(CONFIG_ARCH_MX3)		:= imx
 machine-$(CONFIG_ARCH_MX5)		:= mx5
+machine-$(CONFIG_ARCH_MX6)		:= imx
 machine-$(CONFIG_ARCH_MXS)		:= mxs
 machine-$(CONFIG_ARCH_NETX)		:= netx
 machine-$(CONFIG_ARCH_NOMADIK)		:= nomadik
arch/arm/mach-imx/Kconfig +4 -0
index 0519dd7..4cf5178 100644
@@ -58,6 +58,10 @@ config SOC_IMX35
 	select ARCH_MX35
 	select MXC_AVIC
 
+config SOC_IMX6Q
+	bool
+	select ARM_GIC
+	select CPU_V7
 
 if ARCH_MX1
 
arch/arm/mach-imx/Makefile +2 -0
index e9eb36d..96ecc96 100644
@@ -61,3 +61,5 @@ obj-$(CONFIG_MACH_MX35_3DS) += mach-mx35_3ds.o
 obj-$(CONFIG_MACH_EUKREA_CPUIMX35) += mach-cpuimx35.o
 obj-$(CONFIG_MACH_EUKREA_MBIMXSD35_BASEBOARD) += eukrea_mbimxsd35-baseboard.o
 obj-$(CONFIG_MACH_VPR200) += mach-vpr200.o
+
+obj-$(CONFIG_DEBUG_LL) += lluart.o
arch/arm/mach-imx/Makefile.boot +0 -0
index ebee18b..389a0e3 100644
@@ -17,3 +17,7 @@ initrd_phys-$(CONFIG_MACH_MX27)	:= 0xA0800000
Quoted 9 lines

arch/arm/mach-imx/Makefile.boot initrd_phys-$(CONFIG_MACH_MX27) := 0xA0800000 · line 23

Quoted 7 lines
arch/arm/mach-imx/Makefile.boot +4 -0
 zreladdr-$(CONFIG_ARCH_MX3)	:= 0x80008000
 params_phys-$(CONFIG_ARCH_MX3)	:= 0x80000100
 initrd_phys-$(CONFIG_ARCH_MX3)	:= 0x80800000
+
+zreladdr-$(CONFIG_SOC_IMX6Q)	:= 0x10008000
+params_phys-$(CONFIG_SOC_IMX6Q)	:= 0x10000100
+initrd_phys-$(CONFIG_SOC_IMX6Q)	:= 0x10800000

Do you really need params_phys and initrd_phys?

I added them to make IMX6Q look consistent with other soc in the file, and leave it to a global cleanup, if we decide to clean later.

Quoted 32 lines
Quoted 32 lines
arch/arm/mach-imx/lluart.c new file +26 -0
new file mode 100644
index 0000000..34205cb
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2011 Freescale Semiconductor, Inc.
+ * Copyright 2011 Linaro Ltd.
+ *
+ * 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 <asm/page.h>
+#include <asm/sizes.h>
+#include <asm/mach/map.h>
+#include <mach/hardware.h>
+
+static struct map_desc imx_lluart_desc = {
+#ifdef CONFIG_DEBUG_IMX6Q_UART
+	.virtual	= MX6Q_UART4_BASE_VADDR,
+	.pfn		= __phys_to_pfn(MX6Q_UART4_BASE_ADDR),
+	.length		= SZ_16K,
+	.type		= MT_DEVICE,
+#endif
+};
Quoted 8 lines

arch/arm/mach-imx/lluart.c line 32

Quoted 6 lines
arch/arm/mach-imx/lluart.c new file +6 -0
+
+void __init imx_lluart_map_io(void)
+{
+	if (imx_lluart_desc.virtual)
+		iotable_init(&imx_lluart_desc, 1);
+}

I don't see yet where this is called, but I wonder what happens on a non-imx6q machine (provided it is called there).

This is called by imx6q_map_io() in mach-imx6q.c. For non-imx6q machines, imx_lluart_desc will be all zero, therefore iotable_init() call will be bypassed.

Quoted 55 lines
Quoted 22 lines
arch/arm/mach-imx/lluart.c new file +1 -0
+
arch/arm/plat-mxc/Kconfig +5 -0
index a5353fc..e548f9b 100644
@@ -48,6 +48,11 @@ config ARCH_MX51
 	help
 	  This enables support for systems based on the Freescale i.MX51 family
 
+config ARCH_MX6
+	bool "i.MX6"
+	help
+	  This enables support for systems based on the Freescale i.MX6 family
+
 endchoice
 
 source "arch/arm/mach-imx/Kconfig"
arch/arm/plat-mxc/include/mach/debug-macro.S +0 -0
index 07cfdbe..471872a 100644

arch/arm/plat-mxc/include/mach/debug-macro.S line 29

Quoted 6 lines
arch/arm/plat-mxc/include/mach/debug-macro.S +3 -0
@@ -24,9 +24,14 @@
 #define UART_PADDR	MX51_UART1_BASE_ADDR
 #elif defined (CONFIG_DEBUG_IMX50_IMX53_UART)
 #define UART_PADDR	MX53_UART1_BASE_ADDR
+#elif defined (CONFIG_DEBUG_IMX6Q_UART)
+#define UART_PADDR	MX6Q_UART4_BASE_ADDR
+#define UART_VADDR	MX6Q_UART4_BASE_VADDR

You cannot use the existing IMX_IO_P2V? I'd like to have a look into it to make it usable there, too. See below.

Quoted 24 lines
arch/arm/plat-mxc/include/mach/debug-macro.S +2 -0
 #endif
 
+#ifndef UART_VADDR
 #define UART_VADDR	IMX_IO_ADDRESS(UART_PADDR)
+#endif
 
 		.macro	addruart, rp, rv
 		ldr	\rp, =UART_PADDR	@ physical
arch/arm/plat-mxc/include/mach/entry-macro.S +1 -1
index 066d464..341f800 100644
@@ -1,6 +1,6 @@
 /*
  *  Copyright (C) 2007 Lennert Buytenhek <[email protected]>
- *  Copyright 2004-2009 Freescale Semiconductor, Inc. All Rights Reserved.
+ *  Copyright 2004-2011 Freescale Semiconductor, Inc. All Rights Reserved.
  */
 
 /*
@@ -11,6 +11,17 @@
 
 #include <mach/hardware.h>
 
Quoted 14 lines

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

Quoted 11 lines
arch/arm/plat-mxc/include/mach/entry-macro.S +11 -0
+#ifdef CONFIG_ARM_GIC
+#include <asm/hardware/entry-macro-gic.S>
+
+	.macro	disable_fiq
+	.endm
+
+	.macro	arch_ret_to_user, tmp1, tmp2
+	.endm
+
+#else
+

hmm, this essentially means mx6 support cannot go into a kernel image for the other imx machines :-(

Ah, sorry. I totally forgot about this. Will fix it in the next version.

Quoted 37 lines
Quoted 37 lines
arch/arm/plat-mxc/include/mach/entry-macro.S +2 -0
 #define AVIC_NIMASK	0x04
 
 	@ this macro disables fast irq (not implemented)
@@ -78,3 +89,5 @@
 	movs \irqnr, \irqnr
 #endif
 	.endm
+
+#endif /* CONFIG_ARM_GIC */
arch/arm/plat-mxc/include/mach/hardware.h +1 -0
index a8bfd56..e1f84ce 100644
@@ -97,6 +97,7 @@
 
 #include <mach/mxc.h>
 
+#include <mach/mx6q.h>
 #include <mach/mx50.h>
 #include <mach/mx51.h>
 #include <mach/mx53.h>
arch/arm/plat-mxc/include/mach/irqs.h +5 -2
index 00e812b..3ae400f 100644
@@ -14,12 +14,15 @@
 #include <asm-generic/gpio.h>
 
 /*
- * SoCs with TZIC interrupt controller have 128 IRQs, those with AVIC have 64
+ * SoCs with AVIC interrupt controller have 64 IRQs, those with TZIC
+ * have 128, otherwise those with GIC have 160 IRQs.
  */
-#ifdef CONFIG_MXC_TZIC
+#if defined CONFIG_MXC_AVIC
+#define MXC_INTERNAL_IRQS	64
+#elif defined CONFIG_MXC_TZIC
Quoted 9 lines

arch/arm/plat-mxc/include/mach/irqs.h line 26

Quoted 5 lines
arch/arm/plat-mxc/include/mach/irqs.h +1 -1
 #define MXC_INTERNAL_IRQS	128
 #else
-#define MXC_INTERNAL_IRQS	64
+#define MXC_INTERNAL_IRQS	160
 #endif

This is broken. The highest number has to go to the top. Otherwise if you have an image with at least 2 of the available irq controllers your MXC_INTERNAL_IRQS is too small.

Yes, this is yet another one I forgot about single image support. I should probably put some documentation about the correct order, which can be forgot by people like me.

Thanks for catching this.

Quoted 59 lines
Quoted 46 lines
arch/arm/plat-mxc/include/mach/irqs.h +0 -0
 #define MXC_GPIO_IRQ_START	MXC_INTERNAL_IRQS
arch/arm/plat-mxc/include/mach/memory.h +3 -0
index 11be5cd..2b8e186 100644
@@ -19,6 +19,7 @@
 #define MX50_PHYS_OFFSET	UL(0x70000000)
 #define MX51_PHYS_OFFSET	UL(0x90000000)
 #define MX53_PHYS_OFFSET	UL(0x70000000)
+#define MX6Q_PHYS_OFFSET	UL(0x10000000)
 
 #if !defined(CONFIG_RUNTIME_PHYS_OFFSET)
 # if defined CONFIG_ARCH_MX1
@@ -37,6 +38,8 @@
 #  define PLAT_PHYS_OFFSET		MX51_PHYS_OFFSET
 # elif defined CONFIG_ARCH_MX53
 #  define PLAT_PHYS_OFFSET		MX53_PHYS_OFFSET
+# elif defined CONFIG_SOC_IMX6Q
+#  define PLAT_PHYS_OFFSET		MX6Q_PHYS_OFFSET
 # endif
 #endif
 
arch/arm/plat-mxc/include/mach/mx6q.h new file +17 -0
new file mode 100644
index 0000000..7432310
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2011 Freescale Semiconductor, Inc. All Rights Reserved.
+ * Copyright 2011 Linaro Ltd.
+ *
+ * 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_MX6Q_H__
+#define __MACH_MX6Q_H__
+
+/* static mappings */
+#define IMX6Q_VA(x)		(0xf4000000 + (x))

arch/arm/plat-mxc/include/mach/mx6q.h line 27

Quoted 10 lines
arch/arm/plat-mxc/include/mach/mx6q.h new file +10 -0
+
+#define MX6Q_SCU_BASE_ADDR	0x00a00000
+#define MX6Q_CCM_BASE_ADDR	0x020c4000
+#define MX6Q_ANATOP_BASE_ADDR	0x020c8000
+#define MX6Q_UART4_BASE_ADDR	0x021f0000
+
+#define MX6Q_SCU_BASE_VADDR	IMX6Q_VA(MX6Q_SCU_BASE_ADDR)
+#define MX6Q_CCM_BASE_VADDR	IMX6Q_VA(MX6Q_CCM_BASE_ADDR)
+#define MX6Q_ANATOP_BASE_VADDR	IMX6Q_VA(MX6Q_ANATOP_BASE_ADDR)
+#define MX6Q_UART4_BASE_VADDR	IMX6Q_VA(MX6Q_UART4_BASE_ADDR)

Depending on the sizes of these memory regions you can use the existing IMX_IO_P2V here. The conditions are:

Quoted 5 lines
	SCU_SIZE <= 0x200000
	CCM_SIZE <= 0x4000
	ANATOP_SIZE <= 0x28000
	UART4 <= 0x100000

This is exactly what I dislike about IMX_IO_P2V(). We have to verify all these conditions manually. Looking at the static mapping below (copied from arch/arm/plat-mxc/include/mach/hardware.h), do you think it's really scalable and easy to maintain for the long run?

/*
* This is rather complicated for humans and ugly to verify, but for a machine
* it's OK. Still more as it is usually only applied to constants. The upsides
* on using this approach are:
*

 *  - same mapping on all i.MX machines
 *  - works for assembler, too
 *  - no need to nurture #defines for virtual addresses
 *
 * The downside it, it's hard to verify (but I have a script for that).
 *
 * Obviously this needs to be injective for each SoC.  In general it maps the
 * whole address space to [0xf4000000, 0xf5ffffff].  So [0xf6000000,0xfeffffff]
 * is free for per-machine use (e.g. KZM_ARM11_01 uses 64MiB there).
 *
 * It applies the following mappings for the different SoCs:
 *
 * mx1:
 *	IO	0x00200000+0x100000	->	0xf4000000+0x100000
 * mx21:
 *	AIPI	0x10000000+0x100000	->	0xf4400000+0x100000
 *	SAHB1	0x80000000+0x100000	->	0xf4000000+0x100000
 *	X_MEMC	0xdf000000+0x004000	->	0xf5f00000+0x004000
 * mx25:
 *	AIPS1	0x43f00000+0x100000	->	0xf5300000+0x100000
 *	AIPS2	0x53f00000+0x100000	->	0xf5700000+0x100000
 *	AVIC	0x68000000+0x100000	->	0xf5800000+0x100000
 * mx27:
 *	AIPI	0x10000000+0x100000	->	0xf4400000+0x100000
 *	SAHB1	0x80000000+0x100000	->	0xf4000000+0x100000
 *	X_MEMC	0xd8000000+0x100000	->	0xf5c00000+0x100000
 * mx31:
 *	AIPS1	0x43f00000+0x100000	->	0xf5300000+0x100000
 *	AIPS2	0x53f00000+0x100000	->	0xf5700000+0x100000
 *	AVIC	0x68000000+0x100000	->	0xf5800000+0x100000
 *	X_MEMC	0xb8000000+0x010000	->	0xf4c00000+0x010000
 *	SPBA0	0x50000000+0x100000	->	0xf5400000+0x100000
 * mx35:
 *	AIPS1	0x43f00000+0x100000	->	0xf5300000+0x100000
 *	AIPS2	0x53f00000+0x100000	->	0xf5700000+0x100000
 *	AVIC	0x68000000+0x100000	->	0xf5800000+0x100000
 *	X_MEMC	0xb8000000+0x010000	->	0xf4c00000+0x010000
 *	SPBA0	0x50000000+0x100000	->	0xf5400000+0x100000
 * mx50:
 *	TZIC	0x0fffc000+0x004000	->	0xf4bfc000+0x004000
 *	SPBA0	0x50000000+0x100000	->	0xf5400000+0x100000
 *	AIPS1	0x53f00000+0x100000	->	0xf5700000+0x100000
 *	AIPS2	0x63f00000+0x100000	->	0xf5300000+0x100000
 * mx51:
 *	IRAM	0x1ffe0000+0x020000	->	0xf4fe0000+0x020000
 *	DEBUG	0x60000000+0x100000	->	0xf5000000+0x100000
 *	SPBA0	0x70000000+0x100000	->	0xf5400000+0x100000
 *	AIPS1	0x73f00000+0x100000	->	0xf5700000+0x100000
 *	AIPS2	0x83f00000+0x100000	->	0xf4300000+0x100000
 */
#define IMX_IO_P2V(x)	(						\
			0xf4000000 +					\
			(((x) & 0x50000000) >> 6) +			\
			(((x) & 0x0b000000) >> 4) +			\
			(((x) & 0x000fffff)))
Quoted 2 lines

hmm, looking at patch 4 SCU_BASE is determined by a coprocessor instruction?!

Ah, yes. The SCU physical base address can be retrieved from coprocessor.

Regards,
Shawn

Quoted 2 lines

Other than that these restrictions seem to be fulfilled.

#9 lore raw

PATCH 2/6 arm/imx6q: add core definitions and low-level debug uart

Quoted 107 lines · Shawn Guo
Quoted 97 lines · Uwe Kleine-K?nig
Quoted 96 lines · Shawn Guo

It adds the core definitions and low-level debug uart support for imx6q.

---
 arch/arm/Kconfig                             |    2 +-
 arch/arm/Kconfig.debug                       |    7 +++++
 arch/arm/Makefile                            |    1 +
 arch/arm/mach-imx/Kconfig                    |    4 +++
 arch/arm/mach-imx/Makefile                   |    2 +
 arch/arm/mach-imx/Makefile.boot              |    4 +++
 arch/arm/mach-imx/lluart.c                   |   33 ++++++++++++++++++++++++++
 arch/arm/plat-mxc/Kconfig                    |    5 ++++
 arch/arm/plat-mxc/include/mach/debug-macro.S |    5 ++++
 arch/arm/plat-mxc/include/mach/entry-macro.S |   15 +++++++++++-
 arch/arm/plat-mxc/include/mach/hardware.h    |    1 +
 arch/arm/plat-mxc/include/mach/irqs.h        |    9 ++++--
 arch/arm/plat-mxc/include/mach/memory.h      |    3 ++
 arch/arm/plat-mxc/include/mach/mx6q.h        |   29 ++++++++++++++++++++++
 14 files changed, 115 insertions(+), 5 deletions(-)
 create mode 100644 arch/arm/mach-imx/lluart.c
 create mode 100644 arch/arm/plat-mxc/include/mach/mx6q.h
arch/arm/Kconfig +1 -1
index 4ea9974..37c20a4 100644
@@ -1348,7 +1348,7 @@ config SMP
 	depends on REALVIEW_EB_ARM11MP || REALVIEW_EB_A9MP || \
 		 MACH_REALVIEW_PB11MP || MACH_REALVIEW_PBX || ARCH_OMAP4 || \
 		 ARCH_EXYNOS4 || ARCH_TEGRA || ARCH_U8500 || ARCH_VEXPRESS_CA9X4 || \
-		 ARCH_MSM_SCORPIONMP || ARCH_SHMOBILE
+		 ARCH_MSM_SCORPIONMP || ARCH_SHMOBILE || SOC_IMX6Q
 	select USE_GENERIC_SMP_HELPERS
 	select HAVE_ARM_SCU if !ARCH_MSM_SCORPIONMP
 	help
arch/arm/Kconfig.debug +7 -0
index 965d59a..68fc155 100644
@@ -155,6 +155,13 @@ choice
 		  Say Y here if you want kernel low-level debugging support
 		  on i.MX50 or i.MX53.
 
+	config DEBUG_IMX6Q_UART
+		bool "i.MX6Q Debug UART"
+		depends on SOC_IMX6Q
+		help
+		  Say Y here if you want kernel low-level debugging support
+		  on i.MX6Q.
+
 	config DEBUG_S3C_UART0
 		depends on PLAT_SAMSUNG
 		bool "Use S3C UART 0 for low-level debug"
arch/arm/Makefile +1 -0
index 70c424e..3a0bbe4 100644
@@ -159,6 +159,7 @@ machine-$(CONFIG_ARCH_MX2)		:= imx
 machine-$(CONFIG_ARCH_MX25)		:= imx
 machine-$(CONFIG_ARCH_MX3)		:= imx
 machine-$(CONFIG_ARCH_MX5)		:= mx5
+machine-$(CONFIG_ARCH_MX6)		:= imx
 machine-$(CONFIG_ARCH_MXS)		:= mxs
 machine-$(CONFIG_ARCH_NETX)		:= netx
 machine-$(CONFIG_ARCH_NOMADIK)		:= nomadik
arch/arm/mach-imx/Kconfig +4 -0
index 0519dd7..4cf5178 100644
@@ -58,6 +58,10 @@ config SOC_IMX35
 	select ARCH_MX35
 	select MXC_AVIC
 
+config SOC_IMX6Q
+	bool
+	select ARM_GIC
+	select CPU_V7
 
 if ARCH_MX1
 
arch/arm/mach-imx/Makefile +2 -0
index e9eb36d..96ecc96 100644
@@ -61,3 +61,5 @@ obj-$(CONFIG_MACH_MX35_3DS) += mach-mx35_3ds.o
 obj-$(CONFIG_MACH_EUKREA_CPUIMX35) += mach-cpuimx35.o
 obj-$(CONFIG_MACH_EUKREA_MBIMXSD35_BASEBOARD) += eukrea_mbimxsd35-baseboard.o
 obj-$(CONFIG_MACH_VPR200) += mach-vpr200.o
+
+obj-$(CONFIG_DEBUG_LL) += lluart.o
arch/arm/mach-imx/Makefile.boot +0 -0
index ebee18b..389a0e3 100644
@@ -17,3 +17,7 @@ initrd_phys-$(CONFIG_MACH_MX27)	:= 0xA0800000
Quoted 9 lines

arch/arm/mach-imx/Makefile.boot initrd_phys-$(CONFIG_MACH_MX27) := 0xA0800000 · line 23

Quoted 7 lines
arch/arm/mach-imx/Makefile.boot +4 -0
 zreladdr-$(CONFIG_ARCH_MX3)	:= 0x80008000
 params_phys-$(CONFIG_ARCH_MX3)	:= 0x80000100
 initrd_phys-$(CONFIG_ARCH_MX3)	:= 0x80800000
+
+zreladdr-$(CONFIG_SOC_IMX6Q)	:= 0x10008000
+params_phys-$(CONFIG_SOC_IMX6Q)	:= 0x10000100
+initrd_phys-$(CONFIG_SOC_IMX6Q)	:= 0x10800000

Do you really need params_phys and initrd_phys?

Quoted 2 lines

I added them to make IMX6Q look consistent with other soc in the file, and leave it to a global cleanup, if we decide to clean later.

If you ask me don't do that. Better do it for imx6q as clean as possible.

Quoted 41 lines
Quoted 32 lines
Quoted 32 lines
arch/arm/mach-imx/lluart.c new file +26 -0
new file mode 100644
index 0000000..34205cb
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2011 Freescale Semiconductor, Inc.
+ * Copyright 2011 Linaro Ltd.
+ *
+ * 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 <asm/page.h>
+#include <asm/sizes.h>
+#include <asm/mach/map.h>
+#include <mach/hardware.h>
+
+static struct map_desc imx_lluart_desc = {
+#ifdef CONFIG_DEBUG_IMX6Q_UART
+	.virtual	= MX6Q_UART4_BASE_VADDR,
+	.pfn		= __phys_to_pfn(MX6Q_UART4_BASE_ADDR),
+	.length		= SZ_16K,
+	.type		= MT_DEVICE,
+#endif
+};
Quoted 8 lines

arch/arm/mach-imx/lluart.c line 32

Quoted 6 lines
arch/arm/mach-imx/lluart.c new file +6 -0
+
+void __init imx_lluart_map_io(void)
+{
+	if (imx_lluart_desc.virtual)
+		iotable_init(&imx_lluart_desc, 1);
+}

I don't see yet where this is called, but I wonder what happens on a non-imx6q machine (provided it is called there).

Quoted 2 lines

This is called by imx6q_map_io() in mach-imx6q.c. For non-imx6q machines, imx_lluart_desc will be all zero,

But only if the image doesn't support imx6q, right? Anyhow, I hope imx6q_map_io isn't called for pre-imx6q SoCs. Ah, and I hope we don't need to argue here as Russell doesn't like the new DEBUG_LL changes :-)

Quoted 122 lines

therefore iotable_init()
call will be bypassed.

Quoted 55 lines
Quoted 22 lines
arch/arm/mach-imx/lluart.c new file +1 -0
+
arch/arm/plat-mxc/Kconfig +5 -0
index a5353fc..e548f9b 100644
@@ -48,6 +48,11 @@ config ARCH_MX51
 	help
 	  This enables support for systems based on the Freescale i.MX51 family
 
+config ARCH_MX6
+	bool "i.MX6"
+	help
+	  This enables support for systems based on the Freescale i.MX6 family
+
 endchoice
 
 source "arch/arm/mach-imx/Kconfig"
arch/arm/plat-mxc/include/mach/debug-macro.S +0 -0
index 07cfdbe..471872a 100644

arch/arm/plat-mxc/include/mach/debug-macro.S line 29

Quoted 6 lines
arch/arm/plat-mxc/include/mach/debug-macro.S +3 -0
@@ -24,9 +24,14 @@
 #define UART_PADDR	MX51_UART1_BASE_ADDR
 #elif defined (CONFIG_DEBUG_IMX50_IMX53_UART)
 #define UART_PADDR	MX53_UART1_BASE_ADDR
+#elif defined (CONFIG_DEBUG_IMX6Q_UART)
+#define UART_PADDR	MX6Q_UART4_BASE_ADDR
+#define UART_VADDR	MX6Q_UART4_BASE_VADDR

You cannot use the existing IMX_IO_P2V? I'd like to have a look into it to make it usable there, too. See below.

Quoted 24 lines
arch/arm/plat-mxc/include/mach/debug-macro.S +2 -0
 #endif
 
+#ifndef UART_VADDR
 #define UART_VADDR	IMX_IO_ADDRESS(UART_PADDR)
+#endif
 
 		.macro	addruart, rp, rv
 		ldr	\rp, =UART_PADDR	@ physical
arch/arm/plat-mxc/include/mach/entry-macro.S +1 -1
index 066d464..341f800 100644
@@ -1,6 +1,6 @@
 /*
  *  Copyright (C) 2007 Lennert Buytenhek <[email protected]>
- *  Copyright 2004-2009 Freescale Semiconductor, Inc. All Rights Reserved.
+ *  Copyright 2004-2011 Freescale Semiconductor, Inc. All Rights Reserved.
  */
 
 /*
@@ -11,6 +11,17 @@
 
 #include <mach/hardware.h>
 
Quoted 14 lines

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

Quoted 11 lines
arch/arm/plat-mxc/include/mach/entry-macro.S +11 -0
+#ifdef CONFIG_ARM_GIC
+#include <asm/hardware/entry-macro-gic.S>
+
+	.macro	disable_fiq
+	.endm
+
+	.macro	arch_ret_to_user, tmp1, tmp2
+	.endm
+
+#else
+

hmm, this essentially means mx6 support cannot go into a kernel image for the other imx machines :-(

Ah, sorry. I totally forgot about this. Will fix it in the next version.

Quoted 37 lines
Quoted 37 lines
arch/arm/plat-mxc/include/mach/entry-macro.S +2 -0
 #define AVIC_NIMASK	0x04
 
 	@ this macro disables fast irq (not implemented)
@@ -78,3 +89,5 @@
 	movs \irqnr, \irqnr
 #endif
 	.endm
+
+#endif /* CONFIG_ARM_GIC */
arch/arm/plat-mxc/include/mach/hardware.h +1 -0
index a8bfd56..e1f84ce 100644
@@ -97,6 +97,7 @@
 
 #include <mach/mxc.h>
 
+#include <mach/mx6q.h>
 #include <mach/mx50.h>
 #include <mach/mx51.h>
 #include <mach/mx53.h>
arch/arm/plat-mxc/include/mach/irqs.h +5 -2
index 00e812b..3ae400f 100644
@@ -14,12 +14,15 @@
 #include <asm-generic/gpio.h>
 
 /*
- * SoCs with TZIC interrupt controller have 128 IRQs, those with AVIC have 64
+ * SoCs with AVIC interrupt controller have 64 IRQs, those with TZIC
+ * have 128, otherwise those with GIC have 160 IRQs.
  */
-#ifdef CONFIG_MXC_TZIC
+#if defined CONFIG_MXC_AVIC
+#define MXC_INTERNAL_IRQS	64
+#elif defined CONFIG_MXC_TZIC
Quoted 9 lines

arch/arm/plat-mxc/include/mach/irqs.h line 26

Quoted 5 lines
arch/arm/plat-mxc/include/mach/irqs.h +1 -1
 #define MXC_INTERNAL_IRQS	128
 #else
-#define MXC_INTERNAL_IRQS	64
+#define MXC_INTERNAL_IRQS	160
 #endif

This is broken. The highest number has to go to the top. Otherwise if you have an image with at least 2 of the available irq controllers your MXC_INTERNAL_IRQS is too small.

Quoted 3 lines

Yes, this is yet another one I forgot about single image support. I should probably put some documentation about the correct order, which can be forgot by people like me.

Maybe just introduce a corresponding comment when you touch this part of code anyhow?!

Quoted 58 lines
Quoted 58 lines
Quoted 45 lines
arch/arm/plat-mxc/include/mach/irqs.h +0 -0
 #define MXC_GPIO_IRQ_START	MXC_INTERNAL_IRQS
arch/arm/plat-mxc/include/mach/memory.h +3 -0
index 11be5cd..2b8e186 100644
@@ -19,6 +19,7 @@
 #define MX50_PHYS_OFFSET	UL(0x70000000)
 #define MX51_PHYS_OFFSET	UL(0x90000000)
 #define MX53_PHYS_OFFSET	UL(0x70000000)
+#define MX6Q_PHYS_OFFSET	UL(0x10000000)
 
 #if !defined(CONFIG_RUNTIME_PHYS_OFFSET)
 # if defined CONFIG_ARCH_MX1
@@ -37,6 +38,8 @@
 #  define PLAT_PHYS_OFFSET		MX51_PHYS_OFFSET
 # elif defined CONFIG_ARCH_MX53
 #  define PLAT_PHYS_OFFSET		MX53_PHYS_OFFSET
+# elif defined CONFIG_SOC_IMX6Q
+#  define PLAT_PHYS_OFFSET		MX6Q_PHYS_OFFSET
 # endif
 #endif
 
arch/arm/plat-mxc/include/mach/mx6q.h new file +17 -0
new file mode 100644
index 0000000..7432310
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2011 Freescale Semiconductor, Inc. All Rights Reserved.
+ * Copyright 2011 Linaro Ltd.
+ *
+ * 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_MX6Q_H__
+#define __MACH_MX6Q_H__
+
+/* static mappings */
+#define IMX6Q_VA(x)		(0xf4000000 + (x))

arch/arm/plat-mxc/include/mach/mx6q.h line 27

Quoted 10 lines
arch/arm/plat-mxc/include/mach/mx6q.h new file +10 -0
+
+#define MX6Q_SCU_BASE_ADDR	0x00a00000
+#define MX6Q_CCM_BASE_ADDR	0x020c4000
+#define MX6Q_ANATOP_BASE_ADDR	0x020c8000
+#define MX6Q_UART4_BASE_ADDR	0x021f0000
+
+#define MX6Q_SCU_BASE_VADDR	IMX6Q_VA(MX6Q_SCU_BASE_ADDR)
+#define MX6Q_CCM_BASE_VADDR	IMX6Q_VA(MX6Q_CCM_BASE_ADDR)
+#define MX6Q_ANATOP_BASE_VADDR	IMX6Q_VA(MX6Q_ANATOP_BASE_ADDR)
+#define MX6Q_UART4_BASE_VADDR	IMX6Q_VA(MX6Q_UART4_BASE_ADDR)

Depending on the sizes of these memory regions you can use the existing IMX_IO_P2V here. The conditions are:

Quoted 1 line
Quoted 1 line
	SCU_SIZE <= 0x200000

Actually this should be 0x100000 as this is the size that is mapped in a continous chunk.

Quoted 6 lines
Quoted 4 lines
	CCM_SIZE <= 0x4000
	ANATOP_SIZE <= 0x28000
	UART4 <= 0x100000

This is exactly what I dislike about IMX_IO_P2V(). We have to verify all these conditions manually. Looking at the static mapping below

I did it semi-manual, I just put your constants for imx6q into my script (all with size=0x4000 for now) and it told me:

...
* mx6q:
* SCU 0x00a00000+0x004000 -> 0xf4000000+0x004000
* CCM 0x020c4000+0x004000 -> 0xf42c4000+0x004000
* ANATOP 0x020c8000+0x004000 -> 0xf42c8000+0x004000
* UART4 0x021f0000+0x004000 -> 0xf42f0000+0x004000
...

Quoted 2 lines

(copied from arch/arm/plat-mxc/include/mach/hardware.h), do you think it's really scalable and easy to maintain for the long run?

At least it provides a way to verify the correctness of the mapping. Before I introduced the mapping function there was a conflict IIRC.

Quoted 10 lines

/*
* This is rather complicated for humans and ugly to verify, but for a machine
* it's OK. Still more as it is usually only applied to constants. The upsides
* on using this approach are:
*

 *  - same mapping on all i.MX machines
 *  - works for assembler, too
 *  - no need to nurture #defines for virtual addresses

*
* The downside it, it's hard to verify (but I have a script for that).

If you want I can provide you that script.

Quoted 50 lines

* Obviously this needs to be injective for each SoC. In general it maps the
* whole address space to [0xf4000000, 0xf5ffffff]. So [0xf6000000,0xfeffffff]
* is free for per-machine use (e.g. KZM_ARM11_01 uses 64MiB there). *
* It applies the following mappings for the different SoCs:
*
* mx1:
* IO 0x00200000+0x100000 -> 0xf4000000+0x100000
* mx21:
* AIPI 0x10000000+0x100000 -> 0xf4400000+0x100000
* SAHB1 0x80000000+0x100000 -> 0xf4000000+0x100000
* X_MEMC 0xdf000000+0x004000 -> 0xf5f00000+0x004000
* mx25:
* AIPS1 0x43f00000+0x100000 -> 0xf5300000+0x100000
* AIPS2 0x53f00000+0x100000 -> 0xf5700000+0x100000
* AVIC 0x68000000+0x100000 -> 0xf5800000+0x100000
* mx27:
* AIPI 0x10000000+0x100000 -> 0xf4400000+0x100000
* SAHB1 0x80000000+0x100000 -> 0xf4000000+0x100000
* X_MEMC 0xd8000000+0x100000 -> 0xf5c00000+0x100000
* mx31:
* AIPS1 0x43f00000+0x100000 -> 0xf5300000+0x100000
* AIPS2 0x53f00000+0x100000 -> 0xf5700000+0x100000
* AVIC 0x68000000+0x100000 -> 0xf5800000+0x100000
* X_MEMC 0xb8000000+0x010000 -> 0xf4c00000+0x010000
* SPBA0 0x50000000+0x100000 -> 0xf5400000+0x100000
* mx35:
* AIPS1 0x43f00000+0x100000 -> 0xf5300000+0x100000
* AIPS2 0x53f00000+0x100000 -> 0xf5700000+0x100000
* AVIC 0x68000000+0x100000 -> 0xf5800000+0x100000
* X_MEMC 0xb8000000+0x010000 -> 0xf4c00000+0x010000
* SPBA0 0x50000000+0x100000 -> 0xf5400000+0x100000
* mx50:
* TZIC 0x0fffc000+0x004000 -> 0xf4bfc000+0x004000
* SPBA0 0x50000000+0x100000 -> 0xf5400000+0x100000
* AIPS1 0x53f00000+0x100000 -> 0xf5700000+0x100000
* AIPS2 0x63f00000+0x100000 -> 0xf5300000+0x100000
* mx51:
* IRAM 0x1ffe0000+0x020000 -> 0xf4fe0000+0x020000
* DEBUG 0x60000000+0x100000 -> 0xf5000000+0x100000
* SPBA0 0x70000000+0x100000 -> 0xf5400000+0x100000
* AIPS1 0x73f00000+0x100000 -> 0xf5700000+0x100000
* AIPS2 0x83f00000+0x100000 -> 0xf4300000+0x100000
*/

#define IMX_IO_P2V(x)	(						\
			0xf4000000 +					\
			(((x) & 0x50000000) >> 6) +			\
			(((x) & 0x0b000000) >> 4) +			\
			(((x) & 0x000fffff)))
Quoted 5 lines
Quoted 2 lines

hmm, looking at patch 4 SCU_BASE is determined by a coprocessor instruction?!

Ah, yes. The SCU physical base address can be retrieved from coprocessor.

Is there an advantage in autodetecting the base address?

Best regards
Uwe

Signature · 2 lines
Pengutronix e.K.                           | Uwe Kleine-K?nig            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
#10 lore raw

PATCH 2/6 arm/imx6q: add core definitions and low-level debug uart

Quoted 3 lines · Uwe Kleine-K?nig

But only if the image doesn't support imx6q, right? Anyhow, I hope imx6q_map_io isn't called for pre-imx6q SoCs. Ah, and I hope we don't need to argue here as Russell doesn't like the new DEBUG_LL changes :-)

I have no problem with the Kconfig menu approach or existing approaches to DEBUG_LL. What I have an objection to is trying to stuff the information for it into places which ultimately render the facility useless for its intended purpose - to permit debugging the _really_ _early_ assembly code.

That is what it was written for: if we introduce complicated ways to put behind it, we'll need to come up with a completely new debugging infrastructure to debug the now buggered debugging infrastructure.

And then people will want to do the same to the debug debugging infrastructure. Then we'll have to invent the debug debugging debugging infrastructure. Repeat until you've nested it a million times.

It's supposed to be _simple_ and _obviously_ correct so that it _works_ with minimal fuss. Making it complicated by picking out information from device trees will kill that, and at that point its not worth keeping around anymore.

Let me give you an instance: your kernel doesn't boot. Early printk doesn't work. You want to find out if control is even getting to the very first instruction in head.S. You can do that with DEBUG_LL as it stands today because we know exactly where the serial port is supposed to be.

If you have to pick the DEBUG_LL information out of a DT, you can no longer do that - you first have to obtain the pointer to DT, and then parse the DT table to find out where the hell the port is. What if the reason your kernel isn't booting is because the DT pointer is wrong? What if the reason your kernel isn't booting is because the information contained within DT is wrong?

How do you debug that? You probably end up having to write your own debugging infrastructure using a fixed address for the port. Congratulations - you just reinvented what DEBUG_LL was designed to be doing before someone came along and totally buggered it up.

The fact that DEBUG_LL is hard-coded to a certain port address is one of its strongest points. It means that if you know that the port address is correct (which is a matter of looking at the SoCs data sheets and confirming that the hex digits match) then you can be reasonably sure that you're going to get some output from it. No need to wonder "Is the DT pointer correct? Are we parsing DT properly?" etc.

So, either we keep it in its current form or we throw it out from mainline entirely and I keep it as a separate add-on patch for those who want to use it.

#11 lore raw

PATCH 2/6 arm/imx6q: add core definitions and low-level debug uart

Quoted 11 lines · Russell King - ARM Linux
Quoted 3 lines · Uwe Kleine-K?nig

But only if the image doesn't support imx6q, right? Anyhow, I hope imx6q_map_io isn't called for pre-imx6q SoCs. Ah, and I hope we don't need to argue here as Russell doesn't like the new DEBUG_LL changes :-)

I have no problem with the Kconfig menu approach or existing approaches to DEBUG_LL. What I have an objection to is trying to stuff the information for it into places which ultimately render the facility useless for its intended purpose - to permit debugging the _really_ _early_ assembly code.

Quoted 3 lines

That is what it was written for: if we introduce complicated ways to put behind it, we'll need to come up with a completely new debugging infrastructure to debug the now buggered debugging infrastructure.

For the record I now agree with Russell.

In order to have early serial output that works across multiple SOCs in the same kernel image intended to non developers we'll have to add a parallel infrastructure. Keeping the DEBUG_LL code as simple as possible for developers is the way to go (and that might be needed to debug that parallel infrastructure).

Nicolas

#12 lore raw

PATCH 2/6 arm/imx6q: add core definitions and low-level debug uart

Quoted 17 lines · Nicolas Pitre
Quoted 11 lines · Russell King - ARM Linux
Quoted 3 lines · Uwe Kleine-K?nig

But only if the image doesn't support imx6q, right? Anyhow, I hope imx6q_map_io isn't called for pre-imx6q SoCs. Ah, and I hope we don't need to argue here as Russell doesn't like the new DEBUG_LL changes :-)

I have no problem with the Kconfig menu approach or existing approaches to DEBUG_LL. What I have an objection to is trying to stuff the information for it into places which ultimately render the facility useless for its intended purpose - to permit debugging the really early assembly code.

Quoted 3 lines

That is what it was written for: if we introduce complicated ways to put behind it, we'll need to come up with a completely new debugging infrastructure to debug the now buggered debugging infrastructure.

Quoted 7 lines

For the record I now agree with Russell.

In order to have early serial output that works across multiple SOCs in the same kernel image intended to non developers we'll have to add a parallel infrastructure. Keeping the DEBUG_LL code as simple as possible for developers is the way to go (and that might be needed to debug that parallel infrastructure).

Yes, agreed. It should not be too hard to provide more CON_BOOT consoles. For 8250, this can actually be done already using the code from drivers/tty/serial/8250_early.c with a custom command line, but there are better ways to do that in a generic way.

Arnd

#13 lore raw

PATCH 2/6 arm/imx6q: add core definitions and low-level debug uart

Quoted 26 lines · Arnd Bergmann
Quoted 17 lines · Nicolas Pitre
Quoted 11 lines · Russell King - ARM Linux
Quoted 3 lines · Uwe Kleine-K?nig

But only if the image doesn't support imx6q, right? Anyhow, I hope imx6q_map_io isn't called for pre-imx6q SoCs. Ah, and I hope we don't need to argue here as Russell doesn't like the new DEBUG_LL changes :-)

I have no problem with the Kconfig menu approach or existing approaches to DEBUG_LL. What I have an objection to is trying to stuff the information for it into places which ultimately render the facility useless for its intended purpose - to permit debugging the really early assembly code.

Quoted 3 lines

That is what it was written for: if we introduce complicated ways to put behind it, we'll need to come up with a completely new debugging infrastructure to debug the now buggered debugging infrastructure.

Quoted 7 lines

For the record I now agree with Russell.

In order to have early serial output that works across multiple SOCs in the same kernel image intended to non developers we'll have to add a parallel infrastructure. Keeping the DEBUG_LL code as simple as possible for developers is the way to go (and that might be needed to debug that parallel infrastructure).

Quoted 4 lines

Yes, agreed. It should not be too hard to provide more CON_BOOT consoles. For 8250, this can actually be done already using the code from drivers/tty/serial/8250_early.c with a custom command line, but there are better ways to do that in a generic way.

Sounds good to me.

Regards,

Tony

#14 lore raw

PATCH 2/6 arm/imx6q: add core definitions and low-level debug uart

In reply to Uwe Kleine-König
Quoted 3 lines · Uwe Kleine-K?nig
Quoted 2 lines · Shawn Guo
Quoted 1 line · Uwe Kleine-K?nig

On Tue, Sep 06, 2011 at 05:58:36PM +0800, Shawn Guo wrote:

[...]

Quoted 72 lines
Quoted 36 lines
Quoted 36 lines
Quoted 23 lines
arch/arm/plat-mxc/include/mach/mx6q.h new file +17 -0
new file mode 100644
index 0000000..7432310
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2011 Freescale Semiconductor, Inc. All Rights Reserved.
+ * Copyright 2011 Linaro Ltd.
+ *
+ * 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_MX6Q_H__
+#define __MACH_MX6Q_H__
+
+/* static mappings */
+#define IMX6Q_VA(x)		(0xf4000000 + (x))

arch/arm/plat-mxc/include/mach/mx6q.h line 27

Quoted 10 lines
arch/arm/plat-mxc/include/mach/mx6q.h new file +10 -0
+
+#define MX6Q_SCU_BASE_ADDR	0x00a00000
+#define MX6Q_CCM_BASE_ADDR	0x020c4000
+#define MX6Q_ANATOP_BASE_ADDR	0x020c8000
+#define MX6Q_UART4_BASE_ADDR	0x021f0000
+
+#define MX6Q_SCU_BASE_VADDR	IMX6Q_VA(MX6Q_SCU_BASE_ADDR)
+#define MX6Q_CCM_BASE_VADDR	IMX6Q_VA(MX6Q_CCM_BASE_ADDR)
+#define MX6Q_ANATOP_BASE_VADDR	IMX6Q_VA(MX6Q_ANATOP_BASE_ADDR)
+#define MX6Q_UART4_BASE_VADDR	IMX6Q_VA(MX6Q_UART4_BASE_ADDR)

Depending on the sizes of these memory regions you can use the existing IMX_IO_P2V here. The conditions are:

Quoted 1 line
Quoted 1 line
	SCU_SIZE <= 0x200000

Actually this should be 0x100000 as this is the size that is mapped in a continous chunk.

Quoted 6 lines
Quoted 4 lines
	CCM_SIZE <= 0x4000
	ANATOP_SIZE <= 0x28000
	UART4 <= 0x100000

This is exactly what I dislike about IMX_IO_P2V(). We have to verify all these conditions manually. Looking at the static mapping below

I did it semi-manual, I just put your constants for imx6q into my script (all with size=0x4000 for now) and it told me:

...
* mx6q:
* SCU 0x00a00000+0x004000 -> 0xf4000000+0x004000
* CCM 0x020c4000+0x004000 -> 0xf42c4000+0x004000
* ANATOP 0x020c8000+0x004000 -> 0xf42c8000+0x004000
* UART4 0x021f0000+0x004000 -> 0xf42f0000+0x004000
...

Quoted 2 lines

(copied from arch/arm/plat-mxc/include/mach/hardware.h), do you think it's really scalable and easy to maintain for the long run?

At least it provides a way to verify the correctness of the mapping. Before I introduced the mapping function there was a conflict IIRC.

Quoted 10 lines

/*
* This is rather complicated for humans and ugly to verify, but for a machine
* it's OK. Still more as it is usually only applied to constants. The upsides
* on using this approach are:
*

 *  - same mapping on all i.MX machines
 *  - works for assembler, too
 *  - no need to nurture #defines for virtual addresses

*
* The downside it, it's hard to verify (but I have a script for that).

Quoted 2 lines

If you want I can provide you that script.

Yes, please. I would use IMX_IO_P2V() in the next post.

[...]

Quoted 6 lines
Quoted 6 lines
#define IMX_IO_P2V(x)	(						\
			0xf4000000 +					\
			(((x) & 0x50000000) >> 6) +			\
			(((x) & 0x0b000000) >> 4) +			\
			(((x) & 0x000fffff)))
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

hmm, looking at patch 4 SCU_BASE is determined by a coprocessor instruction?!

Ah, yes. The SCU physical base address can be retrieved from coprocessor.

Is there an advantage in autodetecting the base address?

Any disadvantage for doing so?

Signature · 2 lines
Regards,
Shawn
#15 lore raw

PATCH 2/6 arm/imx6q: add core definitions and low-level debug uart

Hello Shawn,

Quoted 79 lines · Shawn Guo
Quoted 3 lines · Uwe Kleine-K?nig
Quoted 2 lines · Shawn Guo
Quoted 1 line · Uwe Kleine-K?nig

On Tue, Sep 06, 2011 at 05:58:36PM +0800, Shawn Guo wrote:

[...]

Quoted 72 lines
Quoted 36 lines
Quoted 36 lines
Quoted 23 lines
arch/arm/plat-mxc/include/mach/mx6q.h new file +17 -0
new file mode 100644
index 0000000..7432310
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2011 Freescale Semiconductor, Inc. All Rights Reserved.
+ * Copyright 2011 Linaro Ltd.
+ *
+ * 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_MX6Q_H__
+#define __MACH_MX6Q_H__
+
+/* static mappings */
+#define IMX6Q_VA(x)		(0xf4000000 + (x))

arch/arm/plat-mxc/include/mach/mx6q.h line 27

Quoted 10 lines
arch/arm/plat-mxc/include/mach/mx6q.h new file +10 -0
+
+#define MX6Q_SCU_BASE_ADDR	0x00a00000
+#define MX6Q_CCM_BASE_ADDR	0x020c4000
+#define MX6Q_ANATOP_BASE_ADDR	0x020c8000
+#define MX6Q_UART4_BASE_ADDR	0x021f0000
+
+#define MX6Q_SCU_BASE_VADDR	IMX6Q_VA(MX6Q_SCU_BASE_ADDR)
+#define MX6Q_CCM_BASE_VADDR	IMX6Q_VA(MX6Q_CCM_BASE_ADDR)
+#define MX6Q_ANATOP_BASE_VADDR	IMX6Q_VA(MX6Q_ANATOP_BASE_ADDR)
+#define MX6Q_UART4_BASE_VADDR	IMX6Q_VA(MX6Q_UART4_BASE_ADDR)

Depending on the sizes of these memory regions you can use the existing IMX_IO_P2V here. The conditions are:

Quoted 1 line
Quoted 1 line
	SCU_SIZE <= 0x200000

Actually this should be 0x100000 as this is the size that is mapped in a continous chunk.

Quoted 6 lines
Quoted 4 lines
	CCM_SIZE <= 0x4000
	ANATOP_SIZE <= 0x28000
	UART4 <= 0x100000

This is exactly what I dislike about IMX_IO_P2V(). We have to verify all these conditions manually. Looking at the static mapping below

I did it semi-manual, I just put your constants for imx6q into my script (all with size=0x4000 for now) and it told me:

...
* mx6q:
* SCU 0x00a00000+0x004000 -> 0xf4000000+0x004000
* CCM 0x020c4000+0x004000 -> 0xf42c4000+0x004000
* ANATOP 0x020c8000+0x004000 -> 0xf42c8000+0x004000
* UART4 0x021f0000+0x004000 -> 0xf42f0000+0x004000
...

Quoted 2 lines

(copied from arch/arm/plat-mxc/include/mach/hardware.h), do you think it's really scalable and easy to maintain for the long run?

At least it provides a way to verify the correctness of the mapping. Before I introduced the mapping function there was a conflict IIRC.

Quoted 10 lines

/*
* This is rather complicated for humans and ugly to verify, but for a machine
* it's OK. Still more as it is usually only applied to constants. The upsides
* on using this approach are:
*

 *  - same mapping on all i.MX machines
 *  - works for assembler, too
 *  - no need to nurture #defines for virtual addresses

*
* The downside it, it's hard to verify (but I have a script for that).

Quoted 3 lines
Quoted 2 lines

If you want I can provide you that script.

Yes, please. I would use IMX_IO_P2V() in the next post.

I just found a bug in the conflict detection code, so I put it in a repository to prevent the broken script to enter the archives. You can find it on

git://git.pengutronix.de/git/ukl/imx-iop2v.git

Quoted 8 lines

[...]

Quoted 6 lines
Quoted 6 lines
#define IMX_IO_P2V(x)	(						\
			0xf4000000 +					\
			(((x) & 0x50000000) >> 6) +			\
			(((x) & 0x0b000000) >> 4) +			\
			(((x) & 0x000fffff)))
Quoted 8 lines
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

hmm, looking at patch 4 SCU_BASE is determined by a coprocessor instruction?!

Ah, yes. The SCU physical base address can be retrieved from coprocessor.

Is there an advantage in autodetecting the base address?

Any disadvantage for doing so?

It makes

	#define MX6Q_SCU_BASE_ADDR       0x00a00000

superfluous. And in case the real address is different it might make

	IMX_IO_P2V(real scu address) != scu_io_desc.virtual

which makes the scriptable check for conflicts kind of useless and might come as a surprise.

Best regards
Uwe

Signature · 2 lines
Pengutronix e.K.                           | Uwe Kleine-K?nig            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
#16 lore raw

PATCH 2/6 arm/imx6q: add core definitions and low-level debug uart

Quoted 82 lines · Uwe Kleine-K?nig

Hello Shawn,

Quoted 79 lines · Shawn Guo
Quoted 3 lines · Uwe Kleine-K?nig
Quoted 2 lines · Shawn Guo
Quoted 1 line · Uwe Kleine-K?nig

On Tue, Sep 06, 2011 at 05:58:36PM +0800, Shawn Guo wrote:

[...]

Quoted 72 lines
Quoted 36 lines
Quoted 36 lines
Quoted 23 lines
arch/arm/plat-mxc/include/mach/mx6q.h new file +17 -0
new file mode 100644
index 0000000..7432310
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2011 Freescale Semiconductor, Inc. All Rights Reserved.
+ * Copyright 2011 Linaro Ltd.
+ *
+ * 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_MX6Q_H__
+#define __MACH_MX6Q_H__
+
+/* static mappings */
+#define IMX6Q_VA(x)		(0xf4000000 + (x))

arch/arm/plat-mxc/include/mach/mx6q.h line 27

Quoted 10 lines
arch/arm/plat-mxc/include/mach/mx6q.h new file +10 -0
+
+#define MX6Q_SCU_BASE_ADDR	0x00a00000
+#define MX6Q_CCM_BASE_ADDR	0x020c4000
+#define MX6Q_ANATOP_BASE_ADDR	0x020c8000
+#define MX6Q_UART4_BASE_ADDR	0x021f0000
+
+#define MX6Q_SCU_BASE_VADDR	IMX6Q_VA(MX6Q_SCU_BASE_ADDR)
+#define MX6Q_CCM_BASE_VADDR	IMX6Q_VA(MX6Q_CCM_BASE_ADDR)
+#define MX6Q_ANATOP_BASE_VADDR	IMX6Q_VA(MX6Q_ANATOP_BASE_ADDR)
+#define MX6Q_UART4_BASE_VADDR	IMX6Q_VA(MX6Q_UART4_BASE_ADDR)

Depending on the sizes of these memory regions you can use the existing IMX_IO_P2V here. The conditions are:

Quoted 1 line
Quoted 1 line
	SCU_SIZE <= 0x200000

Actually this should be 0x100000 as this is the size that is mapped in a continous chunk.

Quoted 6 lines
Quoted 4 lines
	CCM_SIZE <= 0x4000
	ANATOP_SIZE <= 0x28000
	UART4 <= 0x100000

This is exactly what I dislike about IMX_IO_P2V(). We have to verify all these conditions manually. Looking at the static mapping below

I did it semi-manual, I just put your constants for imx6q into my script (all with size=0x4000 for now) and it told me:

...
* mx6q:
* SCU 0x00a00000+0x004000 -> 0xf4000000+0x004000
* CCM 0x020c4000+0x004000 -> 0xf42c4000+0x004000
* ANATOP 0x020c8000+0x004000 -> 0xf42c8000+0x004000
* UART4 0x021f0000+0x004000 -> 0xf42f0000+0x004000
...

Quoted 2 lines

(copied from arch/arm/plat-mxc/include/mach/hardware.h), do you think it's really scalable and easy to maintain for the long run?

At least it provides a way to verify the correctness of the mapping. Before I introduced the mapping function there was a conflict IIRC.

Quoted 10 lines

/*
* This is rather complicated for humans and ugly to verify, but for a machine
* it's OK. Still more as it is usually only applied to constants. The upsides
* on using this approach are:
*

 *  - same mapping on all i.MX machines
 *  - works for assembler, too
 *  - no need to nurture #defines for virtual addresses

*
* The downside it, it's hard to verify (but I have a script for that).

Quoted 9 lines
Quoted 3 lines
Quoted 2 lines

If you want I can provide you that script.

Yes, please. I would use IMX_IO_P2V() in the next post.

I just found a bug in the conflict detection code, so I put it in a repository to prevent the broken script to enter the archives. You can find it on

git://git.pengutronix.de/git/ukl/imx-iop2v.git

Thanks, Uwe.

Quoted 13 lines
Quoted 13 lines

[...]

Quoted 11 lines
Quoted 11 lines
#define IMX_IO_P2V(x)	(						\
			0xf4000000 +					\
			(((x) & 0x50000000) >> 6) +			\
			(((x) & 0x0b000000) >> 4) +			\
			(((x) & 0x000fffff)))
Quoted 2 lines

hmm, looking at patch 4 SCU_BASE is determined by a coprocessor instruction?!

Ah, yes. The SCU physical base address can be retrieved from coprocessor.

Quoted 8 lines
Quoted 3 lines
Quoted 2 lines

Is there an advantage in autodetecting the base address?

Any disadvantage for doing so?

It makes

	#define MX6Q_SCU_BASE_ADDR       0x00a00000

superfluous.

The definition is actually not needed. I put it there as a documentation telling SCU is statically mapped.

Quoted 4 lines

And in case the real address is different it might make

	IMX_IO_P2V(real scu address) != scu_io_desc.virtual

This should never happen.

One thing I'm trying to do is to keep arch/arm/mach-imx/platsmp.c not specific to imx6q. The auto-detecting helps to keep MX6Q_SCU_BASE_ADDR away from the file, so that one day when we have another imx smp soc, we can simply reuse the file.

Regards,
Shawn

Quoted 3 lines

which makes the scriptable check for conflicts kind of useless and might come as a surprise.

maintainer
#17 lore raw

PATCH 2/6 arm/imx6q: add core definitions and low-level debug uart

In reply to Shawn Guo
Quoted 107 lines · Shawn Guo
Quoted 97 lines · Uwe Kleine-K?nig
Quoted 96 lines · Shawn Guo

It adds the core definitions and low-level debug uart support for imx6q.

---
 arch/arm/Kconfig                             |    2 +-
 arch/arm/Kconfig.debug                       |    7 +++++
 arch/arm/Makefile                            |    1 +
 arch/arm/mach-imx/Kconfig                    |    4 +++
 arch/arm/mach-imx/Makefile                   |    2 +
 arch/arm/mach-imx/Makefile.boot              |    4 +++
 arch/arm/mach-imx/lluart.c                   |   33 ++++++++++++++++++++++++++
 arch/arm/plat-mxc/Kconfig                    |    5 ++++
 arch/arm/plat-mxc/include/mach/debug-macro.S |    5 ++++
 arch/arm/plat-mxc/include/mach/entry-macro.S |   15 +++++++++++-
 arch/arm/plat-mxc/include/mach/hardware.h    |    1 +
 arch/arm/plat-mxc/include/mach/irqs.h        |    9 ++++--
 arch/arm/plat-mxc/include/mach/memory.h      |    3 ++
 arch/arm/plat-mxc/include/mach/mx6q.h        |   29 ++++++++++++++++++++++
 14 files changed, 115 insertions(+), 5 deletions(-)
 create mode 100644 arch/arm/mach-imx/lluart.c
 create mode 100644 arch/arm/plat-mxc/include/mach/mx6q.h
arch/arm/Kconfig +1 -1
index 4ea9974..37c20a4 100644
@@ -1348,7 +1348,7 @@ config SMP
 	depends on REALVIEW_EB_ARM11MP || REALVIEW_EB_A9MP || \
 		 MACH_REALVIEW_PB11MP || MACH_REALVIEW_PBX || ARCH_OMAP4 || \
 		 ARCH_EXYNOS4 || ARCH_TEGRA || ARCH_U8500 || ARCH_VEXPRESS_CA9X4 || \
-		 ARCH_MSM_SCORPIONMP || ARCH_SHMOBILE
+		 ARCH_MSM_SCORPIONMP || ARCH_SHMOBILE || SOC_IMX6Q
 	select USE_GENERIC_SMP_HELPERS
 	select HAVE_ARM_SCU if !ARCH_MSM_SCORPIONMP
 	help
arch/arm/Kconfig.debug +7 -0
index 965d59a..68fc155 100644
@@ -155,6 +155,13 @@ choice
 		  Say Y here if you want kernel low-level debugging support
 		  on i.MX50 or i.MX53.
 
+	config DEBUG_IMX6Q_UART
+		bool "i.MX6Q Debug UART"
+		depends on SOC_IMX6Q
+		help
+		  Say Y here if you want kernel low-level debugging support
+		  on i.MX6Q.
+
 	config DEBUG_S3C_UART0
 		depends on PLAT_SAMSUNG
 		bool "Use S3C UART 0 for low-level debug"
arch/arm/Makefile +1 -0
index 70c424e..3a0bbe4 100644
@@ -159,6 +159,7 @@ machine-$(CONFIG_ARCH_MX2)		:= imx
 machine-$(CONFIG_ARCH_MX25)		:= imx
 machine-$(CONFIG_ARCH_MX3)		:= imx
 machine-$(CONFIG_ARCH_MX5)		:= mx5
+machine-$(CONFIG_ARCH_MX6)		:= imx
 machine-$(CONFIG_ARCH_MXS)		:= mxs
 machine-$(CONFIG_ARCH_NETX)		:= netx
 machine-$(CONFIG_ARCH_NOMADIK)		:= nomadik
arch/arm/mach-imx/Kconfig +4 -0
index 0519dd7..4cf5178 100644
@@ -58,6 +58,10 @@ config SOC_IMX35
 	select ARCH_MX35
 	select MXC_AVIC
 
+config SOC_IMX6Q
+	bool
+	select ARM_GIC
+	select CPU_V7
 
 if ARCH_MX1
 
arch/arm/mach-imx/Makefile +2 -0
index e9eb36d..96ecc96 100644
@@ -61,3 +61,5 @@ obj-$(CONFIG_MACH_MX35_3DS) += mach-mx35_3ds.o
 obj-$(CONFIG_MACH_EUKREA_CPUIMX35) += mach-cpuimx35.o
 obj-$(CONFIG_MACH_EUKREA_MBIMXSD35_BASEBOARD) += eukrea_mbimxsd35-baseboard.o
 obj-$(CONFIG_MACH_VPR200) += mach-vpr200.o
+
+obj-$(CONFIG_DEBUG_LL) += lluart.o
arch/arm/mach-imx/Makefile.boot +0 -0
index ebee18b..389a0e3 100644
@@ -17,3 +17,7 @@ initrd_phys-$(CONFIG_MACH_MX27)	:= 0xA0800000
Quoted 9 lines

arch/arm/mach-imx/Makefile.boot initrd_phys-$(CONFIG_MACH_MX27) := 0xA0800000 · line 23

Quoted 7 lines
arch/arm/mach-imx/Makefile.boot +4 -0
 zreladdr-$(CONFIG_ARCH_MX3)	:= 0x80008000
 params_phys-$(CONFIG_ARCH_MX3)	:= 0x80000100
 initrd_phys-$(CONFIG_ARCH_MX3)	:= 0x80800000
+
+zreladdr-$(CONFIG_SOC_IMX6Q)	:= 0x10008000
+params_phys-$(CONFIG_SOC_IMX6Q)	:= 0x10000100
+initrd_phys-$(CONFIG_SOC_IMX6Q)	:= 0x10800000

Do you really need params_phys and initrd_phys?

Quoted 2 lines

I added them to make IMX6Q look consistent with other soc in the file, and leave it to a global cleanup, if we decide to clean later.

I vote to skip params_phys and initrd_phys now. Every recent bootloader does not need them. As the i.MX6 is a new SoC, we have no reason to handle legacy bootloaders. When we want to to a global cleanup for these variables we already know that i.MX6 has no legacy bootloader problems.

BTW many variables have the name imx6q, I suppose the 'q' is for quad cpu. From the FSL website I know that there are other versions of the i.MX6 planned. Are these variables really imx6q specific? Otherwise please skip the 'q'.

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

PATCH 2/6 arm/imx6q: add core definitions and low-level debug uart

Quoted 108 lines · Sascha Hauer
Quoted 107 lines · Shawn Guo
Quoted 106 lines · Uwe Kleine-K?nig
Quoted 96 lines · Shawn Guo

It adds the core definitions and low-level debug uart support for imx6q.

---
 arch/arm/Kconfig                             |    2 +-
 arch/arm/Kconfig.debug                       |    7 +++++
 arch/arm/Makefile                            |    1 +
 arch/arm/mach-imx/Kconfig                    |    4 +++
 arch/arm/mach-imx/Makefile                   |    2 +
 arch/arm/mach-imx/Makefile.boot              |    4 +++
 arch/arm/mach-imx/lluart.c                   |   33 ++++++++++++++++++++++++++
 arch/arm/plat-mxc/Kconfig                    |    5 ++++
 arch/arm/plat-mxc/include/mach/debug-macro.S |    5 ++++
 arch/arm/plat-mxc/include/mach/entry-macro.S |   15 +++++++++++-
 arch/arm/plat-mxc/include/mach/hardware.h    |    1 +
 arch/arm/plat-mxc/include/mach/irqs.h        |    9 ++++--
 arch/arm/plat-mxc/include/mach/memory.h      |    3 ++
 arch/arm/plat-mxc/include/mach/mx6q.h        |   29 ++++++++++++++++++++++
 14 files changed, 115 insertions(+), 5 deletions(-)
 create mode 100644 arch/arm/mach-imx/lluart.c
 create mode 100644 arch/arm/plat-mxc/include/mach/mx6q.h
arch/arm/Kconfig +1 -1
index 4ea9974..37c20a4 100644
@@ -1348,7 +1348,7 @@ config SMP
 	depends on REALVIEW_EB_ARM11MP || REALVIEW_EB_A9MP || \
 		 MACH_REALVIEW_PB11MP || MACH_REALVIEW_PBX || ARCH_OMAP4 || \
 		 ARCH_EXYNOS4 || ARCH_TEGRA || ARCH_U8500 || ARCH_VEXPRESS_CA9X4 || \
-		 ARCH_MSM_SCORPIONMP || ARCH_SHMOBILE
+		 ARCH_MSM_SCORPIONMP || ARCH_SHMOBILE || SOC_IMX6Q
 	select USE_GENERIC_SMP_HELPERS
 	select HAVE_ARM_SCU if !ARCH_MSM_SCORPIONMP
 	help
arch/arm/Kconfig.debug +7 -0
index 965d59a..68fc155 100644
@@ -155,6 +155,13 @@ choice
 		  Say Y here if you want kernel low-level debugging support
 		  on i.MX50 or i.MX53.
 
+	config DEBUG_IMX6Q_UART
+		bool "i.MX6Q Debug UART"
+		depends on SOC_IMX6Q
+		help
+		  Say Y here if you want kernel low-level debugging support
+		  on i.MX6Q.
+
 	config DEBUG_S3C_UART0
 		depends on PLAT_SAMSUNG
 		bool "Use S3C UART 0 for low-level debug"
arch/arm/Makefile +1 -0
index 70c424e..3a0bbe4 100644
@@ -159,6 +159,7 @@ machine-$(CONFIG_ARCH_MX2)		:= imx
 machine-$(CONFIG_ARCH_MX25)		:= imx
 machine-$(CONFIG_ARCH_MX3)		:= imx
 machine-$(CONFIG_ARCH_MX5)		:= mx5
+machine-$(CONFIG_ARCH_MX6)		:= imx
 machine-$(CONFIG_ARCH_MXS)		:= mxs
 machine-$(CONFIG_ARCH_NETX)		:= netx
 machine-$(CONFIG_ARCH_NOMADIK)		:= nomadik
arch/arm/mach-imx/Kconfig +4 -0
index 0519dd7..4cf5178 100644
@@ -58,6 +58,10 @@ config SOC_IMX35
 	select ARCH_MX35
 	select MXC_AVIC
 
+config SOC_IMX6Q
+	bool
+	select ARM_GIC
+	select CPU_V7
 
 if ARCH_MX1
 
arch/arm/mach-imx/Makefile +2 -0
index e9eb36d..96ecc96 100644
@@ -61,3 +61,5 @@ obj-$(CONFIG_MACH_MX35_3DS) += mach-mx35_3ds.o
 obj-$(CONFIG_MACH_EUKREA_CPUIMX35) += mach-cpuimx35.o
 obj-$(CONFIG_MACH_EUKREA_MBIMXSD35_BASEBOARD) += eukrea_mbimxsd35-baseboard.o
 obj-$(CONFIG_MACH_VPR200) += mach-vpr200.o
+
+obj-$(CONFIG_DEBUG_LL) += lluart.o
arch/arm/mach-imx/Makefile.boot +0 -0
index ebee18b..389a0e3 100644

arch/arm/mach-imx/Makefile.boot initrd_phys-$(CONFIG_MACH_MX27) := 0xA0800000 · line 23

Quoted 7 lines
arch/arm/mach-imx/Makefile.boot +4 -0
@@ -17,3 +17,7 @@ initrd_phys-$(CONFIG_MACH_MX27)	:= 0xA0800000
 zreladdr-$(CONFIG_ARCH_MX3)	:= 0x80008000
 params_phys-$(CONFIG_ARCH_MX3)	:= 0x80000100
 initrd_phys-$(CONFIG_ARCH_MX3)	:= 0x80800000
+
+zreladdr-$(CONFIG_SOC_IMX6Q)	:= 0x10008000
+params_phys-$(CONFIG_SOC_IMX6Q)	:= 0x10000100
+initrd_phys-$(CONFIG_SOC_IMX6Q)	:= 0x10800000

Do you really need params_phys and initrd_phys?

Quoted 8 lines
Quoted 2 lines

I added them to make IMX6Q look consistent with other soc in the file, and leave it to a global cleanup, if we decide to clean later.

I vote to skip params_phys and initrd_phys now. Every recent bootloader does not need them. As the i.MX6 is a new SoC, we have no reason to handle legacy bootloaders. When we want to to a global cleanup for these variables we already know that i.MX6 has no legacy bootloader problems.

Ok.

Quoted 5 lines

BTW many variables have the name imx6q, I suppose the 'q' is for quad cpu. From the FSL website I know that there are other versions of the i.MX6 planned. Are these variables really imx6q specific? Otherwise please skip the 'q'.

Before other imx6 family SoCs come to world, we really do not know what are imx6q specific and what are not.

Signature · 2 lines
Regards,
Shawn
#19 lore raw

PATCH 2/6 arm/imx6q: add core definitions and low-level debug uart

In reply to Sascha Hauer
Quoted 3 lines · Sascha Hauer

I vote to skip params_phys and initrd_phys now. Every recent bootloader does not need them. As the i.MX6 is a new SoC, we have no reason to handle legacy bootloaders.

Can we stop this misunderstanding right now.

It's NOT about legacy boot loaders. It's about the bootp code which allows an initrd to be packaged up together with a zImage file as one single file.

That's used to be able to boot with an initrd on platforms which can only obtain one file from the boot media, and they specify where the parameters are expected to be (which can be solved by updating the code to use r2) and where to place the initrd image (which can't be solved as it would mean encoding memory information for every platform into the bootp code.)

An example of a current boot loader which requires this: Simtec's Able boot loader.

#20 lore raw

PATCH 2/6 arm/imx6q: add core definitions and low-level debug uart

Quoted 18 lines · Russell King - ARM Linux
Quoted 3 lines · Sascha Hauer

I vote to skip params_phys and initrd_phys now. Every recent bootloader does not need them. As the i.MX6 is a new SoC, we have no reason to handle legacy bootloaders.

Can we stop this misunderstanding right now.

It's NOT about legacy boot loaders. It's about the bootp code which allows an initrd to be packaged up together with a zImage file as one single file.

That's used to be able to boot with an initrd on platforms which can only obtain one file from the boot media, and they specify where the parameters are expected to be (which can be solved by updating the code to use r2) and where to place the initrd image (which can't be solved as it would mean encoding memory information for every platform into the bootp code.)

Quoted 2 lines

An example of a current boot loader which requires this: Simtec's Able boot loader.

Here's a patch to reduce the reliance of arch/arm/boot/bootp on having a correct initrd image location passed from the platform Makefile.boot. It doesn't get rid of it, as it's required if the platform does not pass a valid value in r2 to the kernel.

Note - I have a new code for a platform (of the nommu variety) which requires this to be able to boot. Also note that we're probably going to have to find a way to make this work with DT too (if not then I may be submitting this platform without DT any support.)

---
 arch/arm/boot/bootp/init.S |   34 ++++++++++++++++++++++++++++++----
 1 file changed, 30 insertions(+), 4 deletions(-)
arch/arm/boot/bootp/init.S +30 -4
index 78b5080..d1cb5a9 100644
@@ -16,6 +16,14 @@
  *  size immediately following the kernel, we could build this into
  *  a binary blob, and concatenate the zImage using the cat command.
  */
+
+#define ATAG_CORE 0x54410001
+#define ATAG_CORE_SIZE ((2*4 + 3*4) >> 2)
+#define ATAG_CORE_SIZE_EMPTY ((2*4) >> 2)
+
+#define ATAG_INITRD2 0x54420005
+#define ATAG_INITRD2_SIZE ((4*4) >> 2)
+
 		.section .start,#alloc,#execinstr
 		.type	_start, #function
 		.globl	_start
@@ -37,13 +45,31 @@ _start:		add	lr, pc, #-0x8		@ lr = current load addr
 						@ r8 = initrd end
 						@ r9 = param_struct address
 
+/*
+ * Check whether we were given a valid ATAG list from the boot loader.
+ * If it looks like a valid pointer, then use that rather than the
+ * hard-coded value.
+ */
+		tst	r2, #3			@ aligned
+		bne	1f
+		ldr	r10, [r2, #0]		@ get first tag size
+		teq	r10, #ATAG_CORE_SIZE
+		teqne	r10, #ATAG_CORE_SIZE_EMPTY
+		bne	1f
+		ldr	r10, [r2, #4]		@ get first tag type
+		teq	r10, r5			@ is it ATAG_CORE?
+		bne	1f
+		mov	r9, r2
+		b	taglist
+
+1:		mov	r2, r9			@ params for the kernel
 		ldr	r10, [r9, #4]		@ get first tag
 		teq	r10, r5			@ is it ATAG_CORE?
 /*
  * If we didn't find a valid tag list, create a dummy ATAG_CORE entry.
  */
 		movne	r10, #0			@ terminator
-		movne	r4, #2			@ Size of this entry (2 words)
+		movne	r4, #ATAG_CORE_SIZE_EMPTY @ Size of this entry (2 words)
 		stmneia	r9, {r4, r5, r10}	@ Size, ATAG_CORE, terminator
 
 /*
@@ -56,7 +82,7 @@ taglist:	ldr	r10, [r9, #0]		@ tag length
 		addne	r9, r9, r10, lsl #2
 		bne	taglist
 
-		mov	r5, #4			@ Size of initrd tag (4 words)
+		mov	r5, #ATAG_INITRD2_SIZE	@ Size of initrd tag (4 words)
 		stmia	r9, {r5, r6, r7, r8, r10}
 		b	kernel_start		@ call kernel
 
@@ -80,8 +106,8 @@ data:		.word	initrd_start		@ source initrd address
 		.word	initrd_phys		@ destination initrd address
 		.word	initrd_size		@ initrd size
 
-		.word	0x54410001		@ r5 = ATAG_CORE
-		.word	0x54420005		@ r6 = ATAG_INITRD2
+		.word	ATAG_CORE		@ r5
+		.word	ATAG_INITRD2		@ r6
 		.word	initrd_phys		@ r7
 		.word	initrd_size		@ r8
 		.word	params_phys		@ r9
#21 lore raw

PATCH 2/6 arm/imx6q: add core definitions and low-level debug uart

In reply to Uwe Kleine-König

Hi Uwe,

Quoted 1 line · Uwe Kleine-K?nig

On Tue, Sep 06, 2011 at 05:58:36PM +0800, Shawn Guo wrote:

[...]

Quoted 16 lines
Quoted 16 lines
arch/arm/plat-mxc/include/mach/entry-macro.S +1 -1
index 066d464..341f800 100644
@@ -1,6 +1,6 @@
 /*
  *  Copyright (C) 2007 Lennert Buytenhek <[email protected]>
- *  Copyright 2004-2009 Freescale Semiconductor, Inc. All Rights Reserved.
+ *  Copyright 2004-2011 Freescale Semiconductor, Inc. All Rights Reserved.
  */
 
 /*
@@ -11,6 +11,17 @@
 
 #include <mach/hardware.h>
 
Quoted 14 lines

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

Quoted 11 lines
arch/arm/plat-mxc/include/mach/entry-macro.S +11 -0
+#ifdef CONFIG_ARM_GIC
+#include <asm/hardware/entry-macro-gic.S>
+
+	.macro	disable_fiq
+	.endm
+
+	.macro	arch_ret_to_user, tmp1, tmp2
+	.endm
+
+#else
+

hmm, this essentially means mx6 support cannot go into a kernel image for the other imx machines :-(

I thought you gave this comment because imx6q change breaks the existing support for single image. But looking at the code a little bit closer, I found that even the coexisting of AVIC and TZIC have not been supported. That said imx6q change did not make the situation any worse, and we should come up with a solution later than this series to build AVIC, TZIC and GIC in single image.

Signature · 2 lines
Regards,
Shawn
author
#22 lore raw

PATCH 3/6 arm/imx6q: add core drivers clock, gpc, mmdc and src

In reply to Shawn Guo

It adds a number of core drivers support for imx6q, including clock, General Power Controller (gpc), Multi Mode DDR Controller(mmdc) and System Reset Controller (src).

---
 arch/arm/mach-imx/Kconfig       |   13 +
 arch/arm/mach-imx/Makefile      |    4 +
 arch/arm/mach-imx/clock-imx6q.c | 1990 +++++++++++++++++++++++++++++++++++++++
 arch/arm/mach-imx/gpc.c         |  110 +++
 arch/arm/mach-imx/mmdc.c        |   71 ++
 arch/arm/mach-imx/src.c         |   52 +
 6 files changed, 2240 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/mach-imx/clock-imx6q.c
 create mode 100644 arch/arm/mach-imx/gpc.c
 create mode 100644 arch/arm/mach-imx/mmdc.c
 create mode 100644 arch/arm/mach-imx/src.c
arch/arm/mach-imx/Kconfig +13 -0
index 4cf5178..30f2868 100644
@@ -1,5 +1,15 @@
 config IMX_HAVE_DMA_V1
 	bool
+
+config HAVE_IMX_GPC
+	bool
+
+config HAVE_IMX_MMDC
+	bool
+
+config HAVE_IMX_SRC
+	bool
+
 #
 # ARCH_MX31 and ARCH_MX35 are left for compatibility
 # Some usages assume that having one of them implies not having (e.g.) ARCH_MX2.
@@ -62,6 +72,9 @@ config SOC_IMX6Q
 	bool
 	select ARM_GIC
 	select CPU_V7
+	select HAVE_IMX_GPC
+	select HAVE_IMX_MMDC
+	select HAVE_IMX_SRC
 
 if ARCH_MX1
 
arch/arm/mach-imx/Makefile +4 -0
index 96ecc96..8c21fda 100644
@@ -63,3 +63,7 @@ obj-$(CONFIG_MACH_EUKREA_MBIMXSD35_BASEBOARD) += eukrea_mbimxsd35-baseboard.o
 obj-$(CONFIG_MACH_VPR200) += mach-vpr200.o
 
 obj-$(CONFIG_DEBUG_LL) += lluart.o
+obj-$(CONFIG_HAVE_IMX_GPC) += gpc.o
+obj-$(CONFIG_HAVE_IMX_MMDC) += mmdc.o
+obj-$(CONFIG_HAVE_IMX_SRC) += src.o
+obj-$(CONFIG_SOC_IMX6Q) += clock-imx6q.o
arch/arm/mach-imx/clock-imx6q.c new file +1990 -0

1,990 lines not on this page · raw message

arch/arm/mach-imx/gpc.c new file +110 -0

110 lines not on this page · raw message

arch/arm/mach-imx/mmdc.c new file +71 -0

71 lines not on this page · raw message

arch/arm/mach-imx/src.c new file +52 -0

52 lines not on this page · raw message

Signature · 1 line
1.7.4.1
#23 lore raw

PATCH 3/6 arm/imx6q: add core drivers clock, gpc, mmdc and src

Quoted 6 lines · On Tuesday 06 September 2011 17:58:37 Shawn Guo wrote:

It adds a number of core drivers support for imx6q, including clock, General Power Controller (gpc), Multi Mode DDR Controller(mmdc) and System Reset Controller (src).

Quoted 8 lines
---
 arch/arm/mach-imx/Kconfig       |   13 +
 arch/arm/mach-imx/Makefile      |    4 +
 arch/arm/mach-imx/clock-imx6q.c | 1990 +++++++++++++++++++++++++++++++++++++++
 arch/arm/mach-imx/gpc.c         |  110 +++
 arch/arm/mach-imx/mmdc.c        |   71 ++
 arch/arm/mach-imx/src.c         |   52 +
 6 files changed, 2240 insertions(+), 0 deletions(-)

This is unfortunately still a major problem. I realize that we don't yet have a good framework to do this with significantly less code, but adding a platform that is mostly consisting of stupid additions of clock descriptions that really should be in the device tree does not scale much longer. We decided to let this still get in for prima2, which was also ugly in this regard but much simpler than imx6.

My feeling is that this time, we should wait for the common clock framework to get in and simplify this. I believe Thomas is now planning to do this, but I haven't followed what the current state is.

The other three drivers in this patch are basically ok, so you can definitely post them as a separate patch and perhaps get minor comments for those, similar to what I commented on the other patches.

For the clock-imx6q.c file, what I first want to hear from someone is how this is supposed to look like in the long run with device tree integration, and how far away from that we are.

Can you comment on how far we get without the clock driver with imx6? Is is basically useless, or is there a way we can merge the remaining imx6 code and other drivers but postpone the large clock driver?

Arnd

#24 lore raw

PATCH 3/6 arm/imx6q: add core drivers clock, gpc, mmdc and src

Hi Arnd,

Quoted 16 lines · Arnd Bergmann
Quoted 6 lines · On Tuesday 06 September 2011 17:58:37 Shawn Guo wrote:

It adds a number of core drivers support for imx6q, including clock, General Power Controller (gpc), Multi Mode DDR Controller(mmdc) and System Reset Controller (src).

Quoted 8 lines
---
 arch/arm/mach-imx/Kconfig       |   13 +
 arch/arm/mach-imx/Makefile      |    4 +
 arch/arm/mach-imx/clock-imx6q.c | 1990 +++++++++++++++++++++++++++++++++++++++
 arch/arm/mach-imx/gpc.c         |  110 +++
 arch/arm/mach-imx/mmdc.c        |   71 ++
 arch/arm/mach-imx/src.c         |   52 +
 6 files changed, 2240 insertions(+), 0 deletions(-)
Quoted 1 line

This is unfortunately still a major problem.

It's so sad to still get this comment. Back to Linaro Connect on Cambridge, I believe I asked for your opinion on new SoC clock support without waiting for the clock framework. You said you do not have a strong position on this and would defer to others' judgement. Then I talked to Russell and Grant respectively, and they both agree that we should not be blocked by the clock framework. That's why I decided to start upstreaming imx6q.

Quoted 5 lines

I realize that we don't
yet have a good framework to do this with significantly less code, but adding a platform that is mostly consisting of stupid additions of clock descriptions that really should be in the device tree does not scale much longer.

I definitely agree this does not scale for long term. And I would immediately migrate it to clock framework once it gets ready and put the description into device tree when clock binding is ready. Before we get there, we need a way out. It's unreasonable for us to hold the new soc support for an unspecified time. It's been 20 months since we saw the common clock patches[1] from Jeremy, and we do not know yet how many months we still have to wait. Grant worked out the auxdata to remove the device tree dependency on clock framework. I think we should not get new soc support blocked by clock framework either.

Quoted 3 lines

We decided to let this still get in for prima2, which was also ugly in this regard but much simpler than imx6.

It's unfair to me that you reject imx6q clock code just because it's an implementation for a hardware complexer than prima2.

Quoted 4 lines

My feeling is that this time, we should wait for the common clock framework to get in and simplify this. I believe Thomas is now planning to do this, but I haven't followed what the current state is.

Sadly, if this is the position of entire arm-soc maintainer group, I think I have made a wrong decision to start upstreaming imx6q now.

Quoted 4 lines

The other three drivers in this patch are basically ok, so you can definitely post them as a separate patch and perhaps get minor comments for those, similar to what I commented on the other patches.

Quoted 8 lines

For the clock-imx6q.c file, what I first want to hear from someone is how this is supposed to look like in the long run with device tree integration, and how far away from that we are.

Can you comment on how far we get without the clock driver with imx6? Is is basically useless, or is there a way we can merge the remaining imx6 code and other drivers but postpone the large clock driver?

Unfortunately, clock is pretty fundamental for imx6q support. Without clock support, imx6q platform is useless. We have a real example here. Back to Dec. 2010, Sascha refused to take clock patch when Freescale was submitting imx50 platform support, because he thought the clock framework will get merged pretty soon. But we end up with the facts that clock framework is still up in the air and imx50 platform support on mainline is totally useless.

I have been tried very hard to reduce the LOC of clock-imx6q.c. It's a 5K LOC file in the Freescale internal tree. Now it's 2K LOC. I know it's still large enough for you to dislike it. But this is the clock that the hardware has. I'm afraid we can not do much to reduce the LOC significantly, unless we only implement the small portion other than the full clock tree, which is what I really hate to do.

Regards,
Shawn

[1] http://lists.infradead.org/pipermail/linux-arm-kernel/2010-January/007238.html

#25 lore raw

PATCH 3/6 arm/imx6q: add core drivers clock, gpc, mmdc and src

Quoted 10 lines · On Wednesday 07 September 2011 14:05:03 Shawn Guo wrote:
Quoted 9 lines
Quoted 7 lines
 arch/arm/mach-imx/Kconfig       |   13 +
 arch/arm/mach-imx/Makefile      |    4 +
 arch/arm/mach-imx/clock-imx6q.c | 1990 +++++++++++++++++++++++++++++++++++++++
 arch/arm/mach-imx/gpc.c         |  110 +++
 arch/arm/mach-imx/mmdc.c        |   71 ++
 arch/arm/mach-imx/src.c         |   52 +
 6 files changed, 2240 insertions(+), 0 deletions(-)

This is unfortunately still a major problem.

Quoted 7 lines

It's so sad to still get this comment. Back to Linaro Connect on Cambridge, I believe I asked for your opinion on new SoC clock support without waiting for the clock framework. You said you do not have a strong position on this and would defer to others' judgement. Then I talked to Russell and Grant respectively, and they both agree that we should not be blocked by the clock framework. That's why I decided to start upstreaming imx6q.

I don't mind being overruled on this if Russell, Grant or others have a good feeling about the clock code going in like this.

I thought that the discussion we had in Cambridge was about migrating the existing i.mx code to device tree without waiting for the clock framework. If I misremember that and we had actually made a different decision back then, then please forgive my overreaction.

Quoted 16 lines
Quoted 5 lines

I realize that we don't
yet have a good framework to do this with significantly less code, but adding a platform that is mostly consisting of stupid additions of clock descriptions that really should be in the device tree does not scale much longer.

I definitely agree this does not scale for long term. And I would immediately migrate it to clock framework once it gets ready and put the description into device tree when clock binding is ready. Before we get there, we need a way out. It's unreasonable for us to hold the new soc support for an unspecified time. It's been 20 months since we saw the common clock patches[1] from Jeremy, and we do not know yet how many months we still have to wait. Grant worked out the auxdata to remove the device tree dependency on clock framework. I think we should not get new soc support blocked by clock framework either.

Quoted 5 lines
Quoted 3 lines

We decided to let this still get in for prima2, which was also ugly in this regard but much simpler than imx6.

It's unfair to me that you reject imx6q clock code just because it's an implementation for a hardware complexer than prima2.

We have to stop taking new platform clock code at some point and get all new platforms to use common code as much as possible. The unresolved question here is when that will be. My feeling is that prima2 was borderline and this is too far, but I may be pushing it here given that we are still waiting for the clock framework to actually get merged.

However, if there is no pressure at all, we might never see that framework.

Quoted 6 lines
Quoted 4 lines

My feeling is that this time, we should wait for the common clock framework to get in and simplify this. I believe Thomas is now planning to do this, but I haven't followed what the current state is.

Sadly, if this is the position of entire arm-soc maintainer group, I think I have made a wrong decision to start upstreaming imx6q now.

We haven't discussed it as a group, it's my own opinion.

Quoted 20 lines
Quoted 4 lines

The other three drivers in this patch are basically ok, so you can definitely post them as a separate patch and perhaps get minor comments for those, similar to what I commented on the other patches.

Quoted 8 lines

For the clock-imx6q.c file, what I first want to hear from someone is how this is supposed to look like in the long run with device tree integration, and how far away from that we are.

Can you comment on how far we get without the clock driver with imx6? Is is basically useless, or is there a way we can merge the remaining imx6 code and other drivers but postpone the large clock driver?

Unfortunately, clock is pretty fundamental for imx6q support. Without clock support, imx6q platform is useless. We have a real example here. Back to Dec. 2010, Sascha refused to take clock patch when Freescale was submitting imx50 platform support, because he thought the clock framework will get merged pretty soon. But we end up with the facts that clock framework is still up in the air and imx50 platform support on mainline is totally useless.

Quoted 6 lines

I have been tried very hard to reduce the LOC of clock-imx6q.c. It's a 5K LOC file in the Freescale internal tree. Now it's 2K LOC. I know it's still large enough for you to dislike it. But this is the clock that the hardware has. I'm afraid we can not do much to reduce the LOC significantly, unless we only implement the small portion other than the full clock tree, which is what I really hate to do.

I actually think that you have done a great job on the code and that it certainly looks better than a lot of the other implementations that we have in the tree.

Also, at least half of the code is now real driver code that we won't be able to reduce any further even with the clock framework. However, when I look at long sets of DEF_CLK and DEF_*MUX and _REGISTER_CLOCK, it feels like exactly the stuff that we should be moving into the device tree and have automatically parsed.

Arnd

#26 lore raw

PATCH 3/6 arm/imx6q: add core drivers clock, gpc, mmdc and src

Quoted 59 lines · Arnd Bergmann
Quoted 10 lines · On Wednesday 07 September 2011 14:05:03 Shawn Guo wrote:
Quoted 9 lines
Quoted 7 lines
 arch/arm/mach-imx/Kconfig       |   13 +
 arch/arm/mach-imx/Makefile      |    4 +
 arch/arm/mach-imx/clock-imx6q.c | 1990 +++++++++++++++++++++++++++++++++++++++
 arch/arm/mach-imx/gpc.c         |  110 +++
 arch/arm/mach-imx/mmdc.c        |   71 ++
 arch/arm/mach-imx/src.c         |   52 +
 6 files changed, 2240 insertions(+), 0 deletions(-)

This is unfortunately still a major problem.

Quoted 7 lines

It's so sad to still get this comment. Back to Linaro Connect on Cambridge, I believe I asked for your opinion on new SoC clock support without waiting for the clock framework. You said you do not have a strong position on this and would defer to others' judgement. Then I talked to Russell and Grant respectively, and they both agree that we should not be blocked by the clock framework. That's why I decided to start upstreaming imx6q.

I don't mind being overruled on this if Russell, Grant or others have a good feeling about the clock code going in like this.

I thought that the discussion we had in Cambridge was about migrating the existing i.mx code to device tree without waiting for the clock framework. If I misremember that and we had actually made a different decision back then, then please forgive my overreaction.

Quoted 16 lines
Quoted 5 lines

I realize that we don't
yet have a good framework to do this with significantly less code, but adding a platform that is mostly consisting of stupid additions of clock descriptions that really should be in the device tree does not scale much longer.

I definitely agree this does not scale for long term. And I would immediately migrate it to clock framework once it gets ready and put the description into device tree when clock binding is ready. Before we get there, we need a way out. It's unreasonable for us to hold the new soc support for an unspecified time. It's been 20 months since we saw the common clock patches[1] from Jeremy, and we do not know yet how many months we still have to wait. Grant worked out the auxdata to remove the device tree dependency on clock framework. I think we should not get new soc support blocked by clock framework either.

Quoted 5 lines
Quoted 3 lines

We decided to let this still get in for prima2, which was also ugly in this regard but much simpler than imx6.

It's unfair to me that you reject imx6q clock code just because it's an implementation for a hardware complexer than prima2.

We have to stop taking new platform clock code at some point and get all new platforms to use common code as much as possible. The unresolved question here is when that will be. My feeling is that prima2 was borderline and this is too far, but I may be pushing it here given that we are still waiting for the clock framework to actually get merged.

However, if there is no pressure at all, we might never see that framework.

Quoted 9 lines
Quoted 6 lines
Quoted 4 lines

My feeling is that this time, we should wait for the common clock framework to get in and simplify this. I believe Thomas is now planning to do this, but I haven't followed what the current state is.

Sadly, if this is the position of entire arm-soc maintainer group, I think I have made a wrong decision to start upstreaming imx6q now.

We haven't discussed it as a group, it's my own opinion.

Hi Thomas, Grant,

Could you please share your opinion here?

I really do not see the hope that clock framework and device tree binding could possibly catch v3.2 window, while I'm hoping that imx6q series can go into v3.2.

Can you please agree that we can let the imx6q clock code in and then migrate it to clock framework and device tree once they get ready?

Regards,
Shawn

Quoted 39 lines
Quoted 20 lines
Quoted 4 lines

The other three drivers in this patch are basically ok, so you can definitely post them as a separate patch and perhaps get minor comments for those, similar to what I commented on the other patches.

Quoted 8 lines

For the clock-imx6q.c file, what I first want to hear from someone is how this is supposed to look like in the long run with device tree integration, and how far away from that we are.

Can you comment on how far we get without the clock driver with imx6? Is is basically useless, or is there a way we can merge the remaining imx6 code and other drivers but postpone the large clock driver?

Unfortunately, clock is pretty fundamental for imx6q support. Without clock support, imx6q platform is useless. We have a real example here. Back to Dec. 2010, Sascha refused to take clock patch when Freescale was submitting imx50 platform support, because he thought the clock framework will get merged pretty soon. But we end up with the facts that clock framework is still up in the air and imx50 platform support on mainline is totally useless.

Quoted 6 lines

I have been tried very hard to reduce the LOC of clock-imx6q.c. It's a 5K LOC file in the Freescale internal tree. Now it's 2K LOC. I know it's still large enough for you to dislike it. But this is the clock that the hardware has. I'm afraid we can not do much to reduce the LOC significantly, unless we only implement the small portion other than the full clock tree, which is what I really hate to do.

I actually think that you have done a great job on the code and that it certainly looks better than a lot of the other implementations that we have in the tree.

Also, at least half of the code is now real driver code that we won't be able to reduce any further even with the clock framework. However, when I look at long sets of DEF_CLK and DEF_*MUX and _REGISTER_CLOCK, it feels like exactly the stuff that we should be moving into the device tree and have automatically parsed.

Arnd

#27 lore raw

PATCH 3/6 arm/imx6q: add core drivers clock, gpc, mmdc and src

Quoted 14 lines · Shawn Guo
Quoted 10 lines · Arnd Bergmann
Quoted 6 lines · On Wednesday 07 September 2011 14:05:03 Shawn Guo wrote:
Quoted 4 lines

My feeling is that this time, we should wait for the common clock framework to get in and simplify this. I believe Thomas is now planning to do this, but I haven't followed what the current state is.

Sadly, if this is the position of entire arm-soc maintainer group, I think I have made a wrong decision to start upstreaming imx6q now.

We haven't discussed it as a group, it's my own opinion.

Hi Thomas, Grant,

Quoted 8 lines

Could you please share your opinion here?

I really do not see the hope that clock framework and device tree binding could possibly catch v3.2 window, while I'm hoping that imx6q series can go into v3.2.

Can you please agree that we can let the imx6q clock code in and then migrate it to clock framework and device tree once they get ready?

I've not looked very deeply at this patch, but I completely agree that we cannot block new platforms on infrastructure that isn't remotely mergable at this point in time.

However, imx6 is a new platform. There isn't any non-DT board support code to continue to support. At the very least, the configurable parameters, like what is passed into mx6q_clocks_init() should be obtained from the device tree (maybe it already does this though, I haven't looked that closely).

In general, I say merge it.

g.

#28 lore raw

PATCH 3/6 arm/imx6q: add core drivers clock, gpc, mmdc and src

Quoted 28 lines · On Monday 12 September 2011 13:40:33 Grant Likely wrote:
Quoted 14 lines · Shawn Guo
Quoted 10 lines · Arnd Bergmann
Quoted 6 lines · On Wednesday 07 September 2011 14:05:03 Shawn Guo wrote:
Quoted 4 lines

My feeling is that this time, we should wait for the common clock framework to get in and simplify this. I believe Thomas is now planning to do this, but I haven't followed what the current state is.

Sadly, if this is the position of entire arm-soc maintainer group, I think I have made a wrong decision to start upstreaming imx6q now.

We haven't discussed it as a group, it's my own opinion.

Hi Thomas, Grant,

Quoted 8 lines

Could you please share your opinion here?

I really do not see the hope that clock framework and device tree binding could possibly catch v3.2 window, while I'm hoping that imx6q series can go into v3.2.

Can you please agree that we can let the imx6q clock code in and then migrate it to clock framework and device tree once they get ready?

I've not looked very deeply at this patch, but I completely agree that we cannot block new platforms on infrastructure that isn't remotely mergable at this point in time.

Quoted 7 lines

However, imx6 is a new platform. There isn't any non-DT board support code to continue to support. At the very least, the configurable parameters, like what is passed into mx6q_clocks_init() should be obtained from the device tree (maybe it already does this though, I haven't looked that closely).

In general, I say merge it.

Ok, thanks for taking a look. Do you believe that the clock binding is any closer to being finalized than the actual code implementing it? I think it would be very helpful to at least put all the clock related settings into the device tree in a way that is going to be stable, even if the code is still in flux.

Moreover, if we have a binding document, we can start implementing code for one platform and then generalize it later.

Arnd

#29 lore raw

PATCH 3/6 arm/imx6q: add core drivers clock, gpc, mmdc and src

Quoted 35 lines · Arnd Bergmann
Quoted 34 lines · On Monday 12 September 2011 13:40:33 Grant Likely wrote:
Quoted 14 lines · Shawn Guo
Quoted 10 lines · Arnd Bergmann
Quoted 6 lines · On Wednesday 07 September 2011 14:05:03 Shawn Guo wrote:
Quoted 4 lines

My feeling is that this time, we should wait for the common clock framework to get in and simplify this. I believe Thomas is now planning to do this, but I haven't followed what the current state is.

Sadly, if this is the position of entire arm-soc maintainer group, I think I have made a wrong decision to start upstreaming imx6q now.

We haven't discussed it as a group, it's my own opinion.

Hi Thomas, Grant,

Quoted 8 lines

Could you please share your opinion here?

I really do not see the hope that clock framework and device tree binding could possibly catch v3.2 window, while I'm hoping that imx6q series can go into v3.2.

Can you please agree that we can let the imx6q clock code in and then migrate it to clock framework and device tree once they get ready?

I've not looked very deeply at this patch, but I completely agree that we cannot block new platforms on infrastructure that isn't remotely mergable at this point in time.

However, imx6 is a new platform. There isn't any non-DT board support code to continue to support. At the very least, the configurable parameters, like what is passed into mx6q_clocks_init() should be obtained from the device tree (maybe it already does this though, I haven't looked that closely).

Quoted 4 lines
Quoted 1 line

In general, I say merge it.

Ok, thanks for taking a look. Do you believe that the clock binding is any closer to being finalized than the actual code implementing it? I think

Amit is assigning a Linaro engineer to look at it, and there will be a conference call later this week to look over the work that has been done with an eye to getting something ready to be merged. Hopefully with a full time engineer things will start moving forward again. We had a meeting about it at LPC last week.

Quoted 6 lines

it would be very helpful to at least put all the clock related settings into the device tree in a way that is going to be stable, even if the code is still in flux.

Moreover, if we have a binding document, we can start implementing code for one platform and then generalize it later.

Yes, a binding would be useful, but I still expect that things will be in flux during these early stages, so there will be some room to modify insufficient early bindings.

g.

#30 lore raw

PATCH 3/6 arm/imx6q: add core drivers clock, gpc, mmdc and src

In reply to Grant Likely
Quoted 28 lines · Grant Likely
Quoted 14 lines · Shawn Guo
Quoted 10 lines · Arnd Bergmann
Quoted 6 lines · On Wednesday 07 September 2011 14:05:03 Shawn Guo wrote:
Quoted 4 lines

My feeling is that this time, we should wait for the common clock framework to get in and simplify this. I believe Thomas is now planning to do this, but I haven't followed what the current state is.

Sadly, if this is the position of entire arm-soc maintainer group, I think I have made a wrong decision to start upstreaming imx6q now.

We haven't discussed it as a group, it's my own opinion.

Hi Thomas, Grant,

Quoted 8 lines

Could you please share your opinion here?

I really do not see the hope that clock framework and device tree binding could possibly catch v3.2 window, while I'm hoping that imx6q series can go into v3.2.

Can you please agree that we can let the imx6q clock code in and then migrate it to clock framework and device tree once they get ready?

I've not looked very deeply at this patch, but I completely agree that we cannot block new platforms on infrastructure that isn't remotely mergable at this point in time.

Quoted 6 lines

However, imx6 is a new platform. There isn't any non-DT board support code to continue to support. At the very least, the configurable parameters, like what is passed into mx6q_clocks_init() should be obtained from the device tree (maybe it already does this though, I haven't looked that closely).

Ok, will do in the next post.

Quoted 2 lines

In general, I say merge it.

Thanks, Grant.

Signature · 2 lines
Regards,
Shawn
#31 lore raw

PATCH 3/6 arm/imx6q: add core drivers clock, gpc, mmdc and src

In reply to Shawn Guo

2011/9/7 Shawn Guo <[email protected]>:

Quoted 45 lines

Hi Arnd,

Quoted 16 lines · Arnd Bergmann
Quoted 6 lines · On Tuesday 06 September 2011 17:58:37 Shawn Guo wrote:

It adds a number of core drivers support for imx6q, including clock, General Power Controller (gpc), Multi Mode DDR Controller(mmdc) and System Reset Controller (src).

Quoted 8 lines

---

?arch/arm/mach-imx/Kconfig ? ? ? | ? 13 +
?arch/arm/mach-imx/Makefile ? ? ?| ? ?4 +
?arch/arm/mach-imx/clock-imx6q.c | 1990 +++++++++++++++++++++++++++++++++++++++
?arch/arm/mach-imx/gpc.c ? ? ? ? | ?110 +++
?arch/arm/mach-imx/mmdc.c ? ? ? ?| ? 71 ++
?arch/arm/mach-imx/src.c ? ? ? ? | ? 52 +

?6 files changed, 2240 insertions(+), 0 deletions(-)

Quoted 1 line

This is unfortunately still a major problem.

It's so sad to still get this comment. ?Back to Linaro Connect on Cambridge, I believe I asked for your opinion on new SoC clock support without waiting for the clock framework. ?You said you do not have a strong position on this and would defer to others' judgement. ?Then I talked to Russell and Grant respectively, and they both agree that we should not be blocked by the clock framework. ?That's why I decided to start upstreaming imx6q.

Quoted 5 lines

I realize that we don't
yet have a good framework to do this with significantly less code, but adding a platform that is mostly consisting of stupid additions of clock descriptions that really should be in the device tree does not scale much longer.

I definitely agree this does not scale for long term. ?And I would immediately migrate it to clock framework once it gets ready and put the description into device tree when clock binding is ready. ?Before we get there, we need a way out. ?It's unreasonable for us to hold the new soc support for an unspecified time. ?It's been 20 months since we saw the common clock patches[1] from Jeremy, and we do not know yet how many months we still have to wait. ?Grant worked out the auxdata to remove the device tree dependency on clock framework. ?I think we should not get new soc support blocked by clock framework either.

Quoted 5 lines
Quoted 3 lines

We decided to let this still get in for prima2, which was also ugly in this regard but much simpler than imx6.

It's unfair to me that you reject imx6q clock code just because it's an implementation for a hardware complexer than prima2.

i understand your feeling.

actually i am also waiting for the common clock framework to finish the whole prima2 clock tree driver. now prima2 only includes a little part of clock trees, actually if i list all of them, the file will be large too. And codes are ugly too.

auxdata is really a temp solution, it really brings many details to kernel, which should not be in kernel at all.

Quoted 35 lines
Quoted 5 lines

My feeling is that this time, we should wait for the common clock framework to get in and simplify this. I believe Thomas is now planning to do this, but I haven't followed what the current state is.

Sadly, if this is the position of entire arm-soc maintainer group, I think I have made a wrong decision to start upstreaming imx6q now.

Quoted 4 lines

The other three drivers in this patch are basically ok, so you can definitely post them as a separate patch and perhaps get minor comments for those, similar to what I commented on the other patches.

Quoted 8 lines

For the clock-imx6q.c file, what I first want to hear from someone is how this is supposed to look like in the long run with device tree integration, and how far away from that we are.

Can you comment on how far we get without the clock driver with imx6? Is is basically useless, or is there a way we can merge the remaining imx6 code and other drivers but postpone the large clock driver?

Unfortunately, clock is pretty fundamental for imx6q support. ?Without clock support, imx6q platform is useless. ?We have a real example here. Back to Dec. 2010, Sascha refused to take clock patch when Freescale was submitting imx50 platform support, because he thought the clock framework will get merged pretty soon. ?But we end up with the facts that clock framework is still up in the air and imx50 platform support on mainline is totally useless.

I have been tried very hard to reduce the LOC of clock-imx6q.c. ?It's a 5K LOC file in the Freescale internal tree. ?Now it's 2K LOC. ?I know it's still large enough for you to dislike it. ?But this is the clock that the hardware has. ?I'm afraid we can not do much to reduce the LOC significantly, unless we only implement the small portion other than the full clock tree, which is what I really hate to do.

Quoted 5 lines

Regards,
Shawn

[1] http://lists.infradead.org/pipermail/linux-arm-kernel/2010-January/007238.html

Thanks
barry

#32 lore raw

PATCH 3/6 arm/imx6q: add core drivers clock, gpc, mmdc and src

Quoted 46 lines · Barry Song

2011/9/7 Shawn Guo <[email protected]>:

Quoted 45 lines

Hi Arnd,

Quoted 16 lines · Arnd Bergmann
Quoted 6 lines · On Tuesday 06 September 2011 17:58:37 Shawn Guo wrote:

It adds a number of core drivers support for imx6q, including clock, General Power Controller (gpc), Multi Mode DDR Controller(mmdc) and System Reset Controller (src).

Quoted 8 lines

---

?arch/arm/mach-imx/Kconfig ? ? ? | ? 13 +
?arch/arm/mach-imx/Makefile ? ? ?| ? ?4 +
?arch/arm/mach-imx/clock-imx6q.c | 1990 +++++++++++++++++++++++++++++++++++++++
?arch/arm/mach-imx/gpc.c ? ? ? ? | ?110 +++
?arch/arm/mach-imx/mmdc.c ? ? ? ?| ? 71 ++
?arch/arm/mach-imx/src.c ? ? ? ? | ? 52 +

?6 files changed, 2240 insertions(+), 0 deletions(-)

Quoted 1 line

This is unfortunately still a major problem.

It's so sad to still get this comment. ?Back to Linaro Connect on Cambridge, I believe I asked for your opinion on new SoC clock support without waiting for the clock framework. ?You said you do not have a strong position on this and would defer to others' judgement. ?Then I talked to Russell and Grant respectively, and they both agree that we should not be blocked by the clock framework. ?That's why I decided to start upstreaming imx6q.

Quoted 5 lines

I realize that we don't
yet have a good framework to do this with significantly less code, but adding a platform that is mostly consisting of stupid additions of clock descriptions that really should be in the device tree does not scale much longer.

I definitely agree this does not scale for long term. ?And I would immediately migrate it to clock framework once it gets ready and put the description into device tree when clock binding is ready. ?Before we get there, we need a way out. ?It's unreasonable for us to hold the new soc support for an unspecified time. ?It's been 20 months since we saw the common clock patches[1] from Jeremy, and we do not know yet how many months we still have to wait. ?Grant worked out the auxdata to remove the device tree dependency on clock framework. ?I think we should not get new soc support blocked by clock framework either.

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

We decided to let this still get in for prima2, which was also ugly in this regard but much simpler than imx6.

It's unfair to me that you reject imx6q clock code just because it's an implementation for a hardware complexer than prima2.

i understand your feeling.

No, you do not :) With the talking at Cambridge, I thought I'm allowed to add new platform support without being blocked by clock framework. That's why I have been worked very hard for 3 weeks to come up with this patch series. Now I'm getting a "no", which really frustrates me.

Quoted 5 lines

actually i am also waiting for the common clock framework to finish the whole prima2 clock tree driver. now prima2 only includes a little part of clock trees, actually if i list all of them, the file will be large too. And codes are ugly too.

I did not hear "ugly" from Arnd on imx6q-clock.c. Instead, he said the description of the clocks and the tree should be migrated to clock frame and device tree clock bindings, which unfortunately have not been available yet.

Quoted 3 lines

auxdata is really a temp solution, it really brings many details to kernel, which should not be in kernel at all.

The auxdata was originally designed to be a temp solution. But we will see if it's really temp, considering it could also be used to carry platform callbacks and attach device id. There are some other cases beside clock lookup that we have not been able to sort out just by device tree and will probably have to use auxdata as well.

Signature · 2 lines
Regards,
Shawn
#33 lore raw

PATCH 3/6 arm/imx6q: add core drivers clock, gpc, mmdc and src

2011/9/8 Shawn Guo <[email protected]>:

Quoted 65 lines · Barry Song
Quoted 46 lines

2011/9/7 Shawn Guo <[email protected]>:

Quoted 45 lines

Hi Arnd,

Quoted 16 lines · Arnd Bergmann
Quoted 6 lines · On Tuesday 06 September 2011 17:58:37 Shawn Guo wrote:

It adds a number of core drivers support for imx6q, including clock, General Power Controller (gpc), Multi Mode DDR Controller(mmdc) and System Reset Controller (src).

Quoted 8 lines

---

?arch/arm/mach-imx/Kconfig ? ? ? | ? 13 +
?arch/arm/mach-imx/Makefile ? ? ?| ? ?4 +
?arch/arm/mach-imx/clock-imx6q.c | 1990 +++++++++++++++++++++++++++++++++++++++
?arch/arm/mach-imx/gpc.c ? ? ? ? | ?110 +++
?arch/arm/mach-imx/mmdc.c ? ? ? ?| ? 71 ++
?arch/arm/mach-imx/src.c ? ? ? ? | ? 52 +

?6 files changed, 2240 insertions(+), 0 deletions(-)

Quoted 1 line

This is unfortunately still a major problem.

It's so sad to still get this comment. ?Back to Linaro Connect on Cambridge, I believe I asked for your opinion on new SoC clock support without waiting for the clock framework. ?You said you do not have a strong position on this and would defer to others' judgement. ?Then I talked to Russell and Grant respectively, and they both agree that we should not be blocked by the clock framework. ?That's why I decided to start upstreaming imx6q.

Quoted 5 lines

I realize that we don't
yet have a good framework to do this with significantly less code, but adding a platform that is mostly consisting of stupid additions of clock descriptions that really should be in the device tree does not scale much longer.

I definitely agree this does not scale for long term. ?And I would immediately migrate it to clock framework once it gets ready and put the description into device tree when clock binding is ready. ?Before we get there, we need a way out. ?It's unreasonable for us to hold the new soc support for an unspecified time. ?It's been 20 months since we saw the common clock patches[1] from Jeremy, and we do not know yet how many months we still have to wait. ?Grant worked out the auxdata to remove the device tree dependency on clock framework. ?I think we should not get new soc support blocked by clock framework either.

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

We decided to let this still get in for prima2, which was also ugly in this regard but much simpler than imx6.

It's unfair to me that you reject imx6q clock code just because it's an implementation for a hardware complexer than prima2.

i understand your feeling.

No, you do not :) ?With the talking at Cambridge, I thought I'm allowed to add new platform support without being blocked by clock framework. That's why I have been worked very hard for 3 weeks to come up with this patch series. ?Now I'm getting a "no", which really frustrates me.

Quoted 5 lines

actually i am also waiting for the common clock framework to finish the whole prima2 clock tree driver. now prima2 only includes a little part of clock trees, actually if i list all of them, the file will be large too. And codes are ugly too.

Quoted 4 lines

I did not hear "ugly" from Arnd on imx6q-clock.c. ?Instead, he said the description of the clocks and the tree should be migrated to clock frame and device tree clock bindings, which unfortunately have not been available yet.

i see :-) might you push other imx6q stuff at first? it looks like Arnd is really glad with your other files.

Quoted 10 lines
Quoted 4 lines

auxdata is really a temp solution, it really brings many details to kernel, which should not be in kernel at all.

The auxdata was originally designed to be a temp solution. ?But we will see if it's really temp, considering it could also be used to carry platform callbacks and attach device id. ?There are some other cases beside clock lookup that we have not been able to sort out just by device tree and will probably have to use auxdata as well.

Quoted 5 lines

--
Regards,
Shawn

-barry

#34 lore raw

PATCH 3/6 arm/imx6q: add core drivers clock, gpc, mmdc and src

In reply to Shawn Guo
Quoted 9 lines · Shawn Guo
Quoted 3 lines · Barry Song

auxdata is really a temp solution, it really brings many details to kernel, which should not be in kernel at all.

The auxdata was originally designed to be a temp solution. But we will see if it's really temp, considering it could also be used to carry platform callbacks and attach device id. There are some other cases beside clock lookup that we have not been able to sort out just by device tree and will probably have to use auxdata as well.

auxdata is indeed intended to be a temporary solution, and it is an absolute requirement that board ports migrate away from it as soon as feasible (ie. when needed infrastructure for clk, etc, become available).

However, I don't expect auxdata to ever be completely removed. There will always be a handful of boards that require something special to be provided by board code. In those cases, auxdata is a perfectly acceptable solution.

g.

maintainer
#35 lore raw

PATCH 3/6 arm/imx6q: add core drivers clock, gpc, mmdc and src

In reply to Shawn Guo
Quoted 55 lines · Shawn Guo

It adds a number of core drivers support for imx6q, including clock, General Power Controller (gpc), Multi Mode DDR Controller(mmdc) and System Reset Controller (src).

---

arch/arm/mach-imx/src.c new file +42 -0
new file mode 100644
index 0000000..95fdd65
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2011 Freescale Semiconductor, Inc.
+ * Copyright 2011 Linaro Ltd.
+ *
+ * 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/io.h>
+#include <linux/of.h>
+#include <linux/of_address.h>
+#include <asm/unified.h>
+
+#define SRC_SCR				0x000
+#define SRC_GPR1			0x020
+#define BP_SRC_SCR_CORE1_RST		14
+#define BP_SRC_SCR_CORE1_ENABLE		22
+
+static void __iomem *src_base;
+
+void imx_enable_cpu(int cpu, bool enable)
+{
+	u32 mask, val;
+
+	mask = 1 << (BP_SRC_SCR_CORE1_ENABLE + cpu - 1);
+	val = __raw_readl(src_base + SRC_SCR);
+	val = enable ? val | mask : val & ~mask;
+	__raw_writel(val, src_base + SRC_SCR);
+}
+
+void imx_set_cpu_jump(int cpu, void *jump_addr)
+{
+	__raw_writel(BSYM(virt_to_phys(jump_addr)),
+		     src_base + SRC_GPR1 + cpu * 8);
+}
+
+static int __init imx_src_init(void)

arch/arm/mach-imx/src.c line 52

Quoted 10 lines
arch/arm/mach-imx/src.c new file +10 -0
+{
+	struct device_node *np;
+
+	np = of_find_compatible_node(NULL, NULL, "fsl,imx6q-src");
+	src_base = of_iomap(np, 0);
+	WARN_ON(!src_base);
+
+	return 0;
+}
+early_initcall(imx_src_init);

What I'm concerned about is that we carefully removed all assumptions about which SoC the code runs on in the past. Now with this patchset many of them come back. Here we have a initcall without any check whether we really run on i.MX6. Above we have a imx_enable_cpu function but this is really a imx6 specific function. Nevertheless it is called from generic code in arch/arm/mach-imx/platsmp.c.

We've been there before and it was hard to remove all the implicit assumptions on which SoC we are on. Please do not reintroduce it.

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

PATCH 3/6 arm/imx6q: add core drivers clock, gpc, mmdc and src

Quoted 63 lines · Sascha Hauer
Quoted 62 lines · Shawn Guo

It adds a number of core drivers support for imx6q, including clock, General Power Controller (gpc), Multi Mode DDR Controller(mmdc) and System Reset Controller (src).

---

arch/arm/mach-imx/src.c new file +49 -0
new file mode 100644
index 0000000..95fdd65
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2011 Freescale Semiconductor, Inc.
+ * Copyright 2011 Linaro Ltd.
+ *
+ * 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/io.h>
+#include <linux/of.h>
+#include <linux/of_address.h>
+#include <asm/unified.h>
+
+#define SRC_SCR				0x000
+#define SRC_GPR1			0x020
+#define BP_SRC_SCR_CORE1_RST		14
+#define BP_SRC_SCR_CORE1_ENABLE		22
+
+static void __iomem *src_base;
+
+void imx_enable_cpu(int cpu, bool enable)
+{
+	u32 mask, val;
+
+	mask = 1 << (BP_SRC_SCR_CORE1_ENABLE + cpu - 1);
+	val = __raw_readl(src_base + SRC_SCR);
+	val = enable ? val | mask : val & ~mask;
+	__raw_writel(val, src_base + SRC_SCR);
+}
+
+void imx_set_cpu_jump(int cpu, void *jump_addr)
+{
+	__raw_writel(BSYM(virt_to_phys(jump_addr)),
+		     src_base + SRC_GPR1 + cpu * 8);
+}
+
+static int __init imx_src_init(void)
+{
+	struct device_node *np;
+
+	np = of_find_compatible_node(NULL, NULL, "fsl,imx6q-src");
+	src_base = of_iomap(np, 0);
+	WARN_ON(!src_base);
+
Quoted 8 lines

arch/arm/mach-imx/src.c line 52

Quoted 3 lines
arch/arm/mach-imx/src.c new file +3 -0
+	return 0;
+}
+early_initcall(imx_src_init);

What I'm concerned about is that we carefully removed all assumptions about which SoC the code runs on in the past. Now with this patchset many of them come back. Here we have a initcall without any check whether we really run on i.MX6.

The "check" has been done on Kconfig level as below.

config SOC_IMX6Q
bool "i.MX6 Quad support"
select HAVE_IMX_SRC

obj-$(CONFIG_HAVE_IMX_SRC) += src.o

Quoted 2 lines

Above we have a imx_enable_cpu function
but this is really a imx6 specific function.

I would say this is a imx smp specific function.

Quoted 6 lines

Nevertheless it is called
from generic code in arch/arm/mach-imx/platsmp.c.

We've been there before and it was hard to remove all the implicit assumptions on which SoC we are on. Please do not reintroduce it.

We create platform driver for (talking to) specific device (IP block), and select the driver for SoCs that have the device. Anything wrong with this approach? Or I missed your point here?

Signature · 2 lines
Regards,
Shawn
#37 lore raw

PATCH 3/6 arm/imx6q: add core drivers clock, gpc, mmdc and src

Hello Shawn,

Quoted 19 lines · Shawn Guo
Quoted 17 lines · Sascha Hauer

arch/arm/mach-imx/src.c line 52

Quoted 11 lines · Shawn Guo
arch/arm/mach-imx/src.c new file +11 -0
+static int __init imx_src_init(void)
+{
+	struct device_node *np;
+
+	np = of_find_compatible_node(NULL, NULL, "fsl,imx6q-src");
+	src_base = of_iomap(np, 0);
+	WARN_ON(!src_base);
+
+	return 0;
+}
+early_initcall(imx_src_init);

What I'm concerned about is that we carefully removed all assumptions about which SoC the code runs on in the past. Now with this patchset many of them come back. Here we have a initcall without any check whether we really run on i.MX6.

Quoted 7 lines

The "check" has been done on Kconfig level as below.

config SOC_IMX6Q
bool "i.MX6 Quad support"
select HAVE_IMX_SRC

obj-$(CONFIG_HAVE_IMX_SRC) += src.o

Think multi-SoC-kernel that has SOC_IMX6Q and say SOC_IMX51.

Best regards
Uwe

Signature · 2 lines
Pengutronix e.K.                           | Uwe Kleine-K?nig            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
#38 lore raw

PATCH 3/6 arm/imx6q: add core drivers clock, gpc, mmdc and src

Quoted 20 lines · Uwe Kleine-K?nig
Quoted 19 lines · Shawn Guo
Quoted 17 lines · Sascha Hauer

arch/arm/mach-imx/src.c line 52

Quoted 11 lines · Shawn Guo
arch/arm/mach-imx/src.c new file +11 -0
+static int __init imx_src_init(void)
+{
+ struct device_node *np;
+
+ np = of_find_compatible_node(NULL, NULL, "fsl,imx6q-src");
+ src_base = of_iomap(np, 0);
+ WARN_ON(!src_base);
+
+ return 0;
+}
+early_initcall(imx_src_init);

What I'm concerned about is that we carefully removed all assumptions about which SoC the code runs on in the past. Now with this patchset many of them come back. Here we have a initcall without any check whether we really run on i.MX6.

Quoted 8 lines
Quoted 7 lines

The "check" has been done on Kconfig level as below.

config SOC_IMX6Q
bool "i.MX6 Quad support"
select HAVE_IMX_SRC

obj-$(CONFIG_HAVE_IMX_SRC) += src.o

Think multi-SoC-kernel that has SOC_IMX6Q and say SOC_IMX51.

I think the code is almost ok, since it's only active when there is a "fsl,imx6q-src" device node. However, the WARN_ON must be removed if we want this to work well on a multi-soc kernel.

The more important point is to ensure that src_base is not being used on other SoCs, but that's probably covered as well.

Arnd

#39 lore raw

PATCH 3/6 arm/imx6q: add core drivers clock, gpc, mmdc and src

Quoted 21 lines · Arnd Bergmann
Quoted 20 lines · Uwe Kleine-K?nig
Quoted 19 lines · Shawn Guo
Quoted 17 lines · Sascha Hauer

arch/arm/mach-imx/src.c line 52

Quoted 11 lines · Shawn Guo
arch/arm/mach-imx/src.c new file +11 -0
+static int __init imx_src_init(void)
+{
+ struct device_node *np;
+
+ np = of_find_compatible_node(NULL, NULL, "fsl,imx6q-src");
+ src_base = of_iomap(np, 0);
+ WARN_ON(!src_base);
+
+ return 0;
+}
+early_initcall(imx_src_init);

What I'm concerned about is that we carefully removed all assumptions about which SoC the code runs on in the past. Now with this patchset many of them come back. Here we have a initcall without any check whether we really run on i.MX6.

Quoted 9 lines
Quoted 8 lines
Quoted 7 lines

The "check" has been done on Kconfig level as below.

config SOC_IMX6Q
bool "i.MX6 Quad support"
select HAVE_IMX_SRC

obj-$(CONFIG_HAVE_IMX_SRC) += src.o

Think multi-SoC-kernel that has SOC_IMX6Q and say SOC_IMX51.

Aha, I did miss the point. I was misled by "Now with this patchset many of them come back". SRC is the only one being called by initcall. MMDC is a real platform driver. GPC and Clock init are called by specific platform code.

Quoted 7 lines

I think the code is almost ok, since it's only active when there is a "fsl,imx6q-src" device node. However, the WARN_ON must be removed if we want this to work well on a multi-soc kernel.

The more important point is to ensure that src_base is not being used on other SoCs, but that's probably covered as well.

Thanks, Arnd.

Signature · 2 lines
Regards,
Shawn
#40 lore raw

PATCH 3/6 arm/imx6q: add core drivers clock, gpc, mmdc and src

Quoted 36 lines · Shawn Guo
Quoted 21 lines · Arnd Bergmann
Quoted 20 lines · Uwe Kleine-K?nig
Quoted 19 lines · Shawn Guo
Quoted 17 lines · Sascha Hauer

arch/arm/mach-imx/src.c line 52

Quoted 11 lines · Shawn Guo
arch/arm/mach-imx/src.c new file +11 -0
+static int __init imx_src_init(void)
+{
+ struct device_node *np;
+
+ np = of_find_compatible_node(NULL, NULL, "fsl,imx6q-src");
+ src_base = of_iomap(np, 0);
+ WARN_ON(!src_base);
+
+ return 0;
+}
+early_initcall(imx_src_init);

What I'm concerned about is that we carefully removed all assumptions about which SoC the code runs on in the past. Now with this patchset many of them come back. Here we have a initcall without any check whether we really run on i.MX6.

Quoted 9 lines
Quoted 8 lines
Quoted 7 lines

The "check" has been done on Kconfig level as below.

config SOC_IMX6Q
bool "i.MX6 Quad support"
select HAVE_IMX_SRC

obj-$(CONFIG_HAVE_IMX_SRC) += src.o

Think multi-SoC-kernel that has SOC_IMX6Q and say SOC_IMX51.

Aha, I did miss the point. I was misled by "Now with this patchset many of them come back". SRC is the only one being called by initcall. MMDC is a real platform driver. GPC and Clock init are called by specific platform code.

Quoted 9 lines
Quoted 7 lines

I think the code is almost ok, since it's only active when there is a "fsl,imx6q-src" device node. However, the WARN_ON must be removed if we want this to work well on a multi-soc kernel.

The more important point is to ensure that src_base is not being used on other SoCs, but that's probably covered as well.

Thanks, Arnd.

I will drop the initcall from imx_src_init() and find some place in imx6q platform code to call it.

Signature · 2 lines
Regards,
Shawn
author
#41 lore raw

PATCH 4/6 arm/imx6q: add smp and cpu hotplug support

In reply to Shawn Guo

It adds smp and cpu hotplug support for imx6q.

---
 arch/arm/mach-imx/Kconfig               |    1 +
 arch/arm/mach-imx/Makefile              |    4 ++
 arch/arm/mach-imx/head-v7.S             |   75 +++++++++++++++++++++++++++
 arch/arm/mach-imx/hotplug.c             |   44 ++++++++++++++++
 arch/arm/mach-imx/localtimer.c          |   64 +++++++++++++++++++++++
 arch/arm/mach-imx/platsmp.c             |   86 +++++++++++++++++++++++++++++++
 arch/arm/plat-mxc/include/mach/common.h |    3 +
 7 files changed, 277 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/mach-imx/head-v7.S
 create mode 100644 arch/arm/mach-imx/hotplug.c
 create mode 100644 arch/arm/mach-imx/localtimer.c
 create mode 100644 arch/arm/mach-imx/platsmp.c
arch/arm/mach-imx/Kconfig +1 -0
index 30f2868..13e0301 100644
@@ -72,6 +72,7 @@ config SOC_IMX6Q
 	bool
 	select ARM_GIC
 	select CPU_V7
+	select HAVE_ARM_SCU
 	select HAVE_IMX_GPC
 	select HAVE_IMX_MMDC
 	select HAVE_IMX_SRC
arch/arm/mach-imx/Makefile +4 -0
index 8c21fda..d46b2e7 100644
@@ -66,4 +66,8 @@ obj-$(CONFIG_DEBUG_LL) += lluart.o
 obj-$(CONFIG_HAVE_IMX_GPC) += gpc.o
 obj-$(CONFIG_HAVE_IMX_MMDC) += mmdc.o
 obj-$(CONFIG_HAVE_IMX_SRC) += src.o
+obj-$(CONFIG_CPU_V7) += head-v7.o
+obj-$(CONFIG_SMP) += platsmp.o
+obj-$(CONFIG_HOTPLUG_CPU) += hotplug.o
+obj-$(CONFIG_LOCAL_TIMERS) += localtimer.o
 obj-$(CONFIG_SOC_IMX6Q) += clock-imx6q.o
arch/arm/mach-imx/head-v7.S new file +75 -0

75 lines not on this page · raw message

arch/arm/mach-imx/hotplug.c new file +44 -0

44 lines not on this page · raw message

arch/arm/mach-imx/localtimer.c new file +64 -0

64 lines not on this page · raw message

arch/arm/mach-imx/platsmp.c new file +86 -0

86 lines not on this page · raw message

arch/arm/plat-mxc/include/mach/common.h +3 -0
index 4e3d978..73da910 100644
@@ -72,4 +72,7 @@ extern void mxc_arch_reset_init(void __iomem *);
 extern void mx51_efikamx_reset(void);
 extern int mx53_revision(void);
 extern int mx53_display_revision(void);
+
+extern void imx_enable_cpu(int cpu, bool enable);
+extern void imx_set_cpu_jump(int cpu, void *jump_addr);
 #endif
Signature · 1 line
1.7.4.1
#42 lore raw

PATCH 4/6 arm/imx6q: add smp and cpu hotplug support

Quoted 17 lines · On Tuesday 06 September 2011 17:58:38 Shawn Guo wrote:

It adds smp and cpu hotplug support for imx6q.

arch/arm/mach-imx/localtimer.c new file +16 -0
+static u32 twd_saved_regs[4];
+static int twd_irq;
+
+/*
+ * Resuming from ARM Dormant/Shutdown mode, the boot procedure will
+ * re-setup local timer for secondary cores.  For primary core, it
+ * has to take care of itself with the following pair of functions
+ * during suspend/resume.
+ */
+void imx_local_timer_pre_suspend(void)
+{
+	twd_saved_regs[0] = __raw_readl(twd_base + TWD_TIMER_LOAD);
+	twd_saved_regs[1] = __raw_readl(twd_base + TWD_TIMER_COUNTER);
+	twd_saved_regs[2] = __raw_readl(twd_base + TWD_TIMER_CONTROL);
+	twd_saved_regs[3] = __raw_readl(twd_base + TWD_TIMER_INTSTAT);
+}

arch/arm/mach-imx/localtimer.c line 45

Quoted 10 lines
arch/arm/mach-imx/localtimer.c new file +10 -0
+
+void imx_local_timer_post_resume(void)
+{
+	__raw_writel(twd_saved_regs[0], twd_base + TWD_TIMER_LOAD);
+	__raw_writel(twd_saved_regs[1], twd_base + TWD_TIMER_COUNTER);
+	__raw_writel(twd_saved_regs[2], twd_base + TWD_TIMER_CONTROL);
+	__raw_writel(twd_saved_regs[3], twd_base + TWD_TIMER_INTSTAT);
+
+	gic_enable_ppi(twd_irq);
+}

readl_relaxed()?

arch/arm/mach-imx/platsmp.c line 25

Quoted 5 lines
arch/arm/mach-imx/platsmp.c new file +5 -0
+extern void v7_secondary_startup(void);
+
+#define IMX_SCU_VIRT_BASE	0xf4a00000
+
+static void __iomem *scu_base = ((void __iomem *)(IMX_SCU_VIRT_BASE));

It's a little bit silly to have a variable for the base and then initialize it statically. Not sure what the best solution is here.

Quoted 7 lines
arch/arm/mach-imx/platsmp.c new file +7 -0
+static struct map_desc scu_io_desc __initdata = {
+	.virtual	= IMX_SCU_VIRT_BASE,
+	.pfn		= 0, /* run-time */
+	.length		= SZ_4K,
+	.type		= MT_DEVICE,
+};
+

arch/arm/mach-imx/platsmp.c line 43

Quoted 10 lines
arch/arm/mach-imx/platsmp.c new file +10 -0
+void __init imx_scu_map_io(void)
+{
+	unsigned long base;
+
+	/* Get SCU base */
+	asm("mrc p15, 4, %0, c15, c0, 0" : "=r" (base));
+
+	scu_io_desc.pfn = __phys_to_pfn(base);
+	iotable_init(&scu_io_desc, 1);
+}

Maybe we can simply define a platform-independent where the SCU gets mapped? That would get rid of most of the platform specific SCU code, at least for those platforms that can reliably read the scu base.

Quoted 15 lines
arch/arm/mach-imx/platsmp.c new file +15 -0
+/*
+ * Initialise the CPU possible map early - this describes the CPUs
+ * which may be present or become present in the system.
+ */
+void __init smp_init_cpus(void)
+{
+	int i, ncores;
+
+	ncores = scu_get_core_count(scu_base);
+
+	for (i = 0; i < ncores; i++)
+		set_cpu_possible(i, true);
+
+	set_smp_cross_call(gic_raise_softirq);
+}

arch/arm/mach-imx/platsmp.c line 86

Quoted 10 lines
arch/arm/mach-imx/platsmp.c new file +10 -0
+
+void imx_smp_prepare(void)
+{
+	scu_enable(scu_base);
+}
+
+void __init platform_smp_prepare_cpus(unsigned int max_cpus)
+{
+	imx_smp_prepare();
+}

Then these functions could also be moved into the smp_scu file as generic helpers that can be used by all similar platforms.

Arnd

#43 lore raw

PATCH 4/6 arm/imx6q: add smp and cpu hotplug support

Quoted 22 lines · Arnd Bergmann
Quoted 21 lines · On Tuesday 06 September 2011 17:58:38 Shawn Guo wrote:

It adds smp and cpu hotplug support for imx6q.

arch/arm/mach-imx/localtimer.c new file +20 -0
+static u32 twd_saved_regs[4];
+static int twd_irq;
+
+/*
+ * Resuming from ARM Dormant/Shutdown mode, the boot procedure will
+ * re-setup local timer for secondary cores.  For primary core, it
+ * has to take care of itself with the following pair of functions
+ * during suspend/resume.
+ */
+void imx_local_timer_pre_suspend(void)
+{
+	twd_saved_regs[0] = __raw_readl(twd_base + TWD_TIMER_LOAD);
+	twd_saved_regs[1] = __raw_readl(twd_base + TWD_TIMER_COUNTER);
+	twd_saved_regs[2] = __raw_readl(twd_base + TWD_TIMER_CONTROL);
+	twd_saved_regs[3] = __raw_readl(twd_base + TWD_TIMER_INTSTAT);
+}
+
+void imx_local_timer_post_resume(void)
+{
+	__raw_writel(twd_saved_regs[0], twd_base + TWD_TIMER_LOAD);
Quoted 9 lines

arch/arm/mach-imx/localtimer.c line 45

Quoted 6 lines
arch/arm/mach-imx/localtimer.c new file +6 -0
+	__raw_writel(twd_saved_regs[1], twd_base + TWD_TIMER_COUNTER);
+	__raw_writel(twd_saved_regs[2], twd_base + TWD_TIMER_CONTROL);
+	__raw_writel(twd_saved_regs[3], twd_base + TWD_TIMER_INTSTAT);
+
+	gic_enable_ppi(twd_irq);
+}

readl_relaxed()?

Ok. You get the best judgement on this.

Quoted 9 lines

arch/arm/mach-imx/platsmp.c line 25

Quoted 5 lines
arch/arm/mach-imx/platsmp.c new file +5 -0
+extern void v7_secondary_startup(void);
+
+#define IMX_SCU_VIRT_BASE	0xf4a00000
+
+static void __iomem *scu_base = ((void __iomem *)(IMX_SCU_VIRT_BASE));

It's a little bit silly to have a variable for the base and then initialize it statically. Not sure what the best solution is here.

I have to admit that this scu mapping code was cloned from highbank :)

Quoted 13 lines
Quoted 13 lines
arch/arm/mach-imx/platsmp.c new file +13 -0
+static struct map_desc scu_io_desc __initdata = {
+	.virtual	= IMX_SCU_VIRT_BASE,
+	.pfn		= 0, /* run-time */
+	.length		= SZ_4K,
+	.type		= MT_DEVICE,
+};
+
+void __init imx_scu_map_io(void)
+{
+	unsigned long base;
+
+	/* Get SCU base */
+	asm("mrc p15, 4, %0, c15, c0, 0" : "=r" (base));
Quoted 9 lines

arch/arm/mach-imx/platsmp.c line 43

Quoted 4 lines
arch/arm/mach-imx/platsmp.c new file +4 -0
+
+	scu_io_desc.pfn = __phys_to_pfn(base);
+	iotable_init(&scu_io_desc, 1);
+}

Maybe we can simply define a platform-independent where the SCU gets mapped? That would get rid of most of the platform specific SCU code, at least for those platforms that can reliably read the scu base.

Yes, if we can find a virtual base working for all platforms. The scu virtual base needs to be available before dynamic mapping gets ready, so it has to be static mapping.

Quoted 29 lines
Quoted 15 lines
arch/arm/mach-imx/platsmp.c new file +15 -0
+/*
+ * Initialise the CPU possible map early - this describes the CPUs
+ * which may be present or become present in the system.
+ */
+void __init smp_init_cpus(void)
+{
+	int i, ncores;
+
+	ncores = scu_get_core_count(scu_base);
+
+	for (i = 0; i < ncores; i++)
+		set_cpu_possible(i, true);
+
+	set_smp_cross_call(gic_raise_softirq);
+}

arch/arm/mach-imx/platsmp.c line 86

Quoted 10 lines
arch/arm/mach-imx/platsmp.c new file +10 -0
+
+void imx_smp_prepare(void)
+{
+	scu_enable(scu_base);
+}
+
+void __init platform_smp_prepare_cpus(unsigned int max_cpus)
+{
+	imx_smp_prepare();
+}

Then these functions could also be moved into the smp_scu file as generic helpers that can be used by all similar platforms.

Signature · 2 lines
Regards,
Shawn
#44 lore raw

PATCH 4/6 arm/imx6q: add smp and cpu hotplug support

Quoted 32 lines · Shawn Guo
Quoted 22 lines · Arnd Bergmann
Quoted 21 lines · On Tuesday 06 September 2011 17:58:38 Shawn Guo wrote:

It adds smp and cpu hotplug support for imx6q.

arch/arm/mach-imx/localtimer.c new file +20 -0
+static u32 twd_saved_regs[4];
+static int twd_irq;
+
+/*
+ * Resuming from ARM Dormant/Shutdown mode, the boot procedure will
+ * re-setup local timer for secondary cores. ?For primary core, it
+ * has to take care of itself with the following pair of functions
+ * during suspend/resume.
+ */
+void imx_local_timer_pre_suspend(void)
+{
+ ? twd_saved_regs[0] = __raw_readl(twd_base + TWD_TIMER_LOAD);
+ ? twd_saved_regs[1] = __raw_readl(twd_base + TWD_TIMER_COUNTER);
+ ? twd_saved_regs[2] = __raw_readl(twd_base + TWD_TIMER_CONTROL);
+ ? twd_saved_regs[3] = __raw_readl(twd_base + TWD_TIMER_INTSTAT);
+}
+
+void imx_local_timer_post_resume(void)
+{
+ ? __raw_writel(twd_saved_regs[0], twd_base + TWD_TIMER_LOAD);
Quoted 9 lines

arch/arm/mach-imx/hotplug.c line 20

Quoted 6 lines

+ ? __raw_writel(twd_saved_regs[1], twd_base + TWD_TIMER_COUNTER);
+ ? __raw_writel(twd_saved_regs[2], twd_base + TWD_TIMER_CONTROL);
+ ? __raw_writel(twd_saved_regs[3], twd_base + TWD_TIMER_INTSTAT);

arch/arm/mach-imx/hotplug.c new file +3 -0
+
+ ? gic_enable_ppi(twd_irq);
+}

readl_relaxed()?

Quoted 2 lines

Ok. ?You get the best judgement on this.

You don't have to save local timer registers any more. The local timer is always re-configued and this is already handled in common kernel.

You can drop above change and test your patches. I am sure they will still work.

#45 lore raw

PATCH 4/6 arm/imx6q: add smp and cpu hotplug support

Quoted 33 lines · Santosh
Quoted 32 lines · Shawn Guo
Quoted 31 lines · Arnd Bergmann
Quoted 17 lines · On Tuesday 06 September 2011 17:58:38 Shawn Guo wrote:

It adds smp and cpu hotplug support for imx6q.

arch/arm/mach-imx/localtimer.c new file +16 -0
+static u32 twd_saved_regs[4];
+static int twd_irq;
+
+/*
+ * Resuming from ARM Dormant/Shutdown mode, the boot procedure will
+ * re-setup local timer for secondary cores. ?For primary core, it
+ * has to take care of itself with the following pair of functions
+ * during suspend/resume.
+ */
+void imx_local_timer_pre_suspend(void)
+{
+ ? twd_saved_regs[0] = __raw_readl(twd_base + TWD_TIMER_LOAD);
+ ? twd_saved_regs[1] = __raw_readl(twd_base + TWD_TIMER_COUNTER);
+ ? twd_saved_regs[2] = __raw_readl(twd_base + TWD_TIMER_CONTROL);
+ ? twd_saved_regs[3] = __raw_readl(twd_base + TWD_TIMER_INTSTAT);
+}

arch/arm/mach-imx/localtimer.c line 45

Quoted 10 lines
arch/arm/mach-imx/localtimer.c new file +10 -0
+
+void imx_local_timer_post_resume(void)
+{
+ ? __raw_writel(twd_saved_regs[0], twd_base + TWD_TIMER_LOAD);
+ ? __raw_writel(twd_saved_regs[1], twd_base + TWD_TIMER_COUNTER);
+ ? __raw_writel(twd_saved_regs[2], twd_base + TWD_TIMER_CONTROL);
+ ? __raw_writel(twd_saved_regs[3], twd_base + TWD_TIMER_INTSTAT);
+
+ ? gic_enable_ppi(twd_irq);
+}

readl_relaxed()?

Quoted 8 lines
Quoted 2 lines

Ok. ?You get the best judgement on this.

You don't have to save local timer registers any more. The local timer is always re-configued and this is already handled in common kernel.

You can drop above change and test your patches. I am sure they will still work.

Ah, yes. This registers saving/restoring was added together with cpu0 twd_irq enabling when I use git_reinit() approach, which turns out to be unnecessary. This pair of imx_local_timer_pre_suspend/resume can totally be removed now, since "CPU PM notifiers" patches come to play.

Thanks for catching this, Santosh.

Signature · 2 lines
Regards,
Shawn
author
#46 lore raw

PATCH 5/6 arm/imx6q: add device tree machine support

In reply to Shawn Guo

It adds generic device tree based machine support for imx6q.

---
 arch/arm/mach-imx/Kconfig               |   13 +++++
 arch/arm/mach-imx/Makefile              |    1 +
 arch/arm/mach-imx/mach-imx6q.c          |   81 +++++++++++++++++++++++++++++++
 arch/arm/mm/Kconfig                     |    2 +-
 arch/arm/plat-mxc/include/mach/common.h |   13 +++++
 5 files changed, 109 insertions(+), 1 deletions(-)
 create mode 100644 arch/arm/mach-imx/mach-imx6q.c
arch/arm/mach-imx/Kconfig +13 -0
index 13e0301..3364b59 100644
@@ -624,3 +624,16 @@ config MACH_VPR200
 	  configurations for the board and its peripherals.
 
 endif
+
+if ARCH_MX6
+comment "i.MX6 machines:"
+
+config MACH_IMX6Q
+	bool "Support i.MX6 Quad platforms from device tree"
+	select SOC_IMX6Q
+	select USE_OF
+	help
+	  Include support for Freescale i.MX6 Quad based platforms
+	  using the device tree for discovery
+
+endif
arch/arm/mach-imx/Makefile +1 -0
index d46b2e7..84bd18c 100644
@@ -71,3 +71,4 @@ obj-$(CONFIG_SMP) += platsmp.o
 obj-$(CONFIG_HOTPLUG_CPU) += hotplug.o
 obj-$(CONFIG_LOCAL_TIMERS) += localtimer.o
 obj-$(CONFIG_SOC_IMX6Q) += clock-imx6q.o
+obj-$(CONFIG_MACH_IMX6Q) += mach-imx6q.o
arch/arm/mach-imx/mach-imx6q.c new file +81 -0

81 lines not on this page · raw message

arch/arm/mm/Kconfig +1 -1
index 88633fe..c3ce146 100644
@@ -822,7 +822,7 @@ config CACHE_L2X0
 		   REALVIEW_EB_A9MP || SOC_IMX35 || SOC_IMX31 || MACH_REALVIEW_PBX || \
 		   ARCH_NOMADIK || ARCH_OMAP4 || ARCH_EXYNOS4 || ARCH_TEGRA || \
 		   ARCH_U8500 || ARCH_VEXPRESS_CA9X4 || ARCH_SHMOBILE || \
-		   ARCH_PRIMA2 || ARCH_ZYNQ || ARCH_CNS3XXX
+		   ARCH_PRIMA2 || ARCH_ZYNQ || ARCH_CNS3XXX || ARCH_MX6
 	default y
 	select OUTER_CACHE
 	select OUTER_CACHE_SYNC
arch/arm/plat-mxc/include/mach/common.h +13 -0
index 73da910..ff86063 100644
@@ -64,6 +64,8 @@ extern int mx51_clocks_init(unsigned long ckil, unsigned long osc,
 			unsigned long ckih1, unsigned long ckih2);
 extern int mx53_clocks_init(unsigned long ckil, unsigned long osc,
 			unsigned long ckih1, unsigned long ckih2);
+extern int mx6q_clocks_init(unsigned long ckil, unsigned long osc,
+			unsigned long ckih1, unsigned long ckih2);
 extern struct platform_device *mxc_register_gpio(char *name, int id,
 	resource_size_t iobase, resource_size_t iosize, int irq, int irq_high);
 extern int mxc_register_device(struct platform_device *pdev, void *data);
@@ -73,6 +75,17 @@ extern void mx51_efikamx_reset(void);
 extern int mx53_revision(void);
 extern int mx53_display_revision(void);
 
+#ifdef CONFIG_DEBUG_LL
+extern void imx_lluart_map_io(void);
+#else
+static inline void imx_lluart_map_io(void) {}
+#endif
+#ifdef CONFIG_SMP
+extern void imx_scu_map_io(void);
+#else
+static inline void imx_scu_map_io(void) {}
+#endif
 extern void imx_enable_cpu(int cpu, bool enable);
 extern void imx_set_cpu_jump(int cpu, void *jump_addr);
+extern void imx_gpc_init(void);
 #endif
Signature · 1 line
1.7.4.1
#47 lore raw

PATCH 5/6 arm/imx6q: add device tree machine support

Quoted 11 lines · On Tuesday 06 September 2011 17:58:39 Shawn Guo wrote:
arch/arm/mach-imx/Kconfig +3 -0
index 13e0301..3364b59 100644
@@ -624,3 +624,16 @@ config MACH_VPR200
 	  configurations for the board and its peripherals.
 
 endif
+
+if ARCH_MX6
+comment "i.MX6 machines:"

arch/arm/mach-imx/Kconfig config MACH_VPR200 · line 639

Quoted 10 lines
arch/arm/mach-imx/Kconfig +10 -0
+
+config MACH_IMX6Q
+	bool "Support i.MX6 Quad platforms from device tree"
+	select SOC_IMX6Q
+	select USE_OF
+	help
+	  Include support for Freescale i.MX6 Quad based platforms
+	  using the device tree for discovery
+
+endif

As we have done on zynq and prima2, I would suggest not to add multiple machines types at all. You already have the intialization in a generic imx6q file, it would be logical to get rid of the configuration entry as well.

What you can still have is config options for optional drivers that might be needed for one soc but not another.

Arnd

#48 lore raw

PATCH 5/6 arm/imx6q: add device tree machine support

Quoted 20 lines · Arnd Bergmann
Quoted 18 lines · On Tuesday 06 September 2011 17:58:39 Shawn Guo wrote:
arch/arm/mach-imx/Kconfig +10 -0
index 13e0301..3364b59 100644
@@ -624,3 +624,16 @@ config MACH_VPR200
 	  configurations for the board and its peripherals.
 
 endif
+
+if ARCH_MX6
+comment "i.MX6 machines:"
+
+config MACH_IMX6Q
+	bool "Support i.MX6 Quad platforms from device tree"
+	select SOC_IMX6Q
+	select USE_OF
+	help
+	  Include support for Freescale i.MX6 Quad based platforms
Quoted 9 lines

arch/arm/mach-imx/Kconfig config MACH_VPR200 · line 639

Quoted 3 lines
arch/arm/mach-imx/Kconfig +3 -0
+	  using the device tree for discovery
+
+endif

As we have done on zynq and prima2, I would suggest not to add multiple machines types at all. You already have the intialization in a generic imx6q file, it would be logical to get rid of the configuration entry as well.

This MACH_IMX6Q was added to make the IMX6Q Kconfig hierarchy look consistent with other SoCs in arch/arm/mach-imx/Kconfig. If you do not like it, I can kill it.

Signature · 2 lines
Regards,
Shawn
#49 lore raw

PATCH 5/6 arm/imx6q: add device tree machine support

Quoted 30 lines · On Wednesday 07 September 2011 11:07:34 Shawn Guo wrote:
Quoted 20 lines · Arnd Bergmann
Quoted 18 lines · On Tuesday 06 September 2011 17:58:39 Shawn Guo wrote:
arch/arm/mach-imx/Kconfig +10 -0
index 13e0301..3364b59 100644
@@ -624,3 +624,16 @@ config MACH_VPR200
      configurations for the board and its peripherals.
 
 endif
+
+if ARCH_MX6
+comment "i.MX6 machines:"
+
+config MACH_IMX6Q
+   bool "Support i.MX6 Quad platforms from device tree"
+   select SOC_IMX6Q
+   select USE_OF
+   help
+     Include support for Freescale i.MX6 Quad based platforms
Quoted 9 lines

arch/arm/mach-imx/Kconfig config MACH_VPR200 · line 639

Quoted 3 lines
arch/arm/mach-imx/Kconfig +3 -0
+     using the device tree for discovery
+
+endif

As we have done on zynq and prima2, I would suggest not to add multiple machines types at all. You already have the intialization in a generic imx6q file, it would be logical to get rid of the configuration entry as well.

Quoted 3 lines

This MACH_IMX6Q was added to make the IMX6Q Kconfig hierarchy look consistent with other SoCs in arch/arm/mach-imx/Kconfig. If you do not like it, I can kill it.

Yes, plase do. I think we should in the long run get more platforms to do the same, it will be a sign that mx6 is part of the new generation.

Arnd

author
#50 lore raw

PATCH 6/6 arm/imx6q: add suspend/resume support

In reply to Shawn Guo

It adds suspend/resume support for imx6q.

---
 arch/arm/mach-imx/Makefile              |    2 +-
 arch/arm/mach-imx/pm-imx6q.c            |   63 +++++++++++++++++++++++++++++++
 arch/arm/plat-mxc/include/mach/common.h |   12 ++++++
 3 files changed, 76 insertions(+), 1 deletions(-)
 create mode 100644 arch/arm/mach-imx/pm-imx6q.c
arch/arm/mach-imx/Makefile +1 -1
index 84bd18c..531da76 100644
@@ -70,5 +70,5 @@ obj-$(CONFIG_CPU_V7) += head-v7.o
 obj-$(CONFIG_SMP) += platsmp.o
 obj-$(CONFIG_HOTPLUG_CPU) += hotplug.o
 obj-$(CONFIG_LOCAL_TIMERS) += localtimer.o
-obj-$(CONFIG_SOC_IMX6Q) += clock-imx6q.o
+obj-$(CONFIG_SOC_IMX6Q) += clock-imx6q.o pm-imx6q.o
 obj-$(CONFIG_MACH_IMX6Q) += mach-imx6q.o
arch/arm/mach-imx/pm-imx6q.c new file +63 -0

63 lines not on this page · raw message

arch/arm/plat-mxc/include/mach/common.h +12 -0
index ff86063..7c3d078 100644
@@ -80,12 +80,24 @@ extern void imx_lluart_map_io(void);
 #else
 static inline void imx_lluart_map_io(void) {}
 #endif
+extern void v7_cpu_resume(void);
 #ifdef CONFIG_SMP
 extern void imx_scu_map_io(void);
+extern void imx_smp_prepare(void);
 #else
 static inline void imx_scu_map_io(void) {}
+static inline void imx_smp_prepare(void) {}
 #endif
 extern void imx_enable_cpu(int cpu, bool enable);
 extern void imx_set_cpu_jump(int cpu, void *jump_addr);
 extern void imx_gpc_init(void);
+extern void imx_gpc_pre_suspend(void);
+extern void imx_gpc_post_resume(void);
+#ifdef CONFIG_LOCAL_TIMERS
+extern void imx_local_timer_pre_suspend(void);
+extern void imx_local_timer_post_resume(void);
+#else
+static inline void imx_local_timer_pre_suspend(void) {}
+static inline void imx_local_timer_post_resume(void) {}
+#endif
 #endif
Signature · 1 line
1.7.4.1
#52 lore raw

PATCH 6/6 arm/imx6q: add suspend/resume support

In reply to Shawn Guo
Quoted 6 lines
(quoted diff) +6 -0
+
+static int imx6q_pm_enter(suspend_state_t state)
+{
+ ? ? ? switch (state) {
+ ? ? ? case PM_SUSPEND_MEM:
+ ? ? ? ? ? ? ? imx_local_timer_pre_suspend();

Review

Quoted 10 lines
(quoted diff) +10 -0
+ ? ? ? ? ? ? ? imx_gpc_pre_suspend();
+ ? ? ? ? ? ? ? outer_flush_all();
+ ? ? ? ? ? ? ? outer_disable();
+ ? ? ? ? ? ? ? imx_set_cpu_jump(0, v7_cpu_resume);
+
+ ? ? ? ? ? ? ? /* Zzz ... */
+ ? ? ? ? ? ? ? cpu_suspend(0, imx6q_suspend_finish);
+
+ ? ? ? ? ? ? ? imx_smp_prepare();
+ ? ? ? ? ? ? ? l2x0_of_init(0, ~0UL);

it is pretty clear and good. i think we can refine arch/arm/mach-prima2/pm.c to the way you are suspending/resuming l2. on prima2, l2 will totally lose power in suspend cycle. i remember you once said imx6q will retain l2 in suspend cycle?

arch/arm/mach-imx/pm-imx6q.c line 26

Quoted 9 lines

+ ? ? ? ? ? ? ? imx_gpc_post_resume();
+ ? ? ? ? ? ? ? imx_local_timer_post_resume();
+ ? ? ? ? ? ? ? break;
+ ? ? ? default:
+ ? ? ? ? ? ? ? return -EINVAL;
+ ? ? ? }

arch/arm/mach-imx/pm-imx6q.c new file +3 -0
+
+ ? ? ? return 0;
+}

thanks
barry

#53 lore raw

PATCH 6/6 arm/imx6q: add suspend/resume support

Quoted 13 lines · Barry Song
Quoted 13 lines
(quoted diff) +13 -0
+
+static int imx6q_pm_enter(suspend_state_t state)
+{
+ ? ? ? switch (state) {
+ ? ? ? case PM_SUSPEND_MEM:
+ ? ? ? ? ? ? ? imx_local_timer_pre_suspend();
+ ? ? ? ? ? ? ? imx_gpc_pre_suspend();
+ ? ? ? ? ? ? ? outer_flush_all();
+ ? ? ? ? ? ? ? outer_disable();
+ ? ? ? ? ? ? ? imx_set_cpu_jump(0, v7_cpu_resume);
+
+ ? ? ? ? ? ? ? /* Zzz ... */
+ ? ? ? ? ? ? ? cpu_suspend(0, imx6q_suspend_finish);
Quoted 9 lines
Quoted 3 lines

+
+ ? ? ? ? ? ? ? imx_smp_prepare();
+ ? ? ? ? ? ? ? l2x0_of_init(0, ~0UL);

it is pretty clear and good. i think we can refine arch/arm/mach-prima2/pm.c to the way you are suspending/resuming l2. on prima2, l2 will totally lose power in suspend cycle. i remember you once said imx6q will retain l2 in suspend cycle?

Yes, if you lose L2 power in suspend, it's the easiest way for you to resume L2.

For my case which retains L2, I actually do not want to call this function which will invalidate L2. But since we still have problem to use rmk's generic suspend/resume updates (ARM: pm: add L2 cache cleaning for suspend), we have to flush the entire L2 on imx6q for now.

Regards,
Shawn

Quoted 15 lines

arch/arm/mach-imx/pm-imx6q.c line 26

Quoted 9 lines

+ ? ? ? ? ? ? ? imx_gpc_post_resume();
+ ? ? ? ? ? ? ? imx_local_timer_post_resume();
+ ? ? ? ? ? ? ? break;
+ ? ? ? default:
+ ? ? ? ? ? ? ? return -EINVAL;
+ ? ? ? }

arch/arm/mach-imx/pm-imx6q.c new file +3 -0
+
+ ? ? ? return 0;
+}

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

#54 lore raw

PATCH 6/6 arm/imx6q: add suspend/resume support

Quoted 7 lines · Shawn Guo

Yes, if you lose L2 power in suspend, it's the easiest way for you to resume L2.

For my case which retains L2, I actually do not want to call this function which will invalidate L2. But since we still have problem to use rmk's generic suspend/resume updates (ARM: pm: add L2 cache cleaning for suspend), we have to flush the entire L2 on imx6q for now.

OMAP44xx has the same problem but they re-initialize L2 on resume in their pre-cpu_resume() assembly code.

#55 lore raw

PATCH 6/6 arm/imx6q: add suspend/resume support

Quoted 4 lines · Russell King - ARM Linux
Quoted 3 lines · Shawn Guo

Yes, if you lose L2 power in suspend, it's the easiest way for you to resume L2.

Quoted 8 lines
Quoted 4 lines

For my case which retains L2, I actually do not want to call this function which will invalidate L2. But since we still have problem to use rmk's generic suspend/resume updates (ARM: pm: add L2 cache cleaning for suspend), we have to flush the entire L2 on imx6q for now.

OMAP44xx has the same problem but they re-initialize L2 on resume in their pre-cpu_resume() assembly code.

Are you suggesting that this might be the reason why imx6q has problem with your patch? Are we supposed to re-initialize L2 before calling into generic cpu_resume()?

Signature · 2 lines
Regards,
Shawn
#56 lore raw

PATCH 6/6 arm/imx6q: add suspend/resume support

Quoted 10 lines · Shawn Guo
Quoted 9 lines · Russell King - ARM Linux
Quoted 7 lines · Shawn Guo

Yes, if you lose L2 power in suspend, it's the easiest way for you to resume L2.

For my case which retains L2, I actually do not want to call this function which will invalidate L2. But since we still have problem to use rmk's generic suspend/resume updates (ARM: pm: add L2 cache cleaning for suspend), we have to flush the entire L2 on imx6q for now.

Quoted 5 lines
Quoted 3 lines

OMAP44xx has the same problem but they re-initialize L2 on resume in their pre-cpu_resume() assembly code.

Are you suggesting that this might be the reason why imx6q has problem with your patch?

Consider the mechanics of what is happening.

On suspend, when we enter cpu_suspend(), we assume the L2 cache is still enabled.

We _always_ assume that L1 cache state is lost, so we always flush the entire L1 cache.

As SoCs can (and do) preserve the L2 contents over suspend/resume cycles, we leave it to the platform's finisher to decide whether it needs to flush the entire L2 cache to RAM or not.

If L2 is preserved, then we want to ensure that as much data as possible is retained in the L2 cache (if the hardware preserves its contents, we don't want waste time flushing data out of the cache needlessly - especially if we're using these paths for cpuidle.) However, we need access to a certain amount of data to bring the system back up, and as the L2 cache typically will not be searched before the MMU is enabled, we have to flush out a certain minimal amount of data (the location of the stacked restore information and the stacked restore information itself.)

However, we don't flush out anything else from the L2 cache.

Now, upon resume, the resume code will be able to read the data it needs to restore the system as we ensured that was flushed out to memory - as I mentioned above, the L2 cache won't be searched for this irrespective of whether the control registers have enabled it or not.

We will continue to the point where we hit the first bit of information stored in L2, which will probably be the stacked SVC register set. If at this point we're not able to search the L2 cache, then we'll read stale data from the backing memory instead, and the system will crash.

Consider what generic code could do about this - if we flushed out that register set to memory, then we could get past that point - but we then would need to call a function to enable the L2 cache. What if that function needs data which is sitting in the L2 cache to function (eg, it may need values from the device tree). We would need to ensure that that data were also flushed out of the L2 cache. What about spinlocks? Maybe some other CPU has dragged the spinlock data into the L2 cache. That gets _much_ harder to solve.

Now to the physical act of enabling the L2 cache. The L2 cache control registers are subject to security restrictions when running in non-secure mode, needing platform specific SMC calls to reprogram the cache. Generic code is unable to do this.

Hence why it's left up to the platform to figure out how to enable the L2 cache before calling cpu_resume(). The platform is best placed to work out what it needs to do to setup the L2 cache so that the L2 cache is available by the time the system control register is written, enabling the MMU and caches.

Quoted 2 lines

Are we supposed to re-initialize L2 before calling into generic cpu_resume()?

So, the above is the long way of saying "yes" to this question. I hope it gives the full picture about why this is so.

#57 lore raw

PATCH 6/6 arm/imx6q: add suspend/resume support

Quoted 71 lines · Russell King - ARM Linux
Quoted 10 lines · Shawn Guo
Quoted 9 lines · Russell King - ARM Linux
Quoted 7 lines · Shawn Guo

Yes, if you lose L2 power in suspend, it's the easiest way for you to resume L2.

For my case which retains L2, I actually do not want to call this function which will invalidate L2. But since we still have problem to use rmk's generic suspend/resume updates (ARM: pm: add L2 cache cleaning for suspend), we have to flush the entire L2 on imx6q for now.

Quoted 5 lines
Quoted 3 lines

OMAP44xx has the same problem but they re-initialize L2 on resume in their pre-cpu_resume() assembly code.

Are you suggesting that this might be the reason why imx6q has problem with your patch?

Consider the mechanics of what is happening.

On suspend, when we enter cpu_suspend(), we assume the L2 cache is still enabled.

We _always_ assume that L1 cache state is lost, so we always flush the entire L1 cache.

As SoCs can (and do) preserve the L2 contents over suspend/resume cycles, we leave it to the platform's finisher to decide whether it needs to flush the entire L2 cache to RAM or not.

If L2 is preserved, then we want to ensure that as much data as possible is retained in the L2 cache (if the hardware preserves its contents, we don't want waste time flushing data out of the cache needlessly - especially if we're using these paths for cpuidle.) However, we need access to a certain amount of data to bring the system back up, and as the L2 cache typically will not be searched before the MMU is enabled, we have to flush out a certain minimal amount of data (the location of the stacked restore information and the stacked restore information itself.)

However, we don't flush out anything else from the L2 cache.

Now, upon resume, the resume code will be able to read the data it needs to restore the system as we ensured that was flushed out to memory - as I mentioned above, the L2 cache won't be searched for this irrespective of whether the control registers have enabled it or not.

We will continue to the point where we hit the first bit of information stored in L2, which will probably be the stacked SVC register set. If at this point we're not able to search the L2 cache, then we'll read stale data from the backing memory instead, and the system will crash.

Consider what generic code could do about this - if we flushed out that register set to memory, then we could get past that point - but we then would need to call a function to enable the L2 cache. What if that function needs data which is sitting in the L2 cache to function (eg, it may need values from the device tree). We would need to ensure that that data were also flushed out of the L2 cache. What about spinlocks? Maybe some other CPU has dragged the spinlock data into the L2 cache. That gets _much_ harder to solve.

Now to the physical act of enabling the L2 cache. The L2 cache control registers are subject to security restrictions when running in non-secure mode, needing platform specific SMC calls to reprogram the cache. Generic code is unable to do this.

Hence why it's left up to the platform to figure out how to enable the L2 cache before calling cpu_resume(). The platform is best placed to work out what it needs to do to setup the L2 cache so that the L2 cache is available by the time the system control register is written, enabling the MMU and caches.

Quoted 6 lines
Quoted 2 lines

Are we supposed to re-initialize L2 before calling into generic cpu_resume()?

So, the above is the long way of saying "yes" to this question. I hope it gives the full picture about why this is so.

I could not agree more. On top of that l2x0_of_init invalidates L2 which is not what we want on retention.
Furthermore, parsing the device tree every given suspend, as fast as it can be, that seems silly to me for registers that will never ever change (maybe perf counters, but perf will save them). And if they do change parsing them from the device tree might not be what we want.

Let's save those registers once for all at boot and reprogramme them before jumping to cpu_resume, that's by far the best solution.

#58 lore raw

PATCH 6/6 arm/imx6q: add suspend/resume support

Quoted 86 lines · Lorenzo Pieralisi
Quoted 71 lines · Russell King - ARM Linux
Quoted 10 lines · Shawn Guo
Quoted 9 lines · Russell King - ARM Linux
Quoted 7 lines · Shawn Guo

Yes, if you lose L2 power in suspend, it's the easiest way for you to resume L2.

For my case which retains L2, I actually do not want to call this function which will invalidate L2. But since we still have problem to use rmk's generic suspend/resume updates (ARM: pm: add L2 cache cleaning for suspend), we have to flush the entire L2 on imx6q for now.

Quoted 5 lines
Quoted 3 lines

OMAP44xx has the same problem but they re-initialize L2 on resume in their pre-cpu_resume() assembly code.

Are you suggesting that this might be the reason why imx6q has problem with your patch?

Consider the mechanics of what is happening.

On suspend, when we enter cpu_suspend(), we assume the L2 cache is still enabled.

We _always_ assume that L1 cache state is lost, so we always flush the entire L1 cache.

As SoCs can (and do) preserve the L2 contents over suspend/resume cycles, we leave it to the platform's finisher to decide whether it needs to flush the entire L2 cache to RAM or not.

If L2 is preserved, then we want to ensure that as much data as possible is retained in the L2 cache (if the hardware preserves its contents, we don't want waste time flushing data out of the cache needlessly - especially if we're using these paths for cpuidle.) However, we need access to a certain amount of data to bring the system back up, and as the L2 cache typically will not be searched before the MMU is enabled, we have to flush out a certain minimal amount of data (the location of the stacked restore information and the stacked restore information itself.)

However, we don't flush out anything else from the L2 cache.

Now, upon resume, the resume code will be able to read the data it needs to restore the system as we ensured that was flushed out to memory - as I mentioned above, the L2 cache won't be searched for this irrespective of whether the control registers have enabled it or not.

We will continue to the point where we hit the first bit of information stored in L2, which will probably be the stacked SVC register set. If at this point we're not able to search the L2 cache, then we'll read stale data from the backing memory instead, and the system will crash.

Consider what generic code could do about this - if we flushed out that register set to memory, then we could get past that point - but we then would need to call a function to enable the L2 cache. What if that function needs data which is sitting in the L2 cache to function (eg, it may need values from the device tree). We would need to ensure that that data were also flushed out of the L2 cache. What about spinlocks? Maybe some other CPU has dragged the spinlock data into the L2 cache. That gets _much_ harder to solve.

Now to the physical act of enabling the L2 cache. The L2 cache control registers are subject to security restrictions when running in non-secure mode, needing platform specific SMC calls to reprogram the cache. Generic code is unable to do this.

Hence why it's left up to the platform to figure out how to enable the L2 cache before calling cpu_resume(). The platform is best placed to work out what it needs to do to setup the L2 cache so that the L2 cache is available by the time the system control register is written, enabling the MMU and caches.

Quoted 6 lines
Quoted 2 lines

Are we supposed to re-initialize L2 before calling into generic cpu_resume()?

So, the above is the long way of saying "yes" to this question. I hope it gives the full picture about why this is so.

I could not agree more. On top of that l2x0_of_init invalidates L2 which is not what we want on retention.
Furthermore, parsing the device tree every given suspend, as fast as it can be, that seems silly to me for registers that will never ever change (maybe perf counters, but perf will save them). And if they do change parsing them from the device tree might not be what we want.

Quoted 3 lines

Let's save those registers once for all at boot and reprogramme them before jumping to cpu_resume, that's by far the best solution.

For cases like imx6q where L2 content will be retained across the suspend/resume cycle, I agree that this is the best. I used l2x0_of_init() approach for imx6q as a temp workaround, because I have something to sort out with applying rmk's patches.

However, I still think l2x0_of_init() reinitialization is the best approach for cases like Prima2 where even L2 content gets lost during suspend/resume cycle.

Signature · 2 lines
Regards,
Shawn
#59 lore raw

PATCH 6/6 arm/imx6q: add suspend/resume support

In reply to Russell King - ARM Linux

2011/9/9 Russell King - ARM Linux <[email protected]>:

Quoted 65 lines · Shawn Guo
Quoted 10 lines · Russell King - ARM Linux
Quoted 9 lines · Shawn Guo
Quoted 7 lines

Yes, if you lose L2 power in suspend, it's the easiest way for you to resume L2.

For my case which retains L2, I actually do not want to call this function which will invalidate L2. ?But since we still have problem to use rmk's generic suspend/resume updates (ARM: pm: add L2 cache cleaning for suspend), we have to flush the entire L2 on imx6q for now.

Quoted 5 lines
Quoted 3 lines

OMAP44xx has the same problem but they re-initialize L2 on resume in their pre-cpu_resume() assembly code.

Are you suggesting that this might be the reason why imx6q has problem with your patch?

Consider the mechanics of what is happening.

On suspend, when we enter cpu_suspend(), we assume the L2 cache is still enabled.

We _always_ assume that L1 cache state is lost, so we always flush the entire L1 cache.

As SoCs can (and do) preserve the L2 contents over suspend/resume cycles, we leave it to the platform's finisher to decide whether it needs to flush the entire L2 cache to RAM or not.

If L2 is preserved, then we want to ensure that as much data as possible is retained in the L2 cache (if the hardware preserves its contents, we don't want waste time flushing data out of the cache needlessly - especially if we're using these paths for cpuidle.) ?However, we need access to a certain amount of data to bring the system back up, and as the L2 cache typically will not be searched before the MMU is enabled, we have to flush out a certain minimal amount of data (the location of the stacked restore information and the stacked restore information itself.)

However, we don't flush out anything else from the L2 cache.

Now, upon resume, the resume code will be able to read the data it needs to restore the system as we ensured that was flushed out to memory - as I mentioned above, the L2 cache won't be searched for this irrespective of whether the control registers have enabled it or not.

We will continue to the point where we hit the first bit of information stored in L2, which will probably be the stacked SVC register set. ?If at this point we're not able to search the L2 cache, then we'll read stale data from the backing memory instead, and the system will crash.

Consider what generic code could do about this - if we flushed out that register set to memory, then we could get past that point - but we then would need to call a function to enable the L2 cache. ?What if that function needs data which is sitting in the L2 cache to function (eg, it may need values from the device tree). ?We would need to ensure that that data were also flushed out of the L2 cache. ?What about spinlocks? ?Maybe some other CPU has dragged the spinlock data into the L2 cache. ?That gets _much_ harder to solve.

Now to the physical act of enabling the L2 cache. ?The L2 cache control registers are subject to security restrictions when running in non-secure mode, needing platform specific SMC calls to reprogram the cache. ?Generic code is unable to do this.

Quoted 5 lines

Hence why it's left up to the platform to figure out how to enable the L2 cache before calling cpu_resume(). ?The platform is best placed to work out what it needs to do to setup the L2 cache so that the L2 cache is available by the time the system control register is written, enabling the MMU and caches.

Thanks for your great document to explain what happen. it is really clear and good.

but in case l2 is not preserved and it is lost in suspend cycles, we will flush all data out of l2 before suspending. and we don't need to re-enable l2
before calling cpu_resume() too since nobody will hit data in l2 not in memory. after resuming, we just re-init the l2 like cold boot. then l2x0_of_init() and moving l2x0_init out of init section might be suitable?

Quoted 7 lines
Quoted 3 lines

Are we supposed to re-initialize L2 before calling into generic cpu_resume()?

So, the above is the long way of saying "yes" to this question. ?I hope it gives the full picture about why this is so.

thanks
barry

#60 lore raw

PATCH 6/6 arm/imx6q: add suspend/resume support

In reply to Russell King - ARM Linux

Hi Russell,

Really appreciate the explanation.

Quoted 60 lines · Russell King - ARM Linux
Quoted 10 lines · Shawn Guo
Quoted 9 lines · Russell King - ARM Linux
Quoted 7 lines · Shawn Guo

Yes, if you lose L2 power in suspend, it's the easiest way for you to resume L2.

For my case which retains L2, I actually do not want to call this function which will invalidate L2. But since we still have problem to use rmk's generic suspend/resume updates (ARM: pm: add L2 cache cleaning for suspend), we have to flush the entire L2 on imx6q for now.

Quoted 5 lines
Quoted 3 lines

OMAP44xx has the same problem but they re-initialize L2 on resume in their pre-cpu_resume() assembly code.

Are you suggesting that this might be the reason why imx6q has problem with your patch?

Consider the mechanics of what is happening.

On suspend, when we enter cpu_suspend(), we assume the L2 cache is still enabled.

We _always_ assume that L1 cache state is lost, so we always flush the entire L1 cache.

As SoCs can (and do) preserve the L2 contents over suspend/resume cycles, we leave it to the platform's finisher to decide whether it needs to flush the entire L2 cache to RAM or not.

If L2 is preserved, then we want to ensure that as much data as possible is retained in the L2 cache (if the hardware preserves its contents, we don't want waste time flushing data out of the cache needlessly - especially if we're using these paths for cpuidle.) However, we need access to a certain amount of data to bring the system back up, and as the L2 cache typically will not be searched before the MMU is enabled, we have to flush out a certain minimal amount of data (the location of the stacked restore information and the stacked restore information itself.)

However, we don't flush out anything else from the L2 cache.

Now, upon resume, the resume code will be able to read the data it needs to restore the system as we ensured that was flushed out to memory - as I mentioned above, the L2 cache won't be searched for this irrespective of whether the control registers have enabled it or not.

We will continue to the point where we hit the first bit of information stored in L2, which will probably be the stacked SVC register set. If at this point we're not able to search the L2 cache, then we'll read stale data from the backing memory instead, and the system will crash.

Consider what generic code could do about this - if we flushed out that register set to memory, then we could get past that point - but we then would need to call a function to enable the L2 cache. What if that function needs data which is sitting in the L2 cache to function (eg, it may need values from the device tree). We would need to ensure that that data were also flushed out of the L2 cache. What about spinlocks? Maybe some other CPU has dragged the spinlock data into the L2 cache. That gets _much_ harder to solve.

Quoted 5 lines

Now to the physical act of enabling the L2 cache. The L2 cache control registers are subject to security restrictions when running in non-secure mode, needing platform specific SMC calls to reprogram the cache. Generic code is unable to do this.

I could be very possibly wrong here. But isn't the core in secure mode upon reset? Do we really have to reprogram L2 through SMC calls there?

Quoted 6 lines

Hence why it's left up to the platform to figure out how to enable the L2 cache before calling cpu_resume(). The platform is best placed to work out what it needs to do to setup the L2 cache so that the L2 cache is available by the time the system control register is written, enabling the MMU and caches.

Quoted 6 lines
Quoted 2 lines

Are we supposed to re-initialize L2 before calling into generic cpu_resume()?

So, the above is the long way of saying "yes" to this question. I hope it gives the full picture about why this is so.

Yes, it does. Thanks, again.

Signature · 2 lines
Regards,
Shawn
#61 lore raw

PATCH 6/6 arm/imx6q: add suspend/resume support

Quoted 7 lines · Shawn Guo
Quoted 4 lines

Now to the physical act of enabling the L2 cache. The L2 cache control registers are subject to security restrictions when running in non-secure mode, needing platform specific SMC calls to reprogram the cache. Generic code is unable to do this.

I could be very possibly wrong here. But isn't the core in secure mode upon reset? Do we really have to reprogram L2 through SMC calls there?

It probably will be, but the core won't be running the resume function directly on reset. (No ARM CPU does this - not even the pre-security ones. They've traditionally run the boot loader first.)

Take a moment to think about this in terms of security of data stored on the secure side (where there maybe private keys stored.)

The kernel runs in the non-secure side of the partition. If it were to be entered on resume in secure mode, it could access those keys. That would be a really great security hole, which would make the whole thing pointless.

What would happen is the secure monitor ROM code gets control first, just like it does at normal boot time on secure devices. Eventually, the kernel will gain control but only after the secure monitor has switched to non-secure mode.

#62 lore raw

PATCH 6/6 arm/imx6q: add suspend/resume support

Quoted 6 lines · Russell King - ARM Linux
Quoted 5 lines · Shawn Guo
Quoted 4 lines

Now to the physical act of enabling the L2 cache. The L2 cache control registers are subject to security restrictions when running in non-secure mode, needing platform specific SMC calls to reprogram the cache. Generic code is unable to do this.

Quoted 7 lines
Quoted 2 lines

I could be very possibly wrong here. But isn't the core in secure mode upon reset? Do we really have to reprogram L2 through SMC calls there?

It probably will be, but the core won't be running the resume function directly on reset. (No ARM CPU does this - not even the pre-security ones. They've traditionally run the boot loader first.)

Some naive boot ROM may simply jump to the resume entry address saved in persistent register.

Quoted 12 lines

Take a moment to think about this in terms of security of data stored on the secure side (where there maybe private keys stored.)

The kernel runs in the non-secure side of the partition. If it were to be entered on resume in secure mode, it could access those keys. That would be a really great security hole, which would make the whole thing pointless.

What would happen is the secure monitor ROM code gets control first, just like it does at normal boot time on secure devices. Eventually, the kernel will gain control but only after the secure monitor has switched to non-secure mode.

Then the question is that for given bad boot ROM, whether kernel resume routine should stand up to fill the hole up.

Signature · 2 lines
Regards,
Shawn
#63 lore raw

PATCH 6/6 arm/imx6q: add suspend/resume support

Quoted 10 lines · Shawn Guo
Quoted 9 lines · Russell King - ARM Linux
Quoted 7 lines · Shawn Guo
Quoted 4 lines

Now to the physical act of enabling the L2 cache. The L2 cache control registers are subject to security restrictions when running in non-secure mode, needing platform specific SMC calls to reprogram the cache. Generic code is unable to do this.

I could be very possibly wrong here. But isn't the core in secure mode upon reset? Do we really have to reprogram L2 through SMC calls there?

Quoted 6 lines
Quoted 3 lines

It probably will be, but the core won't be running the resume function directly on reset. (No ARM CPU does this - not even the pre-security ones. They've traditionally run the boot loader first.)

Some naive boot ROM may simply jump to the resume entry address saved in persistent register.

That would mean that the platform code needs to deal with this too - and it's likely that it too is platform specific.

Quoted 2 lines

Then the question is that for given bad boot ROM, whether kernel resume routine should stand up to fill the hole up.

That can only be done with knowledge of the platform (eg, where the secure mode vectors should be pointed) and so can't be dealt with by generic code.

I would also imagine that it's also far easier to sort out before we enable the MMU, rather than dealing with the aftermath of having pulled secure mode entries from the non-secure world into the caches.

#64 lore raw

cover add initial imx6q support

In reply to Shawn Guo
Quoted 17 lines · On Tuesday 06 September 2011 17:58:34 Shawn Guo wrote:

This patch series adds the initial support for imx6q, which is a Cortex-A9 MPCore (4 cores) SoC.

It's based on v3.1-rc4 with the patches below applied.

* [PATCH v2 0/5] Convert DEBUG_LL UART selection to a Kconfig choice
http://thread.gmane.org/gmane.linux.ports.arm.kernel/129702

* [PATCH v4 2/2] ARM: l2x0: Add OF based initialization
http://article.gmane.org/gmane.linux.kernel/1164401

* [PATCH 1/7] ARM: l2x0: add empty l2x0_of_init
http://article.gmane.org/gmane.linux.ports.arm.kernel/130878

* [RFC PATCH 0/3] Yet another GIC OF binding series
http://thread.gmane.org/gmane.linux.drivers.devicetree/7226

Quoted 8 lines

For suspend/resume support, it needs the following extra patches applied.

* [PATCH v2 0/2] make reinitialization of ARM core components possible
http://thread.gmane.org/gmane.linux.ports.arm.kernel/131356

* [PATCH v2 0/5] CPU PM notifiers
http://thread.gmane.org/gmane.linux.ports.arm.kernel/131212/focus=131353

Hi Shawn,

We've talked about it before, but I don't remember the outcome. Can you explain (and add to the above text) a short explanation of why this is in the mach-imx directory, rather than the mach-mx5 (which probably is closer to mx6 than mx3 is) or a new mach-mx6?

Arnd

#65 lore raw

cover add initial imx6q support

Hello Arnd,

Quoted 4 lines · Arnd Bergmann

We've talked about it before, but I don't remember the outcome. Can you explain (and add to the above text) a short explanation of why this is in the mach-imx directory, rather than the mach-mx5 (which probably is closer to mx6 than mx3 is) or a new mach-mx6?

Not having looked into the patches yet, but I think mach-imx is the right choice. The longterm plan for mach-mx5 is to be folded into mach-imx, too. We just didn't found a volunteer for that.

Best regards
Uwe

BTW, are you on irc somewhere?

Signature · 2 lines
Pengutronix e.K.                           | Uwe Kleine-K?nig            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
#66 lore raw

cover add initial imx6q support

Quoted 10 lines · Uwe Kleine-K?nig

Hello Arnd,

Quoted 4 lines · Arnd Bergmann

We've talked about it before, but I don't remember the outcome. Can you explain (and add to the above text) a short explanation of why this is in the mach-imx directory, rather than the mach-mx5 (which probably is closer to mx6 than mx3 is) or a new mach-mx6?

Not having looked into the patches yet, but I think mach-imx is the right choice. The longterm plan for mach-mx5 is to be folded into mach-imx, too. We just didn't found a volunteer for that.

My plan is to convert all the board files in mach-mx5 to imx51-dt.c and imx53-dt.c first, and then merge the folder into mach-imx.

Quoted 6 lines

Best regards
Uwe

BTW, are you on irc somewhere?

I'm not sure this is a question for me or Arnd. I'm usually on #linaro-kernel.

Signature · 2 lines
Regards,
Shawn
#67 lore raw

cover add initial imx6q support

Quoted 8 lines · On Wednesday 07 September 2011 10:55:12 Shawn Guo wrote:
Quoted 7 lines · Uwe Kleine-K?nig

Hello Arnd,

Quoted 4 lines · Arnd Bergmann

We've talked about it before, but I don't remember the outcome. Can you explain (and add to the above text) a short explanation of why this is in the mach-imx directory, rather than the mach-mx5 (which probably is closer to mx6 than mx3 is) or a new mach-mx6?

Quoted 6 lines
Quoted 3 lines

Not having looked into the patches yet, but I think mach-imx is the right choice. The longterm plan for mach-mx5 is to be folded into mach-imx, too. We just didn't found a volunteer for that.

My plan is to convert all the board files in mach-mx5 to imx51-dt.c and imx53-dt.c first, and then merge the folder into mach-imx.

Ok, sounds good.

Thanks,

Arnd

#68 lore raw

cover add initial imx6q support

In reply to Arnd Bergmann
Quoted 27 lines · Arnd Bergmann
Quoted 17 lines · On Tuesday 06 September 2011 17:58:34 Shawn Guo wrote:

This patch series adds the initial support for imx6q, which is a Cortex-A9 MPCore (4 cores) SoC.

It's based on v3.1-rc4 with the patches below applied.

* [PATCH v2 0/5] Convert DEBUG_LL UART selection to a Kconfig choice
http://thread.gmane.org/gmane.linux.ports.arm.kernel/129702

* [PATCH v4 2/2] ARM: l2x0: Add OF based initialization
http://article.gmane.org/gmane.linux.kernel/1164401

* [PATCH 1/7] ARM: l2x0: add empty l2x0_of_init
http://article.gmane.org/gmane.linux.ports.arm.kernel/130878

* [RFC PATCH 0/3] Yet another GIC OF binding series
http://thread.gmane.org/gmane.linux.drivers.devicetree/7226

Quoted 8 lines

For suspend/resume support, it needs the following extra patches applied.

* [PATCH v2 0/2] make reinitialization of ARM core components possible
http://thread.gmane.org/gmane.linux.ports.arm.kernel/131356

* [PATCH v2 0/5] CPU PM notifiers
http://thread.gmane.org/gmane.linux.ports.arm.kernel/131212/focus=131353

Quoted 7 lines

Hi Shawn,

We've talked about it before, but I don't remember the outcome. Can you explain (and add to the above text) a short explanation of why this is in the mach-imx directory, rather than the mach-mx5 (which probably is closer to mx6 than mx3 is) or a new mach-mx6?

As Uwe mentioned, our long term view on imx sub-architecture is to move mach-mx5 into mach-imx, so that we can have single mach folder for imx, though whether we eventually move plat-mxc into mach-imx or not is another thing we can think about later.

I will add something about that in the cover letter with the next post.

Signature · 2 lines
Regards,
Shawn