board-dt.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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/dma-mapping.h>
  18. #include <linux/irqchip.h>
  19. #include <linux/kexec.h>
  20. #include <asm/mach/arch.h>
  21. #include <asm/mach/map.h>
  22. #include <mach/bridge-regs.h>
  23. #include <linux/platform_data/usb-ehci-orion.h>
  24. #include <plat/irq.h>
  25. #include <plat/common.h>
  26. #include "common.h"
  27. /*
  28. * There are still devices that doesn't know about DT yet. Get clock
  29. * gates here and add a clock lookup alias, so that old platform
  30. * devices still work.
  31. */
  32. static void __init kirkwood_legacy_clk_init(void)
  33. {
  34. struct device_node *np = of_find_compatible_node(
  35. NULL, NULL, "marvell,kirkwood-gating-clock");
  36. struct of_phandle_args clkspec;
  37. struct clk *clk;
  38. clkspec.np = np;
  39. clkspec.args_count = 1;
  40. clkspec.args[0] = CGC_BIT_PEX0;
  41. orion_clkdev_add("0", "pcie",
  42. of_clk_get_from_provider(&clkspec));
  43. clkspec.args[0] = CGC_BIT_PEX1;
  44. orion_clkdev_add("1", "pcie",
  45. of_clk_get_from_provider(&clkspec));
  46. /*
  47. * The ethernet interfaces forget the MAC address assigned by
  48. * u-boot if the clocks are turned off. Until proper DT support
  49. * is available we always enable them for now.
  50. */
  51. clkspec.args[0] = CGC_BIT_GE0;
  52. clk = of_clk_get_from_provider(&clkspec);
  53. clk_prepare_enable(clk);
  54. clkspec.args[0] = CGC_BIT_GE1;
  55. clk = of_clk_get_from_provider(&clkspec);
  56. clk_prepare_enable(clk);
  57. }
  58. static void __init kirkwood_dt_init_early(void)
  59. {
  60. mvebu_mbus_init("marvell,kirkwood-mbus",
  61. BRIDGE_WINS_BASE, BRIDGE_WINS_SZ,
  62. DDR_WINDOW_CPU_BASE, DDR_WINDOW_CPU_SZ);
  63. }
  64. static void __init kirkwood_dt_init(void)
  65. {
  66. pr_info("Kirkwood: %s, TCLK=%d.\n", kirkwood_id(), kirkwood_tclk);
  67. /*
  68. * Disable propagation of mbus errors to the CPU local bus,
  69. * as this causes mbus errors (which can occur for example
  70. * for PCI aborts) to throw CPU aborts, which we're not set
  71. * up to deal with.
  72. */
  73. writel(readl(CPU_CONFIG) & ~CPU_CONFIG_ERROR_PROP, CPU_CONFIG);
  74. BUG_ON(mvebu_mbus_dt_init());
  75. kirkwood_setup_wins();
  76. kirkwood_l2_init();
  77. kirkwood_cpufreq_init();
  78. /* Setup clocks for legacy devices */
  79. kirkwood_legacy_clk_init();
  80. kirkwood_cpuidle_init();
  81. #ifdef CONFIG_KEXEC
  82. kexec_reinit = kirkwood_enable_pcie;
  83. #endif
  84. if (of_machine_is_compatible("marvell,mv88f6281gtw-ge"))
  85. mv88f6281gtw_ge_init();
  86. of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
  87. }
  88. static const char * const kirkwood_dt_board_compat[] = {
  89. "marvell,kirkwood",
  90. NULL
  91. };
  92. DT_MACHINE_START(KIRKWOOD_DT, "Marvell Kirkwood (Flattened Device Tree)")
  93. /* Maintainer: Jason Cooper <jason@lakedaemon.net> */
  94. .map_io = kirkwood_map_io,
  95. .init_early = kirkwood_dt_init_early,
  96. .init_machine = kirkwood_dt_init,
  97. .restart = kirkwood_restart,
  98. .dt_compat = kirkwood_dt_board_compat,
  99. MACHINE_END