aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-kirkwood/common.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/arm/mach-kirkwood/common.c')
-rw-r--r--arch/arm/mach-kirkwood/common.c167
1 files changed, 165 insertions, 2 deletions
diff --git a/arch/arm/mach-kirkwood/common.c b/arch/arm/mach-kirkwood/common.c
index eeb00240d784..0f6919838011 100644
--- a/arch/arm/mach-kirkwood/common.c
+++ b/arch/arm/mach-kirkwood/common.c
@@ -16,6 +16,7 @@
16#include <linux/mv643xx_eth.h> 16#include <linux/mv643xx_eth.h>
17#include <linux/mv643xx_i2c.h> 17#include <linux/mv643xx_i2c.h>
18#include <linux/ata_platform.h> 18#include <linux/ata_platform.h>
19#include <linux/mtd/nand.h>
19#include <linux/spi/orion_spi.h> 20#include <linux/spi/orion_spi.h>
20#include <net/dsa.h> 21#include <net/dsa.h>
21#include <asm/page.h> 22#include <asm/page.h>
@@ -29,6 +30,7 @@
29#include <plat/mvsdio.h> 30#include <plat/mvsdio.h>
30#include <plat/mv_xor.h> 31#include <plat/mv_xor.h>
31#include <plat/orion_nand.h> 32#include <plat/orion_nand.h>
33#include <plat/orion_wdt.h>
32#include <plat/time.h> 34#include <plat/time.h>
33#include "common.h" 35#include "common.h"
34 36
@@ -54,6 +56,13 @@ void __init kirkwood_map_io(void)
54 iotable_init(kirkwood_io_desc, ARRAY_SIZE(kirkwood_io_desc)); 56 iotable_init(kirkwood_io_desc, ARRAY_SIZE(kirkwood_io_desc));
55} 57}
56 58
59/*
60 * Default clock control bits. Any bit _not_ set in this variable
61 * will be cleared from the hardware after platform devices have been
62 * registered. Some reserved bits must be set to 1.
63 */
64unsigned int kirkwood_clk_ctrl = CGC_DUNIT | CGC_RESERVED;
65
57 66
58/***************************************************************************** 67/*****************************************************************************
59 * EHCI 68 * EHCI
@@ -95,6 +104,7 @@ static struct platform_device kirkwood_ehci = {
95 104
96void __init kirkwood_ehci_init(void) 105void __init kirkwood_ehci_init(void)
97{ 106{
107 kirkwood_clk_ctrl |= CGC_USB0;
98 platform_device_register(&kirkwood_ehci); 108 platform_device_register(&kirkwood_ehci);
99} 109}
100 110
@@ -144,10 +154,14 @@ static struct platform_device kirkwood_ge00 = {
144 .id = 0, 154 .id = 0,
145 .num_resources = 1, 155 .num_resources = 1,
146 .resource = kirkwood_ge00_resources, 156 .resource = kirkwood_ge00_resources,
157 .dev = {
158 .coherent_dma_mask = 0xffffffff,
159 },
147}; 160};
148 161
149void __init kirkwood_ge00_init(struct mv643xx_eth_platform_data *eth_data) 162void __init kirkwood_ge00_init(struct mv643xx_eth_platform_data *eth_data)
150{ 163{
164 kirkwood_clk_ctrl |= CGC_GE0;
151 eth_data->shared = &kirkwood_ge00_shared; 165 eth_data->shared = &kirkwood_ge00_shared;
152 kirkwood_ge00.dev.platform_data = eth_data; 166 kirkwood_ge00.dev.platform_data = eth_data;
153 167
@@ -202,10 +216,14 @@ static struct platform_device kirkwood_ge01 = {
202 .id = 1, 216 .id = 1,
203 .num_resources = 1, 217 .num_resources = 1,
204 .resource = kirkwood_ge01_resources, 218 .resource = kirkwood_ge01_resources,
219 .dev = {
220 .coherent_dma_mask = 0xffffffff,
221 },
205}; 222};
206 223
207void __init kirkwood_ge01_init(struct mv643xx_eth_platform_data *eth_data) 224void __init kirkwood_ge01_init(struct mv643xx_eth_platform_data *eth_data)
208{ 225{
226 kirkwood_clk_ctrl |= CGC_GE1;
209 eth_data->shared = &kirkwood_ge01_shared; 227 eth_data->shared = &kirkwood_ge01_shared;
210 kirkwood_ge01.dev.platform_data = eth_data; 228 kirkwood_ge01.dev.platform_data = eth_data;
211 229
@@ -252,6 +270,43 @@ void __init kirkwood_ge00_switch_init(struct dsa_platform_data *d, int irq)
252 270
253 271
254/***************************************************************************** 272/*****************************************************************************
273 * NAND flash
274 ****************************************************************************/
275static struct resource kirkwood_nand_resource = {
276 .flags = IORESOURCE_MEM,
277 .start = KIRKWOOD_NAND_MEM_PHYS_BASE,
278 .end = KIRKWOOD_NAND_MEM_PHYS_BASE +
279 KIRKWOOD_NAND_MEM_SIZE - 1,
280};
281
282static struct orion_nand_data kirkwood_nand_data = {
283 .cle = 0,
284 .ale = 1,
285 .width = 8,
286};
287
288static struct platform_device kirkwood_nand_flash = {
289 .name = "orion_nand",
290 .id = -1,
291 .dev = {
292 .platform_data = &kirkwood_nand_data,
293 },
294 .resource = &kirkwood_nand_resource,
295 .num_resources = 1,
296};
297
298void __init kirkwood_nand_init(struct mtd_partition *parts, int nr_parts,
299 int chip_delay)
300{
301 kirkwood_clk_ctrl |= CGC_RUNIT;
302 kirkwood_nand_data.parts = parts;
303 kirkwood_nand_data.nr_parts = nr_parts;
304 kirkwood_nand_data.chip_delay = chip_delay;
305 platform_device_register(&kirkwood_nand_flash);
306}
307
308
309/*****************************************************************************
255 * SoC RTC 310 * SoC RTC
256 ****************************************************************************/ 311 ****************************************************************************/
257static struct resource kirkwood_rtc_resource = { 312static struct resource kirkwood_rtc_resource = {
@@ -295,6 +350,9 @@ static struct platform_device kirkwood_sata = {
295 350
296void __init kirkwood_sata_init(struct mv_sata_platform_data *sata_data) 351void __init kirkwood_sata_init(struct mv_sata_platform_data *sata_data)
297{ 352{
353 kirkwood_clk_ctrl |= CGC_SATA0;
354 if (sata_data->n_ports > 1)
355 kirkwood_clk_ctrl |= CGC_SATA1;
298 sata_data->dram = &kirkwood_mbus_dram_info; 356 sata_data->dram = &kirkwood_mbus_dram_info;
299 kirkwood_sata.dev.platform_data = sata_data; 357 kirkwood_sata.dev.platform_data = sata_data;
300 platform_device_register(&kirkwood_sata); 358 platform_device_register(&kirkwood_sata);
@@ -340,6 +398,7 @@ void __init kirkwood_sdio_init(struct mvsdio_platform_data *mvsdio_data)
340 else 398 else
341 mvsdio_data->clock = 200000000; 399 mvsdio_data->clock = 200000000;
342 mvsdio_data->dram = &kirkwood_mbus_dram_info; 400 mvsdio_data->dram = &kirkwood_mbus_dram_info;
401 kirkwood_clk_ctrl |= CGC_SDIO;
343 kirkwood_sdio.dev.platform_data = mvsdio_data; 402 kirkwood_sdio.dev.platform_data = mvsdio_data;
344 platform_device_register(&kirkwood_sdio); 403 platform_device_register(&kirkwood_sdio);
345} 404}
@@ -371,6 +430,7 @@ static struct platform_device kirkwood_spi = {
371 430
372void __init kirkwood_spi_init() 431void __init kirkwood_spi_init()
373{ 432{
433 kirkwood_clk_ctrl |= CGC_RUNIT;
374 platform_device_register(&kirkwood_spi); 434 platform_device_register(&kirkwood_spi);
375} 435}
376 436
@@ -386,12 +446,10 @@ static struct mv64xxx_i2c_pdata kirkwood_i2c_pdata = {
386 446
387static struct resource kirkwood_i2c_resources[] = { 447static struct resource kirkwood_i2c_resources[] = {
388 { 448 {
389 .name = "i2c",
390 .start = I2C_PHYS_BASE, 449 .start = I2C_PHYS_BASE,
391 .end = I2C_PHYS_BASE + 0x1f, 450 .end = I2C_PHYS_BASE + 0x1f,
392 .flags = IORESOURCE_MEM, 451 .flags = IORESOURCE_MEM,
393 }, { 452 }, {
394 .name = "i2c",
395 .start = IRQ_KIRKWOOD_TWSI, 453 .start = IRQ_KIRKWOOD_TWSI,
396 .end = IRQ_KIRKWOOD_TWSI, 454 .end = IRQ_KIRKWOOD_TWSI,
397 .flags = IORESOURCE_IRQ, 455 .flags = IORESOURCE_IRQ,
@@ -503,6 +561,43 @@ void __init kirkwood_uart1_init(void)
503 561
504 562
505/***************************************************************************** 563/*****************************************************************************
564 * Cryptographic Engines and Security Accelerator (CESA)
565 ****************************************************************************/
566
567static struct resource kirkwood_crypto_res[] = {
568 {
569 .name = "regs",
570 .start = CRYPTO_PHYS_BASE,
571 .end = CRYPTO_PHYS_BASE + 0xffff,
572 .flags = IORESOURCE_MEM,
573 }, {
574 .name = "sram",
575 .start = KIRKWOOD_SRAM_PHYS_BASE,
576 .end = KIRKWOOD_SRAM_PHYS_BASE + KIRKWOOD_SRAM_SIZE - 1,
577 .flags = IORESOURCE_MEM,
578 }, {
579 .name = "crypto interrupt",
580 .start = IRQ_KIRKWOOD_CRYPTO,
581 .end = IRQ_KIRKWOOD_CRYPTO,
582 .flags = IORESOURCE_IRQ,
583 },
584};
585
586static struct platform_device kirkwood_crypto_device = {
587 .name = "mv_crypto",
588 .id = -1,
589 .num_resources = ARRAY_SIZE(kirkwood_crypto_res),
590 .resource = kirkwood_crypto_res,
591};
592
593void __init kirkwood_crypto_init(void)
594{
595 kirkwood_clk_ctrl |= CGC_CRYPTO;
596 platform_device_register(&kirkwood_crypto_device);
597}
598
599
600/*****************************************************************************
506 * XOR 601 * XOR
507 ****************************************************************************/ 602 ****************************************************************************/
508static struct mv_xor_platform_shared_data kirkwood_xor_shared_data = { 603static struct mv_xor_platform_shared_data kirkwood_xor_shared_data = {
@@ -593,6 +688,7 @@ static struct platform_device kirkwood_xor01_channel = {
593 688
594static void __init kirkwood_xor0_init(void) 689static void __init kirkwood_xor0_init(void)
595{ 690{
691 kirkwood_clk_ctrl |= CGC_XOR0;
596 platform_device_register(&kirkwood_xor0_shared); 692 platform_device_register(&kirkwood_xor0_shared);
597 693
598 /* 694 /*
@@ -691,6 +787,7 @@ static struct platform_device kirkwood_xor11_channel = {
691 787
692static void __init kirkwood_xor1_init(void) 788static void __init kirkwood_xor1_init(void)
693{ 789{
790 kirkwood_clk_ctrl |= CGC_XOR1;
694 platform_device_register(&kirkwood_xor1_shared); 791 platform_device_register(&kirkwood_xor1_shared);
695 792
696 /* 793 /*
@@ -709,6 +806,29 @@ static void __init kirkwood_xor1_init(void)
709 806
710 807
711/***************************************************************************** 808/*****************************************************************************
809 * Watchdog
810 ****************************************************************************/
811static struct orion_wdt_platform_data kirkwood_wdt_data = {
812 .tclk = 0,
813};
814
815static struct platform_device kirkwood_wdt_device = {
816 .name = "orion_wdt",
817 .id = -1,
818 .dev = {
819 .platform_data = &kirkwood_wdt_data,
820 },
821 .num_resources = 0,
822};
823
824static void __init kirkwood_wdt_init(void)
825{
826 kirkwood_wdt_data.tclk = kirkwood_tclk;
827 platform_device_register(&kirkwood_wdt_device);
828}
829
830
831/*****************************************************************************
712 * Time handling 832 * Time handling
713 ****************************************************************************/ 833 ****************************************************************************/
714int kirkwood_tclk; 834int kirkwood_tclk;
@@ -800,6 +920,49 @@ void __init kirkwood_init(void)
800 920
801 /* internal devices that every board has */ 921 /* internal devices that every board has */
802 kirkwood_rtc_init(); 922 kirkwood_rtc_init();
923 kirkwood_wdt_init();
803 kirkwood_xor0_init(); 924 kirkwood_xor0_init();
804 kirkwood_xor1_init(); 925 kirkwood_xor1_init();
926 kirkwood_crypto_init();
927}
928
929static int __init kirkwood_clock_gate(void)
930{
931 unsigned int curr = readl(CLOCK_GATING_CTRL);
932
933 printk(KERN_DEBUG "Gating clock of unused units\n");
934 printk(KERN_DEBUG "before: 0x%08x\n", curr);
935
936 /* Make sure those units are accessible */
937 writel(curr | CGC_SATA0 | CGC_SATA1 | CGC_PEX0, CLOCK_GATING_CTRL);
938
939 /* For SATA: first shutdown the phy */
940 if (!(kirkwood_clk_ctrl & CGC_SATA0)) {
941 /* Disable PLL and IVREF */
942 writel(readl(SATA0_PHY_MODE_2) & ~0xf, SATA0_PHY_MODE_2);
943 /* Disable PHY */
944 writel(readl(SATA0_IF_CTRL) | 0x200, SATA0_IF_CTRL);
945 }
946 if (!(kirkwood_clk_ctrl & CGC_SATA1)) {
947 /* Disable PLL and IVREF */
948 writel(readl(SATA1_PHY_MODE_2) & ~0xf, SATA1_PHY_MODE_2);
949 /* Disable PHY */
950 writel(readl(SATA1_IF_CTRL) | 0x200, SATA1_IF_CTRL);
951 }
952
953 /* For PCIe: first shutdown the phy */
954 if (!(kirkwood_clk_ctrl & CGC_PEX0)) {
955 writel(readl(PCIE_LINK_CTRL) | 0x10, PCIE_LINK_CTRL);
956 while (1)
957 if (readl(PCIE_STATUS) & 0x1)
958 break;
959 writel(readl(PCIE_LINK_CTRL) & ~0x10, PCIE_LINK_CTRL);
960 }
961
962 /* Now gate clock the required units */
963 writel(kirkwood_clk_ctrl, CLOCK_GATING_CTRL);
964 printk(KERN_DEBUG " after: 0x%08x\n", readl(CLOCK_GATING_CTRL));
965
966 return 0;
805} 967}
968late_initcall(kirkwood_clock_gate);