ARM: mxs: Add initial support for MX23 and MX28
Subsystems (3)
v7 cover ARM: mxs: Add initial support for MX23 and MX28
Changes for v7 of this patch series:
- Use clocksource_register_hz
- Add mxs namespace for the missing ones
- Use CLKCTRL_RESET_CHIP over RTC_WATCHDOG to implement arch_reset
- Define naked pad and introduce validity bits for mA/vol/pull to ease the pad modification
- List all pad definitions at once generated from Freescale pinmux Excel sheet
- Add more comments for timrot instance used for MX23 and MX28
- Use HW_TIMROT_TIMCOUNTn for v1 to avoid confusion
- Detect timrot version by reading register HW_TIMROT_VERSION
- Switch over to use gpiolib __gpio_to_irq()
- Fix some checkpatch warnings
The full change log could be found in the version history of following individual patch.
[PATCH v7 03/15] ARM: mxs: Add reset routines [PATCH v7 04/15] ARM: mxs: Add interrupt support [PATCH v7 05/15] ARM: mxs: Add low-level debug UART support [PATCH v7 06/15] ARM: mxs: Add timer support [PATCH v7 07/15] ARM: mxs: Add gpio support [PATCH v7 08/15] ARM: mxs: Add iomux support [PATCH v7 09/15] ARM: mxs: Add clock support [PATCH v7 13/15] ARM: mxs: Add initial mx23evk support [PATCH v7 14/15] ARM: mxs: Add initial mx28evk support
Thanks all for the review.
Regards,
Shawn
PATCH v7 3/15 ARM: mxs: Add reset routines
- The mxs wdog is implemented in RTC block.
- There is a generic software reset routine for most modules on mxs.
---
Changes for v7:
- Use CLKCTRL_RESET_CHIP over RTC_WATCHDOG to implement arch_reset
Changes for v6:
- Use __mxs_setl() and __mxs_clrl() for bit set/clear
Changes for v4:
- Add blank line above comment to make the code easy to read
- Tell compiler unlikely(ret)
- Make mxs_arch_reset_init __initcall
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 | 137 +++++++++++++++++++++++++++++++ 2 files changed, 164 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 +137 -0
137 lines not on this page · raw message
Signature · 1 line
1.7.1
PATCH v7 4/15 ARM: mxs: Add interrupt support
In reply to Shawn GuoAdd Interrupt Collector (ICOLL) support for MXS-based.
---
Change for v7:
- Add namespace for ICOLL_VBASE
Changes for v3:
- icoll.c: add #include <linux/io.h> as it's removed from mx23.h and mx28.h
- Change inclusion of hardware.h to mxs.h
- Move writing to HW_ICOLL_VECTOR from icoll.c icoll_ack_irq() into entry-macro.S get_irqnr_and_base
- icoll.c: add more words into comments for level 0 irq ack
- mx23 and mx28 share the same icoll base address, so hard-coding of the address is ok
- entry-macro.S: define and use HW_ICOLL_STAT_OFFSET over 0x70
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 | 81 ++++++++++++++++++++++++++ arch/arm/mach-mxs/include/mach/entry-macro.S | 41 +++++++++++++ 2 files changed, 122 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 +81 -0
@@ -0,0 +1,81 @@ +/* +* 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 <linux/io.h> + +#include <mach/mxs.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 + +static void __iomem *icoll_base =MXS_IO_ADDRESS (MXS_ICOLL_BASE_ADDR ); + +static void icoll_ack_irq (unsigned int irq) +{ +/* +* The Interrupt Collector is able to prioritize irqs. +* Currently only level 0 is used. So acking can use +* BV_ICOLL_LEVELACK_IRQLEVELACK__LEVEL0 unconditionally. +*/ +__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 ) +{ +int i; + +/* +* Interrupt Collector reset, which initializes the priority +* for each irq to level 0. +*/ +mxs_reset_block (icoll_base +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 +41 -0
41 lines not on this page · raw message
Signature · 1 line
1.7.1
PATCH v7 5/15 ARM: mxs: Add low-level debug UART support
In reply to Shawn Guo - DEBUG_LL support, which is incompatible with multi-soc MXS image because of different DUART base address on MX23 and MX28
- uncompress message support
---
Changes for v7:
- Add namespace for uart_base and UART()
Changes for v3:
- debug-macro.S: change inclusion of hardware.h to mx23.h plus mx28.h
- Remove #define __MXS_BOOT_UNCOMPRESS
- Add namespace MXS_DUART_ for macros
- Add comment "If it's not, the output is simply discarded."
Changes for v2:
- Remove incorrect comments
arch/arm/mach-mxs/include/mach/debug-macro.S | 52 ++++++++++++++++++ arch/arm/mach-mxs/include/mach/uncompress.h | 76 ++++++++++++++++++++++++++ 2 files changed, 128 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 +52 -0
@@ -0,0 +1,52 @@ +/* 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/mx23.h> +#include <mach/mx28.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 +76 -0
76 lines not on this page · raw message
Signature · 1 line
1.7.1
PATCH v7 5/15 ARM: mxs: Add low-level debug UART support
Hi Shawn,
I discovered this weekend that the DUART is just an amba-pl011 which is already supported in mainline. So we should use the existing infrastructure here.
Quoted 2 lines · Shawn Guo
-
DEBUG_LLsupport, which is incompatible with multi-soc MXS image because of different DUART base address on MX23 and MX28
We should be able to use the AMBA identification signature to distinguish at runtime, no?
Quoted 5 lines
- uncompress message support
Signed-off-by Shawn Guo <[email protected]>arch/arm/mach-mxs/include/mach/debug-macro.S | 52 ++++++++++++++++++
We should use asm/hardware/debug-pl01x.S, like the other users:
wsa at katana:~/Kernel/linux-2.6/arch/arm$ g debug-pl01x include/asm/hardware/debug-pl01x.S:1:/* arch/arm/include/asm/hardware/debug-pl01x.S mach-cns3xxx/include/mach/debug-macro.S:19:#include <asm/hardware/debug-pl01x.S> mach-ep93xx/include/mach/debug-macro.S:21:#include <asm/hardware/debug-pl01x.S> mach-integrator/include/mach/debug-macro.S:20:#include <asm/hardware/debug-pl01x.S> mach-nomadik/include/mach/debug-macro.S:20:#include <asm/hardware/debug-pl01x.S> mach-realview/include/mach/debug-macro.S:42:#include <asm/hardware/debug-pl01x.S> mach-u300/include/mach/debug-macro.S:21:#include <asm/hardware/debug-pl01x.S> mach-ux500/include/mach/debug-macro.S:26:#include <asm/hardware/debug-pl01x.S> mach-versatile/include/mach/debug-macro.S:21:#include <asm/hardware/debug-pl01x.S> mach-vexpress/include/mach/debug-macro.S:21:#include <asm/hardware/debug-pl01x.S>
Quoted 1 line
arch/arm/mach-mxs/include/mach/uncompress.h | 76 ++++++++++++++++++++++++++
Auto-detection could be used here, too?
Kind regards,
Wolfram
Signature · 9 lines
Pengutronix e.K. | Wolfram Sang | Industrial Linux Solutions | http://www.pengutronix.de/ | -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 198 bytes Desc: Digital signature URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20101220/da1846e6/attachment.sig>
PATCH v7 5/15 ARM: mxs: Add low-level debug UART support
Quoted 22 lines · Wolfram Sang
Hi Shawn,
I discovered this weekend that the DUART is just an amba-pl011 which is already supported in mainline. So we should use the existing infrastructure here.
Quoted 2 lines · Shawn Guo
-
DEBUG_LLsupport, which is incompatible with multi-soc MXS image because of different DUART base address on MX23 and MX28We should be able to use the AMBA identification signature to distinguish at runtime, no?
Quoted 5 lines
- uncompress message support
Signed-off-by Shawn Guo <[email protected]>arch/arm/mach-mxs/include/mach/debug-macro.S | 52 ++++++++++++++++++We should use
asm/hardware/debug-pl01x.S, like the other users:
Quoted 12 lines
wsa at katana:~/Kernel/linux-2.6/arch/arm$ g debug-pl01x include/asm/hardware/debug-pl01x.S:1:/*
arch/arm/include/asm/hardware/debug-pl01x.Smach-cns3xxx/include/mach/debug-macro.S:19:#include <asm/hardware/debug-pl01x.S> mach-ep93xx/include/mach/debug-macro.S:21:#include <asm/hardware/debug-pl01x.S> mach-integrator/include/mach/debug-macro.S:20:#include <asm/hardware/debug-pl01x.S> mach-nomadik/include/mach/debug-macro.S:20:#include <asm/hardware/debug-pl01x.S> mach-realview/include/mach/debug-macro.S:42:#include <asm/hardware/debug-pl01x.S> mach-u300/include/mach/debug-macro.S:21:#include <asm/hardware/debug-pl01x.S> mach-ux500/include/mach/debug-macro.S:26:#include <asm/hardware/debug-pl01x.S> mach-versatile/include/mach/debug-macro.S:21:#include <asm/hardware/debug-pl01x.S> mach-vexpress/include/mach/debug-macro.S:21:#include <asm/hardware/debug-pl01x.S>
Just tested it, and it works. Will do in v8. Thanks for the comment.
Quoted 5 lines
Quoted 2 lines
arch/arm/mach-mxs/include/mach/uncompress.h | 76 ++++++++++++++++++++++++++Auto-detection could be used here, too?
I'm afraid not. How do you expect the detection is done, by reading some register like we are doing in system.c? Which register specifically? If the register gets different address between mx23 and mx28, we need to utilize the current mechanism to distinguish the address anyway.
Signature · 2 lines
Regards, Shawn
PATCH v7 5/15 ARM: mxs: Add low-level debug UART support
Quoted 4 lines
Quoted 2 lines
We should use
asm/hardware/debug-pl01x.S, like the other users:Just tested it, and it works. Will do in v8. Thanks for the comment.
Cool.
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
arch/arm/mach-mxs/include/mach/uncompress.h | 76 ++++++++++++++++++++++++++Auto-detection could be used here, too?
I'm afraid not. How do you expect the detection is done, by reading some register like we are doing in
system.c?
I am not sure which register you mean in system.c?
Quoted 1 line
Which register specifically?
The signature of the amba device (base + size - 0x20). You can check drivers/amba/bus.c how it checks for the signature.
Quoted 3 lines
If the register gets different address between mx23 and mx28, we need to utilize the current mechanism to distinguish the address anyway.
We could simply test both locations and see where it is present?
Kind regards,
Wolfram
Signature · 9 lines
Pengutronix e.K. | Wolfram Sang | Industrial Linux Solutions | http://www.pengutronix.de/ | -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 198 bytes Desc: Digital signature URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20101220/73f23c53/attachment.sig>
PATCH v7 5/15 ARM: mxs: Add low-level debug UART support
Hi Wolfram,
Quoted 19 lines · Wolfram Sang
Quoted 4 lines
Quoted 2 lines
We should use
asm/hardware/debug-pl01x.S, like the other users:Just tested it, and it works. Will do in v8. Thanks for the comment.
Cool.
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
arch/arm/mach-mxs/include/mach/uncompress.h | 76 ++++++++++++++++++++++++++Auto-detection could be used here, too?
I'm afraid not. How do you expect the detection is done, by reading some register like we are doing in
system.c?I am not sure which register you mean in
system.c?Quoted 1 line
Which register specifically?
Quoted 9 lines
The signature of the amba device (base + size -
0x20). You can checkdrivers/amba/bus.chow it checks for the signature.Quoted 3 lines
If the register gets different address between mx23 and mx28, we need to utilize the current mechanism to distinguish the address anyway.
We could simply test both locations and see where it is present?
Is there any problem of simply using arch_id here? I do not see significant benefit of using the detection you suggest here over the current way.
Signature · 2 lines
Regards, Shawn
PATCH v7 5/15 ARM: mxs: Add low-level debug UART support
Hi Shawn,
Quoted 14 lines
Quoted 14 lines
Quoted 2 lines
I'm afraid not. How do you expect the detection is done, by reading some register like we are doing in
system.c?I am not sure which register you mean in
system.c?Quoted 1 line
Which register specifically?
The signature of the amba device (base + size -
0x20). You can checkdrivers/amba/bus.chow it checks for the signature.Quoted 3 lines
If the register gets different address between mx23 and mx28, we need to utilize the current mechanism to distinguish the address anyway.
Quoted 5 lines
Quoted 2 lines
We could simply test both locations and see where it is present?
Is there any problem of simply using
arch_idhere? I do not see significant benefit of using the detection you suggest here over the current way.
Ah, sorry, I thought you meant auto-detection was not possible in debug.S as well (and there it is worthwhile so mx23 and mx28 can be built into one kernel). For uncompress.h, the gain is nothing major, true. One would save to add custom boards there just to match the base address, but well...
Kind regards,
Wolfram
Signature · 9 lines
Pengutronix e.K. | Wolfram Sang | Industrial Linux Solutions | http://www.pengutronix.de/ | -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 198 bytes Desc: Digital signature URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20101220/5a6e9cdb/attachment.sig>
PATCH v7 6/15 ARM: mxs: Add timer support
In reply to Shawn GuoThere are 2 versions of the timrot on Freescale MXS-based SoCs. The v1 on MX23 only gets 16 bits counter, while v2 on MX28 extends the counter to 32 bits.
The implementation uses two timers, one for clock_event and another for clocksource. MX28 uses timrot 0 and 1, while MX23 uses 0 and 2.
---
Changes for v7:
- Use clocksource_register_hz suggested by Rusell
- Add more comments for timrot instance used for MX23 and MX28
- Use HW_TIMROT_TIMCOUNTn for v1 to avoid confusion
- Detect timrot version by reading register HW_TIMROT_VERSION
- Add namespace for clockevent_device and clockevent_mode
- Add namespace for timer_base
Changes for v6:
- Use __mxs_setl() and __mxs_clrl() for bit set/clear
Changes for v4:
- Change inclusion of hardware.h to mxs.h
- Use two timers on MX28 also to simpify timrotv2_set_next_event()
- MX23 and MX28 share the common timrot base address, so it can be a hard-assignment.
- Pass &clockevent_mxs to mxs_timer_interrupt via mxs_timer_irq.dev_id
- Fix code of setting far-far future
- Change printk to pr_info and pr_err
- Change timrotv2 min_delta_ns to 0xf
Changes for v3:
- Use term clock_event over next_event and clocksource over get_cycles
- Split BV_TIMROT_TIMCTRLn_SELECT__32KHZ_XTAL into two definitions for v1 and v2 respectively
- Turn timrot_get_cycles() into timrotv1_get_cycles() and timrotv2_get_cycles()
- Turn timrot_set_next_event() into timrotv1_set_next_event() and timrotv2_set_next_event()
- Skip flag IRQF_DISABLED
- Remove unncessary IRQ disabling in mxs_set_mode()
- Change shift of clocksource_mxs to 17
Changes for v2:
- 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 | 296 +++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 296 insertions(+), 0 deletions(-) create mode 100644 arch/arm/mach-mxs/timer.c
arch/arm/mach-mxs/timer.c new file +296 -0
@@ -0,0 +1,296 @@ +/* +* 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 <asm/mach/time.h> +#include <mach/mxs.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, while v2 on MX28 +* extends the counter to 32 bits. +* +* The implementation uses two timers, one for clock_event and +* another for clocksource. MX28 uses timrot 0 and 1, while MX23 +* uses 0 and 2. +*/ + +#define MX23_TIMROT_VERSION_OFFSET 0x0a0 +#define MX28_TIMROT_VERSION_OFFSET 0x120 +#define BP_TIMROT_MAJOR_VERSION 24 +#define BV_TIMROT_VERSION_1 0x01 +#define BV_TIMROT_VERSION_2 0x02 +#define timrot_is_v1 () (timrot_major_version == BV_TIMROT_VERSION_1) + +/* +* There are 4 registers for each timrotv2 instance, and 2 registers +* for each timrotv1. So address step 0x40 in macros below strides +* one instance of timrotv2 while two instances of timrotv1. +* +* As the result, HW_TIMROT_XXXn(1) defines the address of timrot1 +* on MX28 while timrot2 on MX23. +*/ +/* common between v1 and v2 */ +#define HW_TIMROT_ROTCTRL 0x00 +#define HW_TIMROT_TIMCTRLn (n) (0x20 + (n) * 0x40) +/* v1 only */ +#define HW_TIMROT_TIMCOUNTn (n) (0x30 + (n) * 0x40) +/* v2 only */ +#define HW_TIMROT_RUNNING_COUNTn (n) (0x30 + (n) * 0x40) +#define HW_TIMROT_FIXED_COUNTn (n) (0x40 + (n) * 0x40) + +#define BM_TIMROT_TIMCTRLn_RELOAD (1 << 6) +#define BM_TIMROT_TIMCTRLn_UPDATE (1 << 7) +#define BM_TIMROT_TIMCTRLn_IRQ_EN (1 << 14) +#define BM_TIMROT_TIMCTRLn_IRQ (1 << 15) +#define BP_TIMROT_TIMCTRLn_SELECT 0 +#define BV_TIMROTv1_TIMCTRLn_SELECT__32KHZ_XTAL 0x8 +#define BV_TIMROTv2_TIMCTRLn_SELECT__32KHZ_XTAL 0xb + +static struct clock_event_device mxs_clockevent_device; +static enum clock_event_mode mxs_clockevent_mode =CLOCK_EVT_MODE_UNUSED ; + +static void __iomem *mxs_timrot_base =MXS_IO_ADDRESS (MXS_TIMROT_BASE_ADDR ); +static u32 timrot_major_version; + +static inline void timrot_irq_disable (void ) +{ +__mxs_clrl (BM_TIMROT_TIMCTRLn_IRQ_EN, + mxs_timrot_base +HW_TIMROT_TIMCTRLn (0 )); +} + +static inline void timrot_irq_enable (void ) +{ +__mxs_setl (BM_TIMROT_TIMCTRLn_IRQ_EN, + mxs_timrot_base +HW_TIMROT_TIMCTRLn (0 )); +} + +static void timrot_irq_acknowledge (void ) +{ +__mxs_clrl (BM_TIMROT_TIMCTRLn_IRQ, + mxs_timrot_base +HW_TIMROT_TIMCTRLn (0 )); +} + +static cycle_t timrotv1_get_cycles (struct clocksource *cs) +{ +return ~((__raw_readl (mxs_timrot_base +HW_TIMROT_TIMCOUNTn (1 )) + &0xffff0000 ) >>16 ); +} + +static cycle_t timrotv2_get_cycles (struct clocksource *cs) +{ +return ~__raw_readl (mxs_timrot_base +HW_TIMROT_RUNNING_COUNTn (1 )); +} + +static int timrotv1_set_next_event (unsigned long evt, +struct clock_event_device *dev) +{ +/* timrot decrements the count */ +__raw_writel (evt, mxs_timrot_base +HW_TIMROT_TIMCOUNTn (0 )); + +return 0 ; +} + +static int timrotv2_set_next_event (unsigned long evt, +struct clock_event_device *dev) +{ +/* timrot decrements the count */ +__raw_writel (evt, mxs_timrot_base +HW_TIMROT_FIXED_COUNTn (0 )); + +return 0 ; +} + +static irqreturn_t mxs_timer_interrupt (int irq,void *dev_id) +{ +struct clock_event_device *evt = dev_id; + +timrot_irq_acknowledge (); + evt->event_handler (evt); + +return IRQ_HANDLED ; +} + +static struct irqaction mxs_timer_irq = { + .name ="MXS Timer Tick" , + .dev_id = &mxs_clockevent_device, + .flags =IRQF_TIMER |IRQF_IRQPOLL , + .handler = mxs_timer_interrupt, +}; + +#ifdef DEBUG +static const char *clock_event_mode_label[] const = { + [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) +{ +/* Disable interrupt in timer module */ +timrot_irq_disable (); + +if (mode != mxs_clockevent_mode) { +/* Set event time into the furthest future */ +if (timrot_is_v1 ()) +__raw_writel (0xffff , + mxs_timrot_base +HW_TIMROT_TIMCOUNTn (1 )); +else +__raw_writel (0xffffffff , + mxs_timrot_base +HW_TIMROT_FIXED_COUNTn (1 )); + +/* Clear pending interrupt */ +timrot_irq_acknowledge (); + } + +#ifdef DEBUG +pr_info ("%s: changing mode from %s to %s\n" , __func__, + clock_event_mode_label[mxs_clockevent_mode], + clock_event_mode_label[mode]); +#endif /* DEBUG */ + +/* Remember timer mode */ + mxs_clockevent_mode = mode; + +switch (mode) { +case CLOCK_EVT_MODE_PERIODIC : +pr_err ("%s: Periodic mode is not implemented\n" , __func__); +break ; +case CLOCK_EVT_MODE_ONESHOT : +timrot_irq_enable (); +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 mxs_clockevent_device = { + .name ="mxs_timrot" , + .features =CLOCK_EVT_FEAT_ONESHOT , + .shift =32 , + .set_mode = mxs_set_mode, + .set_next_event = timrotv2_set_next_event, + .rating =200 , +}; + +static int __init mxs_clockevent_init (struct clk *timer_clk) +{ +unsigned int c =clk_get_rate (timer_clk); + + mxs_clockevent_device.mult = +div_sc (c,NSEC_PER_SEC , mxs_clockevent_device.shift); + mxs_clockevent_device.cpumask =cpumask_of (0 ); +if (timrot_is_v1 ()) { + mxs_clockevent_device.set_next_event = timrotv1_set_next_event; + mxs_clockevent_device.max_delta_ns = +clockevent_delta2ns (0xfffe , &mxs_clockevent_device); + mxs_clockevent_device.min_delta_ns = +clockevent_delta2ns (0xf , &mxs_clockevent_device); + }else { + mxs_clockevent_device.max_delta_ns = +clockevent_delta2ns (0xfffffffe , &mxs_clockevent_device); + mxs_clockevent_device.min_delta_ns = +clockevent_delta2ns (0xf , &mxs_clockevent_device); + } + +clockevents_register_device (&mxs_clockevent_device); + +return 0 ; +} + +static struct clocksource clocksource_mxs = { + .name ="mxs_timer" , + .rating =200 , + .read = timrotv2_get_cycles, + .mask =CLOCKSOURCE_MASK (32 ), + .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.read = timrotv1_get_cycles; + clocksource_mxs.mask =CLOCKSOURCE_MASK (16 ); + } + +clocksource_register_hz (&clocksource_mxs, c); + +return 0 ; +} + +void __init mxs_timer_init (struct clk *timer_clk,int irq) +{ +clk_enable (timer_clk); + +/* +* Initialize timers to a known state +*/ +mxs_reset_block (mxs_timrot_base +HW_TIMROT_ROTCTRL ); + +/* get timrot version */ + timrot_major_version =__raw_readl (mxs_timrot_base + + (cpu_is_mx23 () ?MX23_TIMROT_VERSION_OFFSET : +MX28_TIMROT_VERSION_OFFSET )); + timrot_major_version >>=BP_TIMROT_MAJOR_VERSION ; + +/* one for clock_event */ +__raw_writel ((timrot_is_v1 () ? + BV_TIMROTv1_TIMCTRLn_SELECT__32KHZ_XTAL : + BV_TIMROTv2_TIMCTRLn_SELECT__32KHZ_XTAL) | + BM_TIMROT_TIMCTRLn_UPDATE | + BM_TIMROT_TIMCTRLn_IRQ_EN, + mxs_timrot_base +HW_TIMROT_TIMCTRLn (0 )); + +/* another for clocksource */ +__raw_writel ((timrot_is_v1 () ? + BV_TIMROTv1_TIMCTRLn_SELECT__32KHZ_XTAL : + BV_TIMROTv2_TIMCTRLn_SELECT__32KHZ_XTAL) | + BM_TIMROT_TIMCTRLn_RELOAD, + mxs_timrot_base +HW_TIMROT_TIMCTRLn (1 )); + +/* set clocksource timer fixed count to the maximum */ +if (timrot_is_v1 ()) +__raw_writel (0xffff , + mxs_timrot_base +HW_TIMROT_TIMCOUNTn (1 )); +else +__raw_writel (0xffffffff , + mxs_timrot_base +HW_TIMROT_FIXED_COUNTn (1 )); + +/* 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 v7 7/15 ARM: mxs: Add gpio support
In reply to Shawn GuoMXS-based SoCs implement gpio support in block PINCTRL.
---
Changes for v7:
- Switch over to use gpiolib __gpio_to_irq()
Changes for v6:
- Use __mxs_setl() and __mxs_clrl() for bit set/clear
- Rename functions for not using leading underscore
- Add mxs_ to some functions name to align naming scheme
- Introduce variables pin_mask and pin_addr to make code look better
- Remove PINCTRL_PIN2IRQ from irq_stat assignment
- Add comment for clearing status bit in IRQSTAT
- Set up irq handler before registering gpio chip
Changes for v5:
- Leave PIN2IRQ set when disabling gpio IRQ to avoid losting interrupt
Changes for v3:
- include/mach/gpio.h: remove the inclusion of hardware.h
- gpio.c: change inclusion of hardware.h to mx23.h plus mx28.h
- Remove spinlock totally since SET/CLE can be used in all the gpio register access
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 | 325 +++++++++++++++++++++++++++++++++ arch/arm/mach-mxs/gpio.h | 34 ++++ arch/arm/mach-mxs/include/mach/gpio.h | 35 ++++ 3 files changed, 394 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 +325 -0
@@ -0,0 +1,325 @@ +/* +* 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/mx23.h> +#include <mach/mx28.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) +{ +__mxs_clrl (1 << index, port->base +PINCTRL_IRQSTAT (port->id)); +} + +static void set_gpio_irqenable (struct mxs_gpio_port *port,u32 index, +int enable) +{ +if (enable) { +__mxs_setl (1 << index, port->base +PINCTRL_IRQEN (port->id)); +__mxs_setl (1 << index, port->base +PINCTRL_PIN2IRQ (port->id)); + }else { +__mxs_clrl (1 << index, port->base +PINCTRL_IRQEN (port->id)); + } +} + +static void mxs_gpio_ack_irq (u32 irq) +{ +u32 gpio =irq_to_gpio (irq); +clear_gpio_irqstatus (&mxs_gpio_ports[gpio /32 ], gpio &0x1f ); +} + +static void mxs_gpio_mask_irq (u32 irq) +{ +u32 gpio =irq_to_gpio (irq); +set_gpio_irqenable (&mxs_gpio_ports[gpio /32 ], gpio &0x1f ,0 ); +} + +static void mxs_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 mxs_gpio_set_irq_type (u32 irq,u32 type) +{ +u32 gpio =irq_to_gpio (irq); +u32 pin_mask =1 << (gpio &31 ); +struct mxs_gpio_port *port = &mxs_gpio_ports[gpio /32 ]; +void __iomem *pin_addr; +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 */ + pin_addr = port->base +PINCTRL_IRQLEV (port->id); +if (edge &GPIO_INT_LEV_MASK ) +__mxs_setl (pin_mask, pin_addr); +else +__mxs_clrl (pin_mask, pin_addr); + +/* set polarity */ + pin_addr = port->base +PINCTRL_IRQPOL (port->id); +if (edge &GPIO_INT_POL_MASK ) +__mxs_setl (pin_mask, pin_addr); +else +__mxs_clrl (pin_mask, pin_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)); + +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 mxs_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 = mxs_gpio_ack_irq, + .mask = mxs_gpio_mask_irq, + .unmask = mxs_gpio_unmask_irq, + .set_type = mxs_gpio_set_irq_type, + .set_wake = mxs_gpio_set_wake_irq, +}; + +static void mxs_set_gpio_direction (struct gpio_chip *chip,unsigned offset, +int dir) +{ +struct mxs_gpio_port *port = + container_of(chip, struct mxs_gpio_port, chip); +void __iomem *pin_addr = port->base +PINCTRL_DOE (port->id); + +if (dir) +__mxs_setl (1 << offset, pin_addr); +else +__mxs_clrl (1 << offset, pin_addr); +} + +static int mxs_gpio_get (struct gpio_chip *chip,unsigned offset) +{ +struct mxs_gpio_port *port = + container_of(chip, struct mxs_gpio_port, chip); + +return (__raw_readl (port->base +PINCTRL_DIN (port->id)) >> offset) &1 ; +} + +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); +void __iomem *pin_addr = port->base +PINCTRL_DOUT (port->id); + +if (value) +__mxs_setl (1 << offset, pin_addr); +else +__mxs_clrl (1 << offset, pin_addr); +} + +static int mxs_gpio_to_irq (struct gpio_chip *chip,unsigned offset) +{ +struct mxs_gpio_port *port = + container_of(chip, struct mxs_gpio_port, chip); + +return port->virtual_irq_start + offset; +} + +static int mxs_gpio_direction_input (struct gpio_chip *chip,unsigned offset) +{ +mxs_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); +mxs_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)); + +/* clear address has to be used to clear IRQSTAT bits */ +__mxs_clrl (~0U , port[i].base +PINCTRL_IRQSTAT (i)); + +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 ); + } + +/* 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]); + +/* 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.to_irq = mxs_gpio_to_irq; + port[i].chip.base = i *32 ; + port[i].chip.ngpio =32 ; + +/* its a serious configuration bug when it fails */ +BUG_ON (gpiochip_add (&port[i].chip) <0 ); + } + +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 +34 -0
@@ -0,0 +1,34 @@ +/* +* 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 __MXS_GPIO_H__ +#define __MXS_GPIO_H__ + +struct mxs_gpio_port { +void __iomem *base; +int id; +int irq; +int irq_high; +int virtual_irq_start; +struct gpio_chip chip; +}; + +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, [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 __MACH_MXS_GPIO_H__ +#define __MACH_MXS_GPIO_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_to_irq + +#define irq_to_gpio (irq) ((irq) - MXS_GPIO_IRQ_START) + +#endif /* __MACH_MXS_GPIO_H__ */
Signature · 1 line
1.7.1
PATCH v7 8/15 ARM: mxs: Add iomux support
In reply to Shawn GuoMXS-based SoCs implements iomux functions in block PINCTRL.
---
Changes for v7
- Define naked pad and introduce validity bits for mA/vol/pull to ease the pad modification
- List all pad definitions at once generated from Freescale pinmux Excel sheet
Changes for v6:
- Use __mxs_setl() and __mxs_clrl() for bit set/clear
Changes for v5:
- Change iomux_cfg_t from u64 to u16
- Add namespace MXS_ to shift, mask, and pad definitions
- Use SET/CLR register for 1 bit setting
- Get "if" and "{" at the same line
- Remove space in middle of tabs
- Change "setups" to "configures" in comments
Changes for v3:
- Change iomux_cfg_t to u64 to facilitate adding platform specific pad_ctrl settings to an existing pad definition
- Change inclusion of hardware.h to mxs.h
- Get iomux_base a hard-assignment in mxs_iomux_setup_pad(), since mx23 and mx28 share the common pinctrl base adress and it's only used in mxs_iomux_setup_pad().
- Remove EXPORT_SYMBOL and the static of mxs_iomux_setup_pad()
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 | 355 ++++++++++++++++++ arch/arm/mach-mxs/include/mach/iomux-mx28.h | 537 +++++++++++++++++++++++++++ arch/arm/mach-mxs/include/mach/iomux.h | 165 ++++++++ arch/arm/mach-mxs/iomux.c | 101 +++++ 4 files changed, 1158 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 +355 -0
@@ -0,0 +1,355 @@ +/* +* 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 +*/ +/* MUXSEL_0 */ +#define MX23_PAD_GPMI_D00__GPMI_D00 MXS_IOMUX_PAD_NAKED(0, 0, PAD_MUXSEL_0) +#define MX23_PAD_GPMI_D01__GPMI_D01 MXS_IOMUX_PAD_NAKED(0, 1, PAD_MUXSEL_0) +#define MX23_PAD_GPMI_D02__GPMI_D02 MXS_IOMUX_PAD_NAKED(0, 2, PAD_MUXSEL_0) +#define MX23_PAD_GPMI_D03__GPMI_D03 MXS_IOMUX_PAD_NAKED(0, 3, PAD_MUXSEL_0) +#define MX23_PAD_GPMI_D04__GPMI_D04 MXS_IOMUX_PAD_NAKED(0, 4, PAD_MUXSEL_0) +#define MX23_PAD_GPMI_D05__GPMI_D05 MXS_IOMUX_PAD_NAKED(0, 5, PAD_MUXSEL_0) +#define MX23_PAD_GPMI_D06__GPMI_D06 MXS_IOMUX_PAD_NAKED(0, 6, PAD_MUXSEL_0) +#define MX23_PAD_GPMI_D07__GPMI_D07 MXS_IOMUX_PAD_NAKED(0, 7, PAD_MUXSEL_0) +#define MX23_PAD_GPMI_D08__GPMI_D08 MXS_IOMUX_PAD_NAKED(0, 8, PAD_MUXSEL_0) +#define MX23_PAD_GPMI_D09__GPMI_D09 MXS_IOMUX_PAD_NAKED(0, 9, PAD_MUXSEL_0) +#define MX23_PAD_GPMI_D10__GPMI_D10 MXS_IOMUX_PAD_NAKED(0, 10, PAD_MUXSEL_0) +#define MX23_PAD_GPMI_D11__GPMI_D11 MXS_IOMUX_PAD_NAKED(0, 11, PAD_MUXSEL_0) +#define MX23_PAD_GPMI_D12__GPMI_D12 MXS_IOMUX_PAD_NAKED(0, 12, PAD_MUXSEL_0) +#define MX23_PAD_GPMI_D13__GPMI_D13 MXS_IOMUX_PAD_NAKED(0, 13, PAD_MUXSEL_0) +#define MX23_PAD_GPMI_D14__GPMI_D14 MXS_IOMUX_PAD_NAKED(0, 14, PAD_MUXSEL_0) +#define MX23_PAD_GPMI_D15__GPMI_D15 MXS_IOMUX_PAD_NAKED(0, 15, PAD_MUXSEL_0) +#define MX23_PAD_GPMI_CLE__GPMI_CLE MXS_IOMUX_PAD_NAKED(0, 16, PAD_MUXSEL_0) +#define MX23_PAD_GPMI_ALE__GPMI_ALE MXS_IOMUX_PAD_NAKED(0, 17, PAD_MUXSEL_0) +#define MX23_PAD_GPMI_CE2N__GPMI_CE2N MXS_IOMUX_PAD_NAKED(0, 18, PAD_MUXSEL_0) +#define MX23_PAD_GPMI_RDY0__GPMI_RDY0 MXS_IOMUX_PAD_NAKED(0, 19, PAD_MUXSEL_0) +#define MX23_PAD_GPMI_RDY1__GPMI_RDY1 MXS_IOMUX_PAD_NAKED(0, 20, PAD_MUXSEL_0) +#define MX23_PAD_GPMI_RDY2__GPMI_RDY2 MXS_IOMUX_PAD_NAKED(0, 21, PAD_MUXSEL_0) +#define MX23_PAD_GPMI_RDY3__GPMI_RDY3 MXS_IOMUX_PAD_NAKED(0, 22, PAD_MUXSEL_0) +#define MX23_PAD_GPMI_WPN__GPMI_WPN MXS_IOMUX_PAD_NAKED(0, 23, PAD_MUXSEL_0) +#define MX23_PAD_GPMI_WRN__GPMI_WRN MXS_IOMUX_PAD_NAKED(0, 24, PAD_MUXSEL_0) +#define MX23_PAD_GPMI_RDN__GPMI_RDN MXS_IOMUX_PAD_NAKED(0, 25, PAD_MUXSEL_0) +#define MX23_PAD_AUART1_CTS__AUART1_CTS MXS_IOMUX_PAD_NAKED(0, 26, PAD_MUXSEL_0) +#define MX23_PAD_AUART1_RTS__AUART1_RTS MXS_IOMUX_PAD_NAKED(0, 27, PAD_MUXSEL_0) +#define MX23_PAD_AUART1_RX__AUART1_RX MXS_IOMUX_PAD_NAKED(0, 28, PAD_MUXSEL_0) +#define MX23_PAD_AUART1_TX__AUART1_TX MXS_IOMUX_PAD_NAKED(0, 29, PAD_MUXSEL_0) +#define MX23_PAD_I2C_SCL__I2C_SCL MXS_IOMUX_PAD_NAKED(0, 30, PAD_MUXSEL_0) +#define MX23_PAD_I2C_SDA__I2C_SDA MXS_IOMUX_PAD_NAKED(0, 31, PAD_MUXSEL_0) + +#define MX23_PAD_LCD_D00__LCD_D00 MXS_IOMUX_PAD_NAKED(1, 0, PAD_MUXSEL_0) +#define MX23_PAD_LCD_D01__LCD_D01 MXS_IOMUX_PAD_NAKED(1, 1, PAD_MUXSEL_0) +#define MX23_PAD_LCD_D02__LCD_D02 MXS_IOMUX_PAD_NAKED(1, 2, PAD_MUXSEL_0) +#define MX23_PAD_LCD_D03__LCD_D03 MXS_IOMUX_PAD_NAKED(1, 3, PAD_MUXSEL_0) +#define MX23_PAD_LCD_D04__LCD_D04 MXS_IOMUX_PAD_NAKED(1, 4, PAD_MUXSEL_0) +#define MX23_PAD_LCD_D05__LCD_D05 MXS_IOMUX_PAD_NAKED(1, 5, PAD_MUXSEL_0) +#define MX23_PAD_LCD_D06__LCD_D06 MXS_IOMUX_PAD_NAKED(1, 6, PAD_MUXSEL_0) +#define MX23_PAD_LCD_D07__LCD_D07 MXS_IOMUX_PAD_NAKED(1, 7, PAD_MUXSEL_0) +#define MX23_PAD_LCD_D08__LCD_D08 MXS_IOMUX_PAD_NAKED(1, 8, PAD_MUXSEL_0) +#define MX23_PAD_LCD_D09__LCD_D09 MXS_IOMUX_PAD_NAKED(1, 9, PAD_MUXSEL_0) +#define MX23_PAD_LCD_D10__LCD_D10 MXS_IOMUX_PAD_NAKED(1, 10, PAD_MUXSEL_0) +#define MX23_PAD_LCD_D11__LCD_D11 MXS_IOMUX_PAD_NAKED(1, 11, PAD_MUXSEL_0) +#define MX23_PAD_LCD_D12__LCD_D12 MXS_IOMUX_PAD_NAKED(1, 12, PAD_MUXSEL_0) +#define MX23_PAD_LCD_D13__LCD_D13 MXS_IOMUX_PAD_NAKED(1, 13, PAD_MUXSEL_0) +#define MX23_PAD_LCD_D14__LCD_D14 MXS_IOMUX_PAD_NAKED(1, 14, PAD_MUXSEL_0) +#define MX23_PAD_LCD_D15__LCD_D15 MXS_IOMUX_PAD_NAKED(1, 15, PAD_MUXSEL_0) +#define MX23_PAD_LCD_D16__LCD_D16 MXS_IOMUX_PAD_NAKED(1, 16, PAD_MUXSEL_0) +#define MX23_PAD_LCD_D17__LCD_D17 MXS_IOMUX_PAD_NAKED(1, 17, PAD_MUXSEL_0) +#define MX23_PAD_LCD_RESET__LCD_RESET MXS_IOMUX_PAD_NAKED(1, 18, PAD_MUXSEL_0) +#define MX23_PAD_LCD_RS__LCD_RS MXS_IOMUX_PAD_NAKED(1, 19, PAD_MUXSEL_0) +#define MX23_PAD_LCD_WR__LCD_WR MXS_IOMUX_PAD_NAKED(1, 20, PAD_MUXSEL_0) +#define MX23_PAD_LCD_CS__LCD_CS MXS_IOMUX_PAD_NAKED(1, 21, PAD_MUXSEL_0) +#define MX23_PAD_LCD_DOTCK__LCD_DOTCK MXS_IOMUX_PAD_NAKED(1, 22, PAD_MUXSEL_0) +#define MX23_PAD_LCD_ENABLE__LCD_ENABLE MXS_IOMUX_PAD_NAKED(1, 23, PAD_MUXSEL_0) +#define MX23_PAD_LCD_HSYNC__LCD_HSYNC MXS_IOMUX_PAD_NAKED(1, 24, PAD_MUXSEL_0) +#define MX23_PAD_LCD_VSYNC__LCD_VSYNC MXS_IOMUX_PAD_NAKED(1, 25, PAD_MUXSEL_0) +#define MX23_PAD_PWM0__PWM0 MXS_IOMUX_PAD_NAKED(1, 26, PAD_MUXSEL_0) +#define MX23_PAD_PWM1__PWM1 MXS_IOMUX_PAD_NAKED(1, 27, PAD_MUXSEL_0) +#define MX23_PAD_PWM2__PWM2 MXS_IOMUX_PAD_NAKED(1, 28, PAD_MUXSEL_0) +#define MX23_PAD_PWM3__PWM3 MXS_IOMUX_PAD_NAKED(1, 29, PAD_MUXSEL_0) +#define MX23_PAD_PWM4__PWM4 MXS_IOMUX_PAD_NAKED(1, 30, PAD_MUXSEL_0) + +#define MX23_PAD_SSP1_CMD__SSP1_CMD MXS_IOMUX_PAD_NAKED(2, 0, PAD_MUXSEL_0) +#define MX23_PAD_SSP1_DETECT__SSP1_DETECT MXS_IOMUX_PAD_NAKED(2, 1, PAD_MUXSEL_0) +#define MX23_PAD_SSP1_DATA0__SSP1_DATA0 MXS_IOMUX_PAD_NAKED(2, 2, PAD_MUXSEL_0) +#define MX23_PAD_SSP1_DATA1__SSP1_DATA1 MXS_IOMUX_PAD_NAKED(2, 3, PAD_MUXSEL_0) +#define MX23_PAD_SSP1_DATA2__SSP1_DATA2 MXS_IOMUX_PAD_NAKED(2, 4, PAD_MUXSEL_0) +#define MX23_PAD_SSP1_DATA3__SSP1_DATA3 MXS_IOMUX_PAD_NAKED(2, 5, PAD_MUXSEL_0) +#define MX23_PAD_SSP1_SCK__SSP1_SCK MXS_IOMUX_PAD_NAKED(2, 6, PAD_MUXSEL_0) +#define MX23_PAD_ROTARYA__ROTARYA MXS_IOMUX_PAD_NAKED(2, 7, PAD_MUXSEL_0) +#define MX23_PAD_ROTARYB__ROTARYB MXS_IOMUX_PAD_NAKED(2, 8, PAD_MUXSEL_0) +#define MX23_PAD_EMI_A00__EMI_A00 MXS_IOMUX_PAD_NAKED(2, 9, PAD_MUXSEL_0) +#define MX23_PAD_EMI_A01__EMI_A01 MXS_IOMUX_PAD_NAKED(2, 10, PAD_MUXSEL_0) +#define MX23_PAD_EMI_A02__EMI_A02 MXS_IOMUX_PAD_NAKED(2, 11, PAD_MUXSEL_0) +#define MX23_PAD_EMI_A03__EMI_A03 MXS_IOMUX_PAD_NAKED(2, 12, PAD_MUXSEL_0) +#define MX23_PAD_EMI_A04__EMI_A04 MXS_IOMUX_PAD_NAKED(2, 13, PAD_MUXSEL_0) +#define MX23_PAD_EMI_A05__EMI_A05 MXS_IOMUX_PAD_NAKED(2, 14, PAD_MUXSEL_0) +#define MX23_PAD_EMI_A06__EMI_A06 MXS_IOMUX_PAD_NAKED(2, 15, PAD_MUXSEL_0) +#define MX23_PAD_EMI_A07__EMI_A07 MXS_IOMUX_PAD_NAKED(2, 16, PAD_MUXSEL_0) +#define MX23_PAD_EMI_A08__EMI_A08 MXS_IOMUX_PAD_NAKED(2, 17, PAD_MUXSEL_0) +#define MX23_PAD_EMI_A09__EMI_A09 MXS_IOMUX_PAD_NAKED(2, 18, PAD_MUXSEL_0) +#define MX23_PAD_EMI_A10__EMI_A10 MXS_IOMUX_PAD_NAKED(2, 19, PAD_MUXSEL_0) +#define MX23_PAD_EMI_A11__EMI_A11 MXS_IOMUX_PAD_NAKED(2, 20, PAD_MUXSEL_0) +#define MX23_PAD_EMI_A12__EMI_A12 MXS_IOMUX_PAD_NAKED(2, 21, PAD_MUXSEL_0) +#define MX23_PAD_EMI_BA0__EMI_BA0 MXS_IOMUX_PAD_NAKED(2, 22, PAD_MUXSEL_0) +#define MX23_PAD_EMI_BA1__EMI_BA1 MXS_IOMUX_PAD_NAKED(2, 23, PAD_MUXSEL_0) +#define MX23_PAD_EMI_CASN__EMI_CASN MXS_IOMUX_PAD_NAKED(2, 24, PAD_MUXSEL_0) +#define MX23_PAD_EMI_CE0N__EMI_CE0N MXS_IOMUX_PAD_NAKED(2, 25, PAD_MUXSEL_0) +#define MX23_PAD_EMI_CE1N__EMI_CE1N MXS_IOMUX_PAD_NAKED(2, 26, PAD_MUXSEL_0) +#define MX23_PAD_GPMI_CE1N__GPMI_CE1N MXS_IOMUX_PAD_NAKED(2, 27, PAD_MUXSEL_0) +#define MX23_PAD_GPMI_CE0N__GPMI_CE0N MXS_IOMUX_PAD_NAKED(2, 28, PAD_MUXSEL_0) +#define MX23_PAD_EMI_CKE__EMI_CKE MXS_IOMUX_PAD_NAKED(2, 29, PAD_MUXSEL_0) +#define MX23_PAD_EMI_RASN__EMI_RASN MXS_IOMUX_PAD_NAKED(2, 30, PAD_MUXSEL_0) +#define MX23_PAD_EMI_WEN__EMI_WEN MXS_IOMUX_PAD_NAKED(2, 31, PAD_MUXSEL_0) + +#define MX23_PAD_EMI_D00__EMI_D00 MXS_IOMUX_PAD_NAKED(3, 0, PAD_MUXSEL_0) +#define MX23_PAD_EMI_D01__EMI_D01 MXS_IOMUX_PAD_NAKED(3, 1, PAD_MUXSEL_0) +#define MX23_PAD_EMI_D02__EMI_D02 MXS_IOMUX_PAD_NAKED(3, 2, PAD_MUXSEL_0) +#define MX23_PAD_EMI_D03__EMI_D03 MXS_IOMUX_PAD_NAKED(3, 3, PAD_MUXSEL_0) +#define MX23_PAD_EMI_D04__EMI_D04 MXS_IOMUX_PAD_NAKED(3, 4, PAD_MUXSEL_0) +#define MX23_PAD_EMI_D05__EMI_D05 MXS_IOMUX_PAD_NAKED(3, 5, PAD_MUXSEL_0) +#define MX23_PAD_EMI_D06__EMI_D06 MXS_IOMUX_PAD_NAKED(3, 6, PAD_MUXSEL_0) +#define MX23_PAD_EMI_D07__EMI_D07 MXS_IOMUX_PAD_NAKED(3, 7, PAD_MUXSEL_0) +#define MX23_PAD_EMI_D08__EMI_D08 MXS_IOMUX_PAD_NAKED(3, 8, PAD_MUXSEL_0) +#define MX23_PAD_EMI_D09__EMI_D09 MXS_IOMUX_PAD_NAKED(3, 9, PAD_MUXSEL_0) +#define MX23_PAD_EMI_D10__EMI_D10 MXS_IOMUX_PAD_NAKED(3, 10, PAD_MUXSEL_0) +#define MX23_PAD_EMI_D11__EMI_D11 MXS_IOMUX_PAD_NAKED(3, 11, PAD_MUXSEL_0) +#define MX23_PAD_EMI_D12__EMI_D12 MXS_IOMUX_PAD_NAKED(3, 12, PAD_MUXSEL_0) +#define MX23_PAD_EMI_D13__EMI_D13 MXS_IOMUX_PAD_NAKED(3, 13, PAD_MUXSEL_0) +#define MX23_PAD_EMI_D14__EMI_D14 MXS_IOMUX_PAD_NAKED(3, 14, PAD_MUXSEL_0) +#define MX23_PAD_EMI_D15__EMI_D15 MXS_IOMUX_PAD_NAKED(3, 15, PAD_MUXSEL_0) +#define MX23_PAD_EMI_DQM0__EMI_DQM0 MXS_IOMUX_PAD_NAKED(3, 16, PAD_MUXSEL_0) +#define MX23_PAD_EMI_DQM1__EMI_DQM1 MXS_IOMUX_PAD_NAKED(3, 17, PAD_MUXSEL_0) +#define MX23_PAD_EMI_DQS0__EMI_DQS0 MXS_IOMUX_PAD_NAKED(3, 18, PAD_MUXSEL_0) +#define MX23_PAD_EMI_DQS1__EMI_DQS1 MXS_IOMUX_PAD_NAKED(3, 19, PAD_MUXSEL_0) +#define MX23_PAD_EMI_CLK__EMI_CLK MXS_IOMUX_PAD_NAKED(3, 20, PAD_MUXSEL_0) +#define MX23_PAD_EMI_CLKN__EMI_CLKN MXS_IOMUX_PAD_NAKED(3, 21, PAD_MUXSEL_0) + +/* MUXSEL_1 */ +#define MX23_PAD_GPMI_D00__LCD_D8 MXS_IOMUX_PAD_NAKED(0, 0, PAD_MUXSEL_1) +#define MX23_PAD_GPMI_D01__LCD_D9 MXS_IOMUX_PAD_NAKED(0, 1, PAD_MUXSEL_1) +#define MX23_PAD_GPMI_D02__LCD_D10 MXS_IOMUX_PAD_NAKED(0, 2, PAD_MUXSEL_1) +#define MX23_PAD_GPMI_D03__LCD_D11 MXS_IOMUX_PAD_NAKED(0, 3, PAD_MUXSEL_1) +#define MX23_PAD_GPMI_D04__LCD_D12 MXS_IOMUX_PAD_NAKED(0, 4, PAD_MUXSEL_1) +#define MX23_PAD_GPMI_D05__LCD_D13 MXS_IOMUX_PAD_NAKED(0, 5, PAD_MUXSEL_1) +#define MX23_PAD_GPMI_D06__LCD_D14 MXS_IOMUX_PAD_NAKED(0, 6, PAD_MUXSEL_1) +#define MX23_PAD_GPMI_D07__LCD_D15 MXS_IOMUX_PAD_NAKED(0, 7, PAD_MUXSEL_1) +#define MX23_PAD_GPMI_D08__LCD_D18 MXS_IOMUX_PAD_NAKED(0, 8, PAD_MUXSEL_1) +#define MX23_PAD_GPMI_D09__LCD_D19 MXS_IOMUX_PAD_NAKED(0, 9, PAD_MUXSEL_1) +#define MX23_PAD_GPMI_D10__LCD_D20 MXS_IOMUX_PAD_NAKED(0, 10, PAD_MUXSEL_1) +#define MX23_PAD_GPMI_D11__LCD_D21 MXS_IOMUX_PAD_NAKED(0, 11, PAD_MUXSEL_1) +#define MX23_PAD_GPMI_D12__LCD_D22 MXS_IOMUX_PAD_NAKED(0, 12, PAD_MUXSEL_1) +#define MX23_PAD_GPMI_D13__LCD_D23 MXS_IOMUX_PAD_NAKED(0, 13, PAD_MUXSEL_1) +#define MX23_PAD_GPMI_D14__AUART2_RX MXS_IOMUX_PAD_NAKED(0, 14, PAD_MUXSEL_1) +#define MX23_PAD_GPMI_D15__AUART2_TX MXS_IOMUX_PAD_NAKED(0, 15, PAD_MUXSEL_1) +#define MX23_PAD_GPMI_CLE__LCD_D16 MXS_IOMUX_PAD_NAKED(0, 16, PAD_MUXSEL_1) +#define MX23_PAD_GPMI_ALE__LCD_D17 MXS_IOMUX_PAD_NAKED(0, 17, PAD_MUXSEL_1) +#define MX23_PAD_GPMI_CE2N__ATA_A2 MXS_IOMUX_PAD_NAKED(0, 18, PAD_MUXSEL_1) +#define MX23_PAD_AUART1_RTS__IR_CLK MXS_IOMUX_PAD_NAKED(0, 27, PAD_MUXSEL_1) +#define MX23_PAD_AUART1_RX__IR_RX MXS_IOMUX_PAD_NAKED(0, 28, PAD_MUXSEL_1) +#define MX23_PAD_AUART1_TX__IR_TX MXS_IOMUX_PAD_NAKED(0, 29, PAD_MUXSEL_1) +#define MX23_PAD_I2C_SCL__GPMI_RDY2 MXS_IOMUX_PAD_NAKED(0, 30, PAD_MUXSEL_1) +#define MX23_PAD_I2C_SDA__GPMI_CE2N MXS_IOMUX_PAD_NAKED(0, 31, PAD_MUXSEL_1) + +#define MX23_PAD_LCD_D00__ETM_DA8 MXS_IOMUX_PAD_NAKED(1, 0, PAD_MUXSEL_1) +#define MX23_PAD_LCD_D01__ETM_DA9 MXS_IOMUX_PAD_NAKED(1, 1, PAD_MUXSEL_1) +#define MX23_PAD_LCD_D02__ETM_DA10 MXS_IOMUX_PAD_NAKED(1, 2, PAD_MUXSEL_1) +#define MX23_PAD_LCD_D03__ETM_DA11 MXS_IOMUX_PAD_NAKED(1, 3, PAD_MUXSEL_1) +#define MX23_PAD_LCD_D04__ETM_DA12 MXS_IOMUX_PAD_NAKED(1, 4, PAD_MUXSEL_1) +#define MX23_PAD_LCD_D05__ETM_DA13 MXS_IOMUX_PAD_NAKED(1, 5, PAD_MUXSEL_1) +#define MX23_PAD_LCD_D06__ETM_DA14 MXS_IOMUX_PAD_NAKED(1, 6, PAD_MUXSEL_1) +#define MX23_PAD_LCD_D07__ETM_DA15 MXS_IOMUX_PAD_NAKED(1, 7, PAD_MUXSEL_1) +#define MX23_PAD_LCD_D08__ETM_DA0 MXS_IOMUX_PAD_NAKED(1, 8, PAD_MUXSEL_1) +#define MX23_PAD_LCD_D09__ETM_DA1 MXS_IOMUX_PAD_NAKED(1, 9, PAD_MUXSEL_1) +#define MX23_PAD_LCD_D10__ETM_DA2 MXS_IOMUX_PAD_NAKED(1, 10, PAD_MUXSEL_1) +#define MX23_PAD_LCD_D11__ETM_DA3 MXS_IOMUX_PAD_NAKED(1, 11, PAD_MUXSEL_1) +#define MX23_PAD_LCD_D12__ETM_DA4 MXS_IOMUX_PAD_NAKED(1, 12, PAD_MUXSEL_1) +#define MX23_PAD_LCD_D13__ETM_DA5 MXS_IOMUX_PAD_NAKED(1, 13, PAD_MUXSEL_1) +#define MX23_PAD_LCD_D14__ETM_DA6 MXS_IOMUX_PAD_NAKED(1, 14, PAD_MUXSEL_1) +#define MX23_PAD_LCD_D15__ETM_DA7 MXS_IOMUX_PAD_NAKED(1, 15, PAD_MUXSEL_1) +#define MX23_PAD_LCD_RESET__ETM_TCTL MXS_IOMUX_PAD_NAKED(1, 18, PAD_MUXSEL_1) +#define MX23_PAD_LCD_RS__ETM_TCLK MXS_IOMUX_PAD_NAKED(1, 19, PAD_MUXSEL_1) +#define MX23_PAD_LCD_DOTCK__GPMI_RDY3 MXS_IOMUX_PAD_NAKED(1, 22, PAD_MUXSEL_1) +#define MX23_PAD_LCD_ENABLE__I2C_SCL MXS_IOMUX_PAD_NAKED(1, 23, PAD_MUXSEL_1) +#define MX23_PAD_LCD_HSYNC__I2C_SDA MXS_IOMUX_PAD_NAKED(1, 24, PAD_MUXSEL_1) +#define MX23_PAD_LCD_VSYNC__LCD_BUSY MXS_IOMUX_PAD_NAKED(1, 25, PAD_MUXSEL_1) +#define MX23_PAD_PWM0__ROTARYA MXS_IOMUX_PAD_NAKED(1, 26, PAD_MUXSEL_1) +#define MX23_PAD_PWM1__ROTARYB MXS_IOMUX_PAD_NAKED(1, 27, PAD_MUXSEL_1) +#define MX23_PAD_PWM2__GPMI_RDY3 MXS_IOMUX_PAD_NAKED(1, 28, PAD_MUXSEL_1) +#define MX23_PAD_PWM3__ETM_TCTL MXS_IOMUX_PAD_NAKED(1, 29, PAD_MUXSEL_1) +#define MX23_PAD_PWM4__ETM_TCLK MXS_IOMUX_PAD_NAKED(1, 30, PAD_MUXSEL_1) + +#define MX23_PAD_SSP1_DETECT__GPMI_CE3N MXS_IOMUX_PAD_NAKED(2, 1, PAD_MUXSEL_1) +#define MX23_PAD_SSP1_DATA1__I2C_SCL MXS_IOMUX_PAD_NAKED(2, 3, PAD_MUXSEL_1) +#define MX23_PAD_SSP1_DATA2__I2C_SDA MXS_IOMUX_PAD_NAKED(2, 4, PAD_MUXSEL_1) +#define MX23_PAD_ROTARYA__AUART2_RTS MXS_IOMUX_PAD_NAKED(2, 7, PAD_MUXSEL_1) +#define MX23_PAD_ROTARYB__AUART2_CTS MXS_IOMUX_PAD_NAKED(2, 8, PAD_MUXSEL_1) + +/* MUXSEL_2 */ +#define MX23_PAD_GPMI_D00__SSP2_DATA0 MXS_IOMUX_PAD_NAKED(0, 0, PAD_MUXSEL_2) +#define MX23_PAD_GPMI_D01__SSP2_DATA1 MXS_IOMUX_PAD_NAKED(0, 1, PAD_MUXSEL_2) +#define MX23_PAD_GPMI_D02__SSP2_DATA2 MXS_IOMUX_PAD_NAKED(0, 2, PAD_MUXSEL_2) +#define MX23_PAD_GPMI_D03__SSP2_DATA3 MXS_IOMUX_PAD_NAKED(0, 3, PAD_MUXSEL_2) +#define MX23_PAD_GPMI_D04__SSP2_DATA4 MXS_IOMUX_PAD_NAKED(0, 4, PAD_MUXSEL_2) +#define MX23_PAD_GPMI_D05__SSP2_DATA5 MXS_IOMUX_PAD_NAKED(0, 5, PAD_MUXSEL_2) +#define MX23_PAD_GPMI_D06__SSP2_DATA6 MXS_IOMUX_PAD_NAKED(0, 6, PAD_MUXSEL_2) +#define MX23_PAD_GPMI_D07__SSP2_DATA7 MXS_IOMUX_PAD_NAKED(0, 7, PAD_MUXSEL_2) +#define MX23_PAD_GPMI_D08__SSP1_DATA4 MXS_IOMUX_PAD_NAKED(0, 8, PAD_MUXSEL_2) +#define MX23_PAD_GPMI_D09__SSP1_DATA5 MXS_IOMUX_PAD_NAKED(0, 9, PAD_MUXSEL_2) +#define MX23_PAD_GPMI_D10__SSP1_DATA6 MXS_IOMUX_PAD_NAKED(0, 10, PAD_MUXSEL_2) +#define MX23_PAD_GPMI_D11__SSP1_DATA7 MXS_IOMUX_PAD_NAKED(0, 11, PAD_MUXSEL_2) +#define MX23_PAD_GPMI_D15__GPMI_CE3N MXS_IOMUX_PAD_NAKED(0, 15, PAD_MUXSEL_2) +#define MX23_PAD_GPMI_RDY0__SSP2_DETECT MXS_IOMUX_PAD_NAKED(0, 19, PAD_MUXSEL_2) +#define MX23_PAD_GPMI_RDY1__SSP2_CMD MXS_IOMUX_PAD_NAKED(0, 20, PAD_MUXSEL_2) +#define MX23_PAD_GPMI_WRN__SSP2_SCK MXS_IOMUX_PAD_NAKED(0, 24, PAD_MUXSEL_2) +#define MX23_PAD_AUART1_CTS__SSP1_DATA4 MXS_IOMUX_PAD_NAKED(0, 26, PAD_MUXSEL_2) +#define MX23_PAD_AUART1_RTS__SSP1_DATA5 MXS_IOMUX_PAD_NAKED(0, 27, PAD_MUXSEL_2) +#define MX23_PAD_AUART1_RX__SSP1_DATA6 MXS_IOMUX_PAD_NAKED(0, 28, PAD_MUXSEL_2) +#define MX23_PAD_AUART1_TX__SSP1_DATA7 MXS_IOMUX_PAD_NAKED(0, 29, PAD_MUXSEL_2) +#define MX23_PAD_I2C_SCL__AUART1_TX MXS_IOMUX_PAD_NAKED(0, 30, PAD_MUXSEL_2) +#define MX23_PAD_I2C_SDA__AUART1_RX MXS_IOMUX_PAD_NAKED(0, 31, PAD_MUXSEL_2) + +#define MX23_PAD_LCD_D08__SAIF2_SDATA0 MXS_IOMUX_PAD_NAKED(1, 8, PAD_MUXSEL_2) +#define MX23_PAD_LCD_D09__SAIF1_SDATA0 MXS_IOMUX_PAD_NAKED(1, 9, PAD_MUXSEL_2) +#define MX23_PAD_LCD_D10__SAIF_MCLK_BITCLK MXS_IOMUX_PAD_NAKED(1, 10, PAD_MUXSEL_2) +#define MX23_PAD_LCD_D11__SAIF_LRCLK MXS_IOMUX_PAD_NAKED(1, 11, PAD_MUXSEL_2) +#define MX23_PAD_LCD_D12__SAIF2_SDATA1 MXS_IOMUX_PAD_NAKED(1, 12, PAD_MUXSEL_2) +#define MX23_PAD_LCD_D13__SAIF2_SDATA2 MXS_IOMUX_PAD_NAKED(1, 13, PAD_MUXSEL_2) +#define MX23_PAD_LCD_D14__SAIF1_SDATA2 MXS_IOMUX_PAD_NAKED(1, 14, PAD_MUXSEL_2) +#define MX23_PAD_LCD_D15__SAIF1_SDATA1 MXS_IOMUX_PAD_NAKED(1, 15, PAD_MUXSEL_2) +#define MX23_PAD_LCD_D16__SAIF_ALT_BITCLK MXS_IOMUX_PAD_NAKED(1, 16, PAD_MUXSEL_2) +#define MX23_PAD_LCD_RESET__GPMI_CE3N MXS_IOMUX_PAD_NAKED(1, 18, PAD_MUXSEL_2) +#define MX23_PAD_PWM0__DUART_RX MXS_IOMUX_PAD_NAKED(1, 26, PAD_MUXSEL_2) +#define MX23_PAD_PWM1__DUART_TX MXS_IOMUX_PAD_NAKED(1, 27, PAD_MUXSEL_2) +#define MX23_PAD_PWM3__AUART1_CTS MXS_IOMUX_PAD_NAKED(1, 29, PAD_MUXSEL_2) +#define MX23_PAD_PWM4__AUART1_RTS MXS_IOMUX_PAD_NAKED(1, 30, PAD_MUXSEL_2) + +#define MX23_PAD_SSP1_CMD__JTAG_TDO MXS_IOMUX_PAD_NAKED(2, 0, PAD_MUXSEL_2) +#define MX23_PAD_SSP1_DETECT__USB_OTG_ID MXS_IOMUX_PAD_NAKED(2, 1, PAD_MUXSEL_2) +#define MX23_PAD_SSP1_DATA0__JTAG_TDI MXS_IOMUX_PAD_NAKED(2, 2, PAD_MUXSEL_2) +#define MX23_PAD_SSP1_DATA1__JTAG_TCLK MXS_IOMUX_PAD_NAKED(2, 3, PAD_MUXSEL_2) +#define MX23_PAD_SSP1_DATA2__JTAG_RTCK MXS_IOMUX_PAD_NAKED(2, 4, PAD_MUXSEL_2) +#define MX23_PAD_SSP1_DATA3__JTAG_TMS MXS_IOMUX_PAD_NAKED(2, 5, PAD_MUXSEL_2) +#define MX23_PAD_SSP1_SCK__JTAG_TRST MXS_IOMUX_PAD_NAKED(2, 6, PAD_MUXSEL_2) +#define MX23_PAD_ROTARYA__SPDIF MXS_IOMUX_PAD_NAKED(2, 7, PAD_MUXSEL_2) +#define MX23_PAD_ROTARYB__GPMI_CE3N MXS_IOMUX_PAD_NAKED(2, 8, PAD_MUXSEL_2) + +/* MUXSEL_GPIO */ +#define MX23_PAD_GPMI_D00__GPO_0_0 MXS_IOMUX_PAD_NAKED(0, 0, PAD_MUXSEL_GPIO) +#define MX23_PAD_GPMI_D01__GPO_0_1 MXS_IOMUX_PAD_NAKED(0, 1, PAD_MUXSEL_GPIO) +#define MX23_PAD_GPMI_D02__GPO_0_2 MXS_IOMUX_PAD_NAKED(0, 2, PAD_MUXSEL_GPIO) +#define MX23_PAD_GPMI_D03__GPO_0_3 MXS_IOMUX_PAD_NAKED(0, 3, PAD_MUXSEL_GPIO) +#define MX23_PAD_GPMI_D04__GPO_0_4 MXS_IOMUX_PAD_NAKED(0, 4, PAD_MUXSEL_GPIO) +#define MX23_PAD_GPMI_D05__GPO_0_5 MXS_IOMUX_PAD_NAKED(0, 5, PAD_MUXSEL_GPIO) +#define MX23_PAD_GPMI_D06__GPO_0_6 MXS_IOMUX_PAD_NAKED(0, 6, PAD_MUXSEL_GPIO) +#define MX23_PAD_GPMI_D07__GPO_0_7 MXS_IOMUX_PAD_NAKED(0, 7, PAD_MUXSEL_GPIO) +#define MX23_PAD_GPMI_D08__GPO_0_8 MXS_IOMUX_PAD_NAKED(0, 8, PAD_MUXSEL_GPIO) +#define MX23_PAD_GPMI_D09__GPO_0_9 MXS_IOMUX_PAD_NAKED(0, 9, PAD_MUXSEL_GPIO) +#define MX23_PAD_GPMI_D10__GPO_0_10 MXS_IOMUX_PAD_NAKED(0, 10, PAD_MUXSEL_GPIO) +#define MX23_PAD_GPMI_D11__GPO_0_11 MXS_IOMUX_PAD_NAKED(0, 11, PAD_MUXSEL_GPIO) +#define MX23_PAD_GPMI_D12__GPO_0_12 MXS_IOMUX_PAD_NAKED(0, 12, PAD_MUXSEL_GPIO) +#define MX23_PAD_GPMI_D13__GPO_0_13 MXS_IOMUX_PAD_NAKED(0, 13, PAD_MUXSEL_GPIO) +#define MX23_PAD_GPMI_D14__GPO_0_14 MXS_IOMUX_PAD_NAKED(0, 14, PAD_MUXSEL_GPIO) +#define MX23_PAD_GPMI_D15__GPO_0_15 MXS_IOMUX_PAD_NAKED(0, 15, PAD_MUXSEL_GPIO) +#define MX23_PAD_GPMI_CLE__GPO_0_16 MXS_IOMUX_PAD_NAKED(0, 16, PAD_MUXSEL_GPIO) +#define MX23_PAD_GPMI_ALE__GPO_0_17 MXS_IOMUX_PAD_NAKED(0, 17, PAD_MUXSEL_GPIO) +#define MX23_PAD_GPMI_CE2N__GPO_0_18 MXS_IOMUX_PAD_NAKED(0, 18, PAD_MUXSEL_GPIO) +#define MX23_PAD_GPMI_RDY0__GPO_0_19 MXS_IOMUX_PAD_NAKED(0, 19, PAD_MUXSEL_GPIO) +#define MX23_PAD_GPMI_RDY1__GPO_0_20 MXS_IOMUX_PAD_NAKED(0, 20, PAD_MUXSEL_GPIO) +#define MX23_PAD_GPMI_RDY2__GPO_0_21 MXS_IOMUX_PAD_NAKED(0, 21, PAD_MUXSEL_GPIO) +#define MX23_PAD_GPMI_RDY3__GPO_0_22 MXS_IOMUX_PAD_NAKED(0, 22, PAD_MUXSEL_GPIO) +#define MX23_PAD_GPMI_WPN__GPO_0_23 MXS_IOMUX_PAD_NAKED(0, 23, PAD_MUXSEL_GPIO) +#define MX23_PAD_GPMI_WRN__GPO_0_24 MXS_IOMUX_PAD_NAKED(0, 24, PAD_MUXSEL_GPIO) +#define MX23_PAD_GPMI_RDN__GPO_0_25 MXS_IOMUX_PAD_NAKED(0, 25, PAD_MUXSEL_GPIO) +#define MX23_PAD_AUART1_CTS__GPO_0_26 MXS_IOMUX_PAD_NAKED(0, 26, PAD_MUXSEL_GPIO) +#define MX23_PAD_AUART1_RTS__GPO_0_27 MXS_IOMUX_PAD_NAKED(0, 27, PAD_MUXSEL_GPIO) +#define MX23_PAD_AUART1_RX__GPO_0_28 MXS_IOMUX_PAD_NAKED(0, 28, PAD_MUXSEL_GPIO) +#define MX23_PAD_AUART1_TX__GPO_0_29 MXS_IOMUX_PAD_NAKED(0, 29, PAD_MUXSEL_GPIO) +#define MX23_PAD_I2C_SCL__GPO_0_30 MXS_IOMUX_PAD_NAKED(0, 30, PAD_MUXSEL_GPIO) +#define MX23_PAD_I2C_SDA__GPO_0_31 MXS_IOMUX_PAD_NAKED(0, 31, PAD_MUXSEL_GPIO) + +#define MX23_PAD_LCD_D00__GPO_1_0 MXS_IOMUX_PAD_NAKED(1, 0, PAD_MUXSEL_GPIO) +#define MX23_PAD_LCD_D01__GPO_1_1 MXS_IOMUX_PAD_NAKED(1, 1, PAD_MUXSEL_GPIO) +#define MX23_PAD_LCD_D02__GPO_1_2 MXS_IOMUX_PAD_NAKED(1, 2, PAD_MUXSEL_GPIO) +#define MX23_PAD_LCD_D03__GPO_1_3 MXS_IOMUX_PAD_NAKED(1, 3, PAD_MUXSEL_GPIO) +#define MX23_PAD_LCD_D04__GPO_1_4 MXS_IOMUX_PAD_NAKED(1, 4, PAD_MUXSEL_GPIO) +#define MX23_PAD_LCD_D05__GPO_1_5 MXS_IOMUX_PAD_NAKED(1, 5, PAD_MUXSEL_GPIO) +#define MX23_PAD_LCD_D06__GPO_1_6 MXS_IOMUX_PAD_NAKED(1, 6, PAD_MUXSEL_GPIO) +#define MX23_PAD_LCD_D07__GPO_1_7 MXS_IOMUX_PAD_NAKED(1, 7, PAD_MUXSEL_GPIO) +#define MX23_PAD_LCD_D08__GPO_1_8 MXS_IOMUX_PAD_NAKED(1, 8, PAD_MUXSEL_GPIO) +#define MX23_PAD_LCD_D09__GPO_1_9 MXS_IOMUX_PAD_NAKED(1, 9, PAD_MUXSEL_GPIO) +#define MX23_PAD_LCD_D10__GPO_1_10 MXS_IOMUX_PAD_NAKED(1, 10, PAD_MUXSEL_GPIO) +#define MX23_PAD_LCD_D11__GPO_1_11 MXS_IOMUX_PAD_NAKED(1, 11, PAD_MUXSEL_GPIO) +#define MX23_PAD_LCD_D12__GPO_1_12 MXS_IOMUX_PAD_NAKED(1, 12, PAD_MUXSEL_GPIO) +#define MX23_PAD_LCD_D13__GPO_1_13 MXS_IOMUX_PAD_NAKED(1, 13, PAD_MUXSEL_GPIO) +#define MX23_PAD_LCD_D14__GPO_1_14 MXS_IOMUX_PAD_NAKED(1, 14, PAD_MUXSEL_GPIO) +#define MX23_PAD_LCD_D15__GPO_1_15 MXS_IOMUX_PAD_NAKED(1, 15, PAD_MUXSEL_GPIO) +#define MX23_PAD_LCD_D16__GPO_1_16 MXS_IOMUX_PAD_NAKED(1, 16, PAD_MUXSEL_GPIO) +#define MX23_PAD_LCD_D17__GPO_1_17 MXS_IOMUX_PAD_NAKED(1, 17, PAD_MUXSEL_GPIO) +#define MX23_PAD_LCD_RESET__GPO_1_18 MXS_IOMUX_PAD_NAKED(1, 18, PAD_MUXSEL_GPIO) +#define MX23_PAD_LCD_RS__GPO_1_19 MXS_IOMUX_PAD_NAKED(1, 19, PAD_MUXSEL_GPIO) +#define MX23_PAD_LCD_WR__GPO_1_20 MXS_IOMUX_PAD_NAKED(1, 20, PAD_MUXSEL_GPIO) +#define MX23_PAD_LCD_CS__GPO_1_21 MXS_IOMUX_PAD_NAKED(1, 21, PAD_MUXSEL_GPIO) +#define MX23_PAD_LCD_DOTCK__GPO_1_22 MXS_IOMUX_PAD_NAKED(1, 22, PAD_MUXSEL_GPIO) +#define MX23_PAD_LCD_ENABLE__GPO_1_23 MXS_IOMUX_PAD_NAKED(1, 23, PAD_MUXSEL_GPIO) +#define MX23_PAD_LCD_HSYNC__GPO_1_24 MXS_IOMUX_PAD_NAKED(1, 24, PAD_MUXSEL_GPIO) +#define MX23_PAD_LCD_VSYNC__GPO_1_25 MXS_IOMUX_PAD_NAKED(1, 25, PAD_MUXSEL_GPIO) +#define MX23_PAD_PWM0__GPO_1_26 MXS_IOMUX_PAD_NAKED(1, 26, PAD_MUXSEL_GPIO) +#define MX23_PAD_PWM1__GPO_1_27 MXS_IOMUX_PAD_NAKED(1, 27, PAD_MUXSEL_GPIO) +#define MX23_PAD_PWM2__GPO_1_28 MXS_IOMUX_PAD_NAKED(1, 28, PAD_MUXSEL_GPIO) +#define MX23_PAD_PWM3__GPO_1_29 MXS_IOMUX_PAD_NAKED(1, 29, PAD_MUXSEL_GPIO) +#define MX23_PAD_PWM4__GPO_1_30 MXS_IOMUX_PAD_NAKED(1, 30, PAD_MUXSEL_GPIO) + +#define MX23_PAD_SSP1_CMD__GPO_2_0 MXS_IOMUX_PAD_NAKED(2, 0, PAD_MUXSEL_GPIO) +#define MX23_PAD_SSP1_DETECT__GPO_2_1 MXS_IOMUX_PAD_NAKED(2, 1, PAD_MUXSEL_GPIO) +#define MX23_PAD_SSP1_DATA0__GPO_2_2 MXS_IOMUX_PAD_NAKED(2, 2, PAD_MUXSEL_GPIO) +#define MX23_PAD_SSP1_DATA1__GPO_2_3 MXS_IOMUX_PAD_NAKED(2, 3, PAD_MUXSEL_GPIO) +#define MX23_PAD_SSP1_DATA2__GPO_2_4 MXS_IOMUX_PAD_NAKED(2, 4, PAD_MUXSEL_GPIO) +#define MX23_PAD_SSP1_DATA3__GPO_2_5 MXS_IOMUX_PAD_NAKED(2, 5, PAD_MUXSEL_GPIO) +#define MX23_PAD_SSP1_SCK__GPO_2_6 MXS_IOMUX_PAD_NAKED(2, 6, PAD_MUXSEL_GPIO) +#define MX23_PAD_ROTARYA__GPO_2_7 MXS_IOMUX_PAD_NAKED(2, 7, PAD_MUXSEL_GPIO) +#define MX23_PAD_ROTARYB__GPO_2_8 MXS_IOMUX_PAD_NAKED(2, 8, PAD_MUXSEL_GPIO) +#define MX23_PAD_EMI_A00__GPO_2_9 MXS_IOMUX_PAD_NAKED(2, 9, PAD_MUXSEL_GPIO) +#define MX23_PAD_EMI_A01__GPO_2_10 MXS_IOMUX_PAD_NAKED(2, 10, PAD_MUXSEL_GPIO) +#define MX23_PAD_EMI_A02__GPO_2_11 MXS_IOMUX_PAD_NAKED(2, 11, PAD_MUXSEL_GPIO) +#define MX23_PAD_EMI_A03__GPO_2_12 MXS_IOMUX_PAD_NAKED(2, 12, PAD_MUXSEL_GPIO) +#define MX23_PAD_EMI_A04__GPO_2_13 MXS_IOMUX_PAD_NAKED(2, 13, PAD_MUXSEL_GPIO) +#define MX23_PAD_EMI_A05__GPO_2_14 MXS_IOMUX_PAD_NAKED(2, 14, PAD_MUXSEL_GPIO) +#define MX23_PAD_EMI_A06__GPO_2_15 MXS_IOMUX_PAD_NAKED(2, 15, PAD_MUXSEL_GPIO) +#define MX23_PAD_EMI_A07__GPO_2_16 MXS_IOMUX_PAD_NAKED(2, 16, PAD_MUXSEL_GPIO) +#define MX23_PAD_EMI_A08__GPO_2_17 MXS_IOMUX_PAD_NAKED(2, 17, PAD_MUXSEL_GPIO) +#define MX23_PAD_EMI_A09__GPO_2_18 MXS_IOMUX_PAD_NAKED(2, 18, PAD_MUXSEL_GPIO) +#define MX23_PAD_EMI_A10__GPO_2_19 MXS_IOMUX_PAD_NAKED(2, 19, PAD_MUXSEL_GPIO) +#define MX23_PAD_EMI_A11__GPO_2_20 MXS_IOMUX_PAD_NAKED(2, 20, PAD_MUXSEL_GPIO) +#define MX23_PAD_EMI_A12__GPO_2_21 MXS_IOMUX_PAD_NAKED(2, 21, PAD_MUXSEL_GPIO) +#define MX23_PAD_EMI_BA0__GPO_2_22 MXS_IOMUX_PAD_NAKED(2, 22, PAD_MUXSEL_GPIO) +#define MX23_PAD_EMI_BA1__GPO_2_23 MXS_IOMUX_PAD_NAKED(2, 23, PAD_MUXSEL_GPIO) +#define MX23_PAD_EMI_CASN__GPO_2_24 MXS_IOMUX_PAD_NAKED(2, 24, PAD_MUXSEL_GPIO) +#define MX23_PAD_EMI_CE0N__GPO_2_25 MXS_IOMUX_PAD_NAKED(2, 25, PAD_MUXSEL_GPIO) +#define MX23_PAD_EMI_CE1N__GPO_2_26 MXS_IOMUX_PAD_NAKED(2, 26, PAD_MUXSEL_GPIO) +#define MX23_PAD_GPMI_CE1N__GPO_2_27 MXS_IOMUX_PAD_NAKED(2, 27, PAD_MUXSEL_GPIO) +#define MX23_PAD_GPMI_CE0N__GPO_2_28 MXS_IOMUX_PAD_NAKED(2, 28, PAD_MUXSEL_GPIO) +#define MX23_PAD_EMI_CKE__GPO_2_29 MXS_IOMUX_PAD_NAKED(2, 29, PAD_MUXSEL_GPIO) +#define MX23_PAD_EMI_RASN__GPO_2_30 MXS_IOMUX_PAD_NAKED(2, 30, PAD_MUXSEL_GPIO) +#define MX23_PAD_EMI_WEN__GPO_2_31 MXS_IOMUX_PAD_NAKED(2, 31, PAD_MUXSEL_GPIO) + +#endif /* __MACH_IOMUX_MX23_H__ */
arch/arm/mach-mxs/include/mach/iomux-mx28.h new file +537 -0
537 lines not on this page · raw message
arch/arm/mach-mxs/include/mach/iomux.h new file +165 -0
165 lines not on this page · raw message
arch/arm/mach-mxs/iomux.c new file +101 -0
101 lines not on this page · raw message
Signature · 1 line
1.7.1
PATCH v7 8/15 ARM: mxs: Add iomux support
Hello Shawn
Quoted 30 lines · Shawn Guo
MXS-based SoCs implements iomux functions in block PINCTRL.
Signed-off-by Shawn Guo <[email protected]>---
[...]arch/arm/mach-mxs/iomux.c new file +19
-0@@ -0,0 +1,101 @@ +[...] +/* +* configures a single pad in the iomuxer +*/ +int mxs_iomux_setup_pad (iomux_cfg_t pad) +{ +u32 reg, ofs, bp, bm; +void __iomem *iomux_base =MXS_IO_ADDRESS (MXS_PINCTRL_BASE_ADDR ); + +/* muxsel */ + ofs =0x100 ; + ofs +=PAD_BANK (pad) *0x20 +PAD_PIN (pad) /16 *0x10 ; + bp =PAD_PIN (pad) %16 *2 ; + bm =0x3 << bp; + reg =__raw_readl (iomux_base + ofs); + reg &= ~bm; + reg |=PAD_MUXSEL (pad) << bp; +__raw_writel (reg, iomux_base + ofs); +
arch/arm/mach-mxs/iomux.c line 29
Quoted 10 lines
arch/arm/mach-mxs/iomux.c new file +10
-0+/* drive */ + ofs =cpu_is_mx23 () ?0x200 :0x300 ; + ofs +=PAD_BANK (pad) *0x40 +PAD_PIN (pad) /8 *0x10 ; +/* mA */ +if (PAD_MA_VALID (pad)) { + bp =PAD_PIN (pad) %8 *4 ; + bm =0x3 << bp; + reg =__raw_readl (iomux_base + ofs); + reg &= ~bm; + reg |=PAD_MA (pad) << bp;
s/ / /
This wasn't here before
I'm not sure if this is worth a v8.
Uwe
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-K?nig | Industrial Linux Solutions | http://www.pengutronix.de/ |
PATCH v7 9/15 ARM: mxs: Add clock support
In reply to Shawn GuoAdd clock for MXS-based SoCs, MX23 and MX28.
---
Changes for v7:
- Remove one tailing tab in clock-mx23.c and clock-mx28.c
Changes for v5
- Fix PARENT_RATE_SHIFT from left to right
Changes for v3:
- Fix freq overflow in clock-mx23.c as well
- Fix the overflow using SH_DIV and shifting 8 bits
- Remove the inclusion of hardware.h and include mx23.h/mx28.h
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 | 526 ++++++++++++++++++++++ arch/arm/mach-mxs/clock-mx28.c | 734 +++++++++++++++++++++++++++++++ arch/arm/mach-mxs/clock.c | 200 +++++++++ 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, 2649 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 +526 -0
@@ -0,0 +1,526 @@ +/* +* 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 <linux/jiffies.h> + +#include <asm/clkdev.h> +#include <asm/div64.h> + +#include <mach/mx23.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) + +#define PARENT_RATE_SHIFT 8 + +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 SH_DIV((parent_rate >> PARENT_RATE_SHIFT) * 18, \ + div, PARENT_RATE_SHIFT); \ +} + +_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 ; + rate >>=PARENT_RATE_SHIFT ; + parent_rate >>=PARENT_RATE_SHIFT ; + diff = parent_rate; + div = frac =1 ; +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_INT_TIMER0); + + return 0; +}
arch/arm/mach-mxs/clock-mx28.c new file +734 -0
734 lines not on this page · raw message
arch/arm/mach-mxs/clock.c new file +200 -0
200 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 v7 13/15 ARM: mxs: Add initial mx23evk support
In reply to Shawn GuoAdd initial mx23evk support with duart.
---
Changes for v7:
- Define mx23evk pads using naked pad "OR" mA/vol/pull configurations
Changes for v3:
- Remove inclusion of hardware.h
- Add __initconst for mx23evk_pads[]
Changes for v2:
- Remove boot_params
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/common.h> +#include <mach/iomux-mx23.h> + +#include "devices-mx23.h" + +static const iomux_cfg_t mx23evk_pads[]__initconst = { +/* duart */ +MX23_PAD_PWM0__DUART_RX | +MXS_PAD_4MA , +MX23_PAD_PWM1__DUART_TX | +MXS_PAD_4MA , +}; + +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. */ + .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 v7 13/15 ARM: mxs: Add initial mx23evk support
Hello Shawn,
Quoted 24 lines · Shawn Guo
Add initial mx23evk support with duart.
Signed-off-by Shawn Guo <[email protected]>---
Changes for v7:
- Define mx23evk pads using naked pad "OR" mA/vol/pull configurationsChanges for v3:
- Remove inclusion ofhardware.h
- Add__initconstfor mx23evk_pads[]Changes for v2:
- Removeboot_paramsarch/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 +0
-0
arch/arm/mach-mxs/mach-mx23evk.c line 35
Quoted 8 lines
arch/arm/mach-mxs/mach-mx23evk.c new file +7
-0@@ -0,0 +1,59 @@ +static const iomux_cfg_t mx23evk_pads[]__initconst = { +/* duart */ +MX23_PAD_PWM0__DUART_RX | +MXS_PAD_4MA , +MX23_PAD_PWM1__DUART_TX | +MXS_PAD_4MA , +};
I would keep these on a single line. YMMV, so for me no need for a v8.
I will test this series later on hardware, and if no show stoppers appear I'd say this is ready to be merged. The (maybe) remaining issues can then be resolved in follow up patches.
Uwe
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-K?nig | Industrial Linux Solutions | http://www.pengutronix.de/ |
PATCH v7 13/15 ARM: mxs: Add initial mx23evk support
Hi Uwe,
Quoted 37 lines · Uwe Kleine-K?nig
Hello Shawn,
Quoted 24 lines · Shawn Guo
Add initial mx23evk support with duart.
Signed-off-by Shawn Guo <[email protected]>---
Changes for v7:
- Define mx23evk pads using naked pad "OR" mA/vol/pull configurationsChanges for v3:
- Remove inclusion ofhardware.h
- Add__initconstfor mx23evk_pads[]Changes for v2:
- Removeboot_paramsarch/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 +0
-0arch/arm/mach-mxs/mach-mx23evk.c line 35
Quoted 8 lines
arch/arm/mach-mxs/mach-mx23evk.c new file +7
-0@@ -0,0 +1,59 @@ +static const iomux_cfg_t mx23evk_pads[]__initconst = { +/* duart */ +MX23_PAD_PWM0__DUART_RX | +MXS_PAD_4MA , +MX23_PAD_PWM1__DUART_TX | +MXS_PAD_4MA , +};I would keep these on a single line. YMMV, so for me no need for a v8.
Quoted 4 lines
I will test this series later on hardware, and if no show stoppers appear I'd say this is ready to be merged. The (maybe) remaining issues can then be resolved in follow up patches.
My intension was to keep the pad configuration on different line from the naked pad. I will keep this comment and that extra space one in mind, and address them later.
Thanks for the review and test effort.
Signature · 2 lines
Regards, Shawn
PATCH v7 14/15 ARM: mxs: Add initial mx28evk support
In reply to Shawn GuoAdd initial mx28evk support with duart and fec0.
---
Changes for v7:
- Define mx28evk pads using naked pad "OR" mA/vol/pull configurations
Changes for v3:
- Remove inclusion of hardware.h
- Add __initconst for mx28evk_pads[]
Changes for v2:
- Change function mx28evk_fec_reset() from inline to __init
- Enable pll2 clock before phy operation
- Add error checking for gpio_direction_output()
- Save bytes by passing parameter into pr_err format string
- Change mx28_add_fec0() to mx28_add_fec(0)
- Remove boot_params
arch/arm/mach-mxs/mach-mx28evk.c | 138 ++++++++++++++++++++++++++++++++++++++ 1 files changed, 138 insertions(+), 0 deletions(-) create mode 100644 arch/arm/mach-mxs/mach-mx28evk.c
arch/arm/mach-mxs/mach-mx28evk.c new file +138 -0
@@ -0,0 +1,138 @@ +/* +* 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 <linux/clk.h> + +#include <asm/mach-types.h> +#include <asm/mach/arch.h> +#include <asm/mach/time.h> + +#include <mach/common.h> +#include <mach/iomux-mx28.h> + +#include "devices-mx28.h" +#include "gpio.h" + +#define MX28EVK_FEC_PHY_POWER MXS_GPIO_NR(2, 15) +#define MX28EVK_FEC_PHY_RESET MXS_GPIO_NR(4, 13) + +static const iomux_cfg_t mx28evk_pads[]__initconst = { +/* duart */ +MX28_PAD_PWM0__DUART_RX | + (MXS_PAD_4MA |MXS_PAD_3V3 |MXS_PAD_NOPULL ), +MX28_PAD_PWM1__DUART_TX | + (MXS_PAD_4MA |MXS_PAD_3V3 |MXS_PAD_NOPULL ), + +/* fec0 */ +MX28_PAD_ENET0_MDC__ENET0_MDC | + (MXS_PAD_8MA |MXS_PAD_3V3 |MXS_PAD_PULLUP ), +MX28_PAD_ENET0_MDIO__ENET0_MDIO | + (MXS_PAD_8MA |MXS_PAD_3V3 |MXS_PAD_PULLUP ), +MX28_PAD_ENET0_RX_EN__ENET0_RX_EN | + (MXS_PAD_8MA |MXS_PAD_3V3 |MXS_PAD_PULLUP ), +MX28_PAD_ENET0_RXD0__ENET0_RXD0 | + (MXS_PAD_8MA |MXS_PAD_3V3 |MXS_PAD_PULLUP ), +MX28_PAD_ENET0_RXD1__ENET0_RXD1 | + (MXS_PAD_8MA |MXS_PAD_3V3 |MXS_PAD_PULLUP ), +MX28_PAD_ENET0_TX_EN__ENET0_TX_EN | + (MXS_PAD_8MA |MXS_PAD_3V3 |MXS_PAD_PULLUP ), +MX28_PAD_ENET0_TXD0__ENET0_TXD0 | + (MXS_PAD_8MA |MXS_PAD_3V3 |MXS_PAD_PULLUP ), +MX28_PAD_ENET0_TXD1__ENET0_TXD1 | + (MXS_PAD_8MA |MXS_PAD_3V3 |MXS_PAD_PULLUP ), +MX28_PAD_ENET_CLK__CLKCTRL_ENET | + (MXS_PAD_8MA |MXS_PAD_3V3 |MXS_PAD_PULLUP ), +/* phy power line */ +MX28_PAD_SSP1_DATA3__GPIO_2_15 | + (MXS_PAD_4MA |MXS_PAD_3V3 |MXS_PAD_NOPULL ), +/* phy reset line */ +MX28_PAD_ENET0_RX_CLK__GPIO_4_13 | + (MXS_PAD_4MA |MXS_PAD_3V3 |MXS_PAD_NOPULL ), +}; + +/* fec */ +static void __init mx28evk_fec_reset (void ) +{ +int ret; +struct clk *clk; + +/* Enable fec phy clock */ + clk =clk_get_sys ("pll2" ,NULL ); +if (!IS_ERR (clk)) +clk_enable (clk); + +/* Power up fec phy */ + ret =gpio_request (MX28EVK_FEC_PHY_POWER ,"fec-phy-power" ); +if (ret) { +pr_err ("Failed to request gpio fec-phy-%s: %d\n" ,"power" , ret); +return ; + } + + ret =gpio_direction_output (MX28EVK_FEC_PHY_POWER ,0 ); +if (ret) { +pr_err ("Failed to drive gpio fec-phy-%s: %d\n" ,"power" , ret); +return ; + } + +/* Reset fec phy */ + ret =gpio_request (MX28EVK_FEC_PHY_RESET ,"fec-phy-reset" ); +if (ret) { +pr_err ("Failed to request gpio fec-phy-%s: %d\n" ,"reset" , ret); +return ; + } + +gpio_direction_output (MX28EVK_FEC_PHY_RESET ,0 ); +if (ret) { +pr_err ("Failed to drive gpio fec-phy-%s: %d\n" ,"reset" , ret); +return ; + } + +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_fec (0 , &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. */ + .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