Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ryusuke...
[linux-2.6-block.git] / arch / m68knommu / platform / 520x / config.c
CommitLineData
88a605b0
GU
1/***************************************************************************/
2
3/*
4 * linux/arch/m68knommu/platform/520x/config.c
5 *
6 * Copyright (C) 2005, Freescale (www.freescale.com)
7 * Copyright (C) 2005, Intec Automation (mike@steroidmicros.com)
7dabb9ad 8 * Copyright (C) 1999-2007, Greg Ungerer (gerg@snapgear.com)
88a605b0
GU
9 * Copyright (C) 2001-2003, SnapGear Inc. (www.snapgear.com)
10 */
11
12/***************************************************************************/
13
88a605b0
GU
14#include <linux/kernel.h>
15#include <linux/param.h>
7dabb9ad 16#include <linux/init.h>
7dabb9ad 17#include <linux/io.h>
88a605b0 18#include <asm/machdep.h>
7dabb9ad
GU
19#include <asm/coldfire.h>
20#include <asm/mcfsim.h>
21#include <asm/mcfuart.h>
88a605b0
GU
22
23/***************************************************************************/
24
7dabb9ad
GU
25static struct mcf_platform_uart m520x_uart_platform[] = {
26 {
27 .mapbase = MCF_MBAR + MCFUART_BASE1,
28 .irq = MCFINT_VECBASE + MCFINT_UART0,
29 },
30 {
31 .mapbase = MCF_MBAR + MCFUART_BASE2,
32 .irq = MCFINT_VECBASE + MCFINT_UART1,
33 },
34 {
35 .mapbase = MCF_MBAR + MCFUART_BASE3,
36 .irq = MCFINT_VECBASE + MCFINT_UART2,
37 },
38 { },
39};
40
41static struct platform_device m520x_uart = {
42 .name = "mcfuart",
43 .id = 0,
44 .dev.platform_data = m520x_uart_platform,
45};
46
ffba3f48
GU
47static struct resource m520x_fec_resources[] = {
48 {
49 .start = MCF_MBAR + 0x30000,
50 .end = MCF_MBAR + 0x30000 + 0x7ff,
51 .flags = IORESOURCE_MEM,
52 },
53 {
54 .start = 64 + 36,
55 .end = 64 + 36,
56 .flags = IORESOURCE_IRQ,
57 },
58 {
59 .start = 64 + 40,
60 .end = 64 + 40,
61 .flags = IORESOURCE_IRQ,
62 },
63 {
64 .start = 64 + 42,
65 .end = 64 + 42,
66 .flags = IORESOURCE_IRQ,
67 },
68};
69
70static struct platform_device m520x_fec = {
71 .name = "fec",
72 .id = 0,
73 .num_resources = ARRAY_SIZE(m520x_fec_resources),
74 .resource = m520x_fec_resources,
75};
76
7dabb9ad
GU
77static struct platform_device *m520x_devices[] __initdata = {
78 &m520x_uart,
ffba3f48 79 &m520x_fec,
7dabb9ad
GU
80};
81
82/***************************************************************************/
83
84#define INTC0 (MCF_MBAR + MCFICM_INTC0)
85
86static void __init m520x_uart_init_line(int line, int irq)
87{
88 u32 imr;
89 u16 par;
90 u8 par2;
91
92 writeb(0x03, INTC0 + MCFINTC_ICR0 + MCFINT_UART0 + line);
93
94 imr = readl(INTC0 + MCFINTC_IMRL);
95 imr &= ~((1 << (irq - MCFINT_VECBASE)) | 1);
96 writel(imr, INTC0 + MCFINTC_IMRL);
97
98 switch (line) {
99 case 0:
100 par = readw(MCF_IPSBAR + MCF_GPIO_PAR_UART);
101 par |= MCF_GPIO_PAR_UART_PAR_UTXD0 |
102 MCF_GPIO_PAR_UART_PAR_URXD0;
103 writew(par, MCF_IPSBAR + MCF_GPIO_PAR_UART);
104 break;
105 case 1:
106 par = readw(MCF_IPSBAR + MCF_GPIO_PAR_UART);
107 par |= MCF_GPIO_PAR_UART_PAR_UTXD1 |
108 MCF_GPIO_PAR_UART_PAR_URXD1;
109 writew(par, MCF_IPSBAR + MCF_GPIO_PAR_UART);
110 break;
111 case 2:
112 par2 = readb(MCF_IPSBAR + MCF_GPIO_PAR_FECI2C);
113 par2 &= ~0x0F;
114 par2 |= MCF_GPIO_PAR_FECI2C_PAR_SCL_UTXD2 |
115 MCF_GPIO_PAR_FECI2C_PAR_SDA_URXD2;
116 writeb(par2, MCF_IPSBAR + MCF_GPIO_PAR_FECI2C);
117 break;
118 }
119}
120
121static void __init m520x_uarts_init(void)
122{
123 const int nrlines = ARRAY_SIZE(m520x_uart_platform);
124 int line;
125
126 for (line = 0; (line < nrlines); line++)
127 m520x_uart_init_line(line, m520x_uart_platform[line].irq);
128}
88a605b0
GU
129
130/***************************************************************************/
131
ffba3f48
GU
132static void __init m520x_fec_init(void)
133{
134 u32 imr;
135 u8 v;
136
137 /* Unmask FEC interrupts at ColdFire interrupt controller */
138 writeb(0x4, MCF_IPSBAR + MCFICM_INTC0 + MCFINTC_ICR0 + 36);
139 writeb(0x4, MCF_IPSBAR + MCFICM_INTC0 + MCFINTC_ICR0 + 40);
140 writeb(0x4, MCF_IPSBAR + MCFICM_INTC0 + MCFINTC_ICR0 + 42);
141
142 imr = readl(MCF_IPSBAR + MCFICM_INTC0 + MCFINTC_IMRH);
143 imr &= ~0x0001FFF0;
144 writel(imr, MCF_IPSBAR + MCFICM_INTC0 + MCFINTC_IMRH);
145
146 /* Set multi-function pins to ethernet mode */
147 v = readb(MCF_IPSBAR + MCF_GPIO_PAR_FEC);
148 writeb(v | 0xf0, MCF_IPSBAR + MCF_GPIO_PAR_FEC);
149
150 v = readb(MCF_IPSBAR + MCF_GPIO_PAR_FECI2C);
151 writeb(v | 0x0f, MCF_IPSBAR + MCF_GPIO_PAR_FECI2C);
152}
153
154/***************************************************************************/
155
88a605b0
GU
156/*
157 * Program the vector to be an auto-vectored.
158 */
159
160void mcf_autovector(unsigned int vec)
161{
162 /* Everything is auto-vectored on the 520x devices */
163}
164
165/***************************************************************************/
166
25ce4a90
GU
167static void m520x_cpu_reset(void)
168{
169 local_irq_disable();
170 __raw_writeb(MCF_RCR_SWRESET, MCF_RCR);
171}
172
173/***************************************************************************/
174
7dabb9ad 175void __init config_BSP(char *commandp, int size)
88a605b0 176{
25ce4a90 177 mach_reset = m520x_cpu_reset;
7dabb9ad 178 m520x_uarts_init();
ffba3f48 179 m520x_fec_init();
88a605b0
GU
180}
181
182/***************************************************************************/
7dabb9ad
GU
183
184static int __init init_BSP(void)
185{
186 platform_add_devices(m520x_devices, ARRAY_SIZE(m520x_devices));
187 return 0;
188}
189
190arch_initcall(init_BSP);
191
192/***************************************************************************/