blob: 8f3dadf7ec2f4c32a1246a9ecdcc23af516d8549 [file] [log] [blame]
Channagoud Kadabi4d385152014-02-18 11:56:07 -08001/* Copyright (c) 2012-2014, 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
Channagoud Kadabibdac7092013-08-20 15:28:07 -070042#define gpll4_source_val 5
Siddhartha Agrawalacdaf5b2013-01-22 18:14:53 -080043#define cxo_mm_source_val 0
44#define mmpll0_mm_source_val 1
45#define mmpll1_mm_source_val 2
46#define mmpll3_mm_source_val 3
47#define gpll0_mm_source_val 5
Asaf Pensod7ce9c22013-06-30 13:21:50 +030048#define edppll_270_mm_source_val 4
49#define edppll_350_mm_source_val 4
Amol Jadi29f95032012-06-22 12:52:54 -070050
51struct clk_freq_tbl rcg_dummy_freq = F_END;
52
53
54/* Clock Operations */
55static struct clk_ops clk_ops_branch =
56{
57 .enable = clock_lib2_branch_clk_enable,
58 .disable = clock_lib2_branch_clk_disable,
59 .set_rate = clock_lib2_branch_set_rate,
60};
61
62static struct clk_ops clk_ops_rcg_mnd =
63{
64 .enable = clock_lib2_rcg_enable,
65 .set_rate = clock_lib2_rcg_set_rate,
66};
67
68static struct clk_ops clk_ops_rcg =
69{
70 .enable = clock_lib2_rcg_enable,
71 .set_rate = clock_lib2_rcg_set_rate,
72};
73
74static struct clk_ops clk_ops_cxo =
75{
76 .enable = cxo_clk_enable,
77 .disable = cxo_clk_disable,
78};
79
80static struct clk_ops clk_ops_pll_vote =
81{
82 .enable = pll_vote_clk_enable,
83 .disable = pll_vote_clk_disable,
84 .auto_off = pll_vote_clk_disable,
85 .is_enabled = pll_vote_clk_is_enabled,
86};
87
Neeti Desaiac011272012-08-29 18:24:54 -070088static struct clk_ops clk_ops_vote =
89{
90 .enable = clock_lib2_vote_clk_enable,
91 .disable = clock_lib2_vote_clk_disable,
92};
Amol Jadi29f95032012-06-22 12:52:54 -070093
94/* Clock Sources */
95static struct fixed_clk cxo_clk_src =
96{
97 .c = {
98 .rate = 19200000,
99 .dbg_name = "cxo_clk_src",
100 .ops = &clk_ops_cxo,
101 },
102};
103
104static struct pll_vote_clk gpll0_clk_src =
105{
106 .en_reg = (void *) APCS_GPLL_ENA_VOTE,
107 .en_mask = BIT(0),
108 .status_reg = (void *) GPLL0_STATUS,
109 .status_mask = BIT(17),
110 .parent = &cxo_clk_src.c,
111
112 .c = {
113 .rate = 600000000,
114 .dbg_name = "gpll0_clk_src",
115 .ops = &clk_ops_pll_vote,
116 },
117};
118
Channagoud Kadabibdac7092013-08-20 15:28:07 -0700119static struct pll_vote_clk gpll4_clk_src =
120{
121 .en_reg = (void *) APCS_GPLL_ENA_VOTE,
122 .en_mask = BIT(4),
123 .status_reg = (void *) GPLL4_STATUS,
124 .status_mask = BIT(17),
125 .parent = &cxo_clk_src.c,
126
127 .c = {
128 .rate = 768000000,
129 .dbg_name = "gpll4_clk_src",
130 .ops = &clk_ops_pll_vote,
131 },
132};
133
Amol Jadi29f95032012-06-22 12:52:54 -0700134/* SDCC Clocks */
Channagoud Kadabibdac7092013-08-20 15:28:07 -0700135/* This table is for sdc1 apps clk only for MSM8974 PRO AC */
136static struct clk_freq_tbl ftbl_gcc_sdcc1_apps_clk_ac[] =
137{
138 F( 144000, cxo, 16, 3, 25),
139 F( 400000, cxo, 12, 1, 4),
140 F( 20000000, gpll0, 15, 1, 2),
141 F( 25000000, gpll0, 12, 1, 2),
142 F( 50000000, gpll0, 12, 0, 0),
143 F(100000000, gpll0, 6, 0, 0),
144 F(192000000, gpll4, 4, 0, 0),
145 F(384000000, gpll4, 2, 0, 0),
146 F_END
147};
148
149/* This table is for
150 * sdc[1-4] for all MSM8974 excluding MSM8974PROAC
151 * sdc[2-4] for MSM8974PRO AC
152 */
153static struct clk_freq_tbl ftbl_gcc_sdcc1_4_apps_clk[] =
Amol Jadi29f95032012-06-22 12:52:54 -0700154{
155 F( 144000, cxo, 16, 3, 25),
156 F( 400000, cxo, 12, 1, 4),
157 F( 20000000, gpll0, 15, 1, 2),
158 F( 25000000, gpll0, 12, 1, 2),
159 F( 50000000, gpll0, 12, 0, 0),
160 F(100000000, gpll0, 6, 0, 0),
161 F(200000000, gpll0, 3, 0, 0),
162 F_END
163};
164
165static struct rcg_clk sdcc1_apps_clk_src =
166{
167 .cmd_reg = (uint32_t *) SDCC1_CMD_RCGR,
168 .cfg_reg = (uint32_t *) SDCC1_CFG_RCGR,
169 .m_reg = (uint32_t *) SDCC1_M,
170 .n_reg = (uint32_t *) SDCC1_N,
171 .d_reg = (uint32_t *) SDCC1_D,
172
173 .set_rate = clock_lib2_rcg_set_rate_mnd,
Channagoud Kadabibdac7092013-08-20 15:28:07 -0700174 .freq_tbl = ftbl_gcc_sdcc1_4_apps_clk,
Amol Jadi29f95032012-06-22 12:52:54 -0700175 .current_freq = &rcg_dummy_freq,
176
177 .c = {
178 .dbg_name = "sdc1_clk",
179 .ops = &clk_ops_rcg_mnd,
180 },
181};
182
183static struct branch_clk gcc_sdcc1_apps_clk =
184{
185 .cbcr_reg = (uint32_t *) SDCC1_APPS_CBCR,
186 .parent = &sdcc1_apps_clk_src.c,
187
188 .c = {
189 .dbg_name = "gcc_sdcc1_apps_clk",
190 .ops = &clk_ops_branch,
191 },
192};
193
194static struct branch_clk gcc_sdcc1_ahb_clk =
195{
196 .cbcr_reg = (uint32_t *) SDCC1_AHB_CBCR,
197 .has_sibling = 1,
198
199 .c = {
200 .dbg_name = "gcc_sdcc1_ahb_clk",
201 .ops = &clk_ops_branch,
202 },
203};
204
Channagoud Kadabibdac7092013-08-20 15:28:07 -0700205static struct branch_clk gcc_sdcc1_cdccal_sleep_clk =
206{
207 .cbcr_reg = SDCC1_CDCCAL_SLEEP_CBCR,
208 .has_sibling = 1,
209
210 .c = {
211 .dbg_name = "gcc_sdcc1_cdccal_sleep_clk",
212 .ops = &clk_ops_branch,
213 },
214};
215
216static struct branch_clk gcc_sdcc1_cdccal_ff_clk =
217{
218 .cbcr_reg = SDCC1_CDCCAL_FF_CBCR,
219 .has_sibling = 1,
220
221 .c = {
222 .dbg_name = "gcc_sdcc1_cdccal_ff_clk",
223 .ops = &clk_ops_branch,
224 },
225};
226
Channagoud Kadabi5a612c72013-06-04 13:28:14 -0700227static struct rcg_clk sdcc2_apps_clk_src =
228{
229 .cmd_reg = (uint32_t *) SDCC2_CMD_RCGR,
230 .cfg_reg = (uint32_t *) SDCC2_CFG_RCGR,
231 .m_reg = (uint32_t *) SDCC2_M,
232 .n_reg = (uint32_t *) SDCC2_N,
233 .d_reg = (uint32_t *) SDCC2_D,
234
235 .set_rate = clock_lib2_rcg_set_rate_mnd,
Channagoud Kadabibdac7092013-08-20 15:28:07 -0700236 .freq_tbl = ftbl_gcc_sdcc1_4_apps_clk,
Channagoud Kadabi5a612c72013-06-04 13:28:14 -0700237 .current_freq = &rcg_dummy_freq,
238
239 .c = {
240 .dbg_name = "sdc2_clk",
241 .ops = &clk_ops_rcg_mnd,
242 },
243};
244
245static struct branch_clk gcc_sdcc2_apps_clk =
246{
247 .cbcr_reg = (uint32_t *) SDCC2_APPS_CBCR,
248 .parent = &sdcc2_apps_clk_src.c,
249
250 .c = {
251 .dbg_name = "gcc_sdcc2_apps_clk",
252 .ops = &clk_ops_branch,
253 },
254};
255
256static struct branch_clk gcc_sdcc2_ahb_clk =
257{
258 .cbcr_reg = (uint32_t *) SDCC2_AHB_CBCR,
259 .has_sibling = 1,
260
261 .c = {
262 .dbg_name = "gcc_sdcc2_ahb_clk",
263 .ops = &clk_ops_branch,
264 },
265};
266
Amol Jadi29f95032012-06-22 12:52:54 -0700267/* UART Clocks */
268static struct clk_freq_tbl ftbl_gcc_blsp1_2_uart1_6_apps_clk[] =
269{
270 F( 3686400, gpll0, 1, 96, 15625),
271 F( 7372800, gpll0, 1, 192, 15625),
272 F(14745600, gpll0, 1, 384, 15625),
273 F(16000000, gpll0, 5, 2, 15),
274 F(19200000, cxo, 1, 0, 0),
275 F(24000000, gpll0, 5, 1, 5),
276 F(32000000, gpll0, 1, 4, 75),
277 F(40000000, gpll0, 15, 0, 0),
278 F(46400000, gpll0, 1, 29, 375),
279 F(48000000, gpll0, 12.5, 0, 0),
280 F(51200000, gpll0, 1, 32, 375),
281 F(56000000, gpll0, 1, 7, 75),
282 F(58982400, gpll0, 1, 1536, 15625),
283 F(60000000, gpll0, 10, 0, 0),
284 F_END
285};
286
Neeti Desaiac011272012-08-29 18:24:54 -0700287static struct rcg_clk blsp1_uart2_apps_clk_src =
Amol Jadi29f95032012-06-22 12:52:54 -0700288{
Neeti Desaiac011272012-08-29 18:24:54 -0700289 .cmd_reg = (uint32_t *) BLSP1_UART2_APPS_CMD_RCGR,
290 .cfg_reg = (uint32_t *) BLSP1_UART2_APPS_CFG_RCGR,
291 .m_reg = (uint32_t *) BLSP1_UART2_APPS_M,
292 .n_reg = (uint32_t *) BLSP1_UART2_APPS_N,
293 .d_reg = (uint32_t *) BLSP1_UART2_APPS_D,
Amol Jadi29f95032012-06-22 12:52:54 -0700294
295 .set_rate = clock_lib2_rcg_set_rate_mnd,
296 .freq_tbl = ftbl_gcc_blsp1_2_uart1_6_apps_clk,
297 .current_freq = &rcg_dummy_freq,
298
299 .c = {
Neeti Desaiac011272012-08-29 18:24:54 -0700300 .dbg_name = "blsp1_uart2_apps_clk",
Amol Jadi29f95032012-06-22 12:52:54 -0700301 .ops = &clk_ops_rcg_mnd,
302 },
303};
304
Neeti Desaiac011272012-08-29 18:24:54 -0700305static struct branch_clk gcc_blsp1_uart2_apps_clk =
Amol Jadi29f95032012-06-22 12:52:54 -0700306{
Neeti Desaiac011272012-08-29 18:24:54 -0700307 .cbcr_reg = (uint32_t *) BLSP1_UART2_APPS_CBCR,
308 .parent = &blsp1_uart2_apps_clk_src.c,
Amol Jadi29f95032012-06-22 12:52:54 -0700309
310 .c = {
Neeti Desaiac011272012-08-29 18:24:54 -0700311 .dbg_name = "gcc_blsp1_uart2_apps_clk",
Amol Jadi29f95032012-06-22 12:52:54 -0700312 .ops = &clk_ops_branch,
313 },
314};
315
Neeti Desaiac011272012-08-29 18:24:54 -0700316static struct vote_clk gcc_blsp1_ahb_clk = {
317 .cbcr_reg = (uint32_t *) BLSP1_AHB_CBCR,
Deepa Dinamani32bfad02012-11-02 12:15:05 -0700318 .vote_reg = (uint32_t *) APCS_CLOCK_BRANCH_ENA_VOTE,
Neeti Desaiac011272012-08-29 18:24:54 -0700319 .en_mask = BIT(17),
Amol Jadi29f95032012-06-22 12:52:54 -0700320
321 .c = {
Neeti Desaiac011272012-08-29 18:24:54 -0700322 .dbg_name = "gcc_blsp1_ahb_clk",
323 .ops = &clk_ops_vote,
Amol Jadi29f95032012-06-22 12:52:54 -0700324 },
325};
326
Channagoud Kadabi634ac6d2012-12-12 18:13:56 -0800327static struct vote_clk gcc_blsp2_ahb_clk = {
328 .cbcr_reg = (uint32_t *) BLSP2_AHB_CBCR,
329 .vote_reg = (uint32_t *) APCS_CLOCK_BRANCH_ENA_VOTE,
330 .en_mask = BIT(15),
331
332 .c = {
333 .dbg_name = "gcc_blsp2_ahb_clk",
334 .ops = &clk_ops_vote,
335 },
336};
337
Amol Jadi29f95032012-06-22 12:52:54 -0700338/* USB Clocks */
339static struct clk_freq_tbl ftbl_gcc_usb_hs_system_clk[] =
340{
341 F(75000000, gpll0, 8, 0, 0),
342 F_END
343};
344
345static struct rcg_clk usb_hs_system_clk_src =
346{
347 .cmd_reg = (uint32_t *) USB_HS_SYSTEM_CMD_RCGR,
348 .cfg_reg = (uint32_t *) USB_HS_SYSTEM_CFG_RCGR,
349
350 .set_rate = clock_lib2_rcg_set_rate_hid,
351 .freq_tbl = ftbl_gcc_usb_hs_system_clk,
352 .current_freq = &rcg_dummy_freq,
353
354 .c = {
355 .dbg_name = "usb_hs_system_clk",
356 .ops = &clk_ops_rcg,
357 },
358};
359
360static struct branch_clk gcc_usb_hs_system_clk =
361{
362 .cbcr_reg = (uint32_t *) USB_HS_SYSTEM_CBCR,
363 .parent = &usb_hs_system_clk_src.c,
364
365 .c = {
366 .dbg_name = "gcc_usb_hs_system_clk",
367 .ops = &clk_ops_branch,
368 },
369};
370
371static struct branch_clk gcc_usb_hs_ahb_clk =
372{
373 .cbcr_reg = (uint32_t *) USB_HS_AHB_CBCR,
374 .has_sibling = 1,
375
376 .c = {
377 .dbg_name = "gcc_usb_hs_ahb_clk",
378 .ops = &clk_ops_branch,
379 },
380};
381
Deepa Dinamani32bfad02012-11-02 12:15:05 -0700382/* CE Clocks */
383static struct clk_freq_tbl ftbl_gcc_ce2_clk[] = {
384 F( 50000000, gpll0, 12, 0, 0),
385 F(100000000, gpll0, 6, 0, 0),
386 F_END
387};
388
389static struct rcg_clk ce2_clk_src = {
390 .cmd_reg = (uint32_t *) GCC_CE2_CMD_RCGR,
391 .cfg_reg = (uint32_t *) GCC_CE2_CFG_RCGR,
392 .set_rate = clock_lib2_rcg_set_rate_hid,
393 .freq_tbl = ftbl_gcc_ce2_clk,
394 .current_freq = &rcg_dummy_freq,
395
396 .c = {
397 .dbg_name = "ce2_clk_src",
398 .ops = &clk_ops_rcg,
399 },
400};
401
402static struct vote_clk gcc_ce2_clk = {
403 .cbcr_reg = (uint32_t *) GCC_CE2_CBCR,
404 .vote_reg = (uint32_t *) APCS_CLOCK_BRANCH_ENA_VOTE,
405 .en_mask = BIT(2),
406
407 .c = {
408 .dbg_name = "gcc_ce2_clk",
409 .ops = &clk_ops_vote,
410 },
411};
412
413static struct vote_clk gcc_ce2_ahb_clk = {
414 .cbcr_reg = (uint32_t *) GCC_CE2_AHB_CBCR,
415 .vote_reg = (uint32_t *) APCS_CLOCK_BRANCH_ENA_VOTE,
416 .en_mask = BIT(0),
417
418 .c = {
419 .dbg_name = "gcc_ce2_ahb_clk",
420 .ops = &clk_ops_vote,
421 },
422};
423
424static struct vote_clk gcc_ce2_axi_clk = {
425 .cbcr_reg = (uint32_t *) GCC_CE2_AXI_CBCR,
426 .vote_reg = (uint32_t *) APCS_CLOCK_BRANCH_ENA_VOTE,
427 .en_mask = BIT(1),
428
429 .c = {
430 .dbg_name = "gcc_ce2_axi_clk",
431 .ops = &clk_ops_vote,
432 },
433};
Amol Jadi29f95032012-06-22 12:52:54 -0700434
sundarajan srinivasan6aaa50c2013-02-27 14:18:57 -0800435static struct clk_freq_tbl ftbl_gcc_ce1_clk[] = {
436 F( 50000000, gpll0, 12, 0, 0),
437 F(100000000, gpll0, 6, 0, 0),
438 F_END
439};
440
441static struct rcg_clk ce1_clk_src = {
442 .cmd_reg = (uint32_t *) GCC_CE1_CMD_RCGR,
443 .cfg_reg = (uint32_t *) GCC_CE1_CFG_RCGR,
444 .set_rate = clock_lib2_rcg_set_rate_hid,
445 .freq_tbl = ftbl_gcc_ce1_clk,
446 .current_freq = &rcg_dummy_freq,
447
448 .c = {
449 .dbg_name = "ce1_clk_src",
450 .ops = &clk_ops_rcg,
451 },
452};
453
454static struct vote_clk gcc_ce1_clk = {
455 .cbcr_reg = (uint32_t *) GCC_CE1_CBCR,
456 .vote_reg = (uint32_t *) APCS_CLOCK_BRANCH_ENA_VOTE,
457 .en_mask = BIT(5),
458
459 .c = {
460 .dbg_name = "gcc_ce1_clk",
461 .ops = &clk_ops_vote,
462 },
463};
464
465static struct vote_clk gcc_ce1_ahb_clk = {
466 .cbcr_reg = (uint32_t *) GCC_CE1_AHB_CBCR,
467 .vote_reg = (uint32_t *) APCS_CLOCK_BRANCH_ENA_VOTE,
468 .en_mask = BIT(3),
469
470 .c = {
471 .dbg_name = "gcc_ce1_ahb_clk",
472 .ops = &clk_ops_vote,
473 },
474};
475
476static struct vote_clk gcc_ce1_axi_clk = {
477 .cbcr_reg = (uint32_t *) GCC_CE1_AXI_CBCR,
478 .vote_reg = (uint32_t *) APCS_CLOCK_BRANCH_ENA_VOTE,
479 .en_mask = BIT(4),
480
481 .c = {
482 .dbg_name = "gcc_ce1_axi_clk",
483 .ops = &clk_ops_vote,
484 },
485};
486
487
Channagoud Kadabi634ac6d2012-12-12 18:13:56 -0800488struct branch_clk gcc_blsp2_qup5_i2c_apps_clk = {
489 .cbcr_reg = BLSP2_QUP5_I2C_APPS_CBCR,
490 .parent = &cxo_clk_src.c,
491
492 .c = {
493 .dbg_name = "gcc_blsp2_qup5_i2c_apps_clk",
494 .ops = &clk_ops_branch,
495 },
496};
497
Siddhartha Agrawalacdaf5b2013-01-22 18:14:53 -0800498/* Display clocks */
499static struct clk_freq_tbl ftbl_mdss_esc0_1_clk[] = {
500 F_MM(19200000, cxo, 1, 0, 0),
501 F_END
502};
503
Siddhartha Agrawalc88737b2013-05-29 20:41:35 -0700504static struct clk_freq_tbl ftbl_mdss_esc1_1_clk[] = {
505 F_MM(19200000, cxo, 1, 0, 0),
506 F_END
507};
508
Siddhartha Agrawalacdaf5b2013-01-22 18:14:53 -0800509static struct clk_freq_tbl ftbl_mmss_axi_clk[] = {
510 F_MM(19200000, cxo, 1, 0, 0),
511 F_MM(100000000, gpll0, 6, 0, 0),
512 F_END
513};
514
515static struct clk_freq_tbl ftbl_mdp_clk[] = {
516 F_MM( 75000000, gpll0, 8, 0, 0),
Siddhartha Agrawal6bf6c152013-05-29 20:47:20 -0700517 F_MM( 240000000, gpll0, 2.5, 0, 0),
Siddhartha Agrawalacdaf5b2013-01-22 18:14:53 -0800518 F_END
519};
520
521static struct rcg_clk dsi_esc0_clk_src = {
522 .cmd_reg = (uint32_t *) DSI_ESC0_CMD_RCGR,
523 .cfg_reg = (uint32_t *) DSI_ESC0_CFG_RCGR,
524 .set_rate = clock_lib2_rcg_set_rate_hid,
525 .freq_tbl = ftbl_mdss_esc0_1_clk,
526
527 .c = {
528 .dbg_name = "dsi_esc0_clk_src",
529 .ops = &clk_ops_rcg,
530 },
531};
532
Siddhartha Agrawalc88737b2013-05-29 20:41:35 -0700533static struct rcg_clk dsi_esc1_clk_src = {
534 .cmd_reg = (uint32_t *) DSI_ESC1_CMD_RCGR,
535 .cfg_reg = (uint32_t *) DSI_ESC1_CFG_RCGR,
536 .set_rate = clock_lib2_rcg_set_rate_hid,
537 .freq_tbl = ftbl_mdss_esc1_1_clk,
538
539 .c = {
540 .dbg_name = "dsi_esc1_clk_src",
541 .ops = &clk_ops_rcg,
542 },
543};
544
Siddhartha Agrawal9d6e28f2013-04-21 16:00:07 -0700545static struct clk_freq_tbl ftbl_mdss_vsync_clk[] = {
546 F_MM(19200000, cxo, 1, 0, 0),
547 F_END
548};
549
550static struct rcg_clk vsync_clk_src = {
551 .cmd_reg = (uint32_t *) VSYNC_CMD_RCGR,
552 .cfg_reg = (uint32_t *) VSYNC_CFG_RCGR,
553 .set_rate = clock_lib2_rcg_set_rate_hid,
554 .freq_tbl = ftbl_mdss_vsync_clk,
555
556 .c = {
557 .dbg_name = "vsync_clk_src",
558 .ops = &clk_ops_rcg,
559 },
560};
561
Siddhartha Agrawalacdaf5b2013-01-22 18:14:53 -0800562static struct rcg_clk mdp_axi_clk_src = {
563 .cmd_reg = (uint32_t *) MDP_AXI_CMD_RCGR,
564 .cfg_reg = (uint32_t *) MDP_AXI_CFG_RCGR,
565 .set_rate = clock_lib2_rcg_set_rate_hid,
566 .freq_tbl = ftbl_mmss_axi_clk,
567
568 .c = {
569 .dbg_name = "mdp_axi_clk_src",
570 .ops = &clk_ops_rcg,
571 },
572};
573
574static struct branch_clk mdss_esc0_clk = {
575 .cbcr_reg = (uint32_t *) DSI_ESC0_CBCR,
576 .parent = &dsi_esc0_clk_src.c,
577 .has_sibling = 0,
578
579 .c = {
580 .dbg_name = "mdss_esc0_clk",
581 .ops = &clk_ops_branch,
582 },
583};
584
Siddhartha Agrawalc88737b2013-05-29 20:41:35 -0700585static struct branch_clk mdss_esc1_clk = {
586 .cbcr_reg = (uint32_t *) DSI_ESC1_CBCR,
587 .parent = &dsi_esc1_clk_src.c,
588 .has_sibling = 0,
589
590 .c = {
591 .dbg_name = "mdss_esc1_clk",
592 .ops = &clk_ops_branch,
593 },
594};
595
Siddhartha Agrawalacdaf5b2013-01-22 18:14:53 -0800596static struct branch_clk mdss_axi_clk = {
597 .cbcr_reg = (uint32_t *) MDP_AXI_CBCR,
598 .parent = &mdp_axi_clk_src.c,
599 .has_sibling = 0,
600
601 .c = {
602 .dbg_name = "mdss_axi_clk",
603 .ops = &clk_ops_branch,
604 },
605};
606
607static struct branch_clk mmss_mmssnoc_axi_clk = {
608 .cbcr_reg = (uint32_t *) MMSS_MMSSNOC_AXI_CBCR,
609 .parent = &mdp_axi_clk_src.c,
610 .has_sibling = 0,
611
612 .c = {
613 .dbg_name = "mmss_mmssnoc_axi_clk",
614 .ops = &clk_ops_branch,
615 },
616};
617
618static struct branch_clk mmss_s0_axi_clk = {
619 .cbcr_reg = (uint32_t *) MMSS_S0_AXI_CBCR,
620 .parent = &mdp_axi_clk_src.c,
621 .has_sibling = 0,
622
623 .c = {
624 .dbg_name = "mmss_s0_axi_clk",
625 .ops = &clk_ops_branch,
626 },
627};
628
629static struct branch_clk mdp_ahb_clk = {
630 .cbcr_reg = (uint32_t *) MDP_AHB_CBCR,
631 .has_sibling = 1,
632
633 .c = {
634 .dbg_name = "mdp_ahb_clk",
635 .ops = &clk_ops_branch,
636 },
637};
638
639static struct rcg_clk mdss_mdp_clk_src = {
640 .cmd_reg = (uint32_t *) MDP_CMD_RCGR,
641 .cfg_reg = (uint32_t *) MDP_CFG_RCGR,
642 .set_rate = clock_lib2_rcg_set_rate_hid,
643 .freq_tbl = ftbl_mdp_clk,
644 .current_freq = &rcg_dummy_freq,
645
646 .c = {
647 .dbg_name = "mdss_mdp_clk_src",
648 .ops = &clk_ops_rcg,
649 },
650};
651
652static struct branch_clk mdss_mdp_clk = {
653 .cbcr_reg = (uint32_t *) MDP_CBCR,
654 .parent = &mdss_mdp_clk_src.c,
655 .has_sibling = 1,
656
657 .c = {
658 .dbg_name = "mdss_mdp_clk",
659 .ops = &clk_ops_branch,
660 },
661};
662
663static struct branch_clk mdss_mdp_lut_clk = {
664 .cbcr_reg = MDP_LUT_CBCR,
665 .parent = &mdss_mdp_clk_src.c,
666 .has_sibling = 1,
667
668 .c = {
669 .dbg_name = "mdss_mdp_lut_clk",
670 .ops = &clk_ops_branch,
671 },
672};
673
Siddhartha Agrawal9d6e28f2013-04-21 16:00:07 -0700674static struct branch_clk mdss_vsync_clk = {
675 .cbcr_reg = MDSS_VSYNC_CBCR,
676 .parent = &vsync_clk_src.c,
677 .has_sibling = 0,
678
679 .c = {
680 .dbg_name = "mdss_vsync_clk",
681 .ops = &clk_ops_branch,
682 },
683};
684
Kuogee Hsiehe99937a2013-06-06 14:21:48 -0700685static struct clk_freq_tbl ftbl_mdss_edpaux_clk[] = {
686 F_MM(19200000, cxo, 1, 0, 0),
687 F_END
688};
689
690static struct rcg_clk edpaux_clk_src = {
691 .cmd_reg = (uint32_t *) EDPAUX_CMD_RCGR,
692 .set_rate = clock_lib2_rcg_set_rate_hid,
693 .freq_tbl = ftbl_mdss_edpaux_clk,
694
695 .c = {
696 .dbg_name = "edpaux_clk_src",
697 .ops = &clk_ops_rcg,
698 },
699};
700
701static struct branch_clk mdss_edpaux_clk = {
702 .cbcr_reg = MDSS_EDPAUX_CBCR,
703 .parent = &edpaux_clk_src.c,
704 .has_sibling = 0,
705
706 .c = {
707 .dbg_name = "mdss_edpaux_clk",
708 .ops = &clk_ops_branch,
709 },
710};
711
Asaf Pensod7ce9c22013-06-30 13:21:50 +0300712static struct clk_freq_tbl ftbl_mdss_edplink_clk[] = {
713 F_MDSS(162000000, edppll_270, 2, 0, 0),
714 F_MDSS(270000000, edppll_270, 11, 0, 0),
715 F_END
716};
717
718static struct rcg_clk edplink_clk_src = {
719 .cmd_reg = (uint32_t *)EDPLINK_CMD_RCGR,
720 .set_rate = clock_lib2_rcg_set_rate_hid,
721 .freq_tbl = ftbl_mdss_edplink_clk,
722 .current_freq = &rcg_dummy_freq,
723 .c = {
724 .dbg_name = "edplink_clk_src",
725 .ops = &clk_ops_rcg,
726 },
727};
728
729static struct clk_freq_tbl ftbl_mdss_edppixel_clk[] = {
730 F_MDSS(138500000, edppll_350, 2, 0, 0),
731 F_MDSS(350000000, edppll_350, 11, 0, 0),
732 F_END
733};
734
735static struct rcg_clk edppixel_clk_src = {
736 .cmd_reg = (uint32_t *)EDPPIXEL_CMD_RCGR,
737 .set_rate = clock_lib2_rcg_set_rate_mnd,
738 .freq_tbl = ftbl_mdss_edppixel_clk,
739 .current_freq = &rcg_dummy_freq,
740 .c = {
741 .dbg_name = "edppixel_clk_src",
742 .ops = &clk_ops_rcg_mnd,
743 },
744};
745
746static struct branch_clk mdss_edplink_clk = {
747 .cbcr_reg = (uint32_t *)MDSS_EDPLINK_CBCR,
748 .has_sibling = 0,
749 .parent = &edplink_clk_src.c,
750 .c = {
751 .dbg_name = "mdss_edplink_clk",
752 .ops = &clk_ops_branch,
753 },
754};
755
756static struct branch_clk mdss_edppixel_clk = {
757 .cbcr_reg = (uint32_t *)MDSS_EDPPIXEL_CBCR,
758 .has_sibling = 0,
759 .parent = &edppixel_clk_src.c,
760 .c = {
761 .dbg_name = "mdss_edppixel_clk",
762 .ops = &clk_ops_branch,
763 },
764};
765
Amol Jadi38450af2013-07-23 15:01:48 -0700766/* USB 3.0 Clocks */
767static struct clk_freq_tbl ftbl_gcc_usb30_master_clk[] =
768{
769 F(125000000, gpll0, 1, 5, 24),
770 F_END
771};
772
773static struct rcg_clk usb30_master_clk_src =
774{
775 .cmd_reg = (uint32_t *) GCC_USB30_MASTER_CMD_RCGR,
776 .cfg_reg = (uint32_t *) GCC_USB30_MASTER_CFG_RCGR,
777 .m_reg = (uint32_t *) GCC_USB30_MASTER_M,
778 .n_reg = (uint32_t *) GCC_USB30_MASTER_N,
779 .d_reg = (uint32_t *) GCC_USB30_MASTER_D,
780
781 .set_rate = clock_lib2_rcg_set_rate_mnd,
782 .freq_tbl = ftbl_gcc_usb30_master_clk,
783 .current_freq = &rcg_dummy_freq,
784
785 .c = {
786 .dbg_name = "usb30_master_clk_src",
787 .ops = &clk_ops_rcg,
788 },
789};
790
791
792static struct branch_clk gcc_usb30_master_clk =
793{
794 .cbcr_reg = (uint32_t *) GCC_USB30_MASTER_CBCR,
795 .parent = &usb30_master_clk_src.c,
796
797 .c = {
798 .dbg_name = "gcc_usb30_master_clk",
799 .ops = &clk_ops_branch,
800 },
801};
802
803static struct branch_clk gcc_sys_noc_usb30_axi_clk =
804{
805 .cbcr_reg = (uint32_t *) SYS_NOC_USB3_AXI_CBCR,
806 .has_sibling = 1,
807
808 .c = {
809 .dbg_name = "gcc_sys_noc_usb3_axi_clk",
810 .ops = &clk_ops_branch,
811 },
812};
813
Amol Jadi29f95032012-06-22 12:52:54 -0700814/* Clock lookup table */
815static struct clk_lookup msm_clocks_8974[] =
816{
817 CLK_LOOKUP("sdc1_iface_clk", gcc_sdcc1_ahb_clk.c),
818 CLK_LOOKUP("sdc1_core_clk", gcc_sdcc1_apps_clk.c),
819
Channagoud Kadabibdac7092013-08-20 15:28:07 -0700820 CLK_LOOKUP("gcc_sdcc1_cdccal_sleep_clk", gcc_sdcc1_cdccal_sleep_clk.c),
821 CLK_LOOKUP("gcc_sdcc1_cdccal_ff_clk", gcc_sdcc1_cdccal_ff_clk.c),
822
Channagoud Kadabi5a612c72013-06-04 13:28:14 -0700823 CLK_LOOKUP("sdc2_iface_clk", gcc_sdcc2_ahb_clk.c),
824 CLK_LOOKUP("sdc2_core_clk", gcc_sdcc2_apps_clk.c),
825
Neeti Desaiac011272012-08-29 18:24:54 -0700826 CLK_LOOKUP("uart2_iface_clk", gcc_blsp1_ahb_clk.c),
827 CLK_LOOKUP("uart2_core_clk", gcc_blsp1_uart2_apps_clk.c),
Amol Jadi29f95032012-06-22 12:52:54 -0700828
829 CLK_LOOKUP("usb_iface_clk", gcc_usb_hs_ahb_clk.c),
830 CLK_LOOKUP("usb_core_clk", gcc_usb_hs_system_clk.c),
Deepa Dinamani32bfad02012-11-02 12:15:05 -0700831
832 CLK_LOOKUP("ce2_ahb_clk", gcc_ce2_ahb_clk.c),
833 CLK_LOOKUP("ce2_axi_clk", gcc_ce2_axi_clk.c),
834 CLK_LOOKUP("ce2_core_clk", gcc_ce2_clk.c),
835 CLK_LOOKUP("ce2_src_clk", ce2_clk_src.c),
Channagoud Kadabi634ac6d2012-12-12 18:13:56 -0800836
sundarajan srinivasan6aaa50c2013-02-27 14:18:57 -0800837 CLK_LOOKUP("ce1_ahb_clk", gcc_ce1_ahb_clk.c),
838 CLK_LOOKUP("ce1_axi_clk", gcc_ce1_axi_clk.c),
839 CLK_LOOKUP("ce1_core_clk", gcc_ce1_clk.c),
840 CLK_LOOKUP("ce1_src_clk", ce1_clk_src.c),
841
842
Channagoud Kadabi634ac6d2012-12-12 18:13:56 -0800843 CLK_LOOKUP("blsp2_ahb_clk", gcc_blsp2_ahb_clk.c),
844 CLK_LOOKUP("blsp2_qup5_i2c_apps_clk", gcc_blsp2_qup5_i2c_apps_clk.c),
Siddhartha Agrawalacdaf5b2013-01-22 18:14:53 -0800845
846 CLK_LOOKUP("mdp_ahb_clk", mdp_ahb_clk.c),
847 CLK_LOOKUP("mdss_esc0_clk", mdss_esc0_clk.c),
Siddhartha Agrawalc88737b2013-05-29 20:41:35 -0700848 CLK_LOOKUP("mdss_esc1_clk", mdss_esc1_clk.c),
Siddhartha Agrawalacdaf5b2013-01-22 18:14:53 -0800849 CLK_LOOKUP("mdss_axi_clk", mdss_axi_clk.c),
850 CLK_LOOKUP("mmss_mmssnoc_axi_clk", mmss_mmssnoc_axi_clk.c),
851 CLK_LOOKUP("mmss_s0_axi_clk", mmss_s0_axi_clk.c),
Siddhartha Agrawal9d6e28f2013-04-21 16:00:07 -0700852 CLK_LOOKUP("mdss_vsync_clk", mdss_vsync_clk.c),
Siddhartha Agrawalacdaf5b2013-01-22 18:14:53 -0800853 CLK_LOOKUP("mdss_mdp_clk_src", mdss_mdp_clk_src.c),
854 CLK_LOOKUP("mdss_mdp_clk", mdss_mdp_clk.c),
855 CLK_LOOKUP("mdss_mdp_lut_clk", mdss_mdp_lut_clk.c),
Asaf Pensod7ce9c22013-06-30 13:21:50 +0300856
857 CLK_LOOKUP("edp_pixel_clk", mdss_edppixel_clk.c),
858 CLK_LOOKUP("edp_link_clk", mdss_edplink_clk.c),
Kuogee Hsiehe99937a2013-06-06 14:21:48 -0700859 CLK_LOOKUP("edp_aux_clk", mdss_edpaux_clk.c),
Amol Jadi38450af2013-07-23 15:01:48 -0700860
861 /* USB 3.0 */
862 CLK_LOOKUP("usb30_iface_clk", gcc_sys_noc_usb30_axi_clk.c),
863 CLK_LOOKUP("usb30_master_clk", gcc_usb30_master_clk.c),
Amol Jadi29f95032012-06-22 12:52:54 -0700864};
865
Channagoud Kadabibdac7092013-08-20 15:28:07 -0700866void msm8974_ac_clock_override()
867{
868 sdcc1_apps_clk_src.freq_tbl = ftbl_gcc_sdcc1_apps_clk_ac;
869}
Amol Jadi29f95032012-06-22 12:52:54 -0700870
871void platform_clock_init(void)
872{
Channagoud Kadabi4d385152014-02-18 11:56:07 -0800873 if (platform_is_8974ac())
Channagoud Kadabibdac7092013-08-20 15:28:07 -0700874 msm8974_ac_clock_override();
Amol Jadi29f95032012-06-22 12:52:54 -0700875 clk_init(msm_clocks_8974, ARRAY_SIZE(msm_clocks_8974));
876}