2 * arch/arm/mach-mv78xx0/common.c
4 * Core functions for Marvell MV78xx0 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>
18 #include <asm/mach/map.h>
19 #include <asm/mach/time.h>
20 #include <mach/mv78xx0.h>
21 #include <plat/cache-feroceon-l2.h>
22 #include <plat/ehci-orion.h>
23 #include <plat/orion_nand.h>
24 #include <plat/time.h>
28 /*****************************************************************************
30 ****************************************************************************/
31 int mv78xx0_core_index(void)
36 * Read Extra Features register.
38 __asm__("mrc p15, 1, %0, c15, c1, 0" : "=r" (extra));
40 return !!(extra & 0x00004000);
43 static int get_hclk(void)
48 * HCLK tick rate is configured by DEV_D[7:5] pins.
50 switch ((readl(SAMPLE_AT_RESET_LOW) >> 5) & 7) {
67 panic("unknown HCLK PLL setting: %.8x\n",
68 readl(SAMPLE_AT_RESET_LOW));
74 static void get_pclk_l2clk(int hclk, int core_index, int *pclk, int *l2clk)
79 * Core #0 PCLK/L2CLK is configured by bits [13:8], core #1
80 * PCLK/L2CLK by bits [19:14].
82 if (core_index == 0) {
83 cfg = (readl(SAMPLE_AT_RESET_LOW) >> 8) & 0x3f;
85 cfg = (readl(SAMPLE_AT_RESET_LOW) >> 14) & 0x3f;
89 * Bits [11:8] ([17:14] for core #1) configure the PCLK:HCLK
90 * ratio (1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5, 5.5, 6).
92 *pclk = ((u64)hclk * (2 + (cfg & 0xf))) >> 1;
95 * Bits [13:12] ([19:18] for core #1) configure the PCLK:L2CLK
98 *l2clk = *pclk / (((cfg >> 4) & 3) + 1);
101 static int get_tclk(void)
106 * TCLK tick rate is configured by DEV_A[2:0] strap pins.
108 switch ((readl(SAMPLE_AT_RESET_HIGH) >> 6) & 7) {
116 panic("unknown TCLK PLL setting: %.8x\n",
117 readl(SAMPLE_AT_RESET_HIGH));
124 /*****************************************************************************
125 * I/O Address Mapping
126 ****************************************************************************/
127 static struct map_desc mv78xx0_io_desc[] __initdata = {
129 .virtual = MV78XX0_CORE_REGS_VIRT_BASE,
131 .length = MV78XX0_CORE_REGS_SIZE,
134 .virtual = MV78XX0_PCIE_IO_VIRT_BASE(0),
135 .pfn = __phys_to_pfn(MV78XX0_PCIE_IO_PHYS_BASE(0)),
136 .length = MV78XX0_PCIE_IO_SIZE * 8,
139 .virtual = MV78XX0_REGS_VIRT_BASE,
140 .pfn = __phys_to_pfn(MV78XX0_REGS_PHYS_BASE),
141 .length = MV78XX0_REGS_SIZE,
146 void __init mv78xx0_map_io(void)
151 * Map the right set of per-core registers depending on
152 * which core we are running on.
154 if (mv78xx0_core_index() == 0) {
155 phys = MV78XX0_CORE0_REGS_PHYS_BASE;
157 phys = MV78XX0_CORE1_REGS_PHYS_BASE;
159 mv78xx0_io_desc[0].pfn = __phys_to_pfn(phys);
161 iotable_init(mv78xx0_io_desc, ARRAY_SIZE(mv78xx0_io_desc));
165 /*****************************************************************************
167 ****************************************************************************/
168 static struct orion_ehci_data mv78xx0_ehci_data = {
169 .dram = &mv78xx0_mbus_dram_info,
172 static u64 ehci_dmamask = 0xffffffffUL;
175 /*****************************************************************************
177 ****************************************************************************/
178 static struct resource mv78xx0_ehci0_resources[] = {
180 .start = USB0_PHYS_BASE,
181 .end = USB0_PHYS_BASE + 0x0fff,
182 .flags = IORESOURCE_MEM,
184 .start = IRQ_MV78XX0_USB_0,
185 .end = IRQ_MV78XX0_USB_0,
186 .flags = IORESOURCE_IRQ,
190 static struct platform_device mv78xx0_ehci0 = {
191 .name = "orion-ehci",
194 .dma_mask = &ehci_dmamask,
195 .coherent_dma_mask = 0xffffffff,
196 .platform_data = &mv78xx0_ehci_data,
198 .resource = mv78xx0_ehci0_resources,
199 .num_resources = ARRAY_SIZE(mv78xx0_ehci0_resources),
202 void __init mv78xx0_ehci0_init(void)
204 platform_device_register(&mv78xx0_ehci0);
208 /*****************************************************************************
210 ****************************************************************************/
211 static struct resource mv78xx0_ehci1_resources[] = {
213 .start = USB1_PHYS_BASE,
214 .end = USB1_PHYS_BASE + 0x0fff,
215 .flags = IORESOURCE_MEM,
217 .start = IRQ_MV78XX0_USB_1,
218 .end = IRQ_MV78XX0_USB_1,
219 .flags = IORESOURCE_IRQ,
223 static struct platform_device mv78xx0_ehci1 = {
224 .name = "orion-ehci",
227 .dma_mask = &ehci_dmamask,
228 .coherent_dma_mask = 0xffffffff,
229 .platform_data = &mv78xx0_ehci_data,
231 .resource = mv78xx0_ehci1_resources,
232 .num_resources = ARRAY_SIZE(mv78xx0_ehci1_resources),
235 void __init mv78xx0_ehci1_init(void)
237 platform_device_register(&mv78xx0_ehci1);
241 /*****************************************************************************
243 ****************************************************************************/
244 static struct resource mv78xx0_ehci2_resources[] = {
246 .start = USB2_PHYS_BASE,
247 .end = USB2_PHYS_BASE + 0x0fff,
248 .flags = IORESOURCE_MEM,
250 .start = IRQ_MV78XX0_USB_2,
251 .end = IRQ_MV78XX0_USB_2,
252 .flags = IORESOURCE_IRQ,
256 static struct platform_device mv78xx0_ehci2 = {
257 .name = "orion-ehci",
260 .dma_mask = &ehci_dmamask,
261 .coherent_dma_mask = 0xffffffff,
262 .platform_data = &mv78xx0_ehci_data,
264 .resource = mv78xx0_ehci2_resources,
265 .num_resources = ARRAY_SIZE(mv78xx0_ehci2_resources),
268 void __init mv78xx0_ehci2_init(void)
270 platform_device_register(&mv78xx0_ehci2);
274 /*****************************************************************************
276 ****************************************************************************/
277 struct mv643xx_eth_shared_platform_data mv78xx0_ge00_shared_data = {
279 .dram = &mv78xx0_mbus_dram_info,
282 static struct resource mv78xx0_ge00_shared_resources[] = {
285 .start = GE00_PHYS_BASE + 0x2000,
286 .end = GE00_PHYS_BASE + 0x3fff,
287 .flags = IORESOURCE_MEM,
289 .name = "ge err irq",
290 .start = IRQ_MV78XX0_GE_ERR,
291 .end = IRQ_MV78XX0_GE_ERR,
292 .flags = IORESOURCE_IRQ,
296 static struct platform_device mv78xx0_ge00_shared = {
297 .name = MV643XX_ETH_SHARED_NAME,
300 .platform_data = &mv78xx0_ge00_shared_data,
302 .num_resources = ARRAY_SIZE(mv78xx0_ge00_shared_resources),
303 .resource = mv78xx0_ge00_shared_resources,
306 static struct resource mv78xx0_ge00_resources[] = {
309 .start = IRQ_MV78XX0_GE00_SUM,
310 .end = IRQ_MV78XX0_GE00_SUM,
311 .flags = IORESOURCE_IRQ,
315 static struct platform_device mv78xx0_ge00 = {
316 .name = MV643XX_ETH_NAME,
319 .resource = mv78xx0_ge00_resources,
322 void __init mv78xx0_ge00_init(struct mv643xx_eth_platform_data *eth_data)
324 eth_data->shared = &mv78xx0_ge00_shared;
325 mv78xx0_ge00.dev.platform_data = eth_data;
327 platform_device_register(&mv78xx0_ge00_shared);
328 platform_device_register(&mv78xx0_ge00);
332 /*****************************************************************************
334 ****************************************************************************/
335 struct mv643xx_eth_shared_platform_data mv78xx0_ge01_shared_data = {
337 .dram = &mv78xx0_mbus_dram_info,
338 .shared_smi = &mv78xx0_ge00_shared,
341 static struct resource mv78xx0_ge01_shared_resources[] = {
344 .start = GE01_PHYS_BASE + 0x2000,
345 .end = GE01_PHYS_BASE + 0x3fff,
346 .flags = IORESOURCE_MEM,
350 static struct platform_device mv78xx0_ge01_shared = {
351 .name = MV643XX_ETH_SHARED_NAME,
354 .platform_data = &mv78xx0_ge01_shared_data,
357 .resource = mv78xx0_ge01_shared_resources,
360 static struct resource mv78xx0_ge01_resources[] = {
363 .start = IRQ_MV78XX0_GE01_SUM,
364 .end = IRQ_MV78XX0_GE01_SUM,
365 .flags = IORESOURCE_IRQ,
369 static struct platform_device mv78xx0_ge01 = {
370 .name = MV643XX_ETH_NAME,
373 .resource = mv78xx0_ge01_resources,
376 void __init mv78xx0_ge01_init(struct mv643xx_eth_platform_data *eth_data)
378 eth_data->shared = &mv78xx0_ge01_shared;
379 mv78xx0_ge01.dev.platform_data = eth_data;
381 platform_device_register(&mv78xx0_ge01_shared);
382 platform_device_register(&mv78xx0_ge01);
386 /*****************************************************************************
388 ****************************************************************************/
389 struct mv643xx_eth_shared_platform_data mv78xx0_ge10_shared_data = {
391 .dram = &mv78xx0_mbus_dram_info,
392 .shared_smi = &mv78xx0_ge00_shared,
395 static struct resource mv78xx0_ge10_shared_resources[] = {
398 .start = GE10_PHYS_BASE + 0x2000,
399 .end = GE10_PHYS_BASE + 0x3fff,
400 .flags = IORESOURCE_MEM,
404 static struct platform_device mv78xx0_ge10_shared = {
405 .name = MV643XX_ETH_SHARED_NAME,
408 .platform_data = &mv78xx0_ge10_shared_data,
411 .resource = mv78xx0_ge10_shared_resources,
414 static struct resource mv78xx0_ge10_resources[] = {
417 .start = IRQ_MV78XX0_GE10_SUM,
418 .end = IRQ_MV78XX0_GE10_SUM,
419 .flags = IORESOURCE_IRQ,
423 static struct platform_device mv78xx0_ge10 = {
424 .name = MV643XX_ETH_NAME,
427 .resource = mv78xx0_ge10_resources,
430 void __init mv78xx0_ge10_init(struct mv643xx_eth_platform_data *eth_data)
432 eth_data->shared = &mv78xx0_ge10_shared;
433 mv78xx0_ge10.dev.platform_data = eth_data;
435 platform_device_register(&mv78xx0_ge10_shared);
436 platform_device_register(&mv78xx0_ge10);
440 /*****************************************************************************
442 ****************************************************************************/
443 struct mv643xx_eth_shared_platform_data mv78xx0_ge11_shared_data = {
445 .dram = &mv78xx0_mbus_dram_info,
446 .shared_smi = &mv78xx0_ge00_shared,
449 static struct resource mv78xx0_ge11_shared_resources[] = {
452 .start = GE11_PHYS_BASE + 0x2000,
453 .end = GE11_PHYS_BASE + 0x3fff,
454 .flags = IORESOURCE_MEM,
458 static struct platform_device mv78xx0_ge11_shared = {
459 .name = MV643XX_ETH_SHARED_NAME,
462 .platform_data = &mv78xx0_ge11_shared_data,
465 .resource = mv78xx0_ge11_shared_resources,
468 static struct resource mv78xx0_ge11_resources[] = {
471 .start = IRQ_MV78XX0_GE11_SUM,
472 .end = IRQ_MV78XX0_GE11_SUM,
473 .flags = IORESOURCE_IRQ,
477 static struct platform_device mv78xx0_ge11 = {
478 .name = MV643XX_ETH_NAME,
481 .resource = mv78xx0_ge11_resources,
484 void __init mv78xx0_ge11_init(struct mv643xx_eth_platform_data *eth_data)
486 eth_data->shared = &mv78xx0_ge11_shared;
487 mv78xx0_ge11.dev.platform_data = eth_data;
489 platform_device_register(&mv78xx0_ge11_shared);
490 platform_device_register(&mv78xx0_ge11);
494 /*****************************************************************************
496 ****************************************************************************/
497 static struct resource mv78xx0_sata_resources[] = {
500 .start = SATA_PHYS_BASE,
501 .end = SATA_PHYS_BASE + 0x5000 - 1,
502 .flags = IORESOURCE_MEM,
505 .start = IRQ_MV78XX0_SATA,
506 .end = IRQ_MV78XX0_SATA,
507 .flags = IORESOURCE_IRQ,
511 static struct platform_device mv78xx0_sata = {
515 .coherent_dma_mask = 0xffffffff,
517 .num_resources = ARRAY_SIZE(mv78xx0_sata_resources),
518 .resource = mv78xx0_sata_resources,
521 void __init mv78xx0_sata_init(struct mv_sata_platform_data *sata_data)
523 sata_data->dram = &mv78xx0_mbus_dram_info;
524 mv78xx0_sata.dev.platform_data = sata_data;
525 platform_device_register(&mv78xx0_sata);
529 /*****************************************************************************
531 ****************************************************************************/
532 static struct plat_serial8250_port mv78xx0_uart0_data[] = {
534 .mapbase = UART0_PHYS_BASE,
535 .membase = (char *)UART0_VIRT_BASE,
536 .irq = IRQ_MV78XX0_UART_0,
537 .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
545 static struct resource mv78xx0_uart0_resources[] = {
547 .start = UART0_PHYS_BASE,
548 .end = UART0_PHYS_BASE + 0xff,
549 .flags = IORESOURCE_MEM,
551 .start = IRQ_MV78XX0_UART_0,
552 .end = IRQ_MV78XX0_UART_0,
553 .flags = IORESOURCE_IRQ,
557 static struct platform_device mv78xx0_uart0 = {
558 .name = "serial8250",
561 .platform_data = mv78xx0_uart0_data,
563 .resource = mv78xx0_uart0_resources,
564 .num_resources = ARRAY_SIZE(mv78xx0_uart0_resources),
567 void __init mv78xx0_uart0_init(void)
569 platform_device_register(&mv78xx0_uart0);
573 /*****************************************************************************
575 ****************************************************************************/
576 static struct plat_serial8250_port mv78xx0_uart1_data[] = {
578 .mapbase = UART1_PHYS_BASE,
579 .membase = (char *)UART1_VIRT_BASE,
580 .irq = IRQ_MV78XX0_UART_1,
581 .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
589 static struct resource mv78xx0_uart1_resources[] = {
591 .start = UART1_PHYS_BASE,
592 .end = UART1_PHYS_BASE + 0xff,
593 .flags = IORESOURCE_MEM,
595 .start = IRQ_MV78XX0_UART_1,
596 .end = IRQ_MV78XX0_UART_1,
597 .flags = IORESOURCE_IRQ,
601 static struct platform_device mv78xx0_uart1 = {
602 .name = "serial8250",
605 .platform_data = mv78xx0_uart1_data,
607 .resource = mv78xx0_uart1_resources,
608 .num_resources = ARRAY_SIZE(mv78xx0_uart1_resources),
611 void __init mv78xx0_uart1_init(void)
613 platform_device_register(&mv78xx0_uart1);
617 /*****************************************************************************
619 ****************************************************************************/
620 static struct plat_serial8250_port mv78xx0_uart2_data[] = {
622 .mapbase = UART2_PHYS_BASE,
623 .membase = (char *)UART2_VIRT_BASE,
624 .irq = IRQ_MV78XX0_UART_2,
625 .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
633 static struct resource mv78xx0_uart2_resources[] = {
635 .start = UART2_PHYS_BASE,
636 .end = UART2_PHYS_BASE + 0xff,
637 .flags = IORESOURCE_MEM,
639 .start = IRQ_MV78XX0_UART_2,
640 .end = IRQ_MV78XX0_UART_2,
641 .flags = IORESOURCE_IRQ,
645 static struct platform_device mv78xx0_uart2 = {
646 .name = "serial8250",
649 .platform_data = mv78xx0_uart2_data,
651 .resource = mv78xx0_uart2_resources,
652 .num_resources = ARRAY_SIZE(mv78xx0_uart2_resources),
655 void __init mv78xx0_uart2_init(void)
657 platform_device_register(&mv78xx0_uart2);
661 /*****************************************************************************
663 ****************************************************************************/
664 static struct plat_serial8250_port mv78xx0_uart3_data[] = {
666 .mapbase = UART3_PHYS_BASE,
667 .membase = (char *)UART3_VIRT_BASE,
668 .irq = IRQ_MV78XX0_UART_3,
669 .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
677 static struct resource mv78xx0_uart3_resources[] = {
679 .start = UART3_PHYS_BASE,
680 .end = UART3_PHYS_BASE + 0xff,
681 .flags = IORESOURCE_MEM,
683 .start = IRQ_MV78XX0_UART_3,
684 .end = IRQ_MV78XX0_UART_3,
685 .flags = IORESOURCE_IRQ,
689 static struct platform_device mv78xx0_uart3 = {
690 .name = "serial8250",
693 .platform_data = mv78xx0_uart3_data,
695 .resource = mv78xx0_uart3_resources,
696 .num_resources = ARRAY_SIZE(mv78xx0_uart3_resources),
699 void __init mv78xx0_uart3_init(void)
701 platform_device_register(&mv78xx0_uart3);
705 /*****************************************************************************
707 ****************************************************************************/
708 static void mv78xx0_timer_init(void)
710 orion_time_init(IRQ_MV78XX0_TIMER_1, get_tclk());
713 struct sys_timer mv78xx0_timer = {
714 .init = mv78xx0_timer_init,
718 /*****************************************************************************
720 ****************************************************************************/
721 static int __init is_l2_writethrough(void)
723 return !!(readl(CPU_CONTROL) & L2_WRITETHROUGH);
726 void __init mv78xx0_init(void)
734 core_index = mv78xx0_core_index();
736 get_pclk_l2clk(hclk, core_index, &pclk, &l2clk);
739 printk(KERN_INFO "MV78xx0 core #%d, ", core_index);
740 printk("PCLK = %dMHz, ", (pclk + 499999) / 1000000);
741 printk("L2 = %dMHz, ", (l2clk + 499999) / 1000000);
742 printk("HCLK = %dMHz, ", (hclk + 499999) / 1000000);
743 printk("TCLK = %dMHz\n", (tclk + 499999) / 1000000);
745 mv78xx0_setup_cpu_mbus();
747 #ifdef CONFIG_CACHE_FEROCEON_L2
748 feroceon_l2_init(is_l2_writethrough());
751 mv78xx0_ge00_shared_data.t_clk = tclk;
752 mv78xx0_ge01_shared_data.t_clk = tclk;
753 mv78xx0_ge10_shared_data.t_clk = tclk;
754 mv78xx0_ge11_shared_data.t_clk = tclk;
755 mv78xx0_uart0_data[0].uartclk = tclk;
756 mv78xx0_uart1_data[0].uartclk = tclk;
757 mv78xx0_uart2_data[0].uartclk = tclk;
758 mv78xx0_uart3_data[0].uartclk = tclk;