visws_quirks.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687
  1. /*
  2. * SGI Visual Workstation support and quirks, unmaintained.
  3. *
  4. * Split out from setup.c by davej@suse.de
  5. *
  6. * Copyright (C) 1999 Bent Hagemark, Ingo Molnar
  7. *
  8. * SGI Visual Workstation interrupt controller
  9. *
  10. * The Cobalt system ASIC in the Visual Workstation contains a "Cobalt" APIC
  11. * which serves as the main interrupt controller in the system. Non-legacy
  12. * hardware in the system uses this controller directly. Legacy devices
  13. * are connected to the PIIX4 which in turn has its 8259(s) connected to
  14. * a of the Cobalt APIC entry.
  15. *
  16. * 09/02/2000 - Updated for 2.4 by jbarnes@sgi.com
  17. *
  18. * 25/11/2002 - Updated for 2.5 by Andrey Panin <pazke@orbita1.ru>
  19. */
  20. #include <linux/interrupt.h>
  21. #include <linux/module.h>
  22. #include <linux/init.h>
  23. #include <linux/smp.h>
  24. #include <asm/visws/cobalt.h>
  25. #include <asm/visws/piix4.h>
  26. #include <asm/io_apic.h>
  27. #include <asm/fixmap.h>
  28. #include <asm/reboot.h>
  29. #include <asm/setup.h>
  30. #include <asm/apic.h>
  31. #include <asm/e820.h>
  32. #include <asm/io.h>
  33. #include <linux/kernel_stat.h>
  34. #include <asm/i8259.h>
  35. #include <asm/irq_vectors.h>
  36. #include <asm/visws/lithium.h>
  37. #include <linux/sched.h>
  38. #include <linux/kernel.h>
  39. #include <linux/pci.h>
  40. #include <linux/pci_ids.h>
  41. extern int no_broadcast;
  42. char visws_board_type = -1;
  43. char visws_board_rev = -1;
  44. int is_visws_box(void)
  45. {
  46. return visws_board_type >= 0;
  47. }
  48. static int __init visws_time_init(void)
  49. {
  50. printk(KERN_INFO "Starting Cobalt Timer system clock\n");
  51. /* Set the countdown value */
  52. co_cpu_write(CO_CPU_TIMEVAL, CO_TIME_HZ/HZ);
  53. /* Start the timer */
  54. co_cpu_write(CO_CPU_CTRL, co_cpu_read(CO_CPU_CTRL) | CO_CTRL_TIMERUN);
  55. /* Enable (unmask) the timer interrupt */
  56. co_cpu_write(CO_CPU_CTRL, co_cpu_read(CO_CPU_CTRL) & ~CO_CTRL_TIMEMASK);
  57. /*
  58. * Zero return means the generic timer setup code will set up
  59. * the standard vector:
  60. */
  61. return 0;
  62. }
  63. static int __init visws_pre_intr_init(void)
  64. {
  65. init_VISWS_APIC_irqs();
  66. /*
  67. * We dont want ISA irqs to be set up by the generic code:
  68. */
  69. return 1;
  70. }
  71. /* Quirk for machine specific memory setup. */
  72. #define MB (1024 * 1024)
  73. unsigned long sgivwfb_mem_phys;
  74. unsigned long sgivwfb_mem_size;
  75. EXPORT_SYMBOL(sgivwfb_mem_phys);
  76. EXPORT_SYMBOL(sgivwfb_mem_size);
  77. long long mem_size __initdata = 0;
  78. static char * __init visws_memory_setup(void)
  79. {
  80. long long gfx_mem_size = 8 * MB;
  81. mem_size = boot_params.alt_mem_k;
  82. if (!mem_size) {
  83. printk(KERN_WARNING "Bootloader didn't set memory size, upgrade it !\n");
  84. mem_size = 128 * MB;
  85. }
  86. /*
  87. * this hardcodes the graphics memory to 8 MB
  88. * it really should be sized dynamically (or at least
  89. * set as a boot param)
  90. */
  91. if (!sgivwfb_mem_size) {
  92. printk(KERN_WARNING "Defaulting to 8 MB framebuffer size\n");
  93. sgivwfb_mem_size = 8 * MB;
  94. }
  95. /*
  96. * Trim to nearest MB
  97. */
  98. sgivwfb_mem_size &= ~((1 << 20) - 1);
  99. sgivwfb_mem_phys = mem_size - gfx_mem_size;
  100. e820_add_region(0, LOWMEMSIZE(), E820_RAM);
  101. e820_add_region(HIGH_MEMORY, mem_size - sgivwfb_mem_size - HIGH_MEMORY, E820_RAM);
  102. e820_add_region(sgivwfb_mem_phys, sgivwfb_mem_size, E820_RESERVED);
  103. return "PROM";
  104. }
  105. static void visws_machine_emergency_restart(void)
  106. {
  107. /*
  108. * Visual Workstations restart after this
  109. * register is poked on the PIIX4
  110. */
  111. outb(PIIX4_RESET_VAL, PIIX4_RESET_PORT);
  112. }
  113. static void visws_machine_power_off(void)
  114. {
  115. unsigned short pm_status;
  116. /* extern unsigned int pci_bus0; */
  117. while ((pm_status = inw(PMSTS_PORT)) & 0x100)
  118. outw(pm_status, PMSTS_PORT);
  119. outw(PM_SUSPEND_ENABLE, PMCNTRL_PORT);
  120. mdelay(10);
  121. #define PCI_CONF1_ADDRESS(bus, devfn, reg) \
  122. (0x80000000 | (bus << 16) | (devfn << 8) | (reg & ~3))
  123. /* outl(PCI_CONF1_ADDRESS(pci_bus0, SPECIAL_DEV, SPECIAL_REG), 0xCF8); */
  124. outl(PIIX_SPECIAL_STOP, 0xCFC);
  125. }
  126. static int __init visws_get_smp_config(unsigned int early)
  127. {
  128. /*
  129. * Prevent MP-table parsing by the generic code:
  130. */
  131. return 1;
  132. }
  133. /*
  134. * The Visual Workstation is Intel MP compliant in the hardware
  135. * sense, but it doesn't have a BIOS(-configuration table).
  136. * No problem for Linux.
  137. */
  138. static void __init MP_processor_info(struct mpc_cpu *m)
  139. {
  140. int ver, logical_apicid;
  141. physid_mask_t apic_cpus;
  142. if (!(m->cpuflag & CPU_ENABLED))
  143. return;
  144. logical_apicid = m->apicid;
  145. printk(KERN_INFO "%sCPU #%d %u:%u APIC version %d\n",
  146. m->cpuflag & CPU_BOOTPROCESSOR ? "Bootup " : "",
  147. m->apicid, (m->cpufeature & CPU_FAMILY_MASK) >> 8,
  148. (m->cpufeature & CPU_MODEL_MASK) >> 4, m->apicver);
  149. if (m->cpuflag & CPU_BOOTPROCESSOR)
  150. boot_cpu_physical_apicid = m->apicid;
  151. ver = m->apicver;
  152. if ((ver >= 0x14 && m->apicid >= 0xff) || m->apicid >= 0xf) {
  153. printk(KERN_ERR "Processor #%d INVALID. (Max ID: %d).\n",
  154. m->apicid, MAX_APICS);
  155. return;
  156. }
  157. apic_cpus = apic->apicid_to_cpu_present(m->apicid);
  158. physids_or(phys_cpu_present_map, phys_cpu_present_map, apic_cpus);
  159. /*
  160. * Validate version
  161. */
  162. if (ver == 0x0) {
  163. printk(KERN_ERR "BIOS bug, APIC version is 0 for CPU#%d! "
  164. "fixing up to 0x10. (tell your hw vendor)\n",
  165. m->apicid);
  166. ver = 0x10;
  167. }
  168. apic_version[m->apicid] = ver;
  169. }
  170. static int __init visws_find_smp_config(unsigned int reserve)
  171. {
  172. struct mpc_cpu *mp = phys_to_virt(CO_CPU_TAB_PHYS);
  173. unsigned short ncpus = readw(phys_to_virt(CO_CPU_NUM_PHYS));
  174. if (ncpus > CO_CPU_MAX) {
  175. printk(KERN_WARNING "find_visws_smp: got cpu count of %d at %p\n",
  176. ncpus, mp);
  177. ncpus = CO_CPU_MAX;
  178. }
  179. if (ncpus > setup_max_cpus)
  180. ncpus = setup_max_cpus;
  181. #ifdef CONFIG_X86_LOCAL_APIC
  182. smp_found_config = 1;
  183. #endif
  184. while (ncpus--)
  185. MP_processor_info(mp++);
  186. mp_lapic_addr = APIC_DEFAULT_PHYS_BASE;
  187. return 1;
  188. }
  189. static int visws_trap_init(void);
  190. static struct x86_quirks visws_x86_quirks __initdata = {
  191. .arch_time_init = visws_time_init,
  192. .arch_pre_intr_init = visws_pre_intr_init,
  193. .arch_memory_setup = visws_memory_setup,
  194. .arch_intr_init = NULL,
  195. .arch_trap_init = visws_trap_init,
  196. .mach_get_smp_config = visws_get_smp_config,
  197. .mach_find_smp_config = visws_find_smp_config,
  198. };
  199. void __init visws_early_detect(void)
  200. {
  201. int raw;
  202. visws_board_type = (char)(inb_p(PIIX_GPI_BD_REG) & PIIX_GPI_BD_REG)
  203. >> PIIX_GPI_BD_SHIFT;
  204. if (visws_board_type < 0)
  205. return;
  206. /*
  207. * Install special quirks for timer, interrupt and memory setup:
  208. * Fall back to generic behavior for traps:
  209. * Override generic MP-table parsing:
  210. */
  211. x86_quirks = &visws_x86_quirks;
  212. /*
  213. * Install reboot quirks:
  214. */
  215. pm_power_off = visws_machine_power_off;
  216. machine_ops.emergency_restart = visws_machine_emergency_restart;
  217. /*
  218. * Do not use broadcast IPIs:
  219. */
  220. no_broadcast = 0;
  221. #ifdef CONFIG_X86_IO_APIC
  222. /*
  223. * Turn off IO-APIC detection and initialization:
  224. */
  225. skip_ioapic_setup = 1;
  226. #endif
  227. /*
  228. * Get Board rev.
  229. * First, we have to initialize the 307 part to allow us access
  230. * to the GPIO registers. Let's map them at 0x0fc0 which is right
  231. * after the PIIX4 PM section.
  232. */
  233. outb_p(SIO_DEV_SEL, SIO_INDEX);
  234. outb_p(SIO_GP_DEV, SIO_DATA); /* Talk to GPIO regs. */
  235. outb_p(SIO_DEV_MSB, SIO_INDEX);
  236. outb_p(SIO_GP_MSB, SIO_DATA); /* MSB of GPIO base address */
  237. outb_p(SIO_DEV_LSB, SIO_INDEX);
  238. outb_p(SIO_GP_LSB, SIO_DATA); /* LSB of GPIO base address */
  239. outb_p(SIO_DEV_ENB, SIO_INDEX);
  240. outb_p(1, SIO_DATA); /* Enable GPIO registers. */
  241. /*
  242. * Now, we have to map the power management section to write
  243. * a bit which enables access to the GPIO registers.
  244. * What lunatic came up with this shit?
  245. */
  246. outb_p(SIO_DEV_SEL, SIO_INDEX);
  247. outb_p(SIO_PM_DEV, SIO_DATA); /* Talk to GPIO regs. */
  248. outb_p(SIO_DEV_MSB, SIO_INDEX);
  249. outb_p(SIO_PM_MSB, SIO_DATA); /* MSB of PM base address */
  250. outb_p(SIO_DEV_LSB, SIO_INDEX);
  251. outb_p(SIO_PM_LSB, SIO_DATA); /* LSB of PM base address */
  252. outb_p(SIO_DEV_ENB, SIO_INDEX);
  253. outb_p(1, SIO_DATA); /* Enable PM registers. */
  254. /*
  255. * Now, write the PM register which enables the GPIO registers.
  256. */
  257. outb_p(SIO_PM_FER2, SIO_PM_INDEX);
  258. outb_p(SIO_PM_GP_EN, SIO_PM_DATA);
  259. /*
  260. * Now, initialize the GPIO registers.
  261. * We want them all to be inputs which is the
  262. * power on default, so let's leave them alone.
  263. * So, let's just read the board rev!
  264. */
  265. raw = inb_p(SIO_GP_DATA1);
  266. raw &= 0x7f; /* 7 bits of valid board revision ID. */
  267. if (visws_board_type == VISWS_320) {
  268. if (raw < 0x6) {
  269. visws_board_rev = 4;
  270. } else if (raw < 0xc) {
  271. visws_board_rev = 5;
  272. } else {
  273. visws_board_rev = 6;
  274. }
  275. } else if (visws_board_type == VISWS_540) {
  276. visws_board_rev = 2;
  277. } else {
  278. visws_board_rev = raw;
  279. }
  280. printk(KERN_INFO "Silicon Graphics Visual Workstation %s (rev %d) detected\n",
  281. (visws_board_type == VISWS_320 ? "320" :
  282. (visws_board_type == VISWS_540 ? "540" :
  283. "unknown")), visws_board_rev);
  284. }
  285. #define A01234 (LI_INTA_0 | LI_INTA_1 | LI_INTA_2 | LI_INTA_3 | LI_INTA_4)
  286. #define BCD (LI_INTB | LI_INTC | LI_INTD)
  287. #define ALLDEVS (A01234 | BCD)
  288. static __init void lithium_init(void)
  289. {
  290. set_fixmap(FIX_LI_PCIA, LI_PCI_A_PHYS);
  291. set_fixmap(FIX_LI_PCIB, LI_PCI_B_PHYS);
  292. if ((li_pcia_read16(PCI_VENDOR_ID) != PCI_VENDOR_ID_SGI) ||
  293. (li_pcia_read16(PCI_DEVICE_ID) != PCI_DEVICE_ID_SGI_LITHIUM)) {
  294. printk(KERN_EMERG "Lithium hostbridge %c not found\n", 'A');
  295. /* panic("This machine is not SGI Visual Workstation 320/540"); */
  296. }
  297. if ((li_pcib_read16(PCI_VENDOR_ID) != PCI_VENDOR_ID_SGI) ||
  298. (li_pcib_read16(PCI_DEVICE_ID) != PCI_DEVICE_ID_SGI_LITHIUM)) {
  299. printk(KERN_EMERG "Lithium hostbridge %c not found\n", 'B');
  300. /* panic("This machine is not SGI Visual Workstation 320/540"); */
  301. }
  302. li_pcia_write16(LI_PCI_INTEN, ALLDEVS);
  303. li_pcib_write16(LI_PCI_INTEN, ALLDEVS);
  304. }
  305. static __init void cobalt_init(void)
  306. {
  307. /*
  308. * On normal SMP PC this is used only with SMP, but we have to
  309. * use it and set it up here to start the Cobalt clock
  310. */
  311. set_fixmap(FIX_APIC_BASE, APIC_DEFAULT_PHYS_BASE);
  312. setup_local_APIC();
  313. printk(KERN_INFO "Local APIC Version %#x, ID %#x\n",
  314. (unsigned int)apic_read(APIC_LVR),
  315. (unsigned int)apic_read(APIC_ID));
  316. set_fixmap(FIX_CO_CPU, CO_CPU_PHYS);
  317. set_fixmap(FIX_CO_APIC, CO_APIC_PHYS);
  318. printk(KERN_INFO "Cobalt Revision %#lx, APIC ID %#lx\n",
  319. co_cpu_read(CO_CPU_REV), co_apic_read(CO_APIC_ID));
  320. /* Enable Cobalt APIC being careful to NOT change the ID! */
  321. co_apic_write(CO_APIC_ID, co_apic_read(CO_APIC_ID) | CO_APIC_ENABLE);
  322. printk(KERN_INFO "Cobalt APIC enabled: ID reg %#lx\n",
  323. co_apic_read(CO_APIC_ID));
  324. }
  325. static int __init visws_trap_init(void)
  326. {
  327. lithium_init();
  328. cobalt_init();
  329. return 1;
  330. }
  331. /*
  332. * IRQ controller / APIC support:
  333. */
  334. static DEFINE_SPINLOCK(cobalt_lock);
  335. /*
  336. * Set the given Cobalt APIC Redirection Table entry to point
  337. * to the given IDT vector/index.
  338. */
  339. static inline void co_apic_set(int entry, int irq)
  340. {
  341. co_apic_write(CO_APIC_LO(entry), CO_APIC_LEVEL | (irq + FIRST_EXTERNAL_VECTOR));
  342. co_apic_write(CO_APIC_HI(entry), 0);
  343. }
  344. /*
  345. * Cobalt (IO)-APIC functions to handle PCI devices.
  346. */
  347. static inline int co_apic_ide0_hack(void)
  348. {
  349. extern char visws_board_type;
  350. extern char visws_board_rev;
  351. if (visws_board_type == VISWS_320 && visws_board_rev == 5)
  352. return 5;
  353. return CO_APIC_IDE0;
  354. }
  355. static int is_co_apic(unsigned int irq)
  356. {
  357. if (IS_CO_APIC(irq))
  358. return CO_APIC(irq);
  359. switch (irq) {
  360. case 0: return CO_APIC_CPU;
  361. case CO_IRQ_IDE0: return co_apic_ide0_hack();
  362. case CO_IRQ_IDE1: return CO_APIC_IDE1;
  363. default: return -1;
  364. }
  365. }
  366. /*
  367. * This is the SGI Cobalt (IO-)APIC:
  368. */
  369. static void enable_cobalt_irq(unsigned int irq)
  370. {
  371. co_apic_set(is_co_apic(irq), irq);
  372. }
  373. static void disable_cobalt_irq(unsigned int irq)
  374. {
  375. int entry = is_co_apic(irq);
  376. co_apic_write(CO_APIC_LO(entry), CO_APIC_MASK);
  377. co_apic_read(CO_APIC_LO(entry));
  378. }
  379. /*
  380. * "irq" really just serves to identify the device. Here is where we
  381. * map this to the Cobalt APIC entry where it's physically wired.
  382. * This is called via request_irq -> setup_irq -> irq_desc->startup()
  383. */
  384. static unsigned int startup_cobalt_irq(unsigned int irq)
  385. {
  386. unsigned long flags;
  387. struct irq_desc *desc = irq_to_desc(irq);
  388. spin_lock_irqsave(&cobalt_lock, flags);
  389. if ((desc->status & (IRQ_DISABLED | IRQ_INPROGRESS | IRQ_WAITING)))
  390. desc->status &= ~(IRQ_DISABLED | IRQ_INPROGRESS | IRQ_WAITING);
  391. enable_cobalt_irq(irq);
  392. spin_unlock_irqrestore(&cobalt_lock, flags);
  393. return 0;
  394. }
  395. static void ack_cobalt_irq(unsigned int irq)
  396. {
  397. unsigned long flags;
  398. spin_lock_irqsave(&cobalt_lock, flags);
  399. disable_cobalt_irq(irq);
  400. apic_write(APIC_EOI, APIC_EIO_ACK);
  401. spin_unlock_irqrestore(&cobalt_lock, flags);
  402. }
  403. static void end_cobalt_irq(unsigned int irq)
  404. {
  405. unsigned long flags;
  406. struct irq_desc *desc = irq_to_desc(irq);
  407. spin_lock_irqsave(&cobalt_lock, flags);
  408. if (!(desc->status & (IRQ_DISABLED | IRQ_INPROGRESS)))
  409. enable_cobalt_irq(irq);
  410. spin_unlock_irqrestore(&cobalt_lock, flags);
  411. }
  412. static struct irq_chip cobalt_irq_type = {
  413. .typename = "Cobalt-APIC",
  414. .startup = startup_cobalt_irq,
  415. .shutdown = disable_cobalt_irq,
  416. .enable = enable_cobalt_irq,
  417. .disable = disable_cobalt_irq,
  418. .ack = ack_cobalt_irq,
  419. .end = end_cobalt_irq,
  420. };
  421. /*
  422. * This is the PIIX4-based 8259 that is wired up indirectly to Cobalt
  423. * -- not the manner expected by the code in i8259.c.
  424. *
  425. * there is a 'master' physical interrupt source that gets sent to
  426. * the CPU. But in the chipset there are various 'virtual' interrupts
  427. * waiting to be handled. We represent this to Linux through a 'master'
  428. * interrupt controller type, and through a special virtual interrupt-
  429. * controller. Device drivers only see the virtual interrupt sources.
  430. */
  431. static unsigned int startup_piix4_master_irq(unsigned int irq)
  432. {
  433. init_8259A(0);
  434. return startup_cobalt_irq(irq);
  435. }
  436. static void end_piix4_master_irq(unsigned int irq)
  437. {
  438. unsigned long flags;
  439. spin_lock_irqsave(&cobalt_lock, flags);
  440. enable_cobalt_irq(irq);
  441. spin_unlock_irqrestore(&cobalt_lock, flags);
  442. }
  443. static struct irq_chip piix4_master_irq_type = {
  444. .typename = "PIIX4-master",
  445. .startup = startup_piix4_master_irq,
  446. .ack = ack_cobalt_irq,
  447. .end = end_piix4_master_irq,
  448. };
  449. static struct irq_chip piix4_virtual_irq_type = {
  450. .typename = "PIIX4-virtual",
  451. .shutdown = disable_8259A_irq,
  452. .enable = enable_8259A_irq,
  453. .disable = disable_8259A_irq,
  454. };
  455. /*
  456. * PIIX4-8259 master/virtual functions to handle interrupt requests
  457. * from legacy devices: floppy, parallel, serial, rtc.
  458. *
  459. * None of these get Cobalt APIC entries, neither do they have IDT
  460. * entries. These interrupts are purely virtual and distributed from
  461. * the 'master' interrupt source: CO_IRQ_8259.
  462. *
  463. * When the 8259 interrupts its handler figures out which of these
  464. * devices is interrupting and dispatches to its handler.
  465. *
  466. * CAREFUL: devices see the 'virtual' interrupt only. Thus disable/
  467. * enable_irq gets the right irq. This 'master' irq is never directly
  468. * manipulated by any driver.
  469. */
  470. static irqreturn_t piix4_master_intr(int irq, void *dev_id)
  471. {
  472. int realirq;
  473. struct irq_desc *desc;
  474. unsigned long flags;
  475. spin_lock_irqsave(&i8259A_lock, flags);
  476. /* Find out what's interrupting in the PIIX4 master 8259 */
  477. outb(0x0c, 0x20); /* OCW3 Poll command */
  478. realirq = inb(0x20);
  479. /*
  480. * Bit 7 == 0 means invalid/spurious
  481. */
  482. if (unlikely(!(realirq & 0x80)))
  483. goto out_unlock;
  484. realirq &= 7;
  485. if (unlikely(realirq == 2)) {
  486. outb(0x0c, 0xa0);
  487. realirq = inb(0xa0);
  488. if (unlikely(!(realirq & 0x80)))
  489. goto out_unlock;
  490. realirq = (realirq & 7) + 8;
  491. }
  492. /* mask and ack interrupt */
  493. cached_irq_mask |= 1 << realirq;
  494. if (unlikely(realirq > 7)) {
  495. inb(0xa1);
  496. outb(cached_slave_mask, 0xa1);
  497. outb(0x60 + (realirq & 7), 0xa0);
  498. outb(0x60 + 2, 0x20);
  499. } else {
  500. inb(0x21);
  501. outb(cached_master_mask, 0x21);
  502. outb(0x60 + realirq, 0x20);
  503. }
  504. spin_unlock_irqrestore(&i8259A_lock, flags);
  505. desc = irq_to_desc(realirq);
  506. /*
  507. * handle this 'virtual interrupt' as a Cobalt one now.
  508. */
  509. kstat_incr_irqs_this_cpu(realirq, desc);
  510. if (likely(desc->action != NULL))
  511. handle_IRQ_event(realirq, desc->action);
  512. if (!(desc->status & IRQ_DISABLED))
  513. enable_8259A_irq(realirq);
  514. return IRQ_HANDLED;
  515. out_unlock:
  516. spin_unlock_irqrestore(&i8259A_lock, flags);
  517. return IRQ_NONE;
  518. }
  519. static struct irqaction master_action = {
  520. .handler = piix4_master_intr,
  521. .name = "PIIX4-8259",
  522. };
  523. static struct irqaction cascade_action = {
  524. .handler = no_action,
  525. .name = "cascade",
  526. };
  527. void init_VISWS_APIC_irqs(void)
  528. {
  529. int i;
  530. for (i = 0; i < CO_IRQ_APIC0 + CO_APIC_LAST + 1; i++) {
  531. struct irq_desc *desc = irq_to_desc(i);
  532. desc->status = IRQ_DISABLED;
  533. desc->action = 0;
  534. desc->depth = 1;
  535. if (i == 0) {
  536. desc->chip = &cobalt_irq_type;
  537. }
  538. else if (i == CO_IRQ_IDE0) {
  539. desc->chip = &cobalt_irq_type;
  540. }
  541. else if (i == CO_IRQ_IDE1) {
  542. desc->chip = &cobalt_irq_type;
  543. }
  544. else if (i == CO_IRQ_8259) {
  545. desc->chip = &piix4_master_irq_type;
  546. }
  547. else if (i < CO_IRQ_APIC0) {
  548. desc->chip = &piix4_virtual_irq_type;
  549. }
  550. else if (IS_CO_APIC(i)) {
  551. desc->chip = &cobalt_irq_type;
  552. }
  553. }
  554. setup_irq(CO_IRQ_8259, &master_action);
  555. setup_irq(2, &cascade_action);
  556. }