board-dt.c 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. /*
  2. * Copyright 2012 (C), Jason Cooper <jason@lakedaemon.net>
  3. *
  4. * arch/arm/mach-kirkwood/board-dt.c
  5. *
  6. * Flattened Device Tree board initialization
  7. *
  8. * This file is licensed under the terms of the GNU General Public
  9. * License version 2. This program is licensed "as is" without any
  10. * warranty of any kind, whether express or implied.
  11. */
  12. #include <linux/kernel.h>
  13. #include <linux/init.h>
  14. #include <linux/of.h>
  15. #include <linux/of_platform.h>
  16. #include <linux/clk-provider.h>
  17. #include <linux/clocksource.h>
  18. #include <linux/dma-mapping.h>
  19. #include <linux/irqchip.h>
  20. #include <linux/kexec.h>
  21. #include <asm/mach/arch.h>
  22. #include <asm/mach/map.h>
  23. #include <mach/bridge-regs.h>
  24. #include <linux/platform_data/usb-ehci-orion.h>
  25. #include <plat/irq.h>
  26. #include <plat/common.h>
  27. #include "common.h"
  28. /*
  29. * There are still devices that doesn't know about DT yet. Get clock
  30. * gates here and add a clock lookup alias, so that old platform
  31. * devices still work.
  32. */
  33. static void __init kirkwood_legacy_clk_init(void)
  34. {
  35. struct device_node *np = of_find_compatible_node(
  36. NULL, NULL, "marvell,kirkwood-gating-clock");
  37. struct of_phandle_args clkspec;
  38. struct clk *clk;
  39. clkspec.np = np;
  40. clkspec.args_count = 1;
  41. clkspec.args[0] = CGC_BIT_PEX0;
  42. orion_clkdev_add("0", "pcie",
  43. of_clk_get_from_provider(&clkspec));
  44. clkspec.args[0] = CGC_BIT_PEX1;
  45. orion_clkdev_add("1", "pcie",
  46. of_clk_get_from_provider(&clkspec));
  47. clkspec.args[0] = CGC_BIT_SDIO;
  48. orion_clkdev_add(NULL, "mvsdio",
  49. of_clk_get_from_provider(&clkspec));
  50. /*
  51. * The ethernet interfaces forget the MAC address assigned by
  52. * u-boot if the clocks are turned off. Until proper DT support
  53. * is available we always enable them for now.
  54. */
  55. clkspec.args[0] = CGC_BIT_GE0;
  56. clk = of_clk_get_from_provider(&clkspec);
  57. clk_prepare_enable(clk);
  58. clkspec.args[0] = CGC_BIT_GE1;
  59. clk = of_clk_get_from_provider(&clkspec);
  60. clk_prepare_enable(clk);
  61. }
  62. static void __init kirkwood_dt_time_init(void)
  63. {
  64. of_clk_init(NULL);
  65. clocksource_of_init();
  66. }
  67. static void __init kirkwood_dt_init_early(void)
  68. {
  69. mvebu_mbus_init("marvell,kirkwood-mbus",
  70. BRIDGE_WINS_BASE, BRIDGE_WINS_SZ,
  71. DDR_WINDOW_CPU_BASE, DDR_WINDOW_CPU_SZ);
  72. }
  73. static void __init kirkwood_dt_init(void)
  74. {
  75. pr_info("Kirkwood: %s, TCLK=%d.\n", kirkwood_id(), kirkwood_tclk);
  76. /*
  77. * Disable propagation of mbus errors to the CPU local bus,
  78. * as this causes mbus errors (which can occur for example
  79. * for PCI aborts) to throw CPU aborts, which we're not set
  80. * up to deal with.
  81. */
  82. writel(readl(CPU_CONFIG) & ~CPU_CONFIG_ERROR_PROP, CPU_CONFIG);
  83. kirkwood_setup_wins();
  84. kirkwood_l2_init();
  85. kirkwood_cpufreq_init();
  86. /* Setup clocks for legacy devices */
  87. kirkwood_legacy_clk_init();
  88. kirkwood_cpuidle_init();
  89. #ifdef CONFIG_KEXEC
  90. kexec_reinit = kirkwood_enable_pcie;
  91. #endif
  92. if (of_machine_is_compatible("dlink,dns-kirkwood"))
  93. dnskw_init();
  94. of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
  95. }
  96. static const char * const kirkwood_dt_board_compat[] = {
  97. "marvell,kirkwood",
  98. NULL
  99. };
  100. DT_MACHINE_START(KIRKWOOD_DT, "Marvell Kirkwood (Flattened Device Tree)")
  101. /* Maintainer: Jason Cooper <jason@lakedaemon.net> */
  102. .map_io = kirkwood_map_io,
  103. .init_early = kirkwood_dt_init_early,
  104. .init_time = kirkwood_dt_time_init,
  105. .init_machine = kirkwood_dt_init,
  106. .restart = kirkwood_restart,
  107. .dt_compat = kirkwood_dt_board_compat,
  108. MACHINE_END