Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
sticore.h
Go to the documentation of this file.
1 #ifndef STICORE_H
2 #define STICORE_H
3 
4 /* generic STI structures & functions */
5 
6 #if 0
7 #define DPRINTK(x) printk x
8 #else
9 #define DPRINTK(x)
10 #endif
11 
12 #define MAX_STI_ROMS 4 /* max no. of ROMs which this driver handles */
13 
14 #define STI_REGION_MAX 8 /* hardcoded STI constants */
15 #define STI_DEV_NAME_LENGTH 32
16 #define STI_MONITOR_MAX 256
17 
18 #define STI_FONT_HPROMAN8 1
19 #define STI_FONT_KANA8 2
20 
21 /* The latency of the STI functions cannot really be reduced by setting
22  * this to 0; STI doesn't seem to be designed to allow calling a different
23  * function (or the same function with different arguments) after a
24  * function exited with 1 as return value.
25  *
26  * As all of the functions below could be called from interrupt context,
27  * we have to spin_lock_irqsave around the do { ret = bla(); } while(ret==1)
28  * block. Really bad latency there.
29  *
30  * Probably the best solution to all this is have the generic code manage
31  * the screen buffer and a kernel thread to call STI occasionally.
32  *
33  * Luckily, the frame buffer guys have the same problem so we can just wait
34  * for them to fix it and steal their solution. prumpf
35  */
36 
37 #include <asm/io.h>
38 
39 #define STI_WAIT 1
40 
41 #define STI_PTR(p) ( virt_to_phys(p) )
42 #define PTR_STI(p) ( phys_to_virt((unsigned long)p) )
43 #define STI_CALL(func, flags, inptr, outptr, glob_cfg) \
44  ({ \
45  pdc_sti_call( func, STI_PTR(flags), \
46  STI_PTR(inptr), \
47  STI_PTR(outptr), \
48  STI_PTR(glob_cfg)); \
49  })
50 
51 
52 #define sti_onscreen_x(sti) (sti->glob_cfg->onscreen_x)
53 #define sti_onscreen_y(sti) (sti->glob_cfg->onscreen_y)
54 
55 /* sti_font_xy() use the native font ROM ! */
56 #define sti_font_x(sti) (PTR_STI(sti->font)->width)
57 #define sti_font_y(sti) (PTR_STI(sti->font)->height)
58 
59 
60 /* STI function configuration structs */
61 
62 typedef union region {
63  struct {
64  u32 offset : 14; /* offset in 4kbyte page */
65  u32 sys_only : 1; /* don't map to user space */
66  u32 cache : 1; /* map to data cache */
67  u32 btlb : 1; /* map to block tlb */
68  u32 last : 1; /* last region in list */
69  u32 length : 14; /* length in 4kbyte page */
70  } region_desc;
71 
72  u32 region; /* complete region value */
73 } region_t;
74 
75 #define REGION_OFFSET_TO_PHYS( rt, hpa ) \
76  (((rt).region_desc.offset << 12) + (hpa))
77 
79  u8 curr_mon; /* current monitor configured */
80  u8 friendly_boot; /* in friendly boot mode */
81  s16 power; /* power calculation (in Watts) */
82  s32 freq_ref; /* frequency reference */
83  u32 sti_mem_addr; /* pointer to global sti memory (size=sti_mem_request) */
84  u32 future_ptr; /* pointer to future data */
85 };
86 
87 struct sti_glob_cfg {
88  s32 text_planes; /* number of planes used for text */
89  s16 onscreen_x; /* screen width in pixels */
90  s16 onscreen_y; /* screen height in pixels */
91  s16 offscreen_x; /* offset width in pixels */
92  s16 offscreen_y; /* offset height in pixels */
93  s16 total_x; /* frame buffer width in pixels */
94  s16 total_y; /* frame buffer height in pixels */
95  u32 region_ptrs[STI_REGION_MAX]; /* region pointers */
96  s32 reent_lvl; /* storage for reentry level value */
97  u32 save_addr; /* where to save or restore reentrant state */
98  u32 ext_ptr; /* pointer to extended glob_cfg data structure */
99 };
100 
101 
102 /* STI init function structs */
103 
105  u32 wait : 1; /* should routine idle wait or not */
106  u32 reset : 1; /* hard reset the device? */
107  u32 text : 1; /* turn on text display planes? */
108  u32 nontext : 1; /* turn on non-text display planes? */
109  u32 clear : 1; /* clear text display planes? */
110  u32 cmap_blk : 1; /* non-text planes cmap black? */
111  u32 enable_be_timer : 1; /* enable bus error timer */
112  u32 enable_be_int : 1; /* enable bus error timer interrupt */
113  u32 no_chg_tx : 1; /* don't change text settings */
114  u32 no_chg_ntx : 1; /* don't change non-text settings */
115  u32 no_chg_bet : 1; /* don't change berr timer settings */
116  u32 no_chg_bei : 1; /* don't change berr int settings */
117  u32 init_cmap_tx : 1; /* initialize cmap for text planes */
118  u32 cmt_chg : 1; /* change current monitor type */
119  u32 retain_ie : 1; /* don't allow reset to clear int enables */
120  u32 caller_bootrom : 1; /* set only by bootrom for each call */
121  u32 caller_kernel : 1; /* set only by kernel for each call */
122  u32 caller_other : 1; /* set only by non-[BR/K] caller */
123  u32 pad : 14; /* pad to word boundary */
124  u32 future_ptr; /* pointer to future data */
125 };
126 
128  u8 config_mon_type; /* configure to monitor type */
129  u8 pad[1]; /* pad to word boundary */
130  u16 inflight_data; /* inflight data possible on PCI */
131  u32 future_ptr; /* pointer to future data */
132 };
133 
135  s32 text_planes; /* number of planes to use for text */
136  u32 ext_ptr; /* pointer to extended init_graph inptr data structure*/
137 };
138 
139 
141  s32 errno; /* error number on failure */
142  s32 text_planes; /* number of planes used for text */
143  u32 future_ptr; /* pointer to future data */
144 };
145 
146 
147 
148 /* STI configuration function structs */
149 
151  u32 wait : 1; /* should routine idle wait or not */
152  u32 pad : 31; /* pad to word boundary */
153  u32 future_ptr; /* pointer to future data */
154 };
155 
157  u32 future_ptr; /* pointer to future data */
158 };
159 
161  u32 crt_config[3]; /* hardware specific X11/OGL information */
164 };
165 
167  s32 errno; /* error number on failure */
168  s16 onscreen_x; /* screen width in pixels */
169  s16 onscreen_y; /* screen height in pixels */
170  s16 offscreen_x; /* offscreen width in pixels */
171  s16 offscreen_y; /* offscreen height in pixels */
172  s16 total_x; /* frame buffer width in pixels */
173  s16 total_y; /* frame buffer height in pixels */
174  s32 bits_per_pixel; /* bits/pixel device has configured */
175  s32 bits_used; /* bits which can be accessed */
176  s32 planes; /* number of fb planes in system */
177  u8 dev_name[STI_DEV_NAME_LENGTH]; /* null terminated product name */
178  u32 attributes; /* flags denoting attributes */
179  u32 ext_ptr; /* pointer to future data */
180 };
181 
182 struct sti_rom {
183  u8 type[4];
186  u8 revno[2];
188 
193 
199 
207 
217  u8 res040[7 * 4];
218 
229 };
230 
231 struct sti_rom_font {
236  u8 font_type; /* language type */
241  u8 res008[2];
242 };
243 
244 /* sticore internal font handling */
245 
247  struct sti_rom_font *raw;
249 };
250 
252  struct sti_rom *raw;
254 };
255 
256 /* STI font printing function structs */
257 
259  u32 font_start_addr; /* address of font start */
260  s16 index; /* index into font table of character */
261  u8 fg_color; /* foreground color of character */
262  u8 bg_color; /* background color of character */
263  s16 dest_x; /* X location of character upper left */
264  s16 dest_y; /* Y location of character upper left */
265  u32 future_ptr; /* pointer to future data */
266 };
267 
269  u32 wait : 1; /* should routine idle wait or not */
270  u32 non_text : 1; /* font unpack/move in non_text planes =1, text =0 */
271  u32 pad : 30; /* pad to word boundary */
272  u32 future_ptr; /* pointer to future data */
273 };
274 
276  s32 errno; /* error number on failure */
277  u32 future_ptr; /* pointer to future data */
278 };
279 
280 /* STI blockmove structs */
281 
283  u32 wait : 1; /* should routine idle wait or not */
284  u32 color : 1; /* change color during move? */
285  u32 clear : 1; /* clear during move? */
286  u32 non_text : 1; /* block move in non_text planes =1, text =0 */
287  u32 pad : 28; /* pad to word boundary */
288  u32 future_ptr; /* pointer to future data */
289 };
290 
292  u8 fg_color; /* foreground color after move */
293  u8 bg_color; /* background color after move */
294  s16 src_x; /* source upper left pixel x location */
295  s16 src_y; /* source upper left pixel y location */
296  s16 dest_x; /* dest upper left pixel x location */
297  s16 dest_y; /* dest upper left pixel y location */
298  s16 width; /* block width in pixels */
299  s16 height; /* block height in pixels */
300  u32 future_ptr; /* pointer to future data */
301 };
302 
304  s32 errno; /* error number on failure */
305  u32 future_ptr; /* pointer to future data */
306 };
307 
308 
309 /* internal generic STI struct */
310 
311 struct sti_struct {
313 
314  /* the following fields needs to be filled in by the word/byte routines */
317  /* char **mon_strings; */
320 
322 
323  unsigned long font_unpmv;
324  unsigned long block_move;
325  unsigned long init_graph;
326  unsigned long inq_conf;
327 
328  /* all following fields are initialized by the generic routines */
331  unsigned long regions_phys[STI_REGION_MAX];
332 
334  struct sti_cooked_font *font; /* ptr to selected font (cooked) */
335 
336  struct sti_conf_outptr outptr; /* configuration */
338 
339  struct pci_dev *pd;
340 
341  /* PCI data structures (pg. 17ff from sti.pdf) */
342  u8 rm_entry[16]; /* pci region mapper array == pci config space offset */
343 
344  /* pointer to the fb_info where this STI device is used */
345  struct fb_info *info;
346 };
347 
348 
349 /* sticore interface functions */
350 
351 struct sti_struct *sti_get_rom(unsigned int index); /* 0: default sti */
352 
353 /* functions to call the STI ROM directly */
354 
355 void sti_putc(struct sti_struct *sti, int c, int y, int x);
356 void sti_set(struct sti_struct *sti, int src_y, int src_x,
357  int height, int width, u8 color);
358 void sti_clear(struct sti_struct *sti, int src_y, int src_x,
359  int height, int width, int c);
360 void sti_bmove(struct sti_struct *sti, int src_y, int src_x,
361  int dst_y, int dst_x, int height, int width);
362 
363 #endif /* STICORE_H */