mac_psc.h 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Apple Peripheral System Controller (PSC)
  4. *
  5. * The PSC is used on the AV Macs to control IO functions not handled
  6. * by the VIAs (Ethernet, DSP, SCC, Sound). This includes nine DMA
  7. * channels.
  8. *
  9. * The first seven DMA channels appear to be "one-shot" and are actually
  10. * sets of two channels; one member is active while the other is being
  11. * configured, and then you flip the active member and start all over again.
  12. * The one-shot channels are grouped together and are:
  13. *
  14. * 1. SCSI
  15. * 2. Ethernet Read
  16. * 3. Ethernet Write
  17. * 4. Floppy Disk Controller
  18. * 5. SCC Channel A Receive
  19. * 6. SCC Channel B Receive
  20. * 7. SCC Channel A Transmit
  21. *
  22. * The remaining two channels are handled somewhat differently. They appear
  23. * to be closely tied and share one set of registers. They also seem to run
  24. * continuously, although how you keep the buffer filled in this scenario is
  25. * not understood as there seems to be only one input and one output buffer
  26. * pointer.
  27. *
  28. * Much of this was extrapolated from what was known about the Ethernet
  29. * registers and subsequently confirmed using MacsBug (ie by pinging the
  30. * machine with easy-to-find patterns and looking for them in the DMA
  31. * buffers, or by sending a file over the serial ports and finding the
  32. * file in the buffers.)
  33. *
  34. * 1999-05-25 (jmt)
  35. */
  36. #define PSC_BASE (0x50F31000)
  37. /*
  38. * The IER/IFR registers work like the VIA, except that it has 4
  39. * of them each on different interrupt levels, and each register
  40. * set only seems to handle four interrupts instead of seven.
  41. *
  42. * To access a particular set of registers, add 0xn0 to the base
  43. * where n = 3,4,5 or 6.
  44. */
  45. #define pIFRbase 0x100
  46. #define pIERbase 0x104
  47. /*
  48. * One-shot DMA control registers
  49. */
  50. #define PSC_MYSTERY 0x804
  51. #define PSC_CTL_BASE 0xC00
  52. #define PSC_SCSI_CTL 0xC00
  53. #define PSC_ENETRD_CTL 0xC10
  54. #define PSC_ENETWR_CTL 0xC20
  55. #define PSC_FDC_CTL 0xC30
  56. #define PSC_SCCA_CTL 0xC40
  57. #define PSC_SCCB_CTL 0xC50
  58. #define PSC_SCCATX_CTL 0xC60
  59. /*
  60. * DMA channels. Add +0x10 for the second channel in the set.
  61. * You're supposed to use one channel while the other runs and
  62. * then flip channels and do the whole thing again.
  63. */
  64. #define PSC_ADDR_BASE 0x1000
  65. #define PSC_LEN_BASE 0x1004
  66. #define PSC_CMD_BASE 0x1008
  67. #define PSC_SET0 0x00
  68. #define PSC_SET1 0x10
  69. #define PSC_SCSI_ADDR 0x1000 /* confirmed */
  70. #define PSC_SCSI_LEN 0x1004 /* confirmed */
  71. #define PSC_SCSI_CMD 0x1008 /* confirmed */
  72. #define PSC_ENETRD_ADDR 0x1020 /* confirmed */
  73. #define PSC_ENETRD_LEN 0x1024 /* confirmed */
  74. #define PSC_ENETRD_CMD 0x1028 /* confirmed */
  75. #define PSC_ENETWR_ADDR 0x1040 /* confirmed */
  76. #define PSC_ENETWR_LEN 0x1044 /* confirmed */
  77. #define PSC_ENETWR_CMD 0x1048 /* confirmed */
  78. #define PSC_FDC_ADDR 0x1060 /* strongly suspected */
  79. #define PSC_FDC_LEN 0x1064 /* strongly suspected */
  80. #define PSC_FDC_CMD 0x1068 /* strongly suspected */
  81. #define PSC_SCCA_ADDR 0x1080 /* confirmed */
  82. #define PSC_SCCA_LEN 0x1084 /* confirmed */
  83. #define PSC_SCCA_CMD 0x1088 /* confirmed */
  84. #define PSC_SCCB_ADDR 0x10A0 /* confirmed */
  85. #define PSC_SCCB_LEN 0x10A4 /* confirmed */
  86. #define PSC_SCCB_CMD 0x10A8 /* confirmed */
  87. #define PSC_SCCATX_ADDR 0x10C0 /* confirmed */
  88. #define PSC_SCCATX_LEN 0x10C4 /* confirmed */
  89. #define PSC_SCCATX_CMD 0x10C8 /* confirmed */
  90. /*
  91. * Free-running DMA registers. The only part known for sure are the bits in
  92. * the control register, the buffer addresses and the buffer length. Everything
  93. * else is anybody's guess.
  94. *
  95. * These registers seem to be mirrored every thirty-two bytes up until offset
  96. * 0x300. It's safe to assume then that a new set of registers starts there.
  97. */
  98. #define PSC_SND_CTL 0x200 /*
  99. * [ 16-bit ]
  100. * Sound (Singer?) control register.
  101. *
  102. * bit 0 : ????
  103. * bit 1 : ????
  104. * bit 2 : Set to one to enable sound
  105. * output. Possibly a mute flag.
  106. * bit 3 : ????
  107. * bit 4 : ????
  108. * bit 5 : ????
  109. * bit 6 : Set to one to enable pass-thru
  110. * audio. In this mode the audio data
  111. * seems to appear in both the input
  112. * buffer and the output buffer.
  113. * bit 7 : Set to one to activate the
  114. * sound input DMA or zero to
  115. * disable it.
  116. * bit 8 : Set to one to activate the
  117. * sound output DMA or zero to
  118. * disable it.
  119. * bit 9 : \
  120. * bit 11 : |
  121. * These two bits control the sample
  122. * rate. Usually set to binary 10 and
  123. * MacOS 8.0 says I'm at 48 KHz. Using
  124. * a binary value of 01 makes things
  125. * sound about 1/2 speed (24 KHz?) and
  126. * binary 00 is slower still (22 KHz?)
  127. *
  128. * Setting this to 0x0000 is a good way to
  129. * kill all DMA at boot time so that the
  130. * PSC won't overwrite the kernel image
  131. * with sound data.
  132. */
  133. /*
  134. * 0x0202 - 0x0203 is unused. Writing there
  135. * seems to clobber the control register.
  136. */
  137. #define PSC_SND_SOURCE 0x204 /*
  138. * [ 32-bit ]
  139. * Controls input source and volume:
  140. *
  141. * bits 12-15 : input source volume, 0 - F
  142. * bits 16-19 : unknown, always 0x5
  143. * bits 20-23 : input source selection:
  144. * 0x3 = CD Audio
  145. * 0x4 = External Audio
  146. *
  147. * The volume is definitely not the general
  148. * output volume as it doesn't affect the
  149. * alert sound volume.
  150. */
  151. #define PSC_SND_STATUS1 0x208 /*
  152. * [ 32-bit ]
  153. * Appears to be a read-only status register.
  154. * The usual value is 0x00400002.
  155. */
  156. #define PSC_SND_HUH3 0x20C /*
  157. * [ 16-bit ]
  158. * Unknown 16-bit value, always 0x0000.
  159. */
  160. #define PSC_SND_BITS2GO 0x20E /*
  161. * [ 16-bit ]
  162. * Counts down to zero from some constant
  163. * value. The value appears to be the
  164. * number of _bits_ remaining before the
  165. * buffer is full, which would make sense
  166. * since Apple's docs say the sound DMA
  167. * channels are 1 bit wide.
  168. */
  169. #define PSC_SND_INADDR 0x210 /*
  170. * [ 32-bit ]
  171. * Address of the sound input DMA buffer
  172. */
  173. #define PSC_SND_OUTADDR 0x214 /*
  174. * [ 32-bit ]
  175. * Address of the sound output DMA buffer
  176. */
  177. #define PSC_SND_LEN 0x218 /*
  178. * [ 16-bit ]
  179. * Length of both buffers in eight-byte units.
  180. */
  181. #define PSC_SND_HUH4 0x21A /*
  182. * [ 16-bit ]
  183. * Unknown, always 0x0000.
  184. */
  185. #define PSC_SND_STATUS2 0x21C /*
  186. * [ 16-bit ]
  187. * Appears to e a read-only status register.
  188. * The usual value is 0x0200.
  189. */
  190. #define PSC_SND_HUH5 0x21E /*
  191. * [ 16-bit ]
  192. * Unknown, always 0x0000.
  193. */
  194. #ifndef __ASSEMBLY__
  195. extern volatile __u8 *psc;
  196. extern void psc_register_interrupts(void);
  197. extern void psc_irq_enable(int);
  198. extern void psc_irq_disable(int);
  199. /*
  200. * Access functions
  201. */
  202. static inline void psc_write_byte(int offset, __u8 data)
  203. {
  204. *((volatile __u8 *)(psc + offset)) = data;
  205. }
  206. static inline void psc_write_word(int offset, __u16 data)
  207. {
  208. *((volatile __u16 *)(psc + offset)) = data;
  209. }
  210. static inline void psc_write_long(int offset, __u32 data)
  211. {
  212. *((volatile __u32 *)(psc + offset)) = data;
  213. }
  214. static inline u8 psc_read_byte(int offset)
  215. {
  216. return *((volatile __u8 *)(psc + offset));
  217. }
  218. static inline u16 psc_read_word(int offset)
  219. {
  220. return *((volatile __u16 *)(psc + offset));
  221. }
  222. static inline u32 psc_read_long(int offset)
  223. {
  224. return *((volatile __u32 *)(psc + offset));
  225. }
  226. #endif /* __ASSEMBLY__ */