ARM: mxs: Add initial support for MX23 and MX28
Subsystems (3)
PATCH v2 11/15 ARM: mxs: Dynamically allocate duart devices
In reply to Shawn GuoDynamically allocate duart devices for MX23 and MX28.
---
Changes for v2:
- Change inclusion of hardware.h to mx23.h plus mx28.h
arch/arm/mach-mxs/devices-mx23.h | 16 +++++ arch/arm/mach-mxs/devices-mx28.h | 16 +++++ arch/arm/mach-mxs/devices.c | 75 +++++++++++++++++++++++ arch/arm/mach-mxs/devices/platform-duart.c | 48 ++++++++++++++ arch/arm/mach-mxs/include/mach/devices-common.h | 34 ++++++++++ 5 files changed, 189 insertions(+), 0 deletions(-) create mode 100644 arch/arm/mach-mxs/devices-mx23.h create mode 100644 arch/arm/mach-mxs/devices-mx28.h create mode 100644 arch/arm/mach-mxs/devices.c create mode 100644 arch/arm/mach-mxs/devices/platform-duart.c create mode 100644 arch/arm/mach-mxs/include/mach/devices-common.h
arch/arm/mach-mxs/devices-mx23.h new file +16 -0
@@ -0,0 +1,16 @@ +/* +* Copyright (C) 2010 Pengutronix +* Uwe Kleine-Koenig <[email protected]> +* +* Copyright 2010 Freescale Semiconductor, Inc. All Rights Reserved. +* +* This program is free software; you can redistribute it and/or modify it under +* the terms of the GNU General Public License version 2 as published by the +* Free Software Foundation. +*/ +#include <mach/mx23.h> +#include <mach/devices-common.h> + +extern const struct mxs_duart_data mx23_duart_data__initconst ; +#define mx23_add_duart () \ + mxs_add_duart(&mx23_duart_data)
arch/arm/mach-mxs/devices-mx28.h new file +16 -0
@@ -0,0 +1,16 @@ +/* +* Copyright (C) 2010 Pengutronix +* Uwe Kleine-Koenig <[email protected]> +* +* Copyright 2010 Freescale Semiconductor, Inc. All Rights Reserved. +* +* This program is free software; you can redistribute it and/or modify it under +* the terms of the GNU General Public License version 2 as published by the +* Free Software Foundation. +*/ +#include <mach/mx28.h> +#include <mach/devices-common.h> + +extern const struct mxs_duart_data mx28_duart_data__initconst ; +#define mx28_add_duart () \ + mxs_add_duart(&mx28_duart_data)
arch/arm/mach-mxs/devices.c new file +75 -0
75 lines not on this page · raw message
arch/arm/mach-mxs/devices/platform-duart.c new file +48 -0
48 lines not on this page · raw message
arch/arm/mach-mxs/include/mach/devices-common.h new file +34 -0
@@ -0,0 +1,34 @@ +/* +* Copyright (C) 2009-2010 Pengutronix +* Uwe Kleine-Koenig <[email protected]> +* +* This program is free software; you can redistribute it and/or modify it under +* the terms of the GNU General Public License version 2 as published by the +* Free Software Foundation. +*/ +#include <linux/kernel.h> +#include <linux/platform_device.h> +#include <linux/init.h> + +struct platform_device *mxs_add_platform_device_dmamask ( +const char *name,int id, +const struct resource *res,unsigned int num_resources, +const void *data,size_t size_data,u64 dmamask); + +static inline struct platform_device *mxs_add_platform_device ( +const char *name,int id, +const struct resource *res,unsigned int num_resources, +const void *data,size_t size_data) +{ +return mxs_add_platform_device_dmamask ( + name, id, res, num_resources, data, size_data,0 ); +} + +/* duart */ +struct mxs_duart_data { +resource_size_t iobase; +resource_size_t iosize; +resource_size_t irq; +}; +struct platform_device *__init mxs_add_duart ( +const struct mxs_duart_data *data);
Signature · 1 line
1.7.1
PATCH v2 12/15 ARM: mxs: Dynamically allocate fec devices
In reply to Shawn GuoDynamically allocate fec devices for MX28, which gets dual fec interface.
---
Changes for v2:
- Remove the use of mx28_add_fec0 and mx28_add_fec1
- Remove unnessary passing of data->iosize
arch/arm/mach-mxs/devices-mx28.h | 4 ++ arch/arm/mach-mxs/devices/platform-fec.c | 50 +++++++++++++++++++++++ arch/arm/mach-mxs/include/mach/devices-common.h | 12 +++++ 3 files changed, 66 insertions(+), 0 deletions(-) create mode 100644 arch/arm/mach-mxs/devices/platform-fec.c
arch/arm/mach-mxs/devices-mx28.h +4 -0
@@ -14,3 +14,7 @@extern const struct mxs_duart_data mx28_duart_data__initconst ;#define mx28_add_duart () \ mxs_add_duart(&mx28_duart_data) + +extern const struct mxs_fec_data mx28_fec_data[]__initconst ; +#define mx28_add_fec (id, pdata) \ + mxs_add_fec(&mx28_fec_data[id], pdata)
arch/arm/mach-mxs/devices/platform-fec.c new file +50 -0
50 lines not on this page · raw message
arch/arm/mach-mxs/include/mach/devices-common.h +12 -0
@@ -32,3 +32,15 @@ struct mxs_duart_data { };struct platform_device *__init mxs_add_duart (const struct mxs_duart_data *data); + +/* fec */ +#include <linux/fec.h> +struct mxs_fec_data { +int id; +resource_size_t iobase; +resource_size_t iosize; +resource_size_t irq; +}; +struct platform_device *__init mxs_add_fec ( +const struct mxs_fec_data *data, +const struct fec_platform_data *pdata);
Signature · 1 line
1.7.1
PATCH v2 13/15 ARM: mxs: Add initial mx23evk support
In reply to Shawn GuoAdd initial mx23evk support with duart.
---
Changes for v2:
- Remove boot_params
arch/arm/mach-mxs/mach-mx23evk.c | 58 ++++++++++++++++++++++++++++++++++++++ 1 files changed, 58 insertions(+), 0 deletions(-) create mode 100644 arch/arm/mach-mxs/mach-mx23evk.c
arch/arm/mach-mxs/mach-mx23evk.c new file +58 -0
@@ -0,0 +1,58 @@ +/* +* Copyright 2010 Freescale Semiconductor, Inc. All Rights Reserved. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +*/ + +#include <linux/delay.h> +#include <linux/platform_device.h> +#include <linux/gpio.h> +#include <linux/irq.h> + +#include <asm/mach-types.h> +#include <asm/mach/arch.h> +#include <asm/mach/time.h> + +#include <mach/hardware.h> +#include <mach/common.h> +#include <mach/iomux-mx23.h> + +#include "devices-mx23.h" + +static iomux_cfg_t mx23evk_pads[] = { +/* duart */ +MX23_PAD_PWM0__DUART_RX , +MX23_PAD_PWM1__DUART_TX , +}; + +static void __init mx23evk_init (void ) +{ +mxs_iomux_setup_multiple_pads (mx23evk_pads,ARRAY_SIZE (mx23evk_pads)); + +mx23_add_duart (); +} + +static void __init mx23evk_timer_init (void ) +{ +mx23_clocks_init (); +} + +static struct sys_timer mx23evk_timer = { + .init = mx23evk_timer_init, +}; + +MACHINE_START (MX23EVK ,"Freescale MX23 EVK" ) +/* Maintainer: Freescale Semiconductor, Inc. */ + .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 v3 4/15 ARM: mxs: Add interrupt support
In reply to Shawn GuoAdd Interrupt Collector (ICOLL) support for MXS-based.
---
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 v4 1/15 ARM: mxs: Add core definitions
In reply to Shawn GuoAdd core definitions for MXS-based SoC MX23 and MX28.
---
Changes for v4:
- Move all MXS related definitions from hardware.h into mxs.h, but have to keep hardware.h which is required by external file.
- Define IO addresses common to MXS-based in mxs.h
- Include hardware.h in mxs.h, include mxs.h in mx23.h and mx28.h, so that files can include mxs.h, mx23.h, mx28.h individually when necessary.
- Remove #include <linux/io.h> from mx23.h and mx28.h, since it's not necessary.
Changes for v3:
- Update MXS_IO_P2V definition and comment to get them matched
- Sort mx23 base address definitions by offset
- Remove mx28 reserved IRQ definitions
- Remove unnecessary dummy definitions for cpu_is_mx23() and cpu_is_mx28()
Changes for v2:
- Remove MXS_IO_P2V_MODULE from hardware.h which is not needed
- Simplify MXS_IO_P2V_MODULE definition in hardware.h
- Remove unnecessary inclusion protection from hardware.h
- Change cpu_is_mx23/mx28() implementation in mxs.h to use machine_is_xxx
arch/arm/mach-mxs/include/mach/hardware.h | 29 +++++ arch/arm/mach-mxs/include/mach/irqs.h | 32 +++++ arch/arm/mach-mxs/include/mach/memory.h | 24 ++++ arch/arm/mach-mxs/include/mach/mx23.h | 145 ++++++++++++++++++++++ arch/arm/mach-mxs/include/mach/mx28.h | 188 +++++++++++++++++++++++++++++ arch/arm/mach-mxs/include/mach/mxs.h | 85 +++++++++++++ 6 files changed, 503 insertions(+), 0 deletions(-) create mode 100644 arch/arm/mach-mxs/include/mach/hardware.h create mode 100644 arch/arm/mach-mxs/include/mach/irqs.h create mode 100644 arch/arm/mach-mxs/include/mach/memory.h create mode 100644 arch/arm/mach-mxs/include/mach/mx23.h create mode 100644 arch/arm/mach-mxs/include/mach/mx28.h create mode 100644 arch/arm/mach-mxs/include/mach/mxs.h
arch/arm/mach-mxs/include/mach/hardware.h new file +29 -0
@@ -0,0 +1,29 @@ +/* +* Copyright 2004-2007 Freescale Semiconductor, Inc. All Rights Reserved. +* Copyright 2008 Juergen Beisert, kernel at pengutronix.de +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +* MA 02110-1301, USA. +*/ + +#ifndef __MACH_MXS_HARDWARE_H__ +#define __MACH_MXS_HARDWARE_H__ + +#ifdef __ASSEMBLER__ +#define IOMEM (addr) (addr) +#else +#define IOMEM (addr) ((void __force __iomem *)(addr)) +#endif + +#endif /* __MACH_MXS_HARDWARE_H__ */
arch/arm/mach-mxs/include/mach/irqs.h new file +32 -0
@@ -0,0 +1,32 @@ +/* +* Copyright 2004-2007 Freescale Semiconductor, Inc. All Rights Reserved. +*/ + +/* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +*/ + +#ifndef __MACH_MXS_IRQS_H__ +#define __MACH_MXS_IRQS_H__ + +#define MXS_INTERNAL_IRQS 128 + +#define MXS_GPIO_IRQ_START MXS_INTERNAL_IRQS + +/* the maximum for MXS-based */ +#define MXS_GPIO_IRQS (32 * 5) + +/* +* The next 16 interrupts are for board specific purposes. Since +* the kernel can only run on one machine at a time, we can re-use +* these. If you need more, increase MXS_BOARD_IRQS, but keep it +* within sensible limits. +*/ +#define MXS_BOARD_IRQ_START (MXS_GPIO_IRQ_START + MXS_GPIO_IRQS) +#define MXS_BOARD_IRQS 16 + +#define NR_IRQS (MXS_BOARD_IRQ_START + MXS_BOARD_IRQS) + +#endif /* __MACH_MXS_IRQS_H__ */
arch/arm/mach-mxs/include/mach/memory.h new file +24 -0
@@ -0,0 +1,24 @@ +/* +* Copyright (C) 2009-2010 Freescale Semiconductor, Inc. All Rights Reserved. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License along +* with this program; if not, write to the Free Software Foundation, Inc., +* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ + +#ifndef __MACH_MXS_MEMORY_H__ +#define __MACH_MXS_MEMORY_H__ + +#define PHYS_OFFSET UL(0x40000000) + +#endif /* __MACH_MXS_MEMORY_H__ */
arch/arm/mach-mxs/include/mach/mx23.h new file +145 -0
145 lines not on this page · raw message
arch/arm/mach-mxs/include/mach/mx28.h new file +188 -0
188 lines not on this page · raw message
arch/arm/mach-mxs/include/mach/mxs.h new file +85 -0
85 lines not on this page · raw message
Signature · 1 line
1.7.1
PATCH v4 1/15 ARM: mxs: Add core definitions
A word of advice, merely as an on-looker. Don't thread your new versions of patches into the old thread. I now have a total mixture of v4, v3, v2, etc of these patches and it's not obvious what's the latest, even if I switch to unsorted or received date.
It might be better to version the series, so that anyone can see which patches related to the last series - and if you want per patch version information, include that in the body of the message.
2190 Dec 08 Shawn Guo ( 112) ??>[PATCH v2 12/15] ARM: mxs: Dynamically 2191 Dec 08 Shawn Guo ( 84) ??>[PATCH v2 13/15] ARM: mxs: Add initial 2192 Dec 08 Shawn Guo ( 157) ??>[PATCH v2 14/15] ARM: mxs: Add initial 2193 Dec 08 Uwe Kleine-K?ni ( 183) ? ??> 2194 Dec 09 Shawn Guo ( 78) ? ??> 2195 Dec 09 Uwe Kleine-K?ni ( 22) ? ??> 2196 Dec 09 Shawn Guo ( 39) ? ??> 2197 Dec 09 Uwe Kleine-K?ni ( 30) ? ??> 2198 Dec 09 Shawn Guo ( 58) ? ??> 2199 Dec 09 Lothar Wa?mann ( 93) ? ??> 2200 Dec 09 Shawn Guo ( 130) ? ??> 2201 Dec 09 Shawn Guo ( 133) ? ??> 2202 Dec 08 Shawn Guo ( 155) ??>[PATCH v3 15/15] ARM: mxs: Add build c 2203 N Dec 09 Shawn Guo ( 588) ??>[PATCH v4 01/15] ARM: mxs: Add core de 2204 N Dec 09 Shawn Guo ( 154) ??>[PATCH v3 02/15] ARM: mxs: Add helper 2205 N Dec 09 Shawn Guo ( 213) ??>[PATCH v4 03/15] ARM: mxs: Add reset r 2206 N Dec 09 Shawn Guo ( 168) ??>[PATCH v3 04/15] ARM: mxs: Add interru 2207 N Dec 09 Shawn Guo ( 170) ??>[PATCH v3 05/15] ARM: mxs: Add low-lev 2208 N Dec 09 Shawn Guo ( 322) ??>[PATCH v4 06/15] ARM: mxs: Add timer s 2209 N Dec 09 Shawn Guo ( 440) ??>[PATCH v3 07/15] ARM: mxs: Add gpio su 2210 N Dec 09 Lothar Wa?mann ( 135) ? ??> 2211 N Dec 09 Shawn Guo (2730) ??>[PATCH v3 09/15] ARM: mxs: Add clock s 2212 N Dec 09 Shawn Guo ( 127) ??>[PATCH v2 10/15] ARM: mxs: Add static 2213 N Dec 09 Shawn Guo ( 247) ??>[PATCH v2 11/15] ARM: mxs: Dynamically 2214 N Dec 09 Shawn Guo ( 115) ??>[PATCH v3 12/15] ARM: mxs: Dynamically 2215 N Dec 09 Shawn Guo ( 87) ??>[PATCH v3 13/15] ARM: mxs: Add initial 2216 N Dec 09 Shawn Guo ( 160) ??>[PATCH v3 14/15] ARM: mxs: Add initial 2217 Dec 09 Lothar Wa?mann ( 432) ??>Re: [PATCH v3 08/15] ARM: mxs: Add iom
And we're currently on message number 3200 in this mailbox... so these messages are buried about 1000 mails back. Not good.
Quoted 588 lines · Shawn Guo
Add core definitions for MXS-based SoC MX23 and MX28.
Signed-off-by Shawn Guo <[email protected]>---
Changes for v4:
- Move all MXS related definitions fromhardware.hintomxs.h, but have to keephardware.hwhich is required by external file.
- Define IO addresses common to MXS-based inmxs.h
- Includehardware.hinmxs.h, includemxs.hinmx23.handmx28.h, so that files can includemxs.h,mx23.h,mx28.hindividually when necessary.
- Remove #include <linux/io.h> frommx23.handmx28.h, since it's not necessary.Changes for v3:
- UpdateMXS_IO_P2Vdefinition and comment to get them matched
- Sort mx23 base address definitions by offset
- Remove mx28 reserved IRQ definitions
- Remove unnecessary dummy definitions forcpu_is_mx23()andcpu_is_mx28()Changes for v2:
- RemoveMXS_IO_P2V_MODULEfromhardware.hwhich is not needed
- SimplifyMXS_IO_P2V_MODULEdefinition inhardware.h
- Remove unnecessary inclusion protection fromhardware.h
- Change cpu_is_mx23/mx28() implementation inmxs.hto usemachine_is_xxxarch/arm/mach-mxs/include/mach/hardware.h | 29 +++++ arch/arm/mach-mxs/include/mach/irqs.h | 32 +++++ arch/arm/mach-mxs/include/mach/memory.h | 24 ++++ arch/arm/mach-mxs/include/mach/mx23.h | 145 ++++++++++++++++++++++ arch/arm/mach-mxs/include/mach/mx28.h | 188 +++++++++++++++++++++++++++++ arch/arm/mach-mxs/include/mach/mxs.h | 85 +++++++++++++ 6 files changed, 503 insertions(+), 0 deletions(-) create mode 100644 arch/arm/mach-mxs/include/mach/hardware.h create mode 100644 arch/arm/mach-mxs/include/mach/irqs.h create mode 100644 arch/arm/mach-mxs/include/mach/memory.h create mode 100644 arch/arm/mach-mxs/include/mach/mx23.h create mode 100644 arch/arm/mach-mxs/include/mach/mx28.h create mode 100644 arch/arm/mach-mxs/include/mach/mxs.harch/arm/mach-mxs/include/mach/hardware.h new file +29
-0@@ -0,0 +1,29 @@ +/* +* Copyright 2004-2007 Freescale Semiconductor, Inc. All Rights Reserved. +* Copyright 2008 Juergen Beisert, kernel at pengutronix.de +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +* MA 02110-1301, USA. +*/ + +#ifndef __MACH_MXS_HARDWARE_H__ +#define __MACH_MXS_HARDWARE_H__ + +#ifdef __ASSEMBLER__ +#define IOMEM (addr) (addr) +#else +#define IOMEM (addr) ((void __force __iomem *)(addr)) +#endif + +#endif /* __MACH_MXS_HARDWARE_H__ */ arch/arm/mach-mxs/include/mach/irqs.h new file +32
-0@@ -0,0 +1,32 @@ +/* +* Copyright 2004-2007 Freescale Semiconductor, Inc. All Rights Reserved. +*/ + +/* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +*/ + +#ifndef __MACH_MXS_IRQS_H__ +#define __MACH_MXS_IRQS_H__ + +#define MXS_INTERNAL_IRQS 128 + +#define MXS_GPIO_IRQ_START MXS_INTERNAL_IRQS + +/* the maximum for MXS-based */ +#define MXS_GPIO_IRQS (32 * 5) + +/* +* The next 16 interrupts are for board specific purposes. Since +* the kernel can only run on one machine at a time, we can re-use +* these. If you need more, increase MXS_BOARD_IRQS, but keep it +* within sensible limits. +*/ +#define MXS_BOARD_IRQ_START (MXS_GPIO_IRQ_START + MXS_GPIO_IRQS) +#define MXS_BOARD_IRQS 16 + +#define NR_IRQS (MXS_BOARD_IRQ_START + MXS_BOARD_IRQS) + +#endif /* __MACH_MXS_IRQS_H__ */ arch/arm/mach-mxs/include/mach/memory.h new file +24
-0@@ -0,0 +1,24 @@ +/* +* Copyright (C) 2009-2010 Freescale Semiconductor, Inc. All Rights Reserved. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License along +* with this program; if not, write to the Free Software Foundation, Inc., +* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ + +#ifndef __MACH_MXS_MEMORY_H__ +#define __MACH_MXS_MEMORY_H__ + +#define PHYS_OFFSET UL(0x40000000) + +#endif /* __MACH_MXS_MEMORY_H__ */ arch/arm/mach-mxs/include/mach/mx23.h new file +145
-0@@ -0,0 +1,145 @@ +/* +* Copyright (C) 2009-2010 Freescale Semiconductor, Inc. All Rights Reserved. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License along +* with this program; if not, write to the Free Software Foundation, Inc., +* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ + +#ifndef __MACH_MX23_H__ +#define __MACH_MX23_H__ + +#include <mach/mxs.h> + +/* +* OCRAM +*/ +#define MX23_OCRAM_BASE_ADDR 0x00000000 +#define MX23_OCRAM_SIZE SZ_32K + +/* +* IO +*/ +#define MX23_IO_BASE_ADDR 0x80000000 +#define MX23_IO_SIZE SZ_1M + +#define MX23_ICOLL_BASE_ADDR (MX23_IO_BASE_ADDR + 0x000000) +#define MX23_APBH_DMA_BASE_ADDR (MX23_IO_BASE_ADDR + 0x004000) +#define MX23_BCH_BASE_ADDR (MX23_IO_BASE_ADDR + 0x00a000) +#define MX23_GPMI_BASE_ADDR (MX23_IO_BASE_ADDR + 0x00c000) +#define MX23_SSP1_BASE_ADDR (MX23_IO_BASE_ADDR + 0x010000) +#define MX23_PINCTRL_BASE_ADDR (MX23_IO_BASE_ADDR + 0x018000) +#define MX23_DIGCTL_BASE_ADDR (MX23_IO_BASE_ADDR + 0x01c000) +#define MX23_ETM_BASE_ADDR (MX23_IO_BASE_ADDR + 0x020000) +#define MX23_APBX_DMA_BASE_ADDR (MX23_IO_BASE_ADDR + 0x024000) +#define MX23_DCP_BASE_ADDR (MX23_IO_BASE_ADDR + 0x028000) +#define MX23_PXP_BASE_ADDR (MX23_IO_BASE_ADDR + 0x02a000) +#define MX23_OCOTP_BASE_ADDR (MX23_IO_BASE_ADDR + 0x02c000) +#define MX23_AXI_AHB0_BASE_ADDR (MX23_IO_BASE_ADDR + 0x02e000) +#define MX23_LCDIF_BASE_ADDR (MX23_IO_BASE_ADDR + 0x030000) +#define MX23_SSP2_BASE_ADDR (MX23_IO_BASE_ADDR + 0x034000) +#define MX23_TVENC_BASE_ADDR (MX23_IO_BASE_ADDR + 0x038000) +#define MX23_CLKCTRL_BASE_ADDR (MX23_IO_BASE_ADDR + 0x040000) +#define MX23_SAIF0_BASE_ADDR (MX23_IO_BASE_ADDR + 0x042000) +#define MX23_POWER_BASE_ADDR (MX23_IO_BASE_ADDR + 0x044000) +#define MX23_SAIF1_BASE_ADDR (MX23_IO_BASE_ADDR + 0x046000) +#define MX23_AUDIOOUT_BASE_ADDR (MX23_IO_BASE_ADDR + 0x048000) +#define MX23_AUDIOIN_BASE_ADDR (MX23_IO_BASE_ADDR + 0x04c000) +#define MX23_LRADC_BASE_ADDR (MX23_IO_BASE_ADDR + 0x050000) +#define MX23_SPDIF_BASE_ADDR (MX23_IO_BASE_ADDR + 0x054000) +#define MX23_I2C0_BASE_ADDR (MX23_IO_BASE_ADDR + 0x058000) +#define MX23_RTC_BASE_ADDR (MX23_IO_BASE_ADDR + 0x05c000) +#define MX23_PWM_BASE_ADDR (MX23_IO_BASE_ADDR + 0x064000) +#define MX23_TIMROT_BASE_ADDR (MX23_IO_BASE_ADDR + 0x068000) +#define MX23_AUART1_BASE_ADDR (MX23_IO_BASE_ADDR + 0x06c000) +#define MX23_AUART2_BASE_ADDR (MX23_IO_BASE_ADDR + 0x06e000) +#define MX23_DUART_BASE_ADDR (MX23_IO_BASE_ADDR + 0x070000) +#define MX23_USBPHY_BASE_ADDR (MX23_IO_BASE_ADDR + 0x07c000) +#define MX23_USBCTRL_BASE_ADDR (MX23_IO_BASE_ADDR + 0x080000) +#define MX23_DRAM_BASE_ADDR (MX23_IO_BASE_ADDR + 0x0e0000) + +#define MX23_IO_P2V (x) MXS_IO_P2V(x) +#define MX23_IO_ADDRESS (x) IOMEM(MX23_IO_P2V(x)) + +/* +* IRQ +*/ +#define MX23_INT_DUART 0 +#define MX23_INT_COMMS_RX 1 +#define MX23_INT_COMMS_TX 1 +#define MX23_INT_SSP2_ERROR 2 +#define MX23_INT_VDD5V 3 +#define MX23_INT_HEADPHONE_SHORT 4 +#define MX23_INT_DAC_DMA 5 +#define MX23_INT_DAC_ERROR 6 +#define MX23_INT_ADC_DMA 7 +#define MX23_INT_ADC_ERROR 8 +#define MX23_INT_SPDIF_DMA 9 +#define MX23_INT_SAIF2_DMA 9 +#define MX23_INT_SPDIF_ERROR 10 +#define MX23_INT_SAIF1_IRQ 10 +#define MX23_INT_SAIF2_IRQ 10 +#define MX23_INT_USB_CTRL 11 +#define MX23_INT_USB_WAKEUP 12 +#define MX23_INT_GPMI_DMA 13 +#define MX23_INT_SSP1_DMA 14 +#define MX23_INT_SSP_ERROR 15 +#define MX23_INT_GPIO0 16 +#define MX23_INT_GPIO1 17 +#define MX23_INT_GPIO2 18 +#define MX23_INT_SAIF1_DMA 19 +#define MX23_INT_SSP2_DMA 20 +#define MX23_INT_ECC8_IRQ 21 +#define MX23_INT_RTC_ALARM 22 +#define MX23_INT_UARTAPP_TX_DMA 23 +#define MX23_INT_UARTAPP_INTERNAL 24 +#define MX23_INT_UARTAPP_RX_DMA 25 +#define MX23_INT_I2C_DMA 26 +#define MX23_INT_I2C_ERROR 27 +#define MX23_INT_TIMER0 28 +#define MX23_INT_TIMER1 29 +#define MX23_INT_TIMER2 30 +#define MX23_INT_TIMER3 31 +#define MX23_INT_BATT_BRNOUT 32 +#define MX23_INT_VDDD_BRNOUT 33 +#define MX23_INT_VDDIO_BRNOUT 34 +#define MX23_INT_VDD18_BRNOUT 35 +#define MX23_INT_TOUCH_DETECT 36 +#define MX23_INT_LRADC_CH0 37 +#define MX23_INT_LRADC_CH1 38 +#define MX23_INT_LRADC_CH2 39 +#define MX23_INT_LRADC_CH3 40 +#define MX23_INT_LRADC_CH4 41 +#define MX23_INT_LRADC_CH5 42 +#define MX23_INT_LRADC_CH6 43 +#define MX23_INT_LRADC_CH7 44 +#define MX23_INT_LCDIF_DMA 45 +#define MX23_INT_LCDIF_ERROR 46 +#define MX23_INT_DIGCTL_DEBUG_TRAP 47 +#define MX23_INT_RTC_1MSEC 48 +#define MX23_INT_DRI_DMA 49 +#define MX23_INT_DRI_ATTENTION 50 +#define MX23_INT_GPMI_ATTENTION 51 +#define MX23_INT_IR 52 +#define MX23_INT_DCP_VMI 53 +#define MX23_INT_DCP 54 +#define MX23_INT_BCH 56 +#define MX23_INT_PXP 57 +#define MX23_INT_UARTAPP2_TX_DMA 58 +#define MX23_INT_UARTAPP2_INTERNAL 59 +#define MX23_INT_UARTAPP2_RX_DMA 60 +#define MX23_INT_VDAC_DETECT 61 +#define MX23_INT_VDD5V_DROOP 64 +#define MX23_INT_DCDC4P2_BO 65 + +#endif /* __MACH_MX23_H__ */ arch/arm/mach-mxs/include/mach/mx28.h new file +188
-0@@ -0,0 +1,188 @@ +/* +* Copyright (C) 2009-2010 Freescale Semiconductor, Inc. All Rights Reserved. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License along +* with this program; if not, write to the Free Software Foundation, Inc., +* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ + +#ifndef __MACH_MX28_H__ +#define __MACH_MX28_H__ + +#include <mach/mxs.h> + +/* +* OCRAM +*/ +#define MX28_OCRAM_BASE_ADDR 0x00000000 +#define MX28_OCRAM_SIZE SZ_128K + +/* +* IO +*/ +#define MX28_IO_BASE_ADDR 0x80000000 +#define MX28_IO_SIZE SZ_1M + +#define MX28_ICOLL_BASE_ADDR (MX28_IO_BASE_ADDR + 0x000000) +#define MX28_HSADC_BASE_ADDR (MX28_IO_BASE_ADDR + 0x002000) +#define MX28_APBH_DMA_BASE_ADDR (MX28_IO_BASE_ADDR + 0x004000) +#define MX28_PERFMON_BASE_ADDR (MX28_IO_BASE_ADDR + 0x006000) +#define MX28_BCH_BASE_ADDR (MX28_IO_BASE_ADDR + 0x00a000) +#define MX28_GPMI_BASE_ADDR (MX28_IO_BASE_ADDR + 0x00c000) +#define MX28_SSP0_BASE_ADDR (MX28_IO_BASE_ADDR + 0x010000) +#define MX28_SSP1_BASE_ADDR (MX28_IO_BASE_ADDR + 0x012000) +#define MX28_SSP2_BASE_ADDR (MX28_IO_BASE_ADDR + 0x014000) +#define MX28_SSP3_BASE_ADDR (MX28_IO_BASE_ADDR + 0x016000) +#define MX28_PINCTRL_BASE_ADDR (MX28_IO_BASE_ADDR + 0x018000) +#define MX28_DIGCTL_BASE_ADDR (MX28_IO_BASE_ADDR + 0x01c000) +#define MX28_ETM_BASE_ADDR (MX28_IO_BASE_ADDR + 0x022000) +#define MX28_APBX_DMA_BASE_ADDR (MX28_IO_BASE_ADDR + 0x024000) +#define MX28_DCP_BASE_ADDR (MX28_IO_BASE_ADDR + 0x028000) +#define MX28_PXP_BASE_ADDR (MX28_IO_BASE_ADDR + 0x02a000) +#define MX28_OCOTP_BASE_ADDR (MX28_IO_BASE_ADDR + 0x02c000) +#define MX28_AXI_AHB0_BASE_ADDR (MX28_IO_BASE_ADDR + 0x02e000) +#define MX28_LCDIF_BASE_ADDR (MX28_IO_BASE_ADDR + 0x030000) +#define MX28_CAN0_BASE_ADDR (MX28_IO_BASE_ADDR + 0x032000) +#define MX28_CAN1_BASE_ADDR (MX28_IO_BASE_ADDR + 0x034000) +#define MX28_SIMDBG_BASE_ADDR (MX28_IO_BASE_ADDR + 0x03c000) +#define MX28_SIMGPMISEL_BASE_ADDR (MX28_IO_BASE_ADDR + 0x03c200) +#define MX28_SIMSSPSEL_BASE_ADDR (MX28_IO_BASE_ADDR + 0x03c300) +#define MX28_SIMMEMSEL_BASE_ADDR (MX28_IO_BASE_ADDR + 0x03c400) +#define MX28_GPIOMON_BASE_ADDR (MX28_IO_BASE_ADDR + 0x03c500) +#define MX28_SIMENET_BASE_ADDR (MX28_IO_BASE_ADDR + 0x03c700) +#define MX28_ARMJTAG_BASE_ADDR (MX28_IO_BASE_ADDR + 0x03c800) +#define MX28_CLKCTRL_BASE_ADDR (MX28_IO_BASE_ADDR + 0x040000) +#define MX28_SAIF0_BASE_ADDR (MX28_IO_BASE_ADDR + 0x042000) +#define MX28_POWER_BASE_ADDR (MX28_IO_BASE_ADDR + 0x044000) +#define MX28_SAIF1_BASE_ADDR (MX28_IO_BASE_ADDR + 0x046000) +#define MX28_LRADC_BASE_ADDR (MX28_IO_BASE_ADDR + 0x050000) +#define MX28_SPDIF_BASE_ADDR (MX28_IO_BASE_ADDR + 0x054000) +#define MX28_RTC_BASE_ADDR (MX28_IO_BASE_ADDR + 0x056000) +#define MX28_I2C0_BASE_ADDR (MX28_IO_BASE_ADDR + 0x058000) +#define MX28_I2C1_BASE_ADDR (MX28_IO_BASE_ADDR + 0x05a000) +#define MX28_PWM_BASE_ADDR (MX28_IO_BASE_ADDR + 0x064000) +#define MX28_TIMROT_BASE_ADDR (MX28_IO_BASE_ADDR + 0x068000) +#define MX28_AUART0_BASE_ADDR (MX28_IO_BASE_ADDR + 0x06a000) +#define MX28_AUART1_BASE_ADDR (MX28_IO_BASE_ADDR + 0x06c000) +#define MX28_AUART2_BASE_ADDR (MX28_IO_BASE_ADDR + 0x06e000) +#define MX28_AUART3_BASE_ADDR (MX28_IO_BASE_ADDR + 0x070000) +#define MX28_AUART4_BASE_ADDR (MX28_IO_BASE_ADDR + 0x072000) +#define MX28_DUART_BASE_ADDR (MX28_IO_BASE_ADDR + 0x074000) +#define MX28_USBPHY0_BASE_ADDR (MX28_IO_BASE_ADDR + 0x07C000) +#define MX28_USBPHY1_BASE_ADDR (MX28_IO_BASE_ADDR + 0x07e000) +#define MX28_USBCTRL0_BASE_ADDR (MX28_IO_BASE_ADDR + 0x080000) +#define MX28_USBCTRL1_BASE_ADDR (MX28_IO_BASE_ADDR + 0x090000) +#define MX28_DFLPT_BASE_ADDR (MX28_IO_BASE_ADDR + 0x0c0000) +#define MX28_DRAM_BASE_ADDR (MX28_IO_BASE_ADDR + 0x0e0000) +#define MX28_ENET_MAC0_BASE_ADDR (MX28_IO_BASE_ADDR + 0x0f0000) +#define MX28_ENET_MAC1_BASE_ADDR (MX28_IO_BASE_ADDR + 0x0f4000) + +#define MX28_IO_P2V (x) MXS_IO_P2V(x) +#define MX28_IO_ADDRESS (x) IOMEM(MX28_IO_P2V(x)) + +/* +* IRQ +*/ +#define MX28_INT_BATT_BRNOUT 0 +#define MX28_INT_VDDD_BRNOUT 1 +#define MX28_INT_VDDIO_BRNOUT 2 +#define MX28_INT_VDDA_BRNOUT 3 +#define MX28_INT_VDD5V_DROOP 4 +#define MX28_INT_DCDC4P2_BRNOUT 5 +#define MX28_INT_VDD5V 6 +#define MX28_INT_CAN0 8 +#define MX28_INT_CAN1 9 +#define MX28_INT_LRADC_TOUCH 10 +#define MX28_INT_HSADC 13 +#define MX28_INT_IRADC_THRESH0 14 +#define MX28_INT_IRADC_THRESH1 15 +#define MX28_INT_LRADC_CH0 16 +#define MX28_INT_LRADC_CH1 17 +#define MX28_INT_LRADC_CH2 18 +#define MX28_INT_LRADC_CH3 19 +#define MX28_INT_LRADC_CH4 20 +#define MX28_INT_LRADC_CH5 21 +#define MX28_INT_LRADC_CH6 22 +#define MX28_INT_LRADC_CH7 23 +#define MX28_INT_LRADC_BUTTON0 24 +#define MX28_INT_LRADC_BUTTON1 25 +#define MX28_INT_PERFMON 27 +#define MX28_INT_RTC_1MSEC 28 +#define MX28_INT_RTC_ALARM 29 +#define MX28_INT_COMMS 31 +#define MX28_INT_EMI_ERR 32 +#define MX28_INT_LCDIF 38 +#define MX28_INT_PXP 39 +#define MX28_INT_BCH 41 +#define MX28_INT_GPMI 42 +#define MX28_INT_SPDIF_ERROR 45 +#define MX28_INT_DUART 47 +#define MX28_INT_TIMER0 48 +#define MX28_INT_TIMER1 49 +#define MX28_INT_TIMER2 50 +#define MX28_INT_TIMER3 51 +#define MX28_INT_DCP_VMI 52 +#define MX28_INT_DCP 53 +#define MX28_INT_DCP_SECURE 54 +#define MX28_INT_SAIF1 58 +#define MX28_INT_SAIF0 59 +#define MX28_INT_SPDIF_DMA 66 +#define MX28_INT_I2C0_DMA 68 +#define MX28_INT_I2C1_DMA 69 +#define MX28_INT_AUART0_RX_DMA 70 +#define MX28_INT_AUART0_TX_DMA 71 +#define MX28_INT_AUART1_RX_DMA 72 +#define MX28_INT_AUART1_TX_DMA 73 +#define MX28_INT_AUART2_RX_DMA 74 +#define MX28_INT_AUART2_TX_DMA 75 +#define MX28_INT_AUART3_RX_DMA 76 +#define MX28_INT_AUART3_TX_DMA 77 +#define MX28_INT_AUART4_RX_DMA 78 +#define MX28_INT_AUART4_TX_DMA 79 +#define MX28_INT_SAIF0_DMA 80 +#define MX28_INT_SAIF1_DMA 81 +#define MX28_INT_SSP0_DMA 82 +#define MX28_INT_SSP1_DMA 83 +#define MX28_INT_SSP2_DMA 84 +#define MX28_INT_SSP3_DMA 85 +#define MX28_INT_LCDIF_DMA 86 +#define MX28_INT_HSADC_DMA 87 +#define MX28_INT_GPMI_DMA 88 +#define MX28_INT_DIGCTL_DEBUG_TRAP 89 +#define MX28_INT_USB1 92 +#define MX28_INT_USB0 93 +#define MX28_INT_USB1_WAKEUP 94 +#define MX28_INT_USB0_WAKEUP 95 +#define MX28_INT_SSP0 96 +#define MX28_INT_SSP1 97 +#define MX28_INT_SSP2 98 +#define MX28_INT_SSP3 99 +#define MX28_INT_ENET_SWI 100 +#define MX28_INT_ENET_MAC0 101 +#define MX28_INT_ENET_MAC1 102 +#define MX28_INT_ENET_MAC0_1588 103 +#define MX28_INT_ENET_MAC1_1588 104 +#define MX28_INT_I2C1_ERROR 110 +#define MX28_INT_I2C0_ERROR 111 +#define MX28_INT_AUART0 112 +#define MX28_INT_AUART1 113 +#define MX28_INT_AUART2 114 +#define MX28_INT_AUART3 115 +#define MX28_INT_AUART4 116 +#define MX28_INT_GPIO4 123 +#define MX28_INT_GPIO3 124 +#define MX28_INT_GPIO2 125 +#define MX28_INT_GPIO1 126 +#define MX28_INT_GPIO0 127 + +#endif /* __MACH_MX28_H__ */ arch/arm/mach-mxs/include/mach/mxs.h new file +85
-0@@ -0,0 +1,85 @@ +/* +* Copyright (C) 2009-2010 Freescale Semiconductor, Inc. All Rights Reserved. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License along +* with this program; if not, write to the Free Software Foundation, Inc., +* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ + +#ifndef __MACH_MXS_H__ +#define __MACH_MXS_H__ + +#include <asm/mach-types.h> +#include <mach/hardware.h> + +/* +* MXS CPU types +*/ +#define cpu_is_mx23 () (machine_is_mx23evk()) +#define cpu_is_mx28 () (machine_is_mx28evk()) + +#define MXS_SET_ADDR 0x4 +#define MXS_CLR_ADDR 0x8 +#define MXS_TOG_ADDR 0xc + +/* +* IO addresses common to MXS-based +*/ +#define MXS_IO_BASE_ADDR 0x80000000 +#define MXS_IO_SIZE SZ_1M + +#define MXS_ICOLL_BASE_ADDR (MXS_IO_BASE_ADDR + 0x000000) +#define MXS_APBH_DMA_BASE_ADDR (MXS_IO_BASE_ADDR + 0x004000) +#define MXS_BCH_BASE_ADDR (MXS_IO_BASE_ADDR + 0x00a000) +#define MXS_GPMI_BASE_ADDR (MXS_IO_BASE_ADDR + 0x00c000) +#define MXS_PINCTRL_BASE_ADDR (MXS_IO_BASE_ADDR + 0x018000) +#define MXS_DIGCTL_BASE_ADDR (MXS_IO_BASE_ADDR + 0x01c000) +#define MXS_APBX_DMA_BASE_ADDR (MXS_IO_BASE_ADDR + 0x024000) +#define MXS_DCP_BASE_ADDR (MXS_IO_BASE_ADDR + 0x028000) +#define MXS_PXP_BASE_ADDR (MXS_IO_BASE_ADDR + 0x02a000) +#define MXS_OCOTP_BASE_ADDR (MXS_IO_BASE_ADDR + 0x02c000) +#define MXS_AXI_AHB0_BASE_ADDR (MXS_IO_BASE_ADDR + 0x02e000) +#define MXS_LCDIF_BASE_ADDR (MXS_IO_BASE_ADDR + 0x030000) +#define MXS_CLKCTRL_BASE_ADDR (MXS_IO_BASE_ADDR + 0x040000) +#define MXS_SAIF0_BASE_ADDR (MXS_IO_BASE_ADDR + 0x042000) +#define MXS_POWER_BASE_ADDR (MXS_IO_BASE_ADDR + 0x044000) +#define MXS_SAIF1_BASE_ADDR (MXS_IO_BASE_ADDR + 0x046000) +#define MXS_LRADC_BASE_ADDR (MXS_IO_BASE_ADDR + 0x050000) +#define MXS_SPDIF_BASE_ADDR (MXS_IO_BASE_ADDR + 0x054000) +#define MXS_I2C0_BASE_ADDR (MXS_IO_BASE_ADDR + 0x058000) +#define MXS_PWM_BASE_ADDR (MXS_IO_BASE_ADDR + 0x064000) +#define MXS_TIMROT_BASE_ADDR (MXS_IO_BASE_ADDR + 0x068000) +#define MXS_AUART1_BASE_ADDR (MXS_IO_BASE_ADDR + 0x06c000) +#define MXS_AUART2_BASE_ADDR (MXS_IO_BASE_ADDR + 0x06e000) +#define MXS_DRAM_BASE_ADDR (MXS_IO_BASE_ADDR + 0x0e0000) + +/* +* It maps the whole address space to [0xf4000000, 0xf50fffff]. +* +* OCRAM 0x00000000+0x020000 -> 0xf4000000+0x020000 +* IO 0x80000000+0x100000 -> 0xf5000000+0x100000 +*/ +#define MXS_IO_P2V (x) (0xf4000000 + \ + (((x) & 0x80000000) >> 7) + \ + (((x) & 0x000fffff))) + +#define MXS_IO_ADDRESS (x) IOMEM(MXS_IO_P2V(x)) + +#define mxs_map_entry (soc, name, _type) { \ + .virtual = soc ## _IO_P2V(soc ## _ ## name ## _BASE_ADDR), \ + .pfn = __phys_to_pfn(soc ## _ ## name ## _BASE_ADDR), \ + .length = soc ## _ ## name ## _SIZE, \ + .type = _type, \ +} + +#endif /* __MACH_MXS_H__ */ Signature · 8 lines
1.7.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel at lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH v3 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 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 v4 3/15 ARM: mxs: Add reset routines
In reply to Shawn Guo - The mxs wdog is implemented in RTC block.
- There is a generic software reset routine for most modules on mxs.
---
Changes for 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 | 142 +++++++++++++++++++++++++++++++ 2 files changed, 169 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 +142 -0
142 lines not on this page · raw message
Signature · 1 line
1.7.1
PATCH v3 6/15 ARM: mxs: Add timer support
In reply to Shawn GuoFreescale MXS-based SoCs implement timer support in block TIMROT. There are two versions of TIMROT. The v1 on MX23 only gets 16 bits counter and has no match function. The v2 on MX28 extends the counter to 32 bits and add the match function.
As the result, we need two instances of timers with v1 for better implementation, one for clock_event and another for clocksource. Otherwise, get_cycles may get imprecise result after long time cumulating. With v2, one instance can serve two purposes well.
---
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 | 276 +++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 276 insertions(+), 0 deletions(-) create mode 100644 arch/arm/mach-mxs/timer.c
arch/arm/mach-mxs/timer.c new file +276 -0
@@ -0,0 +1,276 @@ +/* +* Copyright (C) 2000-2001 Deep Blue Solutions +* Copyright (C) 2002 Shane Nay (shane at minirl.com) +* Copyright (C) 2006-2007 Pavel Pisa (ppisa at pikron.com) +* Copyright (C) 2008 Juergen Beisert (kernel at pengutronix.de) +* Copyright (C) 2010 Freescale Semiconductor, Inc. All Rights Reserved. +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +* MA 02110-1301, USA. +*/ + +#include <linux/interrupt.h> +#include <linux/irq.h> +#include <linux/clockchips.h> +#include <linux/clk.h> + +#include <mach/hardware.h> +#include <asm/mach/time.h> +#include <mach/common.h> + +/* +* There are 2 versions of the timrot on Freescale MXS-based SoCs. +* The v1 on MX23 only gets 16 bits counter and has no match function. +* The v2 on MX28 extends the counter to 32 bits and add the match function. +* +* As the result, we need two instances of timers with v1 for better +* implementation, one for clock_event and another for clocksource. Otherwise, +* get_cycles may get imprecise result after long time cumulating. +* With v2, one instance can serve two purposes well. +*/ +#define timrot_is_v1 () (cpu_is_mx23()) + +#define HW_TIMROT_ROTCTRL 0x00 +#define HW_TIMROT_TIMCTRLn (n) (0x20 + (n) * 0x40) +#define HW_TIMROT_RUNNING_COUNTn (n) (0x30 + (n) * 0x40) +#define HW_TIMROT_MATCH_COUNTn (n) (0x50 + (n) * 0x40) +#define BM_TIMROT_TIMCTRLn_RELOAD (1 << 6) +#define BM_TIMROT_TIMCTRLn_UPDATE (1 << 7) +#define BM_TIMROT_TIMCTRLn_MATCH_MODE (1 << 11) +#define BM_TIMROT_TIMCTRLn_IRQ_EN (1 << 14) +#define BM_TIMROT_TIMCTRLn_IRQ (1 << 15) +#define BP_TIMROT_TIMCTRLn_SELECT 0 +#define BV_TIMROTv1_TIMCTRLn_SELECT__32KHZ_XTAL 0x8 +#define BV_TIMROTv2_TIMCTRLn_SELECT__32KHZ_XTAL 0xb + +static struct clock_event_device clockevent_mxs; +static enum clock_event_mode clockevent_mode =CLOCK_EVT_MODE_UNUSED ; + +static void __iomem *timer_base; + +static inline void timrot_irq_disable (void ) +{ +__raw_writel (BM_TIMROT_TIMCTRLn_IRQ_EN, + timer_base +HW_TIMROT_TIMCTRLn (0 ) +MXS_CLR_ADDR ); +} + +static inline void timrot_irq_enable (void ) +{ +__raw_writel (BM_TIMROT_TIMCTRLn_IRQ_EN, + timer_base +HW_TIMROT_TIMCTRLn (0 ) +MXS_SET_ADDR ); +} + +static void timrot_irq_acknowledge (void ) +{ +__raw_writel (BM_TIMROT_TIMCTRLn_IRQ, + timer_base +HW_TIMROT_TIMCTRLn (0 ) +MXS_CLR_ADDR ); +} + +static cycle_t timrotv1_get_cycles (struct clocksource *cs) +{ +return ~((__raw_readl (timer_base +HW_TIMROT_RUNNING_COUNTn (1 )) + &0xffff0000 ) >>16 ); +} + +static cycle_t timrotv2_get_cycles (struct clocksource *cs) +{ +return ~__raw_readl (timer_base +HW_TIMROT_RUNNING_COUNTn (0 )); +} + +static int timrotv1_set_next_event (unsigned long evt, +struct clock_event_device *dev) +{ +/* timrot decrements the count */ +__raw_writel (evt, timer_base +HW_TIMROT_RUNNING_COUNTn (0 )); + +return 0 ; +} + +static int timrotv2_set_next_event (unsigned long evt, +struct clock_event_device *dev) +{ +unsigned long match; + +/* timrot decrements the count */ + match =__raw_readl (timer_base +HW_TIMROT_RUNNING_COUNTn (0 )) + - evt; +__raw_writel (match, timer_base +HW_TIMROT_MATCH_COUNTn (0 )); + +return (int )(match -__raw_readl (timer_base + +HW_TIMROT_RUNNING_COUNTn (0 ))) >0 ? -ETIME :0 ; +} + +static irqreturn_t mxs_timer_interrupt (int irq,void *dev_id) +{ +struct clock_event_device *evt = &clockevent_mxs; + +timrot_irq_acknowledge (); + evt->event_handler (evt); + +return IRQ_HANDLED ; +} + +static struct irqaction mxs_timer_irq = { + .name ="MXS Timer Tick" , + .flags =IRQF_TIMER |IRQF_IRQPOLL , + .handler = mxs_timer_interrupt, +}; + +#ifdef DEBUG +static const char *clock_event_mode_label[] = { + [CLOCK_EVT_MODE_PERIODIC ] ="CLOCK_EVT_MODE_PERIODIC" , + [CLOCK_EVT_MODE_ONESHOT ] ="CLOCK_EVT_MODE_ONESHOT" , + [CLOCK_EVT_MODE_SHUTDOWN ] ="CLOCK_EVT_MODE_SHUTDOWN" , + [CLOCK_EVT_MODE_UNUSED ] ="CLOCK_EVT_MODE_UNUSED" +}; +#endif /* DEBUG */ + +static void mxs_set_mode (enum clock_event_mode mode, +struct clock_event_device *evt) +{ +/* Disable interrupt in timer module */ +timrot_irq_disable (); + +if (mode != clockevent_mode) { +/* Set event time into far-far future */ +__raw_writel (__raw_readl (timer_base + +HW_TIMROT_RUNNING_COUNTn (0 )) +3 , + timer_base +HW_TIMROT_MATCH_COUNTn (0 )); + +/* Clear pending interrupt */ +timrot_irq_acknowledge (); + } + +#ifdef DEBUG +printk (KERN_INFO "mxs_set_mode: changing mode from %s to %s\n" , + clock_event_mode_label[clockevent_mode], + clock_event_mode_label[mode]); +#endif /* DEBUG */ + +/* Remember timer mode */ + clockevent_mode = mode; + +switch (mode) { +case CLOCK_EVT_MODE_PERIODIC : +printk (KERN_ERR "mxs_set_mode: Periodic mode is not " +"supported for MXS-based\n" ); +break ; +case CLOCK_EVT_MODE_ONESHOT : +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 clockevent_mxs = { + .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); + + clockevent_mxs.mult =div_sc (c,NSEC_PER_SEC , clockevent_mxs.shift); + clockevent_mxs.cpumask =cpumask_of (0 ); +if (timrot_is_v1 ()) { + clockevent_mxs.set_next_event = timrotv1_set_next_event; + clockevent_mxs.max_delta_ns = +clockevent_delta2ns (0xfffe , &clockevent_mxs); + clockevent_mxs.min_delta_ns = +clockevent_delta2ns (0xf , &clockevent_mxs); + }else { + clockevent_mxs.max_delta_ns = +clockevent_delta2ns (0xfffffffe , &clockevent_mxs); + clockevent_mxs.min_delta_ns = +clockevent_delta2ns (0xff , &clockevent_mxs); + } + +clockevents_register_device (&clockevent_mxs); + +return 0 ; +} + +static struct clocksource clocksource_mxs = { + .name ="mxs_timer" , + .rating =200 , + .read = timrotv2_get_cycles, + .mask =CLOCKSOURCE_MASK (32 ), + .shift =17 , + .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_mxs.mult =clocksource_hz2mult (c, clocksource_mxs.shift); +clocksource_register (&clocksource_mxs); + +return 0 ; +} + +void __init mxs_timer_init (struct clk *timer_clk, +void __iomem *base,int irq) +{ +clk_enable (timer_clk); + + timer_base = base; + +/* +* Initialize timers to a known state +*/ +mxs_reset_block (base +HW_TIMROT_ROTCTRL ); + +if (timrot_is_v1 ()) { +/* timer0 is for clock_event */ +__raw_writel ( + BV_TIMROTv1_TIMCTRLn_SELECT__32KHZ_XTAL | + BM_TIMROT_TIMCTRLn_UPDATE | + BM_TIMROT_TIMCTRLn_IRQ_EN, + base +HW_TIMROT_TIMCTRLn (0 )); +/* timer1 is for clocksource */ +__raw_writel ( + BV_TIMROTv1_TIMCTRLn_SELECT__32KHZ_XTAL | + BM_TIMROT_TIMCTRLn_RELOAD, + base +HW_TIMROT_TIMCTRLn (1 )); +__raw_writel (0xffff , timer_base +HW_TIMROT_RUNNING_COUNTn (1 )); + + }else { +__raw_writel ( + BV_TIMROTv2_TIMCTRLn_SELECT__32KHZ_XTAL | + BM_TIMROT_TIMCTRLn_IRQ_EN | + BM_TIMROT_TIMCTRLn_MATCH_MODE, + timer_base +HW_TIMROT_TIMCTRLn (0 )); + } + +/* init and register the timer to the framework */ +mxs_clocksource_init (timer_clk); +mxs_clockevent_init (timer_clk); + +/* Make irqs happen */ +setup_irq (irq, &mxs_timer_irq); +}
Signature · 1 line
1.7.1
PATCH v3 6/15 ARM: mxs: Add timer support
Quoted 136 lines · Shawn Guo
Freescale MXS-based SoCs implement timer support in block TIMROT. There are two versions of TIMROT. The v1 on MX23 only gets 16 bits counter and has no match function. The v2 on MX28 extends the counter to 32 bits and add the match function.
As the result, we need two instances of timers with v1 for better implementation, one for
clock_eventand another for clocksource. Otherwise,get_cyclesmay get imprecise result after long time cumulating. With v2, one instance can serve two purposes well.Signed-off-by Shawn Guo <[email protected]>---
Changes for v3:
- Use termclock_eventovernext_eventand clocksource overget_cycles
- SplitBV_TIMROT_TIMCTRLn_SELECT__32KHZ_XTALinto two definitions for v1 and v2 respectively
- Turntimrot_get_cycles()intotimrotv1_get_cycles()andtimrotv2_get_cycles()
- Turntimrot_set_next_event()intotimrotv1_set_next_event()andtimrotv2_set_next_event()
- Skip flagIRQF_DISABLED
- Remove unncessary IRQ disabling inmxs_set_mode()
- Change shift ofclocksource_mxsto 17Changes for v2:
- Fix a bug intimrot_set_next_event(). It should readHW_TIMROT_RUNNING_COUNTnto get the current counts.arch/arm/mach-mxs/timer.c | 276 +++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 276 insertions(+), 0 deletions(-) create mode 100644 arch/arm/mach-mxs/timer.carch/arm/mach-mxs/timer.c new file +101
-0@@ -0,0 +1,276 @@ +/* +* Copyright (C) 2000-2001 Deep Blue Solutions +* Copyright (C) 2002 Shane Nay (shane at minirl.com) +* Copyright (C) 2006-2007 Pavel Pisa (ppisa at pikron.com) +* Copyright (C) 2008 Juergen Beisert (kernel at pengutronix.de) +* Copyright (C) 2010 Freescale Semiconductor, Inc. All Rights Reserved. +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +* MA 02110-1301, USA. +*/ + +#include <linux/interrupt.h> +#include <linux/irq.h> +#include <linux/clockchips.h> +#include <linux/clk.h> + +#include <mach/hardware.h> +#include <asm/mach/time.h> +#include <mach/common.h> + +/* +* There are 2 versions of the timrot on Freescale MXS-based SoCs. +* The v1 on MX23 only gets 16 bits counter and has no match function. +* The v2 on MX28 extends the counter to 32 bits and add the match function. +* +* As the result, we need two instances of timers with v1 for better +* implementation, one for clock_event and another for clocksource. Otherwise, +* get_cycles may get imprecise result after long time cumulating. +* With v2, one instance can serve two purposes well. +*/ +#define timrot_is_v1 () (cpu_is_mx23()) + +#define HW_TIMROT_ROTCTRL 0x00 +#define HW_TIMROT_TIMCTRLn (n) (0x20 + (n) * 0x40) +#define HW_TIMROT_RUNNING_COUNTn (n) (0x30 + (n) * 0x40) +#define HW_TIMROT_MATCH_COUNTn (n) (0x50 + (n) * 0x40) +#define BM_TIMROT_TIMCTRLn_RELOAD (1 << 6) +#define BM_TIMROT_TIMCTRLn_UPDATE (1 << 7) +#define BM_TIMROT_TIMCTRLn_MATCH_MODE (1 << 11) +#define BM_TIMROT_TIMCTRLn_IRQ_EN (1 << 14) +#define BM_TIMROT_TIMCTRLn_IRQ (1 << 15) +#define BP_TIMROT_TIMCTRLn_SELECT 0 +#define BV_TIMROTv1_TIMCTRLn_SELECT__32KHZ_XTAL 0x8 +#define BV_TIMROTv2_TIMCTRLn_SELECT__32KHZ_XTAL 0xb + +static struct clock_event_device clockevent_mxs; +static enum clock_event_mode clockevent_mode =CLOCK_EVT_MODE_UNUSED ; + +static void __iomem *timer_base; + +static inline void timrot_irq_disable (void ) +{ +__raw_writel (BM_TIMROT_TIMCTRLn_IRQ_EN, + timer_base +HW_TIMROT_TIMCTRLn (0 ) +MXS_CLR_ADDR ); +} + +static inline void timrot_irq_enable (void ) +{ +__raw_writel (BM_TIMROT_TIMCTRLn_IRQ_EN, + timer_base +HW_TIMROT_TIMCTRLn (0 ) +MXS_SET_ADDR ); +} + +static void timrot_irq_acknowledge (void ) +{ +__raw_writel (BM_TIMROT_TIMCTRLn_IRQ, + timer_base +HW_TIMROT_TIMCTRLn (0 ) +MXS_CLR_ADDR ); +} + +static cycle_t timrotv1_get_cycles (struct clocksource *cs) +{ +return ~((__raw_readl (timer_base +HW_TIMROT_RUNNING_COUNTn (1 )) + &0xffff0000 ) >>16 ); +} + +static cycle_t timrotv2_get_cycles (struct clocksource *cs) +{ +return ~__raw_readl (timer_base +HW_TIMROT_RUNNING_COUNTn (0 )); +} + +static int timrotv1_set_next_event (unsigned long evt, +struct clock_event_device *dev) +{ +/* timrot decrements the count */ +__raw_writel (evt, timer_base +HW_TIMROT_RUNNING_COUNTn (0 )); + +return 0 ; +} + +static int timrotv2_set_next_event (unsigned long evt, +struct clock_event_device *dev)
arch/arm/mach-mxs/timer.c line 111
Quoted 10 lines
arch/arm/mach-mxs/timer.c new file +10
-0+{ +unsigned long match; + +/* timrot decrements the count */ + match =__raw_readl (timer_base +HW_TIMROT_RUNNING_COUNTn (0 )) + - evt; +__raw_writel (match, timer_base +HW_TIMROT_MATCH_COUNTn (0 )); + +return (int )(match -__raw_readl (timer_base + +HW_TIMROT_RUNNING_COUNTn (0 ))) >0 ? -ETIME :0 ;
Wouldn't it be easier to use the same approach as in timrotv1? (i.e. use two timers and then having a simpler set_next_event.)
arch/arm/mach-mxs/timer.c line 116
Quoted 5 lines
arch/arm/mach-mxs/timer.c new file +5
-0+} + +static irqreturn_t mxs_timer_interrupt (int irq,void *dev_id) +{ +struct clock_event_device *evt = &clockevent_mxs;
I assume dev_id is &clockevent_mxs
Quoted 41 lines
arch/arm/mach-mxs/timer.c new file +41
-0+ +timrot_irq_acknowledge (); + evt->event_handler (evt); + +return IRQ_HANDLED ; +} + +static struct irqaction mxs_timer_irq = { + .name ="MXS Timer Tick" , + .flags =IRQF_TIMER |IRQF_IRQPOLL , + .handler = mxs_timer_interrupt, +}; + +#ifdef DEBUG +static const char *clock_event_mode_label[] = { + [CLOCK_EVT_MODE_PERIODIC ] ="CLOCK_EVT_MODE_PERIODIC" , + [CLOCK_EVT_MODE_ONESHOT ] ="CLOCK_EVT_MODE_ONESHOT" , + [CLOCK_EVT_MODE_SHUTDOWN ] ="CLOCK_EVT_MODE_SHUTDOWN" , + [CLOCK_EVT_MODE_UNUSED ] ="CLOCK_EVT_MODE_UNUSED" +}; +#endif /* DEBUG */ + +static void mxs_set_mode (enum clock_event_mode mode, +struct clock_event_device *evt) +{ +/* Disable interrupt in timer module */ +timrot_irq_disable (); + +if (mode != clockevent_mode) { +/* Set event time into far-far future */ +__raw_writel (__raw_readl (timer_base + +HW_TIMROT_RUNNING_COUNTn (0 )) +3 , + timer_base +HW_TIMROT_MATCH_COUNTn (0 )); + +/* Clear pending interrupt */ +timrot_irq_acknowledge (); + } + +#ifdef DEBUG + printk(KERN_INFO "mxs_set_mode: changing mode from %s to %s\n", + clock_event_mode_label[clockevent_mode],
arch/arm/mach-mxs/timer.c line 167
Quoted 10 lines
arch/arm/mach-mxs/timer.c new file +10
-0+ clock_event_mode_label[mode]); +#endif /* DEBUG */ + +/* Remember timer mode */ + clockevent_mode = mode; + +switch (mode) { +case CLOCK_EVT_MODE_PERIODIC : +printk (KERN_ERR "mxs_set_mode: Periodic mode is not " +"supported for MXS-based\n" );
It's more that it's not implemented. (At least it could be provided when a dedicated timer is used for clock_event.)
Quoted 28 lines
arch/arm/mach-mxs/timer.c new file +28
-0+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 clockevent_mxs = { + .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); + + clockevent_mxs.mult =div_sc (c,NSEC_PER_SEC , clockevent_mxs.shift); + clockevent_mxs.cpumask =cpumask_of (0 ); +if (timrot_is_v1 ()) {
arch/arm/mach-mxs/timer.c line 205
Quoted 10 lines
arch/arm/mach-mxs/timer.c new file +10
-0+ clockevent_mxs.set_next_event = timrotv1_set_next_event; + clockevent_mxs.max_delta_ns = +clockevent_delta2ns (0xfffe , &clockevent_mxs); + clockevent_mxs.min_delta_ns = +clockevent_delta2ns (0xf , &clockevent_mxs); + }else { + clockevent_mxs.max_delta_ns = +clockevent_delta2ns (0xfffffffe , &clockevent_mxs); + clockevent_mxs.min_delta_ns = +clockevent_delta2ns (0xff , &clockevent_mxs);
Why is timrotv1's min_delta smaller than v2's?
Quoted 61 lines
arch/arm/mach-mxs/timer.c new file +61
-0+ } + +clockevents_register_device (&clockevent_mxs); + +return 0 ; +} + +static struct clocksource clocksource_mxs = { + .name ="mxs_timer" , + .rating =200 , + .read = timrotv2_get_cycles, + .mask =CLOCKSOURCE_MASK (32 ), + .shift =17 , + .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_mxs.mult =clocksource_hz2mult (c, clocksource_mxs.shift); +clocksource_register (&clocksource_mxs); + +return 0 ; +} + +void __init mxs_timer_init (struct clk *timer_clk, +void __iomem *base,int irq) +{ +clk_enable (timer_clk); + + timer_base = base; + +/* +* Initialize timers to a known state +*/ +mxs_reset_block (base +HW_TIMROT_ROTCTRL ); + +if (timrot_is_v1 ()) { +/* timer0 is for clock_event */ +__raw_writel ( + BV_TIMROTv1_TIMCTRLn_SELECT__32KHZ_XTAL | + BM_TIMROT_TIMCTRLn_UPDATE | + BM_TIMROT_TIMCTRLn_IRQ_EN, + base +HW_TIMROT_TIMCTRLn (0 )); +/* timer1 is for clocksource */ +__raw_writel ( + BV_TIMROTv1_TIMCTRLn_SELECT__32KHZ_XTAL | + BM_TIMROT_TIMCTRLn_RELOAD, + base +HW_TIMROT_TIMCTRLn (1 )); +__raw_writel (0xffff , timer_base +HW_TIMROT_RUNNING_COUNTn (1 )); + + }else { + __raw_writel( + BV_TIMROTv2_TIMCTRLn_SELECT__32KHZ_XTAL | + BM_TIMROT_TIMCTRLn_IRQ_EN | + BM_TIMROT_TIMCTRLn_MATCH_MODE,
arch/arm/mach-mxs/timer.c line 276
Quoted 10 lines
arch/arm/mach-mxs/timer.c new file +10
-0+ timer_base + HW_TIMROT_TIMCTRLn(0)); + } + +/* init and register the timer to the framework */ +mxs_clocksource_init (timer_clk); +mxs_clockevent_init (timer_clk); + +/* Make irqs happen */ +setup_irq (irq, &mxs_timer_irq); +}
Best regards
Uwe
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-K?nig | Industrial Linux Solutions | http://www.pengutronix.de/ |
PATCH v3 6/15 ARM: mxs: Add timer support
Hi Uwe,
2010/12/8 Uwe Kleine-K?nig <[email protected]>:
Quoted 1 line · Shawn Guo
[...]
Quoted 6 lines
Quoted 6 lines
arch/arm/mach-mxs/timer.c new file +6
-0+static int timrotv2_set_next_event (unsigned long evt, + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? struct clock_event_device *dev) +{ + ? ? unsigned long match; + + ? ? /* timrot decrements the count */
Quoted 9 lines
Quoted 6 lines
+ ? ? match =
__raw_readl(timer_base + HW_TIMROT_RUNNING_COUNTn(0))
+ ? ? ? ? ? ? ? ? ? ? - evt;
+ ? ?__raw_writel(match, timer_base + HW_TIMROT_MATCH_COUNTn(0)); +
+ ? ? return (int)(match - __raw_readl(timer_base +
+ ? ? ? ? ? ? ? ? ? ?HW_TIMROT_RUNNING_COUNTn(0))) > 0 ?-ETIME: 0;Wouldn't it be easier to use the same approach as in timrotv1? ?(i.e. use two timers and then having a simpler
set_next_event.)
Using two timrotv1 timers is not to make code look simpler. Instead, we have to use two, because timrotv1 has no match function. One most significant improvement of v2 over v1 is adding match function, so that one v2 timer can serve clock_event and clocksource without problem. I would keep the implementation to utilize v2 capability, save timer resource and show the difference between v1 and v2.
Quoted 7 lines
arch/arm/mach-mxs/timer.c
Quoted 5 lines
arch/arm/mach-mxs/timer.c new file +5
-0+} + +static irqreturn_t mxs_timer_interrupt (int irq,void *dev_id) +{ + ? ? struct clock_event_device *evt = &clockevent_mxs;I assume
dev_idis&clockevent_mxs
The assumption is only true if we assign &clockevent_mxs to dev_id. So you want to see the following change?
static irqreturn_t mxs_timer_interrupt(int irq, void *dev_id) {
- struct clock_event_device *evt = &clockevent_mxs;
+ struct clock_event_device *evt = dev_id;
timrot_irq_acknowledge();
evt->event_handler(evt); static struct irqaction mxs_timer_irq = {
.name = "MXS Timer Tick",
+ .dev_id = &clockevent_mxs,
.flags = IRQF_TIMER | IRQF_IRQPOLL,
.handler = mxs_timer_interrupt,};
Signature · 2 lines
Regards, Shawn
PATCH v3 6/15 ARM: mxs: Add timer support
Quoted 20 lines · Shawn Guo
Hi Uwe,
2010/12/8 Uwe Kleine-K?nig <[email protected]>:
Quoted 1 line · Shawn Guo
[...]
Quoted 6 lines
Quoted 6 lines
arch/arm/mach-mxs/timer.c new file +6
-0+static int timrotv2_set_next_event (unsigned long evt, + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? struct clock_event_device *dev) +{ + ? ? unsigned long match; + + ? ? /* timrot decrements the count */Quoted 9 lines
Quoted 6 lines
+ ? ? match =
__raw_readl(timer_base + HW_TIMROT_RUNNING_COUNTn(0))
+ ? ? ? ? ? ? ? ? ? ? - evt;
+ ? ?__raw_writel(match, timer_base + HW_TIMROT_MATCH_COUNTn(0)); +
+ ? ? return (int)(match - __raw_readl(timer_base +
+ ? ? ? ? ? ? ? ? ? ?HW_TIMROT_RUNNING_COUNTn(0))) > 0 ?-ETIME: 0;Wouldn't it be easier to use the same approach as in timrotv1? ?(i.e. use two timers and then having a simpler
set_next_event.)
Quoted 6 lines
Using two timrotv1 timers is not to make code look simpler. Instead, we have to use two, because timrotv1 has no match function. One most significant improvement of v2 over v1 is adding match function, so that one v2 timer can serve
clock_eventand clocksource without problem. I would keep the implementation to utilize v2 capability, save timer resource and show the difference between v1 and v2.
Is there an advantage of keeping one additional timer unused? IMHO it doesn't make much sense to use the match support just because it exists if it doesn't make things easier. Here the main impact is that it complicates the set_next_event callback.
Quoted 12 lines
Quoted 7 lines
arch/arm/mach-mxs/timer.c
Quoted 5 lines
arch/arm/mach-mxs/timer.c new file +5
-0+} + +static irqreturn_t mxs_timer_interrupt (int irq,void *dev_id) +{ + ? ? struct clock_event_device *evt = &clockevent_mxs;I assume
dev_idis&clockevent_mxsThe assumption is only true if we assign
&clockevent_mxstodev_id. So you want to see the following change?static
irqreturn_tmxs_timer_interrupt(int irq, void *dev_id){
Review
Quoted 2 lines
(quoted diff) +1
-1- struct clock_event_device *evt = &clockevent_mxs; + struct clock_event_device *evt = dev_id;
This might save an instruction or two.
Quoted 9 lines
timrot_irq_acknowledge(); evt->event_handler(evt);static struct irqaction
mxs_timer_irq= {.name = "MXS Timer Tick", + .dev_id = &clockevent_mxs, .flags = IRQF_TIMER | IRQF_IRQPOLL, .handler = mxs_timer_interrupt,};
This looks more correct at least (IMHO).
Uwe
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-K?nig | Industrial Linux Solutions | http://www.pengutronix.de/ |
PATCH v3 6/15 ARM: mxs: Add timer support
In reply to Shawn GuoHi,
Quoted 34 lines · Shawn Guo
Freescale MXS-based SoCs implement timer support in block TIMROT. There are two versions of TIMROT. The v1 on MX23 only gets 16 bits counter and has no match function. The v2 on MX28 extends the counter to 32 bits and add the match function.
As the result, we need two instances of timers with v1 for better implementation, one for
clock_eventand another for clocksource. Otherwise,get_cyclesmay get imprecise result after long time cumulating. With v2, one instance can serve two purposes well.Signed-off-by Shawn Guo <[email protected]>---
Changes for v3:
- Use termclock_eventovernext_eventand clocksource overget_cycles
- SplitBV_TIMROT_TIMCTRLn_SELECT__32KHZ_XTALinto two definitions for v1 and v2 respectively
- Turntimrot_get_cycles()intotimrotv1_get_cycles()andtimrotv2_get_cycles()
- Turntimrot_set_next_event()intotimrotv1_set_next_event()andtimrotv2_set_next_event()
- Skip flagIRQF_DISABLED
- Remove unncessary IRQ disabling inmxs_set_mode()
- Change shift ofclocksource_mxsto 17Changes for v2:
- Fix a bug intimrot_set_next_event(). It should readHW_TIMROT_RUNNING_COUNTnto get the current counts.arch/arm/mach-mxs/timer.c | 276 +++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 276 insertions(+), 0 deletions(-) create mode 100644 arch/arm/mach-mxs/timer.carch/arm/mach-mxs/timer.c new file +0
-0
[...]
arch/arm/mach-mxs/timer.c line 167
Quoted 5 lines
arch/arm/mach-mxs/timer.c new file +4
-0+switch (mode) { +case CLOCK_EVT_MODE_PERIODIC : +printk (KERN_ERR "mxs_set_mode: Periodic mode is not " +"supported for MXS-based\n" );
Please do not line wrap message strings. Also, if you want the function name to appear in the message, use __func__ or __FUNCTION__. That way the name is always correct even if the function is renamed or the printk() statement is copied to a different function.
Lothar Wa?mann
Signature · 9 lines
___________________________________________________________ Ka-Ro electronics GmbH | Pascalstra?e 22 | D - 52076 Aachen Phone: +49 2408 1402-0 | Fax: +49 2408 1402-10 Gesch?ftsf?hrer: Matthias Kaussen Handelsregistereintrag: Amtsgericht Aachen, HRB 4996 www.karo-electronics.de | info at karo-electronics.de ___________________________________________________________
PATCH v3 6/15 ARM: mxs: Add timer support
Hello Lothar,
Quoted 9 lines · Lothar Wa?mann
arch/arm/mach-mxs/timer.c line 167
Quoted 5 lines
arch/arm/mach-mxs/timer.c new file +4
-0+switch (mode) { +case CLOCK_EVT_MODE_PERIODIC : +printk (KERN_ERR "mxs_set_mode: Periodic mode is not " +"supported for MXS-based\n" );Please do not line wrap message strings. Also, if you want the function name to appear in the message, use
__func__or__FUNCTION__. That way the name is always correct even if the function is renamed or theprintk()statement is copied to a different function.
__FUNCTION__ isn't considered good, so please use __func__. (__FUNCTION__ is a gcc extension, __func__ is c99 (I think)). checkpatch warns about __FUNCTION__, too.
Shawn, you can also consider using pr_err.
Uwe
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-K?nig | Industrial Linux Solutions | http://www.pengutronix.de/ |
PATCH v3 7/15 ARM: mxs: Add gpio support
In reply to Shawn GuoMXS-based SoCs implement gpio support in block PINCTRL.
---
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 | 321 +++++++++++++++++++++++++++++++++ arch/arm/mach-mxs/gpio.h | 33 ++++ arch/arm/mach-mxs/include/mach/gpio.h | 34 ++++ 3 files changed, 388 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 +321 -0
@@ -0,0 +1,321 @@ +/* +* 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) +{ +__raw_writel (1 << index, + port->base +PINCTRL_IRQSTAT (port->id) +MXS_CLR_ADDR ); +} + +static void _set_gpio_irqenable (struct mxs_gpio_port *port,u32 index, +int enable) +{ +if (enable ==0 ) { +__raw_writel (1 << index, + port->base +PINCTRL_PIN2IRQ (port->id) +MXS_CLR_ADDR ); +__raw_writel (1 << index, + port->base +PINCTRL_IRQEN (port->id) +MXS_CLR_ADDR ); + }else { +__raw_writel (1 << index, + port->base +PINCTRL_PIN2IRQ (port->id) +MXS_SET_ADDR ); +__raw_writel (1 << index, + port->base +PINCTRL_IRQEN (port->id) +MXS_SET_ADDR ); + } +} + +static void gpio_ack_irq (u32 irq) +{ +u32 gpio =irq_to_gpio (irq); +_clear_gpio_irqstatus (&mxs_gpio_ports[gpio /32 ], gpio &0x1f ); +} + +static void gpio_mask_irq (u32 irq) +{ +u32 gpio =irq_to_gpio (irq); +_set_gpio_irqenable (&mxs_gpio_ports[gpio /32 ], gpio &0x1f ,0 ); +} + +static void gpio_unmask_irq (u32 irq) +{ +u32 gpio =irq_to_gpio (irq); +_set_gpio_irqenable (&mxs_gpio_ports[gpio /32 ], gpio &0x1f ,1 ); +} + +static int mxs_gpio_get (struct gpio_chip *chip,unsigned offset); + +static int gpio_set_irq_type (u32 irq,u32 type) +{ +u32 gpio =irq_to_gpio (irq); +struct mxs_gpio_port *port = &mxs_gpio_ports[gpio /32 ]; +int edge; + +switch (type) { +case IRQ_TYPE_EDGE_RISING : + edge =GPIO_INT_RISE_EDGE ; +break ; +case IRQ_TYPE_EDGE_FALLING : + edge =GPIO_INT_FALL_EDGE ; +break ; +case IRQ_TYPE_LEVEL_LOW : + edge =GPIO_INT_LOW_LEV ; +break ; +case IRQ_TYPE_LEVEL_HIGH : + edge =GPIO_INT_HIGH_LEV ; +break ; +default : +return -EINVAL ; + } + +/* set level or edge */ +if (edge &GPIO_INT_LEV_MASK ) +__raw_writel (1 << (gpio &31 ), + port->base +PINCTRL_IRQLEV (port->id) +MXS_SET_ADDR ); +else +__raw_writel (1 << (gpio &31 ), + port->base +PINCTRL_IRQLEV (port->id) +MXS_CLR_ADDR ); + +/* set polarity */ +if (edge &GPIO_INT_POL_MASK ) +__raw_writel (1 << (gpio &31 ), + port->base +PINCTRL_IRQPOL (port->id) +MXS_SET_ADDR ); +else +__raw_writel (1 << (gpio &31 ), + port->base +PINCTRL_IRQPOL (port->id) +MXS_CLR_ADDR ); + +_clear_gpio_irqstatus (port, gpio &0x1f ); + +return 0 ; +} + +/* MXS has one interrupt *per* gpio port */ +static void mxs_gpio_irq_handler (u32 irq,struct irq_desc *desc) +{ +u32 irq_stat; +struct mxs_gpio_port *port = (struct mxs_gpio_port *)get_irq_data (irq); +u32 gpio_irq_no_base = port->virtual_irq_start; + + irq_stat =__raw_readl (port->base +PINCTRL_IRQSTAT (port->id)) & +__raw_readl (port->base +PINCTRL_IRQEN (port->id)) & +__raw_readl (port->base +PINCTRL_PIN2IRQ (port->id)); + +while (irq_stat !=0 ) { +int irqoffset =fls (irq_stat) -1 ; +generic_handle_irq (gpio_irq_no_base + irqoffset); + irq_stat &= ~(1 << irqoffset); + } +} + +/* +* Set interrupt number "irq" in the GPIO as a wake-up source. +* While system is running, all registered GPIO interrupts need to have +* wake-up enabled. When system is suspended, only selected GPIO interrupts +* need to have wake-up enabled. +* @param irq interrupt source number +* @param enable enable as wake-up if equal to non-zero +* @return This function returns 0 on success. +*/ +static int gpio_set_wake_irq (u32 irq,u32 enable) +{ +u32 gpio =irq_to_gpio (irq); +u32 gpio_idx = gpio &0x1f ; +struct mxs_gpio_port *port = &mxs_gpio_ports[gpio /32 ]; + +if (enable) { +if (port->irq_high && (gpio_idx >=16 )) +enable_irq_wake (port->irq_high); +else +enable_irq_wake (port->irq); + }else { +if (port->irq_high && (gpio_idx >=16 )) +disable_irq_wake (port->irq_high); +else +disable_irq_wake (port->irq); + } + +return 0 ; +} + +static struct irq_chip gpio_irq_chip = { + .ack = gpio_ack_irq, + .mask = gpio_mask_irq, + .unmask = gpio_unmask_irq, + .set_type = gpio_set_irq_type, + .set_wake = gpio_set_wake_irq, +}; + +static void _set_gpio_direction (struct gpio_chip *chip,unsigned offset, +int dir) +{ +struct mxs_gpio_port *port = + container_of(chip, struct mxs_gpio_port, chip); + +if (dir) +__raw_writel (1 << offset, + port->base +PINCTRL_DOE (port->id) +MXS_SET_ADDR ); +else +__raw_writel (1 << offset, + port->base +PINCTRL_DOE (port->id) +MXS_CLR_ADDR ); +} + +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); + +__raw_writel (1 << offset, port->base +PINCTRL_DOUT (port->id) + + (value ?MXS_SET_ADDR :MXS_CLR_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 int mxs_gpio_direction_input (struct gpio_chip *chip,unsigned offset) +{ +_set_gpio_direction (chip, offset,0 ); +return 0 ; +} + +static int mxs_gpio_direction_output (struct gpio_chip *chip, +unsigned offset,int value) +{ +mxs_gpio_set (chip, offset, value); +_set_gpio_direction (chip, offset,1 ); +return 0 ; +} + +int __init mxs_gpio_init (struct mxs_gpio_port *port,int cnt) +{ +int i, j; + +/* save for local usage */ + mxs_gpio_ports = port; + gpio_table_size = cnt; + +pr_info ("MXS GPIO hardware\n" ); + +for (i =0 ; i < cnt; i++) { +/* disable the interrupt and clear the status */ +__raw_writel (0 , port[i].base + +PINCTRL_PIN2IRQ (i)); +__raw_writel (0 , port[i].base + +PINCTRL_IRQEN (i)); +__raw_writel (~0 , port[i].base + +PINCTRL_IRQSTAT (i) +MXS_CLR_ADDR ); + +for (j = port[i].virtual_irq_start; + j < port[i].virtual_irq_start +32 ; j++) { +set_irq_chip (j, &gpio_irq_chip); +set_irq_handler (j, handle_level_irq); +set_irq_flags (j,IRQF_VALID ); + } + +/* register gpio chip */ + port[i].chip.direction_input = mxs_gpio_direction_input; + port[i].chip.direction_output = mxs_gpio_direction_output; + port[i].chip.get = mxs_gpio_get; + port[i].chip.set = mxs_gpio_set; + port[i].chip.base = i *32 ; + port[i].chip.ngpio =32 ; + +/* its a serious configuration bug when it fails */ +BUG_ON (gpiochip_add (&port[i].chip) <0 ); + +/* setup one handler for each entry */ +set_irq_chained_handler (port[i].irq, mxs_gpio_irq_handler); +set_irq_data (port[i].irq, &port[i]); + } + +return 0 ; +} + +#define DEFINE_MXS_GPIO_PORT (soc, _id) \ + { \ + .chip.label = "gpio-" #_id, \ + .id = _id, \ + .irq = soc ## _INT_GPIO ## _id, \ + .base = soc ## _IO_ADDRESS( \ + soc ## _PINCTRL ## _BASE_ADDR), \ + .virtual_irq_start = MXS_GPIO_IRQ_START + (_id) * 32, \ + } + +#define DEFINE_REGISTER_FUNCTION (prefix) \ +int __init prefix ## _register_gpios(void) \ +{ \ + return mxs_gpio_init(prefix ## _gpio_ports, \ + ARRAY_SIZE(prefix ## _gpio_ports)); \ +} + +#ifdef CONFIG_SOC_IMX23 +static struct mxs_gpio_port mx23_gpio_ports[] = { +DEFINE_MXS_GPIO_PORT (MX23 ,0 ), +DEFINE_MXS_GPIO_PORT (MX23 ,1 ), +DEFINE_MXS_GPIO_PORT (MX23 ,2 ), +}; +DEFINE_REGISTER_FUNCTION(mx23) +#endif + +#ifdef CONFIG_SOC_IMX28 +static struct mxs_gpio_port mx28_gpio_ports[] = { +DEFINE_MXS_GPIO_PORT (MX28 ,0 ), +DEFINE_MXS_GPIO_PORT (MX28 ,1 ), +DEFINE_MXS_GPIO_PORT (MX28 ,2 ), +DEFINE_MXS_GPIO_PORT (MX28 ,3 ), +DEFINE_MXS_GPIO_PORT (MX28 ,4 ), +}; +DEFINE_REGISTER_FUNCTION(mx28) +#endif
arch/arm/mach-mxs/gpio.h new file +33 -0
@@ -0,0 +1,33 @@ +/* +* 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 +34 -0
@@ -0,0 +1,34 @@ +/* +* 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) (MXS_GPIO_IRQ_START + (gpio)) +#define irq_to_gpio (irq) ((irq) - MXS_GPIO_IRQ_START) + +#endif /* __MACH_MXS_GPIO_H__ */
Signature · 1 line
1.7.1
PATCH v3 7/15 ARM: mxs: Add gpio support
Hi,
Quoted 88 lines · Shawn Guo
MXS-based SoCs implement gpio support in block PINCTRL.
Signed-off-by Shawn Guo <[email protected]>---
Changes for v3:
-include/mach/gpio.h: remove the inclusion ofhardware.h
-gpio.c: change inclusion ofhardware.htomx23.hplusmx28.h
- Remove spinlock totally since SET/CLE can be used in all the gpio register accessChanges for v2:
- Createarch/arm/mach-mxs/gpio.hto accommodate stuff private for mach-mxs
- UseGPIO_INT_LEV_MASKandGPIO_INT_POL_MASKinstead of constant
- Remove both edges IRQ support which is not needed
- Use SET and CLR register ofPINCTRL_DOEin_set_gpio_direction()
- Usepr_infooverprintk(KERN_INFO)arch/arm/mach-mxs/gpio.c | 321 +++++++++++++++++++++++++++++++++ arch/arm/mach-mxs/gpio.h | 33 ++++ arch/arm/mach-mxs/include/mach/gpio.h | 34 ++++ 3 files changed, 388 insertions(+), 0 deletions(-) create mode 100644 arch/arm/mach-mxs/gpio.c create mode 100644 arch/arm/mach-mxs/gpio.h create mode 100644 arch/arm/mach-mxs/include/mach/gpio.harch/arm/mach-mxs/gpio.c new file +57
-0@@ -0,0 +1,321 @@ +/* +* 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) +{ +__raw_writel (1 << index, + port->base +PINCTRL_IRQSTAT (port->id) +MXS_CLR_ADDR );
arch/arm/mach-mxs/gpio.c line 67
Quoted 10 lines
arch/arm/mach-mxs/gpio.c new file +10
-0+} + +static void _set_gpio_irqenable (struct mxs_gpio_port *port,u32 index, +int enable) +{ +if (enable ==0 ) { +__raw_writel (1 << index, + port->base +PINCTRL_PIN2IRQ (port->id) +MXS_CLR_ADDR ); +__raw_writel (1 << index, + port->base +PINCTRL_IRQEN (port->id) +MXS_CLR_ADDR );
This will loose interrupt pulses that happen while IRQs are disabled. IMO PIN2IRQ should only be cleared when an IRQ is freed, not when it is disabled.
Lothar Wa?mann
Signature · 9 lines
___________________________________________________________ Ka-Ro electronics GmbH | Pascalstra?e 22 | D - 52076 Aachen Phone: +49 2408 1402-0 | Fax: +49 2408 1402-10 Gesch?ftsf?hrer: Matthias Kaussen Handelsregistereintrag: Amtsgericht Aachen, HRB 4996 www.karo-electronics.de | info at karo-electronics.de ___________________________________________________________
PATCH v3 7/15 ARM: mxs: Add gpio support
Hi Lothar,
Quoted 96 lines · Lothar Wa?mann
Hi,
Quoted 93 lines · Shawn Guo
MXS-based SoCs implement gpio support in block PINCTRL.
Signed-off-by Shawn Guo <[email protected]>---
Changes for v3:
?-include/mach/gpio.h: remove the inclusion ofhardware.h?-gpio.c: change inclusion ofhardware.htomx23.hplusmx28.h?- Remove spinlock totally since SET/CLE can be used in all the ? ?gpio register accessChanges for v2:
?- Createarch/arm/mach-mxs/gpio.hto accommodate stuff private for mach-mxs ?- UseGPIO_INT_LEV_MASKandGPIO_INT_POL_MASKinstead of constant ?- Remove both edges IRQ support which is not needed
?- Use SET and CLR register ofPINCTRL_DOEin_set_gpio_direction()?- Usepr_infooverprintk(KERN_INFO)?arch/arm/mach-mxs/gpio.c ? ? ? ? ? ? ?| ?321 +++++++++++++++++++++++++++++++++ ?arch/arm/mach-mxs/gpio.h ? ? ? ? ? ? ?| ? 33 ++++ ?arch/arm/mach-mxs/include/mach/gpio.h | ? 34 ++++?3 files changed, 388 insertions(+), 0 deletions(-) ?create mode 100644
arch/arm/mach-mxs/gpio.c?create mode 100644arch/arm/mach-mxs/gpio.h?create mode 100644arch/arm/mach-mxs/include/mach/gpio.harch/arm/mach-mxs/gpio.c new file +62
-0@@ -0,0 +1,321 @@ +/* +* 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) +{ + ? ? __raw_writel(1 << index, + ? ? ? ? ? ? ? ? ? ? port->base + PINCTRL_IRQSTAT(port->id) + MXS_CLR_ADDR); +} + +static void _set_gpio_irqenable (struct mxs_gpio_port *port,u32 index, + ? ? ? ? ? ? ? ? ? ? ? ? ? ? int enable) +{
Quoted 9 lines
arch/arm/mach-mxs/gpio.c line 67
Quoted 5 lines
arch/arm/mach-mxs/gpio.c new file +5
-0+ ? ? if (enable == 0) { + ? ? ? ? ? ? __raw_writel(1 << index, + ? ? ? ? ? ? ? ? ? ? port->base + PINCTRL_PIN2IRQ(port->id) + MXS_CLR_ADDR); + ? ? ? ? ? ? __raw_writel(1 << index, + ? ? ? ? ? ? ? ? ? ? port->base + PINCTRL_IRQEN(port->id) + MXS_CLR_ADDR);This will loose interrupt pulses that happen while IRQs are disabled. IMO PIN2IRQ should only be cleared when an IRQ is freed, not when it is disabled.
What about leaving PIN2IRQ always be 1 and only using IRQEN to enable/disable IRQ? I consulted the designer it's no problem no matter what the pin function is.
Signature · 2 lines
Regards, Shawn
PATCH v3 7/15 ARM: mxs: Add gpio support
Quoted 108 lines · Shawn Guo
Hi Lothar,
Quoted 96 lines · Lothar Wa?mann
Hi,
Quoted 93 lines · Shawn Guo
MXS-based SoCs implement gpio support in block PINCTRL.
Signed-off-by Shawn Guo <[email protected]>---
Changes for v3:
?-include/mach/gpio.h: remove the inclusion ofhardware.h?-gpio.c: change inclusion ofhardware.htomx23.hplusmx28.h?- Remove spinlock totally since SET/CLE can be used in all the ? ?gpio register accessChanges for v2:
?- Createarch/arm/mach-mxs/gpio.hto accommodate stuff private for mach-mxs ?- UseGPIO_INT_LEV_MASKandGPIO_INT_POL_MASKinstead of constant ?- Remove both edges IRQ support which is not needed
?- Use SET and CLR register ofPINCTRL_DOEin_set_gpio_direction()?- Usepr_infooverprintk(KERN_INFO)?arch/arm/mach-mxs/gpio.c ? ? ? ? ? ? ?| ?321 +++++++++++++++++++++++++++++++++ ?arch/arm/mach-mxs/gpio.h ? ? ? ? ? ? ?| ? 33 ++++ ?arch/arm/mach-mxs/include/mach/gpio.h | ? 34 ++++?3 files changed, 388 insertions(+), 0 deletions(-) ?create mode 100644
arch/arm/mach-mxs/gpio.c?create mode 100644arch/arm/mach-mxs/gpio.h?create mode 100644arch/arm/mach-mxs/include/mach/gpio.harch/arm/mach-mxs/gpio.c new file +62
-0@@ -0,0 +1,321 @@ +/* +* 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) +{ + ? ? __raw_writel(1 << index, + ? ? ? ? ? ? ? ? ? ? port->base + PINCTRL_IRQSTAT(port->id) + MXS_CLR_ADDR); +} + +static void _set_gpio_irqenable (struct mxs_gpio_port *port,u32 index, + ? ? ? ? ? ? ? ? ? ? ? ? ? ? int enable) +{Quoted 9 lines
arch/arm/mach-mxs/gpio.c line 67
Quoted 5 lines
arch/arm/mach-mxs/gpio.c new file +5
-0+ ? ? if (enable == 0) { + ? ? ? ? ? ? __raw_writel(1 << index, + ? ? ? ? ? ? ? ? ? ? port->base + PINCTRL_PIN2IRQ(port->id) + MXS_CLR_ADDR); + ? ? ? ? ? ? __raw_writel(1 << index, + ? ? ? ? ? ? ? ? ? ? port->base + PINCTRL_IRQEN(port->id) + MXS_CLR_ADDR);This will loose interrupt pulses that happen while IRQs are disabled. IMO PIN2IRQ should only be cleared when an IRQ is freed, not when it is disabled.
Quoted 4 lines
What about leaving PIN2IRQ always be 1 and only using IRQEN to enable/disable IRQ? ?I consulted the designer it's no problem no matter what the pin function is.
The code will be like:
static void _set_gpio_irqenable(struct mxs_gpio_port *port, u32 index,
int enable)
{
if (enable) {
__raw_writel(1 << index,
port->base + PINCTRL_IRQEN(port->id) + MXS_SET_ADDR);
__raw_writel(1 << index,
port->base + PINCTRL_PIN2IRQ(port->id) + MXS_SET_ADDR);
} else {
__raw_writel(1 << index,
port->base + PINCTRL_IRQEN(port->id) + MXS_CLR_ADDR);
}
}Signature · 2 lines
Regards, Shawn
PATCH v3 7/15 ARM: mxs: Add gpio support
Hello Shawn,
Quoted 23 lines · Shawn Guo
Quoted 14 lines · Shawn Guo
Quoted 13 lines · Lothar Wa?mann
Review
Quoted 8 lines · Shawn Guo
(quoted diff) +8
-0+static void _set_gpio_irqenable(struct mxs_gpio_port *port, u32 index, + ? ? ? ? ? ? ? ? ? ? ? ? ? ? int enable) +{ + ? ? if (enable == 0) { + ? ? ? ? ? ? __raw_writel(1 << index, + ? ? ? ? ? ? ? ? ? ? port->base + PINCTRL_PIN2IRQ(port->id) + MXS_CLR_ADDR); + ? ? ? ? ? ? __raw_writel(1 << index, + ? ? ? ? ? ? ? ? ? ? port->base + PINCTRL_IRQEN(port->id) + MXS_CLR_ADDR);This will loose interrupt pulses that happen while IRQs are disabled. IMO PIN2IRQ should only be cleared when an IRQ is freed, not when it is disabled.
Quoted 4 lines
What about leaving PIN2IRQ always be 1 and only using IRQEN to enable/disable IRQ? ?I consulted the designer it's no problem no matter what the pin function is.
The code will be like:
static void _set_gpio_irqenable(struct
mxs_gpio_port*port, u32 index,
int enable)
Quoted 11 lines
{
if (enable) {
__raw_writel(1 << index,
port->base + PINCTRL_IRQEN(port->id) + MXS_SET_ADDR);
__raw_writel(1 << index,
port->base + PINCTRL_PIN2IRQ(port->id) + MXS_SET_ADDR);
} else {
__raw_writel(1 << index,
port->base + PINCTRL_IRQEN(port->id) + MXS_CLR_ADDR);
}
}If I understood Lothar correctly the best way is to set and clear PINCTRL_PIN2IRQ in the irqchips irq_startup and irq_shutdown routine.
Best regards
Uwe
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-K?nig | Industrial Linux Solutions | http://www.pengutronix.de/ |
PATCH v3 7/15 ARM: mxs: Add gpio support
Hi Uwe,
2010/12/10 Uwe Kleine-K?nig <[email protected]>:
Quoted 37 lines
Hello Shawn,
Quoted 21 lines · Shawn Guo
Quoted 14 lines · Shawn Guo
Quoted 13 lines · Lothar Wa?mann
Review
Quoted 8 lines · Shawn Guo
(quoted diff) +8
-0+static void _set_gpio_irqenable(struct mxs_gpio_port *port, u32 index, + ? ? ? ? ? ? ? ? ? ? ? ? ? ? int enable) +{ + ? ? if (enable == 0) { + ? ? ? ? ? ? __raw_writel(1 << index, + ? ? ? ? ? ? ? ? ? ? port->base + PINCTRL_PIN2IRQ(port->id) + MXS_CLR_ADDR); + ? ? ? ? ? ? __raw_writel(1 << index, + ? ? ? ? ? ? ? ? ? ? port->base + PINCTRL_IRQEN(port->id) + MXS_CLR_ADDR);This will loose interrupt pulses that happen while IRQs are disabled. IMO PIN2IRQ should only be cleared when an IRQ is freed, not when it is disabled.
Quoted 4 lines
What about leaving PIN2IRQ always be 1 and only using IRQEN to enable/disable IRQ? ?I consulted the designer it's no problem no matter what the pin function is.
The code will be like:
Quoted 13 lines
static void
_set_gpio_irqenable(struct mxs_gpio_port *port, u32 index, ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? int enable)
{
? ? ? ? if (enable) {
? ? ? ? ? ? ? ? __raw_writel(1 << index,
? ? ? ? ? ? ? ? ? ? ? ?port->base+PINCTRL_IRQEN(port->id)+MXS_SET_ADDR); ? ? ? ? ? ? ? ? __raw_writel(1 << index,
? ? ? ? ? ? ? ? ? ? ? ?port->base+PINCTRL_PIN2IRQ(port->id)+MXS_SET_ADDR); ? ? ? ? } else {
? ? ? ? ? ? ? ? __raw_writel(1 << index,
? ? ? ? ? ? ? ? ? ? ? ?port->base+PINCTRL_IRQEN(port->id)+MXS_CLR_ADDR); ? ? ? ? }
}
Quoted 3 lines
If I understood Lothar correctly the best way is to set and clear
PINCTRL_PIN2IRQin the irqchipsirq_startupandirq_shutdownroutine.
Is there any problem with the current code to address Lothar's concern? If no, I would not introduce two more irq_chip routines into the file.
Signature · 2 lines
Regards, Shawn
PATCH v4 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 timer0 and timer1, while MX23 uses timer0 and timer3.
---
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 | 270 +++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 270 insertions(+), 0 deletions(-) create mode 100644 arch/arm/mach-mxs/timer.c
arch/arm/mach-mxs/timer.c new file +270 -0
@@ -0,0 +1,270 @@ +/* +* 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 timer0 and timer1, while +* MX23 uses timer0 and timer3. +*/ +#define timrot_is_v1 () (cpu_is_mx23()) + +#define HW_TIMROT_ROTCTRL 0x00 +#define HW_TIMROT_TIMCTRLn (n) (0x20 + (n) * 0x40) +#define HW_TIMROT_RUNNING_COUNTn (n) (0x30 + (n) * 0x40) +#define HW_TIMROT_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 clockevent_mxs; +static enum clock_event_mode clockevent_mode =CLOCK_EVT_MODE_UNUSED ; + +static void __iomem *timer_base =MXS_IO_ADDRESS (MXS_TIMROT_BASE_ADDR ); + +static inline void timrot_irq_disable (void ) +{ +__raw_writel (BM_TIMROT_TIMCTRLn_IRQ_EN, + timer_base +HW_TIMROT_TIMCTRLn (0 ) +MXS_CLR_ADDR ); +} + +static inline void timrot_irq_enable (void ) +{ +__raw_writel (BM_TIMROT_TIMCTRLn_IRQ_EN, + timer_base +HW_TIMROT_TIMCTRLn (0 ) +MXS_SET_ADDR ); +} + +static void timrot_irq_acknowledge (void ) +{ +__raw_writel (BM_TIMROT_TIMCTRLn_IRQ, + timer_base +HW_TIMROT_TIMCTRLn (0 ) +MXS_CLR_ADDR ); +} + +static cycle_t timrotv1_get_cycles (struct clocksource *cs) +{ +return ~((__raw_readl (timer_base +HW_TIMROT_RUNNING_COUNTn (1 )) + &0xffff0000 ) >>16 ); +} + +static cycle_t timrotv2_get_cycles (struct clocksource *cs) +{ +return ~__raw_readl (timer_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, timer_base +HW_TIMROT_RUNNING_COUNTn (0 )); + +return 0 ; +} + +static int timrotv2_set_next_event (unsigned long evt, +struct clock_event_device *dev) +{ +/* timrot decrements the count */ +__raw_writel (evt, timer_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 = &clockevent_mxs, + .flags =IRQF_TIMER |IRQF_IRQPOLL , + .handler = mxs_timer_interrupt, +}; + +#ifdef DEBUG +static const char *clock_event_mode_label[] = { + [CLOCK_EVT_MODE_PERIODIC ] ="CLOCK_EVT_MODE_PERIODIC" , + [CLOCK_EVT_MODE_ONESHOT ] ="CLOCK_EVT_MODE_ONESHOT" , + [CLOCK_EVT_MODE_SHUTDOWN ] ="CLOCK_EVT_MODE_SHUTDOWN" , + [CLOCK_EVT_MODE_UNUSED ] ="CLOCK_EVT_MODE_UNUSED" +}; +#endif /* DEBUG */ + +static void mxs_set_mode (enum clock_event_mode mode, +struct clock_event_device *evt) +{ +/* Disable interrupt in timer module */ +timrot_irq_disable (); + +if (mode != clockevent_mode) { +/* Set event time into the furthest future */ +if (timrot_is_v1 ()) +__raw_writel (0xffff , + timer_base +HW_TIMROT_RUNNING_COUNTn (1 )); +else +__raw_writel (0xffffffff , + timer_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[clockevent_mode], + clock_event_mode_label[mode]); +#endif /* DEBUG */ + +/* Remember timer mode */ + 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 clockevent_mxs = { + .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); + + clockevent_mxs.mult =div_sc (c,NSEC_PER_SEC , clockevent_mxs.shift); + clockevent_mxs.cpumask =cpumask_of (0 ); +if (timrot_is_v1 ()) { + clockevent_mxs.set_next_event = timrotv1_set_next_event; + clockevent_mxs.max_delta_ns = +clockevent_delta2ns (0xfffe , &clockevent_mxs); + clockevent_mxs.min_delta_ns = +clockevent_delta2ns (0xf , &clockevent_mxs); + }else { + clockevent_mxs.max_delta_ns = +clockevent_delta2ns (0xfffffffe , &clockevent_mxs); + clockevent_mxs.min_delta_ns = +clockevent_delta2ns (0xf , &clockevent_mxs); + } + +clockevents_register_device (&clockevent_mxs); + +return 0 ; +} + +static struct clocksource clocksource_mxs = { + .name ="mxs_timer" , + .rating =200 , + .read = timrotv2_get_cycles, + .mask =CLOCKSOURCE_MASK (32 ), + .shift =17 , + .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_mxs.mult =clocksource_hz2mult (c, clocksource_mxs.shift); +clocksource_register (&clocksource_mxs); + +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 (timer_base +HW_TIMROT_ROTCTRL ); + +/* timer0 is 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, + timer_base +HW_TIMROT_TIMCTRLn (0 )); + +/* timer1 is for clocksource */ +__raw_writel ((timrot_is_v1 () ? + BV_TIMROTv1_TIMCTRLn_SELECT__32KHZ_XTAL : + BV_TIMROTv2_TIMCTRLn_SELECT__32KHZ_XTAL) | + BM_TIMROT_TIMCTRLn_RELOAD, + timer_base +HW_TIMROT_TIMCTRLn (1 )); + +/* set timer1 fixed count to the maximum */ +if (timrot_is_v1 ()) +__raw_writel (0xffff , + timer_base +HW_TIMROT_RUNNING_COUNTn (1 )); +else +__raw_writel (0xffffffff , + timer_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 v3 8/15 ARM: mxs: Add iomux support
In reply to Shawn GuoMXS-based SoCs implements iomux functions in block PINCTRL.
---
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 | 29 +++++++ arch/arm/mach-mxs/include/mach/iomux-mx28.h | 44 ++++++++++ arch/arm/mach-mxs/include/mach/iomux.h | 117 +++++++++++++++++++++++++++ arch/arm/mach-mxs/iomux.c | 103 +++++++++++++++++++++++ 4 files changed, 293 insertions(+), 0 deletions(-) create mode 100644 arch/arm/mach-mxs/include/mach/iomux-mx23.h create mode 100644 arch/arm/mach-mxs/include/mach/iomux-mx28.h create mode 100644 arch/arm/mach-mxs/include/mach/iomux.h create mode 100644 arch/arm/mach-mxs/iomux.c
arch/arm/mach-mxs/include/mach/iomux-mx23.h new file +29 -0
@@ -0,0 +1,29 @@ +/* +* Copyright (C) 2009-2010 Amit Kucheria <[email protected]> +* Copyright (C) 2010 Freescale Semiconductor, Inc. +* +* The code contained herein is licensed under the GNU General Public +* License. You may obtain a copy of the GNU General Public License +* Version 2 or later at the following locations: +* +* http://www.opensource.org/licenses/gpl-license.html +* http://www.gnu.org/copyleft/gpl.html +*/ + +#ifndef __MACH_IOMUX_MX23_H__ +#define __MACH_IOMUX_MX23_H__ + +#include <mach/iomux.h> + +/* +* The naming convention for the pad modes is MX23_PAD_<padname>__<padmode> +* If <padname> or <padmode> refers to a GPIO, it is named GPIO_<unit>_<num> +* See also iomux.h +* +* BANK PIN MUX VOL MA PULL +*/ +/* DUART */ +#define MX23_PAD_PWM0__DUART_RX IOMUX_PAD(1, 26, PAD_MUXSEL_2, PAD_VOL_NONE, PAD_4MA, PAD_NOPULL) +#define MX23_PAD_PWM1__DUART_TX IOMUX_PAD(1, 27, PAD_MUXSEL_2, PAD_VOL_NONE, PAD_4MA, PAD_NOPULL) + +#endif /* __MACH_IOMUX_MX23_H__ */
arch/arm/mach-mxs/include/mach/iomux-mx28.h new file +44 -0
44 lines not on this page · raw message
arch/arm/mach-mxs/include/mach/iomux.h new file +117 -0
117 lines not on this page · raw message
arch/arm/mach-mxs/iomux.c new file +103 -0
103 lines not on this page · raw message
Signature · 1 line
1.7.1
PATCH v3 8/15 ARM: mxs: Add iomux support
Hi,
Quoted 47 lines · Shawn Guo
MXS-based SoCs implements iomux functions in block PINCTRL.
Signed-off-by Shawn Guo <[email protected]>---
Changes for v3:
- Changeiomux_cfg_tto u64 to facilitate adding platform specificpad_ctrlsettings to an existing pad definition
- Change inclusion ofhardware.htomxs.h
- Getiomux_basea hard-assignment inmxs_iomux_setup_pad(), since mx23 and mx28 share the common pinctrl base adress and it's only used inmxs_iomux_setup_pad().
- RemoveEXPORT_SYMBOLand the static ofmxs_iomux_setup_pad()Changes for v2:
- Defineiomux_cfg_tas u64
- Turnmxs_iomux_setup_pad()into a static function
- Fix a bug inmxs_iomux_setup_pad(), muxsel starts at offset0x100than 0 of pinctrl block.arch/arm/mach-mxs/include/mach/iomux-mx23.h | 29 +++++++ arch/arm/mach-mxs/include/mach/iomux-mx28.h | 44 ++++++++++ arch/arm/mach-mxs/include/mach/iomux.h | 117 +++++++++++++++++++++++++++ arch/arm/mach-mxs/iomux.c | 103 +++++++++++++++++++++++ 4 files changed, 293 insertions(+), 0 deletions(-) create mode 100644 arch/arm/mach-mxs/include/mach/iomux-mx23.h create mode 100644 arch/arm/mach-mxs/include/mach/iomux-mx28.h create mode 100644 arch/arm/mach-mxs/include/mach/iomux.h create mode 100644 arch/arm/mach-mxs/iomux.carch/arm/mach-mxs/include/mach/iomux-mx23.h new file +13
-0@@ -0,0 +1,29 @@ +/* +* Copyright (C) 2009-2010 Amit Kucheria <[email protected]> +* Copyright (C) 2010 Freescale Semiconductor, Inc. +* +* The code contained herein is licensed under the GNU General Public +* License. You may obtain a copy of the GNU General Public License +* Version 2 or later at the following locations: +* +* http://www.opensource.org/licenses/gpl-license.html +* http://www.gnu.org/copyleft/gpl.html +*/ + +#ifndef __MACH_IOMUX_MX23_H__
arch/arm/mach-mxs/include/mach/iomux-mx23.h line 23
Quoted 10 lines
arch/arm/mach-mxs/include/mach/iomux-mx23.h new file +10
-0+#define __MACH_IOMUX_MX23_H__ + +#include <mach/iomux.h> + +/* +* The naming convention for the pad modes is MX23_PAD_<padname>__<padmode> +* If <padname> or <padmode> refers to a GPIO, it is named GPIO_<unit>_<num> +* See also iomux.h +* +* BANK PIN MUX VOL MA PULL
^
TAB/SPACE mixup (emacs can highlight those ;)
Quoted 25 lines
arch/arm/mach-mxs/include/mach/iomux-mx23.h new file +6
-0+*/ +/* DUART */ +#define MX23_PAD_PWM0__DUART_RX IOMUX_PAD(1, 26, PAD_MUXSEL_2, PAD_VOL_NONE, PAD_4MA, PAD_NOPULL) +#define MX23_PAD_PWM1__DUART_TX IOMUX_PAD(1, 27, PAD_MUXSEL_2, PAD_VOL_NONE, PAD_4MA, PAD_NOPULL) + +#endif /* __MACH_IOMUX_MX23_H__ */ arch/arm/mach-mxs/include/mach/iomux-mx28.h new file +13
-0@@ -0,0 +1,44 @@ +/* +* Copyright (C) 2009-2010 Amit Kucheria <[email protected]> +* Copyright (C) 2010 Freescale Semiconductor, Inc. +* +* The code contained herein is licensed under the GNU General Public +* License. You may obtain a copy of the GNU General Public License +* Version 2 or later at the following locations: +* +* http://www.opensource.org/licenses/gpl-license.html +* http://www.gnu.org/copyleft/gpl.html +*/ + +#ifndef __MACH_IOMUX_MX28_H__
arch/arm/mach-mxs/include/mach/iomux-mx28.h line 23
Quoted 10 lines
arch/arm/mach-mxs/include/mach/iomux-mx28.h new file +10
-0+#define __MACH_IOMUX_MX28_H__ + +#include <mach/iomux.h> + +/* +* The naming convention for the pad modes is MX28_PAD_<padname>__<padmode> +* If <padname> or <padmode> refers to a GPIO, it is named GPIO_<unit>_<num> +* See also iomux.h +* +* BANK PIN MUX VOL MA PULL
^
TAB/SPACE mixup
Quoted 53 lines
arch/arm/mach-mxs/include/mach/iomux-mx28.h new file +21
-0+*/ +/* DUART */ +#define MX28_PAD_PWM0__DUART_RX IOMUX_PAD(3, 16, PAD_MUXSEL_2, PAD_3V3, PAD_4MA, PAD_NOPULL) +#define MX28_PAD_PWM1__DUART_TX IOMUX_PAD(3, 17, PAD_MUXSEL_2, PAD_3V3, PAD_4MA, PAD_NOPULL) + +/* FEC */ +#define MX28_PAD_ENET0_MDC__ENET0_MDC IOMUX_PAD(4, 0, PAD_MUXSEL_0, PAD_3V3, PAD_8MA, PAD_PULLUP) +#define MX28_PAD_ENET0_MDIO__ENET0_MDIO IOMUX_PAD(4, 1, PAD_MUXSEL_0, PAD_3V3, PAD_8MA, PAD_PULLUP) +#define MX28_PAD_ENET0_RX_EN__ENET0_RX_EN IOMUX_PAD(4, 2, PAD_MUXSEL_0, PAD_3V3, PAD_8MA, PAD_PULLUP) +#define MX28_PAD_ENET0_RXD0__ENET0_RXD0 IOMUX_PAD(4, 3, PAD_MUXSEL_0, PAD_3V3, PAD_8MA, PAD_PULLUP) +#define MX28_PAD_ENET0_RXD1__ENET0_RXD1 IOMUX_PAD(4, 4, PAD_MUXSEL_0, PAD_3V3, PAD_8MA, PAD_PULLUP) +#define MX28_PAD_ENET0_TX_EN__ENET0_TX_EN IOMUX_PAD(4, 6, PAD_MUXSEL_0, PAD_3V3, PAD_8MA, PAD_PULLUP) +#define MX28_PAD_ENET0_TXD0__ENET0_TXD0 IOMUX_PAD(4, 7, PAD_MUXSEL_0, PAD_3V3, PAD_8MA, PAD_PULLUP) +#define MX28_PAD_ENET0_TXD1__ENET0_TXD1 IOMUX_PAD(4, 8, PAD_MUXSEL_0, PAD_3V3, PAD_8MA, PAD_PULLUP) +#define MX28_PAD_ENET_CLK__ENET_CLK IOMUX_PAD(4, 16, PAD_MUXSEL_0, PAD_3V3, PAD_8MA, PAD_PULLUP) + +/* GPIO */ +#define MX28_PAD_SSP1_DATA3__GPIO_2_15 IOMUX_PAD(2, 15, PAD_MUXSEL_GPIO, PAD_3V3, PAD_4MA, PAD_NOPULL) +#define MX28_PAD_ENET0_RX_CLK__GPIO_4_13 IOMUX_PAD(4, 13, PAD_MUXSEL_GPIO, PAD_3V3, PAD_4MA, PAD_NOPULL) + +#endif /* __MACH_IOMUX_MX28_H__ */ arch/arm/mach-mxs/include/mach/iomux.h new file +26
-0@@ -0,0 +1,117 @@ +/* +* Copyright (C) 2009 by Jan Weitzel Phytec Messtechnik GmbH, +* <[email protected]> +* Copyright (C) 2010 Freescale Semiconductor, Inc. All Rights Reserved. +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +* MA 02110-1301, USA. +*/ + +#ifndef __MACH_MXS_IOMUX_H__ +#define __MACH_MXS_IOMUX_H__ + +/* +* IOMUX/PAD Bit field definitions +*
arch/arm/mach-mxs/include/mach/iomux.h line 36
Quoted 10 lines
arch/arm/mach-mxs/include/mach/iomux.h new file +10
-0+* PAD_BANK: 0..2 (3) +* PAD_PIN: 3..7 (5) +* PAD_MUXSEL: 8..9 (2) +* PAD_MA: 10..12 (3) +* PAD_VOL: 13..14 (2) +* PAD_PULL: 15 (1) +* RESERVED: 16..63 (48) +*/ +typedef u64 iomux_cfg_t ; +
Only because i.MX5 has so many bits to remember does not mean we have to waste space on this arch too. No need for u64 here (could obviously even be u16).
Quoted 11 lines
arch/arm/mach-mxs/include/mach/iomux.h new file +11
-0+#define PAD_BANK_SHIFT 0 +#define PAD_BANK_MASK ((iomux_cfg_t)0x7 << PAD_BANK_SHIFT) +#define PAD_PIN_SHIFT 3 +#define PAD_PIN_MASK ((iomux_cfg_t)0x1f << PAD_PIN_SHIFT) +#define PAD_MUXSEL_SHIFT 8 +#define PAD_MUXSEL_MASK ((iomux_cfg_t)0x3 << PAD_MUXSEL_SHIFT) +#define PAD_MA_SHIFT 10 +#define PAD_MA_MASK ((iomux_cfg_t)0x7 << PAD_MA_SHIFT) +#define PAD_VOL_SHIFT 13 +#define PAD_VOL_MASK ((iomux_cfg_t)0x3 << PAD_VOL_SHIFT) +#define PAD_PULL_SHIFT 15
arch/arm/mach-mxs/include/mach/iomux.h line 57
Quoted 10 lines
arch/arm/mach-mxs/include/mach/iomux.h new file +10
-0+#define PAD_PULL_MASK ((iomux_cfg_t)0x1 << PAD_PULL_SHIFT) + +#define IOMUX_PAD (_bank, _pin, _muxsel, _vol, _ma, _pull) \ + (((iomux_cfg_t)(_bank) << PAD_BANK_SHIFT) | \ + ((iomux_cfg_t)(_pin) << PAD_PIN_SHIFT) | \ + ((iomux_cfg_t)(_muxsel) << PAD_MUXSEL_SHIFT) | \ + ((iomux_cfg_t)(_vol) << PAD_VOL_SHIFT) | \ + ((iomux_cfg_t)(_ma) << PAD_MA_SHIFT) | \ + ((iomux_cfg_t)(_pull) << PAD_PULL_SHIFT)) +
These also should have a namespace prefix like:
MXS_PAD_*, MXS_IOMUX_PAD()
Quoted 40 lines
arch/arm/mach-mxs/include/mach/iomux.h new file +40
-0+#define PAD_MUXSEL_0 0 +#define PAD_MUXSEL_1 1 +#define PAD_MUXSEL_2 2 +#define PAD_MUXSEL_GPIO 3 + +#define PAD_1V8 0 +#define PAD_3V3 1 +#define PAD_VOL_NONE 2 + +#define PAD_4MA 0 +#define PAD_8MA 1 +#define PAD_12MA 2 +#define PAD_16MA 3 +#define PAD_MA_NONE 4 + +#define PAD_NOPULL 0 +#define PAD_PULLUP 1 + +static inline unsigned int PAD_BANK (iomux_cfg_t pad) +{ +return (pad &PAD_BANK_MASK ) >>PAD_BANK_SHIFT ; +} + +static inline unsigned int PAD_PIN (iomux_cfg_t pad) +{ +return (pad &PAD_PIN_MASK ) >>PAD_PIN_SHIFT ; +} + +static inline unsigned int PAD_MUXSEL (iomux_cfg_t pad) +{ +return (pad &PAD_MUXSEL_MASK ) >>PAD_MUXSEL_SHIFT ; +} + +static inline unsigned int PAD_MA (iomux_cfg_t pad) +{ +return (pad &PAD_MA_MASK ) >>PAD_MA_SHIFT ; +} + +static inline unsigned int PAD_VOL (iomux_cfg_t pad) +{
arch/arm/mach-mxs/include/mach/iomux.h line 107
Quoted 10 lines
arch/arm/mach-mxs/include/mach/iomux.h new file +10
-0+return (pad &PAD_VOL_MASK ) >>PAD_VOL_SHIFT ; +} + +static inline unsigned int PAD_PULL (iomux_cfg_t pad) +{ +return (pad &PAD_PULL_MASK ) >>PAD_PULL_SHIFT ; +} + +/* +* setups a single pad in the iomuxer
s/setups/configures/
arch/arm/mach-mxs/include/mach/iomux.h line 112
Quoted 5 lines
arch/arm/mach-mxs/include/mach/iomux.h new file +5
-0+*/ +int mxs_iomux_setup_pad (iomux_cfg_t pad); + +/* +* setups multiple pads
dto.
Quoted 56 lines
arch/arm/mach-mxs/include/mach/iomux.h new file +5
-0+* convenient way to call the above function with tables +*/ +int mxs_iomux_setup_multiple_pads (const iomux_cfg_t *pad_list,unsigned count); + +#endif /* __MACH_MXS_IOMUX_H__*/ arch/arm/mach-mxs/iomux.c new file +45
-0@@ -0,0 +1,103 @@ +/* +* Copyright 2004-2006,2010 Freescale Semiconductor, Inc. All Rights Reserved. +* Copyright (C) 2008 by Sascha Hauer <[email protected]> +* Copyright (C) 2009 by Jan Weitzel Phytec Messtechnik GmbH, +* <[email protected]> +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +* MA 02110-1301, USA. +*/ + +#include <linux/errno.h> +#include <linux/init.h> +#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/string.h> +#include <linux/gpio.h> + +#include <asm/mach/map.h> + +#include <mach/mxs.h> +#include <mach/iomux.h> + +/* +* 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 ;
arch/arm/mach-mxs/iomux.c line 55
Quoted 10 lines
arch/arm/mach-mxs/iomux.c new file +10
-0+ bm =0x3 << bp; + reg =__raw_readl (iomux_base + ofs); + reg &= ~bm; + reg |=PAD_MUXSEL (pad) << bp; +__raw_writel (reg, iomux_base + ofs); + +/* drive */ + ofs =cpu_is_mx23 () ?0x200 :0x300 ; + ofs +=PAD_BANK (pad) *0x40 +PAD_PIN (pad) /8 *0x10 ; +/* ma */
'mA' would make it much clearer that milliamps are meant.
arch/arm/mach-mxs/iomux.c line 57
Quoted 2 lines
arch/arm/mach-mxs/iomux.c new file +2
-0+if (PAD_MA (pad) !=PAD_MA_NONE ) + {
'{' should be at the end of the 'if' line.
arch/arm/mach-mxs/iomux.c line 67
Quoted 10 lines
arch/arm/mach-mxs/iomux.c new file +10
-0+ bp =PAD_PIN (pad) %8 *4 ; + bm =0x3 << bp; + reg =__raw_readl (iomux_base + ofs); + reg &= ~bm; + reg |=PAD_MA (pad) << bp; +__raw_writel (reg, iomux_base + ofs); + } +/* vol */ +if (PAD_VOL (pad) !=PAD_VOL_NONE ) + {
dto.
arch/arm/mach-mxs/iomux.c line 73
Quoted 6 lines
arch/arm/mach-mxs/iomux.c new file +6
-0+ bp =PAD_PIN (pad) %8 *4 +2 ; + bm =0x1 << bp; + reg =__raw_readl (iomux_base + ofs); + reg &= ~bm; + reg |=PAD_VOL (pad) << bp; +__raw_writel (reg, iomux_base + ofs);
You could use a write to the SET/CLR address here instead of read/modify/write.
arch/arm/mach-mxs/iomux.c line 84
Quoted 11 lines
arch/arm/mach-mxs/iomux.c new file +11
-0+ } + +/* pull */ + ofs =cpu_is_mx23 () ?0x400 :0x600 ; + ofs +=PAD_BANK (pad) *0x10 ; + bp =PAD_PIN (pad); + bm =0x1 << bp; + reg =__raw_readl (iomux_base + ofs); + reg &= ~bm; + reg |=PAD_PULL (pad) << bp; +__raw_writel (reg, iomux_base + ofs);
dto.
Quoted 23 lines
arch/arm/mach-mxs/iomux.c new file +19
-0+ +return 0 ; +} + +int mxs_iomux_setup_multiple_pads (const iomux_cfg_t *pad_list,unsigned count) +{ +const iomux_cfg_t *p = pad_list; +int i; +int ret; + +for (i =0 ; i < count; i++) { + ret =mxs_iomux_setup_pad (*p); +if (ret) +return ret; + p++; + } + +return 0 ; +}Signature · 1 line
1.7.1
Lothar Wa?mann
Signature · 9 lines
___________________________________________________________ Ka-Ro electronics GmbH | Pascalstra?e 22 | D - 52076 Aachen Phone: +49 2408 1402-0 | Fax: +49 2408 1402-10 Gesch?ftsf?hrer: Matthias Kaussen Handelsregistereintrag: Amtsgericht Aachen, HRB 4996 www.karo-electronics.de | info at karo-electronics.de ___________________________________________________________
PATCH v3 9/15 ARM: mxs: Add clock support
In reply to Shawn GuoAdd clock for MXS-based SoCs, MX23 and MX28.
---
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 v3 9/15 ARM: mxs: Add clock support
Hello Shawn,
arch/arm/mach-mxs/clock-mx23.c line 6
Quoted 12 lines · Shawn Guo
arch/arm/mach-mxs/clock-mx23.c new file +6
-0@@ -0,0 +1,526 @@ +[...] +static int cpu_clk_set_rate (struct clk *clk,unsigned long rate) +{ +[...] + rate <<=PARENT_RATE_SHIFT ; + parent_rate <<=PARENT_RATE_SHIFT ;
You're making the problem worse here. You need to shift right!
Uwe
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-K?nig | Industrial Linux Solutions | http://www.pengutronix.de/ |
PATCH v3 12/15 ARM: mxs: Dynamically allocate fec devices
In reply to Shawn GuoDynamically allocate fec devices for MX28, which gets dual fec interface.
---
Changes for v3:
- Change inclusion of hardware.h to mx28.h
Changes for v2:
- Remove the use of mx28_add_fec0 and mx28_add_fec1
- Remove unnessary passing of data->iosize
arch/arm/mach-mxs/devices-mx28.h | 4 ++ arch/arm/mach-mxs/devices/platform-fec.c | 50 +++++++++++++++++++++++ arch/arm/mach-mxs/include/mach/devices-common.h | 12 +++++ 3 files changed, 66 insertions(+), 0 deletions(-) create mode 100644 arch/arm/mach-mxs/devices/platform-fec.c
arch/arm/mach-mxs/devices-mx28.h +4 -0
@@ -14,3 +14,7 @@extern const struct mxs_duart_data mx28_duart_data__initconst ;#define mx28_add_duart () \ mxs_add_duart(&mx28_duart_data) + +extern const struct mxs_fec_data mx28_fec_data[]__initconst ; +#define mx28_add_fec (id, pdata) \ + mxs_add_fec(&mx28_fec_data[id], pdata)
arch/arm/mach-mxs/devices/platform-fec.c new file +50 -0
50 lines not on this page · raw message
arch/arm/mach-mxs/include/mach/devices-common.h +12 -0
@@ -32,3 +32,15 @@ struct mxs_duart_data { };struct platform_device *__init mxs_add_duart (const struct mxs_duart_data *data); + +/* fec */ +#include <linux/fec.h> +struct mxs_fec_data { +int id; +resource_size_t iobase; +resource_size_t iosize; +resource_size_t irq; +}; +struct platform_device *__init mxs_add_fec ( +const struct mxs_fec_data *data, +const struct fec_platform_data *pdata);
Signature · 1 line
1.7.1
PATCH v2 14/15 ARM: mxs: Add initial mx28evk support
In reply to Shawn GuoAdd initial mx28evk support with duart and fec0.
---
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 | 126 ++++++++++++++++++++++++++++++++++++++ 1 files changed, 126 insertions(+), 0 deletions(-) create mode 100644 arch/arm/mach-mxs/mach-mx28evk.c
arch/arm/mach-mxs/mach-mx28evk.c new file +126 -0
@@ -0,0 +1,126 @@ +/* +* 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/hardware.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 iomux_cfg_t mx28evk_pads[] = { +/* duart */ +MX28_PAD_PWM0__DUART_RX , +MX28_PAD_PWM1__DUART_TX , + +/* fec0 */ +MX28_PAD_ENET0_MDC__ENET0_MDC , +MX28_PAD_ENET0_MDIO__ENET0_MDIO , +MX28_PAD_ENET0_RX_EN__ENET0_RX_EN , +MX28_PAD_ENET0_RXD0__ENET0_RXD0 , +MX28_PAD_ENET0_RXD1__ENET0_RXD1 , +MX28_PAD_ENET0_TX_EN__ENET0_TX_EN , +MX28_PAD_ENET0_TXD0__ENET0_TXD0 , +MX28_PAD_ENET0_TXD1__ENET0_TXD1 , +MX28_PAD_ENET_CLK__ENET_CLK , +/* phy power line */ +MX28_PAD_SSP1_DATA3__GPIO_2_15 , +/* phy reset line */ +MX28_PAD_ENET0_RX_CLK__GPIO_4_13 , +}; + +/* fec */ +static 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
PATCH v2 14/15 ARM: mxs: Add initial mx28evk support
Hello Shawn,
Quoted 47 lines · Shawn Guo
Add initial mx28evk support with duart and fec0.
Signed-off-by Shawn Guo <[email protected]>---
Changes for v2:
- Change functionmx28evk_fec_reset()from inline to__init
- Enable pll2 clock before phy operation
- Add error checking forgpio_direction_output()
- Save bytes by passing parameter intopr_errformat string
- Changemx28_add_fec0()tomx28_add_fec(0)
- Removeboot_paramsarch/arm/mach-mxs/mach-mx28evk.c | 126 ++++++++++++++++++++++++++++++++++++++ 1 files changed, 126 insertions(+), 0 deletions(-) create mode 100644 arch/arm/mach-mxs/mach-mx28evk.carch/arm/mach-mxs/mach-mx28evk.c new file +25
-0@@ -0,0 +1,126 @@ +/* +* 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/hardware.h>
arch/arm/mach-mxs/mach-mx28evk.c line 35
Quoted 10 lines
arch/arm/mach-mxs/mach-mx28evk.c new file +10
-0+#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 iomux_cfg_t mx28evk_pads[] = {
This can be const and __initconst, ditto for mx23evk
Quoted 101 lines
arch/arm/mach-mxs/mach-mx28evk.c new file +91
-0+/* duart */ +MX28_PAD_PWM0__DUART_RX , +MX28_PAD_PWM1__DUART_TX , + +/* fec0 */ +MX28_PAD_ENET0_MDC__ENET0_MDC , +MX28_PAD_ENET0_MDIO__ENET0_MDIO , +MX28_PAD_ENET0_RX_EN__ENET0_RX_EN , +MX28_PAD_ENET0_RXD0__ENET0_RXD0 , +MX28_PAD_ENET0_RXD1__ENET0_RXD1 , +MX28_PAD_ENET0_TX_EN__ENET0_TX_EN , +MX28_PAD_ENET0_TXD0__ENET0_TXD0 , +MX28_PAD_ENET0_TXD1__ENET0_TXD1 , +MX28_PAD_ENET_CLK__ENET_CLK , +/* phy power line */ +MX28_PAD_SSP1_DATA3__GPIO_2_15 , +/* phy reset line */ + MX28_PAD_ENET0_RX_CLK__GPIO_4_13, +}; + +/* fec */ +static 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 · 8 lines
1.7.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel at lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-K?nig | Industrial Linux Solutions | http://www.pengutronix.de/ |
PATCH v2 14/15 ARM: mxs: Add initial mx28evk support
Hi Uwe,
2010/12/9 Uwe Kleine-K?nig <[email protected]>:
Quoted 53 lines
Hello Shawn,
Quoted 50 lines · Shawn Guo
Add initial mx28evk support with duart and fec0.
Signed-off-by Shawn Guo <[email protected]>---
Changes for v2:
?- Change functionmx28evk_fec_reset()from inline to__init?- Enable pll2 clock before phy operation
?- Add error checking forgpio_direction_output()?- Save bytes by passing parameter intopr_errformat string ?- Changemx28_add_fec0()tomx28_add_fec(0)
?- Removeboot_params?arch/arm/mach-mxs/mach-mx28evk.c | ?126 ++++++++++++++++++++++++++++++++++++++ ?1 files changed, 126 insertions(+), 0 deletions(-)
?create mode 100644arch/arm/mach-mxs/mach-mx28evk.carch/arm/mach-mxs/mach-mx28evk.c new file +28
-0@@ -0,0 +1,126 @@ +/* +* 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/hardware.h> +#include <mach/common.h> +#include <mach/iomux-mx28.h> +
Quoted 9 lines
arch/arm/mach-mxs/mach-mx28evk.c line 35
Quoted 7 lines
arch/arm/mach-mxs/mach-mx28evk.c new file +7
-0+#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 iomux_cfg_t mx28evk_pads[] = {This can be const and
__initconst, ditto for mx23evk
With u64 iomux_cfg_t changes, I'm afraid the suggestion becomes invalid.
Signature · 2 lines
Regards, Shawn
PATCH v2 14/15 ARM: mxs: Add initial mx28evk support
Hello Shwan,
Quoted 6 lines · Shawn Guo
2010/12/9 Uwe Kleine-K?nig <[email protected]>:
Quoted 4 lines · Shawn Guo
Quoted 1 line
+static
iomux_cfg_tmx28evk_pads[] = {This can be const and
__initconst, ditto for mx23evkWith u64
iomux_cfg_tchanges, I'm afraid the suggestion becomes invalid.
Really? Why?
Uwe
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-K?nig | Industrial Linux Solutions | http://www.pengutronix.de/ |
PATCH v2 14/15 ARM: mxs: Add initial mx28evk support
Hi Uwe,
2010/12/9 Uwe Kleine-K?nig <[email protected]>:
Quoted 11 lines
Hello Shwan,
Quoted 6 lines · Shawn Guo
2010/12/9 Uwe Kleine-K?nig <[email protected]>:
Quoted 4 lines · Shawn Guo
Quoted 1 line
+static
iomux_cfg_tmx28evk_pads[] = {This can be const and
__initconst, ditto for mx23evkWith u64
iomux_cfg_tchanges, I'm afraid the suggestion becomes invalid.Really? Why?
I'm confused by the compiling error below when adding __initconst for mx28evk_pads[], and mistakenly blaming u64 iomux_cfg_t changes.
arch/arm/mach-mxs/mach-mx28evk.c: In function ?mx28evk_init?:arch/arm/mach-mxs/mach-mx28evk.c:34: error: mx28_fec_pdata causes a section type conflict
make[1]: *** [arch/arm/mach-mxs/mach-mx28evk.o] Error 1
make: *** [arch/arm/mach-mxs] Error 2
Actually it can be fixed by the following change.
-static const struct fec_platform_data mx28_fec_pdata __initconst = { +static struct fec_platform_data mx28_fec_pdata __initconst = {
.phy = PHY_INTERFACE_MODE_RMII,
};
Signature · 2 lines
Regards, Shawn
PATCH v2 14/15 ARM: mxs: Add initial mx28evk support
Hello Shawn
Quoted 2 lines · Shawn Guo
2010/12/9 Uwe Kleine-K?nig <[email protected]>:
Quoted 1 line
Hello Shwan,
ups, sorry for mistyping your name.
Quoted 20 lines
Quoted 9 lines · Shawn Guo
Quoted 6 lines
2010/12/9 Uwe Kleine-K?nig <[email protected]>:
Quoted 4 lines · Shawn Guo
Quoted 1 line
+static
iomux_cfg_tmx28evk_pads[] = {This can be const and
__initconst, ditto for mx23evkWith u64
iomux_cfg_tchanges, I'm afraid the suggestion becomes invalid.Really? Why?
I'm confused by the compiling error below when adding
__initconstfor mx28evk_pads[], and mistakenly blaming u64iomux_cfg_tchanges.
arch/arm/mach-mxs/mach-mx28evk.c: In function ?mx28evk_init?:arch/arm/mach-mxs/mach-mx28evk.c:34: error:mx28_fec_pdatacauses a section type conflict
make[1]: *** [arch/arm/mach-mxs/mach-mx28evk.o] Error 1
make: *** [arch/arm/mach-mxs] Error 2Actually it can be fixed by the following change.
Review
Quoted 4 lines
(quoted diff) +1
-1-static const struct fec_platform_data mx28_fec_pdata __initconst = { +static struct fec_platform_data mx28_fec_pdata __initconst = { .phy = PHY_INTERFACE_MODE_RMII, };
this change is wrong. You need to assert that all data being marked with __initconst is const, too.
Uwe
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-K?nig | Industrial Linux Solutions | http://www.pengutronix.de/ |
PATCH v2 14/15 ARM: mxs: Add initial mx28evk support
2010/12/9 Uwe Kleine-K?nig <[email protected]>:
Quoted 24 lines
Hello Shawn
Quoted 2 lines · Shawn Guo
2010/12/9 Uwe Kleine-K?nig <[email protected]>:
Quoted 1 line
Hello Shwan,
ups, sorry for mistyping your name.
Quoted 18 lines
Quoted 9 lines · Shawn Guo
Quoted 6 lines
2010/12/9 Uwe Kleine-K?nig <[email protected]>:
Quoted 4 lines · Shawn Guo
Quoted 1 line
+static
iomux_cfg_tmx28evk_pads[] = {This can be const and
__initconst, ditto for mx23evkWith u64
iomux_cfg_tchanges, I'm afraid the suggestion becomes invalid.Really? Why?
I'm confused by the compiling error below when adding
__initconstfor mx28evk_pads[], and mistakenly blaming u64iomux_cfg_tchanges.
arch/arm/mach-mxs/mach-mx28evk.c: In function ?mx28evk_init?:arch/arm/mach-mxs/mach-mx28evk.c:34: error:mx28_fec_pdatacauses a section type conflict
make[1]: *** [arch/arm/mach-mxs/mach-mx28evk.o] Error 1
make: *** [arch/arm/mach-mxs] Error 2
Quoted 9 lines
Quoted 6 lines
Actually it can be fixed by the following change.
(quoted diff) +1
-1-static const struct fec_platform_data mx28_fec_pdata __initconst = { +static struct fec_platform_data mx28_fec_pdata __initconst = {? ? ? ? ?.phy =
PHY_INTERFACE_MODE_RMII,
?};this change is wrong. ?You need to assert that all data being marked with
__initconstis const, too.
After adding const for mx28evk_pads[], I got the following error.
CC arch/arm/mach-mxs/mach-mx28evk.oarch/arm/mach-mxs/mach-mx28evk.c: In function ?mx28evk_init?:arch/arm/mach-mxs/mach-mx28evk.c:102: warning: passing argument 1 of ?mxs_iomux_setup_multiple_pads? discards qualifiers from pointer target typearch/arm/mach-mxs/include/mach/iomux.h:115: note: expected ?iomux_cfg_t *? but argument is of type ?const iomux_cfg_t *?
This takes me back to my first judgment. Is it proper to add __initconst for mx28evk_pads[]? We are changing iomux_cfg_t to u64 for making pad definition modifiable.
Signature · 2 lines
Regards, Shawn
PATCH v2 14/15 ARM: mxs: Add initial mx28evk support
Quoted 36 lines · Shawn Guo
2010/12/9 Uwe Kleine-K?nig <[email protected]>:
Quoted 24 lines
Hello Shawn
Quoted 2 lines · Shawn Guo
2010/12/9 Uwe Kleine-K?nig <[email protected]>:
Quoted 1 line
Hello Shwan,
ups, sorry for mistyping your name.
Quoted 18 lines
Quoted 9 lines · Shawn Guo
Quoted 6 lines
2010/12/9 Uwe Kleine-K?nig <[email protected]>:
Quoted 4 lines · Shawn Guo
Quoted 1 line
+static
iomux_cfg_tmx28evk_pads[] = {This can be const and
__initconst, ditto for mx23evkWith u64
iomux_cfg_tchanges, I'm afraid the suggestion becomes invalid.Really? Why?
I'm confused by the compiling error below when adding
__initconstfor mx28evk_pads[], and mistakenly blaming u64iomux_cfg_tchanges.
arch/arm/mach-mxs/mach-mx28evk.c: In function ?mx28evk_init?:arch/arm/mach-mxs/mach-mx28evk.c:34: error:mx28_fec_pdatacauses a section type conflict
make[1]: *** [arch/arm/mach-mxs/mach-mx28evk.o] Error 1
make: *** [arch/arm/mach-mxs] Error 2Quoted 9 lines
Quoted 6 lines
Actually it can be fixed by the following change.
(quoted diff) +1
-1-static const struct fec_platform_data mx28_fec_pdata __initconst = { +static struct fec_platform_data mx28_fec_pdata __initconst = {? ? ? ? ?.phy =
PHY_INTERFACE_MODE_RMII,
?};this change is wrong. ?You need to assert that all data being marked with
__initconstis const, too.After adding const for mx28evk_pads[], I got the following error.
Quoted 8 lines
CC
arch/arm/mach-mxs/mach-mx28evk.oarch/arm/mach-mxs/mach-mx28evk.c: In function ?mx28evk_init?:arch/arm/mach-mxs/mach-mx28evk.c:102: warning: passing argument 1 of ?mxs_iomux_setup_multiple_pads? discards qualifiers from pointer target typearch/arm/mach-mxs/include/mach/iomux.h:115: note: expected ?iomux_cfg_t *? but argument is of type ?constiomux_cfg_t*?
The argument of mxs_iomux_setup_multiple_pads() should get the const attribute:
-int mxs_iomux_setup_multiple_pads(iomux_cfg_t *pad_list, unsigned count) +int mxs_iomux_setup_multiple_pads(const iomux_cfg_t *pad_list, unsigned count)
Quoted 4 lines
This takes me back to my first judgment. Is it proper to add
__initconstfor mx28evk_pads[]? We are changingiomux_cfg_tto u64 for making pad definition modifiable.
Modifiable in the sense that you can add platform specific PAD settings by simply ORing them to the original pad definition so that there is no need for runtime modifications like:
| iomux_v3_cfg_t power_key = MX51_PAD_EIM_A27__GPIO_2_21;
...
| power_key.pad_ctrl = MX51_GPIO_PAD_CTRL_2;
| mxc_iomux_v3_setup_pad(&power_key);
but you can do:
| iomux_v3_cfg_t power_key = (MX51_PAD_EIM_A27__GPIO_2_21 &
| ~MUX_PAD_CTRL_MASK) | MX51_GPIO_PAD_CTRL_2;
...
| mxc_iomux_v3_setup_pad(power_key);
instead. You can also augment the pad desc in a static table:
|static iomux_cfg_t pad_desc[] = {
| (MX51_PAD_EIM_A27__GPIO_2_21 & ~MUX_PAD_CTRL_MASK) | MX51_GPIO_PAD_CTRL_2,
Lothar Wa?mann
Signature · 9 lines
___________________________________________________________ Ka-Ro electronics GmbH | Pascalstra?e 22 | D - 52076 Aachen Phone: +49 2408 1402-0 | Fax: +49 2408 1402-10 Gesch?ftsf?hrer: Matthias Kaussen Handelsregistereintrag: Amtsgericht Aachen, HRB 4996 www.karo-electronics.de | info at karo-electronics.de ___________________________________________________________
PATCH v2 14/15 ARM: mxs: Add initial mx28evk support
Hi Lothar,
Quoted 54 lines · Lothar Wa?mann
Quoted 36 lines · Shawn Guo
2010/12/9 Uwe Kleine-K?nig <[email protected]>:
Quoted 24 lines
Hello Shawn
Quoted 2 lines · Shawn Guo
2010/12/9 Uwe Kleine-K?nig <[email protected]>:
Quoted 1 line
Hello Shwan,
ups, sorry for mistyping your name.
Quoted 18 lines
Quoted 9 lines · Shawn Guo
Quoted 6 lines
2010/12/9 Uwe Kleine-K?nig <[email protected]>:
Quoted 4 lines · Shawn Guo
Quoted 1 line
+static
iomux_cfg_tmx28evk_pads[] = {This can be const and
__initconst, ditto for mx23evkWith u64
iomux_cfg_tchanges, I'm afraid the suggestion becomes invalid.Really? Why?
I'm confused by the compiling error below when adding
__initconstfor mx28evk_pads[], and mistakenly blaming u64iomux_cfg_tchanges.
arch/arm/mach-mxs/mach-mx28evk.c: In function ?mx28evk_init?:arch/arm/mach-mxs/mach-mx28evk.c:34: error:mx28_fec_pdatacauses a section type conflict
make[1]: *** [arch/arm/mach-mxs/mach-mx28evk.o] Error 1
make: *** [arch/arm/mach-mxs] Error 2Quoted 9 lines
Quoted 6 lines
Actually it can be fixed by the following change.
(quoted diff) +1
-1-static const struct fec_platform_data mx28_fec_pdata __initconst = { +static struct fec_platform_data mx28_fec_pdata __initconst = {? ? ? ? ?.phy =
PHY_INTERFACE_MODE_RMII,
?};this change is wrong. ?You need to assert that all data being marked with
__initconstis const, too.After adding const for mx28evk_pads[], I got the following error.
Quoted 8 lines
? CC ? ? ?arch/arm/mach-mxs/mach-mx28evk.o
arch/arm/mach-mxs/mach-mx28evk.c: In function ?mx28evk_init?:arch/arm/mach-mxs/mach-mx28evk.c:102: warning: passing argument 1 of ?mxs_iomux_setup_multiple_pads? discards qualifiers from pointer target typearch/arm/mach-mxs/include/mach/iomux.h:115: note: expected ?iomux_cfg_t *? but argument is of type ?constiomux_cfg_t*?The argument of
mxs_iomux_setup_multiple_pads()should get the const attribute:(quoted diff) +1
-1-int mxs_iomux_setup_multiple_pads(iomux_cfg_t *pad_list, unsigned count) +int mxs_iomux_setup_multiple_pads(const iomux_cfg_t *pad_list, unsigned count)Quoted 5 lines
This takes me back to my first judgment. ?Is it proper to add
__initconstfor mx28evk_pads[]? We are changingiomux_cfg_tto u64 for making pad definition modifiable.
Quoted 17 lines
Modifiable in the sense that you can add platform specific PAD settings by simply ORing them to the original pad definition so that there is no need for runtime modifications like:
| ? ? ?iomux_v3_cfg_tpower_key=MX51_PAD_EIM_A27__GPIO_2_21;
...
| ? ? ? power_key.pad_ctrl =MX51_GPIO_PAD_CTRL_2;
| ? ? ?mxc_iomux_v3_setup_pad(&power_key);
but you can do:
| ? ? ?iomux_v3_cfg_tpower_key= (MX51_PAD_EIM_A27__GPIO_2_21&
| ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ~MUX_PAD_CTRL_MASK) |MX51_GPIO_PAD_CTRL_2;
...
| ? ? ?mxc_iomux_v3_setup_pad(power_key);
instead. You can also augment the pad desc in a static table:
|staticiomux_cfg_tpad_desc[] = {
| ? ? ? (MX51_PAD_EIM_A27__GPIO_2_21& ~MUX_PAD_CTRL_MASK) |MX51_GPIO_PAD_CTRL_2,
Thanks for the explanation. But I'm a little puzzled by the use of "const" here. Per your suggestion, I have the following.
mach-28evk.c
static const iomux_cfg_t mx28evk_pads[] __initconst = {
iomux.h
int mxs_iomux_setup_multiple_pads(const iomux_cfg_t *pad_list, unsigned count);
iomux.c
int mxs_iomux_setup_multiple_pads(const iomux_cfg_t *pad_list, unsigned count)
Compiler complains as below.
CC arch/arm/mach-mxs/iomux.oarch/arm/mach-mxs/iomux.c:89: error: conflicting types for ?mxs_iomux_setup_multiple_pads? arch/arm/mach-mxs/include/mach/iomux.h:115: note: previous declaration of ?mxs_iomux_setup_multiple_pads? was here
make[1]: *** [arch/arm/mach-mxs/iomux.o] Error 1
make: *** [arch/arm/mach-mxs] Error 2
If I remove the "const" in iomux.h as below.
iomux.h
int mxs_iomux_setup_multiple_pads(iomux_cfg_t *pad_list, unsigned count);
Compiler gives the following warning.
CC arch/arm/mach-mxs/mach-mx28evk.oarch/arm/mach-mxs/mach-mx28evk.c: In function ?mx28evk_init?:arch/arm/mach-mxs/mach-mx28evk.c:102: warning: passing argument 1 of ?mxs_iomux_setup_multiple_pads? discards qualifiers from pointer target typearch/arm/mach-mxs/include/mach/iomux.h:115: note: expected ?iomux_cfg_t *? but argument is of type ?const iomux_cfg_t *?
What's wrong here?
Signature · 2 lines
Regards, Shawn
PATCH v2 14/15 ARM: mxs: Add initial mx28evk support
Quoted 111 lines · Shawn Guo
Hi Lothar,
Quoted 54 lines · Lothar Wa?mann
Quoted 36 lines · Shawn Guo
2010/12/9 Uwe Kleine-K?nig <[email protected]>:
Quoted 24 lines
Hello Shawn
Quoted 2 lines · Shawn Guo
2010/12/9 Uwe Kleine-K?nig <[email protected]>:
Quoted 1 line
Hello Shwan,
ups, sorry for mistyping your name.
Quoted 18 lines
Quoted 9 lines · Shawn Guo
Quoted 6 lines
2010/12/9 Uwe Kleine-K?nig <[email protected]>:
Quoted 4 lines · Shawn Guo
Quoted 1 line
+static
iomux_cfg_tmx28evk_pads[] = {This can be const and
__initconst, ditto for mx23evkWith u64
iomux_cfg_tchanges, I'm afraid the suggestion becomes invalid.Really? Why?
I'm confused by the compiling error below when adding
__initconstfor mx28evk_pads[], and mistakenly blaming u64iomux_cfg_tchanges.
arch/arm/mach-mxs/mach-mx28evk.c: In function ?mx28evk_init?:arch/arm/mach-mxs/mach-mx28evk.c:34: error:mx28_fec_pdatacauses a section type conflict
make[1]: *** [arch/arm/mach-mxs/mach-mx28evk.o] Error 1
make: *** [arch/arm/mach-mxs] Error 2Quoted 9 lines
Quoted 6 lines
Actually it can be fixed by the following change.
(quoted diff) +1
-1-static const struct fec_platform_data mx28_fec_pdata __initconst = { +static struct fec_platform_data mx28_fec_pdata __initconst = {? ? ? ? ?.phy =
PHY_INTERFACE_MODE_RMII,
?};this change is wrong. ?You need to assert that all data being marked with
__initconstis const, too.After adding const for mx28evk_pads[], I got the following error.
Quoted 8 lines
? CC ? ? ?arch/arm/mach-mxs/mach-mx28evk.o
arch/arm/mach-mxs/mach-mx28evk.c: In function ?mx28evk_init?:arch/arm/mach-mxs/mach-mx28evk.c:102: warning: passing argument 1 of ?mxs_iomux_setup_multiple_pads? discards qualifiers from pointer target typearch/arm/mach-mxs/include/mach/iomux.h:115: note: expected ?iomux_cfg_t *? but argument is of type ?constiomux_cfg_t*?The argument of
mxs_iomux_setup_multiple_pads()should get the const attribute:(quoted diff) +1
-1-int mxs_iomux_setup_multiple_pads(iomux_cfg_t *pad_list, unsigned count) +int mxs_iomux_setup_multiple_pads(const iomux_cfg_t *pad_list, unsigned count)Quoted 5 lines
This takes me back to my first judgment. ?Is it proper to add
__initconstfor mx28evk_pads[]? We are changingiomux_cfg_tto u64 for making pad definition modifiable.Quoted 17 lines
Modifiable in the sense that you can add platform specific PAD settings by simply ORing them to the original pad definition so that there is no need for runtime modifications like:
| ? ? ?iomux_v3_cfg_tpower_key=MX51_PAD_EIM_A27__GPIO_2_21;
...
| ? ? ? power_key.pad_ctrl =MX51_GPIO_PAD_CTRL_2;
| ? ? ?mxc_iomux_v3_setup_pad(&power_key);
but you can do:
| ? ? ?iomux_v3_cfg_tpower_key= (MX51_PAD_EIM_A27__GPIO_2_21&
| ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ~MUX_PAD_CTRL_MASK) |MX51_GPIO_PAD_CTRL_2;
...
| ? ? ?mxc_iomux_v3_setup_pad(power_key);
instead. You can also augment the pad desc in a static table:
|staticiomux_cfg_tpad_desc[] = {
| ? ? ? (MX51_PAD_EIM_A27__GPIO_2_21& ~MUX_PAD_CTRL_MASK) |MX51_GPIO_PAD_CTRL_2,Thanks for the explanation. ?But I'm a little puzzled by the use of "const" here. Per your suggestion, I have the following.
mach-28evk.c
static constiomux_cfg_tmx28evk_pads[]__initconst= {
iomux.h
intmxs_iomux_setup_multiple_pads(const iomux_cfg_t *pad_list, unsigned count);
iomux.c
intmxs_iomux_setup_multiple_pads(const iomux_cfg_t *pad_list, unsigned count)Compiler complains as below.
?CC ? ? ?arch/arm/mach-mxs/iomux.o
arch/arm/mach-mxs/iomux.c:89: error: conflicting types for ?mxs_iomux_setup_multiple_pads?arch/arm/mach-mxs/include/mach/iomux.h:115: note: previous declaration of ?mxs_iomux_setup_multiple_pads? was here
make[1]: *** [arch/arm/mach-mxs/iomux.o] Error 1
make: *** [arch/arm/mach-mxs] Error 2If I remove the "const" in
iomux.has below.
iomux.h
intmxs_iomux_setup_multiple_pads(iomux_cfg_t *pad_list, unsigned count);Compiler gives the following warning.
?CC ? ? ?arch/arm/mach-mxs/mach-mx28evk.o
arch/arm/mach-mxs/mach-mx28evk.c: In function ?mx28evk_init?:arch/arm/mach-mxs/mach-mx28evk.c:102: warning: passing argument 1 of ?mxs_iomux_setup_multiple_pads? discards qualifiers from pointer target typearch/arm/mach-mxs/include/mach/iomux.h:115: note: expected ?iomux_cfg_t *? but argument is of type ?constiomux_cfg_t*?
Quoted 2 lines
What's wrong here?
Sorry. Please ignore this message.
Signature · 2 lines
Regards, Shawn
PATCH v2 15/15 ARM: mxs: Add build configuration for mxs
In reply to Shawn Guo---
Changes for v2:
- Remove cpu.o from arch/arm/mach-mxs/Makefile
arch/arm/Kconfig | 10 ++++++++++ arch/arm/Makefile | 1 + arch/arm/mach-mxs/Kconfig | 34 ++++++++++++++++++++++++++++++++++ arch/arm/mach-mxs/Makefile | 14 ++++++++++++++ arch/arm/mach-mxs/Makefile.boot | 3 +++ arch/arm/mach-mxs/devices/Kconfig | 5 +++++ arch/arm/mach-mxs/devices/Makefile | 2 ++ 7 files changed, 69 insertions(+), 0 deletions(-) create mode 100644 arch/arm/mach-mxs/Kconfig create mode 100644 arch/arm/mach-mxs/Makefile create mode 100644 arch/arm/mach-mxs/Makefile.boot create mode 100644 arch/arm/mach-mxs/devices/Kconfig create mode 100644 arch/arm/mach-mxs/devices/Makefile
arch/arm/Kconfig +10 -0
@@ -351,6 +351,14 @@ config ARCH_MXC help Support for Freescale MXC/iMX-based family of processors +config ARCH_MXS + bool "Freescale MXS-based" + select GENERIC_CLOCKEVENTS + select ARCH_REQUIRE_GPIOLIB + select COMMON_CLKDEV + help + Support for Freescale MXS-based family of processors + config ARCH_STMP3XXX bool "Freescale STMP3xxx" select CPU_ARM926T
@@ -924,6 +932,8 @@ source "arch/arm/plat-pxa/Kconfig" source "arch/arm/mach-mmp/Kconfig" +source "arch/arm/mach-mxs/Kconfig" + source "arch/arm/mach-realview/Kconfig" source "arch/arm/mach-sa1100/Kconfig"
arch/arm/Makefile +1 -0
@@ -158,6 +158,7 @@ machine-$(CONFIG_ARCH_MX25) := imx machine-$(CONFIG_ARCH_MX3) := mx3 machine-$(CONFIG_ARCH_MX5) := mx5 machine-$(CONFIG_ARCH_MXC91231) := mxc91231 +machine-$(CONFIG_ARCH_MXS) := mxs machine-$(CONFIG_ARCH_NETX) := netx machine-$(CONFIG_ARCH_NOMADIK) := nomadik machine-$(CONFIG_ARCH_NS9XXX) := ns9xxx
arch/arm/mach-mxs/Kconfig new file +34 -0
@@ -0,0 +1,34 @@ +if ARCH_MXS + +source "arch/arm/mach-mxs/devices/Kconfig" + +config SOC_IMX23 + bool + select CPU_ARM926T + +config SOC_IMX28 + bool + select CPU_ARM926T + +comment "MXS platforms:" + +config MACH_MX23EVK + bool "Support MX23EVK Platform" + select SOC_IMX23 + select MXS_HAVE_PLATFORM_DUART + default y + help + Include support for MX23EVK platform. This includes specific + configurations for the board and its peripherals. + +config MACH_MX28EVK + bool "Support MX28EVK Platform" + select SOC_IMX28 + select MXS_HAVE_PLATFORM_DUART + select MXS_HAVE_PLATFORM_FEC + default y + help + Include support for MX28EVK platform. This includes specific + configurations for the board and its peripherals. + +endif
arch/arm/mach-mxs/Makefile new file +14 -0
@@ -0,0 +1,14 @@ +# +# Makefile for the linux kernel. +# + +# Common support +obj-y := clock.o devices.o gpio.o icoll.o iomux.o system.o timer.o + +obj-$(CONFIG_SOC_IMX23) += clock-mx23.o mm-mx23.o +obj-$(CONFIG_SOC_IMX28) += clock-mx28.o mm-mx28.o + +obj-$(CONFIG_MACH_MX23EVK) += mach-mx23evk.o +obj-$(CONFIG_MACH_MX28EVK) += mach-mx28evk.o + +obj-y += devices/
arch/arm/mach-mxs/Makefile.boot new file +3 -0
@@ -0,0 +1,3 @@ + zreladdr-y := 0x40008000 +params_phys-y := 0x40000100 +initrd_phys-y := 0x40800000
arch/arm/mach-mxs/devices/Kconfig new file +5 -0
@@ -0,0 +1,5 @@ +config MXS_HAVE_PLATFORM_DUART + bool + +config MXS_HAVE_PLATFORM_FEC + bool
arch/arm/mach-mxs/devices/Makefile new file +2 -0
@@ -0,0 +1,2 @@ +obj-$(CONFIG_MXS_HAVE_PLATFORM_DUART) += platform-duart.o +obj-$(CONFIG_MXS_HAVE_PLATFORM_FEC) += platform-fec.o
Signature · 1 line
1.7.1
PATCH v3 13/15 ARM: mxs: Add initial mx23evk support
In reply to Shawn GuoAdd initial mx23evk support with duart.
---
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 | 57 ++++++++++++++++++++++++++++++++++++++ 1 files changed, 57 insertions(+), 0 deletions(-) create mode 100644 arch/arm/mach-mxs/mach-mx23evk.c
arch/arm/mach-mxs/mach-mx23evk.c new file +57 -0
@@ -0,0 +1,57 @@ +/* +* 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 , +MX23_PAD_PWM1__DUART_TX , +}; + +static void __init mx23evk_init (void ) +{ +mxs_iomux_setup_multiple_pads (mx23evk_pads,ARRAY_SIZE (mx23evk_pads)); + +mx23_add_duart (); +} + +static void __init mx23evk_timer_init (void ) +{ +mx23_clocks_init (); +} + +static struct sys_timer mx23evk_timer = { + .init = mx23evk_timer_init, +}; + +MACHINE_START (MX23EVK ,"Freescale MX23 EVK" ) +/* Maintainer: Freescale Semiconductor, Inc. */ + .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 v3 14/15 ARM: mxs: Add initial mx28evk support
In reply to Shawn GuoAdd initial mx28evk support with duart and fec0.
---
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 | 125 ++++++++++++++++++++++++++++++++++++++ 1 files changed, 125 insertions(+), 0 deletions(-) create mode 100644 arch/arm/mach-mxs/mach-mx28evk.c
arch/arm/mach-mxs/mach-mx28evk.c new file +125 -0
@@ -0,0 +1,125 @@ +/* +* 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 , +MX28_PAD_PWM1__DUART_TX , + +/* fec0 */ +MX28_PAD_ENET0_MDC__ENET0_MDC , +MX28_PAD_ENET0_MDIO__ENET0_MDIO , +MX28_PAD_ENET0_RX_EN__ENET0_RX_EN , +MX28_PAD_ENET0_RXD0__ENET0_RXD0 , +MX28_PAD_ENET0_RXD1__ENET0_RXD1 , +MX28_PAD_ENET0_TX_EN__ENET0_TX_EN , +MX28_PAD_ENET0_TXD0__ENET0_TXD0 , +MX28_PAD_ENET0_TXD1__ENET0_TXD1 , +MX28_PAD_ENET_CLK__ENET_CLK , +/* phy power line */ +MX28_PAD_SSP1_DATA3__GPIO_2_15 , +/* phy reset line */ +MX28_PAD_ENET0_RX_CLK__GPIO_4_13 , +}; + +/* fec */ +static 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
PATCH v3 15/15 ARM: mxs: Add build configuration for mxs
In reply to Shawn Guo---
Changes for v3:
- Sort mach-mxs behind plat-mxc in arch/arm/Kconfig
- Remove meaningless comment from arch/arm/mach-mxs/Makefile
- Remove unused params_phys and initrd_phys from arch/arm/mach-mxs/Makefile.boot
Changes for v2:
- Remove cpu.o from arch/arm/mach-mxs/Makefile
arch/arm/Kconfig | 10 ++++++++++ arch/arm/Makefile | 1 + arch/arm/mach-mxs/Kconfig | 34 ++++++++++++++++++++++++++++++++++ arch/arm/mach-mxs/Makefile | 10 ++++++++++ arch/arm/mach-mxs/Makefile.boot | 1 + arch/arm/mach-mxs/devices/Kconfig | 5 +++++ arch/arm/mach-mxs/devices/Makefile | 2 ++ 7 files changed, 63 insertions(+), 0 deletions(-) create mode 100644 arch/arm/mach-mxs/Kconfig create mode 100644 arch/arm/mach-mxs/Makefile create mode 100644 arch/arm/mach-mxs/Makefile.boot create mode 100644 arch/arm/mach-mxs/devices/Kconfig create mode 100644 arch/arm/mach-mxs/devices/Makefile
arch/arm/Kconfig +10 -0
@@ -351,6 +351,14 @@ config ARCH_MXC help Support for Freescale MXC/iMX-based family of processors +config ARCH_MXS + bool "Freescale MXS-based" + select GENERIC_CLOCKEVENTS + select ARCH_REQUIRE_GPIOLIB + select COMMON_CLKDEV + help + Support for Freescale MXS-based family of processors + config ARCH_STMP3XXX bool "Freescale STMP3xxx" select CPU_ARM926T
@@ -902,6 +910,8 @@ source "arch/arm/mach-mv78xx0/Kconfig" source "arch/arm/plat-mxc/Kconfig" +source "arch/arm/mach-mxs/Kconfig" + source "arch/arm/mach-netx/Kconfig" source "arch/arm/mach-nomadik/Kconfig"
arch/arm/Makefile +1 -0
@@ -158,6 +158,7 @@ machine-$(CONFIG_ARCH_MX25) := imx machine-$(CONFIG_ARCH_MX3) := mx3 machine-$(CONFIG_ARCH_MX5) := mx5 machine-$(CONFIG_ARCH_MXC91231) := mxc91231 +machine-$(CONFIG_ARCH_MXS) := mxs machine-$(CONFIG_ARCH_NETX) := netx machine-$(CONFIG_ARCH_NOMADIK) := nomadik machine-$(CONFIG_ARCH_NS9XXX) := ns9xxx
arch/arm/mach-mxs/Kconfig new file +34 -0
@@ -0,0 +1,34 @@ +if ARCH_MXS + +source "arch/arm/mach-mxs/devices/Kconfig" + +config SOC_IMX23 + bool + select CPU_ARM926T + +config SOC_IMX28 + bool + select CPU_ARM926T + +comment "MXS platforms:" + +config MACH_MX23EVK + bool "Support MX23EVK Platform" + select SOC_IMX23 + select MXS_HAVE_PLATFORM_DUART + default y + help + Include support for MX23EVK platform. This includes specific + configurations for the board and its peripherals. + +config MACH_MX28EVK + bool "Support MX28EVK Platform" + select SOC_IMX28 + select MXS_HAVE_PLATFORM_DUART + select MXS_HAVE_PLATFORM_FEC + default y + help + Include support for MX28EVK platform. This includes specific + configurations for the board and its peripherals. + +endif
arch/arm/mach-mxs/Makefile new file +10 -0
@@ -0,0 +1,10 @@ +# Common support +obj-y := clock.o cpu.o devices.o gpio.o icoll.o iomux.o system.o timer.o + +obj-$(CONFIG_SOC_IMX23) += clock-mx23.o mm-mx23.o +obj-$(CONFIG_SOC_IMX28) += clock-mx28.o mm-mx28.o + +obj-$(CONFIG_MACH_MX23EVK) += mach-mx23evk.o +obj-$(CONFIG_MACH_MX28EVK) += mach-mx28evk.o + +obj-y += devices/
arch/arm/mach-mxs/Makefile.boot new file +1 -0
@@ -0,0 +1 @@ +zreladdr-y := 0x40008000
arch/arm/mach-mxs/devices/Kconfig new file +5 -0
@@ -0,0 +1,5 @@ +config MXS_HAVE_PLATFORM_DUART + bool + +config MXS_HAVE_PLATFORM_FEC + bool
arch/arm/mach-mxs/devices/Makefile new file +2 -0
@@ -0,0 +1,2 @@ +obj-$(CONFIG_MXS_HAVE_PLATFORM_DUART) += platform-duart.o +obj-$(CONFIG_MXS_HAVE_PLATFORM_FEC) += platform-fec.o
Signature · 1 line
1.7.1
PATCH v3 15/15 ARM: mxs: Add build configuration for mxs
Hallo Shawn,
arch/arm/mach-mxs/Makefile line 2
Quoted 11 lines · Shawn Guo
- Remove cpu.o from
arch/arm/mach-mxs/Makefile
[...]arch/arm/mach-mxs/Makefile new file +2
-0@@ -0,0 +1,10 @@ +# Common support +obj-y := clock.o cpu.o devices.o gpio.o icoll.o iomux.o system.o timer.o
^^^^^
Uwe
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-K?nig | Industrial Linux Solutions | http://www.pengutronix.de/ |
PATCH v3 15/15 ARM: mxs: Add build configuration for mxs
Hi Uwe,
2010/12/10 Uwe Kleine-K?nig <[email protected]>:
Quoted 6 lines
Hallo Shawn,
Quoted 3 lines · Shawn Guo
?- Remove cpu.o from
arch/arm/mach-mxs/Makefile
[...]
Quoted 10 lines
arch/arm/mach-mxs/Makefile line 2
Quoted 8 lines
arch/arm/mach-mxs/Makefile new file +2
-0@@ -0,0 +1,10 @@ +# Common support +obj-y := clock.o cpu.o devices.o gpio.o icoll.o iomux.o system.o timer.o? ? ? ? ? ? ? ? ? ?^^^^^
There was something wrong with my patch management. The commit of removing cpu.o was squashed into another local patch. Thanks for catching.
Signature · 2 lines
Regards, Shawn