046-clk-nsp-add-clock-support-for-Broadcom-Northstar-Plu.patch 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. From d358480591b34d081806ecb5a9474930a4d59f8a Mon Sep 17 00:00:00 2001
  2. From: Jon Mason <jonmason@broadcom.com>
  3. Date: Thu, 15 Oct 2015 15:48:27 -0400
  4. Subject: [PATCH 46/50] clk: nsp: add clock support for Broadcom Northstar Plus
  5. SoC
  6. The Broadcom Northstar Plus SoC is architected under the iProc
  7. architecture. It has the following PLLs: ARMPLL, GENPLL, LCPLL0, all
  8. derived from an onboard crystal.
  9. Signed-off-by: Jon Mason <jonmason@broadcom.com>
  10. ---
  11. drivers/clk/bcm/Makefile | 2 +
  12. drivers/clk/bcm/clk-nsp.c | 135 ++++++++++++++++++++++++++++++++++++
  13. include/dt-bindings/clock/bcm-nsp.h | 51 ++++++++++++++
  14. 3 files changed, 188 insertions(+)
  15. create mode 100644 drivers/clk/bcm/clk-nsp.c
  16. create mode 100644 include/dt-bindings/clock/bcm-nsp.h
  17. --- a/drivers/clk/bcm/Makefile
  18. +++ b/drivers/clk/bcm/Makefile
  19. @@ -4,3 +4,5 @@ obj-$(CONFIG_CLK_BCM_KONA) += clk-bcm281
  20. obj-$(CONFIG_CLK_BCM_KONA) += clk-bcm21664.o
  21. obj-$(CONFIG_COMMON_CLK_IPROC) += clk-iproc-armpll.o clk-iproc-pll.o clk-iproc-asiu.o
  22. obj-$(CONFIG_ARCH_BCM_CYGNUS) += clk-cygnus.o
  23. +obj-$(CONFIG_ARCH_BCM_NSP) += clk-nsp.o
  24. +obj-$(CONFIG_ARCH_BCM_5301X) += clk-nsp.o
  25. --- /dev/null
  26. +++ b/drivers/clk/bcm/clk-nsp.c
  27. @@ -0,0 +1,135 @@
  28. +/*
  29. + * Copyright (C) 2015 Broadcom Corporation
  30. + *
  31. + * This program is free software; you can redistribute it and/or
  32. + * modify it under the terms of the GNU General Public License as
  33. + * published by the Free Software Foundation version 2.
  34. + *
  35. + * This program is distributed "as is" WITHOUT ANY WARRANTY of any
  36. + * kind, whether express or implied; without even the implied warranty
  37. + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  38. + * GNU General Public License for more details.
  39. + */
  40. +
  41. +#include <linux/kernel.h>
  42. +#include <linux/err.h>
  43. +#include <linux/clk-provider.h>
  44. +#include <linux/io.h>
  45. +#include <linux/of.h>
  46. +#include <linux/of_address.h>
  47. +
  48. +#include <dt-bindings/clock/bcm-nsp.h>
  49. +#include "clk-iproc.h"
  50. +
  51. +#define REG_VAL(o, s, w) { .offset = o, .shift = s, .width = w, }
  52. +
  53. +#define AON_VAL(o, pw, ps, is) { .offset = o, .pwr_width = pw, \
  54. + .pwr_shift = ps, .iso_shift = is }
  55. +
  56. +#define RESET_VAL(o, rs, prs, kis, kiw, kps, kpw, kas, kaw) { .offset = o, \
  57. + .reset_shift = rs, .p_reset_shift = prs, .ki_shift = kis, \
  58. + .ki_width = kiw, .kp_shift = kps, .kp_width = kpw, .ka_shift = kas, \
  59. + .ka_width = kaw }
  60. +
  61. +#define ENABLE_VAL(o, es, hs, bs) { .offset = o, .enable_shift = es, \
  62. + .hold_shift = hs, .bypass_shift = bs }
  63. +
  64. +static void __init nsp_armpll_init(struct device_node *node)
  65. +{
  66. + iproc_armpll_setup(node);
  67. +}
  68. +CLK_OF_DECLARE(nsp_armpll, "brcm,nsp-armpll", nsp_armpll_init);
  69. +
  70. +static const struct iproc_pll_ctrl genpll = {
  71. + .flags = IPROC_CLK_PLL_HAS_NDIV_FRAC | IPROC_CLK_EMBED_PWRCTRL,
  72. + .aon = AON_VAL(0x0, 1, 12, 0),
  73. + .reset = RESET_VAL(0x0, 11, 10, 4, 3, 0, 4, 7, 3),
  74. + .ndiv_int = REG_VAL(0x14, 20, 10),
  75. + .ndiv_frac = REG_VAL(0x14, 0, 20),
  76. + .pdiv = REG_VAL(0x18, 24, 3),
  77. + .status = REG_VAL(0x20, 12, 1),
  78. +};
  79. +
  80. +static const struct iproc_clk_ctrl genpll_clk[] = {
  81. + [BCM_NSP_GENPLL_PHY_CLK] = {
  82. + .channel = BCM_NSP_GENPLL_PHY_CLK,
  83. + .flags = IPROC_CLK_AON,
  84. + .enable = ENABLE_VAL(0x4, 12, 6, 18),
  85. + .mdiv = REG_VAL(0x18, 16, 8),
  86. + },
  87. + [BCM_NSP_GENPLL_ENET_SW_CLK] = {
  88. + .channel = BCM_NSP_GENPLL_ENET_SW_CLK,
  89. + .flags = IPROC_CLK_AON,
  90. + .enable = ENABLE_VAL(0x4, 13, 7, 19),
  91. + .mdiv = REG_VAL(0x18, 8, 8),
  92. + },
  93. + [BCM_NSP_GENPLL_USB_PHY_REF_CLK] = {
  94. + .channel = BCM_NSP_GENPLL_USB_PHY_REF_CLK,
  95. + .flags = IPROC_CLK_AON,
  96. + .enable = ENABLE_VAL(0x4, 14, 8, 20),
  97. + .mdiv = REG_VAL(0x18, 0, 8),
  98. + },
  99. + [BCM_NSP_GENPLL_IPROCFAST_CLK] = {
  100. + .channel = BCM_NSP_GENPLL_IPROCFAST_CLK,
  101. + .flags = IPROC_CLK_AON,
  102. + .enable = ENABLE_VAL(0x4, 15, 9, 21),
  103. + .mdiv = REG_VAL(0x1c, 16, 8),
  104. + },
  105. + [BCM_NSP_GENPLL_SATA1_CLK] = {
  106. + .channel = BCM_NSP_GENPLL_SATA1_CLK,
  107. + .flags = IPROC_CLK_AON,
  108. + .enable = ENABLE_VAL(0x4, 16, 10, 22),
  109. + .mdiv = REG_VAL(0x1c, 8, 8),
  110. + },
  111. + [BCM_NSP_GENPLL_SATA2_CLK] = {
  112. + .channel = BCM_NSP_GENPLL_SATA2_CLK,
  113. + .flags = IPROC_CLK_AON,
  114. + .enable = ENABLE_VAL(0x4, 17, 11, 23),
  115. + .mdiv = REG_VAL(0x1c, 0, 8),
  116. + },
  117. +};
  118. +
  119. +static void __init nsp_genpll_clk_init(struct device_node *node)
  120. +{
  121. + iproc_pll_clk_setup(node, &genpll, NULL, 0, genpll_clk,
  122. + ARRAY_SIZE(genpll_clk));
  123. +}
  124. +CLK_OF_DECLARE(nsp_genpll_clk, "brcm,nsp-genpll", nsp_genpll_clk_init);
  125. +
  126. +static const struct iproc_pll_ctrl lcpll0 = {
  127. + .flags = IPROC_CLK_PLL_HAS_NDIV_FRAC | IPROC_CLK_EMBED_PWRCTRL,
  128. + .aon = AON_VAL(0x0, 1, 24, 0),
  129. + .reset = RESET_VAL(0x0, 23, 22, 16, 3, 12, 4, 19, 4),
  130. + .ndiv_int = REG_VAL(0x4, 20, 8),
  131. + .ndiv_frac = REG_VAL(0x4, 0, 20),
  132. + .pdiv = REG_VAL(0x4, 28, 3),
  133. + .status = REG_VAL(0x10, 12, 1),
  134. +};
  135. +
  136. +static const struct iproc_clk_ctrl lcpll0_clk[] = {
  137. + [BCM_NSP_LCPLL0_PCIE_PHY_REF_CLK] = {
  138. + .channel = BCM_NSP_LCPLL0_PCIE_PHY_REF_CLK,
  139. + .flags = IPROC_CLK_AON,
  140. + .enable = ENABLE_VAL(0x0, 6, 3, 9),
  141. + .mdiv = REG_VAL(0x8, 24, 8),
  142. + },
  143. + [BCM_NSP_LCPLL0_SDIO_CLK] = {
  144. + .channel = BCM_NSP_LCPLL0_SDIO_CLK,
  145. + .flags = IPROC_CLK_AON,
  146. + .enable = ENABLE_VAL(0x0, 7, 4, 10),
  147. + .mdiv = REG_VAL(0x8, 16, 8),
  148. + },
  149. + [BCM_NSP_LCPLL0_DDR_PHY_CLK] = {
  150. + .channel = BCM_NSP_LCPLL0_DDR_PHY_CLK,
  151. + .flags = IPROC_CLK_AON,
  152. + .enable = ENABLE_VAL(0x0, 8, 5, 11),
  153. + .mdiv = REG_VAL(0x8, 8, 8),
  154. + },
  155. +};
  156. +
  157. +static void __init nsp_lcpll0_clk_init(struct device_node *node)
  158. +{
  159. + iproc_pll_clk_setup(node, &lcpll0, NULL, 0, lcpll0_clk,
  160. + ARRAY_SIZE(lcpll0_clk));
  161. +}
  162. +CLK_OF_DECLARE(nsp_lcpll0_clk, "brcm,nsp-lcpll0", nsp_lcpll0_clk_init);
  163. --- /dev/null
  164. +++ b/include/dt-bindings/clock/bcm-nsp.h
  165. @@ -0,0 +1,51 @@
  166. +/*
  167. + * BSD LICENSE
  168. + *
  169. + * Copyright(c) 2015 Broadcom Corporation. All rights reserved.
  170. + *
  171. + * Redistribution and use in source and binary forms, with or without
  172. + * modification, are permitted provided that the following conditions
  173. + * are met:
  174. + *
  175. + * * Redistributions of source code must retain the above copyright
  176. + * notice, this list of conditions and the following disclaimer.
  177. + * * Redistributions in binary form must reproduce the above copyright
  178. + * notice, this list of conditions and the following disclaimer in
  179. + * the documentation and/or other materials provided with the
  180. + * distribution.
  181. + * * Neither the name of Broadcom Corporation nor the names of its
  182. + * contributors may be used to endorse or promote products derived
  183. + * from this software without specific prior written permission.
  184. + *
  185. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  186. + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  187. + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  188. + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  189. + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  190. + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  191. + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  192. + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  193. + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  194. + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  195. + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  196. + */
  197. +
  198. +#ifndef _CLOCK_BCM_NSP_H
  199. +#define _CLOCK_BCM_NSP_H
  200. +
  201. +/* GENPLL clock channel ID */
  202. +#define BCM_NSP_GENPLL 0
  203. +#define BCM_NSP_GENPLL_PHY_CLK 1
  204. +#define BCM_NSP_GENPLL_ENET_SW_CLK 2
  205. +#define BCM_NSP_GENPLL_USB_PHY_REF_CLK 3
  206. +#define BCM_NSP_GENPLL_IPROCFAST_CLK 4
  207. +#define BCM_NSP_GENPLL_SATA1_CLK 5
  208. +#define BCM_NSP_GENPLL_SATA2_CLK 6
  209. +
  210. +/* LCPLL0 clock channel ID */
  211. +#define BCM_NSP_LCPLL0 0
  212. +#define BCM_NSP_LCPLL0_PCIE_PHY_REF_CLK 1
  213. +#define BCM_NSP_LCPLL0_SDIO_CLK 2
  214. +#define BCM_NSP_LCPLL0_DDR_PHY_CLK 3
  215. +
  216. +#endif /* _CLOCK_BCM_NSP_H */