blob: 41efbe33f9c23af1a8ff8a41a6846fcc77ba33b6 [file] [log] [blame]
Channagoud Kadabi0d1a7dc2015-03-16 14:42:37 -07001/* Copyright (c) 2013-2015, The Linux Foundation. All rights reserved.
Channagoud Kadabi123c9722014-02-06 13:22:50 -08002 *
3 * Redistribution and use in source and binary forms, with or without
4 * 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.
15 *
16 * 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.
27 */
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>
Channagoud Kadabi0d1a7dc2015-03-16 14:42:37 -070037#include <platform.h>
Channagoud Kadabi123c9722014-02-06 13:22:50 -080038
39
40/* Mux source select values */
41#define cxo_source_val 0
42#define gpll0_source_val 1
43#define gpll4_source_val 5
44#define cxo_mm_source_val 0
45#define mmpll0_mm_source_val 1
46#define mmpll1_mm_source_val 2
47#define mmpll3_mm_source_val 3
48#define gpll0_mm_source_val 5
Channagoud Kadabib4c64b82014-07-24 17:18:46 -070049#define edppll_270_mm_source_val 4
50#define edppll_350_mm_source_val 4
Ajay Singh Parmar6cf16292015-02-13 17:13:38 -080051#define hdmipll_mm_source_val 3
Channagoud Kadabi123c9722014-02-06 13:22:50 -080052
53struct clk_freq_tbl rcg_dummy_freq = F_END;
54
55
56/* Clock Operations */
Channagoud Kadabi3dcc4ed2014-04-10 14:59:41 -070057static struct clk_ops clk_ops_rst =
58{
59 .reset = clock_lib2_reset_clk_reset,
60};
61
Channagoud Kadabi123c9722014-02-06 13:22:50 -080062static struct clk_ops clk_ops_branch =
63{
64 .enable = clock_lib2_branch_clk_enable,
65 .disable = clock_lib2_branch_clk_disable,
66 .set_rate = clock_lib2_branch_set_rate,
Channagoud Kadabi3dcc4ed2014-04-10 14:59:41 -070067 .reset = clock_lib2_branch_clk_reset,
Channagoud Kadabi123c9722014-02-06 13:22:50 -080068};
69
70static struct clk_ops clk_ops_rcg_mnd =
71{
72 .enable = clock_lib2_rcg_enable,
73 .set_rate = clock_lib2_rcg_set_rate,
74};
75
76static struct clk_ops clk_ops_rcg =
77{
78 .enable = clock_lib2_rcg_enable,
79 .set_rate = clock_lib2_rcg_set_rate,
80};
81
82static struct clk_ops clk_ops_cxo =
83{
84 .enable = cxo_clk_enable,
85 .disable = cxo_clk_disable,
86};
87
88static struct clk_ops clk_ops_pll_vote =
89{
90 .enable = pll_vote_clk_enable,
91 .disable = pll_vote_clk_disable,
92 .auto_off = pll_vote_clk_disable,
93 .is_enabled = pll_vote_clk_is_enabled,
94};
95
96static struct clk_ops clk_ops_vote =
97{
98 .enable = clock_lib2_vote_clk_enable,
99 .disable = clock_lib2_vote_clk_disable,
100};
101
102/* Clock Sources */
103static struct fixed_clk cxo_clk_src =
104{
105 .c = {
106 .rate = 19200000,
107 .dbg_name = "cxo_clk_src",
108 .ops = &clk_ops_cxo,
109 },
110};
111
112static struct pll_vote_clk gpll0_clk_src =
113{
114 .en_reg = (void *) APCS_GPLL_ENA_VOTE,
115 .en_mask = BIT(0),
116 .status_reg = (void *) GPLL0_MODE,
117 .status_mask = BIT(30),
118 .parent = &cxo_clk_src.c,
119
120 .c = {
121 .rate = 600000000,
122 .dbg_name = "gpll0_clk_src",
123 .ops = &clk_ops_pll_vote,
124 },
125};
126
127static struct pll_vote_clk gpll4_clk_src =
128{
129 .en_reg = (void *) APCS_GPLL_ENA_VOTE,
130 .en_mask = BIT(4),
131 .status_reg = (void *) GPLL4_MODE,
132 .status_mask = BIT(30),
133 .parent = &cxo_clk_src.c,
134
135 .c = {
136 .rate = 1600000000,
137 .dbg_name = "gpll4_clk_src",
138 .ops = &clk_ops_pll_vote,
139 },
140};
141
142/* UART Clocks */
143static struct clk_freq_tbl ftbl_gcc_blsp1_2_uart1_6_apps_clk[] =
144{
145 F( 3686400, gpll0, 1, 96, 15625),
146 F( 7372800, gpll0, 1, 192, 15625),
147 F(14745600, gpll0, 1, 384, 15625),
148 F(16000000, gpll0, 5, 2, 15),
149 F(19200000, cxo, 1, 0, 0),
150 F(24000000, gpll0, 5, 1, 5),
151 F(32000000, gpll0, 1, 4, 75),
152 F(40000000, gpll0, 15, 0, 0),
153 F(46400000, gpll0, 1, 29, 375),
154 F(48000000, gpll0, 12.5, 0, 0),
155 F(51200000, gpll0, 1, 32, 375),
156 F(56000000, gpll0, 1, 7, 75),
157 F(58982400, gpll0, 1, 1536, 15625),
158 F(60000000, gpll0, 10, 0, 0),
Channagoud Kadabia66a6f22014-05-28 17:19:44 -0700159 F(63160000, gpll0, 9.5, 0, 0),
Channagoud Kadabi123c9722014-02-06 13:22:50 -0800160 F_END
161};
162
Channagoud Kadabi123c9722014-02-06 13:22:50 -0800163static struct rcg_clk blsp1_uart2_apps_clk_src =
164{
165 .cmd_reg = (uint32_t *) BLSP1_UART2_APPS_CMD_RCGR,
166 .cfg_reg = (uint32_t *) BLSP1_UART2_APPS_CFG_RCGR,
167 .m_reg = (uint32_t *) BLSP1_UART2_APPS_M,
168 .n_reg = (uint32_t *) BLSP1_UART2_APPS_N,
169 .d_reg = (uint32_t *) BLSP1_UART2_APPS_D,
170
171 .set_rate = clock_lib2_rcg_set_rate_mnd,
172 .freq_tbl = ftbl_gcc_blsp1_2_uart1_6_apps_clk,
173 .current_freq = &rcg_dummy_freq,
174
175 .c = {
176 .dbg_name = "blsp1_uart2_apps_clk",
177 .ops = &clk_ops_rcg_mnd,
178 },
179};
180
Channagoud Kadabi123c9722014-02-06 13:22:50 -0800181static struct branch_clk gcc_blsp1_uart2_apps_clk =
182{
183 .cbcr_reg = (uint32_t *) BLSP1_UART2_APPS_CBCR,
184 .parent = &blsp1_uart2_apps_clk_src.c,
185
186 .c = {
187 .dbg_name = "gcc_blsp1_uart2_apps_clk",
188 .ops = &clk_ops_branch,
189 },
190};
191
192static struct vote_clk gcc_blsp1_ahb_clk = {
193 .cbcr_reg = (uint32_t *) BLSP1_AHB_CBCR,
194 .vote_reg = (uint32_t *) APCS_CLOCK_BRANCH_ENA_VOTE,
195 .en_mask = BIT(17),
196
197 .c = {
198 .dbg_name = "gcc_blsp1_ahb_clk",
199 .ops = &clk_ops_vote,
200 },
201};
202
Channagoud Kadabi123c9722014-02-06 13:22:50 -0800203/* USB Clocks */
204static struct clk_freq_tbl ftbl_gcc_usb_hs_system_clk[] =
205{
206 F(75000000, gpll0, 8, 0, 0),
207 F_END
208};
209
210static struct rcg_clk usb_hs_system_clk_src =
211{
212 .cmd_reg = (uint32_t *) USB_HS_SYSTEM_CMD_RCGR,
213 .cfg_reg = (uint32_t *) USB_HS_SYSTEM_CFG_RCGR,
214
215 .set_rate = clock_lib2_rcg_set_rate_hid,
216 .freq_tbl = ftbl_gcc_usb_hs_system_clk,
217 .current_freq = &rcg_dummy_freq,
218
219 .c = {
220 .dbg_name = "usb_hs_system_clk",
221 .ops = &clk_ops_rcg,
222 },
223};
224
225static struct branch_clk gcc_usb_hs_system_clk =
226{
227 .cbcr_reg = (uint32_t *) USB_HS_SYSTEM_CBCR,
228 .parent = &usb_hs_system_clk_src.c,
229
230 .c = {
231 .dbg_name = "gcc_usb_hs_system_clk",
232 .ops = &clk_ops_branch,
233 },
234};
235
236static struct branch_clk gcc_usb_hs_ahb_clk =
237{
238 .cbcr_reg = (uint32_t *) USB_HS_AHB_CBCR,
239 .has_sibling = 1,
240
241 .c = {
242 .dbg_name = "gcc_usb_hs_ahb_clk",
243 .ops = &clk_ops_branch,
244 },
245};
246
247/* SDCC Clocks */
Channagoud Kadabie804d642014-08-20 17:43:57 -0700248static struct clk_freq_tbl ftbl_gcc_sdcc1_apps_clk[] =
Channagoud Kadabi123c9722014-02-06 13:22:50 -0800249{
250 F( 144000, cxo, 16, 3, 25),
251 F( 400000, cxo, 12, 1, 4),
252 F( 20000000, gpll0, 15, 1, 2),
253 F( 25000000, gpll0, 12, 1, 2),
254 F( 50000000, gpll0, 12, 0, 0),
Channagoud Kadabia66a6f22014-05-28 17:19:44 -0700255 F( 96000000, gpll4, 6, 0, 0),
256 F(192000000, gpll4, 2, 0, 0),
257 F(384000000, gpll4, 1, 0, 0),
Channagoud Kadabi123c9722014-02-06 13:22:50 -0800258 F_END
259};
260
Channagoud Kadabi0d1a7dc2015-03-16 14:42:37 -0700261static struct clk_freq_tbl ftbl_gcc_sdcc1_apps_clk_8992[] =
262{
263 F( 144000, cxo, 16, 3, 25),
264 F( 400000, cxo, 12, 1, 4),
265 F( 20000000, gpll0, 15, 1, 2),
266 F( 25000000, gpll0, 12, 1, 2),
267 F( 50000000, gpll0, 12, 0, 0),
268 F( 96000000, gpll4, 6, 0, 0),
269 F(172000000, gpll4, 2, 0, 0),
270 F(344000000, gpll4, 1, 0, 0),
271 F_END
272};
273
Channagoud Kadabie804d642014-08-20 17:43:57 -0700274static struct clk_freq_tbl ftbl_gcc_sdcc2_4_apps_clk[] =
275{
276 F( 144000, cxo, 16, 3, 25),
277 F( 400000, cxo, 12, 1, 4),
278 F( 20000000, gpll0, 15, 1, 2),
279 F( 25000000, gpll0, 12, 1, 2),
280 F( 50000000, gpll0, 12, 0, 0),
281 F(100000000, gpll0, 6, 0, 0),
282 F(200000000, gpll0, 3, 0, 0),
283 F_END
284};
285
Channagoud Kadabi123c9722014-02-06 13:22:50 -0800286static struct rcg_clk sdcc1_apps_clk_src =
287{
288 .cmd_reg = (uint32_t *) SDCC1_CMD_RCGR,
289 .cfg_reg = (uint32_t *) SDCC1_CFG_RCGR,
290 .m_reg = (uint32_t *) SDCC1_M,
291 .n_reg = (uint32_t *) SDCC1_N,
292 .d_reg = (uint32_t *) SDCC1_D,
293
294 .set_rate = clock_lib2_rcg_set_rate_mnd,
Channagoud Kadabie804d642014-08-20 17:43:57 -0700295 .freq_tbl = ftbl_gcc_sdcc1_apps_clk,
Channagoud Kadabi123c9722014-02-06 13:22:50 -0800296 .current_freq = &rcg_dummy_freq,
297
298 .c = {
299 .dbg_name = "sdc1_clk",
300 .ops = &clk_ops_rcg_mnd,
301 },
302};
303
304static struct branch_clk gcc_sdcc1_apps_clk =
305{
306 .cbcr_reg = (uint32_t *) SDCC1_APPS_CBCR,
307 .parent = &sdcc1_apps_clk_src.c,
308
309 .c = {
310 .dbg_name = "gcc_sdcc1_apps_clk",
311 .ops = &clk_ops_branch,
312 },
313};
314
315static struct branch_clk gcc_sdcc1_ahb_clk =
316{
317 .cbcr_reg = (uint32_t *) SDCC1_AHB_CBCR,
318 .has_sibling = 1,
319
320 .c = {
321 .dbg_name = "gcc_sdcc1_ahb_clk",
322 .ops = &clk_ops_branch,
323 },
324};
325
Channagoud Kadabie804d642014-08-20 17:43:57 -0700326static struct rcg_clk sdcc2_apps_clk_src =
327{
328 .cmd_reg = (uint32_t *) SDCC2_CMD_RCGR,
329 .cfg_reg = (uint32_t *) SDCC2_CFG_RCGR,
330 .m_reg = (uint32_t *) SDCC2_M,
331 .n_reg = (uint32_t *) SDCC2_N,
332 .d_reg = (uint32_t *) SDCC2_D,
333
334 .set_rate = clock_lib2_rcg_set_rate_mnd,
335 .freq_tbl = ftbl_gcc_sdcc2_4_apps_clk,
336 .current_freq = &rcg_dummy_freq,
337
338 .c = {
339 .dbg_name = "sdc2_clk",
340 .ops = &clk_ops_rcg_mnd,
341 },
342};
343
344static struct branch_clk gcc_sdcc2_apps_clk =
345{
346 .cbcr_reg = (uint32_t *) SDCC2_APPS_CBCR,
347 .parent = &sdcc2_apps_clk_src.c,
348
349 .c = {
350 .dbg_name = "gcc_sdcc2_apps_clk",
351 .ops = &clk_ops_branch,
352 },
353};
354
355static struct branch_clk gcc_sdcc2_ahb_clk =
356{
357 .cbcr_reg = (uint32_t *) SDCC2_AHB_CBCR,
358 .has_sibling = 1,
359
360 .c = {
361 .dbg_name = "gcc_sdcc2_ahb_clk",
362 .ops = &clk_ops_branch,
363 },
364};
365
Channagoud Kadabi3dcc4ed2014-04-10 14:59:41 -0700366static struct branch_clk gcc_sys_noc_usb30_axi_clk = {
367 .cbcr_reg = (uint32_t *) SYS_NOC_USB3_AXI_CBCR,
368 .has_sibling = 1,
369
370 .c = {
371 .dbg_name = "sys_noc_usb30_axi_clk",
372 .ops = &clk_ops_branch,
373 },
374};
375
376static struct branch_clk gcc_usb2b_phy_sleep_clk = {
377 .cbcr_reg = (uint32_t *) USB2B_PHY_SLEEP_CBCR,
378 .bcr_reg = (uint32_t *) USB2B_PHY_BCR,
379 .has_sibling = 1,
380
381 .c = {
382 .dbg_name = "usb2b_phy_sleep_clk",
383 .ops = &clk_ops_branch,
384 },
385};
386
387static struct clk_freq_tbl ftbl_gcc_usb30_master_clk[] = {
388 F( 125000000, gpll0, 1, 5, 24),
389 F_END
390};
391
392static struct rcg_clk usb30_master_clk_src = {
393 .cmd_reg = (uint32_t *) USB30_MASTER_CMD_RCGR,
394 .cfg_reg = (uint32_t *) USB30_MASTER_CFG_RCGR,
395 .m_reg = (uint32_t *) USB30_MASTER_M,
396 .n_reg = (uint32_t *) USB30_MASTER_N,
397 .d_reg = (uint32_t *) USB30_MASTER_D,
398
399 .set_rate = clock_lib2_rcg_set_rate_mnd,
400 .freq_tbl = ftbl_gcc_usb30_master_clk,
401 .current_freq = &rcg_dummy_freq,
402
403 .c = {
404 .dbg_name = "usb30_master_clk_src",
405 .ops = &clk_ops_rcg,
406 },
407};
408
409static struct branch_clk gcc_usb30_master_clk = {
410 .cbcr_reg = (uint32_t *) USB30_MASTER_CBCR,
411 .bcr_reg = (uint32_t *) USB_30_BCR,
412 .parent = &usb30_master_clk_src.c,
413
414 .c = {
415 .dbg_name = "usb30_master_clk",
416 .ops = &clk_ops_branch,
417 },
418};
419
420static struct clk_freq_tbl ftbl_gcc_usb30_mock_utmi_clk_src[] = {
421 F( 60000000, gpll0, 10, 0, 0),
422 F_END
423};
424
425static struct rcg_clk usb30_mock_utmi_clk_src = {
426 .cmd_reg = (uint32_t *) USB30_MOCK_UTMI_CMD_RCGR,
427 .cfg_reg = (uint32_t *) USB30_MOCK_UTMI_CFG_RCGR,
428 .set_rate = clock_lib2_rcg_set_rate_hid,
429 .freq_tbl = ftbl_gcc_usb30_mock_utmi_clk_src,
430 .current_freq = &rcg_dummy_freq,
431
432 .c = {
433 .dbg_name = "usb30_mock_utmi_clk_src",
434 .ops = &clk_ops_rcg,
435 },
436};
437
438static struct branch_clk gcc_usb30_mock_utmi_clk = {
439 .cbcr_reg = (uint32_t *) USB30_MOCK_UTMI_CBCR,
440 .has_sibling = 0,
441 .parent = &usb30_mock_utmi_clk_src.c,
442
443 .c = {
444 .dbg_name = "usb30_mock_utmi_clk",
445 .ops = &clk_ops_branch,
446 },
447};
448
449static struct branch_clk gcc_usb30_sleep_clk = {
450 .cbcr_reg = (uint32_t *) USB30_SLEEP_CBCR,
451 .has_sibling = 1,
452
453 .c = {
454 .dbg_name = "usb30_sleep_clk",
455 .ops = &clk_ops_branch,
456 },
457};
458
459static struct clk_freq_tbl ftbl_gcc_usb30_phy_aux_clk_src[] = {
460 F( 1200000, cxo, 16, 0, 0),
461 F_END
462};
463
464static struct rcg_clk usb30_phy_aux_clk_src = {
465 .cmd_reg = (uint32_t *) USB30_PHY_AUX_CMD_RCGR,
466 .cfg_reg = (uint32_t *) USB30_PHY_AUX_CFG_RCGR,
467 .set_rate = clock_lib2_rcg_set_rate_hid,
468 .freq_tbl = ftbl_gcc_usb30_phy_aux_clk_src,
469 .current_freq = &rcg_dummy_freq,
470
471 .c = {
472 .dbg_name = "usb30_phy_aux_clk_src",
473 .ops = &clk_ops_rcg,
474 },
475};
476
477static struct branch_clk gcc_usb30_phy_aux_clk = {
478 .cbcr_reg = (uint32_t *)USB30_PHY_AUX_CBCR,
479 .has_sibling = 0,
480 .parent = &usb30_phy_aux_clk_src.c,
481
482 .c = {
483 .dbg_name = "usb30_phy_aux_clk",
484 .ops = &clk_ops_branch,
485 },
486};
487
488static struct branch_clk gcc_usb30_pipe_clk = {
489 .bcr_reg = (uint32_t *) USB30PHY_PHY_BCR,
490 .cbcr_reg = (uint32_t *) USB30_PHY_PIPE_CBCR,
491 .has_sibling = 1,
492
493 .c = {
494 .dbg_name = "usb30_pipe_clk",
495 .ops = &clk_ops_branch,
496 },
497};
498
499static struct reset_clk gcc_usb30_phy_reset = {
Channagoud Kadabi3c2be1c2014-06-01 18:59:21 -0700500 .bcr_reg = (uint32_t )USB30_PHY_BCR,
Channagoud Kadabi3dcc4ed2014-04-10 14:59:41 -0700501
502 .c = {
503 .dbg_name = "usb30_phy_reset",
504 .ops = &clk_ops_rst,
505 },
506};
507
Channagoud Kadabi3c2be1c2014-06-01 18:59:21 -0700508static struct branch_clk gcc_usb_phy_cfg_ahb2phy_clk = {
509 .cbcr_reg = (uint32_t *)USB_PHY_CFG_AHB2PHY_CBCR,
510 .has_sibling = 1,
511
512 .c = {
513 .dbg_name = "usb_phy_cfg_ahb2phy_clk",
514 .ops = &clk_ops_branch,
515 },
516};
517
Channagoud Kadabib4c64b82014-07-24 17:18:46 -0700518/* Display clocks */
519static struct clk_freq_tbl ftbl_mdss_esc0_1_clk[] = {
520 F_MM(19200000, cxo, 1, 0, 0),
521 F_END
522};
523
524static struct clk_freq_tbl ftbl_mdss_esc1_1_clk[] = {
525 F_MM(19200000, cxo, 1, 0, 0),
526 F_END
527};
528
529static struct clk_freq_tbl ftbl_mmss_axi_clk[] = {
530 F_MM(19200000, cxo, 1, 0, 0),
531 F_MM(100000000, gpll0, 6, 0, 0),
Siddhartha Agrawale24a18a2014-10-13 17:07:43 -0700532 F_MM(300000000, gpll0, 2, 0, 0),
Channagoud Kadabib4c64b82014-07-24 17:18:46 -0700533 F_END
534};
535
536static struct clk_freq_tbl ftbl_mdp_clk[] = {
537 F_MM( 75000000, gpll0, 8, 0, 0),
538 F_MM( 240000000, gpll0, 2.5, 0, 0),
Siddhartha Agrawale24a18a2014-10-13 17:07:43 -0700539 F_MM(300000000, gpll0, 2, 0, 0),
Channagoud Kadabib4c64b82014-07-24 17:18:46 -0700540 F_END
541};
542
543static struct rcg_clk dsi_esc0_clk_src = {
544 .cmd_reg = (uint32_t *) DSI_ESC0_CMD_RCGR,
545 .cfg_reg = (uint32_t *) DSI_ESC0_CFG_RCGR,
546 .set_rate = clock_lib2_rcg_set_rate_hid,
547 .freq_tbl = ftbl_mdss_esc0_1_clk,
548
549 .c = {
550 .dbg_name = "dsi_esc0_clk_src",
551 .ops = &clk_ops_rcg,
552 },
553};
554
555static struct rcg_clk dsi_esc1_clk_src = {
556 .cmd_reg = (uint32_t *) DSI_ESC1_CMD_RCGR,
557 .cfg_reg = (uint32_t *) DSI_ESC1_CFG_RCGR,
558 .set_rate = clock_lib2_rcg_set_rate_hid,
559 .freq_tbl = ftbl_mdss_esc1_1_clk,
560
561 .c = {
562 .dbg_name = "dsi_esc1_clk_src",
563 .ops = &clk_ops_rcg,
564 },
565};
566
567static struct clk_freq_tbl ftbl_mdss_vsync_clk[] = {
568 F_MM(19200000, cxo, 1, 0, 0),
569 F_END
570};
571
572static struct rcg_clk vsync_clk_src = {
573 .cmd_reg = (uint32_t *) VSYNC_CMD_RCGR,
574 .cfg_reg = (uint32_t *) VSYNC_CFG_RCGR,
575 .set_rate = clock_lib2_rcg_set_rate_hid,
576 .freq_tbl = ftbl_mdss_vsync_clk,
577
578 .c = {
579 .dbg_name = "vsync_clk_src",
580 .ops = &clk_ops_rcg,
581 },
582};
583
584static struct rcg_clk mdp_axi_clk_src = {
585 .cmd_reg = (uint32_t *) MDP_AXI_CMD_RCGR,
586 .cfg_reg = (uint32_t *) MDP_AXI_CFG_RCGR,
587 .set_rate = clock_lib2_rcg_set_rate_hid,
588 .freq_tbl = ftbl_mmss_axi_clk,
589
590 .c = {
591 .dbg_name = "mdp_axi_clk_src",
592 .ops = &clk_ops_rcg,
593 },
594};
595
596static struct branch_clk mdss_esc0_clk = {
597 .cbcr_reg = (uint32_t *) DSI_ESC0_CBCR,
598 .parent = &dsi_esc0_clk_src.c,
599 .has_sibling = 0,
600
601 .c = {
602 .dbg_name = "mdss_esc0_clk",
603 .ops = &clk_ops_branch,
604 },
605};
606
607static struct branch_clk mdss_esc1_clk = {
608 .cbcr_reg = (uint32_t *) DSI_ESC1_CBCR,
609 .parent = &dsi_esc1_clk_src.c,
610 .has_sibling = 0,
611
612 .c = {
613 .dbg_name = "mdss_esc1_clk",
614 .ops = &clk_ops_branch,
615 },
616};
617
618static struct branch_clk mdss_axi_clk = {
619 .cbcr_reg = (uint32_t *) MDP_AXI_CBCR,
620 .parent = &mdp_axi_clk_src.c,
621 .has_sibling = 0,
622
623 .c = {
624 .dbg_name = "mdss_axi_clk",
625 .ops = &clk_ops_branch,
626 },
627};
628
629static struct branch_clk mmss_mmssnoc_axi_clk = {
630 .cbcr_reg = (uint32_t *) MMSS_MMSSNOC_AXI_CBCR,
631 .parent = &mdp_axi_clk_src.c,
632 .has_sibling = 0,
633
634 .c = {
635 .dbg_name = "mmss_mmssnoc_axi_clk",
636 .ops = &clk_ops_branch,
637 },
638};
639
640static struct branch_clk mmss_s0_axi_clk = {
641 .cbcr_reg = (uint32_t *) MMSS_S0_AXI_CBCR,
642 .parent = &mdp_axi_clk_src.c,
643 .has_sibling = 0,
644
645 .c = {
646 .dbg_name = "mmss_s0_axi_clk",
647 .ops = &clk_ops_branch,
648 },
649};
650
651static struct branch_clk mdp_ahb_clk = {
652 .cbcr_reg = (uint32_t *) MDP_AHB_CBCR,
653 .has_sibling = 1,
654
655 .c = {
656 .dbg_name = "mdp_ahb_clk",
657 .ops = &clk_ops_branch,
658 },
659};
660
661static struct rcg_clk mdss_mdp_clk_src = {
662 .cmd_reg = (uint32_t *) MDP_CMD_RCGR,
663 .cfg_reg = (uint32_t *) MDP_CFG_RCGR,
664 .set_rate = clock_lib2_rcg_set_rate_hid,
665 .freq_tbl = ftbl_mdp_clk,
666 .current_freq = &rcg_dummy_freq,
667
668 .c = {
669 .dbg_name = "mdss_mdp_clk_src",
670 .ops = &clk_ops_rcg,
671 },
672};
673
674static struct branch_clk mdss_mdp_clk = {
675 .cbcr_reg = (uint32_t *) MDP_CBCR,
676 .parent = &mdss_mdp_clk_src.c,
677 .has_sibling = 1,
678
679 .c = {
680 .dbg_name = "mdss_mdp_clk",
681 .ops = &clk_ops_branch,
682 },
683};
684
685static struct branch_clk mdss_mdp_lut_clk = {
Veera Sundaram Sankaran76f05102014-12-09 13:59:40 -0800686 .cbcr_reg = (uint32_t *) MDP_LUT_CBCR,
Channagoud Kadabib4c64b82014-07-24 17:18:46 -0700687 .parent = &mdss_mdp_clk_src.c,
688 .has_sibling = 1,
689
690 .c = {
691 .dbg_name = "mdss_mdp_lut_clk",
692 .ops = &clk_ops_branch,
693 },
694};
695
696static struct branch_clk mdss_vsync_clk = {
Veera Sundaram Sankaran76f05102014-12-09 13:59:40 -0800697 .cbcr_reg = (uint32_t *) MDSS_VSYNC_CBCR,
Channagoud Kadabib4c64b82014-07-24 17:18:46 -0700698 .parent = &vsync_clk_src.c,
699 .has_sibling = 0,
700
701 .c = {
702 .dbg_name = "mdss_vsync_clk",
703 .ops = &clk_ops_branch,
704 },
705};
706
707static struct clk_freq_tbl ftbl_mdss_edpaux_clk[] = {
708 F_MM(19200000, cxo, 1, 0, 0),
709 F_END
710};
711
712static struct rcg_clk edpaux_clk_src = {
713 .cmd_reg = (uint32_t *) EDPAUX_CMD_RCGR,
714 .set_rate = clock_lib2_rcg_set_rate_hid,
715 .freq_tbl = ftbl_mdss_edpaux_clk,
716
717 .c = {
718 .dbg_name = "edpaux_clk_src",
719 .ops = &clk_ops_rcg,
720 },
721};
722
723static struct branch_clk mdss_edpaux_clk = {
Veera Sundaram Sankaran76f05102014-12-09 13:59:40 -0800724 .cbcr_reg = (uint32_t *) MDSS_EDPAUX_CBCR,
Channagoud Kadabib4c64b82014-07-24 17:18:46 -0700725 .parent = &edpaux_clk_src.c,
726 .has_sibling = 0,
727
728 .c = {
729 .dbg_name = "mdss_edpaux_clk",
730 .ops = &clk_ops_branch,
731 },
732};
733
734static struct clk_freq_tbl ftbl_mdss_edplink_clk[] = {
735 F_MDSS(162000000, edppll_270, 2, 0, 0),
736 F_MDSS(270000000, edppll_270, 11, 0, 0),
737 F_END
738};
739
740static struct rcg_clk edplink_clk_src = {
741 .cmd_reg = (uint32_t *)EDPLINK_CMD_RCGR,
742 .set_rate = clock_lib2_rcg_set_rate_hid,
743 .freq_tbl = ftbl_mdss_edplink_clk,
744 .current_freq = &rcg_dummy_freq,
745 .c = {
746 .dbg_name = "edplink_clk_src",
747 .ops = &clk_ops_rcg,
748 },
749};
750
751static struct clk_freq_tbl ftbl_mdss_edppixel_clk[] = {
752 F_MDSS(138500000, edppll_350, 2, 0, 0),
753 F_MDSS(350000000, edppll_350, 11, 0, 0),
754 F_END
755};
756
757static struct rcg_clk edppixel_clk_src = {
758 .cmd_reg = (uint32_t *)EDPPIXEL_CMD_RCGR,
759 .set_rate = clock_lib2_rcg_set_rate_mnd,
760 .freq_tbl = ftbl_mdss_edppixel_clk,
761 .current_freq = &rcg_dummy_freq,
762 .c = {
763 .dbg_name = "edppixel_clk_src",
764 .ops = &clk_ops_rcg_mnd,
765 },
766};
767
768static struct branch_clk mdss_edplink_clk = {
769 .cbcr_reg = (uint32_t *)MDSS_EDPLINK_CBCR,
770 .has_sibling = 0,
771 .parent = &edplink_clk_src.c,
772 .c = {
773 .dbg_name = "mdss_edplink_clk",
774 .ops = &clk_ops_branch,
775 },
776};
777
778static struct branch_clk mdss_edppixel_clk = {
779 .cbcr_reg = (uint32_t *)MDSS_EDPPIXEL_CBCR,
780 .has_sibling = 0,
781 .parent = &edppixel_clk_src.c,
782 .c = {
783 .dbg_name = "mdss_edppixel_clk",
784 .ops = &clk_ops_branch,
785 },
786};
Channagoud Kadabi3c2be1c2014-06-01 18:59:21 -0700787
Channagoud Kadabi5f42b272014-08-21 18:40:39 -0700788static struct branch_clk mmss_misc_ahb_clk = {
Veera Sundaram Sankaran76f05102014-12-09 13:59:40 -0800789 .cbcr_reg = (uint32_t *) MMSS_MISC_AHB_CBCR,
Channagoud Kadabi5f42b272014-08-21 18:40:39 -0700790 .has_sibling = 1,
791
792 .c = {
793 .dbg_name = "mmss_misc_ahb_clk",
794 .ops = &clk_ops_branch,
795 },
796};
797
Ajay Singh Parmar6cf16292015-02-13 17:13:38 -0800798static struct branch_clk mdss_hdmi_ahb_clk = {
799 .cbcr_reg = (uint32_t *) MDSS_HDMI_AHB_CBCR,
800 .has_sibling = 1,
801 .c = {
802 .dbg_name = "mdss_hdmi_ahb_clk",
803 .ops = &clk_ops_branch,
804 },
805};
806
807static struct clk_freq_tbl ftbl_mdss_hdmi_clk[] = {
808 F_MM( 19200000, cxo, 1, 0, 0),
809 F_END
810};
811
812static struct rcg_clk hdmi_clk_src = {
813 .cmd_reg = (uint32_t *) HDMI_CMD_RCGR,
814 .cfg_reg = (uint32_t *) HDMI_CFG_RCGR,
815 .set_rate = clock_lib2_rcg_set_rate_hid,
816 .freq_tbl = ftbl_mdss_hdmi_clk,
817 .current_freq = &rcg_dummy_freq,
818 .c = {
819 .dbg_name = "hdmi_clk_src",
820 .ops = &clk_ops_rcg,
821 },
822};
823
824static struct branch_clk mdss_hdmi_clk = {
825 .cbcr_reg = (uint32_t *) MDSS_HDMI_CBCR,
826 .has_sibling = 0,
827 .parent = &hdmi_clk_src.c,
828 .c = {
829 .dbg_name = "mdss_hdmi_clk",
830 .ops = &clk_ops_branch,
831 },
832};
833
834static struct clk_freq_tbl ftbl_mdss_extpclk_clk[] = {
Ajay Singh Parmar8a0c08f2014-09-06 00:33:44 -0700835 F_MDSS( 74250000, hdmipll, 1, 0, 0),
836 F_MDSS( 25200000, hdmipll, 1, 0, 0),
837 F_MDSS( 27000000, hdmipll, 1, 0, 0),
838 F_MDSS( 27030000, hdmipll, 1, 0, 0),
839 F_MDSS( 27070000, hdmipll, 1, 0, 0),
840 F_MDSS( 65000000, hdmipll, 1, 0, 0),
841 F_MDSS(108000000, hdmipll, 1, 0, 0),
842 F_MDSS(148500000, hdmipll, 1, 0, 0),
843 F_MDSS(268500000, hdmipll, 1, 0, 0),
844 F_MDSS(297000000, hdmipll, 1, 0, 0),
845 F_END
Ajay Singh Parmar6cf16292015-02-13 17:13:38 -0800846};
847
848static struct rcg_clk extpclk_clk_src = {
849 .cmd_reg = (uint32_t *) EXTPCLK_CMD_RCGR,
850 .cfg_reg = (uint32_t *) EXTPCLK_CFG_RCGR,
851 .set_rate = clock_lib2_rcg_set_rate_hid,
852 .freq_tbl = ftbl_mdss_extpclk_clk,
853 .current_freq = &rcg_dummy_freq,
854 .c = {
855 .dbg_name = "extpclk_clk_src",
856 .ops = &clk_ops_rcg,
857 },
858};
859
860static struct branch_clk mdss_extpclk_clk = {
861 .cbcr_reg = (uint32_t *) MDSS_EXTPCLK_CBCR,
862 .has_sibling = 0,
863 .parent = &extpclk_clk_src.c,
864 .c = {
865 .dbg_name = "mdss_extpclk_clk",
866 .ops = &clk_ops_branch,
867 },
868};
869
Channagoud Kadabi123c9722014-02-06 13:22:50 -0800870/* Clock lookup table */
Channagoud Kadabi608b6a72014-04-14 13:58:03 -0700871static struct clk_lookup msm_8994_clocks[] =
Channagoud Kadabi123c9722014-02-06 13:22:50 -0800872{
873 CLK_LOOKUP("sdc1_iface_clk", gcc_sdcc1_ahb_clk.c),
874 CLK_LOOKUP("sdc1_core_clk", gcc_sdcc1_apps_clk.c),
875
Channagoud Kadabie804d642014-08-20 17:43:57 -0700876 CLK_LOOKUP("sdc2_iface_clk", gcc_sdcc2_ahb_clk.c),
877 CLK_LOOKUP("sdc2_core_clk", gcc_sdcc2_apps_clk.c),
878
Channagoud Kadabi123c9722014-02-06 13:22:50 -0800879 CLK_LOOKUP("uart2_iface_clk", gcc_blsp1_ahb_clk.c),
880 CLK_LOOKUP("uart2_core_clk", gcc_blsp1_uart2_apps_clk.c),
881
882 CLK_LOOKUP("usb_iface_clk", gcc_usb_hs_ahb_clk.c),
883 CLK_LOOKUP("usb_core_clk", gcc_usb_hs_system_clk.c),
Channagoud Kadabi3dcc4ed2014-04-10 14:59:41 -0700884
885 /* USB30 clocks */
886 CLK_LOOKUP("usb2b_phy_sleep_clk", gcc_usb2b_phy_sleep_clk.c),
887 CLK_LOOKUP("usb30_master_clk", gcc_usb30_master_clk.c),
Channagoud Kadabi3c2be1c2014-06-01 18:59:21 -0700888 CLK_LOOKUP("usb30_iface_clk", gcc_sys_noc_usb30_axi_clk.c),
Channagoud Kadabi3dcc4ed2014-04-10 14:59:41 -0700889 CLK_LOOKUP("usb30_mock_utmi_clk", gcc_usb30_mock_utmi_clk.c),
890 CLK_LOOKUP("usb30_sleep_clk", gcc_usb30_sleep_clk.c),
891 CLK_LOOKUP("usb30_phy_aux_clk", gcc_usb30_phy_aux_clk.c),
892 CLK_LOOKUP("usb30_pipe_clk", gcc_usb30_pipe_clk.c),
893 CLK_LOOKUP("usb30_phy_reset", gcc_usb30_phy_reset.c),
Channagoud Kadabi3c2be1c2014-06-01 18:59:21 -0700894
895 CLK_LOOKUP("usb_phy_cfg_ahb2phy_clk", gcc_usb_phy_cfg_ahb2phy_clk.c),
Channagoud Kadabib4c64b82014-07-24 17:18:46 -0700896
897 /* mdss clocks */
898 CLK_LOOKUP("mdp_ahb_clk", mdp_ahb_clk.c),
899 CLK_LOOKUP("mdss_esc0_clk", mdss_esc0_clk.c),
900 CLK_LOOKUP("mdss_esc1_clk", mdss_esc1_clk.c),
901 CLK_LOOKUP("mdss_axi_clk", mdss_axi_clk.c),
902 CLK_LOOKUP("mmss_mmssnoc_axi_clk", mmss_mmssnoc_axi_clk.c),
903 CLK_LOOKUP("mmss_s0_axi_clk", mmss_s0_axi_clk.c),
904 CLK_LOOKUP("mdss_vsync_clk", mdss_vsync_clk.c),
905 CLK_LOOKUP("mdss_mdp_clk_src", mdss_mdp_clk_src.c),
906 CLK_LOOKUP("mdss_mdp_clk", mdss_mdp_clk.c),
907 CLK_LOOKUP("mdss_mdp_lut_clk", mdss_mdp_lut_clk.c),
Channagoud Kadabi5f42b272014-08-21 18:40:39 -0700908 CLK_LOOKUP("mmss_misc_ahb_clk", mmss_misc_ahb_clk.c),
Channagoud Kadabib4c64b82014-07-24 17:18:46 -0700909
910 CLK_LOOKUP("edp_pixel_clk", mdss_edppixel_clk.c),
911 CLK_LOOKUP("edp_link_clk", mdss_edplink_clk.c),
912 CLK_LOOKUP("edp_aux_clk", mdss_edpaux_clk.c),
Ajay Singh Parmar6cf16292015-02-13 17:13:38 -0800913
914 CLK_LOOKUP("hdmi_ahb_clk", mdss_hdmi_ahb_clk.c),
915 CLK_LOOKUP("hdmi_core_clk", mdss_hdmi_clk.c),
916 CLK_LOOKUP("hdmi_extp_clk", mdss_extpclk_clk.c),
Channagoud Kadabi123c9722014-02-06 13:22:50 -0800917};
918
Channagoud Kadabi0d1a7dc2015-03-16 14:42:37 -0700919void msm8992_sdc1_clock_override()
920{
921 sdcc1_apps_clk_src.freq_tbl = ftbl_gcc_sdcc1_apps_clk_8992;
922}
923
Channagoud Kadabi123c9722014-02-06 13:22:50 -0800924void platform_clock_init(void)
925{
Channagoud Kadabi0d1a7dc2015-03-16 14:42:37 -0700926 if (platform_is_msm8992())
927 {
928 msm8992_sdc1_clock_override();
929 }
Channagoud Kadabi608b6a72014-04-14 13:58:03 -0700930 clk_init(msm_8994_clocks, ARRAY_SIZE(msm_8994_clocks));
Channagoud Kadabi123c9722014-02-06 13:22:50 -0800931}