[IA64-SGI] - Pass OS logical cpu number to the SN prom (bios)
[pandora-kernel.git] / arch / ia64 / sn / kernel / setup.c
index e510dce..9757934 100644 (file)
@@ -3,7 +3,7 @@
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
  *
- * Copyright (C) 1999,2001-2005 Silicon Graphics, Inc. All rights reserved.
+ * Copyright (C) 1999,2001-2006 Silicon Graphics, Inc. All rights reserved.
  */
 
 #include <linux/config.h>
@@ -67,6 +67,7 @@ extern unsigned long last_time_offset;
 extern void (*ia64_mark_idle) (int);
 extern void snidle(int);
 extern unsigned char acpi_kbd_controller_present;
+extern unsigned long long (*ia64_printk_clock)(void);
 
 unsigned long sn_rtc_cycles_per_second;
 EXPORT_SYMBOL(sn_rtc_cycles_per_second);
@@ -74,7 +75,7 @@ EXPORT_SYMBOL(sn_rtc_cycles_per_second);
 DEFINE_PER_CPU(struct sn_hub_info_s, __sn_hub_info);
 EXPORT_PER_CPU_SYMBOL(__sn_hub_info);
 
-DEFINE_PER_CPU(short, __sn_cnodeid_to_nasid[MAX_NUMNODES]);
+DEFINE_PER_CPU(short, __sn_cnodeid_to_nasid[MAX_COMPACT_NODES]);
 EXPORT_PER_CPU_SYMBOL(__sn_cnodeid_to_nasid);
 
 DEFINE_PER_CPU(struct nodepda_s *, __sn_nodepda);
@@ -124,20 +125,6 @@ struct screen_info sn_screen_info = {
        .orig_video_points = 16
 };
 
-/*
- * This is here so we can use the CMOS detection in ide-probe.c to
- * determine what drives are present.  In theory, we don't need this
- * as the auto-detection could be done via ide-probe.c:do_probe() but
- * in practice that would be much slower, which is painful when
- * running in the simulator.  Note that passing zeroes in DRIVE_INFO
- * is sufficient (the IDE driver will autodetect the drive geometry).
- */
-#ifdef CONFIG_IA64_GENERIC
-extern char drive_info[4 * 16];
-#else
-char drive_info[4 * 16];
-#endif
-
 /*
  * This routine can only be used during init, since
  * smp_boot_data is an init data structure.
@@ -152,7 +139,7 @@ static int __init pxm_to_nasid(int pxm)
        int i;
        int nid;
 
-       nid = pxm_to_nid_map[pxm];
+       nid = pxm_to_node(pxm);
        for (i = 0; i < num_node_memblks; i++) {
                if (node_memblk[i].nid == nid) {
                        return NASID_GET(node_memblk[i].start_paddr);
@@ -209,7 +196,7 @@ void __init early_sn_setup(void)
 }
 
 extern int platform_intr_list[];
-static int __initdata shub_1_1_found = 0;
+static int __initdata shub_1_1_found;
 
 /*
  * sn_check_for_wars
@@ -330,6 +317,7 @@ struct pcdp_vga_device {
 #define PCDP_PCI_TRANS_IOPORT  0x02
 #define PCDP_PCI_TRANS_MMIO    0x01
 
+#if defined(CONFIG_VT) && defined(CONFIG_VGA_CONSOLE)
 static void
 sn_scan_pcdp(void)
 {
@@ -339,10 +327,11 @@ sn_scan_pcdp(void)
        struct pcdp_interface_pci if_pci;
        extern struct efi efi;
 
-       pcdp = efi.hcdp;
-       if (! pcdp)
+       if (efi.hcdp == EFI_INVALID_TABLE_ADDR)
                return;         /* no hcdp/pcdp table */
 
+       pcdp = __va(efi.hcdp);
+
        if (pcdp->rev < 3)
                return;         /* only support PCDP (rev >= 3) */
 
@@ -371,6 +360,17 @@ sn_scan_pcdp(void)
                break; /* once we find the primary, we're done */
        }
 }
+#endif
+
+static unsigned long sn2_rtc_initial;
+
+static unsigned long long ia64_sn2_printk_clock(void)
+{
+       unsigned long rtc_now = rtc_time();
+
+       return (rtc_now - sn2_rtc_initial) *
+               (1000000000 / sn_rtc_cycles_per_second);
+}
 
 /**
  * sn_setup - SN platform setup routine
@@ -386,6 +386,7 @@ void __init sn_setup(char **cmdline_p)
        u32 version = sn_sal_rev();
        extern void sn_cpu_init(void);
 
+       sn2_rtc_initial = rtc_time();
        ia64_sn_plat_set_error_handling_features();     // obsolete
        ia64_sn_set_os_feature(OSF_MCA_SLV_TO_OS_INIT_SLV);
        ia64_sn_set_os_feature(OSF_FEAT_LOG_SBES);
@@ -437,19 +438,6 @@ void __init sn_setup(char **cmdline_p)
         */
        build_cnode_tables();
 
-       /*
-        * Old PROMs do not provide an ACPI FADT. Disable legacy keyboard
-        * support here so we don't have to listen to failed keyboard probe
-        * messages.
-        */
-       if (version <= 0x0209 && acpi_kbd_controller_present) {
-               printk(KERN_INFO "Disabling legacy keyboard support as prom "
-                      "is too old and doesn't provide FADT\n");
-               acpi_kbd_controller_present = 0;
-       }
-
-       printk("SGI SAL version %x.%02x\n", version >> 8, version & 0x00FF);
-
        status =
            ia64_sal_freq_base(SAL_FREQ_BASE_REALTIME_CLOCK, &ticks_per_sec,
                               &drift);
@@ -463,6 +451,21 @@ void __init sn_setup(char **cmdline_p)
 
        platform_intr_list[ACPI_INTERRUPT_CPEI] = IA64_CPE_VECTOR;
 
+       ia64_printk_clock = ia64_sn2_printk_clock;
+
+       /*
+        * Old PROMs do not provide an ACPI FADT. Disable legacy keyboard
+        * support here so we don't have to listen to failed keyboard probe
+        * messages.
+        */
+       if (version <= 0x0209 && acpi_kbd_controller_present) {
+               printk(KERN_INFO "Disabling legacy keyboard support as prom "
+                      "is too old and doesn't provide FADT\n");
+               acpi_kbd_controller_present = 0;
+       }
+
+       printk("SGI SAL version %x.%02x\n", version >> 8, version & 0x00FF);
+
        /*
         * we set the default root device to /dev/hda
         * to make simulation easy
@@ -496,6 +499,7 @@ void __init sn_setup(char **cmdline_p)
         * for sn.
         */
        pm_power_off = ia64_sn_power_down;
+       current->thread.flags |= IA64_THREAD_MIGRATION;
 }
 
 /**
@@ -573,21 +577,32 @@ void __init sn_cpu_init(void)
        int i;
        static int wars_have_been_checked;
 
-       if (smp_processor_id() == 0 && IS_MEDUSA()) {
+       cpuid = smp_processor_id();
+       if (cpuid == 0 && IS_MEDUSA()) {
                if (ia64_sn_is_fake_prom())
                        sn_prom_type = 2;
                else
                        sn_prom_type = 1;
-               printk("Running on medusa with %s PROM\n", (sn_prom_type == 1) ? "real" : "fake");
+               printk(KERN_INFO "Running on medusa with %s PROM\n",
+                      (sn_prom_type == 1) ? "real" : "fake");
        }
 
        memset(pda, 0, sizeof(pda));
-       if (ia64_sn_get_sn_info(0, &sn_hub_info->shub2, &sn_hub_info->nasid_bitmask, &sn_hub_info->nasid_shift,
-                               &sn_system_size, &sn_sharing_domain_size, &sn_partition_id,
-                               &sn_coherency_id, &sn_region_size))
+       if (ia64_sn_get_sn_info(0, &sn_hub_info->shub2,
+                               &sn_hub_info->nasid_bitmask,
+                               &sn_hub_info->nasid_shift,
+                               &sn_system_size, &sn_sharing_domain_size,
+                               &sn_partition_id, &sn_coherency_id,
+                               &sn_region_size))
                BUG();
        sn_hub_info->as_shift = sn_hub_info->nasid_shift - 2;
 
+       /*
+        * Don't check status. The SAL call is not supported on all PROMs
+        * but a failure is harmless.
+        */
+       (void) ia64_sn_set_cpu_number(cpuid);
+
        /*
         * The boot cpu makes this call again after platform initialization is
         * complete.
@@ -599,7 +614,6 @@ void __init sn_cpu_init(void)
                if (ia64_sn_get_prom_feature_set(i, &sn_prom_features[i]) != 0)
                        break;
 
-       cpuid = smp_processor_id();
        cpuphyid = get_sapicid();
 
        if (ia64_sn_get_sapic_info(cpuphyid, &nasid, &subnode, &slice))
@@ -654,7 +668,8 @@ void __init sn_cpu_init(void)
                        SH2_PIO_WRITE_STATUS_1, SH2_PIO_WRITE_STATUS_3};
                u64 *pio;
                pio = is_shub1() ? pio1 : pio2;
-               pda->pio_write_status_addr = (volatile unsigned long *) LOCAL_MMR_ADDR(pio[slice]);
+               pda->pio_write_status_addr =
+                  (volatile unsigned long *)GLOBAL_MMR_ADDR(nasid, pio[slice]);
                pda->pio_write_status_val = is_shub1() ? SH_PIO_WRITE_STATUS_PENDING_WRITE_COUNT_MASK : 0;
        }
 
@@ -695,7 +710,7 @@ void __init build_cnode_tables(void)
         * cnode == node for all C & M bricks.
         */
        for_each_online_node(node) {
-               nasid = pxm_to_nasid(nid_to_pxm_map[node]);
+               nasid = pxm_to_nasid(node_to_pxm(node));
                sn_cnodeid_to_nasid[node] = nasid;
                physical_node_map[nasid] = node;
        }
@@ -716,7 +731,8 @@ void __init build_cnode_tables(void)
        for_each_online_node(node) {
                kl_config_hdr_t *klgraph_header;
                nasid = cnodeid_to_nasid(node);
-               if ((klgraph_header = ia64_sn_get_klconfig_addr(nasid)) == NULL)
+               klgraph_header = ia64_sn_get_klconfig_addr(nasid);
+               if (klgraph_header == NULL)
                        BUG();
                brd = NODE_OFFSET_TO_LBOARD(nasid, klgraph_header->ch_board_info);
                while (brd) {
@@ -734,7 +750,7 @@ nasid_slice_to_cpuid(int nasid, int slice)
 {
        long cpu;
 
-       for (cpu=0; cpu < NR_CPUS; cpu++)
+       for (cpu = 0; cpu < NR_CPUS; cpu++)
                if (cpuid_to_nasid(cpu) == nasid &&
                                        cpuid_to_slice(cpu) == slice)
                        return cpu;