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/ata_platform.h>
17 #include <linux/mtd/nand.h>
18 #include <linux/spi/orion_spi.h>
21 #include <asm/timex.h>
22 #include <asm/kexec.h>
23 #include <asm/mach/map.h>
24 #include <asm/mach/time.h>
25 #include <mach/kirkwood.h>
26 #include <mach/bridge-regs.h>
27 #include <plat/audio.h>
28 #include <plat/cache-feroceon-l2.h>
29 #include <plat/ehci-orion.h>
30 #include <plat/mvsdio.h>
31 #include <plat/mv_xor.h>
32 #include <plat/orion_nand.h>
33 #include <plat/orion_wdt.h>
34 #include <plat/common.h>
35 #include <plat/time.h>
38 /*****************************************************************************
40 ****************************************************************************/
41 static struct map_desc kirkwood_io_desc[] __initdata = {
43 .virtual = KIRKWOOD_PCIE_IO_VIRT_BASE,
44 .pfn = __phys_to_pfn(KIRKWOOD_PCIE_IO_PHYS_BASE),
45 .length = KIRKWOOD_PCIE_IO_SIZE,
48 .virtual = KIRKWOOD_PCIE1_IO_VIRT_BASE,
49 .pfn = __phys_to_pfn(KIRKWOOD_PCIE1_IO_PHYS_BASE),
50 .length = KIRKWOOD_PCIE1_IO_SIZE,
53 .virtual = KIRKWOOD_REGS_VIRT_BASE,
54 .pfn = __phys_to_pfn(KIRKWOOD_REGS_PHYS_BASE),
55 .length = KIRKWOOD_REGS_SIZE,
60 void __init kirkwood_map_io(void)
62 iotable_init(kirkwood_io_desc, ARRAY_SIZE(kirkwood_io_desc));
66 * Default clock control bits. Any bit _not_ set in this variable
67 * will be cleared from the hardware after platform devices have been
68 * registered. Some reserved bits must be set to 1.
70 unsigned int kirkwood_clk_ctrl = CGC_DUNIT | CGC_RESERVED;
73 /*****************************************************************************
75 ****************************************************************************/
76 static struct orion_ehci_data kirkwood_ehci_data = {
77 .dram = &kirkwood_mbus_dram_info,
78 .phy_version = EHCI_PHY_NA,
81 static u64 ehci_dmamask = DMA_BIT_MASK(32);
84 /*****************************************************************************
86 ****************************************************************************/
87 static struct resource kirkwood_ehci_resources[] = {
89 .start = USB_PHYS_BASE,
90 .end = USB_PHYS_BASE + SZ_4K - 1,
91 .flags = IORESOURCE_MEM,
93 .start = IRQ_KIRKWOOD_USB,
94 .end = IRQ_KIRKWOOD_USB,
95 .flags = IORESOURCE_IRQ,
99 static struct platform_device kirkwood_ehci = {
100 .name = "orion-ehci",
103 .dma_mask = &ehci_dmamask,
104 .coherent_dma_mask = DMA_BIT_MASK(32),
105 .platform_data = &kirkwood_ehci_data,
107 .resource = kirkwood_ehci_resources,
108 .num_resources = ARRAY_SIZE(kirkwood_ehci_resources),
111 void __init kirkwood_ehci_init(void)
113 kirkwood_clk_ctrl |= CGC_USB0;
114 platform_device_register(&kirkwood_ehci);
118 /*****************************************************************************
120 ****************************************************************************/
121 void __init kirkwood_ge00_init(struct mv643xx_eth_platform_data *eth_data)
123 kirkwood_clk_ctrl |= CGC_GE0;
125 orion_ge00_init(eth_data, &kirkwood_mbus_dram_info,
126 GE00_PHYS_BASE, IRQ_KIRKWOOD_GE00_SUM,
127 IRQ_KIRKWOOD_GE00_ERR, kirkwood_tclk);
131 /*****************************************************************************
133 ****************************************************************************/
134 void __init kirkwood_ge01_init(struct mv643xx_eth_platform_data *eth_data)
137 kirkwood_clk_ctrl |= CGC_GE1;
139 orion_ge01_init(eth_data, &kirkwood_mbus_dram_info,
140 GE01_PHYS_BASE, IRQ_KIRKWOOD_GE01_SUM,
141 IRQ_KIRKWOOD_GE01_ERR, kirkwood_tclk);
145 /*****************************************************************************
147 ****************************************************************************/
148 void __init kirkwood_ge00_switch_init(struct dsa_platform_data *d, int irq)
150 orion_ge00_switch_init(d, irq);
154 /*****************************************************************************
156 ****************************************************************************/
157 static struct resource kirkwood_nand_resource = {
158 .flags = IORESOURCE_MEM,
159 .start = KIRKWOOD_NAND_MEM_PHYS_BASE,
160 .end = KIRKWOOD_NAND_MEM_PHYS_BASE +
161 KIRKWOOD_NAND_MEM_SIZE - 1,
164 static struct orion_nand_data kirkwood_nand_data = {
170 static struct platform_device kirkwood_nand_flash = {
171 .name = "orion_nand",
174 .platform_data = &kirkwood_nand_data,
176 .resource = &kirkwood_nand_resource,
180 void __init kirkwood_nand_init(struct mtd_partition *parts, int nr_parts,
183 kirkwood_clk_ctrl |= CGC_RUNIT;
184 kirkwood_nand_data.parts = parts;
185 kirkwood_nand_data.nr_parts = nr_parts;
186 kirkwood_nand_data.chip_delay = chip_delay;
187 platform_device_register(&kirkwood_nand_flash);
190 void __init kirkwood_nand_init_rnb(struct mtd_partition *parts, int nr_parts,
191 int (*dev_ready)(struct mtd_info *))
193 kirkwood_clk_ctrl |= CGC_RUNIT;
194 kirkwood_nand_data.parts = parts;
195 kirkwood_nand_data.nr_parts = nr_parts;
196 kirkwood_nand_data.dev_ready = dev_ready;
197 platform_device_register(&kirkwood_nand_flash);
200 /*****************************************************************************
202 ****************************************************************************/
203 static void __init kirkwood_rtc_init(void)
205 orion_rtc_init(RTC_PHYS_BASE, IRQ_KIRKWOOD_RTC);
209 /*****************************************************************************
211 ****************************************************************************/
212 static struct resource kirkwood_sata_resources[] = {
215 .start = SATA_PHYS_BASE,
216 .end = SATA_PHYS_BASE + 0x5000 - 1,
217 .flags = IORESOURCE_MEM,
220 .start = IRQ_KIRKWOOD_SATA,
221 .end = IRQ_KIRKWOOD_SATA,
222 .flags = IORESOURCE_IRQ,
226 static struct platform_device kirkwood_sata = {
230 .coherent_dma_mask = DMA_BIT_MASK(32),
232 .num_resources = ARRAY_SIZE(kirkwood_sata_resources),
233 .resource = kirkwood_sata_resources,
236 void __init kirkwood_sata_init(struct mv_sata_platform_data *sata_data)
238 kirkwood_clk_ctrl |= CGC_SATA0;
239 if (sata_data->n_ports > 1)
240 kirkwood_clk_ctrl |= CGC_SATA1;
241 sata_data->dram = &kirkwood_mbus_dram_info;
242 kirkwood_sata.dev.platform_data = sata_data;
243 platform_device_register(&kirkwood_sata);
247 /*****************************************************************************
249 ****************************************************************************/
250 static struct resource mvsdio_resources[] = {
252 .start = SDIO_PHYS_BASE,
253 .end = SDIO_PHYS_BASE + SZ_1K - 1,
254 .flags = IORESOURCE_MEM,
257 .start = IRQ_KIRKWOOD_SDIO,
258 .end = IRQ_KIRKWOOD_SDIO,
259 .flags = IORESOURCE_IRQ,
263 static u64 mvsdio_dmamask = DMA_BIT_MASK(32);
265 static struct platform_device kirkwood_sdio = {
269 .dma_mask = &mvsdio_dmamask,
270 .coherent_dma_mask = DMA_BIT_MASK(32),
272 .num_resources = ARRAY_SIZE(mvsdio_resources),
273 .resource = mvsdio_resources,
276 void __init kirkwood_sdio_init(struct mvsdio_platform_data *mvsdio_data)
280 kirkwood_pcie_id(&dev, &rev);
281 if (rev == 0 && dev != MV88F6282_DEV_ID) /* catch all Kirkwood Z0's */
282 mvsdio_data->clock = 100000000;
284 mvsdio_data->clock = 200000000;
285 mvsdio_data->dram = &kirkwood_mbus_dram_info;
286 kirkwood_clk_ctrl |= CGC_SDIO;
287 kirkwood_sdio.dev.platform_data = mvsdio_data;
288 platform_device_register(&kirkwood_sdio);
292 /*****************************************************************************
294 ****************************************************************************/
295 static struct orion_spi_info kirkwood_spi_plat_data = {
298 static struct resource kirkwood_spi_resources[] = {
300 .start = SPI_PHYS_BASE,
301 .end = SPI_PHYS_BASE + SZ_512 - 1,
302 .flags = IORESOURCE_MEM,
306 static struct platform_device kirkwood_spi = {
309 .resource = kirkwood_spi_resources,
311 .platform_data = &kirkwood_spi_plat_data,
313 .num_resources = ARRAY_SIZE(kirkwood_spi_resources),
316 void __init kirkwood_spi_init()
318 kirkwood_clk_ctrl |= CGC_RUNIT;
319 platform_device_register(&kirkwood_spi);
323 /*****************************************************************************
325 ****************************************************************************/
326 void __init kirkwood_i2c_init(void)
328 orion_i2c_init(I2C_PHYS_BASE, IRQ_KIRKWOOD_TWSI, 8);
332 /*****************************************************************************
334 ****************************************************************************/
336 void __init kirkwood_uart0_init(void)
338 orion_uart0_init(UART0_VIRT_BASE, UART0_PHYS_BASE,
339 IRQ_KIRKWOOD_UART_0, kirkwood_tclk);
343 /*****************************************************************************
345 ****************************************************************************/
346 void __init kirkwood_uart1_init(void)
348 orion_uart1_init(UART1_VIRT_BASE, UART1_PHYS_BASE,
349 IRQ_KIRKWOOD_UART_1, kirkwood_tclk);
352 /*****************************************************************************
353 * Cryptographic Engines and Security Accelerator (CESA)
354 ****************************************************************************/
356 static struct resource kirkwood_crypto_res[] = {
359 .start = CRYPTO_PHYS_BASE,
360 .end = CRYPTO_PHYS_BASE + 0xffff,
361 .flags = IORESOURCE_MEM,
364 .start = KIRKWOOD_SRAM_PHYS_BASE,
365 .end = KIRKWOOD_SRAM_PHYS_BASE + KIRKWOOD_SRAM_SIZE - 1,
366 .flags = IORESOURCE_MEM,
368 .name = "crypto interrupt",
369 .start = IRQ_KIRKWOOD_CRYPTO,
370 .end = IRQ_KIRKWOOD_CRYPTO,
371 .flags = IORESOURCE_IRQ,
375 static struct platform_device kirkwood_crypto_device = {
378 .num_resources = ARRAY_SIZE(kirkwood_crypto_res),
379 .resource = kirkwood_crypto_res,
382 void __init kirkwood_crypto_init(void)
384 kirkwood_clk_ctrl |= CGC_CRYPTO;
385 platform_device_register(&kirkwood_crypto_device);
389 /*****************************************************************************
391 ****************************************************************************/
392 static struct mv_xor_platform_shared_data kirkwood_xor_shared_data = {
393 .dram = &kirkwood_mbus_dram_info,
397 /*****************************************************************************
399 ****************************************************************************/
400 static struct resource kirkwood_xor0_shared_resources[] = {
403 .start = XOR0_PHYS_BASE,
404 .end = XOR0_PHYS_BASE + 0xff,
405 .flags = IORESOURCE_MEM,
407 .name = "xor 0 high",
408 .start = XOR0_HIGH_PHYS_BASE,
409 .end = XOR0_HIGH_PHYS_BASE + 0xff,
410 .flags = IORESOURCE_MEM,
414 static struct platform_device kirkwood_xor0_shared = {
415 .name = MV_XOR_SHARED_NAME,
418 .platform_data = &kirkwood_xor_shared_data,
420 .num_resources = ARRAY_SIZE(kirkwood_xor0_shared_resources),
421 .resource = kirkwood_xor0_shared_resources,
424 static u64 kirkwood_xor_dmamask = DMA_BIT_MASK(32);
426 static struct resource kirkwood_xor00_resources[] = {
428 .start = IRQ_KIRKWOOD_XOR_00,
429 .end = IRQ_KIRKWOOD_XOR_00,
430 .flags = IORESOURCE_IRQ,
434 static struct mv_xor_platform_data kirkwood_xor00_data = {
435 .shared = &kirkwood_xor0_shared,
437 .pool_size = PAGE_SIZE,
440 static struct platform_device kirkwood_xor00_channel = {
443 .num_resources = ARRAY_SIZE(kirkwood_xor00_resources),
444 .resource = kirkwood_xor00_resources,
446 .dma_mask = &kirkwood_xor_dmamask,
447 .coherent_dma_mask = DMA_BIT_MASK(64),
448 .platform_data = &kirkwood_xor00_data,
452 static struct resource kirkwood_xor01_resources[] = {
454 .start = IRQ_KIRKWOOD_XOR_01,
455 .end = IRQ_KIRKWOOD_XOR_01,
456 .flags = IORESOURCE_IRQ,
460 static struct mv_xor_platform_data kirkwood_xor01_data = {
461 .shared = &kirkwood_xor0_shared,
463 .pool_size = PAGE_SIZE,
466 static struct platform_device kirkwood_xor01_channel = {
469 .num_resources = ARRAY_SIZE(kirkwood_xor01_resources),
470 .resource = kirkwood_xor01_resources,
472 .dma_mask = &kirkwood_xor_dmamask,
473 .coherent_dma_mask = DMA_BIT_MASK(64),
474 .platform_data = &kirkwood_xor01_data,
478 static void __init kirkwood_xor0_init(void)
480 kirkwood_clk_ctrl |= CGC_XOR0;
481 platform_device_register(&kirkwood_xor0_shared);
484 * two engines can't do memset simultaneously, this limitation
485 * satisfied by removing memset support from one of the engines.
487 dma_cap_set(DMA_MEMCPY, kirkwood_xor00_data.cap_mask);
488 dma_cap_set(DMA_XOR, kirkwood_xor00_data.cap_mask);
489 platform_device_register(&kirkwood_xor00_channel);
491 dma_cap_set(DMA_MEMCPY, kirkwood_xor01_data.cap_mask);
492 dma_cap_set(DMA_MEMSET, kirkwood_xor01_data.cap_mask);
493 dma_cap_set(DMA_XOR, kirkwood_xor01_data.cap_mask);
494 platform_device_register(&kirkwood_xor01_channel);
498 /*****************************************************************************
500 ****************************************************************************/
501 static struct resource kirkwood_xor1_shared_resources[] = {
504 .start = XOR1_PHYS_BASE,
505 .end = XOR1_PHYS_BASE + 0xff,
506 .flags = IORESOURCE_MEM,
508 .name = "xor 1 high",
509 .start = XOR1_HIGH_PHYS_BASE,
510 .end = XOR1_HIGH_PHYS_BASE + 0xff,
511 .flags = IORESOURCE_MEM,
515 static struct platform_device kirkwood_xor1_shared = {
516 .name = MV_XOR_SHARED_NAME,
519 .platform_data = &kirkwood_xor_shared_data,
521 .num_resources = ARRAY_SIZE(kirkwood_xor1_shared_resources),
522 .resource = kirkwood_xor1_shared_resources,
525 static struct resource kirkwood_xor10_resources[] = {
527 .start = IRQ_KIRKWOOD_XOR_10,
528 .end = IRQ_KIRKWOOD_XOR_10,
529 .flags = IORESOURCE_IRQ,
533 static struct mv_xor_platform_data kirkwood_xor10_data = {
534 .shared = &kirkwood_xor1_shared,
536 .pool_size = PAGE_SIZE,
539 static struct platform_device kirkwood_xor10_channel = {
542 .num_resources = ARRAY_SIZE(kirkwood_xor10_resources),
543 .resource = kirkwood_xor10_resources,
545 .dma_mask = &kirkwood_xor_dmamask,
546 .coherent_dma_mask = DMA_BIT_MASK(64),
547 .platform_data = &kirkwood_xor10_data,
551 static struct resource kirkwood_xor11_resources[] = {
553 .start = IRQ_KIRKWOOD_XOR_11,
554 .end = IRQ_KIRKWOOD_XOR_11,
555 .flags = IORESOURCE_IRQ,
559 static struct mv_xor_platform_data kirkwood_xor11_data = {
560 .shared = &kirkwood_xor1_shared,
562 .pool_size = PAGE_SIZE,
565 static struct platform_device kirkwood_xor11_channel = {
568 .num_resources = ARRAY_SIZE(kirkwood_xor11_resources),
569 .resource = kirkwood_xor11_resources,
571 .dma_mask = &kirkwood_xor_dmamask,
572 .coherent_dma_mask = DMA_BIT_MASK(64),
573 .platform_data = &kirkwood_xor11_data,
577 static void __init kirkwood_xor1_init(void)
579 kirkwood_clk_ctrl |= CGC_XOR1;
580 platform_device_register(&kirkwood_xor1_shared);
583 * two engines can't do memset simultaneously, this limitation
584 * satisfied by removing memset support from one of the engines.
586 dma_cap_set(DMA_MEMCPY, kirkwood_xor10_data.cap_mask);
587 dma_cap_set(DMA_XOR, kirkwood_xor10_data.cap_mask);
588 platform_device_register(&kirkwood_xor10_channel);
590 dma_cap_set(DMA_MEMCPY, kirkwood_xor11_data.cap_mask);
591 dma_cap_set(DMA_MEMSET, kirkwood_xor11_data.cap_mask);
592 dma_cap_set(DMA_XOR, kirkwood_xor11_data.cap_mask);
593 platform_device_register(&kirkwood_xor11_channel);
597 /*****************************************************************************
599 ****************************************************************************/
600 static struct orion_wdt_platform_data kirkwood_wdt_data = {
604 static struct platform_device kirkwood_wdt_device = {
608 .platform_data = &kirkwood_wdt_data,
613 static void __init kirkwood_wdt_init(void)
615 kirkwood_wdt_data.tclk = kirkwood_tclk;
616 platform_device_register(&kirkwood_wdt_device);
620 /*****************************************************************************
622 ****************************************************************************/
623 void __init kirkwood_init_early(void)
625 orion_time_set_base(TIMER_VIRT_BASE);
630 static int __init kirkwood_find_tclk(void)
634 kirkwood_pcie_id(&dev, &rev);
636 if (dev == MV88F6281_DEV_ID || dev == MV88F6282_DEV_ID)
637 if (((readl(SAMPLE_AT_RESET) >> 21) & 1) == 0)
643 static void __init kirkwood_timer_init(void)
645 kirkwood_tclk = kirkwood_find_tclk();
647 orion_time_init(BRIDGE_VIRT_BASE, BRIDGE_INT_TIMER1_CLR,
648 IRQ_KIRKWOOD_BRIDGE, kirkwood_tclk);
651 struct sys_timer kirkwood_timer = {
652 .init = kirkwood_timer_init,
655 /*****************************************************************************
657 ****************************************************************************/
658 static struct resource kirkwood_i2s_resources[] = {
660 .start = AUDIO_PHYS_BASE,
661 .end = AUDIO_PHYS_BASE + SZ_16K - 1,
662 .flags = IORESOURCE_MEM,
665 .start = IRQ_KIRKWOOD_I2S,
666 .end = IRQ_KIRKWOOD_I2S,
667 .flags = IORESOURCE_IRQ,
671 static struct kirkwood_asoc_platform_data kirkwood_i2s_data = {
672 .dram = &kirkwood_mbus_dram_info,
676 static struct platform_device kirkwood_i2s_device = {
677 .name = "kirkwood-i2s",
679 .num_resources = ARRAY_SIZE(kirkwood_i2s_resources),
680 .resource = kirkwood_i2s_resources,
682 .platform_data = &kirkwood_i2s_data,
686 static struct platform_device kirkwood_pcm_device = {
687 .name = "kirkwood-pcm-audio",
691 void __init kirkwood_audio_init(void)
693 kirkwood_clk_ctrl |= CGC_AUDIO;
694 platform_device_register(&kirkwood_i2s_device);
695 platform_device_register(&kirkwood_pcm_device);
698 /*****************************************************************************
700 ****************************************************************************/
702 * Identify device ID and revision.
704 static char * __init kirkwood_id(void)
708 kirkwood_pcie_id(&dev, &rev);
710 if (dev == MV88F6281_DEV_ID) {
711 if (rev == MV88F6281_REV_Z0)
712 return "MV88F6281-Z0";
713 else if (rev == MV88F6281_REV_A0)
714 return "MV88F6281-A0";
715 else if (rev == MV88F6281_REV_A1)
716 return "MV88F6281-A1";
718 return "MV88F6281-Rev-Unsupported";
719 } else if (dev == MV88F6192_DEV_ID) {
720 if (rev == MV88F6192_REV_Z0)
721 return "MV88F6192-Z0";
722 else if (rev == MV88F6192_REV_A0)
723 return "MV88F6192-A0";
724 else if (rev == MV88F6192_REV_A1)
725 return "MV88F6192-A1";
727 return "MV88F6192-Rev-Unsupported";
728 } else if (dev == MV88F6180_DEV_ID) {
729 if (rev == MV88F6180_REV_A0)
730 return "MV88F6180-Rev-A0";
731 else if (rev == MV88F6180_REV_A1)
732 return "MV88F6180-Rev-A1";
734 return "MV88F6180-Rev-Unsupported";
735 } else if (dev == MV88F6282_DEV_ID) {
736 if (rev == MV88F6282_REV_A0)
737 return "MV88F6282-Rev-A0";
739 return "MV88F6282-Rev-Unsupported";
741 return "Device-Unknown";
745 static void __init kirkwood_l2_init(void)
747 #ifdef CONFIG_CACHE_FEROCEON_L2_WRITETHROUGH
748 writel(readl(L2_CONFIG_REG) | L2_WRITETHROUGH, L2_CONFIG_REG);
751 writel(readl(L2_CONFIG_REG) & ~L2_WRITETHROUGH, L2_CONFIG_REG);
756 void __init kirkwood_init(void)
758 printk(KERN_INFO "Kirkwood: %s, TCLK=%d.\n",
759 kirkwood_id(), kirkwood_tclk);
760 kirkwood_spi_plat_data.tclk = kirkwood_tclk;
761 kirkwood_i2s_data.tclk = kirkwood_tclk;
764 * Disable propagation of mbus errors to the CPU local bus,
765 * as this causes mbus errors (which can occur for example
766 * for PCI aborts) to throw CPU aborts, which we're not set
769 writel(readl(CPU_CONFIG) & ~CPU_CONFIG_ERROR_PROP, CPU_CONFIG);
771 kirkwood_setup_cpu_mbus();
773 #ifdef CONFIG_CACHE_FEROCEON_L2
777 /* internal devices that every board has */
780 kirkwood_xor0_init();
781 kirkwood_xor1_init();
782 kirkwood_crypto_init();
785 kexec_reinit = kirkwood_enable_pcie;
789 static int __init kirkwood_clock_gate(void)
791 unsigned int curr = readl(CLOCK_GATING_CTRL);
794 kirkwood_pcie_id(&dev, &rev);
795 printk(KERN_DEBUG "Gating clock of unused units\n");
796 printk(KERN_DEBUG "before: 0x%08x\n", curr);
798 /* Make sure those units are accessible */
799 writel(curr | CGC_SATA0 | CGC_SATA1 | CGC_PEX0 | CGC_PEX1, CLOCK_GATING_CTRL);
801 /* For SATA: first shutdown the phy */
802 if (!(kirkwood_clk_ctrl & CGC_SATA0)) {
803 /* Disable PLL and IVREF */
804 writel(readl(SATA0_PHY_MODE_2) & ~0xf, SATA0_PHY_MODE_2);
806 writel(readl(SATA0_IF_CTRL) | 0x200, SATA0_IF_CTRL);
808 if (!(kirkwood_clk_ctrl & CGC_SATA1)) {
809 /* Disable PLL and IVREF */
810 writel(readl(SATA1_PHY_MODE_2) & ~0xf, SATA1_PHY_MODE_2);
812 writel(readl(SATA1_IF_CTRL) | 0x200, SATA1_IF_CTRL);
815 /* For PCIe: first shutdown the phy */
816 if (!(kirkwood_clk_ctrl & CGC_PEX0)) {
817 writel(readl(PCIE_LINK_CTRL) | 0x10, PCIE_LINK_CTRL);
819 if (readl(PCIE_STATUS) & 0x1)
821 writel(readl(PCIE_LINK_CTRL) & ~0x10, PCIE_LINK_CTRL);
824 /* For PCIe 1: first shutdown the phy */
825 if (dev == MV88F6282_DEV_ID) {
826 if (!(kirkwood_clk_ctrl & CGC_PEX1)) {
827 writel(readl(PCIE1_LINK_CTRL) | 0x10, PCIE1_LINK_CTRL);
829 if (readl(PCIE1_STATUS) & 0x1)
831 writel(readl(PCIE1_LINK_CTRL) & ~0x10, PCIE1_LINK_CTRL);
833 } else /* keep this bit set for devices that don't have PCIe1 */
834 kirkwood_clk_ctrl |= CGC_PEX1;
836 /* Now gate clock the required units */
837 writel(kirkwood_clk_ctrl, CLOCK_GATING_CTRL);
838 printk(KERN_DEBUG " after: 0x%08x\n", readl(CLOCK_GATING_CTRL));
842 late_initcall(kirkwood_clock_gate);