blob: 7ad3193887e87b396ab0d369229c32763e4dced0 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001// SPDX-License-Identifier: GPL-2.0
Linus Torvalds1da177e2005-04-16 15:20:36 -07002/***************************************************************************/
3
4/*
Greg Ungererece9ae62014-08-19 11:55:24 +10005 * m528x.c -- platform support for ColdFire 528x based boards
Linus Torvalds1da177e2005-04-16 15:20:36 -07006 *
Lucas De Marchi25985ed2011-03-30 22:57:33 -03007 * Sub-architcture dependent initialization code for the Freescale
Greg Ungerer980f9232009-04-28 14:24:25 +10008 * 5280, 5281 and 5282 CPUs.
Linus Torvalds1da177e2005-04-16 15:20:36 -07009 *
10 * Copyright (C) 1999-2003, Greg Ungerer (gerg@snapgear.com)
11 * Copyright (C) 2001-2003, SnapGear Inc. (www.snapgear.com)
12 */
13
14/***************************************************************************/
15
Linus Torvalds1da177e2005-04-16 15:20:36 -070016#include <linux/kernel.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070017#include <linux/param.h>
18#include <linux/init.h>
Greg Ungerereb49e902008-02-01 17:34:50 +100019#include <linux/platform_device.h>
Greg Ungerereb49e902008-02-01 17:34:50 +100020#include <linux/io.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070021#include <asm/machdep.h>
22#include <asm/coldfire.h>
23#include <asm/mcfsim.h>
Greg Ungerereb49e902008-02-01 17:34:50 +100024#include <asm/mcfuart.h>
Greg Ungerer87f37762012-07-13 16:04:22 +100025#include <asm/mcfclk.h>
26
27/***************************************************************************/
28
29DEFINE_CLK(pll, "pll.0", MCF_CLK);
30DEFINE_CLK(sys, "sys.0", MCF_BUSCLK);
31DEFINE_CLK(mcfpit0, "mcfpit.0", MCF_CLK);
32DEFINE_CLK(mcfpit1, "mcfpit.1", MCF_CLK);
33DEFINE_CLK(mcfpit2, "mcfpit.2", MCF_CLK);
34DEFINE_CLK(mcfpit3, "mcfpit.3", MCF_CLK);
35DEFINE_CLK(mcfuart0, "mcfuart.0", MCF_BUSCLK);
36DEFINE_CLK(mcfuart1, "mcfuart.1", MCF_BUSCLK);
37DEFINE_CLK(mcfuart2, "mcfuart.2", MCF_BUSCLK);
Steven King74859522014-05-14 10:06:29 -070038DEFINE_CLK(mcfqspi0, "mcfqspi.0", MCF_BUSCLK);
Greg Ungerer87f37762012-07-13 16:04:22 +100039DEFINE_CLK(fec0, "fec.0", MCF_BUSCLK);
Steven King2d24b532014-06-30 09:53:19 -070040DEFINE_CLK(mcfi2c0, "imx1-i2c.0", MCF_BUSCLK);
Greg Ungerer87f37762012-07-13 16:04:22 +100041
42struct clk *mcf_clks[] = {
43 &clk_pll,
44 &clk_sys,
45 &clk_mcfpit0,
46 &clk_mcfpit1,
47 &clk_mcfpit2,
48 &clk_mcfpit3,
49 &clk_mcfuart0,
50 &clk_mcfuart1,
51 &clk_mcfuart2,
Steven King74859522014-05-14 10:06:29 -070052 &clk_mcfqspi0,
Greg Ungerer87f37762012-07-13 16:04:22 +100053 &clk_fec0,
Steven King2d24b532014-06-30 09:53:19 -070054 &clk_mcfi2c0,
Greg Ungerer87f37762012-07-13 16:04:22 +100055 NULL
56};
Linus Torvalds1da177e2005-04-16 15:20:36 -070057
58/***************************************************************************/
59
Steven King91d60412010-01-22 12:43:03 -080060static void __init m528x_qspi_init(void)
61{
Steven King151d14f2014-05-14 10:07:55 -070062#if IS_ENABLED(CONFIG_SPI_COLDFIRE_QSPI)
Steven King91d60412010-01-22 12:43:03 -080063 /* setup Port QS for QSPI with gpio CS control */
64 __raw_writeb(0x07, MCFGPIO_PQSPAR);
Steven King83ca6002012-05-06 12:22:53 -070065#endif /* IS_ENABLED(CONFIG_SPI_COLDFIRE_QSPI) */
Steven King151d14f2014-05-14 10:07:55 -070066}
Greg Ungerereb49e902008-02-01 17:34:50 +100067
68/***************************************************************************/
69
Steven King2d24b532014-06-30 09:53:19 -070070static void __init m528x_i2c_init(void)
71{
72#if IS_ENABLED(CONFIG_I2C_IMX)
73 u16 paspar;
74
75 /* setup Port AS Pin Assignment Register for I2C */
76 /* set PASPA0 to SCL and PASPA1 to SDA */
77 paspar = readw(MCFGPIO_PASPAR);
78 paspar |= 0xF;
79 writew(paspar, MCFGPIO_PASPAR);
80#endif /* IS_ENABLED(CONFIG_I2C_IMX) */
81}
82
83/***************************************************************************/
84
Greg Ungerercae82a82011-12-24 01:00:48 +100085static void __init m528x_uarts_init(void)
Greg Ungerereb49e902008-02-01 17:34:50 +100086{
87 u8 port;
Greg Ungerereb49e902008-02-01 17:34:50 +100088
Greg Ungerereb49e902008-02-01 17:34:50 +100089 /* make sure PUAPAR is set for UART0 and UART1 */
Greg Ungerer0371a1c2013-03-04 11:51:45 +100090 port = readb(MCFGPIO_PUAPAR);
Greg Ungerercae82a82011-12-24 01:00:48 +100091 port |= 0x03 | (0x03 << 2);
Steven Kingeac57942012-05-21 13:10:19 -070092 writeb(port, MCFGPIO_PUAPAR);
Greg Ungerereb49e902008-02-01 17:34:50 +100093}
Linus Torvalds1da177e2005-04-16 15:20:36 -070094
95/***************************************************************************/
96
Greg Ungererffba3f42009-02-26 22:40:38 -080097static void __init m528x_fec_init(void)
98{
Greg Ungererffba3f42009-02-26 22:40:38 -080099 u16 v16;
100
Greg Ungererffba3f42009-02-26 22:40:38 -0800101 /* Set multi-function pins to ethernet mode for fec0 */
Greg Ungerera91f741582012-09-17 12:20:20 +1000102 v16 = readw(MCFGPIO_PASPAR);
103 writew(v16 | 0xf00, MCFGPIO_PASPAR);
104 writeb(0xc0, MCFGPIO_PEHLPAR);
Greg Ungererffba3f42009-02-26 22:40:38 -0800105}
106
107/***************************************************************************/
108
Steve Bennett188a9a42008-05-01 12:17:08 +1000109#ifdef CONFIG_WILDFIRE
110void wildfire_halt(void)
111{
112 writeb(0, 0x30000007);
113 writeb(0x2, 0x30000007);
114}
115#endif
116
117#ifdef CONFIG_WILDFIREMOD
118void wildfiremod_halt(void)
119{
120 printk(KERN_INFO "WildFireMod hibernating...\n");
121
122 /* Set portE.5 to Digital IO */
Greg Ungerer41b39ea2016-08-23 21:27:16 +1000123 writew(readw(MCFGPIO_PEPAR) & ~(1 << (5 * 2)), MCFGPIO_PEPAR);
Steve Bennett188a9a42008-05-01 12:17:08 +1000124
125 /* Make portE.5 an output */
Greg Ungerer41b39ea2016-08-23 21:27:16 +1000126 writeb(readb(MCFGPIO_PDDR_E) | (1 << 5), MCFGPIO_PDDR_E);
Steve Bennett188a9a42008-05-01 12:17:08 +1000127
128 /* Now toggle portE.5 from low to high */
Greg Ungerer41b39ea2016-08-23 21:27:16 +1000129 writeb(readb(MCFGPIO_PODR_E) & ~(1 << 5), MCFGPIO_PODR_E);
130 writeb(readb(MCFGPIO_PODR_E) | (1 << 5), MCFGPIO_PODR_E);
Steve Bennett188a9a42008-05-01 12:17:08 +1000131
132 printk(KERN_EMERG "Failed to hibernate. Halting!\n");
133}
134#endif
135
Greg Ungerereb49e902008-02-01 17:34:50 +1000136void __init config_BSP(char *commandp, int size)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700137{
Steve Bennett188a9a42008-05-01 12:17:08 +1000138#ifdef CONFIG_WILDFIRE
139 mach_halt = wildfire_halt;
140#endif
141#ifdef CONFIG_WILDFIREMOD
142 mach_halt = wildfiremod_halt;
143#endif
Greg Ungerer35aefb22012-01-23 15:34:58 +1000144 mach_sched_init = hw_timer_init;
Greg Ungerereb49e902008-02-01 17:34:50 +1000145 m528x_uarts_init();
Greg Ungererffba3f42009-02-26 22:40:38 -0800146 m528x_fec_init();
Steven King91d60412010-01-22 12:43:03 -0800147 m528x_qspi_init();
Steven King2d24b532014-06-30 09:53:19 -0700148 m528x_i2c_init();
Greg Ungerereb49e902008-02-01 17:34:50 +1000149}
150
Greg Ungerereb49e902008-02-01 17:34:50 +1000151/***************************************************************************/