xref: /freebsd/sys/isa/pnpreg.h (revision 95ee2897e98f5d444f26ed2334cc7c439f9c16c6)
186cb007fSWarner Losh /*-
2*df57947fSPedro F. Giffuni  * SPDX-License-Identifier: BSD-4-Clause
3*df57947fSPedro F. Giffuni  *
44249382dSDoug Rabson  * Copyright (c) 1996, Sujal M. Patel
54249382dSDoug Rabson  * All rights reserved.
64249382dSDoug Rabson  *
74249382dSDoug Rabson  * Redistribution and use in source and binary forms, with or without
84249382dSDoug Rabson  * modification, are permitted provided that the following conditions
94249382dSDoug Rabson  * are met:
104249382dSDoug Rabson  * 1. Redistributions of source code must retain the above copyright
114249382dSDoug Rabson  *    notice, this list of conditions and the following disclaimer.
124249382dSDoug Rabson  * 2. Redistributions in binary form must reproduce the above copyright
134249382dSDoug Rabson  *    notice, this list of conditions and the following disclaimer in the
144249382dSDoug Rabson  *    documentation and/or other materials provided with the distribution.
154249382dSDoug Rabson  * 3. All advertising materials mentioning features or use of this software
164249382dSDoug Rabson  *    must display the following acknowledgement:
174249382dSDoug Rabson  *      This product includes software developed by Sujal M. Patel
184249382dSDoug Rabson  * 4. Neither the name of the author nor the names of any co-contributors
194249382dSDoug Rabson  *    may be used to endorse or promote products derived from this software
204249382dSDoug Rabson  *    without specific prior written permission.
214249382dSDoug Rabson  *
224249382dSDoug Rabson  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
234249382dSDoug Rabson  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
244249382dSDoug Rabson  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
254249382dSDoug Rabson  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
264249382dSDoug Rabson  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
274249382dSDoug Rabson  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
284249382dSDoug Rabson  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
294249382dSDoug Rabson  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
304249382dSDoug Rabson  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
314249382dSDoug Rabson  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
324249382dSDoug Rabson  * SUCH DAMAGE.
334249382dSDoug Rabson  *      from: pnp.h,v 1.7 1998/09/13 22:15:44 eivind Exp
344249382dSDoug Rabson  */
354249382dSDoug Rabson 
364249382dSDoug Rabson #ifndef _ISA_PNPREG_H_
374249382dSDoug Rabson #define _ISA_PNPREG_H_
384249382dSDoug Rabson 
394249382dSDoug Rabson /* Maximum Number of PnP Devices.  8 should be plenty */
404249382dSDoug Rabson #define PNP_MAX_CARDS 8
414249382dSDoug Rabson 
424249382dSDoug Rabson /* Static ports to access PnP state machine */
434249382dSDoug Rabson #define _PNP_ADDRESS		0x279
444249382dSDoug Rabson #define _PNP_WRITE_DATA		0xa79
454249382dSDoug Rabson 
464249382dSDoug Rabson /* PnP Registers.  Write to ADDRESS and then use WRITE/READ_DATA */
474249382dSDoug Rabson #define PNP_SET_RD_DATA		0x00
484249382dSDoug Rabson 	/***
494249382dSDoug Rabson 	Writing to this location modifies the address of the port used for
504249382dSDoug Rabson 	reading from the Plug and Play ISA cards.   Bits[7:0] become I/O
514249382dSDoug Rabson 	read port address bits[9:2].  Reads from this register are ignored.
524249382dSDoug Rabson 	***/
534249382dSDoug Rabson 
544249382dSDoug Rabson #define PNP_SERIAL_ISOLATION	0x01
554249382dSDoug Rabson 	/***
564249382dSDoug Rabson 	A read to this register causes a Plug and Play cards in the Isolation
574249382dSDoug Rabson 	state to compare one bit of the boards ID.
584249382dSDoug Rabson 	This register is read only.
594249382dSDoug Rabson 	***/
604249382dSDoug Rabson 
614249382dSDoug Rabson #define	PNP_CONFIG_CONTROL	0x02
624249382dSDoug Rabson #define PNP_CONFIG_CONTROL_RESET_CSN	0x04
634249382dSDoug Rabson #define PNP_CONFIG_CONTROL_WAIT_FOR_KEY	0x02
644249382dSDoug Rabson #define PNP_CONFIG_CONTROL_RESET	0x01
654249382dSDoug Rabson 	/***
664249382dSDoug Rabson 	Bit[2]  Reset CSN to 0
674249382dSDoug Rabson 	Bit[1]  Return to the Wait for Key state
684249382dSDoug Rabson 	Bit[0]  Reset all logical devices and restore configuration
694249382dSDoug Rabson 		registers to their power-up values.
704249382dSDoug Rabson 
714249382dSDoug Rabson 	A write to bit[0] of this register performs a reset function on
724249382dSDoug Rabson 	all logical devices.  This resets the contents of configuration
734249382dSDoug Rabson 	registers to  their default state.  All card's logical devices
744249382dSDoug Rabson 	enter their default state and the CSN is preserved.
754249382dSDoug Rabson 
764249382dSDoug Rabson 	A write to bit[1] of this register causes all cards to enter the
774249382dSDoug Rabson 	Wait for Key state but all CSNs are preserved and logical devices
784249382dSDoug Rabson 	are not affected.
794249382dSDoug Rabson 
804249382dSDoug Rabson 	A write to bit[2] of this register causes all cards to reset their
814249382dSDoug Rabson 	CSN to zero .
824249382dSDoug Rabson 
834249382dSDoug Rabson 	This register is write-only.  The values are not sticky, that is,
844249382dSDoug Rabson 	hardware will automatically clear them and there is no need for
854249382dSDoug Rabson 	software to clear the bits.
864249382dSDoug Rabson 	***/
874249382dSDoug Rabson 
884249382dSDoug Rabson #define PNP_WAKE		0x03
894249382dSDoug Rabson 	/***
904249382dSDoug Rabson 	A write to this port will cause all cards that have a CSN that
914249382dSDoug Rabson 	matches the write data[7:0] to go from the Sleep state to the either
924249382dSDoug Rabson 	the Isolation state if the write data for this command is zero or
934249382dSDoug Rabson 	the Config state if the write data is not zero.  Additionally, the
944249382dSDoug Rabson 	pointer to the byte-serial device is reset.  This register is
954249382dSDoug Rabson 	writeonly.
964249382dSDoug Rabson 	***/
974249382dSDoug Rabson 
984249382dSDoug Rabson #define	PNP_RESOURCE_DATA	0x04
994249382dSDoug Rabson 	/***
1004249382dSDoug Rabson 	A read from this address reads the next byte of resource information.
1014249382dSDoug Rabson 	The Status register must be polled until bit[0] is set before this
1024249382dSDoug Rabson 	register may be read.  This register is read only.
1034249382dSDoug Rabson 	***/
1044249382dSDoug Rabson 
1054249382dSDoug Rabson #define PNP_STATUS		0x05
1064249382dSDoug Rabson 	/***
1074249382dSDoug Rabson 	Bit[0] when set indicates it is okay to read the next data byte
1084249382dSDoug Rabson 	from the Resource Data register.  This register is readonly.
1094249382dSDoug Rabson 	***/
1104249382dSDoug Rabson 
1114249382dSDoug Rabson #define PNP_SET_CSN		0x06
1124249382dSDoug Rabson 	/***
1134249382dSDoug Rabson 	A write to this port sets a card's CSN.  The CSN is a value uniquely
1144249382dSDoug Rabson 	assigned to each ISA card after the serial identification process
1154249382dSDoug Rabson 	so that each card may be individually selected during a Wake[CSN]
1164249382dSDoug Rabson 	command. This register is read/write.
1174249382dSDoug Rabson 	***/
1184249382dSDoug Rabson 
1194249382dSDoug Rabson #define PNP_SET_LDN		0x07
1204249382dSDoug Rabson 	/***
1214249382dSDoug Rabson 	Selects the current logical device.  All reads and writes of memory,
1224249382dSDoug Rabson 	I/O, interrupt and DMA configuration information access the registers
1234249382dSDoug Rabson 	of the logical device written here.  In addition, the I/O Range
1244249382dSDoug Rabson 	Check and Activate  commands operate only on the selected logical
1254249382dSDoug Rabson 	device.  This register is read/write. If a card has only 1 logical
1264249382dSDoug Rabson 	device, this location should be a read-only value of 0x00.
1274249382dSDoug Rabson 	***/
1284249382dSDoug Rabson 
1294249382dSDoug Rabson /*** addresses 0x08 - 0x1F Card Level Reserved for future use ***/
1304249382dSDoug Rabson /*** addresses 0x20 - 0x2F Card Level, Vendor Defined ***/
1314249382dSDoug Rabson 
1324249382dSDoug Rabson #define PNP_ACTIVATE		0x30
1334249382dSDoug Rabson 	/***
1344249382dSDoug Rabson 	For each logical device there is one activate register that controls
1354249382dSDoug Rabson 	whether or not the logical device is active on the ISA bus.  Bit[0],
1364249382dSDoug Rabson 	if set, activates the logical device.  Bits[7:1] are reserved and
1374249382dSDoug Rabson 	must return 0 on reads.  This is a read/write register. Before a
1384249382dSDoug Rabson 	logical device is activated, I/O range check must be disabled.
1394249382dSDoug Rabson 	***/
1404249382dSDoug Rabson 
1414249382dSDoug Rabson #define PNP_IO_RANGE_CHECK	0x31
1424249382dSDoug Rabson #define PNP_IO_RANGE_CHECK_ENABLE	0x02
1434249382dSDoug Rabson #define PNP_IO_RANGE_CHECK_READ_AS_55	0x01
1444249382dSDoug Rabson 	/***
1454249382dSDoug Rabson 	This register is used to perform a conflict check on the I/O port
1464249382dSDoug Rabson 	range programmed for use by a logical device.
1474249382dSDoug Rabson 
1484249382dSDoug Rabson 	Bit[7:2]  Reserved and must return 0 on reads
1494249382dSDoug Rabson 	Bit[1]    Enable I/O Range check, if set then I/O Range Check
1504249382dSDoug Rabson 	is enabled. I/O range check is only valid when the logical
1514249382dSDoug Rabson 	device is inactive.
1524249382dSDoug Rabson 
1534249382dSDoug Rabson 	Bit[0], if set, forces the logical device to respond to I/O reads
1544249382dSDoug Rabson 	of the logical device's assigned I/O range with a 0x55 when I/O
1554249382dSDoug Rabson 	range check is in operation.  If clear, the logical device drives
1564249382dSDoug Rabson 	0xAA.  This register is read/write.
1574249382dSDoug Rabson 	***/
1584249382dSDoug Rabson 
1594249382dSDoug Rabson /*** addr 0x32 - 0x37 Logical Device Control Reserved for future use ***/
1604249382dSDoug Rabson /*** addr 0x38 - 0x3F Logical Device Control Vendor Define ***/
1614249382dSDoug Rabson 
1624249382dSDoug Rabson #define PNP_MEM_BASE_HIGH(i)	(0x40 + 8*(i))
1634249382dSDoug Rabson #define PNP_MEM_BASE_LOW(i)	(0x41 + 8*(i))
1644249382dSDoug Rabson #define PNP_MEM_CONTROL(i)	(0x42 * 8*(i))
1654249382dSDoug Rabson #define PNP_MEM_CONTROL_16BIT	0x2
1664249382dSDoug Rabson #define PNP_MEM_CONTROL_LIMIT	0x1
1674249382dSDoug Rabson #define PNP_MEM_RANGE_HIGH(i)	(0x43 + 8*(i))
1684249382dSDoug Rabson #define PNP_MEM_RANGE_LOW(i)	(0x44 + 8*(i))
1694249382dSDoug Rabson 	/***
1704249382dSDoug Rabson 	Four memory resource registers per range, four ranges.
1714249382dSDoug Rabson 	Fill with 0 if no ranges are enabled.
1724249382dSDoug Rabson 
1734249382dSDoug Rabson 	Offset 0:	RW Memory base address bits[23:16]
1744249382dSDoug Rabson 	Offset 1:	RW Memory base address bits[15:8]
1754249382dSDoug Rabson 	Offset 2:	Memory control
1764249382dSDoug Rabson 	    Bit[1] specifies 8/16-bit control.  This bit is set to indicate
1774249382dSDoug Rabson 	    16-bit memory, and cleared to indicate 8-bit memory.
1784249382dSDoug Rabson 	    Bit[0], if cleared, indicates the next field can be used as a range
1794249382dSDoug Rabson 	    length for decode (implies range length and base alignment of memory
1804249382dSDoug Rabson 	    descriptor are equal).
1814249382dSDoug Rabson 	    Bit[0], if set, indicates the next field is the upper limit for
1824249382dSDoug Rabson 	    the address. -  - Bit[0] is read-only.
1834249382dSDoug Rabson 	Offset 3:	RW upper limit or range len, bits[23:16]
1844249382dSDoug Rabson 	Offset 4:	RW upper limit or range len, bits[15:8]
1854249382dSDoug Rabson 	Offset 5-Offset 7: filler, unused.
1864249382dSDoug Rabson 	***/
1874249382dSDoug Rabson 
1884249382dSDoug Rabson #define PNP_IO_BASE_HIGH(i)	(0x60 + 2*(i))
1894249382dSDoug Rabson #define PNP_IO_BASE_LOW(i)	(0x61 + 2*(i))
1904249382dSDoug Rabson 	/***
1914249382dSDoug Rabson 	Eight ranges, two bytes per range.
1924249382dSDoug Rabson 	Offset 0:		I/O port base address bits[15:8]
1934249382dSDoug Rabson 	Offset 1:		I/O port base address bits[7:0]
1944249382dSDoug Rabson 	***/
1954249382dSDoug Rabson 
1964249382dSDoug Rabson #define PNP_IRQ_LEVEL(i)	(0x70 + 2*(i))
1974249382dSDoug Rabson #define PNP_IRQ_TYPE(i)		(0x71 + 2*(i))
1984249382dSDoug Rabson 	/***
1994249382dSDoug Rabson 	Two entries, two bytes per entry.
2004249382dSDoug Rabson 	Offset 0:	RW interrupt level (1..15, 0=unused).
2014249382dSDoug Rabson 	Offset 1:	Bit[1]: level(1:hi, 0:low),
2024249382dSDoug Rabson 			Bit[0]: type (1:level, 0:edge)
2034249382dSDoug Rabson 		byte 1 can be readonly if 1 type of int is used.
2044249382dSDoug Rabson 	***/
2054249382dSDoug Rabson 
2064249382dSDoug Rabson #define PNP_DMA_CHANNEL(i)	(0x74 + 1*(i))
2074249382dSDoug Rabson 	/***
2084249382dSDoug Rabson 	Two entries, one byte per entry. Bits[2:0] select
2094249382dSDoug Rabson 	which DMA channel is in use for DMA 0.  Zero selects DMA channel
2104249382dSDoug Rabson 	0, seven selects DMA channel 7. DMA channel 4, the cascade channel
2114249382dSDoug Rabson 	is used to indicate no DMA channel is active.
2124249382dSDoug Rabson 	***/
2134249382dSDoug Rabson 
2144249382dSDoug Rabson /*** 32-bit memory accesses are at 0x76 ***/
2154249382dSDoug Rabson 
2164249382dSDoug Rabson /* Macros to parse Resource IDs */
2174249382dSDoug Rabson #define PNP_RES_TYPE(a)		(a >> 7)
2184249382dSDoug Rabson #define PNP_SRES_NUM(a)		(a >> 3)
2194249382dSDoug Rabson #define PNP_SRES_LEN(a)		(a & 0x07)
2204249382dSDoug Rabson #define PNP_LRES_NUM(a)		(a & 0x7f)
2214249382dSDoug Rabson 
2224249382dSDoug Rabson /* Small Resource Item names */
2234249382dSDoug Rabson #define PNP_TAG_VERSION		0x1
22448ab255eSPeter Wemm #define PNP_TAG_LOGICAL_DEVICE	0x2
2254249382dSDoug Rabson #define PNP_TAG_COMPAT_DEVICE	0x3
2264249382dSDoug Rabson #define PNP_TAG_IRQ_FORMAT	0x4
2274249382dSDoug Rabson #define PNP_TAG_DMA_FORMAT	0x5
2284249382dSDoug Rabson #define PNP_TAG_START_DEPENDANT	0x6
2294249382dSDoug Rabson #define PNP_TAG_END_DEPENDANT	0x7
2304249382dSDoug Rabson #define PNP_TAG_IO_RANGE	0x8
2314249382dSDoug Rabson #define PNP_TAG_IO_FIXED	0x9
2324249382dSDoug Rabson #define PNP_TAG_RESERVED	0xa-0xd
2334249382dSDoug Rabson #define PNP_TAG_VENDOR		0xe
2344249382dSDoug Rabson #define PNP_TAG_END		0xf
2354249382dSDoug Rabson 
2364249382dSDoug Rabson /* Large Resource Item names */
2374249382dSDoug Rabson #define PNP_TAG_MEMORY_RANGE	0x1
2384249382dSDoug Rabson #define PNP_TAG_ID_ANSI		0x2
2394249382dSDoug Rabson #define PNP_TAG_ID_UNICODE	0x3
2404249382dSDoug Rabson #define PNP_TAG_LARGE_VENDOR	0x4
2414249382dSDoug Rabson #define PNP_TAG_MEMORY32_RANGE	0x5
2424249382dSDoug Rabson #define PNP_TAG_MEMORY32_FIXED	0x6
2434249382dSDoug Rabson #define PNP_TAG_LARGE_RESERVED	0x7-0x7f
2444249382dSDoug Rabson 
2454249382dSDoug Rabson #endif /* !_ISA_PNPREG_H_ */
246