blob: 5d2e7ebf974e23899515059020af9d02f36969db [file] [log] [blame]
Channagoud Kadabide6bab02015-01-21 10:39:46 -08001/* Copyright (c) 2014-2015, The Linux Foundation. All rights reserved.
Channagoud Kadabied60a8b2014-06-27 15:35:09 -07002 *
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 <stdint.h>
30#include <debug.h>
31#include <reg.h>
32#include <mmc.h>
33#include <clock.h>
34#include <platform/timer.h>
35#include <platform/clock.h>
36#include <platform/iomap.h>
37#include <pm8x41.h>
Channagoud Kadabi33686bb2015-06-29 11:59:46 -070038#include <rpm-smd.h>
39#include <regulator.h>
Siddharth Zaveri1cf08b92015-12-02 17:09:14 -050040#include <blsp_qup.h>
41#include <err.h>
Channagoud Kadabi33686bb2015-06-29 11:59:46 -070042
43#define RPM_CE_CLK_TYPE 0x6563
44#define CE1_CLK_ID 0x0
45#define RPM_SMD_KEY_RATE 0x007A484B
46
47uint32_t CE1_CLK[][8]=
48{
49 {
50 RPM_CE_CLK_TYPE, CE1_CLK_ID,
51 KEY_SOFTWARE_ENABLE, 4, GENERIC_DISABLE,
52 RPM_SMD_KEY_RATE, 4, 0,
53 },
54 {
55 RPM_CE_CLK_TYPE, CE1_CLK_ID,
56 KEY_SOFTWARE_ENABLE, 4, GENERIC_ENABLE,
57 RPM_SMD_KEY_RATE, 4, 176128, /* clk rate in KHZ */
58 },
59};
Channagoud Kadabied60a8b2014-06-27 15:35:09 -070060
61void clock_init_mmc(uint32_t interface)
62{
63 char clk_name[64];
64 int ret;
65
66 snprintf(clk_name, sizeof(clk_name), "sdc%u_iface_clk", interface);
67
68 /* enable interface clock */
69 ret = clk_get_set_enable(clk_name, 0, true);
70 if(ret)
71 {
72 dprintf(CRITICAL, "failed to set sdc%u_iface_clk ret = %d\n", interface, ret);
73 ASSERT(0);
74 }
75}
76
77/* Configure MMC clock */
78void clock_config_mmc(uint32_t interface, uint32_t freq)
79{
80 int ret = 0;
81 char clk_name[64];
82
83 snprintf(clk_name, sizeof(clk_name), "sdc%u_core_clk", interface);
84
85 if(freq == MMC_CLK_400KHZ)
86 {
87 ret = clk_get_set_enable(clk_name, 400000, true);
88 }
89 else if(freq == MMC_CLK_50MHZ)
90 {
91 ret = clk_get_set_enable(clk_name, 50000000, true);
92 }
93 else if(freq == MMC_CLK_96MHZ)
94 {
Channagoud Kadabi99d23702015-02-02 20:52:17 -080095 ret = clk_get_set_enable(clk_name, 96000000, true);
Channagoud Kadabied60a8b2014-06-27 15:35:09 -070096 }
97 else if(freq == MMC_CLK_192MHZ)
98 {
99 ret = clk_get_set_enable(clk_name, 192000000, true);
100 }
Channagoud Kadabi99d23702015-02-02 20:52:17 -0800101 else if(freq == MMC_CLK_400MHZ)
102 {
103 ret = clk_get_set_enable(clk_name, 384000000, 1);
104 }
Channagoud Kadabied60a8b2014-06-27 15:35:09 -0700105 else
106 {
107 dprintf(CRITICAL, "sdc frequency (%u) is not supported\n", freq);
108 ASSERT(0);
109 }
110
111 if(ret)
112 {
113 dprintf(CRITICAL, "failed to set sdc%u_core_clk ret = %d\n", interface, ret);
114 ASSERT(0);
115 }
116}
117
118/* Configure UART clock based on the UART block id*/
119void clock_config_uart_dm(uint8_t id)
120{
121 int ret;
122 char iclk[64];
123 char cclk[64];
124
125 snprintf(iclk, sizeof(iclk), "uart%u_iface_clk", id);
126 snprintf(cclk, sizeof(cclk), "uart%u_core_clk", id);
127
128 ret = clk_get_set_enable(iclk, 0, true);
129 if(ret)
130 {
131 dprintf(CRITICAL, "failed to set uart%u_iface_clk ret = %d\n", id, ret);
132 ASSERT(0);
133 }
134
135 ret = clk_get_set_enable(cclk, 7372800, true);
136 if(ret)
137 {
138 dprintf(CRITICAL, "failed to set uart%u_core_clk ret = %d\n", id, ret);
139 ASSERT(0);
140 }
141}
142
143/* Function to asynchronously reset CE (Crypto Engine).
144 * Function assumes that all the CE clocks are off.
145 */
146static void ce_async_reset(uint8_t instance)
147{
Channagoud Kadabi037c8b82015-02-05 12:09:32 -0800148 if (instance == 1)
149 {
150 /* Start the block reset for CE */
151 writel(1, GCC_CE1_BCR);
152 udelay(2);
153 /* Take CE block out of reset */
154 writel(0, GCC_CE1_BCR);
155 udelay(2);
156 }
157 else
158 {
159 dprintf(CRITICAL, "Unsupported CE instance: %u\n", instance);
160 ASSERT(0);
161 }
Channagoud Kadabied60a8b2014-06-27 15:35:09 -0700162}
163
164void clock_ce_enable(uint8_t instance)
165{
Channagoud Kadabi33686bb2015-06-29 11:59:46 -0700166 if (instance == 1)
167 rpm_send_data(&CE1_CLK[GENERIC_ENABLE][0], 24, RPM_REQUEST_TYPE);
168 else
169 {
170 dprintf(CRITICAL, "Unsupported CE instance: %u\n", instance);
171 ASSERT(0);
172 }
Channagoud Kadabied60a8b2014-06-27 15:35:09 -0700173}
174
175void clock_ce_disable(uint8_t instance)
176{
Channagoud Kadabi33686bb2015-06-29 11:59:46 -0700177 if (instance == 1)
178 rpm_send_data(&CE1_CLK[GENERIC_DISABLE][0], 24, RPM_REQUEST_TYPE);
179 else
180 {
181 dprintf(CRITICAL, "Unsupported CE instance: %u\n", instance);
182 ASSERT(0);
183 }
Channagoud Kadabied60a8b2014-06-27 15:35:09 -0700184}
185
186void clock_config_ce(uint8_t instance)
187{
188 /* Need to enable the clock before disabling since the clk_disable()
189 * has a check to default to nop when the clk_enable() is not called
190 * on that particular clock.
191 */
192 clock_ce_enable(instance);
193
194 clock_ce_disable(instance);
195
196 ce_async_reset(instance);
197
198 clock_ce_enable(instance);
199
200}
201
202void clock_usb30_gdsc_enable(void)
203{
204 uint32_t reg = readl(GCC_USB30_GDSCR);
205
206 reg &= ~(0x1);
207
208 writel(reg, GCC_USB30_GDSCR);
209}
210
Tanya Finkel0df43632016-05-31 13:02:35 +0300211/* enables usb20 clocks */
212void clock_usb20_init(void)
213{
214 int ret;
215
216 ret = clk_get_set_enable("usb20_noc_usb20_clk", 0, true);
217 if(ret)
218 {
219 dprintf(CRITICAL, "failed to set usb20_noc_clk. ret = %d\n", ret);
220 ASSERT(0);
221 }
222
223 ret = clk_get_set_enable("usb20_master_clk", 120000000, true);
224 if(ret)
225 {
226 dprintf(CRITICAL, "failed to set usb20_master_clk. ret = %d\n", ret);
227 ASSERT(0);
228 }
229
230 ret = clk_get_set_enable("usb20_mock_utmi_clk", 60000000, true);
231 if(ret)
232 {
233 dprintf(CRITICAL, "failed to set usb20_mock_utmi_clk ret = %d\n", ret);
234 ASSERT(0);
235 }
236
237 ret = clk_get_set_enable("usb20_sleep_clk", 0, true);
238 if(ret)
239 {
240 dprintf(CRITICAL, "failed to set usb2_sleep_clk ret = %d\n", ret);
241 ASSERT(0);
242 }
243}
244
Channagoud Kadabied60a8b2014-06-27 15:35:09 -0700245/* enables usb30 clocks */
246void clock_usb30_init(void)
247{
248 int ret;
249
250 ret = clk_get_set_enable("usb30_iface_clk", 0, true);
251 if(ret)
252 {
253 dprintf(CRITICAL, "failed to set usb30_iface_clk. ret = %d\n", ret);
254 ASSERT(0);
255 }
256
257 clock_usb30_gdsc_enable();
258
Channagoud Kadabidf233d22015-02-11 11:56:48 -0800259 ret = clk_get_set_enable("usb30_master_clk", 150000000, true);
Channagoud Kadabied60a8b2014-06-27 15:35:09 -0700260 if(ret)
261 {
262 dprintf(CRITICAL, "failed to set usb30_master_clk. ret = %d\n", ret);
263 ASSERT(0);
264 }
265
Channagoud Kadabidf233d22015-02-11 11:56:48 -0800266 ret = clk_get_set_enable("gcc_aggre2_usb3_axi_clk", 150000000, true);
267 if (ret)
268 {
269 dprintf(CRITICAL, "failed to set aggre2_usb3_axi_clk, ret = %d\n", ret);
270 ASSERT(0);
271 }
272
Channagoud Kadabied60a8b2014-06-27 15:35:09 -0700273 ret = clk_get_set_enable("usb30_phy_aux_clk", 1200000, true);
274 if(ret)
275 {
276 dprintf(CRITICAL, "failed to set usb30_phy_aux_clk. ret = %d\n", ret);
277 ASSERT(0);
278 }
279
280 ret = clk_get_set_enable("usb30_mock_utmi_clk", 60000000, true);
281 if(ret)
282 {
283 dprintf(CRITICAL, "failed to set usb30_mock_utmi_clk ret = %d\n", ret);
284 ASSERT(0);
285 }
286
287 ret = clk_get_set_enable("usb30_sleep_clk", 0, true);
288 if(ret)
289 {
290 dprintf(CRITICAL, "failed to set usb30_sleep_clk ret = %d\n", ret);
291 ASSERT(0);
292 }
293
294 ret = clk_get_set_enable("usb_phy_cfg_ahb2phy_clk", 0, true);
295 if(ret)
296 {
297 dprintf(CRITICAL, "failed to enable usb_phy_cfg_ahb2phy_clk = %d\n", ret);
298 ASSERT(0);
299 }
Channagoud Kadabied60a8b2014-06-27 15:35:09 -0700300}
301
302void clock_bumpup_pipe3_clk()
303{
304 int ret = 0;
305
306 ret = clk_get_set_enable("usb30_pipe_clk", 0, true);
307 if(ret)
308 {
309 dprintf(CRITICAL, "failed to set usb30_pipe_clk. ret = %d\n", ret);
310 ASSERT(0);
311 }
312
313 return;
314}
315
316void clock_reset_usb_phy()
317{
318 int ret;
319
320 struct clk *phy_reset_clk = NULL;
321 struct clk *pipe_reset_clk = NULL;
Channagoud Kadabia42fb7d2015-06-24 12:50:01 -0700322 struct clk *master_clk = NULL;
323
324 master_clk = clk_get("usb30_master_clk");
325 ASSERT(master_clk);
Channagoud Kadabied60a8b2014-06-27 15:35:09 -0700326
327 /* Look if phy com clock is present */
328 phy_reset_clk = clk_get("usb30_phy_reset");
329 ASSERT(phy_reset_clk);
330
331 pipe_reset_clk = clk_get("usb30_pipe_clk");
332 ASSERT(pipe_reset_clk);
333
334 /* ASSERT */
Channagoud Kadabia42fb7d2015-06-24 12:50:01 -0700335 ret = clk_reset(master_clk, CLK_RESET_ASSERT);
336 if (ret)
337 {
338 dprintf(CRITICAL, "Failed to assert usb30_master_reset clk\n");
339 return;
340 }
Channagoud Kadabied60a8b2014-06-27 15:35:09 -0700341 ret = clk_reset(phy_reset_clk, CLK_RESET_ASSERT);
342
343 if (ret)
344 {
345 dprintf(CRITICAL, "Failed to assert usb30_phy_reset clk\n");
Channagoud Kadabia42fb7d2015-06-24 12:50:01 -0700346 goto deassert_master_clk;
Channagoud Kadabied60a8b2014-06-27 15:35:09 -0700347 }
348
349 ret = clk_reset(pipe_reset_clk, CLK_RESET_ASSERT);
350 if (ret)
351 {
352 dprintf(CRITICAL, "Failed to assert usb30_pipe_clk\n");
353 goto deassert_phy_clk;
354 }
355
356 udelay(100);
357
358 /* DEASSERT */
359 ret = clk_reset(pipe_reset_clk, CLK_RESET_DEASSERT);
360 if (ret)
361 {
362 dprintf(CRITICAL, "Failed to deassert usb_pipe_clk\n");
363 return;
364 }
365
366deassert_phy_clk:
367
368 ret = clk_reset(phy_reset_clk, CLK_RESET_DEASSERT);
369 if (ret)
370 {
371 dprintf(CRITICAL, "Failed to deassert usb30_phy_com_reset clk\n");
372 return;
373 }
Channagoud Kadabia42fb7d2015-06-24 12:50:01 -0700374deassert_master_clk:
375
376 ret = clk_reset(master_clk, CLK_RESET_DEASSERT);
377 if (ret)
378 {
379 dprintf(CRITICAL, "Failed to deassert usb30_master clk\n");
380 return;
381 }
382
Channagoud Kadabied60a8b2014-06-27 15:35:09 -0700383}
Dhaval Patel0f3cbeb2015-03-17 11:52:12 -0700384
385void mmss_gdsc_enable()
386{
387 uint32_t reg = 0;
388
389 reg = readl(MMAGIC_BIMC_GDSCR);
390 if (!(reg & GDSC_POWER_ON_BIT)) {
391 reg &= ~(BIT(0) | GDSC_EN_FEW_WAIT_MASK);
392 reg |= GDSC_EN_FEW_WAIT_256_MASK;
393 writel(reg, MMAGIC_BIMC_GDSCR);
394 while(!(readl(MMAGIC_BIMC_GDSCR) & (GDSC_POWER_ON_BIT)));
395 } else {
396 dprintf(SPEW, "MMAGIC BIMC GDSC already enabled\n");
397 }
398
399 reg = readl(MMAGIC_MDSS_GDSCR);
400 if (!(reg & GDSC_POWER_ON_BIT)) {
401 reg &= ~(BIT(0) | GDSC_EN_FEW_WAIT_MASK);
402 reg |= GDSC_EN_FEW_WAIT_256_MASK;
403 writel(reg, MMAGIC_MDSS_GDSCR);
404 while(!(readl(MMAGIC_MDSS_GDSCR) & (GDSC_POWER_ON_BIT)));
405 } else {
406 dprintf(SPEW, "MMAGIC MDSS GDSC already enabled\n");
407 }
408
409 reg = readl(MDSS_GDSCR);
410 if (!(reg & GDSC_POWER_ON_BIT)) {
411 reg &= ~(BIT(0) | GDSC_EN_FEW_WAIT_MASK);
412 reg |= GDSC_EN_FEW_WAIT_256_MASK;
413 writel(reg, MDSS_GDSCR);
414 while(!(readl(MDSS_GDSCR) & (GDSC_POWER_ON_BIT)));
415 } else {
416 dprintf(SPEW, "MDSS GDSC already enabled\n");
417 }
418}
419
420void mmss_gdsc_disable()
421{
422 uint32_t reg = 0;
423
424 reg = readl(MDSS_GDSCR);
425 reg |= BIT(0);
426 writel(reg, MDSS_GDSCR);
427 while(readl(MDSS_GDSCR) & (GDSC_POWER_ON_BIT));
428
429 reg = readl(MMAGIC_MDSS_GDSCR);
430 reg |= BIT(0);
431 writel(reg, MMAGIC_MDSS_GDSCR);
432 while(readl(MMAGIC_MDSS_GDSCR) & (GDSC_POWER_ON_BIT));
433
434 reg = readl(MMAGIC_BIMC_GDSCR);
435 reg |= BIT(0);
436 writel(reg, MMAGIC_BIMC_GDSCR);
437 while(readl(MMAGIC_BIMC_GDSCR) & (GDSC_POWER_ON_BIT));
438}
439
440void video_gdsc_enable()
441{
442 uint32_t reg = 0;
443
444 reg = readl(MMAGIC_VIDEO_GDSCR);
445 if (!(reg & GDSC_POWER_ON_BIT)) {
446 reg &= ~(BIT(0) | GDSC_EN_FEW_WAIT_MASK);
447 reg |= GDSC_EN_FEW_WAIT_256_MASK;
448 writel(reg, MMAGIC_VIDEO_GDSCR);
449 while(!(readl(MMAGIC_VIDEO_GDSCR) & (GDSC_POWER_ON_BIT)));
450 } else {
451 dprintf(SPEW, "VIDEO BIMC GDSC already enabled\n");
452 }
453
454 reg = readl(VIDEO_GDSCR);
455 if (!(reg & GDSC_POWER_ON_BIT)) {
456 reg &= ~(BIT(0) | GDSC_EN_FEW_WAIT_MASK);
457 reg |= GDSC_EN_FEW_WAIT_256_MASK;
458 writel(reg, VIDEO_GDSCR);
459 while(!(readl(VIDEO_GDSCR) & (GDSC_POWER_ON_BIT)));
460 } else {
461 dprintf(SPEW, "VIDEO GDSC already enabled\n");
462 }
463}
464
465void video_gdsc_disable()
466{
467 uint32_t reg = 0;
468
469 reg = readl(VIDEO_GDSCR);
470 reg |= BIT(0);
471 writel(reg, VIDEO_GDSCR);
472 while(readl(VIDEO_GDSCR) & (GDSC_POWER_ON_BIT));
473
474 reg = readl(MMAGIC_VIDEO_GDSCR);
475 reg |= BIT(0);
476 writel(reg, MMAGIC_VIDEO_GDSCR);
477 while(readl(MMAGIC_VIDEO_GDSCR) & (GDSC_POWER_ON_BIT));
478}
479
480/* Configure MDP clock */
481void mdp_clock_enable(void)
482{
483 int ret;
484
485 ret = clk_get_set_enable("mmss_mmagic_ahb_clk", 19200000, 1);
486 if(ret)
487 {
488 dprintf(CRITICAL, "failed to set mmagic_ahb_clk ret = %d\n", ret);
489 ASSERT(0);
490 }
491
492 ret = clk_get_set_enable("smmu_mdp_ahb_clk", 0, 1);
493 if(ret)
494 {
495 dprintf(CRITICAL, "failed to set smmu_mdp_ahb_clk ret = %d\n", ret);
496 ASSERT(0);
497 }
498
499 ret = clk_get_set_enable("mdp_ahb_clk", 0, 1);
500 if(ret)
501 {
502 dprintf(CRITICAL, "failed to set mdp_ahb_clk ret = %d\n", ret);
503 ASSERT(0);
504 }
505
506 ret = clk_get_set_enable("mdss_mdp_clk", 320000000, 1);
507 if(ret)
508 {
509 dprintf(CRITICAL, "failed to set mdp_clk_src ret = %d\n", ret);
510 ASSERT(0);
511 }
512
513 ret = clk_get_set_enable("mdss_vsync_clk", 0, 1);
514 if(ret)
515 {
516 dprintf(CRITICAL, "failed to set mdss vsync clk ret = %d\n", ret);
517 ASSERT(0);
518 }
519
520}
521
522void mdp_clock_disable()
523{
524 clk_disable(clk_get("mdss_vsync_clk"));
525 clk_disable(clk_get("mdss_mdp_clk"));
526 clk_disable(clk_get("mdp_ahb_clk"));
527 clk_disable(clk_get("smmu_mdp_ahb_clk"));
528 clk_disable(clk_get("mmss_mmagic_ahb_clk"));
529}
530
531void mmss_bus_clock_enable(void)
532{
533 int ret;
534 ret = clk_get_set_enable("mmss_mmagic_axi_clk", 320000000, 1);
535 if(ret)
536 {
537 dprintf(CRITICAL, "failed to set mmss_mmagic_axi_clk ret = %d\n", ret);
538 ASSERT(0);
539 }
540
541 ret = clk_get_set_enable("mmagic_bimc_axi_clk", 320000000, 1);
542 if(ret)
543 {
544 dprintf(CRITICAL, "failed to set mmss_s0_axi_clk ret = %d\n", ret);
545 ASSERT(0);
546 }
547
548 ret = clk_get_set_enable("mmss_s0_axi_clk", 320000000, 1);
549 if(ret)
550 {
551 dprintf(CRITICAL, "failed to set mmss_s0_axi_clk ret = %d\n", ret);
552 ASSERT(0);
553 }
554
555 ret = clk_get_set_enable("mmagic_mdss_axi_clk", 320000000, 1);
556 if(ret)
557 {
558 dprintf(CRITICAL, "failed to set mmss_mmagic_axi_clk ret = %d\n", ret);
559 ASSERT(0);
560 }
561
562 ret = clk_get_set_enable("smmu_mdp_axi_clk", 320000000, 1);
563 if(ret)
564 {
565 dprintf(CRITICAL, "failed to set smmu_mdp_axi_clk ret = %d\n", ret);
566 ASSERT(0);
567 }
568
569 ret = clk_get_set_enable("mdss_axi_clk", 320000000, 1);
570 if(ret)
571 {
572 dprintf(CRITICAL, "failed to set mdss_axi_clk ret = %d\n", ret);
573 ASSERT(0);
574 }
575}
576
577void mmss_bus_clock_disable(void)
578{
579 clk_disable(clk_get("mdss_axi_clk"));
580 clk_disable(clk_get("smmu_mdp_axi_clk"));
581 clk_disable(clk_get("mmagic_mdss_axi_clk"));
582 clk_disable(clk_get("mmss_s0_axi_clk"));
583 clk_disable(clk_get("mmagic_bimc_axi_clk"));
584 clk_disable(clk_get("mmss_mmagic_axi_clk"));
585}
586
Aravind Venkateswaran9586be62015-05-20 00:51:06 -0700587void mmss_dsi_clock_enable(uint32_t cfg_rcgr, uint32_t flags)
Dhaval Patel0f3cbeb2015-03-17 11:52:12 -0700588{
589 int ret;
590
591 if (flags & MMSS_DSI_CLKS_FLAG_DSI0) {
592 /* Enable DSI0 branch clocks */
593
Aravind Venkateswaran9586be62015-05-20 00:51:06 -0700594 writel(cfg_rcgr, DSI_BYTE0_CFG_RCGR);
Dhaval Patel0f3cbeb2015-03-17 11:52:12 -0700595 writel(0x1, DSI_BYTE0_CMD_RCGR);
596 writel(0x1, DSI_BYTE0_CBCR);
597
Aravind Venkateswaran9586be62015-05-20 00:51:06 -0700598 writel(cfg_rcgr, DSI_PIXEL0_CFG_RCGR);
Dhaval Patel0f3cbeb2015-03-17 11:52:12 -0700599 writel(0x1, DSI_PIXEL0_CMD_RCGR);
600 writel(0x1, DSI_PIXEL0_CBCR);
601
602 ret = clk_get_set_enable("mdss_esc0_clk", 0, 1);
603 if(ret)
604 {
605 dprintf(CRITICAL, "failed to set esc0_clk ret = %d\n", ret);
606 ASSERT(0);
607 }
608 }
609
610 if (flags & MMSS_DSI_CLKS_FLAG_DSI1) {
611 /* Enable DSI1 branch clocks */
Aravind Venkateswaran9586be62015-05-20 00:51:06 -0700612 writel(cfg_rcgr, DSI_BYTE1_CFG_RCGR);
Dhaval Patel0f3cbeb2015-03-17 11:52:12 -0700613 writel(0x1, DSI_BYTE1_CMD_RCGR);
614 writel(0x1, DSI_BYTE1_CBCR);
615
Aravind Venkateswaran9586be62015-05-20 00:51:06 -0700616 writel(cfg_rcgr, DSI_PIXEL1_CFG_RCGR);
Dhaval Patel0f3cbeb2015-03-17 11:52:12 -0700617 writel(0x1, DSI_PIXEL1_CMD_RCGR);
618 writel(0x1, DSI_PIXEL1_CBCR);
619
620 ret = clk_get_set_enable("mdss_esc1_clk", 0, 1);
621 if(ret)
622 {
623 dprintf(CRITICAL, "failed to set esc1_clk ret = %d\n", ret);
624 ASSERT(0);
625 }
626 }
627}
628
629void mmss_dsi_clock_disable(uint32_t flags)
630{
631 if (flags & MMSS_DSI_CLKS_FLAG_DSI0) {
632 clk_disable(clk_get("mdss_esc0_clk"));
633 writel(0x0, DSI_BYTE0_CBCR);
634 writel(0x0, DSI_PIXEL0_CBCR);
635 }
636
637 if (flags & MMSS_DSI_CLKS_FLAG_DSI1) {
638 clk_disable(clk_get("mdss_esc1_clk"));
639 writel(0x0, DSI_BYTE1_CBCR);
640 writel(0x0, DSI_PIXEL1_CBCR);
641 }
642}
Siddharth Zaveri1cf08b92015-12-02 17:09:14 -0500643
644
645void clock_config_blsp_i2c(uint8_t blsp_id, uint8_t qup_id)
646{
647 uint8_t ret = 0;
648 char clk_name[64];
649
650 struct clk *qup_clk;
651
652 if((blsp_id != BLSP_ID_2) || ((qup_id != QUP_ID_1) &&
653 (qup_id != QUP_ID_3))) {
654 dprintf(CRITICAL, "Incorrect BLSP-%d or QUP-%d configuration\n",
655 blsp_id, qup_id);
656 ASSERT(0);
657 }
658
659 if (qup_id == QUP_ID_1) {
660 snprintf(clk_name, sizeof(clk_name), "blsp2_qup2_ahb_iface_clk");
661 }
662 else if (qup_id == QUP_ID_3) {
663 snprintf(clk_name, sizeof(clk_name), "blsp1_qup4_ahb_iface_clk");
664 }
665
666 ret = clk_get_set_enable(clk_name, 0 , 1);
667 if (ret) {
668 dprintf(CRITICAL, "Failed to enable %s clock\n", clk_name);
669 return;
670 }
671
672 if (qup_id == QUP_ID_1) {
673 snprintf(clk_name, sizeof(clk_name), "gcc_blsp2_qup2_i2c_apps_clk");
674 }
675 else if (qup_id == QUP_ID_3) {
676 snprintf(clk_name, sizeof(clk_name), "gcc_blsp1_qup4_i2c_apps_clk");
677 }
678
679 qup_clk = clk_get(clk_name);
680 if (!qup_clk) {
681 dprintf(CRITICAL, "Failed to get %s\n", clk_name);
682 return;
683 }
684
685 ret = clk_enable(qup_clk);
686 if (ret) {
687 dprintf(CRITICAL, "Failed to enable %s\n", clk_name);
688 return;
689 }
690}