board-dt.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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/kexec.h>
  18. #include <asm/mach/arch.h>
  19. #include <asm/mach/map.h>
  20. #include <mach/bridge-regs.h>
  21. #include <linux/platform_data/usb-ehci-orion.h>
  22. #include <plat/irq.h>
  23. #include <plat/common.h>
  24. #include "common.h"
  25. /*
  26. * There are still devices that doesn't know about DT yet. Get clock
  27. * gates here and add a clock lookup alias, so that old platform
  28. * devices still work.
  29. */
  30. static void __init kirkwood_legacy_clk_init(void)
  31. {
  32. struct device_node *np = of_find_compatible_node(
  33. NULL, NULL, "marvell,kirkwood-gating-clock");
  34. struct of_phandle_args clkspec;
  35. struct clk *clk;
  36. clkspec.np = np;
  37. clkspec.args_count = 1;
  38. clkspec.args[0] = CGC_BIT_PEX0;
  39. orion_clkdev_add("0", "pcie",
  40. of_clk_get_from_provider(&clkspec));
  41. clkspec.args[0] = CGC_BIT_PEX1;
  42. orion_clkdev_add("1", "pcie",
  43. of_clk_get_from_provider(&clkspec));
  44. clkspec.args[0] = CGC_BIT_SDIO;
  45. orion_clkdev_add(NULL, "mvsdio",
  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_of_clk_init(void)
  60. {
  61. of_clk_init(NULL);
  62. kirkwood_legacy_clk_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. kirkwood_setup_wins();
  75. kirkwood_l2_init();
  76. kirkwood_cpufreq_init();
  77. /* Setup root of clk tree */
  78. kirkwood_of_clk_init();
  79. kirkwood_cpuidle_init();
  80. #ifdef CONFIG_KEXEC
  81. kexec_reinit = kirkwood_enable_pcie;
  82. #endif
  83. if (of_machine_is_compatible("dlink,dns-kirkwood"))
  84. dnskw_init();
  85. of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
  86. }
  87. static const char * const kirkwood_dt_board_compat[] = {
  88. "marvell,kirkwood",
  89. NULL
  90. };
  91. DT_MACHINE_START(KIRKWOOD_DT, "Marvell Kirkwood (Flattened Device Tree)")
  92. /* Maintainer: Jason Cooper <jason@lakedaemon.net> */
  93. .map_io = kirkwood_map_io,
  94. .init_early = kirkwood_init_early,
  95. .init_irq = orion_dt_init_irq,
  96. .init_time = kirkwood_timer_init,
  97. .init_machine = kirkwood_dt_init,
  98. .restart = kirkwood_restart,
  99. .dt_compat = kirkwood_dt_board_compat,
  100. MACHINE_END