ARM: mxs: Add initial support for MX23 and MX28
Subsystems (3)
cover ARM: mxs: Add initial support for MX23 and MX28
This patch series is the successor of the following one.
[PATCH 00/11] ARM: imx: Add initial i.MX28 support
http://lists.infradead.org/pipermail/linux-arm-kernel/2010-November/031464.html
It puts everything about MX23 and MX28 into mach-mxs to address the concern from Uwe and Sascha.
It's being developed against Sascha's imx-for-2.6.38 tree, and supports single image for MX23 and MX28, since they share the same PHYS_OFFSET.
Shawn Guo (15):
arch/arm/Kconfig | 10 + arch/arm/Makefile | 1 + arch/arm/mach-mxs/Kconfig | 34 + arch/arm/mach-mxs/Makefile | 14 + arch/arm/mach-mxs/Makefile.boot | 3 + arch/arm/mach-mxs/clock-mx23.c | 521 ++++++++++++++++ arch/arm/mach-mxs/clock-mx28.c | 732 +++++++++++++++++++++++ arch/arm/mach-mxs/clock.c | 201 +++++++ arch/arm/mach-mxs/cpu.c | 11 + arch/arm/mach-mxs/devices-mx23.h | 16 + arch/arm/mach-mxs/devices-mx28.h | 22 + arch/arm/mach-mxs/devices.c | 75 +++ arch/arm/mach-mxs/devices/Kconfig | 5 + arch/arm/mach-mxs/devices/Makefile | 2 + arch/arm/mach-mxs/devices/platform-duart.c | 47 ++ arch/arm/mach-mxs/devices/platform-fec.c | 51 ++ arch/arm/mach-mxs/gpio.c | 364 +++++++++++ arch/arm/mach-mxs/icoll.c | 77 +++ arch/arm/mach-mxs/include/mach/clkdev.h | 7 + arch/arm/mach-mxs/include/mach/clock.h | 64 ++ arch/arm/mach-mxs/include/mach/common.h | 33 + arch/arm/mach-mxs/include/mach/debug-macro.S | 51 ++ arch/arm/mach-mxs/include/mach/devices-common.h | 46 ++ arch/arm/mach-mxs/include/mach/entry-macro.S | 36 ++ arch/arm/mach-mxs/include/mach/gpio.h | 49 ++ arch/arm/mach-mxs/include/mach/hardware.h | 66 ++ arch/arm/mach-mxs/include/mach/io.h | 22 + arch/arm/mach-mxs/include/mach/iomux-mx23.h | 29 + arch/arm/mach-mxs/include/mach/iomux-mx28.h | 44 ++ arch/arm/mach-mxs/include/mach/iomux.h | 77 +++ arch/arm/mach-mxs/include/mach/irqs.h | 32 + arch/arm/mach-mxs/include/mach/memory.h | 24 + arch/arm/mach-mxs/include/mach/mx23.h | 147 +++++ arch/arm/mach-mxs/include/mach/mx28.h | 227 +++++++ arch/arm/mach-mxs/include/mach/mxs.h | 60 ++ arch/arm/mach-mxs/include/mach/system.h | 27 + arch/arm/mach-mxs/include/mach/timex.h | 21 + arch/arm/mach-mxs/include/mach/uncompress.h | 82 +++ arch/arm/mach-mxs/include/mach/vmalloc.h | 22 + arch/arm/mach-mxs/iomux.c | 110 ++++ arch/arm/mach-mxs/mach-mx23evk.c | 59 ++ arch/arm/mach-mxs/mach-mx28evk.c | 108 ++++ arch/arm/mach-mxs/mm-mx23.c | 48 ++ arch/arm/mach-mxs/mm-mx28.c | 48 ++ arch/arm/mach-mxs/regs-clkctrl-mx23.h | 455 ++++++++++++++ arch/arm/mach-mxs/regs-clkctrl-mx28.h | 663 ++++++++++++++++++++ arch/arm/mach-mxs/system.c | 152 +++++ arch/arm/mach-mxs/timer.c | 285 +++++++++ 48 files changed, 5280 insertions(+), 0 deletions(-)
PATCH 1/15 ARM: mxs: Add core definitions
Add core definitions for MXS-based SoC MX23 and MX28.
--- arch/arm/mach-mxs/include/mach/hardware.h | 66 +++++++++ arch/arm/mach-mxs/include/mach/irqs.h | 32 ++++ arch/arm/mach-mxs/include/mach/memory.h | 24 +++ arch/arm/mach-mxs/include/mach/mx23.h | 147 +++++++++++++++++++ arch/arm/mach-mxs/include/mach/mx28.h | 227 +++++++++++++++++++++++++++++ arch/arm/mach-mxs/include/mach/mxs.h | 60 ++++++++ 6 files changed, 556 insertions(+), 0 deletions(-) create mode 100644 arch/arm/mach-mxs/include/mach/hardware.h create mode 100644 arch/arm/mach-mxs/include/mach/irqs.h create mode 100644 arch/arm/mach-mxs/include/mach/memory.h create mode 100644 arch/arm/mach-mxs/include/mach/mx23.h create mode 100644 arch/arm/mach-mxs/include/mach/mx28.h create mode 100644 arch/arm/mach-mxs/include/mach/mxs.h
arch/arm/mach-mxs/include/mach/hardware.h new file +66 -0
@@ -0,0 +1,66 @@ +/* +* Copyright 2004-2007 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 +* 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_MXS_HARDWARE_H__ +#define __MACH_MXS_HARDWARE_H__ + +#include <asm/sizes.h> + +#ifdef __ASSEMBLER__ +#define IOMEM (addr) (addr) +#else +#define IOMEM (addr) ((void __force __iomem *)(addr)) +#endif + +#define MXS_IO_P2V_MODULE (addr, module) \ + (((addr) - module ## _BASE_ADDR) < module ## _SIZE ? \ + (addr) - (module ## _BASE_ADDR) + (module ## _BASE_ADDR_VIRT) : 0) + +/* +* It maps the whole address space to [0xf4000000, 0xf5ffffff]. +* +* OCRAM 0x00000000+0x020000 -> 0xf4000000+0x020000 +* IO 0x80000000+0x100000 -> 0xf4400000+0x100000 +*/ +#define MXS_IO_P2V (x) ( \ + 0xf4000000 + \ + (((x) & 0x50000000) >> 6) + \ + (((x) & 0x0b000000) >> 4) + \ + (((x) & 0x000fffff))) + +#define MXS_IO_ADDRESS (x) IOMEM(MXS_IO_P2V(x)) + +#ifdef CONFIG_SOC_IMX23 +# include <mach/mx23.h> +#endif + +#ifdef CONFIG_SOC_IMX28 +# include <mach/mx28.h> +#endif + +#include <mach/mxs.h> + +#define mxs_map_entry (soc, name, _type) { \ + .virtual = soc ## _IO_P2V(soc ## _ ## name ## _BASE_ADDR), \ + .pfn = __phys_to_pfn(soc ## _ ## name ## _BASE_ADDR), \ + .length = soc ## _ ## name ## _SIZE, \ + .type = _type, \ +} + +#endif /* __MACH_MXS_HARDWARE_H__ */
arch/arm/mach-mxs/include/mach/irqs.h new file +32 -0
@@ -0,0 +1,32 @@ +/* +* Copyright 2004-2007 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. +*/ + +#ifndef __MACH_MXS_IRQS_H__ +#define __MACH_MXS_IRQS_H__ + +#define MXS_INTERNAL_IRQS 128 + +#define MXS_GPIO_IRQ_START MXS_INTERNAL_IRQS + +/* the maximum for MXS-based */ +#define MXS_GPIO_IRQS (32 * 5) + +/* +* The next 16 interrupts are for board specific purposes. Since +* the kernel can only run on one machine at a time, we can re-use +* these. If you need more, increase MXS_BOARD_IRQS, but keep it +* within sensible limits. +*/ +#define MXS_BOARD_IRQ_START (MXS_GPIO_IRQ_START + MXS_GPIO_IRQS) +#define MXS_BOARD_IRQS 16 + +#define NR_IRQS (MXS_BOARD_IRQ_START + MXS_BOARD_IRQS) + +#endif /* __MACH_MXS_IRQS_H__ */
arch/arm/mach-mxs/include/mach/memory.h new file +24 -0
@@ -0,0 +1,24 @@ +/* +* 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_MXS_MEMORY_H__ +#define __MACH_MXS_MEMORY_H__ + +#define PHYS_OFFSET UL(0x40000000) + +#endif /* __MACH_MXS_MEMORY_H__ */
arch/arm/mach-mxs/include/mach/mx23.h new file +147 -0
147 lines not on this page · raw message
arch/arm/mach-mxs/include/mach/mx28.h new file +227 -0
227 lines not on this page · raw message
arch/arm/mach-mxs/include/mach/mxs.h new file +60 -0
60 lines not on this page · raw message
Signature · 1 line
1.7.1
PATCH 1/15 ARM: mxs: Add core definitions
Hello Shawn,
Quoted 47 lines · Shawn Guo
Add core definitions for MXS-based SoC MX23 and MX28.
Signed-off-by Shawn Guo <[email protected]>--- arch/arm/mach-mxs/include/mach/hardware.h | 66 +++++++++ arch/arm/mach-mxs/include/mach/irqs.h | 32 ++++ arch/arm/mach-mxs/include/mach/memory.h | 24 +++ arch/arm/mach-mxs/include/mach/mx23.h | 147 +++++++++++++++++++ arch/arm/mach-mxs/include/mach/mx28.h | 227 +++++++++++++++++++++++++++++ arch/arm/mach-mxs/include/mach/mxs.h | 60 ++++++++ 6 files changed, 556 insertions(+), 0 deletions(-) create mode 100644 arch/arm/mach-mxs/include/mach/hardware.h create mode 100644 arch/arm/mach-mxs/include/mach/irqs.h create mode 100644 arch/arm/mach-mxs/include/mach/memory.h create mode 100644 arch/arm/mach-mxs/include/mach/mx23.h create mode 100644 arch/arm/mach-mxs/include/mach/mx28.h create mode 100644 arch/arm/mach-mxs/include/mach/mxs.harch/arm/mach-mxs/include/mach/hardware.h new file +23
-0@@ -0,0 +1,66 @@ +/* +* Copyright 2004-2007 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 +* 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_MXS_HARDWARE_H__ +#define __MACH_MXS_HARDWARE_H__ + +#include <asm/sizes.h>
arch/arm/mach-mxs/include/mach/hardware.h line 33
Quoted 10 lines
arch/arm/mach-mxs/include/mach/hardware.h new file +10
-0+ +#ifdef __ASSEMBLER__ +#define IOMEM (addr) (addr) +#else +#define IOMEM (addr) ((void __force __iomem *)(addr)) +#endif + +#define MXS_IO_P2V_MODULE (addr, module) \ + (((addr) - module ## _BASE_ADDR) < module ## _SIZE ? \ + (addr) - (module ## _BASE_ADDR) + (module ## _BASE_ADDR_VIRT) : 0)
Do you need this? On imx this is only used in arch/arm/mach-mx3/mach-kzm_arm11_01.c that uses it to map chip selects. IMHO it should better use a dynamic mapping for that which would allow to let IMX_IO_P2V_MODULE die.
arch/arm/mach-mxs/include/mach/hardware.h line 45
Quoted 11 lines
arch/arm/mach-mxs/include/mach/hardware.h new file +11
-0+/* +* It maps the whole address space to [0xf4000000, 0xf5ffffff]. +* +* OCRAM 0x00000000+0x020000 -> 0xf4000000+0x020000 +* IO 0x80000000+0x100000 -> 0xf4400000+0x100000 +*/ +#define MXS_IO_P2V (x) ( \ + 0xf4000000 + \ + (((x) & 0x50000000) >> 6) + \ + (((x) & 0x0b000000) >> 4) + \ + (((x) & 0x000fffff)))
Did you test this? For me MXS_IO_P2V(0x80000000) == MXS_IO_P2V(0x00000000). You should be able to choose a much simpler function, e.g.
(0xf4000000 + (((x) & 0x80000000) >> 6) + (((x) & 0x000fffff))))
should work for the two areas above
arch/arm/mach-mxs/include/mach/hardware.h line 49
Quoted 4 lines
arch/arm/mach-mxs/include/mach/hardware.h new file +4
-0+ +#define MXS_IO_ADDRESS (x) IOMEM(MXS_IO_P2V(x)) + +#ifdef CONFIG_SOC_IMX23
You don't need to protect inclusion of mach/mx23 if all symbols defined in it are properly namespaced.
Quoted 162 lines
arch/arm/mach-mxs/include/mach/hardware.h new file +17
-0+# include <mach/mx23.h> +#endif + +#ifdef CONFIG_SOC_IMX28 +# include <mach/mx28.h> +#endif + +#include <mach/mxs.h> + +#define mxs_map_entry (soc, name, _type) { \ + .virtual = soc ## _IO_P2V(soc ## _ ## name ## _BASE_ADDR), \ + .pfn = __phys_to_pfn(soc ## _ ## name ## _BASE_ADDR), \ + .length = soc ## _ ## name ## _SIZE, \ + .type = _type, \ +} + +#endif /* __MACH_MXS_HARDWARE_H__ */ arch/arm/mach-mxs/include/mach/irqs.h new file +32
-0@@ -0,0 +1,32 @@ +/* +* Copyright 2004-2007 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. +*/ + +#ifndef __MACH_MXS_IRQS_H__ +#define __MACH_MXS_IRQS_H__ + +#define MXS_INTERNAL_IRQS 128 + +#define MXS_GPIO_IRQ_START MXS_INTERNAL_IRQS + +/* the maximum for MXS-based */ +#define MXS_GPIO_IRQS (32 * 5) + +/* +* The next 16 interrupts are for board specific purposes. Since +* the kernel can only run on one machine at a time, we can re-use +* these. If you need more, increase MXS_BOARD_IRQS, but keep it +* within sensible limits. +*/ +#define MXS_BOARD_IRQ_START (MXS_GPIO_IRQ_START + MXS_GPIO_IRQS) +#define MXS_BOARD_IRQS 16 + +#define NR_IRQS (MXS_BOARD_IRQ_START + MXS_BOARD_IRQS) + +#endif /* __MACH_MXS_IRQS_H__ */ arch/arm/mach-mxs/include/mach/memory.h new file +24
-0@@ -0,0 +1,24 @@ +/* +* 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_MXS_MEMORY_H__ +#define __MACH_MXS_MEMORY_H__ + +#define PHYS_OFFSET UL(0x40000000) + +#endif /* __MACH_MXS_MEMORY_H__ */ arch/arm/mach-mxs/include/mach/mx23.h new file +71
-0@@ -0,0 +1,147 @@ +/* +* 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_MX23_H__ +#define __MACH_MX23_H__ + +#ifndef __ASSEMBLER__ +#include <linux/io.h> +#endif + +/* +* OCRAM +*/ +#define MX23_OCRAM_BASE_ADDR 0x00000000 +#define MX23_OCRAM_SIZE SZ_32K + +/* +* IO +*/ +#define MX23_IO_BASE_ADDR 0x80000000 +#define MX23_IO_SIZE SZ_1M + +#define MX23_ICOLL_BASE_ADDR (MX23_IO_BASE_ADDR + 0x000000) +#define MX23_APBH_DMA_BASE_ADDR (MX23_IO_BASE_ADDR + 0x004000) +#define MX23_BCH_BASE_ADDR (MX23_IO_BASE_ADDR + 0x00a000) +#define MX23_GPMI_BASE_ADDR (MX23_IO_BASE_ADDR + 0x00c000) +#define MX23_SSP1_BASE_ADDR (MX23_IO_BASE_ADDR + 0x010000) +#define MX23_SSP2_BASE_ADDR (MX23_IO_BASE_ADDR + 0x034000) +#define MX23_PINCTRL_BASE_ADDR (MX23_IO_BASE_ADDR + 0x018000) +#define MX23_DIGCTL_BASE_ADDR (MX23_IO_BASE_ADDR + 0x01c000) +#define MX23_ETM_BASE_ADDR (MX23_IO_BASE_ADDR + 0x020000) +#define MX23_APBX_DMA_BASE_ADDR (MX23_IO_BASE_ADDR + 0x024000) +#define MX23_DCP_BASE_ADDR (MX23_IO_BASE_ADDR + 0x028000) +#define MX23_PXP_BASE_ADDR (MX23_IO_BASE_ADDR + 0x02a000) +#define MX23_OCOTP_BASE_ADDR (MX23_IO_BASE_ADDR + 0x02c000) +#define MX23_AXI_AHB0_BASE_ADDR (MX23_IO_BASE_ADDR + 0x02e000) +#define MX23_LCDIF_BASE_ADDR (MX23_IO_BASE_ADDR + 0x030000) +#define MX23_TVENC_BASE_ADDR (MX23_IO_BASE_ADDR + 0x038000) +#define MX23_CLKCTRL_BASE_ADDR (MX23_IO_BASE_ADDR + 0x040000) +#define MX23_SAIF0_BASE_ADDR (MX23_IO_BASE_ADDR + 0x042000) +#define MX23_POWER_BASE_ADDR (MX23_IO_BASE_ADDR + 0x044000) +#define MX23_SAIF1_BASE_ADDR (MX23_IO_BASE_ADDR + 0x046000) +#define MX23_AUDIOOUT_BASE_ADDR (MX23_IO_BASE_ADDR + 0x048000) +#define MX23_AUDIOIN_BASE_ADDR (MX23_IO_BASE_ADDR + 0x04c000) +#define MX23_LRADC_BASE_ADDR (MX23_IO_BASE_ADDR + 0x050000) +#define MX23_SPDIF_BASE_ADDR (MX23_IO_BASE_ADDR + 0x054000) +#define MX23_RTC_BASE_ADDR (MX23_IO_BASE_ADDR + 0x05c000) +#define MX23_I2C0_BASE_ADDR (MX23_IO_BASE_ADDR + 0x058000) +#define MX23_PWM_BASE_ADDR (MX23_IO_BASE_ADDR + 0x064000) +#define MX23_TIMROT_BASE_ADDR (MX23_IO_BASE_ADDR + 0x068000) +#define MX23_AUART1_BASE_ADDR (MX23_IO_BASE_ADDR + 0x06c000) +#define MX23_AUART2_BASE_ADDR (MX23_IO_BASE_ADDR + 0x06e000) +#define MX23_DUART_BASE_ADDR (MX23_IO_BASE_ADDR + 0x070000) +#define MX23_USBPHY_BASE_ADDR (MX23_IO_BASE_ADDR + 0x07c000) +#define MX23_USBCTRL_BASE_ADDR (MX23_IO_BASE_ADDR + 0x080000) +#define MX23_DRAM_BASE_ADDR (MX23_IO_BASE_ADDR + 0x0e0000)
arch/arm/mach-mxs/include/mach/mx23.h line 81
Quoted 10 lines
arch/arm/mach-mxs/include/mach/mx23.h new file +10
-0+ +#define MX23_IO_P2V (x) MXS_IO_P2V(x) +#define MX23_IO_ADDRESS (x) IOMEM(MX23_IO_P2V(x)) + +/* +* IRQ +*/ +#define MX23_INT_DUART 0 +#define MX23_INT_COMMS_RX 1 +#define MX23_INT_COMMS_TX 1
really two names for irq 1?
arch/arm/mach-mxs/include/mach/mx23.h line 90
Quoted 9 lines
arch/arm/mach-mxs/include/mach/mx23.h new file +9
-0+#define MX23_INT_SSP2_ERROR 2 +#define MX23_INT_VDD5V 3 +#define MX23_INT_HEADPHONE_SHORT 4 +#define MX23_INT_DAC_DMA 5 +#define MX23_INT_DAC_ERROR 6 +#define MX23_INT_ADC_DMA 7 +#define MX23_INT_ADC_ERROR 8 +#define MX23_INT_SPDIF_DMA 9 +#define MX23_INT_SAIF2_DMA 9
ditto
arch/arm/mach-mxs/include/mach/mx23.h line 93
Quoted 3 lines
arch/arm/mach-mxs/include/mach/mx23.h new file +3
-0+#define MX23_INT_SPDIF_ERROR 10 +#define MX23_INT_SAIF1_IRQ 10 +#define MX23_INT_SAIF2_IRQ 10
ditto (3 that is)
Quoted 341 lines
arch/arm/mach-mxs/include/mach/mx23.h new file +54
-0+#define MX23_INT_USB_CTRL 11 +#define MX23_INT_USB_WAKEUP 12 +#define MX23_INT_GPMI_DMA 13 +#define MX23_INT_SSP1_DMA 14 +#define MX23_INT_SSP_ERROR 15 +#define MX23_INT_GPIO0 16 +#define MX23_INT_GPIO1 17 +#define MX23_INT_GPIO2 18 +#define MX23_INT_SAIF1_DMA 19 +#define MX23_INT_SSP2_DMA 20 +#define MX23_INT_ECC8_IRQ 21 +#define MX23_INT_RTC_ALARM 22 +#define MX23_INT_UARTAPP_TX_DMA 23 +#define MX23_INT_UARTAPP_INTERNAL 24 +#define MX23_INT_UARTAPP_RX_DMA 25 +#define MX23_INT_I2C_DMA 26 +#define MX23_INT_I2C_ERROR 27 +#define MX23_INT_TIMER0 28 +#define MX23_INT_TIMER1 29 +#define MX23_INT_TIMER2 30 +#define MX23_INT_TIMER3 31 +#define MX23_INT_BATT_BRNOUT 32 +#define MX23_INT_VDDD_BRNOUT 33 +#define MX23_INT_VDDIO_BRNOUT 34 +#define MX23_INT_VDD18_BRNOUT 35 +#define MX23_INT_TOUCH_DETECT 36 +#define MX23_INT_LRADC_CH0 37 +#define MX23_INT_LRADC_CH1 38 +#define MX23_INT_LRADC_CH2 39 +#define MX23_INT_LRADC_CH3 40 +#define MX23_INT_LRADC_CH4 41 +#define MX23_INT_LRADC_CH5 42 +#define MX23_INT_LRADC_CH6 43 +#define MX23_INT_LRADC_CH7 44 +#define MX23_INT_LCDIF_DMA 45 +#define MX23_INT_LCDIF_ERROR 46 +#define MX23_INT_DIGCTL_DEBUG_TRAP 47 +#define MX23_INT_RTC_1MSEC 48 +#define MX23_INT_DRI_DMA 49 +#define MX23_INT_DRI_ATTENTION 50 +#define MX23_INT_GPMI_ATTENTION 51 +#define MX23_INT_IR 52 +#define MX23_INT_DCP_VMI 53 +#define MX23_INT_DCP 54 +#define MX23_INT_BCH 56 +#define MX23_INT_PXP 57 +#define MX23_INT_UARTAPP2_TX_DMA 58 +#define MX23_INT_UARTAPP2_INTERNAL 59 +#define MX23_INT_UARTAPP2_RX_DMA 60 +#define MX23_INT_VDAC_DETECT 61 +#define MX23_INT_VDD5V_DROOP 64 +#define MX23_INT_DCDC4P2_BO 65 + +#endif /* __MACH_MX23_H__ */ arch/arm/mach-mxs/include/mach/mx28.h new file +227
-0@@ -0,0 +1,227 @@ +/* +* 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_MX28_H__ +#define __MACH_MX28_H__ + +#ifndef __ASSEMBLER__ +#include <linux/io.h> +#endif + +/* +* 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) +#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_MAC0_BASE_ADDR (MX28_IO_BASE_ADDR + 0x0f0000) +#define MX28_ENET_MAC1_BASE_ADDR (MX28_IO_BASE_ADDR + 0x0f4000) + +#define MX28_IO_P2V (x) MXS_IO_P2V(x) +#define MX28_IO_ADDRESS (x) IOMEM(MX28_IO_P2V(x)) + +/* +* 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 +#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 +#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 + +#endif /* __MACH_MX28_H__ */ arch/arm/mach-mxs/include/mach/mxs.h new file +48
-0@@ -0,0 +1,60 @@ +/* +* 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_MXS_H__ +#define __MACH_MXS_H__ + +#define MXS_SET_ADDR 0x4 +#define MXS_CLR_ADDR 0x8 +#define MXS_TOG_ADDR 0xc + +/* +* MXS CPU types +*/ +#define MXS_CPU_MX23 23 +#define MXS_CPU_MX28 28 + +#ifndef __ASSEMBLY__ +extern unsigned int __mxs_cpu_type; +#endif + +#ifdef CONFIG_SOC_IMX23 +# ifdef mxs_cpu_type +# undef mxs_cpu_type +# define mxs_cpu_type __mxs_cpu_type +# else +# define mxs_cpu_type MXS_CPU_MX23 +# endif +# define cpu_is_mx23 () (mxs_cpu_type == MXS_CPU_MX23) +#else +# define cpu_is_mx23 () (0) +#endif + +#ifdef CONFIG_SOC_IMX28
arch/arm/mach-mxs/include/mach/mxs.h line 58
Quoted 10 lines
arch/arm/mach-mxs/include/mach/mxs.h new file +10
-0+# ifdef mxs_cpu_type +# undef mxs_cpu_type +# define mxs_cpu_type __mxs_cpu_type +# else +# define mxs_cpu_type MXS_CPU_MX28 +# endif +# define cpu_is_mx28 () (mxs_cpu_type == MXS_CPU_MX28) +#else +# define cpu_is_mx28 () (0) +#endif
For imx I wondered if this is overkill. When I started mainlining ns9xxx I just did:
#define cpu_is_xyz() (machine_is_abc() || ...)
It's much easier and the generated code probably is not much worse. (Better try to reduce the number of usages of these macros.)
(Note, if you're convinced this is good, go ahead, just my personal opinion.)
Best regards
Uwe
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-K?nig | Industrial Linux Solutions | http://www.pengutronix.de/ |
PATCH 1/15 ARM: mxs: Add core definitions
Hi Uwe,
Thanks for the review.
2010/11/26 Uwe Kleine-K?nig <[email protected]>:
Quoted 56 lines
Hello Shawn,
Quoted 53 lines · Shawn Guo
Add core definitions for MXS-based SoC MX23 and MX28.
Signed-off-by Shawn Guo <[email protected]>---
?arch/arm/mach-mxs/include/mach/hardware.h | ? 66 +++++++++ ?arch/arm/mach-mxs/include/mach/irqs.h ? ? | ? 32 ++++ ?arch/arm/mach-mxs/include/mach/memory.h ? | ? 24 +++ ?arch/arm/mach-mxs/include/mach/mx23.h ? ? | ?147 +++++++++++++++++++ ?arch/arm/mach-mxs/include/mach/mx28.h ? ? | ?227 +++++++++++++++++++++++++++++ ?arch/arm/mach-mxs/include/mach/mxs.h ? ? ?| ? 60 ++++++++?6 files changed, 556 insertions(+), 0 deletions(-) ?create mode 100644
arch/arm/mach-mxs/include/mach/hardware.h?create mode 100644arch/arm/mach-mxs/include/mach/irqs.h?create mode 100644arch/arm/mach-mxs/include/mach/memory.h?create mode 100644arch/arm/mach-mxs/include/mach/mx23.h?create mode 100644arch/arm/mach-mxs/include/mach/mx28.h?create mode 100644arch/arm/mach-mxs/include/mach/mxs.harch/arm/mach-mxs/include/mach/hardware.h new file +29
-0@@ -0,0 +1,66 @@ +/* +* Copyright 2004-2007 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 +* 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_MXS_HARDWARE_H__ +#define __MACH_MXS_HARDWARE_H__ + +#include <asm/sizes.h> + +#ifdef __ASSEMBLER__ +#define IOMEM (addr) ?(addr) +#else +#define IOMEM (addr) ?((void __force __iomem *)(addr)) +#endif
Quoted 9 lines
arch/arm/mach-mxs/include/mach/hardware.h line 33
Quoted 4 lines
arch/arm/mach-mxs/include/mach/hardware.h new file +4
-0+ +#define MXS_IO_P2V_MODULE (addr, module) ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?\ + ? ? (((addr) - module ## _BASE_ADDR) < module ## _SIZE ? ? ? ? ? ? ?\ + ? ? ?(addr) - (module ## _BASE_ADDR) + (module ## _BASE_ADDR_VIRT) : 0)Do you need this? ?On imx this is only used in
arch/arm/mach-mx3/mach-kzm_arm11_01.cthat uses it to map chip selects. IMHO it should better use a dynamic mapping for that which would allow to letIMX_IO_P2V_MODULEdie.
Will remove it.
Quoted 15 lines
arch/arm/mach-mxs/include/mach/hardware.h line 44
Quoted 11 lines
arch/arm/mach-mxs/include/mach/hardware.h new file +11
-0+/* +* It maps the whole address space to [0xf4000000, 0xf5ffffff]. +* +* ? OCRAM ? 0x00000000+0x020000 ? ? -> ? ? ?0xf4000000+0x020000 +* ? IO ? ? ?0x80000000+0x100000 ? ? -> ? ? ?0xf4400000+0x100000 +*/ +#define MXS_IO_P2V (x) ? ? ? ?( ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? \ + ? ? ? ? ? ? ? ? ? ? 0xf4000000 + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?\ + ? ? ? ? ? ? ? ? ? ? (((x) & 0x50000000) >> 6) + ? ? ? ? ? ? ? ? ? ? \ + ? ? ? ? ? ? ? ? ? ? (((x) & 0x0b000000) >> 4) + ? ? ? ? ? ? ? ? ? ? \ + ? ? ? ? ? ? ? ? ? ? (((x) & 0x000fffff)))Did you test this? ?For me
MXS_IO_P2V(0x80000000)==MXS_IO_P2V(0x00000000). ?You should be able to choose a much simpler function, e.g.
Quoted 4 lines
? ? ? ? ? ? ? ?(0xf4000000 + (((x) &
0x80000000) >> 6) + (((x) &0x000fffff))))should work for the two areas above
I tested it with limited modules. But I would take your suggestion to simplify the definition.
Quoted 7 lines
arch/arm/mach-mxs/include/mach/hardware.h line 49
Quoted 4 lines
arch/arm/mach-mxs/include/mach/hardware.h new file +4
-0+ +#define MXS_IO_ADDRESS (x) ? ?IOMEM(MXS_IO_P2V(x)) + +#ifdef CONFIG_SOC_IMX23 You don't need to protect inclusion of mach/mx23 if all symbols defined in it are properly namespaced.
Will remove them.
Quoted 165 lines
Quoted 165 lines
arch/arm/mach-mxs/include/mach/hardware.h new file +17
-0+# include <mach/mx23.h> +#endif + +#ifdef CONFIG_SOC_IMX28 +# include <mach/mx28.h> +#endif + +#include <mach/mxs.h> + +#define mxs_map_entry (soc, name, _type) ? ? ?{ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? \ + ? ? .virtual = soc ## _IO_P2V(soc ## _ ## name ## _BASE_ADDR), ? ? ?\ + ? ? .pfn = __phys_to_pfn(soc ## _ ## name ## _BASE_ADDR), ? ? ? ? ? \ + ? ? .length = soc ## _ ## name ## _SIZE, ? ? ? ? ? ? ? ? ? ? ? ? ? ?\ + ? ? .type = _type, ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?\ +} + +#endif /* __MACH_MXS_HARDWARE_H__ */ arch/arm/mach-mxs/include/mach/irqs.h new file +32
-0@@ -0,0 +1,32 @@ +/* +* ?Copyright 2004-2007 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. +*/ + +#ifndef __MACH_MXS_IRQS_H__ +#define __MACH_MXS_IRQS_H__ + +#define MXS_INTERNAL_IRQS ? ?128 + +#define MXS_GPIO_IRQ_START ? MXS_INTERNAL_IRQS + +/* the maximum for MXS-based */ +#define MXS_GPIO_IRQS ? ? ? ? ? ? ? ?(32 * 5) + +/* +* The next 16 interrupts are for board specific purposes. ?Since +* the kernel can only run on one machine at a time, we can re-use +* these. ?If you need more, increase MXS_BOARD_IRQS, but keep it +* within sensible limits. +*/ +#define MXS_BOARD_IRQ_START ?(MXS_GPIO_IRQ_START + MXS_GPIO_IRQS) +#define MXS_BOARD_IRQS ? ? ? ? ? ? ? 16 + +#define NR_IRQS ? ? ? ? ? ? ? ? ? ? ?(MXS_BOARD_IRQ_START + MXS_BOARD_IRQS) + +#endif /* __MACH_MXS_IRQS_H__ */ arch/arm/mach-mxs/include/mach/memory.h new file +24
-0@@ -0,0 +1,24 @@ +/* +* 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_MXS_MEMORY_H__ +#define __MACH_MXS_MEMORY_H__ + +#define PHYS_OFFSET ? ? ? ? ?UL(0x40000000) + +#endif /* __MACH_MXS_MEMORY_H__ */ arch/arm/mach-mxs/include/mach/mx23.h new file +74
-0@@ -0,0 +1,147 @@ +/* +* 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_MX23_H__ +#define __MACH_MX23_H__ + +#ifndef __ASSEMBLER__ +#include <linux/io.h> +#endif + +/* +* OCRAM +*/ +#define MX23_OCRAM_BASE_ADDR ? ? ? ? 0x00000000 +#define MX23_OCRAM_SIZE ? ? ? ? ? ? ? ? ? ? ?SZ_32K + +/* +* IO +*/ +#define MX23_IO_BASE_ADDR ? ? ? ? ? ?0x80000000 +#define MX23_IO_SIZE ? ? ? ? ? ? ? ? SZ_1M + +#define MX23_ICOLL_BASE_ADDR ? ? ? ? (MX23_IO_BASE_ADDR + 0x000000) +#define MX23_APBH_DMA_BASE_ADDR ? ? ? ? ? ? ?(MX23_IO_BASE_ADDR + 0x004000) +#define MX23_BCH_BASE_ADDR ? ? ? ? ? (MX23_IO_BASE_ADDR + 0x00a000) +#define MX23_GPMI_BASE_ADDR ? ? ? ? ?(MX23_IO_BASE_ADDR + 0x00c000) +#define MX23_SSP1_BASE_ADDR ? ? ? ? ?(MX23_IO_BASE_ADDR + 0x010000) +#define MX23_SSP2_BASE_ADDR ? ? ? ? ?(MX23_IO_BASE_ADDR + 0x034000) +#define MX23_PINCTRL_BASE_ADDR ? ? ? ? ? ? ? (MX23_IO_BASE_ADDR + 0x018000) +#define MX23_DIGCTL_BASE_ADDR ? ? ? ? ? ? ? ?(MX23_IO_BASE_ADDR + 0x01c000) +#define MX23_ETM_BASE_ADDR ? ? ? ? ? (MX23_IO_BASE_ADDR + 0x020000) +#define MX23_APBX_DMA_BASE_ADDR ? ? ? ? ? ? ?(MX23_IO_BASE_ADDR + 0x024000) +#define MX23_DCP_BASE_ADDR ? ? ? ? ? (MX23_IO_BASE_ADDR + 0x028000) +#define MX23_PXP_BASE_ADDR ? ? ? ? ? (MX23_IO_BASE_ADDR + 0x02a000) +#define MX23_OCOTP_BASE_ADDR ? ? ? ? (MX23_IO_BASE_ADDR + 0x02c000) +#define MX23_AXI_AHB0_BASE_ADDR ? ? ? ? ? ? ?(MX23_IO_BASE_ADDR + 0x02e000) +#define MX23_LCDIF_BASE_ADDR ? ? ? ? (MX23_IO_BASE_ADDR + 0x030000) +#define MX23_TVENC_BASE_ADDR ? ? ? ? (MX23_IO_BASE_ADDR + 0x038000) +#define MX23_CLKCTRL_BASE_ADDR ? ? ? ? ? ? ? (MX23_IO_BASE_ADDR + 0x040000) +#define MX23_SAIF0_BASE_ADDR ? ? ? ? (MX23_IO_BASE_ADDR + 0x042000) +#define MX23_POWER_BASE_ADDR ? ? ? ? (MX23_IO_BASE_ADDR + 0x044000) +#define MX23_SAIF1_BASE_ADDR ? ? ? ? (MX23_IO_BASE_ADDR + 0x046000) +#define MX23_AUDIOOUT_BASE_ADDR ? ? ? ? ? ? ?(MX23_IO_BASE_ADDR + 0x048000) +#define MX23_AUDIOIN_BASE_ADDR ? ? ? ? ? ? ? (MX23_IO_BASE_ADDR + 0x04c000) +#define MX23_LRADC_BASE_ADDR ? ? ? ? (MX23_IO_BASE_ADDR + 0x050000) +#define MX23_SPDIF_BASE_ADDR ? ? ? ? (MX23_IO_BASE_ADDR + 0x054000) +#define MX23_RTC_BASE_ADDR ? ? ? ? ? (MX23_IO_BASE_ADDR + 0x05c000) +#define MX23_I2C0_BASE_ADDR ? ? ? ? ?(MX23_IO_BASE_ADDR + 0x058000) +#define MX23_PWM_BASE_ADDR ? ? ? ? ? (MX23_IO_BASE_ADDR + 0x064000) +#define MX23_TIMROT_BASE_ADDR ? ? ? ? ? ? ? ?(MX23_IO_BASE_ADDR + 0x068000) +#define MX23_AUART1_BASE_ADDR ? ? ? ? ? ? ? ?(MX23_IO_BASE_ADDR + 0x06c000) +#define MX23_AUART2_BASE_ADDR ? ? ? ? ? ? ? ?(MX23_IO_BASE_ADDR + 0x06e000) +#define MX23_DUART_BASE_ADDR ? ? ? ? (MX23_IO_BASE_ADDR + 0x070000) +#define MX23_USBPHY_BASE_ADDR ? ? ? ? ? ? ? ?(MX23_IO_BASE_ADDR + 0x07c000) +#define MX23_USBCTRL_BASE_ADDR ? ? ? ? ? ? ? (MX23_IO_BASE_ADDR + 0x080000) +#define MX23_DRAM_BASE_ADDR ? ? ? ? ?(MX23_IO_BASE_ADDR + 0x0e0000) + +#define MX23_IO_P2V (x) ? ? ? ? ? ? ? ? ? ? ? MXS_IO_P2V(x) +#define MX23_IO_ADDRESS (x) ? ? ? ? ? IOMEM(MX23_IO_P2V(x))
Quoted 9 lines
arch/arm/mach-mxs/include/mach/mx23.h
Quoted 7 lines
arch/arm/mach-mxs/include/mach/mx23.h new file +7
-0+ +/* +* IRQ +*/ +#define MX23_INT_DUART ? ? ? ? ? ? ? ? ? ? ? 0 +#define MX23_INT_COMMS_RX ? ? ? ? ? ?1 +#define MX23_INT_COMMS_TX ? ? ? ? ? ?1really two names for irq 1?
i.MX23 Application Processor Reference Manual, section 5.2.3 Interrupt Sources.
Quoted 369 lines
arch/arm/mach-mxs/include/mach/mx23.h line 90
Quoted 9 lines
arch/arm/mach-mxs/include/mach/mx23.h new file +9
-0+#define MX23_INT_SSP2_ERROR ? ? ? ? ?2 +#define MX23_INT_VDD5V ? ? ? ? ? ? ? ? ? ? ? 3 +#define MX23_INT_HEADPHONE_SHORT ? ? 4 +#define MX23_INT_DAC_DMA ? ? ? ? ? ? 5 +#define MX23_INT_DAC_ERROR ? ? ? ? ? 6 +#define MX23_INT_ADC_DMA ? ? ? ? ? ? 7 +#define MX23_INT_ADC_ERROR ? ? ? ? ? 8 +#define MX23_INT_SPDIF_DMA ? ? ? ? ? 9 +#define MX23_INT_SAIF2_DMA ? ? ? ? ? 9ditto
arch/arm/mach-mxs/include/mach/mx23.h line 93
Quoted 3 lines
arch/arm/mach-mxs/include/mach/mx23.h new file +3
-0+#define MX23_INT_SPDIF_ERROR ? ? ? ? 10 +#define MX23_INT_SAIF1_IRQ ? ? ? ? ? 10 +#define MX23_INT_SAIF2_IRQ ? ? ? ? ? 10ditto (3 that is)
Quoted 341 lines
arch/arm/mach-mxs/include/mach/mx23.h new file +54
-0+#define MX23_INT_USB_CTRL ? ? ? ? ? ?11 +#define MX23_INT_USB_WAKEUP ? ? ? ? ?12 +#define MX23_INT_GPMI_DMA ? ? ? ? ? ?13 +#define MX23_INT_SSP1_DMA ? ? ? ? ? ?14 +#define MX23_INT_SSP_ERROR ? ? ? ? ? 15 +#define MX23_INT_GPIO0 ? ? ? ? ? ? ? ? ? ? ? 16 +#define MX23_INT_GPIO1 ? ? ? ? ? ? ? ? ? ? ? 17 +#define MX23_INT_GPIO2 ? ? ? ? ? ? ? ? ? ? ? 18 +#define MX23_INT_SAIF1_DMA ? ? ? ? ? 19 +#define MX23_INT_SSP2_DMA ? ? ? ? ? ?20 +#define MX23_INT_ECC8_IRQ ? ? ? ? ? ?21 +#define MX23_INT_RTC_ALARM ? ? ? ? ? 22 +#define MX23_INT_UARTAPP_TX_DMA ? ? ? ? ? ? ?23 +#define MX23_INT_UARTAPP_INTERNAL ? ?24 +#define MX23_INT_UARTAPP_RX_DMA ? ? ? ? ? ? ?25 +#define MX23_INT_I2C_DMA ? ? ? ? ? ? 26 +#define MX23_INT_I2C_ERROR ? ? ? ? ? 27 +#define MX23_INT_TIMER0 ? ? ? ? ? ? ? ? ? ? ?28 +#define MX23_INT_TIMER1 ? ? ? ? ? ? ? ? ? ? ?29 +#define MX23_INT_TIMER2 ? ? ? ? ? ? ? ? ? ? ?30 +#define MX23_INT_TIMER3 ? ? ? ? ? ? ? ? ? ? ?31 +#define MX23_INT_BATT_BRNOUT ? ? ? ? 32 +#define MX23_INT_VDDD_BRNOUT ? ? ? ? 33 +#define MX23_INT_VDDIO_BRNOUT ? ? ? ? ? ? ? ?34 +#define MX23_INT_VDD18_BRNOUT ? ? ? ? ? ? ? ?35 +#define MX23_INT_TOUCH_DETECT ? ? ? ? ? ? ? ?36 +#define MX23_INT_LRADC_CH0 ? ? ? ? ? 37 +#define MX23_INT_LRADC_CH1 ? ? ? ? ? 38 +#define MX23_INT_LRADC_CH2 ? ? ? ? ? 39 +#define MX23_INT_LRADC_CH3 ? ? ? ? ? 40 +#define MX23_INT_LRADC_CH4 ? ? ? ? ? 41 +#define MX23_INT_LRADC_CH5 ? ? ? ? ? 42 +#define MX23_INT_LRADC_CH6 ? ? ? ? ? 43 +#define MX23_INT_LRADC_CH7 ? ? ? ? ? 44 +#define MX23_INT_LCDIF_DMA ? ? ? ? ? 45 +#define MX23_INT_LCDIF_ERROR ? ? ? ? 46 +#define MX23_INT_DIGCTL_DEBUG_TRAP ? 47 +#define MX23_INT_RTC_1MSEC ? ? ? ? ? 48 +#define MX23_INT_DRI_DMA ? ? ? ? ? ? 49 +#define MX23_INT_DRI_ATTENTION ? ? ? ? ? ? ? 50 +#define MX23_INT_GPMI_ATTENTION ? ? ? ? ? ? ?51 +#define MX23_INT_IR ? ? ? ? ? ? ? ? ?52 +#define MX23_INT_DCP_VMI ? ? ? ? ? ? 53 +#define MX23_INT_DCP ? ? ? ? ? ? ? ? 54 +#define MX23_INT_BCH ? ? ? ? ? ? ? ? 56 +#define MX23_INT_PXP ? ? ? ? ? ? ? ? 57 +#define MX23_INT_UARTAPP2_TX_DMA ? ? 58 +#define MX23_INT_UARTAPP2_INTERNAL ? 59 +#define MX23_INT_UARTAPP2_RX_DMA ? ? 60 +#define MX23_INT_VDAC_DETECT ? ? ? ? 61 +#define MX23_INT_VDD5V_DROOP ? ? ? ? 64 +#define MX23_INT_DCDC4P2_BO ? ? ? ? ?65 + +#endif /* __MACH_MX23_H__ */ arch/arm/mach-mxs/include/mach/mx28.h new file +227
-0@@ -0,0 +1,227 @@ +/* +* 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_MX28_H__ +#define __MACH_MX28_H__ + +#ifndef __ASSEMBLER__ +#include <linux/io.h> +#endif + +/* +* 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) +#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_MAC0_BASE_ADDR ? ? (MX28_IO_BASE_ADDR + 0x0f0000) +#define MX28_ENET_MAC1_BASE_ADDR ? ? (MX28_IO_BASE_ADDR + 0x0f4000) + +#define MX28_IO_P2V (x) ? ? ? ? ? ? ? ? ? ? ? MXS_IO_P2V(x) +#define MX28_IO_ADDRESS (x) ? ? ? ? ? IOMEM(MX28_IO_P2V(x)) + +/* +* 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 +#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 +#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 + +#endif /* __MACH_MX28_H__ */ arch/arm/mach-mxs/include/mach/mxs.h new file +48
-0@@ -0,0 +1,60 @@ +/* +* 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_MXS_H__ +#define __MACH_MXS_H__ + +#define MXS_SET_ADDR ? ? ? ? 0x4 +#define MXS_CLR_ADDR ? ? ? ? 0x8 +#define MXS_TOG_ADDR ? ? ? ? 0xc + +/* +* MXS CPU types +*/ +#define MXS_CPU_MX23 ? ? ? ? 23 +#define MXS_CPU_MX28 ? ? ? ? 28 + +#ifndef __ASSEMBLY__ +extern unsigned int __mxs_cpu_type; +#endif + +#ifdef CONFIG_SOC_IMX23 +# ifdef mxs_cpu_type +# ?undef mxs_cpu_type +# ?define mxs_cpu_type __mxs_cpu_type +# else +# ?define mxs_cpu_type MXS_CPU_MX23 +# endif +# define cpu_is_mx23 () ? ? ? ? ? ? ? (mxs_cpu_type == MXS_CPU_MX23) +#else +# define cpu_is_mx23 () ? ? ? ? ? ? ? (0) +#endif + +#ifdef CONFIG_SOC_IMX28 arch/arm/mach-mxs/include/mach/mxs.h line 58
Quoted 10 lines
arch/arm/mach-mxs/include/mach/mxs.h new file +10
-0+# ifdef mxs_cpu_type +# ?undef mxs_cpu_type +# ?define mxs_cpu_type __mxs_cpu_type +# else +# ?define mxs_cpu_type MXS_CPU_MX28 +# endif +# define cpu_is_mx28 () ? ? ? ? ? ? ? (mxs_cpu_type == MXS_CPU_MX28) +#else +# define cpu_is_mx28 () ? ? ? ? ? ? ? (0) +#endif For imx I wondered if this is overkill. ?When I started mainlining ns9xxx I just did:
Quoted 8 lines
? ? ? ?#define
cpu_is_xyz()(machine_is_abc()|| ...)It's much easier and the generated code probably is not much worse. (Better try to reduce the number of usages of these macros.)
(Note, if you're convinced this is good, go ahead, just my personal opinion.)
Your suggestion make sense to me. I will take it.
Signature · 2 lines
Regards, Shawn
PATCH 2/15 ARM: mxs: Add helper definition and function
In reply to Shawn GuoAdd helper definition and function for MXS-based.
--- arch/arm/mach-mxs/cpu.c | 11 ++++++++++ arch/arm/mach-mxs/include/mach/common.h | 33 ++++++++++++++++++++++++++++++ arch/arm/mach-mxs/include/mach/io.h | 22 ++++++++++++++++++++ arch/arm/mach-mxs/include/mach/timex.h | 21 +++++++++++++++++++ arch/arm/mach-mxs/include/mach/vmalloc.h | 22 ++++++++++++++++++++ 5 files changed, 109 insertions(+), 0 deletions(-) create mode 100644 arch/arm/mach-mxs/cpu.c create mode 100644 arch/arm/mach-mxs/include/mach/common.h create mode 100644 arch/arm/mach-mxs/include/mach/io.h create mode 100644 arch/arm/mach-mxs/include/mach/timex.h create mode 100644 arch/arm/mach-mxs/include/mach/vmalloc.h
arch/arm/mach-mxs/cpu.c new file +11 -0
@@ -0,0 +1,11 @@ + +#include <linux/module.h> + +unsigned int __mxs_cpu_type; +EXPORT_SYMBOL (__mxs_cpu_type); + +void mxs_set_cpu_type (unsigned int type) +{ + __mxs_cpu_type = type; +} +
arch/arm/mach-mxs/include/mach/common.h new file +33 -0
@@ -0,0 +1,33 @@ +/* +* Copyright 2004-2007 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. +*/ + +#ifndef __MACH_MXS_COMMON_H__ +#define __MACH_MXS_COMMON_H__ + +struct clk ; + +extern int mxs_reset_block (void __iomem *); +extern void mxs_arch_reset_init (void __iomem *); +extern void mxs_set_cpu_type (unsigned int ); +extern void mxs_timer_init (struct clk *,void __iomem *,int ); + +extern int mx23_register_gpios (void ); +extern int mx23_clocks_init (void ); +extern void mx23_map_io (void ); +extern void mx23_init_irq (void ); + +extern int mx28_register_gpios (void ); +extern int mx28_clocks_init (void ); +extern void mx28_map_io (void ); +extern void mx28_init_irq (void ); + +extern void icoll_init_irq (void __iomem *); + +#endif /* __MACH_MXS_COMMON_H__ */
arch/arm/mach-mxs/include/mach/io.h new file +22 -0
@@ -0,0 +1,22 @@ +/* +* Copyright 2004-2007 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. +*/ + +#ifndef __MACH_MXS_IO_H__ +#define __MACH_MXS_IO_H__ + +/* Allow IO space to be anywhere in the memory */ +#define IO_SPACE_LIMIT 0xffffffff + +/* io address mapping macro */ +#define __io (a) __typesafe_io(a) + +#define __mem_pci (a) (a) + +#endif /* __MACH_MXS_IO_H__ */
arch/arm/mach-mxs/include/mach/timex.h new file +21 -0
@@ -0,0 +1,21 @@ +/* +* Copyright (C) 1999 ARM Limited +* Copyright 2004-2007 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. +*/ + +#ifndef __MACH_MXS_TIMEX_H__ +#define __MACH_MXS_TIMEX_H__ + +#define CLOCK_TICK_RATE 32000/* 32K */ + +#endif /* __MACH_MXS_TIMEX_H__ */
arch/arm/mach-mxs/include/mach/vmalloc.h new file +22 -0
@@ -0,0 +1,22 @@ +/* +* Copyright (C) 2000 Russell King. +* Copyright 2004-2007 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. +*/ + +#ifndef __MACH_MXS_VMALLOC_H__ +#define __MACH_MXS_VMALLOC_H__ + +/* vmalloc ending address */ +#define VMALLOC_END 0xf4000000UL + +#endif /* __MACH_MXS_VMALLOC_H__ */
Signature · 1 line
1.7.1
PATCH 3/15 ARM: mxs: Add reset routines
In reply to Shawn Guo* The mxs wdog is implemented in RTC block.
* There is a generic software reset routine for most modules on mxs.
--- arch/arm/mach-mxs/include/mach/system.h | 27 ++++++ arch/arm/mach-mxs/system.c | 152 +++++++++++++++++++++++++++++++ 2 files changed, 179 insertions(+), 0 deletions(-) create mode 100644 arch/arm/mach-mxs/include/mach/system.h create mode 100644 arch/arm/mach-mxs/system.c
arch/arm/mach-mxs/include/mach/system.h new file +27 -0
@@ -0,0 +1,27 @@ +/* +* Copyright (C) 1999 ARM Limited +* Copyright (C) 2000 Deep Blue Solutions Ltd +* Copyright 2004-2008 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. +*/ + +#ifndef __MACH_MXS_SYSTEM_H__ +#define __MACH_MXS_SYSTEM_H__ + +static inline void arch_idle (void ) +{ +cpu_do_idle (); +} + +void arch_reset (char mode,const char *cmd); + +#endif /* __MACH_MXS_SYSTEM_H__ */
arch/arm/mach-mxs/system.c new file +152 -0
152 lines not on this page · raw message
Signature · 1 line
1.7.1
PATCH 3/15 ARM: mxs: Add reset routines
Hi,
Shawn Guo writes:
[...]
Quoted 46 lines
arch/arm/mach-mxs/system.c new file +39
-0@@ -0,0 +1,152 @@ +/* +* Copyright (C) 1999 ARM Limited +* Copyright (C) 2000 Deep Blue Solutions Ltd +* Copyright 2006-2007,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 +* +* 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/kernel.h> +#include <linux/clk.h> +#include <linux/io.h> +#include <linux/err.h> +#include <linux/delay.h> + +#include <asm/proc-fns.h> +#include <asm/system.h> + +#include <mach/hardware.h> +#include <mach/common.h> + +#define MXS_RTC_WATCHDOG 0x50 +#define MXS_WATCHDOG_EN (1 << 4) + +#define MXS_MODULE_CLKGATE (1 << 30) +#define MXS_MODULE_SFTRST (1 << 31) + +static void __iomem *wdog_base; + +/*
arch/arm/mach-mxs/system.c line 49
Quoted 10 lines
arch/arm/mach-mxs/system.c new file +10
-0+* Reset the system. It is called by machine_restart(). +*/ +void arch_reset (char mode,const char *cmd) +{ +struct clk *clk; + + clk =clk_get_sys ("rtc" ,NULL ); +if (!IS_ERR (clk)) +clk_enable (clk); +
Since arch_reset() may be called from interrupt context (e.g. due to SYSRQ-B) it must not call any functions that may sleep like clk_get*() or clk_enable(). The clock should be acquired and enabled in the init routine.
arch/arm/mach-mxs/system.c line 72
Quoted 5 lines
arch/arm/mach-mxs/system.c new file +5
-0+void mxs_arch_reset_init (void __iomem *base) +{ + wdog_base = base; +} +
Lothar Wa?mann
Signature · 9 lines
___________________________________________________________ Ka-Ro electronics GmbH | Pascalstra?e 22 | D - 52076 Aachen Phone: +49 2408 1402-0 | Fax: +49 2408 1402-10 Gesch?ftsf?hrer: Matthias Kaussen Handelsregistereintrag: Amtsgericht Aachen, HRB 4996 www.karo-electronics.de | info at karo-electronics.de ___________________________________________________________
PATCH 3/15 ARM: mxs: Add reset routines
Hello Lothar,
Quoted 54 lines · Lothar Wa?mann
Shawn Guo writes:
[...]Quoted 52 lines
arch/arm/mach-mxs/system.c new file +46
-0@@ -0,0 +1,152 @@ +/* +* Copyright (C) 1999 ARM Limited +* Copyright (C) 2000 Deep Blue Solutions Ltd +* Copyright 2006-2007,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 +* +* 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/kernel.h> +#include <linux/clk.h> +#include <linux/io.h> +#include <linux/err.h> +#include <linux/delay.h> + +#include <asm/proc-fns.h> +#include <asm/system.h> + +#include <mach/hardware.h> +#include <mach/common.h> + +#define MXS_RTC_WATCHDOG 0x50 +#define MXS_WATCHDOG_EN (1 << 4) + +#define MXS_MODULE_CLKGATE (1 << 30) +#define MXS_MODULE_SFTRST (1 << 31) + +static void __iomem *wdog_base; + +/* +* Reset the system. It is called by machine_restart(). +*/ +void arch_reset (char mode,const char *cmd) +{ +struct clk *clk; + + clk =clk_get_sys ("rtc" ,NULL );
Quoted 8 lines
arch/arm/mach-mxs/system.c line 49
Quoted 4 lines
arch/arm/mach-mxs/system.c new file +3
-0+if (!IS_ERR (clk)) +clk_enable (clk); +Since
arch_reset()may be called from interrupt context (e.g. due to SYSRQ-B) it must not call any functions that may sleep like clk_get*() orclk_enable(). The clock should be acquired and enabled in the init routine.
This is a problem that also exist in arch/arm/plat-mxc/system.c's arch_reset.
Did you already verify that this is indeed a problem? I guess there are more architectures that use clk_get in arch_reset, aren't there?
Best regards
Uwe
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-K?nig | Industrial Linux Solutions | http://www.pengutronix.de/ |
PATCH 3/15 ARM: mxs: Add reset routines
Hi,
Quoted 63 lines · Uwe Kleine-K?nig
Quoted 54 lines · Lothar Wa?mann
Shawn Guo writes:
[...]Quoted 52 lines
arch/arm/mach-mxs/system.c new file +46
-0@@ -0,0 +1,152 @@ +/* +* Copyright (C) 1999 ARM Limited +* Copyright (C) 2000 Deep Blue Solutions Ltd +* Copyright 2006-2007,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 +* +* 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/kernel.h> +#include <linux/clk.h> +#include <linux/io.h> +#include <linux/err.h> +#include <linux/delay.h> + +#include <asm/proc-fns.h> +#include <asm/system.h> + +#include <mach/hardware.h> +#include <mach/common.h> + +#define MXS_RTC_WATCHDOG 0x50 +#define MXS_WATCHDOG_EN (1 << 4) + +#define MXS_MODULE_CLKGATE (1 << 30) +#define MXS_MODULE_SFTRST (1 << 31) + +static void __iomem *wdog_base; + +/* +* Reset the system. It is called by machine_restart(). +*/ +void arch_reset (char mode,const char *cmd) +{ +struct clk *clk; + + clk =clk_get_sys ("rtc" ,NULL );Quoted 8 lines
arch/arm/mach-mxs/system.c line 49
Quoted 4 lines
arch/arm/mach-mxs/system.c new file +3
-0+if (!IS_ERR (clk)) +clk_enable (clk); +Since
arch_reset()may be called from interrupt context (e.g. due to SYSRQ-B) it must not call any functions that may sleep like clk_get*() orclk_enable(). The clock should be acquired and enabled in the init routine.
Quoted 6 lines
This is a problem that also exist in arch/arm/plat-mxc/system.c's
arch_reset.Did you already verify that this is indeed a problem? I guess there are more architectures that use
clk_getinarch_reset, aren't there?
If you consider this a problem:
BUG: sleeping function called from invalid context at /usr/local/src/arm-linux/kernel/mutex.c:
280in_atomic(): 1, irqs_disabled(): 128, pid: 0, name: swapper
2 locks held by swapper/0:
#0: (&port_lock_key){-.-...}, at: [<c01aed10>] imx_rxint+0x24/0x20c #1: (sysrq_key_table_lock){-.....}, at: [<c01a8e14>] __handle_sysrq+0x20/0x170
irq event stamp: 130658 hardirqs last enabled at (130657): [<c0027f80>] default_idle+0x2c/0x3c hardirqs last disabled at (130658): [<c0026a74>] __irq_svc+0x34/0xa8 softirqs last enabled at (130648): [<c004bc1c>] __do_softirq+0x144/0x164 softirqs last disabled at (130637): [<c004bc9c>] irq_exit+0x60/0xb4 Backtrace: [<c002aee0>] (dump_backtrace+0x0/0x114) from [<c0260240>] (dump_stack+0x18/0x1c) r7:00000000 r6:c0326000 r5:00000000 r4:c0326000 [<c0260228>] (dump_stack+0x0/0x1c) from [<c0041930>] (__might_sleep+0x11c/0x13c) [<c0041814>] (__might_sleep+0x0/0x13c) from [<c026181c>] (mutex_lock_nested+0x34/0x31c) r4:c032afd4 [<c02617e8>] (mutex_lock_nested+0x0/0x31c) from [<c003097c>] (clk_get_sys+0x30/0xe8) [<c003094c>] (clk_get_sys+0x0/0xe8) from [<c00338c8>] (arch_reset+0x18/0x8c) [<c00338b0>] (arch_reset+0x0/0x8c) from [<c0028564>] (arm_machine_restart+0x2c/0x5c) r5:00000000 r4:00000068 [<c0028538>] (arm_machine_restart+0x0/0x5c) from [<c0027f3c>] (machine_restart+0x20/0x28) r5:d186b9c0 r4:00000062 [<c0027f1c>] (machine_restart+0x0/0x28) from [<c0056db8>] (emergency_restart+0x14/0x18) [<c0056da4>] (emergency_restart+0x0/0x18) from [<c01a9220>] (sysrq_handle_reboot+0x24/0x28) [<c01a91fc>] (sysrq_handle_reboot+0x0/0x28) from [<c01a8eb4>] (__handle_sysrq+0xc0/0x170) [<c01a8df4>] (__handle_sysrq+0x0/0x170) from [<c01a8fd4>] (handle_sysrq+0x34/0x40) [<c01a8fa0>] (handle_sysrq+0x0/0x40) from [<c01aedd8>] (imx_rxint+0xec/0x20c) [<c01aecec>] (imx_rxint+0x0/0x20c) from [<c01aef20>] (imx_int+0x28/0x68) [<c01aeef8>] (imx_int+0x0/0x68) from [<c007a794>] (handle_IRQ_event+0x2c/0x100) r7:0000002d r6:00000000 r5:00000000 r4:d1eab800 [<c007a768>] (handle_IRQ_event+0x0/0x100) from [<c007c4fc>] (handle_level_irq+0xbc/0x120) r7:d1eab800 r6:c03340b8 r5:0000002d r4:c033407c [<c007c440>] (handle_level_irq+0x0/0x120) from [<c0026070>] (_text+0x70/0x8c) r7:00000002 r6:002d0000 r5:00000000 r4:0000002d [<c0026000>] (_text+0x0/0x8c) from [<c0026a94>] (__irq_svc+0x54/0xa8) Exception stack(0xc0327f48 to 0xc0327f90)
7f40: 00000001 0016e240 20000093 20000013 c0326000 c032aaa8
7f60: c03541e4 c032aaa0 8001ecc4 41069264 8001ec90 c0327f9c c0327f68 c0327f90 7f80: c006c620 c0027f8c 20000013 ffffffff
r5:fc400000 r4:0000001f
[<c0027f54>] (default_idle+0x0/0x3c) from [<c00284dc>] (cpu_idle+0x70/0xcc) [<c002846c>] (cpu_idle+0x0/0xcc) from [<c025d338>] (rest_init+0x70/0x84)
r7:c032aaa0 r6:c0020e14 r5:c0020e18 r4:c0853ad8
[<c025d2c8>] (rest_init+0x0/0x84) from [<c00089a4>] (start_kernel+0x280/0x2d8) [<c0008724>] (start_kernel+0x0/0x2d8) from [<80008034>] (0x80008034)
r5:c0354284 r4:00053175
------------[ cut here ]------------ WARNING: at /usr/local/src/arm-linux/kernel/mutex.c:207 mutex_lock_nested+0xb4/0x31c() Modules linked in: Backtrace: [<c002aee0>] (dump_backtrace+0x0/0x114) from [<c0260240>] (dump_stack+0x18/0x1c) r7:c02e09d3 r6:000000cf r5:c026189c r4:00000000 [<c0260228>] (dump_stack+0x0/0x1c) from [<c004682c>] (warn_slowpath_common+0x50/0x68) [<c00467dc>] (warn_slowpath_common+0x0/0x68) from [<c004685c>] (warn_slowpath_null+0x18/0x1c) r7:00000000 r6:c0326000 r5:c0329868 r4:c032afd4 [<c0046844>] (warn_slowpath_null+0x0/0x1c) from [<c026189c>] (mutex_lock_nested+0xb4/0x31c) [<c02617e8>] (mutex_lock_nested+0x0/0x31c) from [<c003097c>] (clk_get_sys+0x30/0xe8) [<c003094c>] (clk_get_sys+0x0/0xe8) from [<c00338c8>] (arch_reset+0x18/0x8c) [<c00338b0>] (arch_reset+0x0/0x8c) from [<c0028564>] (arm_machine_restart+0x2c/0x5c) r5:00000000 r4:00000068 [<c0028538>] (arm_machine_restart+0x0/0x5c) from [<c0027f3c>] (machine_restart+0x20/0x28) r5:d186b9c0 r4:00000062 [<c0027f1c>] (machine_restart+0x0/0x28) from [<c0056db8>] (emergency_restart+0x14/0x18) [<c0056da4>] (emergency_restart+0x0/0x18) from [<c01a9220>] (sysrq_handle_reboot+0x24/0x28) [<c01a91fc>] (sysrq_handle_reboot+0x0/0x28) from [<c01a8eb4>] (__handle_sysrq+0xc0/0x170) [<c01a8df4>] (__handle_sysrq+0x0/0x170) from [<c01a8fd4>] (handle_sysrq+0x34/0x40) [<c01a8fa0>] (handle_sysrq+0x0/0x40) from [<c01aedd8>] (imx_rxint+0xec/0x20c) [<c01aecec>] (imx_rxint+0x0/0x20c) from [<c01aef20>] (imx_int+0x28/0x68) [<c01aeef8>] (imx_int+0x0/0x68) from [<c007a794>] (handle_IRQ_event+0x2c/0x100) r7:0000002d r6:00000000 r5:00000000 r4:d1eab800 [<c007a768>] (handle_IRQ_event+0x0/0x100) from [<c007c4fc>] (handle_level_irq+0xbc/0x120) r7:d1eab800 r6:c03340b8 r5:0000002d r4:c033407c [<c007c440>] (handle_level_irq+0x0/0x120) from [<c0026070>] (_text+0x70/0x8c) r7:00000002 r6:002d0000 r5:00000000 r4:0000002d [<c0026000>] (_text+0x0/0x8c) from [<c0026a94>] (__irq_svc+0x54/0xa8) Exception stack(0xc0327f48 to 0xc0327f90)
7f40: 00000001 0016e240 20000093 20000013 c0326000 c032aaa8
7f60: c03541e4 c032aaa0 8001ecc4 41069264 8001ec90 c0327f9c c0327f68 c0327f90 7f80: c006c620 c0027f8c 20000013 ffffffff
r5:fc400000 r4:0000001f
[<c0027f54>] (default_idle+0x0/0x3c) from [<c00284dc>] (cpu_idle+0x70/0xcc) [<c002846c>] (cpu_idle+0x0/0xcc) from [<c025d338>] (rest_init+0x70/0x84)
r7:c032aaa0 r6:c0020e14 r5:c0020e18 r4:c0853ad8
[<c025d2c8>] (rest_init+0x0/0x84) from [<c00089a4>] (start_kernel+0x280/0x2d8) [<c0008724>] (start_kernel+0x0/0x2d8) from [<80008034>] (0x80008034)
r5:c0354284 r4:00053175
---[ end trace b484fc13651ee6f1 ]---
Lothar Wa?mann
Signature · 9 lines
___________________________________________________________ Ka-Ro electronics GmbH | Pascalstra?e 22 | D - 52076 Aachen Phone: +49 2408 1402-0 | Fax: +49 2408 1402-10 Gesch?ftsf?hrer: Matthias Kaussen Handelsregistereintrag: Amtsgericht Aachen, HRB 4996 www.karo-electronics.de | info at karo-electronics.de ___________________________________________________________
PATCH 3/15 ARM: mxs: Add reset routines
Hello Lothar,
Quoted 100 lines · Lothar Wa?mann
Quoted 11 lines · Uwe Kleine-K?nig
Quoted 4 lines · Lothar Wa?mann
Since
arch_reset()may be called from interrupt context (e.g. due to SYSRQ-B) it must not call any functions that may sleep like clk_get*() orclk_enable(). The clock should be acquired and enabled in the init routine.This is a problem that also exist in arch/arm/plat-mxc/system.c's
arch_reset.Did you already verify that this is indeed a problem? I guess there are more architectures that use
clk_getinarch_reset, aren't there?If you consider this a problem:
BUG: sleeping function called from invalid context at /usr/local/src/arm-linux/kernel/mutex.c:280
in_atomic(): 1,irqs_disabled(): 128, pid: 0, name: swapper
2 locks held by swapper/0:
#0: (&port_lock_key){-.-...}, at: [<c01aed10>]imx_rxint+0x24/0x20c#1: (sysrq_key_table_lock){-.....}, at: [<c01a8e14>]__handle_sysrq+0x20/0x170irq event stamp: 130658 hardirqs last enabled at (130657): [<c0027f80>] default_idle+0x2c/0x3c hardirqs last disabled at (130658): [<c0026a74>] __irq_svc+0x34/0xa8 softirqs last enabled at (130648): [<c004bc1c>] __do_softirq+0x144/0x164 softirqs last disabled at (130637): [<c004bc9c>] irq_exit+0x60/0xb4 Backtrace: [<c002aee0>] (dump_backtrace+0x0/0x114) from [<c0260240>] (dump_stack+0x18/0x1c) r7:00000000 r6:c0326000 r5:00000000 r4:c0326000 [<c0260228>] (dump_stack+0x0/0x1c) from [<c0041930>] (__might_sleep+0x11c/0x13c) [<c0041814>] (__might_sleep+0x0/0x13c) from [<c026181c>] (mutex_lock_nested+0x34/0x31c) r4:c032afd4 [<c02617e8>] (mutex_lock_nested+0x0/0x31c) from [<c003097c>] (clk_get_sys+0x30/0xe8) [<c003094c>] (clk_get_sys+0x0/0xe8) from [<c00338c8>] (arch_reset+0x18/0x8c) [<c00338b0>] (arch_reset+0x0/0x8c) from [<c0028564>] (arm_machine_restart+0x2c/0x5c) r5:00000000 r4:00000068 [<c0028538>] (arm_machine_restart+0x0/0x5c) from [<c0027f3c>] (machine_restart+0x20/0x28) r5:d186b9c0 r4:00000062 [<c0027f1c>] (machine_restart+0x0/0x28) from [<c0056db8>] (emergency_restart+0x14/0x18) [<c0056da4>] (emergency_restart+0x0/0x18) from [<c01a9220>] (sysrq_handle_reboot+0x24/0x28) [<c01a91fc>] (sysrq_handle_reboot+0x0/0x28) from [<c01a8eb4>] (__handle_sysrq+0xc0/0x170) [<c01a8df4>] (__handle_sysrq+0x0/0x170) from [<c01a8fd4>] (handle_sysrq+0x34/0x40) [<c01a8fa0>] (handle_sysrq+0x0/0x40) from [<c01aedd8>] (imx_rxint+0xec/0x20c) [<c01aecec>] (imx_rxint+0x0/0x20c) from [<c01aef20>] (imx_int+0x28/0x68) [<c01aeef8>] (imx_int+0x0/0x68) from [<c007a794>] (handle_IRQ_event+0x2c/0x100) r7:0000002d r6:00000000 r5:00000000 r4:d1eab800 [<c007a768>] (handle_IRQ_event+0x0/0x100) from [<c007c4fc>] (handle_level_irq+0xbc/0x120) r7:d1eab800 r6:c03340b8 r5:0000002d r4:c033407c [<c007c440>] (handle_level_irq+0x0/0x120) from [<c0026070>] (_text+0x70/0x8c) r7:00000002 r6:002d0000 r5:00000000 r4:0000002d [<c0026000>] (_text+0x0/0x8c) from [<c0026a94>] (__irq_svc+0x54/0xa8) Exception stack(0xc0327f48 to 0xc0327f90)7f40: 00000001
0016e24020000093 20000013c0326000c032aaa8
7f60:c03541e4c032aaa08001ecc4410692648001ec90c0327f9cc0327f68c0327f907f80:c006c620c0027f8c20000013 ffffffff
r5:fc400000 r4:0000001f
[<c0027f54>] (default_idle+0x0/0x3c) from [<c00284dc>] (cpu_idle+0x70/0xcc) [<c002846c>] (cpu_idle+0x0/0xcc) from [<c025d338>] (rest_init+0x70/0x84)
r7:c032aaa0 r6:c0020e14 r5:c0020e18 r4:c0853ad8
[<c025d2c8>] (rest_init+0x0/0x84) from [<c00089a4>] (start_kernel+0x280/0x2d8) [<c0008724>] (start_kernel+0x0/0x2d8) from [<80008034>] (0x80008034)
r5:c0354284 r4:00053175------------[ cut here ]------------ WARNING: at /usr/local/src/arm-linux/kernel/mutex.c:207 mutex_lock_nested+0xb4/0x31c() Modules linked in: Backtrace: [<c002aee0>] (dump_backtrace+0x0/0x114) from [<c0260240>] (dump_stack+0x18/0x1c) r7:c02e09d3 r6:000000cf r5:c026189c r4:00000000 [<c0260228>] (dump_stack+0x0/0x1c) from [<c004682c>] (warn_slowpath_common+0x50/0x68) [<c00467dc>] (warn_slowpath_common+0x0/0x68) from [<c004685c>] (warn_slowpath_null+0x18/0x1c) r7:00000000 r6:c0326000 r5:c0329868 r4:c032afd4 [<c0046844>] (warn_slowpath_null+0x0/0x1c) from [<c026189c>] (mutex_lock_nested+0xb4/0x31c) [<c02617e8>] (mutex_lock_nested+0x0/0x31c) from [<c003097c>] (clk_get_sys+0x30/0xe8) [<c003094c>] (clk_get_sys+0x0/0xe8) from [<c00338c8>] (arch_reset+0x18/0x8c) [<c00338b0>] (arch_reset+0x0/0x8c) from [<c0028564>] (arm_machine_restart+0x2c/0x5c) r5:00000000 r4:00000068 [<c0028538>] (arm_machine_restart+0x0/0x5c) from [<c0027f3c>] (machine_restart+0x20/0x28) r5:d186b9c0 r4:00000062 [<c0027f1c>] (machine_restart+0x0/0x28) from [<c0056db8>] (emergency_restart+0x14/0x18) [<c0056da4>] (emergency_restart+0x0/0x18) from [<c01a9220>] (sysrq_handle_reboot+0x24/0x28) [<c01a91fc>] (sysrq_handle_reboot+0x0/0x28) from [<c01a8eb4>] (__handle_sysrq+0xc0/0x170) [<c01a8df4>] (__handle_sysrq+0x0/0x170) from [<c01a8fd4>] (handle_sysrq+0x34/0x40) [<c01a8fa0>] (handle_sysrq+0x0/0x40) from [<c01aedd8>] (imx_rxint+0xec/0x20c) [<c01aecec>] (imx_rxint+0x0/0x20c) from [<c01aef20>] (imx_int+0x28/0x68) [<c01aeef8>] (imx_int+0x0/0x68) from [<c007a794>] (handle_IRQ_event+0x2c/0x100) r7:0000002d r6:00000000 r5:00000000 r4:d1eab800 [<c007a768>] (handle_IRQ_event+0x0/0x100) from [<c007c4fc>] (handle_level_irq+0xbc/0x120) r7:d1eab800 r6:c03340b8 r5:0000002d r4:c033407c [<c007c440>] (handle_level_irq+0x0/0x120) from [<c0026070>] (_text+0x70/0x8c) r7:00000002 r6:002d0000 r5:00000000 r4:0000002d [<c0026000>] (_text+0x0/0x8c) from [<c0026a94>] (__irq_svc+0x54/0xa8) Exception stack(0xc0327f48 to 0xc0327f90)7f40: 00000001
0016e24020000093 20000013c0326000c032aaa8
7f60:c03541e4c032aaa08001ecc4410692648001ec90c0327f9cc0327f68c0327f907f80:c006c620c0027f8c20000013 ffffffff
r5:fc400000 r4:0000001f
[<c0027f54>] (default_idle+0x0/0x3c) from [<c00284dc>] (cpu_idle+0x70/0xcc) [<c002846c>] (cpu_idle+0x0/0xcc) from [<c025d338>] (rest_init+0x70/0x84)
r7:c032aaa0 r6:c0020e14 r5:c0020e18 r4:c0853ad8
[<c025d2c8>] (rest_init+0x0/0x84) from [<c00089a4>] (start_kernel+0x280/0x2d8) [<c0008724>] (start_kernel+0x0/0x2d8) from [<80008034>] (0x80008034)
r5:c0354284 r4:00053175
Quoted 1 line
---[ end trace b484fc13651ee6f1 ]---
do you care enough to send a patch? If not I can set it on my agenda.
Best regards
Uwe
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-K?nig | Industrial Linux Solutions | http://www.pengutronix.de/ |
PATCH 3/15 ARM: mxs: Add reset routines
Hi,
Quoted 104 lines · Uwe Kleine-K?nig
Hello Lothar,
Quoted 100 lines · Lothar Wa?mann
Quoted 11 lines · Uwe Kleine-K?nig
Quoted 4 lines · Lothar Wa?mann
Since
arch_reset()may be called from interrupt context (e.g. due to SYSRQ-B) it must not call any functions that may sleep like clk_get*() orclk_enable(). The clock should be acquired and enabled in the init routine.This is a problem that also exist in arch/arm/plat-mxc/system.c's
arch_reset.Did you already verify that this is indeed a problem? I guess there are more architectures that use
clk_getinarch_reset, aren't there?If you consider this a problem:
BUG: sleeping function called from invalid context at /usr/local/src/arm-linux/kernel/mutex.c:280
in_atomic(): 1,irqs_disabled(): 128, pid: 0, name: swapper
2 locks held by swapper/0:
#0: (&port_lock_key){-.-...}, at: [<c01aed10>]imx_rxint+0x24/0x20c#1: (sysrq_key_table_lock){-.....}, at: [<c01a8e14>]__handle_sysrq+0x20/0x170irq event stamp: 130658 hardirqs last enabled at (130657): [<c0027f80>] default_idle+0x2c/0x3c hardirqs last disabled at (130658): [<c0026a74>] __irq_svc+0x34/0xa8 softirqs last enabled at (130648): [<c004bc1c>] __do_softirq+0x144/0x164 softirqs last disabled at (130637): [<c004bc9c>] irq_exit+0x60/0xb4 Backtrace: [<c002aee0>] (dump_backtrace+0x0/0x114) from [<c0260240>] (dump_stack+0x18/0x1c) r7:00000000 r6:c0326000 r5:00000000 r4:c0326000 [<c0260228>] (dump_stack+0x0/0x1c) from [<c0041930>] (__might_sleep+0x11c/0x13c) [<c0041814>] (__might_sleep+0x0/0x13c) from [<c026181c>] (mutex_lock_nested+0x34/0x31c) r4:c032afd4 [<c02617e8>] (mutex_lock_nested+0x0/0x31c) from [<c003097c>] (clk_get_sys+0x30/0xe8) [<c003094c>] (clk_get_sys+0x0/0xe8) from [<c00338c8>] (arch_reset+0x18/0x8c) [<c00338b0>] (arch_reset+0x0/0x8c) from [<c0028564>] (arm_machine_restart+0x2c/0x5c) r5:00000000 r4:00000068 [<c0028538>] (arm_machine_restart+0x0/0x5c) from [<c0027f3c>] (machine_restart+0x20/0x28) r5:d186b9c0 r4:00000062 [<c0027f1c>] (machine_restart+0x0/0x28) from [<c0056db8>] (emergency_restart+0x14/0x18) [<c0056da4>] (emergency_restart+0x0/0x18) from [<c01a9220>] (sysrq_handle_reboot+0x24/0x28) [<c01a91fc>] (sysrq_handle_reboot+0x0/0x28) from [<c01a8eb4>] (__handle_sysrq+0xc0/0x170) [<c01a8df4>] (__handle_sysrq+0x0/0x170) from [<c01a8fd4>] (handle_sysrq+0x34/0x40) [<c01a8fa0>] (handle_sysrq+0x0/0x40) from [<c01aedd8>] (imx_rxint+0xec/0x20c) [<c01aecec>] (imx_rxint+0x0/0x20c) from [<c01aef20>] (imx_int+0x28/0x68) [<c01aeef8>] (imx_int+0x0/0x68) from [<c007a794>] (handle_IRQ_event+0x2c/0x100) r7:0000002d r6:00000000 r5:00000000 r4:d1eab800 [<c007a768>] (handle_IRQ_event+0x0/0x100) from [<c007c4fc>] (handle_level_irq+0xbc/0x120) r7:d1eab800 r6:c03340b8 r5:0000002d r4:c033407c [<c007c440>] (handle_level_irq+0x0/0x120) from [<c0026070>] (_text+0x70/0x8c) r7:00000002 r6:002d0000 r5:00000000 r4:0000002d [<c0026000>] (_text+0x0/0x8c) from [<c0026a94>] (__irq_svc+0x54/0xa8) Exception stack(0xc0327f48 to 0xc0327f90)7f40: 00000001
0016e24020000093 20000013c0326000c032aaa8
7f60:c03541e4c032aaa08001ecc4410692648001ec90c0327f9cc0327f68c0327f907f80:c006c620c0027f8c20000013 ffffffff
r5:fc400000 r4:0000001f
[<c0027f54>] (default_idle+0x0/0x3c) from [<c00284dc>] (cpu_idle+0x70/0xcc) [<c002846c>] (cpu_idle+0x0/0xcc) from [<c025d338>] (rest_init+0x70/0x84)
r7:c032aaa0 r6:c0020e14 r5:c0020e18 r4:c0853ad8
[<c025d2c8>] (rest_init+0x0/0x84) from [<c00089a4>] (start_kernel+0x280/0x2d8) [<c0008724>] (start_kernel+0x0/0x2d8) from [<80008034>] (0x80008034)
r5:c0354284 r4:00053175------------[ cut here ]------------ WARNING: at /usr/local/src/arm-linux/kernel/mutex.c:207 mutex_lock_nested+0xb4/0x31c() Modules linked in: Backtrace: [<c002aee0>] (dump_backtrace+0x0/0x114) from [<c0260240>] (dump_stack+0x18/0x1c) r7:c02e09d3 r6:000000cf r5:c026189c r4:00000000 [<c0260228>] (dump_stack+0x0/0x1c) from [<c004682c>] (warn_slowpath_common+0x50/0x68) [<c00467dc>] (warn_slowpath_common+0x0/0x68) from [<c004685c>] (warn_slowpath_null+0x18/0x1c) r7:00000000 r6:c0326000 r5:c0329868 r4:c032afd4 [<c0046844>] (warn_slowpath_null+0x0/0x1c) from [<c026189c>] (mutex_lock_nested+0xb4/0x31c) [<c02617e8>] (mutex_lock_nested+0x0/0x31c) from [<c003097c>] (clk_get_sys+0x30/0xe8) [<c003094c>] (clk_get_sys+0x0/0xe8) from [<c00338c8>] (arch_reset+0x18/0x8c) [<c00338b0>] (arch_reset+0x0/0x8c) from [<c0028564>] (arm_machine_restart+0x2c/0x5c) r5:00000000 r4:00000068 [<c0028538>] (arm_machine_restart+0x0/0x5c) from [<c0027f3c>] (machine_restart+0x20/0x28) r5:d186b9c0 r4:00000062 [<c0027f1c>] (machine_restart+0x0/0x28) from [<c0056db8>] (emergency_restart+0x14/0x18) [<c0056da4>] (emergency_restart+0x0/0x18) from [<c01a9220>] (sysrq_handle_reboot+0x24/0x28) [<c01a91fc>] (sysrq_handle_reboot+0x0/0x28) from [<c01a8eb4>] (__handle_sysrq+0xc0/0x170) [<c01a8df4>] (__handle_sysrq+0x0/0x170) from [<c01a8fd4>] (handle_sysrq+0x34/0x40) [<c01a8fa0>] (handle_sysrq+0x0/0x40) from [<c01aedd8>] (imx_rxint+0xec/0x20c) [<c01aecec>] (imx_rxint+0x0/0x20c) from [<c01aef20>] (imx_int+0x28/0x68) [<c01aeef8>] (imx_int+0x0/0x68) from [<c007a794>] (handle_IRQ_event+0x2c/0x100) r7:0000002d r6:00000000 r5:00000000 r4:d1eab800 [<c007a768>] (handle_IRQ_event+0x0/0x100) from [<c007c4fc>] (handle_level_irq+0xbc/0x120) r7:d1eab800 r6:c03340b8 r5:0000002d r4:c033407c [<c007c440>] (handle_level_irq+0x0/0x120) from [<c0026070>] (_text+0x70/0x8c) r7:00000002 r6:002d0000 r5:00000000 r4:0000002d [<c0026000>] (_text+0x0/0x8c) from [<c0026a94>] (__irq_svc+0x54/0xa8) Exception stack(0xc0327f48 to 0xc0327f90)7f40: 00000001
0016e24020000093 20000013c0326000c032aaa8
7f60:c03541e4c032aaa08001ecc4410692648001ec90c0327f9cc0327f68c0327f907f80:c006c620c0027f8c20000013 ffffffff
r5:fc400000 r4:0000001f
[<c0027f54>] (default_idle+0x0/0x3c) from [<c00284dc>] (cpu_idle+0x70/0xcc) [<c002846c>] (cpu_idle+0x0/0xcc) from [<c025d338>] (rest_init+0x70/0x84)
r7:c032aaa0 r6:c0020e14 r5:c0020e18 r4:c0853ad8
[<c025d2c8>] (rest_init+0x0/0x84) from [<c00089a4>] (start_kernel+0x280/0x2d8) [<c0008724>] (start_kernel+0x0/0x2d8) from [<80008034>] (0x80008034)
r5:c0354284 r4:00053175Quoted 1 line
---[ end trace b484fc13651ee6f1 ]---
Quoted 2 lines
do you care enough to send a patch? If not I can set it on my agenda.
I have it on my to-do list for quite some time. I'll finally try to get it out soon.
Lothar Wa?mann
Signature · 9 lines
___________________________________________________________ Ka-Ro electronics GmbH | Pascalstra?e 22 | D - 52076 Aachen Phone: +49 2408 1402-0 | Fax: +49 2408 1402-10 Gesch?ftsf?hrer: Matthias Kaussen Handelsregistereintrag: Amtsgericht Aachen, HRB 4996 www.karo-electronics.de | info at karo-electronics.de ___________________________________________________________
PATCH 1/1 prevent 'BUG: sleeping function called from invalid context' in arch_reset()
In reply to Uwe Kleine-Königarch_reset() may be called from interrupt context (e.g. induced by SYSRQ-B), thus clk_get() and clk_enable() must not be called from within arch_reset(). Move these calls to mxc_arch_reset_init().
---
arch/arm/plat-mxc/system.c +9 -5
@@ -53,11 +53,6 @@ void arch_reset(char mode, const char *cmd)if (cpu_is_mx1 ()) { wcr_enable = (1 <<0 ); }else { -struct clk *clk; - - clk =clk_get_sys ("imx-wdt.0" ,NULL ); -if (!IS_ERR (clk)) -clk_enable (clk); wcr_enable = (1 <<2 ); }
@@ -78,5 +73,14 @@ void arch_reset(char mode, const char *cmd)void mxc_arch_reset_init (void __iomem *base) { +struct clk *clk; + wdog_base = base; + +if (cpu_is_mx1 ()) +return ; + + clk =clk_get_sys ("imx-wdt.0" ,NULL ); +if (!IS_ERR (clk)) +clk_enable (clk); }
Lothar Wa?mann
Signature · 9 lines
___________________________________________________________ Ka-Ro electronics GmbH | Pascalstra?e 22 | D - 52076 Aachen Phone: +49 2408 1402-0 | Fax: +49 2408 1402-10 Gesch?ftsf?hrer: Matthias Kaussen Handelsregistereintrag: Amtsgericht Aachen, HRB 4996 www.karo-electronics.de | [email protected] ___________________________________________________________
PATCH 1/1 prevent 'BUG: sleeping function called from invalid context' in arch_reset()
Hello Lothar,
Quoted 3 lines · Lothar Wa?mann
arch_reset()may be called from interrupt context (e.g. induced by SYSRQ-B), thusclk_get()andclk_enable()must not be called from withinarch_reset(). Move these calls tomxc_arch_reset_init().
I wonder if SYSRQ-B is the only way to trigger that. And if yes if that could be "fixed" to allow sleeping?!
Quoted 23 lines
Signed-off-by Lothar Wa?mann <[email protected]>---
arch/arm/plat-mxc/system.c +1
-5@@ -53,11 +53,6 @@ void arch_reset(char mode, const char *cmd)if (cpu_is_mx1 ()) { wcr_enable = (1 <<0 ); }else { -struct clk *clk; - - clk =clk_get_sys ("imx-wdt.0" ,NULL ); -if (!IS_ERR (clk)) -clk_enable (clk); wcr_enable = (1 <<2 ); }@@ -78,5 +73,14 @@ void arch_reset(char mode, const char *cmd)void mxc_arch_reset_init (void __iomem *base) { +struct clk *clk;
arch/arm/plat-mxc/system.c void arch_reset(char mode, const char *cmd) · line 86
Quoted 10 lines
arch/arm/plat-mxc/system.c +8
-0+ wdog_base = base; + +if (cpu_is_mx1 ()) +return ; + + clk =clk_get_sys ("imx-wdt.0" ,NULL ); +if (!IS_ERR (clk)) +clk_enable (clk); }
Unrelated to this patch, I wonder why this isn't named "imx2-wdt.0". I just checked, the driver (drivers/watchdog/imx2_wdt.c) uses clk_get_sys, too. IMHO we should rename that.
Best regards
Uwe
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-K?nig | Industrial Linux Solutions | http://www.pengutronix.de/ |
PATCH 1/1 prevent 'BUG: sleeping function called from invalid context' in arch_reset()
[extended the audience, some context: arch/arm/plat-mxc currently uses a clk_enable in arch_reset which might sleep]
Quoted 8 lines · Uwe Kleine-K?nig
Hello Lothar,
Quoted 3 lines · Lothar Wa?mann
arch_reset()may be called from interrupt context (e.g. induced by SYSRQ-B), thusclk_get()andclk_enable()must not be called from withinarch_reset(). Move these calls tomxc_arch_reset_init().I wonder if SYSRQ-B is the only way to trigger that. And if yes if that could be "fixed" to allow sleeping?!
Hmmm, the comment for emergency_restart() says:
/**
* emergency_restart - reboot the system
*
* Without shutting down any hardware or taking any locks * reboot the system. This is called when we know we are in * trouble so this is our best effort to reboot. This is * safe to call in interrupt context.
*/
emergency_restart has several callers apart from sysrq (watchdog, ocfs2, kdb, panic), so I think allowing to sleep isn't that easy.
Moreover the sysrq function is called with the uart port's lock hold, that would need fixing in the serial driver. I found the same problem in amba-pl011 (the only driver I checked), so this seems to be a big task. Sysrq holds a lock, too, while calling the handler.
I still think it's wrong to enable the watchdog clock unconditionally during boot and wonder if that sleep in atomic can just be ignored?!
Uwe
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-K?nig | Industrial Linux Solutions | http://www.pengutronix.de/ |
PATCH 3/15 ARM: mxs: Add reset routines
In reply to Lothar WaßmannHi Lothar
2010/11/26 Lothar Wa?mann <[email protected]>:
Quoted 160 lines
Hi,
Quoted 63 lines · Uwe Kleine-K?nig
Quoted 54 lines · Lothar Wa?mann
Shawn Guo writes:
[...]Quoted 52 lines
arch/arm/mach-mxs/system.c new file +46
-0@@ -0,0 +1,152 @@ +/* +* Copyright (C) 1999 ARM Limited +* Copyright (C) 2000 Deep Blue Solutions Ltd +* Copyright 2006-2007,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 +* +* 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/kernel.h> +#include <linux/clk.h> +#include <linux/io.h> +#include <linux/err.h> +#include <linux/delay.h> + +#include <asm/proc-fns.h> +#include <asm/system.h> + +#include <mach/hardware.h> +#include <mach/common.h> + +#define MXS_RTC_WATCHDOG 0x50 +#define MXS_WATCHDOG_EN ? ? ? ? ?(1 << 4) + +#define MXS_MODULE_CLKGATE ? ? ? (1 << 30) +#define MXS_MODULE_SFTRST ? ? ? ?(1 << 31) + +static void __iomem *wdog_base; + +/* +* Reset the system. It is called by machine_restart(). +*/ +void arch_reset (char mode,const char *cmd) +{ +struct clk *clk; + + clk =clk_get_sys ("rtc" ,NULL );Quoted 8 lines
arch/arm/mach-mxs/system.c line 49
Quoted 4 lines
arch/arm/mach-mxs/system.c new file +3
-0+if (!IS_ERR (clk)) + ? ? ? ? clk_enable(clk); +Since
arch_reset()may be called from interrupt context (e.g. due to SYSRQ-B) it must not call any functions that may sleep like clk_get*() orclk_enable(). The clock should be acquired and enabled in the init routine.Quoted 6 lines
This is a problem that also exist in arch/arm/plat-mxc/system.c's
arch_reset.Did you already verify that this is indeed a problem? ?I guess there are more architectures that use
clk_getinarch_reset, aren't there?If you consider this a problem:
BUG: sleeping function called from invalid context at /usr/local/src/arm-linux/kernel/mutex.c:280
in_atomic(): 1,irqs_disabled(): 128, pid: 0, name: swapper
2 locks held by swapper/0:
?#0: ?(&port_lock_key){-.-...}, at: [<c01aed10>]imx_rxint+0x24/0x20c?#1: ?(sysrq_key_table_lock){-.....}, at: [<c01a8e14>]__handle_sysrq+0x20/0x170irq event stamp: 130658 hardirqs last ?enabled at (130657): [<c0027f80>] default_idle+0x2c/0x3c hardirqs last disabled at (130658): [<c0026a74>] __irq_svc+0x34/0xa8 softirqs last ?enabled at (130648): [<c004bc1c>] __do_softirq+0x144/0x164 softirqs last disabled at (130637): [<c004bc9c>] irq_exit+0x60/0xb4 Backtrace: [<c002aee0>] (dump_backtrace+0x0/0x114) from [<c0260240>] (dump_stack+0x18/0x1c) ?r7:00000000 r6:c0326000 r5:00000000 r4:c0326000 [<c0260228>] (dump_stack+0x0/0x1c) from [<c0041930>] (__might_sleep+0x11c/0x13c) [<c0041814>] (__might_sleep+0x0/0x13c) from [<c026181c>] (mutex_lock_nested+0x34/0x31c)?r4:c032afd4
[<c02617e8>] (mutex_lock_nested+0x0/0x31c) from [<c003097c>] (clk_get_sys+0x30/0xe8) [<c003094c>] (clk_get_sys+0x0/0xe8) from [<c00338c8>] (arch_reset+0x18/0x8c) [<c00338b0>] (arch_reset+0x0/0x8c) from [<c0028564>] (arm_machine_restart+0x2c/0x5c) ?r5:00000000 r4:00000068
[<c0028538>] (arm_machine_restart+0x0/0x5c) from [<c0027f3c>] (machine_restart+0x20/0x28) ?r5:d186b9c0 r4:00000062
[<c0027f1c>] (machine_restart+0x0/0x28) from [<c0056db8>] (emergency_restart+0x14/0x18) [<c0056da4>] (emergency_restart+0x0/0x18) from [<c01a9220>] (sysrq_handle_reboot+0x24/0x28) [<c01a91fc>] (sysrq_handle_reboot+0x0/0x28) from [<c01a8eb4>] (__handle_sysrq+0xc0/0x170) [<c01a8df4>] (__handle_sysrq+0x0/0x170) from [<c01a8fd4>] (handle_sysrq+0x34/0x40) [<c01a8fa0>] (handle_sysrq+0x0/0x40) from [<c01aedd8>] (imx_rxint+0xec/0x20c) [<c01aecec>] (imx_rxint+0x0/0x20c) from [<c01aef20>] (imx_int+0x28/0x68) [<c01aeef8>] (imx_int+0x0/0x68) from [<c007a794>] (handle_IRQ_event+0x2c/0x100) ?r7:0000002d r6:00000000 r5:00000000 r4:d1eab800
[<c007a768>] (handle_IRQ_event+0x0/0x100) from [<c007c4fc>] (handle_level_irq+0xbc/0x120) ?r7:d1eab800 r6:c03340b8 r5:0000002d r4:c033407c
[<c007c440>] (handle_level_irq+0x0/0x120) from [<c0026070>] (_text+0x70/0x8c) ?r7:00000002 r6:002d0000 r5:00000000 r4:0000002d
[<c0026000>] (_text+0x0/0x8c) from [<c0026a94>] (__irq_svc+0x54/0xa8)Exception stack(0xc0327f48 to 0xc0327f90)7f40: ? ? ? ? ? ? ? ? ? 00000001
0016e24020000093 20000013c0326000c032aaa87f60:c03541e4c032aaa08001ecc4410692648001ec90c0327f9cc0327f68c0327f907f80:c006c620c0027f8c20000013 ffffffff
?r5:fc400000 r4:0000001f
[<c0027f54>] (default_idle+0x0/0x3c) from [<c00284dc>] (cpu_idle+0x70/0xcc) [<c002846c>] (cpu_idle+0x0/0xcc) from [<c025d338>] (rest_init+0x70/0x84) ?r7:c032aaa0 r6:c0020e14 r5:c0020e18 r4:c0853ad8
[<c025d2c8>] (rest_init+0x0/0x84) from [<c00089a4>] (start_kernel+0x280/0x2d8) [<c0008724>] (start_kernel+0x0/0x2d8) from [<80008034>] (0x80008034) ?r5:c0354284 r4:00053175------------[ cut here ]------------ WARNING: at /usr/local/src/arm-linux/kernel/mutex.c:207 mutex_lock_nested+0xb4/0x31c() Modules linked in: Backtrace: [<c002aee0>] (dump_backtrace+0x0/0x114) from [<c0260240>] (dump_stack+0x18/0x1c) ?r7:c02e09d3 r6:000000cf r5:c026189c r4:00000000 [<c0260228>] (dump_stack+0x0/0x1c) from [<c004682c>] (warn_slowpath_common+0x50/0x68) [<c00467dc>] (warn_slowpath_common+0x0/0x68) from [<c004685c>] (warn_slowpath_null+0x18/0x1c) ?r7:00000000 r6:c0326000 r5:c0329868 r4:c032afd4 [<c0046844>] (warn_slowpath_null+0x0/0x1c) from [<c026189c>] (mutex_lock_nested+0xb4/0x31c) [<c02617e8>] (mutex_lock_nested+0x0/0x31c) from [<c003097c>] (clk_get_sys+0x30/0xe8) [<c003094c>] (clk_get_sys+0x0/0xe8) from [<c00338c8>] (arch_reset+0x18/0x8c) [<c00338b0>] (arch_reset+0x0/0x8c) from [<c0028564>] (arm_machine_restart+0x2c/0x5c)?r5:00000000 r4:00000068
[<c0028538>] (arm_machine_restart+0x0/0x5c) from [<c0027f3c>] (machine_restart+0x20/0x28) ?r5:d186b9c0 r4:00000062
[<c0027f1c>] (machine_restart+0x0/0x28) from [<c0056db8>] (emergency_restart+0x14/0x18) [<c0056da4>] (emergency_restart+0x0/0x18) from [<c01a9220>] (sysrq_handle_reboot+0x24/0x28) [<c01a91fc>] (sysrq_handle_reboot+0x0/0x28) from [<c01a8eb4>] (__handle_sysrq+0xc0/0x170) [<c01a8df4>] (__handle_sysrq+0x0/0x170) from [<c01a8fd4>] (handle_sysrq+0x34/0x40) [<c01a8fa0>] (handle_sysrq+0x0/0x40) from [<c01aedd8>] (imx_rxint+0xec/0x20c) [<c01aecec>] (imx_rxint+0x0/0x20c) from [<c01aef20>] (imx_int+0x28/0x68) [<c01aeef8>] (imx_int+0x0/0x68) from [<c007a794>] (handle_IRQ_event+0x2c/0x100) ?r7:0000002d r6:00000000 r5:00000000 r4:d1eab800
[<c007a768>] (handle_IRQ_event+0x0/0x100) from [<c007c4fc>] (handle_level_irq+0xbc/0x120) ?r7:d1eab800 r6:c03340b8 r5:0000002d r4:c033407c
[<c007c440>] (handle_level_irq+0x0/0x120) from [<c0026070>] (_text+0x70/0x8c) ?r7:00000002 r6:002d0000 r5:00000000 r4:0000002d
[<c0026000>] (_text+0x0/0x8c) from [<c0026a94>] (__irq_svc+0x54/0xa8)Exception stack(0xc0327f48 to 0xc0327f90)7f40: ? ? ? ? ? ? ? ? ? 00000001
0016e24020000093 20000013c0326000c032aaa87f60:c03541e4c032aaa08001ecc4410692648001ec90c0327f9cc0327f68c0327f907f80:c006c620c0027f8c20000013 ffffffff
?r5:fc400000 r4:0000001f
[<c0027f54>] (default_idle+0x0/0x3c) from [<c00284dc>] (cpu_idle+0x70/0xcc) [<c002846c>] (cpu_idle+0x0/0xcc) from [<c025d338>] (rest_init+0x70/0x84) ?r7:c032aaa0 r6:c0020e14 r5:c0020e18 r4:c0853ad8
[<c025d2c8>] (rest_init+0x0/0x84) from [<c00089a4>] (start_kernel+0x280/0x2d8) [<c0008724>] (start_kernel+0x0/0x2d8) from [<80008034>] (0x80008034) ?r5:c0354284 r4:00053175
Quoted 1 line
---[ end trace b484fc13651ee6f1 ]---
could we use spin_lock but not mutex_lock in the clk_enable/disable? I'm considering there may have drivers call clk enable/disable in the irq context to done feature or save power.
Signature · 3 lines
Best Regards Xinyu Chen Freescale Semiconductor, MAD Linux
PATCH 3/15 ARM: mxs: Add reset routines
Hi,
Quoted 93 lines · Xinyu Chen
Hi Lothar
2010/11/26 Lothar Wa?mann <[email protected]>:
Quoted 88 lines
If you consider this a problem:
BUG: sleeping function called from invalid context at /usr/local/src/arm-linux/kernel/mutex.c:280
in_atomic(): 1,irqs_disabled(): 128, pid: 0, name: swapper
2 locks held by swapper/0:
?#0: ?(&port_lock_key){-.-...}, at: [<c01aed10>]imx_rxint+0x24/0x20c?#1: ?(sysrq_key_table_lock){-.....}, at: [<c01a8e14>]__handle_sysrq+0x20/0x170irq event stamp: 130658 hardirqs last ?enabled at (130657): [<c0027f80>] default_idle+0x2c/0x3c hardirqs last disabled at (130658): [<c0026a74>] __irq_svc+0x34/0xa8 softirqs last ?enabled at (130648): [<c004bc1c>] __do_softirq+0x144/0x164 softirqs last disabled at (130637): [<c004bc9c>] irq_exit+0x60/0xb4 Backtrace: [<c002aee0>] (dump_backtrace+0x0/0x114) from [<c0260240>] (dump_stack+0x18/0x1c) ?r7:00000000 r6:c0326000 r5:00000000 r4:c0326000 [<c0260228>] (dump_stack+0x0/0x1c) from [<c0041930>] (__might_sleep+0x11c/0x13c) [<c0041814>] (__might_sleep+0x0/0x13c) from [<c026181c>] (mutex_lock_nested+0x34/0x31c)?r4:c032afd4
[<c02617e8>] (mutex_lock_nested+0x0/0x31c) from [<c003097c>] (clk_get_sys+0x30/0xe8) [<c003094c>] (clk_get_sys+0x0/0xe8) from [<c00338c8>] (arch_reset+0x18/0x8c) [<c00338b0>] (arch_reset+0x0/0x8c) from [<c0028564>] (arm_machine_restart+0x2c/0x5c) ?r5:00000000 r4:00000068
[<c0028538>] (arm_machine_restart+0x0/0x5c) from [<c0027f3c>] (machine_restart+0x20/0x28) ?r5:d186b9c0 r4:00000062
[<c0027f1c>] (machine_restart+0x0/0x28) from [<c0056db8>] (emergency_restart+0x14/0x18) [<c0056da4>] (emergency_restart+0x0/0x18) from [<c01a9220>] (sysrq_handle_reboot+0x24/0x28) [<c01a91fc>] (sysrq_handle_reboot+0x0/0x28) from [<c01a8eb4>] (__handle_sysrq+0xc0/0x170) [<c01a8df4>] (__handle_sysrq+0x0/0x170) from [<c01a8fd4>] (handle_sysrq+0x34/0x40) [<c01a8fa0>] (handle_sysrq+0x0/0x40) from [<c01aedd8>] (imx_rxint+0xec/0x20c) [<c01aecec>] (imx_rxint+0x0/0x20c) from [<c01aef20>] (imx_int+0x28/0x68) [<c01aeef8>] (imx_int+0x0/0x68) from [<c007a794>] (handle_IRQ_event+0x2c/0x100) ?r7:0000002d r6:00000000 r5:00000000 r4:d1eab800
[<c007a768>] (handle_IRQ_event+0x0/0x100) from [<c007c4fc>] (handle_level_irq+0xbc/0x120) ?r7:d1eab800 r6:c03340b8 r5:0000002d r4:c033407c
[<c007c440>] (handle_level_irq+0x0/0x120) from [<c0026070>] (_text+0x70/0x8c) ?r7:00000002 r6:002d0000 r5:00000000 r4:0000002d
[<c0026000>] (_text+0x0/0x8c) from [<c0026a94>] (__irq_svc+0x54/0xa8)Exception stack(0xc0327f48 to 0xc0327f90)7f40: ? ? ? ? ? ? ? ? ? 00000001
0016e24020000093 20000013c0326000c032aaa87f60:c03541e4c032aaa08001ecc4410692648001ec90c0327f9cc0327f68c0327f907f80:c006c620c0027f8c20000013 ffffffff
?r5:fc400000 r4:0000001f
[<c0027f54>] (default_idle+0x0/0x3c) from [<c00284dc>] (cpu_idle+0x70/0xcc) [<c002846c>] (cpu_idle+0x0/0xcc) from [<c025d338>] (rest_init+0x70/0x84) ?r7:c032aaa0 r6:c0020e14 r5:c0020e18 r4:c0853ad8
[<c025d2c8>] (rest_init+0x0/0x84) from [<c00089a4>] (start_kernel+0x280/0x2d8) [<c0008724>] (start_kernel+0x0/0x2d8) from [<80008034>] (0x80008034) ?r5:c0354284 r4:00053175------------[ cut here ]------------ WARNING: at /usr/local/src/arm-linux/kernel/mutex.c:207 mutex_lock_nested+0xb4/0x31c() Modules linked in: Backtrace: [<c002aee0>] (dump_backtrace+0x0/0x114) from [<c0260240>] (dump_stack+0x18/0x1c) ?r7:c02e09d3 r6:000000cf r5:c026189c r4:00000000 [<c0260228>] (dump_stack+0x0/0x1c) from [<c004682c>] (warn_slowpath_common+0x50/0x68) [<c00467dc>] (warn_slowpath_common+0x0/0x68) from [<c004685c>] (warn_slowpath_null+0x18/0x1c) ?r7:00000000 r6:c0326000 r5:c0329868 r4:c032afd4 [<c0046844>] (warn_slowpath_null+0x0/0x1c) from [<c026189c>] (mutex_lock_nested+0xb4/0x31c) [<c02617e8>] (mutex_lock_nested+0x0/0x31c) from [<c003097c>] (clk_get_sys+0x30/0xe8) [<c003094c>] (clk_get_sys+0x0/0xe8) from [<c00338c8>] (arch_reset+0x18/0x8c) [<c00338b0>] (arch_reset+0x0/0x8c) from [<c0028564>] (arm_machine_restart+0x2c/0x5c)?r5:00000000 r4:00000068
[<c0028538>] (arm_machine_restart+0x0/0x5c) from [<c0027f3c>] (machine_restart+0x20/0x28) ?r5:d186b9c0 r4:00000062
[<c0027f1c>] (machine_restart+0x0/0x28) from [<c0056db8>] (emergency_restart+0x14/0x18) [<c0056da4>] (emergency_restart+0x0/0x18) from [<c01a9220>] (sysrq_handle_reboot+0x24/0x28) [<c01a91fc>] (sysrq_handle_reboot+0x0/0x28) from [<c01a8eb4>] (__handle_sysrq+0xc0/0x170) [<c01a8df4>] (__handle_sysrq+0x0/0x170) from [<c01a8fd4>] (handle_sysrq+0x34/0x40) [<c01a8fa0>] (handle_sysrq+0x0/0x40) from [<c01aedd8>] (imx_rxint+0xec/0x20c) [<c01aecec>] (imx_rxint+0x0/0x20c) from [<c01aef20>] (imx_int+0x28/0x68) [<c01aeef8>] (imx_int+0x0/0x68) from [<c007a794>] (handle_IRQ_event+0x2c/0x100) ?r7:0000002d r6:00000000 r5:00000000 r4:d1eab800
[<c007a768>] (handle_IRQ_event+0x0/0x100) from [<c007c4fc>] (handle_level_irq+0xbc/0x120) ?r7:d1eab800 r6:c03340b8 r5:0000002d r4:c033407c
[<c007c440>] (handle_level_irq+0x0/0x120) from [<c0026070>] (_text+0x70/0x8c) ?r7:00000002 r6:002d0000 r5:00000000 r4:0000002d
[<c0026000>] (_text+0x0/0x8c) from [<c0026a94>] (__irq_svc+0x54/0xa8)Exception stack(0xc0327f48 to 0xc0327f90)7f40: ? ? ? ? ? ? ? ? ? 00000001
0016e24020000093 20000013c0326000c032aaa87f60:c03541e4c032aaa08001ecc4410692648001ec90c0327f9cc0327f68c0327f907f80:c006c620c0027f8c20000013 ffffffff
?r5:fc400000 r4:0000001f
[<c0027f54>] (default_idle+0x0/0x3c) from [<c00284dc>] (cpu_idle+0x70/0xcc) [<c002846c>] (cpu_idle+0x0/0xcc) from [<c025d338>] (rest_init+0x70/0x84) ?r7:c032aaa0 r6:c0020e14 r5:c0020e18 r4:c0853ad8
[<c025d2c8>] (rest_init+0x0/0x84) from [<c00089a4>] (start_kernel+0x280/0x2d8) [<c0008724>] (start_kernel+0x0/0x2d8) from [<80008034>] (0x80008034) ?r5:c0354284 r4:00053175Quoted 1 line
---[ end trace b484fc13651ee6f1 ]---
Quoted 4 lines
could we use
spin_lockbut notmutex_lockin the clk_enable/disable? I'm considering there may have drivers call clk enable/disable in the irq context to done feature or save power.
This has already been discussed in June this year and rejected:
http://lists.infradead.org/pipermail/linux-arm-kernel/2010-June/017758.html
Anyway the offending code in this case is the clk_get_sys() function.
Lothar Wa?mann
Signature · 9 lines
___________________________________________________________ Ka-Ro electronics GmbH | Pascalstra?e 22 | D - 52076 Aachen Phone: +49 2408 1402-0 | Fax: +49 2408 1402-10 Gesch?ftsf?hrer: Matthias Kaussen Handelsregistereintrag: Amtsgericht Aachen, HRB 4996 www.karo-electronics.de | info at karo-electronics.de ___________________________________________________________
PATCH 4/15 ARM: mxs: Add interrupt support
In reply to Shawn GuoAdd Interrupt Collector (ICOLL) support for MXS-based.
--- arch/arm/mach-mxs/icoll.c | 77 ++++++++++++++++++++++++++ arch/arm/mach-mxs/include/mach/entry-macro.S | 36 ++++++++++++ 2 files changed, 113 insertions(+), 0 deletions(-) create mode 100644 arch/arm/mach-mxs/icoll.c create mode 100644 arch/arm/mach-mxs/include/mach/entry-macro.S
arch/arm/mach-mxs/icoll.c new file +77 -0
@@ -0,0 +1,77 @@ +/* +* 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 mxs_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; + +/* Reset icoll */ +mxs_reset_block (irqbase +HW_ICOLL_CTRL ); + +for (i =0 ; i <MXS_INTERNAL_IRQS ; i++) { +set_irq_chip (i, &mxs_icoll_chip); +set_irq_handler (i, handle_level_irq); +set_irq_flags (i,IRQF_VALID ); + } +}
arch/arm/mach-mxs/include/mach/entry-macro.S new file +36 -0
@@ -0,0 +1,36 @@ +/* + * Low-level IRQ helper macros for Freescale MXS-based + * + * 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. + */ + + .macro disable_fiq + .endm + + .macro get_irqnr_and_base, irqnr, irqstat, base, tmp + ldr \base, =icoll_base + ldr \base, [\base] + ldr \irqnr, [\base, #0x70] + cmp \irqnr, #0x7F + moveqs \irqnr, #0 + .endm + + .macro get_irqnr_preamble, base, tmp + .endm + + .macro arch_ret_to_user, tmp1, tmp2 + .endm
Signature · 1 line
1.7.1
PATCH 4/15 ARM: mxs: Add interrupt support
Hello Shawn,
Quoted 44 lines · Shawn Guo
Add Interrupt Collector (ICOLL) support for MXS-based.
Signed-off-by Shawn Guo <[email protected]>--- arch/arm/mach-mxs/icoll.c | 77 ++++++++++++++++++++++++++ arch/arm/mach-mxs/include/mach/entry-macro.S | 36 ++++++++++++ 2 files changed, 113 insertions(+), 0 deletions(-) create mode 100644 arch/arm/mach-mxs/icoll.c create mode 100644 arch/arm/mach-mxs/include/mach/entry-macro.Sarch/arm/mach-mxs/icoll.c new file +28
-0@@ -0,0 +1,77 @@ +/* +* 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
arch/arm/mach-mxs/icoll.c line 38
Quoted 10 lines
arch/arm/mach-mxs/icoll.c new file +10
-0+#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 );
You need to write this before handling the irq, no?
Quoted 60 lines
arch/arm/mach-mxs/icoll.c new file +39
-0+ +/* 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 mxs_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; + +/* Reset icoll */ +mxs_reset_block (irqbase +HW_ICOLL_CTRL ); + +for (i =0 ; i <MXS_INTERNAL_IRQS ; i++) { +set_irq_chip (i, &mxs_icoll_chip); +set_irq_handler (i, handle_level_irq); +set_irq_flags (i,IRQF_VALID ); + } +}arch/arm/mach-mxs/include/mach/entry-macro.S new file +15
-0@@ -0,0 +1,36 @@ +/* + * Low-level IRQ helper macros for Freescale MXS-based + * + * 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. + *
arch/arm/mach-mxs/include/mach/entry-macro.S line 25
Quoted 10 lines
arch/arm/mach-mxs/include/mach/entry-macro.S new file +10
-0+ * 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. + */ + + .macro disable_fiq + .endm + + .macro get_irqnr_and_base, irqnr, irqstat, base, tmp + ldr \base, =icoll_base
Maybe it's worth to hardcode the base address if only a single cpu is compiled in? And what about setting the base register in get_irqnr_preamble?
arch/arm/mach-mxs/include/mach/entry-macro.S line 29
Quoted 4 lines
arch/arm/mach-mxs/include/mach/entry-macro.S new file +4
-0+ ldr \base, [\base] + ldr \irqnr, [\base, #0x70] + cmp \irqnr, #0x7F + moveqs \irqnr, #0
Hmm, you only need that cmp+moveqs because you cannot be sure that an irq is pending, right. Maybe it would make sense not to check for irqs in a loop? (This is a arm-global thing, Russell?) (BTW, you're lucky, for your irq controller it's only ugly to check if there is an irq pending. IIRC ns9xxx has a race here.)
Quoted 12 lines
arch/arm/mach-mxs/include/mach/entry-macro.S new file +7
-0+ .endm + + .macro get_irqnr_preamble, base, tmp + .endm + + .macro arch_ret_to_user, tmp1, tmp2 + .endmSignature · 1 line
1.7.1
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-K?nig | Industrial Linux Solutions | http://www.pengutronix.de/ |
PATCH 4/15 ARM: mxs: Add interrupt support
Quoted 6 lines · Uwe Kleine-K?nig
arch/arm/mach-mxs/include/mach/entry-macro.S line 25
Quoted 2 lines
arch/arm/mach-mxs/include/mach/entry-macro.S new file +2
-0+ .macro get_irqnr_and_base, irqnr, irqstat, base, tmp + ldr \base, =icoll_baseMaybe it's worth to hardcode the base address if only a single cpu is compiled in? And what about setting the base register in
get_irqnr_preamble?
Quoted 9 lines
arch/arm/mach-mxs/include/mach/entry-macro.S line 29
Quoted 4 lines
arch/arm/mach-mxs/include/mach/entry-macro.S new file +4
-0+ ldr \base, [\base] + ldr \irqnr, [\base, #0x70] + cmp \irqnr, #0x7F + moveqs \irqnr, #0Hmm, you only need that cmp+moveqs because you cannot be sure that an irq is pending, right. Maybe it would make sense not to check for irqs in a loop? (This is a arm-global thing, Russell?) (BTW, you're lucky, for your irq controller it's only ugly to check if there is an irq pending. IIRC ns9xxx has a race here.)
It always makes sense to check for more IRQs after you've processed the first one before returning. Entering and exiting from the calling context is very expensive compared to looping back to check for further interrupts.
It's also possible for interrupts to be received on a core, but there to be no IRQ pending in the controller. So you can't guarantee that you have work to do just because the CPU entered the IRQ vector. This is especially true with level-activated IRQ sources.
PATCH 4/15 ARM: mxs: Add interrupt support
In reply to Uwe Kleine-KönigHi Uwe,
2010/11/30 Uwe Kleine-K?nig <[email protected]>:
Quoted 3 lines
Hello Shawn,
On Fri, Nov 26, 2010 at 02:49:03PM +0800, Shawn Guo wrote:
[...]
Quoted 5 lines
arch/arm/mach-mxs/icoll.c
Quoted 3 lines
arch/arm/mach-mxs/icoll.c new file +3
-0+static void icoll_ack_irq (unsigned int irq) +{ + ? ? __raw_writel(0, icoll_base + HW_ICOLL_VECTOR);You need to write this before handling the irq, no?
No need, indeed. Will remove it.
Quoted 6 lines
Quoted 6 lines
arch/arm/mach-mxs/icoll.c new file +6
-0+ + ? ? /* ACK current interrupt (level 0) */ + ? ? __raw_writel(BV_ICOLL_LEVELACK_IRQLEVELACK__LEVEL0, + ? ? ? ? ? ? ? ? ? ? icoll_base + HW_ICOLL_LEVELACK); +} +
[...]
Quoted 7 lines
Quoted 3 lines
+
+ ? ? .macro ?get_irqnr_and_base, irqnr, irqstat, base, tmp
+ ? ? ldr ? ? \base, =icoll_baseMaybe it's worth to hardcode the base address if only a single cpu is compiled in? ?And what about setting the base register in
get_irqnr_preamble?
I suppose you have known that MX23 and MX28 could be built into single zImage. So you are asking something as below, right?
.macro get_irqnr_and_base, irqnr, irqstat, base, tmp
ldr \irqnr, [\base, #0x70]
cmp \irqnr, #0x7F
moveqs \irqnr, #0.endm
.macro get_irqnr_preamble, base, tmp
#if defined (CONFIG_SOC_IMX23) && defined (CONFIG_SOC_IMX28)
ldr \base, =icoll_base
ldr \base, [\base]
#elif defined (CONFIG_SOC_IMX23)
ldr \base, =MX23_ICOLL_BASE_ADDR
#else
ldr \base, =MX28_ICOLL_BASE_ADDR
#endif
.endm
Quoted 10 lines
Quoted 4 lines
+ ? ? ldr ? ? \base, [\base]
+ ? ? ldr ? ? \irqnr, [\base, #0x70]
+ ? ? cmp ? ? \irqnr, #0x7F
+ ? ? moveqs ?\irqnr, #0Hmm, you only need that cmp+moveqs because you cannot be sure that an irq is pending, right. ?Maybe it would make sense not to check for irqs in a loop? ?(This is a arm-global thing, Russell?) ?(BTW, you're lucky, for your irq controller it's only ugly to check if there is an irq pending. ?IIRC ns9xxx has a race here.)
Right. But we actually have a problem with that on i.MX28, because i.MX28 uses IRQ 127 as below.
#define MX28_INT_GPIO0 127
So GPIO0 interrupt will not work. Any suggestion to work around it?
Signature · 2 lines
Regards, Shawn
PATCH 5/15 ARM: mxs: Add low-level debug UART support
In reply to Shawn Guo* DEBUG_LL support, which is incompatible with single MXS image because of different DUART base address on MX23 and MX28
* uncompress message support
--- arch/arm/mach-mxs/include/mach/debug-macro.S | 51 ++++++++++++++++ arch/arm/mach-mxs/include/mach/uncompress.h | 82 ++++++++++++++++++++++++++ 2 files changed, 133 insertions(+), 0 deletions(-) create mode 100644 arch/arm/mach-mxs/include/mach/debug-macro.S create mode 100644 arch/arm/mach-mxs/include/mach/uncompress.h
arch/arm/mach-mxs/include/mach/debug-macro.S new file +51 -0
@@ -0,0 +1,51 @@ +/* arch/arm/mach-mxs/include/mach/debug-macro.S + * + * Debugging macro include header + * + * Copyright (C) 1994-1999 Russell King + * Moved from linux/arch/arm/kernel/debug.S by Ben Dooks + * + * 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> + +#ifdef CONFIG_SOC_IMX23 +#ifdef UART_PADDR +#error "CONFIG_DEBUG_LL is incompatible with multiple archs" +#endif +#define UART_PADDR MX23_DUART_BASE_ADDR +#endif + +#ifdef CONFIG_SOC_IMX28 +#ifdef UART_PADDR +#error "CONFIG_DEBUG_LL is incompatible with multiple archs" +#endif +#define UART_PADDR MX28_DUART_BASE_ADDR +#endif + +#define UART_VADDR MXS_IO_ADDRESS(UART_PADDR) + + .macro addruart, rp, rv + ldr \rp, =UART_PADDR @ physical + ldr \rv, =UART_VADDR @ virtual + .endm + + .macro senduart, rd, rx + str \rd, [\rx, #0x0] @ DR + .endm + + .macro waituart, rd, rx +1001: ldr \rd, [\rx, #0x18] @ FR + tst \rd, #1 << 5 @ FR_TXFF + bne 1001b + .endm + + .macro busyuart, rd, rx +1002: ldr \rd, [\rx, #0x18] @ FR + tst \rd, #1 << 3 @ FR_BUSY + beq 1002b + .endm
arch/arm/mach-mxs/include/mach/uncompress.h new file +82 -0
82 lines not on this page · raw message
Signature · 1 line
1.7.1
PATCH 5/15 ARM: mxs: Add low-level debug UART support
Quoted 108 lines · Shawn Guo
*
DEBUG_LLsupport, which is incompatible with single MXS image because of different DUART base address on MX23 and MX28
* uncompress message supportSigned-off-by Shawn Guo <[email protected]>--- arch/arm/mach-mxs/include/mach/debug-macro.S | 51 ++++++++++++++++ arch/arm/mach-mxs/include/mach/uncompress.h | 82 ++++++++++++++++++++++++++ 2 files changed, 133 insertions(+), 0 deletions(-) create mode 100644 arch/arm/mach-mxs/include/mach/debug-macro.S create mode 100644 arch/arm/mach-mxs/include/mach/uncompress.harch/arm/mach-mxs/include/mach/debug-macro.S new file +51
-0@@ -0,0 +1,51 @@ +/* arch/arm/mach-mxs/include/mach/debug-macro.S + * + * Debugging macro include header + * + * Copyright (C) 1994-1999 Russell King + * Moved from linux/arch/arm/kernel/debug.S by Ben Dooks + * + * 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> + +#ifdef CONFIG_SOC_IMX23 +#ifdef UART_PADDR +#error "CONFIG_DEBUG_LL is incompatible with multiple archs" +#endif +#define UART_PADDR MX23_DUART_BASE_ADDR +#endif + +#ifdef CONFIG_SOC_IMX28 +#ifdef UART_PADDR +#error "CONFIG_DEBUG_LL is incompatible with multiple archs" +#endif +#define UART_PADDR MX28_DUART_BASE_ADDR +#endif + +#define UART_VADDR MXS_IO_ADDRESS(UART_PADDR) + + .macro addruart, rp, rv + ldr \rp, =UART_PADDR @ physical + ldr \rv, =UART_VADDR @ virtual + .endm + + .macro senduart, rd, rx + str \rd, [\rx, #0x0] @ DR + .endm + + .macro waituart, rd, rx +1001: ldr \rd, [\rx, #0x18] @ FR + tst \rd, #1 << 5 @ FR_TXFF + bne 1001b + .endm + + .macro busyuart, rd, rx +1002: ldr \rd, [\rx, #0x18] @ FR + tst \rd, #1 << 3 @ FR_BUSY + beq 1002b + .endmarch/arm/mach-mxs/include/mach/uncompress.h new file +33
-0@@ -0,0 +1,82 @@ +/* +* arch/arm/mach-mxs/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 +* 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. +*/ +#ifndef __MACH_MXS_UNCOMPRESS_H__ +#define __MACH_MXS_UNCOMPRESS_H__ + +#define __MXS_BOOT_UNCOMPRESS + +#include <asm/mach-types.h> + +static unsigned long uart_base; + +#define UART (x) (*(volatile unsigned long *)(uart_base + (x))) + +#define DR 0x00 +#define FR 0x18 +#define FR_BUSY (1 << 3) +#define FR_TXFE (1 << 7) +#define CR 0x30
arch/arm/mach-mxs/include/mach/uncompress.h line 43
Quoted 10 lines
arch/arm/mach-mxs/include/mach/uncompress.h new file +10
-0+#define CR_UARTEN 1 + +/* +* The following code assumes the serial port has already been +* initialized by the bootloader. We search for the first enabled +* port in the most probable order. If you didn't setup a port in +* your bootloader then nothing will appear (which might be desired). +* +* This does not append a newline +*/
This comment seems wrong.
Quoted 43 lines
arch/arm/mach-mxs/include/mach/uncompress.h new file +38
-0+static void putc (int ch) +{ +if (!uart_base) +return ; +if (!(UART (CR ) &CR_UARTEN )) +return ; + +while (!(UART (FR ) &FR_TXFE )) +barrier (); + +UART (DR ) = ch; +} + +static inline void flush (void ) +{ +} + +#define MX23_DUART_BASE_ADDR 0x80070000 +#define MX28_DUART_BASE_ADDR 0x80074000 + +static __inline__void __arch_decomp_setup (unsigned long arch_id) +{ +switch (arch_id) { +case MACH_TYPE_MX23EVK : + uart_base =MX23_DUART_BASE_ADDR ; +break ; +case MACH_TYPE_MX28EVK : + uart_base =MX28_DUART_BASE_ADDR ; +break ; +default : +break ; + } +} + +#define arch_decomp_setup () __arch_decomp_setup(arch_id) +#define arch_decomp_wdog () + +#endif /* __MACH_MXS_UNCOMPRESS_H__ */ Signature · 1 line
1.7.1
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-K?nig | Industrial Linux Solutions | http://www.pengutronix.de/ |
PATCH 6/15 ARM: mxs: Add timer support
In reply to Shawn GuoFreescale MXS-based SoCs implement timer support in block TIMROT. There are two versions of TIMROT. The v1 on MX23 only gets 16 bits counter and has no match function. The v2 on MX28 extends the counter to 32 bits and add the match function.
As the result, we need two instances of timers with v1 for better implementation, one for next_event and another for get_cycles. Otherwise, get_cycles may get imprecise result after long time cumulating. With v2, one instance can serve two purposes well.
--- arch/arm/mach-mxs/timer.c | 285 +++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 285 insertions(+), 0 deletions(-) create mode 100644 arch/arm/mach-mxs/timer.c
arch/arm/mach-mxs/timer.c new file +285 -0
@@ -0,0 +1,285 @@ +/* +* Copyright (C) 2000-2001 Deep Blue Solutions +* 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 +* 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/interrupt.h> +#include <linux/irq.h> +#include <linux/clockchips.h> +#include <linux/clk.h> + +#include <mach/hardware.h> +#include <asm/mach/time.h> +#include <mach/common.h> + +/* +* There are 2 versions of the timrot on Freescale MXS-based SoCs. +* The v1 on MX23 only gets 16 bits counter and has no match function. +* The v2 on MX28 extends the counter to 32 bits and add the match function. +* +* As the result, we need two instances of timers with v1 for better +* implementation, one for next_event and another for get_cycles. Otherwise, +* get_cycles may get imprecise result after long time cumulating. +* With v2, one instance can serve two purposes well. +*/ +#define timrot_is_v1 () (cpu_is_mx23()) + +#define HW_TIMROT_ROTCTRL 0x00 +#define HW_TIMROT_TIMCTRLn (n) (0x20 + (n) * 0x40) +#define HW_TIMROT_RUNNING_COUNTn (n) (0x30 + (n) * 0x40) +#define HW_TIMROT_MATCH_COUNTn (n) (0x50 + (n) * 0x40) +#define BM_TIMROT_TIMCTRLn_RELOAD (1 << 6) +#define BM_TIMROT_TIMCTRLn_UPDATE (1 << 7) +#define BM_TIMROT_TIMCTRLn_MATCH_MODE (1 << 11) +#define BM_TIMROT_TIMCTRLn_IRQ_EN (1 << 14) +#define BM_TIMROT_TIMCTRLn_IRQ (1 << 15) +#define BP_TIMROT_TIMCTRLn_SELECT 0 +#define BV_TIMROT_TIMCTRLn_SELECT__32KHZ_XTAL (timrot_is_v1() ? 0x8 : 0xb) + +static struct clock_event_device clockevent_mxs; +static enum clock_event_mode clockevent_mode =CLOCK_EVT_MODE_UNUSED ; + +static void __iomem *timer_base; + +static inline void timrot_irq_disable (void ) +{ +__raw_writel (BM_TIMROT_TIMCTRLn_IRQ_EN, + timer_base +HW_TIMROT_TIMCTRLn (0 ) +MXS_CLR_ADDR ); +} + +static inline void timrot_irq_enable (void ) +{ +__raw_writel (BM_TIMROT_TIMCTRLn_IRQ_EN, + timer_base +HW_TIMROT_TIMCTRLn (0 ) +MXS_SET_ADDR ); +} + +static void timrot_irq_acknowledge (void ) +{ +__raw_writel (BM_TIMROT_TIMCTRLn_IRQ, + timer_base +HW_TIMROT_TIMCTRLn (0 ) +MXS_CLR_ADDR ); +} + +static cycle_t timrot_get_cycles (struct clocksource *cs) +{ +if (timrot_is_v1 ()) +return ~((__raw_readl (timer_base +HW_TIMROT_RUNNING_COUNTn (1 )) + &0xffff0000 ) >>16 ); +else +return ~__raw_readl (timer_base +HW_TIMROT_RUNNING_COUNTn (0 )); +} + +static int timrot_set_next_event (unsigned long evt, +struct clock_event_device *dev) +{ +unsigned long match; +int ret; + +/* timrot decrements the count */ +if (timrot_is_v1 ()) { +__raw_writel (evt, timer_base +HW_TIMROT_RUNNING_COUNTn (0 )); + ret =0 ; + }else { + match =__raw_readl (timer_base +HW_TIMROT_MATCH_COUNTn (0 )) + - evt; +__raw_writel (match, timer_base +HW_TIMROT_MATCH_COUNTn (0 )); + ret = (int )(match -__raw_readl (timer_base + +HW_TIMROT_RUNNING_COUNTn (0 ))) >0 ? -ETIME :0 ; + } + +return ret; +} + +static irqreturn_t mxs_timer_interrupt (int irq,void *dev_id) +{ +struct clock_event_device *evt = &clockevent_mxs; + +timrot_irq_acknowledge (); + evt->event_handler (evt); + +return IRQ_HANDLED ; +} + +static struct irqaction mxs_timer_irq = { + .name ="MXS Timer Tick" , + .flags =IRQF_DISABLED |IRQF_TIMER |IRQF_IRQPOLL , + .handler = mxs_timer_interrupt, +}; + +#ifdef DEBUG +static const char *clock_event_mode_label[] = { + [CLOCK_EVT_MODE_PERIODIC ] ="CLOCK_EVT_MODE_PERIODIC" , + [CLOCK_EVT_MODE_ONESHOT ] ="CLOCK_EVT_MODE_ONESHOT" , + [CLOCK_EVT_MODE_SHUTDOWN ] ="CLOCK_EVT_MODE_SHUTDOWN" , + [CLOCK_EVT_MODE_UNUSED ] ="CLOCK_EVT_MODE_UNUSED" +}; +#endif /* DEBUG */ + +static void mxs_set_mode (enum clock_event_mode mode, +struct clock_event_device *evt) +{ +unsigned long flags; + +/* +* The timer interrupt generation is disabled at least +* for enough time to call mxs_set_next_event() +*/ +local_irq_save (flags); + +/* Disable interrupt in timer module */ +timrot_irq_disable (); + +if (mode != clockevent_mode) { +/* Set event time into far-far future */ +__raw_writel (__raw_readl (timer_base + +HW_TIMROT_RUNNING_COUNTn (0 )) +3 , + timer_base +HW_TIMROT_MATCH_COUNTn (0 )); + +/* Clear pending interrupt */ +timrot_irq_acknowledge (); + } + +#ifdef DEBUG +printk (KERN_INFO "mxs_set_mode: changing mode from %s to %s\n" , + clock_event_mode_label[clockevent_mode], + clock_event_mode_label[mode]); +#endif /* DEBUG */ + +/* Remember timer mode */ + clockevent_mode = mode; +local_irq_restore (flags); + +switch (mode) { +case CLOCK_EVT_MODE_PERIODIC : +printk (KERN_ERR "mxs_set_mode: Periodic mode is not " +"supported for MXS-based\n" ); +break ; +case CLOCK_EVT_MODE_ONESHOT : +/* +* Do not put overhead of interrupt enable/disable into +* mxs_set_next_event(), the core has about 4 minutes +* to call mxs_set_next_event() or shutdown clock after +* mode switching +*/ +local_irq_save (flags); +timrot_irq_enable (); +local_irq_restore (flags); +break ; +case CLOCK_EVT_MODE_SHUTDOWN : +case CLOCK_EVT_MODE_UNUSED : +case CLOCK_EVT_MODE_RESUME : +/* Left event sources disabled, no more interrupts appear */ +break ; + } +} + +static struct clock_event_device clockevent_mxs = { + .name ="mxs_timrot" , + .features =CLOCK_EVT_FEAT_ONESHOT , + .shift =32 , + .set_mode = mxs_set_mode, + .set_next_event = timrot_set_next_event, + .rating =200 , +}; + +static int __init mxs_clockevent_init (struct clk *timer_clk) +{ +unsigned int c =clk_get_rate (timer_clk); + + clockevent_mxs.mult =div_sc (c,NSEC_PER_SEC , clockevent_mxs.shift); + clockevent_mxs.cpumask =cpumask_of (0 ); +if (timrot_is_v1 ()) { + clockevent_mxs.max_delta_ns = +clockevent_delta2ns (0xfffe , &clockevent_mxs); + clockevent_mxs.min_delta_ns = +clockevent_delta2ns (0xf , &clockevent_mxs); + }else { + clockevent_mxs.max_delta_ns = +clockevent_delta2ns (0xfffffffe , &clockevent_mxs); + clockevent_mxs.min_delta_ns = +clockevent_delta2ns (0xff , &clockevent_mxs); + } + +clockevents_register_device (&clockevent_mxs); + +return 0 ; +} + +static struct clocksource clocksource_mxs = { + .name ="mxs_timer" , + .rating =200 , + .read = timrot_get_cycles, + .mask =CLOCKSOURCE_MASK (32 ), + .shift =10 , + .flags =CLOCK_SOURCE_IS_CONTINUOUS , +}; + +static int __init mxs_clocksource_init (struct clk *timer_clk) +{ +unsigned int c =clk_get_rate (timer_clk); + +if (timrot_is_v1 ()) + clocksource_mxs.mask =CLOCKSOURCE_MASK (16 ); + clocksource_mxs.mult =clocksource_hz2mult (c, clocksource_mxs.shift); +clocksource_register (&clocksource_mxs); + +return 0 ; +} + +void __init mxs_timer_init (struct clk *timer_clk, +void __iomem *base,int irq) +{ +clk_enable (timer_clk); + + timer_base = base; + +/* +* Initialize timers to a known state +*/ +mxs_reset_block (base +HW_TIMROT_ROTCTRL ); + +if (timrot_is_v1 ()) { +/* timer0 is for next_event */ +__raw_writel ( + BV_TIMROT_TIMCTRLn_SELECT__32KHZ_XTAL | + BM_TIMROT_TIMCTRLn_UPDATE | + BM_TIMROT_TIMCTRLn_IRQ_EN, + base +HW_TIMROT_TIMCTRLn (0 )); +/* timer1 is for get_cycles */ +__raw_writel ( + BV_TIMROT_TIMCTRLn_SELECT__32KHZ_XTAL | + BM_TIMROT_TIMCTRLn_RELOAD, + base +HW_TIMROT_TIMCTRLn (1 )); +__raw_writel (0xffff , timer_base +HW_TIMROT_RUNNING_COUNTn (1 )); + + }else { +__raw_writel ( + BV_TIMROT_TIMCTRLn_SELECT__32KHZ_XTAL | + BM_TIMROT_TIMCTRLn_IRQ_EN | + BM_TIMROT_TIMCTRLn_MATCH_MODE, + timer_base +HW_TIMROT_TIMCTRLn (0 )); + } + +/* init and register the timer to the framework */ +mxs_clocksource_init (timer_clk); +mxs_clockevent_init (timer_clk); + +/* Make irqs happen */ +setup_irq (irq, &mxs_timer_irq); +}
Signature · 1 line
1.7.1
PATCH 6/15 ARM: mxs: Add timer support
Hello Shawn,
[added Thomas to Cc, he can probably say more here. Don't know if he want though :-)]
Quoted 66 lines · Shawn Guo
Freescale MXS-based SoCs implement timer support in block TIMROT. There are two versions of TIMROT. The v1 on MX23 only gets 16 bits counter and has no match function. The v2 on MX28 extends the counter to 32 bits and add the match function.
As the result, we need two instances of timers with v1 for better implementation, one for
next_eventand another forget_cycles. Otherwise,get_cyclesmay get imprecise result after long time cumulating. With v2, one instance can serve two purposes well.Signed-off-by Shawn Guo <[email protected]>--- arch/arm/mach-mxs/timer.c | 285 +++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 285 insertions(+), 0 deletions(-) create mode 100644 arch/arm/mach-mxs/timer.carch/arm/mach-mxs/timer.c new file +44
-0@@ -0,0 +1,285 @@ +/* +* Copyright (C) 2000-2001 Deep Blue Solutions +* 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 +* 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/interrupt.h> +#include <linux/irq.h> +#include <linux/clockchips.h> +#include <linux/clk.h> + +#include <mach/hardware.h> +#include <asm/mach/time.h> +#include <mach/common.h> + +/* +* There are 2 versions of the timrot on Freescale MXS-based SoCs. +* The v1 on MX23 only gets 16 bits counter and has no match function. +* The v2 on MX28 extends the counter to 32 bits and add the match function. +* +* As the result, we need two instances of timers with v1 for better +* implementation, one for next_event and another for get_cycles. Otherwise, +* get_cycles may get imprecise result after long time cumulating. +* With v2, one instance can serve two purposes well. +*/ +#define timrot_is_v1 () (cpu_is_mx23()) + +#define HW_TIMROT_ROTCTRL 0x00
arch/arm/mach-mxs/timer.c line 54
Quoted 10 lines
arch/arm/mach-mxs/timer.c new file +10
-0+#define HW_TIMROT_TIMCTRLn (n) (0x20 + (n) * 0x40) +#define HW_TIMROT_RUNNING_COUNTn (n) (0x30 + (n) * 0x40) +#define HW_TIMROT_MATCH_COUNTn (n) (0x50 + (n) * 0x40) +#define BM_TIMROT_TIMCTRLn_RELOAD (1 << 6) +#define BM_TIMROT_TIMCTRLn_UPDATE (1 << 7) +#define BM_TIMROT_TIMCTRLn_MATCH_MODE (1 << 11) +#define BM_TIMROT_TIMCTRLn_IRQ_EN (1 << 14) +#define BM_TIMROT_TIMCTRLn_IRQ (1 << 15) +#define BP_TIMROT_TIMCTRLn_SELECT 0 +#define BV_TIMROT_TIMCTRLn_SELECT__32KHZ_XTAL (timrot_is_v1() ? 0x8 : 0xb)
I don't like hiding different register offsets behind a constant. This might make usage of the constant more expensive than the C-code let expect.
Quoted 22 lines
arch/arm/mach-mxs/timer.c new file +22
-0+ +static struct clock_event_device clockevent_mxs; +static enum clock_event_mode clockevent_mode =CLOCK_EVT_MODE_UNUSED ; + +static void __iomem *timer_base; + +static inline void timrot_irq_disable (void ) +{ +__raw_writel (BM_TIMROT_TIMCTRLn_IRQ_EN, + timer_base +HW_TIMROT_TIMCTRLn (0 ) +MXS_CLR_ADDR ); +} + +static inline void timrot_irq_enable (void ) +{ +__raw_writel (BM_TIMROT_TIMCTRLn_IRQ_EN, + timer_base +HW_TIMROT_TIMCTRLn (0 ) +MXS_SET_ADDR ); +} + +static void timrot_irq_acknowledge (void ) +{ +__raw_writel (BM_TIMROT_TIMCTRLn_IRQ, + timer_base +HW_TIMROT_TIMCTRLn (0 ) +MXS_CLR_ADDR );
arch/arm/mach-mxs/timer.c line 86
Quoted 10 lines
arch/arm/mach-mxs/timer.c new file +10
-0+} + +static cycle_t timrot_get_cycles (struct clocksource *cs) +{ +if (timrot_is_v1 ()) +return ~((__raw_readl (timer_base +HW_TIMROT_RUNNING_COUNTn (1 )) + &0xffff0000 ) >>16 ); +else +return ~__raw_readl (timer_base +HW_TIMROT_RUNNING_COUNTn (0 )); +}
Maybe better implement timrotv1_get_cycles and timrotv2_get_cycles and only do the distinction once at init time when setting the callback instead of each time it is called.
Quoted 10 lines
arch/arm/mach-mxs/timer.c new file +10
-0+static int timrot_set_next_event (unsigned long evt, +struct clock_event_device *dev) +{ +unsigned long match; +int ret; + +/* timrot decrements the count */ +if (timrot_is_v1 ()) { +__raw_writel (evt, timer_base +HW_TIMROT_RUNNING_COUNTn (0 )); + ret =0 ;
arch/arm/mach-mxs/timer.c line 107
Quoted 10 lines
arch/arm/mach-mxs/timer.c new file +10
-0+ }else { + match =__raw_readl (timer_base +HW_TIMROT_MATCH_COUNTn (0 )) + - evt; +__raw_writel (match, timer_base +HW_TIMROT_MATCH_COUNTn (0 )); + ret = (int )(match -__raw_readl (timer_base + +HW_TIMROT_RUNNING_COUNTn (0 ))) >0 ? -ETIME :0 ; + } + +return ret; +}
ditto
Quoted 4 lines
arch/arm/mach-mxs/timer.c new file +4
-0+ +static irqreturn_t mxs_timer_interrupt (int irq,void *dev_id) +{ +struct clock_event_device *evt = &clockevent_mxs;
arch/arm/mach-mxs/timer.c line 121
Quoted 10 lines
arch/arm/mach-mxs/timer.c new file +10
-0+ +timrot_irq_acknowledge (); + evt->event_handler (evt); + +return IRQ_HANDLED ; +} + +static struct irqaction mxs_timer_irq = { + .name ="MXS Timer Tick" , + .flags =IRQF_DISABLED |IRQF_TIMER |IRQF_IRQPOLL ,
IRQF_DISABLED is a noop, skip it.
Quoted 12 lines
arch/arm/mach-mxs/timer.c new file +12
-0+ .handler = mxs_timer_interrupt, +}; + +#ifdef DEBUG +static const char *clock_event_mode_label[] = { + [CLOCK_EVT_MODE_PERIODIC ] ="CLOCK_EVT_MODE_PERIODIC" , + [CLOCK_EVT_MODE_ONESHOT ] ="CLOCK_EVT_MODE_ONESHOT" , + [CLOCK_EVT_MODE_SHUTDOWN ] ="CLOCK_EVT_MODE_SHUTDOWN" , + [CLOCK_EVT_MODE_UNUSED ] ="CLOCK_EVT_MODE_UNUSED" +}; +#endif /* DEBUG */ +
arch/arm/mach-mxs/timer.c line 143
Quoted 10 lines
arch/arm/mach-mxs/timer.c new file +10
-0+static void mxs_set_mode (enum clock_event_mode mode, +struct clock_event_device *evt) +{ +unsigned long flags; + +/* +* The timer interrupt generation is disabled at least +* for enough time to call mxs_set_next_event() +*/ +local_irq_save (flags);
I think set_mode is called with irqs already off.
arch/arm/mach-mxs/timer.c line 152
Quoted 9 lines
arch/arm/mach-mxs/timer.c new file +9
-0+ +/* Disable interrupt in timer module */ +timrot_irq_disable (); + +if (mode != clockevent_mode) { +/* Set event time into far-far future */ +__raw_writel (__raw_readl (timer_base + +HW_TIMROT_RUNNING_COUNTn (0 )) +3 , + timer_base +HW_TIMROT_MATCH_COUNTn (0 ));
I don't know if this is needed, maybe there cannot be a pending event when set_mode is called? Thomas?
Quoted 75 lines
arch/arm/mach-mxs/timer.c new file +75
-0+/* Clear pending interrupt */ +timrot_irq_acknowledge (); + } + +#ifdef DEBUG +printk (KERN_INFO "mxs_set_mode: changing mode from %s to %s\n" , + clock_event_mode_label[clockevent_mode], + clock_event_mode_label[mode]); +#endif /* DEBUG */ + +/* Remember timer mode */ + clockevent_mode = mode; +local_irq_restore (flags); + +switch (mode) { +case CLOCK_EVT_MODE_PERIODIC : +printk (KERN_ERR "mxs_set_mode: Periodic mode is not " +"supported for MXS-based\n" ); +break ; +case CLOCK_EVT_MODE_ONESHOT : +/* +* Do not put overhead of interrupt enable/disable into +* mxs_set_next_event(), the core has about 4 minutes +* to call mxs_set_next_event() or shutdown clock after +* mode switching +*/ +local_irq_save (flags); +timrot_irq_enable (); +local_irq_restore (flags); +break ; +case CLOCK_EVT_MODE_SHUTDOWN : +case CLOCK_EVT_MODE_UNUSED : +case CLOCK_EVT_MODE_RESUME : +/* Left event sources disabled, no more interrupts appear */ +break ; + } +} + +static struct clock_event_device clockevent_mxs = { + .name ="mxs_timrot" , + .features =CLOCK_EVT_FEAT_ONESHOT , + .shift =32 , + .set_mode = mxs_set_mode, + .set_next_event = timrot_set_next_event, + .rating =200 , +}; + +static int __init mxs_clockevent_init (struct clk *timer_clk) +{ +unsigned int c =clk_get_rate (timer_clk); + + clockevent_mxs.mult =div_sc (c,NSEC_PER_SEC , clockevent_mxs.shift); + clockevent_mxs.cpumask =cpumask_of (0 ); +if (timrot_is_v1 ()) { + clockevent_mxs.max_delta_ns = +clockevent_delta2ns (0xfffe , &clockevent_mxs); + clockevent_mxs.min_delta_ns = +clockevent_delta2ns (0xf , &clockevent_mxs); + }else { + clockevent_mxs.max_delta_ns = +clockevent_delta2ns (0xfffffffe , &clockevent_mxs); + clockevent_mxs.min_delta_ns = +clockevent_delta2ns (0xff , &clockevent_mxs); + } + +clockevents_register_device (&clockevent_mxs); + +return 0 ; +} + +static struct clocksource clocksource_mxs = { + .name ="mxs_timer" , + .rating =200 , + .read = timrot_get_cycles, + .mask =CLOCKSOURCE_MASK (32 ),
arch/arm/mach-mxs/timer.c line 238
Quoted 10 lines
arch/arm/mach-mxs/timer.c new file +10
-0+ .shift = 10, + .flags = CLOCK_SOURCE_IS_CONTINUOUS, +}; + +static int __init mxs_clocksource_init (struct clk *timer_clk) +{ +unsigned int c =clk_get_rate (timer_clk); + +if (timrot_is_v1 ()) + clocksource_mxs.mask =CLOCKSOURCE_MASK (16 );
I wonder if a shift of 10 is a bit heavy for a 16 bit timer.
Quoted 10 lines
arch/arm/mach-mxs/timer.c new file +10
-0+ clocksource_mxs.mult =clocksource_hz2mult (c, clocksource_mxs.shift); +clocksource_register (&clocksource_mxs); + +return 0 ; +} + +void __init mxs_timer_init (struct clk *timer_clk, +void __iomem *base,int irq) +{ +clk_enable (timer_clk);
arch/arm/mach-mxs/timer.c line 258
Quoted 10 lines
arch/arm/mach-mxs/timer.c new file +10
-0+ + timer_base = base; + +/* +* Initialize timers to a known state +*/ +mxs_reset_block (base +HW_TIMROT_ROTCTRL ); + +if (timrot_is_v1 ()) { +/* timer0 is for next_event */
The more usual names are clock_event ...
arch/arm/mach-mxs/timer.c line 264
Quoted 6 lines
arch/arm/mach-mxs/timer.c new file +6
-0+__raw_writel ( + BV_TIMROT_TIMCTRLn_SELECT__32KHZ_XTAL | + BM_TIMROT_TIMCTRLn_UPDATE | + BM_TIMROT_TIMCTRLn_IRQ_EN, + base +HW_TIMROT_TIMCTRLn (0 )); +/* timer1 is for get_cycles */
and clocksource.
Quoted 11 lines
arch/arm/mach-mxs/timer.c new file +11
-0+__raw_writel ( + BV_TIMROT_TIMCTRLn_SELECT__32KHZ_XTAL | + BM_TIMROT_TIMCTRLn_RELOAD, + base +HW_TIMROT_TIMCTRLn (1 )); +__raw_writel (0xffff , timer_base +HW_TIMROT_RUNNING_COUNTn (1 )); + + }else { + __raw_writel( + BV_TIMROT_TIMCTRLn_SELECT__32KHZ_XTAL | + BM_TIMROT_TIMCTRLn_IRQ_EN | + BM_TIMROT_TIMCTRLn_MATCH_MODE,
arch/arm/mach-mxs/timer.c line 285
Quoted 10 lines
arch/arm/mach-mxs/timer.c new file +10
-0+ timer_base + HW_TIMROT_TIMCTRLn(0)); + } + +/* init and register the timer to the framework */ +mxs_clocksource_init (timer_clk); +mxs_clockevent_init (timer_clk); + +/* Make irqs happen */ +setup_irq (irq, &mxs_timer_irq); +}
Best regards
Uwe
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-K?nig | Industrial Linux Solutions | http://www.pengutronix.de/ |
PATCH 6/15 ARM: mxs: Add timer support
Hi Uwe,
2010/12/1 Uwe Kleine-K?nig <[email protected]>:
Quoted 2 lines
Hello Shawn,
[...]
Quoted 12 lines
Review
Quoted 9 lines
(quoted diff) +9
-0+ + ? ? /* Disable interrupt in timer module */ + ? ? timrot_irq_disable(); + + ? ? if (mode != clockevent_mode) { + ? ? ? ? ? ? /* Set event time into far-far future */ + ? ? ? ? ? ? __raw_writel(__raw_readl(timer_base + + ? ? ? ? ? ? ? ? ? ? ? ? ? ? HW_TIMROT_RUNNING_COUNTn(0)) + 3, + ? ? ? ? ? ? ? ? ? ? ? ? ? ? timer_base + HW_TIMROT_MATCH_COUNTn(0));I don't know if this is needed, maybe there cannot be a pending event when
set_modeis called? ?Thomas?
Freescale BSP works well without this. It's probably not needed.
Quoted 9 lines
Quoted 9 lines
(quoted diff) +9
-0+ +static struct clocksource clocksource_mxs = { + ? ? .name ? ? ? ? ? = "mxs_timer", + ? ? .rating ? ? ? ? = 200, + ? ? .read ? ? ? ? ? = timrot_get_cycles, + ? ? .mask ? ? ? ? ? = CLOCKSOURCE_MASK(32), + ? ? .shift ? ? ? ? ?= 10, + ? ? .flags ? ? ? ? ?= CLOCK_SOURCE_IS_CONTINUOUS, +};
Quoted 9 lines
arch/arm/mach-mxs/timer.c
Quoted 7 lines
arch/arm/mach-mxs/timer.c new file +7
-0+ +static int __init mxs_clocksource_init (struct clk *timer_clk) +{ + ? ? unsigned int c = clk_get_rate(timer_clk); + + ? ? if (timrot_is_v1()) + ? ? ? ? ? ? clocksource_mxs.mask = CLOCKSOURCE_MASK(16);I wonder if a shift of 10 is a bit heavy for a 16 bit timer.
I do not understand that. The shift is used in clocksource_hz2mult() as below.
static inline u32 clocksource_hz2mult(u32 hz, u32 shift_constant)
{
/* hz = cyc/(Billion ns)
* mult/2^shift = ns/cyc
* mult = ns/cyc * 2^shift
* mult = 1Billion/hz * 2^shift
* mult = 1000000000 * 2^shift / hz
* mult = (1000000000<<shift) / hz
*/
u64 tmp = ((u64)1000000000) << shift_constant;
tmp += hz/2; /* round for do_div */
do_div(tmp, hz);
return (u32)tmp;
}The shift is working against the timers frequency (hz). Should hz be the thing concerned here instead of timer bit width? Since both MX23 and MX28 timer are running@32K, so shift value 10 is picked here.
Signature · 2 lines
Regards, Shawn
PATCH 6/15 ARM: mxs: Add timer support
Quoted 18 lines · Shawn Guo
Hi Uwe,
2010/12/1 Uwe Kleine-K?nig <[email protected]>:
Quoted 2 lines
Hello Shawn,
[...]
Quoted 12 lines
Review
Quoted 9 lines
(quoted diff) +9
-0+ + ? ? /* Disable interrupt in timer module */ + ? ? timrot_irq_disable(); + + ? ? if (mode != clockevent_mode) { + ? ? ? ? ? ? /* Set event time into far-far future */ + ? ? ? ? ? ? __raw_writel(__raw_readl(timer_base + + ? ? ? ? ? ? ? ? ? ? ? ? ? ? HW_TIMROT_RUNNING_COUNTn(0)) + 3, + ? ? ? ? ? ? ? ? ? ? ? ? ? ? timer_base + HW_TIMROT_MATCH_COUNTn(0));I don't know if this is needed, maybe there cannot be a pending event when
set_modeis called? ?Thomas?
Quoted 1 line
Freescale BSP works well without this. It's probably not needed.
There is no guarantee, that there is no event pending. Especially not when we shutdown the timer. And the observation that the Fleescale stuff did not explode yet does not prove anything.
Quoted 5 lines
Quoted 2 lines
I wonder if a shift of 10 is a bit heavy for a 16 bit timer.
I do not understand that. The shift is used in
clocksource_hz2mult()as below.static inline u32
clocksource_hz2mult(u32 hz, u32 shift_constant)
Use clocksource_register_hz() or clocksource_register_khz() and let the clocksource code decide the shift and mult value.
Thanks,
tglx
PATCH 6/15 ARM: mxs: Add timer support
In reply to Shawn GuoHello Shawn (and Thomas),
Quoted 37 lines · Shawn Guo
Quoted 9 lines
Quoted 9 lines
(quoted diff) +9
-0+ +static struct clocksource clocksource_mxs = { + ? ? .name ? ? ? ? ? = "mxs_timer", + ? ? .rating ? ? ? ? = 200, + ? ? .read ? ? ? ? ? = timrot_get_cycles, + ? ? .mask ? ? ? ? ? = CLOCKSOURCE_MASK(32), + ? ? .shift ? ? ? ? ?= 10, + ? ? .flags ? ? ? ? ?= CLOCK_SOURCE_IS_CONTINUOUS, +};Quoted 9 lines
arch/arm/mach-mxs/timer.c
Quoted 7 lines
arch/arm/mach-mxs/timer.c new file +7
-0+ +static int __init mxs_clocksource_init (struct clk *timer_clk) +{ + ? ? unsigned int c = clk_get_rate(timer_clk); + + ? ? if (timrot_is_v1()) + ? ? ? ? ? ? clocksource_mxs.mask = CLOCKSOURCE_MASK(16);I wonder if a shift of 10 is a bit heavy for a 16 bit timer.
I do not understand that. The shift is used in
clocksource_hz2mult()as below.static inline u32
clocksource_hz2mult(u32 hz, u32 shift_constant){ /* hz = cyc/(Billion ns) * mult/2^shift = ns/cyc * mult = ns/cyc * 2^shift * mult = 1Billion/hz * 2^shift * mult = 1000000000 * 2^shift / hz * mult = (1000000000<<shift) / hz */ u64 tmp = ((u64)1000000000) << shift_constant; tmp += hz/2; /* round for do_div */ do_div(tmp, hz); return (u32)tmp; }
Quoted 3 lines
The shift is working against the timers frequency (hz). Should hz be the thing concerned here instead of timer bit width? Since both MX23 and MX28 timer are running at 32K, so shift value 10 is picked here.
Might be, it's some time ago that I dealt with the clock code. After rechecking I think you're right, but now I think 10 is too low :-)
In general a bigger shift increases accuracy at the cost of the range of values that can be converted (from ticks to ns). As a 16 bit counter has a very limited range anyhow you can at least use a high accuracy without loosing anything.
With shift=10 and tickrate=32k you get mult=0x1e84800, so the maximal value that (theoretically) occurs is 0xffff * 0x1e84800 = 0x1e84617b800 which is far away from using the available 64 bits. So (unless I'm mistaken) the shift value using most of the 64 would be 33 but that would overflow mult (which is only 32bit wide). So I'd recommend 17 (resulting in mult=0xf4240000) for both the 16 and the 32 bit case.
Thomas, does this make sense?
Best regards
Uwe
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-K?nig | Industrial Linux Solutions | http://www.pengutronix.de/ |
PATCH 7/15 ARM: mxs: Add gpio support
In reply to Shawn GuoMXS-based SoCs implement gpio support in block PINCTRL.
--- arch/arm/mach-mxs/gpio.c | 364 +++++++++++++++++++++++++++++++++ arch/arm/mach-mxs/include/mach/gpio.h | 49 +++++ 2 files changed, 413 insertions(+), 0 deletions(-) create mode 100644 arch/arm/mach-mxs/gpio.c create mode 100644 arch/arm/mach-mxs/include/mach/gpio.h
arch/arm/mach-mxs/gpio.c new file +364 -0
@@ -0,0 +1,364 @@ +/* +* MXC GPIO support. (c) 2008 Daniel Mack <[email protected]> +* Copyright 2008 Juergen Beisert, kernel at pengutronix.de +* +* Based on code from Freescale, +* Copyright (C) 2004-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/init.h> +#include <linux/interrupt.h> +#include <linux/io.h> +#include <linux/irq.h> +#include <linux/gpio.h> +#include <mach/hardware.h> +#include <asm-generic/bug.h> + +static struct mxs_gpio_port *mxs_gpio_ports; +static int gpio_table_size; + +#define PINCTRL_DOUT (n) ((cpu_is_mx23() ? 0x0500 : 0x0700) + (n) * 0x10) +#define PINCTRL_DIN (n) ((cpu_is_mx23() ? 0x0600 : 0x0900) + (n) * 0x10) +#define PINCTRL_DOE (n) ((cpu_is_mx23() ? 0x0700 : 0x0b00) + (n) * 0x10) +#define PINCTRL_PIN2IRQ (n) ((cpu_is_mx23() ? 0x0800 : 0x1000) + (n) * 0x10) +#define PINCTRL_IRQEN (n) ((cpu_is_mx23() ? 0x0900 : 0x1100) + (n) * 0x10) +#define PINCTRL_IRQLEV (n) ((cpu_is_mx23() ? 0x0a00 : 0x1200) + (n) * 0x10) +#define PINCTRL_IRQPOL (n) ((cpu_is_mx23() ? 0x0b00 : 0x1300) + (n) * 0x10) +#define PINCTRL_IRQSTAT (n) ((cpu_is_mx23() ? 0x0c00 : 0x1400) + (n) * 0x10) + +#define GPIO_INT_FALL_EDGE 0x0 +#define GPIO_INT_LOW_LEV 0x1 +#define GPIO_INT_RISE_EDGE 0x2 +#define GPIO_INT_HIGH_LEV 0x3 + +/* Note: This driver assumes 32 GPIOs are handled in one register */ + +static void _clear_gpio_irqstatus (struct mxs_gpio_port *port,u32 index) +{ +__raw_writel (1 << index, + port->base +PINCTRL_IRQSTAT (port->id) +MXS_CLR_ADDR ); +} + +static void _set_gpio_irqenable (struct mxs_gpio_port *port,u32 index, +int enable) +{ +if (enable ==0 ) { +__raw_writel (1 << index, + port->base +PINCTRL_PIN2IRQ (port->id) +MXS_CLR_ADDR ); +__raw_writel (1 << index, + port->base +PINCTRL_IRQEN (port->id) +MXS_CLR_ADDR ); + }else { +__raw_writel (1 << index, + port->base +PINCTRL_PIN2IRQ (port->id) +MXS_SET_ADDR ); +__raw_writel (1 << index, + port->base +PINCTRL_IRQEN (port->id) +MXS_SET_ADDR ); + } +} + +static void gpio_ack_irq (u32 irq) +{ +u32 gpio =irq_to_gpio (irq); +_clear_gpio_irqstatus (&mxs_gpio_ports[gpio /32 ], gpio &0x1f ); +} + +static void gpio_mask_irq (u32 irq) +{ +u32 gpio =irq_to_gpio (irq); +_set_gpio_irqenable (&mxs_gpio_ports[gpio /32 ], gpio &0x1f ,0 ); +} + +static void gpio_unmask_irq (u32 irq) +{ +u32 gpio =irq_to_gpio (irq); +_set_gpio_irqenable (&mxs_gpio_ports[gpio /32 ], gpio &0x1f ,1 ); +} + +static int mxs_gpio_get (struct gpio_chip *chip,unsigned offset); + +static int gpio_set_irq_type (u32 irq,u32 type) +{ +u32 gpio =irq_to_gpio (irq); +struct mxs_gpio_port *port = &mxs_gpio_ports[gpio /32 ]; +u32 val; +int edge; + + port->both_edges &= ~(1 << (gpio &31 )); +switch (type) { +case IRQ_TYPE_EDGE_RISING : + edge =GPIO_INT_RISE_EDGE ; +break ; +case IRQ_TYPE_EDGE_FALLING : + edge =GPIO_INT_FALL_EDGE ; +break ; +case IRQ_TYPE_EDGE_BOTH : + val =mxs_gpio_get (&port->chip, gpio &31 ); +if (val) { + edge =GPIO_INT_LOW_LEV ; +pr_debug ("mxs: set GPIO %d to low trigger\n" , gpio); + }else { + edge =GPIO_INT_HIGH_LEV ; +pr_debug ("mxs: set GPIO %d to high trigger\n" , gpio); + } + port->both_edges |=1 << (gpio &31 ); +break ; +case IRQ_TYPE_LEVEL_LOW : + edge =GPIO_INT_LOW_LEV ; +break ; +case IRQ_TYPE_LEVEL_HIGH : + edge =GPIO_INT_HIGH_LEV ; +break ; +default : +return -EINVAL ; + } + +/* set level or edge */ +if (edge &0x1 ) +__raw_writel (1 << (gpio &31 ), + port->base +PINCTRL_IRQLEV (port->id) +MXS_SET_ADDR ); +else +__raw_writel (1 << (gpio &31 ), + port->base +PINCTRL_IRQLEV (port->id) +MXS_CLR_ADDR ); + +/* set polarity */ +if ((edge >>1 ) &0x1 ) +__raw_writel (1 << (gpio &31 ), + port->base +PINCTRL_IRQPOL (port->id) +MXS_SET_ADDR ); +else +__raw_writel (1 << (gpio &31 ), + port->base +PINCTRL_IRQPOL (port->id) +MXS_CLR_ADDR ); + +_clear_gpio_irqstatus (port, gpio &0x1f ); + +return 0 ; +} + +static void mxs_flip_edge (struct mxs_gpio_port *port,u32 gpio) +{ +u32 val; +int edge; + + edge =1 << (gpio &31 ); + val =__raw_readl (port->base +PINCTRL_IRQLEV (port->id)); +if (val & edge) { +/* level is invalid for this function */ +pr_err ("mxs: invalid configuration for GPIO %d: %x\n" , + gpio, edge); +return ; + } +__raw_writel (1 << (gpio &31 ), + port->base +PINCTRL_IRQPOL (port->id) +MXS_TOG_ADDR ); +} + +/* MXS has one interrupt *per* gpio port */ +static void mxs_gpio_irq_handler (u32 irq,struct irq_desc *desc) +{ +u32 irq_stat; +struct mxs_gpio_port *port = (struct mxs_gpio_port *)get_irq_data (irq); +u32 gpio_irq_no_base = port->virtual_irq_start; + + irq_stat =__raw_readl (port->base +PINCTRL_IRQSTAT (port->id)) & +__raw_readl (port->base +PINCTRL_IRQEN (port->id)) & +__raw_readl (port->base +PINCTRL_PIN2IRQ (port->id)); + +while (irq_stat !=0 ) { +int irqoffset =fls (irq_stat) -1 ; + +if (port->both_edges & (1 << irqoffset)) +mxs_flip_edge (port, irqoffset); + +generic_handle_irq (gpio_irq_no_base + irqoffset); + + irq_stat &= ~(1 << irqoffset); + } +} + +/* +* Set interrupt number "irq" in the GPIO as a wake-up source. +* While system is running, all registered GPIO interrupts need to have +* wake-up enabled. When system is suspended, only selected GPIO interrupts +* need to have wake-up enabled. +* @param irq interrupt source number +* @param enable enable as wake-up if equal to non-zero +* @return This function returns 0 on success. +*/ +static int gpio_set_wake_irq (u32 irq,u32 enable) +{ +u32 gpio =irq_to_gpio (irq); +u32 gpio_idx = gpio &0x1f ; +struct mxs_gpio_port *port = &mxs_gpio_ports[gpio /32 ]; + +if (enable) { +if (port->irq_high && (gpio_idx >=16 )) +enable_irq_wake (port->irq_high); +else +enable_irq_wake (port->irq); + }else { +if (port->irq_high && (gpio_idx >=16 )) +disable_irq_wake (port->irq_high); +else +disable_irq_wake (port->irq); + } + +return 0 ; +} + +static struct irq_chip gpio_irq_chip = { + .ack = gpio_ack_irq, + .mask = gpio_mask_irq, + .unmask = gpio_unmask_irq, + .set_type = gpio_set_irq_type, + .set_wake = gpio_set_wake_irq, +}; + +static void _set_gpio_direction (struct gpio_chip *chip,unsigned offset, +int dir) +{ +struct mxs_gpio_port *port = + container_of(chip, struct mxs_gpio_port, chip); +u32 l; +unsigned long flags; +void __iomem *reg = port->base +PINCTRL_DOE (port->id); + +spin_lock_irqsave (&port->lock, flags); + l =__raw_readl (reg); +if (dir) + l |=1 << offset; +else + l &= ~(1 << offset); +__raw_writel (l, reg); +spin_unlock_irqrestore (&port->lock, flags); +} + +static void mxs_gpio_set (struct gpio_chip *chip,unsigned offset,int value) +{ +struct mxs_gpio_port *port = + container_of(chip, struct mxs_gpio_port, chip); +u32 l; +unsigned long flags; +void __iomem *reg = port->base +PINCTRL_DOUT (port->id); + +spin_lock_irqsave (&port->lock, flags); + l = (__raw_readl (reg) & (~(1 << offset))) | (!!value << offset); +__raw_writel (l, reg); +spin_unlock_irqrestore (&port->lock, flags); +} + +static int mxs_gpio_get (struct gpio_chip *chip,unsigned offset) +{ +struct mxs_gpio_port *port = + container_of(chip, struct mxs_gpio_port, chip); +void __iomem *reg = port->base +PINCTRL_DIN (port->id); + +return (__raw_readl (reg) >> offset) &1 ; +} + +static int mxs_gpio_direction_input (struct gpio_chip *chip,unsigned offset) +{ +_set_gpio_direction (chip, offset,0 ); +return 0 ; +} + +static int mxs_gpio_direction_output (struct gpio_chip *chip, +unsigned offset,int value) +{ +mxs_gpio_set (chip, offset, value); +_set_gpio_direction (chip, offset,1 ); +return 0 ; +} + +int __init mxs_gpio_init (struct mxs_gpio_port *port,int cnt) +{ +int i, j; + +/* save for local usage */ + mxs_gpio_ports = port; + gpio_table_size = cnt; + +printk (KERN_INFO "MXS GPIO hardware\n" ); + +for (i =0 ; i < cnt; i++) { +/* disable the interrupt and clear the status */ +__raw_writel (0 , port[i].base + +PINCTRL_PIN2IRQ (i)); +__raw_writel (0 , port[i].base + +PINCTRL_IRQEN (i)); +__raw_writel (~0 , port[i].base + +PINCTRL_IRQSTAT (i) +MXS_CLR_ADDR ); + +for (j = port[i].virtual_irq_start; + j < port[i].virtual_irq_start +32 ; j++) { +set_irq_chip (j, &gpio_irq_chip); +set_irq_handler (j, handle_level_irq); +set_irq_flags (j,IRQF_VALID ); + } + +/* register gpio chip */ + port[i].chip.direction_input = mxs_gpio_direction_input; + port[i].chip.direction_output = mxs_gpio_direction_output; + port[i].chip.get = mxs_gpio_get; + port[i].chip.set = mxs_gpio_set; + port[i].chip.base = i *32 ; + port[i].chip.ngpio =32 ; + +spin_lock_init (&port[i].lock); + +/* its a serious configuration bug when it fails */ +BUG_ON (gpiochip_add (&port[i].chip) <0 ); + +/* setup one handler for each entry */ +set_irq_chained_handler (port[i].irq, mxs_gpio_irq_handler); +set_irq_data (port[i].irq, &port[i]); + } + +return 0 ; +} + +#define DEFINE_MXS_GPIO_PORT (soc, _id) \ + { \ + .chip.label = "gpio-" #_id, \ + .id = _id, \ + .irq = soc ## _INT_GPIO ## _id, \ + .base = soc ## _IO_ADDRESS( \ + soc ## _PINCTRL ## _BASE_ADDR), \ + .virtual_irq_start = MXS_GPIO_IRQ_START + (_id) * 32, \ + } + +#define DEFINE_REGISTER_FUNCTION (prefix) \ +int __init prefix ## _register_gpios(void) \ +{ \ + return mxs_gpio_init(prefix ## _gpio_ports, \ + ARRAY_SIZE(prefix ## _gpio_ports)); \ +} + +#ifdef CONFIG_SOC_IMX23 +static struct mxs_gpio_port mx23_gpio_ports[] = { +DEFINE_MXS_GPIO_PORT (MX23 ,0 ), +DEFINE_MXS_GPIO_PORT (MX23 ,1 ), +DEFINE_MXS_GPIO_PORT (MX23 ,2 ), +}; +DEFINE_REGISTER_FUNCTION(mx23) +#endif + +#ifdef CONFIG_SOC_IMX28 +static struct mxs_gpio_port mx28_gpio_ports[] = { +DEFINE_MXS_GPIO_PORT (MX28 ,0 ), +DEFINE_MXS_GPIO_PORT (MX28 ,1 ), +DEFINE_MXS_GPIO_PORT (MX28 ,2 ), +DEFINE_MXS_GPIO_PORT (MX28 ,3 ), +DEFINE_MXS_GPIO_PORT (MX28 ,4 ), +}; +DEFINE_REGISTER_FUNCTION(mx28) +#endif
arch/arm/mach-mxs/include/mach/gpio.h new file +49 -0
49 lines not on this page · raw message
Signature · 1 line
1.7.1
PATCH 7/15 ARM: mxs: Add gpio support
Hello,
Quoted 121 lines · Shawn Guo
MXS-based SoCs implement gpio support in block PINCTRL.
Signed-off-by Shawn Guo <[email protected]>--- arch/arm/mach-mxs/gpio.c | 364 +++++++++++++++++++++++++++++++++ arch/arm/mach-mxs/include/mach/gpio.h | 49 +++++ 2 files changed, 413 insertions(+), 0 deletions(-) create mode 100644 arch/arm/mach-mxs/gpio.c create mode 100644 arch/arm/mach-mxs/include/mach/gpio.harch/arm/mach-mxs/gpio.c new file +105
-0@@ -0,0 +1,364 @@ +/* +* MXC GPIO support. (c) 2008 Daniel Mack <[email protected]> +* Copyright 2008 Juergen Beisert, kernel at pengutronix.de +* +* Based on code from Freescale, +* Copyright (C) 2004-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/init.h> +#include <linux/interrupt.h> +#include <linux/io.h> +#include <linux/irq.h> +#include <linux/gpio.h> +#include <mach/hardware.h> +#include <asm-generic/bug.h> + +static struct mxs_gpio_port *mxs_gpio_ports; +static int gpio_table_size; + +#define PINCTRL_DOUT (n) ((cpu_is_mx23() ? 0x0500 : 0x0700) + (n) * 0x10) +#define PINCTRL_DIN (n) ((cpu_is_mx23() ? 0x0600 : 0x0900) + (n) * 0x10) +#define PINCTRL_DOE (n) ((cpu_is_mx23() ? 0x0700 : 0x0b00) + (n) * 0x10) +#define PINCTRL_PIN2IRQ (n) ((cpu_is_mx23() ? 0x0800 : 0x1000) + (n) * 0x10) +#define PINCTRL_IRQEN (n) ((cpu_is_mx23() ? 0x0900 : 0x1100) + (n) * 0x10) +#define PINCTRL_IRQLEV (n) ((cpu_is_mx23() ? 0x0a00 : 0x1200) + (n) * 0x10) +#define PINCTRL_IRQPOL (n) ((cpu_is_mx23() ? 0x0b00 : 0x1300) + (n) * 0x10) +#define PINCTRL_IRQSTAT (n) ((cpu_is_mx23() ? 0x0c00 : 0x1400) + (n) * 0x10) + +#define GPIO_INT_FALL_EDGE 0x0 +#define GPIO_INT_LOW_LEV 0x1 +#define GPIO_INT_RISE_EDGE 0x2 +#define GPIO_INT_HIGH_LEV 0x3 + +/* Note: This driver assumes 32 GPIOs are handled in one register */ + +static void _clear_gpio_irqstatus (struct mxs_gpio_port *port,u32 index) +{ +__raw_writel (1 << index, + port->base +PINCTRL_IRQSTAT (port->id) +MXS_CLR_ADDR ); +} + +static void _set_gpio_irqenable (struct mxs_gpio_port *port,u32 index, +int enable) +{ +if (enable ==0 ) { +__raw_writel (1 << index, + port->base +PINCTRL_PIN2IRQ (port->id) +MXS_CLR_ADDR ); +__raw_writel (1 << index, + port->base +PINCTRL_IRQEN (port->id) +MXS_CLR_ADDR ); + }else { +__raw_writel (1 << index, + port->base +PINCTRL_PIN2IRQ (port->id) +MXS_SET_ADDR ); +__raw_writel (1 << index, + port->base +PINCTRL_IRQEN (port->id) +MXS_SET_ADDR ); + } +} + +static void gpio_ack_irq (u32 irq) +{ +u32 gpio =irq_to_gpio (irq); +_clear_gpio_irqstatus (&mxs_gpio_ports[gpio /32 ], gpio &0x1f ); +} + +static void gpio_mask_irq (u32 irq) +{ +u32 gpio =irq_to_gpio (irq); +_set_gpio_irqenable (&mxs_gpio_ports[gpio /32 ], gpio &0x1f ,0 ); +} + +static void gpio_unmask_irq (u32 irq) +{ +u32 gpio =irq_to_gpio (irq); +_set_gpio_irqenable (&mxs_gpio_ports[gpio /32 ], gpio &0x1f ,1 ); +} + +static int mxs_gpio_get (struct gpio_chip *chip,unsigned offset); + +static int gpio_set_irq_type (u32 irq,u32 type) +{ +u32 gpio =irq_to_gpio (irq); +struct mxs_gpio_port *port = &mxs_gpio_ports[gpio /32 ]; +u32 val; +int edge; + + port->both_edges &= ~(1 << (gpio &31 )); +switch (type) { +case IRQ_TYPE_EDGE_RISING : + edge =GPIO_INT_RISE_EDGE ; +break ; +case IRQ_TYPE_EDGE_FALLING : + edge =GPIO_INT_FALL_EDGE ; +break ;
arch/arm/mach-mxs/gpio.c line 115
Quoted 10 lines
arch/arm/mach-mxs/gpio.c new file +10
-0+case IRQ_TYPE_EDGE_BOTH : + val =mxs_gpio_get (&port->chip, gpio &31 ); +if (val) { + edge =GPIO_INT_LOW_LEV ; +pr_debug ("mxs: set GPIO %d to low trigger\n" , gpio); + }else { + edge =GPIO_INT_HIGH_LEV ; +pr_debug ("mxs: set GPIO %d to high trigger\n" , gpio); + } + port->both_edges |=1 << (gpio &31 );
This is ugly and might be racy. Do you really need to support IRQ_TYPE_EDGE_BOTH?
arch/arm/mach-mxs/gpio.c line 128
Quoted 13 lines
arch/arm/mach-mxs/gpio.c new file +13
-0+break ; +case IRQ_TYPE_LEVEL_LOW : + edge =GPIO_INT_LOW_LEV ; +break ; +case IRQ_TYPE_LEVEL_HIGH : + edge =GPIO_INT_HIGH_LEV ; +break ; +default : +return -EINVAL ; + } + +/* set level or edge */ +if (edge &0x1 )
Why use 0x1 here instead of a constant?
arch/arm/mach-mxs/gpio.c line 136
Quoted 8 lines
arch/arm/mach-mxs/gpio.c new file +8
-0+__raw_writel (1 << (gpio &31 ), + port->base +PINCTRL_IRQLEV (port->id) +MXS_SET_ADDR ); + else + __raw_writel(1 << (gpio & 31), + port->base + PINCTRL_IRQLEV(port->id) + MXS_CLR_ADDR); + +/* set polarity */ +if ((edge >>1 ) &0x1 )
ditto
Quoted 96 lines
arch/arm/mach-mxs/gpio.c new file +96
-0+__raw_writel (1 << (gpio &31 ), + port->base +PINCTRL_IRQPOL (port->id) +MXS_SET_ADDR ); + else + __raw_writel(1 << (gpio & 31), + port->base + PINCTRL_IRQPOL(port->id) + MXS_CLR_ADDR); + +_clear_gpio_irqstatus (port, gpio &0x1f ); + +return 0 ; +} + +static void mxs_flip_edge (struct mxs_gpio_port *port,u32 gpio) +{ +u32 val; +int edge; + + edge =1 << (gpio &31 ); + val =__raw_readl (port->base +PINCTRL_IRQLEV (port->id)); +if (val & edge) { +/* level is invalid for this function */ +pr_err ("mxs: invalid configuration for GPIO %d: %x\n" , + gpio, edge); +return ; + } +__raw_writel (1 << (gpio &31 ), + port->base +PINCTRL_IRQPOL (port->id) +MXS_TOG_ADDR ); +} + +/* MXS has one interrupt *per* gpio port */ +static void mxs_gpio_irq_handler (u32 irq,struct irq_desc *desc) +{ +u32 irq_stat; +struct mxs_gpio_port *port = (struct mxs_gpio_port *)get_irq_data (irq); +u32 gpio_irq_no_base = port->virtual_irq_start; + + irq_stat =__raw_readl (port->base +PINCTRL_IRQSTAT (port->id)) & +__raw_readl (port->base +PINCTRL_IRQEN (port->id)) & +__raw_readl (port->base +PINCTRL_PIN2IRQ (port->id)); + +while (irq_stat !=0 ) { +int irqoffset =fls (irq_stat) -1 ; + +if (port->both_edges & (1 << irqoffset)) +mxs_flip_edge (port, irqoffset); + +generic_handle_irq (gpio_irq_no_base + irqoffset); + + irq_stat &= ~(1 << irqoffset); + } +} + +/* +* Set interrupt number "irq" in the GPIO as a wake-up source. +* While system is running, all registered GPIO interrupts need to have +* wake-up enabled. When system is suspended, only selected GPIO interrupts +* need to have wake-up enabled. +* @param irq interrupt source number +* @param enable enable as wake-up if equal to non-zero +* @return This function returns 0 on success. +*/ +static int gpio_set_wake_irq (u32 irq,u32 enable) +{ +u32 gpio =irq_to_gpio (irq); +u32 gpio_idx = gpio &0x1f ; +struct mxs_gpio_port *port = &mxs_gpio_ports[gpio /32 ]; + +if (enable) { +if (port->irq_high && (gpio_idx >=16 )) +enable_irq_wake (port->irq_high); +else +enable_irq_wake (port->irq); + }else { +if (port->irq_high && (gpio_idx >=16 )) +disable_irq_wake (port->irq_high); +else +disable_irq_wake (port->irq); + } + +return 0 ; +} + +static struct irq_chip gpio_irq_chip = { + .ack = gpio_ack_irq, + .mask = gpio_mask_irq, + .unmask = gpio_unmask_irq, + .set_type = gpio_set_irq_type, + .set_wake = gpio_set_wake_irq, +}; + +static void _set_gpio_direction (struct gpio_chip *chip,unsigned offset, +int dir) +{ +struct mxs_gpio_port *port = + container_of(chip, struct mxs_gpio_port, chip); +u32 l; +unsigned long flags;
arch/arm/mach-mxs/gpio.c line 242
Quoted 10 lines
arch/arm/mach-mxs/gpio.c new file +10
-0+void __iomem *reg = port->base +PINCTRL_DOE (port->id); + +spin_lock_irqsave (&port->lock, flags); + l =__raw_readl (reg); +if (dir) + l |=1 << offset; +else + l &= ~(1 << offset); +__raw_writel (l, reg); +spin_unlock_irqrestore (&port->lock, flags);
No SET/CLR register set?
Quoted 38 lines
arch/arm/mach-mxs/gpio.c new file +38
-0+} + +static void mxs_gpio_set (struct gpio_chip *chip,unsigned offset,int value) +{ +struct mxs_gpio_port *port = + container_of(chip, struct mxs_gpio_port, chip); +u32 l; +unsigned long flags; +void __iomem *reg = port->base +PINCTRL_DOUT (port->id); + +spin_lock_irqsave (&port->lock, flags); + l = (__raw_readl (reg) & (~(1 << offset))) | (!!value << offset); +__raw_writel (l, reg); +spin_unlock_irqrestore (&port->lock, flags); +} + +static int mxs_gpio_get (struct gpio_chip *chip,unsigned offset) +{ +struct mxs_gpio_port *port = + container_of(chip, struct mxs_gpio_port, chip); +void __iomem *reg = port->base +PINCTRL_DIN (port->id); + +return (__raw_readl (reg) >> offset) &1 ; +} + +static int mxs_gpio_direction_input (struct gpio_chip *chip,unsigned offset) +{ +_set_gpio_direction (chip, offset,0 ); +return 0 ; +} + +static int mxs_gpio_direction_output (struct gpio_chip *chip, +unsigned offset,int value) +{ +mxs_gpio_set (chip, offset, value); +_set_gpio_direction (chip, offset,1 ); +return 0 ; +}
arch/arm/mach-mxs/gpio.c line 290
Quoted 10 lines
arch/arm/mach-mxs/gpio.c new file +10
-0+ +int __init mxs_gpio_init (struct mxs_gpio_port *port,int cnt) +{ +int i, j; + +/* save for local usage */ + mxs_gpio_ports = port; + gpio_table_size = cnt; + +printk (KERN_INFO "MXS GPIO hardware\n" );
pr_info?
Quoted 115 lines
arch/arm/mach-mxs/gpio.c new file +74
-0+ +for (i =0 ; i < cnt; i++) { +/* disable the interrupt and clear the status */ +__raw_writel (0 , port[i].base + +PINCTRL_PIN2IRQ (i)); +__raw_writel (0 , port[i].base + +PINCTRL_IRQEN (i)); +__raw_writel (~0 , port[i].base + +PINCTRL_IRQSTAT (i) +MXS_CLR_ADDR ); + +for (j = port[i].virtual_irq_start; + j < port[i].virtual_irq_start +32 ; j++) { +set_irq_chip (j, &gpio_irq_chip); +set_irq_handler (j, handle_level_irq); +set_irq_flags (j,IRQF_VALID ); + } + +/* register gpio chip */ + port[i].chip.direction_input = mxs_gpio_direction_input; + port[i].chip.direction_output = mxs_gpio_direction_output; + port[i].chip.get = mxs_gpio_get; + port[i].chip.set = mxs_gpio_set; + port[i].chip.base = i *32 ; + port[i].chip.ngpio =32 ; + +spin_lock_init (&port[i].lock); + +/* its a serious configuration bug when it fails */ +BUG_ON (gpiochip_add (&port[i].chip) <0 ); + +/* setup one handler for each entry */ +set_irq_chained_handler (port[i].irq, mxs_gpio_irq_handler); +set_irq_data (port[i].irq, &port[i]); + } + +return 0 ; +} + +#define DEFINE_MXS_GPIO_PORT (soc, _id) \ + { \ + .chip.label = "gpio-" #_id, \ + .id = _id, \ + .irq = soc ## _INT_GPIO ## _id, \ + .base = soc ## _IO_ADDRESS( \ + soc ## _PINCTRL ## _BASE_ADDR), \ + .virtual_irq_start = MXS_GPIO_IRQ_START + (_id) * 32, \ + } + +#define DEFINE_REGISTER_FUNCTION (prefix) \ +int __init prefix ## _register_gpios(void) \ +{ \ + return mxs_gpio_init(prefix ## _gpio_ports, \ + ARRAY_SIZE(prefix ## _gpio_ports)); \ +} + +#ifdef CONFIG_SOC_IMX23 +static struct mxs_gpio_port mx23_gpio_ports[] = { +DEFINE_MXS_GPIO_PORT (MX23 ,0 ), +DEFINE_MXS_GPIO_PORT (MX23 ,1 ), +DEFINE_MXS_GPIO_PORT (MX23 ,2 ), +}; +DEFINE_REGISTER_FUNCTION(mx23) +#endif + +#ifdef CONFIG_SOC_IMX28 +static struct mxs_gpio_port mx28_gpio_ports[] = { +DEFINE_MXS_GPIO_PORT (MX28 ,0 ), +DEFINE_MXS_GPIO_PORT (MX28 ,1 ), +DEFINE_MXS_GPIO_PORT (MX28 ,2 ), +DEFINE_MXS_GPIO_PORT (MX28 ,3 ), +DEFINE_MXS_GPIO_PORT (MX28 ,4 ), +}; +DEFINE_REGISTER_FUNCTION(mx28) +#endif arch/arm/mach-mxs/include/mach/gpio.h new file +35
-0@@ -0,0 +1,49 @@ +/* +* Copyright 2007 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 +* 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_MXS_GPIO_H__ +#define __MACH_MXS_GPIO_H__ + +#include <linux/spinlock.h> +#include <mach/hardware.h> +#include <asm-generic/gpio.h> + +#define MXS_GPIO_NR (bank, nr) ((bank) * 32 + (nr)) + +/* use gpiolib dispatchers */ +#define gpio_get_value __gpio_get_value +#define gpio_set_value __gpio_set_value +#define gpio_cansleep __gpio_cansleep + +#define gpio_to_irq (gpio) (MXS_GPIO_IRQ_START + (gpio)) +#define irq_to_gpio (irq) ((irq) - MXS_GPIO_IRQ_START) +
arch/arm/mach-mxs/include/mach/gpio.h line 45
Quoted 10 lines
arch/arm/mach-mxs/include/mach/gpio.h new file +10
-0+struct mxs_gpio_port { +void __iomem *base; +int id; +int irq; +int irq_high; +int virtual_irq_start; +struct gpio_chip chip; +u32 both_edges; +spinlock_t lock; +};
This doesn't need to be that public, arch/arm/mach-mxs/gpio.h would be enough.
arch/arm/mach-mxs/include/mach/gpio.h line 47
Quoted 2 lines
arch/arm/mach-mxs/include/mach/gpio.h new file +2
-0+ +int mxs_gpio_init (struct mxs_gpio_port *,int );
ditto.
Quoted 7 lines
arch/arm/mach-mxs/include/mach/gpio.h new file +2
-0+ +#endif /* __MACH_MXS_GPIO_H__ */ Signature · 1 line
1.7.1
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-K?nig | Industrial Linux Solutions | http://www.pengutronix.de/ |
PATCH 8/15 ARM: mxs: Add iomux support
In reply to Shawn GuoMXS-based SoCs implements iomux functions in block PINCTRL.
--- arch/arm/mach-mxs/include/mach/iomux-mx23.h | 29 +++++++ arch/arm/mach-mxs/include/mach/iomux-mx28.h | 44 +++++++++++ arch/arm/mach-mxs/include/mach/iomux.h | 77 +++++++++++++++++++ arch/arm/mach-mxs/iomux.c | 110 +++++++++++++++++++++++++++ 4 files changed, 260 insertions(+), 0 deletions(-) create mode 100644 arch/arm/mach-mxs/include/mach/iomux-mx23.h create mode 100644 arch/arm/mach-mxs/include/mach/iomux-mx28.h create mode 100644 arch/arm/mach-mxs/include/mach/iomux.h create mode 100644 arch/arm/mach-mxs/iomux.c
arch/arm/mach-mxs/include/mach/iomux-mx23.h new file +29 -0
@@ -0,0 +1,29 @@ +/* +* Copyright (C) 2009-2010 Amit Kucheria <[email protected]> +* Copyright (C) 2010 Freescale Semiconductor, Inc. +* +* The code contained herein is licensed under the GNU General Public +* License. You may obtain a copy of the GNU General Public License +* Version 2 or later at the following locations: +* +* http://www.opensource.org/licenses/gpl-license.html +* http://www.gnu.org/copyleft/gpl.html +*/ + +#ifndef __MACH_IOMUX_MX23_H__ +#define __MACH_IOMUX_MX23_H__ + +#include <mach/iomux.h> + +/* +* The naming convention for the pad modes is MX23_PAD_<padname>__<padmode> +* If <padname> or <padmode> refers to a GPIO, it is named GPIO_<unit>_<num> +* See also iomux.h +* +* BANK PIN MUX VOL MA PULL +*/ +/* DUART */ +#define MX23_PAD_PWM0__DUART_RX IOMUX_PAD(1, 26, PAD_MUXSEL_2, PAD_VOL_NONE, PAD_4MA, PAD_NOPULL) +#define MX23_PAD_PWM1__DUART_TX IOMUX_PAD(1, 27, PAD_MUXSEL_2, PAD_VOL_NONE, PAD_4MA, PAD_NOPULL) + +#endif /* __MACH_IOMUX_MX23_H__ */
arch/arm/mach-mxs/include/mach/iomux-mx28.h new file +44 -0
44 lines not on this page · raw message
arch/arm/mach-mxs/include/mach/iomux.h new file +77 -0
77 lines not on this page · raw message
arch/arm/mach-mxs/iomux.c new file +110 -0
110 lines not on this page · raw message
Signature · 1 line
1.7.1
PATCH 8/15 ARM: mxs: Add iomux support
Quoted 126 lines · Shawn Guo
MXS-based SoCs implements iomux functions in block PINCTRL.
Signed-off-by Shawn Guo <[email protected]>--- arch/arm/mach-mxs/include/mach/iomux-mx23.h | 29 +++++++ arch/arm/mach-mxs/include/mach/iomux-mx28.h | 44 +++++++++++ arch/arm/mach-mxs/include/mach/iomux.h | 77 +++++++++++++++++++ arch/arm/mach-mxs/iomux.c | 110 +++++++++++++++++++++++++++ 4 files changed, 260 insertions(+), 0 deletions(-) create mode 100644 arch/arm/mach-mxs/include/mach/iomux-mx23.h create mode 100644 arch/arm/mach-mxs/include/mach/iomux-mx28.h create mode 100644 arch/arm/mach-mxs/include/mach/iomux.h create mode 100644 arch/arm/mach-mxs/iomux.carch/arm/mach-mxs/include/mach/iomux-mx23.h new file +29
-0@@ -0,0 +1,29 @@ +/* +* Copyright (C) 2009-2010 Amit Kucheria <[email protected]> +* Copyright (C) 2010 Freescale Semiconductor, Inc. +* +* The code contained herein is licensed under the GNU General Public +* License. You may obtain a copy of the GNU General Public License +* Version 2 or later at the following locations: +* +* http://www.opensource.org/licenses/gpl-license.html +* http://www.gnu.org/copyleft/gpl.html +*/ + +#ifndef __MACH_IOMUX_MX23_H__ +#define __MACH_IOMUX_MX23_H__ + +#include <mach/iomux.h> + +/* +* The naming convention for the pad modes is MX23_PAD_<padname>__<padmode> +* If <padname> or <padmode> refers to a GPIO, it is named GPIO_<unit>_<num> +* See also iomux.h +* +* BANK PIN MUX VOL MA PULL +*/ +/* DUART */ +#define MX23_PAD_PWM0__DUART_RX IOMUX_PAD(1, 26, PAD_MUXSEL_2, PAD_VOL_NONE, PAD_4MA, PAD_NOPULL) +#define MX23_PAD_PWM1__DUART_TX IOMUX_PAD(1, 27, PAD_MUXSEL_2, PAD_VOL_NONE, PAD_4MA, PAD_NOPULL) + +#endif /* __MACH_IOMUX_MX23_H__ */ arch/arm/mach-mxs/include/mach/iomux-mx28.h new file +44
-0@@ -0,0 +1,44 @@ +/* +* Copyright (C) 2009-2010 Amit Kucheria <[email protected]> +* Copyright (C) 2010 Freescale Semiconductor, Inc. +* +* The code contained herein is licensed under the GNU General Public +* License. You may obtain a copy of the GNU General Public License +* Version 2 or later at the following locations: +* +* http://www.opensource.org/licenses/gpl-license.html +* http://www.gnu.org/copyleft/gpl.html +*/ + +#ifndef __MACH_IOMUX_MX28_H__ +#define __MACH_IOMUX_MX28_H__ + +#include <mach/iomux.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.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/mach-mxs/include/mach/iomux.h new file +21
-0@@ -0,0 +1,77 @@ +/* +* 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_MXS_IOMUX_H__
arch/arm/mach-mxs/include/mach/iomux.h line 31
Quoted 10 lines
arch/arm/mach-mxs/include/mach/iomux.h new file +10
-0+#define __MACH_MXS_IOMUX_H__ + +typedef struct pad_desc { +unsigned bank:3 ; +unsigned pin:5 ; +unsigned muxsel:2 ; +unsigned ma:3 ; +unsigned vol:2 ; +unsigned pull:1 ; +}iomux_cfg_t ;
mxc just switches to u64 (IIRC) for pad descriptions because the values are easier to manipulate. This would be better for mxs, too.
Quoted 130 lines
arch/arm/mach-mxs/include/mach/iomux.h new file +46
-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 + +/* +* setups a single pad in the iomuxer +*/ +int mxs_iomux_setup_pad (iomux_cfg_t *pad); + +/* +* setups multiple pads +* convenient way to call the above function with tables +*/ +int mxs_iomux_setup_multiple_pads (iomux_cfg_t *pad_list,unsigned count); + +/* +* Initialise the iomux controller +*/ +void mxs_iomux_init (void __iomem *iomux_base); + +#endif /* __MACH_MXS_IOMUX_H__*/ arch/arm/mach-mxs/iomux.c new file +78
-0@@ -0,0 +1,110 @@ +/* +* Copyright 2004-2006,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.h> + +static void __iomem *base; + +/* +* configures a single pad in the iomuxer +*/ +int mxs_iomux_setup_pad (iomux_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 */ + ofs =cpu_is_mx23 () ?0x200 :0x300 ; + ofs += pad->bank *0x40 + pad->pin /8 *0x10 ; +/* ma */ +if (pad->ma !=PAD_MA_NONE ) + { + bp = pad->pin %8 *4 ; + bm =0x3 << bp; + reg =__raw_readl (base + ofs); + reg &= ~bm; + reg |= pad->ma << bp; +__raw_writel (reg, base + ofs); + } +/* vol */ +if (pad->vol !=PAD_VOL_NONE ) + { + bp = pad->pin %8 *4 +2 ; + bm =0x1 << bp; + reg =__raw_readl (base + ofs); + reg &= ~bm; + reg |= pad->vol << bp; +__raw_writel (reg, base + ofs); + } + +/* pull */ + ofs =cpu_is_mx23 () ?0x400 :0x600 ; + ofs += pad->bank *0x10 ;
arch/arm/mach-mxs/iomux.c line 88
Quoted 10 lines
arch/arm/mach-mxs/iomux.c new file +10
-0+ 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 (mxs_iomux_setup_pad);
Really needed?
Quoted 12 lines
arch/arm/mach-mxs/iomux.c new file +12
-0+ +int mxs_iomux_setup_multiple_pads (iomux_cfg_t *pad_list,unsigned count) +{ +iomux_cfg_t *p = pad_list; +int i; +int ret; + +for (i =0 ; i < count; i++) { + ret =mxs_iomux_setup_pad (p); +if (ret) +return ret; + p++;
arch/arm/mach-mxs/iomux.c line 110
Quoted 10 lines
arch/arm/mach-mxs/iomux.c new file +10
-0+ } + +return 0 ; +} +EXPORT_SYMBOL (mxs_iomux_setup_multiple_pads); + +void mxs_iomux_init (void __iomem *iomux_base) +{ + base = iomux_base; +}
Best regards
Uwe
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-K?nig | Industrial Linux Solutions | http://www.pengutronix.de/ |
PATCH 9/15 ARM: mxs: Add clock support
In reply to Shawn GuoAdd clock for MXS-based SoCs, MX23 and MX28.
--- arch/arm/mach-mxs/clock-mx23.c | 521 ++++++++++++++++++++++ arch/arm/mach-mxs/clock-mx28.c | 732 +++++++++++++++++++++++++++++++ arch/arm/mach-mxs/clock.c | 201 +++++++++ arch/arm/mach-mxs/include/mach/clkdev.h | 7 + arch/arm/mach-mxs/include/mach/clock.h | 64 +++ arch/arm/mach-mxs/regs-clkctrl-mx23.h | 455 +++++++++++++++++++ arch/arm/mach-mxs/regs-clkctrl-mx28.h | 663 ++++++++++++++++++++++++++++ 7 files changed, 2643 insertions(+), 0 deletions(-) create mode 100644 arch/arm/mach-mxs/clock-mx23.c create mode 100644 arch/arm/mach-mxs/clock-mx28.c create mode 100644 arch/arm/mach-mxs/clock.c create mode 100644 arch/arm/mach-mxs/include/mach/clkdev.h create mode 100644 arch/arm/mach-mxs/include/mach/clock.h create mode 100644 arch/arm/mach-mxs/regs-clkctrl-mx23.h create mode 100644 arch/arm/mach-mxs/regs-clkctrl-mx28.h
arch/arm/mach-mxs/clock-mx23.c new file +521 -0
@@ -0,0 +1,521 @@ +/* +* 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-mx23.h" + +#define CLKCTRL_BASE_ADDR MX23_IO_ADDRESS(MX23_CLKCTRL_BASE_ADDR) +#define DIGCTRL_BASE_ADDR MX23_IO_ADDRESS(MX23_DIGCTL_BASE_ADDR) + +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 pll_clk_get_rate (struct clk *clk) +{ +return 480000000 ; +} + +static int pll_clk_enable (struct clk *clk) +{ +__raw_writel (BM_CLKCTRL_PLLCTRL0_POWER | +BM_CLKCTRL_PLLCTRL0_EN_USB_CLKS , +CLKCTRL_BASE_ADDR +HW_CLKCTRL_PLLCTRL0_SET ); + +/* Only a 10us delay is need. PLLCTRL1 LOCK bitfied is only a timer +* and is incorrect (excessive). Per definition of the PLLCTRL0 +* POWER field, waiting at least 10us. +*/ +udelay (10 ); + +return 0 ; +} + +static void pll_clk_disable (struct clk *clk) +{ +__raw_writel (BM_CLKCTRL_PLLCTRL0_POWER | +BM_CLKCTRL_PLLCTRL0_EN_USB_CLKS , +CLKCTRL_BASE_ADDR +HW_CLKCTRL_PLLCTRL0_CLR ); +} + +static struct clk pll_clk = { + .get_rate = pll_clk_get_rate, + .enable = pll_clk_enable, + .disable = pll_clk_disable, + .parent = &ref_xtal_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, FRAC, CPU) +_CLK_GET_RATE_REF(ref_emi_clk, FRAC, EMI) +_CLK_GET_RATE_REF(ref_pix_clk, FRAC, PIX) +_CLK_GET_RATE_REF(ref_io_clk, FRAC, IO) + +#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 = &pll_clk, \ + } + +_DEFINE_CLOCK_REF (ref_cpu_clk,FRAC ,CPU ); +_DEFINE_CLOCK_REF (ref_emi_clk,FRAC ,EMI ); +_DEFINE_CLOCK_REF (ref_pix_clk,FRAC ,PIX ); +_DEFINE_CLOCK_REF (ref_io_clk,FRAC ,IO ); + +/* +* General clocks +* +* clk_get_rate +*/ +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 ; +} + +#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; \ + \ + return clk_get_rate(clk->parent) / div; \ +} + +_CLK_GET_RATE1(hbus_clk, HBUS) +_CLK_GET_RATE1(xbus_clk, XBUS) +_CLK_GET_RATE1(ssp_clk, SSP) +_CLK_GET_RATE1(gpmi_clk, GPMI) +_CLK_GET_RATE1(lcdif_clk, PIX) + +#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 (audio_clk ) +_CLK_GET_RATE_STUB (pwm_clk) + +/* +* clk_set_rate +*/ +static int cpu_clk_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); + +if (clk->parent == &ref_xtal_clk) { + div_max =BM_CLKCTRL_CPU_DIV_XTAL >>BP_CLKCTRL_CPU_DIV_XTAL ; + bm_busy =BM_CLKCTRL_CPU_BUSY_REF_XTAL ; + div =DIV_ROUND_UP (parent_rate, rate); +if (div ==0 || div > div_max) +return -EINVAL ; + }else { + div_max =BM_CLKCTRL_CPU_DIV_CPU >>BP_CLKCTRL_CPU_DIV_CPU ; + bm_busy =BM_CLKCTRL_CPU_BUSY_REF_CPU ; + div = frac =1 ; + diff = parent_rate; +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_FRAC ); + reg &= ~BM_CLKCTRL_FRAC_CPUFRAC ; + reg |= frac; +__raw_writel (reg,CLKCTRL_BASE_ADDR +HW_CLKCTRL_FRAC ); + } + + reg =__raw_readl (CLKCTRL_BASE_ADDR +HW_CLKCTRL_CPU ); + reg &= ~BM_CLKCTRL_CPU_DIV_CPU ; + reg |= div <<BP_CLKCTRL_CPU_DIV_CPU ; +__raw_writel (reg,CLKCTRL_BASE_ADDR +HW_CLKCTRL_CPU ); + +for (i =10000 ; i; i--) +if (!(__raw_readl (CLKCTRL_BASE_ADDR + +HW_CLKCTRL_CPU ) & bm_busy)) +break ; +if (!i) { +pr_err ("%s: divider writing timeout\n" , __func__); +return -ETIMEDOUT ; + } + +return 0 ; +} + +#define _CLK_SET_RATE (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_RATE(xbus_clk, XBUS) +_CLK_SET_RATE(ssp_clk, SSP) +_CLK_SET_RATE(gpmi_clk, GPMI) +_CLK_SET_RATE(lcdif_clk, PIX) + +#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(audio_clk) +_CLK_SET_RATE_STUB(pwm_clk) +_CLK_SET_RATE_STUB(clk32k_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(ssp_clk, SSP) +_CLK_SET_PARENT(gpmi_clk, GPMI) +_CLK_SET_PARENT(lcdif_clk, PIX) + +#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(uart_clk) +_CLK_SET_PARENT_STUB(audio_clk) +_CLK_SET_PARENT_STUB(pwm_clk) +_CLK_SET_PARENT_STUB(clk32k_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 rtc_clk = { + .get_rate = rtc_clk_get_rate, + .parent = &ref_xtal_clk, +}; + +/* usb_clk gate is controlled in DIGCTRL other than CLKCTRL */ +static struct clk usb_clk = { + .enable_reg = DIGCTRL_BASE_ADDR, + .enable_shift = 2, + .enable = _raw_clk_enable, + .disable = _raw_clk_disable, + .parent = &pll_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(ssp_clk, SSP, CLKGATE, &ref_xtal_clk); +_DEFINE_CLOCK(gpmi_clk, GPMI, CLKGATE, &ref_xtal_clk); +_DEFINE_CLOCK(lcdif_clk, PIX, CLKGATE, &ref_xtal_clk); +_DEFINE_CLOCK(uart_clk, XTAL, UART_CLK_GATE, &ref_xtal_clk); +_DEFINE_CLOCK(audio_clk, XTAL, FILT_CLK24M_GATE, &ref_xtal_clk); +_DEFINE_CLOCK(pwm_clk, XTAL, PWM_CLK24M_GATE, &ref_xtal_clk); +_DEFINE_CLOCK(clk32k_clk, XTAL, TIMROT_CLK32K_GATE, &ref_xtal_clk); + +#define _REGISTER_CLOCK(d, n, c) \ + { \ + .dev_id = d, \ + .con_id = n, \ + .clk = &c, \ + }, + +static struct clk_lookup lookups[] = { + _REGISTER_CLOCK("mxs-duart.0", NULL, uart_clk) + _REGISTER_CLOCK("rtc", NULL, rtc_clk) + _REGISTER_CLOCK(NULL, "hclk", hbus_clk) + _REGISTER_CLOCK(NULL, "xclk", xbus_clk) + _REGISTER_CLOCK(NULL, "usb", usb_clk) + _REGISTER_CLOCK(NULL, "audio", audio_clk) + _REGISTER_CLOCK(NULL, "pwm", pwm_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; + ssp_clk.parent = (reg & BM_CLKCTRL_CLKSEQ_BYPASS_SSP) ? + &ref_xtal_clk : &ref_io_clk; + gpmi_clk.parent = (reg & BM_CLKCTRL_CLKSEQ_BYPASS_GPMI) ? + &ref_xtal_clk : &ref_io_clk; + lcdif_clk.parent = (reg & BM_CLKCTRL_CLKSEQ_BYPASS_PIX) ? + &ref_xtal_clk : &ref_pix_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_SSP); + reg &= ~BM_CLKCTRL_SSP_DIV_FRAC_EN; + __raw_writel(reg, CLKCTRL_BASE_ADDR + HW_CLKCTRL_SSP); + + 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_PIX); + reg &= ~BM_CLKCTRL_PIX_DIV_FRAC_EN; + __raw_writel(reg, CLKCTRL_BASE_ADDR + HW_CLKCTRL_PIX); + + /* + * 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_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); + + return 0; +} + +int __init mx23_clocks_init(void) +{ + clk_misc_init(); + + clkdev_add_table(lookups, ARRAY_SIZE(lookups)); + + mxs_timer_init(&clk32k_clk, MX23_IO_ADDRESS(MX23_TIMROT_BASE_ADDR), + MX23_INT_TIMER0); + + return 0; +}
arch/arm/mach-mxs/clock-mx28.c new file +732 -0
732 lines not on this page · raw message
arch/arm/mach-mxs/clock.c new file +201 -0
201 lines not on this page · raw message
arch/arm/mach-mxs/include/mach/clkdev.h new file +7 -0
@@ -0,0 +1,7 @@ +#ifndef __MACH_MXS_CLKDEV_H__ +#define __MACH_MXS_CLKDEV_H__ + +#define __clk_get (clk) ({ 1; }) +#define __clk_put (clk) do { } while (0) + +#endif
arch/arm/mach-mxs/include/mach/clock.h new file +64 -0
64 lines not on this page · raw message
arch/arm/mach-mxs/regs-clkctrl-mx23.h new file +455 -0
455 lines not on this page · raw message
arch/arm/mach-mxs/regs-clkctrl-mx28.h new file +663 -0
663 lines not on this page · raw message
Signature · 1 line
1.7.1
PATCH 9/15 ARM: mxs: Add clock support
Hello Shawn,
Quoted 63 lines · Shawn Guo
Add clock for MXS-based SoCs, MX23 and MX28.
Signed-off-by Shawn Guo <[email protected]>--- arch/arm/mach-mxs/clock-mx23.c | 521 ++++++++++++++++++++++ arch/arm/mach-mxs/clock-mx28.c | 732 +++++++++++++++++++++++++++++++ arch/arm/mach-mxs/clock.c | 201 +++++++++ arch/arm/mach-mxs/include/mach/clkdev.h | 7 + arch/arm/mach-mxs/include/mach/clock.h | 64 +++ arch/arm/mach-mxs/regs-clkctrl-mx23.h | 455 +++++++++++++++++++ arch/arm/mach-mxs/regs-clkctrl-mx28.h | 663 ++++++++++++++++++++++++++++ 7 files changed, 2643 insertions(+), 0 deletions(-) create mode 100644 arch/arm/mach-mxs/clock-mx23.c create mode 100644 arch/arm/mach-mxs/clock-mx28.c create mode 100644 arch/arm/mach-mxs/clock.c create mode 100644 arch/arm/mach-mxs/include/mach/clkdev.h create mode 100644 arch/arm/mach-mxs/include/mach/clock.h create mode 100644 arch/arm/mach-mxs/regs-clkctrl-mx23.h create mode 100644 arch/arm/mach-mxs/regs-clkctrl-mx28.harch/arm/mach-mxs/clock-mx23.c new file +37
-0@@ -0,0 +1,521 @@ +/* +* 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-mx23.h" + +#define CLKCTRL_BASE_ADDR MX23_IO_ADDRESS(MX23_CLKCTRL_BASE_ADDR) +#define DIGCTRL_BASE_ADDR MX23_IO_ADDRESS(MX23_DIGCTL_BASE_ADDR) + +static int _raw_clk_enable (struct clk *clk) +{
arch/arm/mach-mxs/clock-mx23.c line 47
Quoted 10 lines
arch/arm/mach-mxs/clock-mx23.c new file +10
-0+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 ; +}
Hmm, I would have used an approach that is quickly switchable to the generic clock stuff posted a few times here. But probably already too late. So it's up to you to decide when to switch (or if at all).
Best regards
Uwe
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-K?nig | Industrial Linux Solutions | http://www.pengutronix.de/ |
PATCH 9/15 ARM: mxs: Add clock support
Hi Uwe,
2010/12/1 Uwe Kleine-K?nig <[email protected]>:
Quoted 71 lines
Hello Shawn,
Quoted 68 lines · Shawn Guo
Add clock for MXS-based SoCs, MX23 and MX28.
Signed-off-by Shawn Guo <[email protected]>---
?arch/arm/mach-mxs/clock-mx23.c ? ? ? ? ?| ?521 ++++++++++++++++++++++ ?arch/arm/mach-mxs/clock-mx28.c ? ? ? ? ?| ?732 +++++++++++++++++++++++++++++++ ?arch/arm/mach-mxs/clock.c ? ? ? ? ? ? ? | ?201 +++++++++ ?arch/arm/mach-mxs/include/mach/clkdev.h | ? ?7 + ?arch/arm/mach-mxs/include/mach/clock.h ?| ? 64 +++ ?arch/arm/mach-mxs/regs-clkctrl-mx23.h ? | ?455 +++++++++++++++++++ ?arch/arm/mach-mxs/regs-clkctrl-mx28.h ? | ?663 ++++++++++++++++++++++++++++?7 files changed, 2643 insertions(+), 0 deletions(-) ?create mode 100644
arch/arm/mach-mxs/clock-mx23.c?create mode 100644arch/arm/mach-mxs/clock-mx28.c?create mode 100644arch/arm/mach-mxs/clock.c?create mode 100644arch/arm/mach-mxs/include/mach/clkdev.h?create mode 100644arch/arm/mach-mxs/include/mach/clock.h?create mode 100644arch/arm/mach-mxs/regs-clkctrl-mx23.h?create mode 100644arch/arm/mach-mxs/regs-clkctrl-mx28.harch/arm/mach-mxs/clock-mx23.c new file +42
-0@@ -0,0 +1,521 @@ +/* +* 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-mx23.h" + +#define CLKCTRL_BASE_ADDR ? ?MX23_IO_ADDRESS(MX23_CLKCTRL_BASE_ADDR) +#define DIGCTRL_BASE_ADDR ? ?MX23_IO_ADDRESS(MX23_DIGCTL_BASE_ADDR) + +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);
Quoted 9 lines
arch/arm/mach-mxs/clock-mx23.c line 47
Quoted 5 lines
arch/arm/mach-mxs/clock-mx23.c new file +5
-0+ ? ? ? ? ? ? __raw_writel(reg, clk->enable_reg); + ? ? } + + ? ? return 0; +}Hmm, I would have used an approach that is quickly switchable to the generic clock stuff posted a few times here. ?But probably already too late. ?So it's up to you to decide when to switch (or if at all).
I suppose you are talking about the common struct clk patch from Jeremy Kerr. Since mxs is closely tracking mxc, I would switch mxs only mxc is switched.
Signature · 2 lines
Regards, Shawn
PATCH 9/15 ARM: mxs: Add clock support
Hello Shawn,
Quoted 7 lines
Quoted 4 lines
Hmm, I would have used an approach that is quickly switchable to the generic clock stuff posted a few times here. ?But probably already too late. ?So it's up to you to decide when to switch (or if at all).
I suppose you are talking about the common struct clk patch from Jeremy Kerr. Since mxs is closely tracking mxc, I would switch mxs only mxc is switched.
I want mxc switched sooner rather than later.
If you ask me, don't stop to be inovative because of tracking mxc which supports many machines and so isn't that flexible as a new machine support.
Best regards
Uwe
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-K?nig | Industrial Linux Solutions | http://www.pengutronix.de/ |
PATCH 9/15 ARM: mxs: Add clock support
Hi Uwe,
2010/12/7 Uwe Kleine-K?nig <[email protected]>:
Quoted 6 lines
Hello Shawn,
Quoted 4 lines
Quoted 4 lines
Hmm, I would have used an approach that is quickly switchable to the generic clock stuff posted a few times here. ?But probably already too late. ?So it's up to you to decide when to switch (or if at all).
Quoted 9 lines
Quoted 3 lines
I suppose you are talking about the common struct clk patch from Jeremy Kerr. ?Since mxs is closely tracking mxc, I would switch mxs only mxc is switched.
I want mxc switched sooner rather than later.
If you ask me, don't stop to be inovative because of tracking mxc which supports many machines and so isn't that flexible as a new machine support.
OK. I will try to switch once Jeremy's bits get merged. But can we pick the current implementation on imx tree for now, and then switch based off imx tree later?
Signature · 2 lines
Regards, Shawn
PATCH 9/15 ARM: mxs: Add clock support
In reply to Shawn GuoQuoted 156 lines · Shawn Guo
Add clock for MXS-based SoCs, MX23 and MX28.
Signed-off-by Shawn Guo <[email protected]>--- arch/arm/mach-mxs/clock-mx23.c | 521 ++++++++++++++++++++++ arch/arm/mach-mxs/clock-mx28.c | 732 +++++++++++++++++++++++++++++++ arch/arm/mach-mxs/clock.c | 201 +++++++++ arch/arm/mach-mxs/include/mach/clkdev.h | 7 + arch/arm/mach-mxs/include/mach/clock.h | 64 +++ arch/arm/mach-mxs/regs-clkctrl-mx23.h | 455 +++++++++++++++++++ arch/arm/mach-mxs/regs-clkctrl-mx28.h | 663 ++++++++++++++++++++++++++++ 7 files changed, 2643 insertions(+), 0 deletions(-) create mode 100644 arch/arm/mach-mxs/clock-mx23.c create mode 100644 arch/arm/mach-mxs/clock-mx28.c create mode 100644 arch/arm/mach-mxs/clock.c create mode 100644 arch/arm/mach-mxs/include/mach/clkdev.h create mode 100644 arch/arm/mach-mxs/include/mach/clock.h create mode 100644 arch/arm/mach-mxs/regs-clkctrl-mx23.h create mode 100644 arch/arm/mach-mxs/regs-clkctrl-mx28.harch/arm/mach-mxs/clock-mx23.c new file +130
-0@@ -0,0 +1,521 @@ +/* +* 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-mx23.h" + +#define CLKCTRL_BASE_ADDR MX23_IO_ADDRESS(MX23_CLKCTRL_BASE_ADDR) +#define DIGCTRL_BASE_ADDR MX23_IO_ADDRESS(MX23_DIGCTL_BASE_ADDR) + +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 pll_clk_get_rate (struct clk *clk) +{ +return 480000000 ; +} + +static int pll_clk_enable (struct clk *clk) +{ +__raw_writel (BM_CLKCTRL_PLLCTRL0_POWER | +BM_CLKCTRL_PLLCTRL0_EN_USB_CLKS , +CLKCTRL_BASE_ADDR +HW_CLKCTRL_PLLCTRL0_SET ); + +/* Only a 10us delay is need. PLLCTRL1 LOCK bitfied is only a timer +* and is incorrect (excessive). Per definition of the PLLCTRL0 +* POWER field, waiting at least 10us. +*/ +udelay (10 ); + +return 0 ; +} + +static void pll_clk_disable (struct clk *clk) +{ +__raw_writel (BM_CLKCTRL_PLLCTRL0_POWER | +BM_CLKCTRL_PLLCTRL0_EN_USB_CLKS , +CLKCTRL_BASE_ADDR +HW_CLKCTRL_PLLCTRL0_CLR ); +} + +static struct clk pll_clk = { + .get_rate = pll_clk_get_rate, + .enable = pll_clk_enable, + .disable = pll_clk_disable, + .parent = &ref_xtal_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, FRAC, CPU) +_CLK_GET_RATE_REF(ref_emi_clk, FRAC, EMI) +_CLK_GET_RATE_REF(ref_pix_clk, FRAC, PIX) +_CLK_GET_RATE_REF(ref_io_clk, FRAC, IO) + +#define _DEFINE_CLOCK_REF (name, er, es) \
arch/arm/mach-mxs/clock-mx23.c line 140
Quoted 10 lines
arch/arm/mach-mxs/clock-mx23.c new file +10
-0+ 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 = &pll_clk, \ + } + +_DEFINE_CLOCK_REF (ref_cpu_clk,FRAC ,CPU );
What happens if get_clock_rate(ref_cpu_clk) is called?:
ref_cpu_clk_get_rate reg = something div = something else parent_rate = clk_get_rate(clk->parent) = pll_clk_get_rate() = 480000000; return parent_rate * 18 / div = (480000000 * 18) / div = 0x202fbf000 / div = ...
Note that 0x202fbf000 is too big for an unsigned long so (AFAIK) this is truncated to 0x02fbf000 / div which is wrong.
The same overflow happens in at least one set_rate function, too.
Either you have to switch to long long or (IMHO preferable) use shifted values.
Best regards
Uwe
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-K?nig | Industrial Linux Solutions | http://www.pengutronix.de/ |
PATCH 9/15 ARM: mxs: Add clock support
2010/12/2 Uwe Kleine-K?nig <[email protected]>:
Quoted 47 lines · Shawn Guo
Quoted 23 lines
(quoted diff) +23
-0+ +/* + * 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, FRAC, CPU) +_CLK_GET_RATE_REF(ref_emi_clk, FRAC, EMI) +_CLK_GET_RATE_REF(ref_pix_clk, FRAC, PIX) +_CLK_GET_RATE_REF(ref_io_clk, FRAC, IO) + +#define _DEFINE_CLOCK_REF(name, er, es) ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?\Review
Quoted 10 lines
(quoted diff) +10
-0+ ? ? 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 ? ? ? ? = &pll_clk, ? ? ? ? ? ? ? ? ? ? ? ? ? ? \ + ? ? } + +_DEFINE_CLOCK_REF(ref_cpu_clk, FRAC, CPU);What happens if
get_clock_rate(ref_cpu_clk)is called?:? ? ? ?ref_cpu_clk_get_rate
? ? ? ? ? ? ? ?reg = something
? ? ? ? ? ? ? ?div = something else
? ? ? ? ? ? ? ?parent_rate =clk_get_rate(clk->parent)? ? ? ? ? ? ? ? ? ? ? ?=pll_clk_get_rate()
? ? ? ? ? ? ? ? ? ? ? ?= 480000000;
? ? ? ? ? ? ? ?returnparent_rate* 18 / div ? ? ? ? ? ? ? ? ? ? ? ?= (480000000 * 18) / div ? ? ? ? ? ? ? ? ? ? ? ?=0x202fbf000/ div
? ? ? ? ? ? ? ? ? ? ? ?= ...
Quoted 8 lines
Note that
0x202fbf000is too big for an unsigned long so (AFAIK) this is truncated to0x02fbf000/ div which is wrong.The same overflow happens in at least one
set_ratefunction, too.Either you have to switch to long long or (IMHO preferable) use shifted values.
Excellent catch. It solved another issue that I ran into, which caused by imprecise mdelay.
Thanks a million, Uwe.
Signature · 2 lines
Regards, Shawn
PATCH 10/15 ARM: mxs: Add static memory mapping
In reply to Shawn GuoCreate static memory mapping for MX23 and MX28.
--- arch/arm/mach-mxs/mm-mx23.c | 48 +++++++++++++++++++++++++++++++++++++++++++ arch/arm/mach-mxs/mm-mx28.c | 48 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 96 insertions(+), 0 deletions(-) create mode 100644 arch/arm/mach-mxs/mm-mx23.c create mode 100644 arch/arm/mach-mxs/mm-mx28.c
arch/arm/mach-mxs/mm-mx23.c new file +48 -0
@@ -0,0 +1,48 @@ +/* +* 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.h> + +/* +* Define the MX23 memory map. +*/ +static struct map_desc mx23_io_desc[]__initdata = { +mxs_map_entry (MX23 ,OCRAM ,MT_DEVICE ), +mxs_map_entry (MX23 ,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 mx23_map_io (void ) +{ +mxs_set_cpu_type (MXS_CPU_MX23 ); +mxs_iomux_init (MX23_IO_ADDRESS (MX23_PINCTRL_BASE_ADDR )); +mxs_arch_reset_init (MX23_IO_ADDRESS (MX23_RTC_BASE_ADDR )); +iotable_init (mx23_io_desc,ARRAY_SIZE (mx23_io_desc)); +} + +void __init mx23_init_irq (void ) +{ +icoll_init_irq (MX23_IO_ADDRESS (MX23_ICOLL_BASE_ADDR )); +mx23_register_gpios (); +}
arch/arm/mach-mxs/mm-mx28.c new file +48 -0
48 lines not on this page · raw message
Signature · 1 line
1.7.1
PATCH 11/15 ARM: mxs: Dynamically allocate duart devices
In reply to Shawn GuoDynamically allocate duart devices for MX23 and MX28.
--- arch/arm/mach-mxs/devices-mx23.h | 16 +++++ arch/arm/mach-mxs/devices-mx28.h | 16 +++++ arch/arm/mach-mxs/devices.c | 75 +++++++++++++++++++++++ arch/arm/mach-mxs/devices/platform-duart.c | 47 ++++++++++++++ arch/arm/mach-mxs/include/mach/devices-common.h | 34 ++++++++++ 5 files changed, 188 insertions(+), 0 deletions(-) create mode 100644 arch/arm/mach-mxs/devices-mx23.h create mode 100644 arch/arm/mach-mxs/devices-mx28.h create mode 100644 arch/arm/mach-mxs/devices.c create mode 100644 arch/arm/mach-mxs/devices/platform-duart.c create mode 100644 arch/arm/mach-mxs/include/mach/devices-common.h
arch/arm/mach-mxs/devices-mx23.h new file +16 -0
@@ -0,0 +1,16 @@ +/* +* 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/mx23.h> +#include <mach/devices-common.h> + +extern const struct mxs_duart_data mx23_duart_data__initconst ; +#define mx23_add_duart () \ + mxs_add_duart(&mx23_duart_data)
arch/arm/mach-mxs/devices-mx28.h new file +16 -0
@@ -0,0 +1,16 @@ +/* +* 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 mxs_duart_data mx28_duart_data__initconst ; +#define mx28_add_duart () \ + mxs_add_duart(&mx28_duart_data)
arch/arm/mach-mxs/devices.c new file +75 -0
75 lines not on this page · raw message
arch/arm/mach-mxs/devices/platform-duart.c new file +47 -0
47 lines not on this page · raw message
arch/arm/mach-mxs/include/mach/devices-common.h new file +34 -0
@@ -0,0 +1,34 @@ +/* +* Copyright (C) 2009-2010 Pengutronix +* Uwe Kleine-Koenig <[email protected]> +* +* This program is free software; you can redistribute it and/or modify it under +* the terms of the GNU General Public License version 2 as published by the +* Free Software Foundation. +*/ +#include <linux/kernel.h> +#include <linux/platform_device.h> +#include <linux/init.h> + +struct platform_device *mxs_add_platform_device_dmamask ( +const char *name,int id, +const struct resource *res,unsigned int num_resources, +const void *data,size_t size_data,u64 dmamask); + +static inline struct platform_device *mxs_add_platform_device ( +const char *name,int id, +const struct resource *res,unsigned int num_resources, +const void *data,size_t size_data) +{ +return mxs_add_platform_device_dmamask ( + name, id, res, num_resources, data, size_data,0 ); +} + +/* duart */ +struct mxs_duart_data { +resource_size_t iobase; +resource_size_t iosize; +resource_size_t irq; +}; +struct platform_device *__init mxs_add_duart ( +const struct mxs_duart_data *data);
Signature · 1 line
1.7.1
PATCH 12/15 ARM: mxs: Dynamically allocate fec devices
In reply to Shawn GuoDynamically allocate fec devices for MX28, which gets dual fec interface.
--- arch/arm/mach-mxs/devices-mx28.h | 6 +++ arch/arm/mach-mxs/devices/platform-fec.c | 51 +++++++++++++++++++++++ arch/arm/mach-mxs/include/mach/devices-common.h | 12 +++++ 3 files changed, 69 insertions(+), 0 deletions(-) create mode 100644 arch/arm/mach-mxs/devices/platform-fec.c
arch/arm/mach-mxs/devices-mx28.h +6 -0
@@ -14,3 +14,9 @@extern const struct mxs_duart_data mx28_duart_data__initconst ;#define mx28_add_duart () \ mxs_add_duart(&mx28_duart_data) + +extern const struct mxs_fec_data mx28_fec_data[]__initconst ; +#define mx28_add_fec (id, pdata) \ + mxs_add_fec(&mx28_fec_data[id], pdata) +#define mx28_add_fec0 (pdata) mx28_add_fec(0, pdata) +#define mx28_add_fec1 (pdata) mx28_add_fec(1, pdata)
arch/arm/mach-mxs/devices/platform-fec.c new file +51 -0
51 lines not on this page · raw message
arch/arm/mach-mxs/include/mach/devices-common.h +12 -0
@@ -32,3 +32,15 @@ struct mxs_duart_data { };struct platform_device *__init mxs_add_duart (const struct mxs_duart_data *data); + +/* fec */ +#include <linux/fec.h> +struct mxs_fec_data { +int id; +resource_size_t iobase; +resource_size_t iosize; +resource_size_t irq; +}; +struct platform_device *__init mxs_add_fec ( +const struct mxs_fec_data *data, +const struct fec_platform_data *pdata);
Signature · 1 line
1.7.1
PATCH 12/15 ARM: mxs: Dynamically allocate fec devices
Quoted 16 lines · Shawn Guo
Dynamically allocate fec devices for MX28, which gets dual fec interface.
Signed-off-by Shawn Guo <[email protected]>--- arch/arm/mach-mxs/devices-mx28.h | 6 +++ arch/arm/mach-mxs/devices/platform-fec.c | 51 +++++++++++++++++++++++ arch/arm/mach-mxs/include/mach/devices-common.h | 12 +++++ 3 files changed, 69 insertions(+), 0 deletions(-) create mode 100644 arch/arm/mach-mxs/devices/platform-fec.carch/arm/mach-mxs/devices-mx28.h +0
-0
arch/arm/mach-mxs/devices-mx28.h line 22
Quoted 9 lines
arch/arm/mach-mxs/devices-mx28.h +6
-0@@ -14,3 +14,9 @@extern const struct mxs_duart_data mx28_duart_data__initconst ;#define mx28_add_duart () \ mxs_add_duart(&mx28_duart_data) + +extern const struct mxs_fec_data mx28_fec_data[]__initconst ; +#define mx28_add_fec (id, pdata) \ + mxs_add_fec(&mx28_fec_data[id], pdata) +#define mx28_add_fec0 (pdata) mx28_add_fec(0, pdata) +#define mx28_add_fec1 (pdata) mx28_add_fec(1, pdata)
On MXC I only kept the defines that have the id in the macro name for compatibility. Just to let you know.
Quoted 13 lines
arch/arm/mach-mxs/devices/platform-fec.c new file +7
-0@@ -0,0 +1,51 @@ +/* +* Copyright (C) 2010 Pengutronix +* Uwe Kleine-Koenig <[email protected]> +* +* This program is free software; you can redistribute it and/or modify it under +* the terms of the GNU General Public License version 2 as published by the +* Free Software Foundation.
arch/arm/mach-mxs/devices/platform-fec.c line 17
Quoted 10 lines
arch/arm/mach-mxs/devices/platform-fec.c new file +10
-0+*/ +#include <asm/sizes.h> +#include <mach/hardware.h> +#include <mach/devices-common.h> + +#define mxs_fec_data_entry_single (soc, _id, _size) \ + { \ + .id = _id, \ + .iobase = soc ## _ENET_MAC ## _id ## _BASE_ADDR, \ + .iosize = _size, \
You don't necessarily need to add the size here as it's equal for all devices.
Quoted 59 lines
arch/arm/mach-mxs/devices/platform-fec.c new file +34
-0+ .irq = soc ## _INT_ENET_MAC ## _id, \ + } + +#define mxs_fec_data_entry (soc, _id, _size) \ + [_id] = mxs_fec_data_entry_single(soc, _id, _size) + +#ifdef CONFIG_SOC_IMX28 +const struct mxs_fec_data mx28_fec_data[]__initconst = { +#define mx28_fec_data_entry(_id) \ + mxs_fec_data_entry(MX28, _id, SZ_16K) +mx28_fec_data_entry (0 ), +mx28_fec_data_entry (1 ), +}; +#endif + +struct platform_device *__init mxs_add_fec ( +const struct mxs_fec_data *data, +const struct fec_platform_data *pdata) +{ +struct resource res[] = { + { + .start = data->iobase, + .end = data->iobase + data->iosize -1 , + .flags =IORESOURCE_MEM , + }, { + .start = data->irq, + .end = data->irq, + .flags =IORESOURCE_IRQ , + }, + }; + +return mxs_add_platform_device ("fec" , data->id, + res,ARRAY_SIZE (res), pdata,sizeof (*pdata)); +}arch/arm/mach-mxs/include/mach/devices-common.h +12
-0@@ -32,3 +32,15 @@ struct mxs_duart_data { };struct platform_device *__init mxs_add_duart (const struct mxs_duart_data *data); + +/* fec */ +#include <linux/fec.h> +struct mxs_fec_data { +int id; +resource_size_t iobase; +resource_size_t iosize; +resource_size_t irq; +}; +struct platform_device *__init mxs_add_fec ( +const struct mxs_fec_data *data, +const struct fec_platform_data *pdata);Signature · 1 line
1.7.1
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-K?nig | Industrial Linux Solutions | http://www.pengutronix.de/ |
PATCH 13/15 ARM: mxs: Add initial mx23evk support
In reply to Shawn GuoAdd initial mx23evk support with duart.
--- arch/arm/mach-mxs/mach-mx23evk.c | 59 ++++++++++++++++++++++++++++++++++++++ 1 files changed, 59 insertions(+), 0 deletions(-) create mode 100644 arch/arm/mach-mxs/mach-mx23evk.c
arch/arm/mach-mxs/mach-mx23evk.c new file +59 -0
@@ -0,0 +1,59 @@ +/* +* 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-mx23.h> + +#include "devices-mx23.h" + +static iomux_cfg_t mx23evk_pads[] = { +/* duart */ +MX23_PAD_PWM0__DUART_RX , +MX23_PAD_PWM1__DUART_TX , +}; + +static void __init mx23evk_init (void ) +{ +mxs_iomux_setup_multiple_pads (mx23evk_pads,ARRAY_SIZE (mx23evk_pads)); + +mx23_add_duart (); +} + +static void __init mx23evk_timer_init (void ) +{ +mx23_clocks_init (); +} + +static struct sys_timer mx23evk_timer = { + .init = mx23evk_timer_init, +}; + +MACHINE_START (MX23EVK ,"Freescale MX23 EVK" ) +/* Maintainer: Freescale Semiconductor, Inc. */ + .boot_params = PHYS_OFFSET + 0x100, + .map_io = mx23_map_io, + .init_irq = mx23_init_irq, + .init_machine = mx23evk_init, + .timer = &mx23evk_timer, +MACHINE_END
Signature · 1 line
1.7.1
PATCH 13/15 ARM: mxs: Add initial mx23evk support
Quoted 58 lines · Shawn Guo
Add initial mx23evk support with duart.
Signed-off-by Shawn Guo <[email protected]>--- arch/arm/mach-mxs/mach-mx23evk.c | 59 ++++++++++++++++++++++++++++++++++++++ 1 files changed, 59 insertions(+), 0 deletions(-) create mode 100644 arch/arm/mach-mxs/mach-mx23evk.carch/arm/mach-mxs/mach-mx23evk.c new file +44
-0@@ -0,0 +1,59 @@ +/* +* 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-mx23.h> + +#include "devices-mx23.h" + +static iomux_cfg_t mx23evk_pads[] = { +/* duart */ +MX23_PAD_PWM0__DUART_RX , +MX23_PAD_PWM1__DUART_TX , +}; + +static void __init mx23evk_init (void ) +{ +mxs_iomux_setup_multiple_pads (mx23evk_pads,ARRAY_SIZE (mx23evk_pads)); + +mx23_add_duart (); +} + +static void __init mx23evk_timer_init (void ) +{
arch/arm/mach-mxs/mach-mx23evk.c line 54
Quoted 10 lines
arch/arm/mach-mxs/mach-mx23evk.c new file +10
-0+mx23_clocks_init (); +} + +static struct sys_timer mx23evk_timer = { + .init = mx23evk_timer_init, +}; + +MACHINE_START (MX23EVK ,"Freescale MX23 EVK" ) +/* Maintainer: Freescale Semiconductor, Inc. */ + .boot_params = PHYS_OFFSET + 0x100,
MX23_PHYS_OFFSET. Or better just don't define .boot_params at all.
Quoted 5 lines
arch/arm/mach-mxs/mach-mx23evk.c new file +5
-0+ .map_io = mx23_map_io, + .init_irq = mx23_init_irq, + .init_machine = mx23evk_init, + .timer = &mx23evk_timer, +MACHINE_END
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-K?nig | Industrial Linux Solutions | http://www.pengutronix.de/ |
PATCH 14/15 ARM: mxs: Add initial mx28evk support
In reply to Shawn GuoAdd initial mx28evk support with duart and fec0.
--- arch/arm/mach-mxs/mach-mx28evk.c | 108 ++++++++++++++++++++++++++++++++++++++ 1 files changed, 108 insertions(+), 0 deletions(-) create mode 100644 arch/arm/mach-mxs/mach-mx28evk.c
arch/arm/mach-mxs/mach-mx28evk.c new file +108 -0
@@ -0,0 +1,108 @@ +/* +* 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-mx28.h" + +#define MX28EVK_FEC_PHY_POWER MXS_GPIO_NR(2, 15) +#define MX28EVK_FEC_PHY_RESET MXS_GPIO_NR(4, 13) + +static iomux_cfg_t mx28evk_pads[] = { +/* duart */ +MX28_PAD_PWM0__DUART_RX , +MX28_PAD_PWM1__DUART_TX , + +/* fec0 */ +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 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 const struct fec_platform_data mx28_fec_pdata__initconst = { + .phy =PHY_INTERFACE_MODE_RMII , +}; + +static void __init mx28evk_init (void ) +{ +mxs_iomux_setup_multiple_pads (mx28evk_pads,ARRAY_SIZE (mx28evk_pads)); + +mx28_add_duart (); + +mx28evk_fec_reset (); +mx28_add_fec0 (&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 = PHYS_OFFSET + 0x100, + .map_io = mx28_map_io, + .init_irq = mx28_init_irq, + .init_machine = mx28evk_init, + .timer = &mx28evk_timer, +MACHINE_END
Signature · 1 line
1.7.1
PATCH 14/15 ARM: mxs: Add initial mx28evk support
Quoted 59 lines · Shawn Guo
Add initial mx28evk support with duart and fec0.
Signed-off-by Shawn Guo <[email protected]>--- arch/arm/mach-mxs/mach-mx28evk.c | 108 ++++++++++++++++++++++++++++++++++++++ 1 files changed, 108 insertions(+), 0 deletions(-) create mode 100644 arch/arm/mach-mxs/mach-mx28evk.carch/arm/mach-mxs/mach-mx28evk.c new file +45
-0@@ -0,0 +1,108 @@ +/* +* 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-mx28.h" + +#define MX28EVK_FEC_PHY_POWER MXS_GPIO_NR(2, 15) +#define MX28EVK_FEC_PHY_RESET MXS_GPIO_NR(4, 13) + +static iomux_cfg_t mx28evk_pads[] = { +/* duart */ +MX28_PAD_PWM0__DUART_RX , +MX28_PAD_PWM1__DUART_TX , + +/* fec0 */ +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 ,
arch/arm/mach-mxs/mach-mx28evk.c line 55
Quoted 10 lines
arch/arm/mach-mxs/mach-mx28evk.c new file +10
-0+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 inline void mx28evk_fec_reset (void )
If the function is inlined everything is OK. If not it should live in .init.text. I suggest to remove the inline to give the compiler the freedom to inline it or not and mark it with __init.
arch/arm/mach-mxs/mach-mx28evk.c line 65
Quoted 10 lines
arch/arm/mach-mxs/mach-mx28evk.c new file +10
-0+{ +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 );
technically gpio_direction_output can fail. Not sure this matters much here though.
arch/arm/mach-mxs/mach-mx28evk.c line 70
Quoted 5 lines
arch/arm/mach-mxs/mach-mx28evk.c new file +5
-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);
You can save a few bytes here by using the same format string as above. Obviously you need to pass "POWER" and "RESET" as parameter for that. Is it worth the effort? Up to you to decide.
Quoted 43 lines
arch/arm/mach-mxs/mach-mx28evk.c new file +38
-0+return ; + } +gpio_direction_output (MX28EVK_FEC_PHY_RESET ,0 ); +mdelay (1 ); +gpio_set_value (MX28EVK_FEC_PHY_RESET ,1 ); +} + +static const struct fec_platform_data mx28_fec_pdata__initconst = { + .phy =PHY_INTERFACE_MODE_RMII , +}; + +static void __init mx28evk_init (void ) +{ +mxs_iomux_setup_multiple_pads (mx28evk_pads,ARRAY_SIZE (mx28evk_pads)); + +mx28_add_duart (); + +mx28evk_fec_reset (); +mx28_add_fec0 (&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 = PHYS_OFFSET + 0x100, + .map_io = mx28_map_io, + .init_irq = mx28_init_irq, + .init_machine = mx28evk_init, + .timer = &mx28evk_timer, +MACHINE_END Signature · 1 line
1.7.1
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-K?nig | Industrial Linux Solutions | http://www.pengutronix.de/ |
PATCH 15/15 ARM: mxs: Add build configuration for mxs
In reply to Shawn Guo--- arch/arm/Kconfig | 10 ++++++++++ arch/arm/Makefile | 1 + arch/arm/mach-mxs/Kconfig | 34 ++++++++++++++++++++++++++++++++++ arch/arm/mach-mxs/Makefile | 14 ++++++++++++++ arch/arm/mach-mxs/Makefile.boot | 3 +++ arch/arm/mach-mxs/devices/Kconfig | 5 +++++ arch/arm/mach-mxs/devices/Makefile | 2 ++ 7 files changed, 69 insertions(+), 0 deletions(-) create mode 100644 arch/arm/mach-mxs/Kconfig create mode 100644 arch/arm/mach-mxs/Makefile create mode 100644 arch/arm/mach-mxs/Makefile.boot create mode 100644 arch/arm/mach-mxs/devices/Kconfig create mode 100644 arch/arm/mach-mxs/devices/Makefile
arch/arm/Kconfig +10 -0
@@ -351,6 +351,14 @@ config ARCH_MXC help Support for Freescale MXC/iMX-based family of processors +config ARCH_MXS + bool "Freescale MXS-based" + select GENERIC_CLOCKEVENTS + select ARCH_REQUIRE_GPIOLIB + select COMMON_CLKDEV + help + Support for Freescale MXS-based family of processors + config ARCH_STMP3XXX bool "Freescale STMP3xxx" select CPU_ARM926T
@@ -924,6 +932,8 @@ source "arch/arm/plat-pxa/Kconfig" source "arch/arm/mach-mmp/Kconfig" +source "arch/arm/mach-mxs/Kconfig" + source "arch/arm/mach-realview/Kconfig" source "arch/arm/mach-sa1100/Kconfig"
arch/arm/Makefile +1 -0
@@ -158,6 +158,7 @@ machine-$(CONFIG_ARCH_MX25) := imx machine-$(CONFIG_ARCH_MX3) := mx3 machine-$(CONFIG_ARCH_MX5) := mx5 machine-$(CONFIG_ARCH_MXC91231) := mxc91231 +machine-$(CONFIG_ARCH_MXS) := mxs machine-$(CONFIG_ARCH_NETX) := netx machine-$(CONFIG_ARCH_NOMADIK) := nomadik machine-$(CONFIG_ARCH_NS9XXX) := ns9xxx
arch/arm/mach-mxs/Kconfig new file +34 -0
@@ -0,0 +1,34 @@ +if ARCH_MXS + +source "arch/arm/mach-mxs/devices/Kconfig" + +config SOC_IMX23 + bool + select CPU_ARM926T + +config SOC_IMX28 + bool + select CPU_ARM926T + +comment "MXS platforms:" + +config MACH_MX23EVK + bool "Support MX23EVK Platform" + select SOC_IMX23 + select MXS_HAVE_PLATFORM_DUART + default y + help + Include support for MX23EVK platform. This includes specific + configurations for the board and its peripherals. + +config MACH_MX28EVK + bool "Support MX28EVK Platform" + select SOC_IMX28 + select MXS_HAVE_PLATFORM_DUART + select MXS_HAVE_PLATFORM_FEC + default y + help + Include support for MX28EVK platform. This includes specific + configurations for the board and its peripherals. + +endif
arch/arm/mach-mxs/Makefile new file +14 -0
@@ -0,0 +1,14 @@ +# +# Makefile for the linux kernel. +# + +# Common support +obj-y := clock.o cpu.o devices.o gpio.o icoll.o iomux.o system.o timer.o + +obj-$(CONFIG_SOC_IMX23) += clock-mx23.o mm-mx23.o +obj-$(CONFIG_SOC_IMX28) += clock-mx28.o mm-mx28.o + +obj-$(CONFIG_MACH_MX23EVK) += mach-mx23evk.o +obj-$(CONFIG_MACH_MX28EVK) += mach-mx28evk.o + +obj-y += devices/
arch/arm/mach-mxs/Makefile.boot new file +3 -0
@@ -0,0 +1,3 @@ + zreladdr-y := 0x40008000 +params_phys-y := 0x40000100 +initrd_phys-y := 0x40800000
arch/arm/mach-mxs/devices/Kconfig new file +5 -0
@@ -0,0 +1,5 @@ +config MXS_HAVE_PLATFORM_DUART + bool + +config MXS_HAVE_PLATFORM_FEC + bool
arch/arm/mach-mxs/devices/Makefile new file +2 -0
@@ -0,0 +1,2 @@ +obj-$(CONFIG_MXS_HAVE_PLATFORM_DUART) += platform-duart.o +obj-$(CONFIG_MXS_HAVE_PLATFORM_FEC) += platform-fec.o
Signature · 1 line
1.7.1
PATCH 15/15 ARM: mxs: Add build configuration for mxs
Quoted 36 lines · Shawn Guo
Signed-off-by Shawn Guo <[email protected]>--- arch/arm/Kconfig | 10 ++++++++++ arch/arm/Makefile | 1 + arch/arm/mach-mxs/Kconfig | 34 ++++++++++++++++++++++++++++++++++ arch/arm/mach-mxs/Makefile | 14 ++++++++++++++ arch/arm/mach-mxs/Makefile.boot | 3 +++ arch/arm/mach-mxs/devices/Kconfig | 5 +++++ arch/arm/mach-mxs/devices/Makefile | 2 ++ 7 files changed, 69 insertions(+), 0 deletions(-) create mode 100644 arch/arm/mach-mxs/Kconfig create mode 100644 arch/arm/mach-mxs/Makefile create mode 100644 arch/arm/mach-mxs/Makefile.boot create mode 100644 arch/arm/mach-mxs/devices/Kconfig create mode 100644 arch/arm/mach-mxs/devices/Makefilearch/arm/Kconfig +8
-0@@ -351,6 +351,14 @@ config ARCH_MXC help Support for Freescale MXC/iMX-based family of processors +config ARCH_MXS + bool "Freescale MXS-based" + select GENERIC_CLOCKEVENTS + select ARCH_REQUIRE_GPIOLIB + select COMMON_CLKDEV + help + Support for Freescale MXS-based family of processors + config ARCH_STMP3XXX bool "Freescale STMP3xxx" select CPU_ARM926T
arch/arm/Kconfig source "arch/arm/plat-pxa/Kconfig" · line 939
Quoted 8 lines
arch/arm/Kconfig +2
-0@@ -924,6 +932,8 @@ source "arch/arm/plat-pxa/Kconfig" source "arch/arm/mach-mmp/Kconfig" +source "arch/arm/mach-mxs/Kconfig" + source "arch/arm/mach-realview/Kconfig" source "arch/arm/mach-sa1100/Kconfig"
optimally you should put the source line between mxc and stmp3xxx to have the same order as in the symbol definition above.
Quoted 58 lines
arch/arm/Makefile +1
-0@@ -158,6 +158,7 @@ machine-$(CONFIG_ARCH_MX25) := imx machine-$(CONFIG_ARCH_MX3) := mx3 machine-$(CONFIG_ARCH_MX5) := mx5 machine-$(CONFIG_ARCH_MXC91231) := mxc91231 +machine-$(CONFIG_ARCH_MXS) := mxs machine-$(CONFIG_ARCH_NETX) := netx machine-$(CONFIG_ARCH_NOMADIK) := nomadik machine-$(CONFIG_ARCH_NS9XXX) := ns9xxxarch/arm/mach-mxs/Kconfig new file +34
-0@@ -0,0 +1,34 @@ +if ARCH_MXS + +source "arch/arm/mach-mxs/devices/Kconfig" + +config SOC_IMX23 + bool + select CPU_ARM926T + +config SOC_IMX28 + bool + select CPU_ARM926T + +comment "MXS platforms:" + +config MACH_MX23EVK + bool "Support MX23EVK Platform" + select SOC_IMX23 + select MXS_HAVE_PLATFORM_DUART + default y + help + Include support for MX23EVK platform. This includes specific + configurations for the board and its peripherals. + +config MACH_MX28EVK + bool "Support MX28EVK Platform" + select SOC_IMX28 + select MXS_HAVE_PLATFORM_DUART + select MXS_HAVE_PLATFORM_FEC + default y + help + Include support for MX28EVK platform. This includes specific + configurations for the board and its peripherals. + +endifarch/arm/mach-mxs/Makefile new file +0
-0
arch/arm/mach-mxs/Makefile line 2
Quoted 2 lines
arch/arm/mach-mxs/Makefile new file +2
-0@@ -0,0 +1,14 @@ +# +# Makefile for the linux kernel.
not very helpful
Quoted 18 lines
arch/arm/mach-mxs/Makefile new file +12
-0+# + +# Common support +obj-y := clock.o cpu.o devices.o gpio.o icoll.o iomux.o system.o timer.o + +obj-$(CONFIG_SOC_IMX23) += clock-mx23.o mm-mx23.o +obj-$(CONFIG_SOC_IMX28) += clock-mx28.o mm-mx28.o + +obj-$(CONFIG_MACH_MX23EVK) += mach-mx23evk.o +obj-$(CONFIG_MACH_MX28EVK) += mach-mx28evk.o + +obj-y += devices/arch/arm/mach-mxs/Makefile.boot new file +0
-0
arch/arm/mach-mxs/Makefile.boot line 3
Quoted 3 lines
arch/arm/mach-mxs/Makefile.boot new file +3
-0@@ -0,0 +1,3 @@ + zreladdr-y := 0x40008000 +params_phys-y := 0x40000100 +initrd_phys-y := 0x40800000
do you need params_phys and initrd_phys?
Quoted 24 lines
arch/arm/mach-mxs/devices/Kconfig new file +5
-0@@ -0,0 +1,5 @@ +config MXS_HAVE_PLATFORM_DUART + bool + +config MXS_HAVE_PLATFORM_FEC + boolarch/arm/mach-mxs/devices/Makefile new file +2
-0@@ -0,0 +1,2 @@ +obj-$(CONFIG_MXS_HAVE_PLATFORM_DUART) += platform-duart.o +obj-$(CONFIG_MXS_HAVE_PLATFORM_FEC) += platform-fec.oSignature · 1 line
1.7.1
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-K?nig | Industrial Linux Solutions | http://www.pengutronix.de/ |
PATCH v2 1/15 ARM: mxs: Add core definitions
In reply to Shawn GuoAdd core definitions for MXS-based SoC MX23 and MX28.
---
Changes for v2:
- Remove MXS_IO_P2V_MODULE from hardware.h which is not needed
- Simplify MXS_IO_P2V_MODULE definition in hardware.h
- Remove unnecessary inclusion protection from hardware.h
- Change cpu_is_mx23/mx28() implementation in mxs.h to use machine_is_xxx
arch/arm/mach-mxs/include/mach/hardware.h | 55 +++++++ arch/arm/mach-mxs/include/mach/irqs.h | 32 ++++ arch/arm/mach-mxs/include/mach/memory.h | 24 +++ arch/arm/mach-mxs/include/mach/mx23.h | 147 +++++++++++++++++++ arch/arm/mach-mxs/include/mach/mx28.h | 227 +++++++++++++++++++++++++++++ arch/arm/mach-mxs/include/mach/mxs.h | 43 ++++++ 6 files changed, 528 insertions(+), 0 deletions(-) create mode 100644 arch/arm/mach-mxs/include/mach/hardware.h create mode 100644 arch/arm/mach-mxs/include/mach/irqs.h create mode 100644 arch/arm/mach-mxs/include/mach/memory.h create mode 100644 arch/arm/mach-mxs/include/mach/mx23.h create mode 100644 arch/arm/mach-mxs/include/mach/mx28.h create mode 100644 arch/arm/mach-mxs/include/mach/mxs.h
arch/arm/mach-mxs/include/mach/hardware.h new file +55 -0
@@ -0,0 +1,55 @@ +/* +* Copyright 2004-2007 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 +* 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_MXS_HARDWARE_H__ +#define __MACH_MXS_HARDWARE_H__ + +#include <asm/sizes.h> + +#ifdef __ASSEMBLER__ +#define IOMEM (addr) (addr) +#else +#define IOMEM (addr) ((void __force __iomem *)(addr)) +#endif + +/* +* It maps the whole address space to [0xf4000000, 0xf5ffffff]. +* +* OCRAM 0x00000000+0x020000 -> 0xf4000000+0x020000 +* IO 0x80000000+0x100000 -> 0xf4400000+0x100000 +*/ +#define MXS_IO_P2V (x) (0xf4000000 + \ + (((x) & 0x80000000) >> 6) + \ + (((x) & 0x000fffff))) + + +#define MXS_IO_ADDRESS (x) IOMEM(MXS_IO_P2V(x)) + +#include <mach/mx23.h> +#include <mach/mx28.h> +#include <mach/mxs.h> + +#define mxs_map_entry (soc, name, _type) { \ + .virtual = soc ## _IO_P2V(soc ## _ ## name ## _BASE_ADDR), \ + .pfn = __phys_to_pfn(soc ## _ ## name ## _BASE_ADDR), \ + .length = soc ## _ ## name ## _SIZE, \ + .type = _type, \ +} + +#endif /* __MACH_MXS_HARDWARE_H__ */
arch/arm/mach-mxs/include/mach/irqs.h new file +32 -0
@@ -0,0 +1,32 @@ +/* +* Copyright 2004-2007 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. +*/ + +#ifndef __MACH_MXS_IRQS_H__ +#define __MACH_MXS_IRQS_H__ + +#define MXS_INTERNAL_IRQS 128 + +#define MXS_GPIO_IRQ_START MXS_INTERNAL_IRQS + +/* the maximum for MXS-based */ +#define MXS_GPIO_IRQS (32 * 5) + +/* +* The next 16 interrupts are for board specific purposes. Since +* the kernel can only run on one machine at a time, we can re-use +* these. If you need more, increase MXS_BOARD_IRQS, but keep it +* within sensible limits. +*/ +#define MXS_BOARD_IRQ_START (MXS_GPIO_IRQ_START + MXS_GPIO_IRQS) +#define MXS_BOARD_IRQS 16 + +#define NR_IRQS (MXS_BOARD_IRQ_START + MXS_BOARD_IRQS) + +#endif /* __MACH_MXS_IRQS_H__ */
arch/arm/mach-mxs/include/mach/memory.h new file +24 -0
@@ -0,0 +1,24 @@ +/* +* 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_MXS_MEMORY_H__ +#define __MACH_MXS_MEMORY_H__ + +#define PHYS_OFFSET UL(0x40000000) + +#endif /* __MACH_MXS_MEMORY_H__ */
arch/arm/mach-mxs/include/mach/mx23.h new file +147 -0
147 lines not on this page · raw message
arch/arm/mach-mxs/include/mach/mx28.h new file +227 -0
227 lines not on this page · raw message
arch/arm/mach-mxs/include/mach/mxs.h new file +43 -0
43 lines not on this page · raw message
Signature · 1 line
1.7.1
PATCH v2 1/15 ARM: mxs: Add core definitions
Hello Shawn,
Quoted 59 lines · Shawn Guo
Add core definitions for MXS-based SoC MX23 and MX28.
Signed-off-by Shawn Guo <[email protected]>---
Changes for v2:
- RemoveMXS_IO_P2V_MODULEfromhardware.hwhich is not needed
- SimplifyMXS_IO_P2V_MODULEdefinition inhardware.h
- Remove unnecessary inclusion protection fromhardware.h
- Change cpu_is_mx23/mx28() implementation inmxs.hto usemachine_is_xxxarch/arm/mach-mxs/include/mach/hardware.h | 55 +++++++ arch/arm/mach-mxs/include/mach/irqs.h | 32 ++++ arch/arm/mach-mxs/include/mach/memory.h | 24 +++ arch/arm/mach-mxs/include/mach/mx23.h | 147 +++++++++++++++++++ arch/arm/mach-mxs/include/mach/mx28.h | 227 +++++++++++++++++++++++++++++ arch/arm/mach-mxs/include/mach/mxs.h | 43 ++++++ 6 files changed, 528 insertions(+), 0 deletions(-) create mode 100644 arch/arm/mach-mxs/include/mach/hardware.h create mode 100644 arch/arm/mach-mxs/include/mach/irqs.h create mode 100644 arch/arm/mach-mxs/include/mach/memory.h create mode 100644 arch/arm/mach-mxs/include/mach/mx23.h create mode 100644 arch/arm/mach-mxs/include/mach/mx28.h create mode 100644 arch/arm/mach-mxs/include/mach/mxs.harch/arm/mach-mxs/include/mach/hardware.h new file +29
-0@@ -0,0 +1,55 @@ +/* +* Copyright 2004-2007 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 +* 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_MXS_HARDWARE_H__ +#define __MACH_MXS_HARDWARE_H__ + +#include <asm/sizes.h> + +#ifdef __ASSEMBLER__ +#define IOMEM (addr) (addr) +#else +#define IOMEM (addr) ((void __force __iomem *)(addr)) +#endif
arch/arm/mach-mxs/include/mach/hardware.h line 39
Quoted 10 lines
arch/arm/mach-mxs/include/mach/hardware.h new file +10
-0+ +/* +* It maps the whole address space to [0xf4000000, 0xf5ffffff]. +* +* OCRAM 0x00000000+0x020000 -> 0xf4000000+0x020000 +* IO 0x80000000+0x100000 -> 0xf4400000+0x100000 +*/ +#define MXS_IO_P2V (x) (0xf4000000 + \ + (((x) & 0x80000000) >> 6) + \ + (((x) & 0x000fffff)))
The comment doesn't match the function.
Quoted 123 lines
arch/arm/mach-mxs/include/mach/hardware.h new file +16
-0+ + +#define MXS_IO_ADDRESS (x) IOMEM(MXS_IO_P2V(x)) + +#include <mach/mx23.h> +#include <mach/mx28.h> +#include <mach/mxs.h> + +#define mxs_map_entry (soc, name, _type) { \ + .virtual = soc ## _IO_P2V(soc ## _ ## name ## _BASE_ADDR), \ + .pfn = __phys_to_pfn(soc ## _ ## name ## _BASE_ADDR), \ + .length = soc ## _ ## name ## _SIZE, \ + .type = _type, \ +} + +#endif /* __MACH_MXS_HARDWARE_H__ */ arch/arm/mach-mxs/include/mach/irqs.h new file +32
-0@@ -0,0 +1,32 @@ +/* +* Copyright 2004-2007 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. +*/ + +#ifndef __MACH_MXS_IRQS_H__ +#define __MACH_MXS_IRQS_H__ + +#define MXS_INTERNAL_IRQS 128 + +#define MXS_GPIO_IRQ_START MXS_INTERNAL_IRQS + +/* the maximum for MXS-based */ +#define MXS_GPIO_IRQS (32 * 5) + +/* +* The next 16 interrupts are for board specific purposes. Since +* the kernel can only run on one machine at a time, we can re-use +* these. If you need more, increase MXS_BOARD_IRQS, but keep it +* within sensible limits. +*/ +#define MXS_BOARD_IRQ_START (MXS_GPIO_IRQ_START + MXS_GPIO_IRQS) +#define MXS_BOARD_IRQS 16 + +#define NR_IRQS (MXS_BOARD_IRQ_START + MXS_BOARD_IRQS) + +#endif /* __MACH_MXS_IRQS_H__ */ arch/arm/mach-mxs/include/mach/memory.h new file +24
-0@@ -0,0 +1,24 @@ +/* +* 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_MXS_MEMORY_H__ +#define __MACH_MXS_MEMORY_H__ + +#define PHYS_OFFSET UL(0x40000000) + +#endif /* __MACH_MXS_MEMORY_H__ */ arch/arm/mach-mxs/include/mach/mx23.h new file +33
-0@@ -0,0 +1,147 @@ +/* +* 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_MX23_H__ +#define __MACH_MX23_H__ + +#ifndef __ASSEMBLER__ +#include <linux/io.h> +#endif + +/* +* OCRAM +*/ +#define MX23_OCRAM_BASE_ADDR 0x00000000 +#define MX23_OCRAM_SIZE SZ_32K + +/* +* IO
arch/arm/mach-mxs/include/mach/mx23.h line 43
Quoted 10 lines
arch/arm/mach-mxs/include/mach/mx23.h new file +10
-0+*/ +#define MX23_IO_BASE_ADDR 0x80000000 +#define MX23_IO_SIZE SZ_1M + +#define MX23_ICOLL_BASE_ADDR (MX23_IO_BASE_ADDR + 0x000000) +#define MX23_APBH_DMA_BASE_ADDR (MX23_IO_BASE_ADDR + 0x004000) +#define MX23_BCH_BASE_ADDR (MX23_IO_BASE_ADDR + 0x00a000) +#define MX23_GPMI_BASE_ADDR (MX23_IO_BASE_ADDR + 0x00c000) +#define MX23_SSP1_BASE_ADDR (MX23_IO_BASE_ADDR + 0x010000) +#define MX23_SSP2_BASE_ADDR (MX23_IO_BASE_ADDR + 0x034000)
I'd prefer to have these sorted consistently. Either sort by name or address, but not a mixure of both.
Quoted 320 lines
arch/arm/mach-mxs/include/mach/mx23.h new file +104
-0+#define MX23_PINCTRL_BASE_ADDR (MX23_IO_BASE_ADDR + 0x018000) +#define MX23_DIGCTL_BASE_ADDR (MX23_IO_BASE_ADDR + 0x01c000) +#define MX23_ETM_BASE_ADDR (MX23_IO_BASE_ADDR + 0x020000) +#define MX23_APBX_DMA_BASE_ADDR (MX23_IO_BASE_ADDR + 0x024000) +#define MX23_DCP_BASE_ADDR (MX23_IO_BASE_ADDR + 0x028000) +#define MX23_PXP_BASE_ADDR (MX23_IO_BASE_ADDR + 0x02a000) +#define MX23_OCOTP_BASE_ADDR (MX23_IO_BASE_ADDR + 0x02c000) +#define MX23_AXI_AHB0_BASE_ADDR (MX23_IO_BASE_ADDR + 0x02e000) +#define MX23_LCDIF_BASE_ADDR (MX23_IO_BASE_ADDR + 0x030000) +#define MX23_TVENC_BASE_ADDR (MX23_IO_BASE_ADDR + 0x038000) +#define MX23_CLKCTRL_BASE_ADDR (MX23_IO_BASE_ADDR + 0x040000) +#define MX23_SAIF0_BASE_ADDR (MX23_IO_BASE_ADDR + 0x042000) +#define MX23_POWER_BASE_ADDR (MX23_IO_BASE_ADDR + 0x044000) +#define MX23_SAIF1_BASE_ADDR (MX23_IO_BASE_ADDR + 0x046000) +#define MX23_AUDIOOUT_BASE_ADDR (MX23_IO_BASE_ADDR + 0x048000) +#define MX23_AUDIOIN_BASE_ADDR (MX23_IO_BASE_ADDR + 0x04c000) +#define MX23_LRADC_BASE_ADDR (MX23_IO_BASE_ADDR + 0x050000) +#define MX23_SPDIF_BASE_ADDR (MX23_IO_BASE_ADDR + 0x054000) +#define MX23_RTC_BASE_ADDR (MX23_IO_BASE_ADDR + 0x05c000) +#define MX23_I2C0_BASE_ADDR (MX23_IO_BASE_ADDR + 0x058000) +#define MX23_PWM_BASE_ADDR (MX23_IO_BASE_ADDR + 0x064000) +#define MX23_TIMROT_BASE_ADDR (MX23_IO_BASE_ADDR + 0x068000) +#define MX23_AUART1_BASE_ADDR (MX23_IO_BASE_ADDR + 0x06c000) +#define MX23_AUART2_BASE_ADDR (MX23_IO_BASE_ADDR + 0x06e000) +#define MX23_DUART_BASE_ADDR (MX23_IO_BASE_ADDR + 0x070000) +#define MX23_USBPHY_BASE_ADDR (MX23_IO_BASE_ADDR + 0x07c000) +#define MX23_USBCTRL_BASE_ADDR (MX23_IO_BASE_ADDR + 0x080000) +#define MX23_DRAM_BASE_ADDR (MX23_IO_BASE_ADDR + 0x0e0000) + +#define MX23_IO_P2V (x) MXS_IO_P2V(x) +#define MX23_IO_ADDRESS (x) IOMEM(MX23_IO_P2V(x)) + +/* +* IRQ +*/ +#define MX23_INT_DUART 0 +#define MX23_INT_COMMS_RX 1 +#define MX23_INT_COMMS_TX 1 +#define MX23_INT_SSP2_ERROR 2 +#define MX23_INT_VDD5V 3 +#define MX23_INT_HEADPHONE_SHORT 4 +#define MX23_INT_DAC_DMA 5 +#define MX23_INT_DAC_ERROR 6 +#define MX23_INT_ADC_DMA 7 +#define MX23_INT_ADC_ERROR 8 +#define MX23_INT_SPDIF_DMA 9 +#define MX23_INT_SAIF2_DMA 9 +#define MX23_INT_SPDIF_ERROR 10 +#define MX23_INT_SAIF1_IRQ 10 +#define MX23_INT_SAIF2_IRQ 10 +#define MX23_INT_USB_CTRL 11 +#define MX23_INT_USB_WAKEUP 12 +#define MX23_INT_GPMI_DMA 13 +#define MX23_INT_SSP1_DMA 14 +#define MX23_INT_SSP_ERROR 15 +#define MX23_INT_GPIO0 16 +#define MX23_INT_GPIO1 17 +#define MX23_INT_GPIO2 18 +#define MX23_INT_SAIF1_DMA 19 +#define MX23_INT_SSP2_DMA 20 +#define MX23_INT_ECC8_IRQ 21 +#define MX23_INT_RTC_ALARM 22 +#define MX23_INT_UARTAPP_TX_DMA 23 +#define MX23_INT_UARTAPP_INTERNAL 24 +#define MX23_INT_UARTAPP_RX_DMA 25 +#define MX23_INT_I2C_DMA 26 +#define MX23_INT_I2C_ERROR 27 +#define MX23_INT_TIMER0 28 +#define MX23_INT_TIMER1 29 +#define MX23_INT_TIMER2 30 +#define MX23_INT_TIMER3 31 +#define MX23_INT_BATT_BRNOUT 32 +#define MX23_INT_VDDD_BRNOUT 33 +#define MX23_INT_VDDIO_BRNOUT 34 +#define MX23_INT_VDD18_BRNOUT 35 +#define MX23_INT_TOUCH_DETECT 36 +#define MX23_INT_LRADC_CH0 37 +#define MX23_INT_LRADC_CH1 38 +#define MX23_INT_LRADC_CH2 39 +#define MX23_INT_LRADC_CH3 40 +#define MX23_INT_LRADC_CH4 41 +#define MX23_INT_LRADC_CH5 42 +#define MX23_INT_LRADC_CH6 43 +#define MX23_INT_LRADC_CH7 44 +#define MX23_INT_LCDIF_DMA 45 +#define MX23_INT_LCDIF_ERROR 46 +#define MX23_INT_DIGCTL_DEBUG_TRAP 47 +#define MX23_INT_RTC_1MSEC 48 +#define MX23_INT_DRI_DMA 49 +#define MX23_INT_DRI_ATTENTION 50 +#define MX23_INT_GPMI_ATTENTION 51 +#define MX23_INT_IR 52 +#define MX23_INT_DCP_VMI 53 +#define MX23_INT_DCP 54 +#define MX23_INT_BCH 56 +#define MX23_INT_PXP 57 +#define MX23_INT_UARTAPP2_TX_DMA 58 +#define MX23_INT_UARTAPP2_INTERNAL 59 +#define MX23_INT_UARTAPP2_RX_DMA 60 +#define MX23_INT_VDAC_DETECT 61 +#define MX23_INT_VDD5V_DROOP 64 +#define MX23_INT_DCDC4P2_BO 65 + +#endif /* __MACH_MX23_H__ */ arch/arm/mach-mxs/include/mach/mx28.h new file +210
-0@@ -0,0 +1,227 @@ +/* +* 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_MX28_H__ +#define __MACH_MX28_H__ + +#ifndef __ASSEMBLER__ +#include <linux/io.h> +#endif + +/* +* 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) +#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_MAC0_BASE_ADDR (MX28_IO_BASE_ADDR + 0x0f0000) +#define MX28_ENET_MAC1_BASE_ADDR (MX28_IO_BASE_ADDR + 0x0f4000) + +#define MX28_IO_P2V (x) MXS_IO_P2V(x) +#define MX28_IO_ADDRESS (x) IOMEM(MX28_IO_P2V(x)) + +/* +* 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/mach-mxs/include/mach/mx28.h line 220
Quoted 10 lines
arch/arm/mach-mxs/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 skip these RESV defines. They are unused anyhow. And as soon as you need them they need a more sensible name anyhow.
Quoted 44 lines
arch/arm/mach-mxs/include/mach/mx28.h new file +7
-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 + +#endif /* __MACH_MX28_H__ */ arch/arm/mach-mxs/include/mach/mxs.h new file +31
-0@@ -0,0 +1,43 @@ +/* +* 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_MXS_H__ +#define __MACH_MXS_H__ + +#include <asm/mach-types.h> + +#define MXS_SET_ADDR 0x4 +#define MXS_CLR_ADDR 0x8 +#define MXS_TOG_ADDR 0xc + +/* +* MXS CPU types +*/ +#ifdef CONFIG_SOC_IMX23
arch/arm/mach-mxs/include/mach/mxs.h line 41
Quoted 10 lines
arch/arm/mach-mxs/include/mach/mxs.h new file +10
-0+# define cpu_is_mx23 () (machine_is_mx23evk()) +#else +# define cpu_is_mx23 () (0) +#endif + +#ifdef CONFIG_SOC_IMX28 +# define cpu_is_mx28 () (machine_is_mx28evk()) +#else +# define cpu_is_mx28 () (0) +#endif
Why not just:
#define cpu_is_mx28() (machine_is_mx28evk())
? If MACH_MX28EVK isn't defined the macro expands so 0 anyhow.
Uwe
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-K?nig | Industrial Linux Solutions | http://www.pengutronix.de/ |
PATCH v2 2/15 ARM: mxs: Add helper definition and function
In reply to Shawn GuoAdd helper definition and function for MXS-based.
---
Changes for v2:
- Remove cpu.c and reference to mxs_set_cpu_type() from common.h
arch/arm/mach-mxs/include/mach/common.h | 32 ++++++++++++++++++++++++++++++ arch/arm/mach-mxs/include/mach/io.h | 22 ++++++++++++++++++++ arch/arm/mach-mxs/include/mach/timex.h | 21 +++++++++++++++++++ arch/arm/mach-mxs/include/mach/vmalloc.h | 22 ++++++++++++++++++++ 4 files changed, 97 insertions(+), 0 deletions(-) create mode 100644 arch/arm/mach-mxs/include/mach/common.h create mode 100644 arch/arm/mach-mxs/include/mach/io.h create mode 100644 arch/arm/mach-mxs/include/mach/timex.h create mode 100644 arch/arm/mach-mxs/include/mach/vmalloc.h
arch/arm/mach-mxs/include/mach/common.h new file +32 -0
@@ -0,0 +1,32 @@ +/* +* Copyright 2004-2007 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. +*/ + +#ifndef __MACH_MXS_COMMON_H__ +#define __MACH_MXS_COMMON_H__ + +struct clk ; + +extern int mxs_reset_block (void __iomem *); +extern void mxs_arch_reset_init (void __iomem *); +extern void mxs_timer_init (struct clk *,void __iomem *,int ); + +extern int mx23_register_gpios (void ); +extern int mx23_clocks_init (void ); +extern void mx23_map_io (void ); +extern void mx23_init_irq (void ); + +extern int mx28_register_gpios (void ); +extern int mx28_clocks_init (void ); +extern void mx28_map_io (void ); +extern void mx28_init_irq (void ); + +extern void icoll_init_irq (void __iomem *); + +#endif /* __MACH_MXS_COMMON_H__ */
arch/arm/mach-mxs/include/mach/io.h new file +22 -0
@@ -0,0 +1,22 @@ +/* +* Copyright 2004-2007 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. +*/ + +#ifndef __MACH_MXS_IO_H__ +#define __MACH_MXS_IO_H__ + +/* Allow IO space to be anywhere in the memory */ +#define IO_SPACE_LIMIT 0xffffffff + +/* io address mapping macro */ +#define __io (a) __typesafe_io(a) + +#define __mem_pci (a) (a) + +#endif /* __MACH_MXS_IO_H__ */
arch/arm/mach-mxs/include/mach/timex.h new file +21 -0
@@ -0,0 +1,21 @@ +/* +* Copyright (C) 1999 ARM Limited +* Copyright 2004-2007 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. +*/ + +#ifndef __MACH_MXS_TIMEX_H__ +#define __MACH_MXS_TIMEX_H__ + +#define CLOCK_TICK_RATE 32000/* 32K */ + +#endif /* __MACH_MXS_TIMEX_H__ */
arch/arm/mach-mxs/include/mach/vmalloc.h new file +22 -0
@@ -0,0 +1,22 @@ +/* +* Copyright (C) 2000 Russell King. +* Copyright 2004-2007 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. +*/ + +#ifndef __MACH_MXS_VMALLOC_H__ +#define __MACH_MXS_VMALLOC_H__ + +/* vmalloc ending address */ +#define VMALLOC_END 0xf4000000UL + +#endif /* __MACH_MXS_VMALLOC_H__ */
Signature · 1 line
1.7.1
PATCH v2 3/15 ARM: mxs: Add reset routines
In reply to Shawn Guo - The mxs wdog is implemented in RTC block.
- There is a generic software reset routine for most modules on mxs.
---
Changes for v2:
- Move rtc clock enabling from arch_reset() into mxs_arch_reset_init()
arch/arm/mach-mxs/include/mach/system.h | 27 ++++++ arch/arm/mach-mxs/system.c | 152 +++++++++++++++++++++++++++++++ 2 files changed, 179 insertions(+), 0 deletions(-) create mode 100644 arch/arm/mach-mxs/include/mach/system.h create mode 100644 arch/arm/mach-mxs/system.c
arch/arm/mach-mxs/include/mach/system.h new file +27 -0
@@ -0,0 +1,27 @@ +/* +* Copyright (C) 1999 ARM Limited +* Copyright (C) 2000 Deep Blue Solutions Ltd +* Copyright 2004-2008 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. +*/ + +#ifndef __MACH_MXS_SYSTEM_H__ +#define __MACH_MXS_SYSTEM_H__ + +static inline void arch_idle (void ) +{ +cpu_do_idle (); +} + +void arch_reset (char mode,const char *cmd); + +#endif /* __MACH_MXS_SYSTEM_H__ */
arch/arm/mach-mxs/system.c new file +152 -0
152 lines not on this page · raw message
Signature · 1 line
1.7.1
PATCH v2 3/15 ARM: mxs: Add reset routines
Hello,
Quoted 88 lines · Shawn Guo
- The mxs wdog is implemented in RTC block.
- There is a generic software reset routine for most modules on mxs.Signed-off-by Shawn Guo <[email protected]>---
Changes for v2:
- Move rtc clock enabling fromarch_reset()intomxs_arch_reset_init()arch/arm/mach-mxs/include/mach/system.h | 27 ++++++ arch/arm/mach-mxs/system.c | 152 +++++++++++++++++++++++++++++++ 2 files changed, 179 insertions(+), 0 deletions(-) create mode 100644 arch/arm/mach-mxs/include/mach/system.h create mode 100644 arch/arm/mach-mxs/system.carch/arm/mach-mxs/include/mach/system.h new file +27
-0@@ -0,0 +1,27 @@ +/* +* Copyright (C) 1999 ARM Limited +* Copyright (C) 2000 Deep Blue Solutions Ltd +* Copyright 2004-2008 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. +*/ + +#ifndef __MACH_MXS_SYSTEM_H__ +#define __MACH_MXS_SYSTEM_H__ + +static inline void arch_idle (void ) +{ +cpu_do_idle (); +} + +void arch_reset (char mode,const char *cmd); + +#endif /* __MACH_MXS_SYSTEM_H__ */ arch/arm/mach-mxs/system.c new file +35
-0@@ -0,0 +1,152 @@ +/* +* Copyright (C) 1999 ARM Limited +* Copyright (C) 2000 Deep Blue Solutions Ltd +* Copyright 2006-2007,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 +* +* 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/kernel.h> +#include <linux/clk.h> +#include <linux/io.h> +#include <linux/err.h> +#include <linux/delay.h> + +#include <asm/proc-fns.h> +#include <asm/system.h> + +#include <mach/hardware.h> +#include <mach/common.h> + +#define MXS_RTC_WATCHDOG 0x50 +#define MXS_WATCHDOG_EN (1 << 4) + +#define MXS_MODULE_CLKGATE (1 << 30) +#define MXS_MODULE_SFTRST (1 << 31)
arch/arm/mach-mxs/system.c line 45
Quoted 10 lines
arch/arm/mach-mxs/system.c new file +10
-0+ +static void __iomem *wdog_base; + +/* +* Reset the system. It is called by machine_restart(). +*/ +void arch_reset (char mode,const char *cmd) +{ +/* Set wdog count */ +__raw_writel (1 , wdog_base +MXS_RTC_WATCHDOG );
Which unit is used here? Does the timer only start running when it's enabled below? Does this apply when the watchdog is already in use, too?
Quoted 15 lines
arch/arm/mach-mxs/system.c new file +15
-0+ +/* Assert SRS signal */ +__raw_writel (MXS_WATCHDOG_EN , wdog_base +MXS_SET_ADDR ); + +/* Wait for reset to assert... */ +mdelay (500 ); + +pr_err ("Watchdog reset failed to assert reset\n" ); + +/* Delay to allow the serial port to show the message */ +mdelay (50 ); + +/* We'll take a jump through zero as a poor second */ +cpu_reset (0 ); +}
arch/arm/mach-mxs/system.c line 70
Quoted 10 lines
arch/arm/mach-mxs/system.c new file +10
-0+ +void mxs_arch_reset_init (void __iomem *base) +{ +struct clk *clk; + + wdog_base = base; + + clk =clk_get_sys ("rtc" ,NULL ); +if (!IS_ERR (clk)) +clk_enable (clk);
Actually I'm not sure if it's worth to do this. It might hurt if you want to save power.
I'll try to find a time slot to look into that.
Quoted 11 lines
arch/arm/mach-mxs/system.c new file +11
-0+} + +int mxs_reset_block (void __iomem *reset_addr) +{ +u32 val; +int timeout; + +/* +* The process of software reset of IP block is done +* in several steps: +*
arch/arm/mach-mxs/system.c line 91
Quoted 10 lines
arch/arm/mach-mxs/system.c new file +10
-0+* 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 */ + val =__raw_readl (reset_addr); + val &= ~MXS_MODULE_SFTRST ; +__raw_writel (val, reset_addr);
__raw_writel(MXS_MODULE_SFTRST, reset_addr + MXS_CLEAR_ADDR);
instead of read-modify-write here doesn't work here?
arch/arm/mach-mxs/system.c line 101
Quoted 10 lines
arch/arm/mach-mxs/system.c new file +10
-0+/* +* SFTRST needs 3 GPMI clocks to settle, the reference manual +* recommends to wait 1us. +*/ +udelay (1 ); +/* Poll SFTRST cleared */ + timeout =0x400 ; +while ((__raw_readl (reset_addr) &MXS_MODULE_SFTRST ) && --timeout) +/* nothing */ ; +if (!timeout)
Maybe add an unlikely here? (i.e.
if (unlikely(!timeout)) ...
)
arch/arm/mach-mxs/system.c line 105
Quoted 4 lines
arch/arm/mach-mxs/system.c new file +4
-0+ goto error; + +/* Clear CLKGATE */ + val =__raw_readl (reset_addr);
Not sure it's worth to optimize here, but you read reset_addr above.
arch/arm/mach-mxs/system.c line 113
Quoted 8 lines
arch/arm/mach-mxs/system.c new file +8
-0+ val &= ~MXS_MODULE_CLKGATE ; +__raw_writel (val, reset_addr); +/* Set SFTRST to reset the block */ + val =__raw_readl (reset_addr); + val |=MXS_MODULE_SFTRST ; +__raw_writel (val, reset_addr); +/* Wait 1us */ +udelay (1 );
The comment doesn't help much.
Quoted 22 lines
arch/arm/mach-mxs/system.c new file +22
-0+/* Poll CLKGATE set */ + timeout =0x400 ; +while ((!(__raw_readl (reset_addr) &MXS_MODULE_CLKGATE )) && --timeout) +/* nothing */ ; +if (!timeout) + goto error; + +/* Clear SFTRST */ + val =__raw_readl (reset_addr); + val &= ~MXS_MODULE_SFTRST ; +__raw_writel (val, reset_addr); +/* Wait 1us */ +udelay (1 ); +/* Poll SFTRST cleared */ + timeout =0x400 ; +while ((__raw_readl (reset_addr) &MXS_MODULE_SFTRST ) && --timeout) +/* nothing */ ; +if (!timeout) + goto error; + +/* Clear CLKGATE */ + val =__raw_readl (reset_addr);
arch/arm/mach-mxs/system.c line 145
Quoted 10 lines
arch/arm/mach-mxs/system.c new file +10
-0+ val &= ~MXS_MODULE_CLKGATE ; +__raw_writel (val, reset_addr); +/* Wait 1us */ +udelay (1 ); +/* Poll CLKGATE cleared */ + timeout =0x400 ; +while ((__raw_readl (reset_addr) &MXS_MODULE_CLKGATE ) && --timeout) +/* nothing */ ; +if (!timeout) + goto error;
There are quite some repetitions in this function. If you could get it down to something that looks like
clear SFTRST
udelay
poll SFTRST cleared
clear CLKGATE
set SFTRST
udelay
poll CLKGATE set
clear SFTRST
udelay
poll SFTRST cleared
clear CLKGATE
udelay
poll CLKGATE cleared
it's IMHO better than the comment above. If "clear CLKGATE" and "set SFTRST" can be done in a single step this might be done like that:
/* comment describing setmask_poll */
static int setmask_poll(void __iomem *addr, u32 set, u32 mask,
u32 pollval, u32 pollmask, u32 *curval)
{
int timeout = 0x400;
*curval &= ~mask;
*curval |= set;
__raw_writel(*curval, addr)
/*
* some nice comment about 1us being a good idea
*/
udelay(1);
do {
*curval = __raw_readl(addr);
if ((*curval & pollmask) == pollval)
return 0;
} while(--timeout);
return 1;
}
int mxs_reset_block(void __iomem *reset_addr)
{
u32 val = __raw_readl(reset_addr);
int ret;
/* clear SFTRST and poll SFTRST becoming clear */
ret = setmask_poll(reset_addr,
0, MXS_MODULE_SFTRST,
0, MXS_MODULE_SFTRST, &val);
if (ret)
goto error;
/* clear CLKGATE, set SFTRST and poll CLKGATE becoming set */
ret = setmask_poll(reset_addr,
MXS_MODULE_SFTRST, MXS_MODULE_SFTRST | MXS_MODULE_CLKGATE,
0, MXS_MODULE_CLKGATE, &val);
if (ret)
goto error;
...
}Well, not very nice, but IMHO better that your code. Maybe mxs_reset_block fits in a Terminal that way without decreasing the font size :-)
Quoted 12 lines
arch/arm/mach-mxs/system.c new file +7
-0+ +return 0 ; + +error: +pr_err ("%s(%p): module reset timeout\n" , __func__, reset_addr); +return -ETIMEDOUT ; +}Signature · 1 line
1.7.1
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-K?nig | Industrial Linux Solutions | http://www.pengutronix.de/ |
PATCH v2 3/15 ARM: mxs: Add reset routines
Hi Uwe,
2010/11/30 Uwe Kleine-K?nig <[email protected]>:
Quoted 14 lines
Hello,
arch/arm/mach-mxs/system.c
Quoted 7 lines · Shawn Guo
arch/arm/mach-mxs/system.c new file +7
-0+/* +* Reset the system. It is called by machine_restart(). +*/ +void arch_reset (char mode,const char *cmd) +{ + ? ? /* Set wdog count */ + ? ? __raw_writel(1, wdog_base + MXS_RTC_WATCHDOG);Which unit is used here? ?Does the timer only start running when it's enabled below? ?Does this apply when the watchdog is already in use, too?
The unit RTC (i.MX28 RM chapter 22) which has watchdog function inside is used here.
Good catch here. I thought the watchdog counter only starts counting after WATCHDOG_EN is set. But I just confirmed it with designer that the watchdog counter starts counting once CLKGATE is cleared, and WATCHDOG_EN bit only controls the watchdog reset generation. Even in this case, 1ms should be long enough for the WATCHDOG_EN setting below to get executed before counter goes to 0. What is your concern here?
I should change mdelay(500) to mdelay(1).
Quoted 28 lines
Quoted 15 lines
(quoted diff) +15
-0+ + ? ? /* Assert SRS signal */ + ? ? __raw_writel(MXS_WATCHDOG_EN, wdog_base + MXS_SET_ADDR); + + ? ? /* Wait for reset to assert... */ + ? ? mdelay(500); + + ? ? pr_err("Watchdog reset failed to assert reset\n"); + + ? ? /* Delay to allow the serial port to show the message */ + ? ? mdelay(50); + + ? ? /* We'll take a jump through zero as a poor second */ + ? ? cpu_reset(0); +}Review
Quoted 10 lines
(quoted diff) +10
-0+ +void mxs_arch_reset_init(void __iomem *base) +{ + ? ? struct clk *clk; + + ? ? wdog_base = base; + + ? ? clk = clk_get_sys("rtc", NULL); + ? ? if (!IS_ERR(clk)) + ? ? ? ? ? ? clk_enable(clk);Actually I'm not sure if it's worth to do this. ?It might hurt if you want to save power.
Quoted 2 lines
I'll try to find a time slot to look into that.
As this is the very initial support, I would not consider the power saving very much. I will be very happy to applied your solution after it becomes available.
Signature · 2 lines
Regards, Shawn
PATCH v2 3/15 ARM: mxs: Add reset routines
Quoted 17 lines · Shawn Guo
Hi Uwe,
2010/11/30 Uwe Kleine-K?nig <[email protected]>:
Quoted 14 lines
Hello,
arch/arm/mach-mxs/system.c
Quoted 7 lines · Shawn Guo
arch/arm/mach-mxs/system.c new file +7
-0+/* +* Reset the system. It is called by machine_restart(). +*/ +void arch_reset (char mode,const char *cmd) +{ + ? ? /* Set wdog count */ + ? ? __raw_writel(1, wdog_base + MXS_RTC_WATCHDOG);Which unit is used here? ?Does the timer only start running when it's enabled below? ?Does this apply when the watchdog is already in use, too?
Quoted 2 lines
The unit RTC (i.MX28 RM chapter 22) which has watchdog function inside is used here.
"unit" was meant as in "seconds". I assume it means seconds below, but it doesn't matter much.
Quoted 6 lines
Good catch here. I thought the watchdog counter only starts counting after
WATCHDOG_ENis set. But I just confirmed it with designer that the watchdog counter starts counting once CLKGATE is cleared, andWATCHDOG_ENbit only controls the watchdog reset generation. Even in this case, 1ms should be long enough for theWATCHDOG_ENsetting below to get executed before counter goes to 0. What is your concern here?
My concern is that it might happen that even though the timer is set to 1s, the first change happens nearly immediatly resulting in a zero. Depending on the hardware a reset occurs when the enable bit is only set after the counter reached zero.
Quoted 30 lines
I should change mdelay(500) to mdelay(1).
Quoted 28 lines
Quoted 15 lines
(quoted diff) +15
-0+ + ? ? /* Assert SRS signal */ + ? ? __raw_writel(MXS_WATCHDOG_EN, wdog_base + MXS_SET_ADDR); + + ? ? /* Wait for reset to assert... */ + ? ? mdelay(500); + + ? ? pr_err("Watchdog reset failed to assert reset\n"); + + ? ? /* Delay to allow the serial port to show the message */ + ? ? mdelay(50); + + ? ? /* We'll take a jump through zero as a poor second */ + ? ? cpu_reset(0); +}Review
Quoted 10 lines
(quoted diff) +10
-0+ +void mxs_arch_reset_init(void __iomem *base) +{ + ? ? struct clk *clk; + + ? ? wdog_base = base; + + ? ? clk = clk_get_sys("rtc", NULL); + ? ? if (!IS_ERR(clk)) + ? ? ? ? ? ? clk_enable(clk);Actually I'm not sure if it's worth to do this. ?It might hurt if you want to save power.
Quoted 5 lines
Quoted 2 lines
I'll try to find a time slot to look into that.
As this is the very initial support, I would not consider the power saving very much. I will be very happy to applied your solution after it becomes available.
That's OK
Uwe
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-K?nig | Industrial Linux Solutions | http://www.pengutronix.de/ |
PATCH v2 3/15 ARM: mxs: Add reset routines
Hi Uwe,
2010/12/1 Uwe Kleine-K?nig <[email protected]>:
Quoted 18 lines · Shawn Guo
Quoted 17 lines
Hi Uwe,
2010/11/30 Uwe Kleine-K?nig <[email protected]>:
Quoted 14 lines
Hello,
arch/arm/mach-mxs/system.c
Quoted 7 lines · Shawn Guo
arch/arm/mach-mxs/system.c new file +7
-0+/* +* Reset the system. It is called by machine_restart(). +*/ +void arch_reset (char mode,const char *cmd) +{ + ? ? /* Set wdog count */ + ? ? __raw_writel(1, wdog_base + MXS_RTC_WATCHDOG);Which unit is used here? ?Does the timer only start running when it's enabled below? ?Does this apply when the watchdog is already in use, too?
Quoted 5 lines
Quoted 2 lines
The unit RTC (i.MX28 RM chapter 22) which has watchdog function inside is used here.
"unit" was meant as in "seconds". ?I assume it means seconds below, but it doesn't matter much.
Sorry. The unit is 1ms.
Quoted 11 lines
Quoted 6 lines
Good catch here. ?I thought the watchdog counter only starts counting after
WATCHDOG_ENis set. ?But I just confirmed it with designer that the watchdog counter starts counting once CLKGATE is cleared, andWATCHDOG_ENbit only controls the watchdog reset generation. ?Even in this case, 1ms should be long enough for theWATCHDOG_ENsetting below to get executed before counter goes to 0. ?What is your concern here?My concern is that it might happen that even though the timer is set to 1s, the first change happens nearly immediatly resulting in a zero. Depending on the hardware a reset occurs when the enable bit is only set after the counter reached zero.
Should the following changes be safe enough to address your concern?
/* Set wdog timer 10 ms */
__raw_writel(10, wdog_base + MXS_RTC_WATCHDOG);
/* Enable wdog reset */
__raw_writel(MXS_WATCHDOG_EN, wdog_base + MXS_SET_ADDR);
/* Wait for reset to assert... */
mdelay(10);Signature · 2 lines
Regards, Shawn
PATCH v2 3/15 ARM: mxs: Add reset routines
In reply to Uwe Kleine-KönigHi Uwe,
2010/11/30 Uwe Kleine-K?nig <[email protected]>:
Quoted 2 lines
Hello,
[...]
Quoted 101 lines
Quoted 23 lines
+ ? ? /* Poll CLKGATE set */
+ ? ? timeout =0x400;
+ ? ? while ((!(__raw_readl(reset_addr) &MXS_MODULE_CLKGATE)) && --timeout)
+ ? ? ? ? ? ? /* nothing */;
+ ? ? if (!timeout)
+ ? ? ? ? ? ? goto error;(quoted diff) +16
-0+ + ? ? /* Clear SFTRST */ + ? ? val = __raw_readl(reset_addr); + ? ? val &= ~MXS_MODULE_SFTRST; + ? ? __raw_writel(val, reset_addr); + ? ? /* Wait 1us */ + ? ? udelay(1); + ? ? /* Poll SFTRST cleared */ + ? ? timeout = 0x400; + ? ? while ((__raw_readl(reset_addr) & MXS_MODULE_SFTRST) && --timeout) + ? ? ? ? ? ? /* nothing */; + ? ? if (!timeout) + ? ? ? ? ? ? goto error; + + ? ? /* Clear CLKGATE */ + ? ? val = __raw_readl(reset_addr);Review
Quoted 10 lines
(quoted diff) +10
-0+ ? ? val &= ~MXS_MODULE_CLKGATE; + ? ? __raw_writel(val, reset_addr); + ? ? /* Wait 1us */ + ? ? udelay(1); + ? ? /* Poll CLKGATE cleared */ + ? ? timeout = 0x400; + ? ? while ((__raw_readl(reset_addr) & MXS_MODULE_CLKGATE) && --timeout) + ? ? ? ? ? ? /* nothing */; + ? ? if (!timeout) + ? ? ? ? ? ? goto error;There are quite some repetitions in this function. ?If you could get it down to something that looks like
? ? ? ?clear SFTRST
? ? ? ?udelay
? ? ? ?poll SFTRST cleared? ? ? ?clear CLKGATE
? ? ? ?set SFTRST
? ? ? ?udelay
? ? ? ?poll CLKGATE set? ? ? ?clear SFTRST
? ? ? ?udelay
? ? ? ?poll SFTRST cleared? ? ? ?clear CLKGATE
? ? ? ?udelay
? ? ? ?poll CLKGATE clearedit's IMHO better than the comment above. ?If "clear CLKGATE" and "set SFTRST" can be done in a single step this might be done like that:
? ? ? ?/* comment describing
setmask_poll*/
? ? ? ?static intsetmask_poll(void __iomem *addr, u32 set, u32 mask, ? ? ? ? ? ? ? ?u32 pollval, u32 pollmask, u32 *curval)
? ? ? ?{
? ? ? ? ? ? ? ?int timeout =0x400;? ? ? ? ? ? ? ?*curval &= ~mask;
? ? ? ? ? ? ? ?*curval |= set;
? ? ? ? ? ? ? ?__raw_writel(*curval, addr)? ? ? ? ? ? ? ?/*
? ? ? ? ? ? ? ? * some nice comment about 1us being a good idea ? ? ? ? ? ? ? ? */
? ? ? ? ? ? ? ?udelay(1);? ? ? ? ? ? ? ?do {
? ? ? ? ? ? ? ? ? ? ? ?*curval =__raw_readl(addr); ? ? ? ? ? ? ? ? ? ? ? ?if ((*curval & pollmask) == pollval) ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?return 0;? ? ? ? ? ? ? ?} while(--timeout);
? ? ? ? ? ? ? ?return 1;
? ? ? ?}? ? ? ?int
mxs_reset_block(void __iomem *reset_addr)? ? ? ?{
? ? ? ? ? ? ? ?u32 val =__raw_readl(reset_addr); ? ? ? ? ? ? ? ?int ret;? ? ? ? ? ? ? ?/* clear SFTRST and poll SFTRST becoming clear */ ? ? ? ? ? ? ? ?ret = setmask_poll(reset_addr,
? ? ? ? ? ? ? ? ? ? ? ?0,MXS_MODULE_SFTRST,
? ? ? ? ? ? ? ? ? ? ? ?0,MXS_MODULE_SFTRST, &val);
? ? ? ? ? ? ? ?if (ret)
? ? ? ? ? ? ? ? ? ? ? ?goto error;? ? ? ? ? ? ? ?/* clear CLKGATE, set SFTRST and poll CLKGATE becoming set */ ? ? ? ? ? ? ? ?ret = setmask_poll(reset_addr,
? ? ? ? ? ? ? ? ? ? ? ?MXS_MODULE_SFTRST,MXS_MODULE_SFTRST|MXS_MODULE_CLKGATE, ? ? ? ? ? ? ? ? ? ? ? ?0,MXS_MODULE_CLKGATE, &val);
? ? ? ? ? ? ? ?if (ret)
? ? ? ? ? ? ? ? ? ? ? ?goto error;
Quoted 7 lines
? ? ? ? ? ? ? ?...
? ? ? ?}Well, not very nice, but IMHO better that your code. ?Maybe
mxs_reset_blockfits in a Terminal that way without decreasing the font size :-)
I checked designer about doing "clear CLKGATE" and "set SFTRST" in a single step, and got the following feedback.
"Per HW design, it is not safe to get those two done by write once time. By two step write, one instruction period interval can be ensured at least for clock enabling before sync. Soft reset. Your code is only once time write in fact, so it shall not be equal to two write operation."
In this case, how do the following changes look to you?
/*
* Clear the bit and poll it cleared, the bit has to be
* SFTRST(bit 31) or CLKGATE (bit 30) of block control register. */
static int clear_poll_bit(void __iomem *addr, u32 mask)
{
int timeout = 0x400;
/* clear the bit */
__raw_writel(mask, addr + MXS_CLR_ADDR);
/*
* SFTRST needs 3 GPMI clocks to settle, the reference manual
* recommends to wait 1us.
*/
udelay(1);
/* poll the bit becoming clear */
while ((__raw_readl(addr) & mask) && --timeout)
/* nothing */;
if (unlikely(!timeout))
return 1;
return 0;
}int mxs_reset_block(void __iomem *reset_addr)
{
int ret;
int timeout = 0x400;
/* clear and poll SFTRST */
ret = clear_poll_bit(reset_addr, MXS_MODULE_SFTRST);
if (ret)
goto error;
/* clear CLKGATE */
__raw_writel(MXS_MODULE_CLKGATE, reset_addr + MXS_CLR_ADDR);
/* set SFTRST to reset the block */
__raw_writel(MXS_MODULE_SFTRST, reset_addr + MXS_SET_ADDR);
udelay(1);
/* poll CLKGATE becoming set */
while ((!(__raw_readl(reset_addr) & MXS_MODULE_CLKGATE)) && --timeout)
/* nothing */;
if (unlikely(!timeout))
goto error;
/* clear and poll SFTRST */
ret = clear_poll_bit(reset_addr, MXS_MODULE_SFTRST);
if (ret)
goto error;
/* clear and poll CLKGATE */
ret = clear_poll_bit(reset_addr, MXS_MODULE_CLKGATE);
if (ret)
goto error;error:
pr_err("%s(%p): module reset timeout\n", __func__, reset_addr);
return -ETIMEDOUT;
}Signature · 2 lines
Regards, Shawn
PATCH v2 3/15 ARM: mxs: Add reset routines
Hi Shawn,
Quoted 123 lines · Shawn Guo
Hi Uwe,
2010/11/30 Uwe Kleine-K?nig <[email protected]>:
Quoted 2 lines
Hello,
[...]
Quoted 101 lines
Quoted 23 lines
+ ? ? /* Poll CLKGATE set */
+ ? ? timeout =0x400;
+ ? ? while ((!(__raw_readl(reset_addr) &MXS_MODULE_CLKGATE)) && --timeout)
+ ? ? ? ? ? ? /* nothing */;
+ ? ? if (!timeout)
+ ? ? ? ? ? ? goto error;(quoted diff) +16
-0+ + ? ? /* Clear SFTRST */ + ? ? val = __raw_readl(reset_addr); + ? ? val &= ~MXS_MODULE_SFTRST; + ? ? __raw_writel(val, reset_addr); + ? ? /* Wait 1us */ + ? ? udelay(1); + ? ? /* Poll SFTRST cleared */ + ? ? timeout = 0x400; + ? ? while ((__raw_readl(reset_addr) & MXS_MODULE_SFTRST) && --timeout) + ? ? ? ? ? ? /* nothing */; + ? ? if (!timeout) + ? ? ? ? ? ? goto error; + + ? ? /* Clear CLKGATE */ + ? ? val = __raw_readl(reset_addr);Review
Quoted 10 lines
(quoted diff) +10
-0+ ? ? val &= ~MXS_MODULE_CLKGATE; + ? ? __raw_writel(val, reset_addr); + ? ? /* Wait 1us */ + ? ? udelay(1); + ? ? /* Poll CLKGATE cleared */ + ? ? timeout = 0x400; + ? ? while ((__raw_readl(reset_addr) & MXS_MODULE_CLKGATE) && --timeout) + ? ? ? ? ? ? /* nothing */; + ? ? if (!timeout) + ? ? ? ? ? ? goto error;There are quite some repetitions in this function. ?If you could get it down to something that looks like
? ? ? ?clear SFTRST
? ? ? ?udelay
? ? ? ?poll SFTRST cleared? ? ? ?clear CLKGATE
? ? ? ?set SFTRST
? ? ? ?udelay
? ? ? ?poll CLKGATE set? ? ? ?clear SFTRST
? ? ? ?udelay
? ? ? ?poll SFTRST cleared? ? ? ?clear CLKGATE
? ? ? ?udelay
? ? ? ?poll CLKGATE clearedit's IMHO better than the comment above. ?If "clear CLKGATE" and "set SFTRST" can be done in a single step this might be done like that:
? ? ? ?/* comment describing
setmask_poll*/
? ? ? ?static intsetmask_poll(void __iomem *addr, u32 set, u32 mask, ? ? ? ? ? ? ? ?u32 pollval, u32 pollmask, u32 *curval)
? ? ? ?{
? ? ? ? ? ? ? ?int timeout =0x400;? ? ? ? ? ? ? ?*curval &= ~mask;
? ? ? ? ? ? ? ?*curval |= set;
? ? ? ? ? ? ? ?__raw_writel(*curval, addr)? ? ? ? ? ? ? ?/*
? ? ? ? ? ? ? ? * some nice comment about 1us being a good idea ? ? ? ? ? ? ? ? */
? ? ? ? ? ? ? ?udelay(1);? ? ? ? ? ? ? ?do {
? ? ? ? ? ? ? ? ? ? ? ?*curval =__raw_readl(addr); ? ? ? ? ? ? ? ? ? ? ? ?if ((*curval & pollmask) == pollval) ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?return 0;? ? ? ? ? ? ? ?} while(--timeout);
? ? ? ? ? ? ? ?return 1;
? ? ? ?}? ? ? ?int
mxs_reset_block(void __iomem *reset_addr)? ? ? ?{
? ? ? ? ? ? ? ?u32 val =__raw_readl(reset_addr); ? ? ? ? ? ? ? ?int ret;? ? ? ? ? ? ? ?/* clear SFTRST and poll SFTRST becoming clear */ ? ? ? ? ? ? ? ?ret = setmask_poll(reset_addr,
? ? ? ? ? ? ? ? ? ? ? ?0,MXS_MODULE_SFTRST,
? ? ? ? ? ? ? ? ? ? ? ?0,MXS_MODULE_SFTRST, &val);
? ? ? ? ? ? ? ?if (ret)
? ? ? ? ? ? ? ? ? ? ? ?goto error;? ? ? ? ? ? ? ?/* clear CLKGATE, set SFTRST and poll CLKGATE becoming set */ ? ? ? ? ? ? ? ?ret = setmask_poll(reset_addr,
? ? ? ? ? ? ? ? ? ? ? ?MXS_MODULE_SFTRST,MXS_MODULE_SFTRST|MXS_MODULE_CLKGATE, ? ? ? ? ? ? ? ? ? ? ? ?0,MXS_MODULE_CLKGATE, &val);
? ? ? ? ? ? ? ?if (ret)
? ? ? ? ? ? ? ? ? ? ? ?goto error;Quoted 7 lines
? ? ? ? ? ? ? ?...
? ? ? ?}Well, not very nice, but IMHO better that your code. ?Maybe
mxs_reset_blockfits in a Terminal that way without decreasing the font size :-)I checked designer about doing "clear CLKGATE" and "set SFTRST" in a single step, and got the following feedback.
"Per HW design, it is not safe to get those two done by write once time. By two step write, one instruction period interval can be ensured at least for clock enabling before sync. Soft reset. Your code is only once time write in fact, so it shall not be equal to two write operation."
Quoted 5 lines
In this case, how do the following changes look to you?
/*
* Clear the bit and poll it cleared, the bit has to be
* SFTRST(bit 31) or CLKGATE (bit 30) of block control register.
for the function it doesn't have to be one of these bits. Maybe:
Clear the bit and poll it cleared. This is usually called with a reset address and mask being either SFTRST(bit 31) or CLKGATE (bit 30).
Quoted 7 lines
*/
static intclear_poll_bit(void __iomem *addr, u32 mask){ int timeout = 0x400; /* clear the bit */ __raw_writel(mask, addr + MXS_CLR_ADDR);
ah, so there is a clr register, that's nice.
Quoted 15 lines
/*
* SFTRST needs 3 GPMI clocks to settle, the reference manual
* recommends to wait 1us.
*/
udelay(1);
/* poll the bit becoming clear */
while ((__raw_readl(addr) & mask) && --timeout)
/* nothing */;
if (unlikely(!timeout))
return 1;
return 0;return !timeout; ?
Quoted 24 lines
}
int
mxs_reset_block(void __iomem *reset_addr){ int ret; int timeout = 0x400; /* clear and poll SFTRST */ ret = clear_poll_bit(reset_addr, MXS_MODULE_SFTRST); if (ret) goto error; /* clear CLKGATE */ __raw_writel(MXS_MODULE_CLKGATE, reset_addr + MXS_CLR_ADDR); /* set SFTRST to reset the block */ __raw_writel(MXS_MODULE_SFTRST, reset_addr + MXS_SET_ADDR); udelay(1); /* poll CLKGATE becoming set */ while ((!(__raw_readl(reset_addr) & MXS_MODULE_CLKGATE)) && --timeout) /* nothing */; if (unlikely(!timeout)) goto error; /* clear and poll SFTRST */
Quoted 9 lines
ret = clear_poll_bit(reset_addr, MXS_MODULE_SFTRST);
if (ret)
goto error;
/* clear and poll CLKGATE */
ret = clear_poll_bit(reset_addr, MXS_MODULE_CLKGATE);
if (ret)
goto error;return 0;
Quoted 4 lines
error:
pr_err("%s(%p): module reset timeout\n", __func__, reset_addr); return -ETIMEDOUT; }
Other than that it looks much better IMHO.
Uwe
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-K?nig | Industrial Linux Solutions | http://www.pengutronix.de/ |
PATCH v2 3/15 ARM: mxs: Add reset routines
In reply to Shawn GuoHello Shawn
Quoted 11 lines · Shawn Guo
arch/arm/mach-mxs/system.c new file +11
-0+/* +* Reset the system. It is called by machine_restart(). +*/ +void arch_reset (char mode,const char *cmd) +{ +/* Set wdog count */ +__raw_writel (1 , wdog_base +MXS_RTC_WATCHDOG ); + +/* Assert SRS signal */ +__raw_writel (MXS_WATCHDOG_EN , wdog_base +MXS_SET_ADDR ); +
arch/arm/mach-mxs/system.c line 59
Quoted 10 lines
arch/arm/mach-mxs/system.c new file +10
-0+/* Wait for reset to assert... */ +mdelay (500 ); + +pr_err ("Watchdog reset failed to assert reset\n" ); + +/* Delay to allow the serial port to show the message */ +mdelay (50 ); + +/* We'll take a jump through zero as a poor second */ +cpu_reset (0 );
After reading a bit in IMX28RM, I wonder why do you bother with the watchdog at all? Doesn't
__raw_writel(MXS_CLKCTRL_RESET_CHIP, MXS_CLKCTRL_RESET + MXS_SET_ADDR);
work easier and without the need to worry about timeouts, sleeping while clk_{get,enable} and races?
(Note I didn't check if i.MX23 has the same register at the same address.)
Best regards
Uwe
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-K?nig | Industrial Linux Solutions | http://www.pengutronix.de/ |
PATCH v2 3/15 ARM: mxs: Add reset routines
Hi Uwe,
2010/12/2 Uwe Kleine-K?nig <[email protected]>:
Quoted 27 lines
Hello Shawn
Quoted 11 lines · Shawn Guo
(quoted diff) +11
-0+/* + * Reset the system. It is called by machine_restart(). + */ +void arch_reset(char mode, const char *cmd) +{ + ? ? /* Set wdog count */ + ? ? __raw_writel(1, wdog_base + MXS_RTC_WATCHDOG); + + ? ? /* Assert SRS signal */ + ? ? __raw_writel(MXS_WATCHDOG_EN, wdog_base + MXS_SET_ADDR); +Review
Quoted 10 lines
(quoted diff) +10
-0+ ? ? /* Wait for reset to assert... */ + ? ? mdelay(500); + + ? ? pr_err("Watchdog reset failed to assert reset\n"); + + ? ? /* Delay to allow the serial port to show the message */ + ? ? mdelay(50); + + ? ? /* We'll take a jump through zero as a poor second */ + ? ? cpu_reset(0);After reading a bit in IMX28RM, I wonder why do you bother with the watchdog at all? ?Doesn't
Quoted 7 lines
? ? ? ?__raw_writel(MXS_CLKCTRL_RESET_CHIP,
MXS_CLKCTRL_RESET+MXS_SET_ADDR);work easier and without the need to worry about timeouts, sleeping while clk_{get,enable} and races?
(Note I didn't check if i.MX23 has the same register at the same address.)
Yes, it's a good way to reset mxs SoC. But the bad thing is the offset of the register is different between MX23 and MX28. Also there is no SET_ADDR for this register.
Signature · 2 lines
Regards, Shawn
PATCH v2 4/15 ARM: mxs: Add interrupt support
In reply to Shawn GuoAdd Interrupt Collector (ICOLL) support for MXS-based.
---
Changes for v2:
- Get icoll base in get_irqnr_preamble
- Check the case of single SoC build and use hard-coding address if possible
arch/arm/mach-mxs/icoll.c | 77 ++++++++++++++++++++++++++ arch/arm/mach-mxs/include/mach/entry-macro.S | 44 +++++++++++++++ 2 files changed, 121 insertions(+), 0 deletions(-) create mode 100644 arch/arm/mach-mxs/icoll.c create mode 100644 arch/arm/mach-mxs/include/mach/entry-macro.S
arch/arm/mach-mxs/icoll.c new file +77 -0
@@ -0,0 +1,77 @@ +/* +* 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 mxs_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; + +/* Reset icoll */ +mxs_reset_block (irqbase +HW_ICOLL_CTRL ); + +for (i =0 ; i <MXS_INTERNAL_IRQS ; i++) { +set_irq_chip (i, &mxs_icoll_chip); +set_irq_handler (i, handle_level_irq); +set_irq_flags (i,IRQF_VALID ); + } +}
arch/arm/mach-mxs/include/mach/entry-macro.S new file +44 -0
44 lines not on this page · raw message
Signature · 1 line
1.7.1
PATCH v2 4/15 ARM: mxs: Add interrupt support
Hello Shawn,
Quoted 48 lines · Shawn Guo
Add Interrupt Collector (ICOLL) support for MXS-based.
Signed-off-by Shawn Guo <[email protected]>---
Changes for v2:
- Get icoll base inget_irqnr_preamble
- Check the case of single SoC build and use hard-coding address if possiblearch/arm/mach-mxs/icoll.c | 77 ++++++++++++++++++++++++++ arch/arm/mach-mxs/include/mach/entry-macro.S | 44 +++++++++++++++ 2 files changed, 121 insertions(+), 0 deletions(-) create mode 100644 arch/arm/mach-mxs/icoll.c create mode 100644 arch/arm/mach-mxs/include/mach/entry-macro.Sarch/arm/mach-mxs/icoll.c new file +28
-0@@ -0,0 +1,77 @@ +/* +* 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
arch/arm/mach-mxs/icoll.c line 38
Quoted 10 lines
arch/arm/mach-mxs/icoll.c new file +10
-0+#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 );
You need to write this before handling the irq, no? Note this question is a repetition. You answered "No need, indeed. Will remove it." According to MCIMX28RM a write to HW_ICOLL_VECTOR "indicates the in-service state". Are you sure this is not needed? If no (i.e. it's needed) the write should go into entry-macro.S. As I don't have hardware yet I cannot test that. Maybe it's only needed when the priority levels are used?!
arch/arm/mach-mxs/icoll.c line 40
Quoted 2 lines
arch/arm/mach-mxs/icoll.c new file +2
-0+ +/* ACK current interrupt (level 0) */
I suggest to extend this a bit, like:
The Interrupt Collector is able to prioritize irqs. Currently only level 0 is used. So acking can use BV_ICOLL_LEVELACK_IRQLEVELACK__LEVEL0 unconditionally.
Quoted 20 lines
arch/arm/mach-mxs/icoll.c new file +20
-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 mxs_icoll_chip = { + .ack = icoll_ack_irq, + .mask = icoll_mask_irq, + .unmask = icoll_unmask_irq,
arch/arm/mach-mxs/icoll.c line 70
Quoted 10 lines
arch/arm/mach-mxs/icoll.c new file +10
-0+}; + +void __init icoll_init_irq (void __iomem *irqbase) +{ +int i; + + icoll_base = irqbase; + +/* Reset icoll */ +mxs_reset_block (irqbase +HW_ICOLL_CTRL );
I assume this initializes the priority for each irq to level 0. Maybe this should be documented here.
Quoted 27 lines
arch/arm/mach-mxs/icoll.c new file +7
-0+ +for (i =0 ; i <MXS_INTERNAL_IRQS ; i++) { +set_irq_chip (i, &mxs_icoll_chip); +set_irq_handler (i, handle_level_irq); +set_irq_flags (i,IRQF_VALID ); + } +}arch/arm/mach-mxs/include/mach/entry-macro.S new file +14
-0@@ -0,0 +1,44 @@ +/* + * Low-level IRQ helper macros for Freescale MXS-based + * + * 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.
arch/arm/mach-mxs/include/mach/entry-macro.S line 24
Quoted 10 lines
arch/arm/mach-mxs/include/mach/entry-macro.S new file +10
-0+ * + * 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 <mach/hardware.h> + + .macro disable_fiq + .endm
I think is isn't needed. Only when you start to actually use the fiq.
arch/arm/mach-mxs/include/mach/entry-macro.S line 33
Quoted 8 lines
arch/arm/mach-mxs/include/mach/entry-macro.S new file +8
-0+ .macro get_irqnr_and_base, irqnr, irqstat, base, tmp + ldr \irqnr, [\base, #0x70] + cmp \irqnr, #0x7F + moveqs \irqnr, #0 + .endm + + .macro get_irqnr_preamble, base, tmp +#if defined (CONFIG_SOC_IMX23) && defined (CONFIG_SOC_IMX28)
no space between defined and ( please.
arch/arm/mach-mxs/include/mach/entry-macro.S line 40
Quoted 7 lines
arch/arm/mach-mxs/include/mach/entry-macro.S new file +7
-0+ ldr \base, =icoll_base + ldr \base, [\base] +#elif defined (CONFIG_SOC_IMX23) + ldr \base, =MX23_ICOLL_BASE_ADDR +#else + ldr \base, =MX28_ICOLL_BASE_ADDR +#endif
Mhh, you said the base addresses are different. Unless I'm mistaken they are not. So you can just remove icoll_base.
arch/arm/mach-mxs/include/mach/entry-macro.S line 44
Quoted 4 lines
arch/arm/mach-mxs/include/mach/entry-macro.S new file +4
-0+ .endm + + .macro arch_ret_to_user, tmp1, tmp2 + .endm
Best regards
Uwe
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-K?nig | Industrial Linux Solutions | http://www.pengutronix.de/ |
PATCH v2 4/15 ARM: mxs: Add interrupt support
Hi Uwe,
2010/12/8 Uwe Kleine-K?nig <[email protected]>:
Quoted 3 lines
Hello Shawn,
On Wed, Dec 08, 2010 at 12:31:54AM +0800, Shawn Guo wrote:
[...]
Quoted 12 lines
arch/arm/mach-mxs/icoll.c
Quoted 4 lines
arch/arm/mach-mxs/icoll.c new file +4
-0+ +static void icoll_ack_irq (unsigned int irq) +{ + ? ? __raw_writel(0, icoll_base + HW_ICOLL_VECTOR);You need to write this before handling the irq, no? ?Note this question is a repetition. ?You answered "No need, indeed. ?Will remove it." According to MCIMX28RM a write to
HW_ICOLL_VECTOR"indicates the in-service state". ?Are you sure this is not needed? ?If no (i.e. it's needed) the write should go intoentry-macro.S. ?As I don't have hardware yet I cannot test that. ?Maybe it's only needed when the priority levels are used?!
Sorry. I made a mistake. I thought I had tested the removal of line and gave the comment, but actually not. The line is needed, and image will stop working without the line.
Regarding to moving the writing to register VECTOR into entry-macro.S, can you please help me understand the reason behind the suggestion?
Signature · 2 lines
Regards, Shawn
PATCH v2 4/15 ARM: mxs: Add interrupt support
Hello Shawn,
Quoted 15 lines · Shawn Guo
2010/12/8 Uwe Kleine-K?nig <[email protected]>:
Quoted 1 line · Shawn Guo
[...]
Quoted 12 lines
arch/arm/mach-mxs/icoll.c
Quoted 4 lines
arch/arm/mach-mxs/icoll.c new file +4
-0+ +static void icoll_ack_irq (unsigned int irq) +{ + ? ? __raw_writel(0, icoll_base + HW_ICOLL_VECTOR);You need to write this before handling the irq, no? ?Note this question is a repetition. ?You answered "No need, indeed. ?Will remove it." According to MCIMX28RM a write to
HW_ICOLL_VECTOR"indicates the in-service state". ?Are you sure this is not needed? ?If no (i.e. it's needed) the write should go intoentry-macro.S. ?As I don't have hardware yet I cannot test that. ?Maybe it's only needed when the priority levels are used?!
Quoted 6 lines
Sorry. I made a mistake. I thought I had tested the removal of line and gave the comment, but actually not. The line is needed, and image will stop working without the line.
Regarding to moving the writing to register VECTOR into
entry-macro.S, can you please help me understand the reason behind the suggestion?
Section 5.2.1 of MCIMX28RM writes:
After the CPU enters the interrupt service routine, it must notify the interrupt collector as soon as possible. Software indicates the in-service state by writing to the HW_ICOLL_VECTOR register.
Best regards
Uwe
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-K?nig | Industrial Linux Solutions | http://www.pengutronix.de/ |
PATCH v2 4/15 ARM: mxs: Add interrupt support
Hi Uwe,
2010/12/8 Uwe Kleine-K?nig <[email protected]>:
Quoted 22 lines
Hello Shawn,
Quoted 19 lines · Shawn Guo
2010/12/8 Uwe Kleine-K?nig <[email protected]>:
Quoted 1 line · Shawn Guo
[...]
Quoted 12 lines
arch/arm/mach-mxs/icoll.c
Quoted 4 lines
arch/arm/mach-mxs/icoll.c new file +4
-0+ +static void icoll_ack_irq (unsigned int irq) +{ + ? ? __raw_writel(0, icoll_base + HW_ICOLL_VECTOR);You need to write this before handling the irq, no? ?Note this question is a repetition. ?You answered "No need, indeed. ?Will remove it." According to MCIMX28RM a write to
HW_ICOLL_VECTOR"indicates the in-service state". ?Are you sure this is not needed? ?If no (i.e. it's needed) the write should go intoentry-macro.S. ?As I don't have hardware yet I cannot test that. ?Maybe it's only needed when the priority levels are used?!Sorry. I made a mistake. ?I thought I had tested the removal of line and gave the comment, but actually not. The line is needed, and image will stop working without the line.
Quoted 9 lines
Quoted 2 lines
Regarding to moving the writing to register VECTOR into
entry-macro.S, can you please help me understand the reason behind the suggestion?Section 5.2.1 of MCIMX28RM writes:
? ? ? ?After the CPU enters the interrupt service routine, it must ? ? ? ?notify the interrupt collector as soon as possible. Software ? ? ? ?indicates the in-service state by writing to the
HW_ICOLL_VECTOR? ? ? ?register.
In case you will ask why, I would give the fact here. I'm not sure what is your first thought. Mine is to add it into get_irqnr_preamble as below.
.macro get_irqnr_preamble, base, tmp
ldr \base, =ICOLL_ADDR
mov \tmp, #0
str \tmp, [\base].endm
But I got the following error.
[...]
VFS: Mounted root (nfs filesystem) on device 0:11.
Freeing init memory: 92K
irq 101: nobody cared (try booting with the "irqpoll" option) [<c0025084>] (unwind_backtrace+0x0/0xe4) from [<c0063d54>] (__report_bad_irq+0x3 4/0x8c)
[<c0063d54>] (__report_bad_irq+0x34/0x8c) from [<c0063ef8>] (note_interrupt+0x14 c/0x1d8)
[<c0063ef8>] (note_interrupt+0x14c/0x1d8) from [<c0064d5c>] (handle_level_irq+0x 108/0x198)
[<c0064d5c>] (handle_level_irq+0x108/0x198) from [<c001f070>] (asm_do_IRQ+0x70/0 x94)
[<c001f070>] (asm_do_IRQ+0x70/0x94) from [<c0237050>] (__irq_svc+0x50/0x8c)
Exception stack(0xc02e7d38 to 0xc02e7d80)
7d20: c02e7db0 00000000
7d40: ffffffd0 00000000 c7990800 00000000 c79a3820 000005a8 c02e7df8 c0217380 7d60: c7997a28 000005a8 00000000 c02e7d80 c02173a8 c02173c0 40000013 ffffffff [<c0237050>] (__irq_svc+0x50/0x8c) from [<c02173c0>] (xs_tcp_data_recv+0x40/0x62
c)
[<c02173c0>] (xs_tcp_data_recv+0x40/0x62c) from [<c01d6160>] (tcp_read_sock+0x70 /0x1e8)
[<c01d6160>] (tcp_read_sock+0x70/0x1e8) from [<c021734c>] (xs_tcp_data_ready+0x7 c/0xb0)
[<c021734c>] (xs_tcp_data_ready+0x7c/0xb0) from [<c01dee3c>] (tcp_rcv_establishe
d+0x484/0x610) [<c01dee3c>] (tcp_rcv_established+0x484/0x610) from [<c01e5fd4>] (tcp_v4_do_rcv+
0x28/0x1c8)
[<c01e5fd4>] (tcp_v4_do_rcv+0x28/0x1c8) from [<c01e65fc>] (tcp_v4_rcv+0x488/0x83
c)
[<c01e65fc>] (tcp_v4_rcv+0x488/0x83c) from [<c01ca038>] (ip_local_deliver+0x100/ 0x1fc)
[<c01ca038>] (ip_local_deliver+0x100/0x1fc) from [<c01c9efc>] (ip_rcv+0x540/0x57
c)
[<c01c9efc>] (ip_rcv+0x540/0x57c) from [<c01ad490>] (__netif_receive_skb+0x32c/0 x388)
[<c01ad490>] (__netif_receive_skb+0x32c/0x388) from [<c01ad56c>] (process_backlo
g+0x80/0x140) [<c01ad56c>] (process_backlog+0x80/0x140) from [<c01ad8a4>] (net_rx_action+0x58/
0x180)
[<c01ad8a4>] (net_rx_action+0x58/0x180) from [<c0037c50>] (__do_softirq+0x78/0x1
10)
[<c0037c50>] (__do_softirq+0x78/0x110) from [<c0037d2c>] (irq_exit+0x44/0xa8) [<c0037d2c>] (irq_exit+0x44/0xa8) from [<c001f074>] (asm_do_IRQ+0x74/0x94) [<c001f074>] (asm_do_IRQ+0x74/0x94) from [<c0237050>] (__irq_svc+0x50/0x8c)
Exception stack(0xc02e7f80 to 0xc02e7fc8)
7f80: 00000000 0005317f 0005217f 60000013 c02e6000 c001baf4 c001baf0 c02e9b60 7fa0: 4001a848 41069265 4001a7e0 00000000 600000d3 c02e7fc8 c0020bc4 c0020bd0 7fc0: 60000013 ffffffff
[<c0237050>] (__irq_svc+0x50/0x8c) from [<c0020bd0>] (default_idle+0x2c/0x30) [<c0020bd0>] (default_idle+0x2c/0x30) from [<c002110c>] (cpu_idle+0x60/0xc0) [<c002110c>] (cpu_idle+0x60/0xc0) from [<c00088f0>] (start_kernel+0x238/0x27c) [<c00088f0>] (start_kernel+0x238/0x27c) from [<40008034>] (0x40008034) handlers:
[<c01872e4>] (fec_enet_interrupt+0x0/0x3ec)
Disabling IRQ #101
However, when I add it into get_irqnr_and_base as below.
.macro get_irqnr_and_base, irqnr, irqstat, base, tmp
mov \tmp, #0
str \tmp, [\base]
ldr \irqnr, [\base, #0x70]
cmp \irqnr, #0x7F
moveqs \irqnr, #0.endm
Everything seems fine.
Signature · 2 lines
Regards, Shawn
PATCH v2 4/15 ARM: mxs: Add interrupt support
Quoted 38 lines · Shawn Guo
Hi Uwe,
2010/12/8 Uwe Kleine-K?nig <[email protected]>:
Quoted 22 lines
Hello Shawn,
Quoted 19 lines · Shawn Guo
2010/12/8 Uwe Kleine-K?nig <[email protected]>:
Quoted 1 line · Shawn Guo
[...]
Quoted 12 lines
arch/arm/mach-mxs/icoll.c
Quoted 4 lines
arch/arm/mach-mxs/icoll.c new file +4
-0+ +static void icoll_ack_irq (unsigned int irq) +{ + ? ? __raw_writel(0, icoll_base + HW_ICOLL_VECTOR);You need to write this before handling the irq, no? ?Note this question is a repetition. ?You answered "No need, indeed. ?Will remove it." According to MCIMX28RM a write to
HW_ICOLL_VECTOR"indicates the in-service state". ?Are you sure this is not needed? ?If no (i.e. it's needed) the write should go intoentry-macro.S. ?As I don't have hardware yet I cannot test that. ?Maybe it's only needed when the priority levels are used?!Sorry. I made a mistake. ?I thought I had tested the removal of line and gave the comment, but actually not. The line is needed, and image will stop working without the line.
Quoted 9 lines
Quoted 2 lines
Regarding to moving the writing to register VECTOR into
entry-macro.S, can you please help me understand the reason behind the suggestion?Section 5.2.1 of MCIMX28RM writes:
? ? ? ?After the CPU enters the interrupt service routine, it must ? ? ? ?notify the interrupt collector as soon as possible. Software ? ? ? ?indicates the in-service state by writing to the
HW_ICOLL_VECTOR? ? ? ?register.In case you will ask why, I would give the fact here. I'm not sure what is your first thought. Mine is to add it into
get_irqnr_preambleas below.
Quoted 5 lines
.macro get_irqnr_preamble, base, tmp ldr \base, =ICOLL_ADDR mov \tmp, #0 str \tmp, [\base].endm
It's wrong to do that in get_irqnr_preamble.
Quoted 66 lines
But I got the following error.
[...]
VFS: Mounted root (nfs filesystem) on device 0:11.
Freeing init memory: 92K
irq 101: nobody cared (try booting with the "irqpoll" option) [<c0025084>] (unwind_backtrace+0x0/0xe4) from [<c0063d54>] (__report_bad_irq+0x34/0x8c)
[<c0063d54>] (__report_bad_irq+0x34/0x8c) from [<c0063ef8>] (note_interrupt+0x14c/0x1d8)
[<c0063ef8>] (note_interrupt+0x14c/0x1d8) from [<c0064d5c>] (handle_level_irq+0x 108/0x198)
[<c0064d5c>] (handle_level_irq+0x108/0x198) from [<c001f070>] (asm_do_IRQ+0x70/0 x94)
[<c001f070>] (asm_do_IRQ+0x70/0x94) from [<c0237050>] (__irq_svc+0x50/0x8c)Exception stack(0xc02e7d38 to 0xc02e7d80)7d20:
c02e7db000000000
7d40:ffffffd000000000c799080000000000c79a3820000005a8c02e7df8c02173807d60:c7997a28000005a800000000c02e7d80c02173a8c02173c040000013 ffffffff [<c0237050>] (__irq_svc+0x50/0x8c) from [<c02173c0>] (xs_tcp_data_recv+0x40/0x62
c)
[<c02173c0>] (xs_tcp_data_recv+0x40/0x62c) from [<c01d6160>] (tcp_read_sock+0x70/0x1e8)
[<c01d6160>] (tcp_read_sock+0x70/0x1e8) from [<c021734c>] (xs_tcp_data_ready+0x7c/0xb0)
[<c021734c>] (xs_tcp_data_ready+0x7c/0xb0) from [<c01dee3c>] (tcp_rcv_established+0x484/0x610) [<c01dee3c>] (tcp_rcv_established+0x484/0x610) from [<c01e5fd4>] (tcp_v4_do_rcv+0x28/0x1c8)
[<c01e5fd4>] (tcp_v4_do_rcv+0x28/0x1c8) from [<c01e65fc>] (tcp_v4_rcv+0x488/0x83
c)
[<c01e65fc>] (tcp_v4_rcv+0x488/0x83c) from [<c01ca038>] (ip_local_deliver+0x100/0x1fc)
[<c01ca038>] (ip_local_deliver+0x100/0x1fc) from [<c01c9efc>] (ip_rcv+0x540/0x57
c)
[<c01c9efc>] (ip_rcv+0x540/0x57c) from [<c01ad490>] (__netif_receive_skb+0x32c/0 x388)
[<c01ad490>] (__netif_receive_skb+0x32c/0x388) from [<c01ad56c>] (process_backlog+0x80/0x140) [<c01ad56c>] (process_backlog+0x80/0x140) from [<c01ad8a4>] (net_rx_action+0x58/
0x180)
[<c01ad8a4>] (net_rx_action+0x58/0x180) from [<c0037c50>] (__do_softirq+0x78/0x1
10)
[<c0037c50>] (__do_softirq+0x78/0x110) from [<c0037d2c>] (irq_exit+0x44/0xa8) [<c0037d2c>] (irq_exit+0x44/0xa8) from [<c001f074>] (asm_do_IRQ+0x74/0x94) [<c001f074>] (asm_do_IRQ+0x74/0x94) from [<c0237050>] (__irq_svc+0x50/0x8c)Exception stack(0xc02e7f80 to 0xc02e7fc8)7f80: 00000000
0005317f0005217f60000013c02e6000c001baf4c001baf0c02e9b607fa0:4001a848410692654001a7e000000000600000d3c02e7fc8c0020bc4c0020bd07fc0: 60000013 ffffffff
[<c0237050>] (__irq_svc+0x50/0x8c) from [<c0020bd0>] (default_idle+0x2c/0x30) [<c0020bd0>] (default_idle+0x2c/0x30) from [<c002110c>] (cpu_idle+0x60/0xc0) [<c002110c>] (cpu_idle+0x60/0xc0) from [<c00088f0>] (start_kernel+0x238/0x27c) [<c00088f0>] (start_kernel+0x238/0x27c) from [<40008034>] (0x40008034) handlers:
[<c01872e4>] (fec_enet_interrupt+0x0/0x3ec)
Disabling IRQ #101However, when I add it into
get_irqnr_and_baseas below..macro get_irqnr_and_base, irqnr, irqstat, base, tmp mov \tmp, #0 str \tmp, [\base] ldr \irqnr, [\base, #0x70] cmp \irqnr, #0x7F moveqs \irqnr, #0
Quoted 3 lines
.endm
Everything seems fine.
I think you need to do the following:
.macro get_irqnr_and_base, irqnr, irqstat, base, tmp ldr \irqnr, [\base, #0x70] cmp \irqnr, #0x7F strne \irqnr, [\base] moveq \irqnr, #0 .endm
(i.e. only write to VECTOR if there is an irq pending).
As before this is completely untested.
Another thing I just noticed is that you don't really want to hardcode the 0x70, take a look into arch/arm/mach-ns9xxx/include/mach/entry-macro.S for an example to avoid it.
Uwe
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-K?nig | Industrial Linux Solutions | http://www.pengutronix.de/ |
PATCH v2 4/15 ARM: mxs: Add interrupt support
2010/12/8 Uwe Kleine-K?nig <[email protected]>:
Quoted 125 lines · Shawn Guo
Quoted 38 lines
Hi Uwe,
2010/12/8 Uwe Kleine-K?nig <[email protected]>:
Quoted 22 lines
Hello Shawn,
Quoted 19 lines · Shawn Guo
2010/12/8 Uwe Kleine-K?nig <[email protected]>:
Quoted 1 line · Shawn Guo
[...]
Quoted 12 lines
arch/arm/mach-mxs/icoll.c
Quoted 4 lines
arch/arm/mach-mxs/icoll.c new file +4
-0+ +static void icoll_ack_irq (unsigned int irq) +{ + ? ? __raw_writel(0, icoll_base + HW_ICOLL_VECTOR);You need to write this before handling the irq, no? ?Note this question is a repetition. ?You answered "No need, indeed. ?Will remove it." According to MCIMX28RM a write to
HW_ICOLL_VECTOR"indicates the in-service state". ?Are you sure this is not needed? ?If no (i.e. it's needed) the write should go intoentry-macro.S. ?As I don't have hardware yet I cannot test that. ?Maybe it's only needed when the priority levels are used?!Sorry. I made a mistake. ?I thought I had tested the removal of line and gave the comment, but actually not. The line is needed, and image will stop working without the line.
Quoted 9 lines
Quoted 2 lines
Regarding to moving the writing to register VECTOR into
entry-macro.S, can you please help me understand the reason behind the suggestion?Section 5.2.1 of MCIMX28RM writes:
? ? ? ?After the CPU enters the interrupt service routine, it must ? ? ? ?notify the interrupt collector as soon as possible. Software ? ? ? ?indicates the in-service state by writing to the
HW_ICOLL_VECTOR? ? ? ?register.In case you will ask why, I would give the fact here. ?I'm not sure what is your first thought. ?Mine is to add it into
get_irqnr_preambleas below.Quoted 5 lines
? ? ? ? .macro ?get_irqnr_preamble, base, tmp
? ? ? ? ldr ? ? \base, =ICOLL_ADDR
? ? ? ? mov ? ? \tmp, #0
? ? ? ? str ? ? \tmp, [\base]
? ? ? ? .endmIt's wrong to do that in
get_irqnr_preamble.Quoted 68 lines
But I got the following error.
[...]
VFS: Mounted root (nfs filesystem) on device 0:11.
Freeing init memory: 92K
irq 101: nobody cared (try booting with the "irqpoll" option) [<c0025084>] (unwind_backtrace+0x0/0xe4) from [<c0063d54>] (__report_bad_irq+0x34/0x8c)
[<c0063d54>] (__report_bad_irq+0x34/0x8c) from [<c0063ef8>] (note_interrupt+0x14c/0x1d8)
[<c0063ef8>] (note_interrupt+0x14c/0x1d8) from [<c0064d5c>] (handle_level_irq+0x 108/0x198)
[<c0064d5c>] (handle_level_irq+0x108/0x198) from [<c001f070>] (asm_do_IRQ+0x70/0 x94)
[<c001f070>] (asm_do_IRQ+0x70/0x94) from [<c0237050>] (__irq_svc+0x50/0x8c)Exception stack(0xc02e7d38 to 0xc02e7d80)7d20: ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
c02e7db000000000 7d40:ffffffd000000000c799080000000000c79a3820000005a8c02e7df8c02173807d60:c7997a28000005a800000000c02e7d80c02173a8c02173c040000013 ffffffff [<c0237050>] (__irq_svc+0x50/0x8c) from [<c02173c0>] (xs_tcp_data_recv+0x40/0x62
c)
[<c02173c0>] (xs_tcp_data_recv+0x40/0x62c) from [<c01d6160>] (tcp_read_sock+0x70/0x1e8)
[<c01d6160>] (tcp_read_sock+0x70/0x1e8) from [<c021734c>] (xs_tcp_data_ready+0x7c/0xb0)
[<c021734c>] (xs_tcp_data_ready+0x7c/0xb0) from [<c01dee3c>] (tcp_rcv_established+0x484/0x610) [<c01dee3c>] (tcp_rcv_established+0x484/0x610) from [<c01e5fd4>] (tcp_v4_do_rcv+0x28/0x1c8)
[<c01e5fd4>] (tcp_v4_do_rcv+0x28/0x1c8) from [<c01e65fc>] (tcp_v4_rcv+0x488/0x83
c)
[<c01e65fc>] (tcp_v4_rcv+0x488/0x83c) from [<c01ca038>] (ip_local_deliver+0x100/0x1fc)
[<c01ca038>] (ip_local_deliver+0x100/0x1fc) from [<c01c9efc>] (ip_rcv+0x540/0x57
c)
[<c01c9efc>] (ip_rcv+0x540/0x57c) from [<c01ad490>] (__netif_receive_skb+0x32c/0 x388)
[<c01ad490>] (__netif_receive_skb+0x32c/0x388) from [<c01ad56c>] (process_backlog+0x80/0x140) [<c01ad56c>] (process_backlog+0x80/0x140) from [<c01ad8a4>] (net_rx_action+0x58/
0x180)
[<c01ad8a4>] (net_rx_action+0x58/0x180) from [<c0037c50>] (__do_softirq+0x78/0x1
10)
[<c0037c50>] (__do_softirq+0x78/0x110) from [<c0037d2c>] (irq_exit+0x44/0xa8) [<c0037d2c>] (irq_exit+0x44/0xa8) from [<c001f074>] (asm_do_IRQ+0x74/0x94) [<c001f074>] (asm_do_IRQ+0x74/0x94) from [<c0237050>] (__irq_svc+0x50/0x8c)Exception stack(0xc02e7f80 to 0xc02e7fc8)7f80: 00000000
0005317f0005217f60000013c02e6000c001baf4c001baf0c02e9b607fa0:4001a848410692654001a7e000000000600000d3c02e7fc8c0020bc4c0020bd07fc0: 60000013 ffffffff
[<c0237050>] (__irq_svc+0x50/0x8c) from [<c0020bd0>] (default_idle+0x2c/0x30) [<c0020bd0>] (default_idle+0x2c/0x30) from [<c002110c>] (cpu_idle+0x60/0xc0) [<c002110c>] (cpu_idle+0x60/0xc0) from [<c00088f0>] (start_kernel+0x238/0x27c) [<c00088f0>] (start_kernel+0x238/0x27c) from [<40008034>] (0x40008034) handlers:
[<c01872e4>] (fec_enet_interrupt+0x0/0x3ec)
Disabling IRQ #101However, when I add it into
get_irqnr_and_baseas below.? ? ? ? .macro ?get_irqnr_and_base, irqnr, irqstat, base, tmp ? ? ? ? mov ? ? \tmp, #0
? ? ? ? str ? ? \tmp, [\base]
? ? ? ? ldr ? ? \irqnr, [\base, #0x70]
? ? ? ? cmp ? ? \irqnr, #0x7F
? ? ? ? moveqs ?\irqnr, #0
? ? ? ? .endmQuoted 1 line
Everything seems fine.
I think you need to do the following:
? ? ? ?.macro ?get_irqnr_and_base, irqnr, irqstat, base, tmp ? ? ? ?ldr ? ? \irqnr, [\base, #0x70]
? ? ? ?cmp ? ? \irqnr, #0x7F
? ? ? ?strne ? \irqnr, [\base]
? ? ? ?moveq ? \irqnr, #0
? ? ? ?.endm
Quoted 4 lines
(i.e. only write to VECTOR if there is an irq pending).
As before this is completely untested.
Tested. It's OK. Thanks Uwe.
Signature · 2 lines
Regards, Shawn
PATCH v2 4/15 ARM: mxs: Add interrupt support
In reply to Uwe Kleine-KönigHi Uwe,
2010/12/8 Uwe Kleine-K?nig <[email protected]>:
Quoted 2 lines
Hello Shawn,
[...]
Quoted 5 lines
Quoted 3 lines
+
+ ? ? .macro ?disable_fiq
+ ? ? .endmI think is isn't needed. ?Only when you start to actually use the fiq.
Without it, the compiler will complain when compiling arch/arm/kernel/entry-armv.S.
[...]
Quoted 10 lines
arch/arm/mach-mxs/include/mach/entry-macro.S line 40
Quoted 7 lines
+ ? ? ldr ? ? \base, =icoll_base
+ ? ? ldr ? ? \base, [\base]arch/arm/mach-mxs/include/mach/entry-macro.S new file +5
-0+#elif defined (CONFIG_SOC_IMX23) + ? ? ldr ? ? \base, =MX23_ICOLL_BASE_ADDR +#else + ? ? ldr ? ? \base, =MX28_ICOLL_BASE_ADDR +#endifMhh, you said the base addresses are different. ?Unless I'm mistaken they are not. ?So you can just remove
icoll_base.
Something went wrong in my head. The addresses are same.
Signature · 2 lines
Regards, Shawn
PATCH v2 4/15 ARM: mxs: Add interrupt support
Hello Shawn,
Quoted 9 lines · Shawn Guo
2010/12/8 Uwe Kleine-K?nig <[email protected]>:
[...]Quoted 5 lines
Quoted 3 lines
+
+ ? ? .macro ?disable_fiq
+ ? ? .endmI think is isn't needed. ?Only when you start to actually use the fiq.
Without it, the compiler will complain when compiling
arch/arm/kernel/entry-armv.S.
OK
Uwe
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-K?nig | Industrial Linux Solutions | http://www.pengutronix.de/ |
PATCH v2 4/15 ARM: mxs: Add interrupt support
In reply to Shawn GuoHi,
Quoted 14 lines · Shawn Guo
Add Interrupt Collector (ICOLL) support for MXS-based.
Signed-off-by Shawn Guo <[email protected]>---
Changes for v2:
- Get icoll base inget_irqnr_preamble
- Check the case of single SoC build and use hard-coding address if possiblearch/arm/mach-mxs/icoll.c | 77 ++++++++++++++++++++++++++ arch/arm/mach-mxs/include/mach/entry-macro.S | 44 +++++++++++++++ 2 files changed, 121 insertions(+), 0 deletions(-) create mode 100644 arch/arm/mach-mxs/icoll.c create mode 100644 arch/arm/mach-mxs/include/mach/entry-macro.S
[...]
Quoted 34 lines
arch/arm/mach-mxs/include/mach/entry-macro.S new file +27
-0@@ -0,0 +1,44 @@ +/* + * Low-level IRQ helper macros for Freescale MXS-based + * + * 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 <mach/hardware.h> + + .macro disable_fiq + .endm + + .macro get_irqnr_and_base, irqnr, irqstat, base, tmp + ldr \irqnr, [\base, #0x70]
arch/arm/mach-mxs/include/mach/entry-macro.S line 37
Quoted 10 lines
arch/arm/mach-mxs/include/mach/entry-macro.S new file +10
-0+ cmp \irqnr, #0x7F + moveqs \irqnr, #0 + .endm + + .macro get_irqnr_preamble, base, tmp +#if defined (CONFIG_SOC_IMX23) && defined (CONFIG_SOC_IMX28) + ldr \base, =icoll_base + ldr \base, [\base] +#elif defined (CONFIG_SOC_IMX23) + ldr \base, =MX23_ICOLL_BASE_ADDR
MX23_IO_ADDRESS(MX23_ICOLL_BASE_ADDR)
arch/arm/mach-mxs/include/mach/entry-macro.S line 39
Quoted 3 lines
arch/arm/mach-mxs/include/mach/entry-macro.S new file +2
-0+#else + ldr \base, =MX28_ICOLL_BASE_ADDR
MX28_IO_ADDRESS(MX28_ICOLL_BASE_ADDR)
Lothar Wa?mann
Signature · 9 lines
___________________________________________________________ Ka-Ro electronics GmbH | Pascalstra?e 22 | D - 52076 Aachen Phone: +49 2408 1402-0 | Fax: +49 2408 1402-10 Gesch?ftsf?hrer: Matthias Kaussen Handelsregistereintrag: Amtsgericht Aachen, HRB 4996 www.karo-electronics.de | info at karo-electronics.de ___________________________________________________________
PATCH v2 5/15 ARM: mxs: Add low-level debug UART support
In reply to Shawn Guo - DEBUG_LL support, which is incompatible with single MXS image because of different DUART base address on MX23 and MX28
- uncompress message support
---
Changes for v2:
- Remove incorrect comments
arch/arm/mach-mxs/include/mach/debug-macro.S | 51 +++++++++++++++++ arch/arm/mach-mxs/include/mach/uncompress.h | 78 ++++++++++++++++++++++++++ 2 files changed, 129 insertions(+), 0 deletions(-) create mode 100644 arch/arm/mach-mxs/include/mach/debug-macro.S create mode 100644 arch/arm/mach-mxs/include/mach/uncompress.h
arch/arm/mach-mxs/include/mach/debug-macro.S new file +51 -0
@@ -0,0 +1,51 @@ +/* arch/arm/mach-mxs/include/mach/debug-macro.S + * + * Debugging macro include header + * + * Copyright (C) 1994-1999 Russell King + * Moved from linux/arch/arm/kernel/debug.S by Ben Dooks + * + * 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> + +#ifdef CONFIG_SOC_IMX23 +#ifdef UART_PADDR +#error "CONFIG_DEBUG_LL is incompatible with multiple archs" +#endif +#define UART_PADDR MX23_DUART_BASE_ADDR +#endif + +#ifdef CONFIG_SOC_IMX28 +#ifdef UART_PADDR +#error "CONFIG_DEBUG_LL is incompatible with multiple archs" +#endif +#define UART_PADDR MX28_DUART_BASE_ADDR +#endif + +#define UART_VADDR MXS_IO_ADDRESS(UART_PADDR) + + .macro addruart, rp, rv + ldr \rp, =UART_PADDR @ physical + ldr \rv, =UART_VADDR @ virtual + .endm + + .macro senduart, rd, rx + str \rd, [\rx, #0x0] @ DR + .endm + + .macro waituart, rd, rx +1001: ldr \rd, [\rx, #0x18] @ FR + tst \rd, #1 << 5 @ FR_TXFF + bne 1001b + .endm + + .macro busyuart, rd, rx +1002: ldr \rd, [\rx, #0x18] @ FR + tst \rd, #1 << 3 @ FR_BUSY + beq 1002b + .endm
arch/arm/mach-mxs/include/mach/uncompress.h new file +78 -0
78 lines not on this page · raw message
Signature · 1 line
1.7.1
PATCH v2 5/15 ARM: mxs: Add low-level debug UART support
Quoted 1 line · Shawn Guo
-
DEBUG_LLsupport, which is incompatible with single MXS image
maybe better: s/single/multi-soc/
Quoted 101 lines
because of different DUART base address on MX23 and MX28
- uncompress message supportSigned-off-by Shawn Guo <[email protected]>---
Changes for v2:
- Remove incorrect commentsarch/arm/mach-mxs/include/mach/debug-macro.S | 51 +++++++++++++++++ arch/arm/mach-mxs/include/mach/uncompress.h | 78 ++++++++++++++++++++++++++ 2 files changed, 129 insertions(+), 0 deletions(-) create mode 100644 arch/arm/mach-mxs/include/mach/debug-macro.S create mode 100644 arch/arm/mach-mxs/include/mach/uncompress.harch/arm/mach-mxs/include/mach/debug-macro.S new file +51
-0@@ -0,0 +1,51 @@ +/* arch/arm/mach-mxs/include/mach/debug-macro.S + * + * Debugging macro include header + * + * Copyright (C) 1994-1999 Russell King + * Moved from linux/arch/arm/kernel/debug.S by Ben Dooks + * + * 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> + +#ifdef CONFIG_SOC_IMX23 +#ifdef UART_PADDR +#error "CONFIG_DEBUG_LL is incompatible with multiple archs" +#endif +#define UART_PADDR MX23_DUART_BASE_ADDR +#endif + +#ifdef CONFIG_SOC_IMX28 +#ifdef UART_PADDR +#error "CONFIG_DEBUG_LL is incompatible with multiple archs" +#endif +#define UART_PADDR MX28_DUART_BASE_ADDR +#endif + +#define UART_VADDR MXS_IO_ADDRESS(UART_PADDR) + + .macro addruart, rp, rv + ldr \rp, =UART_PADDR @ physical + ldr \rv, =UART_VADDR @ virtual + .endm + + .macro senduart, rd, rx + str \rd, [\rx, #0x0] @ DR + .endm + + .macro waituart, rd, rx +1001: ldr \rd, [\rx, #0x18] @ FR + tst \rd, #1 << 5 @ FR_TXFF + bne 1001b + .endm + + .macro busyuart, rd, rx +1002: ldr \rd, [\rx, #0x18] @ FR + tst \rd, #1 << 3 @ FR_BUSY + beq 1002b + .endmarch/arm/mach-mxs/include/mach/uncompress.h new file +24
-0@@ -0,0 +1,78 @@ +/* +* arch/arm/mach-mxs/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 +* 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. +*/ +#ifndef __MACH_MXS_UNCOMPRESS_H__ +#define __MACH_MXS_UNCOMPRESS_H__ + +#define __MXS_BOOT_UNCOMPRESS + +#include <asm/mach-types.h> +
arch/arm/mach-mxs/include/mach/uncompress.h line 34
Quoted 10 lines
arch/arm/mach-mxs/include/mach/uncompress.h new file +10
-0+static unsigned long uart_base; + +#define UART (x) (*(volatile unsigned long *)(uart_base + (x))) + +#define DR 0x00 +#define FR 0x18 +#define FR_BUSY (1 << 3) +#define FR_TXFE (1 << 7) +#define CR 0x30 +#define CR_UARTEN 1
Maybe namespace these? Maybe better define CR_UARTEN as (1 << 0) for consistency?
arch/arm/mach-mxs/include/mach/uncompress.h line 38
Quoted 4 lines
arch/arm/mach-mxs/include/mach/uncompress.h new file +4
-0+ +/* +* The following code assumes the serial port has already been +* initialized by the bootloader.
Maybe add:
* If it's not, the output is simply discarded.
Quoted 50 lines
arch/arm/mach-mxs/include/mach/uncompress.h new file +40
-0+*/ + +static void putc (int ch) +{ +if (!uart_base) +return ; +if (!(UART (CR ) &CR_UARTEN )) +return ; + +while (!(UART (FR ) &FR_TXFE )) +barrier (); + +UART (DR ) = ch; +} + +static inline void flush (void ) +{ +} + +#define MX23_DUART_BASE_ADDR 0x80070000 +#define MX28_DUART_BASE_ADDR 0x80074000 + +static __inline__void __arch_decomp_setup (unsigned long arch_id) +{ +switch (arch_id) { +case MACH_TYPE_MX23EVK : + uart_base =MX23_DUART_BASE_ADDR ; +break ; +case MACH_TYPE_MX28EVK : + uart_base =MX28_DUART_BASE_ADDR ; +break ; +default : +break ; + } +} + +#define arch_decomp_setup () __arch_decomp_setup(arch_id) +#define arch_decomp_wdog () + +#endif /* __MACH_MXS_UNCOMPRESS_H__ */ Signature · 8 lines
1.7.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel at lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-K?nig | Industrial Linux Solutions | http://www.pengutronix.de/ |
PATCH v2 5/15 ARM: mxs: Add low-level debug UART support
Hi Uwe,
2010/12/9 Uwe Kleine-K?nig <[email protected]>:
Quoted 1 line · Shawn Guo
[...]
Quoted 34 lines
Quoted 34 lines
arch/arm/mach-mxs/include/mach/uncompress.h new file +28
-0@@ -0,0 +1,78 @@ +/* +* ?arch/arm/mach-mxs/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 +* 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. +*/ +#ifndef __MACH_MXS_UNCOMPRESS_H__ +#define __MACH_MXS_UNCOMPRESS_H__ + +#define __MXS_BOOT_UNCOMPRESS + +#include <asm/mach-types.h> + +static unsigned long uart_base; + +#define UART (x) (*(volatile unsigned long *)(uart_base + (x))) +
Quoted 9 lines
arch/arm/mach-mxs/include/mach/uncompress.h line 34
Quoted 6 lines
arch/arm/mach-mxs/include/mach/uncompress.h new file +6
-0+#define DR ? ? ? ? ? 0x00 +#define FR ? ? ? ? ? 0x18 +#define FR_BUSY ? ? ? ? ? ? ?(1 << 3) +#define FR_TXFE ? ? ? ? ? ? ?(1 << 7) +#define CR ? ? ? ? ? 0x30 +#define CR_UARTEN ? ?1Maybe namespace these? ?Maybe better define
CR_UARTENas (1 << 0) for consistency?
Are you expecting namespace "MXS_" or "DUART_" for better?
Signature · 2 lines
Regards, Shawn
PATCH v2 5/15 ARM: mxs: Add low-level debug UART support
Hello Shawn,
Quoted 5 lines · Shawn Guo
2010/12/9 Uwe Kleine-K?nig <[email protected]>:
Quoted 4 lines
arch/arm/mach-mxs/include/mach/uncompress.h line 21
Quoted 4 lines
arch/arm/mach-mxs/include/mach/uncompress.h new file +4
-0+#ifndef __MACH_MXS_UNCOMPRESS_H__ +#define __MACH_MXS_UNCOMPRESS_H__ + +#define __MXS_BOOT_UNCOMPRESS
is this used, BTW?
Quoted 16 lines
Quoted 7 lines
Quoted 7 lines
arch/arm/mach-mxs/include/mach/uncompress.h new file +7
-0+ +#include <asm/mach-types.h> + +static unsigned long uart_base; + +#define UART (x) (*(volatile unsigned long *)(uart_base + (x))) +Quoted 9 lines
Review
Quoted 6 lines
(quoted diff) +6
-0+#define DR ? ? ? ? ? 0x00 +#define FR ? ? ? ? ? 0x18 +#define FR_BUSY ? ? ? ? ? ? ?(1 << 3) +#define FR_TXFE ? ? ? ? ? ? ?(1 << 7) +#define CR ? ? ? ? ? 0x30 +#define CR_UARTEN ? ?1Maybe namespace these? ?Maybe better define
CR_UARTENas (1 << 0) for consistency?
Quoted 1 line
Are you expecting namespace "
MXS_" or "DUART_" for better?
both?
Uwe
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-K?nig | Industrial Linux Solutions | http://www.pengutronix.de/ |
PATCH v2 6/15 ARM: mxs: Add timer support
In reply to Shawn GuoFreescale MXS-based SoCs implement timer support in block TIMROT. There are two versions of TIMROT. The v1 on MX23 only gets 16 bits counter and has no match function. The v2 on MX28 extends the counter to 32 bits and add the match function.
As the result, we need two instances of timers with v1 for better implementation, one for next_event and another for get_cycles. Otherwise, get_cycles may get imprecise result after long time cumulating. With v2, one instance can serve two purposes well.
---
- Fix a bug in timrot_set_next_event(). It should read HW_TIMROT_RUNNING_COUNTn to get the current counts.
arch/arm/mach-mxs/timer.c | 285 +++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 285 insertions(+), 0 deletions(-) create mode 100644 arch/arm/mach-mxs/timer.c
arch/arm/mach-mxs/timer.c new file +285 -0
@@ -0,0 +1,285 @@ +/* +* Copyright (C) 2000-2001 Deep Blue Solutions +* 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 +* 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/interrupt.h> +#include <linux/irq.h> +#include <linux/clockchips.h> +#include <linux/clk.h> + +#include <mach/hardware.h> +#include <asm/mach/time.h> +#include <mach/common.h> + +/* +* There are 2 versions of the timrot on Freescale MXS-based SoCs. +* The v1 on MX23 only gets 16 bits counter and has no match function. +* The v2 on MX28 extends the counter to 32 bits and add the match function. +* +* As the result, we need two instances of timers with v1 for better +* implementation, one for next_event and another for get_cycles. Otherwise, +* get_cycles may get imprecise result after long time cumulating. +* With v2, one instance can serve two purposes well. +*/ +#define timrot_is_v1 () (cpu_is_mx23()) + +#define HW_TIMROT_ROTCTRL 0x00 +#define HW_TIMROT_TIMCTRLn (n) (0x20 + (n) * 0x40) +#define HW_TIMROT_RUNNING_COUNTn (n) (0x30 + (n) * 0x40) +#define HW_TIMROT_MATCH_COUNTn (n) (0x50 + (n) * 0x40) +#define BM_TIMROT_TIMCTRLn_RELOAD (1 << 6) +#define BM_TIMROT_TIMCTRLn_UPDATE (1 << 7) +#define BM_TIMROT_TIMCTRLn_MATCH_MODE (1 << 11) +#define BM_TIMROT_TIMCTRLn_IRQ_EN (1 << 14) +#define BM_TIMROT_TIMCTRLn_IRQ (1 << 15) +#define BP_TIMROT_TIMCTRLn_SELECT 0 +#define BV_TIMROT_TIMCTRLn_SELECT__32KHZ_XTAL (timrot_is_v1() ? 0x8 : 0xb) + +static struct clock_event_device clockevent_mxs; +static enum clock_event_mode clockevent_mode =CLOCK_EVT_MODE_UNUSED ; + +static void __iomem *timer_base; + +static inline void timrot_irq_disable (void ) +{ +__raw_writel (BM_TIMROT_TIMCTRLn_IRQ_EN, + timer_base +HW_TIMROT_TIMCTRLn (0 ) +MXS_CLR_ADDR ); +} + +static inline void timrot_irq_enable (void ) +{ +__raw_writel (BM_TIMROT_TIMCTRLn_IRQ_EN, + timer_base +HW_TIMROT_TIMCTRLn (0 ) +MXS_SET_ADDR ); +} + +static void timrot_irq_acknowledge (void ) +{ +__raw_writel (BM_TIMROT_TIMCTRLn_IRQ, + timer_base +HW_TIMROT_TIMCTRLn (0 ) +MXS_CLR_ADDR ); +} + +static cycle_t timrot_get_cycles (struct clocksource *cs) +{ +if (timrot_is_v1 ()) +return ~((__raw_readl (timer_base +HW_TIMROT_RUNNING_COUNTn (1 )) + &0xffff0000 ) >>16 ); +else +return ~__raw_readl (timer_base +HW_TIMROT_RUNNING_COUNTn (0 )); +} + +static int timrot_set_next_event (unsigned long evt, +struct clock_event_device *dev) +{ +unsigned long match; +int ret; + +/* timrot decrements the count */ +if (timrot_is_v1 ()) { +__raw_writel (evt, timer_base +HW_TIMROT_RUNNING_COUNTn (0 )); + ret =0 ; + }else { + match =__raw_readl (timer_base +HW_TIMROT_RUNNING_COUNTn (0 )) + - evt; +__raw_writel (match, timer_base +HW_TIMROT_MATCH_COUNTn (0 )); + ret = (int )(match -__raw_readl (timer_base + +HW_TIMROT_RUNNING_COUNTn (0 ))) >0 ? -ETIME :0 ; + } + +return ret; +} + +static irqreturn_t mxs_timer_interrupt (int irq,void *dev_id) +{ +struct clock_event_device *evt = &clockevent_mxs; + +timrot_irq_acknowledge (); + evt->event_handler (evt); + +return IRQ_HANDLED ; +} + +static struct irqaction mxs_timer_irq = { + .name ="MXS Timer Tick" , + .flags =IRQF_DISABLED |IRQF_TIMER |IRQF_IRQPOLL , + .handler = mxs_timer_interrupt, +}; + +#ifdef DEBUG +static const char *clock_event_mode_label[] = { + [CLOCK_EVT_MODE_PERIODIC ] ="CLOCK_EVT_MODE_PERIODIC" , + [CLOCK_EVT_MODE_ONESHOT ] ="CLOCK_EVT_MODE_ONESHOT" , + [CLOCK_EVT_MODE_SHUTDOWN ] ="CLOCK_EVT_MODE_SHUTDOWN" , + [CLOCK_EVT_MODE_UNUSED ] ="CLOCK_EVT_MODE_UNUSED" +}; +#endif /* DEBUG */ + +static void mxs_set_mode (enum clock_event_mode mode, +struct clock_event_device *evt) +{ +unsigned long flags; + +/* +* The timer interrupt generation is disabled at least +* for enough time to call mxs_set_next_event() +*/ +local_irq_save (flags); + +/* Disable interrupt in timer module */ +timrot_irq_disable (); + +if (mode != clockevent_mode) { +/* Set event time into far-far future */ +__raw_writel (__raw_readl (timer_base + +HW_TIMROT_RUNNING_COUNTn (0 )) +3 , + timer_base +HW_TIMROT_MATCH_COUNTn (0 )); + +/* Clear pending interrupt */ +timrot_irq_acknowledge (); + } + +#ifdef DEBUG +printk (KERN_INFO "mxs_set_mode: changing mode from %s to %s\n" , + clock_event_mode_label[clockevent_mode], + clock_event_mode_label[mode]); +#endif /* DEBUG */ + +/* Remember timer mode */ + clockevent_mode = mode; +local_irq_restore (flags); + +switch (mode) { +case CLOCK_EVT_MODE_PERIODIC : +printk (KERN_ERR "mxs_set_mode: Periodic mode is not " +"supported for MXS-based\n" ); +break ; +case CLOCK_EVT_MODE_ONESHOT : +/* +* Do not put overhead of interrupt enable/disable into +* mxs_set_next_event(), the core has about 4 minutes +* to call mxs_set_next_event() or shutdown clock after +* mode switching +*/ +local_irq_save (flags); +timrot_irq_enable (); +local_irq_restore (flags); +break ; +case CLOCK_EVT_MODE_SHUTDOWN : +case CLOCK_EVT_MODE_UNUSED : +case CLOCK_EVT_MODE_RESUME : +/* Left event sources disabled, no more interrupts appear */ +break ; + } +} + +static struct clock_event_device clockevent_mxs = { + .name ="mxs_timrot" , + .features =CLOCK_EVT_FEAT_ONESHOT , + .shift =32 , + .set_mode = mxs_set_mode, + .set_next_event = timrot_set_next_event, + .rating =200 , +}; + +static int __init mxs_clockevent_init (struct clk *timer_clk) +{ +unsigned int c =clk_get_rate (timer_clk); + + clockevent_mxs.mult =div_sc (c,NSEC_PER_SEC , clockevent_mxs.shift); + clockevent_mxs.cpumask =cpumask_of (0 ); +if (timrot_is_v1 ()) { + clockevent_mxs.max_delta_ns = +clockevent_delta2ns (0xfffe , &clockevent_mxs); + clockevent_mxs.min_delta_ns = +clockevent_delta2ns (0xf , &clockevent_mxs); + }else { + clockevent_mxs.max_delta_ns = +clockevent_delta2ns (0xfffffffe , &clockevent_mxs); + clockevent_mxs.min_delta_ns = +clockevent_delta2ns (0xff , &clockevent_mxs); + } + +clockevents_register_device (&clockevent_mxs); + +return 0 ; +} + +static struct clocksource clocksource_mxs = { + .name ="mxs_timer" , + .rating =200 , + .read = timrot_get_cycles, + .mask =CLOCKSOURCE_MASK (32 ), + .shift =10 , + .flags =CLOCK_SOURCE_IS_CONTINUOUS , +}; + +static int __init mxs_clocksource_init (struct clk *timer_clk) +{ +unsigned int c =clk_get_rate (timer_clk); + +if (timrot_is_v1 ()) + clocksource_mxs.mask =CLOCKSOURCE_MASK (16 ); + clocksource_mxs.mult =clocksource_hz2mult (c, clocksource_mxs.shift); +clocksource_register (&clocksource_mxs); + +return 0 ; +} + +void __init mxs_timer_init (struct clk *timer_clk, +void __iomem *base,int irq) +{ +clk_enable (timer_clk); + + timer_base = base; + +/* +* Initialize timers to a known state +*/ +mxs_reset_block (base +HW_TIMROT_ROTCTRL ); + +if (timrot_is_v1 ()) { +/* timer0 is for next_event */ +__raw_writel ( + BV_TIMROT_TIMCTRLn_SELECT__32KHZ_XTAL | + BM_TIMROT_TIMCTRLn_UPDATE | + BM_TIMROT_TIMCTRLn_IRQ_EN, + base +HW_TIMROT_TIMCTRLn (0 )); +/* timer1 is for get_cycles */ +__raw_writel ( + BV_TIMROT_TIMCTRLn_SELECT__32KHZ_XTAL | + BM_TIMROT_TIMCTRLn_RELOAD, + base +HW_TIMROT_TIMCTRLn (1 )); +__raw_writel (0xffff , timer_base +HW_TIMROT_RUNNING_COUNTn (1 )); + + }else { +__raw_writel ( + BV_TIMROT_TIMCTRLn_SELECT__32KHZ_XTAL | + BM_TIMROT_TIMCTRLn_IRQ_EN | + BM_TIMROT_TIMCTRLn_MATCH_MODE, + timer_base +HW_TIMROT_TIMCTRLn (0 )); + } + +/* init and register the timer to the framework */ +mxs_clocksource_init (timer_clk); +mxs_clockevent_init (timer_clk); + +/* Make irqs happen */ +setup_irq (irq, &mxs_timer_irq); +}
Signature · 1 line
1.7.1
PATCH v3 1/15 ARM: mxs: Add core definitions
In reply to Shawn GuoAdd core definitions for MXS-based SoC MX23 and MX28.
---
Changes for v3:
- Update MXS_IO_P2V definition and comment to get them matched
- Sort mx23 base address definitions by offset
- Remove mx28 reserved IRQ definitions
- Remove unnecessary dummy definitions for cpu_is_mx23() and cpu_is_mx28()
Changes for v2:
- Remove MXS_IO_P2V_MODULE from hardware.h which is not needed
- Simplify MXS_IO_P2V_MODULE definition in hardware.h
- Remove unnecessary inclusion protection from hardware.h
- Change cpu_is_mx23/mx28() implementation in mxs.h to use machine_is_xxx
arch/arm/mach-mxs/include/mach/hardware.h | 55 +++++++++ arch/arm/mach-mxs/include/mach/irqs.h | 32 +++++ arch/arm/mach-mxs/include/mach/memory.h | 24 ++++ arch/arm/mach-mxs/include/mach/mx23.h | 147 ++++++++++++++++++++++ arch/arm/mach-mxs/include/mach/mx28.h | 190 +++++++++++++++++++++++++++++ arch/arm/mach-mxs/include/mach/mxs.h | 34 +++++ 6 files changed, 482 insertions(+), 0 deletions(-) create mode 100644 arch/arm/mach-mxs/include/mach/hardware.h create mode 100644 arch/arm/mach-mxs/include/mach/irqs.h create mode 100644 arch/arm/mach-mxs/include/mach/memory.h create mode 100644 arch/arm/mach-mxs/include/mach/mx23.h create mode 100644 arch/arm/mach-mxs/include/mach/mx28.h create mode 100644 arch/arm/mach-mxs/include/mach/mxs.h
arch/arm/mach-mxs/include/mach/hardware.h new file +55 -0
@@ -0,0 +1,55 @@ +/* +* Copyright 2004-2007 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 +* 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_MXS_HARDWARE_H__ +#define __MACH_MXS_HARDWARE_H__ + +#include <asm/sizes.h> + +#ifdef __ASSEMBLER__ +#define IOMEM (addr) (addr) +#else +#define IOMEM (addr) ((void __force __iomem *)(addr)) +#endif + +/* +* It maps the whole address space to [0xf4000000, 0xf5ffffff]. +* +* OCRAM 0x00000000+0x020000 -> 0xf4000000+0x020000 +* IO 0x80000000+0x100000 -> 0xf5000000+0x100000 +*/ +#define MXS_IO_P2V (x) (0xf4000000 + \ + (((x) & 0x80000000) >> 7) + \ + (((x) & 0x000fffff))) + + +#define MXS_IO_ADDRESS (x) IOMEM(MXS_IO_P2V(x)) + +#include <mach/mx23.h> +#include <mach/mx28.h> +#include <mach/mxs.h> + +#define mxs_map_entry (soc, name, _type) { \ + .virtual = soc ## _IO_P2V(soc ## _ ## name ## _BASE_ADDR), \ + .pfn = __phys_to_pfn(soc ## _ ## name ## _BASE_ADDR), \ + .length = soc ## _ ## name ## _SIZE, \ + .type = _type, \ +} + +#endif /* __MACH_MXS_HARDWARE_H__ */
arch/arm/mach-mxs/include/mach/irqs.h new file +32 -0
@@ -0,0 +1,32 @@ +/* +* Copyright 2004-2007 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. +*/ + +#ifndef __MACH_MXS_IRQS_H__ +#define __MACH_MXS_IRQS_H__ + +#define MXS_INTERNAL_IRQS 128 + +#define MXS_GPIO_IRQ_START MXS_INTERNAL_IRQS + +/* the maximum for MXS-based */ +#define MXS_GPIO_IRQS (32 * 5) + +/* +* The next 16 interrupts are for board specific purposes. Since +* the kernel can only run on one machine at a time, we can re-use +* these. If you need more, increase MXS_BOARD_IRQS, but keep it +* within sensible limits. +*/ +#define MXS_BOARD_IRQ_START (MXS_GPIO_IRQ_START + MXS_GPIO_IRQS) +#define MXS_BOARD_IRQS 16 + +#define NR_IRQS (MXS_BOARD_IRQ_START + MXS_BOARD_IRQS) + +#endif /* __MACH_MXS_IRQS_H__ */
arch/arm/mach-mxs/include/mach/memory.h new file +24 -0
@@ -0,0 +1,24 @@ +/* +* 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_MXS_MEMORY_H__ +#define __MACH_MXS_MEMORY_H__ + +#define PHYS_OFFSET UL(0x40000000) + +#endif /* __MACH_MXS_MEMORY_H__ */
arch/arm/mach-mxs/include/mach/mx23.h new file +147 -0
147 lines not on this page · raw message
arch/arm/mach-mxs/include/mach/mx28.h new file +190 -0
190 lines not on this page · raw message
arch/arm/mach-mxs/include/mach/mxs.h new file +34 -0
@@ -0,0 +1,34 @@ +/* +* 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_MXS_H__ +#define __MACH_MXS_H__ + +#include <asm/mach-types.h> + +#define MXS_SET_ADDR 0x4 +#define MXS_CLR_ADDR 0x8 +#define MXS_TOG_ADDR 0xc + +/* +* MXS CPU types +*/ +# define cpu_is_mx23 () (machine_is_mx23evk()) +# define cpu_is_mx28 () (machine_is_mx28evk()) + +#endif /* __MACH_MXS_H__ */
Signature · 1 line
1.7.1
PATCH v3 1/15 ARM: mxs: Add core definitions
Quoted 58 lines · Shawn Guo
Add core definitions for MXS-based SoC MX23 and MX28.
Signed-off-by Shawn Guo <[email protected]>---
Changes for v3:
- UpdateMXS_IO_P2Vdefinition and comment to get them matched
- Sort mx23 base address definitions by offset
- Remove mx28 reserved IRQ definitions
- Remove unnecessary dummy definitions forcpu_is_mx23()andcpu_is_mx28()Changes for v2:
- RemoveMXS_IO_P2V_MODULEfromhardware.hwhich is not needed
- SimplifyMXS_IO_P2V_MODULEdefinition inhardware.h
- Remove unnecessary inclusion protection fromhardware.h
- Change cpu_is_mx23/mx28() implementation inmxs.hto usemachine_is_xxxarch/arm/mach-mxs/include/mach/hardware.h | 55 +++++++++ arch/arm/mach-mxs/include/mach/irqs.h | 32 +++++ arch/arm/mach-mxs/include/mach/memory.h | 24 ++++ arch/arm/mach-mxs/include/mach/mx23.h | 147 ++++++++++++++++++++++ arch/arm/mach-mxs/include/mach/mx28.h | 190 +++++++++++++++++++++++++++++ arch/arm/mach-mxs/include/mach/mxs.h | 34 +++++ 6 files changed, 482 insertions(+), 0 deletions(-) create mode 100644 arch/arm/mach-mxs/include/mach/hardware.h create mode 100644 arch/arm/mach-mxs/include/mach/irqs.h create mode 100644 arch/arm/mach-mxs/include/mach/memory.h create mode 100644 arch/arm/mach-mxs/include/mach/mx23.h create mode 100644 arch/arm/mach-mxs/include/mach/mx28.h create mode 100644 arch/arm/mach-mxs/include/mach/mxs.harch/arm/mach-mxs/include/mach/hardware.h new file +22
-0@@ -0,0 +1,55 @@ +/* +* Copyright 2004-2007 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 +* 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_MXS_HARDWARE_H__ +#define __MACH_MXS_HARDWARE_H__ +
arch/arm/mach-mxs/include/mach/hardware.h line 32
Quoted 10 lines
arch/arm/mach-mxs/include/mach/hardware.h new file +10
-0+#include <asm/sizes.h> + +#ifdef __ASSEMBLER__ +#define IOMEM (addr) (addr) +#else +#define IOMEM (addr) ((void __force __iomem *)(addr)) +#endif + +/* +* It maps the whole address space to [0xf4000000, 0xf5ffffff].
The maximal address that can occur is 0xf50fffff
Quoted 111 lines
arch/arm/mach-mxs/include/mach/hardware.h new file +23
-0+* +* OCRAM 0x00000000+0x020000 -> 0xf4000000+0x020000 +* IO 0x80000000+0x100000 -> 0xf5000000+0x100000 +*/ +#define MXS_IO_P2V (x) (0xf4000000 + \ + (((x) & 0x80000000) >> 7) + \ + (((x) & 0x000fffff))) + + +#define MXS_IO_ADDRESS (x) IOMEM(MXS_IO_P2V(x)) + +#include <mach/mx23.h> +#include <mach/mx28.h> +#include <mach/mxs.h> + +#define mxs_map_entry (soc, name, _type) { \ + .virtual = soc ## _IO_P2V(soc ## _ ## name ## _BASE_ADDR), \ + .pfn = __phys_to_pfn(soc ## _ ## name ## _BASE_ADDR), \ + .length = soc ## _ ## name ## _SIZE, \ + .type = _type, \ +} + +#endif /* __MACH_MXS_HARDWARE_H__ */ arch/arm/mach-mxs/include/mach/irqs.h new file +32
-0@@ -0,0 +1,32 @@ +/* +* Copyright 2004-2007 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. +*/ + +#ifndef __MACH_MXS_IRQS_H__ +#define __MACH_MXS_IRQS_H__ + +#define MXS_INTERNAL_IRQS 128 + +#define MXS_GPIO_IRQ_START MXS_INTERNAL_IRQS + +/* the maximum for MXS-based */ +#define MXS_GPIO_IRQS (32 * 5) + +/* +* The next 16 interrupts are for board specific purposes. Since +* the kernel can only run on one machine at a time, we can re-use +* these. If you need more, increase MXS_BOARD_IRQS, but keep it +* within sensible limits. +*/ +#define MXS_BOARD_IRQ_START (MXS_GPIO_IRQ_START + MXS_GPIO_IRQS) +#define MXS_BOARD_IRQS 16 + +#define NR_IRQS (MXS_BOARD_IRQ_START + MXS_BOARD_IRQS) + +#endif /* __MACH_MXS_IRQS_H__ */ arch/arm/mach-mxs/include/mach/memory.h new file +24
-0@@ -0,0 +1,24 @@ +/* +* 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_MXS_MEMORY_H__ +#define __MACH_MXS_MEMORY_H__ + +#define PHYS_OFFSET UL(0x40000000) + +#endif /* __MACH_MXS_MEMORY_H__ */ arch/arm/mach-mxs/include/mach/mx23.h new file +14
-0@@ -0,0 +1,147 @@ +/* +* 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/mach-mxs/include/mach/mx23.h line 24
Quoted 10 lines
arch/arm/mach-mxs/include/mach/mx23.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_MX23_H__ +#define __MACH_MX23_H__ + +#ifndef __ASSEMBLER__ +#include <linux/io.h> +#endif
You don't need this, do you?
#inclusion of hardware.h would be OK, then you could remove the #includes of mx23.h and mx28.h in there.
(Believe me, this is better, mxc already made me headaches because of that.)
Quoted 142 lines
arch/arm/mach-mxs/include/mach/mx23.h new file +122
-0+/* +* OCRAM +*/ +#define MX23_OCRAM_BASE_ADDR 0x00000000 +#define MX23_OCRAM_SIZE SZ_32K + +/* +* IO +*/ +#define MX23_IO_BASE_ADDR 0x80000000 +#define MX23_IO_SIZE SZ_1M + +#define MX23_ICOLL_BASE_ADDR (MX23_IO_BASE_ADDR + 0x000000) +#define MX23_APBH_DMA_BASE_ADDR (MX23_IO_BASE_ADDR + 0x004000) +#define MX23_BCH_BASE_ADDR (MX23_IO_BASE_ADDR + 0x00a000) +#define MX23_GPMI_BASE_ADDR (MX23_IO_BASE_ADDR + 0x00c000) +#define MX23_SSP1_BASE_ADDR (MX23_IO_BASE_ADDR + 0x010000) +#define MX23_PINCTRL_BASE_ADDR (MX23_IO_BASE_ADDR + 0x018000) +#define MX23_DIGCTL_BASE_ADDR (MX23_IO_BASE_ADDR + 0x01c000) +#define MX23_ETM_BASE_ADDR (MX23_IO_BASE_ADDR + 0x020000) +#define MX23_APBX_DMA_BASE_ADDR (MX23_IO_BASE_ADDR + 0x024000) +#define MX23_DCP_BASE_ADDR (MX23_IO_BASE_ADDR + 0x028000) +#define MX23_PXP_BASE_ADDR (MX23_IO_BASE_ADDR + 0x02a000) +#define MX23_OCOTP_BASE_ADDR (MX23_IO_BASE_ADDR + 0x02c000) +#define MX23_AXI_AHB0_BASE_ADDR (MX23_IO_BASE_ADDR + 0x02e000) +#define MX23_LCDIF_BASE_ADDR (MX23_IO_BASE_ADDR + 0x030000) +#define MX23_SSP2_BASE_ADDR (MX23_IO_BASE_ADDR + 0x034000) +#define MX23_TVENC_BASE_ADDR (MX23_IO_BASE_ADDR + 0x038000) +#define MX23_CLKCTRL_BASE_ADDR (MX23_IO_BASE_ADDR + 0x040000) +#define MX23_SAIF0_BASE_ADDR (MX23_IO_BASE_ADDR + 0x042000) +#define MX23_POWER_BASE_ADDR (MX23_IO_BASE_ADDR + 0x044000) +#define MX23_SAIF1_BASE_ADDR (MX23_IO_BASE_ADDR + 0x046000) +#define MX23_AUDIOOUT_BASE_ADDR (MX23_IO_BASE_ADDR + 0x048000) +#define MX23_AUDIOIN_BASE_ADDR (MX23_IO_BASE_ADDR + 0x04c000) +#define MX23_LRADC_BASE_ADDR (MX23_IO_BASE_ADDR + 0x050000) +#define MX23_SPDIF_BASE_ADDR (MX23_IO_BASE_ADDR + 0x054000) +#define MX23_I2C0_BASE_ADDR (MX23_IO_BASE_ADDR + 0x058000) +#define MX23_RTC_BASE_ADDR (MX23_IO_BASE_ADDR + 0x05c000) +#define MX23_PWM_BASE_ADDR (MX23_IO_BASE_ADDR + 0x064000) +#define MX23_TIMROT_BASE_ADDR (MX23_IO_BASE_ADDR + 0x068000) +#define MX23_AUART1_BASE_ADDR (MX23_IO_BASE_ADDR + 0x06c000) +#define MX23_AUART2_BASE_ADDR (MX23_IO_BASE_ADDR + 0x06e000) +#define MX23_DUART_BASE_ADDR (MX23_IO_BASE_ADDR + 0x070000) +#define MX23_USBPHY_BASE_ADDR (MX23_IO_BASE_ADDR + 0x07c000) +#define MX23_USBCTRL_BASE_ADDR (MX23_IO_BASE_ADDR + 0x080000) +#define MX23_DRAM_BASE_ADDR (MX23_IO_BASE_ADDR + 0x0e0000) + +#define MX23_IO_P2V (x) MXS_IO_P2V(x) +#define MX23_IO_ADDRESS (x) IOMEM(MX23_IO_P2V(x)) + +/* +* IRQ +*/ +#define MX23_INT_DUART 0 +#define MX23_INT_COMMS_RX 1 +#define MX23_INT_COMMS_TX 1 +#define MX23_INT_SSP2_ERROR 2 +#define MX23_INT_VDD5V 3 +#define MX23_INT_HEADPHONE_SHORT 4 +#define MX23_INT_DAC_DMA 5 +#define MX23_INT_DAC_ERROR 6 +#define MX23_INT_ADC_DMA 7 +#define MX23_INT_ADC_ERROR 8 +#define MX23_INT_SPDIF_DMA 9 +#define MX23_INT_SAIF2_DMA 9 +#define MX23_INT_SPDIF_ERROR 10 +#define MX23_INT_SAIF1_IRQ 10 +#define MX23_INT_SAIF2_IRQ 10 +#define MX23_INT_USB_CTRL 11 +#define MX23_INT_USB_WAKEUP 12 +#define MX23_INT_GPMI_DMA 13 +#define MX23_INT_SSP1_DMA 14 +#define MX23_INT_SSP_ERROR 15 +#define MX23_INT_GPIO0 16 +#define MX23_INT_GPIO1 17 +#define MX23_INT_GPIO2 18 +#define MX23_INT_SAIF1_DMA 19 +#define MX23_INT_SSP2_DMA 20 +#define MX23_INT_ECC8_IRQ 21 +#define MX23_INT_RTC_ALARM 22 +#define MX23_INT_UARTAPP_TX_DMA 23 +#define MX23_INT_UARTAPP_INTERNAL 24 +#define MX23_INT_UARTAPP_RX_DMA 25 +#define MX23_INT_I2C_DMA 26 +#define MX23_INT_I2C_ERROR 27 +#define MX23_INT_TIMER0 28 +#define MX23_INT_TIMER1 29 +#define MX23_INT_TIMER2 30 +#define MX23_INT_TIMER3 31 +#define MX23_INT_BATT_BRNOUT 32 +#define MX23_INT_VDDD_BRNOUT 33 +#define MX23_INT_VDDIO_BRNOUT 34 +#define MX23_INT_VDD18_BRNOUT 35 +#define MX23_INT_TOUCH_DETECT 36 +#define MX23_INT_LRADC_CH0 37 +#define MX23_INT_LRADC_CH1 38 +#define MX23_INT_LRADC_CH2 39 +#define MX23_INT_LRADC_CH3 40 +#define MX23_INT_LRADC_CH4 41 +#define MX23_INT_LRADC_CH5 42 +#define MX23_INT_LRADC_CH6 43 +#define MX23_INT_LRADC_CH7 44 +#define MX23_INT_LCDIF_DMA 45 +#define MX23_INT_LCDIF_ERROR 46 +#define MX23_INT_DIGCTL_DEBUG_TRAP 47 +#define MX23_INT_RTC_1MSEC 48 +#define MX23_INT_DRI_DMA 49 +#define MX23_INT_DRI_ATTENTION 50 +#define MX23_INT_GPMI_ATTENTION 51 +#define MX23_INT_IR 52 +#define MX23_INT_DCP_VMI 53 +#define MX23_INT_DCP 54 +#define MX23_INT_BCH 56 +#define MX23_INT_PXP 57 +#define MX23_INT_UARTAPP2_TX_DMA 58 +#define MX23_INT_UARTAPP2_INTERNAL 59 +#define MX23_INT_UARTAPP2_RX_DMA 60 +#define MX23_INT_VDAC_DETECT 61 +#define MX23_INT_VDD5V_DROOP 64 +#define MX23_INT_DCDC4P2_BO 65 + +#endif /* __MACH_MX23_H__ */ arch/arm/mach-mxs/include/mach/mx28.h new file +14
-0@@ -0,0 +1,190 @@ +/* +* 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/mach-mxs/include/mach/mx28.h line 24
Quoted 10 lines
arch/arm/mach-mxs/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
ditto
Quoted 208 lines
arch/arm/mach-mxs/include/mach/mx28.h new file +166
-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) +#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_MAC0_BASE_ADDR (MX28_IO_BASE_ADDR + 0x0f0000) +#define MX28_ENET_MAC1_BASE_ADDR (MX28_IO_BASE_ADDR + 0x0f4000) + +#define MX28_IO_P2V (x) MXS_IO_P2V(x) +#define MX28_IO_ADDRESS (x) IOMEM(MX28_IO_P2V(x)) + +/* +* 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_CAN0 8 +#define MX28_INT_CAN1 9 +#define MX28_INT_LRADC_TOUCH 10 +#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_PERFMON 27 +#define MX28_INT_RTC_1MSEC 28 +#define MX28_INT_RTC_ALARM 29 +#define MX28_INT_COMMS 31 +#define MX28_INT_EMI_ERR 32 +#define MX28_INT_LCDIF 38 +#define MX28_INT_PXP 39 +#define MX28_INT_BCH 41 +#define MX28_INT_GPMI 42 +#define MX28_INT_SPDIF_ERROR 45 +#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_SAIF1 58 +#define MX28_INT_SAIF0 59 +#define MX28_INT_SPDIF_DMA 66 +#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_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_I2C1_ERROR 110 +#define MX28_INT_I2C0_ERROR 111 +#define MX28_INT_AUART0 112 +#define MX28_INT_AUART1 113 +#define MX28_INT_AUART2 114 +#define MX28_INT_AUART3 115 +#define MX28_INT_AUART4 116 +#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 + +#endif /* __MACH_MX28_H__ */ arch/arm/mach-mxs/include/mach/mxs.h new file +34
-0@@ -0,0 +1,34 @@ +/* +* 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_MXS_H__ +#define __MACH_MXS_H__ + +#include <asm/mach-types.h> + +#define MXS_SET_ADDR 0x4 +#define MXS_CLR_ADDR 0x8 +#define MXS_TOG_ADDR 0xc + +/* +* MXS CPU types +*/ +# define cpu_is_mx23 () (machine_is_mx23evk()) +# define cpu_is_mx28 () (machine_is_mx28evk()) + +#endif /* __MACH_MXS_H__ */ Signature · 1 line
1.7.1
Best regards
Uwe
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-K?nig | Industrial Linux Solutions | http://www.pengutronix.de/ |
PATCH v3 1/15 ARM: mxs: Add core definitions
Hi Uwe,
2010/12/8 Uwe Kleine-K?nig <[email protected]>:
Quoted 1 line · Shawn Guo
[...]
Quoted 8 lines
arch/arm/mach-mxs/include/mach/mx23.h line 24
Quoted 6 lines
arch/arm/mach-mxs/include/mach/mx23.h new file +6
-0+#ifndef __MACH_MX23_H__ +#define __MACH_MX23_H__ + +#ifndef __ASSEMBLER__ +#include <linux/io.h> +#endif You don't need this, do you?
It can be removed after adding "#include <linux/io.h>" into icoll.c.
Quoted 5 lines
#inclusion of
hardware.hwould be OK, then you could remove the #includes ofmx23.handmx28.hin there.
(Believe me, this is better, mxc already made me headaches because of that.)
I do not get it. Can you please help me understand what you want exactly? Remove includes of mx23.h and mx28.h from hardware.h, and then include mx23.h, mx28.h, hardware.h individually when necessary?
Signature · 2 lines
Regards, Shawn
PATCH v3 1/15 ARM: mxs: Add core definitions
Quoted 13 lines · Shawn Guo
Hi Uwe,
2010/12/8 Uwe Kleine-K?nig <[email protected]>:
Quoted 1 line · Shawn Guo
[...]
Quoted 8 lines
arch/arm/mach-mxs/include/mach/mx23.h line 24
Quoted 6 lines
arch/arm/mach-mxs/include/mach/mx23.h new file +6
-0+#ifndef __MACH_MX23_H__ +#define __MACH_MX23_H__ + +#ifndef __ASSEMBLER__ +#include <linux/io.h> +#endif You don't need this, do you?
Quoted 1 line
It can be removed after adding "#include <
linux/io.h>" intoicoll.c.
fine
Quoted 8 lines
Quoted 5 lines
#inclusion of
hardware.hwould be OK, then you could remove the #includes ofmx23.handmx28.hin there.
(Believe me, this is better, mxc already made me headaches because of that.)I do not get it. Can you please help me understand what you want exactly? Remove includes of
mx23.handmx28.hfromhardware.h, and then includemx23.h,mx28.h,hardware.hindividually when necessary?
Yeap. You will need hardware.h for mx2[38].h to get the macros MXS_IO_P2V and IOMEM.
Best regards
UWe
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-K?nig | Industrial Linux Solutions | http://www.pengutronix.de/ |
PATCH v3 2/15 ARM: mxs: Add helper definition and function
In reply to Shawn GuoAdd helper definition and function for MXS-based.
---
Changes for v3:
- Remove reference to mxs_arch_reset_init() from common.h, since it becomes __initcall.
- icoll_init_irq() does not need to carry on icoll base address, since MX23 and MX28 share the same one.
- mxs_timer_init() does not need to carry on timrot base address, since MX23 and MX28 share the same one.
Changes for v2:
- Remove cpu.c and reference to mxs_set_cpu_type() from common.h
arch/arm/mach-mxs/include/mach/common.h | 31 ++++++++++++++++++++++++++++++ arch/arm/mach-mxs/include/mach/io.h | 22 +++++++++++++++++++++ arch/arm/mach-mxs/include/mach/timex.h | 21 ++++++++++++++++++++ arch/arm/mach-mxs/include/mach/vmalloc.h | 22 +++++++++++++++++++++ 4 files changed, 96 insertions(+), 0 deletions(-) create mode 100644 arch/arm/mach-mxs/include/mach/common.h create mode 100644 arch/arm/mach-mxs/include/mach/io.h create mode 100644 arch/arm/mach-mxs/include/mach/timex.h create mode 100644 arch/arm/mach-mxs/include/mach/vmalloc.h
arch/arm/mach-mxs/include/mach/common.h new file +31 -0
@@ -0,0 +1,31 @@ +/* +* Copyright 2004-2007 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. +*/ + +#ifndef __MACH_MXS_COMMON_H__ +#define __MACH_MXS_COMMON_H__ + +struct clk ; + +extern int mxs_reset_block (void __iomem *); +extern void mxs_timer_init (struct clk *,int ); + +extern int mx23_register_gpios (void ); +extern int mx23_clocks_init (void ); +extern void mx23_map_io (void ); +extern void mx23_init_irq (void ); + +extern int mx28_register_gpios (void ); +extern int mx28_clocks_init (void ); +extern void mx28_map_io (void ); +extern void mx28_init_irq (void ); + +extern void icoll_init_irq (void ); + +#endif /* __MACH_MXS_COMMON_H__ */
arch/arm/mach-mxs/include/mach/io.h new file +22 -0
@@ -0,0 +1,22 @@ +/* +* Copyright 2004-2007 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. +*/ + +#ifndef __MACH_MXS_IO_H__ +#define __MACH_MXS_IO_H__ + +/* Allow IO space to be anywhere in the memory */ +#define IO_SPACE_LIMIT 0xffffffff + +/* io address mapping macro */ +#define __io (a) __typesafe_io(a) + +#define __mem_pci (a) (a) + +#endif /* __MACH_MXS_IO_H__ */
arch/arm/mach-mxs/include/mach/timex.h new file +21 -0
@@ -0,0 +1,21 @@ +/* +* Copyright (C) 1999 ARM Limited +* Copyright 2004-2007 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. +*/ + +#ifndef __MACH_MXS_TIMEX_H__ +#define __MACH_MXS_TIMEX_H__ + +#define CLOCK_TICK_RATE 32000/* 32K */ + +#endif /* __MACH_MXS_TIMEX_H__ */
arch/arm/mach-mxs/include/mach/vmalloc.h new file +22 -0
@@ -0,0 +1,22 @@ +/* +* Copyright (C) 2000 Russell King. +* Copyright 2004-2007 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. +*/ + +#ifndef __MACH_MXS_VMALLOC_H__ +#define __MACH_MXS_VMALLOC_H__ + +/* vmalloc ending address */ +#define VMALLOC_END 0xf4000000UL + +#endif /* __MACH_MXS_VMALLOC_H__ */
Signature · 1 line
1.7.1
PATCH v2 7/15 ARM: mxs: Add gpio support
In reply to Shawn GuoMXS-based SoCs implement gpio support in block PINCTRL.
---
Changes for v2:
- Create arch/arm/mach-mxs/gpio.h to accommodate stuff private for mach-mxs
- Use GPIO_INT_LEV_MASK and GPIO_INT_POL_MASK instead of constant
- Remove both edges IRQ support which is not needed
- Use SET and CLR register of PINCTRL_DOE in _set_gpio_direction()
- Use pr_info over printk(KERN_INFO)
arch/arm/mach-mxs/gpio.c | 331 +++++++++++++++++++++++++++++++++ arch/arm/mach-mxs/gpio.h | 36 ++++ arch/arm/mach-mxs/include/mach/gpio.h | 35 ++++ 3 files changed, 402 insertions(+), 0 deletions(-) create mode 100644 arch/arm/mach-mxs/gpio.c create mode 100644 arch/arm/mach-mxs/gpio.h create mode 100644 arch/arm/mach-mxs/include/mach/gpio.h
arch/arm/mach-mxs/gpio.c new file +331 -0
@@ -0,0 +1,331 @@ +/* +* MXC GPIO support. (c) 2008 Daniel Mack <[email protected]> +* Copyright 2008 Juergen Beisert, kernel at pengutronix.de +* +* Based on code from Freescale, +* Copyright (C) 2004-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/init.h> +#include <linux/interrupt.h> +#include <linux/io.h> +#include <linux/irq.h> +#include <linux/gpio.h> +#include <mach/hardware.h> +#include <asm-generic/bug.h> + +#include "gpio.h" + +static struct mxs_gpio_port *mxs_gpio_ports; +static int gpio_table_size; + +#define PINCTRL_DOUT (n) ((cpu_is_mx23() ? 0x0500 : 0x0700) + (n) * 0x10) +#define PINCTRL_DIN (n) ((cpu_is_mx23() ? 0x0600 : 0x0900) + (n) * 0x10) +#define PINCTRL_DOE (n) ((cpu_is_mx23() ? 0x0700 : 0x0b00) + (n) * 0x10) +#define PINCTRL_PIN2IRQ (n) ((cpu_is_mx23() ? 0x0800 : 0x1000) + (n) * 0x10) +#define PINCTRL_IRQEN (n) ((cpu_is_mx23() ? 0x0900 : 0x1100) + (n) * 0x10) +#define PINCTRL_IRQLEV (n) ((cpu_is_mx23() ? 0x0a00 : 0x1200) + (n) * 0x10) +#define PINCTRL_IRQPOL (n) ((cpu_is_mx23() ? 0x0b00 : 0x1300) + (n) * 0x10) +#define PINCTRL_IRQSTAT (n) ((cpu_is_mx23() ? 0x0c00 : 0x1400) + (n) * 0x10) + +#define GPIO_INT_FALL_EDGE 0x0 +#define GPIO_INT_LOW_LEV 0x1 +#define GPIO_INT_RISE_EDGE 0x2 +#define GPIO_INT_HIGH_LEV 0x3 +#define GPIO_INT_LEV_MASK (1 << 0) +#define GPIO_INT_POL_MASK (1 << 1) + +/* Note: This driver assumes 32 GPIOs are handled in one register */ + +static void _clear_gpio_irqstatus (struct mxs_gpio_port *port,u32 index) +{ +__raw_writel (1 << index, + port->base +PINCTRL_IRQSTAT (port->id) +MXS_CLR_ADDR ); +} + +static void _set_gpio_irqenable (struct mxs_gpio_port *port,u32 index, +int enable) +{ +if (enable ==0 ) { +__raw_writel (1 << index, + port->base +PINCTRL_PIN2IRQ (port->id) +MXS_CLR_ADDR ); +__raw_writel (1 << index, + port->base +PINCTRL_IRQEN (port->id) +MXS_CLR_ADDR ); + }else { +__raw_writel (1 << index, + port->base +PINCTRL_PIN2IRQ (port->id) +MXS_SET_ADDR ); +__raw_writel (1 << index, + port->base +PINCTRL_IRQEN (port->id) +MXS_SET_ADDR ); + } +} + +static void gpio_ack_irq (u32 irq) +{ +u32 gpio =irq_to_gpio (irq); +_clear_gpio_irqstatus (&mxs_gpio_ports[gpio /32 ], gpio &0x1f ); +} + +static void gpio_mask_irq (u32 irq) +{ +u32 gpio =irq_to_gpio (irq); +_set_gpio_irqenable (&mxs_gpio_ports[gpio /32 ], gpio &0x1f ,0 ); +} + +static void gpio_unmask_irq (u32 irq) +{ +u32 gpio =irq_to_gpio (irq); +_set_gpio_irqenable (&mxs_gpio_ports[gpio /32 ], gpio &0x1f ,1 ); +} + +static int mxs_gpio_get (struct gpio_chip *chip,unsigned offset); + +static int gpio_set_irq_type (u32 irq,u32 type) +{ +u32 gpio =irq_to_gpio (irq); +struct mxs_gpio_port *port = &mxs_gpio_ports[gpio /32 ]; +int edge; + +switch (type) { +case IRQ_TYPE_EDGE_RISING : + edge =GPIO_INT_RISE_EDGE ; +break ; +case IRQ_TYPE_EDGE_FALLING : + edge =GPIO_INT_FALL_EDGE ; +break ; +case IRQ_TYPE_LEVEL_LOW : + edge =GPIO_INT_LOW_LEV ; +break ; +case IRQ_TYPE_LEVEL_HIGH : + edge =GPIO_INT_HIGH_LEV ; +break ; +default : +return -EINVAL ; + } + +/* set level or edge */ +if (edge &GPIO_INT_LEV_MASK ) +__raw_writel (1 << (gpio &31 ), + port->base +PINCTRL_IRQLEV (port->id) +MXS_SET_ADDR ); +else +__raw_writel (1 << (gpio &31 ), + port->base +PINCTRL_IRQLEV (port->id) +MXS_CLR_ADDR ); + +/* set polarity */ +if (edge &GPIO_INT_POL_MASK ) +__raw_writel (1 << (gpio &31 ), + port->base +PINCTRL_IRQPOL (port->id) +MXS_SET_ADDR ); +else +__raw_writel (1 << (gpio &31 ), + port->base +PINCTRL_IRQPOL (port->id) +MXS_CLR_ADDR ); + +_clear_gpio_irqstatus (port, gpio &0x1f ); + +return 0 ; +} + +/* MXS has one interrupt *per* gpio port */ +static void mxs_gpio_irq_handler (u32 irq,struct irq_desc *desc) +{ +u32 irq_stat; +struct mxs_gpio_port *port = (struct mxs_gpio_port *)get_irq_data (irq); +u32 gpio_irq_no_base = port->virtual_irq_start; + + irq_stat =__raw_readl (port->base +PINCTRL_IRQSTAT (port->id)) & +__raw_readl (port->base +PINCTRL_IRQEN (port->id)) & +__raw_readl (port->base +PINCTRL_PIN2IRQ (port->id)); + +while (irq_stat !=0 ) { +int irqoffset =fls (irq_stat) -1 ; +generic_handle_irq (gpio_irq_no_base + irqoffset); + irq_stat &= ~(1 << irqoffset); + } +} + +/* +* Set interrupt number "irq" in the GPIO as a wake-up source. +* While system is running, all registered GPIO interrupts need to have +* wake-up enabled. When system is suspended, only selected GPIO interrupts +* need to have wake-up enabled. +* @param irq interrupt source number +* @param enable enable as wake-up if equal to non-zero +* @return This function returns 0 on success. +*/ +static int gpio_set_wake_irq (u32 irq,u32 enable) +{ +u32 gpio =irq_to_gpio (irq); +u32 gpio_idx = gpio &0x1f ; +struct mxs_gpio_port *port = &mxs_gpio_ports[gpio /32 ]; + +if (enable) { +if (port->irq_high && (gpio_idx >=16 )) +enable_irq_wake (port->irq_high); +else +enable_irq_wake (port->irq); + }else { +if (port->irq_high && (gpio_idx >=16 )) +disable_irq_wake (port->irq_high); +else +disable_irq_wake (port->irq); + } + +return 0 ; +} + +static struct irq_chip gpio_irq_chip = { + .ack = gpio_ack_irq, + .mask = gpio_mask_irq, + .unmask = gpio_unmask_irq, + .set_type = gpio_set_irq_type, + .set_wake = gpio_set_wake_irq, +}; + +static void _set_gpio_direction (struct gpio_chip *chip,unsigned offset, +int dir) +{ +struct mxs_gpio_port *port = + container_of(chip, struct mxs_gpio_port, chip); +unsigned long flags; + +spin_lock_irqsave (&port->lock, flags); +if (dir) +__raw_writel (1 << offset, + port->base +PINCTRL_DOE (port->id) +MXS_SET_ADDR ); +else +__raw_writel (1 << offset, + port->base +PINCTRL_DOE (port->id) +MXS_CLR_ADDR ); +spin_unlock_irqrestore (&port->lock, flags); +} + +static void mxs_gpio_set (struct gpio_chip *chip,unsigned offset,int value) +{ +struct mxs_gpio_port *port = + container_of(chip, struct mxs_gpio_port, chip); +u32 l; +unsigned long flags; +void __iomem *reg = port->base +PINCTRL_DOUT (port->id); + +spin_lock_irqsave (&port->lock, flags); + l = (__raw_readl (reg) & (~(1 << offset))) | (!!value << offset); +__raw_writel (l, reg); +spin_unlock_irqrestore (&port->lock, flags); +} + +static int mxs_gpio_get (struct gpio_chip *chip,unsigned offset) +{ +struct mxs_gpio_port *port = + container_of(chip, struct mxs_gpio_port, chip); +void __iomem *reg = port->base +PINCTRL_DIN (port->id); + +return (__raw_readl (reg) >> offset) &1 ; +} + +static int mxs_gpio_direction_input (struct gpio_chip *chip,unsigned offset) +{ +_set_gpio_direction (chip, offset,0 ); +return 0 ; +} + +static int mxs_gpio_direction_output (struct gpio_chip *chip, +unsigned offset,int value) +{ +mxs_gpio_set (chip, offset, value); +_set_gpio_direction (chip, offset,1 ); +return 0 ; +} + +int __init mxs_gpio_init (struct mxs_gpio_port *port,int cnt) +{ +int i, j; + +/* save for local usage */ + mxs_gpio_ports = port; + gpio_table_size = cnt; + +pr_info ("MXS GPIO hardware\n" ); + +for (i =0 ; i < cnt; i++) { +/* disable the interrupt and clear the status */ +__raw_writel (0 , port[i].base + +PINCTRL_PIN2IRQ (i)); +__raw_writel (0 , port[i].base + +PINCTRL_IRQEN (i)); +__raw_writel (~0 , port[i].base + +PINCTRL_IRQSTAT (i) +MXS_CLR_ADDR ); + +for (j = port[i].virtual_irq_start; + j < port[i].virtual_irq_start +32 ; j++) { +set_irq_chip (j, &gpio_irq_chip); +set_irq_handler (j, handle_level_irq); +set_irq_flags (j,IRQF_VALID ); + } + +/* register gpio chip */ + port[i].chip.direction_input = mxs_gpio_direction_input; + port[i].chip.direction_output = mxs_gpio_direction_output; + port[i].chip.get = mxs_gpio_get; + port[i].chip.set = mxs_gpio_set; + port[i].chip.base = i *32 ; + port[i].chip.ngpio =32 ; + +spin_lock_init (&port[i].lock); + +/* its a serious configuration bug when it fails */ +BUG_ON (gpiochip_add (&port[i].chip) <0 ); + +/* setup one handler for each entry */ +set_irq_chained_handler (port[i].irq, mxs_gpio_irq_handler); +set_irq_data (port[i].irq, &port[i]); + } + +return 0 ; +} + +#define DEFINE_MXS_GPIO_PORT (soc, _id) \ + { \ + .chip.label = "gpio-" #_id, \ + .id = _id, \ + .irq = soc ## _INT_GPIO ## _id, \ + .base = soc ## _IO_ADDRESS( \ + soc ## _PINCTRL ## _BASE_ADDR), \ + .virtual_irq_start = MXS_GPIO_IRQ_START + (_id) * 32, \ + } + +#define DEFINE_REGISTER_FUNCTION (prefix) \ +int __init prefix ## _register_gpios(void) \ +{ \ + return mxs_gpio_init(prefix ## _gpio_ports, \ + ARRAY_SIZE(prefix ## _gpio_ports)); \ +} + +#ifdef CONFIG_SOC_IMX23 +static struct mxs_gpio_port mx23_gpio_ports[] = { +DEFINE_MXS_GPIO_PORT (MX23 ,0 ), +DEFINE_MXS_GPIO_PORT (MX23 ,1 ), +DEFINE_MXS_GPIO_PORT (MX23 ,2 ), +}; +DEFINE_REGISTER_FUNCTION(mx23) +#endif + +#ifdef CONFIG_SOC_IMX28 +static struct mxs_gpio_port mx28_gpio_ports[] = { +DEFINE_MXS_GPIO_PORT (MX28 ,0 ), +DEFINE_MXS_GPIO_PORT (MX28 ,1 ), +DEFINE_MXS_GPIO_PORT (MX28 ,2 ), +DEFINE_MXS_GPIO_PORT (MX28 ,3 ), +DEFINE_MXS_GPIO_PORT (MX28 ,4 ), +}; +DEFINE_REGISTER_FUNCTION(mx28) +#endif
arch/arm/mach-mxs/gpio.h new file +36 -0
@@ -0,0 +1,36 @@ +/* +* Copyright 2007 Freescale Semiconductor, Inc. All Rights Reserved. +* Copyright 2008 Juergen Beisert, [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. +*/ + +#ifndef __MXS_GPIO_H__ +#define __MXS_GPIO_H__ + +#include <linux/spinlock.h> + +struct mxs_gpio_port { +void __iomem *base; +int id; +int irq; +int irq_high; +int virtual_irq_start; +struct gpio_chip chip; +spinlock_t lock; +}; + +int mxs_gpio_init (struct mxs_gpio_port *,int ); + +#endif /* __MXS_GPIO_H__ */
arch/arm/mach-mxs/include/mach/gpio.h new file +35 -0
@@ -0,0 +1,35 @@ +/* +* Copyright 2007 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 +* 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_MXS_GPIO_H__ +#define __MACH_MXS_GPIO_H__ + +#include <mach/hardware.h> +#include <asm-generic/gpio.h> + +#define MXS_GPIO_NR (bank, nr) ((bank) * 32 + (nr)) + +/* use gpiolib dispatchers */ +#define gpio_get_value __gpio_get_value +#define gpio_set_value __gpio_set_value +#define gpio_cansleep __gpio_cansleep + +#define gpio_to_irq (gpio) (MXS_GPIO_IRQ_START + (gpio)) +#define irq_to_gpio (irq) ((irq) - MXS_GPIO_IRQ_START) + +#endif /* __MACH_MXS_GPIO_H__ */
Signature · 1 line
1.7.1
PATCH v2 7/15 ARM: mxs: Add gpio support
Hi,
Quoted 24 lines · Shawn Guo
MXS-based SoCs implement gpio support in block PINCTRL.
Signed-off-by Shawn Guo <[email protected]>---
Changes for v2:
- Createarch/arm/mach-mxs/gpio.hto accommodate stuff private for mach-mxs
- UseGPIO_INT_LEV_MASKandGPIO_INT_POL_MASKinstead of constant
- Remove both edges IRQ support which is not needed
- Use SET and CLR register ofPINCTRL_DOEin_set_gpio_direction()
- Usepr_infooverprintk(KERN_INFO)arch/arm/mach-mxs/gpio.c | 331 +++++++++++++++++++++++++++++++++ arch/arm/mach-mxs/gpio.h | 36 ++++ arch/arm/mach-mxs/include/mach/gpio.h | 35 ++++ 3 files changed, 402 insertions(+), 0 deletions(-) create mode 100644 arch/arm/mach-mxs/gpio.c create mode 100644 arch/arm/mach-mxs/gpio.h create mode 100644 arch/arm/mach-mxs/include/mach/gpio.harch/arm/mach-mxs/gpio.c new file +0
-0
[...]
arch/arm/mach-mxs/gpio.c line 223
Quoted 12 lines
arch/arm/mach-mxs/gpio.c new file +12
-0+static void mxs_gpio_set (struct gpio_chip *chip,unsigned offset,int value) +{ +struct mxs_gpio_port *port = + container_of(chip, struct mxs_gpio_port, chip); +u32 l; +unsigned long flags; +void __iomem *reg = port->base +PINCTRL_DOUT (port->id); + +spin_lock_irqsave (&port->lock, flags); + l = (__raw_readl (reg) & (~(1 << offset))) | (!!value << offset); +__raw_writel (l, reg); +spin_unlock_irqrestore (&port->lock, flags);
Why not:
__raw_writel(1 << offset, reg + (value ? MXS_SET_ADDR : MXS_CLR_ADDR));
which would not even need any locking.
Lothar Wa?mann
Signature · 9 lines
___________________________________________________________ Ka-Ro electronics GmbH | Pascalstra?e 22 | D - 52076 Aachen Phone: +49 2408 1402-0 | Fax: +49 2408 1402-10 Gesch?ftsf?hrer: Matthias Kaussen Handelsregistereintrag: Amtsgericht Aachen, HRB 4996 www.karo-electronics.de | [email protected] ___________________________________________________________
PATCH v2 8/15 ARM: mxs: Add iomux support
In reply to Shawn GuoMXS-based SoCs implements iomux functions in block PINCTRL.
---
Changes for v2:
- Define iomux_cfg_t as u64
- Turn mxs_iomux_setup_pad() into a static function
- Fix a bug in mxs_iomux_setup_pad(), muxsel starts at offset 0x100 than 0 of pinctrl block.
arch/arm/mach-mxs/include/mach/iomux-mx23.h | 29 +++++++ arch/arm/mach-mxs/include/mach/iomux-mx28.h | 44 +++++++++++ arch/arm/mach-mxs/include/mach/iomux.h | 72 +++++++++++++++++ arch/arm/mach-mxs/iomux.c | 110 +++++++++++++++++++++++++++ 4 files changed, 255 insertions(+), 0 deletions(-) create mode 100644 arch/arm/mach-mxs/include/mach/iomux-mx23.h create mode 100644 arch/arm/mach-mxs/include/mach/iomux-mx28.h create mode 100644 arch/arm/mach-mxs/include/mach/iomux.h create mode 100644 arch/arm/mach-mxs/iomux.c
arch/arm/mach-mxs/include/mach/iomux-mx23.h new file +29 -0
@@ -0,0 +1,29 @@ +/* +* Copyright (C) 2009-2010 Amit Kucheria <[email protected]> +* Copyright (C) 2010 Freescale Semiconductor, Inc. +* +* The code contained herein is licensed under the GNU General Public +* License. You may obtain a copy of the GNU General Public License +* Version 2 or later at the following locations: +* +* http://www.opensource.org/licenses/gpl-license.html +* http://www.gnu.org/copyleft/gpl.html +*/ + +#ifndef __MACH_IOMUX_MX23_H__ +#define __MACH_IOMUX_MX23_H__ + +#include <mach/iomux.h> + +/* +* The naming convention for the pad modes is MX23_PAD_<padname>__<padmode> +* If <padname> or <padmode> refers to a GPIO, it is named GPIO_<unit>_<num> +* See also iomux.h +* +* BANK PIN MUX VOL MA PULL +*/ +/* DUART */ +#define MX23_PAD_PWM0__DUART_RX IOMUX_PAD(1, 26, PAD_MUXSEL_2, PAD_VOL_NONE, PAD_4MA, PAD_NOPULL) +#define MX23_PAD_PWM1__DUART_TX IOMUX_PAD(1, 27, PAD_MUXSEL_2, PAD_VOL_NONE, PAD_4MA, PAD_NOPULL) + +#endif /* __MACH_IOMUX_MX23_H__ */
arch/arm/mach-mxs/include/mach/iomux-mx28.h new file +44 -0
44 lines not on this page · raw message
arch/arm/mach-mxs/include/mach/iomux.h new file +72 -0
72 lines not on this page · raw message
arch/arm/mach-mxs/iomux.c new file +110 -0
110 lines not on this page · raw message
Signature · 1 line
1.7.1
PATCH v2 8/15 ARM: mxs: Add iomux support
Hi,
Quoted 6 lines · Shawn Guo
MXS-based SoCs implements iomux functions in block PINCTRL.
Signed-off-by Shawn Guo <[email protected]>---
Changes for v2:
- Defineiomux_cfg_tas u64
^^^^^^^^^^^^^^^^^^^^^^^^^
Really?
arch/arm/mach-mxs/include/mach/iomux.h line 31
Quoted 8 lines
arch/arm/mach-mxs/include/mach/iomux.h new file +8
-0+typedef struct pad_desc { +unsigned bank:12 ; +unsigned pin:20 ; +unsigned muxsel:8 ; +unsigned ma:12 ; +unsigned vol:8 ; +unsigned pull:4 ; +}iomux_cfg_t ;
^^^^^^^^^^^^^^^^^
Lothar Wa?mann
Signature · 9 lines
___________________________________________________________ Ka-Ro electronics GmbH | Pascalstra?e 22 | D - 52076 Aachen Phone: +49 2408 1402-0 | Fax: +49 2408 1402-10 Gesch?ftsf?hrer: Matthias Kaussen Handelsregistereintrag: Amtsgericht Aachen, HRB 4996 www.karo-electronics.de | info at karo-electronics.de ___________________________________________________________
PATCH v2 8/15 ARM: mxs: Add iomux support
Hi Lothar,
Thanks for the review.
Quoted 12 lines · Lothar Wa?mann
Hi,
Quoted 6 lines · Shawn Guo
MXS-based SoCs implements iomux functions in block PINCTRL.
Signed-off-by Shawn Guo <[email protected]>---
Changes for v2:
?- Defineiomux_cfg_tas u64? ? ^^^^^^^^^^^^^^^^^^^^^^^^^
Really?
Quoted 10 lines
Review
Quoted 8 lines
(quoted diff) +8
-0+typedef struct pad_desc { + ? ? unsigned bank:12; + ? ? unsigned pin:20; + ? ? unsigned muxsel:8; + ? ? unsigned ma:12; + ? ? unsigned vol:8; + ? ? unsigned pull:4; +} iomux_cfg_t;^^^^^^^^^^^^^^^^^
I did not pick the correct word. What I meant is 64 bits. Since this error is in change log, I would fix it if there is v3 of the patch.
Signature · 2 lines
Regards, Shawn
PATCH v2 8/15 ARM: mxs: Add iomux support
Hello,
Quoted 27 lines · Shawn Guo
Hi Lothar,
Thanks for the review.
Quoted 12 lines · Lothar Wa?mann
Hi,
Quoted 6 lines · Shawn Guo
MXS-based SoCs implements iomux functions in block PINCTRL.
Signed-off-by Shawn Guo <[email protected]>---
Changes for v2:
?- Defineiomux_cfg_tas u64? ? ^^^^^^^^^^^^^^^^^^^^^^^^^
Really?Quoted 10 lines
Review
Quoted 8 lines
(quoted diff) +8
-0+typedef struct pad_desc { + ? ? unsigned bank:12; + ? ? unsigned pin:20; + ? ? unsigned muxsel:8; + ? ? unsigned ma:12; + ? ? unsigned vol:8; + ? ? unsigned pull:4; +} iomux_cfg_t;^^^^^^^^^^^^^^^^^
Quoted 2 lines
I did not pick the correct word. What I meant is 64 bits. Since this error is in change log, I would fix it if there is v3 of the patch.
the idea was to really use an u64 to have the pin definitions modifyable.
Best regards
Uwe
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-K?nig | Industrial Linux Solutions | http://www.pengutronix.de/ |
PATCH v2 8/15 ARM: mxs: Add iomux support
2010/12/8 Uwe Kleine-K?nig <[email protected]>:
Quoted 30 lines
Hello,
Quoted 27 lines · Shawn Guo
Hi Lothar,
Thanks for the review.
Quoted 22 lines · Lothar Wa?mann
Hi,
Quoted 6 lines · Shawn Guo
MXS-based SoCs implements iomux functions in block PINCTRL.
Signed-off-by Shawn Guo <[email protected]>---
Changes for v2:
?- Defineiomux_cfg_tas u64? ? ^^^^^^^^^^^^^^^^^^^^^^^^^
Really?Review
Quoted 8 lines
(quoted diff) +8
-0+typedef struct pad_desc { + ? ? unsigned bank:12; + ? ? unsigned pin:20; + ? ? unsigned muxsel:8; + ? ? unsigned ma:12; + ? ? unsigned vol:8; + ? ? unsigned pull:4; +} iomux_cfg_t;^^^^^^^^^^^^^^^^^
Quoted 4 lines
Quoted 2 lines
I did not pick the correct word. ?What I meant is 64 bits. ?Since this error is in change log, I would fix it if there is v3 of the patch.
the idea was to really use an u64 to have the pin definitions modifyable.
Ah, I misunderstood the comments. But I did not see mxc switches to u64. Do you have example to show what you want exactly?
Signature · 2 lines
Regards, Shawn
PATCH v2 8/15 ARM: mxs: Add iomux support
Quoted 31 lines · Shawn Guo
2010/12/8 Uwe Kleine-K?nig <[email protected]>:
Quoted 30 lines
Hello,
Quoted 27 lines · Shawn Guo
Hi Lothar,
Thanks for the review.
Quoted 22 lines · Lothar Wa?mann
Hi,
Quoted 6 lines · Shawn Guo
MXS-based SoCs implements iomux functions in block PINCTRL.
Signed-off-by Shawn Guo <[email protected]>---
Changes for v2:
?- Defineiomux_cfg_tas u64? ? ^^^^^^^^^^^^^^^^^^^^^^^^^
Really?Review
Quoted 8 lines
(quoted diff) +8
-0+typedef struct pad_desc { + ? ? unsigned bank:12; + ? ? unsigned pin:20; + ? ? unsigned muxsel:8; + ? ? unsigned ma:12; + ? ? unsigned vol:8; + ? ? unsigned pull:4; +} iomux_cfg_t;^^^^^^^^^^^^^^^^^
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
I did not pick the correct word. ?What I meant is 64 bits. ?Since this error is in change log, I would fix it if there is v3 of the patch.
the idea was to really use an u64 to have the pin definitions modifyable.
Ah, I misunderstood the comments. But I did not see mxc switches to u64. Do you have example to show what you want exactly?
See:
http://lists.infradead.org/pipermail/linux-arm-kernel/2010-November/032202.html
Lothar Wa?mann
Signature · 9 lines
___________________________________________________________ Ka-Ro electronics GmbH | Pascalstra?e 22 | D - 52076 Aachen Phone: +49 2408 1402-0 | Fax: +49 2408 1402-10 Gesch?ftsf?hrer: Matthias Kaussen Handelsregistereintrag: Amtsgericht Aachen, HRB 4996 www.karo-electronics.de | info at karo-electronics.de ___________________________________________________________
PATCH v2 8/15 ARM: mxs: Add iomux support
Quoted 34 lines · Lothar Wa?mann
Quoted 33 lines · Shawn Guo
2010/12/8 Uwe Kleine-K?nig <[email protected]>:
Quoted 32 lines
Hello,
Quoted 29 lines · Shawn Guo
Hi Lothar,
Thanks for the review.
Quoted 12 lines · Lothar Wa?mann
Hi,
Quoted 6 lines · Shawn Guo
MXS-based SoCs implements iomux functions in block PINCTRL.
Signed-off-by Shawn Guo <[email protected]>---
Changes for v2:
?- Defineiomux_cfg_tas u64? ? ^^^^^^^^^^^^^^^^^^^^^^^^^
Really?Quoted 10 lines
Review
Quoted 8 lines
(quoted diff) +8
-0+typedef struct pad_desc { + ? ? unsigned bank:12; + ? ? unsigned pin:20; + ? ? unsigned muxsel:8; + ? ? unsigned ma:12; + ? ? unsigned vol:8; + ? ? unsigned pull:4; +} iomux_cfg_t;^^^^^^^^^^^^^^^^^
I did not pick the correct word. ?What I meant is 64 bits. ?Since this error is in change log, I would fix it if there is v3 of the patch.
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
the idea was to really use an u64 to have the pin definitions modifyable.
Ah, I misunderstood the comments. ?But I did not see mxc switches to u64. ?Do you have example to show what you want exactly?
See:
http://lists.infradead.org/pipermail/linux-arm-kernel/2010-November/032202.html
Thanks, Lothar.
Hi Uwe,
Looking at the page Lothar gave, the patch is to facilitate adding platform specific pad_ctrl settings to an
existing pad definition. In this case, it might be reasonable to keep EXPORT_SYMBOL(mxs_iomux_setup_pad), which you asked me to remove. What do you think?
Signature · 2 lines
Regards, Shawn
PATCH v2 8/15 ARM: mxs: Add iomux support
Hello,
Quoted 8 lines · Shawn Guo
Quoted 6 lines
Quoted 3 lines
Ah, I misunderstood the comments. ?But I did not see mxc switches to u64. ?Do you have example to show what you want exactly?
See:
http://lists.infradead.org/pipermail/linux-arm-kernel/2010-November/032202.htmlThanks, Lothar.
Quoted 7 lines
Hi Uwe,
Looking at the page Lothar gave, the patch is to facilitate adding platform specific
pad_ctrlsettings to an
existing pad definition. In this case, it might be reasonable to keepEXPORT_SYMBOL(mxs_iomux_setup_pad), which you asked me to remove. What do you think?
Just don't make it static. There is no need for EXPORT_SYMBOL. Ditto for the multiple variant.
Uwe
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-K?nig | Industrial Linux Solutions | http://www.pengutronix.de/ |
PATCH v3 3/15 ARM: mxs: Add reset routines
In reply to Shawn Guo - The mxs wdog is implemented in RTC block.
- There is a generic software reset routine for most modules on mxs.
---
Changes for v3:
- Change wdog timeout to 10ms for safety
- Simplify function mxs_reset_block() to get it look better
Changes for v2:
- Move rtc clock enabling from arch_reset() into mxs_arch_reset_init()
arch/arm/mach-mxs/include/mach/system.h | 27 ++++++ arch/arm/mach-mxs/system.c | 134 +++++++++++++++++++++++++++++++ 2 files changed, 161 insertions(+), 0 deletions(-) create mode 100644 arch/arm/mach-mxs/include/mach/system.h create mode 100644 arch/arm/mach-mxs/system.c
arch/arm/mach-mxs/include/mach/system.h new file +27 -0
@@ -0,0 +1,27 @@ +/* +* Copyright (C) 1999 ARM Limited +* Copyright (C) 2000 Deep Blue Solutions Ltd +* Copyright 2004-2008 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. +*/ + +#ifndef __MACH_MXS_SYSTEM_H__ +#define __MACH_MXS_SYSTEM_H__ + +static inline void arch_idle (void ) +{ +cpu_do_idle (); +} + +void arch_reset (char mode,const char *cmd); + +#endif /* __MACH_MXS_SYSTEM_H__ */
arch/arm/mach-mxs/system.c new file +134 -0
134 lines not on this page · raw message
Signature · 1 line
1.7.1
PATCH v3 3/15 ARM: mxs: Add reset routines
Hello Shawn,
Quoted 152 lines · Shawn Guo
- The mxs wdog is implemented in RTC block.
- There is a generic software reset routine for most modules on mxs.Signed-off-by Shawn Guo <[email protected]>---
Changes for v3:
- Change wdog timeout to 10ms for safety
- Simplify functionmxs_reset_block()to get it look betterChanges for v2:
- Move rtc clock enabling fromarch_reset()intomxs_arch_reset_init()arch/arm/mach-mxs/include/mach/system.h | 27 ++++++ arch/arm/mach-mxs/system.c | 134 +++++++++++++++++++++++++++++++ 2 files changed, 161 insertions(+), 0 deletions(-) create mode 100644 arch/arm/mach-mxs/include/mach/system.h create mode 100644 arch/arm/mach-mxs/system.carch/arm/mach-mxs/include/mach/system.h new file +27
-0@@ -0,0 +1,27 @@ +/* +* Copyright (C) 1999 ARM Limited +* Copyright (C) 2000 Deep Blue Solutions Ltd +* Copyright 2004-2008 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. +*/ + +#ifndef __MACH_MXS_SYSTEM_H__ +#define __MACH_MXS_SYSTEM_H__ + +static inline void arch_idle (void ) +{ +cpu_do_idle (); +} + +void arch_reset (char mode,const char *cmd); + +#endif /* __MACH_MXS_SYSTEM_H__ */ arch/arm/mach-mxs/system.c new file +95
-0@@ -0,0 +1,134 @@ +/* +* Copyright (C) 1999 ARM Limited +* Copyright (C) 2000 Deep Blue Solutions Ltd +* Copyright 2006-2007,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 +* +* 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/kernel.h> +#include <linux/clk.h> +#include <linux/io.h> +#include <linux/err.h> +#include <linux/delay.h> + +#include <asm/proc-fns.h> +#include <asm/system.h> + +#include <mach/hardware.h> +#include <mach/common.h> + +#define MXS_RTC_WATCHDOG 0x50 +#define MXS_WATCHDOG_EN (1 << 4) + +#define MXS_MODULE_CLKGATE (1 << 30) +#define MXS_MODULE_SFTRST (1 << 31) + +static void __iomem *wdog_base; + +/* +* Reset the system. It is called by machine_restart(). +*/ +void arch_reset (char mode,const char *cmd) +{ +/* Set wdog timer 10 ms */ +__raw_writel (10 , wdog_base +MXS_RTC_WATCHDOG ); + +/* Enable wdog reset */ +__raw_writel (MXS_WATCHDOG_EN , wdog_base +MXS_SET_ADDR ); + +/* Wait for reset to assert... */ +mdelay (10 ); + +pr_err ("Watchdog reset failed to assert reset\n" ); + +/* Delay to allow the serial port to show the message */ +mdelay (50 ); + +/* We'll take a jump through zero as a poor second */ +cpu_reset (0 ); +} + +void mxs_arch_reset_init (void __iomem *base) +{ +struct clk *clk; + + wdog_base = base; + + clk =clk_get_sys ("rtc" ,NULL ); +if (!IS_ERR (clk)) +clk_enable (clk); +} + +/* +* Clear the bit and poll it cleared. This is usually called with +* a reset address and mask being either SFTRST(bit 31) or CLKGATE +* (bit 30). +*/ +static int clear_poll_bit (void __iomem *addr,u32 mask) +{ +int timeout =0x400 ; + +/* clear the bit */ +__raw_writel (mask, addr +MXS_CLR_ADDR ); + +/* +* SFTRST needs 3 GPMI clocks to settle, the reference manual +* recommends to wait 1us. +*/ +udelay (1 ); + +/* poll the bit becoming clear */ +while ((__raw_readl (addr) & mask) && --timeout) +/* nothing */ ; + +return !timeout;
arch/arm/mach-mxs/system.c line 105
Quoted 10 lines
arch/arm/mach-mxs/system.c new file +10
-0+} + +int mxs_reset_block (void __iomem *reset_addr) +{ +int ret; +int timeout =0x400 ; + +/* clear and poll SFTRST */ + ret =clear_poll_bit (reset_addr,MXS_MODULE_SFTRST ); +if (ret)
unlikely(ret)?
arch/arm/mach-mxs/system.c line 113
Quoted 10 lines
arch/arm/mach-mxs/system.c new file +8
-0+ goto error; + +/* clear CLKGATE */ +__raw_writel (MXS_MODULE_CLKGATE , reset_addr +MXS_CLR_ADDR ); +/* set SFTRST to reset the block */ +__raw_writel (MXS_MODULE_SFTRST , reset_addr +MXS_SET_ADDR ); +udelay (1 ); +/* poll CLKGATE becoming set */
Can you add empty lines above the comments, please. This makes it much easier to read.
Quoted 23 lines
arch/arm/mach-mxs/system.c new file +21
-0+while ((!(__raw_readl (reset_addr) &MXS_MODULE_CLKGATE )) && --timeout) +/* nothing */ ; +if (unlikely (!timeout)) + goto error; + +/* clear and poll SFTRST */ + ret =clear_poll_bit (reset_addr,MXS_MODULE_SFTRST ); +if (ret) + goto error; + +/* clear and poll CLKGATE */ + ret =clear_poll_bit (reset_addr,MXS_MODULE_CLKGATE ); +if (ret) + goto error; + +return 0 ; + +error: +pr_err ("%s(%p): module reset timeout\n" , __func__, reset_addr); +return -ETIMEDOUT ; +}Signature · 1 line
1.7.1
Best regards
Uwe
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-K?nig | Industrial Linux Solutions | http://www.pengutronix.de/ |
PATCH v3 3/15 ARM: mxs: Add reset routines
In reply to Shawn GuoHi,
Quoted 12 lines · Shawn Guo
- The mxs wdog is implemented in RTC block.
- There is a generic software reset routine for most modules on mxs.Signed-off-by Shawn Guo <[email protected]>---
Changes for v3:
- Change wdog timeout to 10ms for safety
- Simplify functionmxs_reset_block()to get it look betterChanges for v2:
- Move rtc clock enabling fromarch_reset()intomxs_arch_reset_init()
mxs_arch_reset_init() is currently being called from the .map_io hook in mach-mxs/mm-mx23.c and mm-mx28.c which is called before clocks are registered.
But IMO this should be removed from the .map_io hook anyway (as well as mxs_iomux_init()).
Lothar Wa?mann
Signature · 9 lines
___________________________________________________________ Ka-Ro electronics GmbH | Pascalstra?e 22 | D - 52076 Aachen Phone: +49 2408 1402-0 | Fax: +49 2408 1402-10 Gesch?ftsf?hrer: Matthias Kaussen Handelsregistereintrag: Amtsgericht Aachen, HRB 4996 www.karo-electronics.de | info at karo-electronics.de ___________________________________________________________
PATCH v3 3/15 ARM: mxs: Add reset routines
Hi Lothar,
Quoted 12 lines · Lothar Wa?mann
Hi,
Quoted 9 lines · Shawn Guo
- The mxs wdog is implemented in RTC block.
- There is a generic software reset routine for most modules on mxs.Signed-off-by Shawn Guo <[email protected]>---
Changes for v3:
- Change wdog timeout to 10ms for safety
- Simplify functionmxs_reset_block()to get it look better
Quoted 8 lines
Quoted 3 lines
Changes for v2:
- Move rtc clock enabling fromarch_reset()intomxs_arch_reset_init()
mxs_arch_reset_init()is currently being called from the .map_io hook inmach-mxs/mm-mx23.candmm-mx28.cwhich is called before clocks are registered.
But IMO this should be removed from the .map_io hook anyway (as well asmxs_iomux_init()).
I assume you want to make this an initcall?
Best regards
Uwe
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-K?nig | Industrial Linux Solutions | http://www.pengutronix.de/ |
PATCH v3 3/15 ARM: mxs: Add reset routines
2010/12/9 Uwe Kleine-K?nig <[email protected]>:
Quoted 18 lines
Hi Lothar,
Quoted 15 lines · Lothar Wa?mann
Hi,
Quoted 12 lines · Shawn Guo
?- The mxs wdog is implemented in RTC block.
?- There is a generic software reset routine for most modules on mxs.Signed-off-by Shawn Guo <[email protected]>---
Changes for v3:
?- Change wdog timeout to 10ms for safety
?- Simplify functionmxs_reset_block()to get it look betterChanges for v2:
?- Move rtc clock enabling fromarch_reset()intomxs_arch_reset_init()
Quoted 7 lines
Quoted 5 lines
mxs_arch_reset_init()is currently being called from the .map_io hook inmach-mxs/mm-mx23.candmm-mx28.cwhich is called before clocks are registered.
But IMO this should be removed from the .map_io hook anyway (as well asmxs_iomux_init()).I assume you want to make this an initcall?
Here is how they look.
static int __init mxs_arch_reset_init(void)
{
struct clk *clk;
wdog_base = cpu_is_mx23() ? MX23_IO_ADDRESS(MX23_RTC_BASE_ADDR) :
MX28_IO_ADDRESS(MX28_RTC_BASE_ADDR);
clk = clk_get_sys("rtc", NULL);
if (!IS_ERR(clk))
clk_enable(clk);
else
return 0;
}core_initcall(mxs_arch_reset_init);
static int __init mxs_iomux_init(void)
{
iomux_base = MXS_IO_ADDRESS(MXS_PINCTRL_BASE_ADDR);
return 0;
}core_initcall(mxs_iomux_init);
Signature · 2 lines
Regards, Shawn
PATCH v3 3/15 ARM: mxs: Add reset routines
Quoted 7 lines · Shawn Guo
static int
__initmxs_iomux_init(void){ iomux_base = MXS_IO_ADDRESS(MXS_PINCTRL_BASE_ADDR); return 0; }
core_initcall(mxs_iomux_init);
why not simply initialize iomux_base statically?
Uwe
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-K?nig | Industrial Linux Solutions | http://www.pengutronix.de/ |
PATCH v2 9/15 ARM: mxs: Add clock support
In reply to Shawn GuoAdd clock for MXS-based SoCs, MX23 and MX28.
---
Changes for v2:
- Shift pll0_clock freq 480MHz in children freq computation to avoid overflow
- Fix fec_clk to stand for fec clock than IEEE1588 time clock
- Add pll2_clk into clock lookups, as it's fec phy clock and needs to be on before reset phy
arch/arm/mach-mxs/clock-mx23.c | 521 ++++++++++++++++++++++ arch/arm/mach-mxs/clock-mx28.c | 731 +++++++++++++++++++++++++++++++ arch/arm/mach-mxs/clock.c | 201 +++++++++ arch/arm/mach-mxs/include/mach/clkdev.h | 7 + arch/arm/mach-mxs/include/mach/clock.h | 64 +++ arch/arm/mach-mxs/regs-clkctrl-mx23.h | 455 +++++++++++++++++++ arch/arm/mach-mxs/regs-clkctrl-mx28.h | 663 ++++++++++++++++++++++++++++ 7 files changed, 2642 insertions(+), 0 deletions(-) create mode 100644 arch/arm/mach-mxs/clock-mx23.c create mode 100644 arch/arm/mach-mxs/clock-mx28.c create mode 100644 arch/arm/mach-mxs/clock.c create mode 100644 arch/arm/mach-mxs/include/mach/clkdev.h create mode 100644 arch/arm/mach-mxs/include/mach/clock.h create mode 100644 arch/arm/mach-mxs/regs-clkctrl-mx23.h create mode 100644 arch/arm/mach-mxs/regs-clkctrl-mx28.h
arch/arm/mach-mxs/clock-mx23.c new file +521 -0
@@ -0,0 +1,521 @@ +/* +* 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-mx23.h" + +#define CLKCTRL_BASE_ADDR MX23_IO_ADDRESS(MX23_CLKCTRL_BASE_ADDR) +#define DIGCTRL_BASE_ADDR MX23_IO_ADDRESS(MX23_DIGCTL_BASE_ADDR) + +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 pll_clk_get_rate (struct clk *clk) +{ +return 480000000 ; +} + +static int pll_clk_enable (struct clk *clk) +{ +__raw_writel (BM_CLKCTRL_PLLCTRL0_POWER | +BM_CLKCTRL_PLLCTRL0_EN_USB_CLKS , +CLKCTRL_BASE_ADDR +HW_CLKCTRL_PLLCTRL0_SET ); + +/* Only a 10us delay is need. PLLCTRL1 LOCK bitfied is only a timer +* and is incorrect (excessive). Per definition of the PLLCTRL0 +* POWER field, waiting at least 10us. +*/ +udelay (10 ); + +return 0 ; +} + +static void pll_clk_disable (struct clk *clk) +{ +__raw_writel (BM_CLKCTRL_PLLCTRL0_POWER | +BM_CLKCTRL_PLLCTRL0_EN_USB_CLKS , +CLKCTRL_BASE_ADDR +HW_CLKCTRL_PLLCTRL0_CLR ); +} + +static struct clk pll_clk = { + .get_rate = pll_clk_get_rate, + .enable = pll_clk_enable, + .disable = pll_clk_disable, + .parent = &ref_xtal_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, FRAC, CPU) +_CLK_GET_RATE_REF(ref_emi_clk, FRAC, EMI) +_CLK_GET_RATE_REF(ref_pix_clk, FRAC, PIX) +_CLK_GET_RATE_REF(ref_io_clk, FRAC, IO) + +#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 = &pll_clk, \ + } + +_DEFINE_CLOCK_REF (ref_cpu_clk,FRAC ,CPU ); +_DEFINE_CLOCK_REF (ref_emi_clk,FRAC ,EMI ); +_DEFINE_CLOCK_REF (ref_pix_clk,FRAC ,PIX ); +_DEFINE_CLOCK_REF (ref_io_clk,FRAC ,IO ); + +/* +* General clocks +* +* clk_get_rate +*/ +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 ; +} + +#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; \ + \ + return clk_get_rate(clk->parent) / div; \ +} + +_CLK_GET_RATE1(hbus_clk, HBUS) +_CLK_GET_RATE1(xbus_clk, XBUS) +_CLK_GET_RATE1(ssp_clk, SSP) +_CLK_GET_RATE1(gpmi_clk, GPMI) +_CLK_GET_RATE1(lcdif_clk, PIX) + +#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 (audio_clk ) +_CLK_GET_RATE_STUB (pwm_clk) + +/* +* clk_set_rate +*/ +static int cpu_clk_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); + +if (clk->parent == &ref_xtal_clk) { + div_max =BM_CLKCTRL_CPU_DIV_XTAL >>BP_CLKCTRL_CPU_DIV_XTAL ; + bm_busy =BM_CLKCTRL_CPU_BUSY_REF_XTAL ; + div =DIV_ROUND_UP (parent_rate, rate); +if (div ==0 || div > div_max) +return -EINVAL ; + }else { + div_max =BM_CLKCTRL_CPU_DIV_CPU >>BP_CLKCTRL_CPU_DIV_CPU ; + bm_busy =BM_CLKCTRL_CPU_BUSY_REF_CPU ; + div = frac =1 ; + diff = parent_rate; +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_FRAC ); + reg &= ~BM_CLKCTRL_FRAC_CPUFRAC ; + reg |= frac; +__raw_writel (reg,CLKCTRL_BASE_ADDR +HW_CLKCTRL_FRAC ); + } + + reg =__raw_readl (CLKCTRL_BASE_ADDR +HW_CLKCTRL_CPU ); + reg &= ~BM_CLKCTRL_CPU_DIV_CPU ; + reg |= div <<BP_CLKCTRL_CPU_DIV_CPU ; +__raw_writel (reg,CLKCTRL_BASE_ADDR +HW_CLKCTRL_CPU ); + +for (i =10000 ; i; i--) +if (!(__raw_readl (CLKCTRL_BASE_ADDR + +HW_CLKCTRL_CPU ) & bm_busy)) +break ; +if (!i) { +pr_err ("%s: divider writing timeout\n" , __func__); +return -ETIMEDOUT ; + } + +return 0 ; +} + +#define _CLK_SET_RATE (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_RATE(xbus_clk, XBUS) +_CLK_SET_RATE(ssp_clk, SSP) +_CLK_SET_RATE(gpmi_clk, GPMI) +_CLK_SET_RATE(lcdif_clk, PIX) + +#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(audio_clk) +_CLK_SET_RATE_STUB(pwm_clk) +_CLK_SET_RATE_STUB(clk32k_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(ssp_clk, SSP) +_CLK_SET_PARENT(gpmi_clk, GPMI) +_CLK_SET_PARENT(lcdif_clk, PIX) + +#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(uart_clk) +_CLK_SET_PARENT_STUB(audio_clk) +_CLK_SET_PARENT_STUB(pwm_clk) +_CLK_SET_PARENT_STUB(clk32k_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 rtc_clk = { + .get_rate = rtc_clk_get_rate, + .parent = &ref_xtal_clk, +}; + +/* usb_clk gate is controlled in DIGCTRL other than CLKCTRL */ +static struct clk usb_clk = { + .enable_reg = DIGCTRL_BASE_ADDR, + .enable_shift = 2, + .enable = _raw_clk_enable, + .disable = _raw_clk_disable, + .parent = &pll_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(ssp_clk, SSP, CLKGATE, &ref_xtal_clk); +_DEFINE_CLOCK(gpmi_clk, GPMI, CLKGATE, &ref_xtal_clk); +_DEFINE_CLOCK(lcdif_clk, PIX, CLKGATE, &ref_xtal_clk); +_DEFINE_CLOCK(uart_clk, XTAL, UART_CLK_GATE, &ref_xtal_clk); +_DEFINE_CLOCK(audio_clk, XTAL, FILT_CLK24M_GATE, &ref_xtal_clk); +_DEFINE_CLOCK(pwm_clk, XTAL, PWM_CLK24M_GATE, &ref_xtal_clk); +_DEFINE_CLOCK(clk32k_clk, XTAL, TIMROT_CLK32K_GATE, &ref_xtal_clk); + +#define _REGISTER_CLOCK(d, n, c) \ + { \ + .dev_id = d, \ + .con_id = n, \ + .clk = &c, \ + }, + +static struct clk_lookup lookups[] = { + _REGISTER_CLOCK("mxs-duart.0", NULL, uart_clk) + _REGISTER_CLOCK("rtc", NULL, rtc_clk) + _REGISTER_CLOCK(NULL, "hclk", hbus_clk) + _REGISTER_CLOCK(NULL, "xclk", xbus_clk) + _REGISTER_CLOCK(NULL, "usb", usb_clk) + _REGISTER_CLOCK(NULL, "audio", audio_clk) + _REGISTER_CLOCK(NULL, "pwm", pwm_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; + ssp_clk.parent = (reg & BM_CLKCTRL_CLKSEQ_BYPASS_SSP) ? + &ref_xtal_clk : &ref_io_clk; + gpmi_clk.parent = (reg & BM_CLKCTRL_CLKSEQ_BYPASS_GPMI) ? + &ref_xtal_clk : &ref_io_clk; + lcdif_clk.parent = (reg & BM_CLKCTRL_CLKSEQ_BYPASS_PIX) ? + &ref_xtal_clk : &ref_pix_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_SSP); + reg &= ~BM_CLKCTRL_SSP_DIV_FRAC_EN; + __raw_writel(reg, CLKCTRL_BASE_ADDR + HW_CLKCTRL_SSP); + + 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_PIX); + reg &= ~BM_CLKCTRL_PIX_DIV_FRAC_EN; + __raw_writel(reg, CLKCTRL_BASE_ADDR + HW_CLKCTRL_PIX); + + /* + * 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_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); + + return 0; +} + +int __init mx23_clocks_init(void) +{ + clk_misc_init(); + + clkdev_add_table(lookups, ARRAY_SIZE(lookups)); + + mxs_timer_init(&clk32k_clk, MX23_IO_ADDRESS(MX23_TIMROT_BASE_ADDR), + MX23_INT_TIMER0); + + return 0; +}
arch/arm/mach-mxs/clock-mx28.c new file +731 -0
731 lines not on this page · raw message
arch/arm/mach-mxs/clock.c new file +201 -0
201 lines not on this page · raw message
arch/arm/mach-mxs/include/mach/clkdev.h new file +7 -0
@@ -0,0 +1,7 @@ +#ifndef __MACH_MXS_CLKDEV_H__ +#define __MACH_MXS_CLKDEV_H__ + +#define __clk_get (clk) ({ 1; }) +#define __clk_put (clk) do { } while (0) + +#endif
arch/arm/mach-mxs/include/mach/clock.h new file +64 -0
64 lines not on this page · raw message
arch/arm/mach-mxs/regs-clkctrl-mx23.h new file +455 -0
455 lines not on this page · raw message
arch/arm/mach-mxs/regs-clkctrl-mx28.h new file +663 -0
663 lines not on this page · raw message
Signature · 1 line
1.7.1
PATCH v2 9/15 ARM: mxs: Add clock support
Quoted 6 lines · Shawn Guo
Add clock for MXS-based SoCs, MX23 and MX28.
Signed-off-by Shawn Guo <[email protected]>---
Changes for v2:
- Shiftpll0_clockfreq 480MHz in children freq computation to avoid overflow
really?
arch/arm/mach-mxs/clock-mx23.c line 77
Quoted 7 lines
[...]
arch/arm/mach-mxs/clock-mx23.c new file +6
-0+/* +* pll_clk +*/ +static unsigned long pll_clk_get_rate (struct clk *clk) +{ +return 480000000 ;
pll's get_rate still returns 0x1c9c3800
Quoted 8 lines
[...]
arch/arm/mach-mxs/clock-mx23.c new file +7
-0+/* +* ref_clk +*/ +#define _CLK_GET_RATE_REF (name, sr, ss) \ +static unsigned long name##_get_rate(struct clk *clk) \ +{ \ + unsigned long parent_rate; \
arch/arm/mach-mxs/clock-mx23.c line 125
Quoted 10 lines
arch/arm/mach-mxs/clock-mx23.c new file +10
-0+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,FRAC ,CPU )
ref_cpu_clk's get_rate still uses parent_rate * 18
Quoted 5 lines
arch/arm/mach-mxs/clock-mx23.c new file +5
-0+_CLK_GET_RATE_REF(ref_emi_clk, FRAC, EMI) +_CLK_GET_RATE_REF(ref_pix_clk, FRAC, PIX) +_CLK_GET_RATE_REF(ref_io_clk, FRAC, IO) + +#define _DEFINE_CLOCK_REF (name, er, es) \
arch/arm/mach-mxs/clock-mx23.c line 140
Quoted 10 lines
arch/arm/mach-mxs/clock-mx23.c new file +10
-0+ 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 = &pll_clk, \ + } + +_DEFINE_CLOCK_REF (ref_cpu_clk,FRAC ,CPU );
ref_cpu_clk's parent still is pll_clk
Uwe
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-K?nig | Industrial Linux Solutions | http://www.pengutronix.de/ |
PATCH v2 9/15 ARM: mxs: Add clock support
2010/12/9 Uwe Kleine-K?nig <[email protected]>:
Quoted 38 lines · Shawn Guo
Quoted 6 lines
Add clock for MXS-based SoCs, MX23 and MX28.
Signed-off-by Shawn Guo <[email protected]>---
Changes for v2:
?- Shiftpll0_clockfreq 480MHz in children freq computation to avoid overflowreally?
arch/arm/mach-mxs/clock-mx23.c
Quoted 7 lines
[...]
arch/arm/mach-mxs/clock-mx23.c new file +6
-0+/* +* pll_clk +*/ +static unsigned long pll_clk_get_rate (struct clk *clk) +{ + ? ? return 480000000;pll's
get_ratestill returns0x1c9c3800Quoted 8 lines
[...]
(quoted diff) +7
-0+/* + * ref_clk + */ +#define _CLK_GET_RATE_REF(name, sr, ss) ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?\ +static unsigned long name##_get_rate(struct clk *clk) ? ? ? ? ? ? ? ? ? ? ? ?\ +{ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?\ + ? ? unsigned long parent_rate; ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?\Review
Quoted 10 lines
(quoted diff) +10
-0+ ? ? 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, FRAC, CPU)ref_cpu_clk's
get_ratestill usesparent_rate* 18
Quoted 17 lines
Quoted 5 lines
(quoted diff) +5
-0+_CLK_GET_RATE_REF(ref_emi_clk, FRAC, EMI) +_CLK_GET_RATE_REF(ref_pix_clk, FRAC, PIX) +_CLK_GET_RATE_REF(ref_io_clk, FRAC, IO) + +#define _DEFINE_CLOCK_REF(name, er, es) ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?\Review
Quoted 10 lines
(quoted diff) +10
-0+ ? ? 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 ? ? ? ? = &pll_clk, ? ? ? ? ? ? ? ? ? ? ? ? ? ? \ + ? ? } + +_DEFINE_CLOCK_REF(ref_cpu_clk, FRAC, CPU);ref_cpu_clk's parent still is
pll_clk
My mistake. I only fixed clock-mx28.c and forgot clock-mx23.c.
Signature · 2 lines
Regards, Shawn
PATCH v2 9/15 ARM: mxs: Add clock support
In reply to Shawn GuoHello Shawn,
arch/arm/mach-mxs/clock-mx28.c line 163
Quoted 11 lines
arch/arm/mach-mxs/clock-mx28.c new file +11
-0+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 / 1000 * 18 / div * 1000; \ +}
1000 isn't the most clever choice. It might be for a human, but not for a machine.
I'd suggest (untested):
return SH_DIV((parent_rate >> 8) * 18, div, 8);
(don't know if 8 is a good value). What is the range of div here?
Best regards
Uwe
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-K?nig | Industrial Linux Solutions | http://www.pengutronix.de/ |
PATCH v2 9/15 ARM: mxs: Add clock support
Hi Uwe,
2010/12/9 Uwe Kleine-K?nig <[email protected]>:
Quoted 16 lines
Hello Shawn,
Review
Quoted 11 lines
(quoted diff) +11
-0+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 / 1000 * 18 / div * 1000; ? ? ? ? ? ? ? ? ? ?\ +}1000 isn't the most clever choice. ?It might be for a human, but not for a machine.
Quoted 6 lines
I'd suggest (untested):
? ? ? ?return
SH_DIV((parent_rate >> 8) * 18, div, 8);(don't know if 8 is a good value). ?What is the range of div here?
The div range is 18 ~ 35.
Signature · 2 lines
Regards, Shawn
PATCH v2 9/15 ARM: mxs: Add clock support
In reply to Uwe Kleine-König2010/12/9 Uwe Kleine-K?nig <[email protected]>:
Quoted 16 lines
Hello Shawn,
Review
Quoted 11 lines
(quoted diff) +11
-0+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 / 1000 * 18 / div * 1000; ? ? ? ? ? ? ? ? ? ?\ +}1000 isn't the most clever choice. ?It might be for a human, but not for a machine.
Quoted 6 lines
I'd suggest (untested):
? ? ? ?return
SH_DIV((parent_rate >> 8) * 18, div, 8);(don't know if 8 is a good value). ?What is the range of div here?
Tested.
Signature · 2 lines
Regards, Shawn
PATCH v2 10/15 ARM: mxs: Add static memory mapping
In reply to Shawn GuoCreate static memory mapping for MX23 and MX28.
---
Changes for v2:
- Remove the calls to mxs_set_cpu_type()
arch/arm/mach-mxs/mm-mx23.c | 47 +++++++++++++++++++++++++++++++++++++++++++ arch/arm/mach-mxs/mm-mx28.c | 47 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 94 insertions(+), 0 deletions(-) create mode 100644 arch/arm/mach-mxs/mm-mx23.c create mode 100644 arch/arm/mach-mxs/mm-mx28.c
arch/arm/mach-mxs/mm-mx23.c new file +47 -0
@@ -0,0 +1,47 @@ +/* +* 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.h> + +/* +* Define the MX23 memory map. +*/ +static struct map_desc mx23_io_desc[]__initdata = { +mxs_map_entry (MX23 ,OCRAM ,MT_DEVICE ), +mxs_map_entry (MX23 ,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 mx23_map_io (void ) +{ +mxs_iomux_init (MX23_IO_ADDRESS (MX23_PINCTRL_BASE_ADDR )); +mxs_arch_reset_init (MX23_IO_ADDRESS (MX23_RTC_BASE_ADDR )); +iotable_init (mx23_io_desc,ARRAY_SIZE (mx23_io_desc)); +} + +void __init mx23_init_irq (void ) +{ +icoll_init_irq (MX23_IO_ADDRESS (MX23_ICOLL_BASE_ADDR )); +mx23_register_gpios (); +}
arch/arm/mach-mxs/mm-mx28.c new file +47 -0
47 lines not on this page · raw message
Signature · 1 line
1.7.1
PATCH v2 10/15 ARM: mxs: Add static memory mapping
In reply to Shawn GuoCreate static memory mapping for MX23 and MX28.
---
Changes for v2:
- Change the inclusion of hardware.h to mx23.h and mx28.h respectively
- Remove the call to mxs_iomux_init() and mxs_arch_reset_init() from map_io callback, and turn them into __initcall, as the call here is a little late.
arch/arm/mach-mxs/mm-mx23.c | 45 +++++++++++++++++++++++++++++++++++++++++++ arch/arm/mach-mxs/mm-mx28.c | 45 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 90 insertions(+), 0 deletions(-) create mode 100644 arch/arm/mach-mxs/mm-mx23.c create mode 100644 arch/arm/mach-mxs/mm-mx28.c
arch/arm/mach-mxs/mm-mx23.c new file +45 -0
@@ -0,0 +1,45 @@ +/* +* 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/mx23.h> +#include <mach/common.h> +#include <mach/iomux.h> + +/* +* Define the MX23 memory map. +*/ +static struct map_desc mx23_io_desc[]__initdata = { +mxs_map_entry (MX23 ,OCRAM ,MT_DEVICE ), +mxs_map_entry (MX23 ,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 mx23_map_io (void ) +{ +iotable_init (mx23_io_desc,ARRAY_SIZE (mx23_io_desc)); +} + +void __init mx23_init_irq (void ) +{ +icoll_init_irq (); +mx23_register_gpios (); +}
arch/arm/mach-mxs/mm-mx28.c new file +45 -0
45 lines not on this page · raw message
Signature · 1 line
1.7.1