Dhaval Patel | bb40871 | 2014-03-18 11:45:53 -0700 | [diff] [blame] | 1 | /* Copyright (c) 2012-2014, The Linux Foundation. All rights reserved. |
Shashank Mittal | 4bfb2e3 | 2012-04-16 10:56:27 -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. |
Siddhartha Agrawal | 3e694ea | 2013-01-23 17:01:31 -0800 | [diff] [blame] | 12 | * * Neither the name of The Linux Foundation nor the names of its |
Shashank Mittal | 4bfb2e3 | 2012-04-16 10:56:27 -0700 | [diff] [blame] | 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 <debug.h> |
| 30 | #include <reg.h> |
| 31 | #include <mipi_dsi.h> |
Shashank Mittal | 4bfb2e3 | 2012-04-16 10:56:27 -0700 | [diff] [blame] | 32 | #include <platform/iomap.h> |
| 33 | |
Siddhartha Agrawal | 1b2ed84 | 2013-05-29 18:02:28 -0700 | [diff] [blame] | 34 | #if (DISPLAY_TYPE_MDSS == 0) |
| 35 | #define MIPI_DSI0_BASE MIPI_DSI_BASE |
| 36 | #define MIPI_DSI1_BASE MIPI_DSI_BASE |
| 37 | #endif |
| 38 | |
Dhaval Patel | ee8c9b3 | 2014-08-12 16:18:50 -0700 | [diff] [blame] | 39 | #define MMSS_DSI_CLKOUT_TIMING_CTRL 0x0c4 |
| 40 | #define MMSS_DSI_PHY_TIMING_CTRL_0 0x0140 |
| 41 | #define MMSS_DSI_PHY_CTRL_0 0x0170 |
| 42 | #define MMSS_DSI_PHY_CTRL_1 0x0174 |
| 43 | #define MMSS_DSI_PHY_CTRL_2 0x0178 |
| 44 | #define MMSS_DSI_PHY_STRENGTH_CTRL_0 0x0184 |
| 45 | #define MMSS_DSI_PHY_STRENGTH_CTRL_1 0x0188 |
| 46 | #define MMSS_DSI_PHY_BIST_CTRL_0 0x01b4 |
| 47 | #define MMSS_DSI_PHY_GLBL_TEST_CTRL 0x01d4 |
| 48 | #define MMSS_DSI_PHY_LDO_CTRL 0x01dc |
| 49 | |
| 50 | #define TOTAL_TIMING_CTRL_CONFIG 12 |
| 51 | #define TOTAL_BIST_CTRL_CONFIG 6 |
| 52 | /* 4 data lanes and 1 clock lanes */ |
| 53 | #define TOTAL_LANE_COUNT 5 |
| 54 | #define CONFIG_REG_FOR_EACH_LANE 9 |
| 55 | |
Shashank Mittal | 4bfb2e3 | 2012-04-16 10:56:27 -0700 | [diff] [blame] | 56 | static void mipi_dsi_calibration(void) |
| 57 | { |
| 58 | uint32_t i = 0; |
| 59 | uint32_t term_cnt = 5000; |
| 60 | int32_t cal_busy = readl(MIPI_DSI_BASE + 0x550); |
| 61 | |
| 62 | /* DSI1_DSIPHY_REGULATOR_CAL_PWR_CFG */ |
| 63 | writel(0x01, MIPI_DSI_BASE + 0x0518); |
| 64 | |
| 65 | /* DSI1_DSIPHY_CAL_SW_CFG2 */ |
| 66 | writel(0x0, MIPI_DSI_BASE + 0x0534); |
| 67 | /* DSI1_DSIPHY_CAL_HW_CFG1 */ |
| 68 | writel(0x5a, MIPI_DSI_BASE + 0x053c); |
| 69 | /* DSI1_DSIPHY_CAL_HW_CFG3 */ |
| 70 | writel(0x10, MIPI_DSI_BASE + 0x0544); |
| 71 | /* DSI1_DSIPHY_CAL_HW_CFG4 */ |
| 72 | writel(0x01, MIPI_DSI_BASE + 0x0548); |
| 73 | /* DSI1_DSIPHY_CAL_HW_CFG0 */ |
| 74 | writel(0x01, MIPI_DSI_BASE + 0x0538); |
| 75 | |
| 76 | /* DSI1_DSIPHY_CAL_HW_TRIGGER */ |
| 77 | writel(0x01, MIPI_DSI_BASE + 0x0528); |
| 78 | |
| 79 | /* DSI1_DSIPHY_CAL_HW_TRIGGER */ |
| 80 | writel(0x00, MIPI_DSI_BASE + 0x0528); |
| 81 | |
| 82 | cal_busy = readl(MIPI_DSI_BASE + 0x550); |
| 83 | while (cal_busy & 0x10) { |
| 84 | i++; |
| 85 | if (i > term_cnt) { |
| 86 | dprintf(CRITICAL, "DSI1 PHY REGULATOR NOT READY," |
| 87 | "exceeded polling TIMEOUT!\n"); |
| 88 | break; |
| 89 | } |
| 90 | cal_busy = readl(MIPI_DSI_BASE + 0x550); |
| 91 | } |
| 92 | } |
| 93 | |
Aravind Venkateswaran | ce4dd7f | 2014-12-04 16:54:26 -0800 | [diff] [blame^] | 94 | #if (DISPLAY_TYPE_MDSS == 0) |
Shashank Mittal | 4bfb2e3 | 2012-04-16 10:56:27 -0700 | [diff] [blame] | 95 | int mipi_dsi_phy_init(struct mipi_dsi_panel_config *pinfo) |
| 96 | { |
| 97 | struct mipi_dsi_phy_ctrl *pd; |
| 98 | uint32_t i, off = 0; |
Channagoud Kadabi | 539ef72 | 2012-03-29 16:02:50 +0530 | [diff] [blame] | 99 | int mdp_rev; |
Shashank Mittal | 4bfb2e3 | 2012-04-16 10:56:27 -0700 | [diff] [blame] | 100 | |
Channagoud Kadabi | 539ef72 | 2012-03-29 16:02:50 +0530 | [diff] [blame] | 101 | mdp_rev = mdp_get_revision(); |
Shashank Mittal | 4bfb2e3 | 2012-04-16 10:56:27 -0700 | [diff] [blame] | 102 | |
Channagoud Kadabi | 539ef72 | 2012-03-29 16:02:50 +0530 | [diff] [blame] | 103 | if (MDP_REV_303 == mdp_rev || MDP_REV_41 == mdp_rev) { |
| 104 | writel(0x00000001, DSIPHY_SW_RESET); |
| 105 | writel(0x00000000, DSIPHY_SW_RESET); |
Shashank Mittal | 4bfb2e3 | 2012-04-16 10:56:27 -0700 | [diff] [blame] | 106 | |
Channagoud Kadabi | 539ef72 | 2012-03-29 16:02:50 +0530 | [diff] [blame] | 107 | pd = (pinfo->dsi_phy_config); |
Shashank Mittal | 4bfb2e3 | 2012-04-16 10:56:27 -0700 | [diff] [blame] | 108 | |
Channagoud Kadabi | 539ef72 | 2012-03-29 16:02:50 +0530 | [diff] [blame] | 109 | off = 0x02cc; /* regulator ctrl 0 */ |
| 110 | for (i = 0; i < 4; i++) { |
| 111 | writel(pd->regulator[i], MIPI_DSI_BASE + off); |
| 112 | off += 4; |
| 113 | } |
Shashank Mittal | 4bfb2e3 | 2012-04-16 10:56:27 -0700 | [diff] [blame] | 114 | |
Channagoud Kadabi | 539ef72 | 2012-03-29 16:02:50 +0530 | [diff] [blame] | 115 | off = 0x0260; /* phy timig ctrl 0 */ |
| 116 | for (i = 0; i < 11; i++) { |
| 117 | writel(pd->timing[i], MIPI_DSI_BASE + off); |
| 118 | off += 4; |
| 119 | } |
Shashank Mittal | 4bfb2e3 | 2012-04-16 10:56:27 -0700 | [diff] [blame] | 120 | |
Channagoud Kadabi | 539ef72 | 2012-03-29 16:02:50 +0530 | [diff] [blame] | 121 | /* T_CLK_POST, T_CLK_PRE for CLK lane P/N HS 200 mV timing |
| 122 | length should > data lane HS timing length */ |
| 123 | writel(0xa1e, DSI_CLKOUT_TIMING_CTRL); |
Shashank Mittal | 4bfb2e3 | 2012-04-16 10:56:27 -0700 | [diff] [blame] | 124 | |
Channagoud Kadabi | 539ef72 | 2012-03-29 16:02:50 +0530 | [diff] [blame] | 125 | off = 0x0290; /* ctrl 0 */ |
| 126 | for (i = 0; i < 4; i++) { |
| 127 | writel(pd->ctrl[i], MIPI_DSI_BASE + off); |
| 128 | off += 4; |
| 129 | } |
Shashank Mittal | 4bfb2e3 | 2012-04-16 10:56:27 -0700 | [diff] [blame] | 130 | |
Channagoud Kadabi | 539ef72 | 2012-03-29 16:02:50 +0530 | [diff] [blame] | 131 | off = 0x02a0; /* strength 0 */ |
| 132 | for (i = 0; i < 4; i++) { |
| 133 | writel(pd->strength[i], MIPI_DSI_BASE + off); |
| 134 | off += 4; |
| 135 | } |
Shashank Mittal | 4bfb2e3 | 2012-04-16 10:56:27 -0700 | [diff] [blame] | 136 | |
Channagoud Kadabi | 539ef72 | 2012-03-29 16:02:50 +0530 | [diff] [blame] | 137 | if (1 == pinfo->num_of_lanes) |
| 138 | pd->pll[10] |= 0x8; |
Shashank Mittal | 4bfb2e3 | 2012-04-16 10:56:27 -0700 | [diff] [blame] | 139 | |
Channagoud Kadabi | 539ef72 | 2012-03-29 16:02:50 +0530 | [diff] [blame] | 140 | off = 0x0204; /* pll ctrl 1, skip 0 */ |
| 141 | for (i = 1; i < 21; i++) { |
| 142 | writel(pd->pll[i], MIPI_DSI_BASE + off); |
| 143 | off += 4; |
| 144 | } |
| 145 | |
| 146 | /* pll ctrl 0 */ |
| 147 | writel(pd->pll[0], MIPI_DSI_BASE + 0x200); |
| 148 | writel((pd->pll[0] | 0x01), MIPI_DSI_BASE + 0x200); |
| 149 | /* lane swp ctrol */ |
| 150 | if (pinfo->lane_swap) |
| 151 | writel(pinfo->lane_swap, MIPI_DSI_BASE + 0xac); |
| 152 | } else { |
| 153 | writel(0x0001, MIPI_DSI_BASE + 0x128); /* start phy sw reset */ |
| 154 | writel(0x0000, MIPI_DSI_BASE + 0x128); /* end phy w reset */ |
| 155 | writel(0x0003, MIPI_DSI_BASE + 0x500); /* regulator_ctrl_0 */ |
| 156 | writel(0x0001, MIPI_DSI_BASE + 0x504); /* regulator_ctrl_1 */ |
| 157 | writel(0x0001, MIPI_DSI_BASE + 0x508); /* regulator_ctrl_2 */ |
| 158 | writel(0x0000, MIPI_DSI_BASE + 0x50c); /* regulator_ctrl_3 */ |
| 159 | writel(0x0100, MIPI_DSI_BASE + 0x510); /* regulator_ctrl_4 */ |
| 160 | |
| 161 | pd = (pinfo->dsi_phy_config); |
| 162 | |
| 163 | off = 0x0480; /* strength 0 - 2 */ |
| 164 | for (i = 0; i < 3; i++) { |
| 165 | writel(pd->strength[i], MIPI_DSI_BASE + off); |
| 166 | off += 4; |
| 167 | } |
| 168 | |
| 169 | off = 0x0470; /* ctrl 0 - 3 */ |
| 170 | for (i = 0; i < 4; i++) { |
| 171 | writel(pd->ctrl[i], MIPI_DSI_BASE + off); |
| 172 | off += 4; |
| 173 | } |
| 174 | |
| 175 | off = 0x0500; /* regulator ctrl 0 - 4 */ |
| 176 | for (i = 0; i < 5; i++) { |
| 177 | writel(pd->regulator[i], MIPI_DSI_BASE + off); |
| 178 | off += 4; |
| 179 | } |
| 180 | mipi_dsi_calibration(); |
| 181 | |
| 182 | off = 0x0204; /* pll ctrl 1 - 19, skip 0 */ |
| 183 | for (i = 1; i < 20; i++) { |
| 184 | writel(pd->pll[i], MIPI_DSI_BASE + off); |
| 185 | off += 4; |
| 186 | } |
| 187 | |
| 188 | /* pll ctrl 0 */ |
| 189 | writel(pd->pll[0], MIPI_DSI_BASE + 0x200); |
| 190 | writel((pd->pll[0] | 0x01), MIPI_DSI_BASE + 0x200); |
| 191 | |
| 192 | /* Check that PHY is ready */ |
| 193 | while (!(readl(DSIPHY_PLL_RDY) & 0x01)) |
| 194 | udelay(1); |
| 195 | |
| 196 | writel(0x202D, DSI_CLKOUT_TIMING_CTRL); |
| 197 | |
| 198 | off = 0x0440; /* phy timing ctrl 0 - 11 */ |
| 199 | for (i = 0; i < 12; i++) { |
| 200 | writel(pd->timing[i], MIPI_DSI_BASE + off); |
| 201 | off += 4; |
| 202 | } |
Shashank Mittal | 4bfb2e3 | 2012-04-16 10:56:27 -0700 | [diff] [blame] | 203 | } |
| 204 | return 0; |
| 205 | } |
Aravind Venkateswaran | ce4dd7f | 2014-12-04 16:54:26 -0800 | [diff] [blame^] | 206 | #endif |
Siddhartha Agrawal | 3e694ea | 2013-01-23 17:01:31 -0800 | [diff] [blame] | 207 | |
Siddhartha Agrawal | 1b2ed84 | 2013-05-29 18:02:28 -0700 | [diff] [blame] | 208 | void mdss_dsi_phy_sw_reset(uint32_t ctl_base) |
Chandan Uddaraju | 932723b | 2013-02-21 18:36:20 -0800 | [diff] [blame] | 209 | { |
| 210 | /* start phy sw reset */ |
Siddhartha Agrawal | 1b2ed84 | 2013-05-29 18:02:28 -0700 | [diff] [blame] | 211 | writel(0x0001, ctl_base + 0x012c); |
Chandan Uddaraju | 932723b | 2013-02-21 18:36:20 -0800 | [diff] [blame] | 212 | udelay(1000); |
| 213 | |
| 214 | /* end phy sw reset */ |
Siddhartha Agrawal | 1b2ed84 | 2013-05-29 18:02:28 -0700 | [diff] [blame] | 215 | writel(0x0000, ctl_base + 0x012c); |
Chandan Uddaraju | 932723b | 2013-02-21 18:36:20 -0800 | [diff] [blame] | 216 | udelay(100); |
| 217 | } |
| 218 | |
Padmanabhan Komanduru | 2232c14 | 2014-10-29 00:06:24 +0530 | [diff] [blame] | 219 | int mdss_dsi_phy_regulator_init(struct mdss_dsi_phy_ctrl *pd, uint32_t phy_base) |
Siddhartha Agrawal | 1b2ed84 | 2013-05-29 18:02:28 -0700 | [diff] [blame] | 220 | { |
| 221 | /* DSI0 and DSI1 have a common regulator */ |
| 222 | |
Padmanabhan Komanduru | cdc651e | 2014-03-25 20:25:55 +0530 | [diff] [blame] | 223 | uint32_t off = 0x0280; /* phy regulator ctrl settings */ |
Siddhartha Agrawal | 1b2ed84 | 2013-05-29 18:02:28 -0700 | [diff] [blame] | 224 | |
Padmanabhan Komanduru | 2232c14 | 2014-10-29 00:06:24 +0530 | [diff] [blame] | 225 | if (pd->regulator_mode == DSI_PHY_REGULATOR_LDO_MODE) { |
| 226 | /* Regulator ctrl 0 */ |
| 227 | writel(0x00, DSI0_PHY_BASE + off + (4 * 0)); |
| 228 | /* Regulator ctrl - CAL_PWD_CFG */ |
| 229 | writel(pd->regulator[6], DSI0_PHY_BASE + off + (4 * 6)); |
| 230 | /* Add h/w recommended delay */ |
| 231 | udelay(1000); |
| 232 | /* Regulator ctrl - TEST */ |
| 233 | writel(pd->regulator[5], DSI0_PHY_BASE + off + (4 * 5)); |
| 234 | /* Regulator ctrl 3 */ |
| 235 | writel(pd->regulator[3], DSI0_PHY_BASE + off + (4 * 3)); |
| 236 | /* Regulator ctrl 2 */ |
| 237 | writel(pd->regulator[2], DSI0_PHY_BASE + off + (4 * 2)); |
| 238 | /* Regulator ctrl 1 */ |
| 239 | writel(pd->regulator[1], DSI0_PHY_BASE + off + (4 * 1)); |
| 240 | /* Regulator ctrl 4 */ |
| 241 | writel(pd->regulator[4], DSI0_PHY_BASE + off + (4 * 4)); |
| 242 | /* LDO ctrl */ |
| 243 | if (readl(MIPI_DSI0_BASE) == DSI_HW_REV_103_1) /* 8916/8939 */ |
| 244 | writel(0x05, phy_base + 0x01dc); |
| 245 | else if (readl(MIPI_DSI0_BASE) == DSI_HW_REV_103) /* 8994 */ |
| 246 | writel(0x1d, phy_base + 0x01dc); |
| 247 | else |
| 248 | writel(0x0d, phy_base + 0x01dc); |
| 249 | dmb(); |
| 250 | } else { |
| 251 | /* Regulator ctrl 0 */ |
| 252 | writel(0x00, DSI0_PHY_BASE + off + (4 * 0)); |
| 253 | /* Regulator ctrl - CAL_PWD_CFG */ |
| 254 | writel(pd->regulator[6], DSI0_PHY_BASE + off + (4 * 6)); |
| 255 | /* Add h/w recommended delay */ |
| 256 | udelay(1000); |
| 257 | /* Regulator ctrl 1 */ |
| 258 | writel(pd->regulator[1], DSI0_PHY_BASE + off + (4 * 1)); |
| 259 | /* Regulator ctrl 2 */ |
| 260 | writel(pd->regulator[2], DSI0_PHY_BASE + off + (4 * 2)); |
| 261 | /* Regulator ctrl 3 */ |
| 262 | writel(pd->regulator[3], DSI0_PHY_BASE + off + (4 * 3)); |
| 263 | /* Regulator ctrl 4 */ |
| 264 | writel(pd->regulator[4], DSI0_PHY_BASE + off + (4 * 4)); |
| 265 | /* LDO ctrl */ |
| 266 | writel(0x00, phy_base + 0x01dc); |
| 267 | /* Regulator ctrl 0 */ |
| 268 | writel(pd->regulator[0], DSI0_PHY_BASE + off + (4 * 0)); |
| 269 | dmb(); |
| 270 | } |
Siddhartha Agrawal | 1b2ed84 | 2013-05-29 18:02:28 -0700 | [diff] [blame] | 271 | } |
| 272 | |
Terence Hampson | f49ff4e | 2013-06-18 15:11:31 -0400 | [diff] [blame] | 273 | int mdss_dsi_v2_phy_init(struct mipi_dsi_panel_config *pinfo, uint32_t ctl_base) |
| 274 | { |
| 275 | struct mdss_dsi_phy_ctrl *pd; |
| 276 | uint32_t i, ln, off = 0, offset; |
| 277 | |
| 278 | pd = pinfo->mdss_dsi_phy_config; |
| 279 | /* DSI PHY configuration */ |
| 280 | off = 0x480; |
| 281 | writel(pd->strength[0], ctl_base + off + (4 * 0)); |
| 282 | writel(pd->strength[1], ctl_base + off + (4 * 2)); |
| 283 | |
| 284 | off = 0x470; |
| 285 | writel(0x10, ctl_base + off + (4 * 3)); |
| 286 | writel(0x5F, ctl_base + off + (4 * 0)); |
| 287 | |
| 288 | off = 0x500; |
Xiaoming Zhou | 7c9e1ee | 2013-07-18 10:51:41 -0400 | [diff] [blame] | 289 | /* use LDO mode */ |
| 290 | writel(0x25, ctl_base + 0x4B0); |
Terence Hampson | f49ff4e | 2013-06-18 15:11:31 -0400 | [diff] [blame] | 291 | for (i = 0; i < 5; i++) |
| 292 | writel(pd->regulator[i], ctl_base + off + (4 * i)); |
| 293 | |
| 294 | mipi_dsi_calibration(); |
| 295 | |
| 296 | /* 4 lanes + clk lane configuration */ |
| 297 | /* lane config n * (0 - 4) & DataPath setup */ |
| 298 | for (ln = 0; ln < 5; ln++) { |
| 299 | off = 0x0300 + (ln * 0x40); |
| 300 | for (i = 0; i < 9; i++) { |
| 301 | offset = i + (ln * 9); |
| 302 | writel(pd->laneCfg[offset], ctl_base + off); |
| 303 | dmb(); |
| 304 | off += 4; |
| 305 | } |
| 306 | } |
| 307 | |
| 308 | off = 0x440; |
| 309 | for (i = 0; i < 12; i++) |
| 310 | writel(pd->timing[i], ctl_base + off + (4 * i)); |
| 311 | |
| 312 | if (1 == pinfo->num_of_lanes) |
| 313 | writel(0x8, ctl_base + 0x200 + (4 * 11)); |
| 314 | |
| 315 | |
| 316 | if (pinfo->lane_swap) |
| 317 | writel(pinfo->lane_swap, ctl_base + 0x0ac); |
| 318 | |
| 319 | /* T_CLK_POST, T_CLK_PRE for CLK lane P/N HS 200 mV timing |
| 320 | length should > data lane HS timing length */ |
| 321 | writel(0x41b, ctl_base + 0x0c0); |
| 322 | return 0; |
| 323 | } |
| 324 | |
Dhaval Patel | ee8c9b3 | 2014-08-12 16:18:50 -0700 | [diff] [blame] | 325 | static int mdss_dsi_phy_28nm_init(struct mipi_dsi_panel_config *pinfo, |
Padmanabhan Komanduru | cdc651e | 2014-03-25 20:25:55 +0530 | [diff] [blame] | 326 | uint32_t ctl_base, uint32_t phy_base) |
Siddhartha Agrawal | 3e694ea | 2013-01-23 17:01:31 -0800 | [diff] [blame] | 327 | { |
| 328 | struct mdss_dsi_phy_ctrl *pd; |
| 329 | uint32_t i, off = 0, ln, offset; |
| 330 | |
Terence Hampson | f49ff4e | 2013-06-18 15:11:31 -0400 | [diff] [blame] | 331 | if (mdp_get_revision() == MDP_REV_304) |
| 332 | return mdss_dsi_v2_phy_init(pinfo, ctl_base); |
| 333 | |
Siddhartha Agrawal | 3e694ea | 2013-01-23 17:01:31 -0800 | [diff] [blame] | 334 | pd = (pinfo->mdss_dsi_phy_config); |
| 335 | |
| 336 | /* Strength ctrl 0 */ |
Padmanabhan Komanduru | cdc651e | 2014-03-25 20:25:55 +0530 | [diff] [blame] | 337 | writel(pd->strength[0], phy_base + 0x0184); |
Siddhartha Agrawal | 3e694ea | 2013-01-23 17:01:31 -0800 | [diff] [blame] | 338 | |
Padmanabhan Komanduru | 2232c14 | 2014-10-29 00:06:24 +0530 | [diff] [blame] | 339 | mdss_dsi_phy_regulator_init(pd, phy_base); |
Chandan Uddaraju | 932723b | 2013-02-21 18:36:20 -0800 | [diff] [blame] | 340 | |
Padmanabhan Komanduru | cdc651e | 2014-03-25 20:25:55 +0530 | [diff] [blame] | 341 | off = 0x0140; /* phy timing ctrl 0 - 11 */ |
Siddhartha Agrawal | 3e694ea | 2013-01-23 17:01:31 -0800 | [diff] [blame] | 342 | for (i = 0; i < 12; i++) { |
Padmanabhan Komanduru | cdc651e | 2014-03-25 20:25:55 +0530 | [diff] [blame] | 343 | writel(pd->timing[i], phy_base + off); |
Siddhartha Agrawal | 3e694ea | 2013-01-23 17:01:31 -0800 | [diff] [blame] | 344 | dmb(); |
| 345 | off += 4; |
| 346 | } |
| 347 | |
| 348 | /* MMSS_DSI_0_PHY_DSIPHY_CTRL_1 */ |
Padmanabhan Komanduru | cdc651e | 2014-03-25 20:25:55 +0530 | [diff] [blame] | 349 | writel(0x00, phy_base + 0x0174); |
Siddhartha Agrawal | 3e694ea | 2013-01-23 17:01:31 -0800 | [diff] [blame] | 350 | /* MMSS_DSI_0_PHY_DSIPHY_CTRL_0 */ |
Padmanabhan Komanduru | cdc651e | 2014-03-25 20:25:55 +0530 | [diff] [blame] | 351 | writel(0x5f, phy_base + 0x0170); |
Siddhartha Agrawal | 3e694ea | 2013-01-23 17:01:31 -0800 | [diff] [blame] | 352 | |
Siddhartha Agrawal | 3e694ea | 2013-01-23 17:01:31 -0800 | [diff] [blame] | 353 | dmb(); |
| 354 | /* 4 lanes + clk lane configuration */ |
| 355 | /* lane config n * (0 - 4) & DataPath setup */ |
| 356 | for (ln = 0; ln < 5; ln++) { |
Padmanabhan Komanduru | cdc651e | 2014-03-25 20:25:55 +0530 | [diff] [blame] | 357 | off = (ln * 0x40); |
Siddhartha Agrawal | 3e694ea | 2013-01-23 17:01:31 -0800 | [diff] [blame] | 358 | for (i = 0; i < 9; i++) { |
| 359 | offset = i + (ln * 9); |
Padmanabhan Komanduru | cdc651e | 2014-03-25 20:25:55 +0530 | [diff] [blame] | 360 | writel(pd->laneCfg[offset], phy_base + off); |
Siddhartha Agrawal | 3e694ea | 2013-01-23 17:01:31 -0800 | [diff] [blame] | 361 | dmb(); |
| 362 | off += 4; |
| 363 | } |
| 364 | } |
| 365 | |
| 366 | /* MMSS_DSI_0_PHY_DSIPHY_CTRL_0 */ |
Padmanabhan Komanduru | cdc651e | 2014-03-25 20:25:55 +0530 | [diff] [blame] | 367 | writel(0x5f, phy_base + 0x0170); |
Siddhartha Agrawal | 3e694ea | 2013-01-23 17:01:31 -0800 | [diff] [blame] | 368 | |
Siddhartha Agrawal | 1b2ed84 | 2013-05-29 18:02:28 -0700 | [diff] [blame] | 369 | /* DSI_PHY_DSIPHY_GLBL_TEST_CTRL */ |
Vineet Bajaj | 2f08a36 | 2014-07-24 20:50:42 +0530 | [diff] [blame] | 370 | if (phy_base == DSI0_PHY_BASE || |
| 371 | (readl(MIPI_DSI0_BASE) == DSI_HW_REV_103_1)) |
Padmanabhan Komanduru | cdc651e | 2014-03-25 20:25:55 +0530 | [diff] [blame] | 372 | writel(0x01, phy_base + 0x01d4); |
Siddhartha Agrawal | 1b2ed84 | 2013-05-29 18:02:28 -0700 | [diff] [blame] | 373 | else |
Padmanabhan Komanduru | cdc651e | 2014-03-25 20:25:55 +0530 | [diff] [blame] | 374 | writel(0x00, phy_base + 0x01d4); |
Siddhartha Agrawal | 1b2ed84 | 2013-05-29 18:02:28 -0700 | [diff] [blame] | 375 | |
Siddhartha Agrawal | 3e694ea | 2013-01-23 17:01:31 -0800 | [diff] [blame] | 376 | dmb(); |
| 377 | |
Padmanabhan Komanduru | cdc651e | 2014-03-25 20:25:55 +0530 | [diff] [blame] | 378 | off = 0x01b4; /* phy BIST ctrl 0 - 5 */ |
Siddhartha Agrawal | 3e694ea | 2013-01-23 17:01:31 -0800 | [diff] [blame] | 379 | for (i = 0; i < 6; i++) { |
Padmanabhan Komanduru | cdc651e | 2014-03-25 20:25:55 +0530 | [diff] [blame] | 380 | writel(pd->bistCtrl[i], phy_base + off); |
Siddhartha Agrawal | 3e694ea | 2013-01-23 17:01:31 -0800 | [diff] [blame] | 381 | off += 4; |
| 382 | } |
| 383 | dmb(); |
| 384 | |
| 385 | /* DSI_0_CLKOUT_TIMING_CTRL */ |
Siddhartha Agrawal | 1b2ed84 | 2013-05-29 18:02:28 -0700 | [diff] [blame] | 386 | writel(0x41b, ctl_base + 0x0c4); |
Siddhartha Agrawal | 3e694ea | 2013-01-23 17:01:31 -0800 | [diff] [blame] | 387 | dmb(); |
| 388 | |
| 389 | } |
Xiaoming Zhou | 03fd48b | 2014-07-31 15:24:41 -0400 | [diff] [blame] | 390 | |
| 391 | void mdss_dsi_phy_contention_detection( |
| 392 | struct mipi_dsi_panel_config *pinfo, |
| 393 | uint32_t phy_base) |
| 394 | { |
| 395 | struct mdss_dsi_phy_ctrl *pd; |
| 396 | |
| 397 | if (mdp_get_revision() == MDP_REV_304) |
| 398 | return; |
| 399 | |
| 400 | pd = (pinfo->mdss_dsi_phy_config); |
| 401 | writel(pd->strength[1], phy_base + 0x0188); |
| 402 | dmb(); |
| 403 | } |
| 404 | |
Dhaval Patel | ee8c9b3 | 2014-08-12 16:18:50 -0700 | [diff] [blame] | 405 | static int mdss_dsi_phy_20nm_init(struct mipi_dsi_panel_config *pinfo, |
| 406 | uint32_t ctl_base, uint32_t phy_base) |
| 407 | { |
| 408 | struct mdss_dsi_phy_ctrl *pd = pinfo->mdss_dsi_phy_config; |
| 409 | uint32_t i, off = 0, ln, offset; |
| 410 | |
| 411 | /* Strength ctrl 0 */ |
| 412 | writel(pd->strength[0], phy_base + MMSS_DSI_PHY_STRENGTH_CTRL_0); |
| 413 | |
Padmanabhan Komanduru | 2232c14 | 2014-10-29 00:06:24 +0530 | [diff] [blame] | 414 | mdss_dsi_phy_regulator_init(pd, phy_base); |
Dhaval Patel | ee8c9b3 | 2014-08-12 16:18:50 -0700 | [diff] [blame] | 415 | |
| 416 | off = MMSS_DSI_PHY_TIMING_CTRL_0; |
| 417 | for (i = 0; i < TOTAL_TIMING_CTRL_CONFIG; i++, off += 4) { |
| 418 | writel(pd->timing[i], phy_base + off); |
| 419 | dmb(); |
| 420 | } |
| 421 | |
| 422 | /* Currently the Phy settings for the DSI 0 is done in clk prepare*/ |
| 423 | if (phy_base == DSI1_PHY_BASE) { |
| 424 | writel(0x00, phy_base + MMSS_DSI_PHY_CTRL_1); |
| 425 | writel(0x05, phy_base + MMSS_DSI_PHY_CTRL_0); |
| 426 | dmb(); |
| 427 | |
| 428 | writel(0x7f, phy_base + MMSS_DSI_PHY_CTRL_0); |
| 429 | dmb(); |
| 430 | |
| 431 | /* BITCLK_HS_SEL should be set to 0 for left */ |
| 432 | writel(0x00, phy_base + MMSS_DSI_PHY_GLBL_TEST_CTRL); |
| 433 | |
| 434 | writel(0x00, phy_base + MMSS_DSI_PHY_CTRL_2); |
| 435 | writel(0x02, phy_base + MMSS_DSI_PHY_CTRL_2); |
| 436 | writel(0x03, phy_base + MMSS_DSI_PHY_CTRL_2); |
| 437 | dmb(); |
| 438 | } |
| 439 | |
| 440 | writel(pd->strength[1], phy_base + MMSS_DSI_PHY_STRENGTH_CTRL_1); |
| 441 | dmb(); |
| 442 | |
| 443 | for (ln = 0; ln < TOTAL_LANE_COUNT; ln++) { |
| 444 | off = (ln * 0x40); |
| 445 | for (i = 0; i < CONFIG_REG_FOR_EACH_LANE; i++, off += 4) { |
| 446 | offset = i + (ln * CONFIG_REG_FOR_EACH_LANE); |
| 447 | writel(pd->laneCfg[offset], phy_base + off); |
| 448 | dmb(); |
| 449 | } |
| 450 | } |
| 451 | |
| 452 | dmb(); |
| 453 | |
| 454 | off = MMSS_DSI_PHY_BIST_CTRL_0; |
| 455 | for (i = 0; i < TOTAL_BIST_CTRL_CONFIG; i++, off +=4) { |
| 456 | writel(pd->bistCtrl[i], phy_base + off); |
| 457 | } |
| 458 | dmb(); |
| 459 | |
| 460 | writel(0x41b, ctl_base + MMSS_DSI_CLKOUT_TIMING_CTRL); |
| 461 | dmb(); |
| 462 | } |
| 463 | |
| 464 | int mdss_dsi_phy_init (struct mipi_dsi_panel_config *pinfo, |
| 465 | uint32_t ctl_base, uint32_t phy_base) |
| 466 | { |
| 467 | int ret; |
| 468 | |
| 469 | if (pinfo->mdss_dsi_phy_config->is_pll_20nm) |
| 470 | ret = mdss_dsi_phy_20nm_init(pinfo, ctl_base, phy_base); |
| 471 | else |
| 472 | ret = mdss_dsi_phy_28nm_init(pinfo, ctl_base, phy_base); |
| 473 | |
| 474 | return ret; |
| 475 | } |