spear6xx.c 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. /*
  2. * arch/arm/mach-spear6xx/spear6xx.c
  3. *
  4. * SPEAr6XX machines common source file
  5. *
  6. * Copyright (C) 2009 ST Microelectronics
  7. * Rajeev Kumar<rajeev-dlh.kumar@st.com>
  8. *
  9. * Copyright 2012 Stefan Roese <sr@denx.de>
  10. *
  11. * This file is licensed under the terms of the GNU General Public
  12. * License version 2. This program is licensed "as is" without any
  13. * warranty of any kind, whether express or implied.
  14. */
  15. #include <linux/of.h>
  16. #include <linux/of_address.h>
  17. #include <linux/of_irq.h>
  18. #include <linux/of_platform.h>
  19. #include <asm/hardware/vic.h>
  20. #include <asm/mach/arch.h>
  21. #include <mach/generic.h>
  22. #include <mach/hardware.h>
  23. /* Following will create static virtual/physical mappings */
  24. static struct map_desc spear6xx_io_desc[] __initdata = {
  25. {
  26. .virtual = VA_SPEAR6XX_ICM1_UART0_BASE,
  27. .pfn = __phys_to_pfn(SPEAR6XX_ICM1_UART0_BASE),
  28. .length = SZ_4K,
  29. .type = MT_DEVICE
  30. }, {
  31. .virtual = VA_SPEAR6XX_CPU_VIC_PRI_BASE,
  32. .pfn = __phys_to_pfn(SPEAR6XX_CPU_VIC_PRI_BASE),
  33. .length = SZ_4K,
  34. .type = MT_DEVICE
  35. }, {
  36. .virtual = VA_SPEAR6XX_CPU_VIC_SEC_BASE,
  37. .pfn = __phys_to_pfn(SPEAR6XX_CPU_VIC_SEC_BASE),
  38. .length = SZ_4K,
  39. .type = MT_DEVICE
  40. }, {
  41. .virtual = VA_SPEAR6XX_ICM3_SYS_CTRL_BASE,
  42. .pfn = __phys_to_pfn(SPEAR6XX_ICM3_SYS_CTRL_BASE),
  43. .length = SZ_4K,
  44. .type = MT_DEVICE
  45. }, {
  46. .virtual = VA_SPEAR6XX_ICM3_MISC_REG_BASE,
  47. .pfn = __phys_to_pfn(SPEAR6XX_ICM3_MISC_REG_BASE),
  48. .length = SZ_4K,
  49. .type = MT_DEVICE
  50. },
  51. };
  52. /* This will create static memory mapping for selected devices */
  53. void __init spear6xx_map_io(void)
  54. {
  55. iotable_init(spear6xx_io_desc, ARRAY_SIZE(spear6xx_io_desc));
  56. }
  57. static void __init spear6xx_timer_init(void)
  58. {
  59. char pclk_name[] = "pll3_48m_clk";
  60. struct clk *gpt_clk, *pclk;
  61. spear6xx_clk_init();
  62. /* get the system timer clock */
  63. gpt_clk = clk_get_sys("gpt0", NULL);
  64. if (IS_ERR(gpt_clk)) {
  65. pr_err("%s:couldn't get clk for gpt\n", __func__);
  66. BUG();
  67. }
  68. /* get the suitable parent clock for timer*/
  69. pclk = clk_get(NULL, pclk_name);
  70. if (IS_ERR(pclk)) {
  71. pr_err("%s:couldn't get %s as parent for gpt\n",
  72. __func__, pclk_name);
  73. BUG();
  74. }
  75. clk_set_parent(gpt_clk, pclk);
  76. clk_put(gpt_clk);
  77. clk_put(pclk);
  78. spear_setup_timer();
  79. }
  80. struct sys_timer spear6xx_timer = {
  81. .init = spear6xx_timer_init,
  82. };
  83. static void __init spear600_dt_init(void)
  84. {
  85. of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
  86. }
  87. static const char *spear600_dt_board_compat[] = {
  88. "st,spear600",
  89. NULL
  90. };
  91. static const struct of_device_id vic_of_match[] __initconst = {
  92. { .compatible = "arm,pl190-vic", .data = vic_of_init, },
  93. { /* Sentinel */ }
  94. };
  95. static void __init spear6xx_dt_init_irq(void)
  96. {
  97. of_irq_init(vic_of_match);
  98. }
  99. DT_MACHINE_START(SPEAR600_DT, "ST SPEAr600 (Flattened Device Tree)")
  100. .map_io = spear6xx_map_io,
  101. .init_irq = spear6xx_dt_init_irq,
  102. .handle_irq = vic_handle_irq,
  103. .timer = &spear6xx_timer,
  104. .init_machine = spear600_dt_init,
  105. .restart = spear_restart,
  106. .dt_compat = spear600_dt_board_compat,
  107. MACHINE_END