blob: 4b7370340241e6154afa6128647c9b0a1092428a [file] [log] [blame]
Deepa Dinamani32bfad02012-11-02 12:15:05 -07001/* Copyright (c) 2012, The Linux Foundation. All rights reserved.
Amol Jadi29f95032012-06-22 12:52:54 -07002 *
3 * Redistribution and use in source and binary forms, with or without
Deepa Dinamani32bfad02012-11-02 12:15:05 -07004 * modification, are permitted provided that the following conditions are
5 * met:
6 * * Redistributions of source code must retain the above copyright
7 * notice, this list of conditions and the following disclaimer.
8 * * Redistributions in binary form must reproduce the above
9 * copyright notice, this list of conditions and the following
10 * disclaimer in the documentation and/or other materials provided
11 * with the distribution.
12 * * Neither the name of The Linux Foundation nor the names of its
13 * contributors may be used to endorse or promote products derived
14 * from this software without specific prior written permission.
Amol Jadi29f95032012-06-22 12:52:54 -070015 *
Deepa Dinamani32bfad02012-11-02 12:15:05 -070016 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
23 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
25 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
26 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Amol Jadi29f95032012-06-22 12:52:54 -070027 */
28
29#include <assert.h>
30#include <reg.h>
31#include <err.h>
32#include <clock.h>
33#include <clock_pll.h>
34#include <clock_lib2.h>
35#include <platform/clock.h>
36#include <platform/iomap.h>
37
38
39/* Mux source select values */
40#define cxo_source_val 0
41#define gpll0_source_val 1
42
43struct clk_freq_tbl rcg_dummy_freq = F_END;
44
45
46/* Clock Operations */
47static struct clk_ops clk_ops_branch =
48{
49 .enable = clock_lib2_branch_clk_enable,
50 .disable = clock_lib2_branch_clk_disable,
51 .set_rate = clock_lib2_branch_set_rate,
52};
53
54static struct clk_ops clk_ops_rcg_mnd =
55{
56 .enable = clock_lib2_rcg_enable,
57 .set_rate = clock_lib2_rcg_set_rate,
58};
59
60static struct clk_ops clk_ops_rcg =
61{
62 .enable = clock_lib2_rcg_enable,
63 .set_rate = clock_lib2_rcg_set_rate,
64};
65
66static struct clk_ops clk_ops_cxo =
67{
68 .enable = cxo_clk_enable,
69 .disable = cxo_clk_disable,
70};
71
72static struct clk_ops clk_ops_pll_vote =
73{
74 .enable = pll_vote_clk_enable,
75 .disable = pll_vote_clk_disable,
76 .auto_off = pll_vote_clk_disable,
77 .is_enabled = pll_vote_clk_is_enabled,
78};
79
Neeti Desaiac011272012-08-29 18:24:54 -070080static struct clk_ops clk_ops_vote =
81{
82 .enable = clock_lib2_vote_clk_enable,
83 .disable = clock_lib2_vote_clk_disable,
84};
Amol Jadi29f95032012-06-22 12:52:54 -070085
86/* Clock Sources */
87static struct fixed_clk cxo_clk_src =
88{
89 .c = {
90 .rate = 19200000,
91 .dbg_name = "cxo_clk_src",
92 .ops = &clk_ops_cxo,
93 },
94};
95
96static struct pll_vote_clk gpll0_clk_src =
97{
98 .en_reg = (void *) APCS_GPLL_ENA_VOTE,
99 .en_mask = BIT(0),
100 .status_reg = (void *) GPLL0_STATUS,
101 .status_mask = BIT(17),
102 .parent = &cxo_clk_src.c,
103
104 .c = {
105 .rate = 600000000,
106 .dbg_name = "gpll0_clk_src",
107 .ops = &clk_ops_pll_vote,
108 },
109};
110
111/* SDCC Clocks */
112static struct clk_freq_tbl ftbl_gcc_sdcc1_2_apps_clk[] =
113{
114 F( 144000, cxo, 16, 3, 25),
115 F( 400000, cxo, 12, 1, 4),
116 F( 20000000, gpll0, 15, 1, 2),
117 F( 25000000, gpll0, 12, 1, 2),
118 F( 50000000, gpll0, 12, 0, 0),
119 F(100000000, gpll0, 6, 0, 0),
120 F(200000000, gpll0, 3, 0, 0),
121 F_END
122};
123
124static struct rcg_clk sdcc1_apps_clk_src =
125{
126 .cmd_reg = (uint32_t *) SDCC1_CMD_RCGR,
127 .cfg_reg = (uint32_t *) SDCC1_CFG_RCGR,
128 .m_reg = (uint32_t *) SDCC1_M,
129 .n_reg = (uint32_t *) SDCC1_N,
130 .d_reg = (uint32_t *) SDCC1_D,
131
132 .set_rate = clock_lib2_rcg_set_rate_mnd,
133 .freq_tbl = ftbl_gcc_sdcc1_2_apps_clk,
134 .current_freq = &rcg_dummy_freq,
135
136 .c = {
137 .dbg_name = "sdc1_clk",
138 .ops = &clk_ops_rcg_mnd,
139 },
140};
141
142static struct branch_clk gcc_sdcc1_apps_clk =
143{
144 .cbcr_reg = (uint32_t *) SDCC1_APPS_CBCR,
145 .parent = &sdcc1_apps_clk_src.c,
146
147 .c = {
148 .dbg_name = "gcc_sdcc1_apps_clk",
149 .ops = &clk_ops_branch,
150 },
151};
152
153static struct branch_clk gcc_sdcc1_ahb_clk =
154{
155 .cbcr_reg = (uint32_t *) SDCC1_AHB_CBCR,
156 .has_sibling = 1,
157
158 .c = {
159 .dbg_name = "gcc_sdcc1_ahb_clk",
160 .ops = &clk_ops_branch,
161 },
162};
163
164/* UART Clocks */
165static struct clk_freq_tbl ftbl_gcc_blsp1_2_uart1_6_apps_clk[] =
166{
167 F( 3686400, gpll0, 1, 96, 15625),
168 F( 7372800, gpll0, 1, 192, 15625),
169 F(14745600, gpll0, 1, 384, 15625),
170 F(16000000, gpll0, 5, 2, 15),
171 F(19200000, cxo, 1, 0, 0),
172 F(24000000, gpll0, 5, 1, 5),
173 F(32000000, gpll0, 1, 4, 75),
174 F(40000000, gpll0, 15, 0, 0),
175 F(46400000, gpll0, 1, 29, 375),
176 F(48000000, gpll0, 12.5, 0, 0),
177 F(51200000, gpll0, 1, 32, 375),
178 F(56000000, gpll0, 1, 7, 75),
179 F(58982400, gpll0, 1, 1536, 15625),
180 F(60000000, gpll0, 10, 0, 0),
181 F_END
182};
183
Neeti Desaiac011272012-08-29 18:24:54 -0700184static struct rcg_clk blsp1_uart2_apps_clk_src =
Amol Jadi29f95032012-06-22 12:52:54 -0700185{
Neeti Desaiac011272012-08-29 18:24:54 -0700186 .cmd_reg = (uint32_t *) BLSP1_UART2_APPS_CMD_RCGR,
187 .cfg_reg = (uint32_t *) BLSP1_UART2_APPS_CFG_RCGR,
188 .m_reg = (uint32_t *) BLSP1_UART2_APPS_M,
189 .n_reg = (uint32_t *) BLSP1_UART2_APPS_N,
190 .d_reg = (uint32_t *) BLSP1_UART2_APPS_D,
Amol Jadi29f95032012-06-22 12:52:54 -0700191
192 .set_rate = clock_lib2_rcg_set_rate_mnd,
193 .freq_tbl = ftbl_gcc_blsp1_2_uart1_6_apps_clk,
194 .current_freq = &rcg_dummy_freq,
195
196 .c = {
Neeti Desaiac011272012-08-29 18:24:54 -0700197 .dbg_name = "blsp1_uart2_apps_clk",
Amol Jadi29f95032012-06-22 12:52:54 -0700198 .ops = &clk_ops_rcg_mnd,
199 },
200};
201
Neeti Desaiac011272012-08-29 18:24:54 -0700202static struct branch_clk gcc_blsp1_uart2_apps_clk =
Amol Jadi29f95032012-06-22 12:52:54 -0700203{
Neeti Desaiac011272012-08-29 18:24:54 -0700204 .cbcr_reg = (uint32_t *) BLSP1_UART2_APPS_CBCR,
205 .parent = &blsp1_uart2_apps_clk_src.c,
Amol Jadi29f95032012-06-22 12:52:54 -0700206
207 .c = {
Neeti Desaiac011272012-08-29 18:24:54 -0700208 .dbg_name = "gcc_blsp1_uart2_apps_clk",
Amol Jadi29f95032012-06-22 12:52:54 -0700209 .ops = &clk_ops_branch,
210 },
211};
212
Neeti Desaiac011272012-08-29 18:24:54 -0700213static struct vote_clk gcc_blsp1_ahb_clk = {
214 .cbcr_reg = (uint32_t *) BLSP1_AHB_CBCR,
Deepa Dinamani32bfad02012-11-02 12:15:05 -0700215 .vote_reg = (uint32_t *) APCS_CLOCK_BRANCH_ENA_VOTE,
Neeti Desaiac011272012-08-29 18:24:54 -0700216 .en_mask = BIT(17),
Amol Jadi29f95032012-06-22 12:52:54 -0700217
218 .c = {
Neeti Desaiac011272012-08-29 18:24:54 -0700219 .dbg_name = "gcc_blsp1_ahb_clk",
220 .ops = &clk_ops_vote,
Amol Jadi29f95032012-06-22 12:52:54 -0700221 },
222};
223
224/* USB Clocks */
225static struct clk_freq_tbl ftbl_gcc_usb_hs_system_clk[] =
226{
227 F(75000000, gpll0, 8, 0, 0),
228 F_END
229};
230
231static struct rcg_clk usb_hs_system_clk_src =
232{
233 .cmd_reg = (uint32_t *) USB_HS_SYSTEM_CMD_RCGR,
234 .cfg_reg = (uint32_t *) USB_HS_SYSTEM_CFG_RCGR,
235
236 .set_rate = clock_lib2_rcg_set_rate_hid,
237 .freq_tbl = ftbl_gcc_usb_hs_system_clk,
238 .current_freq = &rcg_dummy_freq,
239
240 .c = {
241 .dbg_name = "usb_hs_system_clk",
242 .ops = &clk_ops_rcg,
243 },
244};
245
246static struct branch_clk gcc_usb_hs_system_clk =
247{
248 .cbcr_reg = (uint32_t *) USB_HS_SYSTEM_CBCR,
249 .parent = &usb_hs_system_clk_src.c,
250
251 .c = {
252 .dbg_name = "gcc_usb_hs_system_clk",
253 .ops = &clk_ops_branch,
254 },
255};
256
257static struct branch_clk gcc_usb_hs_ahb_clk =
258{
259 .cbcr_reg = (uint32_t *) USB_HS_AHB_CBCR,
260 .has_sibling = 1,
261
262 .c = {
263 .dbg_name = "gcc_usb_hs_ahb_clk",
264 .ops = &clk_ops_branch,
265 },
266};
267
Deepa Dinamani32bfad02012-11-02 12:15:05 -0700268/* CE Clocks */
269static struct clk_freq_tbl ftbl_gcc_ce2_clk[] = {
270 F( 50000000, gpll0, 12, 0, 0),
271 F(100000000, gpll0, 6, 0, 0),
272 F_END
273};
274
275static struct rcg_clk ce2_clk_src = {
276 .cmd_reg = (uint32_t *) GCC_CE2_CMD_RCGR,
277 .cfg_reg = (uint32_t *) GCC_CE2_CFG_RCGR,
278 .set_rate = clock_lib2_rcg_set_rate_hid,
279 .freq_tbl = ftbl_gcc_ce2_clk,
280 .current_freq = &rcg_dummy_freq,
281
282 .c = {
283 .dbg_name = "ce2_clk_src",
284 .ops = &clk_ops_rcg,
285 },
286};
287
288static struct vote_clk gcc_ce2_clk = {
289 .cbcr_reg = (uint32_t *) GCC_CE2_CBCR,
290 .vote_reg = (uint32_t *) APCS_CLOCK_BRANCH_ENA_VOTE,
291 .en_mask = BIT(2),
292
293 .c = {
294 .dbg_name = "gcc_ce2_clk",
295 .ops = &clk_ops_vote,
296 },
297};
298
299static struct vote_clk gcc_ce2_ahb_clk = {
300 .cbcr_reg = (uint32_t *) GCC_CE2_AHB_CBCR,
301 .vote_reg = (uint32_t *) APCS_CLOCK_BRANCH_ENA_VOTE,
302 .en_mask = BIT(0),
303
304 .c = {
305 .dbg_name = "gcc_ce2_ahb_clk",
306 .ops = &clk_ops_vote,
307 },
308};
309
310static struct vote_clk gcc_ce2_axi_clk = {
311 .cbcr_reg = (uint32_t *) GCC_CE2_AXI_CBCR,
312 .vote_reg = (uint32_t *) APCS_CLOCK_BRANCH_ENA_VOTE,
313 .en_mask = BIT(1),
314
315 .c = {
316 .dbg_name = "gcc_ce2_axi_clk",
317 .ops = &clk_ops_vote,
318 },
319};
Amol Jadi29f95032012-06-22 12:52:54 -0700320
321/* Clock lookup table */
322static struct clk_lookup msm_clocks_8974[] =
323{
324 CLK_LOOKUP("sdc1_iface_clk", gcc_sdcc1_ahb_clk.c),
325 CLK_LOOKUP("sdc1_core_clk", gcc_sdcc1_apps_clk.c),
326
Neeti Desaiac011272012-08-29 18:24:54 -0700327 CLK_LOOKUP("uart2_iface_clk", gcc_blsp1_ahb_clk.c),
328 CLK_LOOKUP("uart2_core_clk", gcc_blsp1_uart2_apps_clk.c),
Amol Jadi29f95032012-06-22 12:52:54 -0700329
330 CLK_LOOKUP("usb_iface_clk", gcc_usb_hs_ahb_clk.c),
331 CLK_LOOKUP("usb_core_clk", gcc_usb_hs_system_clk.c),
Deepa Dinamani32bfad02012-11-02 12:15:05 -0700332
333 CLK_LOOKUP("ce2_ahb_clk", gcc_ce2_ahb_clk.c),
334 CLK_LOOKUP("ce2_axi_clk", gcc_ce2_axi_clk.c),
335 CLK_LOOKUP("ce2_core_clk", gcc_ce2_clk.c),
336 CLK_LOOKUP("ce2_src_clk", ce2_clk_src.c),
Amol Jadi29f95032012-06-22 12:52:54 -0700337};
338
339
340void platform_clock_init(void)
341{
342 clk_init(msm_clocks_8974, ARRAY_SIZE(msm_clocks_8974));
343}