board-dt.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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. /*
  48. * The ethernet interfaces forget the MAC address assigned by
  49. * u-boot if the clocks are turned off. Until proper DT support
  50. * is available we always enable them for now.
  51. */
  52. clkspec.args[0] = CGC_BIT_GE0;
  53. clk = of_clk_get_from_provider(&clkspec);
  54. clk_prepare_enable(clk);
  55. clkspec.args[0] = CGC_BIT_GE1;
  56. clk = of_clk_get_from_provider(&clkspec);
  57. clk_prepare_enable(clk);
  58. }
  59. static void __init kirkwood_dt_time_init(void)
  60. {
  61. of_clk_init(NULL);
  62. clocksource_of_init();
  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_pm_init();
  81. kirkwood_cpuidle_init();
  82. #ifdef CONFIG_KEXEC
  83. kexec_reinit = kirkwood_enable_pcie;
  84. #endif
  85. if (of_machine_is_compatible("marvell,mv88f6281gtw-ge"))
  86. mv88f6281gtw_ge_init();
  87. of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
  88. }
  89. static const char * const kirkwood_dt_board_compat[] = {
  90. "marvell,kirkwood",
  91. NULL
  92. };
  93. DT_MACHINE_START(KIRKWOOD_DT, "Marvell Kirkwood (Flattened Device Tree)")
  94. /* Maintainer: Jason Cooper <jason@lakedaemon.net> */
  95. .map_io = kirkwood_map_io,
  96. .init_time = kirkwood_dt_time_init,
  97. .init_machine = kirkwood_dt_init,
  98. .restart = kirkwood_restart,
  99. .dt_compat = kirkwood_dt_board_compat,
  100. MACHINE_END