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 <asm/arch/mv78xx0.h>
21 #include <asm/plat-orion/cache-feroceon-l2.h>
22 #include <asm/plat-orion/ehci-orion.h>
23 #include <asm/plat-orion/orion_nand.h>
24 #include <asm/plat-orion/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,
291 static struct platform_device mv78xx0_ge00_shared = {
292 .name = MV643XX_ETH_SHARED_NAME,
295 .platform_data = &mv78xx0_ge00_shared_data,
298 .resource = mv78xx0_ge00_shared_resources,
301 static struct resource mv78xx0_ge00_resources[] = {
304 .start = IRQ_MV78XX0_GE00_SUM,
305 .end = IRQ_MV78XX0_GE00_SUM,
306 .flags = IORESOURCE_IRQ,
310 static struct platform_device mv78xx0_ge00 = {
311 .name = MV643XX_ETH_NAME,
314 .resource = mv78xx0_ge00_resources,
317 void __init mv78xx0_ge00_init(struct mv643xx_eth_platform_data *eth_data)
319 eth_data->shared = &mv78xx0_ge00_shared;
320 mv78xx0_ge00.dev.platform_data = eth_data;
322 platform_device_register(&mv78xx0_ge00_shared);
323 platform_device_register(&mv78xx0_ge00);
327 /*****************************************************************************
329 ****************************************************************************/
330 struct mv643xx_eth_shared_platform_data mv78xx0_ge01_shared_data = {
332 .dram = &mv78xx0_mbus_dram_info,
335 static struct resource mv78xx0_ge01_shared_resources[] = {
338 .start = GE01_PHYS_BASE + 0x2000,
339 .end = GE01_PHYS_BASE + 0x3fff,
340 .flags = IORESOURCE_MEM,
344 static struct platform_device mv78xx0_ge01_shared = {
345 .name = MV643XX_ETH_SHARED_NAME,
348 .platform_data = &mv78xx0_ge01_shared_data,
351 .resource = mv78xx0_ge01_shared_resources,
354 static struct resource mv78xx0_ge01_resources[] = {
357 .start = IRQ_MV78XX0_GE01_SUM,
358 .end = IRQ_MV78XX0_GE01_SUM,
359 .flags = IORESOURCE_IRQ,
363 static struct platform_device mv78xx0_ge01 = {
364 .name = MV643XX_ETH_NAME,
367 .resource = mv78xx0_ge01_resources,
370 void __init mv78xx0_ge01_init(struct mv643xx_eth_platform_data *eth_data)
372 eth_data->shared = &mv78xx0_ge01_shared;
373 eth_data->shared_smi = &mv78xx0_ge00_shared;
374 mv78xx0_ge01.dev.platform_data = eth_data;
376 platform_device_register(&mv78xx0_ge01_shared);
377 platform_device_register(&mv78xx0_ge01);
381 /*****************************************************************************
383 ****************************************************************************/
384 struct mv643xx_eth_shared_platform_data mv78xx0_ge10_shared_data = {
386 .dram = &mv78xx0_mbus_dram_info,
389 static struct resource mv78xx0_ge10_shared_resources[] = {
392 .start = GE10_PHYS_BASE + 0x2000,
393 .end = GE10_PHYS_BASE + 0x3fff,
394 .flags = IORESOURCE_MEM,
398 static struct platform_device mv78xx0_ge10_shared = {
399 .name = MV643XX_ETH_SHARED_NAME,
402 .platform_data = &mv78xx0_ge10_shared_data,
405 .resource = mv78xx0_ge10_shared_resources,
408 static struct resource mv78xx0_ge10_resources[] = {
411 .start = IRQ_MV78XX0_GE10_SUM,
412 .end = IRQ_MV78XX0_GE10_SUM,
413 .flags = IORESOURCE_IRQ,
417 static struct platform_device mv78xx0_ge10 = {
418 .name = MV643XX_ETH_NAME,
421 .resource = mv78xx0_ge10_resources,
424 void __init mv78xx0_ge10_init(struct mv643xx_eth_platform_data *eth_data)
426 eth_data->shared = &mv78xx0_ge10_shared;
427 eth_data->shared_smi = &mv78xx0_ge00_shared;
428 mv78xx0_ge10.dev.platform_data = eth_data;
430 platform_device_register(&mv78xx0_ge10_shared);
431 platform_device_register(&mv78xx0_ge10);
435 /*****************************************************************************
437 ****************************************************************************/
438 struct mv643xx_eth_shared_platform_data mv78xx0_ge11_shared_data = {
440 .dram = &mv78xx0_mbus_dram_info,
443 static struct resource mv78xx0_ge11_shared_resources[] = {
446 .start = GE11_PHYS_BASE + 0x2000,
447 .end = GE11_PHYS_BASE + 0x3fff,
448 .flags = IORESOURCE_MEM,
452 static struct platform_device mv78xx0_ge11_shared = {
453 .name = MV643XX_ETH_SHARED_NAME,
456 .platform_data = &mv78xx0_ge11_shared_data,
459 .resource = mv78xx0_ge11_shared_resources,
462 static struct resource mv78xx0_ge11_resources[] = {
465 .start = IRQ_MV78XX0_GE11_SUM,
466 .end = IRQ_MV78XX0_GE11_SUM,
467 .flags = IORESOURCE_IRQ,
471 static struct platform_device mv78xx0_ge11 = {
472 .name = MV643XX_ETH_NAME,
475 .resource = mv78xx0_ge11_resources,
478 void __init mv78xx0_ge11_init(struct mv643xx_eth_platform_data *eth_data)
480 eth_data->shared = &mv78xx0_ge11_shared;
481 eth_data->shared_smi = &mv78xx0_ge00_shared;
482 mv78xx0_ge11.dev.platform_data = eth_data;
484 platform_device_register(&mv78xx0_ge11_shared);
485 platform_device_register(&mv78xx0_ge11);
489 /*****************************************************************************
491 ****************************************************************************/
492 static struct resource mv78xx0_sata_resources[] = {
495 .start = SATA_PHYS_BASE,
496 .end = SATA_PHYS_BASE + 0x5000 - 1,
497 .flags = IORESOURCE_MEM,
500 .start = IRQ_MV78XX0_SATA,
501 .end = IRQ_MV78XX0_SATA,
502 .flags = IORESOURCE_IRQ,
506 static struct platform_device mv78xx0_sata = {
510 .coherent_dma_mask = 0xffffffff,
512 .num_resources = ARRAY_SIZE(mv78xx0_sata_resources),
513 .resource = mv78xx0_sata_resources,
516 void __init mv78xx0_sata_init(struct mv_sata_platform_data *sata_data)
518 sata_data->dram = &mv78xx0_mbus_dram_info;
519 mv78xx0_sata.dev.platform_data = sata_data;
520 platform_device_register(&mv78xx0_sata);
524 /*****************************************************************************
526 ****************************************************************************/
527 static struct plat_serial8250_port mv78xx0_uart0_data[] = {
529 .mapbase = UART0_PHYS_BASE,
530 .membase = (char *)UART0_VIRT_BASE,
531 .irq = IRQ_MV78XX0_UART_0,
532 .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
540 static struct resource mv78xx0_uart0_resources[] = {
542 .start = UART0_PHYS_BASE,
543 .end = UART0_PHYS_BASE + 0xff,
544 .flags = IORESOURCE_MEM,
546 .start = IRQ_MV78XX0_UART_0,
547 .end = IRQ_MV78XX0_UART_0,
548 .flags = IORESOURCE_IRQ,
552 static struct platform_device mv78xx0_uart0 = {
553 .name = "serial8250",
556 .platform_data = mv78xx0_uart0_data,
558 .resource = mv78xx0_uart0_resources,
559 .num_resources = ARRAY_SIZE(mv78xx0_uart0_resources),
562 void __init mv78xx0_uart0_init(void)
564 platform_device_register(&mv78xx0_uart0);
568 /*****************************************************************************
570 ****************************************************************************/
571 static struct plat_serial8250_port mv78xx0_uart1_data[] = {
573 .mapbase = UART1_PHYS_BASE,
574 .membase = (char *)UART1_VIRT_BASE,
575 .irq = IRQ_MV78XX0_UART_1,
576 .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
584 static struct resource mv78xx0_uart1_resources[] = {
586 .start = UART1_PHYS_BASE,
587 .end = UART1_PHYS_BASE + 0xff,
588 .flags = IORESOURCE_MEM,
590 .start = IRQ_MV78XX0_UART_1,
591 .end = IRQ_MV78XX0_UART_1,
592 .flags = IORESOURCE_IRQ,
596 static struct platform_device mv78xx0_uart1 = {
597 .name = "serial8250",
600 .platform_data = mv78xx0_uart1_data,
602 .resource = mv78xx0_uart1_resources,
603 .num_resources = ARRAY_SIZE(mv78xx0_uart1_resources),
606 void __init mv78xx0_uart1_init(void)
608 platform_device_register(&mv78xx0_uart1);
612 /*****************************************************************************
614 ****************************************************************************/
615 static struct plat_serial8250_port mv78xx0_uart2_data[] = {
617 .mapbase = UART2_PHYS_BASE,
618 .membase = (char *)UART2_VIRT_BASE,
619 .irq = IRQ_MV78XX0_UART_2,
620 .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
628 static struct resource mv78xx0_uart2_resources[] = {
630 .start = UART2_PHYS_BASE,
631 .end = UART2_PHYS_BASE + 0xff,
632 .flags = IORESOURCE_MEM,
634 .start = IRQ_MV78XX0_UART_2,
635 .end = IRQ_MV78XX0_UART_2,
636 .flags = IORESOURCE_IRQ,
640 static struct platform_device mv78xx0_uart2 = {
641 .name = "serial8250",
644 .platform_data = mv78xx0_uart2_data,
646 .resource = mv78xx0_uart2_resources,
647 .num_resources = ARRAY_SIZE(mv78xx0_uart2_resources),
650 void __init mv78xx0_uart2_init(void)
652 platform_device_register(&mv78xx0_uart2);
656 /*****************************************************************************
658 ****************************************************************************/
659 static struct plat_serial8250_port mv78xx0_uart3_data[] = {
661 .mapbase = UART3_PHYS_BASE,
662 .membase = (char *)UART3_VIRT_BASE,
663 .irq = IRQ_MV78XX0_UART_3,
664 .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
672 static struct resource mv78xx0_uart3_resources[] = {
674 .start = UART3_PHYS_BASE,
675 .end = UART3_PHYS_BASE + 0xff,
676 .flags = IORESOURCE_MEM,
678 .start = IRQ_MV78XX0_UART_3,
679 .end = IRQ_MV78XX0_UART_3,
680 .flags = IORESOURCE_IRQ,
684 static struct platform_device mv78xx0_uart3 = {
685 .name = "serial8250",
688 .platform_data = mv78xx0_uart3_data,
690 .resource = mv78xx0_uart3_resources,
691 .num_resources = ARRAY_SIZE(mv78xx0_uart3_resources),
694 void __init mv78xx0_uart3_init(void)
696 platform_device_register(&mv78xx0_uart3);
700 /*****************************************************************************
702 ****************************************************************************/
703 static void mv78xx0_timer_init(void)
705 orion_time_init(IRQ_MV78XX0_TIMER_1, get_tclk());
708 struct sys_timer mv78xx0_timer = {
709 .init = mv78xx0_timer_init,
713 /*****************************************************************************
715 ****************************************************************************/
716 static int __init is_l2_writethrough(void)
718 return !!(readl(CPU_CONTROL) & L2_WRITETHROUGH);
721 void __init mv78xx0_init(void)
729 core_index = mv78xx0_core_index();
731 get_pclk_l2clk(hclk, core_index, &pclk, &l2clk);
734 printk(KERN_INFO "MV78xx0 core #%d, ", core_index);
735 printk("PCLK = %dMHz, ", (pclk + 499999) / 1000000);
736 printk("L2 = %dMHz, ", (l2clk + 499999) / 1000000);
737 printk("HCLK = %dMHz, ", (hclk + 499999) / 1000000);
738 printk("TCLK = %dMHz\n", (tclk + 499999) / 1000000);
740 mv78xx0_setup_cpu_mbus();
742 #ifdef CONFIG_CACHE_FEROCEON_L2
743 feroceon_l2_init(is_l2_writethrough());
746 mv78xx0_ge00_shared_data.t_clk = tclk;
747 mv78xx0_ge01_shared_data.t_clk = tclk;
748 mv78xx0_ge10_shared_data.t_clk = tclk;
749 mv78xx0_ge11_shared_data.t_clk = tclk;
750 mv78xx0_uart0_data[0].uartclk = tclk;
751 mv78xx0_uart1_data[0].uartclk = tclk;
752 mv78xx0_uart2_data[0].uartclk = tclk;
753 mv78xx0_uart3_data[0].uartclk = tclk;