via.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619
  1. /*
  2. * 6522 Versatile Interface Adapter (VIA)
  3. *
  4. * There are two of these on the Mac II. Some IRQ's are vectored
  5. * via them as are assorted bits and bobs - eg RTC, ADB.
  6. *
  7. * CSA: Motorola seems to have removed documentation on the 6522 from
  8. * their web site; try
  9. * http://nerini.drf.com/vectrex/other/text/chips/6522/
  10. * http://www.zymurgy.net/classic/vic20/vicdet1.htm
  11. * and
  12. * http://193.23.168.87/mikro_laborversuche/via_iobaustein/via6522_1.html
  13. * for info. A full-text web search on 6522 AND VIA will probably also
  14. * net some usefulness. <cananian@alumni.princeton.edu> 20apr1999
  15. *
  16. * PRAM/RTC access algorithms are from the NetBSD RTC toolkit version 1.08b
  17. * by Erik Vogan and adapted to Linux by Joshua M. Thompson (funaho@jurai.org)
  18. *
  19. */
  20. #include <linux/types.h>
  21. #include <linux/kernel.h>
  22. #include <linux/mm.h>
  23. #include <linux/delay.h>
  24. #include <linux/init.h>
  25. #include <linux/ide.h>
  26. #include <asm/traps.h>
  27. #include <asm/bootinfo.h>
  28. #include <asm/macintosh.h>
  29. #include <asm/macints.h>
  30. #include <asm/machw.h>
  31. #include <asm/mac_via.h>
  32. #include <asm/mac_psc.h>
  33. volatile __u8 *via1, *via2;
  34. #if 0
  35. /* See note in mac_via.h about how this is possibly not useful */
  36. volatile long *via_memory_bogon=(long *)&via_memory_bogon;
  37. #endif
  38. int rbv_present,via_alt_mapping;
  39. __u8 rbv_clear;
  40. /*
  41. * Globals for accessing the VIA chip registers without having to
  42. * check if we're hitting a real VIA or an RBV. Normally you could
  43. * just hit the combined register (ie, vIER|rIER) but that seems to
  44. * break on AV Macs...probably because they actually decode more than
  45. * eight address bits. Why can't Apple engineers at least be
  46. * _consistently_ lazy? - 1999-05-21 (jmt)
  47. */
  48. static int gIER,gIFR,gBufA,gBufB;
  49. /*
  50. * Timer defs.
  51. */
  52. #define TICK_SIZE 10000
  53. #define MAC_CLOCK_TICK (783300/HZ) /* ticks per HZ */
  54. #define MAC_CLOCK_LOW (MAC_CLOCK_TICK&0xFF)
  55. #define MAC_CLOCK_HIGH (MAC_CLOCK_TICK>>8)
  56. static int nubus_active;
  57. void via_debug_dump(void);
  58. irqreturn_t via1_irq(int, void *, struct pt_regs *);
  59. irqreturn_t via2_irq(int, void *, struct pt_regs *);
  60. irqreturn_t via_nubus_irq(int, void *, struct pt_regs *);
  61. void via_irq_enable(int irq);
  62. void via_irq_disable(int irq);
  63. void via_irq_clear(int irq);
  64. extern irqreturn_t mac_bang(int, void *, struct pt_regs *);
  65. extern irqreturn_t mac_scc_dispatch(int, void *, struct pt_regs *);
  66. extern int oss_present;
  67. /*
  68. * Initialize the VIAs
  69. *
  70. * First we figure out where they actually _are_ as well as what type of
  71. * VIA we have for VIA2 (it could be a real VIA or an RBV or even an OSS.)
  72. * Then we pretty much clear them out and disable all IRQ sources.
  73. *
  74. * Note: the OSS is actually "detected" here and not in oss_init(). It just
  75. * seems more logical to do it here since via_init() needs to know
  76. * these things anyways.
  77. */
  78. void __init via_init(void)
  79. {
  80. switch(macintosh_config->via_type) {
  81. /* IIci, IIsi, IIvx, IIvi (P6xx), LC series */
  82. case MAC_VIA_IIci:
  83. via1 = (void *) VIA1_BASE;
  84. if (macintosh_config->ident == MAC_MODEL_IIFX) {
  85. via2 = NULL;
  86. rbv_present = 0;
  87. oss_present = 1;
  88. } else {
  89. via2 = (void *) RBV_BASE;
  90. rbv_present = 1;
  91. oss_present = 0;
  92. }
  93. if (macintosh_config->ident == MAC_MODEL_LCIII) {
  94. rbv_clear = 0x00;
  95. } else {
  96. /* on most RBVs (& unlike the VIAs), you */
  97. /* need to set bit 7 when you write to IFR */
  98. /* in order for your clear to occur. */
  99. rbv_clear = 0x80;
  100. }
  101. gIER = rIER;
  102. gIFR = rIFR;
  103. gBufA = rSIFR;
  104. gBufB = rBufB;
  105. break;
  106. /* Quadra and early MacIIs agree on the VIA locations */
  107. case MAC_VIA_QUADRA:
  108. case MAC_VIA_II:
  109. via1 = (void *) VIA1_BASE;
  110. via2 = (void *) VIA2_BASE;
  111. rbv_present = 0;
  112. oss_present = 0;
  113. rbv_clear = 0x00;
  114. gIER = vIER;
  115. gIFR = vIFR;
  116. gBufA = vBufA;
  117. gBufB = vBufB;
  118. break;
  119. default:
  120. panic("UNKNOWN VIA TYPE");
  121. }
  122. printk(KERN_INFO "VIA1 at %p is a 6522 or clone\n", via1);
  123. printk(KERN_INFO "VIA2 at %p is ", via2);
  124. if (rbv_present) {
  125. printk(KERN_INFO "an RBV\n");
  126. } else if (oss_present) {
  127. printk(KERN_INFO "an OSS\n");
  128. } else {
  129. printk(KERN_INFO "a 6522 or clone\n");
  130. }
  131. #ifdef DEBUG_VIA
  132. via_debug_dump();
  133. #endif
  134. /*
  135. * Shut down all IRQ sources, reset the timers, and
  136. * kill the timer latch on VIA1.
  137. */
  138. via1[vIER] = 0x7F;
  139. via1[vIFR] = 0x7F;
  140. via1[vT1LL] = 0;
  141. via1[vT1LH] = 0;
  142. via1[vT1CL] = 0;
  143. via1[vT1CH] = 0;
  144. via1[vT2CL] = 0;
  145. via1[vT2CH] = 0;
  146. via1[vACR] &= 0x3F;
  147. /*
  148. * SE/30: disable video IRQ
  149. * XXX: testing for SE/30 VBL
  150. */
  151. if (macintosh_config->ident == MAC_MODEL_SE30) {
  152. via1[vDirB] |= 0x40;
  153. via1[vBufB] |= 0x40;
  154. }
  155. /*
  156. * Set the RTC bits to a known state: all lines to outputs and
  157. * RTC disabled (yes that's 0 to enable and 1 to disable).
  158. */
  159. via1[vDirB] |= (VIA1B_vRTCEnb | VIA1B_vRTCClk | VIA1B_vRTCData);
  160. via1[vBufB] |= (VIA1B_vRTCEnb | VIA1B_vRTCClk);
  161. /* Everything below this point is VIA2/RBV only... */
  162. if (oss_present) return;
  163. #if 1
  164. /* Some machines support an alternate IRQ mapping that spreads */
  165. /* Ethernet and Sound out to their own autolevel IRQs and moves */
  166. /* VIA1 to level 6. A/UX uses this mapping and we do too. Note */
  167. /* that the IIfx emulates this alternate mapping using the OSS. */
  168. switch(macintosh_config->ident) {
  169. case MAC_MODEL_C610:
  170. case MAC_MODEL_Q610:
  171. case MAC_MODEL_C650:
  172. case MAC_MODEL_Q650:
  173. case MAC_MODEL_Q700:
  174. case MAC_MODEL_Q800:
  175. case MAC_MODEL_Q900:
  176. case MAC_MODEL_Q950:
  177. via_alt_mapping = 1;
  178. via1[vDirB] |= 0x40;
  179. via1[vBufB] &= ~0x40;
  180. break;
  181. default:
  182. via_alt_mapping = 0;
  183. break;
  184. }
  185. #else
  186. /* The alernate IRQ mapping seems to just not work. Anyone with a */
  187. /* supported machine is welcome to take a stab at fixing it. It */
  188. /* _should_ work on the following Quadras: 610,650,700,800,900,950 */
  189. /* - 1999-06-12 (jmt) */
  190. via_alt_mapping = 0;
  191. #endif
  192. /*
  193. * Now initialize VIA2. For RBV we just kill all interrupts;
  194. * for a regular VIA we also reset the timers and stuff.
  195. */
  196. via2[gIER] = 0x7F;
  197. via2[gIFR] = 0x7F | rbv_clear;
  198. if (!rbv_present) {
  199. via2[vT1LL] = 0;
  200. via2[vT1LH] = 0;
  201. via2[vT1CL] = 0;
  202. via2[vT1CH] = 0;
  203. via2[vT2CL] = 0;
  204. via2[vT2CH] = 0;
  205. via2[vACR] &= 0x3F;
  206. }
  207. }
  208. /*
  209. * Start the 100 Hz clock
  210. */
  211. void __init via_init_clock(irqreturn_t (*func)(int, void *, struct pt_regs *))
  212. {
  213. via1[vACR] |= 0x40;
  214. via1[vT1LL] = MAC_CLOCK_LOW;
  215. via1[vT1LH] = MAC_CLOCK_HIGH;
  216. via1[vT1CL] = MAC_CLOCK_LOW;
  217. via1[vT1CH] = MAC_CLOCK_HIGH;
  218. request_irq(IRQ_MAC_TIMER_1, func, IRQ_FLG_LOCK, "timer", func);
  219. }
  220. /*
  221. * Register the interrupt dispatchers for VIA or RBV machines only.
  222. */
  223. void __init via_register_interrupts(void)
  224. {
  225. if (via_alt_mapping) {
  226. cpu_request_irq(IRQ_AUTO_1, via1_irq,
  227. IRQ_FLG_LOCK|IRQ_FLG_FAST, "software",
  228. (void *) via1);
  229. cpu_request_irq(IRQ_AUTO_6, via1_irq,
  230. IRQ_FLG_LOCK|IRQ_FLG_FAST, "via1",
  231. (void *) via1);
  232. } else {
  233. cpu_request_irq(IRQ_AUTO_1, via1_irq,
  234. IRQ_FLG_LOCK|IRQ_FLG_FAST, "via1",
  235. (void *) via1);
  236. #if 0 /* interferes with serial on some machines */
  237. if (!psc_present) {
  238. cpu_request_irq(IRQ_AUTO_6, mac_bang, IRQ_FLG_LOCK,
  239. "Off Switch", mac_bang);
  240. }
  241. #endif
  242. }
  243. cpu_request_irq(IRQ_AUTO_2, via2_irq, IRQ_FLG_LOCK|IRQ_FLG_FAST,
  244. "via2", (void *) via2);
  245. if (!psc_present) {
  246. cpu_request_irq(IRQ_AUTO_4, mac_scc_dispatch, IRQ_FLG_LOCK,
  247. "scc", mac_scc_dispatch);
  248. }
  249. request_irq(IRQ_MAC_NUBUS, via_nubus_irq, IRQ_FLG_LOCK|IRQ_FLG_FAST,
  250. "nubus", (void *) via2);
  251. }
  252. /*
  253. * Debugging dump, used in various places to see what's going on.
  254. */
  255. void via_debug_dump(void)
  256. {
  257. printk(KERN_DEBUG "VIA1: DDRA = 0x%02X DDRB = 0x%02X ACR = 0x%02X\n",
  258. (uint) via1[vDirA], (uint) via1[vDirB], (uint) via1[vACR]);
  259. printk(KERN_DEBUG " PCR = 0x%02X IFR = 0x%02X IER = 0x%02X\n",
  260. (uint) via1[vPCR], (uint) via1[vIFR], (uint) via1[vIER]);
  261. if (oss_present) {
  262. printk(KERN_DEBUG "VIA2: <OSS>\n");
  263. } else if (rbv_present) {
  264. printk(KERN_DEBUG "VIA2: IFR = 0x%02X IER = 0x%02X\n",
  265. (uint) via2[rIFR], (uint) via2[rIER]);
  266. printk(KERN_DEBUG " SIFR = 0x%02X SIER = 0x%02X\n",
  267. (uint) via2[rSIFR], (uint) via2[rSIER]);
  268. } else {
  269. printk(KERN_DEBUG "VIA2: DDRA = 0x%02X DDRB = 0x%02X ACR = 0x%02X\n",
  270. (uint) via2[vDirA], (uint) via2[vDirB],
  271. (uint) via2[vACR]);
  272. printk(KERN_DEBUG " PCR = 0x%02X IFR = 0x%02X IER = 0x%02X\n",
  273. (uint) via2[vPCR],
  274. (uint) via2[vIFR], (uint) via2[vIER]);
  275. }
  276. }
  277. /*
  278. * This is always executed with interrupts disabled.
  279. *
  280. * TBI: get time offset between scheduling timer ticks
  281. */
  282. unsigned long mac_gettimeoffset (void)
  283. {
  284. unsigned long ticks, offset = 0;
  285. /* read VIA1 timer 2 current value */
  286. ticks = via1[vT1CL] | (via1[vT1CH] << 8);
  287. /* The probability of underflow is less than 2% */
  288. if (ticks > MAC_CLOCK_TICK - MAC_CLOCK_TICK / 50)
  289. /* Check for pending timer interrupt in VIA1 IFR */
  290. if (via1[vIFR] & 0x40) offset = TICK_SIZE;
  291. ticks = MAC_CLOCK_TICK - ticks;
  292. ticks = ticks * 10000L / MAC_CLOCK_TICK;
  293. return ticks + offset;
  294. }
  295. /*
  296. * Flush the L2 cache on Macs that have it by flipping
  297. * the system into 24-bit mode for an instant.
  298. */
  299. void via_flush_cache(void)
  300. {
  301. via2[gBufB] &= ~VIA2B_vMode32;
  302. via2[gBufB] |= VIA2B_vMode32;
  303. }
  304. /*
  305. * Return the status of the L2 cache on a IIci
  306. */
  307. int via_get_cache_disable(void)
  308. {
  309. /* Safeguard against being called accidentally */
  310. if (!via2) {
  311. printk(KERN_ERR "via_get_cache_disable called on a non-VIA machine!\n");
  312. return 1;
  313. }
  314. return (int) via2[gBufB] & VIA2B_vCDis;
  315. }
  316. /*
  317. * Initialize VIA2 for Nubus access
  318. */
  319. void __init via_nubus_init(void)
  320. {
  321. /* don't set nubus_active = 0 here, it kills the Baboon */
  322. /* interrupt that we've already registered. */
  323. /* unlock nubus transactions */
  324. if (!rbv_present) {
  325. /* set the line to be an output on non-RBV machines */
  326. if ((macintosh_config->adb_type != MAC_ADB_PB1) &&
  327. (macintosh_config->adb_type != MAC_ADB_PB2)) {
  328. via2[vDirB] |= 0x02;
  329. }
  330. }
  331. /* this seems to be an ADB bit on PMU machines */
  332. /* according to MkLinux. -- jmt */
  333. if ((macintosh_config->adb_type != MAC_ADB_PB1) &&
  334. (macintosh_config->adb_type != MAC_ADB_PB2)) {
  335. via2[gBufB] |= 0x02;
  336. }
  337. /* disable nubus slot interrupts. */
  338. if (rbv_present) {
  339. via2[rSIER] = 0x7F;
  340. via2[rSIER] = nubus_active | 0x80;
  341. } else {
  342. /* These are ADB bits on PMU */
  343. if ((macintosh_config->adb_type != MAC_ADB_PB1) &&
  344. (macintosh_config->adb_type != MAC_ADB_PB2)) {
  345. switch(macintosh_config->ident)
  346. {
  347. case MAC_MODEL_II:
  348. case MAC_MODEL_IIX:
  349. case MAC_MODEL_IICX:
  350. case MAC_MODEL_SE30:
  351. via2[vBufA] |= 0x3F;
  352. via2[vDirA] = ~nubus_active | 0xc0;
  353. break;
  354. default:
  355. via2[vBufA] = 0xFF;
  356. via2[vDirA] = ~nubus_active;
  357. }
  358. }
  359. }
  360. }
  361. /*
  362. * The generic VIA interrupt routines (shamelessly stolen from Alan Cox's
  363. * via6522.c :-), disable/pending masks added.
  364. *
  365. * The new interrupt architecture in macints.c takes care of a lot of the
  366. * gruntwork for us, including tallying the interrupts and calling the
  367. * handlers on the linked list. All we need to do here is basically generate
  368. * the machspec interrupt number after clearing the interrupt.
  369. */
  370. irqreturn_t via1_irq(int irq, void *dev_id, struct pt_regs *regs)
  371. {
  372. int irq_bit, i;
  373. unsigned char events, mask;
  374. mask = via1[vIER] & 0x7F;
  375. if (!(events = via1[vIFR] & mask))
  376. return IRQ_NONE;
  377. for (i = 0, irq_bit = 1 ; i < 7 ; i++, irq_bit <<= 1)
  378. if (events & irq_bit) {
  379. via1[vIER] = irq_bit;
  380. mac_do_irq_list(VIA1_SOURCE_BASE + i, regs);
  381. via1[vIFR] = irq_bit;
  382. via1[vIER] = irq_bit | 0x80;
  383. }
  384. #if 0 /* freakin' pmu is doing weird stuff */
  385. if (!oss_present) {
  386. /* This (still) seems to be necessary to get IDE
  387. working. However, if you enable VBL interrupts,
  388. you're screwed... */
  389. /* FIXME: should we check the SLOTIRQ bit before
  390. pulling this stunt? */
  391. /* No, it won't be set. that's why we're doing this. */
  392. via_irq_disable(IRQ_MAC_NUBUS);
  393. via_irq_clear(IRQ_MAC_NUBUS);
  394. mac_do_irq_list(IRQ_MAC_NUBUS, regs);
  395. via_irq_enable(IRQ_MAC_NUBUS);
  396. }
  397. #endif
  398. return IRQ_HANDLED;
  399. }
  400. irqreturn_t via2_irq(int irq, void *dev_id, struct pt_regs *regs)
  401. {
  402. int irq_bit, i;
  403. unsigned char events, mask;
  404. mask = via2[gIER] & 0x7F;
  405. if (!(events = via2[gIFR] & mask))
  406. return IRQ_NONE;
  407. for (i = 0, irq_bit = 1 ; i < 7 ; i++, irq_bit <<= 1)
  408. if (events & irq_bit) {
  409. via2[gIER] = irq_bit;
  410. mac_do_irq_list(VIA2_SOURCE_BASE + i, regs);
  411. via2[gIFR] = irq_bit | rbv_clear;
  412. via2[gIER] = irq_bit | 0x80;
  413. }
  414. return IRQ_HANDLED;
  415. }
  416. /*
  417. * Dispatch Nubus interrupts. We are called as a secondary dispatch by the
  418. * VIA2 dispatcher as a fast interrupt handler.
  419. */
  420. irqreturn_t via_nubus_irq(int irq, void *dev_id, struct pt_regs *regs)
  421. {
  422. int irq_bit, i;
  423. unsigned char events;
  424. if (!(events = ~via2[gBufA] & nubus_active))
  425. return IRQ_NONE;
  426. for (i = 0, irq_bit = 1 ; i < 7 ; i++, irq_bit <<= 1) {
  427. if (events & irq_bit) {
  428. via_irq_disable(NUBUS_SOURCE_BASE + i);
  429. mac_do_irq_list(NUBUS_SOURCE_BASE + i, regs);
  430. via_irq_enable(NUBUS_SOURCE_BASE + i);
  431. }
  432. }
  433. return IRQ_HANDLED;
  434. }
  435. void via_irq_enable(int irq) {
  436. int irq_src = IRQ_SRC(irq);
  437. int irq_idx = IRQ_IDX(irq);
  438. int irq_bit = 1 << irq_idx;
  439. #ifdef DEBUG_IRQUSE
  440. printk(KERN_DEBUG "via_irq_enable(%d)\n", irq);
  441. #endif
  442. if (irq_src == 1) {
  443. via1[vIER] = irq_bit | 0x80;
  444. } else if (irq_src == 2) {
  445. /*
  446. * Set vPCR for SCSI interrupts (but not on RBV)
  447. */
  448. if ((irq_idx == 0) && !rbv_present) {
  449. if (macintosh_config->scsi_type == MAC_SCSI_OLD) {
  450. /* CB2 (IRQ) indep. input, positive edge */
  451. /* CA2 (DRQ) indep. input, positive edge */
  452. via2[vPCR] = 0x66;
  453. } else {
  454. /* CB2 (IRQ) indep. input, negative edge */
  455. /* CA2 (DRQ) indep. input, negative edge */
  456. via2[vPCR] = 0x22;
  457. }
  458. }
  459. via2[gIER] = irq_bit | 0x80;
  460. } else if (irq_src == 7) {
  461. if (rbv_present) {
  462. /* enable the slot interrupt. SIER works like IER. */
  463. via2[rSIER] = IER_SET_BIT(irq_idx);
  464. } else {
  465. /* Make sure the bit is an input, to enable the irq */
  466. /* But not on PowerBooks, that's ADB... */
  467. if ((macintosh_config->adb_type != MAC_ADB_PB1) &&
  468. (macintosh_config->adb_type != MAC_ADB_PB2)) {
  469. switch(macintosh_config->ident)
  470. {
  471. case MAC_MODEL_II:
  472. case MAC_MODEL_IIX:
  473. case MAC_MODEL_IICX:
  474. case MAC_MODEL_SE30:
  475. via2[vDirA] &= (~irq_bit | 0xc0);
  476. break;
  477. default:
  478. via2[vDirA] &= ~irq_bit;
  479. }
  480. }
  481. }
  482. nubus_active |= irq_bit;
  483. }
  484. }
  485. void via_irq_disable(int irq) {
  486. int irq_src = IRQ_SRC(irq);
  487. int irq_idx = IRQ_IDX(irq);
  488. int irq_bit = 1 << irq_idx;
  489. #ifdef DEBUG_IRQUSE
  490. printk(KERN_DEBUG "via_irq_disable(%d)\n", irq);
  491. #endif
  492. if (irq_src == 1) {
  493. via1[vIER] = irq_bit;
  494. } else if (irq_src == 2) {
  495. via2[gIER] = irq_bit;
  496. } else if (irq_src == 7) {
  497. if (rbv_present) {
  498. /* disable the slot interrupt. SIER works like IER. */
  499. via2[rSIER] = IER_CLR_BIT(irq_idx);
  500. } else {
  501. /* disable the nubus irq by changing dir to output */
  502. /* except on PMU */
  503. if ((macintosh_config->adb_type != MAC_ADB_PB1) &&
  504. (macintosh_config->adb_type != MAC_ADB_PB2)) {
  505. via2[vDirA] |= irq_bit;
  506. }
  507. }
  508. nubus_active &= ~irq_bit;
  509. }
  510. }
  511. void via_irq_clear(int irq) {
  512. int irq_src = IRQ_SRC(irq);
  513. int irq_idx = IRQ_IDX(irq);
  514. int irq_bit = 1 << irq_idx;
  515. if (irq_src == 1) {
  516. via1[vIFR] = irq_bit;
  517. } else if (irq_src == 2) {
  518. via2[gIFR] = irq_bit | rbv_clear;
  519. } else if (irq_src == 7) {
  520. /* FIXME: hmm.. */
  521. }
  522. }
  523. /*
  524. * Returns nonzero if an interrupt is pending on the given
  525. * VIA/IRQ combination.
  526. */
  527. int via_irq_pending(int irq)
  528. {
  529. int irq_src = IRQ_SRC(irq);
  530. int irq_idx = IRQ_IDX(irq);
  531. int irq_bit = 1 << irq_idx;
  532. if (irq_src == 1) {
  533. return via1[vIFR] & irq_bit;
  534. } else if (irq_src == 2) {
  535. return via2[gIFR] & irq_bit;
  536. } else if (irq_src == 7) {
  537. return ~via2[gBufA] & irq_bit;
  538. }
  539. return 0;
  540. }