1 /*
2 * arch/arm/mach-loki/common.c
3 *
4 * Core functions for Marvell Loki (88RC8480) SoCs
5 *
6 * This file is licensed under the terms of the GNU General Public
7 * License version 2. This program is licensed "as is" without any
8 * warranty of any kind, whether express or implied.
9 */
10
11 #include <linux/kernel.h>
12 #include <linux/init.h>
13 #include <linux/platform_device.h>
14 #include <linux/serial_8250.h>
15 #include <linux/mbus.h>
16 #include <linux/mv643xx_eth.h>
17 #include <asm/page.h>
18 #include <asm/timex.h>
19 #include <asm/mach/map.h>
20 #include <asm/mach/time.h>
21 #include <mach/bridge-regs.h>
22 #include <mach/loki.h>
23 #include <plat/orion_nand.h>
24 #include <plat/time.h>
25 #include "common.h"
26
27 /*****************************************************************************
28 * I/O Address Mapping
29 ****************************************************************************/
30 static struct map_desc loki_io_desc[] __initdata = {
31 {
32 .virtual = LOKI_REGS_VIRT_BASE,
33 .pfn = __phys_to_pfn(LOKI_REGS_PHYS_BASE),
34 .length = LOKI_REGS_SIZE,
35 .type = MT_DEVICE,
36 },
37 };
38
loki_map_io(void)39 void __init loki_map_io(void)
40 {
41 iotable_init(loki_io_desc, ARRAY_SIZE(loki_io_desc));
42 }
43
44
45 /*****************************************************************************
46 * GE0
47 ****************************************************************************/
48 struct mv643xx_eth_shared_platform_data loki_ge0_shared_data = {
49 .t_clk = LOKI_TCLK,
50 .dram = &loki_mbus_dram_info,
51 };
52
53 static struct resource loki_ge0_shared_resources[] = {
54 {
55 .name = "ge0 base",
56 .start = GE0_PHYS_BASE + 0x2000,
57 .end = GE0_PHYS_BASE + 0x3fff,
58 .flags = IORESOURCE_MEM,
59 },
60 };
61
62 static struct platform_device loki_ge0_shared = {
63 .name = MV643XX_ETH_SHARED_NAME,
64 .id = 0,
65 .dev = {
66 .platform_data = &loki_ge0_shared_data,
67 },
68 .num_resources = 1,
69 .resource = loki_ge0_shared_resources,
70 };
71
72 static struct resource loki_ge0_resources[] = {
73 {
74 .name = "ge0 irq",
75 .start = IRQ_LOKI_GBE_A_INT,
76 .end = IRQ_LOKI_GBE_A_INT,
77 .flags = IORESOURCE_IRQ,
78 },
79 };
80
81 static struct platform_device loki_ge0 = {
82 .name = MV643XX_ETH_NAME,
83 .id = 0,
84 .num_resources = 1,
85 .resource = loki_ge0_resources,
86 .dev = {
87 .coherent_dma_mask = 0xffffffff,
88 },
89 };
90
loki_ge0_init(struct mv643xx_eth_platform_data * eth_data)91 void __init loki_ge0_init(struct mv643xx_eth_platform_data *eth_data)
92 {
93 eth_data->shared = &loki_ge0_shared;
94 loki_ge0.dev.platform_data = eth_data;
95
96 writel(0x00079220, GE0_VIRT_BASE + 0x20b0);
97 platform_device_register(&loki_ge0_shared);
98 platform_device_register(&loki_ge0);
99 }
100
101
102 /*****************************************************************************
103 * GE1
104 ****************************************************************************/
105 struct mv643xx_eth_shared_platform_data loki_ge1_shared_data = {
106 .t_clk = LOKI_TCLK,
107 .dram = &loki_mbus_dram_info,
108 };
109
110 static struct resource loki_ge1_shared_resources[] = {
111 {
112 .name = "ge1 base",
113 .start = GE1_PHYS_BASE + 0x2000,
114 .end = GE1_PHYS_BASE + 0x3fff,
115 .flags = IORESOURCE_MEM,
116 },
117 };
118
119 static struct platform_device loki_ge1_shared = {
120 .name = MV643XX_ETH_SHARED_NAME,
121 .id = 1,
122 .dev = {
123 .platform_data = &loki_ge1_shared_data,
124 },
125 .num_resources = 1,
126 .resource = loki_ge1_shared_resources,
127 };
128
129 static struct resource loki_ge1_resources[] = {
130 {
131 .name = "ge1 irq",
132 .start = IRQ_LOKI_GBE_B_INT,
133 .end = IRQ_LOKI_GBE_B_INT,
134 .flags = IORESOURCE_IRQ,
135 },
136 };
137
138 static struct platform_device loki_ge1 = {
139 .name = MV643XX_ETH_NAME,
140 .id = 1,
141 .num_resources = 1,
142 .resource = loki_ge1_resources,
143 .dev = {
144 .coherent_dma_mask = 0xffffffff,
145 },
146 };
147
loki_ge1_init(struct mv643xx_eth_platform_data * eth_data)148 void __init loki_ge1_init(struct mv643xx_eth_platform_data *eth_data)
149 {
150 eth_data->shared = &loki_ge1_shared;
151 loki_ge1.dev.platform_data = eth_data;
152
153 writel(0x00079220, GE1_VIRT_BASE + 0x20b0);
154 platform_device_register(&loki_ge1_shared);
155 platform_device_register(&loki_ge1);
156 }
157
158
159 /*****************************************************************************
160 * SAS/SATA
161 ****************************************************************************/
162 static struct resource loki_sas_resources[] = {
163 {
164 .name = "mvsas0 mem",
165 .start = SAS0_PHYS_BASE,
166 .end = SAS0_PHYS_BASE + 0x01ff,
167 .flags = IORESOURCE_MEM,
168 }, {
169 .name = "mvsas0 irq",
170 .start = IRQ_LOKI_SAS_A,
171 .end = IRQ_LOKI_SAS_A,
172 .flags = IORESOURCE_IRQ,
173 }, {
174 .name = "mvsas1 mem",
175 .start = SAS1_PHYS_BASE,
176 .end = SAS1_PHYS_BASE + 0x01ff,
177 .flags = IORESOURCE_MEM,
178 }, {
179 .name = "mvsas1 irq",
180 .start = IRQ_LOKI_SAS_B,
181 .end = IRQ_LOKI_SAS_B,
182 .flags = IORESOURCE_IRQ,
183 },
184 };
185
186 static struct platform_device loki_sas = {
187 .name = "mvsas",
188 .id = 0,
189 .dev = {
190 .coherent_dma_mask = 0xffffffff,
191 },
192 .num_resources = ARRAY_SIZE(loki_sas_resources),
193 .resource = loki_sas_resources,
194 };
195
loki_sas_init(void)196 void __init loki_sas_init(void)
197 {
198 writel(0x8300f707, DDR_REG(0x1424));
199 platform_device_register(&loki_sas);
200 }
201
202
203 /*****************************************************************************
204 * UART0
205 ****************************************************************************/
206 static struct plat_serial8250_port loki_uart0_data[] = {
207 {
208 .mapbase = UART0_PHYS_BASE,
209 .membase = (char *)UART0_VIRT_BASE,
210 .irq = IRQ_LOKI_UART0,
211 .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
212 .iotype = UPIO_MEM,
213 .regshift = 2,
214 .uartclk = LOKI_TCLK,
215 }, {
216 },
217 };
218
219 static struct resource loki_uart0_resources[] = {
220 {
221 .start = UART0_PHYS_BASE,
222 .end = UART0_PHYS_BASE + 0xff,
223 .flags = IORESOURCE_MEM,
224 }, {
225 .start = IRQ_LOKI_UART0,
226 .end = IRQ_LOKI_UART0,
227 .flags = IORESOURCE_IRQ,
228 },
229 };
230
231 static struct platform_device loki_uart0 = {
232 .name = "serial8250",
233 .id = 0,
234 .dev = {
235 .platform_data = loki_uart0_data,
236 },
237 .resource = loki_uart0_resources,
238 .num_resources = ARRAY_SIZE(loki_uart0_resources),
239 };
240
loki_uart0_init(void)241 void __init loki_uart0_init(void)
242 {
243 platform_device_register(&loki_uart0);
244 }
245
246
247 /*****************************************************************************
248 * UART1
249 ****************************************************************************/
250 static struct plat_serial8250_port loki_uart1_data[] = {
251 {
252 .mapbase = UART1_PHYS_BASE,
253 .membase = (char *)UART1_VIRT_BASE,
254 .irq = IRQ_LOKI_UART1,
255 .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
256 .iotype = UPIO_MEM,
257 .regshift = 2,
258 .uartclk = LOKI_TCLK,
259 }, {
260 },
261 };
262
263 static struct resource loki_uart1_resources[] = {
264 {
265 .start = UART1_PHYS_BASE,
266 .end = UART1_PHYS_BASE + 0xff,
267 .flags = IORESOURCE_MEM,
268 }, {
269 .start = IRQ_LOKI_UART1,
270 .end = IRQ_LOKI_UART1,
271 .flags = IORESOURCE_IRQ,
272 },
273 };
274
275 static struct platform_device loki_uart1 = {
276 .name = "serial8250",
277 .id = 1,
278 .dev = {
279 .platform_data = loki_uart1_data,
280 },
281 .resource = loki_uart1_resources,
282 .num_resources = ARRAY_SIZE(loki_uart1_resources),
283 };
284
loki_uart1_init(void)285 void __init loki_uart1_init(void)
286 {
287 platform_device_register(&loki_uart1);
288 }
289
290
291 /*****************************************************************************
292 * Time handling
293 ****************************************************************************/
loki_init_early(void)294 void __init loki_init_early(void)
295 {
296 orion_time_set_base(TIMER_VIRT_BASE);
297 }
298
loki_timer_init(void)299 static void loki_timer_init(void)
300 {
301 orion_time_init(BRIDGE_VIRT_BASE, BRIDGE_INT_TIMER1_CLR,
302 IRQ_LOKI_BRIDGE, LOKI_TCLK);
303 }
304
305 struct sys_timer loki_timer = {
306 .init = loki_timer_init,
307 };
308
309
310 /*****************************************************************************
311 * General
312 ****************************************************************************/
loki_init(void)313 void __init loki_init(void)
314 {
315 printk(KERN_INFO "Loki ID: 88RC8480. TCLK=%d.\n", LOKI_TCLK);
316
317 loki_setup_cpu_mbus();
318 }
319