Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /***************************************************************************/ |
| 2 | |
| 3 | /* |
Greg Ungerer | ece9ae6 | 2014-08-19 11:55:24 +1000 | [diff] [blame] | 4 | * m5272.c -- platform support for ColdFire 5272 based boards |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 12 | #include <linux/kernel.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 | #include <linux/param.h> |
| 14 | #include <linux/init.h> |
Greg Ungerer | 84e6def | 2008-02-01 17:34:32 +1000 | [diff] [blame] | 15 | #include <linux/io.h> |
Greg Ungerer | 41a2159 | 2010-10-12 12:24:49 +1000 | [diff] [blame] | 16 | #include <linux/phy.h> |
| 17 | #include <linux/phy_fixed.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 18 | #include <asm/machdep.h> |
| 19 | #include <asm/coldfire.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 20 | #include <asm/mcfsim.h> |
Greg Ungerer | 84e6def | 2008-02-01 17:34:32 +1000 | [diff] [blame] | 21 | #include <asm/mcfuart.h> |
Greg Ungerer | 7acef7a | 2012-07-13 16:01:59 +1000 | [diff] [blame] | 22 | #include <asm/mcfclk.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 23 | |
| 24 | /***************************************************************************/ |
| 25 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 26 | /* |
| 27 | * Some platforms need software versions of the GPIO data registers. |
| 28 | */ |
| 29 | unsigned short ppdata; |
| 30 | unsigned char ledbank = 0xff; |
| 31 | |
| 32 | /***************************************************************************/ |
| 33 | |
Greg Ungerer | 7acef7a | 2012-07-13 16:01:59 +1000 | [diff] [blame] | 34 | DEFINE_CLK(pll, "pll.0", MCF_CLK); |
| 35 | DEFINE_CLK(sys, "sys.0", MCF_BUSCLK); |
| 36 | DEFINE_CLK(mcftmr0, "mcftmr.0", MCF_BUSCLK); |
| 37 | DEFINE_CLK(mcftmr1, "mcftmr.1", MCF_BUSCLK); |
| 38 | DEFINE_CLK(mcftmr2, "mcftmr.2", MCF_BUSCLK); |
| 39 | DEFINE_CLK(mcftmr3, "mcftmr.3", MCF_BUSCLK); |
| 40 | DEFINE_CLK(mcfuart0, "mcfuart.0", MCF_BUSCLK); |
| 41 | DEFINE_CLK(mcfuart1, "mcfuart.1", MCF_BUSCLK); |
Steven King | 7485952 | 2014-05-14 10:06:29 -0700 | [diff] [blame] | 42 | DEFINE_CLK(mcfqspi0, "mcfqspi.0", MCF_BUSCLK); |
Greg Ungerer | 7acef7a | 2012-07-13 16:01:59 +1000 | [diff] [blame] | 43 | DEFINE_CLK(fec0, "fec.0", MCF_BUSCLK); |
| 44 | |
| 45 | struct clk *mcf_clks[] = { |
| 46 | &clk_pll, |
| 47 | &clk_sys, |
| 48 | &clk_mcftmr0, |
| 49 | &clk_mcftmr1, |
| 50 | &clk_mcftmr2, |
| 51 | &clk_mcftmr3, |
| 52 | &clk_mcfuart0, |
| 53 | &clk_mcfuart1, |
Steven King | 7485952 | 2014-05-14 10:06:29 -0700 | [diff] [blame] | 54 | &clk_mcfqspi0, |
Greg Ungerer | 7acef7a | 2012-07-13 16:01:59 +1000 | [diff] [blame] | 55 | &clk_fec0, |
| 56 | NULL |
| 57 | }; |
| 58 | |
| 59 | /***************************************************************************/ |
| 60 | |
Greg Ungerer | 6b656e8 | 2011-12-24 00:56:52 +1000 | [diff] [blame] | 61 | static void __init m5272_uarts_init(void) |
Greg Ungerer | 84e6def | 2008-02-01 17:34:32 +1000 | [diff] [blame] | 62 | { |
| 63 | u32 v; |
| 64 | |
Greg Ungerer | 6b656e8 | 2011-12-24 00:56:52 +1000 | [diff] [blame] | 65 | /* Enable the output lines for the serial ports */ |
Greg Ungerer | 4fb62ed | 2012-09-14 16:36:08 +1000 | [diff] [blame] | 66 | v = readl(MCFSIM_PBCNT); |
Greg Ungerer | 6b656e8 | 2011-12-24 00:56:52 +1000 | [diff] [blame] | 67 | v = (v & ~0x000000ff) | 0x00000055; |
Greg Ungerer | 4fb62ed | 2012-09-14 16:36:08 +1000 | [diff] [blame] | 68 | writel(v, MCFSIM_PBCNT); |
Greg Ungerer | 84e6def | 2008-02-01 17:34:32 +1000 | [diff] [blame] | 69 | |
Greg Ungerer | 4fb62ed | 2012-09-14 16:36:08 +1000 | [diff] [blame] | 70 | v = readl(MCFSIM_PDCNT); |
Greg Ungerer | 6b656e8 | 2011-12-24 00:56:52 +1000 | [diff] [blame] | 71 | v = (v & ~0x000003fc) | 0x000002a8; |
Greg Ungerer | 4fb62ed | 2012-09-14 16:36:08 +1000 | [diff] [blame] | 72 | writel(v, MCFSIM_PDCNT); |
Greg Ungerer | 84e6def | 2008-02-01 17:34:32 +1000 | [diff] [blame] | 73 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 74 | |
| 75 | /***************************************************************************/ |
| 76 | |
Greg Ungerer | 05728ae | 2009-04-30 23:32:52 +1000 | [diff] [blame] | 77 | static void m5272_cpu_reset(void) |
| 78 | { |
| 79 | local_irq_disable(); |
| 80 | /* Set watchdog to reset, and enabled */ |
Greg Ungerer | 660b73e | 2012-07-15 22:01:08 +1000 | [diff] [blame] | 81 | __raw_writew(0, MCFSIM_WIRR); |
| 82 | __raw_writew(1, MCFSIM_WRRR); |
| 83 | __raw_writew(0, MCFSIM_WCR); |
Greg Ungerer | 05728ae | 2009-04-30 23:32:52 +1000 | [diff] [blame] | 84 | for (;;) |
| 85 | /* wait for watchdog to timeout */; |
| 86 | } |
| 87 | |
| 88 | /***************************************************************************/ |
| 89 | |
Greg Ungerer | 84e6def | 2008-02-01 17:34:32 +1000 | [diff] [blame] | 90 | void __init config_BSP(char *commandp, int size) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 91 | { |
Greg Ungerer | a796266 | 2005-09-09 09:32:14 +1000 | [diff] [blame] | 92 | #if defined (CONFIG_MOD5272) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 93 | /* Set base of device vectors to be 64 */ |
Greg Ungerer | d72a5ab | 2012-09-14 16:25:12 +1000 | [diff] [blame] | 94 | writeb(0x40, MCFSIM_PIVR); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 95 | #endif |
| 96 | |
Greg Ungerer | bc72450 | 2007-07-25 22:07:20 +1000 | [diff] [blame] | 97 | #if defined(CONFIG_NETtel) || defined(CONFIG_SCALES) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 98 | /* Copy command line from FLASH to local buffer... */ |
| 99 | memcpy(commandp, (char *) 0xf0004000, size); |
| 100 | commandp[size-1] = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 101 | #elif defined(CONFIG_CANCam) |
| 102 | /* Copy command line from FLASH to local buffer... */ |
| 103 | memcpy(commandp, (char *) 0xf0010000, size); |
| 104 | commandp[size-1] = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 105 | #endif |
| 106 | |
Greg Ungerer | 05728ae | 2009-04-30 23:32:52 +1000 | [diff] [blame] | 107 | mach_reset = m5272_cpu_reset; |
Greg Ungerer | 35aefb2 | 2012-01-23 15:34:58 +1000 | [diff] [blame] | 108 | mach_sched_init = hw_timer_init; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 109 | } |
| 110 | |
| 111 | /***************************************************************************/ |
Greg Ungerer | 84e6def | 2008-02-01 17:34:32 +1000 | [diff] [blame] | 112 | |
Greg Ungerer | 41a2159 | 2010-10-12 12:24:49 +1000 | [diff] [blame] | 113 | /* |
| 114 | * Some 5272 based boards have the FEC ethernet diectly connected to |
| 115 | * an ethernet switch. In this case we need to use the fixed phy type, |
| 116 | * and we need to declare it early in boot. |
| 117 | */ |
| 118 | static struct fixed_phy_status nettel_fixed_phy_status __initdata = { |
| 119 | .link = 1, |
| 120 | .speed = 100, |
| 121 | .duplex = 0, |
| 122 | }; |
| 123 | |
| 124 | /***************************************************************************/ |
| 125 | |
Greg Ungerer | 84e6def | 2008-02-01 17:34:32 +1000 | [diff] [blame] | 126 | static int __init init_BSP(void) |
| 127 | { |
| 128 | m5272_uarts_init(); |
Greg Ungerer | 41a2159 | 2010-10-12 12:24:49 +1000 | [diff] [blame] | 129 | fixed_phy_add(PHY_POLL, 0, &nettel_fixed_phy_status); |
Greg Ungerer | 84e6def | 2008-02-01 17:34:32 +1000 | [diff] [blame] | 130 | return 0; |
| 131 | } |
| 132 | |
| 133 | arch_initcall(init_BSP); |
| 134 | |
| 135 | /***************************************************************************/ |