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/mv643xx_i2c.h>
18 #include <linux/ata_platform.h>
19 #include <linux/ethtool.h>
20 #include <asm/mach/map.h>
21 #include <asm/mach/time.h>
22 #include <mach/mv78xx0.h>
23 #include <plat/cache-feroceon-l2.h>
24 #include <plat/ehci-orion.h>
25 #include <plat/orion_nand.h>
26 #include <plat/time.h>
30 /*****************************************************************************
32 ****************************************************************************/
33 int mv78xx0_core_index(void)
38 * Read Extra Features register.
40 __asm__("mrc p15, 1, %0, c15, c1, 0" : "=r" (extra));
42 return !!(extra & 0x00004000);
45 static int get_hclk(void)
50 * HCLK tick rate is configured by DEV_D[7:5] pins.
52 switch ((readl(SAMPLE_AT_RESET_LOW) >> 5) & 7) {
69 panic("unknown HCLK PLL setting: %.8x\n",
70 readl(SAMPLE_AT_RESET_LOW));
76 static void get_pclk_l2clk(int hclk, int core_index, int *pclk, int *l2clk)
81 * Core #0 PCLK/L2CLK is configured by bits [13:8], core #1
82 * PCLK/L2CLK by bits [19:14].
84 if (core_index == 0) {
85 cfg = (readl(SAMPLE_AT_RESET_LOW) >> 8) & 0x3f;
87 cfg = (readl(SAMPLE_AT_RESET_LOW) >> 14) & 0x3f;
91 * Bits [11:8] ([17:14] for core #1) configure the PCLK:HCLK
92 * ratio (1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5, 5.5, 6).
94 *pclk = ((u64)hclk * (2 + (cfg & 0xf))) >> 1;
97 * Bits [13:12] ([19:18] for core #1) configure the PCLK:L2CLK
100 *l2clk = *pclk / (((cfg >> 4) & 3) + 1);
103 static int get_tclk(void)
108 * TCLK tick rate is configured by DEV_A[2:0] strap pins.
110 switch ((readl(SAMPLE_AT_RESET_HIGH) >> 6) & 7) {
118 panic("unknown TCLK PLL setting: %.8x\n",
119 readl(SAMPLE_AT_RESET_HIGH));
126 /*****************************************************************************
127 * I/O Address Mapping
128 ****************************************************************************/
129 static struct map_desc mv78xx0_io_desc[] __initdata = {
131 .virtual = MV78XX0_CORE_REGS_VIRT_BASE,
133 .length = MV78XX0_CORE_REGS_SIZE,
136 .virtual = MV78XX0_PCIE_IO_VIRT_BASE(0),
137 .pfn = __phys_to_pfn(MV78XX0_PCIE_IO_PHYS_BASE(0)),
138 .length = MV78XX0_PCIE_IO_SIZE * 8,
141 .virtual = MV78XX0_REGS_VIRT_BASE,
142 .pfn = __phys_to_pfn(MV78XX0_REGS_PHYS_BASE),
143 .length = MV78XX0_REGS_SIZE,
148 void __init mv78xx0_map_io(void)
153 * Map the right set of per-core registers depending on
154 * which core we are running on.
156 if (mv78xx0_core_index() == 0) {
157 phys = MV78XX0_CORE0_REGS_PHYS_BASE;
159 phys = MV78XX0_CORE1_REGS_PHYS_BASE;
161 mv78xx0_io_desc[0].pfn = __phys_to_pfn(phys);
163 iotable_init(mv78xx0_io_desc, ARRAY_SIZE(mv78xx0_io_desc));
167 /*****************************************************************************
169 ****************************************************************************/
170 static struct orion_ehci_data mv78xx0_ehci_data = {
171 .dram = &mv78xx0_mbus_dram_info,
172 .phy_version = EHCI_PHY_NA,
175 static u64 ehci_dmamask = 0xffffffffUL;
178 /*****************************************************************************
180 ****************************************************************************/
181 static struct resource mv78xx0_ehci0_resources[] = {
183 .start = USB0_PHYS_BASE,
184 .end = USB0_PHYS_BASE + 0x0fff,
185 .flags = IORESOURCE_MEM,
187 .start = IRQ_MV78XX0_USB_0,
188 .end = IRQ_MV78XX0_USB_0,
189 .flags = IORESOURCE_IRQ,
193 static struct platform_device mv78xx0_ehci0 = {
194 .name = "orion-ehci",
197 .dma_mask = &ehci_dmamask,
198 .coherent_dma_mask = 0xffffffff,
199 .platform_data = &mv78xx0_ehci_data,
201 .resource = mv78xx0_ehci0_resources,
202 .num_resources = ARRAY_SIZE(mv78xx0_ehci0_resources),
205 void __init mv78xx0_ehci0_init(void)
207 platform_device_register(&mv78xx0_ehci0);
211 /*****************************************************************************
213 ****************************************************************************/
214 static struct resource mv78xx0_ehci1_resources[] = {
216 .start = USB1_PHYS_BASE,
217 .end = USB1_PHYS_BASE + 0x0fff,
218 .flags = IORESOURCE_MEM,
220 .start = IRQ_MV78XX0_USB_1,
221 .end = IRQ_MV78XX0_USB_1,
222 .flags = IORESOURCE_IRQ,
226 static struct platform_device mv78xx0_ehci1 = {
227 .name = "orion-ehci",
230 .dma_mask = &ehci_dmamask,
231 .coherent_dma_mask = 0xffffffff,
232 .platform_data = &mv78xx0_ehci_data,
234 .resource = mv78xx0_ehci1_resources,
235 .num_resources = ARRAY_SIZE(mv78xx0_ehci1_resources),
238 void __init mv78xx0_ehci1_init(void)
240 platform_device_register(&mv78xx0_ehci1);
244 /*****************************************************************************
246 ****************************************************************************/
247 static struct resource mv78xx0_ehci2_resources[] = {
249 .start = USB2_PHYS_BASE,
250 .end = USB2_PHYS_BASE + 0x0fff,
251 .flags = IORESOURCE_MEM,
253 .start = IRQ_MV78XX0_USB_2,
254 .end = IRQ_MV78XX0_USB_2,
255 .flags = IORESOURCE_IRQ,
259 static struct platform_device mv78xx0_ehci2 = {
260 .name = "orion-ehci",
263 .dma_mask = &ehci_dmamask,
264 .coherent_dma_mask = 0xffffffff,
265 .platform_data = &mv78xx0_ehci_data,
267 .resource = mv78xx0_ehci2_resources,
268 .num_resources = ARRAY_SIZE(mv78xx0_ehci2_resources),
271 void __init mv78xx0_ehci2_init(void)
273 platform_device_register(&mv78xx0_ehci2);
277 /*****************************************************************************
279 ****************************************************************************/
280 struct mv643xx_eth_shared_platform_data mv78xx0_ge00_shared_data = {
282 .dram = &mv78xx0_mbus_dram_info,
285 static struct resource mv78xx0_ge00_shared_resources[] = {
288 .start = GE00_PHYS_BASE + 0x2000,
289 .end = GE00_PHYS_BASE + 0x3fff,
290 .flags = IORESOURCE_MEM,
292 .name = "ge err irq",
293 .start = IRQ_MV78XX0_GE_ERR,
294 .end = IRQ_MV78XX0_GE_ERR,
295 .flags = IORESOURCE_IRQ,
299 static struct platform_device mv78xx0_ge00_shared = {
300 .name = MV643XX_ETH_SHARED_NAME,
303 .platform_data = &mv78xx0_ge00_shared_data,
305 .num_resources = ARRAY_SIZE(mv78xx0_ge00_shared_resources),
306 .resource = mv78xx0_ge00_shared_resources,
309 static struct resource mv78xx0_ge00_resources[] = {
312 .start = IRQ_MV78XX0_GE00_SUM,
313 .end = IRQ_MV78XX0_GE00_SUM,
314 .flags = IORESOURCE_IRQ,
318 static struct platform_device mv78xx0_ge00 = {
319 .name = MV643XX_ETH_NAME,
322 .resource = mv78xx0_ge00_resources,
325 void __init mv78xx0_ge00_init(struct mv643xx_eth_platform_data *eth_data)
327 eth_data->shared = &mv78xx0_ge00_shared;
328 mv78xx0_ge00.dev.platform_data = eth_data;
330 platform_device_register(&mv78xx0_ge00_shared);
331 platform_device_register(&mv78xx0_ge00);
335 /*****************************************************************************
337 ****************************************************************************/
338 struct mv643xx_eth_shared_platform_data mv78xx0_ge01_shared_data = {
340 .dram = &mv78xx0_mbus_dram_info,
341 .shared_smi = &mv78xx0_ge00_shared,
344 static struct resource mv78xx0_ge01_shared_resources[] = {
347 .start = GE01_PHYS_BASE + 0x2000,
348 .end = GE01_PHYS_BASE + 0x3fff,
349 .flags = IORESOURCE_MEM,
353 static struct platform_device mv78xx0_ge01_shared = {
354 .name = MV643XX_ETH_SHARED_NAME,
357 .platform_data = &mv78xx0_ge01_shared_data,
360 .resource = mv78xx0_ge01_shared_resources,
363 static struct resource mv78xx0_ge01_resources[] = {
366 .start = IRQ_MV78XX0_GE01_SUM,
367 .end = IRQ_MV78XX0_GE01_SUM,
368 .flags = IORESOURCE_IRQ,
372 static struct platform_device mv78xx0_ge01 = {
373 .name = MV643XX_ETH_NAME,
376 .resource = mv78xx0_ge01_resources,
379 void __init mv78xx0_ge01_init(struct mv643xx_eth_platform_data *eth_data)
381 eth_data->shared = &mv78xx0_ge01_shared;
382 mv78xx0_ge01.dev.platform_data = eth_data;
384 platform_device_register(&mv78xx0_ge01_shared);
385 platform_device_register(&mv78xx0_ge01);
389 /*****************************************************************************
391 ****************************************************************************/
392 struct mv643xx_eth_shared_platform_data mv78xx0_ge10_shared_data = {
394 .dram = &mv78xx0_mbus_dram_info,
395 .shared_smi = &mv78xx0_ge00_shared,
398 static struct resource mv78xx0_ge10_shared_resources[] = {
401 .start = GE10_PHYS_BASE + 0x2000,
402 .end = GE10_PHYS_BASE + 0x3fff,
403 .flags = IORESOURCE_MEM,
407 static struct platform_device mv78xx0_ge10_shared = {
408 .name = MV643XX_ETH_SHARED_NAME,
411 .platform_data = &mv78xx0_ge10_shared_data,
414 .resource = mv78xx0_ge10_shared_resources,
417 static struct resource mv78xx0_ge10_resources[] = {
420 .start = IRQ_MV78XX0_GE10_SUM,
421 .end = IRQ_MV78XX0_GE10_SUM,
422 .flags = IORESOURCE_IRQ,
426 static struct platform_device mv78xx0_ge10 = {
427 .name = MV643XX_ETH_NAME,
430 .resource = mv78xx0_ge10_resources,
433 void __init mv78xx0_ge10_init(struct mv643xx_eth_platform_data *eth_data)
437 eth_data->shared = &mv78xx0_ge10_shared;
438 mv78xx0_ge10.dev.platform_data = eth_data;
441 * On the Z0, ge10 and ge11 are internally connected back
442 * to back, and not brought out.
444 mv78xx0_pcie_id(&dev, &rev);
445 if (dev == MV78X00_Z0_DEV_ID) {
446 eth_data->phy_addr = MV643XX_ETH_PHY_NONE;
447 eth_data->speed = SPEED_1000;
448 eth_data->duplex = DUPLEX_FULL;
451 platform_device_register(&mv78xx0_ge10_shared);
452 platform_device_register(&mv78xx0_ge10);
456 /*****************************************************************************
458 ****************************************************************************/
459 struct mv643xx_eth_shared_platform_data mv78xx0_ge11_shared_data = {
461 .dram = &mv78xx0_mbus_dram_info,
462 .shared_smi = &mv78xx0_ge00_shared,
465 static struct resource mv78xx0_ge11_shared_resources[] = {
468 .start = GE11_PHYS_BASE + 0x2000,
469 .end = GE11_PHYS_BASE + 0x3fff,
470 .flags = IORESOURCE_MEM,
474 static struct platform_device mv78xx0_ge11_shared = {
475 .name = MV643XX_ETH_SHARED_NAME,
478 .platform_data = &mv78xx0_ge11_shared_data,
481 .resource = mv78xx0_ge11_shared_resources,
484 static struct resource mv78xx0_ge11_resources[] = {
487 .start = IRQ_MV78XX0_GE11_SUM,
488 .end = IRQ_MV78XX0_GE11_SUM,
489 .flags = IORESOURCE_IRQ,
493 static struct platform_device mv78xx0_ge11 = {
494 .name = MV643XX_ETH_NAME,
497 .resource = mv78xx0_ge11_resources,
500 void __init mv78xx0_ge11_init(struct mv643xx_eth_platform_data *eth_data)
504 eth_data->shared = &mv78xx0_ge11_shared;
505 mv78xx0_ge11.dev.platform_data = eth_data;
508 * On the Z0, ge10 and ge11 are internally connected back
509 * to back, and not brought out.
511 mv78xx0_pcie_id(&dev, &rev);
512 if (dev == MV78X00_Z0_DEV_ID) {
513 eth_data->phy_addr = MV643XX_ETH_PHY_NONE;
514 eth_data->speed = SPEED_1000;
515 eth_data->duplex = DUPLEX_FULL;
518 platform_device_register(&mv78xx0_ge11_shared);
519 platform_device_register(&mv78xx0_ge11);
522 /*****************************************************************************
524 ****************************************************************************/
526 static struct mv64xxx_i2c_pdata mv78xx0_i2c_0_pdata = {
527 .freq_m = 8, /* assumes 166 MHz TCLK */
529 .timeout = 1000, /* Default timeout of 1 second */
532 static struct resource mv78xx0_i2c_0_resources[] = {
534 .name = "i2c 0 base",
535 .start = I2C_0_PHYS_BASE,
536 .end = I2C_0_PHYS_BASE + 0x1f,
537 .flags = IORESOURCE_MEM,
540 .start = IRQ_MV78XX0_I2C_0,
541 .end = IRQ_MV78XX0_I2C_0,
542 .flags = IORESOURCE_IRQ,
547 static struct platform_device mv78xx0_i2c_0 = {
548 .name = MV64XXX_I2C_CTLR_NAME,
550 .num_resources = ARRAY_SIZE(mv78xx0_i2c_0_resources),
551 .resource = mv78xx0_i2c_0_resources,
553 .platform_data = &mv78xx0_i2c_0_pdata,
557 /*****************************************************************************
559 ****************************************************************************/
561 static struct mv64xxx_i2c_pdata mv78xx0_i2c_1_pdata = {
562 .freq_m = 8, /* assumes 166 MHz TCLK */
564 .timeout = 1000, /* Default timeout of 1 second */
567 static struct resource mv78xx0_i2c_1_resources[] = {
569 .name = "i2c 1 base",
570 .start = I2C_1_PHYS_BASE,
571 .end = I2C_1_PHYS_BASE + 0x1f,
572 .flags = IORESOURCE_MEM,
575 .start = IRQ_MV78XX0_I2C_1,
576 .end = IRQ_MV78XX0_I2C_1,
577 .flags = IORESOURCE_IRQ,
582 static struct platform_device mv78xx0_i2c_1 = {
583 .name = MV64XXX_I2C_CTLR_NAME,
585 .num_resources = ARRAY_SIZE(mv78xx0_i2c_1_resources),
586 .resource = mv78xx0_i2c_1_resources,
588 .platform_data = &mv78xx0_i2c_1_pdata,
592 void __init mv78xx0_i2c_init(void)
594 platform_device_register(&mv78xx0_i2c_0);
595 platform_device_register(&mv78xx0_i2c_1);
598 /*****************************************************************************
600 ****************************************************************************/
601 static struct resource mv78xx0_sata_resources[] = {
604 .start = SATA_PHYS_BASE,
605 .end = SATA_PHYS_BASE + 0x5000 - 1,
606 .flags = IORESOURCE_MEM,
609 .start = IRQ_MV78XX0_SATA,
610 .end = IRQ_MV78XX0_SATA,
611 .flags = IORESOURCE_IRQ,
615 static struct platform_device mv78xx0_sata = {
619 .coherent_dma_mask = 0xffffffff,
621 .num_resources = ARRAY_SIZE(mv78xx0_sata_resources),
622 .resource = mv78xx0_sata_resources,
625 void __init mv78xx0_sata_init(struct mv_sata_platform_data *sata_data)
627 sata_data->dram = &mv78xx0_mbus_dram_info;
628 mv78xx0_sata.dev.platform_data = sata_data;
629 platform_device_register(&mv78xx0_sata);
633 /*****************************************************************************
635 ****************************************************************************/
636 static struct plat_serial8250_port mv78xx0_uart0_data[] = {
638 .mapbase = UART0_PHYS_BASE,
639 .membase = (char *)UART0_VIRT_BASE,
640 .irq = IRQ_MV78XX0_UART_0,
641 .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
649 static struct resource mv78xx0_uart0_resources[] = {
651 .start = UART0_PHYS_BASE,
652 .end = UART0_PHYS_BASE + 0xff,
653 .flags = IORESOURCE_MEM,
655 .start = IRQ_MV78XX0_UART_0,
656 .end = IRQ_MV78XX0_UART_0,
657 .flags = IORESOURCE_IRQ,
661 static struct platform_device mv78xx0_uart0 = {
662 .name = "serial8250",
665 .platform_data = mv78xx0_uart0_data,
667 .resource = mv78xx0_uart0_resources,
668 .num_resources = ARRAY_SIZE(mv78xx0_uart0_resources),
671 void __init mv78xx0_uart0_init(void)
673 platform_device_register(&mv78xx0_uart0);
677 /*****************************************************************************
679 ****************************************************************************/
680 static struct plat_serial8250_port mv78xx0_uart1_data[] = {
682 .mapbase = UART1_PHYS_BASE,
683 .membase = (char *)UART1_VIRT_BASE,
684 .irq = IRQ_MV78XX0_UART_1,
685 .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
693 static struct resource mv78xx0_uart1_resources[] = {
695 .start = UART1_PHYS_BASE,
696 .end = UART1_PHYS_BASE + 0xff,
697 .flags = IORESOURCE_MEM,
699 .start = IRQ_MV78XX0_UART_1,
700 .end = IRQ_MV78XX0_UART_1,
701 .flags = IORESOURCE_IRQ,
705 static struct platform_device mv78xx0_uart1 = {
706 .name = "serial8250",
709 .platform_data = mv78xx0_uart1_data,
711 .resource = mv78xx0_uart1_resources,
712 .num_resources = ARRAY_SIZE(mv78xx0_uart1_resources),
715 void __init mv78xx0_uart1_init(void)
717 platform_device_register(&mv78xx0_uart1);
721 /*****************************************************************************
723 ****************************************************************************/
724 static struct plat_serial8250_port mv78xx0_uart2_data[] = {
726 .mapbase = UART2_PHYS_BASE,
727 .membase = (char *)UART2_VIRT_BASE,
728 .irq = IRQ_MV78XX0_UART_2,
729 .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
737 static struct resource mv78xx0_uart2_resources[] = {
739 .start = UART2_PHYS_BASE,
740 .end = UART2_PHYS_BASE + 0xff,
741 .flags = IORESOURCE_MEM,
743 .start = IRQ_MV78XX0_UART_2,
744 .end = IRQ_MV78XX0_UART_2,
745 .flags = IORESOURCE_IRQ,
749 static struct platform_device mv78xx0_uart2 = {
750 .name = "serial8250",
753 .platform_data = mv78xx0_uart2_data,
755 .resource = mv78xx0_uart2_resources,
756 .num_resources = ARRAY_SIZE(mv78xx0_uart2_resources),
759 void __init mv78xx0_uart2_init(void)
761 platform_device_register(&mv78xx0_uart2);
765 /*****************************************************************************
767 ****************************************************************************/
768 static struct plat_serial8250_port mv78xx0_uart3_data[] = {
770 .mapbase = UART3_PHYS_BASE,
771 .membase = (char *)UART3_VIRT_BASE,
772 .irq = IRQ_MV78XX0_UART_3,
773 .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
781 static struct resource mv78xx0_uart3_resources[] = {
783 .start = UART3_PHYS_BASE,
784 .end = UART3_PHYS_BASE + 0xff,
785 .flags = IORESOURCE_MEM,
787 .start = IRQ_MV78XX0_UART_3,
788 .end = IRQ_MV78XX0_UART_3,
789 .flags = IORESOURCE_IRQ,
793 static struct platform_device mv78xx0_uart3 = {
794 .name = "serial8250",
797 .platform_data = mv78xx0_uart3_data,
799 .resource = mv78xx0_uart3_resources,
800 .num_resources = ARRAY_SIZE(mv78xx0_uart3_resources),
803 void __init mv78xx0_uart3_init(void)
805 platform_device_register(&mv78xx0_uart3);
809 /*****************************************************************************
811 ****************************************************************************/
812 static void mv78xx0_timer_init(void)
814 orion_time_init(IRQ_MV78XX0_TIMER_1, get_tclk());
817 struct sys_timer mv78xx0_timer = {
818 .init = mv78xx0_timer_init,
822 /*****************************************************************************
824 ****************************************************************************/
825 static char * __init mv78xx0_id(void)
829 mv78xx0_pcie_id(&dev, &rev);
831 if (dev == MV78X00_Z0_DEV_ID) {
832 if (rev == MV78X00_REV_Z0)
835 return "MV78X00-Rev-Unsupported";
836 } else if (dev == MV78100_DEV_ID) {
837 if (rev == MV78100_REV_A0)
840 return "MV78100-Rev-Unsupported";
841 } else if (dev == MV78200_DEV_ID) {
842 if (rev == MV78100_REV_A0)
845 return "MV78200-Rev-Unsupported";
847 return "Device-Unknown";
851 static int __init is_l2_writethrough(void)
853 return !!(readl(CPU_CONTROL) & L2_WRITETHROUGH);
856 void __init mv78xx0_init(void)
864 core_index = mv78xx0_core_index();
866 get_pclk_l2clk(hclk, core_index, &pclk, &l2clk);
869 printk(KERN_INFO "%s ", mv78xx0_id());
870 printk("core #%d, ", core_index);
871 printk("PCLK = %dMHz, ", (pclk + 499999) / 1000000);
872 printk("L2 = %dMHz, ", (l2clk + 499999) / 1000000);
873 printk("HCLK = %dMHz, ", (hclk + 499999) / 1000000);
874 printk("TCLK = %dMHz\n", (tclk + 499999) / 1000000);
876 mv78xx0_setup_cpu_mbus();
878 #ifdef CONFIG_CACHE_FEROCEON_L2
879 feroceon_l2_init(is_l2_writethrough());
882 mv78xx0_ge00_shared_data.t_clk = tclk;
883 mv78xx0_ge01_shared_data.t_clk = tclk;
884 mv78xx0_ge10_shared_data.t_clk = tclk;
885 mv78xx0_ge11_shared_data.t_clk = tclk;
886 mv78xx0_uart0_data[0].uartclk = tclk;
887 mv78xx0_uart1_data[0].uartclk = tclk;
888 mv78xx0_uart2_data[0].uartclk = tclk;
889 mv78xx0_uart3_data[0].uartclk = tclk;