Channagoud Kadabi | 7164ddf | 2015-04-09 16:27:36 -0700 | [diff] [blame] | 1 | /* Copyright (c) 2014-2015, The Linux Foundation. All rights reserved. |
Joonwoo Park | 8ef6919 | 2014-06-09 16:54:15 -0700 | [diff] [blame] | 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 | |
| 29 | #include <platform/iomap.h> |
Channagoud Kadabi | 7164ddf | 2015-04-09 16:27:36 -0700 | [diff] [blame] | 30 | #include <qusb2_phy.h> |
Joonwoo Park | 8ef6919 | 2014-06-09 16:54:15 -0700 | [diff] [blame] | 31 | #include <reg.h> |
| 32 | #include <bits.h> |
| 33 | #include <debug.h> |
Veera Sundaram Sankaran | 0018151 | 2014-12-09 11:23:39 -0800 | [diff] [blame] | 34 | #include <qtimer.h> |
Joonwoo Park | 8ef6919 | 2014-06-09 16:54:15 -0700 | [diff] [blame] | 35 | |
Channagoud Kadabi | 12b9693 | 2014-09-23 15:18:11 -0700 | [diff] [blame] | 36 | __WEAK int platform_is_msm8994() |
| 37 | { |
| 38 | return 0; |
| 39 | } |
| 40 | |
Channagoud Kadabi | 7164ddf | 2015-04-09 16:27:36 -0700 | [diff] [blame] | 41 | __WEAK int platform_is_msm8996() |
| 42 | { |
| 43 | return 0; |
| 44 | } |
| 45 | |
Joonwoo Park | 8ef6919 | 2014-06-09 16:54:15 -0700 | [diff] [blame] | 46 | void qusb2_phy_reset(void) |
| 47 | { |
| 48 | uint32_t val; |
| 49 | |
| 50 | /* Block Reset */ |
| 51 | val = readl(GCC_QUSB2_PHY_BCR) | BIT(0); |
| 52 | writel(val, GCC_QUSB2_PHY_BCR); |
| 53 | udelay(10); |
| 54 | writel(val & ~BIT(0), GCC_QUSB2_PHY_BCR); |
| 55 | |
Tanya Finkel | e7aa427 | 2014-08-08 23:41:34 +0300 | [diff] [blame] | 56 | /* set CLAMP_N_EN and stay with disabled USB PHY */ |
| 57 | writel(0x23, QUSB2PHY_PORT_POWERDOWN); |
| 58 | |
Channagoud Kadabi | 7164ddf | 2015-04-09 16:27:36 -0700 | [diff] [blame] | 59 | if (platform_is_msm8996()) |
| 60 | { |
| 61 | writel(0xF8, QUSB2PHY_PORT_TUNE1); |
| 62 | writel(0x83, QUSB2PHY_PORT_TUNE2); |
| 63 | writel(0x93, QUSB2PHY_PORT_TUNE3); |
| 64 | writel(0xC0, QUSB2PHY_PORT_TUNE4); |
| 65 | writel(0x30, QUSB2PHY_PLL_TUNE); |
| 66 | writel(0x79, QUSB2PHY_PLL_USER_CTL1); |
| 67 | writel(0x21, QUSB2PHY_PLL_USER_CTL2); |
| 68 | writel(0x14, QUSB2PHY_PORT_TEST2); |
| 69 | } |
| 70 | else |
| 71 | { |
| 72 | /* Set HS impedance to 42ohms */ |
| 73 | writel(0xA0, QUSB2PHY_PORT_TUNE1); |
Tanya Finkel | e7aa427 | 2014-08-08 23:41:34 +0300 | [diff] [blame] | 74 | |
Channagoud Kadabi | 7164ddf | 2015-04-09 16:27:36 -0700 | [diff] [blame] | 75 | /* Set TX current to 19mA, TX SR and TX bias current to 1, 1 */ |
| 76 | writel(0xA5, QUSB2PHY_PORT_TUNE2); |
Tanya Finkel | e7aa427 | 2014-08-08 23:41:34 +0300 | [diff] [blame] | 77 | |
Channagoud Kadabi | 7164ddf | 2015-04-09 16:27:36 -0700 | [diff] [blame] | 78 | /* Increase autocalibration bias circuit settling time |
| 79 | * and enable utocalibration */ |
| 80 | writel(0x81, QUSB2PHY_PORT_TUNE3); |
Tanya Finkel | e7aa427 | 2014-08-08 23:41:34 +0300 | [diff] [blame] | 81 | |
Channagoud Kadabi | 7164ddf | 2015-04-09 16:27:36 -0700 | [diff] [blame] | 82 | writel(0x85, QUSB2PHY_PORT_TUNE4); |
| 83 | } |
| 84 | |
Tanya Finkel | e7aa427 | 2014-08-08 23:41:34 +0300 | [diff] [blame] | 85 | /* Wait for tuning params to take effect right before re-enabling power*/ |
Joonwoo Park | 8ef6919 | 2014-06-09 16:54:15 -0700 | [diff] [blame] | 86 | udelay(10); |
| 87 | |
Tanya Finkel | e7aa427 | 2014-08-08 23:41:34 +0300 | [diff] [blame] | 88 | /* Disable the PHY */ |
| 89 | writel(0x23, QUSB2PHY_PORT_POWERDOWN); |
| 90 | /* Enable ULPI mode */ |
Channagoud Kadabi | 12b9693 | 2014-09-23 15:18:11 -0700 | [diff] [blame] | 91 | if (platform_is_msm8994()) |
| 92 | writel(0x0, QUSB2PHY_PORT_UTMI_CTRL2); |
Tanya Finkel | e7aa427 | 2014-08-08 23:41:34 +0300 | [diff] [blame] | 93 | /* Enable PHY */ |
| 94 | /* set CLAMP_N_EN and USB PHY is enabled*/ |
Joonwoo Park | 8ef6919 | 2014-06-09 16:54:15 -0700 | [diff] [blame] | 95 | writel(0x22, QUSB2PHY_PORT_POWERDOWN); |
| 96 | } |