blob: 6fbfe9096c3ef5ae85c3896330e00e6fb05ef1e1 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/***************************************************************************/
2
3/*
4 * linux/arch/m68knommu/platform/527x/config.c
5 *
Lucas De Marchi25985ed2011-03-30 22:57:33 -03006 * Sub-architcture dependent initialization code for the Freescale
Linus Torvalds1da177e2005-04-16 15:20:36 -07007 * 5270/5271 CPUs.
8 *
9 * Copyright (C) 1999-2004, Greg Ungerer (gerg@snapgear.com)
10 * Copyright (C) 2001-2004, SnapGear Inc. (www.snapgear.com)
11 */
12
13/***************************************************************************/
14
Linus Torvalds1da177e2005-04-16 15:20:36 -070015#include <linux/kernel.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070016#include <linux/param.h>
17#include <linux/init.h>
Greg Ungerere206da02008-02-01 17:34:40 +100018#include <linux/io.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070019#include <asm/machdep.h>
20#include <asm/coldfire.h>
21#include <asm/mcfsim.h>
Greg Ungerere206da02008-02-01 17:34:40 +100022#include <asm/mcfuart.h>
Greg Ungerera3d8eb02012-07-13 16:03:52 +100023#include <asm/mcfclk.h>
24
25/***************************************************************************/
26
27DEFINE_CLK(pll, "pll.0", MCF_CLK);
28DEFINE_CLK(sys, "sys.0", MCF_BUSCLK);
29DEFINE_CLK(mcfpit0, "mcfpit.0", MCF_CLK);
30DEFINE_CLK(mcfpit1, "mcfpit.1", MCF_CLK);
31DEFINE_CLK(mcfpit2, "mcfpit.2", MCF_CLK);
32DEFINE_CLK(mcfpit3, "mcfpit.3", MCF_CLK);
33DEFINE_CLK(mcfuart0, "mcfuart.0", MCF_BUSCLK);
34DEFINE_CLK(mcfuart1, "mcfuart.1", MCF_BUSCLK);
35DEFINE_CLK(mcfuart2, "mcfuart.2", MCF_BUSCLK);
36DEFINE_CLK(fec0, "fec.0", MCF_BUSCLK);
37DEFINE_CLK(fec1, "fec.1", MCF_BUSCLK);
38
39struct clk *mcf_clks[] = {
40 &clk_pll,
41 &clk_sys,
42 &clk_mcfpit0,
43 &clk_mcfpit1,
44 &clk_mcfpit2,
45 &clk_mcfpit3,
46 &clk_mcfuart0,
47 &clk_mcfuart1,
48 &clk_mcfuart2,
49 &clk_fec0,
50 &clk_fec1,
51 NULL
52};
Linus Torvalds1da177e2005-04-16 15:20:36 -070053
54/***************************************************************************/
55
Steven King83ca6002012-05-06 12:22:53 -070056#if IS_ENABLED(CONFIG_SPI_COLDFIRE_QSPI)
Steven King91d60412010-01-22 12:43:03 -080057
58static void __init m527x_qspi_init(void)
59{
60#if defined(CONFIG_M5271)
61 u16 par;
62
63 /* setup QSPS pins for QSPI with gpio CS control */
64 writeb(0x1f, MCFGPIO_PAR_QSPI);
65 /* and CS2 & CS3 as gpio */
66 par = readw(MCFGPIO_PAR_TIMER);
67 par &= 0x3f3f;
68 writew(par, MCFGPIO_PAR_TIMER);
69#elif defined(CONFIG_M5275)
70 /* setup QSPS pins for QSPI with gpio CS control */
71 writew(0x003e, MCFGPIO_PAR_QSPI);
72#endif
73}
Steven King91d60412010-01-22 12:43:03 -080074
Steven King83ca6002012-05-06 12:22:53 -070075#endif /* IS_ENABLED(CONFIG_SPI_COLDFIRE_QSPI) */
Greg Ungerere206da02008-02-01 17:34:40 +100076
77/***************************************************************************/
78
Greg Ungerer1eb13912011-12-24 00:59:03 +100079static void __init m527x_uarts_init(void)
Greg Ungerere206da02008-02-01 17:34:40 +100080{
81 u16 sepmask;
Greg Ungerere206da02008-02-01 17:34:40 +100082
Greg Ungerere206da02008-02-01 17:34:40 +100083 /*
84 * External Pin Mask Setting & Enable External Pin for Interface
85 */
Greg Ungererf821e342012-09-17 12:07:21 +100086 sepmask = readw(MCFGPIO_PAR_UART);
Greg Ungerer1eb13912011-12-24 00:59:03 +100087 sepmask |= UART0_ENABLE_MASK | UART1_ENABLE_MASK | UART2_ENABLE_MASK;
Greg Ungererf821e342012-09-17 12:07:21 +100088 writew(sepmask, MCFGPIO_PAR_UART);
Greg Ungerere206da02008-02-01 17:34:40 +100089}
90
Linus Torvalds1da177e2005-04-16 15:20:36 -070091/***************************************************************************/
92
Greg Ungererffba3f42009-02-26 22:40:38 -080093static void __init m527x_fec_init(void)
94{
95 u16 par;
96 u8 v;
97
Greg Ungererffba3f42009-02-26 22:40:38 -080098 /* Set multi-function pins to ethernet mode for fec0 */
Richard Retanubun592578a2009-04-08 11:51:27 +100099#if defined(CONFIG_M5271)
Greg Ungererf821e342012-09-17 12:07:21 +1000100 v = readb(MCFGPIO_PAR_FECI2C);
101 writeb(v | 0xf0, MCFGPIO_PAR_FECI2C);
Richard Retanubun592578a2009-04-08 11:51:27 +1000102#else
Greg Ungererf821e342012-09-17 12:07:21 +1000103 par = readw(MCFGPIO_PAR_FECI2C);
104 writew(par | 0xf00, MCFGPIO_PAR_FECI2C);
105 v = readb(MCFGPIO_PAR_FEC0HL);
106 writeb(v | 0xc0, MCFGPIO_PAR_FEC0HL);
Greg Ungererffba3f42009-02-26 22:40:38 -0800107
Greg Ungererffba3f42009-02-26 22:40:38 -0800108 /* Set multi-function pins to ethernet mode for fec1 */
Greg Ungererf821e342012-09-17 12:07:21 +1000109 par = readw(MCFGPIO_PAR_FECI2C);
110 writew(par | 0xa0, MCFGPIO_PAR_FECI2C);
111 v = readb(MCFGPIO_PAR_FEC1HL);
112 writeb(v | 0xc0, MCFGPIO_PAR_FEC1HL);
Greg Ungererffba3f42009-02-26 22:40:38 -0800113#endif
114}
115
116/***************************************************************************/
117
Greg Ungerere206da02008-02-01 17:34:40 +1000118void __init config_BSP(char *commandp, int size)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700119{
Greg Ungerer35aefb22012-01-23 15:34:58 +1000120 mach_sched_init = hw_timer_init;
Greg Ungererffba3f42009-02-26 22:40:38 -0800121 m527x_uarts_init();
122 m527x_fec_init();
Steven King83ca6002012-05-06 12:22:53 -0700123#if IS_ENABLED(CONFIG_SPI_COLDFIRE_QSPI)
Steven King91d60412010-01-22 12:43:03 -0800124 m527x_qspi_init();
125#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700126}
127
128/***************************************************************************/