sm750.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef LYNXDRV_H_
  3. #define LYNXDRV_H_
  4. #define FB_ACCEL_SMI 0xab
  5. #define MHZ(x) ((x) * 1000000)
  6. #define DEFAULT_SM750_CHIP_CLOCK 290
  7. #define DEFAULT_SM750LE_CHIP_CLOCK 333
  8. #ifndef SM750LE_REVISION_ID
  9. #define SM750LE_REVISION_ID ((unsigned char)0xfe)
  10. #endif
  11. enum sm750_pnltype {
  12. sm750_24TFT = 0, /* 24bit tft */
  13. sm750_dualTFT = 2, /* dual 18 bit tft */
  14. sm750_doubleTFT = 1, /* 36 bit double pixel tft */
  15. };
  16. /* vga channel is not concerned */
  17. enum sm750_dataflow {
  18. sm750_simul_pri, /* primary => all head */
  19. sm750_simul_sec, /* secondary => all head */
  20. sm750_dual_normal, /* primary => panel head and secondary => crt */
  21. sm750_dual_swap, /* primary => crt head and secondary => panel */
  22. };
  23. enum sm750_channel {
  24. sm750_primary = 0,
  25. /* enum value equal to the register filed data */
  26. sm750_secondary = 1,
  27. };
  28. enum sm750_path {
  29. sm750_panel = 1,
  30. sm750_crt = 2,
  31. sm750_pnc = 3, /* panel and crt */
  32. };
  33. struct init_status {
  34. ushort powerMode;
  35. /* below three clocks are in unit of MHZ*/
  36. ushort chip_clk;
  37. ushort mem_clk;
  38. ushort master_clk;
  39. ushort setAllEngOff;
  40. ushort resetMemory;
  41. };
  42. struct lynx_accel {
  43. /* base virtual address of DPR registers */
  44. volatile unsigned char __iomem *dprBase;
  45. /* base virtual address of de data port */
  46. volatile unsigned char __iomem *dpPortBase;
  47. /* function pointers */
  48. void (*de_init)(struct lynx_accel *);
  49. int (*de_wait)(void);/* see if hardware ready to work */
  50. int (*de_fillrect)(struct lynx_accel *, u32, u32, u32, u32,
  51. u32, u32, u32, u32, u32);
  52. int (*de_copyarea)(struct lynx_accel *, u32, u32, u32, u32,
  53. u32, u32, u32, u32,
  54. u32, u32, u32, u32);
  55. int (*de_imageblit)(struct lynx_accel *, const char *, u32, u32, u32, u32,
  56. u32, u32, u32, u32,
  57. u32, u32, u32, u32);
  58. };
  59. struct sm750_dev {
  60. /* common members */
  61. u16 devid;
  62. u8 revid;
  63. struct pci_dev *pdev;
  64. struct fb_info *fbinfo[2];
  65. struct lynx_accel accel;
  66. int accel_off;
  67. int fb_count;
  68. int mtrr_off;
  69. struct{
  70. int vram;
  71. } mtrr;
  72. /* all smi graphic adaptor got below attributes */
  73. unsigned long vidmem_start;
  74. unsigned long vidreg_start;
  75. __u32 vidmem_size;
  76. __u32 vidreg_size;
  77. void __iomem *pvReg;
  78. unsigned char __iomem *pvMem;
  79. /* locks*/
  80. spinlock_t slock;
  81. struct init_status initParm;
  82. enum sm750_pnltype pnltype;
  83. enum sm750_dataflow dataflow;
  84. int nocrt;
  85. /*
  86. * 0: no hardware cursor
  87. * 1: primary crtc hw cursor enabled,
  88. * 2: secondary crtc hw cursor enabled
  89. * 3: both ctrc hw cursor enabled
  90. */
  91. int hwCursor;
  92. };
  93. struct lynx_cursor {
  94. /* cursor width ,height and size */
  95. int w;
  96. int h;
  97. int size;
  98. /* hardware limitation */
  99. int maxW;
  100. int maxH;
  101. /* base virtual address and offset of cursor image */
  102. char __iomem *vstart;
  103. int offset;
  104. /* mmio addr of hw cursor */
  105. volatile char __iomem *mmio;
  106. };
  107. struct lynxfb_crtc {
  108. unsigned char __iomem *vCursor; /* virtual address of cursor */
  109. unsigned char __iomem *vScreen; /* virtual address of on_screen */
  110. int oCursor; /* cursor address offset in vidmem */
  111. int oScreen; /* onscreen address offset in vidmem */
  112. int channel;/* which channel this crtc stands for*/
  113. resource_size_t vidmem_size;/* this view's video memory max size */
  114. /* below attributes belong to info->fix, their value depends on specific adaptor*/
  115. u16 line_pad;/* padding information:0,1,2,4,8,16,... */
  116. u16 xpanstep;
  117. u16 ypanstep;
  118. u16 ywrapstep;
  119. void *priv;
  120. /* cursor information */
  121. struct lynx_cursor cursor;
  122. };
  123. struct lynxfb_output {
  124. int dpms;
  125. int paths;
  126. /*
  127. * which paths(s) this output stands for,for sm750:
  128. * paths=1:means output for panel paths
  129. * paths=2:means output for crt paths
  130. * paths=3:means output for both panel and crt paths
  131. */
  132. int *channel;
  133. /*
  134. * which channel these outputs linked with,for sm750:
  135. * *channel=0 means primary channel
  136. * *channel=1 means secondary channel
  137. * output->channel ==> &crtc->channel
  138. */
  139. void *priv;
  140. int (*proc_setBLANK)(struct lynxfb_output*, int);
  141. };
  142. struct lynxfb_par {
  143. /* either 0 or 1 for dual head adaptor,0 is the older one registered */
  144. int index;
  145. unsigned int pseudo_palette[256];
  146. struct lynxfb_crtc crtc;
  147. struct lynxfb_output output;
  148. struct fb_info *info;
  149. struct sm750_dev *dev;
  150. };
  151. static inline unsigned long ps_to_hz(unsigned int psvalue)
  152. {
  153. unsigned long long numerator = 1000 * 1000 * 1000 * 1000ULL;
  154. /* 10^12 / picosecond period gives frequency in Hz */
  155. do_div(numerator, psvalue);
  156. return (unsigned long)numerator;
  157. }
  158. int hw_sm750_map(struct sm750_dev *sm750_dev, struct pci_dev *pdev);
  159. int hw_sm750_inithw(struct sm750_dev *sm750_dev, struct pci_dev *pdev);
  160. void hw_sm750_initAccel(struct sm750_dev *sm750_dev);
  161. int hw_sm750_deWait(void);
  162. int hw_sm750le_deWait(void);
  163. int hw_sm750_output_setMode(struct lynxfb_output *output,
  164. struct fb_var_screeninfo *var,
  165. struct fb_fix_screeninfo *fix);
  166. int hw_sm750_crtc_checkMode(struct lynxfb_crtc *crtc,
  167. struct fb_var_screeninfo *var);
  168. int hw_sm750_crtc_setMode(struct lynxfb_crtc *crtc,
  169. struct fb_var_screeninfo *var,
  170. struct fb_fix_screeninfo *fix);
  171. int hw_sm750_setColReg(struct lynxfb_crtc *crtc, ushort index,
  172. ushort red, ushort green, ushort blue);
  173. int hw_sm750_setBLANK(struct lynxfb_output *output, int blank);
  174. int hw_sm750le_setBLANK(struct lynxfb_output *output, int blank);
  175. int hw_sm750_pan_display(struct lynxfb_crtc *crtc,
  176. const struct fb_var_screeninfo *var,
  177. const struct fb_info *info);
  178. #endif