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