微波EDA网,见证研发工程师的成长!
首页 > 研发问答 > 手机设计讨论 > MTK手机平台交流 > 求 otm8009a dsi代码一份,谢谢!

求 otm8009a dsi代码一份,谢谢!

时间:10-02 整理:3721RD 点击:
RT:哪位兄弟调通过的麻烦共享下,谢谢!


  1. #include <linux/string.h>
  2. #include "lcm_drv.h"
  3. #if defined(BUILD_UBOOT)
  4. #else
  5. #include <linux/kernel.h>
  6. #endif

  7. // ---------------------------------------------------------------------------
  8. //  Local Constants
  9. // ---------------------------------------------------------------------------

  10. #define FRAME_WIDTH                              (480)
  11. #define FRAME_HEIGHT                             (800)

  12. #define REGFLAG_DELAY               0XFE
  13. #define REGFLAG_END_OF_TABLE        0xFFF   // END OF REGISTERS MARKER

  14. #define LCM_ID                      0x8009
  15. // ---------------------------------------------------------------------------
  16. //  Local Variables
  17. // ---------------------------------------------------------------------------

  18. static LCM_UTIL_FUNCS lcm_util = {0};

  19. #define SET_RESET_PIN(v)                                                                    (lcm_util.set_reset_pin((v)))

  20. #define UDELAY(n)                                                                                         (lcm_util.udelay(n))
  21. #define MDELAY(n)                                                                                         (lcm_util.mdelay(n))


  22. // ---------------------------------------------------------------------------
  23. //  Local Functions
  24. // ---------------------------------------------------------------------------

  25. #define dsi_set_cmdq_V2(cmd, count, ppara, force_update)        lcm_util.dsi_set_cmdq_V2(cmd, count, ppara, force_update)
  26. #define dsi_set_cmdq(pdata, queue_size, force_update)                lcm_util.dsi_set_cmdq(pdata, queue_size, force_update)
  27. #define wrtie_cmd(cmd)                                                                                lcm_util.dsi_write_cmd(cmd)
  28. #define write_regs(addr, pdata, byte_nums)                                        lcm_util.dsi_write_regs(addr, pdata, byte_nums)
  29. #define read_reg                                                                                        lcm_util.dsi_read_reg()
  30. #define read_reg_v2(cmd,buffer,buffer_size)                 lcm_util.dsi_dcs_read_lcm_reg_v2(cmd,buffer,buffer_size)      
  31.       

  32. struct LCM_setting_table {
  33.     unsigned cmd;
  34.     unsigned char count;
  35.     unsigned char para_list[64];
  36. };


  37. static struct LCM_setting_table lcm_initialization_setting[] = {
  38.        
  39.         /*
  40.         Note :

  41.         Data ID will depends on the following rule.
  42.        
  43.                 count of parameters > 1        => Data ID = 0x39
  44.                 count of parameters = 1        => Data ID = 0x15
  45.                 count of parameters = 0        => Data ID = 0x05

  46.         Structure Format :

  47.         {DCS command, count of parameters, {parameter list}}
  48.         {REGFLAG_DELAY, milliseconds of time, {}},

  49.         ...

  50.         Setting ending by predefined flag
  51.        
  52.         {REGFLAG_END_OF_TABLE, 0x00, {}}
  53.         */
  54. #if 0
  55.         {0xF0, 5, {0x55,0xAA,0x52,0x08,0x01}},
  56.         {REGFLAG_DELAY, 10, {}},

  57.         {0xB0, 3, {0x0D, 0x0D, 0x0D}},
  58.     {REGFLAG_DELAY, 10, {}},

  59.         {0xB6, 3, {0x44, 0x44, 0x44}},
  60.     {REGFLAG_DELAY, 10, {}},

  61.         {0xB1, 3, {0x0D, 0x0D, 0x0D}},
  62.     {REGFLAG_DELAY, 10, {}},

  63.         {0xB7, 3, {0x34, 0x34, 0x34}},
  64.     {REGFLAG_DELAY, 10, {}},

  65.         {0xB2, 3, {0x00, 0x00, 0x00}},
  66.     {REGFLAG_DELAY, 10, {}},

  67.         {0xB8, 3, {0x34, 0x34, 0x34}},
  68.     {REGFLAG_DELAY, 10, {}},

  69.         {0xBF, 1, {0x01}},
  70.     {REGFLAG_DELAY, 10, {}},

  71.         {0xB3, 3, {0x0F, 0x0F, 0x0F}},
  72.     {REGFLAG_DELAY, 10, {}},

  73.         {0xB9, 3, {0x34, 0x34, 0x34}},
  74.     {REGFLAG_DELAY, 10, {}},

  75.         {0xB5, 3, {0x08, 0x08, 0x08}},
  76.     {REGFLAG_DELAY, 10, {}},

  77.         {0xC2, 1, {0x03}},
  78.     {REGFLAG_DELAY, 10, {}},

  79.         {0xBA, 3, {0x34, 0x34, 0x34}},
  80.     {REGFLAG_DELAY, 10, {}},

  81.         {0xBC, 3, {0x00, 0x78, 0x00}},
  82.     {REGFLAG_DELAY, 10, {}},

  83.         {0xBD, 3, {0x00, 0x78, 0x00}},
  84.     {REGFLAG_DELAY, 10, {}},

  85.         {0xBE, 2, {0x00, 0x5F}},
  86.     {REGFLAG_DELAY, 10, {}},

  87.         {0xD1, 52, {0x00, 0x33, 0x00, 0x34, 0x00, 0x3A, 0x00, 0x4A, 0x00, 0x5C, 0x00, 0x81,
  88.             0x00, 0xA6, 0x00, 0xE5, 0x01, 0x13, 0x01, 0x54, 0x01, 0x82, 0x01, 0xCA,
  89.             0x02, 0x00, 0x02, 0x01, 0x02, 0x34, 0x02, 0x67, 0x02, 0x84, 0x02, 0xA4,
  90.             0x02, 0xB7, 0x02, 0xCF, 0x02, 0xDE, 0x02, 0xF2, 0x02, 0xFE, 0x03, 0x10,
  91.             0x03, 0x33, 0x03, 0x6D }},
  92.     {REGFLAG_DELAY, 10, {}},

  93.         {0xD2, 52, {0x00, 0x33, 0x00, 0x34, 0x00, 0x3A, 0x00, 0x4A, 0x00, 0x5C, 0x00, 0x81,
  94.                         0x00, 0xA6, 0x00, 0xE5, 0x01, 0x13, 0x01, 0x54, 0x01, 0x82, 0x01, 0xCA,
  95.             0x02, 0x00, 0x02, 0x01, 0x02, 0x34, 0x02, 0x67, 0x02, 0x84, 0x02, 0xA4,
  96.             0x02, 0xB7, 0x02, 0xCF, 0x02, 0xDE, 0x02, 0xF2, 0x02, 0xFE, 0x03, 0x10,
  97.             0x03, 0x33, 0x03, 0x6D }},
  98.     {REGFLAG_DELAY, 10, {}},
  99.             
  100.         {0xD3, 52, {0x00, 0x33, 0x00, 0x34, 0x00, 0x3A, 0x00, 0x4A, 0x00, 0x5C, 0x00, 0x81,
  101.             0x00, 0xA6, 0x00, 0xE5, 0x01, 0x13, 0x01, 0x54, 0x01, 0x82, 0x01, 0xCA,
  102.             0x02, 0x00, 0x02, 0x01, 0x02, 0x34, 0x02, 0x67, 0x02, 0x84, 0x02, 0xA4,
  103.             0x02, 0xB7, 0x02, 0xCF, 0x02, 0xDE, 0x02, 0xF2, 0x02, 0xFE, 0x03, 0x10,
  104.             0x03, 0x33, 0x03, 0x6D }},
  105.     {REGFLAG_DELAY, 10, {}},

  106.         {0xD4, 52, {0x00, 0x33, 0x00, 0x34, 0x00, 0x3A, 0x00, 0x4A, 0x00, 0x5C, 0x00, 0x81,
  107.                         0x00, 0xA6, 0x00, 0xE5, 0x01, 0x13, 0x01, 0x54, 0x01, 0x82, 0x01, 0xCA,
  108.             0x02, 0x00, 0x02, 0x01, 0x02, 0x34, 0x02, 0x67, 0x02, 0x84, 0x02, 0xA4,
  109.             0x02, 0xB7, 0x02, 0xCF, 0x02, 0xDE, 0x02, 0xF2, 0x02, 0xFE, 0x03, 0x10,
  110.             0x03, 0x33, 0x03, 0x6D }},
  111.     {REGFLAG_DELAY, 10, {}},

  112.         {0xD5, 52, {0x00, 0x33, 0x00, 0x34, 0x00, 0x3A, 0x00, 0x4A, 0x00, 0x5C, 0x00, 0x81,
  113.             0x00, 0xA6, 0x00, 0xE5, 0x01, 0x13, 0x01, 0x54, 0x01, 0x82, 0x01, 0xCA,
  114.             0x02, 0x00, 0x02, 0x01, 0x02, 0x34, 0x02, 0x67, 0x02, 0x84, 0x02, 0xA4,
  115.             0x02, 0xB7, 0x02, 0xCF, 0x02, 0xDE, 0x02, 0xF2, 0x02, 0xFE, 0x03, 0x10,
  116.             0x03, 0x33, 0x03, 0x6D }},
  117.     {REGFLAG_DELAY, 10, {}},

  118.         {0xD6, 52, {0x00, 0x33, 0x00, 0x34, 0x00, 0x3A, 0x00, 0x4A, 0x00, 0x5C, 0x00, 0x81,
  119.             0x00, 0xA6, 0x00, 0xE5, 0x01, 0x13, 0x01, 0x54, 0x01, 0x82, 0x01, 0xCA,
  120.             0x02, 0x00, 0x02, 0x01, 0x02, 0x34, 0x02, 0x67, 0x02, 0x84, 0x02, 0xA4,
  121.             0x02, 0xB7, 0x02, 0xCF, 0x02, 0xDE, 0x02, 0xF2, 0x02, 0xFE, 0x03, 0x10,
  122.             0x03, 0x33, 0x03, 0x6D }},
  123.     {REGFLAG_DELAY, 10, {}},
  124.             
  125.         {0xF0, 5, {0x55, 0xAA, 0x52, 0x08, 0x00}},
  126.     {REGFLAG_DELAY, 10, {}},

  127.         {0xB1, 2, {0xCC, 0x00}},
  128.     {REGFLAG_DELAY, 10, {}},

  129.         {0xB5, 1, {0x50}},
  130.     {REGFLAG_DELAY, 10, {}},
  131.         {0xB6, 1, {0x05}},
  132.     {REGFLAG_DELAY, 10, {}},

  133.         {0xB7, 2, {0x77, 0x77}},
  134.     {REGFLAG_DELAY, 10, {}},

  135.         {0xB8, 4, {0x01, 0x03, 0x03, 0x03}},
  136.     {REGFLAG_DELAY, 10, {}},

  137.         {0xBC, 3, {0x02, 0x00, 0x00}},
  138.     {REGFLAG_DELAY, 10, {}},

  139.         {0xBD, 5, {0x01, 0x84,0x1C,0x1C, 0x00}},
  140.     {REGFLAG_DELAY, 10, {}},

  141.         {0x3a, 1, {0x77}},
  142.     {REGFLAG_DELAY, 10, {}},

  143.         {0xc9, 5, {0xd0, 0x02, 0x50, 0x50, 0x50}},
  144.     {REGFLAG_DELAY, 10, {}},

  145.         {0x35, 1, {0x00}},
  146.     {REGFLAG_DELAY, 10, {}},
  147.    
  148. //    {0x36, 1, {0xfc}},
  149. //    {REGFLAG_DELAY, 10, {}},
  150.         {0x36, 1, {0x00}},
  151.     {REGFLAG_DELAY, 10, {}},
  152. #endif



  153. {0x00,1,{0x00}},{0xff,3,{0x80,0x09,0x01}},

  154. {0x00,1,{0x80}},{0xff,2,{0x80,0x09}},

  155. {0x00,1,{0x03}},{0xff,1,{0x01}},

  156. {0x00,1,{0xb4}},{0xc0,1,{0x10}},

  157. {0x00,1,{0x89}},{0xc4,1,{0x08}},

  158. {0x00,1,{0xa3}},{0xc0,1,{0x00}},

  159. {0x00,1,{0x82}},{0xc5,1,{0xa3}},

  160. {0x00,1,{0x90}},{0xc5,2,{0xd6,0x87}},

  161. {0x00,1,{0x00}},{0xd8,2,{0x74,0x72}},

  162. {0x00,1,{0x00}},{0xd9,1,{0x50}},

  163. {0x00,1,{0x00}},{0xe1,16,{0x09,0x0c,0x12,0x0e,0x08,0x19,0x0c,0x0b,0x01,0x05,0x03,0x07,0x0e,0x26,0x23,0x1b}},

  164. {0x00,1,{0x00}},{0xe2,16,{0x09,0x0c,0x12,0x0e,0x08,0x19,0x0c,0x0b,0x01,0x05,0x03,0x07,0x0e,0x26,0x23,0x1b}},

  165. {0x00,1,{0x81}},{0xc1,1,{0x66}},

  166. {0x00,1,{0xa1}},{0xc1,1,{0x88}},

  167. {0x00,1,{0x81}},{0xc4,1,{0x83}},

  168. {0x00,1,{0x92}},{0xc5,1,{0x01}},

  169. {0x00,1,{0xb1}},{0xc5,1,{0xa9}},

  170. {0x00,1,{0x80}},{0xce,12,{0x85,0x03,0x00,0x84,0x03,0x00,0x83,0x03,0x00,0x82,0x03,0x00}},

  171. {0x00,1,{0xa0}},{0xce,14,{0x38,0x02,0x03,0x21,0x00,0x00,0x00,0x38,0x01,0x03,0x22,0x00,0x00,0x00}},

  172. {0x00,1,{0xb0}},{0xce,14,{0x38,0x00,0x03,0x23,0x00,0x00,0x00,0x30,0x00,0x03,0x24,0x00,0x00,0x00}},

  173. {0x00,1,{0xc0}},{0xce,14,{0x30,0x01,0x03,0x25,0x00,0x00,0x00,0x30,0x02,0x03,0x26,0x00,0x00,0x00}},

  174. {0x00,1,{0xd0}},{0xce,14,{0x30,0x03,0x03,0x27,0x00,0x00,0x00,0x30,0x04,0x03,0x28,0x00,0x00,0x00}},

  175. {0x00,1,{0xc0}},{0xcf,10,{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}},

  176. {0x00,1,{0xd0}},{0xcf,1,{0x00}},

  177. {0x00,1,{0xc0}},{0xcb,15,{0x00,0x00,0x00,0x00,0x04,0x04,0x04,0x04,0x04,0x04,0x00,0x00,0x00,0x00,0x00}},

  178. {0x00,1,{0xd0}},{0xcb,15,{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x04,0x04,0x04,0x04,0x04}},

  179. {0x00,1,{0xe0}},{0xcb,10,{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}},

  180. {0x00,1,{0x80}},{0xcc,10,{0x00,0x00,0x00,0x00,0x0c,0x0a,0x10,0x0e,0x03,0x04}},

  181. {0x00,1,{0x90}},{0xcc,15,{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0b}},

  182. {0x00,1,{0xa0}},{0xcc,15,{0x09,0x0f,0x0d,0x01,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}},

  183. {0x00,1,{0xb0}},{0xcc,10,{0x00,0x00,0x00,0x00,0x0d,0x0f,0x09,0x0b,0x02,0x01}},

  184. {0x00,1,{0xc0}},{0xcc,15,{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0e}},

  185. {0x00,1,{0xd0}},{0xcc,15,{0x10,0x0a,0x0c,0x04,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}},

  186. {0x00,1,{0x00}},{0xff,3,{0xff,0xff,0xff}},

  187. {0x3a,1,{0x77}},
  188. #ifdef DISPLAY_DIRECTION_0_MODE
  189. DCS_SHORT_1P(0x36,0x00);// Display Direction 0
  190. DCS_SHORT_1P(0x35,0x00);// TE( Fmark ) Signal On
  191. DCS_LONG_2P(0x44,0x01,0x22);// TE( Fmark ) Signal Output Position
  192. #endif

  193. #ifdef DISPLAY_DIRECTION_180_MODE
  194. DCS_SHORT_1P(0x36,0xD0);// Display Direction 180
  195. DCS_SHORT_1P(0x35,0x00);// TE( Fmark ) Signal On
  196. DCS_LONG_2P(0x44,0x01,0xFF);// TE( Fmark ) Signal Output Position
  197. #endif

  198. #ifdef LCD_BACKLIGHT_CONTROL_MODE
  199. DCS_SHORT_1P(0x51,0xFF);// Backlight Level Control
  200. DCS_SHORT_1P(0x53,0x2C);// Backlight On
  201. DCS_SHORT_1P(0x55,0x00);// CABC Function Off
  202. #endif


  203. {0x11,0,{}},

  204. {REGFLAG_DELAY, 50, {}},

  205. {0x29,0,{}},

  206. {REGFLAG_DELAY, 200, {}},

  207. {0x2c,0,{}},
  208. {REGFLAG_DELAY, 120, {}},

  209.         // Note
  210.         // Strongly recommend not to set Sleep out / Display On here. That will cause messed frame to be shown as later the backlight is on.
  211.         // Setting ending by predefined flag
  212.        
  213.         {REGFLAG_END_OF_TABLE, 0x00, {}}
  214. };


  215. static struct LCM_setting_table lcm_set_window[] = {
  216.         {0x2A,        4,        {0x00, 0x00, (FRAME_WIDTH>>8), (FRAME_WIDTH&0xFF)}},
  217.         {0x2B,        4,        {0x00, 0x00, (FRAME_HEIGHT>>8), (FRAME_HEIGHT&0xFF)}},
  218.         {REGFLAG_END_OF_TABLE, 0x00, {}}
  219. };


  220. static struct LCM_setting_table lcm_sleep_out_setting[] = {
  221.     // Sleep Out
  222.         {0x11, 1, {0x00}},
  223.     {REGFLAG_DELAY, 120, {}},

  224.     // Display ON
  225.         {0x29, 1, {0x00}},
  226.         {REGFLAG_DELAY, 20, {}},
  227.         {REGFLAG_END_OF_TABLE, 0x00, {}}
  228. };


  229. static struct LCM_setting_table lcm_deep_sleep_mode_in_setting[] = {
  230.         // Display off sequence
  231.         {0x28, 1, {0x00}},

  232.     // Sleep Mode On
  233.         {0x10, 1, {0x00}},
  234.     {REGFLAG_DELAY, 120, {}},

  235.         {REGFLAG_END_OF_TABLE, 0x00, {}}
  236. };


  237. static struct LCM_setting_table lcm_backlight_level_setting[] = {
  238.         {0x51, 1, {0xFF}},
  239.         {REGFLAG_END_OF_TABLE, 0x00, {}}
  240. };

  241. static struct LCM_setting_table lcm_backlight_mode_setting[] = {
  242.         {0x55, 1, {0x1}},
  243.         {REGFLAG_END_OF_TABLE, 0x00, {}}
  244. };

  245. static void init_lcm_registers(void)
  246. {
  247.         unsigned int data_array[16];

  248. //{0x00,1,{0x00}},{0xff,3,{0x80,0x09,0x01}},
  249.     data_array[0]=0x00001500;
  250.     dsi_set_cmdq(data_array, 1, 1);
  251.     data_array[0]=0x00043902;
  252.         data_array[1]=0x010980ff;
  253.     dsi_set_cmdq(data_array, 2, 1);
  254.    
  255. //{0x00,1,{0x80}},{0xff,2,{0x80,0x09}},
  256.     data_array[0]=0x80001500;
  257.     dsi_set_cmdq(data_array, 1, 1);
  258.     data_array[0]=0x00033902;
  259.         data_array[1]=0x000980ff;
  260.     dsi_set_cmdq(data_array, 2, 1);
  261.    
  262. //{0x00,1,{0x03}},{0xff,1,{0x01}},
  263.     data_array[0]=0x03001500;
  264.     dsi_set_cmdq(data_array, 1, 1);
  265.     data_array[0]=0x01ff1500;
  266.     dsi_set_cmdq(data_array, 1, 1);
  267.    
  268. //{0x00,1,{0xb4}},{0xc0,1,{0x10}},
  269.     data_array[0]=0xb4001500;
  270.     dsi_set_cmdq(data_array, 1, 1);
  271.     data_array[0]=0x20c01500;
  272.     dsi_set_cmdq(data_array, 1, 1);
  273.    
  274. //{0x00,1,{0x89}},{0xc4,1,{0x08}},
  275.     data_array[0]=0x89001500;
  276.     dsi_set_cmdq(data_array, 1, 1);
  277.     data_array[0]=0x08c41500;
  278.     dsi_set_cmdq(data_array, 1, 1);
  279.    
  280. //{0x00,1,{0xa3}},{0xc0,1,{0x00}},
  281.     data_array[0]=0xa3001500;
  282.     dsi_set_cmdq(data_array, 1, 1);
  283.     data_array[0]=0x00c01500;
  284.     dsi_set_cmdq(data_array, 1, 1);
  285.    
  286. //{0x00,1,{0x82}},{0xc5,1,{0xa3}},
  287.     data_array[0]=0x82001500;
  288.     dsi_set_cmdq(data_array, 1, 1);
  289.     data_array[0]=0xa3c51500;
  290.     dsi_set_cmdq(data_array, 1, 1);
  291.    
  292. //{0x00,1,{0x90}},{0xc5,2,{0xd6,0x87}},
  293.     data_array[0]=0x90001500;
  294.     dsi_set_cmdq(data_array, 1, 1);
  295.     data_array[0]=0x00033902;
  296.         data_array[1]=0x0087d6c5;
  297.     dsi_set_cmdq(data_array, 2, 1);
  298.    
  299. //{0x00,1,{0x00}},{0xd8,2,{0x74,0x72}},
  300.     data_array[0]=0x00001500;
  301.     dsi_set_cmdq(data_array, 1, 1);
  302.     data_array[0]=0x00033902;
  303.         data_array[1]=0x007274d8;
  304.     dsi_set_cmdq(data_array, 2, 1);
  305.    
  306. //{0x00,1,{0x00}},{0xd9,1,{0x50}},
  307.     data_array[0]=0x00001500;
  308.     dsi_set_cmdq(data_array, 1, 1);
  309.     data_array[0]=0x50d91500;
  310.     dsi_set_cmdq(data_array, 1, 1);
  311.    
  312. //{0x00,1,{0x00}},{0xe1,16,{0x09,0x0c,0x12,0x0e,0x08,0x19,0x0c,0x0b,0x01,0x05,0x03,0x07,0x0e,0x26,0x23,0x1b}},
  313.     data_array[0]=0x00001500;
  314.     dsi_set_cmdq(data_array, 1, 1);
  315.     data_array[0]=0x00113902;
  316.     data_array[1]=0x120c09e1;
  317.     data_array[2]=0x0c19080e;
  318.     data_array[3]=0x0305010b;
  319.     data_array[4]=0x23260e07;
  320.     data_array[5]=0x0000001b;
  321.     dsi_set_cmdq(data_array, 6, 1);


  322. //{0x00,1,{0x00}},{0xe2,16,{0x09,0x0c,0x12,0x0e,0x08,0x19,0x0c,0x0b,0x01,0x05,0x03,0x07,0x0e,0x26,0x23,0x1b}},
  323.     data_array[0]=0x00001500;
  324.     dsi_set_cmdq(data_array, 1, 1);
  325.     data_array[0]=0x00113902;
  326.     data_array[1]=0x120c09e2;
  327.     data_array[2]=0x0c19080e;
  328.     data_array[3]=0x0305010b;
  329.     data_array[4]=0x23260e07;
  330.     data_array[5]=0x0000001b;
  331.     dsi_set_cmdq(data_array, 6, 1);


  332. //{0x00,1,{0x81}},{0xc1,1,{0x66}},
  333.     data_array[0]=0x81001500;
  334.     dsi_set_cmdq(data_array, 1, 1);
  335.     data_array[0]=0x66c11500;
  336.     dsi_set_cmdq(data_array, 1, 1);
  337.    
  338. //{0x00,1,{0xa1}},{0xc1,1,{0x88}},
  339.     data_array[0]=0xa1001500;
  340.     dsi_set_cmdq(data_array, 1, 1);
  341.     data_array[0]=0x88c11500;
  342.     dsi_set_cmdq(data_array, 1, 1);
  343.    
  344. //{0x00,1,{0x81}},{0xc4,1,{0x83}},
  345.     data_array[0]=0x81001500;
  346.     dsi_set_cmdq(data_array, 1, 1);
  347.     data_array[0]=0x83c41500;
  348.     dsi_set_cmdq(data_array, 1, 1);
  349.    
  350. //{0x00,1,{0x92}},{0xc5,1,{0x01}},
  351.     data_array[0]=0x92001500;
  352.     dsi_set_cmdq(data_array, 1, 1);
  353.     data_array[0]=0x01c51500;
  354.     dsi_set_cmdq(data_array, 1, 1);
  355.    
  356. //{0x00,1,{0xb1}},{0xc5,1,{0xa9}},
  357.     data_array[0]=0xb1001500;
  358.     dsi_set_cmdq(data_array, 1, 1);
  359.     data_array[0]=0xa9c51500;
  360.     dsi_set_cmdq(data_array, 1, 1);
  361.    
  362. //{0x00,1,{0x80}},{0xce,12,{0x85,0x03,0x00,0x84,0x03,0x00,0x83,0x03,0x00,0x82,0x03,0x00}},
  363.     data_array[0]=0x80001500;
  364.     dsi_set_cmdq(data_array, 1, 1);
  365.     data_array[0]=0x000d3902;
  366.     data_array[1]=0x000385ce;
  367.     data_array[2]=0x83000384;
  368.     data_array[3]=0x03820003;
  369.     data_array[4]=0x00000000;
  370.     dsi_set_cmdq(data_array, 5, 1);

  371. //{0x00,1,{0xa0}},{0xce,14,{0x38,0x02,0x03,0x21,0x00,0x00,0x00,0x38,0x01,0x03,0x22,0x00,0x00,0x00}},
  372.     data_array[0]=0xa0001500;
  373.     dsi_set_cmdq(data_array, 1, 1);
  374.     data_array[0]=0x000d3902;
  375.     data_array[1]=0x030238ce;
  376.     data_array[2]=0x00000021;
  377.     data_array[3]=0x22030138;
  378.     data_array[4]=0x00000000;
  379.     dsi_set_cmdq(data_array, 5, 1);
  380.    
  381.    
  382. //{0x00,1,{0xb0}},{0xce,14,{0x38,0x00,0x03,0x23,0x00,0x00,0x00,0x30,0x00,0x03,0x24,0x00,0x00,0x00}},
  383.     data_array[0]=0xb0001500;
  384.     dsi_set_cmdq(data_array, 1, 1);
  385.     data_array[0]=0x000f3902;
  386.     data_array[1]=0x030038ce;
  387.     data_array[2]=0x00000023;
  388.     data_array[3]=0x24030030;
  389.     data_array[4]=0x23000000;
  390.     dsi_set_cmdq(data_array, 5, 1);
  391.    
  392. //{0x00,1,{0xc0}},{0xce,14,{0x30,0x01,0x03,0x25,0x00,0x00,0x00,0x30,0x02,0x03,0x26,0x00,0x00,0x00}},
  393.     data_array[0]= 0xc0001500;
  394.     dsi_set_cmdq(data_array, 1, 1);
  395.     data_array[0]=0x000f3902;
  396.     data_array[1]=0x030130ce;
  397.     data_array[2]=0x00000025;
  398.     data_array[3]=0x26030230;
  399.     data_array[4]=0x23000000;
  400.     dsi_set_cmdq(data_array, 5, 1);
  401.    
  402. //{0x00,1,{0xd0}},{0xce,14,{0x30,0x03,0x03,0x27,0x00,0x00,0x00,0x30,0x04,0x03,0x28,0x00,0x00,0x00}},
  403.     data_array[0]= 0xd0001500;
  404.     dsi_set_cmdq(data_array, 1, 1);
  405.     data_array[0]=0x000f3902;
  406.     data_array[1]=0x030330ce;
  407.     data_array[2]=0x00000027;
  408.     data_array[3]=0x28030430;
  409.     data_array[4]=0x23000000;
  410.     dsi_set_cmdq(data_array, 5, 1);
  411.    
  412. //{0x00,1,{0xc0}},{0xcf,10,{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}},
  413.     data_array[0]= 0xc0001500;
  414.     dsi_set_cmdq(data_array, 1, 1);
  415.     data_array[0]=0x000b3902;
  416.     data_array[1]=0x000000cf;
  417.     data_array[2]=0x00000000;
  418.     data_array[3]=0x28000000;
  419.     dsi_set_cmdq(data_array, 4, 1);


  420. //{0x00,1,{0xd0}},{0xcf,1,{0x00}},
  421.     data_array[0]=0xd0001500;
  422.     dsi_set_cmdq(data_array, 1, 1);
  423.     data_array[0]=0x00cf1500;
  424.     dsi_set_cmdq(data_array, 1, 1);
  425.    
  426. //{0x00,1,{0xc0}},{0xcb,15,{0x00,0x00,0x00,0x00,0x04,0x04,0x04,0x04,0x04,0x04,0x00,0x00,0x00,0x00,0x00}},
  427.     data_array[0]=0xc0001500;
  428.     dsi_set_cmdq(data_array, 1, 1);
  429.     data_array[0]=0x00103902;
  430.     data_array[1]=0x000000cb;
  431.     data_array[2]=0x04040400;
  432.     data_array[3]=0x00040404;
  433.     data_array[4]=0x00000000;
  434.     dsi_set_cmdq(data_array, 5, 1);

  435. //{0x00,1,{0xd0}},{0xcb,15,{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x04,0x04,0x04,0x04,0x04}},
  436.     data_array[0]=0xd0001500;
  437.     dsi_set_cmdq(data_array, 1, 1);
  438.     data_array[0]=0x00103902;
  439.     data_array[1]=0x000000cb;
  440.     data_array[2]=0x00000000;
  441.     data_array[3]=0x04040000;
  442.     data_array[4]=0x04040404;
  443.     dsi_set_cmdq(data_array, 5, 1);
  444. //{0x00,1,{0xe0}},{0xcb,10,{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}},
  445.     data_array[0]=0xe0001500;
  446.     dsi_set_cmdq(data_array, 1, 1);
  447.     data_array[0]=0x000b3902;
  448.     data_array[1]=0x000000cb;
  449.     data_array[2]=0x00000000;
  450.     data_array[3]=0x04000000;
  451.     dsi_set_cmdq(data_array, 4, 1);
  452.   
  453. //{0x00,1,{0x80}},{0xcc,10,{0x00,0x00,0x00,0x00,0x0c,0x0a,0x10,0x0e,0x03,0x04}},
  454.     data_array[0]=0x80001500;
  455.     dsi_set_cmdq(data_array, 1, 1);
  456.     data_array[0]=0x000b3902;
  457.     data_array[1]=0x000000cc;
  458.     data_array[2]=0x100a0c00;
  459.     data_array[3]=0x0404030e;
  460.     dsi_set_cmdq(data_array, 4, 1);
  461.   
  462. //{0x00,1,{0x90}},{0xcc,15,{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0b}},
  463.     data_array[0]=0x90001500;
  464.     dsi_set_cmdq(data_array, 1, 1);
  465.     data_array[0]=0x00103902;
  466.     data_array[1]=0x000000cc;
  467.     data_array[2]=0x00000000;
  468.     data_array[3]=0x00000000;
  469.     data_array[4]=0x0b000000;
  470.     dsi_set_cmdq(data_array, 5, 1);

  471. //{0x00,1,{0xa0}},{0xcc,15,{0x09,0x0f,0x0d,0x01,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}},
  472.     data_array[0]=0xa0001500;
  473.     dsi_set_cmdq(data_array, 1, 1);
  474.     data_array[0]=0x00103902;
  475.     data_array[1]=0x0d0f09cc;
  476.     data_array[2]= 0x00000201;
  477.     data_array[3]=0x00000000;
  478.     data_array[4]=0x00000000;
  479.     dsi_set_cmdq(data_array, 5, 1);

  480. //{0x00,1,{0xb0}},{0xcc,10,{0x00,0x00,0x00,0x00,0x0d,0x0f,0x09,0x0b,0x02,0x01}},
  481.     data_array[0]=0xb0001500;
  482.     dsi_set_cmdq(data_array, 1, 1);
  483.     data_array[0]=0x000b3902;
  484.     data_array[1]=0x000000cc;
  485.     data_array[2]=0x090f0d00;
  486.     data_array[3]=0x0001020b;
  487.     dsi_set_cmdq(data_array, 4, 1);
  488.   
  489. //{0x00,1,{0xc0}},{0xcc,15,{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0e}},
  490.     data_array[0]=0xc0001500;
  491.     dsi_set_cmdq(data_array, 1, 1);
  492.     data_array[0]=0x00103902;
  493.     data_array[1]=0x000000cc;
  494.     data_array[2]= 0x00000000;
  495.     data_array[3]=0x00000000;
  496.     data_array[4]=0x00000000;
  497.     dsi_set_cmdq(data_array, 5, 1);
  498.   
  499. //{0x00,1,{0xd0}},{0xcc,15,{0x10,0x0a,0x0c,0x04,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}},
  500.     data_array[0]=0xd0001500;
  501.     dsi_set_cmdq(data_array, 1, 1);
  502.     data_array[0]=0x00103902;
  503.     data_array[1]=0x0c0a10cc;
  504.     data_array[2]= 0x00000304;
  505.     data_array[3]=0x00000000;
  506.     data_array[4]=0x00000000;
  507.     dsi_set_cmdq(data_array, 5, 1);
  508.   
  509. //{0x00,1,{0x00}},{0xff,3,{0xff,0xff,0xff}},
  510.     data_array[0]=0x00001500;
  511.     dsi_set_cmdq(data_array, 1, 1);
  512.     data_array[0]=0x00043902;
  513.     data_array[1]=0xffffffff;
  514.     dsi_set_cmdq(data_array, 2, 1);

  515. //{0x3a,1,{0x77}},
  516.     data_array[0]=0x773a1500;
  517.     dsi_set_cmdq(data_array, 1, 1);

  518. #ifdef DISPLAY_DIRECTION_0_MODE
  519. //DCS_SHORT_1P(0x36,0x00);// Display Direction 0
  520. //DCS_SHORT_1P(0x35,0x00);// TE( Fmark ) Signal On
  521. //DCS_LONG_2P(0x44,0x01,0x22);// TE( Fmark ) Signal Output Position
  522.     data_array[0]=0x00361500;
  523.     dsi_set_cmdq(data_array, 1, 1);
  524.     data_array[0]=0x00351500;
  525.     dsi_set_cmdq(data_array, 1, 1);
  526.     data_array[0]=0x00033902;
  527.     data_array[0]=0x00220144;
  528.     dsi_set_cmdq(data_array, 2, 1);
  529. #endif

  530.     data_array[0]=0x00361500;
  531.     dsi_set_cmdq(data_array, 1, 1);
  532.     data_array[0]=0x00351500;
  533.     dsi_set_cmdq(data_array, 1, 1);


  534. #ifdef DISPLAY_DIRECTION_180_MODE
  535. //DCS_SHORT_1P(0x36,0xD0);// Display Direction 180
  536. //DCS_SHORT_1P(0x35,0x00);// TE( Fmark ) Signal On
  537. //DCS_LONG_2P(0x44,0x01,0xFF);// TE( Fmark ) Signal Output Position
  538.     data_array[0]=0xd0361500;
  539.     dsi_set_cmdq(data_array, 1, 1);
  540.     data_array[0]=0x00351500;
  541.     dsi_set_cmdq(data_array, 1, 1);
  542.     data_array[0]=0x00033902;
  543.     data_array[0]=0x00ff0144;
  544.     dsi_set_cmdq(data_array, 2, 1);
  545. #endif

  546. #ifdef LCD_BACKLIGHT_CONTROL_MODE
  547. //DCS_SHORT_1P(0x51,0xFF);// Backlight Level Control
  548. //DCS_SHORT_1P(0x53,0x2C);// Backlight On
  549. //DCS_SHORT_1P(0x55,0x00);// CABC Function Off
  550.     data_array[0]=0xff511500;
  551.     dsi_set_cmdq(data_array, 1, 1);
  552.     data_array[0]=0x2c531500;
  553.     dsi_set_cmdq(data_array, 1, 1);
  554.     data_array[0]=0x00551500;
  555.     dsi_set_cmdq(data_array, 1, 1);
  556. #endif


  557. }
  558. static void push_table(struct LCM_setting_table *table, unsigned int count, unsigned char force_update)
  559. {
  560.         unsigned int i;

  561.     for(i = 0; i < count; i++) {
  562.                
  563.         unsigned cmd;
  564.         cmd = table[i].cmd;
  565.                
  566.         switch (cmd) {
  567.                        
  568.             case REGFLAG_DELAY :
  569.                 MDELAY(table[i].count);
  570.                 break;
  571.                                
  572.             case REGFLAG_END_OF_TABLE :
  573.                 break;
  574.                                
  575.             default:
  576.                                 dsi_set_cmdq_V2(cmd, table[i].count, table[i].para_list, force_update);
  577.                }
  578.     }
  579.        
  580. }


  581. // ---------------------------------------------------------------------------
  582. //  LCM Driver Implementations
  583. // ---------------------------------------------------------------------------

  584. static void lcm_set_util_funcs(const LCM_UTIL_FUNCS *util)
  585. {
  586.     memcpy(&lcm_util, util, sizeof(LCM_UTIL_FUNCS));
  587. }


  588. static void lcm_get_params(LCM_PARAMS *params)
  589. {
  590.                 memset(params, 0, sizeof(LCM_PARAMS));
  591.        
  592.                 params->type   = LCM_TYPE_DSI;

  593.                 params->width  = FRAME_WIDTH;
  594.                 params->height = FRAME_HEIGHT;

  595.                 // enable tearing-free
  596.                 params->dbi.te_mode                                 = LCM_DBI_TE_MODE_VSYNC_ONLY;
  597.                 params->dbi.te_edge_polarity                = LCM_POLARITY_RISING;
  598.                 params->dsi.mode                                           = CMD_MODE;

  599.                 // DSI
  600.                 /* Command mode setting */
  601.                 params->dsi.LANE_NUM                                = LCM_TWO_LANE;
  602.                 //The following defined the fomat for data coming from LCD engine.
  603.                 params->dsi.data_format.color_order = LCM_COLOR_ORDER_RGB;
  604.                 params->dsi.data_format.trans_seq   = LCM_DSI_TRANS_SEQ_MSB_FIRST;
  605.                 params->dsi.data_format.padding     = LCM_DSI_PADDING_ON_LSB;
  606.                 params->dsi.data_format.format      = LCM_DSI_FORMAT_RGB888;

  607.                 // Highly depends on LCD driver capability.
  608.                 params->dsi.packet_size                            = 256;

  609.                 // Video mode setting               
  610.                 params->dsi.PS                      = LCM_PACKED_PS_24BIT_RGB888;

  611.                 params->dsi.word_count                  = 480*3;       
  612.                 params->dsi.vertical_sync_active        = 2;
  613.                 params->dsi.vertical_backporch                = 2;
  614.                 params->dsi.vertical_frontporch                = 2;
  615.                 params->dsi.vertical_active_line        = 800;
  616.        
  617.                 params->dsi.line_byte                                = 2180;                // 2256 = 752*3
  618.                 params->dsi.horizontal_sync_active_byte  = 26;
  619.                 params->dsi.horizontal_backporch_byte    = 206;
  620.                 params->dsi.horizontal_frontporch_byte   = 206;       
  621.                 params->dsi.rgb_byte                                         = (480*3+6);       
  622.        
  623.                 params->dsi.horizontal_sync_active_word_count = 20;       
  624.                 params->dsi.horizontal_backporch_word_count   = 200;
  625.                 params->dsi.horizontal_frontporch_word_count  = 200;

  626.                 // Bit rate calculation
  627.                 params->dsi.pll_div1   = 38;                // fref=26MHz, fvco=fref*(div1+1)        (div1=0~63, fvco=500MHZ~1GHz)
  628.                 params->dsi.pll_div2   = 1;                        // div2=0~15: fout=fvo/(2*div2)
  629.                
  630.       
  631. }


  632. static void lcm_init(void)
  633. {
  634.     SET_RESET_PIN(1);
  635.     SET_RESET_PIN(0);
  636.     MDELAY(10 );
  637.     SET_RESET_PIN(1);
  638.     MDELAY(10 );

  639.         //push_table(lcm_initialization_setting, sizeof(lcm_initialization_setting) / sizeof(struct LCM_setting_table), 1);
  640.     init_lcm_registers();
  641. }


  642. static void lcm_suspend(void)
  643. {
  644.         unsigned int data_array[16];
  645.        
  646.         data_array[0]=0x00280500;
  647.         dsi_set_cmdq(&data_array, 1, 1);
  648.         //MDELAY(50);
  649.        
  650.         data_array[0]=0x00100500;
  651.         dsi_set_cmdq(&data_array, 1, 1);       
  652.         MDELAY(150);
  653.         //push_table(lcm_deep_sleep_mode_in_setting, sizeof(lcm_deep_sleep_mode_in_setting) / sizeof(struct LCM_setting_table), 1);
  654. }


  655. static void lcm_resume(void)
  656. {
  657.         unsigned int data_array[16];

  658.         data_array[0]=0x00110500;
  659.         dsi_set_cmdq(&data_array, 1, 1);
  660.         MDELAY(150);
  661.        
  662.         data_array[0]=0x00290500;
  663.         dsi_set_cmdq(&data_array, 1, 1);               
  664.         //push_table(lcm_sleep_out_setting, sizeof(lcm_sleep_out_setting) / sizeof(struct LCM_setting_table), 1);
  665. }


  666. static void lcm_update(unsigned int x, unsigned int y,
  667.                        unsigned int width, unsigned int height)
  668. {
  669.         unsigned int x0 = x;
  670.         unsigned int y0 = y;
  671.         unsigned int x1 = x0 + width - 1;
  672.         unsigned int y1 = y0 + height - 1;

  673.         unsigned char x0_MSB = ((x0>>8)&0xFF);
  674.         unsigned char x0_LSB = (x0&0xFF);
  675.         unsigned char x1_MSB = ((x1>>8)&0xFF);
  676.         unsigned char x1_LSB = (x1&0xFF);
  677.         unsigned char y0_MSB = ((y0>>8)&0xFF);
  678.         unsigned char y0_LSB = (y0&0xFF);
  679.         unsigned char y1_MSB = ((y1>>8)&0xFF);
  680.         unsigned char y1_LSB = (y1&0xFF);

  681.         unsigned int data_array[16];

  682.         data_array[0]= 0x00053902;
  683.         data_array[1]= (x1_MSB<<24)|(x0_LSB<<16)|(x0_MSB<<8)|0x2a;
  684.         data_array[2]= (x1_LSB);
  685.         data_array[3]= 0x00053902;
  686.         data_array[4]= (y1_MSB<<24)|(y0_LSB<<16)|(y0_MSB<<8)|0x2b;
  687.         data_array[5]= (y1_LSB);
  688.         data_array[6]= 0x002c3909;
  689.         dsi_set_cmdq(&data_array, 7, 0);
  690. }


  691. static void lcm_setbacklight(unsigned int level)
  692. {
  693.         unsigned int default_level = 0;
  694.         unsigned int mapped_level = 0;

  695.         //for LGE backlight IC mapping table
  696.         if(level > 255)
  697.                 level = 255;

  698.         if(level >0)
  699.                 mapped_level = default_level+(level)*(255-default_level)/(255);
  700.         else
  701.                 mapped_level=0;

  702.         // Refresh value of backlight level.
  703.         lcm_backlight_level_setting[0].para_list[0] = mapped_level;

  704.         push_table(lcm_backlight_level_setting, sizeof(lcm_backlight_level_setting) / sizeof(struct LCM_setting_table), 1);
  705. }

  706. //static void lcm_setbacklight_mode(unsigned int mode)
  707. //{
  708. //        lcm_backlight_mode_setting[0].para_list[0] = mode;
  709. //        push_table(lcm_backlight_mode_setting, sizeof(lcm_backlight_mode_setting) / sizeof(struct LCM_setting_table), 1);
  710. //}

  711. static void lcm_setpwm(unsigned int divider)
  712. {
  713.         // TBD
  714. }


  715. static unsigned int lcm_getpwm(unsigned int divider)
  716. {
  717.         // ref freq = 15MHz, B0h setting 0x80, so 80.6% * freq is pwm_clk;
  718.         // pwm_clk / 255 / 2(lcm_setpwm() 6th params) = pwm_duration = 23706
  719.         unsigned int pwm_clk = 23706 / (1<<divider);       
  720.         return pwm_clk;
  721. }


  722. static unsigned int otm8009a_cmp_id(void)
  723. {
  724.         unsigned int id=0;
  725.         unsigned char buffer[2];
  726.         unsigned int array[16];   

  727.         SET_RESET_PIN(1);
  728.         SET_RESET_PIN(0);
  729.         MDELAY(25);
  730.         SET_RESET_PIN(1);
  731.         MDELAY(50);

  732.         array[0]=0x00043902;
  733.         array[1]=0x010980ff;
  734.         array[2]=0x80001500;
  735.         array[3]=0x00033902;
  736.         array[4]=0x010980ff;
  737.         dsi_set_cmdq(array, 5, 1);
  738.         MDELAY(10);

  739.         array[0] = 0x00023700;// set return byte number
  740.         dsi_set_cmdq(array, 1, 1);

  741.         array[0] = 0x02001500;
  742.         dsi_set_cmdq(array, 1, 1);

  743.         read_reg_v2(0xD2, &buffer, 2);

  744.         id = buffer[0]<<8 |buffer[1];

  745.        #if defined(BUILD_UBOOT)
  746.             //printf("[UBOOT]lcm_compare_id:LCM ID=%x,%x,x%\n",buffer[0],buffer[1],id);
  747.         #else
  748.             //printk("[UBOOT]lcm_compare_id:LCM ID=%x,%x,x%\n",buffer[0],buffer[1],id);
  749.         #endif
  750.         return (LCM_ID == id)?1:0;

  751. }

  752. // ---------------------------------------------------------------------------
  753. //  Get LCM Driver Hooks
  754. // ---------------------------------------------------------------------------
  755. LCM_DRIVER otm8009a_dsi_lcm_drv =
  756. {
  757.     .name                        = "otm8009a_dsi",
  758.         .set_util_funcs = lcm_set_util_funcs,
  759.         .get_params     = lcm_get_params,
  760.         .init           = lcm_init,
  761.         .suspend        = lcm_suspend,
  762.         .resume         = lcm_resume,
  763.         .update         = lcm_update,
  764.         .set_backlight        = lcm_setbacklight,
  765. //        .set_backlight_mode = lcm_setbacklight_mode,
  766.         //.set_pwm        = lcm_setpwm,
  767.         //.get_pwm        = lcm_getpwm  
  768.         .compare_id    = otm8009a_cmp_id,
  769. };

复制代码

  1. /*****************************************************************************
  2. *  Copyright Statement:
  3. *  --------------------
  4. *  This software is protected by Copyright and the information contained
  5. *  herein is confidential. The software may not be copied and the information
  6. *  contained herein may not be used or disclosed except with the written
  7. *  permission of MediaTek Inc. (C) 2008
  8. *
  9. *  BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
  10. *  THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
  11. *  RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
  12. *  AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
  13. *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
  14. *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
  15. *  NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
  16. *  SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
  17. *  SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
  18. *  THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
  19. *  NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
  20. *  SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
  21. *
  22. *  BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
  23. *  LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
  24. *  AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
  25. *  OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
  26. *  MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
  27. *
  28. *  THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
  29. *  WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
  30. *  LAWS PRINCIPLES.  ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
  31. *  RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
  32. *  THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
  33. *
  34. *****************************************************************************/
  35. #ifdef BUILD_UBOOT
  36. #define ENABLE_DSI_INTERRUPT 0

  37. #include <asm/arch/disp_drv_platform.h>
  38. #else

  39. #define ENABLE_DSI_INTERRUPT 1

  40. #include <linux/delay.h>
  41. #include <disp_drv_log.h>
  42. #include <linux/time.h>
  43. #include <linux/string.h>
  44. #include <linux/spinlock.h>

  45. #include <mach/mt6577_typedefs.h>
  46. #include <mach/mt6577_reg_base.h>
  47. #include <mach/mt6577_irq.h>
  48. #include <mach/mt_gpio.h>
  49. #include "mach/mt6577_clock_manager.h"
  50. #include <mach/mt6577_boot.h>

  51. #include "lcd_reg.h"
  52. #include "lcd_drv.h"

  53. #include "dpi_reg.h"
  54. #include "dpi_drv.h"

  55. #include "dsi_reg.h"
  56. #include "dsi_drv.h"
  57. #endif

  58. #if ENABLE_DSI_INTERRUPT
  59. #include <linux/sched.h>
  60. #include <linux/interrupt.h>
  61. #include <linux/wait.h>
  62. #include <mach/irqs.h>
  63. #include "mtkfb.h"
  64. static wait_queue_head_t _dsi_wait_queue;
  65. static wait_queue_head_t _dsi_dcs_read_wait_queue;
  66. #endif

  67. /*
  68. #define PLL_BASE                        (0xF0060000)
  69. #define DSI_PHY_BASE                (0xF0060B00)
  70. #define DSI_BASE                    (0xF0140000)
  71. */

  72. //#define PWR_OFF                 (APCONFIG_BASE + 0x0304)
  73. //#define GRAPH1_PDN              (1 << 3)
  74. #define G1_MEM_PDN              (APCONFIG_BASE + 0x0060)
  75. #define G1_MEM_DSI              (1)
  76. #ifdef BUILD_UBOOT
  77. #define GRAPH1SYS_CG_SET        (GMC1_BASE + 0x320)
  78. #define GRAPH1SYS_CG_CLR        (GMC1_BASE + 0x340)
  79. #else
  80. #define GRAPH1SYS_CG_SET        (MMSYS1_CONFIG_BASE + 0x320)
  81. #define GRAPH1SYS_CG_CLR        (MMSYS1_CONFIG_BASE + 0x340)
  82. #endif
  83. #define GRAPH1SYS_CG_DSI        (1 << 28)

  84. #if !(defined(CONFIG_MT6577_FPGA) || defined(BUILD_UBOOT))
  85. #define DSI_MIPI_API
  86. #endif

  87. static PDSI_REGS const DSI_REG = (PDSI_REGS)(DSI_BASE);
  88. static PDSI_PHY_REGS const DSI_PHY_REG = (PDSI_PHY_REGS)(MIPI_CONFG_BASE+0x800);
  89. static PDSI_CMDQ_REGS const DSI_CMDQ_REG = (PDSI_CMDQ_REGS)(DSI_BASE+0x180);
  90. static PLCD_REGS const LCD_REG = (PLCD_REGS)(LCD_BASE);
  91. static PDPI_REGS const DPI_REG = (PDPI_REGS)(DPI_BASE);

  92. static MIPITX_CFG0_REG mipitx_con0;
  93. static MIPITX_CFG1_REG mipitx_con1;
  94. static MIPITX_CFG3_REG mipitx_con3;
  95. static MIPITX_CFG6_REG mipitx_con6;
  96. static MIPITX_CFG8_REG mipitx_con8;
  97. static MIPITX_CFG9_REG mipitx_con9;

  98. typedef struct
  99. {
  100.         DSI_REGS regBackup;
  101.         unsigned int bit_time_ns;
  102.         unsigned int vfp_period_us;
  103.         unsigned int vsa_vs_period_us;
  104.         unsigned int vsa_hs_period_us;
  105.         unsigned int vsa_ve_period_us;
  106.         unsigned int vbp_period_us;
  107.     void (*pIntCallback)(DISP_INTERRUPT_EVENTS);
  108. } DSI_CONTEXT;

  109. static bool s_isDsiPowerOn = FALSE;
  110. bool is_needReConfig = true;
  111. static DSI_CONTEXT _dsiContext;

  112. #ifndef BUILD_UBOOT

  113. DEFINE_SPINLOCK(g_handle_esd_lock);

  114. static bool dsi_esd_recovery = false;
  115. static bool dsi_noncont_clk_enabled = false;
  116. static unsigned int dsi_noncont_clk_period = 1;
  117. static bool dsi_int_te_enabled = false;
  118. static unsigned int dsi_int_te_period = 1;
  119. static unsigned int dsi_dpi_isr_count = 0;
  120. unsigned long g_handle_esd_flag;

  121. #endif

  122. #ifdef BUILD_UBOOT
  123. static long int get_current_time_us(void)
  124. {
  125.     return 0;       ///TODO: fix me
  126. }
  127. #else
  128. static long int get_current_time_us(void)
  129. {
  130.     struct timeval t;
  131.     do_gettimeofday(&t);
  132.     return (t.tv_sec & 0xFFF) * 1000000 + t.tv_usec;
  133. }
  134. #endif
  135. static void lcm_mdelay(UINT32 ms)
  136. {
  137.     udelay(1000 * ms);
  138. }

  139. #if ENABLE_DSI_INTERRUPT
  140. static irqreturn_t _DSI_InterruptHandler(int irq, void *dev_id)
  141. {   
  142.     DSI_INT_STATUS_REG status = DSI_REG->DSI_INTSTA;

  143.     if (status.RD_RDY)
  144.     {        
  145.         ///write clear RD_RDY interrupt
  146.         DSI_REG->DSI_INTSTA.RD_RDY = 1;   

  147.         /// write clear RD_RDY interrupt must be before DSI_RACK
  148.         /// because CMD_DONE will raise after DSI_RACK,
  149.         /// so write clear RD_RDY after that will clear CMD_DONE too
  150.         
  151.                 do
  152.         {
  153.             ///send read ACK
  154.             DSI_REG->DSI_RACK.DSI_RACK = 1;
  155.         } while(DSI_REG->DSI_STA.BUSY);

  156.                 wake_up_interruptible(&_dsi_dcs_read_wait_queue);
  157.         if(_dsiContext.pIntCallback)
  158.             _dsiContext.pIntCallback(DISP_DSI_READ_RDY_INT);            
  159.     }

  160.     if (status.CMD_DONE)
  161.     {
  162.         DSI_REG->DSI_INTSTA.CMD_DONE = 1;
  163.             // Go back to LP mode.
  164.             DSI_clk_HS_mode(0);
  165.         wake_up_interruptible(&_dsi_wait_queue);
  166.         if(_dsiContext.pIntCallback)
  167.             _dsiContext.pIntCallback(DISP_DSI_CMD_DONE_INT);            
  168.     }

  169.     return IRQ_HANDLED;
  170. }
  171. #endif


  172. static BOOL _IsEngineBusy(void)
  173. {
  174.         DSI_STATUS_REG status;

  175.         status = DSI_REG->DSI_STA;
  176.        
  177.         if (status.BUSY || status.ERR_MSG)
  178.                 return TRUE;

  179.         return FALSE;
  180. }

  181. #if 0
  182. static BOOL _IsCMDQBusy(void)
  183. {
  184.         DSI_INT_STATUS_REG INT_status;

  185.         INT_status=DSI_REG->DSI_INTSTA;

  186.         if (!INT_status.CMD_DONE)
  187.         {
  188.                 DISP_LOG_PRINT(ANDROID_LOG_WARN, "DSI", " DSI CMDQ status BUSY !\n");
  189.        
  190.                 return TRUE;
  191.         }

  192.         return FALSE;
  193. }
  194. #endif

  195. static void _WaitForEngineNotBusy(

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top