board-dt.c 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  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/clk/mvebu.h>
  18. #include <linux/kexec.h>
  19. #include <asm/mach/arch.h>
  20. #include <asm/mach/map.h>
  21. #include <mach/bridge-regs.h>
  22. #include <linux/platform_data/usb-ehci-orion.h>
  23. #include <plat/irq.h>
  24. #include <plat/common.h>
  25. #include "common.h"
  26. /*
  27. * There are still devices that doesn't know about DT yet. Get clock
  28. * gates here and add a clock lookup alias, so that old platform
  29. * devices still work.
  30. */
  31. static void __init kirkwood_legacy_clk_init(void)
  32. {
  33. struct device_node *np = of_find_compatible_node(
  34. NULL, NULL, "marvell,kirkwood-gating-clock");
  35. struct of_phandle_args clkspec;
  36. struct clk *clk;
  37. clkspec.np = np;
  38. clkspec.args_count = 1;
  39. clkspec.args[0] = CGC_BIT_PEX0;
  40. orion_clkdev_add("0", "pcie",
  41. of_clk_get_from_provider(&clkspec));
  42. clkspec.args[0] = CGC_BIT_PEX1;
  43. orion_clkdev_add("1", "pcie",
  44. of_clk_get_from_provider(&clkspec));
  45. clkspec.args[0] = CGC_BIT_SDIO;
  46. orion_clkdev_add(NULL, "mvsdio",
  47. of_clk_get_from_provider(&clkspec));
  48. /*
  49. * The ethernet interfaces forget the MAC address assigned by
  50. * u-boot if the clocks are turned off. Until proper DT support
  51. * is available we always enable them for now.
  52. */
  53. clkspec.args[0] = CGC_BIT_GE0;
  54. clk = of_clk_get_from_provider(&clkspec);
  55. orion_clkdev_add(NULL, "mv643xx_eth_port.0", clk);
  56. clk_prepare_enable(clk);
  57. clkspec.args[0] = CGC_BIT_GE1;
  58. clk = of_clk_get_from_provider(&clkspec);
  59. orion_clkdev_add(NULL, "mv643xx_eth_port.1", clk);
  60. clk_prepare_enable(clk);
  61. }
  62. static void __init kirkwood_of_clk_init(void)
  63. {
  64. mvebu_clocks_init();
  65. kirkwood_legacy_clk_init();
  66. }
  67. static void __init kirkwood_dt_init(void)
  68. {
  69. pr_info("Kirkwood: %s, TCLK=%d.\n", kirkwood_id(), kirkwood_tclk);
  70. /*
  71. * Disable propagation of mbus errors to the CPU local bus,
  72. * as this causes mbus errors (which can occur for example
  73. * for PCI aborts) to throw CPU aborts, which we're not set
  74. * up to deal with.
  75. */
  76. writel(readl(CPU_CONFIG) & ~CPU_CONFIG_ERROR_PROP, CPU_CONFIG);
  77. kirkwood_setup_wins();
  78. kirkwood_l2_init();
  79. kirkwood_cpufreq_init();
  80. /* Setup root of clk tree */
  81. kirkwood_of_clk_init();
  82. kirkwood_cpuidle_init();
  83. #ifdef CONFIG_KEXEC
  84. kexec_reinit = kirkwood_enable_pcie;
  85. #endif
  86. if (of_machine_is_compatible("globalscale,dreamplug"))
  87. dreamplug_init();
  88. if (of_machine_is_compatible("globalscale,guruplug"))
  89. guruplug_dt_init();
  90. if (of_machine_is_compatible("dlink,dns-kirkwood"))
  91. dnskw_init();
  92. if (of_machine_is_compatible("iom,iconnect"))
  93. iconnect_init();
  94. if (of_machine_is_compatible("raidsonic,ib-nas62x0"))
  95. ib62x0_init();
  96. if (of_machine_is_compatible("qnap,ts219"))
  97. qnap_dt_ts219_init();
  98. if (of_machine_is_compatible("seagate,dockstar"))
  99. dockstar_dt_init();
  100. if (of_machine_is_compatible("seagate,goflexnet"))
  101. goflexnet_init();
  102. if (of_machine_is_compatible("buffalo,lsxl"))
  103. lsxl_init();
  104. if (of_machine_is_compatible("iom,ix2-200"))
  105. iomega_ix2_200_init();
  106. if (of_machine_is_compatible("keymile,km_kirkwood"))
  107. km_kirkwood_init();
  108. if (of_machine_is_compatible("lacie,cloudbox") ||
  109. of_machine_is_compatible("lacie,inetspace_v2") ||
  110. of_machine_is_compatible("lacie,netspace_lite_v2") ||
  111. of_machine_is_compatible("lacie,netspace_max_v2") ||
  112. of_machine_is_compatible("lacie,netspace_mini_v2") ||
  113. of_machine_is_compatible("lacie,netspace_v2"))
  114. ns2_init();
  115. if (of_machine_is_compatible("mpl,cec4"))
  116. mplcec4_init();
  117. if (of_machine_is_compatible("netgear,readynas-duo-v2"))
  118. netgear_readynas_init();
  119. if (of_machine_is_compatible("plathome,openblocks-a6"))
  120. openblocks_a6_init();
  121. if (of_machine_is_compatible("usi,topkick"))
  122. usi_topkick_init();
  123. of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
  124. }
  125. static const char * const kirkwood_dt_board_compat[] = {
  126. "globalscale,dreamplug",
  127. "globalscale,guruplug",
  128. "dlink,dns-320",
  129. "dlink,dns-325",
  130. "iom,iconnect",
  131. "raidsonic,ib-nas62x0",
  132. "qnap,ts219",
  133. "seagate,dockstar",
  134. "seagate,goflexnet",
  135. "buffalo,lsxl",
  136. "iom,ix2-200",
  137. "keymile,km_kirkwood",
  138. "lacie,cloudbox",
  139. "lacie,inetspace_v2",
  140. "lacie,netspace_lite_v2",
  141. "lacie,netspace_max_v2",
  142. "lacie,netspace_mini_v2",
  143. "lacie,netspace_v2",
  144. "mpl,cec4",
  145. "netgear,readynas-duo-v2",
  146. "plathome,openblocks-a6",
  147. "usi,topkick",
  148. "zyxel,nsa310",
  149. NULL
  150. };
  151. DT_MACHINE_START(KIRKWOOD_DT, "Marvell Kirkwood (Flattened Device Tree)")
  152. /* Maintainer: Jason Cooper <jason@lakedaemon.net> */
  153. .map_io = kirkwood_map_io,
  154. .init_early = kirkwood_init_early,
  155. .init_irq = orion_dt_init_irq,
  156. .init_time = kirkwood_timer_init,
  157. .init_machine = kirkwood_dt_init,
  158. .restart = kirkwood_restart,
  159. .dt_compat = kirkwood_dt_board_compat,
  160. MACHINE_END