^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0-only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * System Abstraction Layer (SAL) interface routines.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Copyright (C) 1998, 1999, 2001, 2003 Hewlett-Packard Co
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * David Mosberger-Tang <davidm@hpl.hp.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * Copyright (C) 1999 VA Linux Systems
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) * Copyright (C) 1999 Walt Drummond <drummond@valinux.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <linux/spinlock.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include <linux/string.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #include <asm/delay.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #include <asm/page.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #include <asm/sal.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #include <asm/pal.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) #include <asm/xtp.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) __cacheline_aligned DEFINE_SPINLOCK(sal_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) unsigned long sal_platform_features;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) unsigned short sal_revision;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) unsigned short sal_version;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) #define SAL_MAJOR(x) ((x) >> 8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) #define SAL_MINOR(x) ((x) & 0xff)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) static struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) void *addr; /* function entry point */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) void *gpval; /* gp value to use */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) } pdesc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) static long
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) default_handler (void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) return -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) ia64_sal_handler ia64_sal = (ia64_sal_handler) default_handler;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) ia64_sal_desc_ptc_t *ia64_ptc_domain_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) const char *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) ia64_sal_strerror (long status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) const char *str;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) switch (status) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) case 0: str = "Call completed without error"; break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) case 1: str = "Effect a warm boot of the system to complete "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) "the update"; break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) case -1: str = "Not implemented"; break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) case -2: str = "Invalid argument"; break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) case -3: str = "Call completed with error"; break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) case -4: str = "Virtual address not registered"; break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) case -5: str = "No information available"; break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) case -6: str = "Insufficient space to add the entry"; break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) case -7: str = "Invalid entry_addr value"; break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) case -8: str = "Invalid interrupt vector"; break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) case -9: str = "Requested memory not available"; break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) case -10: str = "Unable to write to the NVM device"; break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) case -11: str = "Invalid partition type specified"; break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) case -12: str = "Invalid NVM_Object id specified"; break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) case -13: str = "NVM_Object already has the maximum number "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) "of partitions"; break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) case -14: str = "Insufficient space in partition for the "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) "requested write sub-function"; break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) case -15: str = "Insufficient data buffer space for the "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) "requested read record sub-function"; break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) case -16: str = "Scratch buffer required for the write/delete "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) "sub-function"; break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) case -17: str = "Insufficient space in the NVM_Object for the "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) "requested create sub-function"; break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) case -18: str = "Invalid value specified in the partition_rec "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) "argument"; break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) case -19: str = "Record oriented I/O not supported for this "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) "partition"; break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) case -20: str = "Bad format of record to be written or "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) "required keyword variable not "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) "specified"; break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) default: str = "Unknown SAL status code"; break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) return str;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) void __init
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) ia64_sal_handler_init (void *entry_point, void *gpval)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) /* fill in the SAL procedure descriptor and point ia64_sal to it: */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) pdesc.addr = entry_point;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) pdesc.gpval = gpval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) ia64_sal = (ia64_sal_handler) &pdesc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) static void __init
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) check_versions (struct ia64_sal_systab *systab)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) sal_revision = (systab->sal_rev_major << 8) | systab->sal_rev_minor;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) sal_version = (systab->sal_b_rev_major << 8) | systab->sal_b_rev_minor;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) /* Check for broken firmware */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) if ((sal_revision == SAL_VERSION_CODE(49, 29))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) && (sal_version == SAL_VERSION_CODE(49, 29)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) * Old firmware for zx2000 prototypes have this weird version number,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) * reset it to something sane.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) sal_revision = SAL_VERSION_CODE(2, 8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) sal_version = SAL_VERSION_CODE(0, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) static void __init
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) sal_desc_entry_point (void *p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) struct ia64_sal_desc_entry_point *ep = p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) ia64_pal_handler_init(__va(ep->pal_proc));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) ia64_sal_handler_init(__va(ep->sal_proc), __va(ep->gp));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) #ifdef CONFIG_SMP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) static void __init
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) set_smp_redirect (int flag)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) #ifndef CONFIG_HOTPLUG_CPU
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) if (no_int_routing)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) smp_int_redirect &= ~flag;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) smp_int_redirect |= flag;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) * For CPU Hotplug we dont want to do any chipset supported
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) * interrupt redirection. The reason is this would require that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) * All interrupts be stopped and hard bind the irq to a cpu.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) * Later when the interrupt is fired we need to set the redir hint
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) * on again in the vector. This is cumbersome for something that the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) * user mode irq balancer will solve anyways.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) no_int_routing=1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) smp_int_redirect &= ~flag;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) #define set_smp_redirect(flag) do { } while (0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) static void __init
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) sal_desc_platform_feature (void *p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) struct ia64_sal_desc_platform_feature *pf = p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) sal_platform_features = pf->feature_mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) printk(KERN_INFO "SAL Platform features:");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) if (!sal_platform_features) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) printk(" None\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) if (sal_platform_features & IA64_SAL_PLATFORM_FEATURE_BUS_LOCK)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) printk(" BusLock");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) if (sal_platform_features & IA64_SAL_PLATFORM_FEATURE_IRQ_REDIR_HINT) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) printk(" IRQ_Redirection");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) set_smp_redirect(SMP_IRQ_REDIRECTION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) if (sal_platform_features & IA64_SAL_PLATFORM_FEATURE_IPI_REDIR_HINT) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) printk(" IPI_Redirection");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) set_smp_redirect(SMP_IPI_REDIRECTION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) if (sal_platform_features & IA64_SAL_PLATFORM_FEATURE_ITC_DRIFT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) printk(" ITC_Drift");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) printk("\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) #ifdef CONFIG_SMP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) static void __init
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) sal_desc_ap_wakeup (void *p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) struct ia64_sal_desc_ap_wakeup *ap = p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) switch (ap->mechanism) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) case IA64_SAL_AP_EXTERNAL_INT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) ap_wakeup_vector = ap->vector;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) printk(KERN_INFO "SAL: AP wakeup using external interrupt "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) "vector 0x%lx\n", ap_wakeup_vector);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) printk(KERN_ERR "SAL: AP wakeup mechanism unsupported!\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) static void __init
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) chk_nointroute_opt(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) char *cp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) for (cp = boot_command_line; *cp; ) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) if (memcmp(cp, "nointroute", 10) == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) no_int_routing = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) printk ("no_int_routing on\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) while (*cp != ' ' && *cp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) ++cp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) while (*cp == ' ')
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) ++cp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) static void __init sal_desc_ap_wakeup(void *p) { }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) * HP rx5670 firmware polls for interrupts during SAL_CACHE_FLUSH by reading
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) * cr.ivr, but it never writes cr.eoi. This leaves any interrupt marked as
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) * "in-service" and masks other interrupts of equal or lower priority.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) * HP internal defect reports: F1859, F2775, F3031.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) static int sal_cache_flush_drops_interrupts;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) static int __init
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) force_pal_cache_flush(char *str)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) sal_cache_flush_drops_interrupts = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) early_param("force_pal_cache_flush", force_pal_cache_flush);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) void __init
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) check_sal_cache_flush (void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) int cpu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) u64 vector, cache_type = 3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) struct ia64_sal_retval isrv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) if (sal_cache_flush_drops_interrupts)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) cpu = get_cpu();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) local_irq_save(flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) * Send ourselves a timer interrupt, wait until it's reported, and see
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) * if SAL_CACHE_FLUSH drops it.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) ia64_send_ipi(cpu, IA64_TIMER_VECTOR, IA64_IPI_DM_INT, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) while (!ia64_get_irr(IA64_TIMER_VECTOR))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) cpu_relax();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) SAL_CALL(isrv, SAL_CACHE_FLUSH, cache_type, 0, 0, 0, 0, 0, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) if (isrv.status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) printk(KERN_ERR "SAL_CAL_FLUSH failed with %ld\n", isrv.status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) if (ia64_get_irr(IA64_TIMER_VECTOR)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) vector = ia64_get_ivr();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) ia64_eoi();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) WARN_ON(vector != IA64_TIMER_VECTOR);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) sal_cache_flush_drops_interrupts = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) printk(KERN_ERR "SAL: SAL_CACHE_FLUSH drops interrupts; "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) "PAL_CACHE_FLUSH will be used instead\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) ia64_eoi();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) local_irq_restore(flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) put_cpu();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) s64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) ia64_sal_cache_flush (u64 cache_type)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) struct ia64_sal_retval isrv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) if (sal_cache_flush_drops_interrupts) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) u64 progress;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) s64 rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) progress = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) local_irq_save(flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) rc = ia64_pal_cache_flush(cache_type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) PAL_CACHE_FLUSH_INVALIDATE, &progress, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) local_irq_restore(flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) SAL_CALL(isrv, SAL_CACHE_FLUSH, cache_type, 0, 0, 0, 0, 0, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) return isrv.status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) EXPORT_SYMBOL_GPL(ia64_sal_cache_flush);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) void __init
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) ia64_sal_init (struct ia64_sal_systab *systab)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) char *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) if (!systab) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) printk(KERN_WARNING "Hmm, no SAL System Table.\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) if (strncmp(systab->signature, "SST_", 4) != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) printk(KERN_ERR "bad signature in system table!");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) check_versions(systab);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) #ifdef CONFIG_SMP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) chk_nointroute_opt();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) /* revisions are coded in BCD, so %x does the job for us */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) printk(KERN_INFO "SAL %x.%x: %.32s %.32s%sversion %x.%x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) SAL_MAJOR(sal_revision), SAL_MINOR(sal_revision),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) systab->oem_id, systab->product_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) systab->product_id[0] ? " " : "",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) SAL_MAJOR(sal_version), SAL_MINOR(sal_version));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) p = (char *) (systab + 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) for (i = 0; i < systab->entry_count; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) * The first byte of each entry type contains the type
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) * descriptor.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) switch (*p) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) case SAL_DESC_ENTRY_POINT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) sal_desc_entry_point(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) case SAL_DESC_PLATFORM_FEATURE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) sal_desc_platform_feature(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) case SAL_DESC_PTC:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) ia64_ptc_domain_info = (ia64_sal_desc_ptc_t *)p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) case SAL_DESC_AP_WAKEUP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) sal_desc_ap_wakeup(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) p += SAL_DESC_SIZE(*p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) ia64_sal_oemcall(struct ia64_sal_retval *isrvp, u64 oemfunc, u64 arg1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) u64 arg2, u64 arg3, u64 arg4, u64 arg5, u64 arg6, u64 arg7)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) if (oemfunc < IA64_SAL_OEMFUNC_MIN || oemfunc > IA64_SAL_OEMFUNC_MAX)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) return -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) SAL_CALL(*isrvp, oemfunc, arg1, arg2, arg3, arg4, arg5, arg6, arg7);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) EXPORT_SYMBOL(ia64_sal_oemcall);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) ia64_sal_oemcall_nolock(struct ia64_sal_retval *isrvp, u64 oemfunc, u64 arg1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) u64 arg2, u64 arg3, u64 arg4, u64 arg5, u64 arg6,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) u64 arg7)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) if (oemfunc < IA64_SAL_OEMFUNC_MIN || oemfunc > IA64_SAL_OEMFUNC_MAX)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) return -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) SAL_CALL_NOLOCK(*isrvp, oemfunc, arg1, arg2, arg3, arg4, arg5, arg6,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) arg7);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) EXPORT_SYMBOL(ia64_sal_oemcall_nolock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) ia64_sal_oemcall_reentrant(struct ia64_sal_retval *isrvp, u64 oemfunc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) u64 arg1, u64 arg2, u64 arg3, u64 arg4, u64 arg5,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) u64 arg6, u64 arg7)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) if (oemfunc < IA64_SAL_OEMFUNC_MIN || oemfunc > IA64_SAL_OEMFUNC_MAX)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) return -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) SAL_CALL_REENTRANT(*isrvp, oemfunc, arg1, arg2, arg3, arg4, arg5, arg6,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) arg7);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) EXPORT_SYMBOL(ia64_sal_oemcall_reentrant);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) long
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) ia64_sal_freq_base (unsigned long which, unsigned long *ticks_per_second,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) unsigned long *drift_info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) struct ia64_sal_retval isrv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) SAL_CALL(isrv, SAL_FREQ_BASE, which, 0, 0, 0, 0, 0, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) *ticks_per_second = isrv.v0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) *drift_info = isrv.v1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) return isrv.status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) EXPORT_SYMBOL_GPL(ia64_sal_freq_base);