clk-nsp.c 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. // Copyright (C) 2015 Broadcom Corporation
  3. #include <linux/kernel.h>
  4. #include <linux/err.h>
  5. #include <linux/clk-provider.h>
  6. #include <linux/io.h>
  7. #include <linux/of.h>
  8. #include <linux/of_address.h>
  9. #include <dt-bindings/clock/bcm-nsp.h>
  10. #include "clk-iproc.h"
  11. #define REG_VAL(o, s, w) { .offset = o, .shift = s, .width = w, }
  12. #define AON_VAL(o, pw, ps, is) { .offset = o, .pwr_width = pw, \
  13. .pwr_shift = ps, .iso_shift = is }
  14. #define RESET_VAL(o, rs, prs) { .offset = o, .reset_shift = rs, \
  15. .p_reset_shift = prs }
  16. #define DF_VAL(o, kis, kiw, kps, kpw, kas, kaw) { .offset = o, .ki_shift = kis,\
  17. .ki_width = kiw, .kp_shift = kps, .kp_width = kpw, .ka_shift = kas, \
  18. .ka_width = kaw }
  19. #define ENABLE_VAL(o, es, hs, bs) { .offset = o, .enable_shift = es, \
  20. .hold_shift = hs, .bypass_shift = bs }
  21. static void __init nsp_armpll_init(struct device_node *node)
  22. {
  23. iproc_armpll_setup(node);
  24. }
  25. CLK_OF_DECLARE(nsp_armpll, "brcm,nsp-armpll", nsp_armpll_init);
  26. static const struct iproc_pll_ctrl genpll = {
  27. .flags = IPROC_CLK_PLL_HAS_NDIV_FRAC | IPROC_CLK_EMBED_PWRCTRL,
  28. .aon = AON_VAL(0x0, 1, 12, 0),
  29. .reset = RESET_VAL(0x0, 11, 10),
  30. .dig_filter = DF_VAL(0x0, 4, 3, 0, 4, 7, 3),
  31. .ndiv_int = REG_VAL(0x14, 20, 10),
  32. .ndiv_frac = REG_VAL(0x14, 0, 20),
  33. .pdiv = REG_VAL(0x18, 24, 3),
  34. .status = REG_VAL(0x20, 12, 1),
  35. };
  36. static const struct iproc_clk_ctrl genpll_clk[] = {
  37. [BCM_NSP_GENPLL_PHY_CLK] = {
  38. .channel = BCM_NSP_GENPLL_PHY_CLK,
  39. .flags = IPROC_CLK_AON,
  40. .enable = ENABLE_VAL(0x4, 12, 6, 18),
  41. .mdiv = REG_VAL(0x18, 16, 8),
  42. },
  43. [BCM_NSP_GENPLL_ENET_SW_CLK] = {
  44. .channel = BCM_NSP_GENPLL_ENET_SW_CLK,
  45. .flags = IPROC_CLK_AON,
  46. .enable = ENABLE_VAL(0x4, 13, 7, 19),
  47. .mdiv = REG_VAL(0x18, 8, 8),
  48. },
  49. [BCM_NSP_GENPLL_USB_PHY_REF_CLK] = {
  50. .channel = BCM_NSP_GENPLL_USB_PHY_REF_CLK,
  51. .flags = IPROC_CLK_AON,
  52. .enable = ENABLE_VAL(0x4, 14, 8, 20),
  53. .mdiv = REG_VAL(0x18, 0, 8),
  54. },
  55. [BCM_NSP_GENPLL_IPROCFAST_CLK] = {
  56. .channel = BCM_NSP_GENPLL_IPROCFAST_CLK,
  57. .flags = IPROC_CLK_AON,
  58. .enable = ENABLE_VAL(0x4, 15, 9, 21),
  59. .mdiv = REG_VAL(0x1c, 16, 8),
  60. },
  61. [BCM_NSP_GENPLL_SATA1_CLK] = {
  62. .channel = BCM_NSP_GENPLL_SATA1_CLK,
  63. .flags = IPROC_CLK_AON,
  64. .enable = ENABLE_VAL(0x4, 16, 10, 22),
  65. .mdiv = REG_VAL(0x1c, 8, 8),
  66. },
  67. [BCM_NSP_GENPLL_SATA2_CLK] = {
  68. .channel = BCM_NSP_GENPLL_SATA2_CLK,
  69. .flags = IPROC_CLK_AON,
  70. .enable = ENABLE_VAL(0x4, 17, 11, 23),
  71. .mdiv = REG_VAL(0x1c, 0, 8),
  72. },
  73. };
  74. static void __init nsp_genpll_clk_init(struct device_node *node)
  75. {
  76. iproc_pll_clk_setup(node, &genpll, NULL, 0, genpll_clk,
  77. ARRAY_SIZE(genpll_clk));
  78. }
  79. CLK_OF_DECLARE(nsp_genpll_clk, "brcm,nsp-genpll", nsp_genpll_clk_init);
  80. static const struct iproc_pll_ctrl lcpll0 = {
  81. .flags = IPROC_CLK_PLL_HAS_NDIV_FRAC | IPROC_CLK_EMBED_PWRCTRL,
  82. .aon = AON_VAL(0x0, 1, 24, 0),
  83. .reset = RESET_VAL(0x0, 23, 22),
  84. .dig_filter = DF_VAL(0x0, 16, 3, 12, 4, 19, 4),
  85. .ndiv_int = REG_VAL(0x4, 20, 8),
  86. .ndiv_frac = REG_VAL(0x4, 0, 20),
  87. .pdiv = REG_VAL(0x4, 28, 3),
  88. .status = REG_VAL(0x10, 12, 1),
  89. };
  90. static const struct iproc_clk_ctrl lcpll0_clk[] = {
  91. [BCM_NSP_LCPLL0_PCIE_PHY_REF_CLK] = {
  92. .channel = BCM_NSP_LCPLL0_PCIE_PHY_REF_CLK,
  93. .flags = IPROC_CLK_AON,
  94. .enable = ENABLE_VAL(0x0, 6, 3, 9),
  95. .mdiv = REG_VAL(0x8, 24, 8),
  96. },
  97. [BCM_NSP_LCPLL0_SDIO_CLK] = {
  98. .channel = BCM_NSP_LCPLL0_SDIO_CLK,
  99. .flags = IPROC_CLK_AON,
  100. .enable = ENABLE_VAL(0x0, 7, 4, 10),
  101. .mdiv = REG_VAL(0x8, 16, 8),
  102. },
  103. [BCM_NSP_LCPLL0_DDR_PHY_CLK] = {
  104. .channel = BCM_NSP_LCPLL0_DDR_PHY_CLK,
  105. .flags = IPROC_CLK_AON,
  106. .enable = ENABLE_VAL(0x0, 8, 5, 11),
  107. .mdiv = REG_VAL(0x8, 8, 8),
  108. },
  109. };
  110. static void __init nsp_lcpll0_clk_init(struct device_node *node)
  111. {
  112. iproc_pll_clk_setup(node, &lcpll0, NULL, 0, lcpll0_clk,
  113. ARRAY_SIZE(lcpll0_clk));
  114. }
  115. CLK_OF_DECLARE(nsp_lcpll0_clk, "brcm,nsp-lcpll0", nsp_lcpll0_clk_init);