blob: 6e608d1836f1e5e69a5d8e9be2dc25add5301986 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/***************************************************************************/
2
3/*
4 * linux/arch/m68knommu/platform/528x/config.c
5 *
Greg Ungerer980f9232009-04-28 14:24:25 +10006 * Sub-architcture dependant initialization code for the Freescale
7 * 5280, 5281 and 5282 CPUs.
Linus Torvalds1da177e2005-04-16 15:20:36 -07008 *
9 * Copyright (C) 1999-2003, Greg Ungerer (gerg@snapgear.com)
10 * Copyright (C) 2001-2003, SnapGear Inc. (www.snapgear.com)
11 */
12
13/***************************************************************************/
14
Linus Torvalds1da177e2005-04-16 15:20:36 -070015#include <linux/kernel.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070016#include <linux/param.h>
17#include <linux/init.h>
Greg Ungerereb49e902008-02-01 17:34:50 +100018#include <linux/platform_device.h>
Greg Ungerereb49e902008-02-01 17:34:50 +100019#include <linux/io.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070020#include <asm/machdep.h>
21#include <asm/coldfire.h>
22#include <asm/mcfsim.h>
Greg Ungerereb49e902008-02-01 17:34:50 +100023#include <asm/mcfuart.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070024
25/***************************************************************************/
26
Greg Ungerereb49e902008-02-01 17:34:50 +100027static struct mcf_platform_uart m528x_uart_platform[] = {
28 {
29 .mapbase = MCF_MBAR + MCFUART_BASE1,
30 .irq = MCFINT_VECBASE + MCFINT_UART0,
31 },
32 {
33 .mapbase = MCF_MBAR + MCFUART_BASE2,
34 .irq = MCFINT_VECBASE + MCFINT_UART0 + 1,
35 },
36 {
37 .mapbase = MCF_MBAR + MCFUART_BASE3,
38 .irq = MCFINT_VECBASE + MCFINT_UART0 + 2,
39 },
40 { },
Linus Torvalds1da177e2005-04-16 15:20:36 -070041};
42
Greg Ungerereb49e902008-02-01 17:34:50 +100043static struct platform_device m528x_uart = {
44 .name = "mcfuart",
45 .id = 0,
46 .dev.platform_data = m528x_uart_platform,
47};
48
Greg Ungererffba3f42009-02-26 22:40:38 -080049static struct resource m528x_fec_resources[] = {
50 {
51 .start = MCF_MBAR + 0x1000,
52 .end = MCF_MBAR + 0x1000 + 0x7ff,
53 .flags = IORESOURCE_MEM,
54 },
55 {
56 .start = 64 + 23,
57 .end = 64 + 23,
58 .flags = IORESOURCE_IRQ,
59 },
60 {
61 .start = 64 + 27,
62 .end = 64 + 27,
63 .flags = IORESOURCE_IRQ,
64 },
65 {
66 .start = 64 + 29,
67 .end = 64 + 29,
68 .flags = IORESOURCE_IRQ,
69 },
70};
71
72static struct platform_device m528x_fec = {
73 .name = "fec",
74 .id = 0,
75 .num_resources = ARRAY_SIZE(m528x_fec_resources),
76 .resource = m528x_fec_resources,
77};
78
79
Greg Ungerereb49e902008-02-01 17:34:50 +100080static struct platform_device *m528x_devices[] __initdata = {
81 &m528x_uart,
Greg Ungererffba3f42009-02-26 22:40:38 -080082 &m528x_fec,
Greg Ungerereb49e902008-02-01 17:34:50 +100083};
84
85/***************************************************************************/
86
Greg Ungerereb49e902008-02-01 17:34:50 +100087static void __init m528x_uart_init_line(int line, int irq)
88{
89 u8 port;
Greg Ungerereb49e902008-02-01 17:34:50 +100090
91 if ((line < 0) || (line > 2))
92 return;
93
Greg Ungerereb49e902008-02-01 17:34:50 +100094 /* make sure PUAPAR is set for UART0 and UART1 */
95 if (line < 2) {
96 port = readb(MCF_MBAR + MCF5282_GPIO_PUAPAR);
97 port |= (0x03 << (line * 2));
98 writeb(port, MCF_MBAR + MCF5282_GPIO_PUAPAR);
99 }
100}
101
102static void __init m528x_uarts_init(void)
103{
104 const int nrlines = ARRAY_SIZE(m528x_uart_platform);
105 int line;
106
107 for (line = 0; (line < nrlines); line++)
108 m528x_uart_init_line(line, m528x_uart_platform[line].irq);
109}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700110
111/***************************************************************************/
112
Greg Ungererffba3f42009-02-26 22:40:38 -0800113static void __init m528x_fec_init(void)
114{
Greg Ungererffba3f42009-02-26 22:40:38 -0800115 u16 v16;
116
Greg Ungererffba3f42009-02-26 22:40:38 -0800117 /* Set multi-function pins to ethernet mode for fec0 */
118 v16 = readw(MCF_IPSBAR + 0x100056);
119 writew(v16 | 0xf00, MCF_IPSBAR + 0x100056);
120 writeb(0xc0, MCF_IPSBAR + 0x100058);
121}
122
123/***************************************************************************/
124
Greg Ungererdd65b1d2009-04-30 23:15:56 +1000125static void m528x_cpu_reset(void)
126{
127 local_irq_disable();
128 __raw_writeb(MCF_RCR_SWRESET, MCF_IPSBAR + MCF_RCR);
129}
130
131/***************************************************************************/
132
Steve Bennett188a9a42008-05-01 12:17:08 +1000133#ifdef CONFIG_WILDFIRE
134void wildfire_halt(void)
135{
136 writeb(0, 0x30000007);
137 writeb(0x2, 0x30000007);
138}
139#endif
140
141#ifdef CONFIG_WILDFIREMOD
142void wildfiremod_halt(void)
143{
144 printk(KERN_INFO "WildFireMod hibernating...\n");
145
146 /* Set portE.5 to Digital IO */
147 MCF5282_GPIO_PEPAR &= ~(1 << (5 * 2));
148
149 /* Make portE.5 an output */
150 MCF5282_GPIO_DDRE |= (1 << 5);
151
152 /* Now toggle portE.5 from low to high */
153 MCF5282_GPIO_PORTE &= ~(1 << 5);
154 MCF5282_GPIO_PORTE |= (1 << 5);
155
156 printk(KERN_EMERG "Failed to hibernate. Halting!\n");
157}
158#endif
159
Greg Ungerereb49e902008-02-01 17:34:50 +1000160void __init config_BSP(char *commandp, int size)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700161{
Steve Bennett188a9a42008-05-01 12:17:08 +1000162#ifdef CONFIG_WILDFIRE
163 mach_halt = wildfire_halt;
164#endif
165#ifdef CONFIG_WILDFIREMOD
166 mach_halt = wildfiremod_halt;
167#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700168}
169
170/***************************************************************************/
Greg Ungerereb49e902008-02-01 17:34:50 +1000171
172static int __init init_BSP(void)
173{
Greg Ungererdd65b1d2009-04-30 23:15:56 +1000174 mach_reset = m528x_cpu_reset;
Greg Ungerereb49e902008-02-01 17:34:50 +1000175 m528x_uarts_init();
Greg Ungererffba3f42009-02-26 22:40:38 -0800176 m528x_fec_init();
Greg Ungerereb49e902008-02-01 17:34:50 +1000177 platform_add_devices(m528x_devices, ARRAY_SIZE(m528x_devices));
178 return 0;
179}
180
181arch_initcall(init_BSP);
182
183/***************************************************************************/