clk-uniphier-sys.c 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. /*
  2. * Copyright (C) 2016 Socionext Inc.
  3. * Author: Masahiro Yamada <[email protected]>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. */
  15. #include <linux/stddef.h>
  16. #include "clk-uniphier.h"
  17. #define UNIPHIER_SLD3_SYS_CLK_SD \
  18. UNIPHIER_CLK_FACTOR("sd-200m", -1, "spll", 1, 8), \
  19. UNIPHIER_CLK_FACTOR("sd-133m", -1, "vpll27a", 1, 2)
  20. #define UNIPHIER_PRO5_SYS_CLK_SD \
  21. UNIPHIER_CLK_FACTOR("sd-200m", -1, "spll", 1, 12), \
  22. UNIPHIER_CLK_FACTOR("sd-133m", -1, "spll", 1, 18)
  23. #define UNIPHIER_LD20_SYS_CLK_SD \
  24. UNIPHIER_CLK_FACTOR("sd-200m", -1, "spll", 1, 10), \
  25. UNIPHIER_CLK_FACTOR("sd-133m", -1, "spll", 1, 15)
  26. #define UNIPHIER_SLD3_SYS_CLK_STDMAC(idx) \
  27. UNIPHIER_CLK_GATE("stdmac", (idx), NULL, 0x2104, 10)
  28. #define UNIPHIER_LD11_SYS_CLK_STDMAC(idx) \
  29. UNIPHIER_CLK_GATE("stdmac", (idx), NULL, 0x210c, 8)
  30. #define UNIPHIER_PRO4_SYS_CLK_GIO(idx) \
  31. UNIPHIER_CLK_GATE("gio", (idx), NULL, 0x2104, 6)
  32. #define UNIPHIER_PRO4_SYS_CLK_USB3(idx, ch) \
  33. UNIPHIER_CLK_GATE("usb3" #ch, (idx), NULL, 0x2104, 16 + (ch))
  34. const struct uniphier_clk_data uniphier_sld3_sys_clk_data[] = {
  35. UNIPHIER_CLK_FACTOR("spll", -1, "ref", 65, 1), /* 1597.44 MHz */
  36. UNIPHIER_CLK_FACTOR("upll", -1, "ref", 6000, 512), /* 288 MHz */
  37. UNIPHIER_CLK_FACTOR("a2pll", -1, "ref", 24, 1), /* 589.824 MHz */
  38. UNIPHIER_CLK_FACTOR("vpll27a", -1, "ref", 5625, 512), /* 270 MHz */
  39. UNIPHIER_CLK_FACTOR("uart", 0, "a2pll", 1, 16),
  40. UNIPHIER_CLK_FACTOR("i2c", 1, "spll", 1, 16),
  41. UNIPHIER_SLD3_SYS_CLK_SD,
  42. UNIPHIER_CLK_FACTOR("usb2", -1, "upll", 1, 12),
  43. UNIPHIER_SLD3_SYS_CLK_STDMAC(8),
  44. { /* sentinel */ }
  45. };
  46. const struct uniphier_clk_data uniphier_ld4_sys_clk_data[] = {
  47. UNIPHIER_CLK_FACTOR("spll", -1, "ref", 65, 1), /* 1597.44 MHz */
  48. UNIPHIER_CLK_FACTOR("upll", -1, "ref", 6000, 512), /* 288 MHz */
  49. UNIPHIER_CLK_FACTOR("a2pll", -1, "ref", 24, 1), /* 589.824 MHz */
  50. UNIPHIER_CLK_FACTOR("vpll27a", -1, "ref", 5625, 512), /* 270 MHz */
  51. UNIPHIER_CLK_FACTOR("uart", 0, "a2pll", 1, 16),
  52. UNIPHIER_CLK_FACTOR("i2c", 1, "spll", 1, 16),
  53. UNIPHIER_SLD3_SYS_CLK_SD,
  54. UNIPHIER_CLK_FACTOR("usb2", -1, "upll", 1, 12),
  55. UNIPHIER_SLD3_SYS_CLK_STDMAC(8), /* Ether, HSC, MIO */
  56. { /* sentinel */ }
  57. };
  58. const struct uniphier_clk_data uniphier_pro4_sys_clk_data[] = {
  59. UNIPHIER_CLK_FACTOR("spll", -1, "ref", 64, 1), /* 1600 MHz */
  60. UNIPHIER_CLK_FACTOR("upll", -1, "ref", 288, 25), /* 288 MHz */
  61. UNIPHIER_CLK_FACTOR("a2pll", -1, "upll", 256, 125), /* 589.824 MHz */
  62. UNIPHIER_CLK_FACTOR("vpll27a", -1, "ref", 270, 25), /* 270 MHz */
  63. UNIPHIER_CLK_FACTOR("uart", 0, "a2pll", 1, 8),
  64. UNIPHIER_CLK_FACTOR("i2c", 1, "spll", 1, 32),
  65. UNIPHIER_SLD3_SYS_CLK_SD,
  66. UNIPHIER_CLK_FACTOR("usb2", -1, "upll", 1, 12),
  67. UNIPHIER_SLD3_SYS_CLK_STDMAC(8), /* HSC, MIO, RLE */
  68. UNIPHIER_PRO4_SYS_CLK_GIO(12), /* Ether, SATA, USB3 */
  69. UNIPHIER_PRO4_SYS_CLK_USB3(14, 0),
  70. UNIPHIER_PRO4_SYS_CLK_USB3(15, 1),
  71. { /* sentinel */ }
  72. };
  73. const struct uniphier_clk_data uniphier_sld8_sys_clk_data[] = {
  74. UNIPHIER_CLK_FACTOR("spll", -1, "ref", 64, 1), /* 1600 MHz */
  75. UNIPHIER_CLK_FACTOR("upll", -1, "ref", 288, 25), /* 288 MHz */
  76. UNIPHIER_CLK_FACTOR("vpll27a", -1, "ref", 270, 25), /* 270 MHz */
  77. UNIPHIER_CLK_FACTOR("uart", 0, "spll", 1, 20),
  78. UNIPHIER_CLK_FACTOR("i2c", 1, "spll", 1, 16),
  79. UNIPHIER_SLD3_SYS_CLK_SD,
  80. UNIPHIER_CLK_FACTOR("usb2", -1, "upll", 1, 12),
  81. UNIPHIER_SLD3_SYS_CLK_STDMAC(8), /* Ether, HSC, MIO */
  82. { /* sentinel */ }
  83. };
  84. const struct uniphier_clk_data uniphier_pro5_sys_clk_data[] = {
  85. UNIPHIER_CLK_FACTOR("spll", -1, "ref", 120, 1), /* 2400 MHz */
  86. UNIPHIER_CLK_FACTOR("dapll1", -1, "ref", 128, 1), /* 2560 MHz */
  87. UNIPHIER_CLK_FACTOR("dapll2", -1, "dapll1", 144, 125), /* 2949.12 MHz */
  88. UNIPHIER_CLK_FACTOR("uart", 0, "dapll2", 1, 40),
  89. UNIPHIER_CLK_FACTOR("i2c", 1, "spll", 1, 48),
  90. UNIPHIER_PRO5_SYS_CLK_SD,
  91. UNIPHIER_SLD3_SYS_CLK_STDMAC(8), /* HSC */
  92. UNIPHIER_PRO4_SYS_CLK_GIO(12), /* PCIe, USB3 */
  93. UNIPHIER_PRO4_SYS_CLK_USB3(14, 0),
  94. UNIPHIER_PRO4_SYS_CLK_USB3(15, 1),
  95. { /* sentinel */ }
  96. };
  97. const struct uniphier_clk_data uniphier_pxs2_sys_clk_data[] = {
  98. UNIPHIER_CLK_FACTOR("spll", -1, "ref", 96, 1), /* 2400 MHz */
  99. UNIPHIER_CLK_FACTOR("uart", 0, "spll", 1, 27),
  100. UNIPHIER_CLK_FACTOR("i2c", 1, "spll", 1, 48),
  101. UNIPHIER_PRO5_SYS_CLK_SD,
  102. UNIPHIER_SLD3_SYS_CLK_STDMAC(8), /* HSC, RLE */
  103. /* GIO is always clock-enabled: no function for 0x2104 bit6 */
  104. UNIPHIER_PRO4_SYS_CLK_USB3(14, 0),
  105. UNIPHIER_PRO4_SYS_CLK_USB3(15, 1),
  106. /* The document mentions 0x2104 bit 18, but not functional */
  107. UNIPHIER_CLK_GATE("usb30-phy", 16, NULL, 0x2104, 19),
  108. UNIPHIER_CLK_GATE("usb31-phy", 20, NULL, 0x2104, 20),
  109. { /* sentinel */ }
  110. };
  111. const struct uniphier_clk_data uniphier_ld11_sys_clk_data[] = {
  112. UNIPHIER_CLK_FACTOR("spll", -1, "ref", 80, 1), /* 2000 MHz */
  113. UNIPHIER_CLK_FACTOR("uart", 0, "spll", 1, 34),
  114. UNIPHIER_CLK_FACTOR("i2c", 1, "spll", 1, 40),
  115. UNIPHIER_LD11_SYS_CLK_STDMAC(8), /* HSC, MIO */
  116. UNIPHIER_CLK_FACTOR("usb2", -1, "ref", 24, 25),
  117. { /* sentinel */ }
  118. };
  119. const struct uniphier_clk_data uniphier_ld20_sys_clk_data[] = {
  120. UNIPHIER_CLK_FACTOR("spll", -1, "ref", 80, 1), /* 2000 MHz */
  121. UNIPHIER_CLK_FACTOR("uart", 0, "spll", 1, 34),
  122. UNIPHIER_CLK_FACTOR("i2c", 1, "spll", 1, 40),
  123. UNIPHIER_LD20_SYS_CLK_SD,
  124. UNIPHIER_LD11_SYS_CLK_STDMAC(8), /* HSC */
  125. /* GIO is always clock-enabled: no function for 0x210c bit5 */
  126. /*
  127. * clock for USB Link is enabled by the logic "OR" of bit 14 and bit 15.
  128. * We do not use bit 15 here.
  129. */
  130. UNIPHIER_CLK_GATE("usb30", 14, NULL, 0x210c, 14),
  131. UNIPHIER_CLK_GATE("usb30-phy0", 16, NULL, 0x210c, 12),
  132. UNIPHIER_CLK_GATE("usb30-phy1", 17, NULL, 0x210c, 13),
  133. { /* sentinel */ }
  134. };