spear13xx.c 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * arch/arm/mach-spear13xx/spear13xx.c
  4. *
  5. * SPEAr13XX machines common source file
  6. *
  7. * Copyright (C) 2012 ST Microelectronics
  8. * Viresh Kumar <[email protected]>
  9. */
  10. #define pr_fmt(fmt) "SPEAr13xx: " fmt
  11. #include <linux/amba/pl022.h>
  12. #include <linux/clk.h>
  13. #include <linux/clk/spear.h>
  14. #include <linux/clocksource.h>
  15. #include <linux/err.h>
  16. #include <linux/of.h>
  17. #include <asm/hardware/cache-l2x0.h>
  18. #include <asm/mach/map.h>
  19. #include "spear.h"
  20. #include "generic.h"
  21. void __init spear13xx_l2x0_init(void)
  22. {
  23. /*
  24. * 512KB (64KB/way), 8-way associativity, parity supported
  25. *
  26. * FIXME: 9th bit, of Auxiliary Controller register must be set
  27. * for some spear13xx devices for stable L2 operation.
  28. *
  29. * Enable Early BRESP, L2 prefetch for Instruction and Data,
  30. * write alloc and 'Full line of zero' options
  31. *
  32. */
  33. if (!IS_ENABLED(CONFIG_CACHE_L2X0))
  34. return;
  35. writel_relaxed(0x06, VA_L2CC_BASE + L310_PREFETCH_CTRL);
  36. /*
  37. * Program following latencies in order to make
  38. * SPEAr1340 work at 600 MHz
  39. */
  40. writel_relaxed(0x221, VA_L2CC_BASE + L310_TAG_LATENCY_CTRL);
  41. writel_relaxed(0x441, VA_L2CC_BASE + L310_DATA_LATENCY_CTRL);
  42. l2x0_init(VA_L2CC_BASE, 0x30a00001, 0xfe0fffff);
  43. }
  44. /*
  45. * Following will create 16MB static virtual/physical mappings
  46. * PHYSICAL VIRTUAL
  47. * 0xB3000000 0xF9000000
  48. * 0xE0000000 0xFD000000
  49. * 0xEC000000 0xFC000000
  50. * 0xED000000 0xFB000000
  51. */
  52. static struct map_desc spear13xx_io_desc[] __initdata = {
  53. {
  54. .virtual = (unsigned long)VA_PERIP_GRP2_BASE,
  55. .pfn = __phys_to_pfn(PERIP_GRP2_BASE),
  56. .length = SZ_16M,
  57. .type = MT_DEVICE
  58. }, {
  59. .virtual = (unsigned long)VA_PERIP_GRP1_BASE,
  60. .pfn = __phys_to_pfn(PERIP_GRP1_BASE),
  61. .length = SZ_16M,
  62. .type = MT_DEVICE
  63. }, {
  64. .virtual = (unsigned long)VA_A9SM_AND_MPMC_BASE,
  65. .pfn = __phys_to_pfn(A9SM_AND_MPMC_BASE),
  66. .length = SZ_16M,
  67. .type = MT_DEVICE
  68. }, {
  69. .virtual = (unsigned long)VA_L2CC_BASE,
  70. .pfn = __phys_to_pfn(L2CC_BASE),
  71. .length = SZ_4K,
  72. .type = MT_DEVICE
  73. },
  74. };
  75. /* This will create static memory mapping for selected devices */
  76. void __init spear13xx_map_io(void)
  77. {
  78. iotable_init(spear13xx_io_desc, ARRAY_SIZE(spear13xx_io_desc));
  79. }
  80. static void __init spear13xx_clk_init(void)
  81. {
  82. if (of_machine_is_compatible("st,spear1310"))
  83. spear1310_clk_init(VA_MISC_BASE, VA_SPEAR1310_RAS_BASE);
  84. else if (of_machine_is_compatible("st,spear1340"))
  85. spear1340_clk_init(VA_MISC_BASE);
  86. else
  87. pr_err("%s: Unknown machine\n", __func__);
  88. }
  89. void __init spear13xx_timer_init(void)
  90. {
  91. char pclk_name[] = "osc_24m_clk";
  92. struct clk *gpt_clk, *pclk;
  93. spear13xx_clk_init();
  94. /* get the system timer clock */
  95. gpt_clk = clk_get_sys("gpt0", NULL);
  96. if (IS_ERR(gpt_clk)) {
  97. pr_err("%s:couldn't get clk for gpt\n", __func__);
  98. BUG();
  99. }
  100. /* get the suitable parent clock for timer*/
  101. pclk = clk_get(NULL, pclk_name);
  102. if (IS_ERR(pclk)) {
  103. pr_err("%s:couldn't get %s as parent for gpt\n", __func__,
  104. pclk_name);
  105. BUG();
  106. }
  107. clk_set_parent(gpt_clk, pclk);
  108. clk_put(gpt_clk);
  109. clk_put(pclk);
  110. spear_setup_of_timer();
  111. timer_probe();
  112. }