* [PATCH 0/2]Add mxc common CPLD debugboard support @ 2010-06-12 14:25 Jason Wang 2010-06-12 14:25 ` [PATCH 1/2] mxc: add common debug board for 3-stack platforms Jason Wang 0 siblings, 1 reply; 10+ messages in thread From: Jason Wang @ 2010-06-12 14:25 UTC (permalink / raw) To: linux-arm-kernel part2: [PATCH 1/2] mxc: add common debug board for 3-stack platforms [PATCH 2/2] mx31_3ds: revert cpld debug board relate code ^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 1/2] mxc: add common debug board for 3-stack platforms 2010-06-12 14:25 [PATCH 0/2]Add mxc common CPLD debugboard support Jason Wang @ 2010-06-12 14:25 ` Jason Wang 2010-06-12 14:25 ` [PATCH 2/2] mx31_3ds: revert cpld debug board relate code Jason Wang 2010-06-16 6:55 ` [PATCH 1/2] mxc: add common debug board for 3-stack platforms Sascha Hauer 0 siblings, 2 replies; 10+ messages in thread From: Jason Wang @ 2010-06-12 14:25 UTC (permalink / raw) To: linux-arm-kernel The debug board is little different for all mxc 3-stack(PDK) platforms, it is possible here to add a common implementation to support this board. Signed-off-by: Jason Wang <jason77.wang@gmail.com> --- arch/arm/plat-mxc/Kconfig | 11 ++ arch/arm/plat-mxc/Makefile | 1 + arch/arm/plat-mxc/cpld_debugboard.c | 161 ++++++++++++++++++++++ arch/arm/plat-mxc/include/mach/cpld_debugboard.h | 60 ++++++++ 4 files changed, 233 insertions(+), 0 deletions(-) create mode 100644 arch/arm/plat-mxc/cpld_debugboard.c create mode 100644 arch/arm/plat-mxc/include/mach/cpld_debugboard.h diff --git a/arch/arm/plat-mxc/Kconfig b/arch/arm/plat-mxc/Kconfig index 7f7ad6f..8bf917e 100644 --- a/arch/arm/plat-mxc/Kconfig +++ b/arch/arm/plat-mxc/Kconfig @@ -81,6 +81,17 @@ config MXC_PWM help Enable support for the i.MX PWM controller(s). +config MXC_DEBUG_BOARD + bool "Enable MXC debug board(for 3-stack)" + help + The debug board is an integral part of the MXC 3-stack(PDK) + platforms, it can be attached or removed from the peripheral + board. On debug board, several debug devices(ethernet, UART, + buttons, LEDs and JTAG) are implemented. Between the MCU and + these devices, a CPLD is added as a bridge which performs + data/address de-multiplexing and decode, signal level shift, + interrupt control and various board functions. + config MXC_ULPI bool diff --git a/arch/arm/plat-mxc/Makefile b/arch/arm/plat-mxc/Makefile index 895bc3c..b9e8c6f 100644 --- a/arch/arm/plat-mxc/Makefile +++ b/arch/arm/plat-mxc/Makefile @@ -17,6 +17,7 @@ obj-$(CONFIG_USB_EHCI_MXC) += ehci.o obj-$(CONFIG_MXC_ULPI) += ulpi.o obj-$(CONFIG_ARCH_MXC_AUDMUX_V1) += audmux-v1.o obj-$(CONFIG_ARCH_MXC_AUDMUX_V2) += audmux-v2.o +obj-$(CONFIG_MXC_DEBUG_BOARD) += cpld_debugboard.o ifdef CONFIG_SND_IMX_SOC obj-y += ssi-fiq.o obj-y += ssi-fiq-ksym.o diff --git a/arch/arm/plat-mxc/cpld_debugboard.c b/arch/arm/plat-mxc/cpld_debugboard.c new file mode 100644 index 0000000..0554fa0 --- /dev/null +++ b/arch/arm/plat-mxc/cpld_debugboard.c @@ -0,0 +1,161 @@ +/* + * Copyright 2008-2009 Freescale Semiconductor, Inc. All Rights Reserved. + * Copyright (C) 2010 Jason Wang <jason77.wang@gmail.com> + * + * The code contained herein is licensed under the GNU General Public + * License. You may obtain a copy of the GNU General Public License + * Version 2 or later at the following locations: + * + * http://www.opensource.org/licenses/gpl-license.html + * http://www.gnu.org/copyleft/gpl.html + */ + +#include <linux/interrupt.h> +#include <linux/irq.h> +#include <linux/io.h> +#include <linux/platform_device.h> +#include <linux/gpio.h> +#include <linux/smsc911x.h> + +#include <mach/hardware.h> +#include <mach/cpld_debugboard.h> + +static void __iomem *brd_io; +static void expio_ack_irq(u32 irq); + +static struct resource smsc911x_resources[] = { + { + .flags = IORESOURCE_MEM, + } , { + .start = EXPIO_INT_ENET, + .end = EXPIO_INT_ENET, + .flags = IORESOURCE_IRQ, + }, +}; + +struct smsc911x_platform_config smsc911x_config = { + .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW, + .flags = SMSC911X_USE_32BIT | SMSC911X_FORCE_INTERNAL_PHY, +}; + +struct platform_device smsc_lan9217_device = { + .name = "smsc911x", + .id = 0, + .dev = { + .platform_data = &smsc911x_config, + }, + .num_resources = ARRAY_SIZE(smsc911x_resources), + .resource = smsc911x_resources, +}; + +static void mxc_expio_irq_handler(u32 irq, struct irq_desc *desc) +{ + u32 imr_val; + u32 int_valid; + u32 expio_irq; + + desc->chip->mask(irq); /* irq = gpio irq number */ + + imr_val = __raw_readw(brd_io + INTR_MASK_REG); + int_valid = __raw_readw(brd_io + INTR_STATUS_REG) & ~imr_val; + + expio_irq = MXC_BOARD_IRQ_START; + for (; int_valid != 0; int_valid >>= 1, expio_irq++) { + struct irq_desc *d; + if ((int_valid & 1) == 0) + continue; + d = irq_desc + expio_irq; + if (unlikely(!(d->handle_irq))) + pr_err("\nEXPIO irq: %d unhandled\n", expio_irq); + else + d->handle_irq(expio_irq, d); + } + + desc->chip->ack(irq); + desc->chip->unmask(irq); +} + +/* + * Disable an expio pin's interrupt by setting the bit in the imr. + * Irq is an expio virtual irq number + */ +static void expio_mask_irq(u32 irq) +{ + u16 reg; + u32 expio = MXC_IRQ_TO_EXPIO(irq); + + reg = __raw_readw(brd_io + INTR_MASK_REG); + reg |= (1 << expio); + __raw_writew(reg, brd_io + INTR_MASK_REG); +} + +static void expio_ack_irq(u32 irq) +{ + u32 expio = MXC_IRQ_TO_EXPIO(irq); + + __raw_writew(1 << expio, brd_io + INTR_RESET_REG); + __raw_writew(0, brd_io + INTR_RESET_REG); + expio_mask_irq(irq); +} + +static void expio_unmask_irq(u32 irq) +{ + u16 reg; + u32 expio = MXC_IRQ_TO_EXPIO(irq); + + reg = __raw_readw(brd_io + INTR_MASK_REG); + reg &= ~(1 << expio); + __raw_writew(reg, brd_io + INTR_MASK_REG); +} + +static struct irq_chip expio_irq_chip = { + .ack = expio_ack_irq, + .mask = expio_mask_irq, + .unmask = expio_unmask_irq, +}; + +int __init mxc_expio_init(u32 base, u32 p_irq) +{ + int i; + + brd_io = ioremap(BOARD_IO_ADDR(base), SZ_4K); + if (brd_io == NULL) + return -ENOMEM; + + if ((__raw_readw(brd_io + MAGIC_NUMBER1_REG) != 0xAAAA) || + (__raw_readw(brd_io + MAGIC_NUMBER2_REG) != 0x5555) || + (__raw_readw(brd_io + MAGIC_NUMBER3_REG) != 0xCAFE)) { + pr_info("3-Stack Debug board not detected\n"); + iounmap(brd_io); + brd_io = NULL; + return -ENODEV; + } + + pr_info("3-Stack Debug board detected, rev = 0x%04X\n", + readw(brd_io + CPLD_CODE_VER_REG)); + + smsc911x_resources[0].start = LAN9217_BASE_ADDR(base); + smsc911x_resources[0].end = LAN9217_BASE_ADDR(base) + 0x100 - 1; + + /* + * Configure INT line as GPIO input + */ + gpio_request(MXC_IRQ_TO_GPIO(p_irq), "expio_pirq"); + gpio_direction_input(MXC_IRQ_TO_GPIO(p_irq)); + + /* disable the interrupt and clear the status */ + __raw_writew(0, brd_io + INTR_MASK_REG); + __raw_writew(0xFFFF, brd_io + INTR_RESET_REG); + __raw_writew(0, brd_io + INTR_RESET_REG); + __raw_writew(0x1F, brd_io + INTR_MASK_REG); + for (i = MXC_EXP_IO_BASE; + i < (MXC_EXP_IO_BASE + MXC_MAX_EXP_IO_LINES); i++) { + set_irq_chip(i, &expio_irq_chip); + set_irq_handler(i, handle_level_irq); + set_irq_flags(i, IRQF_VALID); + } + set_irq_type(p_irq, IRQF_TRIGGER_LOW); + set_irq_chained_handler(p_irq, mxc_expio_irq_handler); + + return 0; +} diff --git a/arch/arm/plat-mxc/include/mach/cpld_debugboard.h b/arch/arm/plat-mxc/include/mach/cpld_debugboard.h new file mode 100644 index 0000000..a1422d2 --- /dev/null +++ b/arch/arm/plat-mxc/include/mach/cpld_debugboard.h @@ -0,0 +1,60 @@ +/* + * Copyright 2008-2009 Freescale Semiconductor, Inc. All Rights Reserved. + * + * + * The code contained herein is licensed under the GNU General Public + * License. You may obtain a copy of the GNU General Public License + * Version 2 or later@the following locations: + * + * http://www.opensource.org/licenses/gpl-license.html + * http://www.gnu.org/copyleft/gpl.html + */ + +#ifndef __ASM_ARCH_MXC_CPLD_DB_H__ +#define __ASM_ARCH_MXC_CPLD_DB_H__ + +/* LAN9217 ethernet base address */ +#define LAN9217_BASE_ADDR(n) (n + 0x0) +/* External UART */ +#define UARTA_BASE_ADDR(n) (n + 0x8000) +#define UARTB_BASE_ADDR(n) (n + 0x10000) + +#define BOARD_IO_ADDR(n) (n + 0x20000) +/* LED switchs */ +#define LED_SWITCH_REG 0x00 +/* buttons */ +#define SWITCH_BUTTONS_REG 0x08 +/* status, interrupt */ +#define INTR_STATUS_REG 0x10 +#define INTR_MASK_REG 0x38 +#define INTR_RESET_REG 0x20 +/* magic word for debug CPLD */ +#define MAGIC_NUMBER1_REG 0x40 +#define MAGIC_NUMBER2_REG 0x48 +/* CPLD code version */ +#define CPLD_CODE_VER_REG 0x50 +/* magic word for debug CPLD */ +#define MAGIC_NUMBER3_REG 0x58 +/* module reset register*/ +#define MODULE_RESET_REG 0x60 +/* CPU ID and Personality ID */ +#define MCU_BOARD_ID_REG 0x68 + +#define MXC_IRQ_TO_EXPIO(irq) ((irq) - MXC_BOARD_IRQ_START) +#define MXC_IRQ_TO_GPIO(irq) ((irq) - MXC_INTERNAL_IRQS) + +#define MXC_EXP_IO_BASE (MXC_BOARD_IRQ_START) +#define MXC_MAX_EXP_IO_LINES 16 + +/* interrupts like external uart , external ethernet etc*/ +#define EXPIO_INT_ENET (MXC_BOARD_IRQ_START + 0) +#define EXPIO_INT_XUART_A (MXC_BOARD_IRQ_START + 1) +#define EXPIO_INT_XUART_B (MXC_BOARD_IRQ_START + 2) +#define EXPIO_INT_BUTTON_A (MXC_BOARD_IRQ_START + 3) +#define EXPIO_INT_BUTTON_B (MXC_BOARD_IRQ_START + 4) + +extern struct platform_device smsc_lan9217_device; + +int __init mxc_expio_init(u32 base, u32 p_irq); + +#endif /* __ASM_ARCH_MXC_CPLD_DB_H__ */ -- 1.5.6.5 ^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 2/2] mx31_3ds: revert cpld debug board relate code 2010-06-12 14:25 ` [PATCH 1/2] mxc: add common debug board for 3-stack platforms Jason Wang @ 2010-06-12 14:25 ` Jason Wang 2010-06-16 6:57 ` Sascha Hauer 2010-06-16 6:55 ` [PATCH 1/2] mxc: add common debug board for 3-stack platforms Sascha Hauer 1 sibling, 1 reply; 10+ messages in thread From: Jason Wang @ 2010-06-12 14:25 UTC (permalink / raw) To: linux-arm-kernel Because we add a cpld debug board support in mxc level, we remove those redudent codes from board level. Signed-off-by: Jason Wang <jason77.wang@gmail.com> --- arch/arm/mach-mx3/Kconfig | 1 + arch/arm/mach-mx3/mach-mx31_3ds.c | 168 +---------------------- arch/arm/plat-mxc/include/mach/board-mx31_3ds.h | 42 ------ 3 files changed, 4 insertions(+), 207 deletions(-) diff --git a/arch/arm/mach-mx3/Kconfig b/arch/arm/mach-mx3/Kconfig index 344753f..fd422cf 100644 --- a/arch/arm/mach-mx3/Kconfig +++ b/arch/arm/mach-mx3/Kconfig @@ -58,6 +58,7 @@ config MACH_MX31LITE config MACH_MX31_3DS bool "Support MX31PDK (3DS)" select ARCH_MX31 + select MXC_DEBUG_BOARD help Include support for MX31PDK (3DS) platform. This includes specific configurations for the board and its peripherals. diff --git a/arch/arm/mach-mx3/mach-mx31_3ds.c b/arch/arm/mach-mx3/mach-mx31_3ds.c index 58e5729..d8af726 100644 --- a/arch/arm/mach-mx3/mach-mx31_3ds.c +++ b/arch/arm/mach-mx3/mach-mx31_3ds.c @@ -22,7 +22,6 @@ #include <linux/clk.h> #include <linux/irq.h> #include <linux/gpio.h> -#include <linux/smsc911x.h> #include <linux/platform_device.h> #include <linux/mfd/mc13783.h> #include <linux/spi/spi.h> @@ -38,6 +37,7 @@ #include <asm/mach/map.h> #include <mach/common.h> #include <mach/board-mx31_3ds.h> +#include <mach/cpld_debugboard.h> #include <mach/imx-uart.h> #include <mach/iomux-mx3.h> #include <mach/mxc_nand.h> @@ -213,173 +213,11 @@ static struct imxuart_platform_data uart_pdata = { }; /* - * Support for the SMSC9217 on the Debug board. - */ - -static struct smsc911x_platform_config smsc911x_config = { - .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW, - .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL, - .flags = SMSC911X_USE_16BIT | SMSC911X_FORCE_INTERNAL_PHY, - .phy_interface = PHY_INTERFACE_MODE_MII, -}; - -static struct resource smsc911x_resources[] = { - { - .start = LAN9217_BASE_ADDR, - .end = LAN9217_BASE_ADDR + 0xff, - .flags = IORESOURCE_MEM, - }, { - .start = EXPIO_INT_ENET, - .end = EXPIO_INT_ENET, - .flags = IORESOURCE_IRQ, - }, -}; - -static struct platform_device smsc911x_device = { - .name = "smsc911x", - .id = -1, - .num_resources = ARRAY_SIZE(smsc911x_resources), - .resource = smsc911x_resources, - .dev = { - .platform_data = &smsc911x_config, - }, -}; - -/* - * Routines for the CPLD on the debug board. It contains a CPLD handling - * LEDs, switches, interrupts for Ethernet. - */ - -static void mx31_3ds_expio_irq_handler(uint32_t irq, struct irq_desc *desc) -{ - uint32_t imr_val; - uint32_t int_valid; - uint32_t expio_irq; - - imr_val = __raw_readw(CPLD_INT_MASK_REG); - int_valid = __raw_readw(CPLD_INT_STATUS_REG) & ~imr_val; - - expio_irq = MXC_EXP_IO_BASE; - for (; int_valid != 0; int_valid >>= 1, expio_irq++) { - if ((int_valid & 1) == 0) - continue; - generic_handle_irq(expio_irq); - } -} - -/* - * Disable an expio pin's interrupt by setting the bit in the imr. - * @param irq an expio virtual irq number - */ -static void expio_mask_irq(uint32_t irq) -{ - uint16_t reg; - uint32_t expio = MXC_IRQ_TO_EXPIO(irq); - - /* mask the interrupt */ - reg = __raw_readw(CPLD_INT_MASK_REG); - reg |= 1 << expio; - __raw_writew(reg, CPLD_INT_MASK_REG); -} - -/* - * Acknowledge an expanded io pin's interrupt by clearing the bit in the isr. - * @param irq an expanded io virtual irq number - */ -static void expio_ack_irq(uint32_t irq) -{ - uint32_t expio = MXC_IRQ_TO_EXPIO(irq); - - /* clear the interrupt status */ - __raw_writew(1 << expio, CPLD_INT_RESET_REG); - __raw_writew(0, CPLD_INT_RESET_REG); - /* mask the interrupt */ - expio_mask_irq(irq); -} - -/* - * Enable a expio pin's interrupt by clearing the bit in the imr. - * @param irq a expio virtual irq number - */ -static void expio_unmask_irq(uint32_t irq) -{ - uint16_t reg; - uint32_t expio = MXC_IRQ_TO_EXPIO(irq); - - /* unmask the interrupt */ - reg = __raw_readw(CPLD_INT_MASK_REG); - reg &= ~(1 << expio); - __raw_writew(reg, CPLD_INT_MASK_REG); -} - -static struct irq_chip expio_irq_chip = { - .ack = expio_ack_irq, - .mask = expio_mask_irq, - .unmask = expio_unmask_irq, -}; - -static int __init mx31_3ds_init_expio(void) -{ - int i; - int ret; - - /* Check if there's a debug board connected */ - if ((__raw_readw(CPLD_MAGIC_NUMBER1_REG) != 0xAAAA) || - (__raw_readw(CPLD_MAGIC_NUMBER2_REG) != 0x5555) || - (__raw_readw(CPLD_MAGIC_NUMBER3_REG) != 0xCAFE)) { - /* No Debug board found */ - return -ENODEV; - } - - pr_info("i.MX31 3DS Debug board detected, rev = 0x%04X\n", - __raw_readw(CPLD_CODE_VER_REG)); - - /* - * Configure INT line as GPIO input - */ - ret = gpio_request(IOMUX_TO_GPIO(MX31_PIN_GPIO1_1), "sms9217-irq"); - if (ret) - pr_warning("could not get LAN irq gpio\n"); - else - gpio_direction_input(IOMUX_TO_GPIO(MX31_PIN_GPIO1_1)); - - /* Disable the interrupts and clear the status */ - __raw_writew(0, CPLD_INT_MASK_REG); - __raw_writew(0xFFFF, CPLD_INT_RESET_REG); - __raw_writew(0, CPLD_INT_RESET_REG); - __raw_writew(0x1F, CPLD_INT_MASK_REG); - for (i = MXC_EXP_IO_BASE; - i < (MXC_EXP_IO_BASE + MXC_MAX_EXP_IO_LINES); - i++) { - set_irq_chip(i, &expio_irq_chip); - set_irq_handler(i, handle_level_irq); - set_irq_flags(i, IRQF_VALID); - } - set_irq_type(EXPIO_PARENT_INT, IRQ_TYPE_LEVEL_LOW); - set_irq_chained_handler(EXPIO_PARENT_INT, mx31_3ds_expio_irq_handler); - - return 0; -} - -/* - * This structure defines the MX31 memory map. - */ -static struct map_desc mx31_3ds_io_desc[] __initdata = { - { - .virtual = MX31_CS5_BASE_ADDR_VIRT, - .pfn = __phys_to_pfn(MX31_CS5_BASE_ADDR), - .length = MX31_CS5_SIZE, - .type = MT_DEVICE, - }, -}; - -/* * Set up static virtual mappings. */ static void __init mx31_3ds_map_io(void) { mx31_map_io(); - iotable_init(mx31_3ds_io_desc, ARRAY_SIZE(mx31_3ds_io_desc)); } /*! @@ -402,8 +240,8 @@ static void __init mxc_board_init(void) mx31_3ds_usbotg_init(); mxc_register_device(&mxc_otg_udc_device, &usbotg_pdata); - if (!mx31_3ds_init_expio()) - platform_device_register(&smsc911x_device); + if (!mxc_expio_init(CS5_BASE_ADDR, EXPIO_PARENT_INT)) + platform_device_register(&smsc_lan9217_device); } static void __init mx31_3ds_timer_init(void) diff --git a/arch/arm/plat-mxc/include/mach/board-mx31_3ds.h b/arch/arm/plat-mxc/include/mach/board-mx31_3ds.h index da92933..c26d88d 100644 --- a/arch/arm/plat-mxc/include/mach/board-mx31_3ds.h +++ b/arch/arm/plat-mxc/include/mach/board-mx31_3ds.h @@ -12,48 +12,6 @@ #define __ASM_ARCH_MXC_BOARD_MX31_3DS_H__ /* Definitions for components on the Debug board */ - -/* Base address of CPLD controller on the Debug board */ -#define DEBUG_BASE_ADDRESS CS5_IO_ADDRESS(CS5_BASE_ADDR) - -/* LAN9217 ethernet base address */ -#define LAN9217_BASE_ADDR CS5_BASE_ADDR - -/* CPLD config and interrupt base address */ -#define CPLD_ADDR (DEBUG_BASE_ADDRESS + 0x20000) - -/* LED switchs */ -#define CPLD_LED_REG (CPLD_ADDR + 0x00) -/* buttons */ -#define CPLD_SWITCH_BUTTONS_REG (EXPIO_ADDR + 0x08) -/* status, interrupt */ -#define CPLD_INT_STATUS_REG (CPLD_ADDR + 0x10) -#define CPLD_INT_MASK_REG (CPLD_ADDR + 0x38) -#define CPLD_INT_RESET_REG (CPLD_ADDR + 0x20) -/* magic word for debug CPLD */ -#define CPLD_MAGIC_NUMBER1_REG (CPLD_ADDR + 0x40) -#define CPLD_MAGIC_NUMBER2_REG (CPLD_ADDR + 0x48) -/* CPLD code version */ -#define CPLD_CODE_VER_REG (CPLD_ADDR + 0x50) -/* magic word for debug CPLD */ -#define CPLD_MAGIC_NUMBER3_REG (CPLD_ADDR + 0x58) -/* module reset register */ -#define CPLD_MODULE_RESET_REG (CPLD_ADDR + 0x60) -/* CPU ID and Personality ID */ -#define CPLD_MCU_BOARD_ID_REG (CPLD_ADDR + 0x68) - -/* CPLD IRQ line for external uart, external ethernet etc */ #define EXPIO_PARENT_INT IOMUX_TO_IRQ(MX31_PIN_GPIO1_1) -#define MXC_EXP_IO_BASE (MXC_BOARD_IRQ_START) -#define MXC_IRQ_TO_EXPIO(irq) ((irq) - MXC_EXP_IO_BASE) - -#define EXPIO_INT_ENET (MXC_EXP_IO_BASE + 0) -#define EXPIO_INT_XUART_A (MXC_EXP_IO_BASE + 1) -#define EXPIO_INT_XUART_B (MXC_EXP_IO_BASE + 2) -#define EXPIO_INT_BUTTON_A (MXC_EXP_IO_BASE + 3) -#define EXPIO_INT_BUTTON_B (MXC_EXP_IO_BASE + 4) - -#define MXC_MAX_EXP_IO_LINES 16 - #endif /* __ASM_ARCH_MXC_BOARD_MX31_3DS_H__ */ -- 1.5.6.5 ^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 2/2] mx31_3ds: revert cpld debug board relate code 2010-06-12 14:25 ` [PATCH 2/2] mx31_3ds: revert cpld debug board relate code Jason Wang @ 2010-06-16 6:57 ` Sascha Hauer 2010-06-16 20:36 ` Magnus Lilja 0 siblings, 1 reply; 10+ messages in thread From: Sascha Hauer @ 2010-06-16 6:57 UTC (permalink / raw) To: linux-arm-kernel [Added Magnus to Cc] Magnus, As you are the original author of the removed code, can I have you Acked-by or Tested-by here? Sascha On Sat, Jun 12, 2010 at 10:25:07PM +0800, Jason Wang wrote: > Because we add a cpld debug board support in mxc level, we remove > those redudent codes from board level. > > Signed-off-by: Jason Wang <jason77.wang@gmail.com> > --- > arch/arm/mach-mx3/Kconfig | 1 + > arch/arm/mach-mx3/mach-mx31_3ds.c | 168 +---------------------- > arch/arm/plat-mxc/include/mach/board-mx31_3ds.h | 42 ------ > 3 files changed, 4 insertions(+), 207 deletions(-) > > diff --git a/arch/arm/mach-mx3/Kconfig b/arch/arm/mach-mx3/Kconfig > index 344753f..fd422cf 100644 > --- a/arch/arm/mach-mx3/Kconfig > +++ b/arch/arm/mach-mx3/Kconfig > @@ -58,6 +58,7 @@ config MACH_MX31LITE > config MACH_MX31_3DS > bool "Support MX31PDK (3DS)" > select ARCH_MX31 > + select MXC_DEBUG_BOARD > help > Include support for MX31PDK (3DS) platform. This includes specific > configurations for the board and its peripherals. > diff --git a/arch/arm/mach-mx3/mach-mx31_3ds.c b/arch/arm/mach-mx3/mach-mx31_3ds.c > index 58e5729..d8af726 100644 > --- a/arch/arm/mach-mx3/mach-mx31_3ds.c > +++ b/arch/arm/mach-mx3/mach-mx31_3ds.c > @@ -22,7 +22,6 @@ > #include <linux/clk.h> > #include <linux/irq.h> > #include <linux/gpio.h> > -#include <linux/smsc911x.h> > #include <linux/platform_device.h> > #include <linux/mfd/mc13783.h> > #include <linux/spi/spi.h> > @@ -38,6 +37,7 @@ > #include <asm/mach/map.h> > #include <mach/common.h> > #include <mach/board-mx31_3ds.h> > +#include <mach/cpld_debugboard.h> > #include <mach/imx-uart.h> > #include <mach/iomux-mx3.h> > #include <mach/mxc_nand.h> > @@ -213,173 +213,11 @@ static struct imxuart_platform_data uart_pdata = { > }; > > /* > - * Support for the SMSC9217 on the Debug board. > - */ > - > -static struct smsc911x_platform_config smsc911x_config = { > - .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW, > - .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL, > - .flags = SMSC911X_USE_16BIT | SMSC911X_FORCE_INTERNAL_PHY, > - .phy_interface = PHY_INTERFACE_MODE_MII, > -}; > - > -static struct resource smsc911x_resources[] = { > - { > - .start = LAN9217_BASE_ADDR, > - .end = LAN9217_BASE_ADDR + 0xff, > - .flags = IORESOURCE_MEM, > - }, { > - .start = EXPIO_INT_ENET, > - .end = EXPIO_INT_ENET, > - .flags = IORESOURCE_IRQ, > - }, > -}; > - > -static struct platform_device smsc911x_device = { > - .name = "smsc911x", > - .id = -1, > - .num_resources = ARRAY_SIZE(smsc911x_resources), > - .resource = smsc911x_resources, > - .dev = { > - .platform_data = &smsc911x_config, > - }, > -}; > - > -/* > - * Routines for the CPLD on the debug board. It contains a CPLD handling > - * LEDs, switches, interrupts for Ethernet. > - */ > - > -static void mx31_3ds_expio_irq_handler(uint32_t irq, struct irq_desc *desc) > -{ > - uint32_t imr_val; > - uint32_t int_valid; > - uint32_t expio_irq; > - > - imr_val = __raw_readw(CPLD_INT_MASK_REG); > - int_valid = __raw_readw(CPLD_INT_STATUS_REG) & ~imr_val; > - > - expio_irq = MXC_EXP_IO_BASE; > - for (; int_valid != 0; int_valid >>= 1, expio_irq++) { > - if ((int_valid & 1) == 0) > - continue; > - generic_handle_irq(expio_irq); > - } > -} > - > -/* > - * Disable an expio pin's interrupt by setting the bit in the imr. > - * @param irq an expio virtual irq number > - */ > -static void expio_mask_irq(uint32_t irq) > -{ > - uint16_t reg; > - uint32_t expio = MXC_IRQ_TO_EXPIO(irq); > - > - /* mask the interrupt */ > - reg = __raw_readw(CPLD_INT_MASK_REG); > - reg |= 1 << expio; > - __raw_writew(reg, CPLD_INT_MASK_REG); > -} > - > -/* > - * Acknowledge an expanded io pin's interrupt by clearing the bit in the isr. > - * @param irq an expanded io virtual irq number > - */ > -static void expio_ack_irq(uint32_t irq) > -{ > - uint32_t expio = MXC_IRQ_TO_EXPIO(irq); > - > - /* clear the interrupt status */ > - __raw_writew(1 << expio, CPLD_INT_RESET_REG); > - __raw_writew(0, CPLD_INT_RESET_REG); > - /* mask the interrupt */ > - expio_mask_irq(irq); > -} > - > -/* > - * Enable a expio pin's interrupt by clearing the bit in the imr. > - * @param irq a expio virtual irq number > - */ > -static void expio_unmask_irq(uint32_t irq) > -{ > - uint16_t reg; > - uint32_t expio = MXC_IRQ_TO_EXPIO(irq); > - > - /* unmask the interrupt */ > - reg = __raw_readw(CPLD_INT_MASK_REG); > - reg &= ~(1 << expio); > - __raw_writew(reg, CPLD_INT_MASK_REG); > -} > - > -static struct irq_chip expio_irq_chip = { > - .ack = expio_ack_irq, > - .mask = expio_mask_irq, > - .unmask = expio_unmask_irq, > -}; > - > -static int __init mx31_3ds_init_expio(void) > -{ > - int i; > - int ret; > - > - /* Check if there's a debug board connected */ > - if ((__raw_readw(CPLD_MAGIC_NUMBER1_REG) != 0xAAAA) || > - (__raw_readw(CPLD_MAGIC_NUMBER2_REG) != 0x5555) || > - (__raw_readw(CPLD_MAGIC_NUMBER3_REG) != 0xCAFE)) { > - /* No Debug board found */ > - return -ENODEV; > - } > - > - pr_info("i.MX31 3DS Debug board detected, rev = 0x%04X\n", > - __raw_readw(CPLD_CODE_VER_REG)); > - > - /* > - * Configure INT line as GPIO input > - */ > - ret = gpio_request(IOMUX_TO_GPIO(MX31_PIN_GPIO1_1), "sms9217-irq"); > - if (ret) > - pr_warning("could not get LAN irq gpio\n"); > - else > - gpio_direction_input(IOMUX_TO_GPIO(MX31_PIN_GPIO1_1)); > - > - /* Disable the interrupts and clear the status */ > - __raw_writew(0, CPLD_INT_MASK_REG); > - __raw_writew(0xFFFF, CPLD_INT_RESET_REG); > - __raw_writew(0, CPLD_INT_RESET_REG); > - __raw_writew(0x1F, CPLD_INT_MASK_REG); > - for (i = MXC_EXP_IO_BASE; > - i < (MXC_EXP_IO_BASE + MXC_MAX_EXP_IO_LINES); > - i++) { > - set_irq_chip(i, &expio_irq_chip); > - set_irq_handler(i, handle_level_irq); > - set_irq_flags(i, IRQF_VALID); > - } > - set_irq_type(EXPIO_PARENT_INT, IRQ_TYPE_LEVEL_LOW); > - set_irq_chained_handler(EXPIO_PARENT_INT, mx31_3ds_expio_irq_handler); > - > - return 0; > -} > - > -/* > - * This structure defines the MX31 memory map. > - */ > -static struct map_desc mx31_3ds_io_desc[] __initdata = { > - { > - .virtual = MX31_CS5_BASE_ADDR_VIRT, > - .pfn = __phys_to_pfn(MX31_CS5_BASE_ADDR), > - .length = MX31_CS5_SIZE, > - .type = MT_DEVICE, > - }, > -}; > - > -/* > * Set up static virtual mappings. > */ > static void __init mx31_3ds_map_io(void) > { > mx31_map_io(); > - iotable_init(mx31_3ds_io_desc, ARRAY_SIZE(mx31_3ds_io_desc)); > } > > /*! > @@ -402,8 +240,8 @@ static void __init mxc_board_init(void) > mx31_3ds_usbotg_init(); > mxc_register_device(&mxc_otg_udc_device, &usbotg_pdata); > > - if (!mx31_3ds_init_expio()) > - platform_device_register(&smsc911x_device); > + if (!mxc_expio_init(CS5_BASE_ADDR, EXPIO_PARENT_INT)) > + platform_device_register(&smsc_lan9217_device); > } > > static void __init mx31_3ds_timer_init(void) > diff --git a/arch/arm/plat-mxc/include/mach/board-mx31_3ds.h b/arch/arm/plat-mxc/include/mach/board-mx31_3ds.h > index da92933..c26d88d 100644 > --- a/arch/arm/plat-mxc/include/mach/board-mx31_3ds.h > +++ b/arch/arm/plat-mxc/include/mach/board-mx31_3ds.h > @@ -12,48 +12,6 @@ > #define __ASM_ARCH_MXC_BOARD_MX31_3DS_H__ > > /* Definitions for components on the Debug board */ > - > -/* Base address of CPLD controller on the Debug board */ > -#define DEBUG_BASE_ADDRESS CS5_IO_ADDRESS(CS5_BASE_ADDR) > - > -/* LAN9217 ethernet base address */ > -#define LAN9217_BASE_ADDR CS5_BASE_ADDR > - > -/* CPLD config and interrupt base address */ > -#define CPLD_ADDR (DEBUG_BASE_ADDRESS + 0x20000) > - > -/* LED switchs */ > -#define CPLD_LED_REG (CPLD_ADDR + 0x00) > -/* buttons */ > -#define CPLD_SWITCH_BUTTONS_REG (EXPIO_ADDR + 0x08) > -/* status, interrupt */ > -#define CPLD_INT_STATUS_REG (CPLD_ADDR + 0x10) > -#define CPLD_INT_MASK_REG (CPLD_ADDR + 0x38) > -#define CPLD_INT_RESET_REG (CPLD_ADDR + 0x20) > -/* magic word for debug CPLD */ > -#define CPLD_MAGIC_NUMBER1_REG (CPLD_ADDR + 0x40) > -#define CPLD_MAGIC_NUMBER2_REG (CPLD_ADDR + 0x48) > -/* CPLD code version */ > -#define CPLD_CODE_VER_REG (CPLD_ADDR + 0x50) > -/* magic word for debug CPLD */ > -#define CPLD_MAGIC_NUMBER3_REG (CPLD_ADDR + 0x58) > -/* module reset register */ > -#define CPLD_MODULE_RESET_REG (CPLD_ADDR + 0x60) > -/* CPU ID and Personality ID */ > -#define CPLD_MCU_BOARD_ID_REG (CPLD_ADDR + 0x68) > - > -/* CPLD IRQ line for external uart, external ethernet etc */ > #define EXPIO_PARENT_INT IOMUX_TO_IRQ(MX31_PIN_GPIO1_1) > > -#define MXC_EXP_IO_BASE (MXC_BOARD_IRQ_START) > -#define MXC_IRQ_TO_EXPIO(irq) ((irq) - MXC_EXP_IO_BASE) > - > -#define EXPIO_INT_ENET (MXC_EXP_IO_BASE + 0) > -#define EXPIO_INT_XUART_A (MXC_EXP_IO_BASE + 1) > -#define EXPIO_INT_XUART_B (MXC_EXP_IO_BASE + 2) > -#define EXPIO_INT_BUTTON_A (MXC_EXP_IO_BASE + 3) > -#define EXPIO_INT_BUTTON_B (MXC_EXP_IO_BASE + 4) > - > -#define MXC_MAX_EXP_IO_LINES 16 > - > #endif /* __ASM_ARCH_MXC_BOARD_MX31_3DS_H__ */ > -- > 1.5.6.5 > > -- Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | ^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 2/2] mx31_3ds: revert cpld debug board relate code 2010-06-16 6:57 ` Sascha Hauer @ 2010-06-16 20:36 ` Magnus Lilja 0 siblings, 0 replies; 10+ messages in thread From: Magnus Lilja @ 2010-06-16 20:36 UTC (permalink / raw) To: linux-arm-kernel Sascha, On 2010-06-16 08:57, Sascha Hauer wrote: > > [Added Magnus to Cc] > > Magnus, > > As you are the original author of the removed code, can I have you > Acked-by or Tested-by here? Yes, I added the debugboard support. I've looked at the patches and the restructure looks ok. The only thing that really differs is the interrupt function but I don't know which variant is more correct. I haven't had a chance to test the patches yet, perhaps in a couple of days. Acked-by: Magnus Lilja <lilja.magnus@gmail.com> /Magnus > > Sascha > > On Sat, Jun 12, 2010 at 10:25:07PM +0800, Jason Wang wrote: >> Because we add a cpld debug board support in mxc level, we remove >> those redudent codes from board level. >> >> Signed-off-by: Jason Wang <jason77.wang@gmail.com> >> --- >> arch/arm/mach-mx3/Kconfig | 1 + >> arch/arm/mach-mx3/mach-mx31_3ds.c | 168 +---------------------- >> arch/arm/plat-mxc/include/mach/board-mx31_3ds.h | 42 ------ >> 3 files changed, 4 insertions(+), 207 deletions(-) >> >> diff --git a/arch/arm/mach-mx3/Kconfig b/arch/arm/mach-mx3/Kconfig >> index 344753f..fd422cf 100644 >> --- a/arch/arm/mach-mx3/Kconfig >> +++ b/arch/arm/mach-mx3/Kconfig >> @@ -58,6 +58,7 @@ config MACH_MX31LITE >> config MACH_MX31_3DS >> bool "Support MX31PDK (3DS)" >> select ARCH_MX31 >> + select MXC_DEBUG_BOARD >> help >> Include support for MX31PDK (3DS) platform. This includes specific >> configurations for the board and its peripherals. >> diff --git a/arch/arm/mach-mx3/mach-mx31_3ds.c b/arch/arm/mach-mx3/mach-mx31_3ds.c >> index 58e5729..d8af726 100644 >> --- a/arch/arm/mach-mx3/mach-mx31_3ds.c >> +++ b/arch/arm/mach-mx3/mach-mx31_3ds.c >> @@ -22,7 +22,6 @@ >> #include <linux/clk.h> >> #include <linux/irq.h> >> #include <linux/gpio.h> >> -#include <linux/smsc911x.h> >> #include <linux/platform_device.h> >> #include <linux/mfd/mc13783.h> >> #include <linux/spi/spi.h> >> @@ -38,6 +37,7 @@ >> #include <asm/mach/map.h> >> #include <mach/common.h> >> #include <mach/board-mx31_3ds.h> >> +#include <mach/cpld_debugboard.h> >> #include <mach/imx-uart.h> >> #include <mach/iomux-mx3.h> >> #include <mach/mxc_nand.h> >> @@ -213,173 +213,11 @@ static struct imxuart_platform_data uart_pdata = { >> }; >> >> /* >> - * Support for the SMSC9217 on the Debug board. >> - */ >> - >> -static struct smsc911x_platform_config smsc911x_config = { >> - .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW, >> - .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL, >> - .flags = SMSC911X_USE_16BIT | SMSC911X_FORCE_INTERNAL_PHY, >> - .phy_interface = PHY_INTERFACE_MODE_MII, >> -}; >> - >> -static struct resource smsc911x_resources[] = { >> - { >> - .start = LAN9217_BASE_ADDR, >> - .end = LAN9217_BASE_ADDR + 0xff, >> - .flags = IORESOURCE_MEM, >> - }, { >> - .start = EXPIO_INT_ENET, >> - .end = EXPIO_INT_ENET, >> - .flags = IORESOURCE_IRQ, >> - }, >> -}; >> - >> -static struct platform_device smsc911x_device = { >> - .name = "smsc911x", >> - .id = -1, >> - .num_resources = ARRAY_SIZE(smsc911x_resources), >> - .resource = smsc911x_resources, >> - .dev = { >> - .platform_data = &smsc911x_config, >> - }, >> -}; >> - >> -/* >> - * Routines for the CPLD on the debug board. It contains a CPLD handling >> - * LEDs, switches, interrupts for Ethernet. >> - */ >> - >> -static void mx31_3ds_expio_irq_handler(uint32_t irq, struct irq_desc *desc) >> -{ >> - uint32_t imr_val; >> - uint32_t int_valid; >> - uint32_t expio_irq; >> - >> - imr_val = __raw_readw(CPLD_INT_MASK_REG); >> - int_valid = __raw_readw(CPLD_INT_STATUS_REG) & ~imr_val; >> - >> - expio_irq = MXC_EXP_IO_BASE; >> - for (; int_valid != 0; int_valid >>= 1, expio_irq++) { >> - if ((int_valid & 1) == 0) >> - continue; >> - generic_handle_irq(expio_irq); >> - } >> -} >> - >> -/* >> - * Disable an expio pin's interrupt by setting the bit in the imr. >> - * @param irq an expio virtual irq number >> - */ >> -static void expio_mask_irq(uint32_t irq) >> -{ >> - uint16_t reg; >> - uint32_t expio = MXC_IRQ_TO_EXPIO(irq); >> - >> - /* mask the interrupt */ >> - reg = __raw_readw(CPLD_INT_MASK_REG); >> - reg |= 1 << expio; >> - __raw_writew(reg, CPLD_INT_MASK_REG); >> -} >> - >> -/* >> - * Acknowledge an expanded io pin's interrupt by clearing the bit in the isr. >> - * @param irq an expanded io virtual irq number >> - */ >> -static void expio_ack_irq(uint32_t irq) >> -{ >> - uint32_t expio = MXC_IRQ_TO_EXPIO(irq); >> - >> - /* clear the interrupt status */ >> - __raw_writew(1 << expio, CPLD_INT_RESET_REG); >> - __raw_writew(0, CPLD_INT_RESET_REG); >> - /* mask the interrupt */ >> - expio_mask_irq(irq); >> -} >> - >> -/* >> - * Enable a expio pin's interrupt by clearing the bit in the imr. >> - * @param irq a expio virtual irq number >> - */ >> -static void expio_unmask_irq(uint32_t irq) >> -{ >> - uint16_t reg; >> - uint32_t expio = MXC_IRQ_TO_EXPIO(irq); >> - >> - /* unmask the interrupt */ >> - reg = __raw_readw(CPLD_INT_MASK_REG); >> - reg &= ~(1 << expio); >> - __raw_writew(reg, CPLD_INT_MASK_REG); >> -} >> - >> -static struct irq_chip expio_irq_chip = { >> - .ack = expio_ack_irq, >> - .mask = expio_mask_irq, >> - .unmask = expio_unmask_irq, >> -}; >> - >> -static int __init mx31_3ds_init_expio(void) >> -{ >> - int i; >> - int ret; >> - >> - /* Check if there's a debug board connected */ >> - if ((__raw_readw(CPLD_MAGIC_NUMBER1_REG) != 0xAAAA) || >> - (__raw_readw(CPLD_MAGIC_NUMBER2_REG) != 0x5555) || >> - (__raw_readw(CPLD_MAGIC_NUMBER3_REG) != 0xCAFE)) { >> - /* No Debug board found */ >> - return -ENODEV; >> - } >> - >> - pr_info("i.MX31 3DS Debug board detected, rev = 0x%04X\n", >> - __raw_readw(CPLD_CODE_VER_REG)); >> - >> - /* >> - * Configure INT line as GPIO input >> - */ >> - ret = gpio_request(IOMUX_TO_GPIO(MX31_PIN_GPIO1_1), "sms9217-irq"); >> - if (ret) >> - pr_warning("could not get LAN irq gpio\n"); >> - else >> - gpio_direction_input(IOMUX_TO_GPIO(MX31_PIN_GPIO1_1)); >> - >> - /* Disable the interrupts and clear the status */ >> - __raw_writew(0, CPLD_INT_MASK_REG); >> - __raw_writew(0xFFFF, CPLD_INT_RESET_REG); >> - __raw_writew(0, CPLD_INT_RESET_REG); >> - __raw_writew(0x1F, CPLD_INT_MASK_REG); >> - for (i = MXC_EXP_IO_BASE; >> - i < (MXC_EXP_IO_BASE + MXC_MAX_EXP_IO_LINES); >> - i++) { >> - set_irq_chip(i, &expio_irq_chip); >> - set_irq_handler(i, handle_level_irq); >> - set_irq_flags(i, IRQF_VALID); >> - } >> - set_irq_type(EXPIO_PARENT_INT, IRQ_TYPE_LEVEL_LOW); >> - set_irq_chained_handler(EXPIO_PARENT_INT, mx31_3ds_expio_irq_handler); >> - >> - return 0; >> -} >> - >> -/* >> - * This structure defines the MX31 memory map. >> - */ >> -static struct map_desc mx31_3ds_io_desc[] __initdata = { >> - { >> - .virtual = MX31_CS5_BASE_ADDR_VIRT, >> - .pfn = __phys_to_pfn(MX31_CS5_BASE_ADDR), >> - .length = MX31_CS5_SIZE, >> - .type = MT_DEVICE, >> - }, >> -}; >> - >> -/* >> * Set up static virtual mappings. >> */ >> static void __init mx31_3ds_map_io(void) >> { >> mx31_map_io(); >> - iotable_init(mx31_3ds_io_desc, ARRAY_SIZE(mx31_3ds_io_desc)); >> } >> >> /*! >> @@ -402,8 +240,8 @@ static void __init mxc_board_init(void) >> mx31_3ds_usbotg_init(); >> mxc_register_device(&mxc_otg_udc_device, &usbotg_pdata); >> >> - if (!mx31_3ds_init_expio()) >> - platform_device_register(&smsc911x_device); >> + if (!mxc_expio_init(CS5_BASE_ADDR, EXPIO_PARENT_INT)) >> + platform_device_register(&smsc_lan9217_device); >> } >> >> static void __init mx31_3ds_timer_init(void) >> diff --git a/arch/arm/plat-mxc/include/mach/board-mx31_3ds.h b/arch/arm/plat-mxc/include/mach/board-mx31_3ds.h >> index da92933..c26d88d 100644 >> --- a/arch/arm/plat-mxc/include/mach/board-mx31_3ds.h >> +++ b/arch/arm/plat-mxc/include/mach/board-mx31_3ds.h >> @@ -12,48 +12,6 @@ >> #define __ASM_ARCH_MXC_BOARD_MX31_3DS_H__ >> >> /* Definitions for components on the Debug board */ >> - >> -/* Base address of CPLD controller on the Debug board */ >> -#define DEBUG_BASE_ADDRESS CS5_IO_ADDRESS(CS5_BASE_ADDR) >> - >> -/* LAN9217 ethernet base address */ >> -#define LAN9217_BASE_ADDR CS5_BASE_ADDR >> - >> -/* CPLD config and interrupt base address */ >> -#define CPLD_ADDR (DEBUG_BASE_ADDRESS + 0x20000) >> - >> -/* LED switchs */ >> -#define CPLD_LED_REG (CPLD_ADDR + 0x00) >> -/* buttons */ >> -#define CPLD_SWITCH_BUTTONS_REG (EXPIO_ADDR + 0x08) >> -/* status, interrupt */ >> -#define CPLD_INT_STATUS_REG (CPLD_ADDR + 0x10) >> -#define CPLD_INT_MASK_REG (CPLD_ADDR + 0x38) >> -#define CPLD_INT_RESET_REG (CPLD_ADDR + 0x20) >> -/* magic word for debug CPLD */ >> -#define CPLD_MAGIC_NUMBER1_REG (CPLD_ADDR + 0x40) >> -#define CPLD_MAGIC_NUMBER2_REG (CPLD_ADDR + 0x48) >> -/* CPLD code version */ >> -#define CPLD_CODE_VER_REG (CPLD_ADDR + 0x50) >> -/* magic word for debug CPLD */ >> -#define CPLD_MAGIC_NUMBER3_REG (CPLD_ADDR + 0x58) >> -/* module reset register */ >> -#define CPLD_MODULE_RESET_REG (CPLD_ADDR + 0x60) >> -/* CPU ID and Personality ID */ >> -#define CPLD_MCU_BOARD_ID_REG (CPLD_ADDR + 0x68) >> - >> -/* CPLD IRQ line for external uart, external ethernet etc */ >> #define EXPIO_PARENT_INT IOMUX_TO_IRQ(MX31_PIN_GPIO1_1) >> >> -#define MXC_EXP_IO_BASE (MXC_BOARD_IRQ_START) >> -#define MXC_IRQ_TO_EXPIO(irq) ((irq) - MXC_EXP_IO_BASE) >> - >> -#define EXPIO_INT_ENET (MXC_EXP_IO_BASE + 0) >> -#define EXPIO_INT_XUART_A (MXC_EXP_IO_BASE + 1) >> -#define EXPIO_INT_XUART_B (MXC_EXP_IO_BASE + 2) >> -#define EXPIO_INT_BUTTON_A (MXC_EXP_IO_BASE + 3) >> -#define EXPIO_INT_BUTTON_B (MXC_EXP_IO_BASE + 4) >> - >> -#define MXC_MAX_EXP_IO_LINES 16 >> - >> #endif /* __ASM_ARCH_MXC_BOARD_MX31_3DS_H__ */ >> -- >> 1.5.6.5 >> >> > ^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 1/2] mxc: add common debug board for 3-stack platforms 2010-06-12 14:25 ` [PATCH 1/2] mxc: add common debug board for 3-stack platforms Jason Wang 2010-06-12 14:25 ` [PATCH 2/2] mx31_3ds: revert cpld debug board relate code Jason Wang @ 2010-06-16 6:55 ` Sascha Hauer 2010-06-17 13:37 ` jason 2010-06-18 14:06 ` jason 1 sibling, 2 replies; 10+ messages in thread From: Sascha Hauer @ 2010-06-16 6:55 UTC (permalink / raw) To: linux-arm-kernel On Sat, Jun 12, 2010 at 10:25:06PM +0800, Jason Wang wrote: > The debug board is little different for all mxc 3-stack(PDK) > platforms, it is possible here to add a common implementation to > support this board. Two small things left: Could you change the name cpld_debugboard.c to something like 3ds_debugboard.c? That we are talking about the 3ds is much more interesting than that there's a cpld on the board. Also, I really prefer having no extra header file for the debug board. All information in this header file is only interesting in this single C file. Sascha > > Signed-off-by: Jason Wang <jason77.wang@gmail.com> > --- > arch/arm/plat-mxc/Kconfig | 11 ++ > arch/arm/plat-mxc/Makefile | 1 + > arch/arm/plat-mxc/cpld_debugboard.c | 161 ++++++++++++++++++++++ > arch/arm/plat-mxc/include/mach/cpld_debugboard.h | 60 ++++++++ > 4 files changed, 233 insertions(+), 0 deletions(-) > create mode 100644 arch/arm/plat-mxc/cpld_debugboard.c > create mode 100644 arch/arm/plat-mxc/include/mach/cpld_debugboard.h > > diff --git a/arch/arm/plat-mxc/Kconfig b/arch/arm/plat-mxc/Kconfig > index 7f7ad6f..8bf917e 100644 > --- a/arch/arm/plat-mxc/Kconfig > +++ b/arch/arm/plat-mxc/Kconfig > @@ -81,6 +81,17 @@ config MXC_PWM > help > Enable support for the i.MX PWM controller(s). > > +config MXC_DEBUG_BOARD > + bool "Enable MXC debug board(for 3-stack)" > + help > + The debug board is an integral part of the MXC 3-stack(PDK) > + platforms, it can be attached or removed from the peripheral > + board. On debug board, several debug devices(ethernet, UART, > + buttons, LEDs and JTAG) are implemented. Between the MCU and > + these devices, a CPLD is added as a bridge which performs > + data/address de-multiplexing and decode, signal level shift, > + interrupt control and various board functions. > + > config MXC_ULPI > bool > > diff --git a/arch/arm/plat-mxc/Makefile b/arch/arm/plat-mxc/Makefile > index 895bc3c..b9e8c6f 100644 > --- a/arch/arm/plat-mxc/Makefile > +++ b/arch/arm/plat-mxc/Makefile > @@ -17,6 +17,7 @@ obj-$(CONFIG_USB_EHCI_MXC) += ehci.o > obj-$(CONFIG_MXC_ULPI) += ulpi.o > obj-$(CONFIG_ARCH_MXC_AUDMUX_V1) += audmux-v1.o > obj-$(CONFIG_ARCH_MXC_AUDMUX_V2) += audmux-v2.o > +obj-$(CONFIG_MXC_DEBUG_BOARD) += cpld_debugboard.o > ifdef CONFIG_SND_IMX_SOC > obj-y += ssi-fiq.o > obj-y += ssi-fiq-ksym.o > diff --git a/arch/arm/plat-mxc/cpld_debugboard.c b/arch/arm/plat-mxc/cpld_debugboard.c > new file mode 100644 > index 0000000..0554fa0 > --- /dev/null > +++ b/arch/arm/plat-mxc/cpld_debugboard.c > @@ -0,0 +1,161 @@ > +/* > + * Copyright 2008-2009 Freescale Semiconductor, Inc. All Rights Reserved. > + * Copyright (C) 2010 Jason Wang <jason77.wang@gmail.com> > + * > + * The code contained herein is licensed under the GNU General Public > + * License. You may obtain a copy of the GNU General Public License > + * Version 2 or later at the following locations: > + * > + * http://www.opensource.org/licenses/gpl-license.html > + * http://www.gnu.org/copyleft/gpl.html > + */ > + > +#include <linux/interrupt.h> > +#include <linux/irq.h> > +#include <linux/io.h> > +#include <linux/platform_device.h> > +#include <linux/gpio.h> > +#include <linux/smsc911x.h> > + > +#include <mach/hardware.h> > +#include <mach/cpld_debugboard.h> > + > +static void __iomem *brd_io; > +static void expio_ack_irq(u32 irq); > + > +static struct resource smsc911x_resources[] = { > + { > + .flags = IORESOURCE_MEM, > + } , { > + .start = EXPIO_INT_ENET, > + .end = EXPIO_INT_ENET, > + .flags = IORESOURCE_IRQ, > + }, > +}; > + > +struct smsc911x_platform_config smsc911x_config = { > + .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW, > + .flags = SMSC911X_USE_32BIT | SMSC911X_FORCE_INTERNAL_PHY, > +}; > + > +struct platform_device smsc_lan9217_device = { > + .name = "smsc911x", > + .id = 0, > + .dev = { > + .platform_data = &smsc911x_config, > + }, > + .num_resources = ARRAY_SIZE(smsc911x_resources), > + .resource = smsc911x_resources, > +}; > + > +static void mxc_expio_irq_handler(u32 irq, struct irq_desc *desc) > +{ > + u32 imr_val; > + u32 int_valid; > + u32 expio_irq; > + > + desc->chip->mask(irq); /* irq = gpio irq number */ > + > + imr_val = __raw_readw(brd_io + INTR_MASK_REG); > + int_valid = __raw_readw(brd_io + INTR_STATUS_REG) & ~imr_val; > + > + expio_irq = MXC_BOARD_IRQ_START; > + for (; int_valid != 0; int_valid >>= 1, expio_irq++) { > + struct irq_desc *d; > + if ((int_valid & 1) == 0) > + continue; > + d = irq_desc + expio_irq; > + if (unlikely(!(d->handle_irq))) > + pr_err("\nEXPIO irq: %d unhandled\n", expio_irq); > + else > + d->handle_irq(expio_irq, d); > + } > + > + desc->chip->ack(irq); > + desc->chip->unmask(irq); > +} > + > +/* > + * Disable an expio pin's interrupt by setting the bit in the imr. > + * Irq is an expio virtual irq number > + */ > +static void expio_mask_irq(u32 irq) > +{ > + u16 reg; > + u32 expio = MXC_IRQ_TO_EXPIO(irq); > + > + reg = __raw_readw(brd_io + INTR_MASK_REG); > + reg |= (1 << expio); > + __raw_writew(reg, brd_io + INTR_MASK_REG); > +} > + > +static void expio_ack_irq(u32 irq) > +{ > + u32 expio = MXC_IRQ_TO_EXPIO(irq); > + > + __raw_writew(1 << expio, brd_io + INTR_RESET_REG); > + __raw_writew(0, brd_io + INTR_RESET_REG); > + expio_mask_irq(irq); > +} > + > +static void expio_unmask_irq(u32 irq) > +{ > + u16 reg; > + u32 expio = MXC_IRQ_TO_EXPIO(irq); > + > + reg = __raw_readw(brd_io + INTR_MASK_REG); > + reg &= ~(1 << expio); > + __raw_writew(reg, brd_io + INTR_MASK_REG); > +} > + > +static struct irq_chip expio_irq_chip = { > + .ack = expio_ack_irq, > + .mask = expio_mask_irq, > + .unmask = expio_unmask_irq, > +}; > + > +int __init mxc_expio_init(u32 base, u32 p_irq) > +{ > + int i; > + > + brd_io = ioremap(BOARD_IO_ADDR(base), SZ_4K); > + if (brd_io == NULL) > + return -ENOMEM; > + > + if ((__raw_readw(brd_io + MAGIC_NUMBER1_REG) != 0xAAAA) || > + (__raw_readw(brd_io + MAGIC_NUMBER2_REG) != 0x5555) || > + (__raw_readw(brd_io + MAGIC_NUMBER3_REG) != 0xCAFE)) { > + pr_info("3-Stack Debug board not detected\n"); > + iounmap(brd_io); > + brd_io = NULL; > + return -ENODEV; > + } > + > + pr_info("3-Stack Debug board detected, rev = 0x%04X\n", > + readw(brd_io + CPLD_CODE_VER_REG)); > + > + smsc911x_resources[0].start = LAN9217_BASE_ADDR(base); > + smsc911x_resources[0].end = LAN9217_BASE_ADDR(base) + 0x100 - 1; > + > + /* > + * Configure INT line as GPIO input > + */ > + gpio_request(MXC_IRQ_TO_GPIO(p_irq), "expio_pirq"); > + gpio_direction_input(MXC_IRQ_TO_GPIO(p_irq)); > + > + /* disable the interrupt and clear the status */ > + __raw_writew(0, brd_io + INTR_MASK_REG); > + __raw_writew(0xFFFF, brd_io + INTR_RESET_REG); > + __raw_writew(0, brd_io + INTR_RESET_REG); > + __raw_writew(0x1F, brd_io + INTR_MASK_REG); > + for (i = MXC_EXP_IO_BASE; > + i < (MXC_EXP_IO_BASE + MXC_MAX_EXP_IO_LINES); i++) { > + set_irq_chip(i, &expio_irq_chip); > + set_irq_handler(i, handle_level_irq); > + set_irq_flags(i, IRQF_VALID); > + } > + set_irq_type(p_irq, IRQF_TRIGGER_LOW); > + set_irq_chained_handler(p_irq, mxc_expio_irq_handler); > + > + return 0; > +} > diff --git a/arch/arm/plat-mxc/include/mach/cpld_debugboard.h b/arch/arm/plat-mxc/include/mach/cpld_debugboard.h > new file mode 100644 > index 0000000..a1422d2 > --- /dev/null > +++ b/arch/arm/plat-mxc/include/mach/cpld_debugboard.h > @@ -0,0 +1,60 @@ > +/* > + * Copyright 2008-2009 Freescale Semiconductor, Inc. All Rights Reserved. > + * > + * > + * The code contained herein is licensed under the GNU General Public > + * License. You may obtain a copy of the GNU General Public License > + * Version 2 or later at the following locations: > + * > + * http://www.opensource.org/licenses/gpl-license.html > + * http://www.gnu.org/copyleft/gpl.html > + */ > + > +#ifndef __ASM_ARCH_MXC_CPLD_DB_H__ > +#define __ASM_ARCH_MXC_CPLD_DB_H__ > + > +/* LAN9217 ethernet base address */ > +#define LAN9217_BASE_ADDR(n) (n + 0x0) > +/* External UART */ > +#define UARTA_BASE_ADDR(n) (n + 0x8000) > +#define UARTB_BASE_ADDR(n) (n + 0x10000) > + > +#define BOARD_IO_ADDR(n) (n + 0x20000) > +/* LED switchs */ > +#define LED_SWITCH_REG 0x00 > +/* buttons */ > +#define SWITCH_BUTTONS_REG 0x08 > +/* status, interrupt */ > +#define INTR_STATUS_REG 0x10 > +#define INTR_MASK_REG 0x38 > +#define INTR_RESET_REG 0x20 > +/* magic word for debug CPLD */ > +#define MAGIC_NUMBER1_REG 0x40 > +#define MAGIC_NUMBER2_REG 0x48 > +/* CPLD code version */ > +#define CPLD_CODE_VER_REG 0x50 > +/* magic word for debug CPLD */ > +#define MAGIC_NUMBER3_REG 0x58 > +/* module reset register*/ > +#define MODULE_RESET_REG 0x60 > +/* CPU ID and Personality ID */ > +#define MCU_BOARD_ID_REG 0x68 > + > +#define MXC_IRQ_TO_EXPIO(irq) ((irq) - MXC_BOARD_IRQ_START) > +#define MXC_IRQ_TO_GPIO(irq) ((irq) - MXC_INTERNAL_IRQS) > + > +#define MXC_EXP_IO_BASE (MXC_BOARD_IRQ_START) > +#define MXC_MAX_EXP_IO_LINES 16 > + > +/* interrupts like external uart , external ethernet etc*/ > +#define EXPIO_INT_ENET (MXC_BOARD_IRQ_START + 0) > +#define EXPIO_INT_XUART_A (MXC_BOARD_IRQ_START + 1) > +#define EXPIO_INT_XUART_B (MXC_BOARD_IRQ_START + 2) > +#define EXPIO_INT_BUTTON_A (MXC_BOARD_IRQ_START + 3) > +#define EXPIO_INT_BUTTON_B (MXC_BOARD_IRQ_START + 4) > + > +extern struct platform_device smsc_lan9217_device; > + > +int __init mxc_expio_init(u32 base, u32 p_irq); > + > +#endif /* __ASM_ARCH_MXC_CPLD_DB_H__ */ > -- > 1.5.6.5 > > -- Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | ^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 1/2] mxc: add common debug board for 3-stack platforms 2010-06-16 6:55 ` [PATCH 1/2] mxc: add common debug board for 3-stack platforms Sascha Hauer @ 2010-06-17 13:37 ` jason 2010-06-18 14:06 ` jason 1 sibling, 0 replies; 10+ messages in thread From: jason @ 2010-06-17 13:37 UTC (permalink / raw) To: linux-arm-kernel Sascha Hauer wrote: > On Sat, Jun 12, 2010 at 10:25:06PM +0800, Jason Wang wrote: > >> The debug board is little different for all mxc 3-stack(PDK) >> platforms, it is possible here to add a common implementation to >> support this board. >> > > Two small things left: > > Could you change the name cpld_debugboard.c to something like > 3ds_debugboard.c? That we are talking about the 3ds is much more > interesting than that there's a cpld on the board. > > Also, I really prefer having no extra header file for the debug board. > All information in this header file is only interesting in this single C > file. > > Sascha > > > Accept, will fix in next version. Thanks, Jason. >> Signed-off-by: Jason Wang <jason77.wang@gmail.com> >> --- >> arch/arm/plat-mxc/Kconfig | 11 ++ >> arch/arm/plat-mxc/Makefile | 1 + >> arch/arm/plat-mxc/cpld_debugboard.c | 161 ++++++++++++++++++++++ >> arch/arm/plat-mxc/include/mach/cpld_debugboard.h | 60 ++++++++ >> 4 files changed, 233 insertions(+), 0 deletions(-) >> create mode 100644 arch/arm/plat-mxc/cpld_debugboard.c >> create mode 100644 arch/arm/plat-mxc/include/mach/cpld_debugboard.h >> <snip> ^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 1/2] mxc: add common debug board for 3-stack platforms 2010-06-16 6:55 ` [PATCH 1/2] mxc: add common debug board for 3-stack platforms Sascha Hauer 2010-06-17 13:37 ` jason @ 2010-06-18 14:06 ` jason 2010-06-21 7:11 ` Sascha Hauer 1 sibling, 1 reply; 10+ messages in thread From: jason @ 2010-06-18 14:06 UTC (permalink / raw) To: linux-arm-kernel Sascha Hauer wrote: > On Sat, Jun 12, 2010 at 10:25:06PM +0800, Jason Wang wrote: > >> The debug board is little different for all mxc 3-stack(PDK) >> platforms, it is possible here to add a common implementation to >> support this board. >> > > Two small things left: > > Could you change the name cpld_debugboard.c to something like > 3ds_debugboard.c? That we are talking about the 3ds is much more > interesting than that there's a cpld on the board. > > Also, I really prefer having no extra header file for the debug board. > All information in this header file is only interesting in this single C > file. > > Sascha > > > Hi Sascha, About the header file, most contents can be moved to c file, but there are two declarations: extern struct platform_device smsc_lan9217_device; int __init mxc_expio_init(u32 base, u32 p_irq); which will be used by board_mxNN_3ds.c, should i move them to mach/common.h and drop 3ds_debugboard.h or keep them in 3ds_debugboard.h? Thanks, Jason. >> Signed-off-by: Jason Wang <jason77.wang@gmail.com> >> --- >> arch/arm/plat-mxc/Kconfig | 11 ++ >> arch/arm/plat-mxc/Makefile | 1 + >> arch/arm/plat-mxc/cpld_debugboard.c | 161 ++++++++++++++++++++++ >> <snip> ^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 1/2] mxc: add common debug board for 3-stack platforms 2010-06-18 14:06 ` jason @ 2010-06-21 7:11 ` Sascha Hauer 2010-06-22 13:08 ` jason 0 siblings, 1 reply; 10+ messages in thread From: Sascha Hauer @ 2010-06-21 7:11 UTC (permalink / raw) To: linux-arm-kernel On Fri, Jun 18, 2010 at 10:06:34PM +0800, jason wrote: > Sascha Hauer wrote: >> On Sat, Jun 12, 2010 at 10:25:06PM +0800, Jason Wang wrote: >> >>> The debug board is little different for all mxc 3-stack(PDK) >>> platforms, it is possible here to add a common implementation to >>> support this board. >>> >> >> Two small things left: >> >> Could you change the name cpld_debugboard.c to something like >> 3ds_debugboard.c? That we are talking about the 3ds is much more >> interesting than that there's a cpld on the board. >> >> Also, I really prefer having no extra header file for the debug board. >> All information in this header file is only interesting in this single C >> file. >> >> Sascha >> >> >> > Hi Sascha, > > About the header file, most contents can be moved to c file, > but there are two declarations: > > extern struct platform_device smsc_lan9217_device; What do you need this one for? > int __init mxc_expio_init(u32 base, u32 p_irq); You'll definitely need this one of course. > > which will be used by board_mxNN_3ds.c, should i move them to mach/common.h and > drop 3ds_debugboard.h or keep them in 3ds_debugboard.h? Keep them in 3ds_debugboard.h. This way we can easily grep for all users of the 3ds debug board code. Sascha -- Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | ^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 1/2] mxc: add common debug board for 3-stack platforms 2010-06-21 7:11 ` Sascha Hauer @ 2010-06-22 13:08 ` jason 0 siblings, 0 replies; 10+ messages in thread From: jason @ 2010-06-22 13:08 UTC (permalink / raw) To: linux-arm-kernel Sascha Hauer wrote: > On Fri, Jun 18, 2010 at 10:06:34PM +0800, jason wrote: > >> Sascha Hauer wrote: >> >>> On Sat, Jun 12, 2010 at 10:25:06PM +0800, Jason Wang wrote: >>> >>> >>>> The debug board is little different for all mxc 3-stack(PDK) >>>> platforms, it is possible here to add a common implementation to >>>> support this board. >>>> >>>> >>> Two small things left: >>> >>> Could you change the name cpld_debugboard.c to something like >>> 3ds_debugboard.c? That we are talking about the 3ds is much more >>> interesting than that there's a cpld on the board. >>> >>> Also, I really prefer having no extra header file for the debug board. >>> All information in this header file is only interesting in this single C >>> file. >>> >>> Sascha >>> >>> >>> >>> >> Hi Sascha, >> >> About the header file, most contents can be moved to c file, >> but there are two declarations: >> >> extern struct platform_device smsc_lan9217_device; >> > > What do you need this one for? > > Originally i want to register lan9217 in the board-mxNN-3ds.c, just like: if (!mxc_expio_init(MX51_CS5_BASE_ADDR, EXPIO_PARENT_INT)) platform_device_register(&smsc_lan9217_device); Of course, i can give it a wrapper like mxc_expio_lan_init(); Please see my next version. Thanks, Jason. >> int __init mxc_expio_init(u32 base, u32 p_irq); >> > > You'll definitely need this one of course. > > >> which will be used by board_mxNN_3ds.c, should i move them to mach/common.h and >> drop 3ds_debugboard.h or keep them in 3ds_debugboard.h? >> > > Keep them in 3ds_debugboard.h. This way we can easily grep for all users > of the 3ds debug board code. > > Sascha > > > ^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2010-06-22 13:08 UTC | newest] Thread overview: 10+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2010-06-12 14:25 [PATCH 0/2]Add mxc common CPLD debugboard support Jason Wang 2010-06-12 14:25 ` [PATCH 1/2] mxc: add common debug board for 3-stack platforms Jason Wang 2010-06-12 14:25 ` [PATCH 2/2] mx31_3ds: revert cpld debug board relate code Jason Wang 2010-06-16 6:57 ` Sascha Hauer 2010-06-16 20:36 ` Magnus Lilja 2010-06-16 6:55 ` [PATCH 1/2] mxc: add common debug board for 3-stack platforms Sascha Hauer 2010-06-17 13:37 ` jason 2010-06-18 14:06 ` jason 2010-06-21 7:11 ` Sascha Hauer 2010-06-22 13:08 ` jason
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).