Greg Ungerer | 0d2fe94 | 2011-12-24 01:17:10 +1000 | [diff] [blame] | 1 | /* |
| 2 | * device.c -- common ColdFire SoC device support |
| 3 | * |
| 4 | * (C) Copyright 2011, Greg Ungerer <gerg@uclinux.org> |
| 5 | * |
| 6 | * This file is subject to the terms and conditions of the GNU General Public |
| 7 | * License. See the file COPYING in the main directory of this archive |
| 8 | * for more details. |
| 9 | */ |
| 10 | |
| 11 | #include <linux/kernel.h> |
| 12 | #include <linux/init.h> |
| 13 | #include <linux/io.h> |
| 14 | #include <asm/traps.h> |
| 15 | #include <asm/coldfire.h> |
| 16 | #include <asm/mcfsim.h> |
| 17 | #include <asm/mcfuart.h> |
| 18 | |
| 19 | static struct mcf_platform_uart mcf_uart_platform_data[] = { |
| 20 | { |
| 21 | .mapbase = MCFUART_BASE0, |
| 22 | .irq = MCF_IRQ_UART0, |
| 23 | }, |
| 24 | { |
| 25 | .mapbase = MCFUART_BASE1, |
| 26 | .irq = MCF_IRQ_UART1, |
| 27 | }, |
| 28 | #ifdef MCFUART_BASE2 |
| 29 | { |
| 30 | .mapbase = MCFUART_BASE2, |
| 31 | .irq = MCF_IRQ_UART2, |
| 32 | }, |
| 33 | #endif |
| 34 | #ifdef MCFUART_BASE3 |
| 35 | { |
| 36 | .mapbase = MCFUART_BASE3, |
| 37 | .irq = MCF_IRQ_UART3, |
| 38 | }, |
| 39 | #endif |
| 40 | { }, |
| 41 | }; |
| 42 | |
| 43 | static struct platform_device mcf_uart = { |
| 44 | .name = "mcfuart", |
| 45 | .id = 0, |
| 46 | .dev.platform_data = mcf_uart_platform_data, |
| 47 | }; |
| 48 | |
| 49 | static struct platform_device *mcf_devices[] __initdata = { |
| 50 | &mcf_uart, |
| 51 | }; |
| 52 | |
Greg Ungerer | 55148f6 | 2011-12-24 01:23:35 +1000 | [diff] [blame] | 53 | |
| 54 | /* |
| 55 | * Some ColdFire UARTs let you set the IRQ line to use. |
| 56 | */ |
| 57 | static void __init mcf_uart_set_irq(void) |
| 58 | { |
| 59 | #ifdef MCFUART_UIVR |
| 60 | /* UART0 interrupt setup */ |
| 61 | writeb(MCFSIM_ICR_LEVEL6 | MCFSIM_ICR_PRI1, MCF_MBAR + MCFSIM_UART1ICR); |
| 62 | writeb(MCF_IRQ_UART0, MCFUART_BASE0 + MCFUART_UIVR); |
| 63 | mcf_mapirq2imr(MCF_IRQ_UART0, MCFINTC_UART0); |
| 64 | |
| 65 | /* UART1 interrupt setup */ |
| 66 | writeb(MCFSIM_ICR_LEVEL6 | MCFSIM_ICR_PRI2, MCF_MBAR + MCFSIM_UART2ICR); |
| 67 | writeb(MCF_IRQ_UART1, MCFUART_BASE1 + MCFUART_UIVR); |
| 68 | mcf_mapirq2imr(MCF_IRQ_UART1, MCFINTC_UART1); |
| 69 | #endif |
| 70 | } |
| 71 | |
Greg Ungerer | 0d2fe94 | 2011-12-24 01:17:10 +1000 | [diff] [blame] | 72 | static int __init mcf_init_devices(void) |
| 73 | { |
Greg Ungerer | 55148f6 | 2011-12-24 01:23:35 +1000 | [diff] [blame] | 74 | mcf_uart_set_irq(); |
Greg Ungerer | 0d2fe94 | 2011-12-24 01:17:10 +1000 | [diff] [blame] | 75 | platform_add_devices(mcf_devices, ARRAY_SIZE(mcf_devices)); |
| 76 | return 0; |
| 77 | } |
| 78 | |
| 79 | arch_initcall(mcf_init_devices); |
| 80 | |