Amol Jadi | 42d7b5a | 2012-05-04 14:50:32 -0700 | [diff] [blame] | 1 | /* |
sundarajan srinivasan | aa1992d | 2013-03-28 18:03:23 -0700 | [diff] [blame] | 2 | * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved. |
Amol Jadi | 42d7b5a | 2012-05-04 14:50:32 -0700 | [diff] [blame] | 3 | * |
| 4 | * Redistribution and use in source and binary forms, with or without |
Amol Jadi | b726c3b | 2012-09-13 13:51:23 -0700 | [diff] [blame] | 5 | * 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 Jadi | 42d7b5a | 2012-05-04 14:50:32 -0700 | [diff] [blame] | 15 | * |
Amol Jadi | b726c3b | 2012-09-13 13:51:23 -0700 | [diff] [blame] | 16 | * 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 Jadi | 42d7b5a | 2012-05-04 14:50:32 -0700 | [diff] [blame] | 27 | */ |
| 28 | |
Amol Jadi | b726c3b | 2012-09-13 13:51:23 -0700 | [diff] [blame] | 29 | #include <err.h> |
| 30 | #include <assert.h> |
| 31 | #include <debug.h> |
| 32 | #include <reg.h> |
| 33 | #include <clock.h> |
Amol Jadi | 42d7b5a | 2012-05-04 14:50:32 -0700 | [diff] [blame] | 34 | #include <platform/clock.h> |
Amol Jadi | b726c3b | 2012-09-13 13:51:23 -0700 | [diff] [blame] | 35 | #include <platform/iomap.h> |
| 36 | #include <platform/timer.h> |
Amol Jadi | 42d7b5a | 2012-05-04 14:50:32 -0700 | [diff] [blame] | 37 | |
| 38 | void hsusb_clock_init(void) |
| 39 | { |
Amol Jadi | b726c3b | 2012-09-13 13:51:23 -0700 | [diff] [blame] | 40 | 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 Jadi | b726c3b | 2012-09-13 13:51:23 -0700 | [diff] [blame] | 50 | /* 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 Dinamani | dca5c66 | 2012-12-03 14:13:07 -0800 | [diff] [blame] | 82 | void 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 | |