Asaf Penso | b8f524c | 2013-05-20 12:32:31 +0300 | [diff] [blame] | 1 | /* Copyright (c) 2013, The Linux Foundation. All rights reserved. |
| 2 | * |
| 3 | * Redistribution and use in source and binary forms, with or without |
| 4 | * modification, are permitted provided that the following conditions |
| 5 | * are met: |
| 6 | * * Redistributions of source code must retain the above copyright |
| 7 | * notice, this list of conditions and the following disclaimer. |
| 8 | * * Redistributions in binary form must reproduce the above copyright |
| 9 | * notice, this list of conditions and the following disclaimer in |
| 10 | * the documentation and/or other materials provided with the |
| 11 | * distribution. |
| 12 | * * Neither the name of The Linux Foundation nor the names of its |
| 13 | * contributors may be used to endorse or promote products derived |
| 14 | * from this software without specific prior written permission. |
| 15 | * |
| 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 17 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 18 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
| 19 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
| 20 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
| 21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
| 22 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS |
| 23 | * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED |
| 24 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
| 25 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT |
| 26 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
| 27 | * SUCH DAMAGE. |
| 28 | */ |
| 29 | |
| 30 | #include "edp.h" |
| 31 | #include "mdp5.h" |
| 32 | |
| 33 | #define RGB_COMPONENTS 3 |
| 34 | #define MAX_NUMBER_EDP_LANES 4 |
| 35 | |
Kuogee Hsieh | ad69c3c | 2013-08-01 14:34:29 -0700 | [diff] [blame] | 36 | static struct msm_panel_info *edp_pinfo; |
| 37 | |
Asaf Penso | b8f524c | 2013-05-20 12:32:31 +0300 | [diff] [blame] | 38 | static void edp_config_sync(void) |
| 39 | { |
| 40 | int ret = 0; |
| 41 | |
| 42 | ret = edp_read(EDP_BASE + 0xc); /* EDP_CONFIGURATION_CTRL */ |
| 43 | ret &= ~0x733; |
| 44 | ret |= (0x55 & 0x733); |
| 45 | edp_write(EDP_BASE + 0xc, ret); |
| 46 | edp_write(EDP_BASE + 0xc, 0x55); /* EDP_CONFIGURATION_CTRL */ |
| 47 | } |
| 48 | |
| 49 | static void edp_config_sw_div(void) |
| 50 | { |
| 51 | edp_write(EDP_BASE + 0x14, 0x13b); /* EDP_SOFTWARE_MVID */ |
| 52 | edp_write(EDP_BASE + 0x18, 0x266); /* EDP_SOFTWARE_NVID */ |
| 53 | } |
| 54 | |
| 55 | static void edp_config_static_mdiv(void) |
| 56 | { |
| 57 | int ret = 0; |
| 58 | |
| 59 | ret = edp_read(EDP_BASE + 0xc); /* EDP_CONFIGURATION_CTRL */ |
| 60 | edp_write(EDP_BASE + 0xc, ret | 0x2); /* EDP_CONFIGURATION_CTRL */ |
| 61 | edp_write(EDP_BASE + 0xc, 0x57); /* EDP_CONFIGURATION_CTRL */ |
| 62 | } |
| 63 | |
Kuogee Hsieh | ad69c3c | 2013-08-01 14:34:29 -0700 | [diff] [blame] | 64 | static void edp_config_tu(void) |
Asaf Penso | b8f524c | 2013-05-20 12:32:31 +0300 | [diff] [blame] | 65 | { |
Kuogee Hsieh | ad69c3c | 2013-08-01 14:34:29 -0700 | [diff] [blame] | 66 | /* temporary */ |
| 67 | edp_write(EDP_BASE + 0x160, 0x2b); |
| 68 | edp_write(EDP_BASE + 0x15c, 0x00320033); |
| 69 | edp_write(EDP_BASE + 0x34, 0x0023001a); |
| 70 | |
| 71 | } |
| 72 | |
| 73 | static void edp_config_timing(struct msm_panel_info *pinfo) |
| 74 | { |
| 75 | unsigned long total_ver, total_hor; |
| 76 | unsigned long data; |
| 77 | |
| 78 | dprintf(INFO, "%s: width=%d hporch= %d %d %d\n", __func__, |
| 79 | pinfo->xres, pinfo->lcdc.h_back_porch, |
| 80 | pinfo->lcdc.h_front_porch, pinfo->lcdc.h_pulse_width); |
| 81 | |
| 82 | dprintf(INFO, "%s: height=%d vporch= %d %d %d\n", __func__, |
| 83 | pinfo->yres, pinfo->lcdc.v_back_porch, |
| 84 | pinfo->lcdc.v_front_porch, pinfo->lcdc.v_pulse_width); |
| 85 | |
| 86 | total_hor = pinfo->xres + pinfo->lcdc.h_back_porch + |
| 87 | pinfo->lcdc.h_front_porch + pinfo->lcdc.h_pulse_width; |
| 88 | |
| 89 | total_ver = pinfo->yres + pinfo->lcdc.v_back_porch + |
| 90 | pinfo->lcdc.v_front_porch + pinfo->lcdc.v_pulse_width; |
| 91 | |
| 92 | data = total_ver; |
| 93 | data <<= 16; |
| 94 | data |= total_hor; |
| 95 | edp_write(EDP_BASE + 0x1c, data); /* EDP_TOTAL_HOR_VER */ |
| 96 | |
| 97 | data = (pinfo->lcdc.v_back_porch + pinfo->lcdc.v_pulse_width); |
| 98 | data <<= 16; |
| 99 | data |= (pinfo->lcdc.h_back_porch + pinfo->lcdc.h_pulse_width); |
| 100 | edp_write(EDP_BASE + 0x20, data); /* EDP_START_HOR_VER_FROM_SYNC */ |
| 101 | |
| 102 | data = pinfo->lcdc.v_pulse_width; |
| 103 | data <<= 16; |
| 104 | data |= pinfo->lcdc.h_pulse_width; |
| 105 | edp_write(EDP_BASE + 0x24, data); /* EDP_HSYNC_VSYNC_WIDTH_POLARITY */ |
| 106 | |
| 107 | data = pinfo->yres; |
| 108 | data <<= 16; |
| 109 | data |= pinfo->xres; |
| 110 | edp_write(EDP_BASE + 0x28, data); /* EDP_ACTIVE_HOR_VER */ |
Asaf Penso | b8f524c | 2013-05-20 12:32:31 +0300 | [diff] [blame] | 111 | } |
| 112 | |
| 113 | static void edp_enable(int enable) |
| 114 | { |
| 115 | edp_write(EDP_BASE + 0x8, 0x0); /* EDP_STATE_CTRL */ |
| 116 | edp_write(EDP_BASE + 0x8, 0x40); /* EDP_STATE_CTRL */ |
Kuogee Hsieh | ad69c3c | 2013-08-01 14:34:29 -0700 | [diff] [blame] | 117 | edp_write(EDP_BASE + 0x4, 0x01); /* EDP_MAINLINK_CTRL */ |
Asaf Penso | b8f524c | 2013-05-20 12:32:31 +0300 | [diff] [blame] | 118 | } |
| 119 | |
Kuogee Hsieh | ad69c3c | 2013-08-01 14:34:29 -0700 | [diff] [blame] | 120 | static void edp_disable(int enable) |
Asaf Penso | b8f524c | 2013-05-20 12:32:31 +0300 | [diff] [blame] | 121 | { |
Kuogee Hsieh | ad69c3c | 2013-08-01 14:34:29 -0700 | [diff] [blame] | 122 | edp_write(EDP_BASE + 0x8, 0x0); /* EDP_STATE_CTRL */ |
| 123 | edp_write(EDP_BASE + 0x4, 0x00); /* EDP_MAINLINK_CTRL */ |
Asaf Penso | b8f524c | 2013-05-20 12:32:31 +0300 | [diff] [blame] | 124 | } |
| 125 | |
| 126 | int edp_on(void) |
| 127 | { |
Kuogee Hsieh | ad69c3c | 2013-08-01 14:34:29 -0700 | [diff] [blame] | 128 | mdss_edp_pll_configure(); |
| 129 | mdss_edp_phy_pll_ready(); |
Asaf Penso | b8f524c | 2013-05-20 12:32:31 +0300 | [diff] [blame] | 130 | edp_phy_misc_cfg(); |
| 131 | edp_config_sync(); |
| 132 | edp_config_sw_div(); |
| 133 | edp_config_static_mdiv(); |
Kuogee Hsieh | ad69c3c | 2013-08-01 14:34:29 -0700 | [diff] [blame] | 134 | edp_config_timing(edp_pinfo); |
| 135 | edp_config_tu(); |
Asaf Penso | b8f524c | 2013-05-20 12:32:31 +0300 | [diff] [blame] | 136 | |
Kuogee Hsieh | ad69c3c | 2013-08-01 14:34:29 -0700 | [diff] [blame] | 137 | edp_config_clk(); |
| 138 | mdss_edp_lane_power_ctrl(1); |
Asaf Penso | b8f524c | 2013-05-20 12:32:31 +0300 | [diff] [blame] | 139 | |
| 140 | edp_enable_mainlink(1); |
Kuogee Hsieh | ad69c3c | 2013-08-01 14:34:29 -0700 | [diff] [blame] | 141 | |
| 142 | mdss_edp_link_train(); |
| 143 | |
Asaf Penso | b8f524c | 2013-05-20 12:32:31 +0300 | [diff] [blame] | 144 | edp_enable(1); |
| 145 | |
Kuogee Hsieh | ad69c3c | 2013-08-01 14:34:29 -0700 | [diff] [blame] | 146 | mdss_edp_wait_for_video_ready(); |
| 147 | |
| 148 | mdss_edp_irq_disable(); |
| 149 | dprintf(INFO, "%s:\n", __func__); |
| 150 | |
Asaf Penso | b8f524c | 2013-05-20 12:32:31 +0300 | [diff] [blame] | 151 | return 0; |
| 152 | } |
| 153 | |
| 154 | int edp_off(void) |
| 155 | { |
Kuogee Hsieh | ad69c3c | 2013-08-01 14:34:29 -0700 | [diff] [blame] | 156 | mdss_edp_irq_disable(); |
Asaf Penso | b8f524c | 2013-05-20 12:32:31 +0300 | [diff] [blame] | 157 | edp_enable_mainlink(0); |
Kuogee Hsieh | ad69c3c | 2013-08-01 14:34:29 -0700 | [diff] [blame] | 158 | edp_phy_pll_reset(); |
| 159 | edp_mainlink_reset(); |
| 160 | edp_aux_reset(); |
Asaf Penso | b8f524c | 2013-05-20 12:32:31 +0300 | [diff] [blame] | 161 | |
Kuogee Hsieh | ad69c3c | 2013-08-01 14:34:29 -0700 | [diff] [blame] | 162 | edp_disable(1); |
| 163 | edp_unconfig_clk(); |
Asaf Penso | b8f524c | 2013-05-20 12:32:31 +0300 | [diff] [blame] | 164 | |
Kuogee Hsieh | ad69c3c | 2013-08-01 14:34:29 -0700 | [diff] [blame] | 165 | mdss_edp_lane_power_ctrl(0); |
| 166 | edp_phy_powerup(0); |
| 167 | |
| 168 | dprintf(INFO, "%s:\n", __func__); |
| 169 | |
Asaf Penso | b8f524c | 2013-05-20 12:32:31 +0300 | [diff] [blame] | 170 | |
| 171 | return 0; |
| 172 | } |
Kuogee Hsieh | ad69c3c | 2013-08-01 14:34:29 -0700 | [diff] [blame] | 173 | |
| 174 | int edp_prepare(void) |
| 175 | { |
| 176 | |
| 177 | mdss_edp_aux_init(); |
| 178 | edp_phy_pll_reset(); |
| 179 | edp_mainlink_reset(); |
| 180 | edp_aux_reset(); |
| 181 | edp_phy_powerup(1); |
| 182 | edp_aux_enable(); |
| 183 | mdss_edp_irq_enable(); |
| 184 | |
| 185 | mdss_edp_wait_for_hpd(); |
| 186 | |
| 187 | mdss_edp_edid_read(); |
| 188 | mdss_edp_dpcd_cap_read(); |
| 189 | |
| 190 | edp_edid2pinfo(edp_pinfo); |
| 191 | edp_cap2pinfo(edp_pinfo); |
| 192 | |
| 193 | dprintf(INFO, "%s:\n", __func__); |
| 194 | |
| 195 | return 0; |
| 196 | } |
| 197 | |
| 198 | void edp_panel_init(struct msm_panel_info *pinfo) |
| 199 | { |
| 200 | if (!pinfo) |
| 201 | return; |
| 202 | |
Siddhartha Agrawal | f67b3ff | 2013-10-23 18:08:04 -0700 | [diff] [blame] | 203 | pinfo->lcdc.dual_pipe = 0; |
Kuogee Hsieh | ad69c3c | 2013-08-01 14:34:29 -0700 | [diff] [blame] | 204 | pinfo->lcdc.split_display = 0; |
| 205 | |
| 206 | edp_pinfo = pinfo; |
| 207 | edp_pinfo->on = edp_on; |
| 208 | edp_pinfo->off = edp_off; |
| 209 | edp_pinfo->prepare = edp_prepare; |
| 210 | } |