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/bridge-regs.h>
22 #include <mach/loki.h>
23 #include <plat/orion_nand.h>
24 #include <plat/time.h>
27 /*****************************************************************************
29 ****************************************************************************/
30 static struct map_desc loki_io_desc
[] __initdata
= {
32 .virtual = LOKI_REGS_VIRT_BASE
,
33 .pfn
= __phys_to_pfn(LOKI_REGS_PHYS_BASE
),
34 .length
= LOKI_REGS_SIZE
,
39 void __init
loki_map_io(void)
41 iotable_init(loki_io_desc
, ARRAY_SIZE(loki_io_desc
));
45 /*****************************************************************************
47 ****************************************************************************/
48 struct mv643xx_eth_shared_platform_data loki_ge0_shared_data
= {
50 .dram
= &loki_mbus_dram_info
,
53 static struct resource loki_ge0_shared_resources
[] = {
56 .start
= GE0_PHYS_BASE
+ 0x2000,
57 .end
= GE0_PHYS_BASE
+ 0x3fff,
58 .flags
= IORESOURCE_MEM
,
62 static struct platform_device loki_ge0_shared
= {
63 .name
= MV643XX_ETH_SHARED_NAME
,
66 .platform_data
= &loki_ge0_shared_data
,
69 .resource
= loki_ge0_shared_resources
,
72 static struct resource loki_ge0_resources
[] = {
75 .start
= IRQ_LOKI_GBE_A_INT
,
76 .end
= IRQ_LOKI_GBE_A_INT
,
77 .flags
= IORESOURCE_IRQ
,
81 static struct platform_device loki_ge0
= {
82 .name
= MV643XX_ETH_NAME
,
85 .resource
= loki_ge0_resources
,
87 .coherent_dma_mask
= 0xffffffff,
91 void __init
loki_ge0_init(struct mv643xx_eth_platform_data
*eth_data
)
93 eth_data
->shared
= &loki_ge0_shared
;
94 loki_ge0
.dev
.platform_data
= eth_data
;
96 writel(0x00079220, GE0_VIRT_BASE
+ 0x20b0);
97 platform_device_register(&loki_ge0_shared
);
98 platform_device_register(&loki_ge0
);
102 /*****************************************************************************
104 ****************************************************************************/
105 struct mv643xx_eth_shared_platform_data loki_ge1_shared_data
= {
107 .dram
= &loki_mbus_dram_info
,
110 static struct resource loki_ge1_shared_resources
[] = {
113 .start
= GE1_PHYS_BASE
+ 0x2000,
114 .end
= GE1_PHYS_BASE
+ 0x3fff,
115 .flags
= IORESOURCE_MEM
,
119 static struct platform_device loki_ge1_shared
= {
120 .name
= MV643XX_ETH_SHARED_NAME
,
123 .platform_data
= &loki_ge1_shared_data
,
126 .resource
= loki_ge1_shared_resources
,
129 static struct resource loki_ge1_resources
[] = {
132 .start
= IRQ_LOKI_GBE_B_INT
,
133 .end
= IRQ_LOKI_GBE_B_INT
,
134 .flags
= IORESOURCE_IRQ
,
138 static struct platform_device loki_ge1
= {
139 .name
= MV643XX_ETH_NAME
,
142 .resource
= loki_ge1_resources
,
144 .coherent_dma_mask
= 0xffffffff,
148 void __init
loki_ge1_init(struct mv643xx_eth_platform_data
*eth_data
)
150 eth_data
->shared
= &loki_ge1_shared
;
151 loki_ge1
.dev
.platform_data
= eth_data
;
153 writel(0x00079220, GE1_VIRT_BASE
+ 0x20b0);
154 platform_device_register(&loki_ge1_shared
);
155 platform_device_register(&loki_ge1
);
159 /*****************************************************************************
161 ****************************************************************************/
162 static struct resource loki_sas_resources
[] = {
164 .name
= "mvsas0 mem",
165 .start
= SAS0_PHYS_BASE
,
166 .end
= SAS0_PHYS_BASE
+ 0x01ff,
167 .flags
= IORESOURCE_MEM
,
169 .name
= "mvsas0 irq",
170 .start
= IRQ_LOKI_SAS_A
,
171 .end
= IRQ_LOKI_SAS_A
,
172 .flags
= IORESOURCE_IRQ
,
174 .name
= "mvsas1 mem",
175 .start
= SAS1_PHYS_BASE
,
176 .end
= SAS1_PHYS_BASE
+ 0x01ff,
177 .flags
= IORESOURCE_MEM
,
179 .name
= "mvsas1 irq",
180 .start
= IRQ_LOKI_SAS_B
,
181 .end
= IRQ_LOKI_SAS_B
,
182 .flags
= IORESOURCE_IRQ
,
186 static struct platform_device loki_sas
= {
190 .coherent_dma_mask
= 0xffffffff,
192 .num_resources
= ARRAY_SIZE(loki_sas_resources
),
193 .resource
= loki_sas_resources
,
196 void __init
loki_sas_init(void)
198 writel(0x8300f707, DDR_REG(0x1424));
199 platform_device_register(&loki_sas
);
203 /*****************************************************************************
205 ****************************************************************************/
206 static struct plat_serial8250_port loki_uart0_data
[] = {
208 .mapbase
= UART0_PHYS_BASE
,
209 .membase
= (char *)UART0_VIRT_BASE
,
210 .irq
= IRQ_LOKI_UART0
,
211 .flags
= UPF_SKIP_TEST
| UPF_BOOT_AUTOCONF
,
214 .uartclk
= LOKI_TCLK
,
219 static struct resource loki_uart0_resources
[] = {
221 .start
= UART0_PHYS_BASE
,
222 .end
= UART0_PHYS_BASE
+ 0xff,
223 .flags
= IORESOURCE_MEM
,
225 .start
= IRQ_LOKI_UART0
,
226 .end
= IRQ_LOKI_UART0
,
227 .flags
= IORESOURCE_IRQ
,
231 static struct platform_device loki_uart0
= {
232 .name
= "serial8250",
235 .platform_data
= loki_uart0_data
,
237 .resource
= loki_uart0_resources
,
238 .num_resources
= ARRAY_SIZE(loki_uart0_resources
),
241 void __init
loki_uart0_init(void)
243 platform_device_register(&loki_uart0
);
247 /*****************************************************************************
249 ****************************************************************************/
250 static struct plat_serial8250_port loki_uart1_data
[] = {
252 .mapbase
= UART1_PHYS_BASE
,
253 .membase
= (char *)UART1_VIRT_BASE
,
254 .irq
= IRQ_LOKI_UART1
,
255 .flags
= UPF_SKIP_TEST
| UPF_BOOT_AUTOCONF
,
258 .uartclk
= LOKI_TCLK
,
263 static struct resource loki_uart1_resources
[] = {
265 .start
= UART1_PHYS_BASE
,
266 .end
= UART1_PHYS_BASE
+ 0xff,
267 .flags
= IORESOURCE_MEM
,
269 .start
= IRQ_LOKI_UART1
,
270 .end
= IRQ_LOKI_UART1
,
271 .flags
= IORESOURCE_IRQ
,
275 static struct platform_device loki_uart1
= {
276 .name
= "serial8250",
279 .platform_data
= loki_uart1_data
,
281 .resource
= loki_uart1_resources
,
282 .num_resources
= ARRAY_SIZE(loki_uart1_resources
),
285 void __init
loki_uart1_init(void)
287 platform_device_register(&loki_uart1
);
291 /*****************************************************************************
293 ****************************************************************************/
294 void __init
loki_init_early(void)
296 orion_time_set_base(TIMER_VIRT_BASE
);
299 static void loki_timer_init(void)
301 orion_time_init(BRIDGE_VIRT_BASE
, BRIDGE_INT_TIMER1_CLR
,
302 IRQ_LOKI_BRIDGE
, LOKI_TCLK
);
305 struct sys_timer loki_timer
= {
306 .init
= loki_timer_init
,
310 /*****************************************************************************
312 ****************************************************************************/
313 void __init
loki_init(void)
315 printk(KERN_INFO
"Loki ID: 88RC8480. TCLK=%d.\n", LOKI_TCLK
);
317 loki_setup_cpu_mbus();