blob: 5812db6b6e22b1f10284d7f0e87f48f6ff111dff [file] [log] [blame]
Amol Jadi42d7b5a2012-05-04 14:50:32 -07001/*
sundarajan srinivasanaa1992d2013-03-28 18:03:23 -07002 * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
Amol Jadi42d7b5a2012-05-04 14:50:32 -07003 *
4 * Redistribution and use in source and binary forms, with or without
Amol Jadib726c3b2012-09-13 13:51:23 -07005 * modification, are permitted provided that the following conditions are 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 copyright
9 * notice, this list of conditions and the following disclaimer in the
10 * documentation and/or other materials provided with the distribution.
11 * * Neither the name of Linux Foundation nor
12 * the names of its contributors may be used to endorse or promote
13 * products derived from this software without specific prior written
14 * permission.
Amol Jadi42d7b5a2012-05-04 14:50:32 -070015 *
Amol Jadib726c3b2012-09-13 13:51:23 -070016 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
20 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
23 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
25 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
26 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Amol Jadi42d7b5a2012-05-04 14:50:32 -070027 */
28
Amol Jadib726c3b2012-09-13 13:51:23 -070029#include <err.h>
30#include <assert.h>
31#include <debug.h>
32#include <reg.h>
33#include <clock.h>
Amol Jadi42d7b5a2012-05-04 14:50:32 -070034#include <platform/clock.h>
Amol Jadib726c3b2012-09-13 13:51:23 -070035#include <platform/iomap.h>
36#include <platform/timer.h>
Amol Jadi42d7b5a2012-05-04 14:50:32 -070037
38void hsusb_clock_init(void)
39{
Amol Jadib726c3b2012-09-13 13:51:23 -070040 int ret;
41 struct clk *iclk;
42 struct clk *cclk;
43
44 iclk = clk_get("usb_iface_clk");
45 cclk = clk_get("usb_core_clk");
46
47 ASSERT(iclk);
48 ASSERT(cclk);
49
Amol Jadib726c3b2012-09-13 13:51:23 -070050 /* Disable interface and core clk */
51 clk_disable(iclk);
52 clk_disable(cclk);
53
54 /* Start the block reset for usb */
55 writel(1, USB_HS_BCR);
56
57 /* Take usb block out of reset */
58 writel(0, USB_HS_BCR);
59
60 ret = clk_enable(iclk);
61 if(ret)
62 {
63 dprintf(CRITICAL, "failed to set usb_iface_clk ret = %d\n", ret);
64 ASSERT(0);
65 }
66
67 ret = clk_set_rate(cclk, 75000000);
68 if(ret)
69 {
70 dprintf(CRITICAL, "failed to set_rate of usb_core_clk ret = %d\n", ret);
71 ASSERT(0);
72 }
73
74 ret = clk_enable(cclk);
75 if(ret)
76 {
77 dprintf(CRITICAL, "failed to enable usb_core_clk ret = %d\n", ret);
78 ASSERT(0);
79 }
80}
81
Deepa Dinamanidca5c662012-12-03 14:13:07 -080082void clock_config_uart_dm(uint8_t id)
83{
84 int ret;
85 char clk_name[64];
86
87 ret = clk_get_set_enable("uart_iface_clk", 0, 1);
88 if (ret)
89 {
90 dprintf(CRITICAL, "failed to set uart_iface_clk ret = %d\n", ret);
91 ASSERT(0);
92 }
93
94 snprintf(clk_name, 64, "uart%u_core_clk", id);
95
96 ret = clk_get_set_enable(clk_name, 7372800, 1);
97 if (ret)
98 {
99 dprintf(CRITICAL, "failed to set uart%u_core_clk ret = %d\n", id, ret);
100 ASSERT(0);
101 }
102}
103