blob: e049245f4092a77e114bfabc6a8647d042759f81 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/***************************************************************************/
2
3/*
4 * linux/arch/m68knommu/platform/5272/config.c
5 *
6 * Copyright (C) 1999-2002, Greg Ungerer (gerg@snapgear.com)
7 * Copyright (C) 2001-2002, SnapGear Inc. (www.snapgear.com)
8 */
9
10/***************************************************************************/
11
Linus Torvalds1da177e2005-04-16 15:20:36 -070012#include <linux/kernel.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070013#include <linux/param.h>
14#include <linux/init.h>
15#include <linux/interrupt.h>
Greg Ungerer84e6def2008-02-01 17:34:32 +100016#include <linux/io.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070017#include <asm/machdep.h>
18#include <asm/coldfire.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070019#include <asm/mcfsim.h>
Greg Ungerer84e6def2008-02-01 17:34:32 +100020#include <asm/mcfuart.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070021
22/***************************************************************************/
23
Linus Torvalds1da177e2005-04-16 15:20:36 -070024void coldfire_reset(void);
25
26extern unsigned int mcf_timervector;
27extern unsigned int mcf_profilevector;
28extern unsigned int mcf_timerlevel;
29
30/***************************************************************************/
31
32/*
33 * Some platforms need software versions of the GPIO data registers.
34 */
35unsigned short ppdata;
36unsigned char ledbank = 0xff;
37
38/***************************************************************************/
39
Greg Ungerer84e6def2008-02-01 17:34:32 +100040static struct mcf_platform_uart m5272_uart_platform[] = {
41 {
42 .mapbase = MCF_MBAR + MCFUART_BASE1,
43 .irq = 73,
44 },
45 {
46 .mapbase = MCF_MBAR + MCFUART_BASE2,
47 .irq = 74,
48 },
49 { },
Linus Torvalds1da177e2005-04-16 15:20:36 -070050};
51
Greg Ungerer84e6def2008-02-01 17:34:32 +100052static struct platform_device m5272_uart = {
53 .name = "mcfuart",
54 .id = 0,
55 .dev.platform_data = m5272_uart_platform,
56};
57
Greg Ungererffba3f42009-02-26 22:40:38 -080058static struct resource m5272_fec_resources[] = {
59 {
60 .start = MCF_MBAR + 0x840,
61 .end = MCF_MBAR + 0x840 + 0x1cf,
62 .flags = IORESOURCE_MEM,
63 },
64 {
65 .start = 86,
66 .end = 86,
67 .flags = IORESOURCE_IRQ,
68 },
69 {
70 .start = 87,
71 .end = 87,
72 .flags = IORESOURCE_IRQ,
73 },
74 {
75 .start = 88,
76 .end = 88,
77 .flags = IORESOURCE_IRQ,
78 },
79};
80
81static struct platform_device m5272_fec = {
82 .name = "fec",
83 .id = 0,
84 .num_resources = ARRAY_SIZE(m5272_fec_resources),
85 .resource = m5272_fec_resources,
86};
87
Greg Ungerer84e6def2008-02-01 17:34:32 +100088static struct platform_device *m5272_devices[] __initdata = {
89 &m5272_uart,
Greg Ungererffba3f42009-02-26 22:40:38 -080090 &m5272_fec,
Greg Ungerer84e6def2008-02-01 17:34:32 +100091};
92
93/***************************************************************************/
94
95static void __init m5272_uart_init_line(int line, int irq)
96{
97 u32 v;
98
99 if ((line >= 0) && (line < 2)) {
100 v = (line) ? 0x0e000000 : 0xe0000000;
101 writel(v, MCF_MBAR + MCFSIM_ICR2);
102
103 /* Enable the output lines for the serial ports */
104 v = readl(MCF_MBAR + MCFSIM_PBCNT);
105 v = (v & ~0x000000ff) | 0x00000055;
106 writel(v, MCF_MBAR + MCFSIM_PBCNT);
107
108 v = readl(MCF_MBAR + MCFSIM_PDCNT);
109 v = (v & ~0x000003fc) | 0x000002a8;
110 writel(v, MCF_MBAR + MCFSIM_PDCNT);
111 }
112}
113
114static void __init m5272_uarts_init(void)
115{
116 const int nrlines = ARRAY_SIZE(m5272_uart_platform);
117 int line;
118
119 for (line = 0; (line < nrlines); line++)
120 m5272_uart_init_line(line, m5272_uart_platform[line].irq);
121}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700122
123/***************************************************************************/
124
Greg Ungererffba3f42009-02-26 22:40:38 -0800125static void __init m5272_fec_init(void)
126{
127 u32 imr;
128
129 /* Unmask FEC interrupts at ColdFire interrupt controller */
130 imr = readl(MCF_MBAR + MCFSIM_ICR3);
131 imr = (imr & ~0x00000fff) | 0x00000ddd;
132 writel(imr, MCF_MBAR + MCFSIM_ICR3);
133
134 imr = readl(MCF_MBAR + MCFSIM_ICR1);
135 imr = (imr & ~0x0f000000) | 0x0d000000;
136 writel(imr, MCF_MBAR + MCFSIM_ICR1);
137}
138
139/***************************************************************************/
140
Linus Torvalds1da177e2005-04-16 15:20:36 -0700141void mcf_disableall(void)
142{
143 volatile unsigned long *icrp;
144
145 icrp = (volatile unsigned long *) (MCF_MBAR + MCFSIM_ICR1);
146 icrp[0] = 0x88888888;
147 icrp[1] = 0x88888888;
148 icrp[2] = 0x88888888;
149 icrp[3] = 0x88888888;
150}
151
152/***************************************************************************/
153
154void mcf_autovector(unsigned int vec)
155{
156 /* Everything is auto-vectored on the 5272 */
157}
158
159/***************************************************************************/
160
161void mcf_settimericr(int timer, int level)
162{
163 volatile unsigned long *icrp;
164
165 if ((timer >= 1 ) && (timer <= 4)) {
166 icrp = (volatile unsigned long *) (MCF_MBAR + MCFSIM_ICR1);
167 *icrp = (0x8 | level) << ((4 - timer) * 4);
168 }
169}
170
171/***************************************************************************/
172
Greg Ungerer84e6def2008-02-01 17:34:32 +1000173void __init config_BSP(char *commandp, int size)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700174{
Greg Ungerera7962662005-09-09 09:32:14 +1000175#if defined (CONFIG_MOD5272)
176 volatile unsigned char *pivrp;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700177
178 /* Set base of device vectors to be 64 */
Greg Ungerera7962662005-09-09 09:32:14 +1000179 pivrp = (volatile unsigned char *) (MCF_MBAR + MCFSIM_PIVR);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700180 *pivrp = 0x40;
181#endif
182
183 mcf_disableall();
184
Greg Ungererbc724502007-07-25 22:07:20 +1000185#if defined(CONFIG_NETtel) || defined(CONFIG_SCALES)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700186 /* Copy command line from FLASH to local buffer... */
187 memcpy(commandp, (char *) 0xf0004000, size);
188 commandp[size-1] = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700189#elif defined(CONFIG_CANCam)
190 /* Copy command line from FLASH to local buffer... */
191 memcpy(commandp, (char *) 0xf0010000, size);
192 commandp[size-1] = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700193#endif
194
195 mcf_timervector = 69;
196 mcf_profilevector = 70;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700197 mach_reset = coldfire_reset;
198}
199
200/***************************************************************************/
Greg Ungerer84e6def2008-02-01 17:34:32 +1000201
202static int __init init_BSP(void)
203{
204 m5272_uarts_init();
Greg Ungererffba3f42009-02-26 22:40:38 -0800205 m5272_fec_init();
Greg Ungerer84e6def2008-02-01 17:34:32 +1000206 platform_add_devices(m5272_devices, ARRAY_SIZE(m5272_devices));
207 return 0;
208}
209
210arch_initcall(init_BSP);
211
212/***************************************************************************/