blob: 13f02611ea23a8c866755af5b0fe8585e2d60de2 [file] [log] [blame]
Greg Ungererb5aaf3f2005-09-02 10:42:52 +10001/***************************************************************************/
2
3/*
4 * linux/arch/m68knommu/platform/523x/config.c
5 *
6 * Sub-architcture dependant initialization code for the Freescale
7 * 523x CPUs.
8 *
9 * Copyright (C) 1999-2005, Greg Ungerer (gerg@snapgear.com)
10 * Copyright (C) 2001-2003, SnapGear Inc. (www.snapgear.com)
11 */
12
13/***************************************************************************/
14
Greg Ungererb5aaf3f2005-09-02 10:42:52 +100015#include <linux/kernel.h>
Greg Ungererb5aaf3f2005-09-02 10:42:52 +100016#include <linux/param.h>
17#include <linux/init.h>
18#include <linux/interrupt.h>
Greg Ungerer4b61a352008-02-01 17:34:15 +100019#include <linux/io.h>
Greg Ungererb5aaf3f2005-09-02 10:42:52 +100020#include <asm/machdep.h>
21#include <asm/coldfire.h>
22#include <asm/mcfsim.h>
Greg Ungerer4b61a352008-02-01 17:34:15 +100023#include <asm/mcfuart.h>
Greg Ungererb5aaf3f2005-09-02 10:42:52 +100024
25/***************************************************************************/
26
Greg Ungererb5aaf3f2005-09-02 10:42:52 +100027void coldfire_reset(void);
28
29/***************************************************************************/
30
Greg Ungerer4b61a352008-02-01 17:34:15 +100031static struct mcf_platform_uart m523x_uart_platform[] = {
32 {
33 .mapbase = MCF_MBAR + MCFUART_BASE1,
34 .irq = MCFINT_VECBASE + MCFINT_UART0,
35 },
36 {
37 .mapbase = MCF_MBAR + MCFUART_BASE2,
38 .irq = MCFINT_VECBASE + MCFINT_UART0 + 1,
39 },
40 {
41 .mapbase = MCF_MBAR + MCFUART_BASE3,
42 .irq = MCFINT_VECBASE + MCFINT_UART0 + 2,
43 },
44 { },
Greg Ungererb5aaf3f2005-09-02 10:42:52 +100045};
46
Greg Ungerer4b61a352008-02-01 17:34:15 +100047static struct platform_device m523x_uart = {
48 .name = "mcfuart",
49 .id = 0,
50 .dev.platform_data = m523x_uart_platform,
51};
52
53static struct platform_device *m523x_devices[] __initdata = {
54 &m523x_uart,
55};
56
57/***************************************************************************/
58
59#define INTC0 (MCF_MBAR + MCFICM_INTC0)
60
61static void __init m523x_uart_init_line(int line, int irq)
62{
63 u32 imr;
64
65 if ((line < 0) || (line > 2))
66 return;
67
68 writeb(0x30+line, (INTC0 + MCFINTC_ICR0 + MCFINT_UART0 + line));
69
70 imr = readl(INTC0 + MCFINTC_IMRL);
71 imr &= ~((1 << (irq - MCFINT_VECBASE)) | 1);
72 writel(imr, INTC0 + MCFINTC_IMRL);
73}
74
75static void __init m523x_uarts_init(void)
76{
77 const int nrlines = ARRAY_SIZE(m523x_uart_platform);
78 int line;
79
80 for (line = 0; (line < nrlines); line++)
81 m523x_uart_init_line(line, m523x_uart_platform[line].irq);
82}
Greg Ungererb5aaf3f2005-09-02 10:42:52 +100083
84/***************************************************************************/
85
86void mcf_disableall(void)
87{
88 *((volatile unsigned long *) (MCF_IPSBAR + MCFICM_INTC0 + MCFINTC_IMRH)) = 0xffffffff;
89 *((volatile unsigned long *) (MCF_IPSBAR + MCFICM_INTC0 + MCFINTC_IMRL)) = 0xffffffff;
90}
91
92/***************************************************************************/
93
94void mcf_autovector(unsigned int vec)
95{
Greg Ungerer4b61a352008-02-01 17:34:15 +100096 /* Everything is auto-vectored on the 523x */
Greg Ungererb5aaf3f2005-09-02 10:42:52 +100097}
98
99/***************************************************************************/
100
Greg Ungerer4b61a352008-02-01 17:34:15 +1000101void __init config_BSP(char *commandp, int size)
Greg Ungererb5aaf3f2005-09-02 10:42:52 +1000102{
103 mcf_disableall();
Greg Ungererb5aaf3f2005-09-02 10:42:52 +1000104 mach_reset = coldfire_reset;
Greg Ungerer4b61a352008-02-01 17:34:15 +1000105 m523x_uarts_init();
Greg Ungererb5aaf3f2005-09-02 10:42:52 +1000106}
107
108/***************************************************************************/
Greg Ungerer4b61a352008-02-01 17:34:15 +1000109
110static int __init init_BSP(void)
111{
112 platform_add_devices(m523x_devices, ARRAY_SIZE(m523x_devices));
113 return 0;
114}
115
116arch_initcall(init_BSP);
117
118/***************************************************************************/