blob: 782e620460b194835615e2f4c0700929c7db459e [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);
Steven King74859522014-05-14 10:06:29 -070036DEFINE_CLK(mcfqspi0, "mcfqspi.0", MCF_BUSCLK);
Greg Ungerera3d8eb02012-07-13 16:03:52 +100037DEFINE_CLK(fec0, "fec.0", MCF_BUSCLK);
38DEFINE_CLK(fec1, "fec.1", MCF_BUSCLK);
39
40struct 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 King74859522014-05-14 10:06:29 -070050 &clk_mcfqspi0,
Greg Ungerera3d8eb02012-07-13 16:03:52 +100051 &clk_fec0,
52 &clk_fec1,
53 NULL
54};
Linus Torvalds1da177e2005-04-16 15:20:36 -070055
56/***************************************************************************/
57
Steven King83ca6002012-05-06 12:22:53 -070058#if IS_ENABLED(CONFIG_SPI_COLDFIRE_QSPI)
Steven King91d60412010-01-22 12:43:03 -080059
60static void __init m527x_qspi_init(void)
61{
62#if defined(CONFIG_M5271)
63 u16 par;
64
65 /* setup QSPS pins for QSPI with gpio CS control */
66 writeb(0x1f, MCFGPIO_PAR_QSPI);
67 /* and CS2 & CS3 as gpio */
68 par = readw(MCFGPIO_PAR_TIMER);
69 par &= 0x3f3f;
70 writew(par, MCFGPIO_PAR_TIMER);
71#elif defined(CONFIG_M5275)
72 /* setup QSPS pins for QSPI with gpio CS control */
73 writew(0x003e, MCFGPIO_PAR_QSPI);
74#endif
75}
Steven King91d60412010-01-22 12:43:03 -080076
Steven King83ca6002012-05-06 12:22:53 -070077#endif /* IS_ENABLED(CONFIG_SPI_COLDFIRE_QSPI) */
Greg Ungerere206da02008-02-01 17:34:40 +100078
79/***************************************************************************/
80
Greg Ungerer1eb13912011-12-24 00:59:03 +100081static void __init m527x_uarts_init(void)
Greg Ungerere206da02008-02-01 17:34:40 +100082{
83 u16 sepmask;
Greg Ungerere206da02008-02-01 17:34:40 +100084
Greg Ungerere206da02008-02-01 17:34:40 +100085 /*
86 * External Pin Mask Setting & Enable External Pin for Interface
87 */
Greg Ungererf821e342012-09-17 12:07:21 +100088 sepmask = readw(MCFGPIO_PAR_UART);
Greg Ungerer1eb13912011-12-24 00:59:03 +100089 sepmask |= UART0_ENABLE_MASK | UART1_ENABLE_MASK | UART2_ENABLE_MASK;
Greg Ungererf821e342012-09-17 12:07:21 +100090 writew(sepmask, MCFGPIO_PAR_UART);
Greg Ungerere206da02008-02-01 17:34:40 +100091}
92
Linus Torvalds1da177e2005-04-16 15:20:36 -070093/***************************************************************************/
94
Greg Ungererffba3f42009-02-26 22:40:38 -080095static void __init m527x_fec_init(void)
96{
97 u16 par;
98 u8 v;
99
Greg Ungererffba3f42009-02-26 22:40:38 -0800100 /* Set multi-function pins to ethernet mode for fec0 */
Richard Retanubun592578a2009-04-08 11:51:27 +1000101#if defined(CONFIG_M5271)
Greg Ungererf821e342012-09-17 12:07:21 +1000102 v = readb(MCFGPIO_PAR_FECI2C);
103 writeb(v | 0xf0, MCFGPIO_PAR_FECI2C);
Richard Retanubun592578a2009-04-08 11:51:27 +1000104#else
Greg Ungererf821e342012-09-17 12:07:21 +1000105 par = readw(MCFGPIO_PAR_FECI2C);
106 writew(par | 0xf00, MCFGPIO_PAR_FECI2C);
107 v = readb(MCFGPIO_PAR_FEC0HL);
108 writeb(v | 0xc0, MCFGPIO_PAR_FEC0HL);
Greg Ungererffba3f42009-02-26 22:40:38 -0800109
Greg Ungererffba3f42009-02-26 22:40:38 -0800110 /* Set multi-function pins to ethernet mode for fec1 */
Greg Ungererf821e342012-09-17 12:07:21 +1000111 par = readw(MCFGPIO_PAR_FECI2C);
112 writew(par | 0xa0, MCFGPIO_PAR_FECI2C);
113 v = readb(MCFGPIO_PAR_FEC1HL);
114 writeb(v | 0xc0, MCFGPIO_PAR_FEC1HL);
Greg Ungererffba3f42009-02-26 22:40:38 -0800115#endif
116}
117
118/***************************************************************************/
119
Greg Ungerere206da02008-02-01 17:34:40 +1000120void __init config_BSP(char *commandp, int size)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700121{
Greg Ungerer35aefb22012-01-23 15:34:58 +1000122 mach_sched_init = hw_timer_init;
Greg Ungererffba3f42009-02-26 22:40:38 -0800123 m527x_uarts_init();
124 m527x_fec_init();
Steven King83ca6002012-05-06 12:22:53 -0700125#if IS_ENABLED(CONFIG_SPI_COLDFIRE_QSPI)
Steven King91d60412010-01-22 12:43:03 -0800126 m527x_qspi_init();
127#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700128}
129
130/***************************************************************************/