blob: b9301920afbf89f8ebb8b92daceccd261a2cbb2e [file] [log] [blame]
Greg Ungerer0d2fe942011-12-24 01:17:10 +10001/*
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
19static 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
43static struct platform_device mcf_uart = {
44 .name = "mcfuart",
45 .id = 0,
46 .dev.platform_data = mcf_uart_platform_data,
47};
48
49static struct platform_device *mcf_devices[] __initdata = {
50 &mcf_uart,
51};
52
Greg Ungerer55148f62011-12-24 01:23:35 +100053
54/*
55 * Some ColdFire UARTs let you set the IRQ line to use.
56 */
57static 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 Ungerer0d2fe942011-12-24 01:17:10 +100072static int __init mcf_init_devices(void)
73{
Greg Ungerer55148f62011-12-24 01:23:35 +100074 mcf_uart_set_irq();
Greg Ungerer0d2fe942011-12-24 01:17:10 +100075 platform_add_devices(mcf_devices, ARRAY_SIZE(mcf_devices));
76 return 0;
77}
78
79arch_initcall(mcf_init_devices);
80