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