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