blob: bd068ad4e890fd27afefc7261d08e2d8b823924a [file] [log] [blame]
vijay kumarca1672a2015-04-09 16:45:40 +05301/* Copyright (c) 2015, The Linux Foundation. All rights reserved.
2 *
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#include <err.h>
29#include <assert.h>
30#include <debug.h>
31#include <reg.h>
32#include <platform/timer.h>
33#include <platform/iomap.h>
34#include <clock.h>
35#include <platform/clock.h>
36#include <platform.h>
37
38void hsusb_clock_init(void)
39{
vijay kumar20627da2015-10-01 13:28:58 +053040 int ret;
41 struct clk *iclk, *cclk;
vijay kumarca1672a2015-04-09 16:45:40 +053042
vijay kumar20627da2015-10-01 13:28:58 +053043 ret = clk_get_set_enable("usb_iface_clk", 0, 1);
44 if(ret)
45 {
46 dprintf(CRITICAL, "failed to set usb_iface_clk ret = %d\n", ret);
47 ASSERT(0);
48 }
49
50 ret = clk_get_set_enable("usb_core_clk", 133330000, 1);
51 if(ret)
52 {
53 dprintf(CRITICAL, "failed to set usb_core_clk ret = %d\n", ret);
54 ASSERT(0);
55 }
56
57 mdelay(20);
58
59 iclk = clk_get("usb_iface_clk");
60 cclk = clk_get("usb_core_clk");
61
62 clk_disable(iclk);
63 clk_disable(cclk);
64
65 mdelay(20);
66
67 /* Start the block reset for usb */
68 writel(1, USB_HS_BCR);
69
70 mdelay(20);
71
72 /* Take usb block out of reset */
73 writel(0, USB_HS_BCR);
74
75 mdelay(20);
76
77 ret = clk_enable(iclk);
78
79 if(ret)
80 {
81 dprintf(CRITICAL, "failed to set usb_iface_clk after async ret = %d\n", ret);
82 ASSERT(0);
83 }
84
85 ret = clk_enable(cclk);
86
87 if(ret)
88 {
89 dprintf(CRITICAL, "failed to set usb_iface_clk after async ret = %d\n", ret);
90 ASSERT(0);
91 }
vijay kumarca1672a2015-04-09 16:45:40 +053092}
93
94/* Configure UART clock based on the UART block id*/
95void clock_config_uart_dm(uint8_t id)
96{
vijay kumar20627da2015-10-01 13:28:58 +053097 int ret;
98 char iclk[64];
99 char cclk[64];
vijay kumarca1672a2015-04-09 16:45:40 +0530100
vijay kumar20627da2015-10-01 13:28:58 +0530101 snprintf(iclk, sizeof(iclk), "uart%u_iface_clk", id);
102 snprintf(cclk, sizeof(cclk), "uart%u_core_clk", id);
103
104 ret = clk_get_set_enable(iclk, 0, 1);
105 if(ret)
106 {
107 dprintf(CRITICAL, "failed to set %s ret = %d\n", iclk, ret);
108 ASSERT(0);
109 }
110
111 ret = clk_get_set_enable(cclk, 7372800, 1);
112 if(ret)
113 {
114 dprintf(CRITICAL, "failed to set %s ret = %d\n", cclk, ret);
115 ASSERT(0);
116 }
vijay kumarca1672a2015-04-09 16:45:40 +0530117}