blob: 1c99cbae1f978fc7e7ca26f0585ae9d1bd7e7b91 [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>
Greg Ungerer84e6def2008-02-01 17:34:32 +100015#include <linux/io.h>
Greg Ungerer41a21592010-10-12 12:24:49 +100016#include <linux/phy.h>
17#include <linux/phy_fixed.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070018#include <asm/machdep.h>
19#include <asm/coldfire.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070020#include <asm/mcfsim.h>
Greg Ungerer84e6def2008-02-01 17:34:32 +100021#include <asm/mcfuart.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070022
23/***************************************************************************/
24
Linus Torvalds1da177e2005-04-16 15:20:36 -070025/*
26 * Some platforms need software versions of the GPIO data registers.
27 */
28unsigned short ppdata;
29unsigned char ledbank = 0xff;
30
31/***************************************************************************/
32
Greg Ungerer84e6def2008-02-01 17:34:32 +100033static struct mcf_platform_uart m5272_uart_platform[] = {
34 {
Greg Ungerer023e0552011-12-24 00:30:37 +100035 .mapbase = MCFUART_BASE0,
36 .irq = MCF_IRQ_UART0,
Greg Ungerer84e6def2008-02-01 17:34:32 +100037 },
38 {
Greg Ungerer023e0552011-12-24 00:30:37 +100039 .mapbase = MCFUART_BASE1,
40 .irq = MCF_IRQ_UART1,
Greg Ungerer84e6def2008-02-01 17:34:32 +100041 },
42 { },
Linus Torvalds1da177e2005-04-16 15:20:36 -070043};
44
Greg Ungerer84e6def2008-02-01 17:34:32 +100045static struct platform_device m5272_uart = {
46 .name = "mcfuart",
47 .id = 0,
48 .dev.platform_data = m5272_uart_platform,
49};
50
Greg Ungererffba3f42009-02-26 22:40:38 -080051static struct resource m5272_fec_resources[] = {
52 {
53 .start = MCF_MBAR + 0x840,
54 .end = MCF_MBAR + 0x840 + 0x1cf,
55 .flags = IORESOURCE_MEM,
56 },
57 {
Greg Ungerer49802962009-07-07 12:13:23 +100058 .start = MCF_IRQ_ERX,
59 .end = MCF_IRQ_ERX,
Greg Ungererffba3f42009-02-26 22:40:38 -080060 .flags = IORESOURCE_IRQ,
61 },
62 {
Greg Ungerer49802962009-07-07 12:13:23 +100063 .start = MCF_IRQ_ETX,
64 .end = MCF_IRQ_ETX,
Greg Ungererffba3f42009-02-26 22:40:38 -080065 .flags = IORESOURCE_IRQ,
66 },
67 {
Greg Ungerer49802962009-07-07 12:13:23 +100068 .start = MCF_IRQ_ENTC,
69 .end = MCF_IRQ_ENTC,
Greg Ungererffba3f42009-02-26 22:40:38 -080070 .flags = IORESOURCE_IRQ,
71 },
72};
73
74static struct platform_device m5272_fec = {
75 .name = "fec",
76 .id = 0,
77 .num_resources = ARRAY_SIZE(m5272_fec_resources),
78 .resource = m5272_fec_resources,
79};
80
Greg Ungerer84e6def2008-02-01 17:34:32 +100081static struct platform_device *m5272_devices[] __initdata = {
82 &m5272_uart,
Greg Ungererffba3f42009-02-26 22:40:38 -080083 &m5272_fec,
Greg Ungerer84e6def2008-02-01 17:34:32 +100084};
85
86/***************************************************************************/
87
88static void __init m5272_uart_init_line(int line, int irq)
89{
90 u32 v;
91
92 if ((line >= 0) && (line < 2)) {
Greg Ungerer84e6def2008-02-01 17:34:32 +100093 /* Enable the output lines for the serial ports */
94 v = readl(MCF_MBAR + MCFSIM_PBCNT);
95 v = (v & ~0x000000ff) | 0x00000055;
96 writel(v, MCF_MBAR + MCFSIM_PBCNT);
97
98 v = readl(MCF_MBAR + MCFSIM_PDCNT);
99 v = (v & ~0x000003fc) | 0x000002a8;
100 writel(v, MCF_MBAR + MCFSIM_PDCNT);
101 }
102}
103
104static void __init m5272_uarts_init(void)
105{
106 const int nrlines = ARRAY_SIZE(m5272_uart_platform);
107 int line;
108
109 for (line = 0; (line < nrlines); line++)
110 m5272_uart_init_line(line, m5272_uart_platform[line].irq);
111}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700112
113/***************************************************************************/
114
Greg Ungerer05728ae2009-04-30 23:32:52 +1000115static void m5272_cpu_reset(void)
116{
117 local_irq_disable();
118 /* Set watchdog to reset, and enabled */
119 __raw_writew(0, MCF_MBAR + MCFSIM_WIRR);
120 __raw_writew(1, MCF_MBAR + MCFSIM_WRRR);
121 __raw_writew(0, MCF_MBAR + MCFSIM_WCR);
122 for (;;)
123 /* wait for watchdog to timeout */;
124}
125
126/***************************************************************************/
127
Greg Ungerer84e6def2008-02-01 17:34:32 +1000128void __init config_BSP(char *commandp, int size)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700129{
Greg Ungerera7962662005-09-09 09:32:14 +1000130#if defined (CONFIG_MOD5272)
131 volatile unsigned char *pivrp;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700132
133 /* Set base of device vectors to be 64 */
Greg Ungerera7962662005-09-09 09:32:14 +1000134 pivrp = (volatile unsigned char *) (MCF_MBAR + MCFSIM_PIVR);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700135 *pivrp = 0x40;
136#endif
137
Greg Ungererbc724502007-07-25 22:07:20 +1000138#if defined(CONFIG_NETtel) || defined(CONFIG_SCALES)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700139 /* Copy command line from FLASH to local buffer... */
140 memcpy(commandp, (char *) 0xf0004000, size);
141 commandp[size-1] = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700142#elif defined(CONFIG_CANCam)
143 /* Copy command line from FLASH to local buffer... */
144 memcpy(commandp, (char *) 0xf0010000, size);
145 commandp[size-1] = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700146#endif
147
Greg Ungerer05728ae2009-04-30 23:32:52 +1000148 mach_reset = m5272_cpu_reset;
Greg Ungerer35aefb22012-01-23 15:34:58 +1000149 mach_sched_init = hw_timer_init;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700150}
151
152/***************************************************************************/
Greg Ungerer84e6def2008-02-01 17:34:32 +1000153
Greg Ungerer41a21592010-10-12 12:24:49 +1000154/*
155 * Some 5272 based boards have the FEC ethernet diectly connected to
156 * an ethernet switch. In this case we need to use the fixed phy type,
157 * and we need to declare it early in boot.
158 */
159static struct fixed_phy_status nettel_fixed_phy_status __initdata = {
160 .link = 1,
161 .speed = 100,
162 .duplex = 0,
163};
164
165/***************************************************************************/
166
Greg Ungerer84e6def2008-02-01 17:34:32 +1000167static int __init init_BSP(void)
168{
169 m5272_uarts_init();
Greg Ungerer41a21592010-10-12 12:24:49 +1000170 fixed_phy_add(PHY_POLL, 0, &nettel_fixed_phy_status);
Greg Ungerer84e6def2008-02-01 17:34:32 +1000171 platform_add_devices(m5272_devices, ARRAY_SIZE(m5272_devices));
172 return 0;
173}
174
175arch_initcall(init_BSP);
176
177/***************************************************************************/