Skip to contentSkip to conversation

ARM: imx: Add initial i.MX28 support

RFC PATCH New Shawn Guo 4 participants 28 messages Nov 15, 2010 – Nov 17, 2010

Subsystems (3)
lore
Share & tools
lore

Shawn Guo

author
#0 lore raw

cover ARM: imx: Add initial i.MX28 support

This patchset adds the initial support of i.MX28, and the target device is i.MX28 EVK Rev C. It's based on the imx-single-kernel branch below, and adding codes into arch/arm/mxc and arch/arm/mach-imx.

git://git.pengutronix.de/git/imx/linux-2.6.git imx-single-kernel

Please take the time to review the patchset. Thanks.

Regards,
Shawn

Shawn Guo (11):

 arch/arm/mach-imx/Kconfig                       |   20 +
 arch/arm/mach-imx/Makefile                      |    4 +
 arch/arm/mach-imx/Makefile.boot                 |    4 +
 arch/arm/mach-imx/clock-imx28.c                 |  733 +++++++++++++++++++++++
 arch/arm/mach-imx/devices-imx28.h               |   20 +
 arch/arm/mach-imx/devices.c                     |   27 +-
 arch/arm/mach-imx/mach-mx28evk.c                |  109 ++++
 arch/arm/mach-imx/mm-imx28.c                    |   50 ++
 arch/arm/mach-imx/regs-clkctrl-mx28.h           |  662 ++++++++++++++++++++
 arch/arm/plat-mxc/Kconfig                       |   12 +
 arch/arm/plat-mxc/Makefile                      |    4 +-
 arch/arm/plat-mxc/devices/Kconfig               |    3 +
 arch/arm/plat-mxc/devices/Makefile              |    1 +
 arch/arm/plat-mxc/devices/platform-duart.c      |   42 ++
 arch/arm/plat-mxc/devices/platform-fec.c        |    5 +
 arch/arm/plat-mxc/gpio.c                        |  186 +++++-
 arch/arm/plat-mxc/icoll.c                       |   79 +++
 arch/arm/plat-mxc/include/mach/common.h         |    5 +
 arch/arm/plat-mxc/include/mach/devices-common.h |   11 +
 arch/arm/plat-mxc/include/mach/entry-macro.S    |   22 +-
 arch/arm/plat-mxc/include/mach/hardware.h       |    9 +-
 arch/arm/plat-mxc/include/mach/iomux-mx28.h     |   50 ++
 arch/arm/plat-mxc/include/mach/iomux-pinctrl.h  |   91 +++
 arch/arm/plat-mxc/include/mach/irqs.h           |   11 +-
 arch/arm/plat-mxc/include/mach/memory.h         |    5 +-
 arch/arm/plat-mxc/include/mach/mx28.h           |  232 +++++++
 arch/arm/plat-mxc/include/mach/mxc.h            |   14 +
 arch/arm/plat-mxc/include/mach/uncompress.h     |   20 +-
 arch/arm/plat-mxc/iomux-pinctrl.c               |   94 +++
 arch/arm/plat-mxc/system.c                      |  104 ++++-
 arch/arm/plat-mxc/time.c                        |  120 +++-
 31 files changed, 2674 insertions(+), 75 deletions(-)
author
#1 lore raw

PATCH 1/11 ARM: imx: Add basic definitions for i.MX28

---
 arch/arm/plat-mxc/include/mach/hardware.h |    9 +-
 arch/arm/plat-mxc/include/mach/irqs.h     |   11 +-
 arch/arm/plat-mxc/include/mach/memory.h   |    5 +-
 arch/arm/plat-mxc/include/mach/mx28.h     |  232 +++++++++++++++++++++++++++++
 arch/arm/plat-mxc/include/mach/mxc.h      |   14 ++
 5 files changed, 264 insertions(+), 7 deletions(-)
 create mode 100644 arch/arm/plat-mxc/include/mach/mx28.h
arch/arm/plat-mxc/include/mach/hardware.h +8 -1
index 2f59b63..499b14c 100644
@@ -1,5 +1,5 @@
 /*
- * Copyright 2004-2007 Freescale Semiconductor, Inc. All Rights Reserved.
+ * Copyright 2004-2010 Freescale Semiconductor, Inc. All Rights Reserved.
  * Copyright 2008 Juergen Beisert, kernel at pengutronix.de
  *
  * This program is free software; you can redistribute it and/or
@@ -63,6 +63,9 @@
  *	AIPI	0x10000000+0x100000	->	0xf4400000+0x100000
  *	SAHB1	0x80000000+0x100000	->	0xf4000000+0x100000
  *	X_MEMC	0xd8000000+0x100000	->	0xf5c00000+0x100000
+ * mx28:
+ *	OCRAM	0x00000000+0x020000	->	0xf4000000+0x020000
+ *	IO	0x80000000+0x100000	->	0xf4400000+0x100000
  * mx31:
  *	AIPS1	0x43f00000+0x100000	->	0xf5300000+0x100000
  *	AIPS2	0x53f00000+0x100000	->	0xf5700000+0x100000
@@ -127,6 +130,10 @@
 # include <mach/mx25.h>
 #endif
 
+#ifdef CONFIG_ARCH_MX28
+# include <mach/mx28.h>
+#endif
+
 #ifdef CONFIG_ARCH_MXC91231
 # include <mach/mxc91231.h>
 #endif
arch/arm/plat-mxc/include/mach/irqs.h +6 -5
index 86781f7..2f810c5 100644
@@ -1,5 +1,5 @@
 /*
- *  Copyright 2004-2007 Freescale Semiconductor, Inc. All Rights Reserved.
+ *  Copyright 2004-2010 Freescale Semiconductor, Inc. All Rights Reserved.
  */
 
 /*
@@ -12,12 +12,13 @@
 #define __ASM_ARCH_MXC_IRQS_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 and ICOLL have 128.
  */
-#ifdef CONFIG_MXC_TZIC
-#define MXC_INTERNAL_IRQS	128
-#else
+#ifdef CONFIG_MXC_AVIC
 #define MXC_INTERNAL_IRQS	64
+#else
+#define MXC_INTERNAL_IRQS	128
 #endif
 
 #define MXC_GPIO_IRQ_START	MXC_INTERNAL_IRQS
arch/arm/plat-mxc/include/mach/memory.h +4 -1
index 564ec9d..af090e3 100644
@@ -1,5 +1,5 @@
 /*
- * Copyright 2004-2007 Freescale Semiconductor, Inc. All Rights Reserved.
+ * Copyright 2004-2010 Freescale Semiconductor, Inc. All Rights Reserved.
  */
 
 /*
@@ -15,6 +15,7 @@
 #define MX21_PHYS_OFFSET	UL(0xc0000000)
 #define MX25_PHYS_OFFSET	UL(0x80000000)
 #define MX27_PHYS_OFFSET	UL(0xa0000000)
+#define MX28_PHYS_OFFSET	UL(0x40000000)
 #define MX3x_PHYS_OFFSET	UL(0x80000000)
 #define MX51_PHYS_OFFSET	UL(0x90000000)
 #define MXC91231_PHYS_OFFSET	UL(0x90000000)
@@ -28,6 +29,8 @@
 #  define PHYS_OFFSET		MX25_PHYS_OFFSET
 # elif defined CONFIG_MACH_MX27
 #  define PHYS_OFFSET		MX27_PHYS_OFFSET
+# elif defined CONFIG_ARCH_MX28
+#  define PHYS_OFFSET		MX28_PHYS_OFFSET
 # elif defined CONFIG_ARCH_MX3
 #  define PHYS_OFFSET		MX3x_PHYS_OFFSET
 # elif defined CONFIG_ARCH_MXC91231
arch/arm/plat-mxc/include/mach/mx28.h new file +232 -0

232 lines not on this page · raw message

arch/arm/plat-mxc/include/mach/mxc.h +14 -0
index 3432b78..563901f 100644
@@ -30,6 +30,7 @@
 #define MXC_CPU_MX21		21
 #define MXC_CPU_MX25		25
 #define MXC_CPU_MX27		27
+#define MXC_CPU_MX28		28
 #define MXC_CPU_MX31		31
 #define MXC_CPU_MX35		35
 #define MXC_CPU_MX51		51
@@ -87,6 +88,18 @@ extern unsigned int __mxc_cpu_type;
 # define cpu_is_mx27()		(0)
 #endif
 
+#ifdef CONFIG_ARCH_MX28
+# ifdef mxc_cpu_type
+#  undef mxc_cpu_type
+#  define mxc_cpu_type __mxc_cpu_type
+# else
+#  define mxc_cpu_type MXC_CPU_MX28
+# endif
+# define cpu_is_mx28()		(mxc_cpu_type == MXC_CPU_MX28)
+#else
+# define cpu_is_mx28()		(0)
+#endif
+
 #ifdef CONFIG_ARCH_MX31
 # ifdef mxc_cpu_type
 #  undef mxc_cpu_type
@@ -161,5 +174,6 @@ extern void __iomem *mxc_irq_base;
 
 #define MXC_IRQ_TYPE_AVIC	1
 #define MXC_IRQ_TYPE_TZIC	2
+#define MXC_IRQ_TYPE_ICOLL	3
 
 #endif /*  __ASM_ARCH_MXC_H__ */
Signature · 1 line
1.7.1
#2 lore raw

PATCH 1/11 ARM: imx: Add basic definitions for i.MX28

Quoted 59 lines · Shawn Guo
---
 arch/arm/plat-mxc/include/mach/hardware.h |    9 +-
 arch/arm/plat-mxc/include/mach/irqs.h     |   11 +-
 arch/arm/plat-mxc/include/mach/memory.h   |    5 +-
 arch/arm/plat-mxc/include/mach/mx28.h     |  232 +++++++++++++++++++++++++++++
 arch/arm/plat-mxc/include/mach/mxc.h      |   14 ++
 5 files changed, 264 insertions(+), 7 deletions(-)
 create mode 100644 arch/arm/plat-mxc/include/mach/mx28.h
arch/arm/plat-mxc/include/mach/hardware.h +8 -1
index 2f59b63..499b14c 100644
@@ -1,5 +1,5 @@
 /*
- * Copyright 2004-2007 Freescale Semiconductor, Inc. All Rights Reserved.
+ * Copyright 2004-2010 Freescale Semiconductor, Inc. All Rights Reserved.
  * Copyright 2008 Juergen Beisert, kernel at pengutronix.de
  *
  * This program is free software; you can redistribute it and/or
@@ -63,6 +63,9 @@
  *	AIPI	0x10000000+0x100000	->	0xf4400000+0x100000
  *	SAHB1	0x80000000+0x100000	->	0xf4000000+0x100000
  *	X_MEMC	0xd8000000+0x100000	->	0xf5c00000+0x100000
+ * mx28:
+ *	OCRAM	0x00000000+0x020000	->	0xf4000000+0x020000
+ *	IO	0x80000000+0x100000	->	0xf4400000+0x100000
  * mx31:
  *	AIPS1	0x43f00000+0x100000	->	0xf5300000+0x100000
  *	AIPS2	0x53f00000+0x100000	->	0xf5700000+0x100000
@@ -127,6 +130,10 @@
 # include <mach/mx25.h>
 #endif
 
+#ifdef CONFIG_ARCH_MX28
+# include <mach/mx28.h>
+#endif
+
 #ifdef CONFIG_ARCH_MXC91231
 # include <mach/mxc91231.h>
 #endif
arch/arm/plat-mxc/include/mach/irqs.h +2 -2
index 86781f7..2f810c5 100644
@@ -1,5 +1,5 @@
 /*
- *  Copyright 2004-2007 Freescale Semiconductor, Inc. All Rights Reserved.
+ *  Copyright 2004-2010 Freescale Semiconductor, Inc. All Rights Reserved.
  */
 
 /*
@@ -12,12 +12,13 @@
 #define __ASM_ARCH_MXC_IRQS_H__
 
 /*
- * SoCs with TZIC interrupt controller have 128 IRQs, those with AVIC have 64
+ * SoCs with AVIC interrupt controller have 64 IRQs,

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

Quoted 10 lines
arch/arm/plat-mxc/include/mach/irqs.h +4 -3
+ * those with TZIC and ICOLL have 128.
  */
-#ifdef CONFIG_MXC_TZIC
-#define MXC_INTERNAL_IRQS	128
-#else
+#ifdef CONFIG_MXC_AVIC
 #define MXC_INTERNAL_IRQS	64
+#else
+#define MXC_INTERNAL_IRQS	128
 #endif

I like the more explicit approach that was used before. When using #elif it doesn't look that ugly.

arch/arm/plat-mxc/include/mach/memory.h line 2

Quoted 9 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 +1 -1
index 564ec9d..af090e3 100644
@@ -1,5 +1,5 @@
 /*
- * Copyright 2004-2007 Freescale Semiconductor, Inc. All Rights Reserved.
+ * Copyright 2004-2010 Freescale Semiconductor, Inc. All Rights Reserved.

INAL but I wonder if your change to the file is worth 3 years of copyright assignment. *I* don't care much though. The same applies to some other files touched by this patch.

Quoted 40 lines
arch/arm/plat-mxc/include/mach/memory.h +3 -0
  */
 
 /*
@@ -15,6 +15,7 @@
 #define MX21_PHYS_OFFSET	UL(0xc0000000)
 #define MX25_PHYS_OFFSET	UL(0x80000000)
 #define MX27_PHYS_OFFSET	UL(0xa0000000)
+#define MX28_PHYS_OFFSET	UL(0x40000000)
 #define MX3x_PHYS_OFFSET	UL(0x80000000)
 #define MX51_PHYS_OFFSET	UL(0x90000000)
 #define MXC91231_PHYS_OFFSET	UL(0x90000000)
@@ -28,6 +29,8 @@
 #  define PHYS_OFFSET		MX25_PHYS_OFFSET
 # elif defined CONFIG_MACH_MX27
 #  define PHYS_OFFSET		MX27_PHYS_OFFSET
+# elif defined CONFIG_ARCH_MX28
+#  define PHYS_OFFSET		MX28_PHYS_OFFSET
 # elif defined CONFIG_ARCH_MX3
 #  define PHYS_OFFSET		MX3x_PHYS_OFFSET
 # elif defined CONFIG_ARCH_MXC91231
arch/arm/plat-mxc/include/mach/mx28.h new file +14 -0
new file mode 100644
index 0000000..6f73888
@@ -0,0 +1,232 @@
+/*
+ * Copyright (C) 2009-2010 Freescale Semiconductor, Inc. All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along

arch/arm/plat-mxc/include/mach/mx28.h line 24

Quoted 10 lines
arch/arm/plat-mxc/include/mach/mx28.h new file +10 -0
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef __MACH_MX28_H__
+#define __MACH_MX28_H__
+
+#ifndef __ASSEMBLER__
+#include <linux/io.h>
+#endif

Is this needed?

arch/arm/plat-mxc/include/mach/mx28.h line 28

Quoted 4 lines
arch/arm/plat-mxc/include/mach/mx28.h new file +4 -0
+
+#define SET_ADDR			0x4
+#define CLR_ADDR			0x8
+#define TOG_ADDR			0xc

Please don't pollute the namespace but use MX28 prefixes. Are these used?

Quoted 59 lines
arch/arm/plat-mxc/include/mach/mx28.h new file +59 -0
+
+/*
+ * OCRAM
+ */
+#define MX28_OCRAM_BASE_ADDR		0x00000000
+#define MX28_OCRAM_SIZE			SZ_128K
+
+/*
+ * IO
+ */
+#define MX28_IO_BASE_ADDR		0x80000000
+#define MX28_IO_SIZE			SZ_1M
+
+#define MX28_ICOLL_BASE_ADDR		(MX28_IO_BASE_ADDR + 0x000000)
+#define MX28_HSADC_BASE_ADDR		(MX28_IO_BASE_ADDR + 0x002000)
+#define MX28_APBH_DMA_BASE_ADDR		(MX28_IO_BASE_ADDR + 0x004000)
+#define MX28_PERFMON_BASE_ADDR		(MX28_IO_BASE_ADDR + 0x006000)
+#define MX28_BCH_BASE_ADDR		(MX28_IO_BASE_ADDR + 0x00a000)
+#define MX28_GPMI_BASE_ADDR		(MX28_IO_BASE_ADDR + 0x00c000)
+#define MX28_SSP0_BASE_ADDR		(MX28_IO_BASE_ADDR + 0x010000)
+#define MX28_SSP1_BASE_ADDR		(MX28_IO_BASE_ADDR + 0x012000)
+#define MX28_SSP2_BASE_ADDR		(MX28_IO_BASE_ADDR + 0x014000)
+#define MX28_SSP3_BASE_ADDR		(MX28_IO_BASE_ADDR + 0x016000)
+#define MX28_PINCTRL_BASE_ADDR		(MX28_IO_BASE_ADDR + 0x018000)
+#define MX28_DIGCTL_BASE_ADDR		(MX28_IO_BASE_ADDR + 0x01c000)
+#define MX28_ETM_BASE_ADDR		(MX28_IO_BASE_ADDR + 0x022000)
+#define MX28_APBX_DMA_BASE_ADDR		(MX28_IO_BASE_ADDR + 0x024000)
+#define MX28_DCP_BASE_ADDR		(MX28_IO_BASE_ADDR + 0x028000)
+#define MX28_PXP_BASE_ADDR		(MX28_IO_BASE_ADDR + 0x02a000)
+#define MX28_OCOTP_BASE_ADDR		(MX28_IO_BASE_ADDR + 0x02c000)
+#define MX28_AXI_AHB0_BASE_ADDR		(MX28_IO_BASE_ADDR + 0x02e000)
+#define MX28_LCDIF_BASE_ADDR		(MX28_IO_BASE_ADDR + 0x030000)
+#define MX28_CAN0_BASE_ADDR		(MX28_IO_BASE_ADDR + 0x032000)
+#define MX28_CAN1_BASE_ADDR		(MX28_IO_BASE_ADDR + 0x034000)
+#define MX28_SIMDBG_BASE_ADDR		(MX28_IO_BASE_ADDR + 0x03c000)
+#define MX28_SIMGPMISEL_BASE_ADDR	(MX28_IO_BASE_ADDR + 0x03c200)
+#define MX28_SIMSSPSEL_BASE_ADDR	(MX28_IO_BASE_ADDR + 0x03c300)
+#define MX28_SIMMEMSEL_BASE_ADDR	(MX28_IO_BASE_ADDR + 0x03c400)
+#define MX28_GPIOMON_BASE_ADDR		(MX28_IO_BASE_ADDR + 0x03c500)
+#define MX28_SIMENET_BASE_ADDR		(MX28_IO_BASE_ADDR + 0x03c700)
+#define MX28_ARMJTAG_BASE_ADDR		(MX28_IO_BASE_ADDR + 0x03c800)
+#define MX28_CLKCTRL_BASE_ADDR		(MX28_IO_BASE_ADDR + 0x040000)
+#define MX28_SAIF0_BASE_ADDR		(MX28_IO_BASE_ADDR + 0x042000)
+#define MX28_POWER_BASE_ADDR		(MX28_IO_BASE_ADDR + 0x044000)
+#define MX28_SAIF1_BASE_ADDR		(MX28_IO_BASE_ADDR + 0x046000)
+#define MX28_LRADC_BASE_ADDR		(MX28_IO_BASE_ADDR + 0x050000)
+#define MX28_SPDIF_BASE_ADDR		(MX28_IO_BASE_ADDR + 0x054000)
+#define MX28_RTC_BASE_ADDR		(MX28_IO_BASE_ADDR + 0x056000)
+#define MX28_I2C0_BASE_ADDR		(MX28_IO_BASE_ADDR + 0x058000)
+#define MX28_I2C1_BASE_ADDR		(MX28_IO_BASE_ADDR + 0x05a000)
+#define MX28_PWM_BASE_ADDR		(MX28_IO_BASE_ADDR + 0x064000)
+#define MX28_TIMROT_BASE_ADDR		(MX28_IO_BASE_ADDR + 0x068000)
+#define MX28_AUART0_BASE_ADDR		(MX28_IO_BASE_ADDR + 0x06a000)
+#define MX28_AUART1_BASE_ADDR		(MX28_IO_BASE_ADDR + 0x06c000)
+#define MX28_AUART2_BASE_ADDR		(MX28_IO_BASE_ADDR + 0x06e000)
+#define MX28_AUART3_BASE_ADDR		(MX28_IO_BASE_ADDR + 0x070000)
+#define MX28_AUART4_BASE_ADDR		(MX28_IO_BASE_ADDR + 0x072000)
+#define MX28_DUART_BASE_ADDR		(MX28_IO_BASE_ADDR + 0x074000)
+#define MX28_USBPHY0_BASE_ADDR		(MX28_IO_BASE_ADDR + 0x07C000)

arch/arm/plat-mxc/include/mach/mx28.h line 97

Quoted 10 lines
arch/arm/plat-mxc/include/mach/mx28.h new file +10 -0
+#define MX28_USBPHY1_BASE_ADDR		(MX28_IO_BASE_ADDR + 0x07e000)
+#define MX28_USBCTRL0_BASE_ADDR		(MX28_IO_BASE_ADDR + 0x080000)
+#define MX28_USBCTRL1_BASE_ADDR		(MX28_IO_BASE_ADDR + 0x090000)
+#define MX28_DFLPT_BASE_ADDR		(MX28_IO_BASE_ADDR + 0x0c0000)
+#define MX28_DRAM_BASE_ADDR		(MX28_IO_BASE_ADDR + 0x0e0000)
+#define MX28_ENET_BASE_ADDR		(MX28_IO_BASE_ADDR + 0x0f0000)
+#define MX28_FEC_BASE_ADDR		MX28_ENET_BASE_ADDR
+
+#define MX28_IO_P2V(x)			IMX_IO_P2V(x)
+#define MX28_IO_ADDRESS(x)		IOMEM(MX27_IO_P2V(x))

s/27/28/ I suppose

Quoted 117 lines
arch/arm/plat-mxc/include/mach/mx28.h new file +117 -0
+
+/*
+ * IRQ
+ */
+#define MX28_INT_BATT_BRNOUT		0
+#define MX28_INT_VDDD_BRNOUT		1
+#define MX28_INT_VDDIO_BRNOUT		2
+#define MX28_INT_VDDA_BRNOUT		3
+#define MX28_INT_VDD5V_DROOP		4
+#define MX28_INT_DCDC4P2_BRNOUT		5
+#define MX28_INT_VDD5V			6
+#define MX28_INT_RESV7			7
+#define MX28_INT_CAN0			8
+#define MX28_INT_CAN1			9
+#define MX28_INT_LRADC_TOUCH		10
+#define MX28_INT_RESV11			11
+#define MX28_INT_RESV12			12
+#define MX28_INT_HSADC			13
+#define MX28_INT_IRADC_THRESH0		14
+#define MX28_INT_IRADC_THRESH1		15
+#define MX28_INT_LRADC_CH0		16
+#define MX28_INT_LRADC_CH1		17
+#define MX28_INT_LRADC_CH2		18
+#define MX28_INT_LRADC_CH3		19
+#define MX28_INT_LRADC_CH4		20
+#define MX28_INT_LRADC_CH5		21
+#define MX28_INT_LRADC_CH6		22
+#define MX28_INT_LRADC_CH7		23
+#define MX28_INT_LRADC_BUTTON0		24
+#define MX28_INT_LRADC_BUTTON1		25
+#define MX28_INT_RESV26			26
+#define MX28_INT_PERFMON		27
+#define MX28_INT_RTC_1MSEC		28
+#define MX28_INT_RTC_ALARM		29
+#define MX28_INT_RESV30			30
+#define MX28_INT_COMMS			31
+#define MX28_INT_EMI_ERR		32
+#define MX28_INT_RESV33			33
+#define MX28_INT_RESV34			34
+#define MX28_INT_RESV35			35
+#define MX28_INT_RESV36			36
+#define MX28_INT_RESV37			37
+#define MX28_INT_LCDIF			38
+#define MX28_INT_PXP			39
+#define MX28_INT_RESV40			40
+#define MX28_INT_BCH			41
+#define MX28_INT_GPMI			42
+#define MX28_INT_RESV43			43
+#define MX28_INT_RESV44			44
+#define MX28_INT_SPDIF_ERROR		45
+#define MX28_INT_RESV46			46
+#define MX28_INT_DUART			47
+#define MX28_INT_TIMER0			48
+#define MX28_INT_TIMER1			49
+#define MX28_INT_TIMER2			50
+#define MX28_INT_TIMER3			51
+#define MX28_INT_DCP_VMI		52
+#define MX28_INT_DCP			53
+#define MX28_INT_DCP_SECURE		54
+#define MX28_INT_RESV55			55
+#define MX28_INT_RESV56			56
+#define MX28_INT_RESV57			57
+#define MX28_INT_SAIF1			58
+#define MX28_INT_SAIF0			59
+#define MX28_INT_RESV60			60
+#define MX28_INT_RESV61			61
+#define MX28_INT_RESV62			62
+#define MX28_INT_RESV63			63
+#define MX28_INT_RESV64			64
+#define MX28_INT_RESV65			65
+#define MX28_INT_SPDIF_DMA		66
+#define MX28_INT_RESV67			67
+#define MX28_INT_I2C0_DMA		68
+#define MX28_INT_I2C1_DMA		69
+#define MX28_INT_AUART0_RX_DMA		70
+#define MX28_INT_AUART0_TX_DMA		71
+#define MX28_INT_AUART1_RX_DMA		72
+#define MX28_INT_AUART1_TX_DMA		73
+#define MX28_INT_AUART2_RX_DMA		74
+#define MX28_INT_AUART2_TX_DMA		75
+#define MX28_INT_AUART3_RX_DMA		76
+#define MX28_INT_AUART3_TX_DMA		77
+#define MX28_INT_AUART4_RX_DMA		78
+#define MX28_INT_AUART4_TX_DMA		79
+#define MX28_INT_SAIF0_DMA		80
+#define MX28_INT_SAIF1_DMA		81
+#define MX28_INT_SSP0_DMA		82
+#define MX28_INT_SSP1_DMA		83
+#define MX28_INT_SSP2_DMA		84
+#define MX28_INT_SSP3_DMA		85
+#define MX28_INT_LCDIF_DMA		86
+#define MX28_INT_HSADC_DMA		87
+#define MX28_INT_GPMI_DMA		88
+#define MX28_INT_DIGCTL_DEBUG_TRAP	89
+#define MX28_INT_RESV90			90
+#define MX28_INT_RESV91			91
+#define MX28_INT_USB1			92
+#define MX28_INT_USB0			93
+#define MX28_INT_USB1_WAKEUP		94
+#define MX28_INT_USB0_WAKEUP		95
+#define MX28_INT_SSP0			96
+#define MX28_INT_SSP1			97
+#define MX28_INT_SSP2			98
+#define MX28_INT_SSP3			99
+#define MX28_INT_ENET_SWI		100
+#define MX28_INT_ENET_MAC0		101
+#define MX28_INT_ENET_MAC1		102
+#define MX28_INT_ENET_MAC0_1588		103
+#define MX28_INT_ENET_MAC1_1588		104
+#define MX28_INT_RESV105		105
+#define MX28_INT_RESV106		106
+#define MX28_INT_RESV107		107
+#define MX28_INT_RESV108		108
+#define MX28_INT_RESV109		109
+#define MX28_INT_I2C1_ERROR		110
+#define MX28_INT_I2C0_ERROR		111
+#define MX28_INT_AUART0			112

arch/arm/plat-mxc/include/mach/mx28.h line 224

Quoted 10 lines
arch/arm/plat-mxc/include/mach/mx28.h new file +10 -0
+#define MX28_INT_AUART1			113
+#define MX28_INT_AUART2			114
+#define MX28_INT_AUART3			115
+#define MX28_INT_AUART4			116
+#define MX28_INT_RESV117		117
+#define MX28_INT_RESV118		118
+#define MX28_INT_RESV119		119
+#define MX28_INT_RESV120		120
+#define MX28_INT_RESV121		121
+#define MX28_INT_RESV122		122

I'd just skip those RESV defines (assuming they mean "reserved").

arch/arm/plat-mxc/include/mach/mx28.h line 230

Quoted 6 lines
arch/arm/plat-mxc/include/mach/mx28.h new file +6 -0
+#define MX28_INT_GPIO4			123
+#define MX28_INT_GPIO3			124
+#define MX28_INT_GPIO2			125
+#define MX28_INT_GPIO1			126
+#define MX28_INT_GPIO0			127
+#define MX28_INT_FEC			MX28_INT_ENET_MAC0

This looks strage. What is MX28_INT_ENET_MAC1 used for?

Quoted 40 lines
arch/arm/plat-mxc/include/mach/mx28.h new file +2 -0
+
+#endif /* __MACH_MX28_H__ */
arch/arm/plat-mxc/include/mach/mxc.h +14 -0
index 3432b78..563901f 100644
@@ -30,6 +30,7 @@
 #define MXC_CPU_MX21		21
 #define MXC_CPU_MX25		25
 #define MXC_CPU_MX27		27
+#define MXC_CPU_MX28		28
 #define MXC_CPU_MX31		31
 #define MXC_CPU_MX35		35
 #define MXC_CPU_MX51		51
@@ -87,6 +88,18 @@ extern unsigned int __mxc_cpu_type;
 # define cpu_is_mx27()		(0)
 #endif
 
+#ifdef CONFIG_ARCH_MX28
+# ifdef mxc_cpu_type
+#  undef mxc_cpu_type
+#  define mxc_cpu_type __mxc_cpu_type
+# else
+#  define mxc_cpu_type MXC_CPU_MX28
+# endif
+# define cpu_is_mx28()		(mxc_cpu_type == MXC_CPU_MX28)
+#else
+# define cpu_is_mx28()		(0)
+#endif
+
 #ifdef CONFIG_ARCH_MX31
 # ifdef mxc_cpu_type
 #  undef mxc_cpu_type
@@ -161,5 +174,6 @@ extern void __iomem *mxc_irq_base;
 
 #define MXC_IRQ_TYPE_AVIC	1
 #define MXC_IRQ_TYPE_TZIC	2
+#define MXC_IRQ_TYPE_ICOLL	3
 
 #endif /*  __ASM_ARCH_MXC_H__ */
Signature · 2 lines
Pengutronix e.K.                           | Uwe Kleine-K?nig            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
author
#3 lore raw

PATCH 2/11 ARM: imx: Add support of interrupt controller ICOLL

In reply to Shawn Guo

MX28 uses Interrupt Collector (ICOLL) as the interrupt controller. So ICOLL becomes the third interrupt controller for MXC besides AVIC and TZIC.

---
 arch/arm/plat-mxc/icoll.c                    |   79 ++++++++++++++++++++++++++
 arch/arm/plat-mxc/include/mach/entry-macro.S |   22 ++++++-
 2 files changed, 97 insertions(+), 4 deletions(-)
 create mode 100644 arch/arm/plat-mxc/icoll.c
arch/arm/plat-mxc/icoll.c new file +79 -0
new file mode 100644
index 0000000..e9a9e42
@@ -0,0 +1,79 @@
+/*
+ * Copyright (C) 2009-2010 Freescale Semiconductor, Inc. All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/irq.h>
+
+#include <mach/hardware.h>
+#include <mach/common.h>
+
+#define HW_ICOLL_VECTOR				0x0000
+#define HW_ICOLL_LEVELACK			0x0010
+#define HW_ICOLL_CTRL				0x0020
+#define HW_ICOLL_INTERRUPTn_SET(n)		(0x0124 + (n) * 0x10)
+#define HW_ICOLL_INTERRUPTn_CLR(n)		(0x0128 + (n) * 0x10)
+#define BM_ICOLL_INTERRUPTn_ENABLE		0x00000004
+#define BV_ICOLL_LEVELACK_IRQLEVELACK__LEVEL0	0x1
+
+void __iomem *icoll_base;
+
+static void icoll_ack_irq(unsigned int irq)
+{
+	__raw_writel(0, icoll_base + HW_ICOLL_VECTOR);
+
+	/* ACK current interrupt (level 0) */
+	__raw_writel(BV_ICOLL_LEVELACK_IRQLEVELACK__LEVEL0,
+			icoll_base + HW_ICOLL_LEVELACK);
+}
+
+static void icoll_mask_irq(unsigned int irq)
+{
+	__raw_writel(BM_ICOLL_INTERRUPTn_ENABLE,
+			icoll_base + HW_ICOLL_INTERRUPTn_CLR(irq));
+}
+
+static void icoll_unmask_irq(unsigned int irq)
+{
+	__raw_writel(BM_ICOLL_INTERRUPTn_ENABLE,
+			icoll_base + HW_ICOLL_INTERRUPTn_SET(irq));
+}
+
+static struct irq_chip mxc_icoll_chip = {
+	.ack = icoll_ack_irq,
+	.mask = icoll_mask_irq,
+	.unmask = icoll_unmask_irq,
+};
+
+void __init icoll_init_irq(void __iomem *irqbase)
+{
+	int i;
+
+	icoll_base = irqbase;
+	mxc_irq_base = irqbase;
+	mxc_irq_controller_type = MXC_IRQ_TYPE_ICOLL;
+
+	/* Reset icoll */
+	mxc_reset_block(irqbase + HW_ICOLL_CTRL);
+
+	for (i = 0; i < MXC_INTERNAL_IRQS; i++) {
+		set_irq_chip(i, &mxc_icoll_chip);
+		set_irq_handler(i, handle_level_irq);
+		set_irq_flags(i, IRQF_VALID);
+	}
+}
arch/arm/plat-mxc/include/mach/entry-macro.S +18 -4
index a7dd008..a66e804 100644
@@ -1,6 +1,6 @@
 /*
  *  Copyright (C) 2007 Lennert Buytenhek <[email protected]>
- *  Copyright 2004-2009 Freescale Semiconductor, Inc. All Rights Reserved.
+ *  Copyright 2004-2010 Freescale Semiconductor, Inc. All Rights Reserved.
  */
 
 /*
@@ -73,25 +73,39 @@
 #endif
 	.endm
 
+	.macro	icoll_get_irqnr_and_base, irqnr, irqstat, base, tmp
+	ldr \irqnr, [\base, #0x70]
+	cmp \irqnr, #0x7F
+	moveqs \irqnr, #0
+	.endm
+
 	.macro get_irqnr_and_base, irqnr, irqstat, base, tmp
-#if defined CONFIG_MXC_TZIC && defined CONFIG_MXC_AVIC
+#if defined CONFIG_MXC_TZIC && defined CONFIG_MXC_AVIC && defined CONFIG_MXC_ICOLL
 	ldr	\tmp, =mxc_irq_controller_type
 	ldr	\tmp, [\tmp]
 	cmp	\tmp, #MXC_IRQ_TYPE_AVIC
 	beq	3001f
+	cmp	\tmp, #MXC_IRQ_TYPE_ICOLL
+	beq	3002f
 
 	tzic_get_irqnr_and_base \irqnr, \irqstat, \base, \tmp
-	b	3002f
+	b	3003f
 3001:
 	avic_get_irqnr_and_base \irqnr, \irqstat, \base, \tmp
+	b	3003f
 3002:
+	icoll_get_irqnr_and_base \irqnr, \irqstat, \base, \tmp
+	b	3003f
+3003:
 
 #elif defined CONFIG_MXC_TZIC
 	tzic_get_irqnr_and_base \irqnr, \irqstat, \base, \tmp
 #elif defined CONFIG_MXC_AVIC
 	avic_get_irqnr_and_base \irqnr, \irqstat, \base, \tmp
+#elif defined CONFIG_MXC_ICOLL
+	icoll_get_irqnr_and_base \irqnr, \irqstat, \base, \tmp
 #else
-#error no tzic and no avic?
+#error none of tzic, avic, icoll?
 #endif
 	.endm
 
Signature · 1 line
1.7.1
#4 lore raw

PATCH 2/11 ARM: imx: Add support of interrupt controller ICOLL

Quoted 79 lines · Shawn Guo

MX28 uses Interrupt Collector (ICOLL) as the interrupt controller. So ICOLL becomes the third interrupt controller for MXC besides AVIC and TZIC.

---
 arch/arm/plat-mxc/icoll.c                    |   79 ++++++++++++++++++++++++++
 arch/arm/plat-mxc/include/mach/entry-macro.S |   22 ++++++-
 2 files changed, 97 insertions(+), 4 deletions(-)
 create mode 100644 arch/arm/plat-mxc/icoll.c
arch/arm/plat-mxc/icoll.c new file +62 -0
new file mode 100644
index 0000000..e9a9e42
@@ -0,0 +1,79 @@
+/*
+ * Copyright (C) 2009-2010 Freescale Semiconductor, Inc. All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/irq.h>
+
+#include <mach/hardware.h>
+#include <mach/common.h>
+
+#define HW_ICOLL_VECTOR				0x0000
+#define HW_ICOLL_LEVELACK			0x0010
+#define HW_ICOLL_CTRL				0x0020
+#define HW_ICOLL_INTERRUPTn_SET(n)		(0x0124 + (n) * 0x10)
+#define HW_ICOLL_INTERRUPTn_CLR(n)		(0x0128 + (n) * 0x10)
+#define BM_ICOLL_INTERRUPTn_ENABLE		0x00000004
+#define BV_ICOLL_LEVELACK_IRQLEVELACK__LEVEL0	0x1
+
+void __iomem *icoll_base;
+
+static void icoll_ack_irq(unsigned int irq)
+{
+	__raw_writel(0, icoll_base + HW_ICOLL_VECTOR);
+
+	/* ACK current interrupt (level 0) */
+	__raw_writel(BV_ICOLL_LEVELACK_IRQLEVELACK__LEVEL0,
+			icoll_base + HW_ICOLL_LEVELACK);
+}
+
+static void icoll_mask_irq(unsigned int irq)
+{
+	__raw_writel(BM_ICOLL_INTERRUPTn_ENABLE,
+			icoll_base + HW_ICOLL_INTERRUPTn_CLR(irq));
+}
+
+static void icoll_unmask_irq(unsigned int irq)
+{
+	__raw_writel(BM_ICOLL_INTERRUPTn_ENABLE,
+			icoll_base + HW_ICOLL_INTERRUPTn_SET(irq));
+}
+
+static struct irq_chip mxc_icoll_chip = {
+	.ack = icoll_ack_irq,
+	.mask = icoll_mask_irq,
+	.unmask = icoll_unmask_irq,
+};
+

arch/arm/plat-mxc/icoll.c line 72

Quoted 10 lines
arch/arm/plat-mxc/icoll.c new file +10 -0
+void __init icoll_init_irq(void __iomem *irqbase)
+{
+	int i;
+
+	icoll_base = irqbase;
+	mxc_irq_base = irqbase;
+	mxc_irq_controller_type = MXC_IRQ_TYPE_ICOLL;
+
+	/* Reset icoll */
+	mxc_reset_block(irqbase + HW_ICOLL_CTRL);

mxc_reset_block is only defined in patch 3, so you must not use it in patch 2.

Quoted 51 lines
arch/arm/plat-mxc/icoll.c new file +7 -0
+
+	for (i = 0; i < MXC_INTERNAL_IRQS; i++) {
+		set_irq_chip(i, &mxc_icoll_chip);
+		set_irq_handler(i, handle_level_irq);
+		set_irq_flags(i, IRQF_VALID);
+	}
+}
arch/arm/plat-mxc/include/mach/entry-macro.S +15 -3
index a7dd008..a66e804 100644
@@ -1,6 +1,6 @@
 /*
  *  Copyright (C) 2007 Lennert Buytenhek <[email protected]>
- *  Copyright 2004-2009 Freescale Semiconductor, Inc. All Rights Reserved.
+ *  Copyright 2004-2010 Freescale Semiconductor, Inc. All Rights Reserved.
  */
 
 /*
@@ -73,25 +73,39 @@
 #endif
 	.endm
 
+	.macro	icoll_get_irqnr_and_base, irqnr, irqstat, base, tmp
+	ldr \irqnr, [\base, #0x70]
+	cmp \irqnr, #0x7F
+	moveqs \irqnr, #0
+	.endm
+
 	.macro get_irqnr_and_base, irqnr, irqstat, base, tmp
-#if defined CONFIG_MXC_TZIC && defined CONFIG_MXC_AVIC
+#if defined CONFIG_MXC_TZIC && defined CONFIG_MXC_AVIC && defined CONFIG_MXC_ICOLL
 	ldr	\tmp, =mxc_irq_controller_type
 	ldr	\tmp, [\tmp]
 	cmp	\tmp, #MXC_IRQ_TYPE_AVIC
 	beq	3001f
+	cmp	\tmp, #MXC_IRQ_TYPE_ICOLL
+	beq	3002f
 
 	tzic_get_irqnr_and_base \irqnr, \irqstat, \base, \tmp
-	b	3002f
+	b	3003f
 3001:
 	avic_get_irqnr_and_base \irqnr, \irqstat, \base, \tmp
+	b	3003f
 3002:
+	icoll_get_irqnr_and_base \irqnr, \irqstat, \base, \tmp
+	b	3003f
+3003:
 
 #elif defined CONFIG_MXC_TZIC

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

Quoted 10 lines
arch/arm/plat-mxc/include/mach/entry-macro.S +3 -1
 	tzic_get_irqnr_and_base \irqnr, \irqstat, \base, \tmp
 #elif defined CONFIG_MXC_AVIC
 	avic_get_irqnr_and_base \irqnr, \irqstat, \base, \tmp
+#elif defined CONFIG_MXC_ICOLL
+	icoll_get_irqnr_and_base \irqnr, \irqstat, \base, \tmp
 #else
-#error no tzic and no avic?
+#error none of tzic, avic, icoll?
 #endif
 	.endm

I wonder if it's sensible to integrate mx28 (and mx23) support into mach-imx/plat-mxc. They seem to better fit into mach-stmp378x?!

Best regards
Uwe

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

PATCH 3/11 ARM: imx: Add reset routine for i.MX28

In reply to Shawn Guo

1. The wdog reset is implemented in RTC block on MX28.
2. Implement the common reset routine for most blocks on MX28, so that the blocks can call it to get a software reset.

---
 arch/arm/plat-mxc/system.c |  104 ++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 101 insertions(+), 3 deletions(-)
arch/arm/plat-mxc/system.c +101 -3
index c3972c5..257b426 100644
@@ -1,7 +1,7 @@
 /*
  * Copyright (C) 1999 ARM Limited
  * Copyright (C) 2000 Deep Blue Solutions Ltd
- * Copyright 2006-2007 Freescale Semiconductor, Inc. All Rights Reserved.
+ * Copyright 2006-2010 Freescale Semiconductor, Inc. All Rights Reserved.
  * Copyright 2008 Juergen Beisert, kernel at pengutronix.de
  * Copyright 2009 Ilya Yanok, Emcraft Systems Ltd, yanok at emcraft.com
  *
@@ -36,6 +36,7 @@ static void __iomem *wdog_base;
 void arch_reset(char mode, const char *cmd)
 {
 	unsigned int wcr_enable;
+	struct clk *clk;
 
 #ifdef CONFIG_ARCH_MXC91231
 	if (cpu_is_mxc91231()) {
@@ -52,9 +53,18 @@ void arch_reset(char mode, const char *cmd)
 
 	if (cpu_is_mx1()) {
 		wcr_enable = (1 << 0);
-	} else {
-		struct clk *clk;
+	} else if (cpu_is_mx28()) {
+		clk = clk_get_sys("rtc", NULL);
+		if (!IS_ERR(clk))
+			clk_enable(clk);
 
+		/* set wdog count */
+		__raw_writel(1, wdog_base + 0x50);
+		/* wdog enbable bit */
+		wcr_enable = (1 << 4);
+		/* shift to SET address */
+		wdog_base += 0x4;
+	} else {
 		clk = clk_get_sys("imx-wdt.0", NULL);
 		if (!IS_ERR(clk))
 			clk_enable(clk);
@@ -80,3 +90,91 @@ void mxc_arch_reset_init(void __iomem *base)
 {
 	wdog_base = base;
 }
+
+#ifdef CONFIG_ARCH_MX28
+int mxc_reset_block(void __iomem *reg_addr)
+{
+	u32 reg;
+	int timeout;
+
+	/*
+	 * The process of software reset of IP block is done
+	 * in several steps:
+	 *
+	 * 1) clear SFTRST and wait it cleared;
+	 * 2) clear CLKGATE, set SFTRST, wait CLKGATE set;
+	 * 3) clear SFTRST and wait it cleared;
+	 * 4) clear CLKGATE and wait it cleared.
+	 */
+
+	/* Clear SFTRST */
+	reg = __raw_readl(reg_addr);
+	reg &= ~(1 << 31);
+	__raw_writel(reg, reg_addr);
+	/* Wait SFTRST cleared */
+	timeout = 1000;
+	do {
+		mdelay(1);
+		if ((__raw_readl(reg_addr) & (1 << 31)) == 0)
+			break;
+	} while (--timeout > 0);
+	if (timeout <= 0) {
+		pr_err("%s(%p): clear SFTRST timeout\n", __func__, reg_addr);
+		return -ETIMEDOUT;
+	}
+
+	/* Clear CLKGATE */
+	reg = __raw_readl(reg_addr);
+	reg &= ~(1 << 30);
+	__raw_writel(reg, reg_addr);
+	/* Set SFTRST to reset the block */
+	reg = __raw_readl(reg_addr);
+	reg |= (1 << 31);
+	__raw_writel(reg, reg_addr);
+	/* Poll CLKGATE set */
+	timeout = 1000;
+	do {
+		mdelay(1);
+		if (__raw_readl(reg_addr) & (1 << 30))
+			break;
+	} while (--timeout > 0);
+	if (timeout <= 0) {
+		pr_err("%s(%p): poll CLKGATE timeout\n", __func__, reg_addr);
+		return -ETIMEDOUT;
+	}
+
+	/* Clear SFTRST */
+	reg = __raw_readl(reg_addr);
+	reg &= ~(1 << 31);
+	__raw_writel(reg, reg_addr);
+	/* Wait SFTRST cleared */
+	timeout = 1000;
+	do {
+		mdelay(1);
+		if ((__raw_readl(reg_addr) & (1 << 31)) == 0)
+			break;
+	} while (--timeout > 0);
+	if (timeout <= 0) {
+		pr_err("%s(%p): clear SFTRST timeout\n", __func__, reg_addr);
+		return -ETIMEDOUT;
+	}
+
+	/* Clear CLKGATE */
+	reg = __raw_readl(reg_addr);
+	reg &= ~(1 << 30);
+	__raw_writel(reg, reg_addr);
+	/* Wait CLKGATE cleared */
+	timeout = 1000;
+	do {
+		mdelay(1);
+		if ((__raw_readl(reg_addr) & (1 << 30)) == 0)
+			break;
+	} while (--timeout > 0);
+	if (timeout <= 0) {
+		pr_err("%s(%p): clear CLKGATE timeout\n", __func__, reg_addr);
+		return -ETIMEDOUT;
+	}
+
+	return 0;
+}
+#endif
Signature · 1 line
1.7.1
#6 lore raw

PATCH 3/11 ARM: imx: Add reset routine for i.MX28

Quoted 34 lines · Shawn Guo

1. The wdog reset is implemented in RTC block on MX28.
2. Implement the common reset routine for most blocks on MX28, so that the blocks can call it to get a software reset.

---
 arch/arm/plat-mxc/system.c |  104 ++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 101 insertions(+), 3 deletions(-)
arch/arm/plat-mxc/system.c +2 -1
index c3972c5..257b426 100644
@@ -1,7 +1,7 @@
 /*
  * Copyright (C) 1999 ARM Limited
  * Copyright (C) 2000 Deep Blue Solutions Ltd
- * Copyright 2006-2007 Freescale Semiconductor, Inc. All Rights Reserved.
+ * Copyright 2006-2010 Freescale Semiconductor, Inc. All Rights Reserved.
  * Copyright 2008 Juergen Beisert, kernel at pengutronix.de
  * Copyright 2009 Ilya Yanok, Emcraft Systems Ltd, yanok at emcraft.com
  *
@@ -36,6 +36,7 @@ static void __iomem *wdog_base;
 void arch_reset(char mode, const char *cmd)
 {
 	unsigned int wcr_enable;
+	struct clk *clk;
 
 #ifdef CONFIG_ARCH_MXC91231
 	if (cpu_is_mxc91231()) {
@@ -52,9 +53,18 @@ void arch_reset(char mode, const char *cmd)
 
 	if (cpu_is_mx1()) {
 		wcr_enable = (1 << 0);

arch/arm/plat-mxc/system.c void arch_reset(char mode, const char *cmd) · line 63

Quoted 10 lines
arch/arm/plat-mxc/system.c +7 -2
-	} else {
-		struct clk *clk;
+	} else if (cpu_is_mx28()) {
+		clk = clk_get_sys("rtc", NULL);
+		if (!IS_ERR(clk))
+			clk_enable(clk);
 
+		/* set wdog count */
+		__raw_writel(1, wdog_base + 0x50);
+		/* wdog enbable bit */

s/enbable/enable/

Quoted 29 lines
arch/arm/plat-mxc/system.c +22 -0
+		wcr_enable = (1 << 4);
+		/* shift to SET address */
+		wdog_base += 0x4;
+	} else {
 		clk = clk_get_sys("imx-wdt.0", NULL);
 		if (!IS_ERR(clk))
 			clk_enable(clk);
@@ -80,3 +90,91 @@ void mxc_arch_reset_init(void __iomem *base)
 {
 	wdog_base = base;
 }
+
+#ifdef CONFIG_ARCH_MX28
+int mxc_reset_block(void __iomem *reg_addr)
+{
+	u32 reg;
+	int timeout;
+
+	/*
+	 * The process of software reset of IP block is done
+	 * in several steps:
+	 *
+	 * 1) clear SFTRST and wait it cleared;
+	 * 2) clear CLKGATE, set SFTRST, wait CLKGATE set;
+	 * 3) clear SFTRST and wait it cleared;
+	 * 4) clear CLKGATE and wait it cleared.
+	 */
+
+	/* Clear SFTRST */

arch/arm/plat-mxc/system.c void mxc_arch_reset_init(void __iomem *base) · line 120

Quoted 10 lines
arch/arm/plat-mxc/system.c +10 -0
+	reg = __raw_readl(reg_addr);
+	reg &= ~(1 << 31);
+	__raw_writel(reg, reg_addr);
+	/* Wait SFTRST cleared */
+	timeout = 1000;
+	do {
+		mdelay(1);
+		if ((__raw_readl(reg_addr) & (1 << 31)) == 0)
+			break;
+	} while (--timeout > 0);

Does the mdelay make sence here?

arch/arm/plat-mxc/system.c void mxc_arch_reset_init(void __iomem *base) · line 132

Quoted 12 lines
arch/arm/plat-mxc/system.c +12 -0
+	if (timeout <= 0) {
+		pr_err("%s(%p): clear SFTRST timeout\n", __func__, reg_addr);
+		return -ETIMEDOUT;
+	}
+
+	/* Clear CLKGATE */
+	reg = __raw_readl(reg_addr);
+	reg &= ~(1 << 30);
+	__raw_writel(reg, reg_addr);
+	/* Set SFTRST to reset the block */
+	reg = __raw_readl(reg_addr);
+	reg |= (1 << 31);

Can we have #defines here instead of constants?

Quoted 53 lines
arch/arm/plat-mxc/system.c +48 -0
+	__raw_writel(reg, reg_addr);
+	/* Poll CLKGATE set */
+	timeout = 1000;
+	do {
+		mdelay(1);
+		if (__raw_readl(reg_addr) & (1 << 30))
+			break;
+	} while (--timeout > 0);
+	if (timeout <= 0) {
+		pr_err("%s(%p): poll CLKGATE timeout\n", __func__, reg_addr);
+		return -ETIMEDOUT;
+	}
+
+	/* Clear SFTRST */
+	reg = __raw_readl(reg_addr);
+	reg &= ~(1 << 31);
+	__raw_writel(reg, reg_addr);
+	/* Wait SFTRST cleared */
+	timeout = 1000;
+	do {
+		mdelay(1);
+		if ((__raw_readl(reg_addr) & (1 << 31)) == 0)
+			break;
+	} while (--timeout > 0);
+	if (timeout <= 0) {
+		pr_err("%s(%p): clear SFTRST timeout\n", __func__, reg_addr);
+		return -ETIMEDOUT;
+	}
+
+	/* Clear CLKGATE */
+	reg = __raw_readl(reg_addr);
+	reg &= ~(1 << 30);
+	__raw_writel(reg, reg_addr);
+	/* Wait CLKGATE cleared */
+	timeout = 1000;
+	do {
+		mdelay(1);
+		if ((__raw_readl(reg_addr) & (1 << 30)) == 0)
+			break;
+	} while (--timeout > 0);
+	if (timeout <= 0) {
+		pr_err("%s(%p): clear CLKGATE timeout\n", __func__, reg_addr);
+		return -ETIMEDOUT;
+	}
+
+	return 0;
+}
+#endif
Signature · 1 line
1.7.1
Signature · 2 lines
Pengutronix e.K.                           | Uwe Kleine-K?nig            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
#7 lore raw

PATCH 3/11 ARM: imx: Add reset routine for i.MX28

2010/11/16 Uwe Kleine-K?nig <[email protected]>:

Quoted 21 lines · Shawn Guo
Quoted 20 lines
(quoted diff) +20 -0
+#ifdef CONFIG_ARCH_MX28
+int mxc_reset_block(void __iomem *reg_addr)
+{
+ ? ? u32 reg;
+ ? ? int timeout;
+
+ ? ? /*
+ ? ? ?* The process of software reset of IP block is done
+ ? ? ?* in several steps:
+ ? ? ?*
+ ? ? ?* 1) clear SFTRST and wait it cleared;
+ ? ? ?* 2) clear CLKGATE, set SFTRST, wait CLKGATE set;
+ ? ? ?* 3) clear SFTRST and wait it cleared;
+ ? ? ?* 4) clear CLKGATE and wait it cleared.
+ ? ? ?*/
+
+ ? ? /* Clear SFTRST */
+ ? ? reg = __raw_readl(reg_addr);
+ ? ? reg &= ~(1 << 31);
+ ? ? __raw_writel(reg, reg_addr);
Quoted 9 lines
Quoted 7 lines

+ ? ? /* Wait SFTRST cleared */
+ ? ? timeout = 1000;
+ ? ? do {
+ ? ? ? ? ? ? mdelay(1);
+ ? ? ? ? ? ? if ((__raw_readl(reg_addr) & (1 << 31)) == 0)
+ ? ? ? ? ? ? ? ? ? ? break;
+ ? ? } while (--timeout > 0);

Does the mdelay make sence here?

i.MX28 Application Processor Reference Manual, Chapter 39.5.10 "Correct Way to Software Reset a Block".

Signature · 2 lines
Regards,
Shawn
#8 lore raw

PATCH 3/11 ARM: imx: Add reset routine for i.MX28

Quoted 31 lines · Shawn Guo

2010/11/16 Uwe Kleine-K?nig <[email protected]>:

Quoted 21 lines · Shawn Guo
Quoted 20 lines
(quoted diff) +20 -0
+#ifdef CONFIG_ARCH_MX28
+int mxc_reset_block(void __iomem *reg_addr)
+{
+ ? ? u32 reg;
+ ? ? int timeout;
+
+ ? ? /*
+ ? ? ?* The process of software reset of IP block is done
+ ? ? ?* in several steps:
+ ? ? ?*
+ ? ? ?* 1) clear SFTRST and wait it cleared;
+ ? ? ?* 2) clear CLKGATE, set SFTRST, wait CLKGATE set;
+ ? ? ?* 3) clear SFTRST and wait it cleared;
+ ? ? ?* 4) clear CLKGATE and wait it cleared.
+ ? ? ?*/
+
+ ? ? /* Clear SFTRST */
+ ? ? reg = __raw_readl(reg_addr);
+ ? ? reg &= ~(1 << 31);
+ ? ? __raw_writel(reg, reg_addr);
Quoted 9 lines
Quoted 7 lines

+ ? ? /* Wait SFTRST cleared */
+ ? ? timeout = 1000;
+ ? ? do {
+ ? ? ? ? ? ? mdelay(1);
+ ? ? ? ? ? ? if ((__raw_readl(reg_addr) & (1 << 31)) == 0)
+ ? ? ? ? ? ? ? ? ? ? break;
+ ? ? } while (--timeout > 0);

Does the mdelay make sence here?

Quoted 2 lines

i.MX28 Application Processor Reference Manual, Chapter 39.5.10 "Correct Way to Software Reset a Block".

Quoting the chapter you pointed out:

	// Prepare for soft-reset by making sure that SFTRST is not currently
	// asserted. Also clear CLKGATE so we can wait for its assertion below.
	HW_GPMI_CTRL0_CLR(BM_GPMI_CTRL0_SFTRST);
	// Wait at least a microsecond for SFTRST to deassert. In actuality, we
	// need to wait 3 GPMI clocks, but this is much easier to implement.
	musecs = hw_profile_GetMicroseconds();
	while (HW_GPMI_CTRL0.B.SFTRST || (hw_profile_GetMicroseconds() - musecs <
	DDI_NAND_HAL_GPMI_SOFT_RESET_LATENCY));
	[...]

This talks about a microsecond, not a millisecond.

Expecting that most of the time not a whole millisecond is needed, I'd do something like that:

	val = __raw_readl(reset_addr);
	val &= ~MX28_MODULERESET_SFTRST;
	__raw_writel(val, reset_addr);

	/*
	 * SFTRST needs 3 GPMI clocks to settle, the reference manual
         * recommends to wait 1us.
	 */
	udelay(1);

	timeout = 0x400;
	while ((__raw_readl(reset_addr) & MX28_MODULERESET_SFTRST) && --timeout)
		/* nothing /*;

	if (!timeout)
		goto error;

That is do a busy read and don't busy wait a millisecond between two consecutive reads just twiddling thumbs.

Best regards
Uwe

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

PATCH 4/11 ARM: imx: Add timer support for i.MX28

In reply to Shawn Guo

SoC i.MX28 implements the timer in block TIMROT. It adds the support in the same file with GPT, and uses timer_is_timrot() to distinguish the IP block.

---
 arch/arm/plat-mxc/time.c |  120 ++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 100 insertions(+), 20 deletions(-)
arch/arm/plat-mxc/time.c +100 -20
index f9a1b05..3e1f09d 100644
@@ -5,6 +5,7 @@
  *  Copyright (C) 2002 Shane Nay (shane at minirl.com)
  *  Copyright (C) 2006-2007 Pavel Pisa (ppisa at pikron.com)
  *  Copyright (C) 2008 Juergen Beisert (kernel at pengutronix.de)
+ *  Copyright (C) 2010 Freescale Semiconductor, Inc. All Rights Reserved.
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -63,8 +64,22 @@
 #define V2_TCN			0x24
 #define V2_TCMP			0x10
 
-#define timer_is_v1()	(cpu_is_mx1() || cpu_is_mx21() || cpu_is_mx27())
-#define timer_is_v2()	(!timer_is_v1())
+/* TIMROT */
+#define HW_TIMROT_ROTCTRL			0x00
+#define HW_TIMROT_TIMCTRL0			0x20
+#define HW_TIMROT_TIMCTRL0_SET			0x24
+#define HW_TIMROT_TIMCTRL0_CLR			0x28
+#define HW_TIMROT_RUNNING_COUNT0		0x30
+#define HW_TIMROT_MATCH_COUNT0			0x50
+#define BM_TIMROT_TIMCTRL0_IRQ_EN		0x00004000
+#define BM_TIMROT_TIMCTRL0_IRQ			0x00008000
+#define BM_TIMROT_TIMCTRL0_MATCH_MODE		0x00000800
+#define BP_TIMROT_TIMCTRL0_SELECT		0
+#define BV_TIMROT_TIMCTRLn_SELECT__32KHZ_XTAL	0xb
+
+#define timer_is_v1()		(cpu_is_mx1() || cpu_is_mx21() || cpu_is_mx27())
+#define timer_is_v2()		(!timer_is_v1())
+#define timer_is_timrot()	(cpu_is_mx28())
 
 static struct clock_event_device clockevent_mxc;
 static enum clock_event_mode clockevent_mode = CLOCK_EVT_MODE_UNUSED;
@@ -105,6 +120,24 @@ static void gpt_irq_acknowledge(void)
 		__raw_writel(V2_TSTAT_OF1, timer_base + V2_TSTAT);
 }
 
+static inline void timrot_irq_disable(void)
+{
+	__raw_writel(BM_TIMROT_TIMCTRL0_IRQ_EN,
+			timer_base + HW_TIMROT_TIMCTRL0_CLR);
+}
+
+static inline void timrot_irq_enable(void)
+{
+	__raw_writel(BM_TIMROT_TIMCTRL0_IRQ_EN,
+			timer_base + HW_TIMROT_TIMCTRL0_SET);
+}
+
+static void timrot_irq_acknowledge(void)
+{
+	__raw_writel(BM_TIMROT_TIMCTRL0_IRQ,
+			timer_base + HW_TIMROT_TIMCTRL0_CLR);
+}
+
 static cycle_t mx1_2_get_cycles(struct clocksource *cs)
 {
 	return __raw_readl(timer_base + MX1_2_TCN);
@@ -115,6 +148,11 @@ static cycle_t v2_get_cycles(struct clocksource *cs)
 	return __raw_readl(timer_base + V2_TCN);
 }
 
+static cycle_t timrot_get_cycles(struct clocksource *cs)
+{
+	return ~__raw_readl(timer_base + HW_TIMROT_RUNNING_COUNT0);
+}
+
 static struct clocksource clocksource_mxc = {
 	.name 		= "mxc_timer1",
 	.rating		= 200,
@@ -128,8 +166,12 @@ static int __init mxc_clocksource_init(struct clk *timer_clk)
 {
 	unsigned int c = clk_get_rate(timer_clk);
 
-	if (timer_is_v2())
+	if (timer_is_timrot()) {
+		clocksource_mxc.read = timrot_get_cycles;
+		clocksource_mxc.shift = 10;
+	} else if (timer_is_v2()) {
 		clocksource_mxc.read = v2_get_cycles;
+	}
 
 	clocksource_mxc.mult = clocksource_hz2mult(c,
 					clocksource_mxc.shift);
@@ -166,6 +208,18 @@ static int v2_set_next_event(unsigned long evt,
 				-ETIME : 0;
 }
 
+static int timrot_set_next_event(unsigned long evt,
+					struct clock_event_device *dev)
+{
+	unsigned long match;
+
+	match = __raw_readl(timer_base + HW_TIMROT_MATCH_COUNT0) - evt;
+	__raw_writel(match, timer_base + HW_TIMROT_MATCH_COUNT0);
+
+	return (int)(match - __raw_readl(timer_base +
+			HW_TIMROT_RUNNING_COUNT0)) > 0 ? -ETIME : 0;
+}
+
 #ifdef DEBUG
 static const char *clock_event_mode_label[] = {
 	[CLOCK_EVT_MODE_PERIODIC] = "CLOCK_EVT_MODE_PERIODIC",
@@ -186,12 +240,19 @@ static void mxc_set_mode(enum clock_event_mode mode,
 	 */
 	local_irq_save(flags);
 
-	/* Disable interrupt in GPT module */
-	gpt_irq_disable();
+	/* Disable interrupt in timer module */
+	if (timer_is_timrot())
+		timrot_irq_disable();
+	else
+		gpt_irq_disable();
 
 	if (mode != clockevent_mode) {
 		/* Set event time into far-far future */
-		if (timer_is_v2())
+		if (timer_is_timrot())
+			__raw_writel(__raw_readl(timer_base +
+					HW_TIMROT_RUNNING_COUNT0) + 3,
+					timer_base + HW_TIMROT_MATCH_COUNT0);
+		else if (timer_is_v2())
 			__raw_writel(__raw_readl(timer_base + V2_TCN) - 3,
 					timer_base + V2_TCMP);
 		else
@@ -199,7 +260,10 @@ static void mxc_set_mode(enum clock_event_mode mode,
 					timer_base + MX1_2_TCMP);
 
 		/* Clear pending interrupt */
-		gpt_irq_acknowledge();
+		if (timer_is_timrot())
+			timrot_irq_acknowledge();
+		else
+			gpt_irq_acknowledge();
 	}
 
 #ifdef DEBUG
@@ -225,7 +289,10 @@ static void mxc_set_mode(enum clock_event_mode mode,
 	 * mode switching
 	 */
 		local_irq_save(flags);
-		gpt_irq_enable();
+		if (timer_is_timrot())
+			timrot_irq_enable();
+		else
+			gpt_irq_enable();
 		local_irq_restore(flags);
 		break;
 	case CLOCK_EVT_MODE_SHUTDOWN:
@@ -249,7 +316,10 @@ static irqreturn_t mxc_timer_interrupt(int irq, void *dev_id)
 	else
 		tstat = __raw_readl(timer_base + MX1_2_TSTAT);
 
-	gpt_irq_acknowledge();
+	if (timer_is_timrot())
+		timrot_irq_acknowledge();
+	else
+		gpt_irq_acknowledge();
 
 	evt->event_handler(evt);
 
@@ -275,7 +345,9 @@ static int __init mxc_clockevent_init(struct clk *timer_clk)
 {
 	unsigned int c = clk_get_rate(timer_clk);
 
-	if (timer_is_v2())
+	if (timer_is_timrot())
+		clockevent_mxc.set_next_event = timrot_set_next_event;
+	else if (timer_is_v2())
 		clockevent_mxc.set_next_event = v2_set_next_event;
 
 	clockevent_mxc.mult = div_sc(c, NSEC_PER_SEC,
@@ -303,16 +375,24 @@ void __init mxc_timer_init(struct clk *timer_clk, void __iomem *base, int irq)
 	/*
 	 * Initialise to a known state (all timers off, and timing reset)
 	 */
-
-	__raw_writel(0, timer_base + MXC_TCTL);
-	__raw_writel(0, timer_base + MXC_TPRER); /* see datasheet note */
-
-	if (timer_is_v2())
-		tctl_val = V2_TCTL_CLK_IPG | V2_TCTL_FRR | V2_TCTL_WAITEN | MXC_TCTL_TEN;
-	else
-		tctl_val = MX1_2_TCTL_FRR | MX1_2_TCTL_CLK_PCLK1 | MXC_TCTL_TEN;
-
-	__raw_writel(tctl_val, timer_base + MXC_TCTL);
+	if (timer_is_timrot()) {
+		mxc_reset_block(base + HW_TIMROT_ROTCTRL);
+		__raw_writel(
+			BV_TIMROT_TIMCTRLn_SELECT__32KHZ_XTAL |
+			BM_TIMROT_TIMCTRL0_IRQ_EN |
+			BM_TIMROT_TIMCTRL0_MATCH_MODE,
+			timer_base + HW_TIMROT_TIMCTRL0); /* timer0*/
+	} else {
+		__raw_writel(0, timer_base + MXC_TCTL);
+		__raw_writel(0, timer_base + MXC_TPRER); /* see datasheet note */
+		if (timer_is_v2())
+			tctl_val = V2_TCTL_CLK_IPG | V2_TCTL_FRR |
+					V2_TCTL_WAITEN | MXC_TCTL_TEN;
+		else
+			tctl_val = MX1_2_TCTL_FRR | MX1_2_TCTL_CLK_PCLK1 |
+					MXC_TCTL_TEN;
+		__raw_writel(tctl_val, timer_base + MXC_TCTL);
+	}
 
 	/* init and register the timer to the framework */
 	mxc_clocksource_init(timer_clk);
Signature · 1 line
1.7.1
#10 lore raw

PATCH 4/11 ARM: imx: Add timer support for i.MX28

Quoted 33 lines · Shawn Guo

SoC i.MX28 implements the timer in block TIMROT. It adds the support in the same file with GPT, and uses timer_is_timrot() to distinguish the IP block.

---
 arch/arm/plat-mxc/time.c |  120 ++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 100 insertions(+), 20 deletions(-)
arch/arm/plat-mxc/time.c +7 -2
index f9a1b05..3e1f09d 100644
@@ -5,6 +5,7 @@
  *  Copyright (C) 2002 Shane Nay (shane at minirl.com)
  *  Copyright (C) 2006-2007 Pavel Pisa (ppisa at pikron.com)
  *  Copyright (C) 2008 Juergen Beisert (kernel at pengutronix.de)
+ *  Copyright (C) 2010 Freescale Semiconductor, Inc. All Rights Reserved.
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -63,8 +64,22 @@
 #define V2_TCN			0x24
 #define V2_TCMP			0x10
 
-#define timer_is_v1()	(cpu_is_mx1() || cpu_is_mx21() || cpu_is_mx27())
-#define timer_is_v2()	(!timer_is_v1())
+/* TIMROT */
+#define HW_TIMROT_ROTCTRL			0x00
+#define HW_TIMROT_TIMCTRL0			0x20
+#define HW_TIMROT_TIMCTRL0_SET			0x24
+#define HW_TIMROT_TIMCTRL0_CLR			0x28
+#define HW_TIMROT_RUNNING_COUNT0		0x30

arch/arm/plat-mxc/time.c line 82

Quoted 10 lines
arch/arm/plat-mxc/time.c +10 -0
+#define HW_TIMROT_MATCH_COUNT0			0x50
+#define BM_TIMROT_TIMCTRL0_IRQ_EN		0x00004000
+#define BM_TIMROT_TIMCTRL0_IRQ			0x00008000
+#define BM_TIMROT_TIMCTRL0_MATCH_MODE		0x00000800
+#define BP_TIMROT_TIMCTRL0_SELECT		0
+#define BV_TIMROT_TIMCTRLn_SELECT__32KHZ_XTAL	0xb
+
+#define timer_is_v1()		(cpu_is_mx1() || cpu_is_mx21() || cpu_is_mx27())
+#define timer_is_v2()		(!timer_is_v1())
+#define timer_is_timrot()	(cpu_is_mx28())

Did you notice that timer_is_v2() evaluates to true on mx28?

Quoted 73 lines
arch/arm/plat-mxc/time.c +40 -1
 static struct clock_event_device clockevent_mxc;
 static enum clock_event_mode clockevent_mode = CLOCK_EVT_MODE_UNUSED;
@@ -105,6 +120,24 @@ static void gpt_irq_acknowledge(void)
 		__raw_writel(V2_TSTAT_OF1, timer_base + V2_TSTAT);
 }
 
+static inline void timrot_irq_disable(void)
+{
+	__raw_writel(BM_TIMROT_TIMCTRL0_IRQ_EN,
+			timer_base + HW_TIMROT_TIMCTRL0_CLR);
+}
+
+static inline void timrot_irq_enable(void)
+{
+	__raw_writel(BM_TIMROT_TIMCTRL0_IRQ_EN,
+			timer_base + HW_TIMROT_TIMCTRL0_SET);
+}
+
+static void timrot_irq_acknowledge(void)
+{
+	__raw_writel(BM_TIMROT_TIMCTRL0_IRQ,
+			timer_base + HW_TIMROT_TIMCTRL0_CLR);
+}
+
 static cycle_t mx1_2_get_cycles(struct clocksource *cs)
 {
 	return __raw_readl(timer_base + MX1_2_TCN);
@@ -115,6 +148,11 @@ static cycle_t v2_get_cycles(struct clocksource *cs)
 	return __raw_readl(timer_base + V2_TCN);
 }
 
+static cycle_t timrot_get_cycles(struct clocksource *cs)
+{
+	return ~__raw_readl(timer_base + HW_TIMROT_RUNNING_COUNT0);
+}
+
 static struct clocksource clocksource_mxc = {
 	.name 		= "mxc_timer1",
 	.rating		= 200,
@@ -128,8 +166,12 @@ static int __init mxc_clocksource_init(struct clk *timer_clk)
 {
 	unsigned int c = clk_get_rate(timer_clk);
 
-	if (timer_is_v2())
+	if (timer_is_timrot()) {
+		clocksource_mxc.read = timrot_get_cycles;
+		clocksource_mxc.shift = 10;
+	} else if (timer_is_v2()) {
 		clocksource_mxc.read = v2_get_cycles;
+	}
 
 	clocksource_mxc.mult = clocksource_hz2mult(c,
 					clocksource_mxc.shift);
@@ -166,6 +208,18 @@ static int v2_set_next_event(unsigned long evt,
 				-ETIME : 0;
 }
 
+static int timrot_set_next_event(unsigned long evt,
+					struct clock_event_device *dev)
+{
+	unsigned long match;
+
+	match = __raw_readl(timer_base + HW_TIMROT_MATCH_COUNT0) - evt;
+	__raw_writel(match, timer_base + HW_TIMROT_MATCH_COUNT0);
+
+	return (int)(match - __raw_readl(timer_base +
+			HW_TIMROT_RUNNING_COUNT0)) > 0 ? -ETIME : 0;
+}
+
 #ifdef DEBUG
 static const char *clock_event_mode_label[] = {
 	[CLOCK_EVT_MODE_PERIODIC] = "CLOCK_EVT_MODE_PERIODIC",

arch/arm/plat-mxc/time.c static void mxc_set_mode(enum clock_event_mode mode, · line 247

Quoted 10 lines
arch/arm/plat-mxc/time.c +5 -2
@@ -186,12 +240,19 @@ static void mxc_set_mode(enum clock_event_mode mode,
 	 */
 	local_irq_save(flags);
 
-	/* Disable interrupt in GPT module */
-	gpt_irq_disable();
+	/* Disable interrupt in timer module */
+	if (timer_is_timrot())
+		timrot_irq_disable();
+	else
+		gpt_irq_disable();

can we have timrot_set_mode() please. Having several cpu_is_... in hot paths isn't nice.

Quoted 98 lines
arch/arm/plat-mxc/time.c +38 -15
 	if (mode != clockevent_mode) {
 		/* Set event time into far-far future */
-		if (timer_is_v2())
+		if (timer_is_timrot())
+			__raw_writel(__raw_readl(timer_base +
+					HW_TIMROT_RUNNING_COUNT0) + 3,
+					timer_base + HW_TIMROT_MATCH_COUNT0);
+		else if (timer_is_v2())
 			__raw_writel(__raw_readl(timer_base + V2_TCN) - 3,
 					timer_base + V2_TCMP);
 		else
@@ -199,7 +260,10 @@ static void mxc_set_mode(enum clock_event_mode mode,
 					timer_base + MX1_2_TCMP);
 
 		/* Clear pending interrupt */
-		gpt_irq_acknowledge();
+		if (timer_is_timrot())
+			timrot_irq_acknowledge();
+		else
+			gpt_irq_acknowledge();
 	}
 
 #ifdef DEBUG
@@ -225,7 +289,10 @@ static void mxc_set_mode(enum clock_event_mode mode,
 	 * mode switching
 	 */
 		local_irq_save(flags);
-		gpt_irq_enable();
+		if (timer_is_timrot())
+			timrot_irq_enable();
+		else
+			gpt_irq_enable();
 		local_irq_restore(flags);
 		break;
 	case CLOCK_EVT_MODE_SHUTDOWN:
@@ -249,7 +316,10 @@ static irqreturn_t mxc_timer_interrupt(int irq, void *dev_id)
 	else
 		tstat = __raw_readl(timer_base + MX1_2_TSTAT);
 
-	gpt_irq_acknowledge();
+	if (timer_is_timrot())
+		timrot_irq_acknowledge();
+	else
+		gpt_irq_acknowledge();
 
 	evt->event_handler(evt);
 
@@ -275,7 +345,9 @@ static int __init mxc_clockevent_init(struct clk *timer_clk)
 {
 	unsigned int c = clk_get_rate(timer_clk);
 
-	if (timer_is_v2())
+	if (timer_is_timrot())
+		clockevent_mxc.set_next_event = timrot_set_next_event;
+	else if (timer_is_v2())
 		clockevent_mxc.set_next_event = v2_set_next_event;
 
 	clockevent_mxc.mult = div_sc(c, NSEC_PER_SEC,
@@ -303,16 +375,24 @@ void __init mxc_timer_init(struct clk *timer_clk, void __iomem *base, int irq)
 	/*
 	 * Initialise to a known state (all timers off, and timing reset)
 	 */
-
-	__raw_writel(0, timer_base + MXC_TCTL);
-	__raw_writel(0, timer_base + MXC_TPRER); /* see datasheet note */
-
-	if (timer_is_v2())
-		tctl_val = V2_TCTL_CLK_IPG | V2_TCTL_FRR | V2_TCTL_WAITEN | MXC_TCTL_TEN;
-	else
-		tctl_val = MX1_2_TCTL_FRR | MX1_2_TCTL_CLK_PCLK1 | MXC_TCTL_TEN;
-
-	__raw_writel(tctl_val, timer_base + MXC_TCTL);
+	if (timer_is_timrot()) {
+		mxc_reset_block(base + HW_TIMROT_ROTCTRL);
+		__raw_writel(
+			BV_TIMROT_TIMCTRLn_SELECT__32KHZ_XTAL |
+			BM_TIMROT_TIMCTRL0_IRQ_EN |
+			BM_TIMROT_TIMCTRL0_MATCH_MODE,
+			timer_base + HW_TIMROT_TIMCTRL0); /* timer0*/
+	} else {
+		__raw_writel(0, timer_base + MXC_TCTL);
+		__raw_writel(0, timer_base + MXC_TPRER); /* see datasheet note */
+		if (timer_is_v2())
+			tctl_val = V2_TCTL_CLK_IPG | V2_TCTL_FRR |
+					V2_TCTL_WAITEN | MXC_TCTL_TEN;
+		else
+			tctl_val = MX1_2_TCTL_FRR | MX1_2_TCTL_CLK_PCLK1 |
+					MXC_TCTL_TEN;
+		__raw_writel(tctl_val, timer_base + MXC_TCTL);
+	}
 
 	/* init and register the timer to the framework */
 	mxc_clocksource_init(timer_clk);
Signature · 1 line
1.7.1
Signature · 2 lines
Pengutronix e.K.                           | Uwe Kleine-K?nig            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
author
#11 lore raw

PATCH 5/11 ARM: imx: Add GPIO support for i.MX28

In reply to Shawn Guo

SoC i.MX28 implements GPIO functions in block PINCTRL. It adds the support in the same file used by other i.MX SoCs, and uses cpu_is_mx28() to distinguish the PINCTRL from GPIO used by other i.MX SoCs.

---
 arch/arm/plat-mxc/gpio.c |  186 +++++++++++++++++++++++++++++++++++++--------
 1 files changed, 153 insertions(+), 33 deletions(-)
arch/arm/plat-mxc/gpio.c +153 -33
index 9c3e362..f0d94af 100644
@@ -30,6 +30,17 @@
 static struct mxc_gpio_port *mxc_gpio_ports;
 static int gpio_table_size;
 
+/* PINCTRL */
+#define GPIO_PORT_ID(p)	(((void *)p - (void *)mxc_gpio_ports) / sizeof(p))
+#define GPIO_DOUT(p)		(0x0700 + GPIO_PORT_ID(p) * 0x10)
+#define GPIO_DIN(p)		(0x0900 + GPIO_PORT_ID(p) * 0x10)
+#define GPIO_DOE(p)		(0x0b00 + GPIO_PORT_ID(p) * 0x10)
+#define GPIO_PIN2IRQ(p)		(0x1000 + GPIO_PORT_ID(p) * 0x10)
+#define GPIO_IRQEN(p)		(0x1100 + GPIO_PORT_ID(p) * 0x10)
+#define GPIO_LEV(p)		(0x1200 + GPIO_PORT_ID(p) * 0x10)
+#define GPIO_POL(p)		(0x1300 + GPIO_PORT_ID(p) * 0x10)
+#define GPIO_IRQSTAT(p)		(0x1400 + GPIO_PORT_ID(p) * 0x10)
+
 #define cpu_is_mx1_mx2()	(cpu_is_mx1() || cpu_is_mx2())
 
 #define GPIO_DR		(cpu_is_mx1_mx2() ? 0x1c : 0x00)
@@ -40,17 +51,25 @@ static int gpio_table_size;
 #define GPIO_IMR	(cpu_is_mx1_mx2() ? 0x30 : 0x14)
 #define GPIO_ISR	(cpu_is_mx1_mx2() ? 0x34 : 0x18)
 
-#define GPIO_INT_LOW_LEV	(cpu_is_mx1_mx2() ? 0x3 : 0x0)
-#define GPIO_INT_HIGH_LEV	(cpu_is_mx1_mx2() ? 0x2 : 0x1)
-#define GPIO_INT_RISE_EDGE	(cpu_is_mx1_mx2() ? 0x0 : 0x2)
-#define GPIO_INT_FALL_EDGE	(cpu_is_mx1_mx2() ? 0x1 : 0x3)
+#define GPIO_INT_LOW_LEV \
+	(cpu_is_mx28() ? 0x1 : (cpu_is_mx1_mx2() ? 0x3 : 0x0))
+#define GPIO_INT_HIGH_LEV \
+	(cpu_is_mx28() ? 0x3 : (cpu_is_mx1_mx2() ? 0x2 : 0x1))
+#define GPIO_INT_RISE_EDGE \
+	(cpu_is_mx1_mx2() ? 0x0 : 0x2)
+#define GPIO_INT_FALL_EDGE \
+	(cpu_is_mx28() ? 0x0 : (cpu_is_mx1_mx2() ? 0x1 : 0x3))
 #define GPIO_INT_NONE		0x4
 
 /* Note: This driver assumes 32 GPIOs are handled in one register */
 
 static void _clear_gpio_irqstatus(struct mxc_gpio_port *port, u32 index)
 {
-	__raw_writel(1 << index, port->base + GPIO_ISR);
+	if (cpu_is_mx28())
+		__raw_writel(1 << index,
+				port->base + GPIO_IRQSTAT(port) + CLR_ADDR);
+	else
+		__raw_writel(1 << index, port->base + GPIO_ISR);
 }
 
 static void _set_gpio_irqenable(struct mxc_gpio_port *port, u32 index,
@@ -58,9 +77,23 @@ static void _set_gpio_irqenable(struct mxc_gpio_port *port, u32 index,
 {
 	u32 l;
 
-	l = __raw_readl(port->base + GPIO_IMR);
-	l = (l & (~(1 << index))) | (!!enable << index);
-	__raw_writel(l, port->base + GPIO_IMR);
+	if (cpu_is_mx28()) {
+		if (enable == 0) {
+			__raw_writel(1 << index,
+				port->base + GPIO_PIN2IRQ(port) + CLR_ADDR);
+			__raw_writel(1 << index,
+				port->base + GPIO_IRQEN(port) + CLR_ADDR);
+		} else {
+			__raw_writel(1 << index,
+				port->base + GPIO_PIN2IRQ(port) + SET_ADDR);
+			__raw_writel(1 << index,
+				port->base + GPIO_IRQEN(port) + SET_ADDR);
+		}
+	} else {
+		l = __raw_readl(port->base + GPIO_IMR);
+		l = (l & (~(1 << index))) | (!!enable << index);
+		__raw_writel(l, port->base + GPIO_IMR);
+	}
 }
 
 static void gpio_ack_irq(u32 irq)
@@ -120,10 +153,28 @@ static int gpio_set_irq_type(u32 irq, u32 type)
 		return -EINVAL;
 	}
 
-	reg += GPIO_ICR1 + ((gpio & 0x10) >> 2); /* lower or upper register */
-	bit = gpio & 0xf;
-	val = __raw_readl(reg) & ~(0x3 << (bit << 1));
-	__raw_writel(val | (edge << (bit << 1)), reg);
+	if (cpu_is_mx28()) {
+		/* set level or edge */
+		if (edge & 0x1)
+			__raw_writel(1 << (gpio & 31),
+					port->base + GPIO_LEV(port) + SET_ADDR);
+		else
+			__raw_writel(1 << (gpio & 31),
+					port->base + GPIO_LEV(port) + CLR_ADDR);
+		/* set polarity */
+		if ((edge >> 1) & 0x1)
+			__raw_writel(1 << (gpio & 31),
+					port->base + GPIO_POL(port) + SET_ADDR);
+		else
+			__raw_writel(1 << (gpio & 31),
+					port->base + GPIO_POL(port) + CLR_ADDR);
+	} else {
+		reg += GPIO_ICR1 + ((gpio & 0x10) >> 2);
+		bit = gpio & 0xf;
+		val = __raw_readl(reg) & ~(0x3 << (bit << 1));
+		__raw_writel(val | (edge << (bit << 1)), reg);
+	}
+
 	_clear_gpio_irqstatus(port, gpio & 0x1f);
 
 	return 0;
@@ -135,23 +186,36 @@ static void mxc_flip_edge(struct mxc_gpio_port *port, u32 gpio)
 	u32 bit, val;
 	int edge;
 
-	reg += GPIO_ICR1 + ((gpio & 0x10) >> 2); /* lower or upper register */
-	bit = gpio & 0xf;
-	val = __raw_readl(reg);
-	edge = (val >> (bit << 1)) & 3;
-	val &= ~(0x3 << (bit << 1));
-	if (edge == GPIO_INT_HIGH_LEV) {
-		edge = GPIO_INT_LOW_LEV;
-		pr_debug("mxc: switch GPIO %d to low trigger\n", gpio);
-	} else if (edge == GPIO_INT_LOW_LEV) {
-		edge = GPIO_INT_HIGH_LEV;
-		pr_debug("mxc: switch GPIO %d to high trigger\n", gpio);
+	if (cpu_is_mx28()) {
+		edge = 1 << (gpio & 31);
+		val = __raw_readl(port->base + GPIO_LEV(port));
+		if (val & edge) {
+			/* level is invalid for this function */
+			pr_err("mxc: invalid configuration for GPIO %d: %x\n",
+				gpio, edge);
+			return;
+		}
+		__raw_writel(1 << (gpio & 31),
+				port->base + GPIO_POL(port) + TOG_ADDR);
 	} else {
-		pr_err("mxc: invalid configuration for GPIO %d: %x\n",
-		       gpio, edge);
-		return;
+		reg += GPIO_ICR1 + ((gpio & 0x10) >> 2);
+		bit = gpio & 0xf;
+		val = __raw_readl(reg);
+		edge = (val >> (bit << 1)) & 3;
+		val &= ~(0x3 << (bit << 1));
+		if (edge == GPIO_INT_HIGH_LEV) {
+			edge = GPIO_INT_LOW_LEV;
+			pr_debug("mxc: switch GPIO %d to low trigger\n", gpio);
+		} else if (edge == GPIO_INT_LOW_LEV) {
+			edge = GPIO_INT_HIGH_LEV;
+			pr_debug("mxc: switch GPIO %d to high trigger\n", gpio);
+		} else {
+			pr_err("mxc: invalid configuration for GPIO %d: %x\n",
+			       gpio, edge);
+			return;
+		}
+		__raw_writel(val | (edge << (bit << 1)), reg);
 	}
-	__raw_writel(val | (edge << (bit << 1)), reg);
 }
 
 /* handle 32 interrupts in one status register */
@@ -183,6 +247,29 @@ static void mx3_gpio_irq_handler(u32 irq, struct irq_desc *desc)
 	mxc_gpio_irq_handler(port, irq_stat);
 }
 
+/* MX28 has one interrupt *per* gpio port */
+static void mx28_gpio_irq_handler(u32 irq, struct irq_desc *desc)
+{
+	u32 irq_stat;
+	struct mxc_gpio_port *port = (struct mxc_gpio_port *)get_irq_data(irq);
+	u32 gpio_irq_no_base = port->virtual_irq_start;
+
+	irq_stat = __raw_readl(port->base + GPIO_IRQSTAT(port)) &
+			__raw_readl(port->base + GPIO_IRQEN(port)) &
+			__raw_readl(port->base + GPIO_PIN2IRQ(port));
+
+	while (irq_stat != 0) {
+		int irqoffset = fls(irq_stat) - 1;
+
+		if (port->both_edges & (1 << irqoffset))
+			mxc_flip_edge(port, irqoffset);
+
+		generic_handle_irq(gpio_irq_no_base + irqoffset);
+
+		irq_stat &= ~(1 << irqoffset);
+	}
+}
+
 /* MX2 has one interrupt *for all* gpio ports */
 static void mx2_gpio_irq_handler(u32 irq, struct irq_desc *desc)
 {
@@ -247,14 +334,20 @@ static void _set_gpio_direction(struct gpio_chip *chip, unsigned offset,
 		container_of(chip, struct mxc_gpio_port, chip);
 	u32 l;
 	unsigned long flags;
+	void __iomem *reg;
+
+	if (cpu_is_mx28())
+		reg = port->base + GPIO_DOE(port);
+	else
+		reg = port->base + GPIO_GDIR;
 
 	spin_lock_irqsave(&port->lock, flags);
-	l = __raw_readl(port->base + GPIO_GDIR);
+	l = __raw_readl(reg);
 	if (dir)
 		l |= 1 << offset;
 	else
 		l &= ~(1 << offset);
-	__raw_writel(l, port->base + GPIO_GDIR);
+	__raw_writel(l, reg);
 	spin_unlock_irqrestore(&port->lock, flags);
 }
 
@@ -262,9 +355,14 @@ static void mxc_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
 {
 	struct mxc_gpio_port *port =
 		container_of(chip, struct mxc_gpio_port, chip);
-	void __iomem *reg = port->base + GPIO_DR;
 	u32 l;
 	unsigned long flags;
+	void __iomem *reg;
+
+	if (cpu_is_mx28())
+		reg = port->base + GPIO_DOUT(port);
+	else
+		reg = port->base + GPIO_DR;
 
 	spin_lock_irqsave(&port->lock, flags);
 	l = (__raw_readl(reg) & (~(1 << offset))) | (!!value << offset);
@@ -276,8 +374,14 @@ static int mxc_gpio_get(struct gpio_chip *chip, unsigned offset)
 {
 	struct mxc_gpio_port *port =
 		container_of(chip, struct mxc_gpio_port, chip);
+	void __iomem *reg;
+
+	if (cpu_is_mx28())
+		reg = port->base + GPIO_DIN(port);
+	else
+		reg = port->base + GPIO_PSR;
 
-	return (__raw_readl(port->base + GPIO_PSR) >> offset) & 1;
+	return (__raw_readl(reg) >> offset) & 1;
 }
 
 static int mxc_gpio_direction_input(struct gpio_chip *chip, unsigned offset)
@@ -306,8 +410,19 @@ int __init mxc_gpio_init(struct mxc_gpio_port *port, int cnt)
 
 	for (i = 0; i < cnt; i++) {
 		/* disable the interrupt and clear the status */
-		__raw_writel(0, port[i].base + GPIO_IMR);
-		__raw_writel(~0, port[i].base + GPIO_ISR);
+		if (cpu_is_mx28()) {
+			__raw_writel(0, port[i].base +
+						GPIO_PIN2IRQ(&port[i]));
+			__raw_writel(0, port[i].base +
+						GPIO_IRQEN(&port[i]));
+			__raw_writel(~0, port[i].base +
+						GPIO_IRQSTAT(&port[i]) +
+						CLR_ADDR);
+		} else {
+			__raw_writel(0, port[i].base + GPIO_IMR);
+			__raw_writel(~0, port[i].base + GPIO_ISR);
+		}
+
 		for (j = port[i].virtual_irq_start;
 			j < port[i].virtual_irq_start + 32; j++) {
 			set_irq_chip(j, &gpio_irq_chip);
@@ -338,6 +453,11 @@ int __init mxc_gpio_init(struct mxc_gpio_port *port, int cnt)
 						mx3_gpio_irq_handler);
 				set_irq_data(port[i].irq_high, &port[i]);
 			}
+		} else if (cpu_is_mx28()) {
+			/* setup one handler for each entry */
+			set_irq_chained_handler(port[i].irq,
+						mx28_gpio_irq_handler);
+			set_irq_data(port[i].irq, &port[i]);
 		}
 	}
 
Signature · 1 line
1.7.1
#12 lore raw

PATCH 5/11 ARM: imx: Add GPIO support for i.MX28

Quoted 33 lines · Shawn Guo

SoC i.MX28 implements GPIO functions in block PINCTRL. It adds the support in the same file used by other i.MX SoCs, and uses cpu_is_mx28() to distinguish the PINCTRL from GPIO used by other i.MX SoCs.

---
 arch/arm/plat-mxc/gpio.c |  186 +++++++++++++++++++++++++++++++++++++--------
 1 files changed, 153 insertions(+), 33 deletions(-)
arch/arm/plat-mxc/gpio.c +11 -0
index 9c3e362..f0d94af 100644
@@ -30,6 +30,17 @@
 static struct mxc_gpio_port *mxc_gpio_ports;
 static int gpio_table_size;
 
+/* PINCTRL */
+#define GPIO_PORT_ID(p)	(((void *)p - (void *)mxc_gpio_ports) / sizeof(p))
+#define GPIO_DOUT(p)		(0x0700 + GPIO_PORT_ID(p) * 0x10)
+#define GPIO_DIN(p)		(0x0900 + GPIO_PORT_ID(p) * 0x10)
+#define GPIO_DOE(p)		(0x0b00 + GPIO_PORT_ID(p) * 0x10)
+#define GPIO_PIN2IRQ(p)		(0x1000 + GPIO_PORT_ID(p) * 0x10)
+#define GPIO_IRQEN(p)		(0x1100 + GPIO_PORT_ID(p) * 0x10)
+#define GPIO_LEV(p)		(0x1200 + GPIO_PORT_ID(p) * 0x10)
+#define GPIO_POL(p)		(0x1300 + GPIO_PORT_ID(p) * 0x10)
+#define GPIO_IRQSTAT(p)		(0x1400 + GPIO_PORT_ID(p) * 0x10)
+
 #define cpu_is_mx1_mx2()	(cpu_is_mx1() || cpu_is_mx2())
 
 #define GPIO_DR		(cpu_is_mx1_mx2() ? 0x1c : 0x00)

arch/arm/plat-mxc/gpio.c static int gpio_table_size; · line 55

Quoted 9 lines
arch/arm/plat-mxc/gpio.c +2 -4
@@ -40,17 +51,25 @@ static int gpio_table_size;
 #define GPIO_IMR	(cpu_is_mx1_mx2() ? 0x30 : 0x14)
 #define GPIO_ISR	(cpu_is_mx1_mx2() ? 0x34 : 0x18)
 
-#define GPIO_INT_LOW_LEV	(cpu_is_mx1_mx2() ? 0x3 : 0x0)
-#define GPIO_INT_HIGH_LEV	(cpu_is_mx1_mx2() ? 0x2 : 0x1)
-#define GPIO_INT_RISE_EDGE	(cpu_is_mx1_mx2() ? 0x0 : 0x2)
-#define GPIO_INT_FALL_EDGE	(cpu_is_mx1_mx2() ? 0x1 : 0x3)
+#define GPIO_INT_LOW_LEV \
+	(cpu_is_mx28() ? 0x1 : (cpu_is_mx1_mx2() ? 0x3 : 0x0))

I'm more and more conviced that it doesn't make sense to fold mx28 into the existing mxc code.

Quoted 189 lines
arch/arm/plat-mxc/gpio.c +109 -25
+#define GPIO_INT_HIGH_LEV \
+	(cpu_is_mx28() ? 0x3 : (cpu_is_mx1_mx2() ? 0x2 : 0x1))
+#define GPIO_INT_RISE_EDGE \
+	(cpu_is_mx1_mx2() ? 0x0 : 0x2)
+#define GPIO_INT_FALL_EDGE \
+	(cpu_is_mx28() ? 0x0 : (cpu_is_mx1_mx2() ? 0x1 : 0x3))
 #define GPIO_INT_NONE		0x4
 
 /* Note: This driver assumes 32 GPIOs are handled in one register */
 
 static void _clear_gpio_irqstatus(struct mxc_gpio_port *port, u32 index)
 {
-	__raw_writel(1 << index, port->base + GPIO_ISR);
+	if (cpu_is_mx28())
+		__raw_writel(1 << index,
+				port->base + GPIO_IRQSTAT(port) + CLR_ADDR);
+	else
+		__raw_writel(1 << index, port->base + GPIO_ISR);
 }
 
 static void _set_gpio_irqenable(struct mxc_gpio_port *port, u32 index,
@@ -58,9 +77,23 @@ static void _set_gpio_irqenable(struct mxc_gpio_port *port, u32 index,
 {
 	u32 l;
 
-	l = __raw_readl(port->base + GPIO_IMR);
-	l = (l & (~(1 << index))) | (!!enable << index);
-	__raw_writel(l, port->base + GPIO_IMR);
+	if (cpu_is_mx28()) {
+		if (enable == 0) {
+			__raw_writel(1 << index,
+				port->base + GPIO_PIN2IRQ(port) + CLR_ADDR);
+			__raw_writel(1 << index,
+				port->base + GPIO_IRQEN(port) + CLR_ADDR);
+		} else {
+			__raw_writel(1 << index,
+				port->base + GPIO_PIN2IRQ(port) + SET_ADDR);
+			__raw_writel(1 << index,
+				port->base + GPIO_IRQEN(port) + SET_ADDR);
+		}
+	} else {
+		l = __raw_readl(port->base + GPIO_IMR);
+		l = (l & (~(1 << index))) | (!!enable << index);
+		__raw_writel(l, port->base + GPIO_IMR);
+	}
 }
 
 static void gpio_ack_irq(u32 irq)
@@ -120,10 +153,28 @@ static int gpio_set_irq_type(u32 irq, u32 type)
 		return -EINVAL;
 	}
 
-	reg += GPIO_ICR1 + ((gpio & 0x10) >> 2); /* lower or upper register */
-	bit = gpio & 0xf;
-	val = __raw_readl(reg) & ~(0x3 << (bit << 1));
-	__raw_writel(val | (edge << (bit << 1)), reg);
+	if (cpu_is_mx28()) {
+		/* set level or edge */
+		if (edge & 0x1)
+			__raw_writel(1 << (gpio & 31),
+					port->base + GPIO_LEV(port) + SET_ADDR);
+		else
+			__raw_writel(1 << (gpio & 31),
+					port->base + GPIO_LEV(port) + CLR_ADDR);
+		/* set polarity */
+		if ((edge >> 1) & 0x1)
+			__raw_writel(1 << (gpio & 31),
+					port->base + GPIO_POL(port) + SET_ADDR);
+		else
+			__raw_writel(1 << (gpio & 31),
+					port->base + GPIO_POL(port) + CLR_ADDR);
+	} else {
+		reg += GPIO_ICR1 + ((gpio & 0x10) >> 2);
+		bit = gpio & 0xf;
+		val = __raw_readl(reg) & ~(0x3 << (bit << 1));
+		__raw_writel(val | (edge << (bit << 1)), reg);
+	}
+
 	_clear_gpio_irqstatus(port, gpio & 0x1f);
 
 	return 0;
@@ -135,23 +186,36 @@ static void mxc_flip_edge(struct mxc_gpio_port *port, u32 gpio)
 	u32 bit, val;
 	int edge;
 
-	reg += GPIO_ICR1 + ((gpio & 0x10) >> 2); /* lower or upper register */
-	bit = gpio & 0xf;
-	val = __raw_readl(reg);
-	edge = (val >> (bit << 1)) & 3;
-	val &= ~(0x3 << (bit << 1));
-	if (edge == GPIO_INT_HIGH_LEV) {
-		edge = GPIO_INT_LOW_LEV;
-		pr_debug("mxc: switch GPIO %d to low trigger\n", gpio);
-	} else if (edge == GPIO_INT_LOW_LEV) {
-		edge = GPIO_INT_HIGH_LEV;
-		pr_debug("mxc: switch GPIO %d to high trigger\n", gpio);
+	if (cpu_is_mx28()) {
+		edge = 1 << (gpio & 31);
+		val = __raw_readl(port->base + GPIO_LEV(port));
+		if (val & edge) {
+			/* level is invalid for this function */
+			pr_err("mxc: invalid configuration for GPIO %d: %x\n",
+				gpio, edge);
+			return;
+		}
+		__raw_writel(1 << (gpio & 31),
+				port->base + GPIO_POL(port) + TOG_ADDR);
 	} else {
-		pr_err("mxc: invalid configuration for GPIO %d: %x\n",
-		       gpio, edge);
-		return;
+		reg += GPIO_ICR1 + ((gpio & 0x10) >> 2);
+		bit = gpio & 0xf;
+		val = __raw_readl(reg);
+		edge = (val >> (bit << 1)) & 3;
+		val &= ~(0x3 << (bit << 1));
+		if (edge == GPIO_INT_HIGH_LEV) {
+			edge = GPIO_INT_LOW_LEV;
+			pr_debug("mxc: switch GPIO %d to low trigger\n", gpio);
+		} else if (edge == GPIO_INT_LOW_LEV) {
+			edge = GPIO_INT_HIGH_LEV;
+			pr_debug("mxc: switch GPIO %d to high trigger\n", gpio);
+		} else {
+			pr_err("mxc: invalid configuration for GPIO %d: %x\n",
+			       gpio, edge);
+			return;
+		}
+		__raw_writel(val | (edge << (bit << 1)), reg);
 	}
-	__raw_writel(val | (edge << (bit << 1)), reg);
 }
 
 /* handle 32 interrupts in one status register */
@@ -183,6 +247,29 @@ static void mx3_gpio_irq_handler(u32 irq, struct irq_desc *desc)
 	mxc_gpio_irq_handler(port, irq_stat);
 }
 
+/* MX28 has one interrupt *per* gpio port */
+static void mx28_gpio_irq_handler(u32 irq, struct irq_desc *desc)
+{
+	u32 irq_stat;
+	struct mxc_gpio_port *port = (struct mxc_gpio_port *)get_irq_data(irq);
+	u32 gpio_irq_no_base = port->virtual_irq_start;
+
+	irq_stat = __raw_readl(port->base + GPIO_IRQSTAT(port)) &
+			__raw_readl(port->base + GPIO_IRQEN(port)) &
+			__raw_readl(port->base + GPIO_PIN2IRQ(port));
+
+	while (irq_stat != 0) {
+		int irqoffset = fls(irq_stat) - 1;
+
+		if (port->both_edges & (1 << irqoffset))
+			mxc_flip_edge(port, irqoffset);
+
+		generic_handle_irq(gpio_irq_no_base + irqoffset);
+
+		irq_stat &= ~(1 << irqoffset);
+	}
+}
+
 /* MX2 has one interrupt *for all* gpio ports */
 static void mx2_gpio_irq_handler(u32 irq, struct irq_desc *desc)
 {
@@ -247,14 +334,20 @@ static void _set_gpio_direction(struct gpio_chip *chip, unsigned offset,
 		container_of(chip, struct mxc_gpio_port, chip);
 	u32 l;
 	unsigned long flags;
+	void __iomem *reg;
+
+	if (cpu_is_mx28())
+		reg = port->base + GPIO_DOE(port);
+	else
+		reg = port->base + GPIO_GDIR;
 
 	spin_lock_irqsave(&port->lock, flags);
-	l = __raw_readl(port->base + GPIO_GDIR);
+	l = __raw_readl(reg);
 	if (dir)
 		l |= 1 << offset;
 	else
 		l &= ~(1 << offset);
-	__raw_writel(l, port->base + GPIO_GDIR);
+	__raw_writel(l, reg);
 	spin_unlock_irqrestore(&port->lock, flags);
 }
 
@@ -262,9 +355,14 @@ static void mxc_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
 {
 	struct mxc_gpio_port *port =

arch/arm/plat-mxc/gpio.c static void mxc_gpio_set(struct gpio_chip *chip, unsigned offset, int value) · line 365

Quoted 10 lines
arch/arm/plat-mxc/gpio.c +6 -1
 		container_of(chip, struct mxc_gpio_port, chip);
-	void __iomem *reg = port->base + GPIO_DR;
 	u32 l;
 	unsigned long flags;
+	void __iomem *reg;
+
+	if (cpu_is_mx28())
+		reg = port->base + GPIO_DOUT(port);
+	else
+		reg = port->base + GPIO_DR;

Here again, you clutter several hot paths with if(cpu_is_...()) tests.

gpiolib is generic enough not to need this.

Quoted 58 lines
arch/arm/plat-mxc/gpio.c +25 -3
 	spin_lock_irqsave(&port->lock, flags);
 	l = (__raw_readl(reg) & (~(1 << offset))) | (!!value << offset);
@@ -276,8 +374,14 @@ static int mxc_gpio_get(struct gpio_chip *chip, unsigned offset)
 {
 	struct mxc_gpio_port *port =
 		container_of(chip, struct mxc_gpio_port, chip);
+	void __iomem *reg;
+
+	if (cpu_is_mx28())
+		reg = port->base + GPIO_DIN(port);
+	else
+		reg = port->base + GPIO_PSR;
 
-	return (__raw_readl(port->base + GPIO_PSR) >> offset) & 1;
+	return (__raw_readl(reg) >> offset) & 1;
 }
 
 static int mxc_gpio_direction_input(struct gpio_chip *chip, unsigned offset)
@@ -306,8 +410,19 @@ int __init mxc_gpio_init(struct mxc_gpio_port *port, int cnt)
 
 	for (i = 0; i < cnt; i++) {
 		/* disable the interrupt and clear the status */
-		__raw_writel(0, port[i].base + GPIO_IMR);
-		__raw_writel(~0, port[i].base + GPIO_ISR);
+		if (cpu_is_mx28()) {
+			__raw_writel(0, port[i].base +
+						GPIO_PIN2IRQ(&port[i]));
+			__raw_writel(0, port[i].base +
+						GPIO_IRQEN(&port[i]));
+			__raw_writel(~0, port[i].base +
+						GPIO_IRQSTAT(&port[i]) +
+						CLR_ADDR);
+		} else {
+			__raw_writel(0, port[i].base + GPIO_IMR);
+			__raw_writel(~0, port[i].base + GPIO_ISR);
+		}
+
 		for (j = port[i].virtual_irq_start;
 			j < port[i].virtual_irq_start + 32; j++) {
 			set_irq_chip(j, &gpio_irq_chip);
@@ -338,6 +453,11 @@ int __init mxc_gpio_init(struct mxc_gpio_port *port, int cnt)
 						mx3_gpio_irq_handler);
 				set_irq_data(port[i].irq_high, &port[i]);
 			}
+		} else if (cpu_is_mx28()) {
+			/* setup one handler for each entry */
+			set_irq_chained_handler(port[i].irq,
+						mx28_gpio_irq_handler);
+			set_irq_data(port[i].irq, &port[i]);
 		}
 	}
 
Signature · 1 line
1.7.1
Signature · 2 lines
Pengutronix e.K.                           | Uwe Kleine-K?nig            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
author
#13 lore raw

PATCH 6/11 ARM: imx: Add IOMUX support for i.MX28

In reply to Shawn Guo

Soc i.MX28 supports IOMUX function in block PINCTRL. Comparing to the naming of iomux-v1 and iomux-v3, it uses iomux-pinctrl, since PINCTRL is a totally different IP block from IOMUX and it's not reasonable to name it iomux-v2 or iomux-v4, which is used to distinguish the different revision of same IP block.

---
 arch/arm/plat-mxc/include/mach/iomux-mx28.h    |   50 +++++++++++++
 arch/arm/plat-mxc/include/mach/iomux-pinctrl.h |   91 +++++++++++++++++++++++
 arch/arm/plat-mxc/iomux-pinctrl.c              |   94 ++++++++++++++++++++++++
 3 files changed, 235 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/plat-mxc/include/mach/iomux-mx28.h
 create mode 100644 arch/arm/plat-mxc/include/mach/iomux-pinctrl.h
 create mode 100644 arch/arm/plat-mxc/iomux-pinctrl.c
arch/arm/plat-mxc/include/mach/iomux-mx28.h new file +50 -0
new file mode 100644
index 0000000..8c68bd6
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2009-2010 Freescale Semiconductor, Inc. All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef __MACH_IOMUX_MX28_H__
+#define __MACH_IOMUX_MX28_H__
+
+#include <mach/iomux-pinctrl.h>
+
+/*
+ * The naming convention for the pad modes is MX28_PAD_<padname>__<padmode>
+ * If <padname> or <padmode> refers to a GPIO, it is named GPIO_<unit>_<num>
+ * See also iomux-pinctrl.h
+ *
+ *					 		BANK PIN     MUX            VOL          MA            PULL
+ */
+/* DUART */
+#define MX28_PAD_PWM0__DUART_RX			IOMUX_PAD(3, 16, PAD_MUXSEL_2,    PAD_3V3,     PAD_4MA,      PAD_NOPULL)
+#define MX28_PAD_PWM1__DUART_TX			IOMUX_PAD(3, 17, PAD_MUXSEL_2,    PAD_3V3,     PAD_4MA,      PAD_NOPULL)
+
+/* FEC */
+#define MX28_PAD_ENET0_MDC__ENET0_MDC		IOMUX_PAD(4, 0,  PAD_MUXSEL_0,    PAD_3V3,     PAD_8MA,      PAD_PULL)
+#define MX28_PAD_ENET0_MDIO__ENET0_MDIO		IOMUX_PAD(4, 1,  PAD_MUXSEL_0,    PAD_3V3,     PAD_8MA,      PAD_PULL)
+#define MX28_PAD_ENET0_RX_EN__ENET0_RX_EN	IOMUX_PAD(4, 2,  PAD_MUXSEL_0,    PAD_3V3,     PAD_8MA,      PAD_PULL)
+#define MX28_PAD_ENET0_RXD0__ENET0_RXD0		IOMUX_PAD(4, 3,  PAD_MUXSEL_0,    PAD_3V3,     PAD_8MA,      PAD_PULL)
+#define MX28_PAD_ENET0_RXD1__ENET0_RXD1		IOMUX_PAD(4, 4,  PAD_MUXSEL_0,    PAD_3V3,     PAD_8MA,      PAD_PULL)
+#define MX28_PAD_ENET0_TX_EN__ENET0_TX_EN	IOMUX_PAD(4, 6,  PAD_MUXSEL_0,    PAD_3V3,     PAD_8MA,      PAD_PULL)
+#define MX28_PAD_ENET0_TXD0__ENET0_TXD0		IOMUX_PAD(4, 7,  PAD_MUXSEL_0,    PAD_3V3,     PAD_8MA,      PAD_PULL)
+#define MX28_PAD_ENET0_TXD1__ENET0_TXD1		IOMUX_PAD(4, 8,  PAD_MUXSEL_0,    PAD_3V3,     PAD_8MA,      PAD_PULL)
+#define MX28_PAD_ENET_CLK__ENET_CLK		IOMUX_PAD(4, 16, PAD_MUXSEL_0,    PAD_3V3,     PAD_8MA,      PAD_PULL)
+
+/* GPIO */
+#define MX28_PAD_SSP1_DATA3__GPIO_2_15		IOMUX_PAD(2, 15, PAD_MUXSEL_GPIO, PAD_3V3,     PAD_4MA,      PAD_NOPULL)
+#define MX28_PAD_ENET0_RX_CLK__GPIO_4_13	IOMUX_PAD(4, 13, PAD_MUXSEL_GPIO, PAD_3V3,     PAD_4MA,      PAD_NOPULL)
+
+#endif /* __MACH_IOMUX_MX28_H__ */
arch/arm/plat-mxc/include/mach/iomux-pinctrl.h new file +91 -0

91 lines not on this page · raw message

arch/arm/plat-mxc/iomux-pinctrl.c new file +94 -0

94 lines not on this page · raw message

Signature · 1 line
1.7.1
#14 lore raw

PATCH 6/11 ARM: imx: Add IOMUX support for i.MX28

Quoted 4 lines · Shawn Guo

Soc i.MX28 supports IOMUX function in block PINCTRL. Comparing to the naming of iomux-v1 and iomux-v3, it uses iomux-pinctrl, since PINCTRL is a totally different IP block from IOMUX and it's not reasonable to name it iomux-v2 or iomux-v4, which is used to

iomux v2 is already taken (by mx31) it just doesn't have this name (yet) in the code.

Quoted 1 line

distinguish the different revision of same IP block.

Sounds more like something complet

Quoted 94 lines
---
 arch/arm/plat-mxc/include/mach/iomux-mx28.h    |   50 +++++++++++++
 arch/arm/plat-mxc/include/mach/iomux-pinctrl.h |   91 +++++++++++++++++++++++
 arch/arm/plat-mxc/iomux-pinctrl.c              |   94 ++++++++++++++++++++++++
 3 files changed, 235 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/plat-mxc/include/mach/iomux-mx28.h
 create mode 100644 arch/arm/plat-mxc/include/mach/iomux-pinctrl.h
 create mode 100644 arch/arm/plat-mxc/iomux-pinctrl.c
arch/arm/plat-mxc/include/mach/iomux-mx28.h new file +50 -0
new file mode 100644
index 0000000..8c68bd6
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2009-2010 Freescale Semiconductor, Inc. All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef __MACH_IOMUX_MX28_H__
+#define __MACH_IOMUX_MX28_H__
+
+#include <mach/iomux-pinctrl.h>
+
+/*
+ * The naming convention for the pad modes is MX28_PAD_<padname>__<padmode>
+ * If <padname> or <padmode> refers to a GPIO, it is named GPIO_<unit>_<num>
+ * See also iomux-pinctrl.h
+ *
+ *					 		BANK PIN     MUX            VOL          MA            PULL
+ */
+/* DUART */
+#define MX28_PAD_PWM0__DUART_RX			IOMUX_PAD(3, 16, PAD_MUXSEL_2,    PAD_3V3,     PAD_4MA,      PAD_NOPULL)
+#define MX28_PAD_PWM1__DUART_TX			IOMUX_PAD(3, 17, PAD_MUXSEL_2,    PAD_3V3,     PAD_4MA,      PAD_NOPULL)
+
+/* FEC */
+#define MX28_PAD_ENET0_MDC__ENET0_MDC		IOMUX_PAD(4, 0,  PAD_MUXSEL_0,    PAD_3V3,     PAD_8MA,      PAD_PULL)
+#define MX28_PAD_ENET0_MDIO__ENET0_MDIO		IOMUX_PAD(4, 1,  PAD_MUXSEL_0,    PAD_3V3,     PAD_8MA,      PAD_PULL)
+#define MX28_PAD_ENET0_RX_EN__ENET0_RX_EN	IOMUX_PAD(4, 2,  PAD_MUXSEL_0,    PAD_3V3,     PAD_8MA,      PAD_PULL)
+#define MX28_PAD_ENET0_RXD0__ENET0_RXD0		IOMUX_PAD(4, 3,  PAD_MUXSEL_0,    PAD_3V3,     PAD_8MA,      PAD_PULL)
+#define MX28_PAD_ENET0_RXD1__ENET0_RXD1		IOMUX_PAD(4, 4,  PAD_MUXSEL_0,    PAD_3V3,     PAD_8MA,      PAD_PULL)
+#define MX28_PAD_ENET0_TX_EN__ENET0_TX_EN	IOMUX_PAD(4, 6,  PAD_MUXSEL_0,    PAD_3V3,     PAD_8MA,      PAD_PULL)
+#define MX28_PAD_ENET0_TXD0__ENET0_TXD0		IOMUX_PAD(4, 7,  PAD_MUXSEL_0,    PAD_3V3,     PAD_8MA,      PAD_PULL)
+#define MX28_PAD_ENET0_TXD1__ENET0_TXD1		IOMUX_PAD(4, 8,  PAD_MUXSEL_0,    PAD_3V3,     PAD_8MA,      PAD_PULL)
+#define MX28_PAD_ENET_CLK__ENET_CLK		IOMUX_PAD(4, 16, PAD_MUXSEL_0,    PAD_3V3,     PAD_8MA,      PAD_PULL)
+
+/* GPIO */
+#define MX28_PAD_SSP1_DATA3__GPIO_2_15		IOMUX_PAD(2, 15, PAD_MUXSEL_GPIO, PAD_3V3,     PAD_4MA,      PAD_NOPULL)
+#define MX28_PAD_ENET0_RX_CLK__GPIO_4_13	IOMUX_PAD(4, 13, PAD_MUXSEL_GPIO, PAD_3V3,     PAD_4MA,      PAD_NOPULL)
+
+#endif /* __MACH_IOMUX_MX28_H__ */
arch/arm/plat-mxc/include/mach/iomux-pinctrl.h new file +21 -0
new file mode 100644
index 0000000..c2fdb33
@@ -0,0 +1,91 @@
+/*
+ * Copyright (C) 2009 by Jan Weitzel Phytec Messtechnik GmbH,
+ *			<[email protected]>
+ * Copyright (C) 2010 Freescale Semiconductor, Inc. All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+
+#ifndef __MACH_IOMUX_PINCTRL_H__

arch/arm/plat-mxc/include/mach/iomux-pinctrl.h line 31

Quoted 10 lines
arch/arm/plat-mxc/include/mach/iomux-pinctrl.h new file +10 -0
+#define __MACH_IOMUX_PINCTRL_H__
+
+typedef struct deprecated_pad_desc {
+	unsigned bank:3;
+	unsigned pin:5;
+	unsigned muxsel:2;
+	unsigned ma:3;
+	unsigned vol:2;
+	unsigned pull:1;
+} iomux_pinctrl_cfg_t;

Oh, you start with things that are already now deprecated?

Quoted 40 lines
arch/arm/plat-mxc/include/mach/iomux-pinctrl.h new file +40 -0
+
+#define IOMUX_PAD(_bank, _pin, _muxsel, _vol, _ma, _pull)	\
+		{						\
+			.bank	= _bank,			\
+			.pin	= _pin,				\
+			.muxsel	= _muxsel,			\
+			.vol	= _vol,				\
+			.ma	= _ma,				\
+			.pull	= _pull,			\
+		}
+
+#define PAD_MUXSEL_0		0
+#define PAD_MUXSEL_1		1
+#define PAD_MUXSEL_2		2
+#define PAD_MUXSEL_GPIO		3
+
+#define PAD_1V8			0
+#define PAD_3V3			1
+#define PAD_VOL_NONE		2
+
+#define PAD_4MA			0
+#define PAD_8MA			1
+#define PAD_12MA		2
+#define PAD_16MA		3
+#define PAD_MA_NONE		4
+
+#define PAD_NOPULL		0
+#define PAD_PULL		1
+
+#define MX51_NUM_GPIO_PORT	4
+
+#define GPIO_PIN_MASK 0x1f
+
+#define GPIO_PORT_SHIFT 5
+#define GPIO_PORT_MASK (0x7 << GPIO_PORT_SHIFT)
+
+#define GPIO_PORTA	(0 << GPIO_PORT_SHIFT)
+#define GPIO_PORTB	(1 << GPIO_PORT_SHIFT)
+#define GPIO_PORTC	(2 << GPIO_PORT_SHIFT)
+#define GPIO_PORTD	(3 << GPIO_PORT_SHIFT)

arch/arm/plat-mxc/include/mach/iomux-pinctrl.h line 81

Quoted 10 lines
arch/arm/plat-mxc/include/mach/iomux-pinctrl.h new file +10 -0
+#define GPIO_PORTE	(4 << GPIO_PORT_SHIFT)
+#define GPIO_PORTF	(5 << GPIO_PORT_SHIFT)
+
+/*
+ * setups a single pad in the iomuxer
+ */
+int mxc_iomux_pinctrl_setup_pad(iomux_pinctrl_cfg_t *pad);
+
+/*
+ * setups mutliple pads

s/mutliple/multiple/

Quoted 115 lines
arch/arm/plat-mxc/include/mach/iomux-pinctrl.h new file +10 -0
+ * convenient way to call the above function with tables
+ */
+int mxc_iomux_pinctrl_setup_multiple_pads(iomux_pinctrl_cfg_t *pad_list, unsigned count);
+
+/*
+ * Initialise the iomux controller
+ */
+void mxc_iomux_pinctrl_init(void __iomem *iomux_pinctrl_base);
+
+#endif /* __MACH_IOMUX_PINCTRL_H__*/
arch/arm/plat-mxc/iomux-pinctrl.c new file +94 -0
new file mode 100644
index 0000000..5f5b5ac
@@ -0,0 +1,94 @@
+/*
+ * Copyright 2004-2010 Freescale Semiconductor, Inc. All Rights Reserved.
+ * Copyright (C) 2008 by Sascha Hauer <[email protected]>
+ * Copyright (C) 2009 by Jan Weitzel Phytec Messtechnik GmbH,
+ *                       <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+#include <linux/errno.h>
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/string.h>
+#include <linux/gpio.h>
+#include <asm/mach/map.h>
+#include <mach/hardware.h>
+#include <mach/iomux-pinctrl.h>
+
+static void __iomem *base;
+
+/*
+ * configures a single pad in the iomuxer
+ */
+int mxc_iomux_pinctrl_setup_pad(iomux_pinctrl_cfg_t *pad)
+{
+	u32 reg, ofs, bp, bm;
+
+	/* MUXSEL */
+	ofs = pad->bank * 0x20 + pad->pin / 16 * 0x10;
+	bp = pad->pin % 16 * 2;
+	bm = 0x3 << bp;
+	reg = __raw_readl(base + ofs);
+	reg &= ~bm;
+	reg |= pad->muxsel << bp;
+	__raw_writel(reg, base + ofs);
+
+	/* DRIVE */
+	if (pad->ma != PAD_MA_NONE && pad->vol != PAD_VOL_NONE)
+	{
+		ofs = 0x300 + pad->bank * 0x40 + pad->pin / 8 * 0x10;
+		bp = pad->pin % 8 * 4;
+		bm = 0x7 << bp;
+		reg = __raw_readl(base + ofs);
+		reg &= ~bm;
+		reg |= pad->ma << bp | pad->vol << (bp + 2);
+		__raw_writel(reg, base + ofs);
+	}
+
+	/* PULL */
+	ofs = 0x600 + pad->bank * 0x10;
+	bp = pad->pin;
+	bm = 0x1 << bp;
+	reg = __raw_readl(base + ofs);
+	reg &= ~bm;
+	reg |= pad->pull << bp;
+	__raw_writel(reg, base + ofs);
+
+	return 0;
+}
+EXPORT_SYMBOL(mxc_iomux_pinctrl_setup_pad);
+
+int mxc_iomux_pinctrl_setup_multiple_pads(iomux_pinctrl_cfg_t *pad_list, unsigned count)
+{
+	iomux_pinctrl_cfg_t *p = pad_list;
+	int i;
+	int ret;
+
+	for (i = 0; i < count; i++) {
+		ret = mxc_iomux_pinctrl_setup_pad(p);
+		if (ret)
+			return ret;
+		p++;
+	}
+
+	return 0;
+}
+EXPORT_SYMBOL(mxc_iomux_pinctrl_setup_multiple_pads);
+
+void mxc_iomux_pinctrl_init(void __iomem *iomux_pinctrl_base)
+{
+	base = iomux_pinctrl_base;
+}
Signature · 1 line
1.7.1
Signature · 2 lines
Pengutronix e.K.                           | Uwe Kleine-K?nig            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
author
#15 lore raw

PATCH 7/11 ARM: imx: Add support of uncompress print for i.MX28

In reply to Shawn Guo

SoC i.MX28 uses DUART IP block as the debug serial. It adds the support in the same file used by other i.MX SoC UART, and uses variable is_duart to distinguish.

---
 arch/arm/plat-mxc/include/mach/uncompress.h |   20 ++++++++++++++------
 1 files changed, 14 insertions(+), 6 deletions(-)
arch/arm/plat-mxc/include/mach/uncompress.h +14 -6
index 9dd9c20..adb617f 100644
@@ -1,8 +1,9 @@
 /*
- *  arch/arm/plat-mxc/include/mach/uncompress.h
+ *  rch/arm/plat-mxc/include/mach/uncompress.h
  *
  *  Copyright (C) 1999 ARM Limited
  *  Copyright (C) Shane Nay (shane at minirl.com)
+ *  Copyright 2010 Freescale Semiconductor, Inc. All Rights Reserved.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -22,14 +23,16 @@
 #include <asm/mach-types.h>
 
 static unsigned long uart_base;
+static unsigned short is_duart = 0;
 
 #define UART(x) (*(volatile unsigned long *)(uart_base + (x)))
 
-#define USR2 0x98
-#define USR2_TXFE (1<<14)
-#define TXR  0x40
-#define UCR1 0x80
-#define UCR1_UARTEN 1
+#define USR2		(is_duart ? 0x18 : 0x98)
+#define USR2_TXFE	(is_duart ? 1<<7 : 1<<14)
+#define USR2_BUSY	(1 << 3)
+#define TXR		(is_duart ? 0x00 : 0x40)
+#define UCR1		(is_duart ? 0x30 : 0x80)
+#define UCR1_UARTEN	1
 
 /*
  * The following code assumes the serial port has already been
@@ -59,6 +62,7 @@ static inline void flush(void)
 
 #define MX1_UART1_BASE_ADDR	0x00206000
 #define MX25_UART1_BASE_ADDR	0x43f90000
+#define MX28_DUART_BASE_ADDR	0x80074000
 #define MX2X_UART1_BASE_ADDR	0x1000a000
 #define MX3X_UART1_BASE_ADDR	0x43F90000
 #define MX3X_UART2_BASE_ADDR	0x43F94000
@@ -83,6 +87,10 @@ static __inline__ void __arch_decomp_setup(unsigned long arch_id)
 	case MACH_TYPE_MXT_TD60:
 		uart_base = MX2X_UART1_BASE_ADDR;
 		break;
+	case MACH_TYPE_MX28EVK:
+		uart_base = MX28_DUART_BASE_ADDR;
+		is_duart = 1;
+		break;
 	case MACH_TYPE_MX31LITE:
 	case MACH_TYPE_ARMADILLO5X0:
 	case MACH_TYPE_MX31MOBOARD:
Signature · 1 line
1.7.1
#16 lore raw

PATCH 7/11 ARM: imx: Add support of uncompress print for i.MX28

Quoted 14 lines · Shawn Guo

SoC i.MX28 uses DUART IP block as the debug serial. It adds the support in the same file used by other i.MX SoC UART, and uses variable is_duart to distinguish.

---
 arch/arm/plat-mxc/include/mach/uncompress.h |   20 ++++++++++++++------
 1 files changed, 14 insertions(+), 6 deletions(-)
arch/arm/plat-mxc/include/mach/uncompress.h +0 -0
index 9dd9c20..adb617f 100644

arch/arm/plat-mxc/include/mach/uncompress.h line 2

Quoted 3 lines
arch/arm/plat-mxc/include/mach/uncompress.h +1 -1
@@ -1,8 +1,9 @@
 /*
- *  arch/arm/plat-mxc/include/mach/uncompress.h
+ *  rch/arm/plat-mxc/include/mach/uncompress.h

???

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

Quoted 12 lines
arch/arm/plat-mxc/include/mach/uncompress.h +2 -0
  *
  *  Copyright (C) 1999 ARM Limited
  *  Copyright (C) Shane Nay (shane at minirl.com)
+ *  Copyright 2010 Freescale Semiconductor, Inc. All Rights Reserved.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -22,14 +23,16 @@
 #include <asm/mach-types.h>
 
 static unsigned long uart_base;
+static unsigned short is_duart = 0;

don't initialize static variables to 0.

Quoted 41 lines
arch/arm/plat-mxc/include/mach/uncompress.h +11 -5
 #define UART(x) (*(volatile unsigned long *)(uart_base + (x)))
 
-#define USR2 0x98
-#define USR2_TXFE (1<<14)
-#define TXR  0x40
-#define UCR1 0x80
-#define UCR1_UARTEN 1
+#define USR2		(is_duart ? 0x18 : 0x98)
+#define USR2_TXFE	(is_duart ? 1<<7 : 1<<14)
+#define USR2_BUSY	(1 << 3)
+#define TXR		(is_duart ? 0x00 : 0x40)
+#define UCR1		(is_duart ? 0x30 : 0x80)
+#define UCR1_UARTEN	1
 
 /*
  * The following code assumes the serial port has already been
@@ -59,6 +62,7 @@ static inline void flush(void)
 
 #define MX1_UART1_BASE_ADDR	0x00206000
 #define MX25_UART1_BASE_ADDR	0x43f90000
+#define MX28_DUART_BASE_ADDR	0x80074000
 #define MX2X_UART1_BASE_ADDR	0x1000a000
 #define MX3X_UART1_BASE_ADDR	0x43F90000
 #define MX3X_UART2_BASE_ADDR	0x43F94000
@@ -83,6 +87,10 @@ static __inline__ void __arch_decomp_setup(unsigned long arch_id)
 	case MACH_TYPE_MXT_TD60:
 		uart_base = MX2X_UART1_BASE_ADDR;
 		break;
+	case MACH_TYPE_MX28EVK:
+		uart_base = MX28_DUART_BASE_ADDR;
+		is_duart = 1;
+		break;
 	case MACH_TYPE_MX31LITE:
 	case MACH_TYPE_ARMADILLO5X0:
 	case MACH_TYPE_MX31MOBOARD:
Signature · 1 line
1.7.1
Signature · 2 lines
Pengutronix e.K.                           | Uwe Kleine-K?nig            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
author
#17 lore raw

PATCH 8/11 ARM: imx: Add clock support for i.MX28

In reply to Shawn Guo
---
 arch/arm/mach-imx/clock-imx28.c       |  733 +++++++++++++++++++++++++++++++++
 arch/arm/mach-imx/regs-clkctrl-mx28.h |  662 +++++++++++++++++++++++++++++
 2 files changed, 1395 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/mach-imx/clock-imx28.c
 create mode 100644 arch/arm/mach-imx/regs-clkctrl-mx28.h
arch/arm/mach-imx/clock-imx28.c new file +733 -0
new file mode 100644
index 0000000..104f95e
@@ -0,0 +1,733 @@
+/*
+ * Copyright (C) 2009-2010 Freescale Semiconductor, Inc. All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include <linux/mm.h>
+#include <linux/delay.h>
+#include <linux/clk.h>
+#include <linux/io.h>
+
+#include <asm/clkdev.h>
+#include <asm/div64.h>
+
+#include <mach/hardware.h>
+#include <mach/common.h>
+#include <mach/clock.h>
+
+#include "regs-clkctrl-mx28.h"
+
+#define CLKCTRL_BASE_ADDR	MX28_IO_ADDRESS(MX28_CLKCTRL_BASE_ADDR)
+#define DIGCTRL_BASE_ADDR	MX28_IO_ADDRESS(MX28_DIGCTL_BASE_ADDR)
+
+static struct clk pll2_clk;
+static struct clk cpu_clk;
+static struct clk emi_clk;
+static struct clk saif0_clk;
+static struct clk saif1_clk;
+static struct clk clk32k_clk;
+
+static int _raw_clk_enable(struct clk *clk)
+{
+	u32 reg;
+
+	if (clk->enable_reg) {
+		reg = __raw_readl(clk->enable_reg);
+		reg &= ~(1 << clk->enable_shift);
+		__raw_writel(reg, clk->enable_reg);
+	}
+
+	return 0;
+}
+
+static void _raw_clk_disable(struct clk *clk)
+{
+	u32 reg;
+
+	if (clk->enable_reg) {
+		reg = __raw_readl(clk->enable_reg);
+		reg |= 1 << clk->enable_shift;
+		__raw_writel(reg, clk->enable_reg);
+	}
+}
+
+/*
+ * ref_xtal_clk
+ */
+static unsigned long ref_xtal_clk_get_rate(struct clk *clk)
+{
+	return 24000000;
+}
+
+static struct clk ref_xtal_clk = {
+	.get_rate = ref_xtal_clk_get_rate,
+};
+
+/*
+ * pll_clk
+ */
+static unsigned long pll0_clk_get_rate(struct clk *clk)
+{
+	return 480000000;
+}
+
+static unsigned long pll1_clk_get_rate(struct clk *clk)
+{
+	return 480000000;
+}
+
+static unsigned long pll2_clk_get_rate(struct clk *clk)
+{
+	return 50000000;
+}
+
+#define _CLK_ENABLE_PLL(name, r, g)					\
+static int name##_enable(struct clk *clk)				\
+{									\
+	__raw_writel(BM_CLKCTRL_##r##CTRL0_POWER,			\
+		     CLKCTRL_BASE_ADDR + HW_CLKCTRL_##r##CTRL0_SET);	\
+	udelay(10);							\
+									\
+	if (clk == &pll2_clk)						\
+		__raw_writel(BM_CLKCTRL_##r##CTRL0_##g,			\
+			CLKCTRL_BASE_ADDR + HW_CLKCTRL_##r##CTRL0_CLR);	\
+	else								\
+		__raw_writel(BM_CLKCTRL_##r##CTRL0_##g,			\
+			CLKCTRL_BASE_ADDR + HW_CLKCTRL_##r##CTRL0_SET);	\
+									\
+	return 0;							\
+}
+
+_CLK_ENABLE_PLL(pll0_clk, PLL0, EN_USB_CLKS)
+_CLK_ENABLE_PLL(pll1_clk, PLL1, EN_USB_CLKS)
+_CLK_ENABLE_PLL(pll2_clk, PLL2, CLKGATE)
+
+#define _CLK_DISABLE_PLL(name, r, g)					\
+static void name##_disable(struct clk *clk)				\
+{									\
+	__raw_writel(BM_CLKCTRL_##r##CTRL0_POWER,			\
+		     CLKCTRL_BASE_ADDR + HW_CLKCTRL_##r##CTRL0_CLR);	\
+									\
+	if (clk == &pll2_clk)						\
+		__raw_writel(BM_CLKCTRL_##r##CTRL0_##g,			\
+			CLKCTRL_BASE_ADDR + HW_CLKCTRL_##r##CTRL0_SET);	\
+	else								\
+		__raw_writel(BM_CLKCTRL_##r##CTRL0_##g,			\
+			CLKCTRL_BASE_ADDR + HW_CLKCTRL_##r##CTRL0_CLR);	\
+									\
+}
+
+_CLK_DISABLE_PLL(pll0_clk, PLL0, EN_USB_CLKS)
+_CLK_DISABLE_PLL(pll1_clk, PLL1, EN_USB_CLKS)
+_CLK_DISABLE_PLL(pll2_clk, PLL2, CLKGATE)
+
+#define _DEFINE_CLOCK_PLL(name)						\
+	static struct clk name = {					\
+		.get_rate	= name##_get_rate,			\
+		.enable		= name##_enable,			\
+		.disable	= name##_disable,			\
+		.parent		= &ref_xtal_clk,			\
+	}
+
+_DEFINE_CLOCK_PLL(pll0_clk);
+_DEFINE_CLOCK_PLL(pll1_clk);
+_DEFINE_CLOCK_PLL(pll2_clk);
+
+/*
+ * ref_clk
+ */
+#define _CLK_GET_RATE_REF(name, sr, ss)					\
+static unsigned long name##_get_rate(struct clk *clk)			\
+{									\
+	unsigned long parent_rate;					\
+	u32 reg, div;							\
+									\
+	reg = __raw_readl(CLKCTRL_BASE_ADDR + HW_CLKCTRL_##sr);		\
+	div = (reg >> BP_CLKCTRL_##sr##_##ss##FRAC) & 0x3f;		\
+	parent_rate = clk_get_rate(clk->parent);			\
+									\
+	return parent_rate * 18 / div;					\
+}
+
+_CLK_GET_RATE_REF(ref_cpu_clk, FRAC0, CPU)
+_CLK_GET_RATE_REF(ref_emi_clk, FRAC0, EMI)
+_CLK_GET_RATE_REF(ref_io0_clk, FRAC0, IO0)
+_CLK_GET_RATE_REF(ref_io1_clk, FRAC0, IO1)
+_CLK_GET_RATE_REF(ref_pix_clk, FRAC1, PIX)
+_CLK_GET_RATE_REF(ref_gpmi_clk, FRAC1, GPMI)
+
+#define _DEFINE_CLOCK_REF(name, er, es)					\
+	static struct clk name = {					\
+		.enable_reg	= CLKCTRL_BASE_ADDR + HW_CLKCTRL_##er,	\
+		.enable_shift	= BP_CLKCTRL_##er##_CLKGATE##es,	\
+		.get_rate	= name##_get_rate,			\
+		.enable		= _raw_clk_enable,			\
+		.disable	= _raw_clk_disable,			\
+		.parent		= &pll0_clk,				\
+	}
+
+_DEFINE_CLOCK_REF(ref_cpu_clk, FRAC0, CPU);
+_DEFINE_CLOCK_REF(ref_emi_clk, FRAC0, EMI);
+_DEFINE_CLOCK_REF(ref_io0_clk, FRAC0, IO0);
+_DEFINE_CLOCK_REF(ref_io1_clk, FRAC0, IO1);
+_DEFINE_CLOCK_REF(ref_pix_clk, FRAC1, PIX);
+_DEFINE_CLOCK_REF(ref_gpmi_clk, FRAC1, GPMI);
+
+/*
+ * General clocks
+ *
+ * clk_get_rate
+ */
+static unsigned long lradc_clk_get_rate(struct clk *clk)
+{
+	return clk_get_rate(clk->parent) / 16;
+}
+
+static unsigned long rtc_clk_get_rate(struct clk *clk)
+{
+	/* ref_xtal_clk is implemented as the only parent */
+	return clk_get_rate(clk->parent) / 768;
+}
+
+static unsigned long clk32k_clk_get_rate(struct clk *clk)
+{
+	return clk->parent->get_rate(clk->parent) / 750;
+}
+
+static unsigned long spdif_clk_get_rate(struct clk *clk)
+{
+	return clk_get_rate(clk->parent) / 4;
+}
+
+#define _CLK_GET_RATE(name, rs)						\
+static unsigned long name##_get_rate(struct clk *clk)			\
+{									\
+	u32 reg, div;							\
+									\
+	reg = __raw_readl(CLKCTRL_BASE_ADDR + HW_CLKCTRL_##rs);		\
+									\
+	if (clk->parent == &ref_xtal_clk)				\
+		div = (reg & BM_CLKCTRL_##rs##_DIV_XTAL) >>		\
+			BP_CLKCTRL_##rs##_DIV_XTAL;			\
+	else								\
+		div = (reg & BM_CLKCTRL_##rs##_DIV_##rs) >>		\
+			BP_CLKCTRL_##rs##_DIV_##rs;			\
+									\
+	if (!div)							\
+		return -EINVAL;						\
+									\
+	return clk_get_rate(clk->parent) / div;				\
+}
+
+_CLK_GET_RATE(cpu_clk, CPU)
+_CLK_GET_RATE(emi_clk, EMI)
+
+#define _CLK_GET_RATE1(name, rs)					\
+static unsigned long name##_get_rate(struct clk *clk)			\
+{									\
+	u32 reg, div;							\
+									\
+	reg = __raw_readl(CLKCTRL_BASE_ADDR + HW_CLKCTRL_##rs);		\
+	div = (reg & BM_CLKCTRL_##rs##_DIV) >> BP_CLKCTRL_##rs##_DIV;	\
+									\
+	if (!div)							\
+		return -EINVAL;						\
+									\
+	if (clk == &saif0_clk || clk == &saif1_clk)			\
+		return (clk_get_rate(clk->parent) >> 16 * div);		\
+	else								\
+		return clk_get_rate(clk->parent) / div;			\
+}
+
+_CLK_GET_RATE1(hbus_clk, HBUS)
+_CLK_GET_RATE1(xbus_clk, XBUS)
+_CLK_GET_RATE1(ssp0_clk, SSP0)
+_CLK_GET_RATE1(ssp1_clk, SSP1)
+_CLK_GET_RATE1(ssp2_clk, SSP2)
+_CLK_GET_RATE1(ssp3_clk, SSP3)
+_CLK_GET_RATE1(gpmi_clk, GPMI)
+_CLK_GET_RATE1(lcdif_clk, DIS_LCDIF)
+_CLK_GET_RATE1(saif0_clk, SAIF0)
+_CLK_GET_RATE1(saif1_clk, SAIF1)
+_CLK_GET_RATE1(fec_clk, ENET)
+
+#define _CLK_GET_RATE_STUB(name)					\
+static unsigned long name##_get_rate(struct clk *clk)			\
+{									\
+	return clk_get_rate(clk->parent);				\
+}
+
+_CLK_GET_RATE_STUB(uart_clk)
+_CLK_GET_RATE_STUB(pwm_clk)
+_CLK_GET_RATE_STUB(can0_clk)
+_CLK_GET_RATE_STUB(can1_clk)
+
+/*
+ * clk_set_rate
+ */
+/* fool compiler */
+#define BM_CLKCTRL_CPU_DIV	0
+#define BP_CLKCTRL_CPU_DIV	0
+#define BM_CLKCTRL_CPU_BUSY	0
+
+#define _CLK_SET_RATE(name, dr, fr, fs)					\
+static int name##_set_rate(struct clk *clk, unsigned long rate)		\
+{									\
+	u32 reg, bm_busy, div_max, d, f, div, frac;			\
+	unsigned long diff, parent_rate, calc_rate;			\
+	int i;								\
+									\
+	parent_rate = clk_get_rate(clk->parent);			\
+	div_max = BM_CLKCTRL_##dr##_DIV >> BP_CLKCTRL_##dr##_DIV;	\
+	bm_busy = BM_CLKCTRL_##dr##_BUSY;				\
+									\
+	if (clk->parent == &ref_xtal_clk) {				\
+		div = DIV_ROUND_UP(parent_rate, rate);			\
+		if (clk == &cpu_clk) {					\
+			div_max = BM_CLKCTRL_CPU_DIV_XTAL >>		\
+				BP_CLKCTRL_CPU_DIV_XTAL;		\
+			bm_busy = BM_CLKCTRL_CPU_BUSY_REF_XTAL;		\
+		}							\
+		if (div == 0 || div > div_max)				\
+			return -EINVAL;					\
+	} else {							\
+		div = frac = 1;						\
+		diff = parent_rate;					\
+		if (clk == &cpu_clk) {					\
+			div_max = BM_CLKCTRL_CPU_DIV_CPU >>		\
+				BP_CLKCTRL_CPU_DIV_CPU;			\
+			bm_busy = BM_CLKCTRL_CPU_BUSY_REF_CPU;		\
+		}							\
+		for (d = 1; d <= div_max; d++) {			\
+			f = parent_rate * 18 / d / rate;		\
+			if ((parent_rate * 18 / d) % rate)		\
+				f++;					\
+			if (f < 18 || f > 35)				\
+				continue;				\
+									\
+			calc_rate = parent_rate * 18 / f / d;		\
+			if (calc_rate > rate)				\
+				continue;				\
+									\
+			if (rate - calc_rate < diff) {			\
+				frac = f;				\
+				div = d;				\
+				diff = rate - calc_rate;		\
+			}						\
+									\
+			if (diff == 0)					\
+				break;					\
+		}							\
+									\
+		if (diff == parent_rate)				\
+			return -EINVAL;					\
+									\
+		reg = __raw_readl(CLKCTRL_BASE_ADDR + HW_CLKCTRL_##fr);	\
+		reg &= ~BM_CLKCTRL_##fr##_##fs##FRAC;			\
+		reg |= frac;						\
+		__raw_writel(reg, CLKCTRL_BASE_ADDR + HW_CLKCTRL_##fr);	\
+	}								\
+									\
+	reg = __raw_readl(CLKCTRL_BASE_ADDR + HW_CLKCTRL_##dr);		\
+	if (clk == &cpu_clk) {						\
+		reg &= ~BM_CLKCTRL_CPU_DIV_CPU;				\
+		reg |= div << BP_CLKCTRL_CPU_DIV_CPU;			\
+	} else {							\
+		reg &= ~BM_CLKCTRL_##dr##_DIV;				\
+		reg |= div << BP_CLKCTRL_##dr##_DIV;			\
+		if (reg | (1 << clk->enable_shift)) {			\
+			pr_err("%s: clock is gated\n", __func__);	\
+			return -EINVAL;					\
+		}							\
+	}								\
+	__raw_writel(reg, CLKCTRL_BASE_ADDR + HW_CLKCTRL_CPU);		\
+									\
+	for (i = 10000; i; i--)						\
+		if (!(__raw_readl(CLKCTRL_BASE_ADDR +			\
+			HW_CLKCTRL_##dr) & bm_busy))			\
+			break;						\
+	if (!i)	{							\
+		pr_err("%s: divider writing timeout\n", __func__);	\
+		return -ETIMEDOUT;					\
+	}								\
+									\
+	return 0;							\
+}
+
+_CLK_SET_RATE(cpu_clk, CPU, FRAC0, CPU)
+_CLK_SET_RATE(ssp0_clk, SSP0, FRAC0, IO0)
+_CLK_SET_RATE(ssp1_clk, SSP1, FRAC0, IO0)
+_CLK_SET_RATE(ssp2_clk, SSP2, FRAC0, IO1)
+_CLK_SET_RATE(ssp3_clk, SSP3, FRAC0, IO1)
+_CLK_SET_RATE(lcdif_clk, DIS_LCDIF, FRAC1, PIX)
+_CLK_SET_RATE(gpmi_clk, GPMI, FRAC1, GPMI)
+
+#define _CLK_SET_RATE1(name, dr)					\
+static int name##_set_rate(struct clk *clk, unsigned long rate)		\
+{									\
+	u32 reg, div_max, div;						\
+	unsigned long parent_rate;					\
+	int i;								\
+									\
+	parent_rate = clk_get_rate(clk->parent);			\
+	div_max = BM_CLKCTRL_##dr##_DIV >> BP_CLKCTRL_##dr##_DIV;	\
+									\
+	div = DIV_ROUND_UP(parent_rate, rate);				\
+	if (div == 0 || div > div_max)					\
+		return -EINVAL;						\
+									\
+	reg = __raw_readl(CLKCTRL_BASE_ADDR + HW_CLKCTRL_##dr);		\
+	reg &= ~BM_CLKCTRL_##dr##_DIV;					\
+	reg |= div << BP_CLKCTRL_##dr##_DIV;				\
+	if (reg | (1 << clk->enable_shift)) {				\
+		pr_err("%s: clock is gated\n", __func__);		\
+		return -EINVAL;						\
+	}								\
+	__raw_writel(reg, CLKCTRL_BASE_ADDR + HW_CLKCTRL_##dr);		\
+									\
+	for (i = 10000; i; i--)						\
+		if (!(__raw_readl(CLKCTRL_BASE_ADDR +			\
+			HW_CLKCTRL_##dr) & BM_CLKCTRL_##dr##_BUSY))	\
+			break;						\
+	if (!i)	{							\
+		pr_err("%s: divider writing timeout\n", __func__);	\
+		return -ETIMEDOUT;					\
+	}								\
+									\
+	return 0;							\
+}
+
+_CLK_SET_RATE1(xbus_clk, XBUS)
+_CLK_SET_RATE1(fec_clk, ENET)
+
+/* saif clock uses 16 bits frac div */
+#define _CLK_SET_RATE_SAIF(name, rs)					\
+static int name##_set_rate(struct clk *clk, unsigned long rate)		\
+{									\
+	u16 div;							\
+	u32 reg;							\
+	u64 lrate;							\
+	unsigned long parent_rate;					\
+	int i;								\
+									\
+	parent_rate = clk_get_rate(clk->parent);			\
+	if (rate > parent_rate)						\
+		return -EINVAL;						\
+									\
+	lrate = (u64)rate << 16;					\
+	do_div(lrate, parent_rate);					\
+	div = (u16)lrate;						\
+									\
+	if (!div)							\
+		return -EINVAL;						\
+									\
+	reg = __raw_readl(CLKCTRL_BASE_ADDR + HW_CLKCTRL_##rs);		\
+	reg &= ~BM_CLKCTRL_##rs##_DIV;					\
+	reg |= div << BP_CLKCTRL_##rs##_DIV;				\
+	__raw_writel(reg, CLKCTRL_BASE_ADDR + HW_CLKCTRL_##rs);		\
+									\
+	for (i = 10000; i; i--)						\
+		if (!(__raw_readl(CLKCTRL_BASE_ADDR +			\
+			HW_CLKCTRL_##rs) & BM_CLKCTRL_##rs##_BUSY))	\
+			break;						\
+	if (!i) {							\
+		pr_err("%s: divider writing timeout\n", __func__);	\
+		return -ETIMEDOUT;					\
+	}								\
+									\
+	return 0;							\
+}
+
+_CLK_SET_RATE_SAIF(saif0_clk, SAIF0)
+_CLK_SET_RATE_SAIF(saif1_clk, SAIF1)
+
+#define _CLK_SET_RATE_STUB(name)					\
+static int name##_set_rate(struct clk *clk, unsigned long rate)		\
+{									\
+	return -EINVAL;							\
+}
+
+_CLK_SET_RATE_STUB(emi_clk)	
+_CLK_SET_RATE_STUB(uart_clk)
+_CLK_SET_RATE_STUB(pwm_clk)
+_CLK_SET_RATE_STUB(spdif_clk)
+_CLK_SET_RATE_STUB(clk32k_clk)
+_CLK_SET_RATE_STUB(can0_clk)
+_CLK_SET_RATE_STUB(can1_clk)
+
+/*
+ * clk_set_parent
+ */
+#define _CLK_SET_PARENT(name, bit)					\
+static int name##_set_parent(struct clk *clk, struct clk *parent)	\
+{									\
+	if (parent != clk->parent) {					\
+		__raw_writel(BM_CLKCTRL_CLKSEQ_BYPASS_##bit,		\
+			 HW_CLKCTRL_CLKSEQ_TOG);			\
+		clk->parent = parent;					\
+	}								\
+									\
+	return 0;							\
+}
+
+_CLK_SET_PARENT(cpu_clk, CPU)
+_CLK_SET_PARENT(emi_clk, EMI)
+_CLK_SET_PARENT(ssp0_clk, SSP0)
+_CLK_SET_PARENT(ssp1_clk, SSP1)
+_CLK_SET_PARENT(ssp2_clk, SSP2)
+_CLK_SET_PARENT(ssp3_clk, SSP3)
+_CLK_SET_PARENT(lcdif_clk, DIS_LCDIF)
+_CLK_SET_PARENT(gpmi_clk, GPMI)
+_CLK_SET_PARENT(saif0_clk, SAIF0)
+_CLK_SET_PARENT(saif1_clk, SAIF1)
+
+#define _CLK_SET_PARENT_STUB(name)					\
+static int name##_set_parent(struct clk *clk, struct clk *parent)	\
+{									\
+	if (parent != clk->parent)					\
+		return -EINVAL;						\
+	else								\
+		return 0;						\
+}
+
+_CLK_SET_PARENT_STUB(pwm_clk)
+_CLK_SET_PARENT_STUB(uart_clk)
+_CLK_SET_PARENT_STUB(clk32k_clk)
+_CLK_SET_PARENT_STUB(spdif_clk)
+_CLK_SET_PARENT_STUB(fec_clk)
+_CLK_SET_PARENT_STUB(can0_clk)
+_CLK_SET_PARENT_STUB(can1_clk)
+
+/*
+ * clk definition
+ */
+static struct clk cpu_clk = {
+	.get_rate = cpu_clk_get_rate,
+	.set_rate = cpu_clk_set_rate,
+	.set_parent = cpu_clk_set_parent,
+	.parent = &ref_cpu_clk,
+};
+
+static struct clk hbus_clk = {
+	.get_rate = hbus_clk_get_rate,
+	.parent = &cpu_clk,
+};
+
+static struct clk xbus_clk = {
+	.get_rate = xbus_clk_get_rate,
+	.set_rate = xbus_clk_set_rate,
+	.parent = &ref_xtal_clk,
+};
+
+static struct clk lradc_clk = {
+	.get_rate = lradc_clk_get_rate,
+	.parent = &clk32k_clk,
+};
+
+static struct clk rtc_clk = {
+	.get_rate = rtc_clk_get_rate,
+	.parent = &ref_xtal_clk,
+};
+
+/* usb_clk is controlled in DIGCTRL other than CLKCTRL */
+static struct clk usb0_clk = {
+	.enable_reg = DIGCTRL_BASE_ADDR,
+	.enable_shift = 2,
+	.enable = _raw_clk_enable,
+	.disable = _raw_clk_disable,
+	.parent = &pll0_clk,
+};
+
+static struct clk usb1_clk = {
+	.enable_reg = DIGCTRL_BASE_ADDR,
+	.enable_shift = 16,
+	.enable = _raw_clk_enable,
+	.disable = _raw_clk_disable,
+	.parent = &pll1_clk,
+};
+
+#define _DEFINE_CLOCK(name, er, es, p)					\
+	static struct clk name = {					\
+		.enable_reg	= CLKCTRL_BASE_ADDR + HW_CLKCTRL_##er,	\
+		.enable_shift	= BP_CLKCTRL_##er##_##es,		\
+		.get_rate	= name##_get_rate,			\
+		.set_rate	= name##_set_rate,			\
+		.set_parent	= name##_set_parent,			\
+		.enable		= _raw_clk_enable,			\
+		.disable	= _raw_clk_disable,			\
+		.parent		= p,					\
+	}
+
+_DEFINE_CLOCK(emi_clk, EMI, CLKGATE, &ref_xtal_clk);
+_DEFINE_CLOCK(ssp0_clk, SSP0, CLKGATE, &ref_xtal_clk);
+_DEFINE_CLOCK(ssp1_clk, SSP1, CLKGATE, &ref_xtal_clk);
+_DEFINE_CLOCK(ssp2_clk, SSP2, CLKGATE, &ref_xtal_clk);
+_DEFINE_CLOCK(ssp3_clk, SSP3, CLKGATE, &ref_xtal_clk);
+_DEFINE_CLOCK(lcdif_clk, DIS_LCDIF, CLKGATE, &ref_xtal_clk);
+_DEFINE_CLOCK(gpmi_clk, GPMI, CLKGATE, &ref_xtal_clk);
+_DEFINE_CLOCK(saif0_clk, SAIF0, CLKGATE, &ref_xtal_clk);
+_DEFINE_CLOCK(saif1_clk, SAIF1, CLKGATE, &ref_xtal_clk);
+_DEFINE_CLOCK(can0_clk, FLEXCAN, STOP_CAN0, &ref_xtal_clk);
+_DEFINE_CLOCK(can1_clk, FLEXCAN, STOP_CAN1, &ref_xtal_clk);
+_DEFINE_CLOCK(pwm_clk, XTAL, PWM_CLK24M_GATE, &ref_xtal_clk);
+_DEFINE_CLOCK(uart_clk, XTAL, UART_CLK_GATE, &ref_xtal_clk);
+_DEFINE_CLOCK(clk32k_clk, XTAL, TIMROT_CLK32K_GATE, &ref_xtal_clk);
+_DEFINE_CLOCK(spdif_clk, SPDIF, CLKGATE, &pll0_clk);
+/* fec 1588 clock */
+_DEFINE_CLOCK(fec_clk, ENET, DISABLE, &pll0_clk);
+
+#define _REGISTER_CLOCK(d, n, c) \
+	{ \
+		.dev_id = d, \
+		.con_id = n, \
+		.clk = &c, \
+	},
+
+static struct clk_lookup lookups[] = {
+	_REGISTER_CLOCK("imx-duart.0", NULL, uart_clk)
+	_REGISTER_CLOCK("fec.0", NULL, fec_clk)
+
+	_REGISTER_CLOCK("hclk", NULL, hbus_clk)
+	_REGISTER_CLOCK("xclk", NULL, xbus_clk)
+	_REGISTER_CLOCK("can.0", NULL, can0_clk)
+	_REGISTER_CLOCK("can.1", NULL, can1_clk)
+	_REGISTER_CLOCK("usb.0", NULL, usb0_clk)
+	_REGISTER_CLOCK("usb.1", NULL, usb1_clk)
+	_REGISTER_CLOCK("rtc", NULL, rtc_clk)
+	_REGISTER_CLOCK("pwm", NULL, pwm_clk)
+	_REGISTER_CLOCK("lradc", NULL, lradc_clk)
+	_REGISTER_CLOCK("spdif", NULL, spdif_clk)
+};
+
+static int clk_misc_init(void)
+{
+	u32 reg;
+	int i;
+
+	/* Fix up parent per register setting */
+	reg = __raw_readl(CLKCTRL_BASE_ADDR + HW_CLKCTRL_CLKSEQ);
+	cpu_clk.parent = (reg & BM_CLKCTRL_CLKSEQ_BYPASS_CPU) ?
+			&ref_xtal_clk : &ref_cpu_clk;
+	emi_clk.parent = (reg & BM_CLKCTRL_CLKSEQ_BYPASS_EMI) ?
+			&ref_xtal_clk : &ref_emi_clk;
+	ssp0_clk.parent = (reg & BM_CLKCTRL_CLKSEQ_BYPASS_SSP0) ?
+			&ref_xtal_clk : &ref_io0_clk;
+	ssp1_clk.parent = (reg & BM_CLKCTRL_CLKSEQ_BYPASS_SSP1) ?
+			&ref_xtal_clk : &ref_io0_clk;
+	ssp2_clk.parent = (reg & BM_CLKCTRL_CLKSEQ_BYPASS_SSP2) ?
+			&ref_xtal_clk : &ref_io1_clk;
+	ssp3_clk.parent = (reg & BM_CLKCTRL_CLKSEQ_BYPASS_SSP3) ?
+			&ref_xtal_clk : &ref_io1_clk;
+	lcdif_clk.parent = (reg & BM_CLKCTRL_CLKSEQ_BYPASS_DIS_LCDIF) ?
+			&ref_xtal_clk : &ref_pix_clk;
+	gpmi_clk.parent = (reg & BM_CLKCTRL_CLKSEQ_BYPASS_GPMI) ?
+			&ref_xtal_clk : &ref_gpmi_clk;
+	saif0_clk.parent = (reg & BM_CLKCTRL_CLKSEQ_BYPASS_SAIF0) ?
+			&ref_xtal_clk : &pll0_clk;
+	saif1_clk.parent = (reg & BM_CLKCTRL_CLKSEQ_BYPASS_SAIF1) ?
+			&ref_xtal_clk : &pll0_clk;
+
+	/* Use int div over frac when both are available */
+	__raw_writel(BM_CLKCTRL_CPU_DIV_XTAL_FRAC_EN,
+			CLKCTRL_BASE_ADDR + HW_CLKCTRL_CPU_CLR);
+	__raw_writel(BM_CLKCTRL_CPU_DIV_CPU_FRAC_EN,
+			CLKCTRL_BASE_ADDR + HW_CLKCTRL_CPU_CLR);
+	__raw_writel(BM_CLKCTRL_HBUS_DIV_FRAC_EN,
+			CLKCTRL_BASE_ADDR + HW_CLKCTRL_HBUS_CLR);
+
+	reg = __raw_readl(CLKCTRL_BASE_ADDR + HW_CLKCTRL_XBUS);
+	reg &= ~BM_CLKCTRL_XBUS_DIV_FRAC_EN;
+	__raw_writel(reg, CLKCTRL_BASE_ADDR + HW_CLKCTRL_XBUS);
+
+	reg = __raw_readl(CLKCTRL_BASE_ADDR + HW_CLKCTRL_SSP0);
+	reg &= ~BM_CLKCTRL_SSP0_DIV_FRAC_EN;
+	__raw_writel(reg, CLKCTRL_BASE_ADDR + HW_CLKCTRL_SSP0);
+
+	reg = __raw_readl(CLKCTRL_BASE_ADDR + HW_CLKCTRL_SSP1);
+	reg &= ~BM_CLKCTRL_SSP1_DIV_FRAC_EN;
+	__raw_writel(reg, CLKCTRL_BASE_ADDR + HW_CLKCTRL_SSP1);
+
+	reg = __raw_readl(CLKCTRL_BASE_ADDR + HW_CLKCTRL_SSP2);
+	reg &= ~BM_CLKCTRL_SSP2_DIV_FRAC_EN;
+	__raw_writel(reg, CLKCTRL_BASE_ADDR + HW_CLKCTRL_SSP2);
+
+	reg = __raw_readl(CLKCTRL_BASE_ADDR + HW_CLKCTRL_SSP3);
+	reg &= ~BM_CLKCTRL_SSP3_DIV_FRAC_EN;
+	__raw_writel(reg, CLKCTRL_BASE_ADDR + HW_CLKCTRL_SSP3);
+
+	reg = __raw_readl(CLKCTRL_BASE_ADDR + HW_CLKCTRL_GPMI);
+	reg &= ~BM_CLKCTRL_GPMI_DIV_FRAC_EN;
+	__raw_writel(reg, CLKCTRL_BASE_ADDR + HW_CLKCTRL_GPMI);
+
+	reg = __raw_readl(CLKCTRL_BASE_ADDR + HW_CLKCTRL_DIS_LCDIF);
+	reg &= ~BM_CLKCTRL_DIS_LCDIF_DIV_FRAC_EN;
+	__raw_writel(reg, CLKCTRL_BASE_ADDR + HW_CLKCTRL_DIS_LCDIF);
+
+	/* SAIF has to use frac div for functional operation */
+	reg = __raw_readl(CLKCTRL_BASE_ADDR + HW_CLKCTRL_SAIF0);
+	reg &= ~BM_CLKCTRL_SAIF0_DIV_FRAC_EN;
+	__raw_writel(reg, CLKCTRL_BASE_ADDR + HW_CLKCTRL_SAIF0);
+
+	reg = __raw_readl(CLKCTRL_BASE_ADDR + HW_CLKCTRL_SAIF1);
+	reg &= ~BM_CLKCTRL_SAIF1_DIV_FRAC_EN;
+	__raw_writel(reg, CLKCTRL_BASE_ADDR + HW_CLKCTRL_SAIF1);
+
+	/*
+	 * Set safe hbus clock divider. A divider of 3 ensure that
+	 * the Vddd voltage required for the cpu clock is sufficiently
+	 * high for the hbus clock.
+	 */
+	reg = __raw_readl(CLKCTRL_BASE_ADDR + HW_CLKCTRL_HBUS);
+	reg &= BM_CLKCTRL_HBUS_DIV;
+	reg |= 3 << BP_CLKCTRL_HBUS_DIV;
+	__raw_writel(reg, CLKCTRL_BASE_ADDR + HW_CLKCTRL_HBUS);
+
+	for (i = 10000; i; i--)
+		if (!(__raw_readl(CLKCTRL_BASE_ADDR +
+			HW_CLKCTRL_HBUS) & BM_CLKCTRL_HBUS_ASM_BUSY))
+			break;
+	if (!i) {
+		pr_err("%s: divider writing timeout\n", __func__);
+		return -ETIMEDOUT;
+	}
+
+	/* Gate off cpu clock in WFI for power saving */
+	__raw_writel(BM_CLKCTRL_CPU_INTERRUPT_WAIT,
+			CLKCTRL_BASE_ADDR + HW_CLKCTRL_CPU_SET);
+
+	/* Extra fec clock setting */
+	reg = __raw_readl(CLKCTRL_BASE_ADDR + HW_CLKCTRL_ENET);
+	reg &= ~BM_CLKCTRL_ENET_SLEEP;
+	__raw_writel(reg, CLKCTRL_BASE_ADDR + HW_CLKCTRL_ENET);
+
+	reg = __raw_readl(CLKCTRL_BASE_ADDR + HW_CLKCTRL_ENET);
+	reg |= BM_CLKCTRL_ENET_CLK_OUT_EN;
+	__raw_writel(reg, CLKCTRL_BASE_ADDR + HW_CLKCTRL_ENET);
+
+	return 0;
+}
+
+int __init mx28_clocks_init(void)
+{
+	clk_misc_init();
+
+	clkdev_add_table(lookups, ARRAY_SIZE(lookups));
+
+	mxc_timer_init(&clk32k_clk, MX28_IO_ADDRESS(MX28_TIMROT_BASE_ADDR),
+			MX28_INT_TIMER0);
+
+	return 0;
+}
arch/arm/mach-imx/regs-clkctrl-mx28.h new file +662 -0

662 lines not on this page · raw message

Signature · 1 line
1.7.1
author
#18 lore raw

PATCH 9/11 ARM: imx: Add memory map support for i.MX28

In reply to Shawn Guo
---
 arch/arm/mach-imx/mm-imx28.c |   50 ++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 50 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/mach-imx/mm-imx28.c
arch/arm/mach-imx/mm-imx28.c new file +50 -0
new file mode 100644
index 0000000..358f2d2
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2008-2010 Freescale Semiconductor, Inc. All Rights Reserved.
+ *
+ * The code contained herein is licensed under the GNU General Public
+ * License.  You may obtain a copy of the GNU General Public License
+ * Version 2 or later at the following locations:
+ *
+ * http://www.opensource.org/licenses/gpl-license.html
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ * Create static mapping between physical to virtual memory.
+ */
+
+#include <linux/mm.h>
+#include <linux/init.h>
+
+#include <asm/mach/map.h>
+
+#include <mach/hardware.h>
+#include <mach/common.h>
+#include <mach/iomux-pinctrl.h>
+
+/*
+ * Define the MX28 memory map.
+ */
+static struct map_desc mx28_io_desc[] __initdata = {
+	imx_map_entry(MX28, OCRAM, MT_DEVICE),
+	imx_map_entry(MX28, IO, MT_DEVICE),
+};
+
+/*
+ * This function initializes the memory map. It is called during the
+ * system startup to create static physical to virtual memory mappings
+ * for the IO modules.
+ */
+void __init mx28_map_io(void)
+{
+	mxc_set_cpu_type(MXC_CPU_MX28);
+	mxc_iomux_pinctrl_init(MX28_IO_ADDRESS(MX28_PINCTRL_BASE_ADDR));
+	mxc_arch_reset_init(MX28_IO_ADDRESS(MX28_RTC_BASE_ADDR));
+	iotable_init(mx28_io_desc, ARRAY_SIZE(mx28_io_desc));
+}
+
+int imx28_register_gpios(void);
+
+void __init mx28_init_irq(void)
+{
+	icoll_init_irq(MX28_IO_ADDRESS(MX28_ICOLL_BASE_ADDR));
+	imx28_register_gpios();
+}
Signature · 1 line
1.7.1
author
#19 lore raw

PATCH 10/11 ARM: imx: Add initial support of machine mx28evk

In reply to Shawn Guo

It adds machine mx28evk with initial duart and fec device registration.

---
 arch/arm/mach-imx/devices-imx28.h               |   20 ++++
 arch/arm/mach-imx/devices.c                     |   27 ++++++-
 arch/arm/mach-imx/mach-mx28evk.c                |  109 +++++++++++++++++++++++
 arch/arm/plat-mxc/devices/platform-duart.c      |   42 +++++++++
 arch/arm/plat-mxc/devices/platform-fec.c        |    5 +
 arch/arm/plat-mxc/include/mach/common.h         |    5 +
 arch/arm/plat-mxc/include/mach/devices-common.h |   11 +++
 7 files changed, 218 insertions(+), 1 deletions(-)
 create mode 100644 arch/arm/mach-imx/devices-imx28.h
 create mode 100644 arch/arm/mach-imx/mach-mx28evk.c
 create mode 100644 arch/arm/plat-mxc/devices/platform-duart.c
arch/arm/mach-imx/devices-imx28.h new file +20 -0
new file mode 100644
index 0000000..f35c910
@@ -0,0 +1,20 @@
+/*
+ * Copyright (C) 2010 Pengutronix
+ * Uwe Kleine-Koenig <[email protected]>
+ *
+ * Copyright 2010 Freescale Semiconductor, Inc. All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License version 2 as published by the
+ * Free Software Foundation.
+ */
+#include <mach/mx28.h>
+#include <mach/devices-common.h>
+
+extern const struct imx_duart_data imx28_duart_data __initconst;
+#define imx28_add_duart()	\
+	imx_add_duart(&imx28_duart_data)
+
+extern const struct imx_fec_data imx28_fec_data __initconst;
+#define imx28_add_fec(pdata)	\
+	imx_add_fec(&imx28_fec_data, pdata)
arch/arm/mach-imx/devices.c +26 -1
index e69e46e..946db32 100644
@@ -9,7 +9,7 @@
  * licensed "as is" without any warranty of any kind, whether express
  * or implied.
  *
- * Copyright 2006-2007 Freescale Semiconductor, Inc. All Rights Reserved.
+ * Copyright 2006-2010 Freescale Semiconductor, Inc. All Rights Reserved.
  * Copyright 2008 Juergen Beisert, kernel at pengutronix.de
  * Copyright 2008 Sascha Hauer, kernel at pengutronix.de
  * Copyright (c) 2008 Paulius Zaleckas <[email protected]>
@@ -551,3 +551,28 @@ struct platform_device imx_kpp_device = {
 };
 
 #endif
+
+#ifdef CONFIG_ARCH_MX28
+/* gpio */
+#define DEFINE_MXC_PINCTRL_GPIO_PORT(n)					\
+	{								\
+		.chip.label = "gpio-" #n,				\
+		.irq = MX28_INT_GPIO##n,				\
+		.base = MX28_IO_ADDRESS(MX28_PINCTRL_BASE_ADDR),	\
+		.virtual_irq_start = MXC_GPIO_IRQ_START + n * 32,	\
+	}
+
+static struct mxc_gpio_port imx28_gpio_ports[] = {
+	DEFINE_MXC_PINCTRL_GPIO_PORT(0),
+	DEFINE_MXC_PINCTRL_GPIO_PORT(1),
+	DEFINE_MXC_PINCTRL_GPIO_PORT(2),
+	DEFINE_MXC_PINCTRL_GPIO_PORT(3),
+	DEFINE_MXC_PINCTRL_GPIO_PORT(4),
+};
+
+int __init imx28_register_gpios(void)
+{
+	return mxc_gpio_init(imx28_gpio_ports,
+			ARRAY_SIZE(imx28_gpio_ports));
+}
+#endif
arch/arm/mach-imx/mach-mx28evk.c new file +109 -0

109 lines not on this page · raw message

arch/arm/plat-mxc/devices/platform-duart.c new file +42 -0

42 lines not on this page · raw message

arch/arm/plat-mxc/devices/platform-fec.c +5 -0
index 11d087f..bd5a84b 100644
@@ -26,6 +26,11 @@ const struct imx_fec_data imx27_fec_data __initconst =
 	imx_fec_data_entry_single(MX27);
 #endif /* ifdef CONFIG_SOC_IMX27 */
 
+#ifdef CONFIG_ARCH_MX28
+const struct imx_fec_data imx28_fec_data __initconst =
+	imx_fec_data_entry_single(MX28);
+#endif
+
 #ifdef CONFIG_ARCH_MX35
 const struct imx_fec_data imx35_fec_data __initconst =
 	imx_fec_data_entry_single(MX35);
arch/arm/plat-mxc/include/mach/common.h +5 -0
index 05676fb..6a5dea7 100644
@@ -18,16 +18,19 @@ extern void mx1_map_io(void);
 extern void mx21_map_io(void);
 extern void mx25_map_io(void);
 extern void mx27_map_io(void);
+extern void mx28_map_io(void);
 extern void mx31_map_io(void);
 extern void mx35_map_io(void);
 extern void mx51_map_io(void);
 extern void mxc91231_map_io(void);
 extern void mxc_init_irq(void __iomem *);
 extern void tzic_init_irq(void __iomem *);
+extern void icoll_init_irq(void __iomem *);
 extern void mx1_init_irq(void);
 extern void mx21_init_irq(void);
 extern void mx25_init_irq(void);
 extern void mx27_init_irq(void);
+extern void mx28_init_irq(void);
 extern void mx31_init_irq(void);
 extern void mx35_init_irq(void);
 extern void mx51_init_irq(void);
@@ -38,6 +41,7 @@ extern int mx1_clocks_init(unsigned long fref);
 extern int mx21_clocks_init(unsigned long lref, unsigned long fref);
 extern int mx25_clocks_init(void);
 extern int mx27_clocks_init(unsigned long fref);
+extern int mx28_clocks_init(void);
 extern int mx31_clocks_init(unsigned long fref);
 extern int mx35_clocks_init(void);
 extern int mx51_clocks_init(unsigned long ckil, unsigned long osc,
@@ -51,4 +55,5 @@ extern void mxc91231_power_off(void);
 extern void mxc91231_arch_reset(int, const char *);
 extern void mxc91231_prepare_idle(void);
 extern void mx51_efikamx_reset(void);
+extern int mxc_reset_block(void __iomem *);
 #endif
arch/arm/plat-mxc/include/mach/devices-common.h +11 -0
index 8c6896f..501329d 100644
@@ -2,6 +2,8 @@
  * Copyright (C) 2009-2010 Pengutronix
  * Uwe Kleine-Koenig <[email protected]>
  *
+ * Copyright 2010 Freescale Semiconductor, Inc. All Rights Reserved.
+ *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License version 2 as published by the
  * Free Software Foundation.
@@ -82,6 +84,15 @@ struct platform_device *__init imx_add_imx_uart_1irq(
 		const struct imx_imx_uart_1irq_data *data,
 		const struct imxuart_platform_data *pdata);
 
+struct imx_duart_data {
+	int id;
+	resource_size_t iobase;
+	resource_size_t iosize;
+	resource_size_t irq;
+};
+struct platform_device *__init imx_add_duart(
+		const struct imx_duart_data *data);
+
 #include <mach/mxc_nand.h>
 struct imx_mxc_nand_data {
 	/*
Signature · 1 line
1.7.1
#20 lore raw

PATCH 10/11 ARM: imx: Add initial support of machine mx28evk

Quoted 4 lines · Shawn Guo

It adds machine mx28evk with initial duart and fec device registration.

Quoted 8 lines
---
 arch/arm/mach-imx/devices-imx28.h               |   20 ++++
 arch/arm/mach-imx/devices.c                     |   27 ++++++-
 arch/arm/mach-imx/mach-mx28evk.c                |  109 +++++++++++++++++++++++
 arch/arm/plat-mxc/devices/platform-duart.c      |   42 +++++++++
 arch/arm/plat-mxc/devices/platform-fec.c        |    5 +
 arch/arm/plat-mxc/include/mach/common.h         |    5 +
 arch/arm/plat-mxc/include/mach/devices-common.h |   11 +++

Can you split this up into (say):

- mx28: dynamically allocate duart devices
- mx28: dynamically allocate fec devices
- mx28: add gpio port definitions
- mx28: mx28evk support

Quoted 63 lines
 7 files changed, 218 insertions(+), 1 deletions(-)
 create mode 100644 arch/arm/mach-imx/devices-imx28.h
 create mode 100644 arch/arm/mach-imx/mach-mx28evk.c
 create mode 100644 arch/arm/plat-mxc/devices/platform-duart.c
arch/arm/mach-imx/devices-imx28.h new file +20 -0
new file mode 100644
index 0000000..f35c910
@@ -0,0 +1,20 @@
+/*
+ * Copyright (C) 2010 Pengutronix
+ * Uwe Kleine-Koenig <[email protected]>
+ *
+ * Copyright 2010 Freescale Semiconductor, Inc. All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License version 2 as published by the
+ * Free Software Foundation.
+ */
+#include <mach/mx28.h>
+#include <mach/devices-common.h>
+
+extern const struct imx_duart_data imx28_duart_data __initconst;
+#define imx28_add_duart()	\
+	imx_add_duart(&imx28_duart_data)
+
+extern const struct imx_fec_data imx28_fec_data __initconst;
+#define imx28_add_fec(pdata)	\
+	imx_add_fec(&imx28_fec_data, pdata)
arch/arm/mach-imx/devices.c +16 -1
index e69e46e..946db32 100644
@@ -9,7 +9,7 @@
  * licensed "as is" without any warranty of any kind, whether express
  * or implied.
  *
- * Copyright 2006-2007 Freescale Semiconductor, Inc. All Rights Reserved.
+ * Copyright 2006-2010 Freescale Semiconductor, Inc. All Rights Reserved.
  * Copyright 2008 Juergen Beisert, kernel at pengutronix.de
  * Copyright 2008 Sascha Hauer, kernel at pengutronix.de
  * Copyright (c) 2008 Paulius Zaleckas <[email protected]>
@@ -551,3 +551,28 @@ struct platform_device imx_kpp_device = {
 };
 
 #endif
+
+#ifdef CONFIG_ARCH_MX28
+/* gpio */
+#define DEFINE_MXC_PINCTRL_GPIO_PORT(n)					\
+	{								\
+		.chip.label = "gpio-" #n,				\
+		.irq = MX28_INT_GPIO##n,				\
+		.base = MX28_IO_ADDRESS(MX28_PINCTRL_BASE_ADDR),	\
+		.virtual_irq_start = MXC_GPIO_IRQ_START + n * 32,	\
+	}
+
+static struct mxc_gpio_port imx28_gpio_ports[] = {
+	DEFINE_MXC_PINCTRL_GPIO_PORT(0),
+	DEFINE_MXC_PINCTRL_GPIO_PORT(1),
+	DEFINE_MXC_PINCTRL_GPIO_PORT(2),

arch/arm/mach-imx/devices.c struct platform_device imx_kpp_device = { · line 578

Quoted 10 lines
arch/arm/mach-imx/devices.c +10 -0
+	DEFINE_MXC_PINCTRL_GPIO_PORT(3),
+	DEFINE_MXC_PINCTRL_GPIO_PORT(4),
+};
+
+int __init imx28_register_gpios(void)
+{
+	return mxc_gpio_init(imx28_gpio_ports,
+			ARRAY_SIZE(imx28_gpio_ports));
+}
+#endif

In my tree I have moved this out of devices.c to plat-mxc/gpio.c.

Quoted 168 lines
arch/arm/mach-imx/mach-mx28evk.c new file +109 -0
new file mode 100644
index 0000000..d5dd940
@@ -0,0 +1,109 @@
+/*
+ * Copyright 2010 Freescale Semiconductor, Inc. All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include <linux/delay.h>
+#include <linux/platform_device.h>
+#include <linux/gpio.h>
+#include <linux/irq.h>
+
+#include <asm/mach-types.h>
+#include <asm/mach/arch.h>
+#include <asm/mach/time.h>
+
+#include <mach/hardware.h>
+#include <mach/common.h>
+#include <mach/iomux-mx28.h>
+
+#include "devices-imx28.h"
+#include "devices.h"
+
+#define MX28EVK_FEC_PHY_POWER	(2*32 + 15)	/* GPIO_2_15 */
+#define MX28EVK_FEC_PHY_RESET	(4*32 + 13)	/* GPIO_4_13 */
+
+static iomux_pinctrl_cfg_t mx28evk_pads[] = {
+	/* DUART */
+	MX28_PAD_PWM0__DUART_RX,
+	MX28_PAD_PWM1__DUART_TX,
+
+	/* FEC */
+	MX28_PAD_ENET0_MDC__ENET0_MDC,
+	MX28_PAD_ENET0_MDIO__ENET0_MDIO,
+	MX28_PAD_ENET0_RX_EN__ENET0_RX_EN,
+	MX28_PAD_ENET0_RXD0__ENET0_RXD0,
+	MX28_PAD_ENET0_RXD1__ENET0_RXD1,
+	MX28_PAD_ENET0_TX_EN__ENET0_TX_EN,
+	MX28_PAD_ENET0_TXD0__ENET0_TXD0,
+	MX28_PAD_ENET0_TXD1__ENET0_TXD1,
+	MX28_PAD_ENET_CLK__ENET_CLK,
+	/* PHY power line */
+	MX28_PAD_SSP1_DATA3__GPIO_2_15,
+	/* PHY reset line */
+	MX28_PAD_ENET0_RX_CLK__GPIO_4_13,
+};
+
+/* FEC */
+static const struct fec_platform_data mx28_fec_pdata __initconst = {
+        .phy = PHY_INTERFACE_MODE_RMII,
+};
+
+static inline void mx28evk_fec_reset(void)
+{
+	int ret;
+
+	/* Power up FEC PHY */
+	ret = gpio_request(MX28EVK_FEC_PHY_POWER, "fec-phy-power");
+	if (ret) {
+		pr_err("Failed to request GPIO_FEC_PHY_POWER: %d\n", ret);
+		return;
+	}
+	gpio_direction_output(MX28EVK_FEC_PHY_POWER, 0);
+
+	/* Reset FEC PHY */
+	ret = gpio_request(MX28EVK_FEC_PHY_RESET, "fec-phy-reset");
+	if (ret) {
+		pr_err("Failed to request GPIO_FEC_PHY_RESET: %d\n", ret);
+		return;
+	}
+	gpio_direction_output(MX28EVK_FEC_PHY_RESET, 0);
+	mdelay(1);
+	gpio_set_value(MX28EVK_FEC_PHY_RESET, 1);
+}
+
+static void __init mx28evk_init(void)
+{
+	mxc_iomux_pinctrl_setup_multiple_pads(mx28evk_pads,
+						ARRAY_SIZE(mx28evk_pads));
+	imx28_add_duart();
+
+	mx28evk_fec_reset();
+	imx28_add_fec(&mx28_fec_pdata);
+}
+
+static void __init mx28evk_timer_init(void)
+{
+	mx28_clocks_init();
+}
+
+static struct sys_timer mx28evk_timer = {
+	.init	= mx28evk_timer_init,
+};
+
+MACHINE_START(MX28EVK, "Freescale MX28 EVK")
+	/* Maintainer: Freescale Semiconductor, Inc. */
+	.boot_params    = MX28_PHYS_OFFSET + 0x100,
+	.map_io         = mx28_map_io,
+	.init_irq       = mx28_init_irq,
+	.init_machine   = mx28evk_init,
+	.timer          = &mx28evk_timer,
+MACHINE_END
arch/arm/plat-mxc/devices/platform-duart.c new file +42 -0
new file mode 100644
index 0000000..2dbf199
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2009-2010 Pengutronix
+ * Uwe Kleine-Koenig <[email protected]>
+ *
+ * Copyright 2010 Freescale Semiconductor, Inc. All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License version 2 as published by the
+ * Free Software Foundation.
+ */
+#include <mach/hardware.h>
+#include <mach/devices-common.h>
+
+#define imx_duart_data_entry_single(soc)				\
+	{								\
+		.iobase = soc ## _DUART_BASE_ADDR,			\
+		.irq = soc ## _INT_DUART,				\
+	}
+
+#ifdef CONFIG_ARCH_MX28
+const struct imx_duart_data imx28_duart_data __initconst =
+	imx_duart_data_entry_single(MX28);
+#endif
+
+struct platform_device *__init imx_add_duart(
+		const struct imx_duart_data *data)
+{
+	struct resource res[] = {
+		{
+			.start = data->iobase,
+			.end = data->iobase + SZ_8K - 1,
+			.flags = IORESOURCE_MEM,
+		}, {
+			.start = data->irq,
+			.end = data->irq,
+			.flags = IORESOURCE_IRQ,
+		},
+	};
+
+	return imx_add_platform_device("imx-duart", 0, res, ARRAY_SIZE(res),
+					NULL, 0);
+}
arch/arm/plat-mxc/devices/platform-fec.c +0 -0
index 11d087f..bd5a84b 100644

arch/arm/plat-mxc/devices/platform-fec.c const struct imx_fec_data imx27_fec_data __initconst = · line 29

Quoted 4 lines
arch/arm/plat-mxc/devices/platform-fec.c +1 -0
@@ -26,6 +26,11 @@ const struct imx_fec_data imx27_fec_data __initconst =
 	imx_fec_data_entry_single(MX27);
 #endif /* ifdef CONFIG_SOC_IMX27 */
 
+#ifdef CONFIG_ARCH_MX28

I'd prefer CONFIG_SOC_MX28 to have uniform naming. (I already switched MX25, MX31 and MX35 to CONFIG_SOC_MX... in my tree)

Quoted 61 lines
arch/arm/plat-mxc/devices/platform-fec.c +4 -0
+const struct imx_fec_data imx28_fec_data __initconst =
+	imx_fec_data_entry_single(MX28);
+#endif
+
 #ifdef CONFIG_ARCH_MX35
 const struct imx_fec_data imx35_fec_data __initconst =
 	imx_fec_data_entry_single(MX35);
arch/arm/plat-mxc/include/mach/common.h +5 -0
index 05676fb..6a5dea7 100644
@@ -18,16 +18,19 @@ extern void mx1_map_io(void);
 extern void mx21_map_io(void);
 extern void mx25_map_io(void);
 extern void mx27_map_io(void);
+extern void mx28_map_io(void);
 extern void mx31_map_io(void);
 extern void mx35_map_io(void);
 extern void mx51_map_io(void);
 extern void mxc91231_map_io(void);
 extern void mxc_init_irq(void __iomem *);
 extern void tzic_init_irq(void __iomem *);
+extern void icoll_init_irq(void __iomem *);
 extern void mx1_init_irq(void);
 extern void mx21_init_irq(void);
 extern void mx25_init_irq(void);
 extern void mx27_init_irq(void);
+extern void mx28_init_irq(void);
 extern void mx31_init_irq(void);
 extern void mx35_init_irq(void);
 extern void mx51_init_irq(void);
@@ -38,6 +41,7 @@ extern int mx1_clocks_init(unsigned long fref);
 extern int mx21_clocks_init(unsigned long lref, unsigned long fref);
 extern int mx25_clocks_init(void);
 extern int mx27_clocks_init(unsigned long fref);
+extern int mx28_clocks_init(void);
 extern int mx31_clocks_init(unsigned long fref);
 extern int mx35_clocks_init(void);
 extern int mx51_clocks_init(unsigned long ckil, unsigned long osc,
@@ -51,4 +55,5 @@ extern void mxc91231_power_off(void);
 extern void mxc91231_arch_reset(int, const char *);
 extern void mxc91231_prepare_idle(void);
 extern void mx51_efikamx_reset(void);
+extern int mxc_reset_block(void __iomem *);
 #endif
arch/arm/plat-mxc/include/mach/devices-common.h +2 -0
index 8c6896f..501329d 100644
@@ -2,6 +2,8 @@
  * Copyright (C) 2009-2010 Pengutronix
  * Uwe Kleine-Koenig <[email protected]>
  *
+ * Copyright 2010 Freescale Semiconductor, Inc. All Rights Reserved.
+ *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License version 2 as published by the
  * Free Software Foundation.
@@ -82,6 +84,15 @@ struct platform_device *__init imx_add_imx_uart_1irq(
 		const struct imx_imx_uart_1irq_data *data,
 		const struct imxuart_platform_data *pdata);

arch/arm/plat-mxc/include/mach/devices-common.h struct platform_device *__init imx_add_imx_uart_1irq( · line 95

Quoted 10 lines
arch/arm/plat-mxc/include/mach/devices-common.h +9 -0
 
+struct imx_duart_data {
+	int id;
+	resource_size_t iobase;
+	resource_size_t iosize;
+	resource_size_t irq;
+};
+struct platform_device *__init imx_add_duart(
+		const struct imx_duart_data *data);
+

Can you please keep the file sorted alphabetically?

Quoted 8 lines
arch/arm/plat-mxc/include/mach/devices-common.h +0 -0
 #include <mach/mxc_nand.h>
 struct imx_mxc_nand_data {
 	/*
Signature · 1 line
1.7.1
Signature · 2 lines
Pengutronix e.K.                           | Uwe Kleine-K?nig            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
author
#21 lore raw

PATCH 11/11 ARM: imx: Add i.MX28 support into Kconfig and Makefile

In reply to Shawn Guo
---
 arch/arm/mach-imx/Kconfig          |   20 ++++++++++++++++++++
 arch/arm/mach-imx/Makefile         |    4 ++++
 arch/arm/mach-imx/Makefile.boot    |    4 ++++
 arch/arm/plat-mxc/Kconfig          |   12 ++++++++++++
 arch/arm/plat-mxc/Makefile         |    4 +++-
 arch/arm/plat-mxc/devices/Kconfig  |    3 +++
 arch/arm/plat-mxc/devices/Makefile |    1 +
 7 files changed, 47 insertions(+), 1 deletions(-)
arch/arm/mach-imx/Kconfig +20 -0
index d6e998f..8accd5c 100644
@@ -199,3 +199,23 @@ config MACH_MXT_TD60
 	  includes specific configurations for the module and its peripherals.
 
 endif
+
+if ARCH_MX28
+
+config SOC_IMX28
+	select CPU_ARM926T
+	select ARCH_MXC_IOMUX_PINCTRL
+	select MXC_ICOLL
+	bool
+
+comment "MX28 platforms:"
+
+config MACH_MX28EVK
+	bool "MX28 EVK platform"
+	select IMX_HAVE_PLATFORM_DUART
+	help
+	  Include support for MX28 EVK platform. This includes specific
+	  configurations for the board and its peripherals.
+
+endif
+
arch/arm/mach-imx/Makefile +4 -0
index 5582692..3b12218 100644
@@ -14,6 +14,8 @@ obj-$(CONFIG_MACH_MX21) += clock-imx21.o mm-imx21.o
 obj-$(CONFIG_MACH_MX27) += cpu-imx27.o pm-imx27.o
 obj-$(CONFIG_MACH_MX27) += clock-imx27.o mm-imx27.o
 
+obj-$(CONFIG_ARCH_MX28) += clock-imx28.o mm-imx28.o
+
 # Support for CMOS sensor interface
 obj-$(CONFIG_MX1_VIDEO)	+= mx1-camera-fiq.o mx1-camera-fiq-ksym.o
 
@@ -32,3 +34,5 @@ obj-$(CONFIG_MACH_CPUIMX27) += mach-cpuimx27.o
 obj-$(CONFIG_MACH_EUKREA_MBIMX27_BASEBOARD) += eukrea_mbimx27-baseboard.o
 obj-$(CONFIG_MACH_PCA100) += mach-pca100.o
 obj-$(CONFIG_MACH_MXT_TD60) += mach-mxt_td60.o
+
+obj-$(CONFIG_MACH_MX28EVK) += mach-mx28evk.o
arch/arm/mach-imx/Makefile.boot +4 -0
index 7988a85..fd451d0 100644
@@ -9,3 +9,7 @@ initrd_phys-$(CONFIG_MACH_MX21)	:= 0xC0800000
 zreladdr-$(CONFIG_MACH_MX27)	:= 0xA0008000
 params_phys-$(CONFIG_MACH_MX27)	:= 0xA0000100
 initrd_phys-$(CONFIG_MACH_MX27)	:= 0xA0800000
+
+zreladdr-$(CONFIG_ARCH_MX28)	:= 0x40008000
+params_phys-$(CONFIG_ARCH_MX28)	:= 0x40000100
+initrd_phys-$(CONFIG_ARCH_MX28)	:= 0x40800000
arch/arm/plat-mxc/Kconfig +12 -0
index 680aeba..fd7ec19 100644
@@ -25,6 +25,12 @@ config ARCH_MX25
 	help
 	  This enables support for systems based on the Freescale i.MX25 family
 
+config ARCH_MX28
+	bool "MX28-based"
+	select SOC_IMX28
+	help
+	  This enables support for systems based on the Freescale i.MX28 family
+
 config ARCH_MX3
 	bool "MX3-based"
 	select CPU_V6
@@ -68,6 +74,9 @@ config MXC_TZIC
 config MXC_AVIC
 	bool
 
+config MXC_ICOLL
+	bool
+
 config MXC_PWM
 	tristate "Enable PWM driver"
 	select HAVE_PWM
@@ -109,6 +118,9 @@ config IMX_HAVE_IOMUX_V1
 config ARCH_MXC_IOMUX_V3
 	bool
 
+config ARCH_MXC_IOMUX_PINCTRL
+	bool
+
 config ARCH_MXC_AUDMUX_V1
 	bool
 
arch/arm/plat-mxc/Makefile +3 -1
index 0e12591..e194468 100644
@@ -5,12 +5,14 @@
 # Common support
 obj-y := clock.o gpio.o time.o devices.o cpu.o system.o
 
-# MX51 uses the TZIC interrupt controller, older platforms use AVIC (irq.o)
 obj-$(CONFIG_MXC_TZIC) += tzic.o
 obj-$(CONFIG_MXC_AVIC) += avic.o
+obj-$(CONFIG_MXC_ICOLL) += icoll.o
 
 obj-$(CONFIG_IMX_HAVE_IOMUX_V1) += iomux-v1.o
 obj-$(CONFIG_ARCH_MXC_IOMUX_V3) += iomux-v3.o
+obj-$(CONFIG_ARCH_MXC_IOMUX_PINCTRL) += iomux-pinctrl.o
+
 obj-$(CONFIG_IRAM_ALLOC) += iram_alloc.o
 obj-$(CONFIG_MXC_PWM)  += pwm.o
 obj-$(CONFIG_USB_EHCI_MXC) += ehci.o
arch/arm/plat-mxc/devices/Kconfig +3 -0
index 9aa6f3e..e8860d9 100644
@@ -1,3 +1,6 @@
+config IMX_HAVE_PLATFORM_DUART
+	bool
+
 config IMX_HAVE_PLATFORM_ESDHC
 	bool
 
arch/arm/plat-mxc/devices/Makefile +1 -0
index 45aefeb..11e2fcf 100644
@@ -1,3 +1,4 @@
+obj-$(CONFIG_IMX_HAVE_PLATFORM_DUART) += platform-duart.o
 obj-$(CONFIG_IMX_HAVE_PLATFORM_ESDHC) += platform-esdhc.o
 obj-$(CONFIG_IMX_HAVE_PLATFORM_FEC) += platform-fec.o
 obj-$(CONFIG_IMX_HAVE_PLATFORM_FLEXCAN) += platform-flexcan.o
Signature · 1 line
1.7.1
#22 lore raw

PATCH 11/11 ARM: imx: Add i.MX28 support into Kconfig and Makefile

Quoted 29 lines · Shawn Guo
---
 arch/arm/mach-imx/Kconfig          |   20 ++++++++++++++++++++
 arch/arm/mach-imx/Makefile         |    4 ++++
 arch/arm/mach-imx/Makefile.boot    |    4 ++++
 arch/arm/plat-mxc/Kconfig          |   12 ++++++++++++
 arch/arm/plat-mxc/Makefile         |    4 +++-
 arch/arm/plat-mxc/devices/Kconfig  |    3 +++
 arch/arm/plat-mxc/devices/Makefile |    1 +
 7 files changed, 47 insertions(+), 1 deletions(-)
arch/arm/mach-imx/Kconfig +10 -0
index d6e998f..8accd5c 100644
@@ -199,3 +199,23 @@ config MACH_MXT_TD60
 	  includes specific configurations for the module and its peripherals.
 
 endif
+
+if ARCH_MX28
+
+config SOC_IMX28
+	select CPU_ARM926T
+	select ARCH_MXC_IOMUX_PINCTRL
+	select MXC_ICOLL
+	bool
+
+comment "MX28 platforms:"

arch/arm/mach-imx/Kconfig config MACH_MXT_TD60 · line 221

Quoted 10 lines
arch/arm/mach-imx/Kconfig +10 -0
+
+config MACH_MX28EVK
+	bool "MX28 EVK platform"
+	select IMX_HAVE_PLATFORM_DUART
+	help
+	  Include support for MX28 EVK platform. This includes specific
+	  configurations for the board and its peripherals.
+
+endif
+

please remove the new line at EOF.

Quoted 36 lines
arch/arm/mach-imx/Makefile +4 -0
index 5582692..3b12218 100644
@@ -14,6 +14,8 @@ obj-$(CONFIG_MACH_MX21) += clock-imx21.o mm-imx21.o
 obj-$(CONFIG_MACH_MX27) += cpu-imx27.o pm-imx27.o
 obj-$(CONFIG_MACH_MX27) += clock-imx27.o mm-imx27.o
 
+obj-$(CONFIG_ARCH_MX28) += clock-imx28.o mm-imx28.o
+
 # Support for CMOS sensor interface
 obj-$(CONFIG_MX1_VIDEO)	+= mx1-camera-fiq.o mx1-camera-fiq-ksym.o
 
@@ -32,3 +34,5 @@ obj-$(CONFIG_MACH_CPUIMX27) += mach-cpuimx27.o
 obj-$(CONFIG_MACH_EUKREA_MBIMX27_BASEBOARD) += eukrea_mbimx27-baseboard.o
 obj-$(CONFIG_MACH_PCA100) += mach-pca100.o
 obj-$(CONFIG_MACH_MXT_TD60) += mach-mxt_td60.o
+
+obj-$(CONFIG_MACH_MX28EVK) += mach-mx28evk.o
arch/arm/mach-imx/Makefile.boot +4 -0
index 7988a85..fd451d0 100644
@@ -9,3 +9,7 @@ initrd_phys-$(CONFIG_MACH_MX21)	:= 0xC0800000
 zreladdr-$(CONFIG_MACH_MX27)	:= 0xA0008000
 params_phys-$(CONFIG_MACH_MX27)	:= 0xA0000100
 initrd_phys-$(CONFIG_MACH_MX27)	:= 0xA0800000
+
+zreladdr-$(CONFIG_ARCH_MX28)	:= 0x40008000
+params_phys-$(CONFIG_ARCH_MX28)	:= 0x40000100
+initrd_phys-$(CONFIG_ARCH_MX28)	:= 0x40800000
arch/arm/plat-mxc/Kconfig +0 -0
index 680aeba..fd7ec19 100644

arch/arm/plat-mxc/Kconfig config ARCH_MX25 · line 30

Quoted 6 lines
arch/arm/plat-mxc/Kconfig +3 -0
@@ -25,6 +25,12 @@ config ARCH_MX25
 	help
 	  This enables support for systems based on the Freescale i.MX25 family
 
+config ARCH_MX28
+	bool "MX28-based"
+	select SOC_IMX28

Can you please let the machines select SOC_IMX28?

Quoted 71 lines
arch/arm/plat-mxc/Kconfig +9 -0
+	help
+	  This enables support for systems based on the Freescale i.MX28 family
+
 config ARCH_MX3
 	bool "MX3-based"
 	select CPU_V6
@@ -68,6 +74,9 @@ config MXC_TZIC
 config MXC_AVIC
 	bool
 
+config MXC_ICOLL
+	bool
+
 config MXC_PWM
 	tristate "Enable PWM driver"
 	select HAVE_PWM
@@ -109,6 +118,9 @@ config IMX_HAVE_IOMUX_V1
 config ARCH_MXC_IOMUX_V3
 	bool
 
+config ARCH_MXC_IOMUX_PINCTRL
+	bool
+
 config ARCH_MXC_AUDMUX_V1
 	bool
 
arch/arm/plat-mxc/Makefile +3 -1
index 0e12591..e194468 100644
@@ -5,12 +5,14 @@
 # Common support
 obj-y := clock.o gpio.o time.o devices.o cpu.o system.o
 
-# MX51 uses the TZIC interrupt controller, older platforms use AVIC (irq.o)
 obj-$(CONFIG_MXC_TZIC) += tzic.o
 obj-$(CONFIG_MXC_AVIC) += avic.o
+obj-$(CONFIG_MXC_ICOLL) += icoll.o
 
 obj-$(CONFIG_IMX_HAVE_IOMUX_V1) += iomux-v1.o
 obj-$(CONFIG_ARCH_MXC_IOMUX_V3) += iomux-v3.o
+obj-$(CONFIG_ARCH_MXC_IOMUX_PINCTRL) += iomux-pinctrl.o
+
 obj-$(CONFIG_IRAM_ALLOC) += iram_alloc.o
 obj-$(CONFIG_MXC_PWM)  += pwm.o
 obj-$(CONFIG_USB_EHCI_MXC) += ehci.o
arch/arm/plat-mxc/devices/Kconfig +3 -0
index 9aa6f3e..e8860d9 100644
@@ -1,3 +1,6 @@
+config IMX_HAVE_PLATFORM_DUART
+	bool
+
 config IMX_HAVE_PLATFORM_ESDHC
 	bool
 
arch/arm/plat-mxc/devices/Makefile +1 -0
index 45aefeb..11e2fcf 100644
@@ -1,3 +1,4 @@
+obj-$(CONFIG_IMX_HAVE_PLATFORM_DUART) += platform-duart.o
 obj-$(CONFIG_IMX_HAVE_PLATFORM_ESDHC) += platform-esdhc.o
 obj-$(CONFIG_IMX_HAVE_PLATFORM_FEC) += platform-fec.o
 obj-$(CONFIG_IMX_HAVE_PLATFORM_FLEXCAN) += platform-flexcan.o
Signature · 1 line
1.7.1
Signature · 2 lines
Pengutronix e.K.                           | Uwe Kleine-K?nig            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
maintainer
#23 lore raw

cover ARM: imx: Add initial i.MX28 support

In reply to Shawn Guo

Hello Shawn,

Quoted 3 lines · Shawn Guo

This patchset adds the initial support of i.MX28, and the target device is i.MX28 EVK Rev C. It's based on the imx-single-kernel branch below, and adding codes into arch/arm/mxc and arch/arm/mach-imx.

Without further looking at the patch I agree with Uwe: The i.MX23/28 are totally different from the other i.MX SoCs and should not be integrated in current i.MX support. And definitely it should not be integrated by adding cpu_is_* into each and every function.

Now you have two choices: Add the code to plat-stmp3xxx (for the interested reader: the i.MX23/28 are based on former Sigmatel SoCs), or add a new mach-mxs like you did in the Freescale Kernel.
I'm not sure which choice of these two is best. It would be good to get some other opinions from people who already had the situation that a vendor got sold and we get the same old metal with new names.

BTW the imx-single-kernel branch is a branch to show where things might or might not go. You should not base your work on this.

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 |
#24 lore raw

cover ARM: imx: Add initial i.MX28 support

Hi Sascha,

Thanks for the comments. Please see my comments below.

Quoted 12 lines · Sascha Hauer

Hello Shawn,

Quoted 3 lines · Shawn Guo

This patchset adds the initial support of i.MX28, and the target device is i.MX28 EVK Rev C. It's based on the imx-single-kernel branch below, and adding codes into arch/arm/mxc and arch/arm/mach-imx.

Without further looking at the patch I agree with Uwe: The i.MX23/28 are totally different from the other i.MX SoCs and should not be integrated in current i.MX support. And definitely it should not be integrated by adding cpu_is_* into each and every function.

cpu_is_* is not being added into each and every function. Uwe had this comment on only two files, arch/arm/plat-mxc/gpio.c and arch/arm/plat-mxc/time.c. As there are big percentage of infrastructural common codes that are IP block independent, I though it's good to use the same file. But since you are not in this position, I would propose another option. Like what I'm doing with iomux-pinctrl, we can create arch/arm/plat-mxc/gpio-pinctrl.c and arch/arm/plat-mxc/time-timrot.c for PINCTRL based gpio and TIMROT based time implementation.

The philosophy behind this is we treat arch/arm/plat-mxc as the Freescale IP block pool. The driver in this folder is IP block oriented other than SoC oriented. And SoC is actually a collection of IP blocks. MX23/MX28 integrates PINCTRL, TIMROT, ICOLL, and MX21/MX25/MX27/MX31/MX35/MX51 integrates GPIO/IOMUXC, GPT and AVIC/TZIC. Accordingly, MX23/MX28 builds gpio-pinctrl.c, timrot.c and icoll.c in, and other i.MX builds gpio.c, iomux-v1//v2/v3, avic.c/tzic.c in. The only thing we need to deal with is picking up the file name to stand for the IP block.

Quoted 7 lines

Now you have two choices: Add the code to plat-stmp3xxx (for the interested reader: the i.MX23/28 are based on former Sigmatel SoCs), or add a new mach-mxs like you did in the Freescale Kernel.
I'm not sure which choice of these two is best. It would be good to get some other opinions from people who already had the situation that a vendor got sold and we get the same old metal with new names.

Yes, MX23/28 are based on former Sigmatel SoCs. The imx-single-kernel demonstrates the possibility of single image for different SoCs from same vendor. My patchset somehow adds the the possibility for SoCs even from different vendors, even though I'm unsure if single image for SoCs from different vendor is something ARM Kernel will possibly go in the future?

The plat-stmp3xxx is not an option for me because of the Freescale marketing concern. For the choice of what Freescale Kernel is doing, there is no mach-mxs. Instead, there are arch/arm/plat-mxs, arch/arm/mach-mx23 and arch/arm/mach-mx28. Going this way, MX23/28 will be totally separated from i.MX family, though their name tells the relationship with i.MX family. Also, Freescale is merging the Sigmatel IP pool into i.MX one and will only maintain the same pool. In another words, Sigmatel IP block are getting consolidated with i.MX ones. You can still say MX28 are former Sigmatel based, but it gets i.MX IP blocks, FEC(ENET), FlexCAN integrated. If MX28 is not so typical, MX50 can be the one. It primarily derives from MX51/MX53 and will go into plat-mxc and mach-mx5 in common understanding, but it gets a lot of MX28 (Sigmatel) based IP blocks integrated, LCDIF, PXP, GPMI, DCP, APHB DMA, and so on. SoC is merging these two families into one. It makes no sense for SW to keeps them separated.

Can you please think about the IP oriented way I mentioned above to see if there is any problem that stops us going? Also do you want to eventually include MX23/28 into imx-single-kernel image? If you do, don't you think my proposal will make it a little bit easier?

Quoted 11 lines

BTW the imx-single-kernel branch is a branch to show where things might or might not go. You should not base your work on this.

Sascha

--

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

cover ARM: imx: Add initial i.MX28 support

Hello Shawn,

Quoted 8 lines · Shawn Guo
Quoted 7 lines · Sascha Hauer

Hello Shawn,

Quoted 3 lines · Shawn Guo

This patchset adds the initial support of i.MX28, and the target device is i.MX28 EVK Rev C. It's based on the imx-single-kernel branch below, and adding codes into arch/arm/mxc and arch/arm/mach-imx.

Quoted 7 lines
Quoted 5 lines

Without further looking at the patch I agree with Uwe: The i.MX23/28 are totally different from the other i.MX SoCs and should not be integrated in current i.MX support. And definitely it should not be integrated by adding cpu_is_* into each and every function.

cpu_is_* is not being added into each and every function. Uwe had this comment on only two files, arch/arm/plat-mxc/gpio.c and

I consider the irq handling very ugly, but I didn't feel like repeating the same argument gives much value. (And OK, the irq handling was ugly already before, that's on my plate to evaluate.) I didn't recheck where I thought the runtime checks were non-optimal, but seeing to much of them makes me feel that this is the wrong approach. This is more a subjective thing and for that it's independant if there are one, two or five instances.

Quoted 8 lines

arch/arm/plat-mxc/time.c. As there are big percentage of infrastructural common codes that are IP block independent, I though it's good to use the same file. But since you are not in this position, I would propose another option. Like what I'm doing with iomux-pinctrl, we can create arch/arm/plat-mxc/gpio-pinctrl.c and arch/arm/plat-mxc/time-timrot.c for PINCTRL based gpio and TIMROT based time implementation.

Quoted 9 lines

The philosophy behind this is we treat arch/arm/plat-mxc as the Freescale IP block pool. The driver in this folder is IP block oriented other than SoC oriented. And SoC is actually a collection of IP blocks. MX23/MX28 integrates PINCTRL, TIMROT, ICOLL, and MX21/MX25/MX27/MX31/MX35/MX51 integrates GPIO/IOMUXC, GPT and AVIC/TZIC. Accordingly, MX23/MX28 builds gpio-pinctrl.c, timrot.c and icoll.c in, and other i.MX builds gpio.c, iomux-v1//v2/v3, avic.c/tzic.c in. The only thing we need to deal with is picking up the file name to stand for the IP block.

For me (not having seen mx50) integrating mx28 into mach-imx seems wrong. Currently they are completely orthogonal for the components that matter for architecture support (i.e. timer, irq handling, clocks, pin muxing, power management and to a slightly lesser degree gpio and memory mapping).

Quoted 7 lines
Quoted 7 lines

Now you have two choices: Add the code to plat-stmp3xxx (for the interested reader: the i.MX23/28 are based on former Sigmatel SoCs), or add a new mach-mxs like you did in the Freescale Kernel.
I'm not sure which choice of these two is best. It would be good to get some other opinions from people who already had the situation that a vendor got sold and we get the same old metal with new names.

Quoted 6 lines

Yes, MX23/28 are based on former Sigmatel SoCs. The imx-single-kernel demonstrates the possibility of single image for different SoCs from same vendor. My patchset somehow adds the the possibility for SoCs even from different vendors, even though I'm unsure if single image for SoCs from different vendor is something ARM Kernel will possibly go in the future?

That's one of the goals of Linaro. I'd prefer to get an "really-all-i.MX" image via this more global approach.

Quoted 2 lines

The plat-stmp3xxx is not an option for me because of the Freescale marketing concern. For the choice of what Freescale Kernel is doing,

I prefer technical arguments here. Just because some guys in the marketing department consider giving similar names to completely different products *I* don't believe grouping them together in the source code makes more sense. (It just reinforces my opinion about marketing guys :-)

Quoted 3 lines

there is no mach-mxs. Instead, there are arch/arm/plat-mxs, arch/arm/mach-mx23 and arch/arm/mach-mx28. Going this way, MX23/28 will be totally separated from i.MX family, though their name tells

Adding mach-mx23, mach-mx28 and plat-mxs is (IMHO) too much. mx23 and mx28 are similar enough to put both of the two into a single mach directory. So seeing the naming choices Freescale did for their kernel mach-mxs looks reasonable to me.

Quoted 1 line

the relationship with i.MX family. Also, Freescale is merging the

This wouldn't be worse than what we had before I merged mach-mx1 and mach-mx2 into mach-imx for 2.6.36: mach-mx1, mach-mx2, mach-mx25, mach-mx3 and mach-mx5.

Quoted 4 lines

Sigmatel IP pool into i.MX one and will only maintain the same pool. In another words, Sigmatel IP block are getting consolidated with i.MX ones. You can still say MX28 are former Sigmatel based, but it gets i.MX IP blocks, FEC(ENET), FlexCAN integrated. If MX28 is not so

This is natural and OK. But these components are no reason to put mx28 into mach-imx. The respective drivers live in drivers/net and drivers/net/can. So at best they can share the imx_add_device_du_jour functions. Here I'd suggest to make these functions available for all ARMs (or even all archs).

Quoted 2 lines

typical, MX50 can be the one. It primarily derives from MX51/MX53 and will go into plat-mxc and mach-mx5 in common understanding, but it

Let's discuss that when you come up with mx50 patches :-)

Quoted 3 lines

gets a lot of MX28 (Sigmatel) based IP blocks integrated, LCDIF, PXP, GPMI, DCP, APHB DMA, and so on. SoC is merging these two families into one. It makes no sense for SW to keeps them separated.

I don't want to separate things artificially that belong together, but I don't want to put things together that are really seperate, too.

Quoted 4 lines

Can you please think about the IP oriented way I mentioned above to see if there is any problem that stops us going? Also do you want to eventually include MX23/28 into imx-single-kernel image? If you do, don't you think my proposal will make it a little bit easier?

It might be easier, yes, but there are also some other criterias that matter, like maintainability, efficiency of compiled code etc. And I think when taking these into account using a different machine directory is the right choice.

Best regards
Uwe

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

cover ARM: imx: Add initial i.MX28 support

Hi Uwe,

2010/11/17 Uwe Kleine-K?nig <[email protected]>:

Quoted 106 lines

Hello Shawn,

Quoted 8 lines · Shawn Guo
Quoted 7 lines · Sascha Hauer

Hello Shawn,

Quoted 3 lines · Shawn Guo

This patchset adds the initial support of i.MX28, and the target device is i.MX28 EVK Rev C. It's based on the imx-single-kernel branch below, and adding codes into arch/arm/mxc and arch/arm/mach-imx.

Quoted 7 lines
Quoted 5 lines

Without further looking at the patch I agree with Uwe: The i.MX23/28 are totally different from the other i.MX SoCs and should not be integrated in current i.MX support. And definitely it should not be integrated by adding cpu_is_* into each and every function.

cpu_is_* is not being added into each and every function. Uwe had this comment on only two files, arch/arm/plat-mxc/gpio.c and

I consider the irq handling very ugly, but I didn't feel like repeating the same argument gives much value. ?(And OK, the irq handling was ugly already before, that's on my plate to evaluate.) ?I didn't recheck where I thought the runtime checks were non-optimal, but seeing to much of them makes me feel that this is the wrong approach. ?This is more a subjective thing and for that it's independant if there are one, two or five instances.

Quoted 8 lines

arch/arm/plat-mxc/time.c. As there are big percentage of infrastructural common codes that are IP block independent, I though it's good to use the same file. ?But since you are not in this position, I would propose another option. Like what I'm doing with iomux-pinctrl, we can create arch/arm/plat-mxc/gpio-pinctrl.c and arch/arm/plat-mxc/time-timrot.c for PINCTRL based gpio and TIMROT based time implementation.

Quoted 9 lines

The philosophy behind this is we treat arch/arm/plat-mxc as the Freescale IP block pool. ?The driver in this folder is IP block oriented other than SoC oriented. ?And SoC is actually a collection of IP blocks. ?MX23/MX28 integrates PINCTRL, TIMROT, ICOLL, and MX21/MX25/MX27/MX31/MX35/MX51 integrates GPIO/IOMUXC, GPT and AVIC/TZIC. ?Accordingly, MX23/MX28 builds gpio-pinctrl.c, timrot.c and icoll.c in, and other i.MX builds gpio.c, iomux-v1//v2/v3, avic.c/tzic.c in. ?The only thing we need to deal with is picking up the file name to stand for the IP block.

For me (not having seen mx50) integrating mx28 into mach-imx seems wrong. ?Currently they are completely orthogonal for the components that matter for architecture support (i.e. timer, irq handling, clocks, pin muxing, power management and to a slightly lesser degree gpio and memory mapping).

Quoted 7 lines
Quoted 7 lines

Now you have two choices: Add the code to plat-stmp3xxx (for the interested reader: the i.MX23/28 are based on former Sigmatel SoCs), or add a new mach-mxs like you did in the Freescale Kernel.
I'm not sure which choice of these two is best. It would be good to get some other opinions from people who already had the situation that a vendor got sold and we get the same old metal with new names.

Quoted 6 lines

Yes, MX23/28 are based on former Sigmatel SoCs. ?The imx-single-kernel demonstrates the possibility of single image for different SoCs from same vendor. ?My patchset somehow adds the the possibility for SoCs even from different vendors, even though I'm unsure if single image for SoCs from different vendor is something ARM Kernel will possibly go in the future?

That's one of the goals of Linaro. ?I'd prefer to get an "really-all-i.MX" image via this more global approach.

Quoted 2 lines

The plat-stmp3xxx is not an option for me because of the Freescale marketing concern. ?For the choice of what Freescale Kernel is doing,

I prefer technical arguments here. ?Just because some guys in the marketing department consider giving similar names to completely different products *I* don't believe grouping them together in the source code makes more sense. ?(It just reinforces my opinion about marketing guys :-)

Quoted 3 lines

there is no mach-mxs. ?Instead, there are arch/arm/plat-mxs, arch/arm/mach-mx23 and arch/arm/mach-mx28. ?Going this way, MX23/28 will be totally separated from i.MX family, though their name tells

Adding mach-mx23, mach-mx28 and plat-mxs is (IMHO) too much. ?mx23 and mx28 are similar enough to put both of the two into a single mach directory. ?So seeing the naming choices Freescale did for their kernel mach-mxs looks reasonable to me.

Quoted 1 line

the relationship with i.MX family. ?Also, Freescale is merging the

This wouldn't be worse than what we had before I merged mach-mx1 and mach-mx2 into mach-imx for 2.6.36: mach-mx1, mach-mx2, mach-mx25, mach-mx3 and mach-mx5.

Quoted 4 lines

Sigmatel IP pool into i.MX one and will only maintain the same pool. In another words, Sigmatel IP block are getting consolidated with i.MX ones. You can still say MX28 are former Sigmatel based, but it gets i.MX IP blocks, FEC(ENET), FlexCAN integrated. ?If MX28 is not so

This is natural and OK. ?But these components are no reason to put mx28 into mach-imx. ?The respective drivers live in drivers/net and drivers/net/can. ?So at best they can share the imx_add_device_du_jour functions. ?Here I'd suggest to make these functions available for all ARMs (or even all archs).

Quoted 2 lines

typical, MX50 can be the one. ?It primarily derives from MX51/MX53 and will go into plat-mxc and mach-mx5 in common understanding, but it

Let's discuss that when you come up with mx50 patches :-)

Quoted 3 lines

gets a lot of MX28 (Sigmatel) based IP blocks integrated, LCDIF, PXP, GPMI, DCP, APHB DMA, and so on. ?SoC is merging these two families into one. ?It makes no sense for SW to keeps them separated.

I don't want to separate things artificially that belong together, but I don't want to put things together that are really seperate, too.

Quoted 9 lines
Quoted 4 lines

Can you please think about the IP oriented way I mentioned above to see if there is any problem that stops us going? ?Also do you want to eventually include MX23/28 into imx-single-kernel image? ?If you do, don't you think my proposal will make it a little bit easier?

It might be easier, yes, but there are also some other criterias that matter, like maintainability, efficiency of compiled code etc. ?And I think when taking these into account using a different machine directory is the right choice.

plat-stmp3xxx is not an option for me. Another reason is it has the support for mach-stmp37xx. If I change anything in plat-stmp3xxx, I can not even find a board to test mach-stmp37xx. For me plat-stmp3xxx, mach-stmp37xx and mach-stmp378x seem out of maintaining. I do not see they are moving.

So at the end of the day, mach-mxs + plat-mxs becomes the option that could work for both of us, right? Correct me I misunderstood your comments.

Quoted 7 lines

Best regards
Uwe

--

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

cover ARM: imx: Add initial i.MX28 support

Hi Shawn,

Quoted 9 lines

plat-stmp3xxx is not an option for me. Another reason is it has the support for mach-stmp37xx. If I change anything in plat-stmp3xxx, I can not even find a board to test mach-stmp37xx. For me plat-stmp3xxx, mach-stmp37xx and mach-stmp378x seem out of maintaining. I do not see they are moving.

So at the end of the day, mach-mxs + plat-mxs becomes the option that could work for both of us, right? Correct me I misunderstood your comments.

As long as you don't use more than mach directory there is no need to populate plat-mxs. Everything can go into mach-mxs.

Best regards
Uwe

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