From 5cf0942123bcacf8af8922eaf3fef70bce6078e6 Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Tue, 9 Sep 2008 10:19:41 +0200 Subject: i.MX3: make SoC devices globally available Make SoC devices globally available to boards rather than using a device specific init function. Signed-off-by: Sascha Hauer --- arch/arm/mach-mx3/devices.c | 43 +++++-------------------------------------- arch/arm/mach-mx3/devices.h | 6 ++++++ arch/arm/mach-mx3/pcm037.c | 6 ++++-- 3 files changed, 15 insertions(+), 40 deletions(-) create mode 100644 arch/arm/mach-mx3/devices.h (limited to 'arch/arm/mach-mx3') diff --git a/arch/arm/mach-mx3/devices.c b/arch/arm/mach-mx3/devices.c index e08c6a8ac56..a6bdcc07f3c 100644 --- a/arch/arm/mach-mx3/devices.c +++ b/arch/arm/mach-mx3/devices.c @@ -36,7 +36,7 @@ static struct resource uart0[] = { }, }; -static struct platform_device mxc_uart_device0 = { +struct platform_device mxc_uart_device0 = { .name = "imx-uart", .id = 0, .resource = uart0, @@ -55,7 +55,7 @@ static struct resource uart1[] = { }, }; -static struct platform_device mxc_uart_device1 = { +struct platform_device mxc_uart_device1 = { .name = "imx-uart", .id = 1, .resource = uart1, @@ -74,7 +74,7 @@ static struct resource uart2[] = { }, }; -static struct platform_device mxc_uart_device2 = { +struct platform_device mxc_uart_device2 = { .name = "imx-uart", .id = 2, .resource = uart2, @@ -93,7 +93,7 @@ static struct resource uart3[] = { }, }; -static struct platform_device mxc_uart_device3 = { +struct platform_device mxc_uart_device3 = { .name = "imx-uart", .id = 3, .resource = uart3, @@ -112,46 +112,13 @@ static struct resource uart4[] = { }, }; -static struct platform_device mxc_uart_device4 = { +struct platform_device mxc_uart_device4 = { .name = "imx-uart", .id = 4, .resource = uart4, .num_resources = ARRAY_SIZE(uart4), }; -/* - * Register only those UARTs that physically exist - */ -int __init imx_init_uart(int uart_no, struct imxuart_platform_data *pdata) -{ - switch (uart_no) { - case 0: - mxc_uart_device0.dev.platform_data = pdata; - platform_device_register(&mxc_uart_device0); - break; - case 1: - mxc_uart_device1.dev.platform_data = pdata; - platform_device_register(&mxc_uart_device1); - break; - case 2: - mxc_uart_device2.dev.platform_data = pdata; - platform_device_register(&mxc_uart_device2); - break; - case 3: - mxc_uart_device3.dev.platform_data = pdata; - platform_device_register(&mxc_uart_device3); - break; - case 4: - mxc_uart_device4.dev.platform_data = pdata; - platform_device_register(&mxc_uart_device4); - break; - default: - return -ENODEV; - } - - return 0; -} - /* GPIO port description */ static struct mxc_gpio_port imx_gpio_ports[] = { [0] = { diff --git a/arch/arm/mach-mx3/devices.h b/arch/arm/mach-mx3/devices.h new file mode 100644 index 00000000000..4dc03f9e600 --- /dev/null +++ b/arch/arm/mach-mx3/devices.h @@ -0,0 +1,6 @@ + +extern struct platform_device mxc_uart_device0; +extern struct platform_device mxc_uart_device1; +extern struct platform_device mxc_uart_device2; +extern struct platform_device mxc_uart_device3; +extern struct platform_device mxc_uart_device4; diff --git a/arch/arm/mach-mx3/pcm037.c b/arch/arm/mach-mx3/pcm037.c index 0a152ed15a8..03374f9e000 100644 --- a/arch/arm/mach-mx3/pcm037.c +++ b/arch/arm/mach-mx3/pcm037.c @@ -33,6 +33,8 @@ #include #include +#include "devices.h" + static struct physmap_flash_data pcm037_flash_data = { .width = 2, }; @@ -73,12 +75,12 @@ static void __init mxc_board_init(void) mxc_iomux_mode(MX31_PIN_TXD1__TXD1); mxc_iomux_mode(MX31_PIN_RXD1__RXD1); - imx_init_uart(0, &uart_pdata); + mxc_register_device(&mxc_uart_device0, &uart_pdata); mxc_iomux_mode(MX31_PIN_CSPI3_MOSI__RXD3); mxc_iomux_mode(MX31_PIN_CSPI3_MISO__TXD3); - imx_init_uart(2, &uart_pdata); + mxc_register_device(&mxc_uart_device2, &uart_pdata); } /* -- cgit v1.2.3 From 0741794c0d4192c45193d5e7f8e87a7bfb79ae0a Mon Sep 17 00:00:00 2001 From: Gilles Chanteperdrix Date: Tue, 9 Sep 2008 10:19:41 +0200 Subject: i.MX31ADS: Enable the first IMX serial port. (take 3) Signed-off-by: Gilles Chanteperdrix Signed-off-by: Sascha Hauer --- arch/arm/mach-mx3/mx31ads.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'arch/arm/mach-mx3') diff --git a/arch/arm/mach-mx3/mx31ads.c b/arch/arm/mach-mx3/mx31ads.c index 60fb4e0d5ac..3b48d1ae3a8 100644 --- a/arch/arm/mach-mx3/mx31ads.c +++ b/arch/arm/mach-mx3/mx31ads.c @@ -31,6 +31,8 @@ #include #include #include +#include +#include /*! * @file mx31ads.c @@ -84,6 +86,26 @@ static inline int mxc_init_extuart(void) } #endif +#if defined(CONFIG_SERIAL_IMX) || defined(CONFIG_SERIAL_IMX_MODULE) +static struct imxuart_platform_data uart_pdata = { + .flags = IMXUART_HAVE_RTSCTS, +}; + +static inline void mxc_init_imx_uart(void) +{ + mxc_iomux_mode(MX31_PIN_CTS1__CTS1); + mxc_iomux_mode(MX31_PIN_RTS1__RTS1); + mxc_iomux_mode(MX31_PIN_TXD1__TXD1); + mxc_iomux_mode(MX31_PIN_RXD1__RXD1); + + mxc_register_device(&mxc_uart_device0, &uart_pdata); +} +#else /* !SERIAL_IMX */ +static inline void mxc_init_imx_uart(void) +{ +} +#endif /* !SERIAL_IMX */ + /*! * This structure defines static mappings for the i.MX31ADS board. */ @@ -126,6 +148,7 @@ void __init mx31ads_map_io(void) static void __init mxc_board_init(void) { mxc_init_extuart(); + mxc_init_imx_uart(); } static void __init mx31ads_timer_init(void) -- cgit v1.2.3 From d7568f79d5c289d0d7859680be7b5afdcea0c9b2 Mon Sep 17 00:00:00 2001 From: Gilles Chanteperdrix Date: Tue, 9 Sep 2008 10:19:42 +0200 Subject: i.MX31ADS: Add CPLD interrupts demultiplexing (take 3). Needed for 8250 serial port and CS89x0 ethernet interface. Signed-off-by: Gilles Chanteperdrix Signed-off-by: Sascha Hauer --- arch/arm/mach-mx3/mx31ads.c | 91 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 90 insertions(+), 1 deletion(-) (limited to 'arch/arm/mach-mx3') diff --git a/arch/arm/mach-mx3/mx31ads.c b/arch/arm/mach-mx3/mx31ads.c index 3b48d1ae3a8..0803fc6c021 100644 --- a/arch/arm/mach-mx3/mx31ads.c +++ b/arch/arm/mach-mx3/mx31ads.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include @@ -106,6 +107,88 @@ static inline void mxc_init_imx_uart(void) } #endif /* !SERIAL_IMX */ +static void mx31ads_expio_irq_handler(u32 irq, struct irq_desc *desc) +{ + u32 imr_val; + u32 int_valid; + u32 expio_irq; + + imr_val = __raw_readw(PBC_INTMASK_SET_REG); + int_valid = __raw_readw(PBC_INTSTATUS_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(u32 irq) +{ + u32 expio = MXC_IRQ_TO_EXPIO(irq); + /* mask the interrupt */ + __raw_writew(1 << expio, PBC_INTMASK_CLEAR_REG); + __raw_readw(PBC_INTMASK_CLEAR_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(u32 irq) +{ + u32 expio = MXC_IRQ_TO_EXPIO(irq); + /* clear the interrupt status */ + __raw_writew(1 << expio, PBC_INTSTATUS_REG); +} + +/* + * 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(u32 irq) +{ + u32 expio = MXC_IRQ_TO_EXPIO(irq); + /* unmask the interrupt */ + __raw_writew(1 << expio, PBC_INTMASK_SET_REG); +} + +static struct irq_chip expio_irq_chip = { + .ack = expio_ack_irq, + .mask = expio_mask_irq, + .unmask = expio_unmask_irq, +}; + +static void __init mx31ads_init_expio(void) +{ + int i; + + printk(KERN_INFO "MX31ADS EXPIO(CPLD) hardware\n"); + + /* + * Configure INT line as GPIO input + */ + mxc_iomux_mode(IOMUX_MODE(MX31_PIN_GPIO1_4, IOMUX_CONFIG_GPIO)); + + /* disable the interrupt and clear the status */ + __raw_writew(0xFFFF, PBC_INTMASK_CLEAR_REG); + __raw_writew(0xFFFF, PBC_INTSTATUS_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_HIGH); + set_irq_chained_handler(EXPIO_PARENT_INT, mx31ads_expio_irq_handler); +} + /*! * This structure defines static mappings for the i.MX31ADS board. */ @@ -142,6 +225,12 @@ void __init mx31ads_map_io(void) iotable_init(mx31ads_io_desc, ARRAY_SIZE(mx31ads_io_desc)); } +void __init mx31ads_init_irq(void) +{ + mxc_init_irq(); + mx31ads_init_expio(); +} + /*! * Board specific initialization. */ @@ -171,7 +260,7 @@ MACHINE_START(MX31ADS, "Freescale MX31ADS") .io_pg_offst = ((AIPS1_BASE_ADDR_VIRT) >> 18) & 0xfffc, .boot_params = PHYS_OFFSET + 0x100, .map_io = mx31ads_map_io, - .init_irq = mxc_init_irq, + .init_irq = mx31ads_init_irq, .init_machine = mxc_board_init, .timer = &mx31ads_timer, MACHINE_END -- cgit v1.2.3 From defa8c309d280915a2e7f4451f70bcbb087088a3 Mon Sep 17 00:00:00 2001 From: Luotao Fu Date: Tue, 9 Sep 2008 10:19:43 +0200 Subject: i.MX3: Fix compiler warnings Fix some base address declaration by adding a cast. Signed-off-by: Luotao Fu Signed-off-by: Sascha Hauer --- arch/arm/mach-mx3/iomux.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'arch/arm/mach-mx3') diff --git a/arch/arm/mach-mx3/iomux.c b/arch/arm/mach-mx3/iomux.c index 3dda1fe23cb..6e664be8cc1 100644 --- a/arch/arm/mach-mx3/iomux.c +++ b/arch/arm/mach-mx3/iomux.c @@ -43,7 +43,8 @@ static DEFINE_SPINLOCK(gpio_mux_lock); */ int mxc_iomux_mode(unsigned int pin_mode) { - u32 reg, field, l, mode, ret = 0; + u32 field, l, mode, ret = 0; + void __iomem *reg; reg = IOMUXSW_MUX_CTL + (pin_mode & IOMUX_REG_MASK); field = pin_mode & 0x3; @@ -70,7 +71,8 @@ EXPORT_SYMBOL(mxc_iomux_mode); */ void mxc_iomux_set_pad(enum iomux_pins pin, u32 config) { - u32 reg, field, l; + u32 field, l; + void __iomem *reg; reg = IOMUXSW_PAD_CTL + (pin + 2) / 3; field = (pin + 2) % 3; -- cgit v1.2.3 From 9b727abdff93b0039fba94e96216fc280af4cf01 Mon Sep 17 00:00:00 2001 From: Russell King Date: Sun, 7 Sep 2008 12:45:01 +0100 Subject: [ARM] Remove MT_NONSHARED_DEVICE alias Use MT_DEVICE_NONSHARED instead. Signed-off-by: Russell King --- arch/arm/mach-mx3/mm.c | 2 +- arch/arm/mach-mx3/mx31ads.c | 6 +++--- arch/arm/mach-mx3/mx31lite.c | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) (limited to 'arch/arm/mach-mx3') diff --git a/arch/arm/mach-mx3/mm.c b/arch/arm/mach-mx3/mm.c index 30d842bd4d6..0589b5cd33c 100644 --- a/arch/arm/mach-mx3/mm.c +++ b/arch/arm/mach-mx3/mm.c @@ -49,7 +49,7 @@ static struct map_desc mxc_io_desc[] __initdata = { .virtual = AVIC_BASE_ADDR_VIRT, .pfn = __phys_to_pfn(AVIC_BASE_ADDR), .length = AVIC_SIZE, - .type = MT_NONSHARED_DEVICE + .type = MT_DEVICE_NONSHARED }, }; diff --git a/arch/arm/mach-mx3/mx31ads.c b/arch/arm/mach-mx3/mx31ads.c index 60fb4e0d5ac..0cd90a9667c 100644 --- a/arch/arm/mach-mx3/mx31ads.c +++ b/arch/arm/mach-mx3/mx31ads.c @@ -92,17 +92,17 @@ static struct map_desc mx31ads_io_desc[] __initdata = { .virtual = AIPS1_BASE_ADDR_VIRT, .pfn = __phys_to_pfn(AIPS1_BASE_ADDR), .length = AIPS1_SIZE, - .type = MT_NONSHARED_DEVICE + .type = MT_DEVICE_NONSHARED }, { .virtual = SPBA0_BASE_ADDR_VIRT, .pfn = __phys_to_pfn(SPBA0_BASE_ADDR), .length = SPBA0_SIZE, - .type = MT_NONSHARED_DEVICE + .type = MT_DEVICE_NONSHARED }, { .virtual = AIPS2_BASE_ADDR_VIRT, .pfn = __phys_to_pfn(AIPS2_BASE_ADDR), .length = AIPS2_SIZE, - .type = MT_NONSHARED_DEVICE + .type = MT_DEVICE_NONSHARED }, { .virtual = CS4_BASE_ADDR_VIRT, .pfn = __phys_to_pfn(CS4_BASE_ADDR), diff --git a/arch/arm/mach-mx3/mx31lite.c b/arch/arm/mach-mx3/mx31lite.c index d363a6e79f8..c4344007014 100644 --- a/arch/arm/mach-mx3/mx31lite.c +++ b/arch/arm/mach-mx3/mx31lite.c @@ -45,17 +45,17 @@ static struct map_desc mx31lite_io_desc[] __initdata = { .virtual = AIPS1_BASE_ADDR_VIRT, .pfn = __phys_to_pfn(AIPS1_BASE_ADDR), .length = AIPS1_SIZE, - .type = MT_NONSHARED_DEVICE + .type = MT_DEVICE_NONSHARED }, { .virtual = SPBA0_BASE_ADDR_VIRT, .pfn = __phys_to_pfn(SPBA0_BASE_ADDR), .length = SPBA0_SIZE, - .type = MT_NONSHARED_DEVICE + .type = MT_DEVICE_NONSHARED }, { .virtual = AIPS2_BASE_ADDR_VIRT, .pfn = __phys_to_pfn(AIPS2_BASE_ADDR), .length = AIPS2_SIZE, - .type = MT_NONSHARED_DEVICE + .type = MT_DEVICE_NONSHARED }, { .virtual = CS4_BASE_ADDR_VIRT, .pfn = __phys_to_pfn(CS4_BASE_ADDR), -- cgit v1.2.3