2 * arch/arm/mach-loki/common.c
4 * Core functions for Marvell Loki (88RC8480) SoCs
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.
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>
18 #include <asm/timex.h>
19 #include <asm/mach/map.h>
20 #include <asm/mach/time.h>
21 #include <mach/loki.h>
22 #include <plat/orion_nand.h>
23 #include <plat/time.h>
26 /*****************************************************************************
28 ****************************************************************************/
29 static struct map_desc loki_io_desc
[] __initdata
= {
31 .virtual = LOKI_REGS_VIRT_BASE
,
32 .pfn
= __phys_to_pfn(LOKI_REGS_PHYS_BASE
),
33 .length
= LOKI_REGS_SIZE
,
38 void __init
loki_map_io(void)
40 iotable_init(loki_io_desc
, ARRAY_SIZE(loki_io_desc
));
44 /*****************************************************************************
46 ****************************************************************************/
47 struct mv643xx_eth_shared_platform_data loki_ge0_shared_data
= {
49 .dram
= &loki_mbus_dram_info
,
52 static struct resource loki_ge0_shared_resources
[] = {
55 .start
= GE0_PHYS_BASE
+ 0x2000,
56 .end
= GE0_PHYS_BASE
+ 0x3fff,
57 .flags
= IORESOURCE_MEM
,
61 static struct platform_device loki_ge0_shared
= {
62 .name
= MV643XX_ETH_SHARED_NAME
,
65 .platform_data
= &loki_ge0_shared_data
,
68 .resource
= loki_ge0_shared_resources
,
71 static struct resource loki_ge0_resources
[] = {
74 .start
= IRQ_LOKI_GBE_A_INT
,
75 .end
= IRQ_LOKI_GBE_A_INT
,
76 .flags
= IORESOURCE_IRQ
,
80 static struct platform_device loki_ge0
= {
81 .name
= MV643XX_ETH_NAME
,
84 .resource
= loki_ge0_resources
,
86 .coherent_dma_mask
= 0xffffffff,
90 void __init
loki_ge0_init(struct mv643xx_eth_platform_data
*eth_data
)
92 eth_data
->shared
= &loki_ge0_shared
;
93 loki_ge0
.dev
.platform_data
= eth_data
;
95 writel(0x00079220, GE0_VIRT_BASE
+ 0x20b0);
96 platform_device_register(&loki_ge0_shared
);
97 platform_device_register(&loki_ge0
);
101 /*****************************************************************************
103 ****************************************************************************/
104 struct mv643xx_eth_shared_platform_data loki_ge1_shared_data
= {
106 .dram
= &loki_mbus_dram_info
,
109 static struct resource loki_ge1_shared_resources
[] = {
112 .start
= GE1_PHYS_BASE
+ 0x2000,
113 .end
= GE1_PHYS_BASE
+ 0x3fff,
114 .flags
= IORESOURCE_MEM
,
118 static struct platform_device loki_ge1_shared
= {
119 .name
= MV643XX_ETH_SHARED_NAME
,
122 .platform_data
= &loki_ge1_shared_data
,
125 .resource
= loki_ge1_shared_resources
,
128 static struct resource loki_ge1_resources
[] = {
131 .start
= IRQ_LOKI_GBE_B_INT
,
132 .end
= IRQ_LOKI_GBE_B_INT
,
133 .flags
= IORESOURCE_IRQ
,
137 static struct platform_device loki_ge1
= {
138 .name
= MV643XX_ETH_NAME
,
141 .resource
= loki_ge1_resources
,
143 .coherent_dma_mask
= 0xffffffff,
147 void __init
loki_ge1_init(struct mv643xx_eth_platform_data
*eth_data
)
149 eth_data
->shared
= &loki_ge1_shared
;
150 loki_ge1
.dev
.platform_data
= eth_data
;
152 writel(0x00079220, GE1_VIRT_BASE
+ 0x20b0);
153 platform_device_register(&loki_ge1_shared
);
154 platform_device_register(&loki_ge1
);
158 /*****************************************************************************
160 ****************************************************************************/
161 static struct resource loki_sas_resources
[] = {
163 .name
= "mvsas0 mem",
164 .start
= SAS0_PHYS_BASE
,
165 .end
= SAS0_PHYS_BASE
+ 0x01ff,
166 .flags
= IORESOURCE_MEM
,
168 .name
= "mvsas0 irq",
169 .start
= IRQ_LOKI_SAS_A
,
170 .end
= IRQ_LOKI_SAS_A
,
171 .flags
= IORESOURCE_IRQ
,
173 .name
= "mvsas1 mem",
174 .start
= SAS1_PHYS_BASE
,
175 .end
= SAS1_PHYS_BASE
+ 0x01ff,
176 .flags
= IORESOURCE_MEM
,
178 .name
= "mvsas1 irq",
179 .start
= IRQ_LOKI_SAS_B
,
180 .end
= IRQ_LOKI_SAS_B
,
181 .flags
= IORESOURCE_IRQ
,
185 static struct platform_device loki_sas
= {
189 .coherent_dma_mask
= 0xffffffff,
191 .num_resources
= ARRAY_SIZE(loki_sas_resources
),
192 .resource
= loki_sas_resources
,
195 void __init
loki_sas_init(void)
197 writel(0x8300f707, DDR_REG(0x1424));
198 platform_device_register(&loki_sas
);
202 /*****************************************************************************
204 ****************************************************************************/
205 static struct plat_serial8250_port loki_uart0_data
[] = {
207 .mapbase
= UART0_PHYS_BASE
,
208 .membase
= (char *)UART0_VIRT_BASE
,
209 .irq
= IRQ_LOKI_UART0
,
210 .flags
= UPF_SKIP_TEST
| UPF_BOOT_AUTOCONF
,
213 .uartclk
= LOKI_TCLK
,
218 static struct resource loki_uart0_resources
[] = {
220 .start
= UART0_PHYS_BASE
,
221 .end
= UART0_PHYS_BASE
+ 0xff,
222 .flags
= IORESOURCE_MEM
,
224 .start
= IRQ_LOKI_UART0
,
225 .end
= IRQ_LOKI_UART0
,
226 .flags
= IORESOURCE_IRQ
,
230 static struct platform_device loki_uart0
= {
231 .name
= "serial8250",
234 .platform_data
= loki_uart0_data
,
236 .resource
= loki_uart0_resources
,
237 .num_resources
= ARRAY_SIZE(loki_uart0_resources
),
240 void __init
loki_uart0_init(void)
242 platform_device_register(&loki_uart0
);
246 /*****************************************************************************
248 ****************************************************************************/
249 static struct plat_serial8250_port loki_uart1_data
[] = {
251 .mapbase
= UART1_PHYS_BASE
,
252 .membase
= (char *)UART1_VIRT_BASE
,
253 .irq
= IRQ_LOKI_UART1
,
254 .flags
= UPF_SKIP_TEST
| UPF_BOOT_AUTOCONF
,
257 .uartclk
= LOKI_TCLK
,
262 static struct resource loki_uart1_resources
[] = {
264 .start
= UART1_PHYS_BASE
,
265 .end
= UART1_PHYS_BASE
+ 0xff,
266 .flags
= IORESOURCE_MEM
,
268 .start
= IRQ_LOKI_UART1
,
269 .end
= IRQ_LOKI_UART1
,
270 .flags
= IORESOURCE_IRQ
,
274 static struct platform_device loki_uart1
= {
275 .name
= "serial8250",
278 .platform_data
= loki_uart1_data
,
280 .resource
= loki_uart1_resources
,
281 .num_resources
= ARRAY_SIZE(loki_uart1_resources
),
284 void __init
loki_uart1_init(void)
286 platform_device_register(&loki_uart1
);
290 /*****************************************************************************
292 ****************************************************************************/
293 static void loki_timer_init(void)
295 orion_time_init(IRQ_LOKI_BRIDGE
, LOKI_TCLK
);
298 struct sys_timer loki_timer
= {
299 .init
= loki_timer_init
,
303 /*****************************************************************************
305 ****************************************************************************/
306 void __init
loki_init(void)
308 printk(KERN_INFO
"Loki ID: 88RC8480. TCLK=%d.\n", LOKI_TCLK
);
310 loki_setup_cpu_mbus();