Duy Truong | f3ac7b3 | 2013-02-13 01:07:28 -0800 | [diff] [blame] | 1 | /* Copyright (c) 2012, The Linux Foundation. All rights reserved. |
Channagoud Kadabi | 10189fd | 2012-05-25 13:33:39 +0530 | [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. |
Duy Truong | f3ac7b3 | 2013-02-13 01:07:28 -0800 | [diff] [blame] | 12 | * * Neither the name of The Linux Foundation nor the names of its |
Channagoud Kadabi | 10189fd | 2012-05-25 13:33:39 +0530 | [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 | |
| 30 | #include <stdint.h> |
| 31 | #include <msm_panel.h> |
| 32 | #include <mipi_dsi.h> |
| 33 | #include <sys/types.h> |
| 34 | #include <err.h> |
| 35 | #include <reg.h> |
| 36 | #include <debug.h> |
| 37 | #include <target/display.h> |
| 38 | |
Channagoud Kadabi | 10189fd | 2012-05-25 13:33:39 +0530 | [diff] [blame] | 39 | /* MIPI NT35510 panel commands */ |
| 40 | static char exit_sleep[4] = {0x11, 0x00, 0x05, 0x80}; |
| 41 | static char display_on[4] = {0x29, 0x00, 0x05, 0x80}; |
| 42 | static char write_ram[4] = {0x2c, 0x00, 0x05, 0x80}; /* write ram */ |
| 43 | |
| 44 | static char cmd0[12] = { |
| 45 | 0x06, 0x00, 0x29, 0xc0, 0xF0, 0x55, 0xAA, 0x52, |
| 46 | 0x08, 0x01, 0xff, 0xff, |
| 47 | }; |
| 48 | static char cmd1[8] = { |
| 49 | 0x04, 0x00, 0x29, 0xc0, 0xBC, 0x00, 0xA0, 0x00, |
| 50 | }; |
| 51 | static char cmd2[8] = { |
| 52 | 0x04, 0x00, 0x29, 0xc0, 0xBD, 0x00, 0xA0, 0x00, |
| 53 | }; |
| 54 | static char cmd3[8] = { |
| 55 | 0x03, 0x00, 0x29, 0xc0, 0xBE, 0x00, 0x79, 0xff, |
| 56 | }; |
| 57 | static char cmd4[60] = { |
| 58 | 0x35, 0x00, 0x29, 0xc0, 0xD1, 0x00, 0x00, 0x00, |
| 59 | 0x14, 0x00, 0x32, 0x00, |
| 60 | 0x4F, 0x00, 0x65, 0x00, |
| 61 | 0x8B, 0x00, 0xA8, 0x00, |
| 62 | 0xD5, 0x00, 0xF7, 0x01, |
| 63 | 0x2B, 0x01, 0x54, 0x01, |
| 64 | 0x8E, 0x01, 0xBB, 0x01, |
| 65 | 0xBC, 0x01, 0xE3, 0x02, |
| 66 | 0x08, 0x02, 0x1C, 0x02, |
| 67 | 0x39, 0x02, 0x4F, 0x02, |
| 68 | 0x76, 0x02, 0xA3, 0x02, |
| 69 | 0xE3, 0x03, 0x12, 0x03, |
| 70 | 0x4C, 0x03, 0x66, 0x03, |
| 71 | 0x9A, 0xff, 0xff, 0xff, |
| 72 | }; |
| 73 | static char cmd5[60] = { |
| 74 | 0x35, 0x00, 0x29, 0xc0, 0xD2, 0x00, 0x00, 0x00, |
| 75 | 0x14, 0x00, 0x32, 0x00, |
| 76 | 0x4F, 0x00, 0x65, 0x00, |
| 77 | 0x8B, 0x00, 0xA8, 0x00, |
| 78 | 0xD5, 0x00, 0xF7, 0x01, |
| 79 | 0x2B, 0x01, 0x54, 0x01, |
| 80 | 0x8E, 0x01, 0xBB, 0x01, |
| 81 | 0xBC, 0x01, 0xE3, 0x02, |
| 82 | 0x08, 0x02, 0x1C, 0x02, |
| 83 | 0x39, 0x02, 0x4F, 0x02, |
| 84 | 0x76, 0x02, 0xA3, 0x02, |
| 85 | 0xE3, 0x03, 0x12, 0x03, |
| 86 | 0x4C, 0x03, 0x66, 0x03, |
| 87 | 0x9A, 0xff, 0xff, 0xff, |
| 88 | }; |
| 89 | static char cmd6[60] = { |
| 90 | 0x35, 0x00, 0x29, 0xc0, 0xD3, 0x00, 0x00, 0x00, |
| 91 | 0x14, 0x00, 0x32, 0x00, |
| 92 | 0x4F, 0x00, 0x65, 0x00, |
| 93 | 0x8B, 0x00, 0xA8, 0x00, |
| 94 | 0xD5, 0x00, 0xF7, 0x01, |
| 95 | 0x2B, 0x01, 0x54, 0x01, |
| 96 | 0x8E, 0x01, 0xBB, 0x01, |
| 97 | 0xBC, 0x01, 0xE3, 0x02, |
| 98 | 0x08, 0x02, 0x1C, 0x02, |
| 99 | 0x39, 0x02, 0x4F, 0x02, |
| 100 | 0x76, 0x02, 0xA3, 0x02, |
| 101 | 0xE3, 0x03, 0x12, 0x03, |
| 102 | 0x4C, 0x03, 0x66, 0x03, |
| 103 | 0x9A, 0xff, 0xff, 0xff, |
| 104 | }; |
| 105 | static char cmd7[60] = { |
| 106 | 0x35, 0x00, 0x29, 0xc0, 0xD4, 0x00, 0x00, 0x00, |
| 107 | 0x14, 0x00, 0x32, 0x00, |
| 108 | 0x4F, 0x00, 0x65, 0x00, |
| 109 | 0x8B, 0x00, 0xA8, 0x00, |
| 110 | 0xD5, 0x00, 0xF7, 0x01, |
| 111 | 0x2B, 0x01, 0x54, 0x01, |
| 112 | 0x8E, 0x01, 0xBB, 0x01, |
| 113 | 0xBC, 0x01, 0xE3, 0x02, |
| 114 | 0x08, 0x02, 0x1C, 0x02, |
| 115 | 0x39, 0x02, 0x4F, 0x02, |
| 116 | 0x76, 0x02, 0xA3, 0x02, |
| 117 | 0xE3, 0x03, 0x12, 0x03, |
| 118 | 0x4C, 0x03, 0x66, 0x03, |
| 119 | 0x9A, 0xff, 0xff, 0xff, |
| 120 | }; |
| 121 | static char cmd8[60] = { |
| 122 | 0x35, 0x00, 0x29, 0xc0, 0xD5, 0x00, 0x00, 0x00, |
| 123 | 0x14, 0x00, 0x32, 0x00, |
| 124 | 0x4F, 0x00, 0x65, 0x00, |
| 125 | 0x8B, 0x00, 0xA8, 0x00, |
| 126 | 0xD5, 0x00, 0xF7, 0x01, |
| 127 | 0x2B, 0x01, 0x54, 0x01, |
| 128 | 0x8E, 0x01, 0xBB, 0x01, |
| 129 | 0xBC, 0x01, 0xE3, 0x02, |
| 130 | 0x08, 0x02, 0x1C, 0x02, |
| 131 | 0x39, 0x02, 0x4F, 0x02, |
| 132 | 0x76, 0x02, 0xA3, 0x02, |
| 133 | 0xE3, 0x03, 0x12, 0x03, |
| 134 | 0x4C, 0x03, 0x66, 0x03, |
| 135 | 0x9A, 0xff, 0xff, 0xff, |
| 136 | }; |
| 137 | static char cmd9[60] = { |
| 138 | 0x35, 0x00, 0x29, 0xc0, 0xD6, 0x00, 0x00, 0x00, |
| 139 | 0x14, 0x00, 0x32, 0x00, |
| 140 | 0x4F, 0x00, 0x65, 0x00, |
| 141 | 0x8B, 0x00, 0xA8, 0x00, |
| 142 | 0xD5, 0x00, 0xF7, 0x01, |
| 143 | 0x2B, 0x01, 0x54, 0x01, |
| 144 | 0x8E, 0x01, 0xBB, 0x01, |
| 145 | 0xBC, 0x01, 0xE3, 0x02, |
| 146 | 0x08, 0x02, 0x1C, 0x02, |
| 147 | 0x39, 0x02, 0x4F, 0x02, |
| 148 | 0x76, 0x02, 0xA3, 0x02, |
| 149 | 0xE3, 0x03, 0x12, 0x03, |
| 150 | 0x4C, 0x03, 0x66, 0x03, |
| 151 | 0x9A, 0xff, 0xff, 0xff, |
| 152 | }; |
| 153 | static char cmd10[8] = { |
| 154 | 0x04, 0x00, 0x29, 0xc0, 0xB0, 0x0A, 0x0A, 0x0A, |
| 155 | }; |
| 156 | static char cmd11[8] = { |
| 157 | 0x04, 0x00, 0x29, 0xc0, 0xB1, 0x0A, 0x0A, 0x0A, |
| 158 | }; |
| 159 | static char cmd12[8] = { |
| 160 | 0x04, 0x00, 0x29, 0xc0, 0xBA, 0x24, 0x24, 0x24, |
| 161 | }; |
| 162 | static char cmd13[8] = { |
| 163 | 0x04, 0x00, 0x29, 0xc0, 0xB9, 0x24, 0x24, 0x24, |
| 164 | }; |
| 165 | static char cmd14[8] = { |
| 166 | 0x04, 0x00, 0x29, 0xc0, 0xB8, 0x24, 0x24, 0x24, |
| 167 | }; |
| 168 | static char cmd15[12] = { |
| 169 | 0x06, 0x00, 0x29, 0xc0, 0xF0, 0x55, 0xAA, 0x52, |
| 170 | 0x08, 0x00, 0xff, 0xff, |
| 171 | }; |
| 172 | static char cmd16[8] = { |
| 173 | 0x02, 0x00, 0x29, 0xc0, 0xB3, 0x00, 0xff, 0xff, |
| 174 | }; |
| 175 | static char cmd17[8] = { |
| 176 | 0x02, 0x00, 0x29, 0xc0, 0xB4, 0x10, 0xff, 0xff, |
| 177 | }; |
| 178 | static char cmd18[8] = { |
| 179 | 0x02, 0x00, 0x29, 0xc0, 0xB6, 0x02, 0xff, 0xff, |
| 180 | }; |
| 181 | static char cmd19[8] = { |
| 182 | 0x03, 0x00, 0x29, 0xc0, 0xB1, 0xEC, 0x00, 0xff, |
| 183 | }; |
Padmanabhan Komanduru | 6ec0033 | 2012-09-22 15:48:43 +0530 | [diff] [blame] | 184 | static char cmd19_rotate[8] = { |
| 185 | 0x03, 0x00, 0x29, 0xc0, 0xB1, 0xEC, 0x06, 0xff, |
| 186 | }; |
Channagoud Kadabi | 10189fd | 2012-05-25 13:33:39 +0530 | [diff] [blame] | 187 | static char cmd20[8] = { |
| 188 | 0x04, 0x00, 0x29, 0xc0, 0xBC, 0x05, 0x05, 0x05, |
| 189 | }; |
| 190 | static char cmd21[8] = { |
| 191 | 0x03, 0x00, 0x29, 0xc0, 0xB7, 0x20, 0x20, 0xff, |
| 192 | }; |
| 193 | static char cmd22[12] = { |
| 194 | 0x05, 0x00, 0x29, 0xc0, 0xB8, 0x01, 0x03, 0x03, |
| 195 | 0x03, 0xff, 0xff, 0xff, |
| 196 | }; |
| 197 | static char cmd23[24] = { |
| 198 | 0x13, 0x00, 0x29, 0xc0, 0xC8, 0x01, 0x00, 0x78, |
| 199 | 0x50, 0x78, 0x50, 0x78, |
| 200 | 0x50, 0x78, 0x50, 0xC8, |
| 201 | 0x3C, 0x3C, 0xC8, 0xC8, |
| 202 | 0x3C, 0x3C, 0xC8, 0xff, |
| 203 | }; |
| 204 | static char cmd24[12] = { |
| 205 | 0x06, 0x00, 0x29, 0xc0, 0xBD, 0x01, 0x84, 0x07, |
| 206 | 0x31, 0x00, 0xff, 0xff, |
| 207 | }; |
| 208 | static char cmd25[12] = { |
| 209 | 0x06, 0x00, 0x29, 0xc0, 0xBE, 0x01, 0x84, 0x07, |
| 210 | 0x31, 0x00, 0xff, 0xff, |
| 211 | }; |
| 212 | static char cmd26[12] = { |
| 213 | 0x06, 0x00, 0x29, 0xc0, 0xBF, 0x01, 0x84, 0x07, |
| 214 | 0x31, 0x00, 0xff, 0xff, |
| 215 | }; |
| 216 | static char cmd27[8] = { |
| 217 | 0x02, 0x00, 0x29, 0xc0, 0x35, 0x00, 0xff, 0xff, |
| 218 | }; |
| 219 | |
| 220 | static char config_MADCTL[4] = {0x36, 0x00, 0x15, 0x80}; |
| 221 | |
| 222 | static struct mipi_dsi_cmd nt35510_panel_cmd_mode_cmds[] = { |
| 223 | {sizeof(cmd0), cmd0}, |
| 224 | {sizeof(cmd1), cmd1}, |
| 225 | {sizeof(cmd2), cmd2}, |
| 226 | {sizeof(cmd3), cmd3}, |
| 227 | {sizeof(cmd4), cmd4}, |
| 228 | {sizeof(cmd5), cmd5}, |
| 229 | {sizeof(cmd6), cmd6}, |
| 230 | {sizeof(cmd7), cmd7}, |
| 231 | {sizeof(cmd8), cmd8}, |
| 232 | {sizeof(cmd9), cmd9}, |
| 233 | {sizeof(cmd10), cmd10}, |
| 234 | {sizeof(cmd11), cmd11}, |
| 235 | {sizeof(cmd12), cmd12}, |
| 236 | {sizeof(cmd13), cmd13}, |
| 237 | {sizeof(cmd14), cmd14}, |
| 238 | {sizeof(cmd15), cmd15}, |
| 239 | {sizeof(cmd16), cmd16}, |
| 240 | {sizeof(cmd17), cmd17}, |
| 241 | {sizeof(cmd18), cmd18}, |
| 242 | {sizeof(cmd19), cmd19}, |
| 243 | {sizeof(cmd20), cmd20}, |
| 244 | {sizeof(cmd21), cmd21}, |
| 245 | {sizeof(cmd22), cmd22}, |
| 246 | {sizeof(cmd23), cmd23}, |
| 247 | {sizeof(cmd24), cmd24}, |
| 248 | {sizeof(cmd25), cmd25}, |
| 249 | {sizeof(cmd26), cmd26}, |
| 250 | {sizeof(cmd27), cmd27}, |
| 251 | {sizeof(exit_sleep), exit_sleep}, |
| 252 | {sizeof(display_on), display_on}, |
| 253 | {sizeof(config_MADCTL), config_MADCTL}, |
| 254 | {sizeof(write_ram), write_ram}, |
| 255 | }; |
| 256 | |
Padmanabhan Komanduru | 6ec0033 | 2012-09-22 15:48:43 +0530 | [diff] [blame] | 257 | static struct mipi_dsi_cmd nt35510_cmd_rotate_cmds[] = { |
| 258 | {sizeof(cmd19_rotate), cmd19_rotate}, |
| 259 | }; |
| 260 | |
Channagoud Kadabi | 10189fd | 2012-05-25 13:33:39 +0530 | [diff] [blame] | 261 | int mipi_nt35510_cmd_wvga_on() |
| 262 | { |
| 263 | int ret = NO_ERROR; |
| 264 | return ret; |
| 265 | } |
| 266 | |
| 267 | int mipi_nt35510_cmd_wvga_off() |
| 268 | { |
| 269 | int ret = NO_ERROR; |
| 270 | return ret; |
| 271 | } |
| 272 | |
Padmanabhan Komanduru | 6ec0033 | 2012-09-22 15:48:43 +0530 | [diff] [blame] | 273 | int mipi_nt35510_cmd_wvga_rotate() |
| 274 | { |
| 275 | int ret = NO_ERROR; |
| 276 | |
| 277 | ret = mipi_dsi_cmds_tx(nt35510_cmd_rotate_cmds, ARRAY_SIZE(nt35510_cmd_rotate_cmds)); |
| 278 | |
| 279 | return ret; |
| 280 | } |
| 281 | |
Channagoud Kadabi | 10189fd | 2012-05-25 13:33:39 +0530 | [diff] [blame] | 282 | int mipi_nt35510_cmd_wvga_config(void *pdata) |
| 283 | { |
| 284 | int ret = NO_ERROR; |
| 285 | |
| 286 | struct msm_panel_info *pinfo = (struct msm_panel_info *) pdata; |
| 287 | |
| 288 | if (pinfo == NULL) |
| 289 | return ERR_INVALID_ARGS; |
| 290 | |
| 291 | ret = mipi_dsi_cmd_mode_config((pinfo->xres), |
| 292 | (pinfo->yres), |
| 293 | (pinfo->xres), |
| 294 | (pinfo->yres), |
| 295 | pinfo->mipi.dst_format, |
| 296 | pinfo->mipi.traffic_mode); |
| 297 | return ret; |
| 298 | } |
| 299 | |
| 300 | struct mipi_dsi_phy_ctrl dsi_cmd_mode_phy_db = { |
| 301 | /* DSI_BIT_CLK at 500MHz, 2 lane, RGB888 */ |
| 302 | {0x03, 0x01, 0x01, 0x00}, /* regulator */ |
| 303 | /* timing */ |
| 304 | {0xb9, 0x8e, 0x1f, 0x00, 0x98, 0x9c, 0x22, |
| 305 | 0x90, 0x18, 0x03, 0x04}, |
| 306 | {0x7f, 0x00, 0x00, 0x00}, /* phy ctrl */ |
| 307 | {0xbb, 0x02, 0x06, 0x00}, /* strength */ |
| 308 | /* pll control */ |
| 309 | {0x00, 0xec, 0x31, 0xd2, 0x00, 0x40, 0x37, 0x62, |
| 310 | 0x01, 0x0f, 0x07, /* --> Two lane configuration */ |
| 311 | 0x05, 0x14, 0x03, 0x0, 0x0, 0x0, 0x20, 0x0, 0x02, 0x0}, |
| 312 | }; |
| 313 | |
| 314 | void mipi_nt35510_cmd_wvga_init(struct msm_panel_info *pinfo) |
| 315 | { |
| 316 | if (!pinfo) |
| 317 | return; |
| 318 | |
| 319 | pinfo->xres = NT35510_MIPI_FB_WIDTH; |
| 320 | pinfo->yres = NT35510_MIPI_FB_HEIGHT; |
| 321 | pinfo->mipi.num_of_lanes = 2; |
| 322 | |
| 323 | pinfo->type = MIPI_CMD_PANEL; |
| 324 | pinfo->wait_cycle = 0; |
| 325 | pinfo->bpp = 24; |
Channagoud Kadabi | ebbca34 | 2012-06-29 18:14:31 +0530 | [diff] [blame] | 326 | pinfo->clk_rate = 499000000; |
Channagoud Kadabi | 10189fd | 2012-05-25 13:33:39 +0530 | [diff] [blame] | 327 | |
| 328 | pinfo->mipi.mode = DSI_CMD_MODE; |
| 329 | pinfo->mipi.traffic_mode = 0; |
| 330 | pinfo->mipi.dst_format = 0; |
| 331 | pinfo->mipi.dsi_phy_db = &dsi_cmd_mode_phy_db; |
| 332 | pinfo->mipi.tx_eot_append = TRUE; |
| 333 | |
| 334 | pinfo->mipi.lane_swap = 1; |
| 335 | pinfo->mipi.panel_cmds = nt35510_panel_cmd_mode_cmds; |
| 336 | pinfo->mipi.num_of_panel_cmds = \ |
| 337 | ARRAY_SIZE(nt35510_panel_cmd_mode_cmds); |
| 338 | |
| 339 | pinfo->on = mipi_nt35510_cmd_wvga_on; |
| 340 | pinfo->off = mipi_nt35510_cmd_wvga_off; |
| 341 | pinfo->config = mipi_nt35510_cmd_wvga_config; |
Padmanabhan Komanduru | 6ec0033 | 2012-09-22 15:48:43 +0530 | [diff] [blame] | 342 | pinfo->rotate = mipi_nt35510_cmd_wvga_rotate; |
Channagoud Kadabi | 10189fd | 2012-05-25 13:33:39 +0530 | [diff] [blame] | 343 | |
| 344 | return; |
| 345 | } |