/*1* Copyright (c) 1996, Sujal M. Patel2* All rights reserved.3*4* Redistribution and use in source and binary forms, with or without5* modification, are permitted provided that the following conditions6* are met:7* 1. Redistributions of source code must retain the above copyright8* notice, this list of conditions and the following disclaimer.9* 2. Redistributions in binary form must reproduce the above copyright10* notice, this list of conditions and the following disclaimer in the11* documentation and/or other materials provided with the distribution.12* 3. All advertising materials mentioning features or use of this software13* must display the following acknowledgement:14* This product includes software developed by Sujal M. Patel15* 4. Neither the name of the author nor the names of any co-contributors16* may be used to endorse or promote products derived from this software17* without specific prior written permission.18*19* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND20* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE21* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE22* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE23* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL24* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS25* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)26* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT27* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY28* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF29* SUCH DAMAGE.30*/3132#ifndef _I386_ISA_PNP_H_33#define _I386_ISA_PNP_H_3435/* Maximum Number of PnP Devices. 8 should be plenty */36#define MAX_PNP_CARDS 837/*38* the following is the maximum number of PnP Logical devices that39* userconfig can handle.40*/41#define MAX_PNP_LDN 204243/* Static ports to access PnP state machine */44#ifndef _KERNEL45#define _PNP_ADDRESS 0x27946#define _PNP_WRITE_DATA 0xa7947#endif4849/* PnP Registers. Write to ADDRESS and then use WRITE/READ_DATA */50#define SET_RD_DATA 0x0051/***52Writing to this location modifies the address of the port used for53reading from the Plug and Play ISA cards. Bits[7:0] become I/O54read port address bits[9:2]. Reads from this register are ignored.55***/5657#define SERIAL_ISOLATION 0x0158/***59A read to this register causes a Plug and Play cards in the Isolation60state to compare one bit of the boards ID.61This register is read only.62***/6364#define CONFIG_CONTROL 0x0265/***66Bit[2] Reset CSN to 067Bit[1] Return to the Wait for Key state68Bit[0] Reset all logical devices and restore configuration69registers to their power-up values.7071A write to bit[0] of this register performs a reset function on72all logical devices. This resets the contents of configuration73registers to their default state. All card's logical devices74enter their default state and the CSN is preserved.7576A write to bit[1] of this register causes all cards to enter the77Wait for Key state but all CSNs are preserved and logical devices78are not affected.7980A write to bit[2] of this register causes all cards to reset their81CSN to zero .8283This register is write-only. The values are not sticky, that is,84hardware will automatically clear them and there is no need for85software to clear the bits.86***/8788#define WAKE 0x0389/***90A write to this port will cause all cards that have a CSN that91matches the write data[7:0] to go from the Sleep state to the either92the Isolation state if the write data for this command is zero or93the Config state if the write data is not zero. Additionally, the94pointer to the byte-serial device is reset. This register is95writeonly.96***/9798#define RESOURCE_DATA 0x0499/***100A read from this address reads the next byte of resource information.101The Status register must be polled until bit[0] is set before this102register may be read. This register is read only.103***/104105#define STATUS 0x05106/***107Bit[0] when set indicates it is okay to read the next data byte108from the Resource Data register. This register is readonly.109***/110111#define SET_CSN 0x06112/***113A write to this port sets a card's CSN. The CSN is a value uniquely114assigned to each ISA card after the serial identification process115so that each card may be individually selected during a Wake[CSN]116command. This register is read/write.117***/118119#define SET_LDN 0x07120/***121Selects the current logical device. All reads and writes of memory,122I/O, interrupt and DMA configuration information access the registers123of the logical device written here. In addition, the I/O Range124Check and Activate commands operate only on the selected logical125device. This register is read/write. If a card has only 1 logical126device, this location should be a read-only value of 0x00.127***/128129/*** addresses 0x08 - 0x1F Card Level Reserved for future use ***/130/*** addresses 0x20 - 0x2F Card Level, Vendor Defined ***/131132#define ACTIVATE 0x30133/***134For each logical device there is one activate register that controls135whether or not the logical device is active on the ISA bus. Bit[0],136if set, activates the logical device. Bits[7:1] are reserved and137must return 0 on reads. This is a read/write register. Before a138logical device is activated, I/O range check must be disabled.139***/140141#define IO_RANGE_CHECK 0x31142/***143This register is used to perform a conflict check on the I/O port144range programmed for use by a logical device.145146Bit[7:2] Reserved and must return 0 on reads147Bit[1] Enable I/O Range check, if set then I/O Range Check148is enabled. I/O range check is only valid when the logical149device is inactive.150151Bit[0], if set, forces the logical device to respond to I/O reads152of the logical device's assigned I/O range with a 0x55 when I/O153range check is in operation. If clear, the logical device drives1540xAA. This register is read/write.155***/156157/*** addr 0x32 - 0x37 Logical Device Control Reserved for future use ***/158/*** addr 0x38 - 0x3F Logical Device Control Vendor Define ***/159160#define MEM_CONFIG 0x40161/***162Four memory resource registers per range, four ranges.163Fill with 0 if no ranges are enabled.164165Offset 0: RW Memory base address bits[23:16]166Offset 1: RW Memory base address bits[15:8]167Offset 2: Memory control168Bit[1] specifies 8/16-bit control. This bit is set to indicate16916-bit memory, and cleared to indicate 8-bit memory.170Bit[0], if cleared, indicates the next field can be used as a range171length for decode (implies range length and base alignment of memory172descriptor are equal).173Bit[0], if set, indicates the next field is the upper limit for174the address. - - Bit[0] is read-only.175Offset 3: RW upper limit or range len, bits[23:16]176Offset 4: RW upper limit or range len, bits[15:8]177Offset 5-Offset 7: filler, unused.178***/179180#define IO_CONFIG_BASE 0x60181/***182Eight ranges, two bytes per range.183Offset 0: I/O port base address bits[15:8]184Offset 1: I/O port base address bits[7:0]185***/186187#define IRQ_CONFIG 0x70188/***189Two entries, two bytes per entry.190Offset 0: RW interrupt level (1..15, 0=unused).191Offset 1: Bit[1]: level(1:hi, 0:low),192Bit[0]: type (1:level, 0:edge)193byte 1 can be readonly if 1 type of int is used.194***/195196#define DRQ_CONFIG 0x74197/***198Two entries, one byte per entry. Bits[2:0] select199which DMA channel is in use for DMA 0. Zero selects DMA channel2000, seven selects DMA channel 7. DMA channel 4, the cascade channel201is used to indicate no DMA channel is active.202***/203204/*** 32-bit memory accesses are at 0x76 ***/205206/* Macros to parse Resource IDs */207#define PNP_RES_TYPE(a) (a >> 7)208#define PNP_SRES_NUM(a) (a >> 3)209#define PNP_SRES_LEN(a) (a & 0x07)210#define PNP_LRES_NUM(a) (a & 0x7f)211212/* Small Resource Item names */213#define PNP_VERSION 0x1214#define LOG_DEVICE_ID 0x2215#define COMP_DEVICE_ID 0x3216#define IRQ_FORMAT 0x4217#define DMA_FORMAT 0x5218#define START_DEPEND_FUNC 0x6219#define END_DEPEND_FUNC 0x7220#define IO_PORT_DESC 0x8221#define FIXED_IO_PORT_DESC 0x9222#define SM_RES_RESERVED 0xa-0xd223#define SM_VENDOR_DEFINED 0xe224#define END_TAG 0xf225226/* Large Resource Item names */227#define MEMORY_RANGE_DESC 0x1228#define ID_STRING_ANSI 0x2229#define ID_STRING_UNICODE 0x3230#define LG_VENDOR_DEFINED 0x4231#define _32BIT_MEM_RANGE_DESC 0x5232#define _32BIT_FIXED_LOC_DESC 0x6233#define LG_RES_RESERVED 0x7-0x7f234235/*236* pnp_cinfo contains Configuration Information. They are used237* to communicate to the device driver the actual configuration238* of the device, and also by the userconfig menu to let the239* operating system override any configuration set by the bios.240*241*/242struct pnp_cinfo {243u_int vendor_id; /* board id */244u_int serial; /* Board's Serial Number */245u_long flags; /* OS-reserved flags */246u_char csn; /* assigned Card Select Number */247u_char ldn; /* Logical Device Number */248u_char enable; /* pnp enable */249u_char override; /* override bios parms (in userconfig) */250u_char irq[2]; /* IRQ Number */251u_char irq_type[2]; /* IRQ Type */252u_char drq[2];253u_short port[8]; /* The Base Address of the Port */254struct {255u_long base; /* Memory Base Address */256int control; /* Memory Control Register */257u_long range; /* Memory Range *OR* Upper Limit */258} mem[4];259};260261#ifdef _KERNEL262263struct pnp_device {264char *pd_name;265char * (*pd_probe ) (u_long csn, u_long vendor_id);266void (*pd_attach ) (u_long csn, u_long vend_id, char * name,267struct isa_device *dev);268u_long *pd_count;269u_int *imask ;270};271272struct _pnp_id {273u_long vendor_id;274u_long serial;275u_char checksum;276} ;277278struct pnp_dlist_node {279struct pnp_device *pnp;280struct isa_device dev;281struct pnp_dlist_node *next;282};283284typedef struct _pnp_id pnp_id;285extern struct pnp_dlist_node *pnp_device_list;286extern pnp_id pnp_devices[MAX_PNP_CARDS];287extern struct pnp_cinfo pnp_ldn_overrides[MAX_PNP_LDN];288extern int pnp_overrides_valid;289290/*291* these two functions are for use in drivers292*/293int read_pnp_parms(struct pnp_cinfo *d, int ldn);294int write_pnp_parms(struct pnp_cinfo *d, int ldn);295int enable_pnp_card(void);296297/*298* used by autoconfigure to actually probe and attach drivers299*/300void pnp_configure(void);301302#endif /* _KERNEL */303304#endif /* !_I386_ISA_PNP_H_ */305306307