sh: Use the generic I/O port base for slowdown.
[safe/jmp/linux-2.6] / arch / sh / kernel / machvec.c
index 1e78191..1652340 100644 (file)
@@ -14,6 +14,8 @@
 #include <linux/string.h>
 #include <asm/machvec.h>
 #include <asm/sections.h>
+#include <asm/addrspace.h>
+#include <asm/setup.h>
 #include <asm/io.h>
 #include <asm/irq.h>
 
@@ -29,12 +31,14 @@ static struct sh_machine_vector * __init get_mv_byname(const char *name)
        struct sh_machine_vector *mv;
 
        for_each_mv(mv)
-               if (strcasecmp(name, get_system_type()) == 0)
+               if (strcasecmp(name, mv->mv_name) == 0)
                        return mv;
 
        return NULL;
 }
 
+static unsigned int __initdata machvec_selected;
+
 static int __init early_parse_mv(char *from)
 {
        char mv_name[MV_NAME_SIZE] = "";
@@ -55,20 +59,23 @@ static int __init early_parse_mv(char *from)
        mv_name[mv_len] = '\0';
        from = mv_end;
 
-       if (strcmp(sh_mv.mv_name, mv_name) != 0) {
-               mvp = get_mv_byname(mv_name);
-               if (unlikely(!mvp)) {
-                       printk("Available vectors:\n\n\t");
-                       for_each_mv(mvp)
-                               printk("'%s', ", mvp->mv_name);
-                       printk("\n\n");
-                       panic("Failed to select machvec '%s' -- halting.\n",
-                             mv_name);
-               } else
-                       sh_mv = *mvp;
-       }
+       machvec_selected = 1;
+
+       /* Boot with the generic vector */
+       if (strcmp(mv_name, "generic") == 0)
+               return 0;
+
+       mvp = get_mv_byname(mv_name);
+       if (unlikely(!mvp)) {
+               printk("Available vectors:\n\n\t'%s', ", sh_mv.mv_name);
+               for_each_mv(mvp)
+                       printk("'%s', ", mvp->mv_name);
+               printk("\n\n");
+               panic("Failed to select machvec '%s' -- halting.\n",
+                     mv_name);
+       } else
+               sh_mv = *mvp;
 
-       printk(KERN_NOTICE "Booting machvec: %s\n", sh_mv.mv_name);
        return 0;
 }
 early_param("sh_mv", early_parse_mv);
@@ -76,6 +83,33 @@ early_param("sh_mv", early_parse_mv);
 void __init sh_mv_setup(void)
 {
        /*
+        * Only overload the machvec if one hasn't been selected on
+        * the command line with sh_mv=
+        */
+       if (!machvec_selected) {
+               unsigned long machvec_size;
+
+               machvec_size = ((unsigned long)&__machvec_end -
+                               (unsigned long)&__machvec_start);
+
+               /*
+                * Sanity check for machvec section alignment. Ensure
+                * __initmv hasn't been misused.
+                */
+               if (machvec_size % sizeof(struct sh_machine_vector))
+                       panic("machvec misaligned, invalid __initmv use?");
+
+               /*
+                * If the machvec hasn't been preselected, use the first
+                * vector (usually the only one) from .machvec.init.
+                */
+               if (machvec_size >= sizeof(struct sh_machine_vector))
+                       sh_mv = *(struct sh_machine_vector *)&__machvec_start;
+       }
+
+       printk(KERN_NOTICE "Booting machvec: %s\n", get_system_type());
+
+       /*
         * Manually walk the vec, fill in anything that the board hasn't yet
         * by hand, wrapping to the generic implementation.
         */
@@ -93,13 +127,17 @@ void __init sh_mv_setup(void)
        mv_set(insb);   mv_set(insw);   mv_set(insl);
        mv_set(outsb);  mv_set(outsw);  mv_set(outsl);
 
-       mv_set(readb);  mv_set(readw);  mv_set(readl);
-       mv_set(writeb); mv_set(writew); mv_set(writel);
-
        mv_set(ioport_map);
        mv_set(ioport_unmap);
        mv_set(irq_demux);
+       mv_set(mode_pins);
 
        if (!sh_mv.mv_nr_irqs)
                sh_mv.mv_nr_irqs = NR_IRQS;
+
+#ifdef P2SEG
+       __set_io_port_base(P2SEG);
+#else
+       __set_io_port_base(0);
+#endif
 }