1
2
3
4
5
6
7
8
9
10
11
12
13
14#include <linux/kernel.h>
15#include <linux/param.h>
16#include <linux/init.h>
17#include <linux/io.h>
18#include <asm/machdep.h>
19#include <asm/coldfire.h>
20#include <asm/mcfsim.h>
21#include <asm/mcfuart.h>
22#include <asm/mcfclk.h>
23
24
25
26DEFINE_CLK(0, "flexbus", 2, MCF_CLK);
27DEFINE_CLK(0, "fec.0", 12, MCF_CLK);
28DEFINE_CLK(0, "edma", 17, MCF_CLK);
29DEFINE_CLK(0, "intc.0", 18, MCF_CLK);
30DEFINE_CLK(0, "iack.0", 21, MCF_CLK);
31DEFINE_CLK(0, "mcfi2c.0", 22, MCF_CLK);
32DEFINE_CLK(0, "mcfqspi.0", 23, MCF_CLK);
33DEFINE_CLK(0, "mcfuart.0", 24, MCF_BUSCLK);
34DEFINE_CLK(0, "mcfuart.1", 25, MCF_BUSCLK);
35DEFINE_CLK(0, "mcfuart.2", 26, MCF_BUSCLK);
36DEFINE_CLK(0, "mcftmr.0", 28, MCF_CLK);
37DEFINE_CLK(0, "mcftmr.1", 29, MCF_CLK);
38DEFINE_CLK(0, "mcftmr.2", 30, MCF_CLK);
39DEFINE_CLK(0, "mcftmr.3", 31, MCF_CLK);
40
41DEFINE_CLK(0, "mcfpit.0", 32, MCF_CLK);
42DEFINE_CLK(0, "mcfpit.1", 33, MCF_CLK);
43DEFINE_CLK(0, "mcfeport.0", 34, MCF_CLK);
44DEFINE_CLK(0, "mcfwdt.0", 35, MCF_CLK);
45DEFINE_CLK(0, "pll.0", 36, MCF_CLK);
46DEFINE_CLK(0, "sys.0", 40, MCF_BUSCLK);
47DEFINE_CLK(0, "gpio.0", 41, MCF_BUSCLK);
48DEFINE_CLK(0, "sdram.0", 42, MCF_CLK);
49
50struct clk *mcf_clks[] = {
51 &__clk_0_2,
52 &__clk_0_12,
53 &__clk_0_17,
54 &__clk_0_18,
55 &__clk_0_21,
56 &__clk_0_22,
57 &__clk_0_23,
58 &__clk_0_24,
59 &__clk_0_25,
60 &__clk_0_26,
61 &__clk_0_28,
62 &__clk_0_29,
63 &__clk_0_30,
64 &__clk_0_31,
65
66 &__clk_0_32,
67 &__clk_0_33,
68 &__clk_0_34,
69 &__clk_0_35,
70 &__clk_0_36,
71 &__clk_0_40,
72 &__clk_0_41,
73 &__clk_0_42,
74NULL,
75};
76
77static struct clk * const enable_clks[] __initconst = {
78 &__clk_0_2,
79 &__clk_0_18,
80 &__clk_0_21,
81 &__clk_0_24,
82 &__clk_0_25,
83 &__clk_0_26,
84
85 &__clk_0_32,
86 &__clk_0_33,
87 &__clk_0_34,
88 &__clk_0_36,
89 &__clk_0_40,
90 &__clk_0_41,
91 &__clk_0_42,
92};
93
94static struct clk * const disable_clks[] __initconst = {
95 &__clk_0_12,
96 &__clk_0_17,
97 &__clk_0_22,
98 &__clk_0_23,
99 &__clk_0_28,
100 &__clk_0_29,
101 &__clk_0_30,
102 &__clk_0_31,
103 &__clk_0_35,
104};
105
106
107static void __init m520x_clk_init(void)
108{
109 unsigned i;
110
111
112 for (i = 0; i < ARRAY_SIZE(enable_clks); ++i)
113 __clk_init_enabled(enable_clks[i]);
114
115 for (i = 0; i < ARRAY_SIZE(disable_clks); ++i)
116 __clk_init_disabled(disable_clks[i]);
117}
118
119
120
121#if IS_ENABLED(CONFIG_SPI_COLDFIRE_QSPI)
122
123static void __init m520x_qspi_init(void)
124{
125 u16 par;
126
127 writeb(0x3f, MCF_GPIO_PAR_QSPI);
128
129 par = readw(MCF_GPIO_PAR_UART);
130 par &= 0x00ff;
131 writew(par, MCF_GPIO_PAR_UART);
132}
133
134#endif
135
136
137
138static void __init m520x_uarts_init(void)
139{
140 u16 par;
141 u8 par2;
142
143
144 par = readw(MCF_GPIO_PAR_UART);
145 par |= MCF_GPIO_PAR_UART_PAR_UTXD0 | MCF_GPIO_PAR_UART_PAR_URXD0;
146 par |= MCF_GPIO_PAR_UART_PAR_UTXD1 | MCF_GPIO_PAR_UART_PAR_URXD1;
147 writew(par, MCF_GPIO_PAR_UART);
148
149
150 par2 = readb(MCF_GPIO_PAR_FECI2C);
151 par2 &= ~0x0F;
152 par2 |= MCF_GPIO_PAR_FECI2C_PAR_SCL_UTXD2 |
153 MCF_GPIO_PAR_FECI2C_PAR_SDA_URXD2;
154 writeb(par2, MCF_GPIO_PAR_FECI2C);
155}
156
157
158
159static void __init m520x_fec_init(void)
160{
161 u8 v;
162
163
164 v = readb(MCF_GPIO_PAR_FEC);
165 writeb(v | 0xf0, MCF_GPIO_PAR_FEC);
166
167 v = readb(MCF_GPIO_PAR_FECI2C);
168 writeb(v | 0x0f, MCF_GPIO_PAR_FECI2C);
169}
170
171
172
173void __init config_BSP(char *commandp, int size)
174{
175 mach_sched_init = hw_timer_init;
176 m520x_clk_init();
177 m520x_uarts_init();
178 m520x_fec_init();
179#if IS_ENABLED(CONFIG_SPI_COLDFIRE_QSPI)
180 m520x_qspi_init();
181#endif
182}
183
184
185