mac_via.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * 6522 Versatile Interface Adapter (VIA)
  4. *
  5. * There are two of these on the Mac II. Some IRQ's are vectored
  6. * via them as are assorted bits and bobs - eg rtc, adb. The picture
  7. * is a bit incomplete as the Mac documentation doesn't cover this well
  8. */
  9. #ifndef _ASM_MAC_VIA_H_
  10. #define _ASM_MAC_VIA_H_
  11. /*
  12. * Base addresses for the VIAs. There are two in every machine,
  13. * although on some machines the second is an RBV or an OSS.
  14. * The OSS is different enough that it's handled separately.
  15. *
  16. * Do not use these values directly; use the via1 and via2 variables
  17. * instead (and don't forget to check rbv_present when using via2!)
  18. */
  19. #define VIA1_BASE (0x50F00000)
  20. #define VIA2_BASE (0x50F02000)
  21. #define RBV_BASE (0x50F26000)
  22. /*
  23. * Not all of these are true post MacII I think.
  24. * CSA: probably the ones CHRP marks as 'unused' change purposes
  25. * when the IWM becomes the SWIM.
  26. * http://www.rs6000.ibm.com/resource/technology/chrpio/via5.mak.html
  27. * ftp://ftp.austin.ibm.com/pub/technology/spec/chrp/inwork/CHRP_IORef_1.0.pdf
  28. *
  29. * also, http://developer.apple.com/technotes/hw/hw_09.html claims the
  30. * following changes for IIfx:
  31. * VIA1A_vSccWrReq not available and that VIA1A_vSync has moved to an IOP.
  32. * Also, "All of the functionality of VIA2 has been moved to other chips".
  33. */
  34. #define VIA1A_vSccWrReq 0x80 /* SCC write. (input)
  35. * [CHRP] SCC WREQ: Reflects the state of the
  36. * Wait/Request pins from the SCC.
  37. * [Macintosh Family Hardware]
  38. * as CHRP on SE/30,II,IIx,IIcx,IIci.
  39. * on IIfx, "0 means an active request"
  40. */
  41. #define VIA1A_vRev8 0x40 /* Revision 8 board ???
  42. * [CHRP] En WaitReqB: Lets the WaitReq_L
  43. * signal from port B of the SCC appear on
  44. * the PA7 input pin. Output.
  45. * [Macintosh Family] On the SE/30, this
  46. * is the bit to flip screen buffers.
  47. * 0=alternate, 1=main.
  48. * on II,IIx,IIcx,IIci,IIfx this is a bit
  49. * for Rev ID. 0=II,IIx, 1=IIcx,IIci,IIfx
  50. */
  51. #define VIA1A_vHeadSel 0x20 /* Head select for IWM.
  52. * [CHRP] unused.
  53. * [Macintosh Family] "Floppy disk
  54. * state-control line SEL" on all but IIfx
  55. */
  56. #define VIA1A_vOverlay 0x10 /* [Macintosh Family] On SE/30,II,IIx,IIcx
  57. * this bit enables the "Overlay" address
  58. * map in the address decoders as it is on
  59. * reset for mapping the ROM over the reset
  60. * vector. 1=use overlay map.
  61. * On the IIci,IIfx it is another bit of the
  62. * CPU ID: 0=normal IIci, 1=IIci with parity
  63. * feature or IIfx.
  64. * [CHRP] En WaitReqA: Lets the WaitReq_L
  65. * signal from port A of the SCC appear
  66. * on the PA7 input pin (CHRP). Output.
  67. * [MkLinux] "Drive Select"
  68. * (with 0x20 being 'disk head select')
  69. */
  70. #define VIA1A_vSync 0x08 /* [CHRP] Sync Modem: modem clock select:
  71. * 1: select the external serial clock to
  72. * drive the SCC's /RTxCA pin.
  73. * 0: Select the 3.6864MHz clock to drive
  74. * the SCC cell.
  75. * [Macintosh Family] Correct on all but IIfx
  76. */
  77. /* Macintosh Family Hardware sez: bits 0-2 of VIA1A are volume control
  78. * on Macs which had the PWM sound hardware. Reserved on newer models.
  79. * On IIci,IIfx, bits 1-2 are the rest of the CPU ID:
  80. * bit 2: 1=IIci, 0=IIfx
  81. * bit 1: 1 on both IIci and IIfx.
  82. * MkLinux sez bit 0 is 'burnin flag' in this case.
  83. * CHRP sez: VIA1A bits 0-2 and 5 are 'unused': if programmed as
  84. * inputs, these bits will read 0.
  85. */
  86. #define VIA1A_vVolume 0x07 /* Audio volume mask for PWM */
  87. #define VIA1A_CPUID0 0x02 /* CPU id bit 0 on RBV, others */
  88. #define VIA1A_CPUID1 0x04 /* CPU id bit 0 on RBV, others */
  89. #define VIA1A_CPUID2 0x10 /* CPU id bit 0 on RBV, others */
  90. #define VIA1A_CPUID3 0x40 /* CPU id bit 0 on RBV, others */
  91. /* Info on VIA1B is from Macintosh Family Hardware & MkLinux.
  92. * CHRP offers no info. */
  93. #define VIA1B_vSound 0x80 /* Sound enable (for compatibility with
  94. * PWM hardware) 0=enabled.
  95. * Also, on IIci w/parity, shows parity error
  96. * 0=error, 1=OK. */
  97. #define VIA1B_vMystery 0x40 /* On IIci, parity enable. 0=enabled,1=disabled
  98. * On SE/30, vertical sync interrupt enable.
  99. * 0=enabled. This vSync interrupt shows up
  100. * as a slot $E interrupt. */
  101. #define VIA1B_vADBS2 0x20 /* ADB state input bit 1 (unused on IIfx) */
  102. #define VIA1B_vADBS1 0x10 /* ADB state input bit 0 (unused on IIfx) */
  103. #define VIA1B_vADBInt 0x08 /* ADB interrupt 0=interrupt (unused on IIfx)*/
  104. #define VIA1B_vRTCEnb 0x04 /* Enable Real time clock. 0=enabled. */
  105. #define VIA1B_vRTCClk 0x02 /* Real time clock serial-clock line. */
  106. #define VIA1B_vRTCData 0x01 /* Real time clock serial-data line. */
  107. /* MkLinux defines the following "VIA1 Register B contents where they
  108. * differ from standard VIA1". From the naming scheme, we assume they
  109. * correspond to a VIA work-alike named 'EVR'. */
  110. #define EVRB_XCVR 0x08 /* XCVR_SESSION* */
  111. #define EVRB_FULL 0x10 /* VIA_FULL */
  112. #define EVRB_SYSES 0x20 /* SYS_SESSION */
  113. #define EVRB_AUXIE 0x00 /* Enable A/UX Interrupt Scheme */
  114. #define EVRB_AUXID 0x40 /* Disable A/UX Interrupt Scheme */
  115. #define EVRB_SFTWRIE 0x00 /* Software Interrupt ReQuest */
  116. #define EVRB_SFTWRID 0x80 /* Software Interrupt ReQuest */
  117. /*
  118. * VIA2 A register is the interrupt lines raised off the nubus
  119. * slots.
  120. * The below info is from 'Macintosh Family Hardware.'
  121. * MkLinux calls the 'IIci internal video IRQ' below the 'RBV slot 0 irq.'
  122. * It also notes that the slot $9 IRQ is the 'Ethernet IRQ' and
  123. * defines the 'Video IRQ' as 0x40 for the 'EVR' VIA work-alike.
  124. * Perhaps OSS uses vRAM1 and vRAM2 for ADB.
  125. */
  126. #define VIA2A_vRAM1 0x80 /* RAM size bit 1 (IIci: reserved) */
  127. #define VIA2A_vRAM0 0x40 /* RAM size bit 0 (IIci: internal video IRQ) */
  128. #define VIA2A_vIRQE 0x20 /* IRQ from slot $E */
  129. #define VIA2A_vIRQD 0x10 /* IRQ from slot $D */
  130. #define VIA2A_vIRQC 0x08 /* IRQ from slot $C */
  131. #define VIA2A_vIRQB 0x04 /* IRQ from slot $B */
  132. #define VIA2A_vIRQA 0x02 /* IRQ from slot $A */
  133. #define VIA2A_vIRQ9 0x01 /* IRQ from slot $9 */
  134. /* RAM size bits decoded as follows:
  135. * bit1 bit0 size of ICs in bank A
  136. * 0 0 256 kbit
  137. * 0 1 1 Mbit
  138. * 1 0 4 Mbit
  139. * 1 1 16 Mbit
  140. */
  141. /*
  142. * Register B has the fun stuff in it
  143. */
  144. #define VIA2B_vVBL 0x80 /* VBL output to VIA1 (60.15Hz) driven by
  145. * timer T1.
  146. * on IIci, parity test: 0=test mode.
  147. * [MkLinux] RBV_PARODD: 1=odd,0=even. */
  148. #define VIA2B_vSndJck 0x40 /* External sound jack status.
  149. * 0=plug is inserted. On SE/30, always 0 */
  150. #define VIA2B_vTfr0 0x20 /* Transfer mode bit 0 ack from NuBus */
  151. #define VIA2B_vTfr1 0x10 /* Transfer mode bit 1 ack from NuBus */
  152. #define VIA2B_vMode32 0x08 /* 24/32bit switch - doubles as cache flush
  153. * on II, AMU/PMMU control.
  154. * if AMU, 0=24bit to 32bit translation
  155. * if PMMU, 1=PMMU is accessing page table.
  156. * on SE/30 tied low.
  157. * on IIx,IIcx,IIfx, unused.
  158. * on IIci/RBV, cache control. 0=flush cache.
  159. */
  160. #define VIA2B_vPower 0x04 /* Power off, 0=shut off power.
  161. * on SE/30 this signal sent to PDS card. */
  162. #define VIA2B_vBusLk 0x02 /* Lock NuBus transactions, 0=locked.
  163. * on SE/30 sent to PDS card. */
  164. #define VIA2B_vCDis 0x01 /* Cache control. On IIci, 1=disable cache card
  165. * on others, 0=disable processor's instruction
  166. * and data caches. */
  167. /* Apple sez: http://developer.apple.com/technotes/ov/ov_04.html
  168. * Another example of a valid function that has no ROM support is the use
  169. * of the alternate video page for page-flipping animation. Since there
  170. * is no ROM call to flip pages, it is necessary to go play with the
  171. * right bit in the VIA chip (6522 Versatile Interface Adapter).
  172. * [CSA: don't know which one this is, but it's one of 'em!]
  173. */
  174. /*
  175. * 6522 registers - see databook.
  176. * CSA: Assignments for VIA1 confirmed from CHRP spec.
  177. */
  178. /* partial address decode. 0xYYXX : XX part for RBV, YY part for VIA */
  179. /* Note: 15 VIA regs, 8 RBV regs */
  180. #define vBufB 0x0000 /* [VIA/RBV] Register B */
  181. #define vBufAH 0x0200 /* [VIA only] Buffer A, with handshake. DON'T USE! */
  182. #define vDirB 0x0400 /* [VIA only] Data Direction Register B. */
  183. #define vDirA 0x0600 /* [VIA only] Data Direction Register A. */
  184. #define vT1CL 0x0800 /* [VIA only] Timer one counter low. */
  185. #define vT1CH 0x0a00 /* [VIA only] Timer one counter high. */
  186. #define vT1LL 0x0c00 /* [VIA only] Timer one latches low. */
  187. #define vT1LH 0x0e00 /* [VIA only] Timer one latches high. */
  188. #define vT2CL 0x1000 /* [VIA only] Timer two counter low. */
  189. #define vT2CH 0x1200 /* [VIA only] Timer two counter high. */
  190. #define vSR 0x1400 /* [VIA only] Shift register. */
  191. #define vACR 0x1600 /* [VIA only] Auxiliary control register. */
  192. #define vPCR 0x1800 /* [VIA only] Peripheral control register. */
  193. /* CHRP sez never ever to *write* this.
  194. * Mac family says never to *change* this.
  195. * In fact we need to initialize it once at start. */
  196. #define vIFR 0x1a00 /* [VIA/RBV] Interrupt flag register. */
  197. #define vIER 0x1c00 /* [VIA/RBV] Interrupt enable register. */
  198. #define vBufA 0x1e00 /* [VIA/RBV] register A (no handshake) */
  199. /* The RBV only decodes the bottom eight address lines; the VIA doesn't
  200. * decode the bottom eight -- so vBufB | rBufB will always get you BufB */
  201. /* CSA: in fact, only bits 0,1, and 4 seem to be decoded.
  202. * BUT note the values for rIER and rIFR, where the top 8 bits *do* seem
  203. * to matter. In fact *all* of the top 8 bits seem to matter;
  204. * setting rIER=0x1813 and rIFR=0x1803 doesn't work, either.
  205. * Perhaps some sort of 'compatibility mode' is built-in? [21-May-1999]
  206. */
  207. #define rBufB 0x0000 /* [VIA/RBV] Register B */
  208. #define rExp 0x0001 /* [RBV only] RBV future expansion (always 0) */
  209. #define rSIFR 0x0002 /* [RBV only] RBV slot interrupts register. */
  210. #define rIFR 0x1a03 /* [VIA/RBV] RBV interrupt flag register. */
  211. #define rMonP 0x0010 /* [RBV only] RBV video monitor type. */
  212. #define rChpT 0x0011 /* [RBV only] RBV test mode register (reads as 0). */
  213. #define rSIER 0x0012 /* [RBV only] RBV slot interrupt enables. */
  214. #define rIER 0x1c13 /* [VIA/RBV] RBV interrupt flag enable register. */
  215. #define rBufA rSIFR /* the 'slot interrupts register' is BufA on a VIA */
  216. /*
  217. * Video monitor parameters, for rMonP:
  218. */
  219. #define RBV_DEPTH 0x07 /* bits per pixel: 000=1,001=2,010=4,011=8 */
  220. #define RBV_MONID 0x38 /* monitor type, as below. */
  221. #define RBV_VIDOFF 0x40 /* 1 turns off onboard video */
  222. /* Supported monitor types: */
  223. #define MON_15BW (1<<3) /* 15" BW portrait. */
  224. #define MON_IIGS (2<<3) /* 12" color (modified IIGS monitor). */
  225. #define MON_15RGB (5<<3) /* 15" RGB portrait. */
  226. #define MON_12OR13 (6<<3) /* 12" BW or 13" RGB. */
  227. #define MON_NONE (7<<3) /* No monitor attached. */
  228. /* To clarify IER manipulations */
  229. #define IER_SET_BIT(b) (0x80 | (1<<(b)) )
  230. #define IER_CLR_BIT(b) (0x7F & (1<<(b)) )
  231. #ifndef __ASSEMBLY__
  232. extern volatile __u8 *via1,*via2;
  233. extern int rbv_present,via_alt_mapping;
  234. struct irq_desc;
  235. extern void via_register_interrupts(void);
  236. extern void via_irq_enable(int);
  237. extern void via_irq_disable(int);
  238. extern void via_nubus_irq_startup(int irq);
  239. extern void via_nubus_irq_shutdown(int irq);
  240. extern void via1_irq(struct irq_desc *desc);
  241. extern void via1_set_head(int);
  242. extern int via2_scsi_drq_pending(void);
  243. static inline int rbv_set_video_bpp(int bpp)
  244. {
  245. char val = (bpp==1)?0:(bpp==2)?1:(bpp==4)?2:(bpp==8)?3:-1;
  246. if (!rbv_present || val<0) return -1;
  247. via2[rMonP] = (via2[rMonP] & ~RBV_DEPTH) | val;
  248. return 0;
  249. }
  250. #endif /* __ASSEMBLY__ */
  251. #endif /* _ASM_MAC_VIA_H_ */