blob: 4ff4c62c3c023fafce9c9e9779d7f0cab6082353 [file] [log] [blame]
Lennert Buytenhek777f9be2008-06-22 22:45:02 +02001/*
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>
Andrew Lunn5c602552011-05-15 13:32:40 +020017#include <linux/dma-mapping.h>
Lennert Buytenhek777f9be2008-06-22 22:45:02 +020018#include <asm/page.h>
19#include <asm/timex.h>
20#include <asm/mach/map.h>
21#include <asm/mach/time.h>
Lennert Buytenhek4ee1f6b2010-10-15 16:50:26 +020022#include <mach/bridge-regs.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010023#include <mach/loki.h>
Lennert Buytenhek6f088f12008-08-09 13:44:58 +020024#include <plat/orion_nand.h>
25#include <plat/time.h>
Lennert Buytenhek777f9be2008-06-22 22:45:02 +020026#include "common.h"
27
28/*****************************************************************************
29 * I/O Address Mapping
30 ****************************************************************************/
31static struct map_desc loki_io_desc[] __initdata = {
32 {
33 .virtual = LOKI_REGS_VIRT_BASE,
34 .pfn = __phys_to_pfn(LOKI_REGS_PHYS_BASE),
35 .length = LOKI_REGS_SIZE,
36 .type = MT_DEVICE,
37 },
38};
39
40void __init loki_map_io(void)
41{
42 iotable_init(loki_io_desc, ARRAY_SIZE(loki_io_desc));
43}
44
45
46/*****************************************************************************
47 * GE0
48 ****************************************************************************/
49struct mv643xx_eth_shared_platform_data loki_ge0_shared_data = {
50 .t_clk = LOKI_TCLK,
51 .dram = &loki_mbus_dram_info,
52};
53
54static struct resource loki_ge0_shared_resources[] = {
55 {
56 .name = "ge0 base",
57 .start = GE0_PHYS_BASE + 0x2000,
Andrew Lunn5c602552011-05-15 13:32:40 +020058 .end = GE0_PHYS_BASE + SZ_16K - 1,
Lennert Buytenhek777f9be2008-06-22 22:45:02 +020059 .flags = IORESOURCE_MEM,
60 },
61};
62
63static struct platform_device loki_ge0_shared = {
64 .name = MV643XX_ETH_SHARED_NAME,
65 .id = 0,
66 .dev = {
67 .platform_data = &loki_ge0_shared_data,
68 },
69 .num_resources = 1,
70 .resource = loki_ge0_shared_resources,
71};
72
73static struct resource loki_ge0_resources[] = {
74 {
75 .name = "ge0 irq",
76 .start = IRQ_LOKI_GBE_A_INT,
77 .end = IRQ_LOKI_GBE_A_INT,
78 .flags = IORESOURCE_IRQ,
79 },
80};
81
82static struct platform_device loki_ge0 = {
83 .name = MV643XX_ETH_NAME,
84 .id = 0,
85 .num_resources = 1,
86 .resource = loki_ge0_resources,
Nicolas Pitrea49a0182009-05-22 16:53:40 -040087 .dev = {
Andrew Lunn5c602552011-05-15 13:32:40 +020088 .coherent_dma_mask = DMA_BIT_MASK(32),
Nicolas Pitrea49a0182009-05-22 16:53:40 -040089 },
Lennert Buytenhek777f9be2008-06-22 22:45:02 +020090};
91
92void __init loki_ge0_init(struct mv643xx_eth_platform_data *eth_data)
93{
94 eth_data->shared = &loki_ge0_shared;
95 loki_ge0.dev.platform_data = eth_data;
96
97 writel(0x00079220, GE0_VIRT_BASE + 0x20b0);
98 platform_device_register(&loki_ge0_shared);
99 platform_device_register(&loki_ge0);
100}
101
102
103/*****************************************************************************
104 * GE1
105 ****************************************************************************/
106struct mv643xx_eth_shared_platform_data loki_ge1_shared_data = {
107 .t_clk = LOKI_TCLK,
108 .dram = &loki_mbus_dram_info,
109};
110
111static struct resource loki_ge1_shared_resources[] = {
112 {
113 .name = "ge1 base",
114 .start = GE1_PHYS_BASE + 0x2000,
Andrew Lunn5c602552011-05-15 13:32:40 +0200115 .end = GE1_PHYS_BASE + SZ_16K - 1,
Lennert Buytenhek777f9be2008-06-22 22:45:02 +0200116 .flags = IORESOURCE_MEM,
117 },
118};
119
120static struct platform_device loki_ge1_shared = {
121 .name = MV643XX_ETH_SHARED_NAME,
122 .id = 1,
123 .dev = {
124 .platform_data = &loki_ge1_shared_data,
125 },
126 .num_resources = 1,
127 .resource = loki_ge1_shared_resources,
128};
129
130static struct resource loki_ge1_resources[] = {
131 {
132 .name = "ge1 irq",
133 .start = IRQ_LOKI_GBE_B_INT,
134 .end = IRQ_LOKI_GBE_B_INT,
135 .flags = IORESOURCE_IRQ,
136 },
137};
138
139static struct platform_device loki_ge1 = {
140 .name = MV643XX_ETH_NAME,
141 .id = 1,
142 .num_resources = 1,
143 .resource = loki_ge1_resources,
Nicolas Pitrea49a0182009-05-22 16:53:40 -0400144 .dev = {
Andrew Lunn5c602552011-05-15 13:32:40 +0200145 .coherent_dma_mask = DMA_BIT_MASK(32),
Nicolas Pitrea49a0182009-05-22 16:53:40 -0400146 },
Lennert Buytenhek777f9be2008-06-22 22:45:02 +0200147};
148
149void __init loki_ge1_init(struct mv643xx_eth_platform_data *eth_data)
150{
151 eth_data->shared = &loki_ge1_shared;
152 loki_ge1.dev.platform_data = eth_data;
153
154 writel(0x00079220, GE1_VIRT_BASE + 0x20b0);
155 platform_device_register(&loki_ge1_shared);
156 platform_device_register(&loki_ge1);
157}
158
159
160/*****************************************************************************
161 * SAS/SATA
162 ****************************************************************************/
163static struct resource loki_sas_resources[] = {
164 {
165 .name = "mvsas0 mem",
166 .start = SAS0_PHYS_BASE,
167 .end = SAS0_PHYS_BASE + 0x01ff,
168 .flags = IORESOURCE_MEM,
169 }, {
170 .name = "mvsas0 irq",
171 .start = IRQ_LOKI_SAS_A,
172 .end = IRQ_LOKI_SAS_A,
173 .flags = IORESOURCE_IRQ,
174 }, {
175 .name = "mvsas1 mem",
176 .start = SAS1_PHYS_BASE,
177 .end = SAS1_PHYS_BASE + 0x01ff,
178 .flags = IORESOURCE_MEM,
179 }, {
180 .name = "mvsas1 irq",
181 .start = IRQ_LOKI_SAS_B,
182 .end = IRQ_LOKI_SAS_B,
183 .flags = IORESOURCE_IRQ,
184 },
185};
186
187static struct platform_device loki_sas = {
188 .name = "mvsas",
189 .id = 0,
190 .dev = {
Andrew Lunn5c602552011-05-15 13:32:40 +0200191 .coherent_dma_mask = DMA_BIT_MASK(32),
Lennert Buytenhek777f9be2008-06-22 22:45:02 +0200192 },
193 .num_resources = ARRAY_SIZE(loki_sas_resources),
194 .resource = loki_sas_resources,
195};
196
197void __init loki_sas_init(void)
198{
199 writel(0x8300f707, DDR_REG(0x1424));
200 platform_device_register(&loki_sas);
201}
202
203
204/*****************************************************************************
205 * UART0
206 ****************************************************************************/
207static struct plat_serial8250_port loki_uart0_data[] = {
208 {
209 .mapbase = UART0_PHYS_BASE,
210 .membase = (char *)UART0_VIRT_BASE,
211 .irq = IRQ_LOKI_UART0,
212 .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
213 .iotype = UPIO_MEM,
214 .regshift = 2,
215 .uartclk = LOKI_TCLK,
216 }, {
217 },
218};
219
220static struct resource loki_uart0_resources[] = {
221 {
222 .start = UART0_PHYS_BASE,
223 .end = UART0_PHYS_BASE + 0xff,
224 .flags = IORESOURCE_MEM,
225 }, {
226 .start = IRQ_LOKI_UART0,
227 .end = IRQ_LOKI_UART0,
228 .flags = IORESOURCE_IRQ,
229 },
230};
231
232static struct platform_device loki_uart0 = {
233 .name = "serial8250",
Andrew Lunn5c602552011-05-15 13:32:40 +0200234 .id = PLAT8250_DEV_PLATFORM,
Lennert Buytenhek777f9be2008-06-22 22:45:02 +0200235 .dev = {
236 .platform_data = loki_uart0_data,
237 },
238 .resource = loki_uart0_resources,
239 .num_resources = ARRAY_SIZE(loki_uart0_resources),
240};
241
242void __init loki_uart0_init(void)
243{
244 platform_device_register(&loki_uart0);
245}
246
247
248/*****************************************************************************
249 * UART1
250 ****************************************************************************/
251static struct plat_serial8250_port loki_uart1_data[] = {
252 {
253 .mapbase = UART1_PHYS_BASE,
254 .membase = (char *)UART1_VIRT_BASE,
255 .irq = IRQ_LOKI_UART1,
256 .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
257 .iotype = UPIO_MEM,
258 .regshift = 2,
259 .uartclk = LOKI_TCLK,
260 }, {
261 },
262};
263
264static struct resource loki_uart1_resources[] = {
265 {
266 .start = UART1_PHYS_BASE,
267 .end = UART1_PHYS_BASE + 0xff,
268 .flags = IORESOURCE_MEM,
269 }, {
270 .start = IRQ_LOKI_UART1,
271 .end = IRQ_LOKI_UART1,
272 .flags = IORESOURCE_IRQ,
273 },
274};
275
276static struct platform_device loki_uart1 = {
277 .name = "serial8250",
Andrew Lunn5c602552011-05-15 13:32:40 +0200278 .id = PLAT8250_DEV_PLATFORM1,
Lennert Buytenhek777f9be2008-06-22 22:45:02 +0200279 .dev = {
280 .platform_data = loki_uart1_data,
281 },
282 .resource = loki_uart1_resources,
283 .num_resources = ARRAY_SIZE(loki_uart1_resources),
284};
285
286void __init loki_uart1_init(void)
287{
288 platform_device_register(&loki_uart1);
289}
290
291
292/*****************************************************************************
293 * Time handling
294 ****************************************************************************/
Lennert Buytenhek4ee1f6b2010-10-15 16:50:26 +0200295void __init loki_init_early(void)
296{
297 orion_time_set_base(TIMER_VIRT_BASE);
298}
299
Lennert Buytenhek777f9be2008-06-22 22:45:02 +0200300static void loki_timer_init(void)
301{
Lennert Buytenhek4ee1f6b2010-10-15 16:50:26 +0200302 orion_time_init(BRIDGE_VIRT_BASE, BRIDGE_INT_TIMER1_CLR,
303 IRQ_LOKI_BRIDGE, LOKI_TCLK);
Lennert Buytenhek777f9be2008-06-22 22:45:02 +0200304}
305
306struct sys_timer loki_timer = {
307 .init = loki_timer_init,
308};
309
310
311/*****************************************************************************
312 * General
313 ****************************************************************************/
314void __init loki_init(void)
315{
316 printk(KERN_INFO "Loki ID: 88RC8480. TCLK=%d.\n", LOKI_TCLK);
317
318 loki_setup_cpu_mbus();
319}