imx51-dt.c 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. /*
  2. * Copyright 2011 Freescale Semiconductor, Inc. All Rights Reserved.
  3. * Copyright 2011 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/irq.h>
  13. #include <linux/irqdomain.h>
  14. #include <linux/of_irq.h>
  15. #include <linux/of_platform.h>
  16. #include <asm/mach/arch.h>
  17. #include <asm/mach/time.h>
  18. #include <mach/common.h>
  19. #include <mach/mx51.h>
  20. /*
  21. * Lookup table for attaching a specific name and platform_data pointer to
  22. * devices as they get created by of_platform_populate(). Ideally this table
  23. * would not exist, but the current clock implementation depends on some devices
  24. * having a specific name.
  25. */
  26. static const struct of_dev_auxdata imx51_auxdata_lookup[] __initconst = {
  27. OF_DEV_AUXDATA("fsl,imx51-uart", MX51_UART1_BASE_ADDR, "imx21-uart.0", NULL),
  28. OF_DEV_AUXDATA("fsl,imx51-uart", MX51_UART2_BASE_ADDR, "imx21-uart.1", NULL),
  29. OF_DEV_AUXDATA("fsl,imx51-uart", MX51_UART3_BASE_ADDR, "imx21-uart.2", NULL),
  30. OF_DEV_AUXDATA("fsl,imx51-fec", MX51_FEC_BASE_ADDR, "imx27-fec.0", NULL),
  31. OF_DEV_AUXDATA("fsl,imx51-esdhc", MX51_ESDHC1_BASE_ADDR, "sdhci-esdhc-imx51.0", NULL),
  32. OF_DEV_AUXDATA("fsl,imx51-esdhc", MX51_ESDHC2_BASE_ADDR, "sdhci-esdhc-imx51.1", NULL),
  33. OF_DEV_AUXDATA("fsl,imx51-esdhc", MX51_ESDHC3_BASE_ADDR, "sdhci-esdhc-imx51.2", NULL),
  34. OF_DEV_AUXDATA("fsl,imx51-esdhc", MX51_ESDHC4_BASE_ADDR, "sdhci-esdhc-imx51.3", NULL),
  35. OF_DEV_AUXDATA("fsl,imx51-ecspi", MX51_ECSPI1_BASE_ADDR, "imx51-ecspi.0", NULL),
  36. OF_DEV_AUXDATA("fsl,imx51-ecspi", MX51_ECSPI2_BASE_ADDR, "imx51-ecspi.1", NULL),
  37. OF_DEV_AUXDATA("fsl,imx51-cspi", MX51_CSPI_BASE_ADDR, "imx35-cspi.0", NULL),
  38. OF_DEV_AUXDATA("fsl,imx51-i2c", MX51_I2C1_BASE_ADDR, "imx-i2c.0", NULL),
  39. OF_DEV_AUXDATA("fsl,imx51-i2c", MX51_I2C2_BASE_ADDR, "imx-i2c.1", NULL),
  40. OF_DEV_AUXDATA("fsl,imx51-sdma", MX51_SDMA_BASE_ADDR, "imx35-sdma", NULL),
  41. OF_DEV_AUXDATA("fsl,imx51-wdt", MX51_WDOG1_BASE_ADDR, "imx2-wdt.0", NULL),
  42. { /* sentinel */ }
  43. };
  44. static int __init imx51_tzic_add_irq_domain(struct device_node *np,
  45. struct device_node *interrupt_parent)
  46. {
  47. irq_domain_add_legacy(np, 128, 0, 0, &irq_domain_simple_ops, NULL);
  48. return 0;
  49. }
  50. static int __init imx51_gpio_add_irq_domain(struct device_node *np,
  51. struct device_node *interrupt_parent)
  52. {
  53. static int gpio_irq_base = MXC_GPIO_IRQ_START + ARCH_NR_GPIOS;
  54. gpio_irq_base -= 32;
  55. irq_domain_add_legacy(np, 32, gpio_irq_base, 0, &irq_domain_simple_ops, NULL);
  56. return 0;
  57. }
  58. static const struct of_device_id imx51_irq_match[] __initconst = {
  59. { .compatible = "fsl,imx51-tzic", .data = imx51_tzic_add_irq_domain, },
  60. { .compatible = "fsl,imx51-gpio", .data = imx51_gpio_add_irq_domain, },
  61. { /* sentinel */ }
  62. };
  63. static const struct of_device_id imx51_iomuxc_of_match[] __initconst = {
  64. { .compatible = "fsl,imx51-iomuxc-babbage", .data = imx51_babbage_common_init, },
  65. { /* sentinel */ }
  66. };
  67. static void __init imx51_dt_init(void)
  68. {
  69. struct device_node *node;
  70. const struct of_device_id *of_id;
  71. void (*func)(void);
  72. of_irq_init(imx51_irq_match);
  73. node = of_find_matching_node(NULL, imx51_iomuxc_of_match);
  74. if (node) {
  75. of_id = of_match_node(imx51_iomuxc_of_match, node);
  76. func = of_id->data;
  77. func();
  78. of_node_put(node);
  79. }
  80. of_platform_populate(NULL, of_default_bus_match_table,
  81. imx51_auxdata_lookup, NULL);
  82. }
  83. static void __init imx51_timer_init(void)
  84. {
  85. mx51_clocks_init_dt();
  86. }
  87. static struct sys_timer imx51_timer = {
  88. .init = imx51_timer_init,
  89. };
  90. static const char *imx51_dt_board_compat[] __initdata = {
  91. "fsl,imx51-babbage",
  92. "fsl,imx51",
  93. NULL
  94. };
  95. DT_MACHINE_START(IMX51_DT, "Freescale i.MX51 (Device Tree Support)")
  96. .map_io = mx51_map_io,
  97. .init_early = imx51_init_early,
  98. .init_irq = mx51_init_irq,
  99. .handle_irq = imx51_handle_irq,
  100. .timer = &imx51_timer,
  101. .init_machine = imx51_dt_init,
  102. .dt_compat = imx51_dt_board_compat,
  103. .restart = mxc_restart,
  104. MACHINE_END