xref: /linux/arch/alpha/kernel/irq_alpha.c (revision e20800fd5cec2a75639a32e956b1cdc023cb87ce)
11da177e4SLinus Torvalds /*
21da177e4SLinus Torvalds  * Alpha specific irq code.
31da177e4SLinus Torvalds  */
41da177e4SLinus Torvalds 
51da177e4SLinus Torvalds #include <linux/init.h>
61da177e4SLinus Torvalds #include <linux/sched.h>
71da177e4SLinus Torvalds #include <linux/irq.h>
81da177e4SLinus Torvalds #include <linux/kernel_stat.h>
9cff52dafSAl Viro #include <linux/module.h>
101da177e4SLinus Torvalds 
111da177e4SLinus Torvalds #include <asm/machvec.h>
121da177e4SLinus Torvalds #include <asm/dma.h>
13979f8671SMichael Cree #include <asm/perf_event.h>
14ec221208SDavid Howells #include <asm/mce.h>
151da177e4SLinus Torvalds 
161da177e4SLinus Torvalds #include "proto.h"
171da177e4SLinus Torvalds #include "irq_impl.h"
181da177e4SLinus Torvalds 
191da177e4SLinus Torvalds /* Hack minimum IPL during interrupt processing for broken hardware.  */
201da177e4SLinus Torvalds #ifdef CONFIG_ALPHA_BROKEN_IRQ_MASK
211da177e4SLinus Torvalds int __min_ipl;
22cff52dafSAl Viro EXPORT_SYMBOL(__min_ipl);
231da177e4SLinus Torvalds #endif
241da177e4SLinus Torvalds 
251da177e4SLinus Torvalds /*
261da177e4SLinus Torvalds  * Performance counter hook.  A module can override this to
271da177e4SLinus Torvalds  * do something useful.
281da177e4SLinus Torvalds  */
291da177e4SLinus Torvalds static void
301da177e4SLinus Torvalds dummy_perf(unsigned long vector, struct pt_regs *regs)
311da177e4SLinus Torvalds {
321da177e4SLinus Torvalds 	irq_err_count++;
331da177e4SLinus Torvalds 	printk(KERN_CRIT "Performance counter interrupt!\n");
341da177e4SLinus Torvalds }
351da177e4SLinus Torvalds 
361da177e4SLinus Torvalds void (*perf_irq)(unsigned long, struct pt_regs *) = dummy_perf;
37cff52dafSAl Viro EXPORT_SYMBOL(perf_irq);
381da177e4SLinus Torvalds 
391da177e4SLinus Torvalds /*
401da177e4SLinus Torvalds  * The main interrupt entry point.
411da177e4SLinus Torvalds  */
421da177e4SLinus Torvalds 
431da177e4SLinus Torvalds asmlinkage void
441da177e4SLinus Torvalds do_entInt(unsigned long type, unsigned long vector,
451da177e4SLinus Torvalds 	  unsigned long la_ptr, struct pt_regs *regs)
461da177e4SLinus Torvalds {
477ca56053SAl Viro 	struct pt_regs *old_regs;
48*e20800fdSWill Deacon 
49*e20800fdSWill Deacon 	/*
50*e20800fdSWill Deacon 	 * Disable interrupts during IRQ handling.
51*e20800fdSWill Deacon 	 * Note that there is no matching local_irq_enable() due to
52*e20800fdSWill Deacon 	 * severe problems with RTI at IPL0 and some MILO PALcode
53*e20800fdSWill Deacon 	 * (namely LX164).
54*e20800fdSWill Deacon 	 */
55*e20800fdSWill Deacon 	local_irq_disable();
561da177e4SLinus Torvalds 	switch (type) {
571da177e4SLinus Torvalds 	case 0:
581da177e4SLinus Torvalds #ifdef CONFIG_SMP
591da177e4SLinus Torvalds 		handle_ipi(regs);
601da177e4SLinus Torvalds 		return;
611da177e4SLinus Torvalds #else
621da177e4SLinus Torvalds 		irq_err_count++;
631da177e4SLinus Torvalds 		printk(KERN_CRIT "Interprocessor interrupt? "
641da177e4SLinus Torvalds 		       "You must be kidding!\n");
651da177e4SLinus Torvalds #endif
661da177e4SLinus Torvalds 		break;
671da177e4SLinus Torvalds 	case 1:
683dbb8c62SAl Viro 		old_regs = set_irq_regs(regs);
691da177e4SLinus Torvalds #ifdef CONFIG_SMP
701da177e4SLinus Torvalds 	  {
711da177e4SLinus Torvalds 		long cpu;
724a89a04fSIvan Kokshaysky 
731da177e4SLinus Torvalds 		smp_percpu_timer_interrupt(regs);
741da177e4SLinus Torvalds 		cpu = smp_processor_id();
751da177e4SLinus Torvalds 		if (cpu != boot_cpuid) {
760b0f0b1cSYinghai Lu 		        kstat_incr_irqs_this_cpu(RTC_IRQ, irq_to_desc(RTC_IRQ));
771da177e4SLinus Torvalds 		} else {
783dbb8c62SAl Viro 			handle_irq(RTC_IRQ);
791da177e4SLinus Torvalds 		}
801da177e4SLinus Torvalds 	  }
811da177e4SLinus Torvalds #else
823dbb8c62SAl Viro 		handle_irq(RTC_IRQ);
831da177e4SLinus Torvalds #endif
843dbb8c62SAl Viro 		set_irq_regs(old_regs);
851da177e4SLinus Torvalds 		return;
861da177e4SLinus Torvalds 	case 2:
874fa1970aSAl Viro 		old_regs = set_irq_regs(regs);
884fa1970aSAl Viro 		alpha_mv.machine_check(vector, la_ptr);
894fa1970aSAl Viro 		set_irq_regs(old_regs);
901da177e4SLinus Torvalds 		return;
911da177e4SLinus Torvalds 	case 3:
927ca56053SAl Viro 		old_regs = set_irq_regs(regs);
937ca56053SAl Viro 		alpha_mv.device_interrupt(vector);
947ca56053SAl Viro 		set_irq_regs(old_regs);
951da177e4SLinus Torvalds 		return;
961da177e4SLinus Torvalds 	case 4:
971da177e4SLinus Torvalds 		perf_irq(la_ptr, regs);
981da177e4SLinus Torvalds 		return;
991da177e4SLinus Torvalds 	default:
1001da177e4SLinus Torvalds 		printk(KERN_CRIT "Hardware intr %ld %lx? Huh?\n",
1011da177e4SLinus Torvalds 		       type, vector);
1021da177e4SLinus Torvalds 	}
1031da177e4SLinus Torvalds 	printk(KERN_CRIT "PC = %016lx PS=%04lx\n", regs->pc, regs->ps);
1041da177e4SLinus Torvalds }
1051da177e4SLinus Torvalds 
1061da177e4SLinus Torvalds void __init
1071da177e4SLinus Torvalds common_init_isa_dma(void)
1081da177e4SLinus Torvalds {
1091da177e4SLinus Torvalds 	outb(0, DMA1_RESET_REG);
1101da177e4SLinus Torvalds 	outb(0, DMA2_RESET_REG);
1111da177e4SLinus Torvalds 	outb(0, DMA1_CLR_MASK_REG);
1121da177e4SLinus Torvalds 	outb(0, DMA2_CLR_MASK_REG);
1131da177e4SLinus Torvalds }
1141da177e4SLinus Torvalds 
1151da177e4SLinus Torvalds void __init
1161da177e4SLinus Torvalds init_IRQ(void)
1171da177e4SLinus Torvalds {
1181da177e4SLinus Torvalds 	/* Just in case the platform init_irq() causes interrupts/mchecks
1191da177e4SLinus Torvalds 	   (as is the case with RAWHIDE, at least).  */
1201da177e4SLinus Torvalds 	wrent(entInt, 0);
1211da177e4SLinus Torvalds 
1221da177e4SLinus Torvalds 	alpha_mv.init_irq();
1231da177e4SLinus Torvalds }
1241da177e4SLinus Torvalds 
1251da177e4SLinus Torvalds /*
1261da177e4SLinus Torvalds  * machine error checks
1271da177e4SLinus Torvalds  */
1281da177e4SLinus Torvalds #define MCHK_K_TPERR           0x0080
1291da177e4SLinus Torvalds #define MCHK_K_TCPERR          0x0082
1301da177e4SLinus Torvalds #define MCHK_K_HERR            0x0084
1311da177e4SLinus Torvalds #define MCHK_K_ECC_C           0x0086
1321da177e4SLinus Torvalds #define MCHK_K_ECC_NC          0x0088
1331da177e4SLinus Torvalds #define MCHK_K_OS_BUGCHECK     0x008A
1341da177e4SLinus Torvalds #define MCHK_K_PAL_BUGCHECK    0x0090
1351da177e4SLinus Torvalds 
1361da177e4SLinus Torvalds #ifndef CONFIG_SMP
1371da177e4SLinus Torvalds struct mcheck_info __mcheck_info;
1381da177e4SLinus Torvalds #endif
1391da177e4SLinus Torvalds 
1401da177e4SLinus Torvalds void
1411da177e4SLinus Torvalds process_mcheck_info(unsigned long vector, unsigned long la_ptr,
1424fa1970aSAl Viro 		    const char *machine, int expected)
1431da177e4SLinus Torvalds {
1441da177e4SLinus Torvalds 	struct el_common *mchk_header;
1451da177e4SLinus Torvalds 	const char *reason;
1461da177e4SLinus Torvalds 
1471da177e4SLinus Torvalds 	/*
1481da177e4SLinus Torvalds 	 * See if the machine check is due to a badaddr() and if so,
1491da177e4SLinus Torvalds 	 * ignore it.
1501da177e4SLinus Torvalds 	 */
1511da177e4SLinus Torvalds 
1521da177e4SLinus Torvalds #ifdef CONFIG_VERBOSE_MCHECK
1531da177e4SLinus Torvalds 	if (alpha_verbose_mcheck > 1) {
1541da177e4SLinus Torvalds 		printk(KERN_CRIT "%s machine check %s\n", machine,
1551da177e4SLinus Torvalds 		       expected ? "expected." : "NOT expected!!!");
1561da177e4SLinus Torvalds 	}
1571da177e4SLinus Torvalds #endif
1581da177e4SLinus Torvalds 
1591da177e4SLinus Torvalds 	if (expected) {
1601da177e4SLinus Torvalds 		int cpu = smp_processor_id();
1611da177e4SLinus Torvalds 		mcheck_expected(cpu) = 0;
1621da177e4SLinus Torvalds 		mcheck_taken(cpu) = 1;
1631da177e4SLinus Torvalds 		return;
1641da177e4SLinus Torvalds 	}
1651da177e4SLinus Torvalds 
1661da177e4SLinus Torvalds 	mchk_header = (struct el_common *)la_ptr;
1671da177e4SLinus Torvalds 
1681da177e4SLinus Torvalds 	printk(KERN_CRIT "%s machine check: vector=0x%lx pc=0x%lx code=0x%x\n",
1694fa1970aSAl Viro 	       machine, vector, get_irq_regs()->pc, mchk_header->code);
1701da177e4SLinus Torvalds 
1711da177e4SLinus Torvalds 	switch (mchk_header->code) {
1721da177e4SLinus Torvalds 	/* Machine check reasons.  Defined according to PALcode sources.  */
1731da177e4SLinus Torvalds 	case 0x80: reason = "tag parity error"; break;
1741da177e4SLinus Torvalds 	case 0x82: reason = "tag control parity error"; break;
1751da177e4SLinus Torvalds 	case 0x84: reason = "generic hard error"; break;
1761da177e4SLinus Torvalds 	case 0x86: reason = "correctable ECC error"; break;
1771da177e4SLinus Torvalds 	case 0x88: reason = "uncorrectable ECC error"; break;
1781da177e4SLinus Torvalds 	case 0x8A: reason = "OS-specific PAL bugcheck"; break;
1791da177e4SLinus Torvalds 	case 0x90: reason = "callsys in kernel mode"; break;
1801da177e4SLinus Torvalds 	case 0x96: reason = "i-cache read retryable error"; break;
1811da177e4SLinus Torvalds 	case 0x98: reason = "processor detected hard error"; break;
1821da177e4SLinus Torvalds 
1831da177e4SLinus Torvalds 	/* System specific (these are for Alcor, at least): */
1841da177e4SLinus Torvalds 	case 0x202: reason = "system detected hard error"; break;
1851da177e4SLinus Torvalds 	case 0x203: reason = "system detected uncorrectable ECC error"; break;
1861da177e4SLinus Torvalds 	case 0x204: reason = "SIO SERR occurred on PCI bus"; break;
1871da177e4SLinus Torvalds 	case 0x205: reason = "parity error detected by core logic"; break;
1881da177e4SLinus Torvalds 	case 0x206: reason = "SIO IOCHK occurred on ISA bus"; break;
1891da177e4SLinus Torvalds 	case 0x207: reason = "non-existent memory error"; break;
1901da177e4SLinus Torvalds 	case 0x208: reason = "MCHK_K_DCSR"; break;
1911da177e4SLinus Torvalds 	case 0x209: reason = "PCI SERR detected"; break;
1921da177e4SLinus Torvalds 	case 0x20b: reason = "PCI data parity error detected"; break;
1931da177e4SLinus Torvalds 	case 0x20d: reason = "PCI address parity error detected"; break;
1941da177e4SLinus Torvalds 	case 0x20f: reason = "PCI master abort error"; break;
1951da177e4SLinus Torvalds 	case 0x211: reason = "PCI target abort error"; break;
1961da177e4SLinus Torvalds 	case 0x213: reason = "scatter/gather PTE invalid error"; break;
1971da177e4SLinus Torvalds 	case 0x215: reason = "flash ROM write error"; break;
1981da177e4SLinus Torvalds 	case 0x217: reason = "IOA timeout detected"; break;
1991da177e4SLinus Torvalds 	case 0x219: reason = "IOCHK#, EISA add-in board parity or other catastrophic error"; break;
2001da177e4SLinus Torvalds 	case 0x21b: reason = "EISA fail-safe timer timeout"; break;
2011da177e4SLinus Torvalds 	case 0x21d: reason = "EISA bus time-out"; break;
2021da177e4SLinus Torvalds 	case 0x21f: reason = "EISA software generated NMI"; break;
2031da177e4SLinus Torvalds 	case 0x221: reason = "unexpected ev5 IRQ[3] interrupt"; break;
2041da177e4SLinus Torvalds 	default: reason = "unknown"; break;
2051da177e4SLinus Torvalds 	}
2061da177e4SLinus Torvalds 
2071da177e4SLinus Torvalds 	printk(KERN_CRIT "machine check type: %s%s\n",
2081da177e4SLinus Torvalds 	       reason, mchk_header->retry ? " (retryable)" : "");
2091da177e4SLinus Torvalds 
2104fa1970aSAl Viro 	dik_show_regs(get_irq_regs(), NULL);
2111da177e4SLinus Torvalds 
2121da177e4SLinus Torvalds #ifdef CONFIG_VERBOSE_MCHECK
2131da177e4SLinus Torvalds 	if (alpha_verbose_mcheck > 1) {
2141da177e4SLinus Torvalds 		/* Dump the logout area to give all info.  */
2151da177e4SLinus Torvalds 		unsigned long *ptr = (unsigned long *)la_ptr;
2161da177e4SLinus Torvalds 		long i;
2171da177e4SLinus Torvalds 		for (i = 0; i < mchk_header->size / sizeof(long); i += 2) {
2181da177e4SLinus Torvalds 			printk(KERN_CRIT "   +%8lx %016lx %016lx\n",
2191da177e4SLinus Torvalds 			       i*sizeof(long), ptr[i], ptr[i+1]);
2201da177e4SLinus Torvalds 		}
2211da177e4SLinus Torvalds 	}
2221da177e4SLinus Torvalds #endif /* CONFIG_VERBOSE_MCHECK */
2231da177e4SLinus Torvalds }
2241da177e4SLinus Torvalds 
2251da177e4SLinus Torvalds /*
2261da177e4SLinus Torvalds  * The special RTC interrupt type.  The interrupt itself was
2271da177e4SLinus Torvalds  * processed by PALcode, and comes in via entInt vector 1.
2281da177e4SLinus Torvalds  */
2291da177e4SLinus Torvalds 
2301da177e4SLinus Torvalds struct irqaction timer_irqaction = {
2311da177e4SLinus Torvalds 	.handler	= timer_interrupt,
232d18ecedcSThomas Gleixner 	.flags		= IRQF_DISABLED,
2331da177e4SLinus Torvalds 	.name		= "timer",
2341da177e4SLinus Torvalds };
2351da177e4SLinus Torvalds 
2361da177e4SLinus Torvalds void __init
2371da177e4SLinus Torvalds init_rtc_irq(void)
2381da177e4SLinus Torvalds {
23961813188SRichard Henderson 	irq_set_chip_and_handler_name(RTC_IRQ, &dummy_irq_chip,
2407d209c81SKyle McMartin 				      handle_simple_irq, "RTC");
2411da177e4SLinus Torvalds 	setup_irq(RTC_IRQ, &timer_irqaction);
2421da177e4SLinus Torvalds }
2431da177e4SLinus Torvalds 
2441da177e4SLinus Torvalds /* Dummy irqactions.  */
2451da177e4SLinus Torvalds struct irqaction isa_cascade_irqaction = {
2461da177e4SLinus Torvalds 	.handler	= no_action,
2471da177e4SLinus Torvalds 	.name		= "isa-cascade"
2481da177e4SLinus Torvalds };
2491da177e4SLinus Torvalds 
2501da177e4SLinus Torvalds struct irqaction timer_cascade_irqaction = {
2511da177e4SLinus Torvalds 	.handler	= no_action,
2521da177e4SLinus Torvalds 	.name		= "timer-cascade"
2531da177e4SLinus Torvalds };
2541da177e4SLinus Torvalds 
2551da177e4SLinus Torvalds struct irqaction halt_switch_irqaction = {
2561da177e4SLinus Torvalds 	.handler	= no_action,
2571da177e4SLinus Torvalds 	.name		= "halt-switch"
2581da177e4SLinus Torvalds };
259