pnpreg.h 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. /*-
  2. * SPDX-License-Identifier: BSD-4-Clause
  3. *
  4. * Copyright (c) 1996, Sujal M. Patel
  5. * All rights reserved.
  6. *
  7. * Redistribution and use in source and binary forms, with or without
  8. * modification, are permitted provided that the following conditions
  9. * are met:
  10. * 1. Redistributions of source code must retain the above copyright
  11. * notice, this list of conditions and the following disclaimer.
  12. * 2. Redistributions in binary form must reproduce the above copyright
  13. * notice, this list of conditions and the following disclaimer in the
  14. * documentation and/or other materials provided with the distribution.
  15. * 3. All advertising materials mentioning features or use of this software
  16. * must display the following acknowledgement:
  17. * This product includes software developed by Sujal M. Patel
  18. * 4. Neither the name of the author nor the names of any co-contributors
  19. * may be used to endorse or promote products derived from this software
  20. * without specific prior written permission.
  21. *
  22. * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
  23. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  24. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  25. * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
  26. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  27. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  28. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  29. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  30. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  31. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  32. * SUCH DAMAGE.
  33. * from: pnp.h,v 1.7 1998/09/13 22:15:44 eivind Exp
  34. */
  35. #ifndef _ISA_PNPREG_H_
  36. #define _ISA_PNPREG_H_
  37. /* Maximum Number of PnP Devices. 8 should be plenty */
  38. #define PNP_MAX_CARDS 8
  39. /* Static ports to access PnP state machine */
  40. #define _PNP_ADDRESS 0x279
  41. #define _PNP_WRITE_DATA 0xa79
  42. /* PnP Registers. Write to ADDRESS and then use WRITE/READ_DATA */
  43. #define PNP_SET_RD_DATA 0x00
  44. /***
  45. Writing to this location modifies the address of the port used for
  46. reading from the Plug and Play ISA cards. Bits[7:0] become I/O
  47. read port address bits[9:2]. Reads from this register are ignored.
  48. ***/
  49. #define PNP_SERIAL_ISOLATION 0x01
  50. /***
  51. A read to this register causes a Plug and Play cards in the Isolation
  52. state to compare one bit of the boards ID.
  53. This register is read only.
  54. ***/
  55. #define PNP_CONFIG_CONTROL 0x02
  56. #define PNP_CONFIG_CONTROL_RESET_CSN 0x04
  57. #define PNP_CONFIG_CONTROL_WAIT_FOR_KEY 0x02
  58. #define PNP_CONFIG_CONTROL_RESET 0x01
  59. /***
  60. Bit[2] Reset CSN to 0
  61. Bit[1] Return to the Wait for Key state
  62. Bit[0] Reset all logical devices and restore configuration
  63. registers to their power-up values.
  64. A write to bit[0] of this register performs a reset function on
  65. all logical devices. This resets the contents of configuration
  66. registers to their default state. All card's logical devices
  67. enter their default state and the CSN is preserved.
  68. A write to bit[1] of this register causes all cards to enter the
  69. Wait for Key state but all CSNs are preserved and logical devices
  70. are not affected.
  71. A write to bit[2] of this register causes all cards to reset their
  72. CSN to zero .
  73. This register is write-only. The values are not sticky, that is,
  74. hardware will automatically clear them and there is no need for
  75. software to clear the bits.
  76. ***/
  77. #define PNP_WAKE 0x03
  78. /***
  79. A write to this port will cause all cards that have a CSN that
  80. matches the write data[7:0] to go from the Sleep state to the either
  81. the Isolation state if the write data for this command is zero or
  82. the Config state if the write data is not zero. Additionally, the
  83. pointer to the byte-serial device is reset. This register is
  84. writeonly.
  85. ***/
  86. #define PNP_RESOURCE_DATA 0x04
  87. /***
  88. A read from this address reads the next byte of resource information.
  89. The Status register must be polled until bit[0] is set before this
  90. register may be read. This register is read only.
  91. ***/
  92. #define PNP_STATUS 0x05
  93. /***
  94. Bit[0] when set indicates it is okay to read the next data byte
  95. from the Resource Data register. This register is readonly.
  96. ***/
  97. #define PNP_SET_CSN 0x06
  98. /***
  99. A write to this port sets a card's CSN. The CSN is a value uniquely
  100. assigned to each ISA card after the serial identification process
  101. so that each card may be individually selected during a Wake[CSN]
  102. command. This register is read/write.
  103. ***/
  104. #define PNP_SET_LDN 0x07
  105. /***
  106. Selects the current logical device. All reads and writes of memory,
  107. I/O, interrupt and DMA configuration information access the registers
  108. of the logical device written here. In addition, the I/O Range
  109. Check and Activate commands operate only on the selected logical
  110. device. This register is read/write. If a card has only 1 logical
  111. device, this location should be a read-only value of 0x00.
  112. ***/
  113. /*** addresses 0x08 - 0x1F Card Level Reserved for future use ***/
  114. /*** addresses 0x20 - 0x2F Card Level, Vendor Defined ***/
  115. #define PNP_ACTIVATE 0x30
  116. /***
  117. For each logical device there is one activate register that controls
  118. whether or not the logical device is active on the ISA bus. Bit[0],
  119. if set, activates the logical device. Bits[7:1] are reserved and
  120. must return 0 on reads. This is a read/write register. Before a
  121. logical device is activated, I/O range check must be disabled.
  122. ***/
  123. #define PNP_IO_RANGE_CHECK 0x31
  124. #define PNP_IO_RANGE_CHECK_ENABLE 0x02
  125. #define PNP_IO_RANGE_CHECK_READ_AS_55 0x01
  126. /***
  127. This register is used to perform a conflict check on the I/O port
  128. range programmed for use by a logical device.
  129. Bit[7:2] Reserved and must return 0 on reads
  130. Bit[1] Enable I/O Range check, if set then I/O Range Check
  131. is enabled. I/O range check is only valid when the logical
  132. device is inactive.
  133. Bit[0], if set, forces the logical device to respond to I/O reads
  134. of the logical device's assigned I/O range with a 0x55 when I/O
  135. range check is in operation. If clear, the logical device drives
  136. 0xAA. This register is read/write.
  137. ***/
  138. /*** addr 0x32 - 0x37 Logical Device Control Reserved for future use ***/
  139. /*** addr 0x38 - 0x3F Logical Device Control Vendor Define ***/
  140. #define PNP_MEM_BASE_HIGH(i) (0x40 + 8*(i))
  141. #define PNP_MEM_BASE_LOW(i) (0x41 + 8*(i))
  142. #define PNP_MEM_CONTROL(i) (0x42 * 8*(i))
  143. #define PNP_MEM_CONTROL_16BIT 0x2
  144. #define PNP_MEM_CONTROL_LIMIT 0x1
  145. #define PNP_MEM_RANGE_HIGH(i) (0x43 + 8*(i))
  146. #define PNP_MEM_RANGE_LOW(i) (0x44 + 8*(i))
  147. /***
  148. Four memory resource registers per range, four ranges.
  149. Fill with 0 if no ranges are enabled.
  150. Offset 0: RW Memory base address bits[23:16]
  151. Offset 1: RW Memory base address bits[15:8]
  152. Offset 2: Memory control
  153. Bit[1] specifies 8/16-bit control. This bit is set to indicate
  154. 16-bit memory, and cleared to indicate 8-bit memory.
  155. Bit[0], if cleared, indicates the next field can be used as a range
  156. length for decode (implies range length and base alignment of memory
  157. descriptor are equal).
  158. Bit[0], if set, indicates the next field is the upper limit for
  159. the address. - - Bit[0] is read-only.
  160. Offset 3: RW upper limit or range len, bits[23:16]
  161. Offset 4: RW upper limit or range len, bits[15:8]
  162. Offset 5-Offset 7: filler, unused.
  163. ***/
  164. #define PNP_IO_BASE_HIGH(i) (0x60 + 2*(i))
  165. #define PNP_IO_BASE_LOW(i) (0x61 + 2*(i))
  166. /***
  167. Eight ranges, two bytes per range.
  168. Offset 0: I/O port base address bits[15:8]
  169. Offset 1: I/O port base address bits[7:0]
  170. ***/
  171. #define PNP_IRQ_LEVEL(i) (0x70 + 2*(i))
  172. #define PNP_IRQ_TYPE(i) (0x71 + 2*(i))
  173. /***
  174. Two entries, two bytes per entry.
  175. Offset 0: RW interrupt level (1..15, 0=unused).
  176. Offset 1: Bit[1]: level(1:hi, 0:low),
  177. Bit[0]: type (1:level, 0:edge)
  178. byte 1 can be readonly if 1 type of int is used.
  179. ***/
  180. #define PNP_DMA_CHANNEL(i) (0x74 + 1*(i))
  181. /***
  182. Two entries, one byte per entry. Bits[2:0] select
  183. which DMA channel is in use for DMA 0. Zero selects DMA channel
  184. 0, seven selects DMA channel 7. DMA channel 4, the cascade channel
  185. is used to indicate no DMA channel is active.
  186. ***/
  187. /*** 32-bit memory accesses are at 0x76 ***/
  188. /* Macros to parse Resource IDs */
  189. #define PNP_RES_TYPE(a) (a >> 7)
  190. #define PNP_SRES_NUM(a) (a >> 3)
  191. #define PNP_SRES_LEN(a) (a & 0x07)
  192. #define PNP_LRES_NUM(a) (a & 0x7f)
  193. /* Small Resource Item names */
  194. #define PNP_TAG_VERSION 0x1
  195. #define PNP_TAG_LOGICAL_DEVICE 0x2
  196. #define PNP_TAG_COMPAT_DEVICE 0x3
  197. #define PNP_TAG_IRQ_FORMAT 0x4
  198. #define PNP_TAG_DMA_FORMAT 0x5
  199. #define PNP_TAG_START_DEPENDANT 0x6
  200. #define PNP_TAG_END_DEPENDANT 0x7
  201. #define PNP_TAG_IO_RANGE 0x8
  202. #define PNP_TAG_IO_FIXED 0x9
  203. #define PNP_TAG_RESERVED 0xa-0xd
  204. #define PNP_TAG_VENDOR 0xe
  205. #define PNP_TAG_END 0xf
  206. /* Large Resource Item names */
  207. #define PNP_TAG_MEMORY_RANGE 0x1
  208. #define PNP_TAG_ID_ANSI 0x2
  209. #define PNP_TAG_ID_UNICODE 0x3
  210. #define PNP_TAG_LARGE_VENDOR 0x4
  211. #define PNP_TAG_MEMORY32_RANGE 0x5
  212. #define PNP_TAG_MEMORY32_FIXED 0x6
  213. #define PNP_TAG_LARGE_RESERVED 0x7-0x7f
  214. #endif /* !_ISA_PNPREG_H_ */