2 * arch/arm/mach-kirkwood/common.c
4 * Core functions for Marvell Kirkwood 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>
17 #include <linux/ata_platform.h>
19 #include <asm/timex.h>
20 #include <asm/mach/map.h>
21 #include <asm/mach/time.h>
22 #include <asm/arch/kirkwood.h>
23 #include <asm/plat-orion/cache-feroceon-l2.h>
24 #include <asm/plat-orion/ehci-orion.h>
25 #include <asm/plat-orion/orion_nand.h>
26 #include <asm/plat-orion/time.h>
29 /*****************************************************************************
31 ****************************************************************************/
32 static struct map_desc kirkwood_io_desc
[] __initdata
= {
34 .virtual = KIRKWOOD_PCIE_IO_VIRT_BASE
,
35 .pfn
= __phys_to_pfn(KIRKWOOD_PCIE_IO_PHYS_BASE
),
36 .length
= KIRKWOOD_PCIE_IO_SIZE
,
39 .virtual = KIRKWOOD_REGS_VIRT_BASE
,
40 .pfn
= __phys_to_pfn(KIRKWOOD_REGS_PHYS_BASE
),
41 .length
= KIRKWOOD_REGS_SIZE
,
46 void __init
kirkwood_map_io(void)
48 iotable_init(kirkwood_io_desc
, ARRAY_SIZE(kirkwood_io_desc
));
52 /*****************************************************************************
54 ****************************************************************************/
55 static struct orion_ehci_data kirkwood_ehci_data
= {
56 .dram
= &kirkwood_mbus_dram_info
,
59 static u64 ehci_dmamask
= 0xffffffffUL
;
62 /*****************************************************************************
64 ****************************************************************************/
65 static struct resource kirkwood_ehci_resources
[] = {
67 .start
= USB_PHYS_BASE
,
68 .end
= USB_PHYS_BASE
+ 0x0fff,
69 .flags
= IORESOURCE_MEM
,
71 .start
= IRQ_KIRKWOOD_USB
,
72 .end
= IRQ_KIRKWOOD_USB
,
73 .flags
= IORESOURCE_IRQ
,
77 static struct platform_device kirkwood_ehci
= {
81 .dma_mask
= &ehci_dmamask
,
82 .coherent_dma_mask
= 0xffffffff,
83 .platform_data
= &kirkwood_ehci_data
,
85 .resource
= kirkwood_ehci_resources
,
86 .num_resources
= ARRAY_SIZE(kirkwood_ehci_resources
),
89 void __init
kirkwood_ehci_init(void)
91 platform_device_register(&kirkwood_ehci
);
95 /*****************************************************************************
97 ****************************************************************************/
98 struct mv643xx_eth_shared_platform_data kirkwood_ge00_shared_data
= {
99 .t_clk
= KIRKWOOD_TCLK
,
100 .dram
= &kirkwood_mbus_dram_info
,
103 static struct resource kirkwood_ge00_shared_resources
[] = {
106 .start
= GE00_PHYS_BASE
+ 0x2000,
107 .end
= GE00_PHYS_BASE
+ 0x3fff,
108 .flags
= IORESOURCE_MEM
,
112 static struct platform_device kirkwood_ge00_shared
= {
113 .name
= MV643XX_ETH_SHARED_NAME
,
116 .platform_data
= &kirkwood_ge00_shared_data
,
119 .resource
= kirkwood_ge00_shared_resources
,
122 static struct resource kirkwood_ge00_resources
[] = {
125 .start
= IRQ_KIRKWOOD_GE00_SUM
,
126 .end
= IRQ_KIRKWOOD_GE00_SUM
,
127 .flags
= IORESOURCE_IRQ
,
131 static struct platform_device kirkwood_ge00
= {
132 .name
= MV643XX_ETH_NAME
,
135 .resource
= kirkwood_ge00_resources
,
138 void __init
kirkwood_ge00_init(struct mv643xx_eth_platform_data
*eth_data
)
140 eth_data
->shared
= &kirkwood_ge00_shared
;
141 kirkwood_ge00
.dev
.platform_data
= eth_data
;
143 platform_device_register(&kirkwood_ge00_shared
);
144 platform_device_register(&kirkwood_ge00
);
148 /*****************************************************************************
150 ****************************************************************************/
151 static struct resource kirkwood_rtc_resource
= {
152 .start
= RTC_PHYS_BASE
,
153 .end
= RTC_PHYS_BASE
+ SZ_16
- 1,
154 .flags
= IORESOURCE_MEM
,
157 void __init
kirkwood_rtc_init(void)
159 platform_device_register_simple("rtc-mv", -1, &kirkwood_rtc_resource
, 1);
163 /*****************************************************************************
165 ****************************************************************************/
166 static struct resource kirkwood_sata_resources
[] = {
169 .start
= SATA_PHYS_BASE
,
170 .end
= SATA_PHYS_BASE
+ 0x5000 - 1,
171 .flags
= IORESOURCE_MEM
,
174 .start
= IRQ_KIRKWOOD_SATA
,
175 .end
= IRQ_KIRKWOOD_SATA
,
176 .flags
= IORESOURCE_IRQ
,
180 static struct platform_device kirkwood_sata
= {
184 .coherent_dma_mask
= 0xffffffff,
186 .num_resources
= ARRAY_SIZE(kirkwood_sata_resources
),
187 .resource
= kirkwood_sata_resources
,
190 void __init
kirkwood_sata_init(struct mv_sata_platform_data
*sata_data
)
192 sata_data
->dram
= &kirkwood_mbus_dram_info
;
193 kirkwood_sata
.dev
.platform_data
= sata_data
;
194 platform_device_register(&kirkwood_sata
);
198 /*****************************************************************************
200 ****************************************************************************/
201 static struct plat_serial8250_port kirkwood_uart0_data
[] = {
203 .mapbase
= UART0_PHYS_BASE
,
204 .membase
= (char *)UART0_VIRT_BASE
,
205 .irq
= IRQ_KIRKWOOD_UART_0
,
206 .flags
= UPF_SKIP_TEST
| UPF_BOOT_AUTOCONF
,
209 .uartclk
= KIRKWOOD_TCLK
,
214 static struct resource kirkwood_uart0_resources
[] = {
216 .start
= UART0_PHYS_BASE
,
217 .end
= UART0_PHYS_BASE
+ 0xff,
218 .flags
= IORESOURCE_MEM
,
220 .start
= IRQ_KIRKWOOD_UART_0
,
221 .end
= IRQ_KIRKWOOD_UART_0
,
222 .flags
= IORESOURCE_IRQ
,
226 static struct platform_device kirkwood_uart0
= {
227 .name
= "serial8250",
230 .platform_data
= kirkwood_uart0_data
,
232 .resource
= kirkwood_uart0_resources
,
233 .num_resources
= ARRAY_SIZE(kirkwood_uart0_resources
),
236 void __init
kirkwood_uart0_init(void)
238 platform_device_register(&kirkwood_uart0
);
242 /*****************************************************************************
244 ****************************************************************************/
245 static struct plat_serial8250_port kirkwood_uart1_data
[] = {
247 .mapbase
= UART1_PHYS_BASE
,
248 .membase
= (char *)UART1_VIRT_BASE
,
249 .irq
= IRQ_KIRKWOOD_UART_1
,
250 .flags
= UPF_SKIP_TEST
| UPF_BOOT_AUTOCONF
,
253 .uartclk
= KIRKWOOD_TCLK
,
258 static struct resource kirkwood_uart1_resources
[] = {
260 .start
= UART1_PHYS_BASE
,
261 .end
= UART1_PHYS_BASE
+ 0xff,
262 .flags
= IORESOURCE_MEM
,
264 .start
= IRQ_KIRKWOOD_UART_1
,
265 .end
= IRQ_KIRKWOOD_UART_1
,
266 .flags
= IORESOURCE_IRQ
,
270 static struct platform_device kirkwood_uart1
= {
271 .name
= "serial8250",
274 .platform_data
= kirkwood_uart1_data
,
276 .resource
= kirkwood_uart1_resources
,
277 .num_resources
= ARRAY_SIZE(kirkwood_uart1_resources
),
280 void __init
kirkwood_uart1_init(void)
282 platform_device_register(&kirkwood_uart1
);
286 /*****************************************************************************
288 ****************************************************************************/
289 static void kirkwood_timer_init(void)
291 orion_time_init(IRQ_KIRKWOOD_BRIDGE
, KIRKWOOD_TCLK
);
294 struct sys_timer kirkwood_timer
= {
295 .init
= kirkwood_timer_init
,
299 /*****************************************************************************
301 ****************************************************************************/
302 static char * __init
kirkwood_id(void)
304 switch (readl(DEVICE_ID
) & 0x3) {
313 return "unknown 88F6000 variant";
316 static int __init
is_l2_writethrough(void)
318 return !!(readl(L2_CONFIG_REG
) & L2_WRITETHROUGH
);
321 void __init
kirkwood_init(void)
323 printk(KERN_INFO
"Kirkwood: %s, TCLK=%d.\n",
324 kirkwood_id(), KIRKWOOD_TCLK
);
326 kirkwood_setup_cpu_mbus();
328 #ifdef CONFIG_CACHE_FEROCEON_L2
329 feroceon_l2_init(is_l2_writethrough());