Fedora kernel-2.6.17-1.2142_FC4 patched with stable patch-2.6.17.4-vs2.0.2-rc26.diff
[linux-2.6.git] / arch / sh / kernel / setup.c
index 574ac24..1680bb0 100644 (file)
 #include <linux/root_dev.h>
 #include <linux/utsname.h>
 #include <linux/cpu.h>
+#include <linux/pfn.h>
+#include <linux/vs_cvirt.h>
 #include <asm/uaccess.h>
 #include <asm/io.h>
-#include <asm/io_generic.h>
 #include <asm/sections.h>
 #include <asm/irq.h>
-#ifdef CONFIG_SH_EARLY_PRINTK
-#include <asm/sh_bios.h>
-#endif
+#include <asm/setup.h>
+#include <asm/clock.h>
 
 #ifdef CONFIG_SH_KGDB
 #include <asm/kgdb.h>
 static int kgdb_parse_options(char *options);
 #endif
-
+extern void * __rd_start, * __rd_end;
 /*
  * Machine setup..
  */
@@ -43,9 +43,8 @@ static int kgdb_parse_options(char *options);
  * This value will be used at the very early stage of serial setup.
  * The bigger value means no problem.
  */
-struct sh_cpuinfo boot_cpu_data = { CPU_SH_NONE, 0, 10000000, };
+struct sh_cpuinfo boot_cpu_data = { CPU_SH_NONE, 10000000, };
 struct screen_info screen_info;
-unsigned char aux_device_present = 0xaa;
 
 #if defined(CONFIG_SH_UNKNOWN)
 struct sh_machine_vector sh_mv;
@@ -85,14 +84,12 @@ static struct sh_machine_vector* __init get_mv_byname(const char* name);
 #define INITRD_SIZE (*(unsigned long *) (PARAM+0x014))
 /* ... */
 #define COMMAND_LINE ((char *) (PARAM+0x100))
-#define COMMAND_LINE_SIZE 256
 
-#define RAMDISK_IMAGE_START_MASK       0x07FF
+#define RAMDISK_IMAGE_START_MASK       0x07FF
 #define RAMDISK_PROMPT_FLAG            0x8000
-#define RAMDISK_LOAD_FLAG              0x4000  
+#define RAMDISK_LOAD_FLAG              0x4000
 
 static char command_line[COMMAND_LINE_SIZE] = { 0, };
-       char saved_command_line[COMMAND_LINE_SIZE];
 
 struct resource standard_io_resources[] = {
        { "dma1", 0x00, 0x1f },
@@ -120,130 +117,6 @@ static struct resource ram_resources[] = {
 
 unsigned long memory_start, memory_end;
 
-/* XXX: MRB-remove - blatant hack */
-#if 1
-#define SCIF_REG       0xffe80000
-
-static void scif_sercon_putc(int c)
-{
-       while (!(ctrl_inw(SCIF_REG + 0x10) & 0x20)) ;
-
-       ctrl_outb(c, SCIF_REG + 12);
-       ctrl_outw((ctrl_inw(SCIF_REG + 0x10) & 0x9f), SCIF_REG + 0x10);
-
-       if (c == '\n')
-               scif_sercon_putc('\r');
-}
-
-static void scif_sercon_flush(void)
-{
-       ctrl_outw((ctrl_inw(SCIF_REG + 0x10) & 0xbf), SCIF_REG + 0x10);
-
-       while (!(ctrl_inw(SCIF_REG + 0x10) & 0x40)) ;
-
-       ctrl_outw((ctrl_inw(SCIF_REG + 0x10) & 0xbf), SCIF_REG + 0x10);
-}
-
-static void scif_sercon_write(struct console *con, const char *s, unsigned count)
-{
-       while (count-- > 0)
-               scif_sercon_putc(*s++);
-
-       scif_sercon_flush();
-}
-
-static int __init scif_sercon_setup(struct console *con, char *options)
-{
-       con->cflag = CREAD | HUPCL | CLOCAL | B57600 | CS8;
-
-       return 0;
-}
-
-static struct console scif_sercon = {
-       .name           = "sercon",
-       .write          = scif_sercon_write,
-       .setup          = scif_sercon_setup,
-       .flags          = CON_PRINTBUFFER,
-       .index          = -1,
-};
-
-void scif_sercon_init(int baud)
-{
-       ctrl_outw(0, SCIF_REG + 8);
-       ctrl_outw(0, SCIF_REG);
-
-       /* Set baud rate */
-       ctrl_outb((50000000 / (32 * baud)) - 1, SCIF_REG + 4);
-
-       ctrl_outw(12, SCIF_REG + 24);
-       ctrl_outw(8, SCIF_REG + 24);
-       ctrl_outw(0, SCIF_REG + 32);
-       ctrl_outw(0x60, SCIF_REG + 16);
-       ctrl_outw(0, SCIF_REG + 36);
-       ctrl_outw(0x30, SCIF_REG + 8);
-
-       register_console(&scif_sercon);
-}
-
-void scif_sercon_unregister(void)
-{
-       unregister_console(&scif_sercon);
-}
-#endif
-
-#ifdef CONFIG_SH_EARLY_PRINTK
-/*
- *     Print a string through the BIOS
- */
-static void sh_console_write(struct console *co, const char *s,
-                                unsigned count)
-{
-       sh_bios_console_write(s, count);
-}
-
-/*
- *     Setup initial baud/bits/parity. We do two things here:
- *     - construct a cflag setting for the first rs_open()
- *     - initialize the serial port
- *     Return non-zero if we didn't find a serial port.
- */
-static int __init sh_console_setup(struct console *co, char *options)
-{
-       int     cflag = CREAD | HUPCL | CLOCAL;
-
-       /*
-        *      Now construct a cflag setting.
-        *      TODO: this is a totally bogus cflag, as we have
-        *      no idea what serial settings the BIOS is using, or
-        *      even if its using the serial port at all.
-        */
-       cflag |= B115200 | CS8 | /*no parity*/0;
-
-       co->cflag = cflag;
-
-       return 0;
-}
-
-static struct console sh_console = {
-       .name           = "bios",
-       .write          = sh_console_write,
-       .setup          = sh_console_setup,
-       .flags          = CON_PRINTBUFFER,
-       .index          = -1,
-};
-
-void sh_console_init(void)
-{
-       register_console(&sh_console);
-}
-
-void sh_console_unregister(void)
-{
-       unregister_console(&sh_console);
-}
-
-#endif
-
 static inline void parse_cmdline (char ** cmdline_p, char mv_name[MV_NAME_SIZE],
                                  struct sh_machine_vector** mvp,
                                  unsigned long *mv_io_base,
@@ -315,7 +188,7 @@ static inline void parse_cmdline (char ** cmdline_p, char mv_name[MV_NAME_SIZE],
 
 static int __init sh_mv_setup(char **cmdline_p)
 {
-#if defined(CONFIG_SH_UNKNOWN)
+#ifdef CONFIG_SH_UNKNOWN
        extern struct sh_machine_vector mv_unknown;
 #endif
        struct sh_machine_vector *mv = NULL;
@@ -325,11 +198,7 @@ static int __init sh_mv_setup(char **cmdline_p)
 
        parse_cmdline(cmdline_p, mv_name, &mv, &mv_io_base, &mv_mmio_enable);
 
-#ifdef CONFIG_CMDLINE_BOOL
-        sprintf(*cmdline_p, CONFIG_CMDLINE);
-#endif
-
-#ifdef CONFIG_SH_GENERIC
+#ifdef CONFIG_SH_UNKNOWN
        if (mv == NULL) {
                mv = &mv_unknown;
                if (*mv_name != '\0') {
@@ -339,9 +208,6 @@ static int __init sh_mv_setup(char **cmdline_p)
        }
        sh_mv = *mv;
 #endif
-#ifdef CONFIG_SH_UNKNOWN
-       sh_mv = mv_unknown;
-#endif
 
        /*
         * Manually walk the vec, fill in anything that the board hasn't yet
@@ -364,10 +230,8 @@ static int __init sh_mv_setup(char **cmdline_p)
        mv_set(readb);  mv_set(readw);  mv_set(readl);
        mv_set(writeb); mv_set(writew); mv_set(writel);
 
-       mv_set(ioremap);
-       mv_set(iounmap);
-
-       mv_set(isa_port2addr);
+       mv_set(ioport_map);
+       mv_set(ioport_unmap);
        mv_set(irq_demux);
 
 #ifdef CONFIG_SH_UNKNOWN
@@ -382,14 +246,15 @@ void __init setup_arch(char **cmdline_p)
        unsigned long bootmap_size;
        unsigned long start_pfn, max_pfn, max_low_pfn;
 
-/* XXX: MRB-remove */
-#if 0
-       scif_sercon_init(57600);
+#ifdef CONFIG_EARLY_PRINTK
+       extern void enable_early_printk(void);
+
+       enable_early_printk();
 #endif
-#ifdef CONFIG_SH_EARLY_PRINTK
-       sh_console_init();
+#ifdef CONFIG_CMDLINE_BOOL
+        strcpy(COMMAND_LINE, CONFIG_CMDLINE);
 #endif
-       
+
        ROOT_DEV = old_decode_dev(ORIG_ROOT_DEV);
 
 #ifdef CONFIG_BLK_DEV_RAM
@@ -405,29 +270,13 @@ void __init setup_arch(char **cmdline_p)
        init_mm.end_data = (unsigned long) _edata;
        init_mm.brk = (unsigned long) _end;
 
-       code_resource.start = virt_to_bus(_text);
-       code_resource.end = virt_to_bus(_etext)-1;
-       data_resource.start = virt_to_bus(_etext);
-       data_resource.end = virt_to_bus(_edata)-1;
+       code_resource.start = (unsigned long)virt_to_phys(_text);
+       code_resource.end = (unsigned long)virt_to_phys(_etext)-1;
+       data_resource.start = (unsigned long)virt_to_phys(_etext);
+       data_resource.end = (unsigned long)virt_to_phys(_edata)-1;
 
        sh_mv_setup(cmdline_p);
 
-#define PFN_UP(x)      (((x) + PAGE_SIZE-1) >> PAGE_SHIFT)
-#define PFN_DOWN(x)    ((x) >> PAGE_SHIFT)
-#define PFN_PHYS(x)    ((x) << PAGE_SHIFT)
-
-#ifdef CONFIG_DISCONTIGMEM
-       NODE_DATA(0)->bdata = &discontig_node_bdata[0];
-       NODE_DATA(1)->bdata = &discontig_node_bdata[1];
-
-       bootmap_size = init_bootmem_node(NODE_DATA(1), 
-                                        PFN_UP(__MEMORY_START_2ND),
-                                        PFN_UP(__MEMORY_START_2ND),
-                                        PFN_DOWN(__MEMORY_START_2ND+__MEMORY_SIZE_2ND));
-       free_bootmem_node(NODE_DATA(1), __MEMORY_START_2ND, __MEMORY_SIZE_2ND);
-       reserve_bootmem_node(NODE_DATA(1), __MEMORY_START_2ND, bootmap_size);
-#endif
-
        /*
         * Find the highest page frame number we have available
         */
@@ -438,10 +287,10 @@ void __init setup_arch(char **cmdline_p)
         */
        max_low_pfn = max_pfn;
 
-       /*
+       /*
         * Partially used pages are not usable - thus
         * we are rounding upwards:
-        */
+        */
        start_pfn = PFN_UP(__pa(_end));
 
        /*
@@ -492,6 +341,13 @@ void __init setup_arch(char **cmdline_p)
        reserve_bootmem_node(NODE_DATA(0), __MEMORY_START, PAGE_SIZE);
 
 #ifdef CONFIG_BLK_DEV_INITRD
+       ROOT_DEV = MKDEV(RAMDISK_MAJOR, 0);
+       if (&__rd_start != &__rd_end) {
+               LOADER_TYPE = 1;
+               INITRD_START = PHYSADDR((unsigned long)&__rd_start) - __MEMORY_START;
+               INITRD_SIZE = (unsigned long)&__rd_end - (unsigned long)&__rd_start;
+       }
+
        if (LOADER_TYPE && INITRD_START) {
                if (INITRD_START + INITRD_SIZE <= (max_low_pfn << PAGE_SHIFT)) {
                        reserve_bootmem_node(NODE_DATA(0), INITRD_START+__MEMORY_START, INITRD_SIZE);
@@ -546,9 +402,8 @@ static int __init topology_init(void)
 {
        int cpu_id;
 
-       for (cpu_id = 0; cpu_id < NR_CPUS; cpu_id++)
-               if (cpu_possible(cpu_id))
-                       register_cpu(&cpu[cpu_id], cpu_id, NULL);
+       for_each_possible_cpu(cpu_id)
+               register_cpu(&cpu[cpu_id], cpu_id, NULL);
 
        return 0;
 }
@@ -557,18 +412,24 @@ subsys_initcall(topology_init);
 
 static const char *cpu_name[] = {
        [CPU_SH7604]    = "SH7604",
+       [CPU_SH7705]    = "SH7705",
        [CPU_SH7708]    = "SH7708",
        [CPU_SH7729]    = "SH7729",
+       [CPU_SH7300]    = "SH7300",
        [CPU_SH7750]    = "SH7750",
        [CPU_SH7750S]   = "SH7750S",
        [CPU_SH7750R]   = "SH7750R",
        [CPU_SH7751]    = "SH7751",
        [CPU_SH7751R]   = "SH7751R",
        [CPU_SH7760]    = "SH7760",
+       [CPU_SH73180]   = "SH73180",
        [CPU_ST40RA]    = "ST40RA",
        [CPU_ST40GX1]   = "ST40GX1",
        [CPU_SH4_202]   = "SH4-202",
        [CPU_SH4_501]   = "SH4-501",
+       [CPU_SH7770]    = "SH7770",
+       [CPU_SH7780]    = "SH7780",
+       [CPU_SH7781]    = "SH7781",
        [CPU_SH_NONE]   = "Unknown"
 };
 
@@ -579,7 +440,7 @@ const char *get_cpu_subtype(void)
 
 #ifdef CONFIG_PROC_FS
 static const char *cpu_flags[] = {
-       "none", "fpu", "p2flush", "mmuassoc", "dsp",
+       "none", "fpu", "p2flush", "mmuassoc", "dsp", "perfctr", "ptea", NULL
 };
 
 static void show_cpuflags(struct seq_file *m)
@@ -593,10 +454,10 @@ static void show_cpuflags(struct seq_file *m)
                return;
        }
 
-       for (i = 0; i < cpu_data->flags; i++)
+       for (i = 0; cpu_flags[i]; i++)
                if ((cpu_data->flags & (1 << i)))
-                       seq_printf(m, " %s", cpu_flags[i]);
-       
+                       seq_printf(m, " %s", cpu_flags[i+1]);
+
        seq_printf(m, "\n");
 }
 
@@ -606,7 +467,8 @@ static void show_cacheinfo(struct seq_file *m, const char *type, struct cache_in
 
        cache_size = info.ways * info.sets * info.linesz;
 
-       seq_printf(m, "%s size\t: %dKiB\n", type, cache_size >> 10);
+       seq_printf(m, "%s size\t: %2dKiB (%d-way)\n",
+                  type, cache_size >> 10, info.ways);
 }
 
 /*
@@ -620,7 +482,7 @@ static int show_cpuinfo(struct seq_file *m, void *v)
                seq_printf(m, "machine\t\t: %s\n", get_system_type());
 
        seq_printf(m, "processor\t: %d\n", cpu);
-       seq_printf(m, "cpu family\t: %s\n", system_utsname.machine);
+       seq_printf(m, "cpu family\t: %s\n", vx_new_uts(machine));
        seq_printf(m, "cpu type\t: %s\n", get_cpu_subtype());
 
        show_cpuflags(m);
@@ -645,21 +507,9 @@ static int show_cpuinfo(struct seq_file *m, void *v)
                     boot_cpu_data.loops_per_jiffy/(500000/HZ),
                     (boot_cpu_data.loops_per_jiffy/(5000/HZ)) % 100);
 
-#define PRINT_CLOCK(name, value) \
-       seq_printf(m, name " clock\t: %d.%02dMHz\n", \
-                    ((value) / 1000000), ((value) % 1000000)/10000)
-       
-       PRINT_CLOCK("cpu", boot_cpu_data.cpu_clock);
-       PRINT_CLOCK("bus", boot_cpu_data.bus_clock);
-#ifdef CONFIG_CPU_SUBTYPE_ST40STB1
-       PRINT_CLOCK("memory", boot_cpu_data.memory_clock);
-#endif
-       PRINT_CLOCK("module", boot_cpu_data.module_clock);
-
-       return 0;
+       return show_clocks(m);
 }
 
-
 static void *c_start(struct seq_file *m, loff_t *pos)
 {
        return *pos < NR_CPUS ? cpu_data + *pos : NULL;
@@ -730,7 +580,7 @@ static int __init kgdb_parse_options(char *options)
                options += map->namelen + 1;
 
                options = (*options == ',') ? options+1 : options;
-               
+
                /* Read optional parameters (baud/parity/bits) */
                baud = simple_strtoul(options, &options, 10);
                if (baud != 0) {