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 | * m528x.c -- platform support for ColdFire 528x based boards |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5 | * |
Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame] | 6 | * Sub-architcture dependent initialization code for the Freescale |
Greg Ungerer | 980f923 | 2009-04-28 14:24:25 +1000 | [diff] [blame] | 7 | * 5280, 5281 and 5282 CPUs. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 8 | * |
| 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 Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 15 | #include <linux/kernel.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 16 | #include <linux/param.h> |
| 17 | #include <linux/init.h> |
Greg Ungerer | eb49e90 | 2008-02-01 17:34:50 +1000 | [diff] [blame] | 18 | #include <linux/platform_device.h> |
Greg Ungerer | eb49e90 | 2008-02-01 17:34:50 +1000 | [diff] [blame] | 19 | #include <linux/io.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 20 | #include <asm/machdep.h> |
| 21 | #include <asm/coldfire.h> |
| 22 | #include <asm/mcfsim.h> |
Greg Ungerer | eb49e90 | 2008-02-01 17:34:50 +1000 | [diff] [blame] | 23 | #include <asm/mcfuart.h> |
Greg Ungerer | 87f3776 | 2012-07-13 16:04:22 +1000 | [diff] [blame] | 24 | #include <asm/mcfclk.h> |
| 25 | |
| 26 | /***************************************************************************/ |
| 27 | |
| 28 | DEFINE_CLK(pll, "pll.0", MCF_CLK); |
| 29 | DEFINE_CLK(sys, "sys.0", MCF_BUSCLK); |
| 30 | DEFINE_CLK(mcfpit0, "mcfpit.0", MCF_CLK); |
| 31 | DEFINE_CLK(mcfpit1, "mcfpit.1", MCF_CLK); |
| 32 | DEFINE_CLK(mcfpit2, "mcfpit.2", MCF_CLK); |
| 33 | DEFINE_CLK(mcfpit3, "mcfpit.3", MCF_CLK); |
| 34 | DEFINE_CLK(mcfuart0, "mcfuart.0", MCF_BUSCLK); |
| 35 | DEFINE_CLK(mcfuart1, "mcfuart.1", MCF_BUSCLK); |
| 36 | DEFINE_CLK(mcfuart2, "mcfuart.2", MCF_BUSCLK); |
Steven King | 7485952 | 2014-05-14 10:06:29 -0700 | [diff] [blame] | 37 | DEFINE_CLK(mcfqspi0, "mcfqspi.0", MCF_BUSCLK); |
Greg Ungerer | 87f3776 | 2012-07-13 16:04:22 +1000 | [diff] [blame] | 38 | DEFINE_CLK(fec0, "fec.0", MCF_BUSCLK); |
| 39 | |
| 40 | struct clk *mcf_clks[] = { |
| 41 | &clk_pll, |
| 42 | &clk_sys, |
| 43 | &clk_mcfpit0, |
| 44 | &clk_mcfpit1, |
| 45 | &clk_mcfpit2, |
| 46 | &clk_mcfpit3, |
| 47 | &clk_mcfuart0, |
| 48 | &clk_mcfuart1, |
| 49 | &clk_mcfuart2, |
Steven King | 7485952 | 2014-05-14 10:06:29 -0700 | [diff] [blame] | 50 | &clk_mcfqspi0, |
Greg Ungerer | 87f3776 | 2012-07-13 16:04:22 +1000 | [diff] [blame] | 51 | &clk_fec0, |
| 52 | NULL |
| 53 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 54 | |
| 55 | /***************************************************************************/ |
| 56 | |
Steven King | 91d6041 | 2010-01-22 12:43:03 -0800 | [diff] [blame] | 57 | static void __init m528x_qspi_init(void) |
| 58 | { |
Steven King | 151d14f | 2014-05-14 10:07:55 -0700 | [diff] [blame] | 59 | #if IS_ENABLED(CONFIG_SPI_COLDFIRE_QSPI) |
Steven King | 91d6041 | 2010-01-22 12:43:03 -0800 | [diff] [blame] | 60 | /* setup Port QS for QSPI with gpio CS control */ |
| 61 | __raw_writeb(0x07, MCFGPIO_PQSPAR); |
Steven King | 83ca600 | 2012-05-06 12:22:53 -0700 | [diff] [blame] | 62 | #endif /* IS_ENABLED(CONFIG_SPI_COLDFIRE_QSPI) */ |
Steven King | 151d14f | 2014-05-14 10:07:55 -0700 | [diff] [blame] | 63 | } |
Greg Ungerer | eb49e90 | 2008-02-01 17:34:50 +1000 | [diff] [blame] | 64 | |
| 65 | /***************************************************************************/ |
| 66 | |
Greg Ungerer | cae82a8 | 2011-12-24 01:00:48 +1000 | [diff] [blame] | 67 | static void __init m528x_uarts_init(void) |
Greg Ungerer | eb49e90 | 2008-02-01 17:34:50 +1000 | [diff] [blame] | 68 | { |
| 69 | u8 port; |
Greg Ungerer | eb49e90 | 2008-02-01 17:34:50 +1000 | [diff] [blame] | 70 | |
Greg Ungerer | eb49e90 | 2008-02-01 17:34:50 +1000 | [diff] [blame] | 71 | /* make sure PUAPAR is set for UART0 and UART1 */ |
Greg Ungerer | 0371a1c | 2013-03-04 11:51:45 +1000 | [diff] [blame] | 72 | port = readb(MCFGPIO_PUAPAR); |
Greg Ungerer | cae82a8 | 2011-12-24 01:00:48 +1000 | [diff] [blame] | 73 | port |= 0x03 | (0x03 << 2); |
Steven King | eac5794 | 2012-05-21 13:10:19 -0700 | [diff] [blame] | 74 | writeb(port, MCFGPIO_PUAPAR); |
Greg Ungerer | eb49e90 | 2008-02-01 17:34:50 +1000 | [diff] [blame] | 75 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 76 | |
| 77 | /***************************************************************************/ |
| 78 | |
Greg Ungerer | ffba3f4 | 2009-02-26 22:40:38 -0800 | [diff] [blame] | 79 | static void __init m528x_fec_init(void) |
| 80 | { |
Greg Ungerer | ffba3f4 | 2009-02-26 22:40:38 -0800 | [diff] [blame] | 81 | u16 v16; |
| 82 | |
Greg Ungerer | ffba3f4 | 2009-02-26 22:40:38 -0800 | [diff] [blame] | 83 | /* Set multi-function pins to ethernet mode for fec0 */ |
Greg Ungerer | a91f741 | 2012-09-17 12:20:20 +1000 | [diff] [blame] | 84 | v16 = readw(MCFGPIO_PASPAR); |
| 85 | writew(v16 | 0xf00, MCFGPIO_PASPAR); |
| 86 | writeb(0xc0, MCFGPIO_PEHLPAR); |
Greg Ungerer | ffba3f4 | 2009-02-26 22:40:38 -0800 | [diff] [blame] | 87 | } |
| 88 | |
| 89 | /***************************************************************************/ |
| 90 | |
Steve Bennett | 188a9a4 | 2008-05-01 12:17:08 +1000 | [diff] [blame] | 91 | #ifdef CONFIG_WILDFIRE |
| 92 | void wildfire_halt(void) |
| 93 | { |
| 94 | writeb(0, 0x30000007); |
| 95 | writeb(0x2, 0x30000007); |
| 96 | } |
| 97 | #endif |
| 98 | |
| 99 | #ifdef CONFIG_WILDFIREMOD |
| 100 | void wildfiremod_halt(void) |
| 101 | { |
| 102 | printk(KERN_INFO "WildFireMod hibernating...\n"); |
| 103 | |
| 104 | /* Set portE.5 to Digital IO */ |
| 105 | MCF5282_GPIO_PEPAR &= ~(1 << (5 * 2)); |
| 106 | |
| 107 | /* Make portE.5 an output */ |
| 108 | MCF5282_GPIO_DDRE |= (1 << 5); |
| 109 | |
| 110 | /* Now toggle portE.5 from low to high */ |
| 111 | MCF5282_GPIO_PORTE &= ~(1 << 5); |
| 112 | MCF5282_GPIO_PORTE |= (1 << 5); |
| 113 | |
| 114 | printk(KERN_EMERG "Failed to hibernate. Halting!\n"); |
| 115 | } |
| 116 | #endif |
| 117 | |
Greg Ungerer | eb49e90 | 2008-02-01 17:34:50 +1000 | [diff] [blame] | 118 | void __init config_BSP(char *commandp, int size) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 119 | { |
Steve Bennett | 188a9a4 | 2008-05-01 12:17:08 +1000 | [diff] [blame] | 120 | #ifdef CONFIG_WILDFIRE |
| 121 | mach_halt = wildfire_halt; |
| 122 | #endif |
| 123 | #ifdef CONFIG_WILDFIREMOD |
| 124 | mach_halt = wildfiremod_halt; |
| 125 | #endif |
Greg Ungerer | 35aefb2 | 2012-01-23 15:34:58 +1000 | [diff] [blame] | 126 | mach_sched_init = hw_timer_init; |
Greg Ungerer | eb49e90 | 2008-02-01 17:34:50 +1000 | [diff] [blame] | 127 | m528x_uarts_init(); |
Greg Ungerer | ffba3f4 | 2009-02-26 22:40:38 -0800 | [diff] [blame] | 128 | m528x_fec_init(); |
Steven King | 91d6041 | 2010-01-22 12:43:03 -0800 | [diff] [blame] | 129 | m528x_qspi_init(); |
Greg Ungerer | eb49e90 | 2008-02-01 17:34:50 +1000 | [diff] [blame] | 130 | } |
| 131 | |
Greg Ungerer | eb49e90 | 2008-02-01 17:34:50 +1000 | [diff] [blame] | 132 | /***************************************************************************/ |