drv_slcdc.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. /*
  2. * File : drv_slcdc.h
  3. * COPYRIGHT (C) 2008 - 2016, RT-Thread Development Team
  4. *
  5. * Change Logs:
  6. * Date Author Notes
  7. * 2017Äê3ÔÂ21ÈÕ Urey the first version
  8. */
  9. #ifndef _DRV_SLCDC_H_
  10. #define _DRV_SLCDC_H_
  11. #ifdef __cplusplus
  12. extern "C" {
  13. #endif
  14. #include <stdint.h>
  15. //#define CONFIG_SLCDC_CONTINUA
  16. #define SLCDC_USING_DUAL_BUFFER
  17. #define CONFIG_SLCDC_USE_TE
  18. #define FB_BASE 0x80200000
  19. #ifndef FB_PAGE_SIZE
  20. # define FB_PAGE_SIZE 4096
  21. #endif
  22. /* SLCDC reg ops */
  23. #define slcd_reg_write(addr,config) writel(config,addr)
  24. #define slcd_reg_read(addr) readl(addr)
  25. struct slcdc_dma_descriptor
  26. {
  27. uint32_t fdadr; /* Frame descriptor address register */
  28. uint32_t fsadr; /* Frame source address register */
  29. uint32_t fidr; /* Frame ID register */
  30. uint32_t ldcmd; /* Command register */
  31. uint32_t offsize; /* Stride Offsize(in word) */
  32. uint32_t page_width; /* Stride Pagewidth(in word) */
  33. uint32_t cmd_num; /* Command Number(for SLCD) */
  34. uint32_t desc_size; /* Foreground Size */
  35. };
  36. /* smart lcd interface_type */
  37. enum smart_lcd_type {
  38. SMART_LCD_TYPE_PARALLEL,
  39. SMART_LCD_TYPE_SERIAL,
  40. };
  41. /* smart lcd command width */
  42. enum smart_lcd_cwidth {
  43. SMART_LCD_CWIDTH_16_BIT_ONCE = (0 << 8),
  44. SMART_LCD_CWIDTH_9_BIT_ONCE = SMART_LCD_CWIDTH_16_BIT_ONCE,
  45. SMART_LCD_CWIDTH_8_BIT_ONCE = (0x1 << 8),
  46. SMART_LCD_CWIDTH_18_BIT_ONCE = (0x2 << 8),
  47. SMART_LCD_CWIDTH_24_BIT_ONCE = (0x3 << 8),
  48. };
  49. /* smart lcd data width */
  50. enum smart_lcd_dwidth {
  51. SMART_LCD_DWIDTH_18_BIT_ONCE_PARALLEL_SERIAL = (0 << 10),
  52. SMART_LCD_DWIDTH_16_BIT_ONCE_PARALLEL_SERIAL = (0x1 << 10),
  53. SMART_LCD_DWIDTH_8_BIT_THIRD_TIME_PARALLEL = (0x2 << 10),
  54. SMART_LCD_DWIDTH_8_BIT_TWICE_TIME_PARALLEL = (0x3 << 10),
  55. SMART_LCD_DWIDTH_8_BIT_ONCE_PARALLEL_SERIAL = (0x4 << 10),
  56. SMART_LCD_DWIDTH_24_BIT_ONCE_PARALLEL = (0x5 << 10),
  57. SMART_LCD_DWIDTH_9_BIT_TWICE_TIME_PARALLEL = (0x7 << 10),
  58. SMART_LCD_DWIDTH_MASK = (0x7 << 10),
  59. };
  60. /* smart lcd new data width */
  61. enum smart_lcd_new_dwidth {
  62. SMART_LCD_NEW_DWIDTH_24_BIT = (4 << 13),
  63. SMART_LCD_NEW_DWIDTH_18_BIT = (3 << 13),
  64. SMART_LCD_NEW_DWIDTH_16_BIT = (2 << 13),
  65. SMART_LCD_NEW_DWIDTH_9_BIT = (1 << 13),
  66. SMART_LCD_NEW_DWIDTH_8_BIT = (0 << 13),
  67. };
  68. /* smart lcd data times */
  69. enum smart_lcd_new_dtimes {
  70. SMART_LCD_NEW_DTIMES_ONCE = (0 << 8),
  71. SMART_LCD_NEW_DTIMES_TWICE = (1 << 8),
  72. SMART_LCD_NEW_DTIMES_THICE = (2 << 8),
  73. };
  74. /* smart lcd init code type */
  75. enum smart_config_type
  76. {
  77. SMART_CONFIG_CMD = 0,
  78. SMART_CONFIG_DATA = 1,
  79. SMART_CONFIG_UDELAY = 2,
  80. };
  81. struct slcd_data_table
  82. {
  83. enum smart_config_type type;
  84. uint32_t value;
  85. };
  86. typedef void (*lcd_bl_func_t)(rt_bool_t isPowerON);
  87. struct slcd_configure;
  88. struct slcdc_dev_s
  89. {
  90. struct rt_device parent;
  91. struct rt_mutex lock;
  92. struct slcd_configure *cfg;
  93. struct slcdc_dma_descriptor *desc_tmp;
  94. struct slcdc_dma_descriptor *desc_cmd;
  95. struct slcdc_dma_descriptor *desc_dat;
  96. struct slcdc_dma_descriptor *desc_self;
  97. rt_uint32_t fb_base;
  98. rt_uint32_t fb_cmd;
  99. rt_uint32_t fb_screen;
  100. #ifdef SLCDC_USING_DUAL_BUFFER
  101. rt_uint32_t fb_dual;
  102. #endif
  103. rt_uint32_t fb_size;
  104. };
  105. struct slcd_configure
  106. {
  107. unsigned pinmd :1;
  108. unsigned pixclk_falling_edge :1;
  109. unsigned data_enable_active_low :1;
  110. unsigned clkply_active_rising:1; /* smart lcd clock polarity:
  111. 0: Active edge is Falling,
  112. 1: Active edge is Rasing */
  113. unsigned rsply_cmd_high:1; /* smart lcd RS polarity.
  114. 0: Command_RS=0, Data_RS=1;
  115. 1: Command_RS=1, Data_RS=0 */
  116. unsigned csply_active_high:1; /* smart lcd CS Polarity.
  117. 0: Active level is low,
  118. 1: Active level is high */
  119. unsigned newcfg_6800_md:1;
  120. unsigned newcfg_fmt_conv:1;
  121. unsigned newcfg_cmd_9bit:1;
  122. rt_uint32_t width;
  123. rt_uint32_t height;
  124. rt_uint32_t fmt;
  125. rt_uint32_t bpp;
  126. rt_uint32_t bus_width;
  127. rt_uint32_t reg_width;
  128. rt_uint32_t refresh;
  129. const struct slcd_data_table *data_table;
  130. rt_uint32_t data_table_num;
  131. const rt_uint32_t *cmd_table; /* write GRAM command */
  132. rt_uint32_t cmd_table_num;
  133. };
  134. int rt_hw_slcd_init (struct slcd_configure *cfg);
  135. void rt_hw_slcd_set_bl_func (lcd_bl_func_t bl_func);
  136. #ifdef __cplusplus
  137. }
  138. #endif
  139. #endif /* _DRV_SLCDC_H_ */