spear6xx.c 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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. /* This will initialize clock framework */
  57. spear6xx_clk_init();
  58. }
  59. static void __init spear6xx_timer_init(void)
  60. {
  61. char pclk_name[] = "pll3_48m_clk";
  62. struct clk *gpt_clk, *pclk;
  63. /* get the system timer clock */
  64. gpt_clk = clk_get_sys("gpt0", NULL);
  65. if (IS_ERR(gpt_clk)) {
  66. pr_err("%s:couldn't get clk for gpt\n", __func__);
  67. BUG();
  68. }
  69. /* get the suitable parent clock for timer*/
  70. pclk = clk_get(NULL, pclk_name);
  71. if (IS_ERR(pclk)) {
  72. pr_err("%s:couldn't get %s as parent for gpt\n",
  73. __func__, pclk_name);
  74. BUG();
  75. }
  76. clk_set_parent(gpt_clk, pclk);
  77. clk_put(gpt_clk);
  78. clk_put(pclk);
  79. spear_setup_timer();
  80. }
  81. struct sys_timer spear6xx_timer = {
  82. .init = spear6xx_timer_init,
  83. };
  84. static void __init spear600_dt_init(void)
  85. {
  86. of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
  87. }
  88. static const char *spear600_dt_board_compat[] = {
  89. "st,spear600",
  90. NULL
  91. };
  92. static const struct of_device_id vic_of_match[] __initconst = {
  93. { .compatible = "arm,pl190-vic", .data = vic_of_init, },
  94. { /* Sentinel */ }
  95. };
  96. static void __init spear6xx_dt_init_irq(void)
  97. {
  98. of_irq_init(vic_of_match);
  99. }
  100. DT_MACHINE_START(SPEAR600_DT, "ST SPEAr600 (Flattened Device Tree)")
  101. .map_io = spear6xx_map_io,
  102. .init_irq = spear6xx_dt_init_irq,
  103. .handle_irq = vic_handle_irq,
  104. .timer = &spear6xx_timer,
  105. .init_machine = spear600_dt_init,
  106. .restart = spear_restart,
  107. .dt_compat = spear600_dt_board_compat,
  108. MACHINE_END