blob: 43e36060da186f6e8b0db445001b89fb576c5350 [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>
Greg Ungerer6621c5c2012-04-17 14:19:11 +100022#include <asm/mcfgpio.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070023
24/***************************************************************************/
25
Linus Torvalds1da177e2005-04-16 15:20:36 -070026/*
27 * Some platforms need software versions of the GPIO data registers.
28 */
29unsigned short ppdata;
30unsigned char ledbank = 0xff;
31
32/***************************************************************************/
33
Greg Ungerer6621c5c2012-04-17 14:19:11 +100034struct mcf_gpio_chip mcf_gpio_chips[] = {
35 MCFGPS(PA, 0, 16, MCFSIM_PADDR, MCFSIM_PADAT, MCFSIM_PADAT),
36 MCFGPS(PB, 16, 16, MCFSIM_PBDDR, MCFSIM_PBDAT, MCFSIM_PBDAT),
37 MCFGPS(Pc, 32, 16, MCFSIM_PCDDR, MCFSIM_PCDAT, MCFSIM_PCDAT),
38};
39
40unsigned int mcf_gpio_chips_size = ARRAY_SIZE(mcf_gpio_chips);
41
42/***************************************************************************/
43
Greg Ungerer6b656e82011-12-24 00:56:52 +100044static void __init m5272_uarts_init(void)
Greg Ungerer84e6def2008-02-01 17:34:32 +100045{
46 u32 v;
47
Greg Ungerer6b656e82011-12-24 00:56:52 +100048 /* Enable the output lines for the serial ports */
49 v = readl(MCF_MBAR + MCFSIM_PBCNT);
50 v = (v & ~0x000000ff) | 0x00000055;
51 writel(v, MCF_MBAR + MCFSIM_PBCNT);
Greg Ungerer84e6def2008-02-01 17:34:32 +100052
Greg Ungerer6b656e82011-12-24 00:56:52 +100053 v = readl(MCF_MBAR + MCFSIM_PDCNT);
54 v = (v & ~0x000003fc) | 0x000002a8;
55 writel(v, MCF_MBAR + MCFSIM_PDCNT);
Greg Ungerer84e6def2008-02-01 17:34:32 +100056}
Linus Torvalds1da177e2005-04-16 15:20:36 -070057
58/***************************************************************************/
59
Greg Ungerer05728ae2009-04-30 23:32:52 +100060static void m5272_cpu_reset(void)
61{
62 local_irq_disable();
63 /* Set watchdog to reset, and enabled */
64 __raw_writew(0, MCF_MBAR + MCFSIM_WIRR);
65 __raw_writew(1, MCF_MBAR + MCFSIM_WRRR);
66 __raw_writew(0, MCF_MBAR + MCFSIM_WCR);
67 for (;;)
68 /* wait for watchdog to timeout */;
69}
70
71/***************************************************************************/
72
Greg Ungerer84e6def2008-02-01 17:34:32 +100073void __init config_BSP(char *commandp, int size)
Linus Torvalds1da177e2005-04-16 15:20:36 -070074{
Greg Ungerera7962662005-09-09 09:32:14 +100075#if defined (CONFIG_MOD5272)
76 volatile unsigned char *pivrp;
Linus Torvalds1da177e2005-04-16 15:20:36 -070077
78 /* Set base of device vectors to be 64 */
Greg Ungerera7962662005-09-09 09:32:14 +100079 pivrp = (volatile unsigned char *) (MCF_MBAR + MCFSIM_PIVR);
Linus Torvalds1da177e2005-04-16 15:20:36 -070080 *pivrp = 0x40;
81#endif
82
Greg Ungererbc724502007-07-25 22:07:20 +100083#if defined(CONFIG_NETtel) || defined(CONFIG_SCALES)
Linus Torvalds1da177e2005-04-16 15:20:36 -070084 /* Copy command line from FLASH to local buffer... */
85 memcpy(commandp, (char *) 0xf0004000, size);
86 commandp[size-1] = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -070087#elif defined(CONFIG_CANCam)
88 /* Copy command line from FLASH to local buffer... */
89 memcpy(commandp, (char *) 0xf0010000, size);
90 commandp[size-1] = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -070091#endif
92
Greg Ungerer05728ae2009-04-30 23:32:52 +100093 mach_reset = m5272_cpu_reset;
Greg Ungerer35aefb22012-01-23 15:34:58 +100094 mach_sched_init = hw_timer_init;
Linus Torvalds1da177e2005-04-16 15:20:36 -070095}
96
97/***************************************************************************/
Greg Ungerer84e6def2008-02-01 17:34:32 +100098
Greg Ungerer41a21592010-10-12 12:24:49 +100099/*
100 * Some 5272 based boards have the FEC ethernet diectly connected to
101 * an ethernet switch. In this case we need to use the fixed phy type,
102 * and we need to declare it early in boot.
103 */
104static struct fixed_phy_status nettel_fixed_phy_status __initdata = {
105 .link = 1,
106 .speed = 100,
107 .duplex = 0,
108};
109
110/***************************************************************************/
111
Greg Ungerer84e6def2008-02-01 17:34:32 +1000112static int __init init_BSP(void)
113{
114 m5272_uarts_init();
Greg Ungerer41a21592010-10-12 12:24:49 +1000115 fixed_phy_add(PHY_POLL, 0, &nettel_fixed_phy_status);
Greg Ungerer84e6def2008-02-01 17:34:32 +1000116 return 0;
117}
118
119arch_initcall(init_BSP);
120
121/***************************************************************************/