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 <mach/bridge-regs.h>
24 #include <plat/cache-feroceon-l2.h>
25 #include <plat/ehci-orion.h>
26 #include <plat/orion_nand.h>
27 #include <plat/time.h>
31 /*****************************************************************************
33 ****************************************************************************/
34 int mv78xx0_core_index(void)
39 * Read Extra Features register.
41 __asm__("mrc p15, 1, %0, c15, c1, 0" : "=r" (extra));
43 return !!(extra & 0x00004000);
46 static int get_hclk(void)
51 * HCLK tick rate is configured by DEV_D[7:5] pins.
53 switch ((readl(SAMPLE_AT_RESET_LOW) >> 5) & 7) {
70 panic("unknown HCLK PLL setting: %.8x\n",
71 readl(SAMPLE_AT_RESET_LOW));
77 static void get_pclk_l2clk(int hclk, int core_index, int *pclk, int *l2clk)
82 * Core #0 PCLK/L2CLK is configured by bits [13:8], core #1
83 * PCLK/L2CLK by bits [19:14].
85 if (core_index == 0) {
86 cfg = (readl(SAMPLE_AT_RESET_LOW) >> 8) & 0x3f;
88 cfg = (readl(SAMPLE_AT_RESET_LOW) >> 14) & 0x3f;
92 * Bits [11:8] ([17:14] for core #1) configure the PCLK:HCLK
93 * ratio (1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5, 5.5, 6).
95 *pclk = ((u64)hclk * (2 + (cfg & 0xf))) >> 1;
98 * Bits [13:12] ([19:18] for core #1) configure the PCLK:L2CLK
101 *l2clk = *pclk / (((cfg >> 4) & 3) + 1);
104 static int get_tclk(void)
109 * TCLK tick rate is configured by DEV_A[2:0] strap pins.
111 switch ((readl(SAMPLE_AT_RESET_HIGH) >> 6) & 7) {
119 panic("unknown TCLK PLL setting: %.8x\n",
120 readl(SAMPLE_AT_RESET_HIGH));
127 /*****************************************************************************
128 * I/O Address Mapping
129 ****************************************************************************/
130 static struct map_desc mv78xx0_io_desc[] __initdata = {
132 .virtual = MV78XX0_CORE_REGS_VIRT_BASE,
134 .length = MV78XX0_CORE_REGS_SIZE,
137 .virtual = MV78XX0_PCIE_IO_VIRT_BASE(0),
138 .pfn = __phys_to_pfn(MV78XX0_PCIE_IO_PHYS_BASE(0)),
139 .length = MV78XX0_PCIE_IO_SIZE * 8,
142 .virtual = MV78XX0_REGS_VIRT_BASE,
143 .pfn = __phys_to_pfn(MV78XX0_REGS_PHYS_BASE),
144 .length = MV78XX0_REGS_SIZE,
149 void __init mv78xx0_map_io(void)
154 * Map the right set of per-core registers depending on
155 * which core we are running on.
157 if (mv78xx0_core_index() == 0) {
158 phys = MV78XX0_CORE0_REGS_PHYS_BASE;
160 phys = MV78XX0_CORE1_REGS_PHYS_BASE;
162 mv78xx0_io_desc[0].pfn = __phys_to_pfn(phys);
164 iotable_init(mv78xx0_io_desc, ARRAY_SIZE(mv78xx0_io_desc));
168 /*****************************************************************************
170 ****************************************************************************/
171 static struct orion_ehci_data mv78xx0_ehci_data = {
172 .dram = &mv78xx0_mbus_dram_info,
173 .phy_version = EHCI_PHY_NA,
176 static u64 ehci_dmamask = 0xffffffffUL;
179 /*****************************************************************************
181 ****************************************************************************/
182 static struct resource mv78xx0_ehci0_resources[] = {
184 .start = USB0_PHYS_BASE,
185 .end = USB0_PHYS_BASE + 0x0fff,
186 .flags = IORESOURCE_MEM,
188 .start = IRQ_MV78XX0_USB_0,
189 .end = IRQ_MV78XX0_USB_0,
190 .flags = IORESOURCE_IRQ,
194 static struct platform_device mv78xx0_ehci0 = {
195 .name = "orion-ehci",
198 .dma_mask = &ehci_dmamask,
199 .coherent_dma_mask = 0xffffffff,
200 .platform_data = &mv78xx0_ehci_data,
202 .resource = mv78xx0_ehci0_resources,
203 .num_resources = ARRAY_SIZE(mv78xx0_ehci0_resources),
206 void __init mv78xx0_ehci0_init(void)
208 platform_device_register(&mv78xx0_ehci0);
212 /*****************************************************************************
214 ****************************************************************************/
215 static struct resource mv78xx0_ehci1_resources[] = {
217 .start = USB1_PHYS_BASE,
218 .end = USB1_PHYS_BASE + 0x0fff,
219 .flags = IORESOURCE_MEM,
221 .start = IRQ_MV78XX0_USB_1,
222 .end = IRQ_MV78XX0_USB_1,
223 .flags = IORESOURCE_IRQ,
227 static struct platform_device mv78xx0_ehci1 = {
228 .name = "orion-ehci",
231 .dma_mask = &ehci_dmamask,
232 .coherent_dma_mask = 0xffffffff,
233 .platform_data = &mv78xx0_ehci_data,
235 .resource = mv78xx0_ehci1_resources,
236 .num_resources = ARRAY_SIZE(mv78xx0_ehci1_resources),
239 void __init mv78xx0_ehci1_init(void)
241 platform_device_register(&mv78xx0_ehci1);
245 /*****************************************************************************
247 ****************************************************************************/
248 static struct resource mv78xx0_ehci2_resources[] = {
250 .start = USB2_PHYS_BASE,
251 .end = USB2_PHYS_BASE + 0x0fff,
252 .flags = IORESOURCE_MEM,
254 .start = IRQ_MV78XX0_USB_2,
255 .end = IRQ_MV78XX0_USB_2,
256 .flags = IORESOURCE_IRQ,
260 static struct platform_device mv78xx0_ehci2 = {
261 .name = "orion-ehci",
264 .dma_mask = &ehci_dmamask,
265 .coherent_dma_mask = 0xffffffff,
266 .platform_data = &mv78xx0_ehci_data,
268 .resource = mv78xx0_ehci2_resources,
269 .num_resources = ARRAY_SIZE(mv78xx0_ehci2_resources),
272 void __init mv78xx0_ehci2_init(void)
274 platform_device_register(&mv78xx0_ehci2);
278 /*****************************************************************************
280 ****************************************************************************/
281 struct mv643xx_eth_shared_platform_data mv78xx0_ge00_shared_data = {
283 .dram = &mv78xx0_mbus_dram_info,
286 static struct resource mv78xx0_ge00_shared_resources[] = {
289 .start = GE00_PHYS_BASE + 0x2000,
290 .end = GE00_PHYS_BASE + 0x3fff,
291 .flags = IORESOURCE_MEM,
293 .name = "ge err irq",
294 .start = IRQ_MV78XX0_GE_ERR,
295 .end = IRQ_MV78XX0_GE_ERR,
296 .flags = IORESOURCE_IRQ,
300 static struct platform_device mv78xx0_ge00_shared = {
301 .name = MV643XX_ETH_SHARED_NAME,
304 .platform_data = &mv78xx0_ge00_shared_data,
306 .num_resources = ARRAY_SIZE(mv78xx0_ge00_shared_resources),
307 .resource = mv78xx0_ge00_shared_resources,
310 static struct resource mv78xx0_ge00_resources[] = {
313 .start = IRQ_MV78XX0_GE00_SUM,
314 .end = IRQ_MV78XX0_GE00_SUM,
315 .flags = IORESOURCE_IRQ,
319 static struct platform_device mv78xx0_ge00 = {
320 .name = MV643XX_ETH_NAME,
323 .resource = mv78xx0_ge00_resources,
325 .coherent_dma_mask = 0xffffffff,
329 void __init mv78xx0_ge00_init(struct mv643xx_eth_platform_data *eth_data)
331 eth_data->shared = &mv78xx0_ge00_shared;
332 mv78xx0_ge00.dev.platform_data = eth_data;
334 platform_device_register(&mv78xx0_ge00_shared);
335 platform_device_register(&mv78xx0_ge00);
339 /*****************************************************************************
341 ****************************************************************************/
342 struct mv643xx_eth_shared_platform_data mv78xx0_ge01_shared_data = {
344 .dram = &mv78xx0_mbus_dram_info,
345 .shared_smi = &mv78xx0_ge00_shared,
348 static struct resource mv78xx0_ge01_shared_resources[] = {
351 .start = GE01_PHYS_BASE + 0x2000,
352 .end = GE01_PHYS_BASE + 0x3fff,
353 .flags = IORESOURCE_MEM,
357 static struct platform_device mv78xx0_ge01_shared = {
358 .name = MV643XX_ETH_SHARED_NAME,
361 .platform_data = &mv78xx0_ge01_shared_data,
364 .resource = mv78xx0_ge01_shared_resources,
367 static struct resource mv78xx0_ge01_resources[] = {
370 .start = IRQ_MV78XX0_GE01_SUM,
371 .end = IRQ_MV78XX0_GE01_SUM,
372 .flags = IORESOURCE_IRQ,
376 static struct platform_device mv78xx0_ge01 = {
377 .name = MV643XX_ETH_NAME,
380 .resource = mv78xx0_ge01_resources,
382 .coherent_dma_mask = 0xffffffff,
386 void __init mv78xx0_ge01_init(struct mv643xx_eth_platform_data *eth_data)
388 eth_data->shared = &mv78xx0_ge01_shared;
389 mv78xx0_ge01.dev.platform_data = eth_data;
391 platform_device_register(&mv78xx0_ge01_shared);
392 platform_device_register(&mv78xx0_ge01);
396 /*****************************************************************************
398 ****************************************************************************/
399 struct mv643xx_eth_shared_platform_data mv78xx0_ge10_shared_data = {
401 .dram = &mv78xx0_mbus_dram_info,
402 .shared_smi = &mv78xx0_ge00_shared,
405 static struct resource mv78xx0_ge10_shared_resources[] = {
408 .start = GE10_PHYS_BASE + 0x2000,
409 .end = GE10_PHYS_BASE + 0x3fff,
410 .flags = IORESOURCE_MEM,
414 static struct platform_device mv78xx0_ge10_shared = {
415 .name = MV643XX_ETH_SHARED_NAME,
418 .platform_data = &mv78xx0_ge10_shared_data,
421 .resource = mv78xx0_ge10_shared_resources,
424 static struct resource mv78xx0_ge10_resources[] = {
427 .start = IRQ_MV78XX0_GE10_SUM,
428 .end = IRQ_MV78XX0_GE10_SUM,
429 .flags = IORESOURCE_IRQ,
433 static struct platform_device mv78xx0_ge10 = {
434 .name = MV643XX_ETH_NAME,
437 .resource = mv78xx0_ge10_resources,
439 .coherent_dma_mask = 0xffffffff,
443 void __init mv78xx0_ge10_init(struct mv643xx_eth_platform_data *eth_data)
447 eth_data->shared = &mv78xx0_ge10_shared;
448 mv78xx0_ge10.dev.platform_data = eth_data;
451 * On the Z0, ge10 and ge11 are internally connected back
452 * to back, and not brought out.
454 mv78xx0_pcie_id(&dev, &rev);
455 if (dev == MV78X00_Z0_DEV_ID) {
456 eth_data->phy_addr = MV643XX_ETH_PHY_NONE;
457 eth_data->speed = SPEED_1000;
458 eth_data->duplex = DUPLEX_FULL;
461 platform_device_register(&mv78xx0_ge10_shared);
462 platform_device_register(&mv78xx0_ge10);
466 /*****************************************************************************
468 ****************************************************************************/
469 struct mv643xx_eth_shared_platform_data mv78xx0_ge11_shared_data = {
471 .dram = &mv78xx0_mbus_dram_info,
472 .shared_smi = &mv78xx0_ge00_shared,
475 static struct resource mv78xx0_ge11_shared_resources[] = {
478 .start = GE11_PHYS_BASE + 0x2000,
479 .end = GE11_PHYS_BASE + 0x3fff,
480 .flags = IORESOURCE_MEM,
484 static struct platform_device mv78xx0_ge11_shared = {
485 .name = MV643XX_ETH_SHARED_NAME,
488 .platform_data = &mv78xx0_ge11_shared_data,
491 .resource = mv78xx0_ge11_shared_resources,
494 static struct resource mv78xx0_ge11_resources[] = {
497 .start = IRQ_MV78XX0_GE11_SUM,
498 .end = IRQ_MV78XX0_GE11_SUM,
499 .flags = IORESOURCE_IRQ,
503 static struct platform_device mv78xx0_ge11 = {
504 .name = MV643XX_ETH_NAME,
507 .resource = mv78xx0_ge11_resources,
509 .coherent_dma_mask = 0xffffffff,
513 void __init mv78xx0_ge11_init(struct mv643xx_eth_platform_data *eth_data)
517 eth_data->shared = &mv78xx0_ge11_shared;
518 mv78xx0_ge11.dev.platform_data = eth_data;
521 * On the Z0, ge10 and ge11 are internally connected back
522 * to back, and not brought out.
524 mv78xx0_pcie_id(&dev, &rev);
525 if (dev == MV78X00_Z0_DEV_ID) {
526 eth_data->phy_addr = MV643XX_ETH_PHY_NONE;
527 eth_data->speed = SPEED_1000;
528 eth_data->duplex = DUPLEX_FULL;
531 platform_device_register(&mv78xx0_ge11_shared);
532 platform_device_register(&mv78xx0_ge11);
535 /*****************************************************************************
537 ****************************************************************************/
539 static struct mv64xxx_i2c_pdata mv78xx0_i2c_0_pdata = {
540 .freq_m = 8, /* assumes 166 MHz TCLK */
542 .timeout = 1000, /* Default timeout of 1 second */
545 static struct resource mv78xx0_i2c_0_resources[] = {
547 .start = I2C_0_PHYS_BASE,
548 .end = I2C_0_PHYS_BASE + 0x1f,
549 .flags = IORESOURCE_MEM,
551 .start = IRQ_MV78XX0_I2C_0,
552 .end = IRQ_MV78XX0_I2C_0,
553 .flags = IORESOURCE_IRQ,
558 static struct platform_device mv78xx0_i2c_0 = {
559 .name = MV64XXX_I2C_CTLR_NAME,
561 .num_resources = ARRAY_SIZE(mv78xx0_i2c_0_resources),
562 .resource = mv78xx0_i2c_0_resources,
564 .platform_data = &mv78xx0_i2c_0_pdata,
568 /*****************************************************************************
570 ****************************************************************************/
572 static struct mv64xxx_i2c_pdata mv78xx0_i2c_1_pdata = {
573 .freq_m = 8, /* assumes 166 MHz TCLK */
575 .timeout = 1000, /* Default timeout of 1 second */
578 static struct resource mv78xx0_i2c_1_resources[] = {
580 .start = I2C_1_PHYS_BASE,
581 .end = I2C_1_PHYS_BASE + 0x1f,
582 .flags = IORESOURCE_MEM,
584 .start = IRQ_MV78XX0_I2C_1,
585 .end = IRQ_MV78XX0_I2C_1,
586 .flags = IORESOURCE_IRQ,
591 static struct platform_device mv78xx0_i2c_1 = {
592 .name = MV64XXX_I2C_CTLR_NAME,
594 .num_resources = ARRAY_SIZE(mv78xx0_i2c_1_resources),
595 .resource = mv78xx0_i2c_1_resources,
597 .platform_data = &mv78xx0_i2c_1_pdata,
601 void __init mv78xx0_i2c_init(void)
603 platform_device_register(&mv78xx0_i2c_0);
604 platform_device_register(&mv78xx0_i2c_1);
607 /*****************************************************************************
609 ****************************************************************************/
610 static struct resource mv78xx0_sata_resources[] = {
613 .start = SATA_PHYS_BASE,
614 .end = SATA_PHYS_BASE + 0x5000 - 1,
615 .flags = IORESOURCE_MEM,
618 .start = IRQ_MV78XX0_SATA,
619 .end = IRQ_MV78XX0_SATA,
620 .flags = IORESOURCE_IRQ,
624 static struct platform_device mv78xx0_sata = {
628 .coherent_dma_mask = 0xffffffff,
630 .num_resources = ARRAY_SIZE(mv78xx0_sata_resources),
631 .resource = mv78xx0_sata_resources,
634 void __init mv78xx0_sata_init(struct mv_sata_platform_data *sata_data)
636 sata_data->dram = &mv78xx0_mbus_dram_info;
637 mv78xx0_sata.dev.platform_data = sata_data;
638 platform_device_register(&mv78xx0_sata);
642 /*****************************************************************************
644 ****************************************************************************/
645 static struct plat_serial8250_port mv78xx0_uart0_data[] = {
647 .mapbase = UART0_PHYS_BASE,
648 .membase = (char *)UART0_VIRT_BASE,
649 .irq = IRQ_MV78XX0_UART_0,
650 .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
658 static struct resource mv78xx0_uart0_resources[] = {
660 .start = UART0_PHYS_BASE,
661 .end = UART0_PHYS_BASE + 0xff,
662 .flags = IORESOURCE_MEM,
664 .start = IRQ_MV78XX0_UART_0,
665 .end = IRQ_MV78XX0_UART_0,
666 .flags = IORESOURCE_IRQ,
670 static struct platform_device mv78xx0_uart0 = {
671 .name = "serial8250",
674 .platform_data = mv78xx0_uart0_data,
676 .resource = mv78xx0_uart0_resources,
677 .num_resources = ARRAY_SIZE(mv78xx0_uart0_resources),
680 void __init mv78xx0_uart0_init(void)
682 platform_device_register(&mv78xx0_uart0);
686 /*****************************************************************************
688 ****************************************************************************/
689 static struct plat_serial8250_port mv78xx0_uart1_data[] = {
691 .mapbase = UART1_PHYS_BASE,
692 .membase = (char *)UART1_VIRT_BASE,
693 .irq = IRQ_MV78XX0_UART_1,
694 .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
702 static struct resource mv78xx0_uart1_resources[] = {
704 .start = UART1_PHYS_BASE,
705 .end = UART1_PHYS_BASE + 0xff,
706 .flags = IORESOURCE_MEM,
708 .start = IRQ_MV78XX0_UART_1,
709 .end = IRQ_MV78XX0_UART_1,
710 .flags = IORESOURCE_IRQ,
714 static struct platform_device mv78xx0_uart1 = {
715 .name = "serial8250",
718 .platform_data = mv78xx0_uart1_data,
720 .resource = mv78xx0_uart1_resources,
721 .num_resources = ARRAY_SIZE(mv78xx0_uart1_resources),
724 void __init mv78xx0_uart1_init(void)
726 platform_device_register(&mv78xx0_uart1);
730 /*****************************************************************************
732 ****************************************************************************/
733 static struct plat_serial8250_port mv78xx0_uart2_data[] = {
735 .mapbase = UART2_PHYS_BASE,
736 .membase = (char *)UART2_VIRT_BASE,
737 .irq = IRQ_MV78XX0_UART_2,
738 .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
746 static struct resource mv78xx0_uart2_resources[] = {
748 .start = UART2_PHYS_BASE,
749 .end = UART2_PHYS_BASE + 0xff,
750 .flags = IORESOURCE_MEM,
752 .start = IRQ_MV78XX0_UART_2,
753 .end = IRQ_MV78XX0_UART_2,
754 .flags = IORESOURCE_IRQ,
758 static struct platform_device mv78xx0_uart2 = {
759 .name = "serial8250",
762 .platform_data = mv78xx0_uart2_data,
764 .resource = mv78xx0_uart2_resources,
765 .num_resources = ARRAY_SIZE(mv78xx0_uart2_resources),
768 void __init mv78xx0_uart2_init(void)
770 platform_device_register(&mv78xx0_uart2);
774 /*****************************************************************************
776 ****************************************************************************/
777 static struct plat_serial8250_port mv78xx0_uart3_data[] = {
779 .mapbase = UART3_PHYS_BASE,
780 .membase = (char *)UART3_VIRT_BASE,
781 .irq = IRQ_MV78XX0_UART_3,
782 .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
790 static struct resource mv78xx0_uart3_resources[] = {
792 .start = UART3_PHYS_BASE,
793 .end = UART3_PHYS_BASE + 0xff,
794 .flags = IORESOURCE_MEM,
796 .start = IRQ_MV78XX0_UART_3,
797 .end = IRQ_MV78XX0_UART_3,
798 .flags = IORESOURCE_IRQ,
802 static struct platform_device mv78xx0_uart3 = {
803 .name = "serial8250",
806 .platform_data = mv78xx0_uart3_data,
808 .resource = mv78xx0_uart3_resources,
809 .num_resources = ARRAY_SIZE(mv78xx0_uart3_resources),
812 void __init mv78xx0_uart3_init(void)
814 platform_device_register(&mv78xx0_uart3);
818 /*****************************************************************************
820 ****************************************************************************/
821 static void mv78xx0_timer_init(void)
823 orion_time_init(IRQ_MV78XX0_TIMER_1, get_tclk());
826 struct sys_timer mv78xx0_timer = {
827 .init = mv78xx0_timer_init,
831 /*****************************************************************************
833 ****************************************************************************/
834 static char * __init mv78xx0_id(void)
838 mv78xx0_pcie_id(&dev, &rev);
840 if (dev == MV78X00_Z0_DEV_ID) {
841 if (rev == MV78X00_REV_Z0)
844 return "MV78X00-Rev-Unsupported";
845 } else if (dev == MV78100_DEV_ID) {
846 if (rev == MV78100_REV_A0)
849 return "MV78100-Rev-Unsupported";
850 } else if (dev == MV78200_DEV_ID) {
851 if (rev == MV78100_REV_A0)
854 return "MV78200-Rev-Unsupported";
856 return "Device-Unknown";
860 static int __init is_l2_writethrough(void)
862 return !!(readl(CPU_CONTROL) & L2_WRITETHROUGH);
865 void __init mv78xx0_init(void)
873 core_index = mv78xx0_core_index();
875 get_pclk_l2clk(hclk, core_index, &pclk, &l2clk);
878 printk(KERN_INFO "%s ", mv78xx0_id());
879 printk("core #%d, ", core_index);
880 printk("PCLK = %dMHz, ", (pclk + 499999) / 1000000);
881 printk("L2 = %dMHz, ", (l2clk + 499999) / 1000000);
882 printk("HCLK = %dMHz, ", (hclk + 499999) / 1000000);
883 printk("TCLK = %dMHz\n", (tclk + 499999) / 1000000);
885 mv78xx0_setup_cpu_mbus();
887 #ifdef CONFIG_CACHE_FEROCEON_L2
888 feroceon_l2_init(is_l2_writethrough());
891 mv78xx0_ge00_shared_data.t_clk = tclk;
892 mv78xx0_ge01_shared_data.t_clk = tclk;
893 mv78xx0_ge10_shared_data.t_clk = tclk;
894 mv78xx0_ge11_shared_data.t_clk = tclk;
895 mv78xx0_uart0_data[0].uartclk = tclk;
896 mv78xx0_uart1_data[0].uartclk = tclk;
897 mv78xx0_uart2_data[0].uartclk = tclk;
898 mv78xx0_uart3_data[0].uartclk = tclk;