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