video-pxafb.h 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Support for the xscale frame buffer.
  4. *
  5. * Author: Jean-Frederic Clere
  6. * Created: Sep 22, 2003
  7. * Copyright: [email protected]
  8. */
  9. #include <linux/fb.h>
  10. /*
  11. * Supported LCD connections
  12. *
  13. * bits 0 - 3: for LCD panel type:
  14. *
  15. * STN - for passive matrix
  16. * DSTN - for dual scan passive matrix
  17. * TFT - for active matrix
  18. *
  19. * bits 4 - 9 : for bus width
  20. * bits 10-17 : for AC Bias Pin Frequency
  21. * bit 18 : for output enable polarity
  22. * bit 19 : for pixel clock edge
  23. * bit 20 : for output pixel format when base is RGBT16
  24. */
  25. #define LCD_CONN_TYPE(_x) ((_x) & 0x0f)
  26. #define LCD_CONN_WIDTH(_x) (((_x) >> 4) & 0x1f)
  27. #define LCD_TYPE_MASK 0xf
  28. #define LCD_TYPE_UNKNOWN 0
  29. #define LCD_TYPE_MONO_STN 1
  30. #define LCD_TYPE_MONO_DSTN 2
  31. #define LCD_TYPE_COLOR_STN 3
  32. #define LCD_TYPE_COLOR_DSTN 4
  33. #define LCD_TYPE_COLOR_TFT 5
  34. #define LCD_TYPE_SMART_PANEL 6
  35. #define LCD_TYPE_MAX 7
  36. #define LCD_MONO_STN_4BPP ((4 << 4) | LCD_TYPE_MONO_STN)
  37. #define LCD_MONO_STN_8BPP ((8 << 4) | LCD_TYPE_MONO_STN)
  38. #define LCD_MONO_DSTN_8BPP ((8 << 4) | LCD_TYPE_MONO_DSTN)
  39. #define LCD_COLOR_STN_8BPP ((8 << 4) | LCD_TYPE_COLOR_STN)
  40. #define LCD_COLOR_DSTN_16BPP ((16 << 4) | LCD_TYPE_COLOR_DSTN)
  41. #define LCD_COLOR_TFT_8BPP ((8 << 4) | LCD_TYPE_COLOR_TFT)
  42. #define LCD_COLOR_TFT_16BPP ((16 << 4) | LCD_TYPE_COLOR_TFT)
  43. #define LCD_COLOR_TFT_18BPP ((18 << 4) | LCD_TYPE_COLOR_TFT)
  44. #define LCD_SMART_PANEL_8BPP ((8 << 4) | LCD_TYPE_SMART_PANEL)
  45. #define LCD_SMART_PANEL_16BPP ((16 << 4) | LCD_TYPE_SMART_PANEL)
  46. #define LCD_SMART_PANEL_18BPP ((18 << 4) | LCD_TYPE_SMART_PANEL)
  47. #define LCD_AC_BIAS_FREQ(x) (((x) & 0xff) << 10)
  48. #define LCD_BIAS_ACTIVE_HIGH (0 << 18)
  49. #define LCD_BIAS_ACTIVE_LOW (1 << 18)
  50. #define LCD_PCLK_EDGE_RISE (0 << 19)
  51. #define LCD_PCLK_EDGE_FALL (1 << 19)
  52. #define LCD_ALTERNATE_MAPPING (1 << 20)
  53. /*
  54. * This structure describes the machine which we are running on.
  55. * It is set in linux/arch/arm/mach-pxa/machine_name.c and used in the probe routine
  56. * of linux/drivers/video/pxafb.c
  57. */
  58. struct pxafb_mode_info {
  59. u_long pixclock;
  60. u_short xres;
  61. u_short yres;
  62. u_char bpp;
  63. u_int cmap_greyscale:1,
  64. depth:8,
  65. transparency:1,
  66. unused:22;
  67. /* Parallel Mode Timing */
  68. u_char hsync_len;
  69. u_char left_margin;
  70. u_char right_margin;
  71. u_char vsync_len;
  72. u_char upper_margin;
  73. u_char lower_margin;
  74. u_char sync;
  75. /* Smart Panel Mode Timing - see PXA27x DM 7.4.15.0.3 for details
  76. * Note:
  77. * 1. all parameters in nanosecond (ns)
  78. * 2. a0cs{rd,wr}_set_hld are controlled by the same register bits
  79. * in pxa27x and pxa3xx, initialize them to the same value or
  80. * the larger one will be used
  81. * 3. same to {rd,wr}_pulse_width
  82. *
  83. * 4. LCD_PCLK_EDGE_{RISE,FALL} controls the L_PCLK_WR polarity
  84. * 5. sync & FB_SYNC_HOR_HIGH_ACT controls the L_LCLK_A0
  85. * 6. sync & FB_SYNC_VERT_HIGH_ACT controls the L_LCLK_RD
  86. */
  87. unsigned a0csrd_set_hld; /* A0 and CS Setup/Hold Time before/after L_FCLK_RD */
  88. unsigned a0cswr_set_hld; /* A0 and CS Setup/Hold Time before/after L_PCLK_WR */
  89. unsigned wr_pulse_width; /* L_PCLK_WR pulse width */
  90. unsigned rd_pulse_width; /* L_FCLK_RD pulse width */
  91. unsigned cmd_inh_time; /* Command Inhibit time between two writes */
  92. unsigned op_hold_time; /* Output Hold time from L_FCLK_RD negation */
  93. };
  94. struct pxafb_mach_info {
  95. struct pxafb_mode_info *modes;
  96. unsigned int num_modes;
  97. unsigned int lcd_conn;
  98. unsigned long video_mem_size;
  99. u_int fixed_modes:1,
  100. cmap_inverse:1,
  101. cmap_static:1,
  102. acceleration_enabled:1,
  103. unused:28;
  104. /* The following should be defined in LCCR0
  105. * LCCR0_Act or LCCR0_Pas Active or Passive
  106. * LCCR0_Sngl or LCCR0_Dual Single/Dual panel
  107. * LCCR0_Mono or LCCR0_Color Mono/Color
  108. * LCCR0_4PixMono or LCCR0_8PixMono (in mono single mode)
  109. * LCCR0_DMADel(Tcpu) (optional) DMA request delay
  110. *
  111. * The following should not be defined in LCCR0:
  112. * LCCR0_OUM, LCCR0_BM, LCCR0_QDM, LCCR0_DIS, LCCR0_EFM
  113. * LCCR0_IUM, LCCR0_SFM, LCCR0_LDM, LCCR0_ENB
  114. */
  115. u_int lccr0;
  116. /* The following should be defined in LCCR3
  117. * LCCR3_OutEnH or LCCR3_OutEnL Output enable polarity
  118. * LCCR3_PixRsEdg or LCCR3_PixFlEdg Pixel clock edge type
  119. * LCCR3_Acb(X) AB Bias pin frequency
  120. * LCCR3_DPC (optional) Double Pixel Clock mode (untested)
  121. *
  122. * The following should not be defined in LCCR3
  123. * LCCR3_HSP, LCCR3_VSP, LCCR0_Pcd(x), LCCR3_Bpp
  124. */
  125. u_int lccr3;
  126. /* The following should be defined in LCCR4
  127. * LCCR4_PAL_FOR_0 or LCCR4_PAL_FOR_1 or LCCR4_PAL_FOR_2
  128. *
  129. * All other bits in LCCR4 should be left alone.
  130. */
  131. u_int lccr4;
  132. void (*pxafb_backlight_power)(int);
  133. void (*pxafb_lcd_power)(int, struct fb_var_screeninfo *);
  134. void (*smart_update)(struct fb_info *);
  135. };
  136. void pxa_set_fb_info(struct device *, struct pxafb_mach_info *);
  137. unsigned long pxafb_get_hsync_time(struct device *dev);
  138. /* smartpanel related */
  139. #define SMART_CMD_A0 (0x1 << 8)
  140. #define SMART_CMD_READ_STATUS_REG (0x0 << 9)
  141. #define SMART_CMD_READ_FRAME_BUFFER ((0x0 << 9) | SMART_CMD_A0)
  142. #define SMART_CMD_WRITE_COMMAND (0x1 << 9)
  143. #define SMART_CMD_WRITE_DATA ((0x1 << 9) | SMART_CMD_A0)
  144. #define SMART_CMD_WRITE_FRAME ((0x2 << 9) | SMART_CMD_A0)
  145. #define SMART_CMD_WAIT_FOR_VSYNC (0x3 << 9)
  146. #define SMART_CMD_NOOP (0x4 << 9)
  147. #define SMART_CMD_INTERRUPT (0x5 << 9)
  148. #define SMART_CMD(x) (SMART_CMD_WRITE_COMMAND | ((x) & 0xff))
  149. #define SMART_DAT(x) (SMART_CMD_WRITE_DATA | ((x) & 0xff))
  150. /* SMART_DELAY() is introduced for software controlled delay primitive which
  151. * can be inserted between command sequences, unused command 0x6 is used here
  152. * and delay ranges from 0ms ~ 255ms
  153. */
  154. #define SMART_CMD_DELAY (0x6 << 9)
  155. #define SMART_DELAY(ms) (SMART_CMD_DELAY | ((ms) & 0xff))
  156. #ifdef CONFIG_FB_PXA_SMARTPANEL
  157. extern int pxafb_smart_queue(struct fb_info *info, uint16_t *cmds, int);
  158. extern int pxafb_smart_flush(struct fb_info *info);
  159. #else
  160. static inline int pxafb_smart_queue(struct fb_info *info,
  161. uint16_t *cmds, int n)
  162. {
  163. return 0;
  164. }
  165. static inline int pxafb_smart_flush(struct fb_info *info)
  166. {
  167. return 0;
  168. }
  169. #endif