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/config.h>
17 #include <linux/module.h>
18 #include <linux/types.h>
19 #include <linux/kernel.h>
20 #include <linux/slab.h>
21 #include <linux/init.h>
22 #include <linux/pci.h>
23 #include <linux/font.h>
25 #include <asm/pgalloc.h>
26 #include <asm/hardware.h>
27 #include <asm/parisc-device.h>
28 #include <asm/cacheflush.h>
30 #include "../sticore.h"
32 #define STI_DRIVERVERSION "Version 0.9a"
34 struct sti_struct *default_sti;
36 static int num_sti_roms; /* # of STI ROMS found */
37 static struct sti_struct *sti_roms[MAX_STI_ROMS]; /* ptr to each sti_struct */
40 /* The colour indices used by STI are
50 * So we have the same colours as VGA (basically one bit each for R, G, B),
51 * but have to translate them, anyway. */
53 static const u8 col_trans[8] = {
58 #define c_fg(sti, c) col_trans[((c>> 8) & 7)]
59 #define c_bg(sti, c) col_trans[((c>>11) & 7)]
60 #define c_index(sti, c) ((c) & 0xff)
62 static const struct sti_init_flags default_init_flags = {
73 sti_init_graph(struct sti_struct *sti)
75 struct sti_init_inptr_ext inptr_ext = { 0, };
76 struct sti_init_inptr inptr = {
77 .text_planes = 3, /* # of text planes (max 3 for STI) */
78 .ext_ptr = STI_PTR(&inptr_ext)
80 struct sti_init_outptr outptr = { 0, };
84 spin_lock_irqsave(&sti->lock, flags);
86 ret = STI_CALL(sti->init_graph, &default_init_flags, &inptr,
87 &outptr, sti->glob_cfg);
89 spin_unlock_irqrestore(&sti->lock, flags);
92 printk(KERN_ERR "STI init_graph failed (ret %d, errno %d)\n",ret,outptr.errno);
96 sti->text_planes = outptr.text_planes;
100 static const struct sti_conf_flags default_conf_flags = {
105 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 /* FIXME: Do we have another solution for this ? */
237 static void sti_flush(unsigned long from, unsigned long len)
240 flush_kernel_dcache_range(from, len);
241 flush_icache_range(from, from+len);
245 sti_rom_copy(unsigned long base, unsigned long count, void *dest)
247 unsigned long dest_len = count;
248 unsigned long dest_start = (unsigned long) dest;
250 /* this still needs to be revisited (see arch/parisc/mm/init.c:246) ! */
253 *(u32 *)dest = __raw_readl(base);
259 *(u8 *)dest = __raw_readb(base);
264 sti_flush(dest_start, dest_len);
270 static char default_sti_path[21];
273 static int __init sti_setup(char *str)
276 strlcpy (default_sti_path, str, sizeof (default_sti_path));
281 /* Assuming the machine has multiple STI consoles (=graphic cards) which
282 * all get detected by sticon, the user may define with the linux kernel
283 * parameter sti=<x> which of them will be the initial boot-console.
284 * <x> is a number between 0 and MAX_STI_ROMS, with 0 as the default
287 __setup("sti=", sti_setup);
292 static char __initdata *font_name[MAX_STI_ROMS] = { "VGA8x16", };
293 static int __initdata font_index[MAX_STI_ROMS],
294 font_height[MAX_STI_ROMS],
295 font_width[MAX_STI_ROMS];
297 static int __init sti_font_setup(char *str)
302 /* we accept sti_font=VGA8x16, sti_font=10x20, sti_font=10*20
303 * or sti_font=7 style command lines. */
305 while (i<MAX_STI_ROMS && str && *str) {
306 if (*str>='0' && *str<='9') {
307 if ((x = strchr(str, 'x')) || (x = strchr(str, '*'))) {
308 font_height[i] = simple_strtoul(str, NULL, 0);
309 font_width[i] = simple_strtoul(x+1, NULL, 0);
311 font_index[i] = simple_strtoul(str, NULL, 0);
314 font_name[i] = str; /* fb font name */
317 if ((x = strchr(str, ',')))
327 /* The optional linux kernel parameter "sti_font" defines which font
328 * should be used by the sticon driver to draw characters to the screen.
329 * Possible values are:
330 * - sti_font=<fb_fontname>:
331 * <fb_fontname> is the name of one of the linux-kernel built-in
332 * framebuffer font names (e.g. VGA8x16, SUN22x18).
333 * This is only available if the fonts have been statically compiled
334 * in with e.g. the CONFIG_FONT_8x16 or CONFIG_FONT_SUN12x22 options.
335 * - sti_font=<number>
336 * most STI ROMs have built-in HP specific fonts, which can be selected
337 * by giving the desired number to the sticon driver.
338 * NOTE: This number is machine and STI ROM dependend.
339 * - sti_font=<height>x<width> (e.g. sti_font=16x8)
340 * <height> and <width> gives hints to the height and width of the
341 * font which the user wants. The sticon driver will try to use
342 * a font with this height and width, but if no suitable font is
343 * found, sticon will use the default 8x8 font.
345 __setup("sti_font=", sti_font_setup);
351 sti_dump_globcfg(struct sti_glob_cfg *glob_cfg, unsigned int sti_mem_request)
353 struct sti_glob_cfg_ext *cfg;
357 "%4d x %4d screen resolution\n"
358 "%4d x %4d offscreen\n"
360 "regions at %08x %08x %08x %08x\n"
361 "regions at %08x %08x %08x %08x\n"
364 glob_cfg->text_planes,
365 glob_cfg->onscreen_x, glob_cfg->onscreen_y,
366 glob_cfg->offscreen_x, glob_cfg->offscreen_y,
367 glob_cfg->total_x, glob_cfg->total_y,
368 glob_cfg->region_ptrs[0], glob_cfg->region_ptrs[1],
369 glob_cfg->region_ptrs[2], glob_cfg->region_ptrs[3],
370 glob_cfg->region_ptrs[4], glob_cfg->region_ptrs[5],
371 glob_cfg->region_ptrs[6], glob_cfg->region_ptrs[7],
373 glob_cfg->save_addr));
375 /* dump extended cfg */
376 cfg = PTR_STI(glob_cfg->ext_ptr);
379 "in friendly mode: %d\n"
380 "power consumption %d watts\n"
382 "sti_mem_addr %08x (size=%d bytes)\n",
387 cfg->sti_mem_addr, sti_mem_request));
391 sti_dump_outptr(struct sti_struct *sti)
394 "%d bits per pixel\n"
398 sti->outptr.bits_per_pixel,
399 sti->outptr.bits_used,
401 sti->outptr.attributes));
405 sti_init_glob_cfg(struct sti_struct *sti,
406 unsigned long rom_address, unsigned long hpa)
408 struct sti_glob_cfg *glob_cfg;
409 struct sti_glob_cfg_ext *glob_cfg_ext;
412 const int save_addr_size = 1024; /* XXX */
415 if (!sti->sti_mem_request)
416 sti->sti_mem_request = 256; /* STI default */
418 glob_cfg = kmalloc(sizeof(*sti->glob_cfg), GFP_KERNEL);
419 glob_cfg_ext = kmalloc(sizeof(*glob_cfg_ext), GFP_KERNEL);
420 save_addr = kmalloc(save_addr_size, GFP_KERNEL);
421 sti_mem_addr = kmalloc(sti->sti_mem_request, GFP_KERNEL);
423 if (!(glob_cfg && glob_cfg_ext && save_addr && sti_mem_addr)) {
431 memset(glob_cfg, 0, sizeof(*glob_cfg));
432 memset(glob_cfg_ext, 0, sizeof(*glob_cfg_ext));
433 memset(save_addr, 0, save_addr_size);
434 memset(sti_mem_addr, 0, sti->sti_mem_request);
436 glob_cfg->ext_ptr = STI_PTR(glob_cfg_ext);
437 glob_cfg->save_addr = STI_PTR(save_addr);
438 for (i=0; i<8; i++) {
439 unsigned long newhpa, len;
442 unsigned char offs = sti->rm_entry[i];
446 if (offs != PCI_ROM_ADDRESS &&
447 (offs < PCI_BASE_ADDRESS_0 ||
448 offs > PCI_BASE_ADDRESS_5)) {
450 "STI pci region maping for region %d (%02x) can't be mapped\n",
454 newhpa = pci_resource_start (sti->pd, (offs - PCI_BASE_ADDRESS_0) / 4);
456 newhpa = (i == 0) ? rom_address : hpa;
458 sti->regions_phys[i] =
459 REGION_OFFSET_TO_PHYS(sti->regions[i], newhpa);
461 /* remap virtually */
462 /* FIXME: add BTLB support if btlb==1 */
463 len = sti->regions[i].region_desc.length * 4096;
466 glob_cfg->region_ptrs[i] = (unsigned long) (
467 sti->regions[i].region_desc.cache ?
468 ioremap(sti->regions_phys[i], len) :
469 ioremap_nocache(sti->regions_phys[i], len) );
471 DPRINTK(("region #%d: phys %08lx, virt %08x, len=%lukB, "
472 "btlb=%d, sysonly=%d, cache=%d, last=%d\n",
473 i, sti->regions_phys[i], glob_cfg->region_ptrs[i],
475 sti->regions[i].region_desc.btlb,
476 sti->regions[i].region_desc.sys_only,
477 sti->regions[i].region_desc.cache,
478 sti->regions[i].region_desc.last));
480 /* last entry reached ? */
481 if (sti->regions[i].region_desc.last)
485 if (++i<8 && sti->regions[i].region)
486 printk(KERN_WARNING "%s: *future ptr (0x%8x) not yet supported !\n",
487 __FILE__, sti->regions[i].region);
489 glob_cfg_ext->sti_mem_addr = STI_PTR(sti_mem_addr);
491 sti->glob_cfg = glob_cfg;
497 struct sti_cooked_font * __init
498 sti_select_fbfont( struct sti_cooked_rom *cooked_rom, char *fbfont_name )
500 struct font_desc *fbfont;
501 unsigned int size, bpc;
503 struct sti_rom_font *nf;
504 struct sti_cooked_font *cooked_font;
506 if (!fbfont_name || !strlen(fbfont_name))
508 fbfont = find_font(fbfont_name);
510 fbfont = get_default_font(1024,768);
514 DPRINTK((KERN_DEBUG "selected %dx%d fb-font %s\n",
515 fbfont->width, fbfont->height, fbfont->name));
517 bpc = ((fbfont->width+7)/8) * fbfont->height;
519 size += sizeof(struct sti_rom_font);
521 nf = kmalloc(size, GFP_KERNEL);
528 nf->width = fbfont->width;
529 nf->height = fbfont->height;
530 nf->font_type = STI_FONT_HPROMAN8;
531 nf->bytes_per_char = bpc;
533 nf->underline_height = 1;
534 nf->underline_pos = fbfont->height - nf->underline_height;
537 dest += sizeof(struct sti_rom_font);
538 memcpy(dest, fbfont->data, bpc*256);
540 cooked_font = kmalloc(sizeof(*cooked_font), GFP_KERNEL);
546 cooked_font->raw = nf;
547 cooked_font->next_font = NULL;
549 cooked_rom->font_start = cooked_font;
554 struct sti_cooked_font * __init
555 sti_select_fbfont(struct sti_cooked_rom *cooked_rom, char *fbfont_name)
561 struct sti_cooked_font * __init
562 sti_select_font(struct sti_cooked_rom *rom,
563 int (*search_font_fnc) (struct sti_cooked_rom *,int,int) )
565 struct sti_cooked_font *font;
567 int index = num_sti_roms;
569 /* check for framebuffer-font first */
570 if ((font = sti_select_fbfont(rom, font_name[index])))
573 if (font_width[index] && font_height[index])
574 font_index[index] = search_font_fnc(rom,
575 font_height[index], font_width[index]);
577 for (font = rom->font_start, i = font_index[index];
579 font = font->next_font, i--);
584 return rom->font_start;
589 sti_dump_rom(struct sti_rom *rom)
591 printk(KERN_INFO " id %04x-%04x, conforms to spec rev. %d.%02x\n",
595 rom->revno[0] & 0x0f);
596 DPRINTK((" supports %d monitors\n", rom->num_mons));
597 DPRINTK((" font start %08x\n", rom->font_start));
598 DPRINTK((" region list %08x\n", rom->region_list));
599 DPRINTK((" init_graph %08x\n", rom->init_graph));
600 DPRINTK((" bus support %02x\n", rom->bus_support));
601 DPRINTK((" ext bus support %02x\n", rom->ext_bus_support));
602 DPRINTK((" alternate code type %d\n", rom->alt_code_type));
607 sti_cook_fonts(struct sti_cooked_rom *cooked_rom,
608 struct sti_rom *raw_rom)
610 struct sti_rom_font *raw_font, *font_start;
611 struct sti_cooked_font *cooked_font;
613 cooked_font = kmalloc(sizeof(*cooked_font), GFP_KERNEL);
617 cooked_rom->font_start = cooked_font;
619 raw_font = ((void *)raw_rom) + (raw_rom->font_start);
621 font_start = raw_font;
622 cooked_font->raw = raw_font;
624 while (raw_font->next_font) {
625 raw_font = ((void *)font_start) + (raw_font->next_font);
627 cooked_font->next_font = kmalloc(sizeof(*cooked_font), GFP_KERNEL);
628 if (!cooked_font->next_font)
631 cooked_font = cooked_font->next_font;
633 cooked_font->raw = raw_font;
636 cooked_font->next_font = NULL;
642 sti_search_font(struct sti_cooked_rom *rom, int height, int width)
644 struct sti_cooked_font *font;
647 for(font = rom->font_start; font; font = font->next_font, i++) {
648 if((font->raw->width == width) && (font->raw->height == height))
654 #define BMODE_RELOCATE(offset) offset = (offset) / 4;
655 #define BMODE_LAST_ADDR_OFFS 0x50
658 sti_bmode_font_raw(struct sti_cooked_font *f)
660 unsigned char *n, *p, *q;
661 int size = f->raw->bytes_per_char*256+sizeof(struct sti_rom_font);
663 n = kmalloc (4*size, GFP_KERNEL);
666 memset (n, 0, 4*size);
668 q = (unsigned char *)f->raw;
677 sti_bmode_rom_copy(unsigned long base, unsigned long count, void *dest)
679 unsigned long dest_len = count;
680 unsigned long dest_start = (unsigned long) dest;
684 *(u8 *)dest = __raw_readl(base);
688 sti_flush(dest_start, dest_len);
691 static struct sti_rom * __init
692 sti_get_bmode_rom (unsigned long address)
696 struct sti_rom_font *raw_font, *font_start;
698 sti_bmode_rom_copy(address + BMODE_LAST_ADDR_OFFS, sizeof(size), &size);
701 raw = kmalloc(size, GFP_KERNEL);
703 sti_bmode_rom_copy(address, size, raw);
704 memmove (&raw->res004, &raw->type[0], 0x3c);
705 raw->type[3] = raw->res004;
707 BMODE_RELOCATE (raw->region_list);
708 BMODE_RELOCATE (raw->font_start);
710 BMODE_RELOCATE (raw->init_graph);
711 BMODE_RELOCATE (raw->state_mgmt);
712 BMODE_RELOCATE (raw->font_unpmv);
713 BMODE_RELOCATE (raw->block_move);
714 BMODE_RELOCATE (raw->inq_conf);
716 raw_font = ((void *)raw) + raw->font_start;
717 font_start = raw_font;
719 while (raw_font->next_font) {
720 BMODE_RELOCATE (raw_font->next_font);
721 raw_font = ((void *)font_start) + raw_font->next_font;
727 struct sti_rom * __init
728 sti_get_wmode_rom (unsigned long address)
733 /* read the ROM size directly from the struct in ROM */
734 size = __raw_readl(address + offsetof(struct sti_rom,last_addr));
736 raw = kmalloc(size, GFP_KERNEL);
738 sti_rom_copy(address, size, raw);
744 sti_read_rom(int wordmode, struct sti_struct *sti, unsigned long address)
746 struct sti_cooked_rom *cooked;
747 struct sti_rom *raw = NULL;
749 cooked = kmalloc(sizeof *cooked, GFP_KERNEL);
754 raw = sti_get_wmode_rom (address);
756 raw = sti_get_bmode_rom (address);
761 if (!sti_cook_fonts(cooked, raw)) {
762 printk(KERN_ERR "No font found for STI at %08lx\n", address);
766 if (raw->region_list)
767 memcpy(sti->regions, ((void *)raw)+raw->region_list, sizeof(sti->regions));
769 address = (unsigned long) STI_PTR(raw);
771 sti->font_unpmv = address + (raw->font_unpmv & 0x03ffffff);
772 sti->block_move = address + (raw->block_move & 0x03ffffff);
773 sti->init_graph = address + (raw->init_graph & 0x03ffffff);
774 sti->inq_conf = address + (raw->inq_conf & 0x03ffffff);
779 sti->font = sti_select_font(sti->rom, sti_search_font);
780 sti->font_width = sti->font->raw->width;
781 sti->font_height = sti->font->raw->height;
783 sti->font->raw = sti_bmode_font_raw(sti->font);
785 sti->sti_mem_request = raw->sti_mem_req;
786 sti->graphics_id[0] = raw->graphics_id[0];
787 sti->graphics_id[1] = raw->graphics_id[1];
802 static struct sti_struct * __init
803 sti_try_rom_generic(unsigned long address, unsigned long hpa, struct pci_dev *pd)
805 struct sti_struct *sti;
809 if (num_sti_roms >= MAX_STI_ROMS) {
810 printk(KERN_WARNING "maximum number of STI ROMS reached !\n");
814 sti = kmalloc(sizeof(*sti), GFP_KERNEL);
816 printk(KERN_ERR "Not enough memory !\n");
820 memset(sti, 0, sizeof(*sti));
821 sti->lock = SPIN_LOCK_UNLOCKED;
824 /* if we can't read the ROM, bail out early. Not being able
825 * to read the hpa is okay, for romless sti */
826 if (pdc_add_valid(address))
829 sig = __raw_readl(address);
831 /* check for a PCI ROM structure */
832 if ((le32_to_cpu(sig)==0xaa55)) {
833 unsigned int i, rm_offset;
835 i = __raw_readl(address+0x04);
837 /* The ROM could have multiple architecture
838 * dependent images (e.g. i386, parisc,...) */
840 "PCI ROM is not a STI ROM type image (0x%8x)\n", i);
846 i = __raw_readl(address+0x0c);
847 DPRINTK(("PCI ROM size (from header) = %d kB\n",
848 le16_to_cpu(i>>16)*512/1024));
849 rm_offset = le16_to_cpu(i & 0xffff);
851 /* read 16 bytes from the pci region mapper array */
852 rm = (u32*) &sti->rm_entry;
853 *rm++ = __raw_readl(address+rm_offset+0x00);
854 *rm++ = __raw_readl(address+rm_offset+0x04);
855 *rm++ = __raw_readl(address+rm_offset+0x08);
856 *rm++ = __raw_readl(address+rm_offset+0x0c);
857 DPRINTK(("PCI region Mapper offset = %08x: ",
860 DPRINTK(("%02x ", sti->rm_entry[i]));
864 address += le32_to_cpu(__raw_readl(address+8));
865 DPRINTK(("sig %04x, PCI STI ROM at %08lx\n", sig, address));
871 if ((sig & 0xff) == 0x01) {
872 DPRINTK((" byte mode ROM at %08lx, hpa at %08lx\n",
874 ok = sti_read_rom(0, sti, address);
877 if ((sig & 0xffff) == 0x0303) {
878 DPRINTK((" word mode ROM at %08lx, hpa at %08lx\n",
880 ok = sti_read_rom(1, sti, address);
886 if (sti_init_glob_cfg(sti, address, hpa))
887 goto out_err; /* not enough memory */
889 /* disable STI PCI ROM. ROM and card RAM overlap and
890 * leaving it enabled would force HPMCs
893 unsigned long rom_base;
894 rom_base = pci_resource_start(sti->pd, PCI_ROM_RESOURCE);
895 pci_write_config_dword(sti->pd, PCI_ROM_ADDRESS, rom_base & ~PCI_ROM_ADDRESS_ENABLE);
896 DPRINTK((KERN_DEBUG "STI PCI ROM disabled\n"));
899 if (sti_init_graph(sti))
903 sti_dump_globcfg(sti->glob_cfg, sti->sti_mem_request);
904 sti_dump_outptr(sti);
906 printk(KERN_INFO " graphics card name: %s\n", sti->outptr.dev_name );
908 sti_roms[num_sti_roms] = sti;
918 static void __init sticore_check_for_default_sti(struct sti_struct *sti, char *path)
920 if (strcmp (path, default_sti_path) == 0)
925 * on newer systems PDC gives the address of the ROM
926 * in the additional address field addr[1] while on
927 * older Systems the PDC stores it in page0->proc_sti
929 static int __init sticore_pa_init(struct parisc_device *dev)
931 unsigned long rom = 0;
933 struct sti_struct *sti = NULL;
940 DPRINTK((KERN_DEBUG "Trying STI ROM at %08lx, hpa at %08lx\n", rom, dev->hpa));
941 sti = sti_try_rom_generic(rom, dev->hpa, NULL);
942 rom = PAGE0->proc_sti;
945 DPRINTK((KERN_DEBUG "Trying STI ROM at %08lx, hpa at %08lx\n", rom, dev->hpa));
946 sti = sti_try_rom_generic(rom, dev->hpa, NULL);
951 print_pa_hwpath(dev, pa_path);
952 sticore_check_for_default_sti (sti, pa_path);
957 static int __devinit sticore_pci_init(struct pci_dev *pd,
958 const struct pci_device_id *ent)
961 unsigned long fb_base, rom_base;
962 unsigned int fb_len, rom_len;
963 struct sti_struct *sti;
965 pci_enable_device(pd);
967 fb_base = pci_resource_start(pd, 0);
968 fb_len = pci_resource_len(pd, 0);
969 rom_base = pci_resource_start(pd, PCI_ROM_RESOURCE);
970 rom_len = pci_resource_len(pd, PCI_ROM_RESOURCE);
972 pci_write_config_dword(pd, PCI_ROM_ADDRESS, rom_base | PCI_ROM_ADDRESS_ENABLE);
973 DPRINTK((KERN_DEBUG "STI PCI ROM enabled at 0x%08lx\n", rom_base));
976 printk(KERN_INFO "STI PCI graphic ROM found at %08lx (%u kB), fb at %08lx (%u MB)\n",
977 rom_base, rom_len/1024, fb_base, fb_len/1024/1024);
979 DPRINTK((KERN_DEBUG "Trying PCI STI ROM at %08lx, PCI hpa at %08lx\n",
982 sti = sti_try_rom_generic(rom_base, fb_base, pd);
985 print_pci_hwpath(pd, pa_path);
986 sticore_check_for_default_sti(sti, pa_path);
990 printk(KERN_WARNING "Unable to handle STI device '%s'\n",
994 #endif /* CONFIG_PCI */
1000 static void __devexit sticore_pci_remove(struct pci_dev *pd)
1006 static struct pci_device_id sti_pci_tbl[] = {
1007 { PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_VISUALIZE_EG, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
1008 { PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_VISUALIZE_FX6, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
1009 { PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_VISUALIZE_FX4, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
1010 { PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_VISUALIZE_FX2, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
1011 { PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_VISUALIZE_FXE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
1012 { 0, } /* terminate list */
1014 MODULE_DEVICE_TABLE(pci, sti_pci_tbl);
1016 static struct pci_driver pci_sti_driver = {
1017 .name = "sti (pci)",
1018 .id_table = sti_pci_tbl,
1019 .probe = sticore_pci_init,
1020 .remove = sticore_pci_remove,
1023 static struct parisc_device_id sti_pa_tbl[] = {
1024 { HPHW_FIO, HVERSION_REV_ANY_ID, HVERSION_ANY_ID, 0x00077 },
1025 { HPHW_FIO, HVERSION_REV_ANY_ID, HVERSION_ANY_ID, 0x00085 },
1029 static struct parisc_driver pa_sti_driver = {
1030 .name = "sti (native)",
1031 .id_table = sti_pa_tbl,
1032 .probe = sticore_pa_init,
1037 * sti_init_roms() - detects all STI ROMs and stores them in sti_roms[]
1040 static int sticore_initialized;
1042 static void __init sti_init_roms(void)
1044 if (sticore_initialized)
1047 sticore_initialized = 1;
1049 printk(KERN_INFO "STI GSC/PCI core graphics driver "
1050 STI_DRIVERVERSION "\n");
1052 /* Register drivers for native & PCI cards */
1053 register_parisc_driver(&pa_sti_driver);
1054 pci_module_init(&pci_sti_driver);
1056 /* if we didn't find the given default sti, take the first one */
1058 default_sti = sti_roms[0];
1063 * index = 0 gives default sti
1064 * index > 0 gives other stis in detection order
1066 struct sti_struct * sti_get_rom(unsigned int index)
1068 if (!sticore_initialized)
1074 if (index > num_sti_roms)
1077 return sti_roms[index-1];
1079 EXPORT_SYMBOL(sti_get_rom);
1081 MODULE_AUTHOR("Philipp Rumpf, Helge Deller, Thomas Bogendoerfer");
1082 MODULE_DESCRIPTION("Core STI driver for HP's NGLE series graphics cards in HP PARISC machines");
1083 MODULE_LICENSE("GPL v2");