via.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633
  1. /*
  2. * 6522 Versatile Interface Adapter (VIA)
  3. *
  4. * There are two of these on the Mac II. Some IRQs 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. * Additional data is here (the SY6522 was used in the Mac II etc):
  17. * http://www.6502.org/documents/datasheets/synertek/synertek_sy6522.pdf
  18. * http://www.6502.org/documents/datasheets/synertek/synertek_sy6522_programming_reference.pdf
  19. *
  20. * PRAM/RTC access algorithms are from the NetBSD RTC toolkit version 1.08b
  21. * by Erik Vogan and adapted to Linux by Joshua M. Thompson (funaho@jurai.org)
  22. *
  23. */
  24. #include <linux/types.h>
  25. #include <linux/kernel.h>
  26. #include <linux/mm.h>
  27. #include <linux/delay.h>
  28. #include <linux/init.h>
  29. #include <linux/module.h>
  30. #include <linux/irq.h>
  31. #include <asm/bootinfo.h>
  32. #include <asm/macintosh.h>
  33. #include <asm/macints.h>
  34. #include <asm/mac_via.h>
  35. #include <asm/mac_psc.h>
  36. #include <asm/mac_oss.h>
  37. volatile __u8 *via1, *via2;
  38. int rbv_present;
  39. int via_alt_mapping;
  40. EXPORT_SYMBOL(via_alt_mapping);
  41. static __u8 rbv_clear;
  42. /*
  43. * Globals for accessing the VIA chip registers without having to
  44. * check if we're hitting a real VIA or an RBV. Normally you could
  45. * just hit the combined register (ie, vIER|rIER) but that seems to
  46. * break on AV Macs...probably because they actually decode more than
  47. * eight address bits. Why can't Apple engineers at least be
  48. * _consistently_ lazy? - 1999-05-21 (jmt)
  49. */
  50. static int gIER,gIFR,gBufA,gBufB;
  51. /*
  52. * Timer defs.
  53. */
  54. #define TICK_SIZE 10000
  55. #define MAC_CLOCK_TICK (783300/HZ) /* ticks per HZ */
  56. #define MAC_CLOCK_LOW (MAC_CLOCK_TICK&0xFF)
  57. #define MAC_CLOCK_HIGH (MAC_CLOCK_TICK>>8)
  58. /* To disable a NuBus slot on Quadras we make that slot IRQ line an output set
  59. * high. On RBV we just use the slot interrupt enable register. On Macs with
  60. * genuine VIA chips we must use nubus_disabled to keep track of disabled slot
  61. * interrupts. When any slot IRQ is disabled we mask the (edge triggered) CA1
  62. * or "SLOTS" interrupt. When no slot is disabled, we unmask the CA1 interrupt.
  63. * So, on genuine VIAs, having more than one NuBus IRQ can mean trouble,
  64. * because closing one of those drivers can mask all of the NuBus interrupts.
  65. * Also, since we can't mask the unregistered slot IRQs on genuine VIAs, it's
  66. * possible to get interrupts from cards that MacOS or the ROM has configured
  67. * but we have not. FWIW, "Designing Cards and Drivers for Macintosh II and
  68. * Macintosh SE", page 9-8, says, a slot IRQ with no driver would crash MacOS.
  69. */
  70. static u8 nubus_disabled;
  71. void via_debug_dump(void);
  72. void via_irq_enable(int irq);
  73. void via_irq_disable(int irq);
  74. void via_irq_clear(int irq);
  75. /*
  76. * Initialize the VIAs
  77. *
  78. * First we figure out where they actually _are_ as well as what type of
  79. * VIA we have for VIA2 (it could be a real VIA or an RBV or even an OSS.)
  80. * Then we pretty much clear them out and disable all IRQ sources.
  81. *
  82. * Note: the OSS is actually "detected" here and not in oss_init(). It just
  83. * seems more logical to do it here since via_init() needs to know
  84. * these things anyways.
  85. */
  86. void __init via_init(void)
  87. {
  88. switch(macintosh_config->via_type) {
  89. /* IIci, IIsi, IIvx, IIvi (P6xx), LC series */
  90. case MAC_VIA_IIci:
  91. via1 = (void *) VIA1_BASE;
  92. if (macintosh_config->ident == MAC_MODEL_IIFX) {
  93. via2 = NULL;
  94. rbv_present = 0;
  95. oss_present = 1;
  96. } else {
  97. via2 = (void *) RBV_BASE;
  98. rbv_present = 1;
  99. oss_present = 0;
  100. }
  101. if (macintosh_config->ident == MAC_MODEL_LCIII) {
  102. rbv_clear = 0x00;
  103. } else {
  104. /* on most RBVs (& unlike the VIAs), you */
  105. /* need to set bit 7 when you write to IFR */
  106. /* in order for your clear to occur. */
  107. rbv_clear = 0x80;
  108. }
  109. gIER = rIER;
  110. gIFR = rIFR;
  111. gBufA = rSIFR;
  112. gBufB = rBufB;
  113. break;
  114. /* Quadra and early MacIIs agree on the VIA locations */
  115. case MAC_VIA_QUADRA:
  116. case MAC_VIA_II:
  117. via1 = (void *) VIA1_BASE;
  118. via2 = (void *) VIA2_BASE;
  119. rbv_present = 0;
  120. oss_present = 0;
  121. rbv_clear = 0x00;
  122. gIER = vIER;
  123. gIFR = vIFR;
  124. gBufA = vBufA;
  125. gBufB = vBufB;
  126. break;
  127. default:
  128. panic("UNKNOWN VIA TYPE");
  129. }
  130. printk(KERN_INFO "VIA1 at %p is a 6522 or clone\n", via1);
  131. printk(KERN_INFO "VIA2 at %p is ", via2);
  132. if (rbv_present) {
  133. printk("an RBV\n");
  134. } else if (oss_present) {
  135. printk("an OSS\n");
  136. } else {
  137. printk("a 6522 or clone\n");
  138. }
  139. #ifdef DEBUG_VIA
  140. via_debug_dump();
  141. #endif
  142. /*
  143. * Shut down all IRQ sources, reset the timers, and
  144. * kill the timer latch on VIA1.
  145. */
  146. via1[vIER] = 0x7F;
  147. via1[vIFR] = 0x7F;
  148. via1[vT1LL] = 0;
  149. via1[vT1LH] = 0;
  150. via1[vT1CL] = 0;
  151. via1[vT1CH] = 0;
  152. via1[vT2CL] = 0;
  153. via1[vT2CH] = 0;
  154. via1[vACR] &= ~0xC0; /* setup T1 timer with no PB7 output */
  155. via1[vACR] &= ~0x03; /* disable port A & B latches */
  156. /*
  157. * SE/30: disable video IRQ
  158. * XXX: testing for SE/30 VBL
  159. */
  160. if (macintosh_config->ident == MAC_MODEL_SE30) {
  161. via1[vDirB] |= 0x40;
  162. via1[vBufB] |= 0x40;
  163. }
  164. /*
  165. * Set the RTC bits to a known state: all lines to outputs and
  166. * RTC disabled (yes that's 0 to enable and 1 to disable).
  167. */
  168. via1[vDirB] |= (VIA1B_vRTCEnb | VIA1B_vRTCClk | VIA1B_vRTCData);
  169. via1[vBufB] |= (VIA1B_vRTCEnb | VIA1B_vRTCClk);
  170. /* Everything below this point is VIA2/RBV only... */
  171. if (oss_present)
  172. return;
  173. /* Some machines support an alternate IRQ mapping that spreads */
  174. /* Ethernet and Sound out to their own autolevel IRQs and moves */
  175. /* VIA1 to level 6. A/UX uses this mapping and we do too. Note */
  176. /* that the IIfx emulates this alternate mapping using the OSS. */
  177. via_alt_mapping = 0;
  178. if (macintosh_config->via_type == MAC_VIA_QUADRA)
  179. switch (macintosh_config->ident) {
  180. case MAC_MODEL_C660:
  181. case MAC_MODEL_Q840:
  182. /* not applicable */
  183. break;
  184. case MAC_MODEL_P588:
  185. case MAC_MODEL_TV:
  186. case MAC_MODEL_PB140:
  187. case MAC_MODEL_PB145:
  188. case MAC_MODEL_PB160:
  189. case MAC_MODEL_PB165:
  190. case MAC_MODEL_PB165C:
  191. case MAC_MODEL_PB170:
  192. case MAC_MODEL_PB180:
  193. case MAC_MODEL_PB180C:
  194. case MAC_MODEL_PB190:
  195. case MAC_MODEL_PB520:
  196. /* not yet tested */
  197. break;
  198. default:
  199. via_alt_mapping = 1;
  200. via1[vDirB] |= 0x40;
  201. via1[vBufB] &= ~0x40;
  202. break;
  203. }
  204. /*
  205. * Now initialize VIA2. For RBV we just kill all interrupts;
  206. * for a regular VIA we also reset the timers and stuff.
  207. */
  208. via2[gIER] = 0x7F;
  209. via2[gIFR] = 0x7F | rbv_clear;
  210. if (!rbv_present) {
  211. via2[vT1LL] = 0;
  212. via2[vT1LH] = 0;
  213. via2[vT1CL] = 0;
  214. via2[vT1CH] = 0;
  215. via2[vT2CL] = 0;
  216. via2[vT2CH] = 0;
  217. via2[vACR] &= ~0xC0; /* setup T1 timer with no PB7 output */
  218. via2[vACR] &= ~0x03; /* disable port A & B latches */
  219. }
  220. /*
  221. * Set vPCR for control line interrupts (but not on RBV)
  222. */
  223. if (!rbv_present) {
  224. /* For all VIA types, CA1 (SLOTS IRQ) and CB1 (ASC IRQ)
  225. * are made negative edge triggered here.
  226. */
  227. if (macintosh_config->scsi_type == MAC_SCSI_OLD) {
  228. /* CB2 (IRQ) indep. input, positive edge */
  229. /* CA2 (DRQ) indep. input, positive edge */
  230. via2[vPCR] = 0x66;
  231. } else {
  232. /* CB2 (IRQ) indep. input, negative edge */
  233. /* CA2 (DRQ) indep. input, negative edge */
  234. via2[vPCR] = 0x22;
  235. }
  236. }
  237. }
  238. /*
  239. * Start the 100 Hz clock
  240. */
  241. void __init via_init_clock(irq_handler_t func)
  242. {
  243. via1[vACR] |= 0x40;
  244. via1[vT1LL] = MAC_CLOCK_LOW;
  245. via1[vT1LH] = MAC_CLOCK_HIGH;
  246. via1[vT1CL] = MAC_CLOCK_LOW;
  247. via1[vT1CH] = MAC_CLOCK_HIGH;
  248. if (request_irq(IRQ_MAC_TIMER_1, func, 0, "timer", func))
  249. pr_err("Couldn't register %s interrupt\n", "timer");
  250. }
  251. /*
  252. * Debugging dump, used in various places to see what's going on.
  253. */
  254. void via_debug_dump(void)
  255. {
  256. printk(KERN_DEBUG "VIA1: DDRA = 0x%02X DDRB = 0x%02X ACR = 0x%02X\n",
  257. (uint) via1[vDirA], (uint) via1[vDirB], (uint) via1[vACR]);
  258. printk(KERN_DEBUG " PCR = 0x%02X IFR = 0x%02X IER = 0x%02X\n",
  259. (uint) via1[vPCR], (uint) via1[vIFR], (uint) via1[vIER]);
  260. if (oss_present) {
  261. printk(KERN_DEBUG "VIA2: <OSS>\n");
  262. } else if (rbv_present) {
  263. printk(KERN_DEBUG "VIA2: IFR = 0x%02X IER = 0x%02X\n",
  264. (uint) via2[rIFR], (uint) via2[rIER]);
  265. printk(KERN_DEBUG " SIFR = 0x%02X SIER = 0x%02X\n",
  266. (uint) via2[rSIFR], (uint) via2[rSIER]);
  267. } else {
  268. printk(KERN_DEBUG "VIA2: DDRA = 0x%02X DDRB = 0x%02X ACR = 0x%02X\n",
  269. (uint) via2[vDirA], (uint) via2[vDirB],
  270. (uint) via2[vACR]);
  271. printk(KERN_DEBUG " PCR = 0x%02X IFR = 0x%02X IER = 0x%02X\n",
  272. (uint) via2[vPCR],
  273. (uint) via2[vIFR], (uint) via2[vIER]);
  274. }
  275. }
  276. /*
  277. * This is always executed with interrupts disabled.
  278. *
  279. * TBI: get time offset between scheduling timer ticks
  280. */
  281. unsigned long mac_gettimeoffset (void)
  282. {
  283. unsigned long ticks, offset = 0;
  284. /* read VIA1 timer 2 current value */
  285. ticks = via1[vT1CL] | (via1[vT1CH] << 8);
  286. /* The probability of underflow is less than 2% */
  287. if (ticks > MAC_CLOCK_TICK - MAC_CLOCK_TICK / 50)
  288. /* Check for pending timer interrupt in VIA1 IFR */
  289. if (via1[vIFR] & 0x40) offset = TICK_SIZE;
  290. ticks = MAC_CLOCK_TICK - ticks;
  291. ticks = ticks * 10000L / MAC_CLOCK_TICK;
  292. return ticks + offset;
  293. }
  294. /*
  295. * Flush the L2 cache on Macs that have it by flipping
  296. * the system into 24-bit mode for an instant.
  297. */
  298. void via_flush_cache(void)
  299. {
  300. via2[gBufB] &= ~VIA2B_vMode32;
  301. via2[gBufB] |= VIA2B_vMode32;
  302. }
  303. /*
  304. * Return the status of the L2 cache on a IIci
  305. */
  306. int via_get_cache_disable(void)
  307. {
  308. /* Safeguard against being called accidentally */
  309. if (!via2) {
  310. printk(KERN_ERR "via_get_cache_disable called on a non-VIA machine!\n");
  311. return 1;
  312. }
  313. return (int) via2[gBufB] & VIA2B_vCDis;
  314. }
  315. /*
  316. * Initialize VIA2 for Nubus access
  317. */
  318. void __init via_nubus_init(void)
  319. {
  320. /* unlock nubus transactions */
  321. if ((macintosh_config->adb_type != MAC_ADB_PB1) &&
  322. (macintosh_config->adb_type != MAC_ADB_PB2)) {
  323. /* set the line to be an output on non-RBV machines */
  324. if (!rbv_present)
  325. via2[vDirB] |= 0x02;
  326. /* this seems to be an ADB bit on PMU machines */
  327. /* according to MkLinux. -- jmt */
  328. via2[gBufB] |= 0x02;
  329. }
  330. /* Disable all the slot interrupts (where possible). */
  331. switch (macintosh_config->via_type) {
  332. case MAC_VIA_II:
  333. /* Just make the port A lines inputs. */
  334. switch(macintosh_config->ident) {
  335. case MAC_MODEL_II:
  336. case MAC_MODEL_IIX:
  337. case MAC_MODEL_IICX:
  338. case MAC_MODEL_SE30:
  339. /* The top two bits are RAM size outputs. */
  340. via2[vDirA] &= 0xC0;
  341. break;
  342. default:
  343. via2[vDirA] &= 0x80;
  344. }
  345. break;
  346. case MAC_VIA_IIci:
  347. /* RBV. Disable all the slot interrupts. SIER works like IER. */
  348. via2[rSIER] = 0x7F;
  349. break;
  350. case MAC_VIA_QUADRA:
  351. /* Disable the inactive slot interrupts by making those lines outputs. */
  352. if ((macintosh_config->adb_type != MAC_ADB_PB1) &&
  353. (macintosh_config->adb_type != MAC_ADB_PB2)) {
  354. via2[vBufA] |= 0x7F;
  355. via2[vDirA] |= 0x7F;
  356. }
  357. break;
  358. }
  359. }
  360. /*
  361. * The generic VIA interrupt routines (shamelessly stolen from Alan Cox's
  362. * via6522.c :-), disable/pending masks added.
  363. */
  364. void via1_irq(unsigned int irq, struct irq_desc *desc)
  365. {
  366. int irq_num;
  367. unsigned char irq_bit, events;
  368. events = via1[vIFR] & via1[vIER] & 0x7F;
  369. if (!events)
  370. return;
  371. irq_num = VIA1_SOURCE_BASE;
  372. irq_bit = 1;
  373. do {
  374. if (events & irq_bit) {
  375. via1[vIFR] = irq_bit;
  376. generic_handle_irq(irq_num);
  377. }
  378. ++irq_num;
  379. irq_bit <<= 1;
  380. } while (events >= irq_bit);
  381. }
  382. static void via2_irq(unsigned int irq, struct irq_desc *desc)
  383. {
  384. int irq_num;
  385. unsigned char irq_bit, events;
  386. events = via2[gIFR] & via2[gIER] & 0x7F;
  387. if (!events)
  388. return;
  389. irq_num = VIA2_SOURCE_BASE;
  390. irq_bit = 1;
  391. do {
  392. if (events & irq_bit) {
  393. via2[gIFR] = irq_bit | rbv_clear;
  394. generic_handle_irq(irq_num);
  395. }
  396. ++irq_num;
  397. irq_bit <<= 1;
  398. } while (events >= irq_bit);
  399. }
  400. /*
  401. * Dispatch Nubus interrupts. We are called as a secondary dispatch by the
  402. * VIA2 dispatcher as a fast interrupt handler.
  403. */
  404. void via_nubus_irq(unsigned int irq, struct irq_desc *desc)
  405. {
  406. int slot_irq;
  407. unsigned char slot_bit, events;
  408. events = ~via2[gBufA] & 0x7F;
  409. if (rbv_present)
  410. events &= via2[rSIER];
  411. else
  412. events &= ~via2[vDirA];
  413. if (!events)
  414. return;
  415. do {
  416. slot_irq = IRQ_NUBUS_F;
  417. slot_bit = 0x40;
  418. do {
  419. if (events & slot_bit) {
  420. events &= ~slot_bit;
  421. generic_handle_irq(slot_irq);
  422. }
  423. --slot_irq;
  424. slot_bit >>= 1;
  425. } while (events);
  426. /* clear the CA1 interrupt and make certain there's no more. */
  427. via2[gIFR] = 0x02 | rbv_clear;
  428. events = ~via2[gBufA] & 0x7F;
  429. if (rbv_present)
  430. events &= via2[rSIER];
  431. else
  432. events &= ~via2[vDirA];
  433. } while (events);
  434. }
  435. /*
  436. * Register the interrupt dispatchers for VIA or RBV machines only.
  437. */
  438. void __init via_register_interrupts(void)
  439. {
  440. if (via_alt_mapping) {
  441. /* software interrupt */
  442. irq_set_chained_handler(IRQ_AUTO_1, via1_irq);
  443. /* via1 interrupt */
  444. irq_set_chained_handler(IRQ_AUTO_6, via1_irq);
  445. } else {
  446. irq_set_chained_handler(IRQ_AUTO_1, via1_irq);
  447. }
  448. irq_set_chained_handler(IRQ_AUTO_2, via2_irq);
  449. irq_set_chained_handler(IRQ_MAC_NUBUS, via_nubus_irq);
  450. }
  451. void via_irq_enable(int irq) {
  452. int irq_src = IRQ_SRC(irq);
  453. int irq_idx = IRQ_IDX(irq);
  454. #ifdef DEBUG_IRQUSE
  455. printk(KERN_DEBUG "via_irq_enable(%d)\n", irq);
  456. #endif
  457. if (irq_src == 1) {
  458. via1[vIER] = IER_SET_BIT(irq_idx);
  459. } else if (irq_src == 2) {
  460. if (irq != IRQ_MAC_NUBUS || nubus_disabled == 0)
  461. via2[gIER] = IER_SET_BIT(irq_idx);
  462. } else if (irq_src == 7) {
  463. switch (macintosh_config->via_type) {
  464. case MAC_VIA_II:
  465. nubus_disabled &= ~(1 << irq_idx);
  466. /* Enable the CA1 interrupt when no slot is disabled. */
  467. if (!nubus_disabled)
  468. via2[gIER] = IER_SET_BIT(1);
  469. break;
  470. case MAC_VIA_IIci:
  471. /* On RBV, enable the slot interrupt.
  472. * SIER works like IER.
  473. */
  474. via2[rSIER] = IER_SET_BIT(irq_idx);
  475. break;
  476. case MAC_VIA_QUADRA:
  477. /* Make the port A line an input to enable the slot irq.
  478. * But not on PowerBooks, that's ADB.
  479. */
  480. if ((macintosh_config->adb_type != MAC_ADB_PB1) &&
  481. (macintosh_config->adb_type != MAC_ADB_PB2))
  482. via2[vDirA] &= ~(1 << irq_idx);
  483. break;
  484. }
  485. }
  486. }
  487. void via_irq_disable(int irq) {
  488. int irq_src = IRQ_SRC(irq);
  489. int irq_idx = IRQ_IDX(irq);
  490. #ifdef DEBUG_IRQUSE
  491. printk(KERN_DEBUG "via_irq_disable(%d)\n", irq);
  492. #endif
  493. if (irq_src == 1) {
  494. via1[vIER] = IER_CLR_BIT(irq_idx);
  495. } else if (irq_src == 2) {
  496. via2[gIER] = IER_CLR_BIT(irq_idx);
  497. } else if (irq_src == 7) {
  498. switch (macintosh_config->via_type) {
  499. case MAC_VIA_II:
  500. nubus_disabled |= 1 << irq_idx;
  501. if (nubus_disabled)
  502. via2[gIER] = IER_CLR_BIT(1);
  503. break;
  504. case MAC_VIA_IIci:
  505. via2[rSIER] = IER_CLR_BIT(irq_idx);
  506. break;
  507. case MAC_VIA_QUADRA:
  508. if ((macintosh_config->adb_type != MAC_ADB_PB1) &&
  509. (macintosh_config->adb_type != MAC_ADB_PB2))
  510. via2[vDirA] |= 1 << irq_idx;
  511. break;
  512. }
  513. }
  514. }
  515. void via_irq_clear(int irq) {
  516. int irq_src = IRQ_SRC(irq);
  517. int irq_idx = IRQ_IDX(irq);
  518. int irq_bit = 1 << irq_idx;
  519. if (irq_src == 1) {
  520. via1[vIFR] = irq_bit;
  521. } else if (irq_src == 2) {
  522. via2[gIFR] = irq_bit | rbv_clear;
  523. } else if (irq_src == 7) {
  524. /* FIXME: There is no way to clear an individual nubus slot
  525. * IRQ flag, other than getting the device to do it.
  526. */
  527. }
  528. }
  529. /*
  530. * Returns nonzero if an interrupt is pending on the given
  531. * VIA/IRQ combination.
  532. */
  533. int via_irq_pending(int irq)
  534. {
  535. int irq_src = IRQ_SRC(irq);
  536. int irq_idx = IRQ_IDX(irq);
  537. int irq_bit = 1 << irq_idx;
  538. if (irq_src == 1) {
  539. return via1[vIFR] & irq_bit;
  540. } else if (irq_src == 2) {
  541. return via2[gIFR] & irq_bit;
  542. } else if (irq_src == 7) {
  543. /* Always 0 for MAC_VIA_QUADRA if the slot irq is disabled. */
  544. return ~via2[gBufA] & irq_bit;
  545. }
  546. return 0;
  547. }
  548. void via1_set_head(int head)
  549. {
  550. if (head == 0)
  551. via1[vBufA] &= ~VIA1A_vHeadSel;
  552. else
  553. via1[vBufA] |= VIA1A_vHeadSel;
  554. }
  555. EXPORT_SYMBOL(via1_set_head);