| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* | 
|  | 2 | *	linux/arch/alpha/kernel/sys_jensen.c | 
|  | 3 | * | 
|  | 4 | *	Copyright (C) 1995 Linus Torvalds | 
|  | 5 | *	Copyright (C) 1998, 1999 Richard Henderson | 
|  | 6 | * | 
|  | 7 | * Code supporting the Jensen. | 
|  | 8 | */ | 
|  | 9 |  | 
|  | 10 | #include <linux/kernel.h> | 
|  | 11 | #include <linux/types.h> | 
|  | 12 | #include <linux/mm.h> | 
|  | 13 | #include <linux/sched.h> | 
|  | 14 | #include <linux/pci.h> | 
|  | 15 | #include <linux/init.h> | 
|  | 16 |  | 
|  | 17 | #include <asm/ptrace.h> | 
|  | 18 | #include <asm/system.h> | 
|  | 19 |  | 
|  | 20 | #define __EXTERN_INLINE inline | 
|  | 21 | #include <asm/io.h> | 
|  | 22 | #include <asm/jensen.h> | 
|  | 23 | #undef  __EXTERN_INLINE | 
|  | 24 |  | 
|  | 25 | #include <asm/dma.h> | 
|  | 26 | #include <asm/irq.h> | 
|  | 27 | #include <asm/mmu_context.h> | 
|  | 28 | #include <asm/pgtable.h> | 
|  | 29 | #include <asm/tlbflush.h> | 
|  | 30 |  | 
|  | 31 | #include "proto.h" | 
|  | 32 | #include "irq_impl.h" | 
|  | 33 | #include "pci_impl.h" | 
|  | 34 | #include "machvec_impl.h" | 
|  | 35 |  | 
|  | 36 |  | 
|  | 37 | /* | 
|  | 38 | * Jensen is special: the vector is 0x8X0 for EISA interrupt X, and | 
|  | 39 | * 0x9X0 for the local motherboard interrupts. | 
|  | 40 | * | 
|  | 41 | * Note especially that those local interrupts CANNOT be masked, | 
|  | 42 | * which causes much of the pain below... | 
|  | 43 | * | 
|  | 44 | *	0x660 - NMI | 
|  | 45 | * | 
|  | 46 | *	0x800 - IRQ0  interval timer (not used, as we use the RTC timer) | 
|  | 47 | *	0x810 - IRQ1  line printer (duh..) | 
|  | 48 | *	0x860 - IRQ6  floppy disk | 
|  | 49 | * | 
|  | 50 | *	0x900 - COM1 | 
|  | 51 | *	0x920 - COM2 | 
|  | 52 | *	0x980 - keyboard | 
|  | 53 | *	0x990 - mouse | 
|  | 54 | * | 
|  | 55 | * PCI-based systems are more sane: they don't have the local | 
|  | 56 | * interrupts at all, and have only normal PCI interrupts from | 
|  | 57 | * devices.  Happily it's easy enough to do a sane mapping from the | 
|  | 58 | * Jensen. | 
|  | 59 | * | 
|  | 60 | * Note that this means that we may have to do a hardware | 
|  | 61 | * "local_op" to a different interrupt than we report to the rest of the | 
|  | 62 | * world. | 
|  | 63 | */ | 
|  | 64 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 65 | static void | 
| Thomas Gleixner | ff53afe | 2011-02-06 14:32:28 +0000 | [diff] [blame] | 66 | jensen_local_enable(struct irq_data *d) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 67 | { | 
|  | 68 | /* the parport is really hw IRQ 1, silly Jensen.  */ | 
| Thomas Gleixner | ff53afe | 2011-02-06 14:32:28 +0000 | [diff] [blame] | 69 | if (d->irq == 7) | 
|  | 70 | i8259a_enable_irq(d); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 71 | } | 
|  | 72 |  | 
|  | 73 | static void | 
| Thomas Gleixner | ff53afe | 2011-02-06 14:32:28 +0000 | [diff] [blame] | 74 | jensen_local_disable(struct irq_data *d) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 75 | { | 
|  | 76 | /* the parport is really hw IRQ 1, silly Jensen.  */ | 
| Thomas Gleixner | ff53afe | 2011-02-06 14:32:28 +0000 | [diff] [blame] | 77 | if (d->irq == 7) | 
|  | 78 | i8259a_disable_irq(d); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 79 | } | 
|  | 80 |  | 
|  | 81 | static void | 
| Thomas Gleixner | ff53afe | 2011-02-06 14:32:28 +0000 | [diff] [blame] | 82 | jensen_local_mask_ack(struct irq_data *d) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 83 | { | 
|  | 84 | /* the parport is really hw IRQ 1, silly Jensen.  */ | 
| Thomas Gleixner | ff53afe | 2011-02-06 14:32:28 +0000 | [diff] [blame] | 85 | if (d->irq == 7) | 
|  | 86 | i8259a_mask_and_ack_irq(d); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 87 | } | 
|  | 88 |  | 
| Thomas Gleixner | 44377f6 | 2009-06-16 15:33:25 -0700 | [diff] [blame] | 89 | static struct irq_chip jensen_local_irq_type = { | 
| Thomas Gleixner | 8ab1221 | 2009-11-30 22:51:31 -0500 | [diff] [blame] | 90 | .name		= "LOCAL", | 
| Thomas Gleixner | ff53afe | 2011-02-06 14:32:28 +0000 | [diff] [blame] | 91 | .irq_unmask	= jensen_local_enable, | 
|  | 92 | .irq_mask	= jensen_local_disable, | 
|  | 93 | .irq_mask_ack	= jensen_local_mask_ack, | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 94 | }; | 
|  | 95 |  | 
|  | 96 | static void | 
| Al Viro | 7ca5605 | 2006-10-08 14:36:08 +0100 | [diff] [blame] | 97 | jensen_device_interrupt(unsigned long vector) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 98 | { | 
|  | 99 | int irq; | 
|  | 100 |  | 
|  | 101 | switch (vector) { | 
|  | 102 | case 0x660: | 
|  | 103 | printk("Whee.. NMI received. Probable hardware error\n"); | 
|  | 104 | printk("61=%02x, 461=%02x\n", inb(0x61), inb(0x461)); | 
|  | 105 | return; | 
|  | 106 |  | 
|  | 107 | /* local device interrupts: */ | 
|  | 108 | case 0x900: irq = 4; break;		/* com1 -> irq 4 */ | 
|  | 109 | case 0x920: irq = 3; break;		/* com2 -> irq 3 */ | 
|  | 110 | case 0x980: irq = 1; break;		/* kbd -> irq 1 */ | 
|  | 111 | case 0x990: irq = 9; break;		/* mouse -> irq 9 */ | 
|  | 112 |  | 
|  | 113 | default: | 
|  | 114 | if (vector > 0x900) { | 
|  | 115 | printk("Unknown local interrupt %lx\n", vector); | 
|  | 116 | return; | 
|  | 117 | } | 
|  | 118 |  | 
|  | 119 | irq = (vector - 0x800) >> 4; | 
|  | 120 | if (irq == 1) | 
|  | 121 | irq = 7; | 
|  | 122 | break; | 
|  | 123 | } | 
|  | 124 |  | 
|  | 125 | /* If there is no handler yet... */ | 
| Kyle McMartin | a891b39 | 2010-10-14 22:31:25 -0400 | [diff] [blame] | 126 | if (!irq_has_action(irq)) { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 127 | /* If it is a local interrupt that cannot be masked... */ | 
|  | 128 | if (vector >= 0x900) | 
|  | 129 | { | 
|  | 130 | /* Clear keyboard/mouse state */ | 
|  | 131 | inb(0x64); | 
|  | 132 | inb(0x60); | 
|  | 133 | /* Reset serial ports */ | 
|  | 134 | inb(0x3fa); | 
|  | 135 | inb(0x2fa); | 
|  | 136 | outb(0x0c, 0x3fc); | 
|  | 137 | outb(0x0c, 0x2fc); | 
|  | 138 | /* Clear NMI */ | 
|  | 139 | outb(0,0x61); | 
|  | 140 | outb(0,0x461); | 
|  | 141 | } | 
|  | 142 | } | 
|  | 143 |  | 
|  | 144 | #if 0 | 
|  | 145 | /* A useful bit of code to find out if an interrupt is going wild.  */ | 
|  | 146 | { | 
|  | 147 | static unsigned int last_msg = 0, last_cc = 0; | 
|  | 148 | static int last_irq = -1, count = 0; | 
|  | 149 | unsigned int cc; | 
|  | 150 |  | 
|  | 151 | __asm __volatile("rpcc %0" : "=r"(cc)); | 
|  | 152 | ++count; | 
|  | 153 | #define JENSEN_CYCLES_PER_SEC	(150000000) | 
|  | 154 | if (cc - last_msg > ((JENSEN_CYCLES_PER_SEC) * 3) || | 
|  | 155 | irq != last_irq) { | 
|  | 156 | printk(KERN_CRIT " irq %d count %d cc %u @ %lx\n", | 
| Al Viro | 7ca5605 | 2006-10-08 14:36:08 +0100 | [diff] [blame] | 157 | irq, count, cc-last_cc, get_irq_regs()->pc); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 158 | count = 0; | 
|  | 159 | last_msg = cc; | 
|  | 160 | last_irq = irq; | 
|  | 161 | } | 
|  | 162 | last_cc = cc; | 
|  | 163 | } | 
|  | 164 | #endif | 
|  | 165 |  | 
| Al Viro | 3dbb8c6 | 2006-10-08 14:37:32 +0100 | [diff] [blame] | 166 | handle_irq(irq); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 167 | } | 
|  | 168 |  | 
|  | 169 | static void __init | 
|  | 170 | jensen_init_irq(void) | 
|  | 171 | { | 
|  | 172 | init_i8259a_irqs(); | 
|  | 173 |  | 
| Thomas Gleixner | a9eb076 | 2011-03-25 22:17:31 +0100 | [diff] [blame] | 174 | irq_set_chip_and_handler(1, &jensen_local_irq_type, handle_level_irq); | 
|  | 175 | irq_set_chip_and_handler(4, &jensen_local_irq_type, handle_level_irq); | 
|  | 176 | irq_set_chip_and_handler(3, &jensen_local_irq_type, handle_level_irq); | 
|  | 177 | irq_set_chip_and_handler(7, &jensen_local_irq_type, handle_level_irq); | 
|  | 178 | irq_set_chip_and_handler(9, &jensen_local_irq_type, handle_level_irq); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 179 |  | 
|  | 180 | common_init_isa_dma(); | 
|  | 181 | } | 
|  | 182 |  | 
|  | 183 | static void __init | 
|  | 184 | jensen_init_arch(void) | 
|  | 185 | { | 
|  | 186 | struct pci_controller *hose; | 
|  | 187 | #ifdef CONFIG_PCI | 
|  | 188 | static struct pci_dev fake_isa_bridge = { .dma_mask = 0xffffffffUL, }; | 
|  | 189 |  | 
|  | 190 | isa_bridge = &fake_isa_bridge; | 
|  | 191 | #endif | 
|  | 192 |  | 
|  | 193 | /* Create a hose so that we can report i/o base addresses to | 
|  | 194 | userland.  */ | 
|  | 195 |  | 
|  | 196 | pci_isa_hose = hose = alloc_pci_controller(); | 
|  | 197 | hose->io_space = &ioport_resource; | 
|  | 198 | hose->mem_space = &iomem_resource; | 
|  | 199 | hose->index = 0; | 
|  | 200 |  | 
|  | 201 | hose->sparse_mem_base = EISA_MEM - IDENT_ADDR; | 
|  | 202 | hose->dense_mem_base = 0; | 
|  | 203 | hose->sparse_io_base = EISA_IO - IDENT_ADDR; | 
|  | 204 | hose->dense_io_base = 0; | 
|  | 205 |  | 
|  | 206 | hose->sg_isa = hose->sg_pci = NULL; | 
|  | 207 | __direct_map_base = 0; | 
|  | 208 | __direct_map_size = 0xffffffff; | 
|  | 209 | } | 
|  | 210 |  | 
|  | 211 | static void | 
| Randy Dunlap | 5f0e3da | 2009-03-31 15:23:36 -0700 | [diff] [blame] | 212 | jensen_machine_check(unsigned long vector, unsigned long la) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 213 | { | 
|  | 214 | printk(KERN_CRIT "Machine check\n"); | 
|  | 215 | } | 
|  | 216 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 217 | /* | 
|  | 218 | * The System Vector | 
|  | 219 | */ | 
|  | 220 |  | 
|  | 221 | struct alpha_machine_vector jensen_mv __initmv = { | 
|  | 222 | .vector_name		= "Jensen", | 
|  | 223 | DO_EV4_MMU, | 
|  | 224 | IO_LITE(JENSEN,jensen), | 
|  | 225 | .machine_check		= jensen_machine_check, | 
|  | 226 | .max_isa_dma_address	= ALPHA_MAX_ISA_DMA_ADDRESS, | 
|  | 227 | .rtc_port		= 0x170, | 
| Ivan Kokshaysky | 5f7dc5d | 2009-01-15 13:51:19 -0800 | [diff] [blame] | 228 | .rtc_get_time		= common_get_rtc_time, | 
|  | 229 | .rtc_set_time		= common_set_rtc_time, | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 230 |  | 
|  | 231 | .nr_irqs		= 16, | 
|  | 232 | .device_interrupt	= jensen_device_interrupt, | 
|  | 233 |  | 
|  | 234 | .init_arch		= jensen_init_arch, | 
|  | 235 | .init_irq		= jensen_init_irq, | 
|  | 236 | .init_rtc		= common_init_rtc, | 
|  | 237 | .init_pci		= NULL, | 
|  | 238 | .kill_arch		= NULL, | 
|  | 239 | }; | 
|  | 240 | ALIAS_MV(jensen) |