spear13xx.c 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. /*
  2. * arch/arm/mach-spear13xx/spear13xx.c
  3. *
  4. * SPEAr13XX machines common source file
  5. *
  6. * Copyright (C) 2012 ST Microelectronics
  7. * Viresh Kumar <viresh.linux@gmail.com>
  8. *
  9. * This file is licensed under the terms of the GNU General Public
  10. * License version 2. This program is licensed "as is" without any
  11. * warranty of any kind, whether express or implied.
  12. */
  13. #define pr_fmt(fmt) "SPEAr13xx: " fmt
  14. #include <linux/amba/pl022.h>
  15. #include <linux/clk.h>
  16. #include <linux/dw_dmac.h>
  17. #include <linux/err.h>
  18. #include <linux/of_irq.h>
  19. #include <asm/hardware/cache-l2x0.h>
  20. #include <asm/hardware/gic.h>
  21. #include <asm/mach/map.h>
  22. #include <asm/smp_twd.h>
  23. #include <mach/generic.h>
  24. #include <mach/spear.h>
  25. /* ssp device registration */
  26. struct pl022_ssp_controller pl022_plat_data = {
  27. .enable_dma = 1,
  28. .dma_filter = dw_dma_generic_filter,
  29. .dma_rx_param = "ssp0_rx",
  30. .dma_tx_param = "ssp0_tx",
  31. .num_chipselect = 3,
  32. };
  33. void __init spear13xx_l2x0_init(void)
  34. {
  35. /*
  36. * 512KB (64KB/way), 8-way associativity, parity supported
  37. *
  38. * FIXME: 9th bit, of Auxillary Controller register must be set
  39. * for some spear13xx devices for stable L2 operation.
  40. *
  41. * Enable Early BRESP, L2 prefetch for Instruction and Data,
  42. * write alloc and 'Full line of zero' options
  43. *
  44. */
  45. writel_relaxed(0x06, VA_L2CC_BASE + L2X0_PREFETCH_CTRL);
  46. /*
  47. * Program following latencies in order to make
  48. * SPEAr1340 work at 600 MHz
  49. */
  50. writel_relaxed(0x221, VA_L2CC_BASE + L2X0_TAG_LATENCY_CTRL);
  51. writel_relaxed(0x441, VA_L2CC_BASE + L2X0_DATA_LATENCY_CTRL);
  52. l2x0_init(VA_L2CC_BASE, 0x70A60001, 0xfe00ffff);
  53. }
  54. /*
  55. * Following will create 16MB static virtual/physical mappings
  56. * PHYSICAL VIRTUAL
  57. * 0xB3000000 0xFE000000
  58. * 0xE0000000 0xFD000000
  59. * 0xEC000000 0xFC000000
  60. * 0xED000000 0xFB000000
  61. */
  62. struct map_desc spear13xx_io_desc[] __initdata = {
  63. {
  64. .virtual = (unsigned long)VA_PERIP_GRP2_BASE,
  65. .pfn = __phys_to_pfn(PERIP_GRP2_BASE),
  66. .length = SZ_16M,
  67. .type = MT_DEVICE
  68. }, {
  69. .virtual = (unsigned long)VA_PERIP_GRP1_BASE,
  70. .pfn = __phys_to_pfn(PERIP_GRP1_BASE),
  71. .length = SZ_16M,
  72. .type = MT_DEVICE
  73. }, {
  74. .virtual = (unsigned long)VA_A9SM_AND_MPMC_BASE,
  75. .pfn = __phys_to_pfn(A9SM_AND_MPMC_BASE),
  76. .length = SZ_16M,
  77. .type = MT_DEVICE
  78. }, {
  79. .virtual = (unsigned long)VA_L2CC_BASE,
  80. .pfn = __phys_to_pfn(L2CC_BASE),
  81. .length = SZ_4K,
  82. .type = MT_DEVICE
  83. },
  84. };
  85. /* This will create static memory mapping for selected devices */
  86. void __init spear13xx_map_io(void)
  87. {
  88. iotable_init(spear13xx_io_desc, ARRAY_SIZE(spear13xx_io_desc));
  89. }
  90. static void __init spear13xx_clk_init(void)
  91. {
  92. if (of_machine_is_compatible("st,spear1310"))
  93. spear1310_clk_init();
  94. else if (of_machine_is_compatible("st,spear1340"))
  95. spear1340_clk_init();
  96. else
  97. pr_err("%s: Unknown machine\n", __func__);
  98. }
  99. static void __init spear13xx_timer_init(void)
  100. {
  101. char pclk_name[] = "osc_24m_clk";
  102. struct clk *gpt_clk, *pclk;
  103. spear13xx_clk_init();
  104. /* get the system timer clock */
  105. gpt_clk = clk_get_sys("gpt0", NULL);
  106. if (IS_ERR(gpt_clk)) {
  107. pr_err("%s:couldn't get clk for gpt\n", __func__);
  108. BUG();
  109. }
  110. /* get the suitable parent clock for timer*/
  111. pclk = clk_get(NULL, pclk_name);
  112. if (IS_ERR(pclk)) {
  113. pr_err("%s:couldn't get %s as parent for gpt\n", __func__,
  114. pclk_name);
  115. BUG();
  116. }
  117. clk_set_parent(gpt_clk, pclk);
  118. clk_put(gpt_clk);
  119. clk_put(pclk);
  120. spear_setup_of_timer();
  121. twd_local_timer_of_register();
  122. }
  123. struct sys_timer spear13xx_timer = {
  124. .init = spear13xx_timer_init,
  125. };
  126. static const struct of_device_id gic_of_match[] __initconst = {
  127. { .compatible = "arm,cortex-a9-gic", .data = gic_of_init },
  128. { /* Sentinel */ }
  129. };
  130. void __init spear13xx_dt_init_irq(void)
  131. {
  132. of_irq_init(gic_of_match);
  133. }