Saravana Kannan | c85ecf9 | 2013-01-21 17:58:35 -0800 | [diff] [blame] | 1 | /* Copyright (c) 2012-2013, The Linux Foundation. All rights reserved. |
Chandan Uddaraju | 09adf32 | 2012-08-16 02:55:23 -0700 | [diff] [blame] | 2 | * |
| 3 | * This program is free software; you can redistribute it and/or modify |
| 4 | * it under the terms of the GNU General Public License version 2 and |
| 5 | * only version 2 as published by the Free Software Foundation. |
| 6 | * |
| 7 | * This program is distributed in the hope that it will be useful, |
| 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 10 | * GNU General Public License for more details. |
| 11 | */ |
| 12 | |
| 13 | #include <linux/kernel.h> |
| 14 | #include <linux/io.h> |
| 15 | #include <linux/err.h> |
| 16 | #include <linux/delay.h> |
| 17 | #include <linux/string.h> |
| 18 | #include <linux/iopoll.h> |
| 19 | #include <linux/clk.h> |
| 20 | |
| 21 | #include <asm/processor.h> |
| 22 | #include <mach/msm_iomap.h> |
Matt Wagantall | 33d01f5 | 2012-02-23 23:27:44 -0800 | [diff] [blame] | 23 | #include <mach/clk-provider.h> |
Chandan Uddaraju | 09adf32 | 2012-08-16 02:55:23 -0700 | [diff] [blame] | 24 | |
Chandan Uddaraju | 09adf32 | 2012-08-16 02:55:23 -0700 | [diff] [blame] | 25 | #include "clock-mdss-8974.h" |
| 26 | |
Abhishek Kharbanda | c155984 | 2012-08-13 18:45:02 -0700 | [diff] [blame] | 27 | #define REG_R(addr) readl_relaxed(addr) |
| 28 | #define REG_W(data, addr) writel_relaxed(data, addr) |
| 29 | |
Matt Wagantall | 7cf535b | 2013-02-28 16:16:51 -0800 | [diff] [blame] | 30 | #define GDSC_PHYS 0xFD8C2304 |
| 31 | #define GDSC_SIZE 0x4 |
| 32 | |
Abhishek Kharbanda | c155984 | 2012-08-13 18:45:02 -0700 | [diff] [blame] | 33 | #define DSI_PHY_PHYS 0xFD922800 |
| 34 | #define DSI_PHY_SIZE 0x00000800 |
| 35 | |
| 36 | #define HDMI_PHY_PHYS 0xFD922500 |
| 37 | #define HDMI_PHY_SIZE 0x0000007C |
| 38 | |
| 39 | #define HDMI_PHY_PLL_PHYS 0xFD922700 |
| 40 | #define HDMI_PHY_PLL_SIZE 0x000000D4 |
| 41 | |
| 42 | /* hdmi phy registers */ |
Ujwal Patel | c801765 | 2012-11-15 18:03:01 -0800 | [diff] [blame] | 43 | #define HDMI_PHY_ANA_CFG0 (0x0000) |
| 44 | #define HDMI_PHY_ANA_CFG1 (0x0004) |
| 45 | #define HDMI_PHY_ANA_CFG2 (0x0008) |
| 46 | #define HDMI_PHY_ANA_CFG3 (0x000C) |
| 47 | #define HDMI_PHY_PD_CTRL0 (0x0010) |
| 48 | #define HDMI_PHY_PD_CTRL1 (0x0014) |
| 49 | #define HDMI_PHY_GLB_CFG (0x0018) |
| 50 | #define HDMI_PHY_DCC_CFG0 (0x001C) |
| 51 | #define HDMI_PHY_DCC_CFG1 (0x0020) |
| 52 | #define HDMI_PHY_TXCAL_CFG0 (0x0024) |
| 53 | #define HDMI_PHY_TXCAL_CFG1 (0x0028) |
| 54 | #define HDMI_PHY_TXCAL_CFG2 (0x002C) |
| 55 | #define HDMI_PHY_TXCAL_CFG3 (0x0030) |
| 56 | #define HDMI_PHY_BIST_CFG0 (0x0034) |
| 57 | #define HDMI_PHY_BIST_CFG1 (0x0038) |
| 58 | #define HDMI_PHY_BIST_PATN0 (0x003C) |
| 59 | #define HDMI_PHY_BIST_PATN1 (0x0040) |
| 60 | #define HDMI_PHY_BIST_PATN2 (0x0044) |
| 61 | #define HDMI_PHY_BIST_PATN3 (0x0048) |
| 62 | #define HDMI_PHY_STATUS (0x005C) |
Abhishek Kharbanda | c155984 | 2012-08-13 18:45:02 -0700 | [diff] [blame] | 63 | |
| 64 | /* hdmi phy unified pll registers */ |
Ujwal Patel | c801765 | 2012-11-15 18:03:01 -0800 | [diff] [blame] | 65 | #define HDMI_UNI_PLL_REFCLK_CFG (0x0000) |
| 66 | #define HDMI_UNI_PLL_POSTDIV1_CFG (0x0004) |
| 67 | #define HDMI_UNI_PLL_CHFPUMP_CFG (0x0008) |
| 68 | #define HDMI_UNI_PLL_VCOLPF_CFG (0x000C) |
| 69 | #define HDMI_UNI_PLL_VREG_CFG (0x0010) |
| 70 | #define HDMI_UNI_PLL_PWRGEN_CFG (0x0014) |
| 71 | #define HDMI_UNI_PLL_GLB_CFG (0x0020) |
| 72 | #define HDMI_UNI_PLL_POSTDIV2_CFG (0x0024) |
| 73 | #define HDMI_UNI_PLL_POSTDIV3_CFG (0x0028) |
| 74 | #define HDMI_UNI_PLL_LPFR_CFG (0x002C) |
| 75 | #define HDMI_UNI_PLL_LPFC1_CFG (0x0030) |
| 76 | #define HDMI_UNI_PLL_LPFC2_CFG (0x0034) |
| 77 | #define HDMI_UNI_PLL_SDM_CFG0 (0x0038) |
| 78 | #define HDMI_UNI_PLL_SDM_CFG1 (0x003C) |
| 79 | #define HDMI_UNI_PLL_SDM_CFG2 (0x0040) |
| 80 | #define HDMI_UNI_PLL_SDM_CFG3 (0x0044) |
| 81 | #define HDMI_UNI_PLL_SDM_CFG4 (0x0048) |
| 82 | #define HDMI_UNI_PLL_SSC_CFG0 (0x004C) |
| 83 | #define HDMI_UNI_PLL_SSC_CFG1 (0x0050) |
| 84 | #define HDMI_UNI_PLL_SSC_CFG2 (0x0054) |
| 85 | #define HDMI_UNI_PLL_SSC_CFG3 (0x0058) |
| 86 | #define HDMI_UNI_PLL_LKDET_CFG0 (0x005C) |
| 87 | #define HDMI_UNI_PLL_LKDET_CFG1 (0x0060) |
| 88 | #define HDMI_UNI_PLL_LKDET_CFG2 (0x0064) |
| 89 | #define HDMI_UNI_PLL_CAL_CFG0 (0x006C) |
| 90 | #define HDMI_UNI_PLL_CAL_CFG1 (0x0070) |
| 91 | #define HDMI_UNI_PLL_CAL_CFG2 (0x0074) |
| 92 | #define HDMI_UNI_PLL_CAL_CFG3 (0x0078) |
| 93 | #define HDMI_UNI_PLL_CAL_CFG4 (0x007C) |
| 94 | #define HDMI_UNI_PLL_CAL_CFG5 (0x0080) |
| 95 | #define HDMI_UNI_PLL_CAL_CFG6 (0x0084) |
| 96 | #define HDMI_UNI_PLL_CAL_CFG7 (0x0088) |
| 97 | #define HDMI_UNI_PLL_CAL_CFG8 (0x008C) |
| 98 | #define HDMI_UNI_PLL_CAL_CFG9 (0x0090) |
| 99 | #define HDMI_UNI_PLL_CAL_CFG10 (0x0094) |
| 100 | #define HDMI_UNI_PLL_CAL_CFG11 (0x0098) |
| 101 | #define HDMI_UNI_PLL_STATUS (0x00C0) |
Chandan Uddaraju | 09adf32 | 2012-08-16 02:55:23 -0700 | [diff] [blame] | 102 | |
| 103 | #define VCO_CLK 424000000 |
| 104 | static unsigned char *mdss_dsi_base; |
Matt Wagantall | 7cf535b | 2013-02-28 16:16:51 -0800 | [diff] [blame] | 105 | static unsigned char *gdsc_base; |
Chandan Uddaraju | 09adf32 | 2012-08-16 02:55:23 -0700 | [diff] [blame] | 106 | static int pll_byte_clk_rate; |
| 107 | static int pll_pclk_rate; |
| 108 | static int pll_initialized; |
| 109 | static struct clk *mdss_dsi_ahb_clk; |
Chandan Uddaraju | 62e5b92 | 2012-09-14 20:50:18 -0700 | [diff] [blame] | 110 | static unsigned long dsi_pll_rate; |
Chandan Uddaraju | 09adf32 | 2012-08-16 02:55:23 -0700 | [diff] [blame] | 111 | |
Abhishek Kharbanda | c155984 | 2012-08-13 18:45:02 -0700 | [diff] [blame] | 112 | static void __iomem *hdmi_phy_base; |
| 113 | static void __iomem *hdmi_phy_pll_base; |
| 114 | static unsigned hdmi_pll_on; |
| 115 | |
Siddhartha Agrawal | 4b0d5a6 | 2013-02-25 23:23:41 -0800 | [diff] [blame] | 116 | void __init mdss_clk_ctrl_pre_init(struct clk *ahb_clk) |
Chandan Uddaraju | 09adf32 | 2012-08-16 02:55:23 -0700 | [diff] [blame] | 117 | { |
Siddhartha Agrawal | 4b0d5a6 | 2013-02-25 23:23:41 -0800 | [diff] [blame] | 118 | BUG_ON(ahb_clk == NULL); |
Matt Wagantall | 7cf535b | 2013-02-28 16:16:51 -0800 | [diff] [blame] | 119 | |
| 120 | gdsc_base = ioremap(GDSC_PHYS, GDSC_SIZE); |
| 121 | if (!gdsc_base) |
| 122 | pr_err("%s: unable to remap gdsc base", __func__); |
| 123 | |
Abhishek Kharbanda | c155984 | 2012-08-13 18:45:02 -0700 | [diff] [blame] | 124 | mdss_dsi_base = ioremap(DSI_PHY_PHYS, DSI_PHY_SIZE); |
Chandan Uddaraju | 09adf32 | 2012-08-16 02:55:23 -0700 | [diff] [blame] | 125 | if (!mdss_dsi_base) |
Abhishek Kharbanda | c155984 | 2012-08-13 18:45:02 -0700 | [diff] [blame] | 126 | pr_err("%s: unable to remap dsi base", __func__); |
Chandan Uddaraju | 09adf32 | 2012-08-16 02:55:23 -0700 | [diff] [blame] | 127 | |
Siddhartha Agrawal | 4b0d5a6 | 2013-02-25 23:23:41 -0800 | [diff] [blame] | 128 | mdss_dsi_ahb_clk = ahb_clk; |
Abhishek Kharbanda | c155984 | 2012-08-13 18:45:02 -0700 | [diff] [blame] | 129 | |
| 130 | hdmi_phy_base = ioremap(HDMI_PHY_PHYS, HDMI_PHY_SIZE); |
| 131 | if (!hdmi_phy_base) |
| 132 | pr_err("%s: unable to ioremap hdmi phy base", __func__); |
| 133 | |
| 134 | hdmi_phy_pll_base = ioremap(HDMI_PHY_PLL_PHYS, HDMI_PHY_PLL_SIZE); |
| 135 | if (!hdmi_phy_pll_base) |
| 136 | pr_err("%s: unable to ioremap hdmi phy pll base", __func__); |
Chandan Uddaraju | 09adf32 | 2012-08-16 02:55:23 -0700 | [diff] [blame] | 137 | } |
| 138 | |
Siddhartha Agrawal | 4b0d5a6 | 2013-02-25 23:23:41 -0800 | [diff] [blame] | 139 | #define PLL_POLL_MAX_READS 10 |
| 140 | #define PLL_POLL_TIMEOUT_US 50 |
| 141 | |
Matt Wagantall | 7cf535b | 2013-02-28 16:16:51 -0800 | [diff] [blame] | 142 | static int mdss_gdsc_enabled(void) |
| 143 | { |
| 144 | if (!gdsc_base) |
| 145 | return 0; |
| 146 | |
| 147 | return !!(readl_relaxed(gdsc_base) & BIT(31)); |
| 148 | } |
| 149 | |
Siddhartha Agrawal | 4b0d5a6 | 2013-02-25 23:23:41 -0800 | [diff] [blame] | 150 | static int mdss_dsi_check_pll_lock(void) |
| 151 | { |
| 152 | u32 status; |
| 153 | |
| 154 | clk_prepare_enable(mdss_dsi_ahb_clk); |
| 155 | /* poll for PLL ready status */ |
| 156 | if (readl_poll_timeout_noirq((mdss_dsi_base + 0x02c0), |
| 157 | status, |
| 158 | ((status & BIT(0)) == 1), |
| 159 | PLL_POLL_MAX_READS, PLL_POLL_TIMEOUT_US)) { |
| 160 | pr_err("%s: DSI PLL status=%x failed to Lock\n", |
| 161 | __func__, status); |
| 162 | pll_initialized = 0; |
| 163 | } else { |
| 164 | pll_initialized = 1; |
| 165 | } |
| 166 | clk_disable_unprepare(mdss_dsi_ahb_clk); |
| 167 | |
| 168 | return pll_initialized; |
| 169 | } |
| 170 | |
Chandan Uddaraju | 09adf32 | 2012-08-16 02:55:23 -0700 | [diff] [blame] | 171 | static long mdss_dsi_pll_byte_round_rate(struct clk *c, unsigned long rate) |
| 172 | { |
| 173 | if (pll_initialized) |
| 174 | return pll_byte_clk_rate; |
| 175 | else { |
| 176 | pr_err("%s: DSI PLL not configured\n", |
| 177 | __func__); |
| 178 | return -EINVAL; |
| 179 | } |
| 180 | } |
| 181 | |
| 182 | static long mdss_dsi_pll_pixel_round_rate(struct clk *c, unsigned long rate) |
| 183 | { |
| 184 | if (pll_initialized) |
| 185 | return pll_pclk_rate; |
| 186 | else { |
| 187 | pr_err("%s: Configure Byte clk first\n", |
| 188 | __func__); |
| 189 | return -EINVAL; |
| 190 | } |
| 191 | } |
| 192 | |
| 193 | static int mdss_dsi_pll_pixel_set_rate(struct clk *c, unsigned long rate) |
| 194 | { |
Aravind Venkateswaran | ee71899 | 2013-03-08 11:37:37 -0800 | [diff] [blame] | 195 | if (pll_initialized) { |
Chandan Uddaraju | 6316b50 | 2013-03-25 18:42:04 -0700 | [diff] [blame] | 196 | pll_pclk_rate = rate; |
Aravind Venkateswaran | ee71899 | 2013-03-08 11:37:37 -0800 | [diff] [blame] | 197 | pr_debug("%s: pll_pclk_rate=%d\n", __func__, pll_pclk_rate); |
Chandan Uddaraju | 09adf32 | 2012-08-16 02:55:23 -0700 | [diff] [blame] | 198 | return 0; |
Aravind Venkateswaran | ee71899 | 2013-03-08 11:37:37 -0800 | [diff] [blame] | 199 | } else { |
| 200 | pr_err("%s: Configure Byte clk first\n", __func__); |
Chandan Uddaraju | 09adf32 | 2012-08-16 02:55:23 -0700 | [diff] [blame] | 201 | return -EINVAL; |
| 202 | } |
| 203 | } |
| 204 | |
Siddhartha Agrawal | 4b0d5a6 | 2013-02-25 23:23:41 -0800 | [diff] [blame] | 205 | static int __mdss_dsi_pll_byte_set_rate(struct clk *c, unsigned long rate) |
Chandan Uddaraju | 09adf32 | 2012-08-16 02:55:23 -0700 | [diff] [blame] | 206 | { |
| 207 | int pll_divcfg1, pll_divcfg2; |
| 208 | int half_bitclk_rate; |
| 209 | |
Chandan Uddaraju | 62e5b92 | 2012-09-14 20:50:18 -0700 | [diff] [blame] | 210 | pr_debug("%s:\n", __func__); |
Chandan Uddaraju | 09adf32 | 2012-08-16 02:55:23 -0700 | [diff] [blame] | 211 | if (pll_initialized) |
| 212 | return 0; |
| 213 | |
Chandan Uddaraju | 09adf32 | 2012-08-16 02:55:23 -0700 | [diff] [blame] | 214 | half_bitclk_rate = rate * 4; |
| 215 | |
| 216 | pll_divcfg1 = (VCO_CLK / half_bitclk_rate) - 2; |
| 217 | |
| 218 | /* Configuring the VCO to 424 Mhz */ |
| 219 | /* Configuring the half rate Bit clk to 212 Mhz */ |
| 220 | |
| 221 | pll_divcfg2 = 3; /* ByteClk is 1/4 the half-bitClk rate */ |
| 222 | |
| 223 | /* Configure the Loop filter */ |
| 224 | /* Loop filter resistance value */ |
Abhishek Kharbanda | c155984 | 2012-08-13 18:45:02 -0700 | [diff] [blame] | 225 | REG_W(0x08, mdss_dsi_base + 0x022c); |
Chandan Uddaraju | 09adf32 | 2012-08-16 02:55:23 -0700 | [diff] [blame] | 226 | /* Loop filter capacitance values : c1 and c2 */ |
Abhishek Kharbanda | c155984 | 2012-08-13 18:45:02 -0700 | [diff] [blame] | 227 | REG_W(0x70, mdss_dsi_base + 0x0230); |
| 228 | REG_W(0x15, mdss_dsi_base + 0x0234); |
Chandan Uddaraju | 09adf32 | 2012-08-16 02:55:23 -0700 | [diff] [blame] | 229 | |
Abhishek Kharbanda | c155984 | 2012-08-13 18:45:02 -0700 | [diff] [blame] | 230 | REG_W(0x02, mdss_dsi_base + 0x0208); /* ChgPump */ |
| 231 | REG_W(pll_divcfg1, mdss_dsi_base + 0x0204); /* postDiv1 */ |
| 232 | REG_W(pll_divcfg2, mdss_dsi_base + 0x0224); /* postDiv2 */ |
Chandan Uddaraju | 6316b50 | 2013-03-25 18:42:04 -0700 | [diff] [blame] | 233 | REG_W(0x05, mdss_dsi_base + 0x0228); /* postDiv3 */ |
Chandan Uddaraju | 09adf32 | 2012-08-16 02:55:23 -0700 | [diff] [blame] | 234 | |
Abhishek Kharbanda | c155984 | 2012-08-13 18:45:02 -0700 | [diff] [blame] | 235 | REG_W(0x2b, mdss_dsi_base + 0x0278); /* Cal CFG3 */ |
Chandan Uddaraju | cee856b | 2013-02-15 17:27:28 -0800 | [diff] [blame] | 236 | REG_W(0x66, mdss_dsi_base + 0x027c); /* Cal CFG4 */ |
| 237 | REG_W(0x05, mdss_dsi_base + 0x0264); /* LKDET CFG2 */ |
Chandan Uddaraju | 09adf32 | 2012-08-16 02:55:23 -0700 | [diff] [blame] | 238 | |
Abhishek Kharbanda | c155984 | 2012-08-13 18:45:02 -0700 | [diff] [blame] | 239 | REG_W(0x0a, mdss_dsi_base + 0x023c); /* SDM CFG1 */ |
| 240 | REG_W(0xab, mdss_dsi_base + 0x0240); /* SDM CFG2 */ |
| 241 | REG_W(0x0a, mdss_dsi_base + 0x0244); /* SDM CFG3 */ |
| 242 | REG_W(0x00, mdss_dsi_base + 0x0248); /* SDM CFG4 */ |
Chandan Uddaraju | 09adf32 | 2012-08-16 02:55:23 -0700 | [diff] [blame] | 243 | |
Abhishek Kharbanda | c155984 | 2012-08-13 18:45:02 -0700 | [diff] [blame] | 244 | REG_W(0x01, mdss_dsi_base + 0x0200); /* REFCLK CFG */ |
| 245 | REG_W(0x00, mdss_dsi_base + 0x0214); /* PWRGEN CFG */ |
Chandan Uddaraju | cee856b | 2013-02-15 17:27:28 -0800 | [diff] [blame] | 246 | REG_W(0x71, mdss_dsi_base + 0x020c); /* VCOLPF CFG */ |
Abhishek Kharbanda | c155984 | 2012-08-13 18:45:02 -0700 | [diff] [blame] | 247 | REG_W(0x02, mdss_dsi_base + 0x0210); /* VREG CFG */ |
| 248 | REG_W(0x00, mdss_dsi_base + 0x0238); /* SDM CFG0 */ |
Chandan Uddaraju | 09adf32 | 2012-08-16 02:55:23 -0700 | [diff] [blame] | 249 | |
Abhishek Kharbanda | c155984 | 2012-08-13 18:45:02 -0700 | [diff] [blame] | 250 | REG_W(0x5f, mdss_dsi_base + 0x028c); /* CAL CFG8 */ |
| 251 | REG_W(0xa8, mdss_dsi_base + 0x0294); /* CAL CFG10 */ |
| 252 | REG_W(0x01, mdss_dsi_base + 0x0298); /* CAL CFG11 */ |
| 253 | REG_W(0x0a, mdss_dsi_base + 0x026c); /* CAL CFG0 */ |
| 254 | REG_W(0x30, mdss_dsi_base + 0x0284); /* CAL CFG6 */ |
| 255 | REG_W(0x00, mdss_dsi_base + 0x0288); /* CAL CFG7 */ |
| 256 | REG_W(0x00, mdss_dsi_base + 0x0290); /* CAL CFG9 */ |
| 257 | REG_W(0x20, mdss_dsi_base + 0x029c); /* EFUSE CFG */ |
Chandan Uddaraju | 09adf32 | 2012-08-16 02:55:23 -0700 | [diff] [blame] | 258 | |
Chandan Uddaraju | 62e5b92 | 2012-09-14 20:50:18 -0700 | [diff] [blame] | 259 | dsi_pll_rate = rate; |
Aravind Venkateswaran | ee71899 | 2013-03-08 11:37:37 -0800 | [diff] [blame] | 260 | pll_byte_clk_rate = rate; |
Chandan Uddaraju | 62e5b92 | 2012-09-14 20:50:18 -0700 | [diff] [blame] | 261 | |
Aravind Venkateswaran | ee71899 | 2013-03-08 11:37:37 -0800 | [diff] [blame] | 262 | pr_debug("%s: PLL initialized. bcl=%d\n", __func__, pll_byte_clk_rate); |
Chandan Uddaraju | 09adf32 | 2012-08-16 02:55:23 -0700 | [diff] [blame] | 263 | pll_initialized = 1; |
| 264 | |
| 265 | return 0; |
| 266 | } |
| 267 | |
Siddhartha Agrawal | 4b0d5a6 | 2013-02-25 23:23:41 -0800 | [diff] [blame] | 268 | static int mdss_dsi_pll_byte_set_rate(struct clk *c, unsigned long rate) |
| 269 | { |
| 270 | int ret; |
| 271 | |
| 272 | clk_prepare_enable(mdss_dsi_ahb_clk); |
| 273 | ret = __mdss_dsi_pll_byte_set_rate(c, rate); |
| 274 | clk_disable_unprepare(mdss_dsi_ahb_clk); |
| 275 | |
| 276 | return ret; |
| 277 | } |
| 278 | |
Chandan Uddaraju | cee856b | 2013-02-15 17:27:28 -0800 | [diff] [blame] | 279 | static void mdss_dsi_uniphy_pll_lock_detect_setting(void) |
| 280 | { |
| 281 | REG_W(0x04, mdss_dsi_base + 0x0264); /* LKDetect CFG2 */ |
| 282 | udelay(100); |
| 283 | REG_W(0x05, mdss_dsi_base + 0x0264); /* LKDetect CFG2 */ |
| 284 | udelay(500); |
| 285 | } |
| 286 | |
| 287 | static void mdss_dsi_uniphy_pll_sw_reset(void) |
| 288 | { |
| 289 | REG_W(0x01, mdss_dsi_base + 0x0268); /* PLL TEST CFG */ |
| 290 | udelay(1); |
| 291 | REG_W(0x00, mdss_dsi_base + 0x0268); /* PLL TEST CFG */ |
| 292 | udelay(1); |
| 293 | } |
| 294 | |
Vikram Mulukutla | de6fb29 | 2012-10-30 20:29:41 -0700 | [diff] [blame] | 295 | static int __mdss_dsi_pll_enable(struct clk *c) |
Chandan Uddaraju | 09adf32 | 2012-08-16 02:55:23 -0700 | [diff] [blame] | 296 | { |
| 297 | u32 status; |
| 298 | u32 max_reads, timeout_us; |
Chandan Uddaraju | 62e5b92 | 2012-09-14 20:50:18 -0700 | [diff] [blame] | 299 | int i; |
Chandan Uddaraju | 09adf32 | 2012-08-16 02:55:23 -0700 | [diff] [blame] | 300 | |
Chandan Uddaraju | 62e5b92 | 2012-09-14 20:50:18 -0700 | [diff] [blame] | 301 | if (!pll_initialized) { |
| 302 | if (dsi_pll_rate) |
Siddhartha Agrawal | 4b0d5a6 | 2013-02-25 23:23:41 -0800 | [diff] [blame] | 303 | __mdss_dsi_pll_byte_set_rate(c, dsi_pll_rate); |
Chandan Uddaraju | 62e5b92 | 2012-09-14 20:50:18 -0700 | [diff] [blame] | 304 | else |
| 305 | pr_err("%s: Calling clk_en before set_rate\n", |
| 306 | __func__); |
| 307 | } |
| 308 | |
Chandan Uddaraju | cee856b | 2013-02-15 17:27:28 -0800 | [diff] [blame] | 309 | mdss_dsi_uniphy_pll_sw_reset(); |
Chandan Uddaraju | 62e5b92 | 2012-09-14 20:50:18 -0700 | [diff] [blame] | 310 | /* PLL power up */ |
Chandan Uddaraju | cee856b | 2013-02-15 17:27:28 -0800 | [diff] [blame] | 311 | /* Add HW recommended delay between |
| 312 | register writes for the update to propagate */ |
| 313 | REG_W(0x01, mdss_dsi_base + 0x0220); /* GLB CFG */ |
| 314 | udelay(1000); |
| 315 | REG_W(0x05, mdss_dsi_base + 0x0220); /* GLB CFG */ |
| 316 | udelay(1000); |
| 317 | REG_W(0x07, mdss_dsi_base + 0x0220); /* GLB CFG */ |
| 318 | udelay(1000); |
| 319 | REG_W(0x0f, mdss_dsi_base + 0x0220); /* GLB CFG */ |
| 320 | udelay(1000); |
Chandan Uddaraju | 62e5b92 | 2012-09-14 20:50:18 -0700 | [diff] [blame] | 321 | |
Chandan Uddaraju | cee856b | 2013-02-15 17:27:28 -0800 | [diff] [blame] | 322 | for (i = 0; i < 3; i++) { |
| 323 | mdss_dsi_uniphy_pll_lock_detect_setting(); |
Chandan Uddaraju | 62e5b92 | 2012-09-14 20:50:18 -0700 | [diff] [blame] | 324 | /* poll for PLL ready status */ |
Chandan Uddaraju | cee856b | 2013-02-15 17:27:28 -0800 | [diff] [blame] | 325 | max_reads = 5; |
Chandan Uddaraju | 62e5b92 | 2012-09-14 20:50:18 -0700 | [diff] [blame] | 326 | timeout_us = 100; |
| 327 | if (readl_poll_timeout_noirq((mdss_dsi_base + 0x02c0), |
| 328 | status, |
| 329 | ((status & 0x01) == 1), |
| 330 | max_reads, timeout_us)) { |
| 331 | pr_debug("%s: DSI PLL status=%x failed to Lock\n", |
| 332 | __func__, status); |
| 333 | pr_debug("%s:Trying to power UP PLL again\n", |
| 334 | __func__); |
| 335 | } else |
| 336 | break; |
Chandan Uddaraju | cee856b | 2013-02-15 17:27:28 -0800 | [diff] [blame] | 337 | |
| 338 | mdss_dsi_uniphy_pll_sw_reset(); |
| 339 | udelay(1000); |
| 340 | /* Add HW recommended delay between |
| 341 | register writes for the update to propagate */ |
| 342 | REG_W(0x01, mdss_dsi_base + 0x0220); /* GLB CFG */ |
| 343 | udelay(1000); |
| 344 | REG_W(0x05, mdss_dsi_base + 0x0220); /* GLB CFG */ |
| 345 | udelay(1000); |
| 346 | REG_W(0x07, mdss_dsi_base + 0x0220); /* GLB CFG */ |
| 347 | udelay(1000); |
| 348 | REG_W(0x05, mdss_dsi_base + 0x0220); /* GLB CFG */ |
| 349 | udelay(1000); |
| 350 | REG_W(0x07, mdss_dsi_base + 0x0220); /* GLB CFG */ |
| 351 | udelay(1000); |
| 352 | REG_W(0x0f, mdss_dsi_base + 0x0220); /* GLB CFG */ |
| 353 | udelay(2000); |
| 354 | |
Chandan Uddaraju | 62e5b92 | 2012-09-14 20:50:18 -0700 | [diff] [blame] | 355 | } |
| 356 | |
| 357 | if ((status & 0x01) != 1) { |
Chandan Uddaraju | 09adf32 | 2012-08-16 02:55:23 -0700 | [diff] [blame] | 358 | pr_err("%s: DSI PLL status=%x failed to Lock\n", |
| 359 | __func__, status); |
Chandan Uddaraju | 09adf32 | 2012-08-16 02:55:23 -0700 | [diff] [blame] | 360 | return -EINVAL; |
| 361 | } |
Chandan Uddaraju | 62e5b92 | 2012-09-14 20:50:18 -0700 | [diff] [blame] | 362 | |
| 363 | pr_debug("%s: **** PLL Lock success\n", __func__); |
Chandan Uddaraju | 09adf32 | 2012-08-16 02:55:23 -0700 | [diff] [blame] | 364 | |
| 365 | return 0; |
| 366 | } |
| 367 | |
Vikram Mulukutla | de6fb29 | 2012-10-30 20:29:41 -0700 | [diff] [blame] | 368 | static void __mdss_dsi_pll_disable(void) |
Chandan Uddaraju | 09adf32 | 2012-08-16 02:55:23 -0700 | [diff] [blame] | 369 | { |
Chandan Uddaraju | 09adf32 | 2012-08-16 02:55:23 -0700 | [diff] [blame] | 370 | writel_relaxed(0x00, mdss_dsi_base + 0x0220); /* GLB CFG */ |
Chandan Uddaraju | 62e5b92 | 2012-09-14 20:50:18 -0700 | [diff] [blame] | 371 | pr_debug("%s: **** disable pll Initialize\n", __func__); |
| 372 | pll_initialized = 0; |
Vikram Mulukutla | de6fb29 | 2012-10-30 20:29:41 -0700 | [diff] [blame] | 373 | } |
| 374 | |
| 375 | static DEFINE_SPINLOCK(dsipll_lock); |
| 376 | static int dsipll_refcount; |
| 377 | |
| 378 | static void mdss_dsi_pll_disable(struct clk *c) |
| 379 | { |
| 380 | unsigned long flags; |
| 381 | |
| 382 | spin_lock_irqsave(&dsipll_lock, flags); |
| 383 | if (WARN(dsipll_refcount == 0, "DSI PLL clock is unbalanced")) |
| 384 | goto out; |
| 385 | if (dsipll_refcount == 1) |
| 386 | __mdss_dsi_pll_disable(); |
| 387 | dsipll_refcount--; |
| 388 | out: |
| 389 | spin_unlock_irqrestore(&dsipll_lock, flags); |
| 390 | } |
| 391 | |
| 392 | static int mdss_dsi_pll_enable(struct clk *c) |
| 393 | { |
| 394 | unsigned long flags; |
| 395 | int ret = 0; |
| 396 | |
| 397 | spin_lock_irqsave(&dsipll_lock, flags); |
| 398 | if (dsipll_refcount == 0) { |
| 399 | ret = __mdss_dsi_pll_enable(c); |
| 400 | if (ret < 0) |
| 401 | goto out; |
| 402 | } |
| 403 | dsipll_refcount++; |
| 404 | out: |
| 405 | spin_unlock_irqrestore(&dsipll_lock, flags); |
| 406 | return ret; |
Chandan Uddaraju | 09adf32 | 2012-08-16 02:55:23 -0700 | [diff] [blame] | 407 | } |
| 408 | |
Siddhartha Agrawal | 4b0d5a6 | 2013-02-25 23:23:41 -0800 | [diff] [blame] | 409 | static enum handoff mdss_dsi_pll_byte_handoff(struct clk *c) |
Saravana Kannan | c85ecf9 | 2013-01-21 17:58:35 -0800 | [diff] [blame] | 410 | { |
Matt Wagantall | 7cf535b | 2013-02-28 16:16:51 -0800 | [diff] [blame] | 411 | if (mdss_gdsc_enabled() && mdss_dsi_check_pll_lock()) { |
Siddhartha Agrawal | 4b0d5a6 | 2013-02-25 23:23:41 -0800 | [diff] [blame] | 412 | c->rate = 53000000; |
| 413 | dsi_pll_rate = 53000000; |
| 414 | pll_byte_clk_rate = 53000000; |
| 415 | pll_pclk_rate = 105000000; |
| 416 | dsipll_refcount++; |
| 417 | return HANDOFF_ENABLED_CLK; |
| 418 | } |
| 419 | |
| 420 | return HANDOFF_DISABLED_CLK; |
| 421 | } |
| 422 | |
| 423 | static enum handoff mdss_dsi_pll_pixel_handoff(struct clk *c) |
| 424 | { |
Matt Wagantall | 7cf535b | 2013-02-28 16:16:51 -0800 | [diff] [blame] | 425 | if (mdss_gdsc_enabled() && mdss_dsi_check_pll_lock()) { |
Siddhartha Agrawal | 4b0d5a6 | 2013-02-25 23:23:41 -0800 | [diff] [blame] | 426 | c->rate = 105000000; |
| 427 | dsipll_refcount++; |
| 428 | return HANDOFF_ENABLED_CLK; |
| 429 | } |
| 430 | |
Saravana Kannan | c85ecf9 | 2013-01-21 17:58:35 -0800 | [diff] [blame] | 431 | return HANDOFF_DISABLED_CLK; |
| 432 | } |
| 433 | |
Abhishek Kharbanda | c155984 | 2012-08-13 18:45:02 -0700 | [diff] [blame] | 434 | void hdmi_pll_disable(void) |
| 435 | { |
Vikram Mulukutla | 5d581bd | 2012-11-30 11:51:41 -0800 | [diff] [blame] | 436 | clk_enable(mdss_dsi_ahb_clk); |
Abhishek Kharbanda | c155984 | 2012-08-13 18:45:02 -0700 | [diff] [blame] | 437 | REG_W(0x0, hdmi_phy_pll_base + HDMI_UNI_PLL_GLB_CFG); |
| 438 | udelay(5); |
| 439 | REG_W(0x0, hdmi_phy_base + HDMI_PHY_GLB_CFG); |
Vikram Mulukutla | 5d581bd | 2012-11-30 11:51:41 -0800 | [diff] [blame] | 440 | clk_disable(mdss_dsi_ahb_clk); |
Abhishek Kharbanda | c155984 | 2012-08-13 18:45:02 -0700 | [diff] [blame] | 441 | |
| 442 | hdmi_pll_on = 0; |
| 443 | } /* hdmi_pll_disable */ |
| 444 | |
| 445 | int hdmi_pll_enable(void) |
| 446 | { |
| 447 | u32 status; |
| 448 | u32 max_reads, timeout_us; |
| 449 | |
Vikram Mulukutla | 5d581bd | 2012-11-30 11:51:41 -0800 | [diff] [blame] | 450 | clk_enable(mdss_dsi_ahb_clk); |
Abhishek Kharbanda | c155984 | 2012-08-13 18:45:02 -0700 | [diff] [blame] | 451 | /* Global Enable */ |
| 452 | REG_W(0x81, hdmi_phy_base + HDMI_PHY_GLB_CFG); |
| 453 | /* Power up power gen */ |
| 454 | REG_W(0x00, hdmi_phy_base + HDMI_PHY_PD_CTRL0); |
| 455 | udelay(350); |
| 456 | |
| 457 | /* PLL Power-Up */ |
| 458 | REG_W(0x01, hdmi_phy_pll_base + HDMI_UNI_PLL_GLB_CFG); |
| 459 | udelay(5); |
| 460 | /* Power up PLL LDO */ |
| 461 | REG_W(0x03, hdmi_phy_pll_base + HDMI_UNI_PLL_GLB_CFG); |
| 462 | udelay(350); |
| 463 | |
| 464 | /* PLL Power-Up */ |
| 465 | REG_W(0x0F, hdmi_phy_pll_base + HDMI_UNI_PLL_GLB_CFG); |
| 466 | udelay(350); |
| 467 | |
| 468 | /* poll for PLL ready status */ |
| 469 | max_reads = 20; |
| 470 | timeout_us = 100; |
| 471 | if (readl_poll_timeout_noirq((hdmi_phy_pll_base + HDMI_UNI_PLL_STATUS), |
| 472 | status, ((status & BIT(0)) == 1), max_reads, timeout_us)) { |
| 473 | pr_err("%s: hdmi phy pll status=%x failed to Lock\n", |
| 474 | __func__, status); |
| 475 | hdmi_pll_disable(); |
Vikram Mulukutla | 5d581bd | 2012-11-30 11:51:41 -0800 | [diff] [blame] | 476 | clk_disable(mdss_dsi_ahb_clk); |
Abhishek Kharbanda | c155984 | 2012-08-13 18:45:02 -0700 | [diff] [blame] | 477 | return -EINVAL; |
| 478 | } |
| 479 | pr_debug("%s: hdmi phy pll is locked\n", __func__); |
| 480 | |
| 481 | udelay(350); |
| 482 | /* poll for PHY ready status */ |
| 483 | max_reads = 20; |
| 484 | timeout_us = 100; |
| 485 | if (readl_poll_timeout_noirq((hdmi_phy_base + HDMI_PHY_STATUS), |
| 486 | status, ((status & BIT(0)) == 1), max_reads, timeout_us)) { |
| 487 | pr_err("%s: hdmi phy status=%x failed to Lock\n", |
| 488 | __func__, status); |
| 489 | hdmi_pll_disable(); |
Vikram Mulukutla | 5d581bd | 2012-11-30 11:51:41 -0800 | [diff] [blame] | 490 | clk_disable(mdss_dsi_ahb_clk); |
Abhishek Kharbanda | c155984 | 2012-08-13 18:45:02 -0700 | [diff] [blame] | 491 | return -EINVAL; |
| 492 | } |
| 493 | pr_debug("%s: hdmi phy is locked\n", __func__); |
Vikram Mulukutla | 5d581bd | 2012-11-30 11:51:41 -0800 | [diff] [blame] | 494 | clk_disable(mdss_dsi_ahb_clk); |
Abhishek Kharbanda | c155984 | 2012-08-13 18:45:02 -0700 | [diff] [blame] | 495 | |
| 496 | hdmi_pll_on = 1; |
| 497 | |
| 498 | return 0; |
| 499 | } /* hdmi_pll_enable */ |
| 500 | |
| 501 | int hdmi_pll_set_rate(unsigned long rate) |
| 502 | { |
| 503 | unsigned int set_power_dwn = 0; |
| 504 | |
| 505 | if (hdmi_pll_on) { |
| 506 | hdmi_pll_disable(); |
| 507 | set_power_dwn = 1; |
| 508 | } |
| 509 | |
Vikram Mulukutla | 5d581bd | 2012-11-30 11:51:41 -0800 | [diff] [blame] | 510 | clk_enable(mdss_dsi_ahb_clk); |
Abhishek Kharbanda | c155984 | 2012-08-13 18:45:02 -0700 | [diff] [blame] | 511 | pr_debug("%s: rate=%ld\n", __func__, rate); |
| 512 | switch (rate) { |
| 513 | case 0: |
| 514 | /* This case is needed for suspend/resume. */ |
| 515 | break; |
| 516 | |
| 517 | case 25200000: |
| 518 | /* 640x480p60 */ |
Ujwal Patel | c801765 | 2012-11-15 18:03:01 -0800 | [diff] [blame] | 519 | REG_W(0x81, hdmi_phy_base + HDMI_PHY_GLB_CFG); |
| 520 | REG_W(0x01, hdmi_phy_pll_base + HDMI_UNI_PLL_GLB_CFG); |
| 521 | REG_W(0x01, hdmi_phy_pll_base + HDMI_UNI_PLL_REFCLK_CFG); |
| 522 | REG_W(0x19, hdmi_phy_pll_base + HDMI_UNI_PLL_VCOLPF_CFG); |
| 523 | REG_W(0x0E, hdmi_phy_pll_base + HDMI_UNI_PLL_LPFR_CFG); |
| 524 | REG_W(0x20, hdmi_phy_pll_base + HDMI_UNI_PLL_LPFC1_CFG); |
| 525 | REG_W(0x0D, hdmi_phy_pll_base + HDMI_UNI_PLL_LPFC2_CFG); |
| 526 | REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG0); |
| 527 | REG_W(0x52, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG1); |
Abhishek Kharbanda | c155984 | 2012-08-13 18:45:02 -0700 | [diff] [blame] | 528 | REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG2); |
Ujwal Patel | c801765 | 2012-11-15 18:03:01 -0800 | [diff] [blame] | 529 | REG_W(0xB0, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG3); |
Abhishek Kharbanda | c155984 | 2012-08-13 18:45:02 -0700 | [diff] [blame] | 530 | REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG4); |
| 531 | REG_W(0x10, hdmi_phy_pll_base + HDMI_UNI_PLL_LKDET_CFG0); |
| 532 | REG_W(0x1A, hdmi_phy_pll_base + HDMI_UNI_PLL_LKDET_CFG1); |
| 533 | REG_W(0x05, hdmi_phy_pll_base + HDMI_UNI_PLL_LKDET_CFG2); |
Ujwal Patel | c801765 | 2012-11-15 18:03:01 -0800 | [diff] [blame] | 534 | REG_W(0x03, hdmi_phy_pll_base + HDMI_UNI_PLL_POSTDIV1_CFG); |
Abhishek Kharbanda | c155984 | 2012-08-13 18:45:02 -0700 | [diff] [blame] | 535 | REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_POSTDIV2_CFG); |
| 536 | REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_POSTDIV3_CFG); |
Ujwal Patel | c801765 | 2012-11-15 18:03:01 -0800 | [diff] [blame] | 537 | REG_W(0x01, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG2); |
Abhishek Kharbanda | c155984 | 2012-08-13 18:45:02 -0700 | [diff] [blame] | 538 | REG_W(0x60, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG8); |
| 539 | REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG9); |
Ujwal Patel | c801765 | 2012-11-15 18:03:01 -0800 | [diff] [blame] | 540 | REG_W(0xF4, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG10); |
| 541 | REG_W(0x02, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG11); |
| 542 | REG_W(0x1F, hdmi_phy_base + HDMI_PHY_PD_CTRL0); |
| 543 | udelay(50); |
| 544 | |
| 545 | REG_W(0x0F, hdmi_phy_pll_base + HDMI_UNI_PLL_GLB_CFG); |
| 546 | REG_W(0x00, hdmi_phy_base + HDMI_PHY_PD_CTRL1); |
| 547 | REG_W(0x10, hdmi_phy_base + HDMI_PHY_ANA_CFG2); |
| 548 | REG_W(0xDB, hdmi_phy_base + HDMI_PHY_ANA_CFG0); |
| 549 | REG_W(0x43, hdmi_phy_base + HDMI_PHY_ANA_CFG1); |
| 550 | REG_W(0x02, hdmi_phy_base + HDMI_PHY_ANA_CFG2); |
| 551 | REG_W(0x00, hdmi_phy_base + HDMI_PHY_ANA_CFG3); |
| 552 | REG_W(0x04, hdmi_phy_pll_base + HDMI_UNI_PLL_VREG_CFG); |
| 553 | REG_W(0xD0, hdmi_phy_base + HDMI_PHY_DCC_CFG0); |
| 554 | REG_W(0x1A, hdmi_phy_base + HDMI_PHY_DCC_CFG1); |
| 555 | REG_W(0x00, hdmi_phy_base + HDMI_PHY_TXCAL_CFG0); |
| 556 | REG_W(0x00, hdmi_phy_base + HDMI_PHY_TXCAL_CFG1); |
| 557 | REG_W(0x02, hdmi_phy_base + HDMI_PHY_TXCAL_CFG2); |
| 558 | REG_W(0x05, hdmi_phy_base + HDMI_PHY_TXCAL_CFG3); |
| 559 | udelay(200); |
Abhishek Kharbanda | c155984 | 2012-08-13 18:45:02 -0700 | [diff] [blame] | 560 | break; |
| 561 | |
Ujwal Patel | e698fae | 2012-11-29 14:04:33 -0800 | [diff] [blame] | 562 | case 27000000: |
| 563 | /* 576p50/576i50 case */ |
| 564 | REG_W(0x81, hdmi_phy_base + HDMI_PHY_GLB_CFG); |
| 565 | REG_W(0x01, hdmi_phy_pll_base + HDMI_UNI_PLL_GLB_CFG); |
| 566 | REG_W(0x01, hdmi_phy_pll_base + HDMI_UNI_PLL_REFCLK_CFG); |
| 567 | REG_W(0x19, hdmi_phy_pll_base + HDMI_UNI_PLL_VCOLPF_CFG); |
| 568 | REG_W(0X0E, hdmi_phy_pll_base + HDMI_UNI_PLL_LPFR_CFG); |
| 569 | REG_W(0x20, hdmi_phy_pll_base + HDMI_UNI_PLL_LPFC1_CFG); |
| 570 | REG_W(0X0D, hdmi_phy_pll_base + HDMI_UNI_PLL_LPFC2_CFG); |
| 571 | REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG0); |
| 572 | REG_W(0x54, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG1); |
| 573 | REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG2); |
| 574 | REG_W(0x18, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG3); |
| 575 | REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG4); |
| 576 | REG_W(0x10, hdmi_phy_pll_base + HDMI_UNI_PLL_LKDET_CFG0); |
| 577 | REG_W(0X1A, hdmi_phy_pll_base + HDMI_UNI_PLL_LKDET_CFG1); |
| 578 | REG_W(0x05, hdmi_phy_pll_base + HDMI_UNI_PLL_LKDET_CFG2); |
| 579 | REG_W(0x03, hdmi_phy_pll_base + HDMI_UNI_PLL_POSTDIV1_CFG); |
| 580 | REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_POSTDIV2_CFG); |
| 581 | REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_POSTDIV3_CFG); |
| 582 | REG_W(0x01, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG2); |
| 583 | REG_W(0x60, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG8); |
| 584 | REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG9); |
| 585 | REG_W(0x2a, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG10); |
| 586 | REG_W(0x03, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG11); |
| 587 | REG_W(0X1F, hdmi_phy_base + HDMI_PHY_PD_CTRL0); |
| 588 | udelay(50); |
| 589 | |
| 590 | REG_W(0X0F, hdmi_phy_pll_base + HDMI_UNI_PLL_GLB_CFG); |
| 591 | REG_W(0x00, hdmi_phy_base + HDMI_PHY_PD_CTRL1); |
| 592 | REG_W(0x10, hdmi_phy_base + HDMI_PHY_ANA_CFG2); |
| 593 | REG_W(0XDB, hdmi_phy_base + HDMI_PHY_ANA_CFG0); |
| 594 | REG_W(0x43, hdmi_phy_base + HDMI_PHY_ANA_CFG1); |
| 595 | REG_W(0x02, hdmi_phy_base + HDMI_PHY_ANA_CFG2); |
| 596 | REG_W(0x00, hdmi_phy_base + HDMI_PHY_ANA_CFG3); |
| 597 | REG_W(0x04, hdmi_phy_pll_base + HDMI_UNI_PLL_VREG_CFG); |
| 598 | REG_W(0XD0, hdmi_phy_base + HDMI_PHY_DCC_CFG0); |
| 599 | REG_W(0X1A, hdmi_phy_base + HDMI_PHY_DCC_CFG1); |
| 600 | REG_W(0x00, hdmi_phy_base + HDMI_PHY_TXCAL_CFG0); |
| 601 | REG_W(0x00, hdmi_phy_base + HDMI_PHY_TXCAL_CFG1); |
| 602 | REG_W(0x02, hdmi_phy_base + HDMI_PHY_TXCAL_CFG2); |
| 603 | REG_W(0x05, hdmi_phy_base + HDMI_PHY_TXCAL_CFG3); |
| 604 | udelay(200); |
| 605 | break; |
| 606 | |
Abhishek Kharbanda | c155984 | 2012-08-13 18:45:02 -0700 | [diff] [blame] | 607 | case 27030000: |
| 608 | /* 480p60/480i60 case */ |
Ujwal Patel | c801765 | 2012-11-15 18:03:01 -0800 | [diff] [blame] | 609 | REG_W(0x81, hdmi_phy_base + HDMI_PHY_GLB_CFG); |
| 610 | REG_W(0x01, hdmi_phy_pll_base + HDMI_UNI_PLL_GLB_CFG); |
| 611 | REG_W(0x01, hdmi_phy_pll_base + HDMI_UNI_PLL_REFCLK_CFG); |
| 612 | REG_W(0x19, hdmi_phy_pll_base + HDMI_UNI_PLL_VCOLPF_CFG); |
| 613 | REG_W(0x0E, hdmi_phy_pll_base + HDMI_UNI_PLL_LPFR_CFG); |
| 614 | REG_W(0x20, hdmi_phy_pll_base + HDMI_UNI_PLL_LPFC1_CFG); |
| 615 | REG_W(0x0D, hdmi_phy_pll_base + HDMI_UNI_PLL_LPFC2_CFG); |
| 616 | REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG0); |
| 617 | REG_W(0x54, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG1); |
| 618 | REG_W(0x66, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG2); |
Abhishek Kharbanda | c155984 | 2012-08-13 18:45:02 -0700 | [diff] [blame] | 619 | REG_W(0x1D, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG3); |
| 620 | REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG4); |
| 621 | REG_W(0x10, hdmi_phy_pll_base + HDMI_UNI_PLL_LKDET_CFG0); |
| 622 | REG_W(0x1A, hdmi_phy_pll_base + HDMI_UNI_PLL_LKDET_CFG1); |
| 623 | REG_W(0x05, hdmi_phy_pll_base + HDMI_UNI_PLL_LKDET_CFG2); |
| 624 | REG_W(0x03, hdmi_phy_pll_base + HDMI_UNI_PLL_POSTDIV1_CFG); |
| 625 | REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_POSTDIV2_CFG); |
| 626 | REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_POSTDIV3_CFG); |
Ujwal Patel | c801765 | 2012-11-15 18:03:01 -0800 | [diff] [blame] | 627 | REG_W(0x01, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG2); |
Abhishek Kharbanda | c155984 | 2012-08-13 18:45:02 -0700 | [diff] [blame] | 628 | REG_W(0x60, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG8); |
| 629 | REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG9); |
| 630 | REG_W(0x2A, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG10); |
| 631 | REG_W(0x03, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG11); |
Ujwal Patel | c801765 | 2012-11-15 18:03:01 -0800 | [diff] [blame] | 632 | REG_W(0x1F, hdmi_phy_base + HDMI_PHY_PD_CTRL0); |
| 633 | udelay(50); |
| 634 | |
| 635 | REG_W(0x0F, hdmi_phy_pll_base + HDMI_UNI_PLL_GLB_CFG); |
| 636 | REG_W(0x00, hdmi_phy_base + HDMI_PHY_PD_CTRL1); |
| 637 | REG_W(0x10, hdmi_phy_base + HDMI_PHY_ANA_CFG2); |
| 638 | REG_W(0xDB, hdmi_phy_base + HDMI_PHY_ANA_CFG0); |
| 639 | REG_W(0x43, hdmi_phy_base + HDMI_PHY_ANA_CFG1); |
| 640 | REG_W(0x02, hdmi_phy_base + HDMI_PHY_ANA_CFG2); |
| 641 | REG_W(0x00, hdmi_phy_base + HDMI_PHY_ANA_CFG3); |
| 642 | REG_W(0x04, hdmi_phy_pll_base + HDMI_UNI_PLL_VREG_CFG); |
| 643 | REG_W(0xD0, hdmi_phy_base + HDMI_PHY_DCC_CFG0); |
| 644 | REG_W(0x1A, hdmi_phy_base + HDMI_PHY_DCC_CFG1); |
| 645 | REG_W(0x00, hdmi_phy_base + HDMI_PHY_TXCAL_CFG0); |
| 646 | REG_W(0x00, hdmi_phy_base + HDMI_PHY_TXCAL_CFG1); |
| 647 | REG_W(0x02, hdmi_phy_base + HDMI_PHY_TXCAL_CFG2); |
| 648 | REG_W(0x05, hdmi_phy_base + HDMI_PHY_TXCAL_CFG3); |
| 649 | udelay(200); |
Abhishek Kharbanda | c155984 | 2012-08-13 18:45:02 -0700 | [diff] [blame] | 650 | break; |
| 651 | |
| 652 | case 74250000: |
| 653 | /* |
| 654 | * 720p60/720p50/1080i60/1080i50 |
| 655 | * 1080p24/1080p30/1080p25 case |
| 656 | */ |
Ujwal Patel | c801765 | 2012-11-15 18:03:01 -0800 | [diff] [blame] | 657 | REG_W(0x81, hdmi_phy_base + HDMI_PHY_GLB_CFG); |
| 658 | REG_W(0x01, hdmi_phy_pll_base + HDMI_UNI_PLL_GLB_CFG); |
| 659 | REG_W(0x01, hdmi_phy_pll_base + HDMI_UNI_PLL_REFCLK_CFG); |
| 660 | REG_W(0x19, hdmi_phy_pll_base + HDMI_UNI_PLL_VCOLPF_CFG); |
| 661 | REG_W(0x0E, hdmi_phy_pll_base + HDMI_UNI_PLL_LPFR_CFG); |
| 662 | REG_W(0x20, hdmi_phy_pll_base + HDMI_UNI_PLL_LPFC1_CFG); |
| 663 | REG_W(0x0D, hdmi_phy_pll_base + HDMI_UNI_PLL_LPFC2_CFG); |
| 664 | REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG0); |
Abhishek Kharbanda | c155984 | 2012-08-13 18:45:02 -0700 | [diff] [blame] | 665 | REG_W(0x52, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG1); |
Ujwal Patel | c801765 | 2012-11-15 18:03:01 -0800 | [diff] [blame] | 666 | REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG2); |
| 667 | REG_W(0x56, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG3); |
Abhishek Kharbanda | c155984 | 2012-08-13 18:45:02 -0700 | [diff] [blame] | 668 | REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG4); |
| 669 | REG_W(0x10, hdmi_phy_pll_base + HDMI_UNI_PLL_LKDET_CFG0); |
| 670 | REG_W(0x1A, hdmi_phy_pll_base + HDMI_UNI_PLL_LKDET_CFG1); |
| 671 | REG_W(0x05, hdmi_phy_pll_base + HDMI_UNI_PLL_LKDET_CFG2); |
Ujwal Patel | c801765 | 2012-11-15 18:03:01 -0800 | [diff] [blame] | 672 | REG_W(0x01, hdmi_phy_pll_base + HDMI_UNI_PLL_POSTDIV1_CFG); |
Abhishek Kharbanda | c155984 | 2012-08-13 18:45:02 -0700 | [diff] [blame] | 673 | REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_POSTDIV2_CFG); |
| 674 | REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_POSTDIV3_CFG); |
Ujwal Patel | c801765 | 2012-11-15 18:03:01 -0800 | [diff] [blame] | 675 | REG_W(0x01, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG2); |
Abhishek Kharbanda | c155984 | 2012-08-13 18:45:02 -0700 | [diff] [blame] | 676 | REG_W(0x60, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG8); |
| 677 | REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG9); |
| 678 | REG_W(0xE6, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG10); |
| 679 | REG_W(0x02, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG11); |
Ujwal Patel | c801765 | 2012-11-15 18:03:01 -0800 | [diff] [blame] | 680 | REG_W(0x1F, hdmi_phy_base + HDMI_PHY_PD_CTRL0); |
| 681 | udelay(50); |
| 682 | |
| 683 | REG_W(0x0F, hdmi_phy_pll_base + HDMI_UNI_PLL_GLB_CFG); |
| 684 | REG_W(0x00, hdmi_phy_base + HDMI_PHY_PD_CTRL1); |
| 685 | REG_W(0x10, hdmi_phy_base + HDMI_PHY_ANA_CFG2); |
| 686 | REG_W(0xDB, hdmi_phy_base + HDMI_PHY_ANA_CFG0); |
| 687 | REG_W(0x43, hdmi_phy_base + HDMI_PHY_ANA_CFG1); |
| 688 | REG_W(0x02, hdmi_phy_base + HDMI_PHY_ANA_CFG2); |
| 689 | REG_W(0x00, hdmi_phy_base + HDMI_PHY_ANA_CFG3); |
| 690 | REG_W(0x04, hdmi_phy_pll_base + HDMI_UNI_PLL_VREG_CFG); |
| 691 | REG_W(0xD0, hdmi_phy_base + HDMI_PHY_DCC_CFG0); |
| 692 | REG_W(0x1A, hdmi_phy_base + HDMI_PHY_DCC_CFG1); |
| 693 | REG_W(0x00, hdmi_phy_base + HDMI_PHY_TXCAL_CFG0); |
| 694 | REG_W(0x00, hdmi_phy_base + HDMI_PHY_TXCAL_CFG1); |
| 695 | REG_W(0x02, hdmi_phy_base + HDMI_PHY_TXCAL_CFG2); |
| 696 | REG_W(0x05, hdmi_phy_base + HDMI_PHY_TXCAL_CFG3); |
| 697 | udelay(200); |
| 698 | break; |
| 699 | |
| 700 | case 148500000: |
| 701 | REG_W(0x81, hdmi_phy_base + HDMI_PHY_GLB_CFG); |
| 702 | REG_W(0x01, hdmi_phy_pll_base + HDMI_UNI_PLL_GLB_CFG); |
| 703 | REG_W(0x01, hdmi_phy_pll_base + HDMI_UNI_PLL_REFCLK_CFG); |
| 704 | REG_W(0x19, hdmi_phy_pll_base + HDMI_UNI_PLL_VCOLPF_CFG); |
| 705 | REG_W(0x0E, hdmi_phy_pll_base + HDMI_UNI_PLL_LPFR_CFG); |
| 706 | REG_W(0x20, hdmi_phy_pll_base + HDMI_UNI_PLL_LPFC1_CFG); |
| 707 | REG_W(0x0D, hdmi_phy_pll_base + HDMI_UNI_PLL_LPFC2_CFG); |
| 708 | REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG0); |
| 709 | REG_W(0x52, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG1); |
| 710 | REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG2); |
| 711 | REG_W(0x56, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG3); |
| 712 | REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG4); |
| 713 | REG_W(0x10, hdmi_phy_pll_base + HDMI_UNI_PLL_LKDET_CFG0); |
| 714 | REG_W(0x1A, hdmi_phy_pll_base + HDMI_UNI_PLL_LKDET_CFG1); |
| 715 | REG_W(0x05, hdmi_phy_pll_base + HDMI_UNI_PLL_LKDET_CFG2); |
| 716 | REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_POSTDIV1_CFG); |
| 717 | REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_POSTDIV2_CFG); |
| 718 | REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_POSTDIV3_CFG); |
| 719 | REG_W(0x01, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG2); |
| 720 | REG_W(0x60, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG8); |
| 721 | REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG9); |
| 722 | REG_W(0xE6, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG10); |
| 723 | REG_W(0x02, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG11); |
| 724 | REG_W(0x1F, hdmi_phy_base + HDMI_PHY_PD_CTRL0); |
| 725 | udelay(50); |
| 726 | |
| 727 | REG_W(0x0F, hdmi_phy_pll_base + HDMI_UNI_PLL_GLB_CFG); |
| 728 | REG_W(0x00, hdmi_phy_base + HDMI_PHY_PD_CTRL1); |
| 729 | REG_W(0x10, hdmi_phy_base + HDMI_PHY_ANA_CFG2); |
| 730 | REG_W(0xDB, hdmi_phy_base + HDMI_PHY_ANA_CFG0); |
| 731 | REG_W(0x43, hdmi_phy_base + HDMI_PHY_ANA_CFG1); |
| 732 | REG_W(0x02, hdmi_phy_base + HDMI_PHY_ANA_CFG2); |
| 733 | REG_W(0x00, hdmi_phy_base + HDMI_PHY_ANA_CFG3); |
| 734 | REG_W(0x04, hdmi_phy_pll_base + HDMI_UNI_PLL_VREG_CFG); |
| 735 | REG_W(0xD0, hdmi_phy_base + HDMI_PHY_DCC_CFG0); |
| 736 | REG_W(0x1A, hdmi_phy_base + HDMI_PHY_DCC_CFG1); |
| 737 | REG_W(0x00, hdmi_phy_base + HDMI_PHY_TXCAL_CFG0); |
| 738 | REG_W(0x00, hdmi_phy_base + HDMI_PHY_TXCAL_CFG1); |
| 739 | REG_W(0x02, hdmi_phy_base + HDMI_PHY_TXCAL_CFG2); |
| 740 | REG_W(0x05, hdmi_phy_base + HDMI_PHY_TXCAL_CFG3); |
| 741 | udelay(200); |
Abhishek Kharbanda | c155984 | 2012-08-13 18:45:02 -0700 | [diff] [blame] | 742 | break; |
| 743 | |
Ujwal Patel | e698fae | 2012-11-29 14:04:33 -0800 | [diff] [blame] | 744 | case 268500000: |
| 745 | REG_W(0x81, hdmi_phy_base + HDMI_PHY_GLB_CFG); |
| 746 | REG_W(0x01, hdmi_phy_pll_base + HDMI_UNI_PLL_GLB_CFG); |
| 747 | REG_W(0x01, hdmi_phy_pll_base + HDMI_UNI_PLL_REFCLK_CFG); |
| 748 | REG_W(0x19, hdmi_phy_pll_base + HDMI_UNI_PLL_VCOLPF_CFG); |
| 749 | REG_W(0x0E, hdmi_phy_pll_base + HDMI_UNI_PLL_LPFR_CFG); |
| 750 | REG_W(0x20, hdmi_phy_pll_base + HDMI_UNI_PLL_LPFC1_CFG); |
| 751 | REG_W(0x0D, hdmi_phy_pll_base + HDMI_UNI_PLL_LPFC2_CFG); |
| 752 | REG_W(0x36, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG0); |
| 753 | REG_W(0x61, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG1); |
| 754 | REG_W(0x01, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG2); |
| 755 | REG_W(0xF6, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG3); |
| 756 | REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG4); |
| 757 | REG_W(0x10, hdmi_phy_pll_base + HDMI_UNI_PLL_LKDET_CFG0); |
| 758 | REG_W(0x1A, hdmi_phy_pll_base + HDMI_UNI_PLL_LKDET_CFG1); |
| 759 | REG_W(0x05, hdmi_phy_pll_base + HDMI_UNI_PLL_LKDET_CFG2); |
| 760 | REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_POSTDIV1_CFG); |
| 761 | REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_POSTDIV2_CFG); |
| 762 | REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_POSTDIV3_CFG); |
| 763 | REG_W(0x01, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG2); |
| 764 | REG_W(0x60, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG8); |
| 765 | REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG9); |
| 766 | REG_W(0x3E, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG10); |
| 767 | REG_W(0x05, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG11); |
| 768 | REG_W(0x1F, hdmi_phy_base + HDMI_PHY_PD_CTRL0); |
| 769 | udelay(50); |
| 770 | |
| 771 | REG_W(0x0F, hdmi_phy_pll_base + HDMI_UNI_PLL_GLB_CFG); |
| 772 | REG_W(0x00, hdmi_phy_base + HDMI_PHY_PD_CTRL1); |
| 773 | REG_W(0x10, hdmi_phy_base + HDMI_PHY_ANA_CFG2); |
| 774 | REG_W(0xDB, hdmi_phy_base + HDMI_PHY_ANA_CFG0); |
| 775 | REG_W(0x43, hdmi_phy_base + HDMI_PHY_ANA_CFG1); |
| 776 | REG_W(0x05, hdmi_phy_base + HDMI_PHY_ANA_CFG2); |
| 777 | REG_W(0x00, hdmi_phy_base + HDMI_PHY_ANA_CFG3); |
| 778 | REG_W(0x04, hdmi_phy_pll_base + HDMI_UNI_PLL_VREG_CFG); |
| 779 | REG_W(0xD0, hdmi_phy_base + HDMI_PHY_DCC_CFG0); |
| 780 | REG_W(0x1A, hdmi_phy_base + HDMI_PHY_DCC_CFG1); |
| 781 | REG_W(0x00, hdmi_phy_base + HDMI_PHY_TXCAL_CFG0); |
| 782 | REG_W(0x00, hdmi_phy_base + HDMI_PHY_TXCAL_CFG1); |
| 783 | REG_W(0x11, hdmi_phy_base + HDMI_PHY_TXCAL_CFG2); |
| 784 | REG_W(0x05, hdmi_phy_base + HDMI_PHY_TXCAL_CFG3); |
| 785 | udelay(200); |
| 786 | break; |
| 787 | |
Abhishek Kharbanda | c155984 | 2012-08-13 18:45:02 -0700 | [diff] [blame] | 788 | case 297000000: |
Ujwal Patel | c801765 | 2012-11-15 18:03:01 -0800 | [diff] [blame] | 789 | REG_W(0x81, hdmi_phy_base + HDMI_PHY_GLB_CFG); |
| 790 | REG_W(0x01, hdmi_phy_pll_base + HDMI_UNI_PLL_GLB_CFG); |
| 791 | REG_W(0x01, hdmi_phy_pll_base + HDMI_UNI_PLL_REFCLK_CFG); |
| 792 | REG_W(0x19, hdmi_phy_pll_base + HDMI_UNI_PLL_VCOLPF_CFG); |
| 793 | REG_W(0x0E, hdmi_phy_pll_base + HDMI_UNI_PLL_LPFR_CFG); |
| 794 | REG_W(0x20, hdmi_phy_pll_base + HDMI_UNI_PLL_LPFC1_CFG); |
| 795 | REG_W(0x0D, hdmi_phy_pll_base + HDMI_UNI_PLL_LPFC2_CFG); |
| 796 | REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG0); |
Abhishek Kharbanda | c155984 | 2012-08-13 18:45:02 -0700 | [diff] [blame] | 797 | REG_W(0x65, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG1); |
Ujwal Patel | c801765 | 2012-11-15 18:03:01 -0800 | [diff] [blame] | 798 | REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG2); |
Abhishek Kharbanda | c155984 | 2012-08-13 18:45:02 -0700 | [diff] [blame] | 799 | REG_W(0xAC, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG3); |
| 800 | REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG4); |
| 801 | REG_W(0x10, hdmi_phy_pll_base + HDMI_UNI_PLL_LKDET_CFG0); |
| 802 | REG_W(0x1A, hdmi_phy_pll_base + HDMI_UNI_PLL_LKDET_CFG1); |
| 803 | REG_W(0x05, hdmi_phy_pll_base + HDMI_UNI_PLL_LKDET_CFG2); |
| 804 | REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_POSTDIV1_CFG); |
| 805 | REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_POSTDIV2_CFG); |
| 806 | REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_POSTDIV3_CFG); |
Ujwal Patel | c801765 | 2012-11-15 18:03:01 -0800 | [diff] [blame] | 807 | REG_W(0x01, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG2); |
Abhishek Kharbanda | c155984 | 2012-08-13 18:45:02 -0700 | [diff] [blame] | 808 | REG_W(0x60, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG8); |
| 809 | REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG9); |
| 810 | REG_W(0xCD, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG10); |
| 811 | REG_W(0x05, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG11); |
Ujwal Patel | c801765 | 2012-11-15 18:03:01 -0800 | [diff] [blame] | 812 | REG_W(0x1F, hdmi_phy_base + HDMI_PHY_PD_CTRL0); |
| 813 | udelay(50); |
| 814 | |
| 815 | REG_W(0x0F, hdmi_phy_pll_base + HDMI_UNI_PLL_GLB_CFG); |
| 816 | REG_W(0x00, hdmi_phy_base + HDMI_PHY_PD_CTRL1); |
| 817 | REG_W(0x10, hdmi_phy_base + HDMI_PHY_ANA_CFG2); |
| 818 | REG_W(0xDB, hdmi_phy_base + HDMI_PHY_ANA_CFG0); |
| 819 | REG_W(0x43, hdmi_phy_base + HDMI_PHY_ANA_CFG1); |
| 820 | REG_W(0x06, hdmi_phy_base + HDMI_PHY_ANA_CFG2); |
| 821 | REG_W(0x03, hdmi_phy_base + HDMI_PHY_ANA_CFG3); |
| 822 | REG_W(0x04, hdmi_phy_pll_base + HDMI_UNI_PLL_VREG_CFG); |
| 823 | REG_W(0xD0, hdmi_phy_base + HDMI_PHY_DCC_CFG0); |
| 824 | REG_W(0x1A, hdmi_phy_base + HDMI_PHY_DCC_CFG1); |
| 825 | REG_W(0x00, hdmi_phy_base + HDMI_PHY_TXCAL_CFG0); |
| 826 | REG_W(0x00, hdmi_phy_base + HDMI_PHY_TXCAL_CFG1); |
| 827 | REG_W(0x02, hdmi_phy_base + HDMI_PHY_TXCAL_CFG2); |
| 828 | REG_W(0x05, hdmi_phy_base + HDMI_PHY_TXCAL_CFG3); |
| 829 | udelay(200); |
Abhishek Kharbanda | c155984 | 2012-08-13 18:45:02 -0700 | [diff] [blame] | 830 | break; |
| 831 | |
Abhishek Kharbanda | c155984 | 2012-08-13 18:45:02 -0700 | [diff] [blame] | 832 | default: |
| 833 | pr_err("%s: not supported rate=%ld\n", __func__, rate); |
| 834 | } |
| 835 | |
| 836 | /* Make sure writes complete before disabling iface clock */ |
| 837 | mb(); |
| 838 | |
Vikram Mulukutla | 5d581bd | 2012-11-30 11:51:41 -0800 | [diff] [blame] | 839 | clk_disable(mdss_dsi_ahb_clk); |
| 840 | |
Abhishek Kharbanda | c155984 | 2012-08-13 18:45:02 -0700 | [diff] [blame] | 841 | if (set_power_dwn) |
| 842 | hdmi_pll_enable(); |
| 843 | |
| 844 | return 0; |
| 845 | } /* hdmi_pll_set_rate */ |
| 846 | |
Chandan Uddaraju | 09adf32 | 2012-08-16 02:55:23 -0700 | [diff] [blame] | 847 | struct clk_ops clk_ops_dsi_pixel_pll = { |
| 848 | .enable = mdss_dsi_pll_enable, |
| 849 | .disable = mdss_dsi_pll_disable, |
| 850 | .set_rate = mdss_dsi_pll_pixel_set_rate, |
| 851 | .round_rate = mdss_dsi_pll_pixel_round_rate, |
Siddhartha Agrawal | 4b0d5a6 | 2013-02-25 23:23:41 -0800 | [diff] [blame] | 852 | .handoff = mdss_dsi_pll_pixel_handoff, |
Chandan Uddaraju | 09adf32 | 2012-08-16 02:55:23 -0700 | [diff] [blame] | 853 | }; |
| 854 | |
| 855 | struct clk_ops clk_ops_dsi_byte_pll = { |
| 856 | .enable = mdss_dsi_pll_enable, |
| 857 | .disable = mdss_dsi_pll_disable, |
| 858 | .set_rate = mdss_dsi_pll_byte_set_rate, |
| 859 | .round_rate = mdss_dsi_pll_byte_round_rate, |
Siddhartha Agrawal | 4b0d5a6 | 2013-02-25 23:23:41 -0800 | [diff] [blame] | 860 | .handoff = mdss_dsi_pll_byte_handoff, |
Chandan Uddaraju | 09adf32 | 2012-08-16 02:55:23 -0700 | [diff] [blame] | 861 | }; |