2 * linux/drivers/video/console/sticore.c -
3 * core code for console driver using HP's STI firmware
5 * Copyright (C) 2000 Philipp Rumpf <prumpf@tux.org>
6 * Copyright (C) 2001-2003 Helge Deller <deller@gmx.de>
7 * Copyright (C) 2001-2002 Thomas Bogendoerfer <tsbogend@alpha.franken.de>
10 * - call STI in virtual mode rather than in real mode
11 * - screen blanking with state_mgmt() in text mode STI ?
12 * - try to make it work on m68k hp workstations ;)
16 #include <linux/module.h>
17 #include <linux/types.h>
18 #include <linux/kernel.h>
19 #include <linux/slab.h>
20 #include <linux/init.h>
21 #include <linux/pci.h>
22 #include <linux/font.h>
24 #include <asm/hardware.h>
26 #include <asm/parisc-device.h>
28 #include <asm/cacheflush.h>
29 #include <asm/grfioctl.h>
31 #include "../sticore.h"
33 #define STI_DRIVERVERSION "Version 0.9a"
35 static struct sti_struct
*default_sti __read_mostly
;
37 /* number of STI ROMS found and their ptrs to each struct */
38 static int num_sti_roms __read_mostly
;
39 static struct sti_struct
*sti_roms
[MAX_STI_ROMS
] __read_mostly
;
42 /* The colour indices used by STI are
52 * So we have the same colours as VGA (basically one bit each for R, G, B),
53 * but have to translate them, anyway. */
55 static const u8 col_trans
[8] = {
60 #define c_fg(sti, c) col_trans[((c>> 8) & 7)]
61 #define c_bg(sti, c) col_trans[((c>>11) & 7)]
62 #define c_index(sti, c) ((c) & 0xff)
64 static const struct sti_init_flags default_init_flags
= {
74 static int sti_init_graph(struct sti_struct
*sti
)
76 struct sti_init_inptr_ext inptr_ext
= { 0, };
77 struct sti_init_inptr inptr
= {
78 .text_planes
= 3, /* # of text planes (max 3 for STI) */
79 .ext_ptr
= STI_PTR(&inptr_ext
)
81 struct sti_init_outptr outptr
= { 0, };
85 spin_lock_irqsave(&sti
->lock
, flags
);
87 ret
= STI_CALL(sti
->init_graph
, &default_init_flags
, &inptr
,
88 &outptr
, sti
->glob_cfg
);
90 spin_unlock_irqrestore(&sti
->lock
, flags
);
93 printk(KERN_ERR
"STI init_graph failed (ret %d, errno %d)\n",ret
,outptr
.errno
);
97 sti
->text_planes
= outptr
.text_planes
;
101 static const struct sti_conf_flags default_conf_flags
= {
105 static void sti_inq_conf(struct sti_struct
*sti
)
107 struct sti_conf_inptr inptr
= { 0, };
111 sti
->outptr
.ext_ptr
= STI_PTR(&sti
->outptr_ext
);
114 spin_lock_irqsave(&sti
->lock
, flags
);
115 ret
= STI_CALL(sti
->inq_conf
, &default_conf_flags
,
116 &inptr
, &sti
->outptr
, sti
->glob_cfg
);
117 spin_unlock_irqrestore(&sti
->lock
, flags
);
121 static const struct sti_font_flags default_font_flags
= {
127 sti_putc(struct sti_struct
*sti
, int c
, int y
, int x
)
129 struct sti_font_inptr inptr
= {
130 .font_start_addr
= STI_PTR(sti
->font
->raw
),
131 .index
= c_index(sti
, c
),
132 .fg_color
= c_fg(sti
, c
),
133 .bg_color
= c_bg(sti
, c
),
134 .dest_x
= x
* sti
->font_width
,
135 .dest_y
= y
* sti
->font_height
,
137 struct sti_font_outptr outptr
= { 0, };
142 spin_lock_irqsave(&sti
->lock
, flags
);
143 ret
= STI_CALL(sti
->font_unpmv
, &default_font_flags
,
144 &inptr
, &outptr
, sti
->glob_cfg
);
145 spin_unlock_irqrestore(&sti
->lock
, flags
);
149 static const struct sti_blkmv_flags clear_blkmv_flags
= {
156 sti_set(struct sti_struct
*sti
, int src_y
, int src_x
,
157 int height
, int width
, u8 color
)
159 struct sti_blkmv_inptr inptr
= {
169 struct sti_blkmv_outptr outptr
= { 0, };
174 spin_lock_irqsave(&sti
->lock
, flags
);
175 ret
= STI_CALL(sti
->block_move
, &clear_blkmv_flags
,
176 &inptr
, &outptr
, sti
->glob_cfg
);
177 spin_unlock_irqrestore(&sti
->lock
, flags
);
182 sti_clear(struct sti_struct
*sti
, int src_y
, int src_x
,
183 int height
, int width
, int c
)
185 struct sti_blkmv_inptr inptr
= {
186 .fg_color
= c_fg(sti
, c
),
187 .bg_color
= c_bg(sti
, c
),
188 .src_x
= src_x
* sti
->font_width
,
189 .src_y
= src_y
* sti
->font_height
,
190 .dest_x
= src_x
* sti
->font_width
,
191 .dest_y
= src_y
* sti
->font_height
,
192 .width
= width
* sti
->font_width
,
193 .height
= height
* sti
->font_height
,
195 struct sti_blkmv_outptr outptr
= { 0, };
200 spin_lock_irqsave(&sti
->lock
, flags
);
201 ret
= STI_CALL(sti
->block_move
, &clear_blkmv_flags
,
202 &inptr
, &outptr
, sti
->glob_cfg
);
203 spin_unlock_irqrestore(&sti
->lock
, flags
);
207 static const struct sti_blkmv_flags default_blkmv_flags
= {
212 sti_bmove(struct sti_struct
*sti
, int src_y
, int src_x
,
213 int dst_y
, int dst_x
, int height
, int width
)
215 struct sti_blkmv_inptr inptr
= {
216 .src_x
= src_x
* sti
->font_width
,
217 .src_y
= src_y
* sti
->font_height
,
218 .dest_x
= dst_x
* sti
->font_width
,
219 .dest_y
= dst_y
* sti
->font_height
,
220 .width
= width
* sti
->font_width
,
221 .height
= height
* sti
->font_height
,
223 struct sti_blkmv_outptr outptr
= { 0, };
228 spin_lock_irqsave(&sti
->lock
, flags
);
229 ret
= STI_CALL(sti
->block_move
, &default_blkmv_flags
,
230 &inptr
, &outptr
, sti
->glob_cfg
);
231 spin_unlock_irqrestore(&sti
->lock
, flags
);
236 static void sti_flush(unsigned long start
, unsigned long end
)
238 flush_icache_range(start
, end
);
241 static void sti_rom_copy(unsigned long base
, unsigned long count
, void *dest
)
243 unsigned long dest_start
= (unsigned long) dest
;
245 /* this still needs to be revisited (see arch/parisc/mm/init.c:246) ! */
248 *(u32
*)dest
= gsc_readl(base
);
254 *(u8
*)dest
= gsc_readb(base
);
259 sti_flush(dest_start
, (unsigned long)dest
);
265 static char default_sti_path
[21] __read_mostly
;
268 static int sti_setup(char *str
)
271 strlcpy (default_sti_path
, str
, sizeof (default_sti_path
));
276 /* Assuming the machine has multiple STI consoles (=graphic cards) which
277 * all get detected by sticon, the user may define with the linux kernel
278 * parameter sti=<x> which of them will be the initial boot-console.
279 * <x> is a number between 0 and MAX_STI_ROMS, with 0 as the default
282 __setup("sti=", sti_setup
);
287 static char *font_name
[MAX_STI_ROMS
] = { "VGA8x16", };
288 static int font_index
[MAX_STI_ROMS
],
289 font_height
[MAX_STI_ROMS
],
290 font_width
[MAX_STI_ROMS
];
292 static int sti_font_setup(char *str
)
297 /* we accept sti_font=VGA8x16, sti_font=10x20, sti_font=10*20
298 * or sti_font=7 style command lines. */
300 while (i
<MAX_STI_ROMS
&& str
&& *str
) {
301 if (*str
>='0' && *str
<='9') {
302 if ((x
= strchr(str
, 'x')) || (x
= strchr(str
, '*'))) {
303 font_height
[i
] = simple_strtoul(str
, NULL
, 0);
304 font_width
[i
] = simple_strtoul(x
+1, NULL
, 0);
306 font_index
[i
] = simple_strtoul(str
, NULL
, 0);
309 font_name
[i
] = str
; /* fb font name */
312 if ((x
= strchr(str
, ',')))
322 /* The optional linux kernel parameter "sti_font" defines which font
323 * should be used by the sticon driver to draw characters to the screen.
324 * Possible values are:
325 * - sti_font=<fb_fontname>:
326 * <fb_fontname> is the name of one of the linux-kernel built-in
327 * framebuffer font names (e.g. VGA8x16, SUN22x18).
328 * This is only available if the fonts have been statically compiled
329 * in with e.g. the CONFIG_FONT_8x16 or CONFIG_FONT_SUN12x22 options.
330 * - sti_font=<number>
331 * most STI ROMs have built-in HP specific fonts, which can be selected
332 * by giving the desired number to the sticon driver.
333 * NOTE: This number is machine and STI ROM dependend.
334 * - sti_font=<height>x<width> (e.g. sti_font=16x8)
335 * <height> and <width> gives hints to the height and width of the
336 * font which the user wants. The sticon driver will try to use
337 * a font with this height and width, but if no suitable font is
338 * found, sticon will use the default 8x8 font.
340 __setup("sti_font=", sti_font_setup
);
345 static void sti_dump_globcfg(struct sti_glob_cfg
*glob_cfg
,
346 unsigned int sti_mem_request
)
348 struct sti_glob_cfg_ext
*cfg
;
352 "%4d x %4d screen resolution\n"
353 "%4d x %4d offscreen\n"
355 "regions at %08x %08x %08x %08x\n"
356 "regions at %08x %08x %08x %08x\n"
359 glob_cfg
->text_planes
,
360 glob_cfg
->onscreen_x
, glob_cfg
->onscreen_y
,
361 glob_cfg
->offscreen_x
, glob_cfg
->offscreen_y
,
362 glob_cfg
->total_x
, glob_cfg
->total_y
,
363 glob_cfg
->region_ptrs
[0], glob_cfg
->region_ptrs
[1],
364 glob_cfg
->region_ptrs
[2], glob_cfg
->region_ptrs
[3],
365 glob_cfg
->region_ptrs
[4], glob_cfg
->region_ptrs
[5],
366 glob_cfg
->region_ptrs
[6], glob_cfg
->region_ptrs
[7],
368 glob_cfg
->save_addr
));
370 /* dump extended cfg */
371 cfg
= PTR_STI((unsigned long)glob_cfg
->ext_ptr
);
374 "in friendly mode: %d\n"
375 "power consumption %d watts\n"
377 "sti_mem_addr %08x (size=%d bytes)\n",
382 cfg
->sti_mem_addr
, sti_mem_request
));
385 static void sti_dump_outptr(struct sti_struct
*sti
)
388 "%d bits per pixel\n"
392 sti
->outptr
.bits_per_pixel
,
393 sti
->outptr
.bits_used
,
395 sti
->outptr
.attributes
));
398 static int sti_init_glob_cfg(struct sti_struct
*sti
, unsigned long rom_address
,
401 struct sti_glob_cfg
*glob_cfg
;
402 struct sti_glob_cfg_ext
*glob_cfg_ext
;
405 const int save_addr_size
= 1024; /* XXX */
408 if (!sti
->sti_mem_request
)
409 sti
->sti_mem_request
= 256; /* STI default */
411 glob_cfg
= kzalloc(sizeof(*sti
->glob_cfg
), GFP_KERNEL
);
412 glob_cfg_ext
= kzalloc(sizeof(*glob_cfg_ext
), GFP_KERNEL
);
413 save_addr
= kzalloc(save_addr_size
, GFP_KERNEL
);
414 sti_mem_addr
= kzalloc(sti
->sti_mem_request
, GFP_KERNEL
);
416 if (!(glob_cfg
&& glob_cfg_ext
&& save_addr
&& sti_mem_addr
)) {
424 glob_cfg
->ext_ptr
= STI_PTR(glob_cfg_ext
);
425 glob_cfg
->save_addr
= STI_PTR(save_addr
);
426 for (i
=0; i
<8; i
++) {
427 unsigned long newhpa
, len
;
430 unsigned char offs
= sti
->rm_entry
[i
];
434 if (offs
!= PCI_ROM_ADDRESS
&&
435 (offs
< PCI_BASE_ADDRESS_0
||
436 offs
> PCI_BASE_ADDRESS_5
)) {
438 "STI pci region mapping for region %d (%02x) can't be mapped\n",
442 newhpa
= pci_resource_start (sti
->pd
, (offs
- PCI_BASE_ADDRESS_0
) / 4);
444 newhpa
= (i
== 0) ? rom_address
: hpa
;
446 sti
->regions_phys
[i
] =
447 REGION_OFFSET_TO_PHYS(sti
->regions
[i
], newhpa
);
449 len
= sti
->regions
[i
].region_desc
.length
* 4096;
451 glob_cfg
->region_ptrs
[i
] = sti
->regions_phys
[i
];
453 DPRINTK(("region #%d: phys %08lx, region_ptr %08x, len=%lukB, "
454 "btlb=%d, sysonly=%d, cache=%d, last=%d\n",
455 i
, sti
->regions_phys
[i
], glob_cfg
->region_ptrs
[i
],
457 sti
->regions
[i
].region_desc
.btlb
,
458 sti
->regions
[i
].region_desc
.sys_only
,
459 sti
->regions
[i
].region_desc
.cache
,
460 sti
->regions
[i
].region_desc
.last
));
462 /* last entry reached ? */
463 if (sti
->regions
[i
].region_desc
.last
)
467 if (++i
<8 && sti
->regions
[i
].region
)
468 printk(KERN_WARNING
"%s: *future ptr (0x%8x) not yet supported !\n",
469 __FILE__
, sti
->regions
[i
].region
);
471 glob_cfg_ext
->sti_mem_addr
= STI_PTR(sti_mem_addr
);
473 sti
->glob_cfg
= glob_cfg
;
479 static struct sti_cooked_font
*
480 sti_select_fbfont(struct sti_cooked_rom
*cooked_rom
, const char *fbfont_name
)
482 const struct font_desc
*fbfont
;
483 unsigned int size
, bpc
;
485 struct sti_rom_font
*nf
;
486 struct sti_cooked_font
*cooked_font
;
488 if (!fbfont_name
|| !strlen(fbfont_name
))
490 fbfont
= find_font(fbfont_name
);
492 fbfont
= get_default_font(1024,768, ~(u32
)0, ~(u32
)0);
496 DPRINTK((KERN_DEBUG
"selected %dx%d fb-font %s\n",
497 fbfont
->width
, fbfont
->height
, fbfont
->name
));
499 bpc
= ((fbfont
->width
+7)/8) * fbfont
->height
;
501 size
+= sizeof(struct sti_rom_font
);
503 nf
= kzalloc(size
, GFP_KERNEL
);
509 nf
->width
= fbfont
->width
;
510 nf
->height
= fbfont
->height
;
511 nf
->font_type
= STI_FONT_HPROMAN8
;
512 nf
->bytes_per_char
= bpc
;
514 nf
->underline_height
= 1;
515 nf
->underline_pos
= fbfont
->height
- nf
->underline_height
;
518 dest
+= sizeof(struct sti_rom_font
);
519 memcpy(dest
, fbfont
->data
, bpc
*256);
521 cooked_font
= kzalloc(sizeof(*cooked_font
), GFP_KERNEL
);
527 cooked_font
->raw
= nf
;
528 cooked_font
->next_font
= NULL
;
530 cooked_rom
->font_start
= cooked_font
;
535 static struct sti_cooked_font
*
536 sti_select_fbfont(struct sti_cooked_rom
*cooked_rom
, const char *fbfont_name
)
542 static struct sti_cooked_font
*sti_select_font(struct sti_cooked_rom
*rom
,
543 int (*search_font_fnc
)(struct sti_cooked_rom
*, int, int))
545 struct sti_cooked_font
*font
;
547 int index
= num_sti_roms
;
549 /* check for framebuffer-font first */
550 if ((font
= sti_select_fbfont(rom
, font_name
[index
])))
553 if (font_width
[index
] && font_height
[index
])
554 font_index
[index
] = search_font_fnc(rom
,
555 font_height
[index
], font_width
[index
]);
557 for (font
= rom
->font_start
, i
= font_index
[index
];
559 font
= font
->next_font
, i
--);
564 return rom
->font_start
;
568 static void sti_dump_rom(struct sti_rom
*rom
)
570 printk(KERN_INFO
" id %04x-%04x, conforms to spec rev. %d.%02x\n",
574 rom
->revno
[0] & 0x0f);
575 DPRINTK((" supports %d monitors\n", rom
->num_mons
));
576 DPRINTK((" font start %08x\n", rom
->font_start
));
577 DPRINTK((" region list %08x\n", rom
->region_list
));
578 DPRINTK((" init_graph %08x\n", rom
->init_graph
));
579 DPRINTK((" bus support %02x\n", rom
->bus_support
));
580 DPRINTK((" ext bus support %02x\n", rom
->ext_bus_support
));
581 DPRINTK((" alternate code type %d\n", rom
->alt_code_type
));
585 static int sti_cook_fonts(struct sti_cooked_rom
*cooked_rom
,
586 struct sti_rom
*raw_rom
)
588 struct sti_rom_font
*raw_font
, *font_start
;
589 struct sti_cooked_font
*cooked_font
;
591 cooked_font
= kzalloc(sizeof(*cooked_font
), GFP_KERNEL
);
595 cooked_rom
->font_start
= cooked_font
;
597 raw_font
= ((void *)raw_rom
) + (raw_rom
->font_start
);
599 font_start
= raw_font
;
600 cooked_font
->raw
= raw_font
;
602 while (raw_font
->next_font
) {
603 raw_font
= ((void *)font_start
) + (raw_font
->next_font
);
605 cooked_font
->next_font
= kzalloc(sizeof(*cooked_font
), GFP_KERNEL
);
606 if (!cooked_font
->next_font
)
609 cooked_font
= cooked_font
->next_font
;
611 cooked_font
->raw
= raw_font
;
614 cooked_font
->next_font
= NULL
;
619 static int sti_search_font(struct sti_cooked_rom
*rom
, int height
, int width
)
621 struct sti_cooked_font
*font
;
624 for (font
= rom
->font_start
; font
; font
= font
->next_font
, i
++) {
625 if ((font
->raw
->width
== width
) &&
626 (font
->raw
->height
== height
))
632 #define BMODE_RELOCATE(offset) offset = (offset) / 4;
633 #define BMODE_LAST_ADDR_OFFS 0x50
635 static void *sti_bmode_font_raw(struct sti_cooked_font
*f
)
637 unsigned char *n
, *p
, *q
;
638 int size
= f
->raw
->bytes_per_char
*256+sizeof(struct sti_rom_font
);
640 n
= kzalloc (4*size
, GFP_KERNEL
);
644 q
= (unsigned char *)f
->raw
;
652 static void sti_bmode_rom_copy(unsigned long base
, unsigned long count
,
655 unsigned long dest_start
= (unsigned long) dest
;
659 *(u8
*)dest
= gsc_readl(base
);
664 sti_flush(dest_start
, (unsigned long)dest
);
667 static struct sti_rom
*sti_get_bmode_rom (unsigned long address
)
671 struct sti_rom_font
*raw_font
, *font_start
;
673 sti_bmode_rom_copy(address
+ BMODE_LAST_ADDR_OFFS
, sizeof(size
), &size
);
676 raw
= kmalloc(size
, GFP_KERNEL
);
678 sti_bmode_rom_copy(address
, size
, raw
);
679 memmove (&raw
->res004
, &raw
->type
[0], 0x3c);
680 raw
->type
[3] = raw
->res004
;
682 BMODE_RELOCATE (raw
->region_list
);
683 BMODE_RELOCATE (raw
->font_start
);
685 BMODE_RELOCATE (raw
->init_graph
);
686 BMODE_RELOCATE (raw
->state_mgmt
);
687 BMODE_RELOCATE (raw
->font_unpmv
);
688 BMODE_RELOCATE (raw
->block_move
);
689 BMODE_RELOCATE (raw
->inq_conf
);
691 raw_font
= ((void *)raw
) + raw
->font_start
;
692 font_start
= raw_font
;
694 while (raw_font
->next_font
) {
695 BMODE_RELOCATE (raw_font
->next_font
);
696 raw_font
= ((void *)font_start
) + raw_font
->next_font
;
702 static struct sti_rom
*sti_get_wmode_rom(unsigned long address
)
707 /* read the ROM size directly from the struct in ROM */
708 size
= gsc_readl(address
+ offsetof(struct sti_rom
,last_addr
));
710 raw
= kmalloc(size
, GFP_KERNEL
);
712 sti_rom_copy(address
, size
, raw
);
717 static int sti_read_rom(int wordmode
, struct sti_struct
*sti
,
718 unsigned long address
)
720 struct sti_cooked_rom
*cooked
;
721 struct sti_rom
*raw
= NULL
;
724 cooked
= kmalloc(sizeof *cooked
, GFP_KERNEL
);
729 raw
= sti_get_wmode_rom (address
);
731 raw
= sti_get_bmode_rom (address
);
736 if (!sti_cook_fonts(cooked
, raw
)) {
737 printk(KERN_ERR
"No font found for STI at %08lx\n", address
);
741 if (raw
->region_list
)
742 memcpy(sti
->regions
, ((void *)raw
)+raw
->region_list
, sizeof(sti
->regions
));
744 address
= (unsigned long) STI_PTR(raw
);
746 sti
->font_unpmv
= address
+ (raw
->font_unpmv
& 0x03ffffff);
747 sti
->block_move
= address
+ (raw
->block_move
& 0x03ffffff);
748 sti
->init_graph
= address
+ (raw
->init_graph
& 0x03ffffff);
749 sti
->inq_conf
= address
+ (raw
->inq_conf
& 0x03ffffff);
754 sti
->font
= sti_select_font(sti
->rom
, sti_search_font
);
755 sti
->font_width
= sti
->font
->raw
->width
;
756 sti
->font_height
= sti
->font
->raw
->height
;
758 sti
->font
->raw
= sti_bmode_font_raw(sti
->font
);
760 sti
->sti_mem_request
= raw
->sti_mem_req
;
761 sti
->graphics_id
[0] = raw
->graphics_id
[0];
762 sti
->graphics_id
[1] = raw
->graphics_id
[1];
766 /* check if the ROM routines in this card are compatible */
767 if (wordmode
|| sti
->graphics_id
[1] != 0x09A02587)
770 revno
= (raw
->revno
[0] << 8) | raw
->revno
[1];
772 switch (sti
->graphics_id
[0]) {
774 /* HyperA or HyperB ? */
775 if (revno
== 0x8408 || revno
== 0x840b)
776 goto msg_not_supported
;
780 goto msg_not_supported
;
782 case CRT_ID_THUNDER2
:
784 goto msg_not_supported
;
790 printk(KERN_ERR
"Sorry, this GSC/STI card is not yet supported.\n");
791 printk(KERN_ERR
"Please see http://parisc-linux.org/faq/"
792 "graphics-howto.html for more info.\n");
800 static struct sti_struct
*sti_try_rom_generic(unsigned long address
,
804 struct sti_struct
*sti
;
808 if (num_sti_roms
>= MAX_STI_ROMS
) {
809 printk(KERN_WARNING
"maximum number of STI ROMS reached !\n");
813 sti
= kzalloc(sizeof(*sti
), GFP_KERNEL
);
815 printk(KERN_ERR
"Not enough memory !\n");
819 spin_lock_init(&sti
->lock
);
822 /* if we can't read the ROM, bail out early. Not being able
823 * to read the hpa is okay, for romless sti */
824 if (pdc_add_valid(address
))
827 sig
= gsc_readl(address
);
829 /* check for a PCI ROM structure */
830 if ((le32_to_cpu(sig
)==0xaa55)) {
831 unsigned int i
, rm_offset
;
833 i
= gsc_readl(address
+0x04);
835 /* The ROM could have multiple architecture
836 * dependent images (e.g. i386, parisc,...) */
838 "PCI ROM is not a STI ROM type image (0x%8x)\n", i
);
844 i
= gsc_readl(address
+0x0c);
845 DPRINTK(("PCI ROM size (from header) = %d kB\n",
846 le16_to_cpu(i
>>16)*512/1024));
847 rm_offset
= le16_to_cpu(i
& 0xffff);
849 /* read 16 bytes from the pci region mapper array */
850 rm
= (u32
*) &sti
->rm_entry
;
851 *rm
++ = gsc_readl(address
+rm_offset
+0x00);
852 *rm
++ = gsc_readl(address
+rm_offset
+0x04);
853 *rm
++ = gsc_readl(address
+rm_offset
+0x08);
854 *rm
++ = gsc_readl(address
+rm_offset
+0x0c);
855 DPRINTK(("PCI region Mapper offset = %08x: ",
858 DPRINTK(("%02x ", sti
->rm_entry
[i
]));
862 address
+= le32_to_cpu(gsc_readl(address
+8));
863 DPRINTK(("sig %04x, PCI STI ROM at %08lx\n", sig
, address
));
869 if ((sig
& 0xff) == 0x01) {
870 DPRINTK((" byte mode ROM at %08lx, hpa at %08lx\n",
872 ok
= sti_read_rom(0, sti
, address
);
875 if ((sig
& 0xffff) == 0x0303) {
876 DPRINTK((" word mode ROM at %08lx, hpa at %08lx\n",
878 ok
= sti_read_rom(1, sti
, address
);
884 if (sti_init_glob_cfg(sti
, address
, hpa
))
885 goto out_err
; /* not enough memory */
887 /* disable STI PCI ROM. ROM and card RAM overlap and
888 * leaving it enabled would force HPMCs
891 unsigned long rom_base
;
892 rom_base
= pci_resource_start(sti
->pd
, PCI_ROM_RESOURCE
);
893 pci_write_config_dword(sti
->pd
, PCI_ROM_ADDRESS
, rom_base
& ~PCI_ROM_ADDRESS_ENABLE
);
894 DPRINTK((KERN_DEBUG
"STI PCI ROM disabled\n"));
897 if (sti_init_graph(sti
))
901 sti_dump_globcfg(sti
->glob_cfg
, sti
->sti_mem_request
);
902 sti_dump_outptr(sti
);
904 printk(KERN_INFO
" graphics card name: %s\n", sti
->outptr
.dev_name
);
906 sti_roms
[num_sti_roms
] = sti
;
916 static void sticore_check_for_default_sti(struct sti_struct
*sti
, char *path
)
918 if (strcmp (path
, default_sti_path
) == 0)
923 * on newer systems PDC gives the address of the ROM
924 * in the additional address field addr[1] while on
925 * older Systems the PDC stores it in page0->proc_sti
927 static int sticore_pa_init(struct parisc_device
*dev
)
930 struct sti_struct
*sti
= NULL
;
931 int hpa
= dev
->hpa
.start
;
933 if (dev
->num_addrs
&& dev
->addr
[0])
934 sti
= sti_try_rom_generic(dev
->addr
[0], hpa
, NULL
);
936 sti
= sti_try_rom_generic(hpa
, hpa
, NULL
);
938 sti
= sti_try_rom_generic(PAGE0
->proc_sti
, hpa
, NULL
);
942 print_pa_hwpath(dev
, pa_path
);
943 sticore_check_for_default_sti(sti
, pa_path
);
948 static int sticore_pci_init(struct pci_dev
*pd
, const struct pci_device_id
*ent
)
951 unsigned long fb_base
, rom_base
;
952 unsigned int fb_len
, rom_len
;
954 struct sti_struct
*sti
;
956 err
= pci_enable_device(pd
);
958 dev_err(&pd
->dev
, "Cannot enable PCI device\n");
962 fb_base
= pci_resource_start(pd
, 0);
963 fb_len
= pci_resource_len(pd
, 0);
964 rom_base
= pci_resource_start(pd
, PCI_ROM_RESOURCE
);
965 rom_len
= pci_resource_len(pd
, PCI_ROM_RESOURCE
);
967 pci_write_config_dword(pd
, PCI_ROM_ADDRESS
, rom_base
| PCI_ROM_ADDRESS_ENABLE
);
968 DPRINTK((KERN_DEBUG
"STI PCI ROM enabled at 0x%08lx\n", rom_base
));
971 printk(KERN_INFO
"STI PCI graphic ROM found at %08lx (%u kB), fb at %08lx (%u MB)\n",
972 rom_base
, rom_len
/1024, fb_base
, fb_len
/1024/1024);
974 DPRINTK((KERN_DEBUG
"Trying PCI STI ROM at %08lx, PCI hpa at %08lx\n",
977 sti
= sti_try_rom_generic(rom_base
, fb_base
, pd
);
980 print_pci_hwpath(pd
, pa_path
);
981 sticore_check_for_default_sti(sti
, pa_path
);
985 printk(KERN_WARNING
"Unable to handle STI device '%s'\n",
989 #endif /* CONFIG_PCI */
995 static void sticore_pci_remove(struct pci_dev
*pd
)
1001 static struct pci_device_id sti_pci_tbl
[] = {
1002 { PCI_DEVICE(PCI_VENDOR_ID_HP
, PCI_DEVICE_ID_HP_VISUALIZE_EG
) },
1003 { PCI_DEVICE(PCI_VENDOR_ID_HP
, PCI_DEVICE_ID_HP_VISUALIZE_FX6
) },
1004 { PCI_DEVICE(PCI_VENDOR_ID_HP
, PCI_DEVICE_ID_HP_VISUALIZE_FX4
) },
1005 { PCI_DEVICE(PCI_VENDOR_ID_HP
, PCI_DEVICE_ID_HP_VISUALIZE_FX2
) },
1006 { PCI_DEVICE(PCI_VENDOR_ID_HP
, PCI_DEVICE_ID_HP_VISUALIZE_FXE
) },
1007 { 0, } /* terminate list */
1009 MODULE_DEVICE_TABLE(pci
, sti_pci_tbl
);
1011 static struct pci_driver pci_sti_driver
= {
1013 .id_table
= sti_pci_tbl
,
1014 .probe
= sticore_pci_init
,
1015 .remove
= sticore_pci_remove
,
1018 static struct parisc_device_id sti_pa_tbl
[] = {
1019 { HPHW_FIO
, HVERSION_REV_ANY_ID
, HVERSION_ANY_ID
, 0x00077 },
1020 { HPHW_FIO
, HVERSION_REV_ANY_ID
, HVERSION_ANY_ID
, 0x00085 },
1024 static struct parisc_driver pa_sti_driver
= {
1026 .id_table
= sti_pa_tbl
,
1027 .probe
= sticore_pa_init
,
1032 * sti_init_roms() - detects all STI ROMs and stores them in sti_roms[]
1035 static int sticore_initialized __read_mostly
;
1037 static void sti_init_roms(void)
1039 if (sticore_initialized
)
1042 sticore_initialized
= 1;
1044 printk(KERN_INFO
"STI GSC/PCI core graphics driver "
1045 STI_DRIVERVERSION
"\n");
1047 /* Register drivers for native & PCI cards */
1048 register_parisc_driver(&pa_sti_driver
);
1049 WARN_ON(pci_register_driver(&pci_sti_driver
));
1051 /* if we didn't find the given default sti, take the first one */
1053 default_sti
= sti_roms
[0];
1058 * index = 0 gives default sti
1059 * index > 0 gives other stis in detection order
1061 struct sti_struct
* sti_get_rom(unsigned int index
)
1063 if (!sticore_initialized
)
1069 if (index
> num_sti_roms
)
1072 return sti_roms
[index
-1];
1074 EXPORT_SYMBOL(sti_get_rom
);
1076 MODULE_AUTHOR("Philipp Rumpf, Helge Deller, Thomas Bogendoerfer");
1077 MODULE_DESCRIPTION("Core STI driver for HP's NGLE series graphics cards in HP PARISC machines");
1078 MODULE_LICENSE("GPL v2");