tree-wide: fix assorted typos all over the place
[safe/jmp/linux-2.6] / drivers / video / console / sticore.c
index 0339f56..6468a29 100644 (file)
@@ -13,7 +13,6 @@
  * 
  */
 
-#include <linux/config.h>
 #include <linux/module.h>
 #include <linux/types.h>
 #include <linux/kernel.h>
 #include <asm/hardware.h>
 #include <asm/parisc-device.h>
 #include <asm/cacheflush.h>
+#include <asm/grfioctl.h>
 
 #include "../sticore.h"
 
 #define STI_DRIVERVERSION "Version 0.9a"
 
-struct sti_struct *default_sti __read_mostly;
+static struct sti_struct *default_sti __read_mostly;
 
 /* number of STI ROMS found and their ptrs to each struct */
 static int num_sti_roms __read_mostly;
@@ -69,8 +69,7 @@ static const struct sti_init_flags default_init_flags = {
        .init_cmap_tx = 1,
 };
 
-int
-sti_init_graph(struct sti_struct *sti) 
+static int sti_init_graph(struct sti_struct *sti)
 {
        struct sti_init_inptr_ext inptr_ext = { 0, };
        struct sti_init_inptr inptr = {
@@ -101,8 +100,7 @@ static const struct sti_conf_flags default_conf_flags = {
        .wait   = STI_WAIT,
 };
 
-void
-sti_inq_conf(struct sti_struct *sti)
+static void sti_inq_conf(struct sti_struct *sti)
 {
        struct sti_conf_inptr inptr = { 0, };
        unsigned long flags;
@@ -233,18 +231,14 @@ sti_bmove(struct sti_struct *sti, int src_y, int src_x,
 }
 
 
-/* FIXME: Do we have another solution for this ? */
-static void sti_flush(unsigned long from, unsigned long len)
+static void sti_flush(unsigned long start, unsigned long end)
 {
-       flush_data_cache();
-       flush_kernel_dcache_range(from, len);
-       flush_icache_range(from, from+len);
+       flush_icache_range(start, end);
 }
 
-void __init
-sti_rom_copy(unsigned long base, unsigned long count, void *dest)
+static void __devinit sti_rom_copy(unsigned long base, unsigned long count,
+                                  void *dest)
 {
-       unsigned long dest_len = count;
        unsigned long dest_start = (unsigned long) dest;
 
        /* this still needs to be revisited (see arch/parisc/mm/init.c:246) ! */
@@ -261,7 +255,7 @@ sti_rom_copy(unsigned long base, unsigned long count, void *dest)
                dest++;
        }
 
-       sti_flush(dest_start, dest_len);
+       sti_flush(dest_start, (unsigned long)dest);
 }
 
 
@@ -270,12 +264,12 @@ sti_rom_copy(unsigned long base, unsigned long count, void *dest)
 static char default_sti_path[21] __read_mostly;
 
 #ifndef MODULE
-static int __init sti_setup(char *str)
+static int __devinit sti_setup(char *str)
 {
        if (str)
                strlcpy (default_sti_path, str, sizeof (default_sti_path));
        
-       return 0;
+       return 1;
 }
 
 /*     Assuming the machine has multiple STI consoles (=graphic cards) which
@@ -289,12 +283,12 @@ __setup("sti=", sti_setup);
 
 
 
-static char __initdata *font_name[MAX_STI_ROMS] = { "VGA8x16", };
-static int __initdata  font_index[MAX_STI_ROMS], 
-                       font_height[MAX_STI_ROMS],
-                       font_width[MAX_STI_ROMS];
+static char __devinitdata      *font_name[MAX_STI_ROMS] = { "VGA8x16", };
+static int __devinitdata       font_index[MAX_STI_ROMS],
+                               font_height[MAX_STI_ROMS],
+                               font_width[MAX_STI_ROMS];
 #ifndef MODULE
-static int __init sti_font_setup(char *str)
+static int __devinit sti_font_setup(char *str)
 {
        char *x;
        int i = 0;
@@ -321,7 +315,7 @@ static int __init sti_font_setup(char *str)
                i++;
        }
 
-       return 0;
+       return 1;
 }
 
 /*     The optional linux kernel parameter "sti_font" defines which font
@@ -347,7 +341,7 @@ __setup("sti_font=", sti_font_setup);
 
 
        
-static void __init
+static void __devinit
 sti_dump_globcfg(struct sti_glob_cfg *glob_cfg, unsigned int sti_mem_request)
 {
        struct sti_glob_cfg_ext *cfg;
@@ -373,7 +367,7 @@ sti_dump_globcfg(struct sti_glob_cfg *glob_cfg, unsigned int sti_mem_request)
                glob_cfg->save_addr));
 
        /* dump extended cfg */ 
-       cfg = PTR_STI(glob_cfg->ext_ptr);
+       cfg = PTR_STI((unsigned long)glob_cfg->ext_ptr);
        DPRINTK(( KERN_INFO
                "monitor %d\n"
                "in friendly mode: %d\n"
@@ -387,7 +381,7 @@ sti_dump_globcfg(struct sti_glob_cfg *glob_cfg, unsigned int sti_mem_request)
                cfg->sti_mem_addr, sti_mem_request));
 }
 
-static void __init
+static void __devinit
 sti_dump_outptr(struct sti_struct *sti)
 {
        DPRINTK((KERN_INFO
@@ -401,7 +395,7 @@ sti_dump_outptr(struct sti_struct *sti)
                 sti->outptr.attributes));
 }
 
-static int __init
+static int __devinit
 sti_init_glob_cfg(struct sti_struct *sti,
            unsigned long rom_address, unsigned long hpa)
 {
@@ -442,7 +436,7 @@ sti_init_glob_cfg(struct sti_struct *sti,
                            (offs < PCI_BASE_ADDRESS_0 ||
                             offs > PCI_BASE_ADDRESS_5)) {
                                printk (KERN_WARNING
-                                       "STI pci region maping for region %d (%02x) can't be mapped\n",
+                                       "STI pci region mapping for region %d (%02x) can't be mapped\n",
                                        i,sti->rm_entry[i]);
                                continue;
                        }
@@ -453,25 +447,11 @@ sti_init_glob_cfg(struct sti_struct *sti,
                sti->regions_phys[i] =
                        REGION_OFFSET_TO_PHYS(sti->regions[i], newhpa);
                
-               /* remap virtually */
-               /* FIXME: add BTLB support if btlb==1 */
                len = sti->regions[i].region_desc.length * 4096;
-
-/* XXX: Enabling IOREMAP debugging causes a crash, so we must be passing
- * a virtual address to something expecting a physical address that doesn't
- * go through a readX macro */
-#if 0
-               if (len)
-                  glob_cfg->region_ptrs[i] = (unsigned long) (
-                       sti->regions[i].region_desc.cache ?
-                       ioremap(sti->regions_phys[i], len) :
-                       ioremap_nocache(sti->regions_phys[i], len) );
-#else
                if (len)
                        glob_cfg->region_ptrs[i] = sti->regions_phys[i];
-#endif
                
-               DPRINTK(("region #%d: phys %08lx, virt %08x, len=%lukB, "
+               DPRINTK(("region #%d: phys %08lx, region_ptr %08x, len=%lukB, "
                         "btlb=%d, sysonly=%d, cache=%d, last=%d\n",
                        i, sti->regions_phys[i], glob_cfg->region_ptrs[i],
                        len/1024,
@@ -497,8 +477,8 @@ sti_init_glob_cfg(struct sti_struct *sti,
 }
 
 #ifdef CONFIG_FB
-struct sti_cooked_font * __init
-sti_select_fbfont(struct sti_cooked_rom *cooked_rom, const char *fbfont_name)
+static struct sti_cooked_font __devinit
+*sti_select_fbfont(struct sti_cooked_rom *cooked_rom, const char *fbfont_name)
 {
        const struct font_desc *fbfont;
        unsigned int size, bpc;
@@ -510,7 +490,7 @@ sti_select_fbfont(struct sti_cooked_rom *cooked_rom, const char *fbfont_name)
                return NULL;
        fbfont = find_font(fbfont_name);
        if (!fbfont)
-               fbfont = get_default_font(1024,768);
+               fbfont = get_default_font(1024,768, ~(u32)0, ~(u32)0);
        if (!fbfont)
                return NULL;
 
@@ -553,16 +533,16 @@ sti_select_fbfont(struct sti_cooked_rom *cooked_rom, const char *fbfont_name)
        return cooked_font;
 }
 #else
-struct sti_cooked_font * __init
-sti_select_fbfont(struct sti_cooked_rom *cooked_rom, const char *fbfont_name)
+static struct sti_cooked_font __devinit
+*sti_select_fbfont(struct sti_cooked_rom *cooked_rom, const char *fbfont_name)
 {
        return NULL;
 }
 #endif
 
-struct sti_cooked_font * __init
-sti_select_font(struct sti_cooked_rom *rom,
-           int (*search_font_fnc) (struct sti_cooked_rom *,int,int) )
+static struct sti_cooked_font __devinit
+*sti_select_font(struct sti_cooked_rom *rom,
+                int (*search_font_fnc)(struct sti_cooked_rom *, int, int))
 {
        struct sti_cooked_font *font;
        int i;
@@ -587,7 +567,7 @@ sti_select_font(struct sti_cooked_rom *rom,
 }
 
 
-static void __init 
+static void __devinit
 sti_dump_rom(struct sti_rom *rom)
 {
        printk(KERN_INFO "    id %04x-%04x, conforms to spec rev. %d.%02x\n",
@@ -605,7 +585,7 @@ sti_dump_rom(struct sti_rom *rom)
 }
 
 
-static int __init 
+static int __devinit
 sti_cook_fonts(struct sti_cooked_rom *cooked_rom,
                        struct sti_rom *raw_rom)
 {
@@ -640,7 +620,7 @@ sti_cook_fonts(struct sti_cooked_rom *cooked_rom,
 }
 
 
-static int __init 
+static int __devinit
 sti_search_font(struct sti_cooked_rom *rom, int height, int width)
 {
        struct sti_cooked_font *font;
@@ -657,7 +637,7 @@ sti_search_font(struct sti_cooked_rom *rom, int height, int width)
 #define BMODE_RELOCATE(offset)         offset = (offset) / 4;
 #define BMODE_LAST_ADDR_OFFS           0x50
 
-static void * __init
+static void * __devinit
 sti_bmode_font_raw(struct sti_cooked_font *f)
 {
        unsigned char *n, *p, *q;
@@ -675,10 +655,9 @@ sti_bmode_font_raw(struct sti_cooked_font *f)
        return n + 3;
 }
 
-static void __init
+static void __devinit
 sti_bmode_rom_copy(unsigned long base, unsigned long count, void *dest)
 {
-       unsigned long dest_len = count;
        unsigned long dest_start = (unsigned long) dest;
 
        while (count) {
@@ -687,10 +666,11 @@ sti_bmode_rom_copy(unsigned long base, unsigned long count, void *dest)
                base += 4;
                dest++;
        }
-       sti_flush(dest_start, dest_len);
+
+       sti_flush(dest_start, (unsigned long)dest);
 }
 
-static struct sti_rom * __init
+static struct sti_rom * __devinit
 sti_get_bmode_rom (unsigned long address)
 {
        struct sti_rom *raw;
@@ -726,8 +706,7 @@ sti_get_bmode_rom (unsigned long address)
        return raw;
 }
 
-struct sti_rom * __init
-sti_get_wmode_rom (unsigned long address)
+static struct sti_rom __devinit *sti_get_wmode_rom(unsigned long address)
 {
        struct sti_rom *raw;
        unsigned long size;
@@ -742,11 +721,12 @@ sti_get_wmode_rom (unsigned long address)
        return raw;
 }
 
-int __init
-sti_read_rom(int wordmode, struct sti_struct *sti, unsigned long address)
+static int __devinit sti_read_rom(int wordmode, struct sti_struct *sti,
+                                 unsigned long address)
 {
        struct sti_cooked_rom *cooked;
        struct sti_rom *raw = NULL;
+       unsigned long revno;
 
        cooked = kmalloc(sizeof *cooked, GFP_KERNEL);
        if (!cooked)
@@ -789,16 +769,42 @@ sti_read_rom(int wordmode, struct sti_struct *sti, unsigned long address)
        sti->graphics_id[1] = raw->graphics_id[1];
        
        sti_dump_rom(raw);
-       
+
+       /* check if the ROM routines in this card are compatible */
+       if (wordmode || sti->graphics_id[1] != 0x09A02587)
+               goto ok;
+
+       revno = (raw->revno[0] << 8) | raw->revno[1];
+
+       switch (sti->graphics_id[0]) {
+       case S9000_ID_HCRX:
+               /* HyperA or HyperB ? */
+               if (revno == 0x8408 || revno == 0x840b)
+                       goto msg_not_supported;
+               break;
+       case CRT_ID_THUNDER:
+               if (revno == 0x8509)
+                       goto msg_not_supported;
+               break;
+       case CRT_ID_THUNDER2:
+               if (revno == 0x850c)
+                       goto msg_not_supported;
+       }
+ok:
        return 1;
 
+msg_not_supported:
+       printk(KERN_ERR "Sorry, this GSC/STI card is not yet supported.\n");
+       printk(KERN_ERR "Please see http://parisc-linux.org/faq/"
+                       "graphics-howto.html for more info.\n");
+       /* fall through */
 out_err:
        kfree(raw);
        kfree(cooked);
        return 0;
 }
 
-static struct sti_struct * __init
+static struct sti_struct * __devinit
 sti_try_rom_generic(unsigned long address, unsigned long hpa, struct pci_dev *pd)
 {
        struct sti_struct *sti;
@@ -913,7 +919,7 @@ out_err:
        return NULL;
 }
 
-static void __init sticore_check_for_default_sti(struct sti_struct *sti, char *path)
+static void __devinit sticore_check_for_default_sti(struct sti_struct *sti, char *path)
 {
        if (strcmp (path, default_sti_path) == 0)
                default_sti = sti;
@@ -924,7 +930,7 @@ static void __init sticore_check_for_default_sti(struct sti_struct *sti, char *p
  * in the additional address field addr[1] while on
  * older Systems the PDC stores it in page0->proc_sti 
  */
-static int __init sticore_pa_init(struct parisc_device *dev)
+static int __devinit sticore_pa_init(struct parisc_device *dev)
 {
        char pa_path[21];
        struct sti_struct *sti = NULL;
@@ -951,9 +957,14 @@ static int __devinit sticore_pci_init(struct pci_dev *pd,
 #ifdef CONFIG_PCI
        unsigned long fb_base, rom_base;
        unsigned int fb_len, rom_len;
+       int err;
        struct sti_struct *sti;
        
-       pci_enable_device(pd);
+       err = pci_enable_device(pd);
+       if (err < 0) {
+               dev_err(&pd->dev, "Cannot enable PCI device\n");
+               return err;
+       }
 
        fb_base = pci_resource_start(pd, 0);
        fb_len = pci_resource_len(pd, 0);
@@ -1030,7 +1041,7 @@ static struct parisc_driver pa_sti_driver = {
 
 static int sticore_initialized __read_mostly;
 
-static void __init sti_init_roms(void)
+static void __devinit sti_init_roms(void)
 {
        if (sticore_initialized)
                return;
@@ -1042,7 +1053,7 @@ static void __init sti_init_roms(void)
 
        /* Register drivers for native & PCI cards */
        register_parisc_driver(&pa_sti_driver);
-       pci_register_driver(&pci_sti_driver);
+       WARN_ON(pci_register_driver(&pci_sti_driver));
 
        /* if we didn't find the given default sti, take the first one */
        if (!default_sti)