mach-mxs.c 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. /*
  2. * Copyright 2012 Freescale Semiconductor, Inc.
  3. * Copyright 2012 Linaro Ltd.
  4. *
  5. * The code contained herein is licensed under the GNU General Public
  6. * License. You may obtain a copy of the GNU General Public License
  7. * Version 2 or later at the following locations:
  8. *
  9. * http://www.opensource.org/licenses/gpl-license.html
  10. * http://www.gnu.org/copyleft/gpl.html
  11. */
  12. #include <linux/clk.h>
  13. #include <linux/clkdev.h>
  14. #include <linux/err.h>
  15. #include <linux/init.h>
  16. #include <linux/init.h>
  17. #include <linux/irqdomain.h>
  18. #include <linux/of_irq.h>
  19. #include <linux/of_platform.h>
  20. #include <asm/mach/arch.h>
  21. #include <asm/mach/time.h>
  22. #include <mach/common.h>
  23. static int __init mxs_icoll_add_irq_domain(struct device_node *np,
  24. struct device_node *interrupt_parent)
  25. {
  26. irq_domain_add_legacy(np, 128, 0, 0, &irq_domain_simple_ops, NULL);
  27. return 0;
  28. }
  29. static int __init mxs_gpio_add_irq_domain(struct device_node *np,
  30. struct device_node *interrupt_parent)
  31. {
  32. static int gpio_irq_base = MXS_GPIO_IRQ_START;
  33. irq_domain_add_legacy(np, 32, gpio_irq_base, 0, &irq_domain_simple_ops, NULL);
  34. gpio_irq_base += 32;
  35. return 0;
  36. }
  37. static const struct of_device_id mxs_irq_match[] __initconst = {
  38. { .compatible = "fsl,mxs-icoll", .data = mxs_icoll_add_irq_domain, },
  39. { .compatible = "fsl,mxs-gpio", .data = mxs_gpio_add_irq_domain, },
  40. { /* sentinel */ }
  41. };
  42. static void __init mxs_dt_init_irq(void)
  43. {
  44. icoll_init_irq();
  45. of_irq_init(mxs_irq_match);
  46. }
  47. static void __init imx23_timer_init(void)
  48. {
  49. mx23_clocks_init();
  50. }
  51. static struct sys_timer imx23_timer = {
  52. .init = imx23_timer_init,
  53. };
  54. static void __init imx28_timer_init(void)
  55. {
  56. mx28_clocks_init();
  57. }
  58. static struct sys_timer imx28_timer = {
  59. .init = imx28_timer_init,
  60. };
  61. static void __init imx28_evk_init(void)
  62. {
  63. struct clk *clk;
  64. /* Enable fec phy clock */
  65. clk = clk_get_sys("enet_out", NULL);
  66. if (!IS_ERR(clk))
  67. clk_prepare_enable(clk);
  68. }
  69. static void __init mxs_machine_init(void)
  70. {
  71. if (of_machine_is_compatible("fsl,imx28-evk"))
  72. imx28_evk_init();
  73. of_platform_populate(NULL, of_default_bus_match_table,
  74. NULL, NULL);
  75. }
  76. static const char *imx23_dt_compat[] __initdata = {
  77. "fsl,imx23-evk",
  78. "fsl,imx23",
  79. NULL,
  80. };
  81. static const char *imx28_dt_compat[] __initdata = {
  82. "fsl,imx28-evk",
  83. "fsl,imx28",
  84. NULL,
  85. };
  86. DT_MACHINE_START(IMX23, "Freescale i.MX23 (Device Tree)")
  87. .map_io = mx23_map_io,
  88. .init_irq = mxs_dt_init_irq,
  89. .timer = &imx23_timer,
  90. .init_machine = mxs_machine_init,
  91. .dt_compat = imx23_dt_compat,
  92. .restart = mxs_restart,
  93. MACHINE_END
  94. DT_MACHINE_START(IMX28, "Freescale i.MX28 (Device Tree)")
  95. .map_io = mx28_map_io,
  96. .init_irq = mxs_dt_init_irq,
  97. .timer = &imx28_timer,
  98. .init_machine = mxs_machine_init,
  99. .dt_compat = imx28_dt_compat,
  100. .restart = mxs_restart,
  101. MACHINE_END