14249382dSDoug Rabson /* 24249382dSDoug Rabson * Copyright (c) 1996, Sujal M. Patel 34249382dSDoug Rabson * All rights reserved. 44249382dSDoug Rabson * 54249382dSDoug Rabson * Redistribution and use in source and binary forms, with or without 64249382dSDoug Rabson * modification, are permitted provided that the following conditions 74249382dSDoug Rabson * are met: 84249382dSDoug Rabson * 1. Redistributions of source code must retain the above copyright 94249382dSDoug Rabson * notice, this list of conditions and the following disclaimer. 104249382dSDoug Rabson * 2. Redistributions in binary form must reproduce the above copyright 114249382dSDoug Rabson * notice, this list of conditions and the following disclaimer in the 124249382dSDoug Rabson * documentation and/or other materials provided with the distribution. 134249382dSDoug Rabson * 144249382dSDoug Rabson * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 154249382dSDoug Rabson * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 164249382dSDoug Rabson * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 174249382dSDoug Rabson * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 184249382dSDoug Rabson * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 194249382dSDoug Rabson * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 204249382dSDoug Rabson * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 214249382dSDoug Rabson * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 224249382dSDoug Rabson * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 234249382dSDoug Rabson * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 244249382dSDoug Rabson * SUCH DAMAGE. 254249382dSDoug Rabson * 264249382dSDoug Rabson * $FreeBSD$ 274249382dSDoug Rabson * from: pnp.c,v 1.11 1999/05/06 22:11:19 peter Exp 284249382dSDoug Rabson */ 294249382dSDoug Rabson 304249382dSDoug Rabson #include <sys/param.h> 314249382dSDoug Rabson #include <sys/systm.h> 324249382dSDoug Rabson #include <sys/kernel.h> 334249382dSDoug Rabson #include <sys/module.h> 344249382dSDoug Rabson #include <sys/bus.h> 354249382dSDoug Rabson #include <sys/malloc.h> 364249382dSDoug Rabson #include <isa/isavar.h> 374249382dSDoug Rabson #include <isa/pnpreg.h> 384249382dSDoug Rabson #include <isa/pnpvar.h> 394249382dSDoug Rabson #include <machine/clock.h> 4021c3015aSDoug Rabson #include <machine/bus.h> 414249382dSDoug Rabson 424249382dSDoug Rabson typedef struct _pnp_id { 434249382dSDoug Rabson u_int32_t vendor_id; 444249382dSDoug Rabson u_int32_t serial; 454249382dSDoug Rabson u_char checksum; 464249382dSDoug Rabson } pnp_id; 474249382dSDoug Rabson 484249382dSDoug Rabson struct pnp_set_config_arg { 494249382dSDoug Rabson int csn; /* Card number to configure */ 504249382dSDoug Rabson int ldn; /* Logical device on card */ 514249382dSDoug Rabson }; 524249382dSDoug Rabson 534249382dSDoug Rabson struct pnp_quirk { 544249382dSDoug Rabson u_int32_t vendor_id; /* Vendor of the card */ 554249382dSDoug Rabson u_int32_t logical_id; /* ID of the device with quirk */ 564249382dSDoug Rabson int type; 574249382dSDoug Rabson #define PNP_QUIRK_WRITE_REG 1 /* Need to write a pnp register */ 58fb0ef528SSeigo Tanimura #define PNP_QUIRK_EXTRA_IO 2 /* Has extra io ports */ 594249382dSDoug Rabson int arg1; 604249382dSDoug Rabson int arg2; 614249382dSDoug Rabson }; 624249382dSDoug Rabson 634249382dSDoug Rabson struct pnp_quirk pnp_quirks[] = { 644249382dSDoug Rabson /* 654249382dSDoug Rabson * The Gravis UltraSound needs register 0xf2 to be set to 0xff 664249382dSDoug Rabson * to enable power. 674249382dSDoug Rabson * XXX need to know the logical device id. 684249382dSDoug Rabson */ 694249382dSDoug Rabson { 0x0100561e /* GRV0001 */, 0, 704249382dSDoug Rabson PNP_QUIRK_WRITE_REG, 0xf2, 0xff }, 71fb0ef528SSeigo Tanimura /* 72fb0ef528SSeigo Tanimura * An emu8000 does not give us other than the first 73fb0ef528SSeigo Tanimura * port. 74fb0ef528SSeigo Tanimura */ 75fb0ef528SSeigo Tanimura { 0x26008c0e /* SB16 */, 0x21008c0e, 76fb0ef528SSeigo Tanimura PNP_QUIRK_EXTRA_IO, 0x400, 0x800 }, 77fb0ef528SSeigo Tanimura { 0x42008c0e /* SB32(CTL0042) */, 0x21008c0e, 78fb0ef528SSeigo Tanimura PNP_QUIRK_EXTRA_IO, 0x400, 0x800 }, 79fb0ef528SSeigo Tanimura { 0x44008c0e /* SB32(CTL0044) */, 0x21008c0e, 80fb0ef528SSeigo Tanimura PNP_QUIRK_EXTRA_IO, 0x400, 0x800 }, 81fb0ef528SSeigo Tanimura { 0x49008c0e /* SB32(CTL0049) */, 0x21008c0e, 82fb0ef528SSeigo Tanimura PNP_QUIRK_EXTRA_IO, 0x400, 0x800 }, 83fb0ef528SSeigo Tanimura { 0xf1008c0e /* SB32(CTL00f1) */, 0x21008c0e, 84fb0ef528SSeigo Tanimura PNP_QUIRK_EXTRA_IO, 0x400, 0x800 }, 85fb0ef528SSeigo Tanimura { 0xc1008c0e /* SB64(CTL00c1) */, 0x22008c0e, 86fb0ef528SSeigo Tanimura PNP_QUIRK_EXTRA_IO, 0x400, 0x800 }, 87fb0ef528SSeigo Tanimura { 0xe4008c0e /* SB64(CTL00e4) */, 0x22008c0e, 88fb0ef528SSeigo Tanimura PNP_QUIRK_EXTRA_IO, 0x400, 0x800 }, 894249382dSDoug Rabson 904249382dSDoug Rabson { 0 } 914249382dSDoug Rabson }; 924249382dSDoug Rabson 934249382dSDoug Rabson #if 0 944249382dSDoug Rabson /* 954249382dSDoug Rabson * these entries are initialized using the autoconfig menu 964249382dSDoug Rabson * The struct is invalid (and must be initialized) if the first 974249382dSDoug Rabson * CSN is zero. The init code fills invalid entries with CSN 255 984249382dSDoug Rabson * which is not a supported value. 994249382dSDoug Rabson */ 1004249382dSDoug Rabson 1014249382dSDoug Rabson struct pnp_cinfo pnp_ldn_overrides[MAX_PNP_LDN] = { 1024249382dSDoug Rabson { 0 } 1034249382dSDoug Rabson }; 1044249382dSDoug Rabson #endif 1054249382dSDoug Rabson 1064249382dSDoug Rabson /* The READ_DATA port that we are using currently */ 1074249382dSDoug Rabson static int pnp_rd_port; 1084249382dSDoug Rabson 1094249382dSDoug Rabson static void pnp_send_initiation_key(void); 1104249382dSDoug Rabson static int pnp_get_serial(pnp_id *p); 1114249382dSDoug Rabson static int pnp_isolation_protocol(device_t parent); 1124249382dSDoug Rabson 113bb2b9030SDoug Rabson char * 114bb2b9030SDoug Rabson pnp_eisaformat(u_int32_t id) 115bb2b9030SDoug Rabson { 116bb2b9030SDoug Rabson u_int8_t *data = (u_int8_t *) &id; 117bb2b9030SDoug Rabson static char idbuf[8]; 118bb2b9030SDoug Rabson const char hextoascii[] = "0123456789abcdef"; 119bb2b9030SDoug Rabson 120bb2b9030SDoug Rabson idbuf[0] = '@' + ((data[0] & 0x7c) >> 2); 121bb2b9030SDoug Rabson idbuf[1] = '@' + (((data[0] & 0x3) << 3) + ((data[1] & 0xe0) >> 5)); 122bb2b9030SDoug Rabson idbuf[2] = '@' + (data[1] & 0x1f); 123bb2b9030SDoug Rabson idbuf[3] = hextoascii[(data[2] >> 4)]; 124bb2b9030SDoug Rabson idbuf[4] = hextoascii[(data[2] & 0xf)]; 125bb2b9030SDoug Rabson idbuf[5] = hextoascii[(data[3] >> 4)]; 126bb2b9030SDoug Rabson idbuf[6] = hextoascii[(data[3] & 0xf)]; 127bb2b9030SDoug Rabson idbuf[7] = 0; 128bb2b9030SDoug Rabson return(idbuf); 129bb2b9030SDoug Rabson } 130bb2b9030SDoug Rabson 1314249382dSDoug Rabson static void 1324249382dSDoug Rabson pnp_write(int d, u_char r) 1334249382dSDoug Rabson { 1344249382dSDoug Rabson outb (_PNP_ADDRESS, d); 1354249382dSDoug Rabson outb (_PNP_WRITE_DATA, r); 1364249382dSDoug Rabson } 1374249382dSDoug Rabson 1384249382dSDoug Rabson #if 0 1394249382dSDoug Rabson 1404249382dSDoug Rabson static u_char 1414249382dSDoug Rabson pnp_read(int d) 1424249382dSDoug Rabson { 1434249382dSDoug Rabson outb (_PNP_ADDRESS, d); 1444249382dSDoug Rabson return (inb(3 | (pnp_rd_port <<2))); 1454249382dSDoug Rabson } 1464249382dSDoug Rabson 1474249382dSDoug Rabson #endif 1484249382dSDoug Rabson 1494249382dSDoug Rabson /* 1504249382dSDoug Rabson * Send Initiation LFSR as described in "Plug and Play ISA Specification", 1514249382dSDoug Rabson * Intel May 94. 1524249382dSDoug Rabson */ 1534249382dSDoug Rabson static void 1544249382dSDoug Rabson pnp_send_initiation_key() 1554249382dSDoug Rabson { 1564249382dSDoug Rabson int cur, i; 1574249382dSDoug Rabson 1584249382dSDoug Rabson /* Reset the LSFR */ 1594249382dSDoug Rabson outb(_PNP_ADDRESS, 0); 1604249382dSDoug Rabson outb(_PNP_ADDRESS, 0); /* yes, we do need it twice! */ 1614249382dSDoug Rabson 1624249382dSDoug Rabson cur = 0x6a; 1634249382dSDoug Rabson outb(_PNP_ADDRESS, cur); 1644249382dSDoug Rabson 1654249382dSDoug Rabson for (i = 1; i < 32; i++) { 1664249382dSDoug Rabson cur = (cur >> 1) | (((cur ^ (cur >> 1)) << 7) & 0xff); 1674249382dSDoug Rabson outb(_PNP_ADDRESS, cur); 1684249382dSDoug Rabson } 1694249382dSDoug Rabson } 1704249382dSDoug Rabson 1714249382dSDoug Rabson 1724249382dSDoug Rabson /* 1734249382dSDoug Rabson * Get the device's serial number. Returns 1 if the serial is valid. 1744249382dSDoug Rabson */ 1754249382dSDoug Rabson static int 1764249382dSDoug Rabson pnp_get_serial(pnp_id *p) 1774249382dSDoug Rabson { 1784249382dSDoug Rabson int i, bit, valid = 0, sum = 0x6a; 1794249382dSDoug Rabson u_char *data = (u_char *)p; 1804249382dSDoug Rabson 1814249382dSDoug Rabson bzero(data, sizeof(char) * 9); 1824249382dSDoug Rabson outb(_PNP_ADDRESS, PNP_SERIAL_ISOLATION); 1834249382dSDoug Rabson for (i = 0; i < 72; i++) { 1844249382dSDoug Rabson bit = inb((pnp_rd_port << 2) | 0x3) == 0x55; 1854249382dSDoug Rabson DELAY(250); /* Delay 250 usec */ 1864249382dSDoug Rabson 1874249382dSDoug Rabson /* Can't Short Circuit the next evaluation, so 'and' is last */ 1884249382dSDoug Rabson bit = (inb((pnp_rd_port << 2) | 0x3) == 0xaa) && bit; 1894249382dSDoug Rabson DELAY(250); /* Delay 250 usec */ 1904249382dSDoug Rabson 1914249382dSDoug Rabson valid = valid || bit; 1924249382dSDoug Rabson 1934249382dSDoug Rabson if (i < 64) 1944249382dSDoug Rabson sum = (sum >> 1) | 1954249382dSDoug Rabson (((sum ^ (sum >> 1) ^ bit) << 7) & 0xff); 1964249382dSDoug Rabson 1974249382dSDoug Rabson data[i / 8] = (data[i / 8] >> 1) | (bit ? 0x80 : 0); 1984249382dSDoug Rabson } 1994249382dSDoug Rabson 2004249382dSDoug Rabson valid = valid && (data[8] == sum); 2014249382dSDoug Rabson 2024249382dSDoug Rabson return valid; 2034249382dSDoug Rabson } 2044249382dSDoug Rabson 2054249382dSDoug Rabson /* 2064249382dSDoug Rabson * Fill's the buffer with resource info from the device. 2075b45337dSDoug Rabson * Returns the number of characters read. 2084249382dSDoug Rabson */ 2094249382dSDoug Rabson static int 2104249382dSDoug Rabson pnp_get_resource_info(u_char *buffer, int len) 2114249382dSDoug Rabson { 2125b45337dSDoug Rabson int i, j, count; 2134249382dSDoug Rabson u_char temp; 2144249382dSDoug Rabson 2155b45337dSDoug Rabson count = 0; 2164249382dSDoug Rabson for (i = 0; i < len; i++) { 2174249382dSDoug Rabson outb(_PNP_ADDRESS, PNP_STATUS); 2184249382dSDoug Rabson for (j = 0; j < 100; j++) { 2194249382dSDoug Rabson if ((inb((pnp_rd_port << 2) | 0x3)) & 0x1) 2204249382dSDoug Rabson break; 2214249382dSDoug Rabson DELAY(1); 2224249382dSDoug Rabson } 2234249382dSDoug Rabson if (j == 100) { 2244249382dSDoug Rabson printf("PnP device failed to report resource data\n"); 2255b45337dSDoug Rabson return count; 2264249382dSDoug Rabson } 2274249382dSDoug Rabson outb(_PNP_ADDRESS, PNP_RESOURCE_DATA); 2284249382dSDoug Rabson temp = inb((pnp_rd_port << 2) | 0x3); 2294249382dSDoug Rabson if (buffer != NULL) 2304249382dSDoug Rabson buffer[i] = temp; 2315b45337dSDoug Rabson count++; 2324249382dSDoug Rabson } 2335b45337dSDoug Rabson return count; 2344249382dSDoug Rabson } 2354249382dSDoug Rabson 2364249382dSDoug Rabson #if 0 2374249382dSDoug Rabson /* 2384249382dSDoug Rabson * write_pnp_parms initializes a logical device with the parms 2394249382dSDoug Rabson * in d, and then activates the board if the last parameter is 1. 2404249382dSDoug Rabson */ 2414249382dSDoug Rabson 2424249382dSDoug Rabson static int 2434249382dSDoug Rabson write_pnp_parms(struct pnp_cinfo *d, pnp_id *p, int ldn) 2444249382dSDoug Rabson { 2454249382dSDoug Rabson int i, empty = -1 ; 2464249382dSDoug Rabson 2474249382dSDoug Rabson pnp_write (SET_LDN, ldn ); 2484249382dSDoug Rabson i = pnp_read(SET_LDN) ; 2494249382dSDoug Rabson if (i != ldn) { 2504249382dSDoug Rabson printf("Warning: LDN %d does not exist\n", ldn); 2514249382dSDoug Rabson } 2524249382dSDoug Rabson for (i = 0; i < 8; i++) { 2534249382dSDoug Rabson pnp_write(IO_CONFIG_BASE + i * 2, d->ic_port[i] >> 8 ); 2544249382dSDoug Rabson pnp_write(IO_CONFIG_BASE + i * 2 + 1, d->ic_port[i] & 0xff ); 2554249382dSDoug Rabson } 2564249382dSDoug Rabson for (i = 0; i < 4; i++) { 2574249382dSDoug Rabson pnp_write(MEM_CONFIG + i*8, (d->ic_mem[i].base >> 16) & 0xff ); 2584249382dSDoug Rabson pnp_write(MEM_CONFIG + i*8+1, (d->ic_mem[i].base >> 8) & 0xff ); 2594249382dSDoug Rabson pnp_write(MEM_CONFIG + i*8+2, d->ic_mem[i].control & 0xff ); 2604249382dSDoug Rabson pnp_write(MEM_CONFIG + i*8+3, (d->ic_mem[i].range >> 16) & 0xff ); 2614249382dSDoug Rabson pnp_write(MEM_CONFIG + i*8+4, (d->ic_mem[i].range >> 8) & 0xff ); 2624249382dSDoug Rabson } 2634249382dSDoug Rabson for (i = 0; i < 2; i++) { 2644249382dSDoug Rabson pnp_write(IRQ_CONFIG + i*2 , d->irq[i] ); 2654249382dSDoug Rabson pnp_write(IRQ_CONFIG + i*2 + 1, d->irq_type[i] ); 2664249382dSDoug Rabson pnp_write(DRQ_CONFIG + i, d->drq[i] ); 2674249382dSDoug Rabson } 2684249382dSDoug Rabson /* 2694249382dSDoug Rabson * store parameters read into the current kernel 2704249382dSDoug Rabson * so manual editing next time is easier 2714249382dSDoug Rabson */ 2724249382dSDoug Rabson for (i = 0 ; i < MAX_PNP_LDN; i++) { 2734249382dSDoug Rabson if (pnp_ldn_overrides[i].csn == d->csn && 2744249382dSDoug Rabson pnp_ldn_overrides[i].ldn == ldn) { 2754249382dSDoug Rabson d->flags = pnp_ldn_overrides[i].flags ; 2764249382dSDoug Rabson pnp_ldn_overrides[i] = *d ; 2774249382dSDoug Rabson break ; 2784249382dSDoug Rabson } else if (pnp_ldn_overrides[i].csn < 1 || 2794249382dSDoug Rabson pnp_ldn_overrides[i].csn == 255) 2804249382dSDoug Rabson empty = i ; 2814249382dSDoug Rabson } 2824249382dSDoug Rabson if (i== MAX_PNP_LDN && empty != -1) 2834249382dSDoug Rabson pnp_ldn_overrides[empty] = *d; 2844249382dSDoug Rabson 2854249382dSDoug Rabson /* 2864249382dSDoug Rabson * Here should really perform the range check, and 2874249382dSDoug Rabson * return a failure if not successful. 2884249382dSDoug Rabson */ 2894249382dSDoug Rabson pnp_write (IO_RANGE_CHECK, 0); 2904249382dSDoug Rabson DELAY(1000); /* XXX is it really necessary ? */ 2914249382dSDoug Rabson pnp_write (ACTIVATE, d->enable ? 1 : 0); 2924249382dSDoug Rabson DELAY(1000); /* XXX is it really necessary ? */ 2934249382dSDoug Rabson return 1 ; 2944249382dSDoug Rabson } 2954249382dSDoug Rabson #endif 2964249382dSDoug Rabson 2974249382dSDoug Rabson /* 2984249382dSDoug Rabson * This function is called after the bus has assigned resource 2994249382dSDoug Rabson * locations for a logical device. 3004249382dSDoug Rabson */ 3014249382dSDoug Rabson static void 3024249382dSDoug Rabson pnp_set_config(void *arg, struct isa_config *config, int enable) 3034249382dSDoug Rabson { 3044249382dSDoug Rabson int csn = ((struct pnp_set_config_arg *) arg)->csn; 3054249382dSDoug Rabson int ldn = ((struct pnp_set_config_arg *) arg)->ldn; 3064249382dSDoug Rabson int i; 3074249382dSDoug Rabson 3084249382dSDoug Rabson /* 3094249382dSDoug Rabson * First put all cards into Sleep state with the initiation 3104249382dSDoug Rabson * key, then put our card into Config state. 3114249382dSDoug Rabson */ 3124249382dSDoug Rabson pnp_send_initiation_key(); 3134249382dSDoug Rabson pnp_write(PNP_WAKE, csn); 3144249382dSDoug Rabson 3154249382dSDoug Rabson /* 3164249382dSDoug Rabson * Select our logical device so that we can program it. 3174249382dSDoug Rabson */ 3184249382dSDoug Rabson pnp_write(PNP_SET_LDN, ldn); 3194249382dSDoug Rabson 3204249382dSDoug Rabson /* 3214249382dSDoug Rabson * Now program the resources. 3224249382dSDoug Rabson */ 3234249382dSDoug Rabson for (i = 0; i < config->ic_nmem; i++) { 3244249382dSDoug Rabson u_int32_t start = config->ic_mem[i].ir_start; 3254249382dSDoug Rabson u_int32_t size = config->ic_mem[i].ir_size; 3264249382dSDoug Rabson if (start & 0xff) 3274249382dSDoug Rabson panic("pnp_set_config: bogus memory assignment"); 3284249382dSDoug Rabson pnp_write(PNP_MEM_BASE_HIGH(i), (start >> 16) & 0xff); 3294249382dSDoug Rabson pnp_write(PNP_MEM_BASE_LOW(i), (start >> 8) & 0xff); 3304249382dSDoug Rabson pnp_write(PNP_MEM_RANGE_HIGH(i), (size >> 16) & 0xff); 3314249382dSDoug Rabson pnp_write(PNP_MEM_RANGE_LOW(i), (size >> 8) & 0xff); 3324249382dSDoug Rabson } 3334249382dSDoug Rabson for (; i < ISA_NMEM; i++) { 3344249382dSDoug Rabson pnp_write(PNP_MEM_BASE_HIGH(i), 0); 3354249382dSDoug Rabson pnp_write(PNP_MEM_BASE_LOW(i), 0); 3364249382dSDoug Rabson pnp_write(PNP_MEM_RANGE_HIGH(i), 0); 3374249382dSDoug Rabson pnp_write(PNP_MEM_RANGE_LOW(i), 0); 3384249382dSDoug Rabson } 3394249382dSDoug Rabson 3404249382dSDoug Rabson for (i = 0; i < config->ic_nport; i++) { 3414249382dSDoug Rabson u_int32_t start = config->ic_port[i].ir_start; 3424249382dSDoug Rabson pnp_write(PNP_IO_BASE_HIGH(i), (start >> 8) & 0xff); 3434249382dSDoug Rabson pnp_write(PNP_IO_BASE_LOW(i), (start >> 0) & 0xff); 3444249382dSDoug Rabson } 3454249382dSDoug Rabson for (; i < ISA_NPORT; i++) { 3464249382dSDoug Rabson pnp_write(PNP_IO_BASE_HIGH(i), 0); 3474249382dSDoug Rabson pnp_write(PNP_IO_BASE_LOW(i), 0); 3484249382dSDoug Rabson } 3494249382dSDoug Rabson 3504249382dSDoug Rabson for (i = 0; i < config->ic_nirq; i++) { 3514249382dSDoug Rabson int irq = ffs(config->ic_irqmask[i]) - 1; 3524249382dSDoug Rabson pnp_write(PNP_IRQ_LEVEL(i), irq); 3534249382dSDoug Rabson pnp_write(PNP_IRQ_TYPE(i), 2); /* XXX */ 3544249382dSDoug Rabson } 3554249382dSDoug Rabson for (; i < ISA_NIRQ; i++) { 3564249382dSDoug Rabson /* 3574249382dSDoug Rabson * IRQ 0 is not a valid interrupt selection and 3584249382dSDoug Rabson * represents no interrupt selection. 3594249382dSDoug Rabson */ 3604249382dSDoug Rabson pnp_write(PNP_IRQ_LEVEL(i), 0); 3614249382dSDoug Rabson } 3624249382dSDoug Rabson 3634249382dSDoug Rabson for (i = 0; i < config->ic_ndrq; i++) { 3644249382dSDoug Rabson int drq = ffs(config->ic_drqmask[i]) - 1; 3654249382dSDoug Rabson pnp_write(PNP_DMA_CHANNEL(i), drq); 3664249382dSDoug Rabson } 3674249382dSDoug Rabson for (; i < ISA_NDRQ; i++) { 3684249382dSDoug Rabson /* 3694249382dSDoug Rabson * DMA channel 4, the cascade channel is used to 3704249382dSDoug Rabson * indicate no DMA channel is active. 3714249382dSDoug Rabson */ 3724249382dSDoug Rabson pnp_write(PNP_DMA_CHANNEL(i), 4); 3734249382dSDoug Rabson } 3744249382dSDoug Rabson 3754249382dSDoug Rabson pnp_write(PNP_ACTIVATE, enable ? 1 : 0); 3764249382dSDoug Rabson 3774249382dSDoug Rabson /* 3784249382dSDoug Rabson * Wake everyone up again, we are finished. 3794249382dSDoug Rabson */ 3804249382dSDoug Rabson pnp_write(PNP_CONFIG_CONTROL, PNP_CONFIG_CONTROL_WAIT_FOR_KEY); 3814249382dSDoug Rabson } 3824249382dSDoug Rabson 3834249382dSDoug Rabson /* 3844249382dSDoug Rabson * Process quirks for a logical device.. The card must be in Config state. 3854249382dSDoug Rabson */ 386fb0ef528SSeigo Tanimura void 387fb0ef528SSeigo Tanimura pnp_check_quirks(u_int32_t vendor_id, u_int32_t logical_id, int ldn, struct isa_config *config) 3884249382dSDoug Rabson { 3894249382dSDoug Rabson struct pnp_quirk *qp; 3904249382dSDoug Rabson 3914249382dSDoug Rabson for (qp = &pnp_quirks[0]; qp->vendor_id; qp++) { 3924249382dSDoug Rabson if (qp->vendor_id == vendor_id 3934249382dSDoug Rabson && (qp->logical_id == 0 3944249382dSDoug Rabson || qp->logical_id == logical_id)) { 3954249382dSDoug Rabson switch (qp->type) { 3964249382dSDoug Rabson case PNP_QUIRK_WRITE_REG: 3974249382dSDoug Rabson pnp_write(PNP_SET_LDN, ldn); 3984249382dSDoug Rabson pnp_write(qp->arg1, qp->arg2); 3994249382dSDoug Rabson break; 400fb0ef528SSeigo Tanimura case PNP_QUIRK_EXTRA_IO: 401fb0ef528SSeigo Tanimura if (config == NULL) 402fb0ef528SSeigo Tanimura break; 403fb0ef528SSeigo Tanimura if (qp->arg1 != 0) { 404fb0ef528SSeigo Tanimura config->ic_nport++; 405fb0ef528SSeigo Tanimura config->ic_port[config->ic_nport - 1] = config->ic_port[0]; 406fb0ef528SSeigo Tanimura config->ic_port[config->ic_nport - 1].ir_start += qp->arg1; 407fb0ef528SSeigo Tanimura config->ic_port[config->ic_nport - 1].ir_end += qp->arg1; 408fb0ef528SSeigo Tanimura } 409fb0ef528SSeigo Tanimura if (qp->arg2 != 0) { 410fb0ef528SSeigo Tanimura config->ic_nport++; 411fb0ef528SSeigo Tanimura config->ic_port[config->ic_nport - 1] = config->ic_port[0]; 412fb0ef528SSeigo Tanimura config->ic_port[config->ic_nport - 1].ir_start += qp->arg2; 413fb0ef528SSeigo Tanimura config->ic_port[config->ic_nport - 1].ir_end += qp->arg2; 414fb0ef528SSeigo Tanimura } 415fb0ef528SSeigo Tanimura break; 4164249382dSDoug Rabson } 4174249382dSDoug Rabson } 4184249382dSDoug Rabson } 4194249382dSDoug Rabson } 4204249382dSDoug Rabson 4214249382dSDoug Rabson /* 4224249382dSDoug Rabson * Scan Resource Data for Logical Devices. 4234249382dSDoug Rabson * 4244249382dSDoug Rabson * This function exits as soon as it gets an error reading *ANY* 4255b45337dSDoug Rabson * Resource Data or it reaches the end of Resource Data. In the first 4264249382dSDoug Rabson * case the return value will be TRUE, FALSE otherwise. 4274249382dSDoug Rabson */ 4284249382dSDoug Rabson static int 4295b45337dSDoug Rabson pnp_create_devices(device_t parent, pnp_id *p, int csn, 4305b45337dSDoug Rabson u_char *resources, int len) 4314249382dSDoug Rabson { 4325b45337dSDoug Rabson u_char tag, *resp, *resinfo, *startres = 0; 4335b45337dSDoug Rabson int large_len, scanning = len, retval = FALSE; 4344249382dSDoug Rabson u_int32_t logical_id; 4354249382dSDoug Rabson u_int32_t compat_id; 4364249382dSDoug Rabson device_t dev = 0; 4374249382dSDoug Rabson int ldn = 0; 4384249382dSDoug Rabson struct pnp_set_config_arg *csnldn; 4395b45337dSDoug Rabson char buf[100]; 4404249382dSDoug Rabson char *desc = 0; 4414249382dSDoug Rabson 4425b45337dSDoug Rabson resp = resources; 4435b45337dSDoug Rabson while (scanning > 0) { 4445b45337dSDoug Rabson tag = *resp++; 4455b45337dSDoug Rabson scanning--; 4465b45337dSDoug Rabson if (PNP_RES_TYPE(tag) != 0) { 4475b45337dSDoug Rabson /* Large resource */ 4485b45337dSDoug Rabson if (scanning < 2) { 4494249382dSDoug Rabson scanning = 0; 4504249382dSDoug Rabson continue; 4514249382dSDoug Rabson } 4525b45337dSDoug Rabson large_len = resp[0] + (resp[1] << 8); 4535b45337dSDoug Rabson resp += 2; 4545b45337dSDoug Rabson 4555b45337dSDoug Rabson if (scanning < large_len) { 4565b45337dSDoug Rabson scanning = 0; 4575b45337dSDoug Rabson continue; 4585b45337dSDoug Rabson } 4595b45337dSDoug Rabson resinfo = resp; 4605b45337dSDoug Rabson resp += large_len; 4615b45337dSDoug Rabson scanning -= large_len; 4625b45337dSDoug Rabson 4635b45337dSDoug Rabson if (PNP_LRES_NUM(tag) == PNP_TAG_ID_ANSI) { 4645b45337dSDoug Rabson if (large_len > sizeof(buf) - 1) 4655b45337dSDoug Rabson large_len = sizeof(buf) - 1; 4665b45337dSDoug Rabson bcopy(resinfo, buf, large_len); 4675b45337dSDoug Rabson 4685b45337dSDoug Rabson /* 4695b45337dSDoug Rabson * Trim trailing spaces. 4705b45337dSDoug Rabson */ 4715b45337dSDoug Rabson while (buf[large_len-1] == ' ') 4725b45337dSDoug Rabson large_len--; 4735b45337dSDoug Rabson buf[large_len] = '\0'; 4745b45337dSDoug Rabson desc = buf; 4755b45337dSDoug Rabson if (dev) 4765b45337dSDoug Rabson device_set_desc_copy(dev, desc); 4775b45337dSDoug Rabson continue; 4785b45337dSDoug Rabson } 4795b45337dSDoug Rabson 4805b45337dSDoug Rabson continue; 4815b45337dSDoug Rabson } 4825b45337dSDoug Rabson 4835b45337dSDoug Rabson /* Small resource */ 4845b45337dSDoug Rabson if (scanning < PNP_SRES_LEN(tag)) { 4855b45337dSDoug Rabson scanning = 0; 4865b45337dSDoug Rabson continue; 4875b45337dSDoug Rabson } 4885b45337dSDoug Rabson resinfo = resp; 4895b45337dSDoug Rabson resp += PNP_SRES_LEN(tag); 4905b45337dSDoug Rabson scanning -= PNP_SRES_LEN(tag);; 4914249382dSDoug Rabson 4924249382dSDoug Rabson switch (PNP_SRES_NUM(tag)) { 49348ab255eSPeter Wemm case PNP_TAG_LOGICAL_DEVICE: 4944249382dSDoug Rabson /* 4955b45337dSDoug Rabson * Parse the resources for the previous 4965b45337dSDoug Rabson * logical device (if any). 4975b45337dSDoug Rabson */ 4985b45337dSDoug Rabson if (startres) { 4995b45337dSDoug Rabson pnp_parse_resources(dev, startres, 500fb0ef528SSeigo Tanimura resinfo - startres - 1, 501fb0ef528SSeigo Tanimura p->vendor_id, logical_id, ldn); 5025b45337dSDoug Rabson dev = 0; 5035b45337dSDoug Rabson startres = 0; 5045b45337dSDoug Rabson } 5055b45337dSDoug Rabson 5065b45337dSDoug Rabson /* 5075b45337dSDoug Rabson * A new logical device. Scan for end of 5085b45337dSDoug Rabson * resources. 5094249382dSDoug Rabson */ 5104249382dSDoug Rabson bcopy(resinfo, &logical_id, 4); 511fb0ef528SSeigo Tanimura pnp_check_quirks(p->vendor_id, logical_id, ldn, NULL); 5124249382dSDoug Rabson compat_id = 0; 5135b45337dSDoug Rabson dev = BUS_ADD_CHILD(parent, ISA_ORDER_PNP, NULL, -1); 5144249382dSDoug Rabson if (desc) 5154249382dSDoug Rabson device_set_desc_copy(dev, desc); 5164249382dSDoug Rabson isa_set_vendorid(dev, p->vendor_id); 5174249382dSDoug Rabson isa_set_serial(dev, p->serial); 5184249382dSDoug Rabson isa_set_logicalid(dev, logical_id); 5195b45337dSDoug Rabson csnldn = malloc(sizeof *csnldn, M_DEVBUF, M_NOWAIT); 5204249382dSDoug Rabson if (!csnldn) { 5214249382dSDoug Rabson device_printf(parent, 5224249382dSDoug Rabson "out of memory\n"); 5234249382dSDoug Rabson scanning = 0; 5244249382dSDoug Rabson break; 5254249382dSDoug Rabson } 5264249382dSDoug Rabson csnldn->csn = csn; 5274249382dSDoug Rabson csnldn->ldn = ldn; 5284249382dSDoug Rabson ISA_SET_CONFIG_CALLBACK(parent, dev, 5295b45337dSDoug Rabson pnp_set_config, csnldn); 5304249382dSDoug Rabson ldn++; 5315b45337dSDoug Rabson startres = resp; 5324249382dSDoug Rabson break; 5334249382dSDoug Rabson 5344249382dSDoug Rabson case PNP_TAG_END: 5355b45337dSDoug Rabson if (!startres) { 5365b45337dSDoug Rabson device_printf(parent, 5375b45337dSDoug Rabson "malformed resources\n"); 5385b45337dSDoug Rabson scanning = 0; 5395b45337dSDoug Rabson break; 5405b45337dSDoug Rabson } 5415b45337dSDoug Rabson pnp_parse_resources(dev, startres, 542fb0ef528SSeigo Tanimura resinfo - startres - 1, 543fb0ef528SSeigo Tanimura p->vendor_id, logical_id, ldn); 5445b45337dSDoug Rabson dev = 0; 5455b45337dSDoug Rabson startres = 0; 5464249382dSDoug Rabson scanning = 0; 5474249382dSDoug Rabson break; 5484249382dSDoug Rabson 5494249382dSDoug Rabson default: 5504249382dSDoug Rabson /* Skip this resource */ 5514249382dSDoug Rabson break; 5524249382dSDoug Rabson } 5534249382dSDoug Rabson } 5544249382dSDoug Rabson 5554249382dSDoug Rabson return retval; 5564249382dSDoug Rabson } 5574249382dSDoug Rabson 5584249382dSDoug Rabson /* 5595b45337dSDoug Rabson * Read 'amount' bytes of resources from the card, allocating memory 5605b45337dSDoug Rabson * as needed. If a buffer is already available, it should be passed in 5615b45337dSDoug Rabson * '*resourcesp' and its length in '*spacep'. The number of resource 5625b45337dSDoug Rabson * bytes already in the buffer should be passed in '*lenp'. The memory 5635b45337dSDoug Rabson * allocated will be returned in '*resourcesp' with its size and the 5645b45337dSDoug Rabson * number of bytes of resources in '*spacep' and '*lenp' respectively. 5655b45337dSDoug Rabson */ 5665b45337dSDoug Rabson static int 5675b45337dSDoug Rabson pnp_read_bytes(int amount, u_char **resourcesp, int *spacep, int *lenp) 5685b45337dSDoug Rabson { 5695b45337dSDoug Rabson u_char *resources = *resourcesp; 5705b45337dSDoug Rabson u_char *newres; 5715b45337dSDoug Rabson int space = *spacep; 5725b45337dSDoug Rabson int len = *lenp; 5735b45337dSDoug Rabson 5745b45337dSDoug Rabson if (space == 0) { 5755b45337dSDoug Rabson space = 1024; 5765b45337dSDoug Rabson resources = malloc(space, M_TEMP, M_NOWAIT); 5775b45337dSDoug Rabson if (!resources) 5785b45337dSDoug Rabson return ENOMEM; 5795b45337dSDoug Rabson } 5805b45337dSDoug Rabson 5815b45337dSDoug Rabson if (len + amount > space) { 5825b45337dSDoug Rabson int extra = 1024; 5835b45337dSDoug Rabson while (len + amount > space + extra) 5845b45337dSDoug Rabson extra += 1024; 5855b45337dSDoug Rabson newres = malloc(space + extra, M_TEMP, M_NOWAIT); 5865b45337dSDoug Rabson if (!newres) 5875b45337dSDoug Rabson return ENOMEM; 5885b45337dSDoug Rabson bcopy(resources, newres, len); 5895b45337dSDoug Rabson free(resources, M_TEMP); 5905b45337dSDoug Rabson resources = newres; 5915b45337dSDoug Rabson space += extra; 5925b45337dSDoug Rabson } 5935b45337dSDoug Rabson 5945b45337dSDoug Rabson if (pnp_get_resource_info(resources + len, amount) != amount) 5955b45337dSDoug Rabson return EINVAL; 5965b45337dSDoug Rabson len += amount; 5975b45337dSDoug Rabson 5985b45337dSDoug Rabson *resourcesp = resources; 5995b45337dSDoug Rabson *spacep = space; 6005b45337dSDoug Rabson *lenp = len; 6015b45337dSDoug Rabson 6025b45337dSDoug Rabson return 0; 6035b45337dSDoug Rabson } 6045b45337dSDoug Rabson 6055b45337dSDoug Rabson /* 6065b45337dSDoug Rabson * Read all resources from the card, allocating memory as needed. If a 6075b45337dSDoug Rabson * buffer is already available, it should be passed in '*resourcesp' 6085b45337dSDoug Rabson * and its length in '*spacep'. The memory allocated will be returned 6095b45337dSDoug Rabson * in '*resourcesp' with its size and the number of bytes of resources 6105b45337dSDoug Rabson * in '*spacep' and '*lenp' respectively. 6115b45337dSDoug Rabson */ 6125b45337dSDoug Rabson static int 6135b45337dSDoug Rabson pnp_read_resources(u_char **resourcesp, int *spacep, int *lenp) 6145b45337dSDoug Rabson { 6155b45337dSDoug Rabson u_char *resources = *resourcesp; 6165b45337dSDoug Rabson int space = *spacep; 6175b45337dSDoug Rabson int len = 0; 6185b45337dSDoug Rabson int error, done; 6195b45337dSDoug Rabson u_char tag; 6205b45337dSDoug Rabson 6215b45337dSDoug Rabson error = 0; 6225b45337dSDoug Rabson done = 0; 6235b45337dSDoug Rabson while (!done) { 6245b45337dSDoug Rabson error = pnp_read_bytes(1, &resources, &space, &len); 6255b45337dSDoug Rabson if (error) 6265b45337dSDoug Rabson goto out; 6275b45337dSDoug Rabson tag = resources[len-1]; 6285b45337dSDoug Rabson if (PNP_RES_TYPE(tag) == 0) { 6295b45337dSDoug Rabson /* 6305b45337dSDoug Rabson * Small resource, read contents. 6315b45337dSDoug Rabson */ 6325b45337dSDoug Rabson error = pnp_read_bytes(PNP_SRES_LEN(tag), 6335b45337dSDoug Rabson &resources, &space, &len); 6345b45337dSDoug Rabson if (error) 6355b45337dSDoug Rabson goto out; 6365b45337dSDoug Rabson if (PNP_SRES_NUM(tag) == PNP_TAG_END) 6375b45337dSDoug Rabson done = 1; 6385b45337dSDoug Rabson } else { 6395b45337dSDoug Rabson /* 6405b45337dSDoug Rabson * Large resource, read length and contents. 6415b45337dSDoug Rabson */ 6425b45337dSDoug Rabson error = pnp_read_bytes(2, &resources, &space, &len); 6435b45337dSDoug Rabson if (error) 6445b45337dSDoug Rabson goto out; 6455b45337dSDoug Rabson error = pnp_read_bytes(resources[len-2] 6465b45337dSDoug Rabson + (resources[len-1] << 8), 6475b45337dSDoug Rabson &resources, &space, &len); 6485b45337dSDoug Rabson if (error) 6495b45337dSDoug Rabson goto out; 6505b45337dSDoug Rabson } 6515b45337dSDoug Rabson } 6525b45337dSDoug Rabson 6535b45337dSDoug Rabson out: 6545b45337dSDoug Rabson *resourcesp = resources; 6555b45337dSDoug Rabson *spacep = space; 6565b45337dSDoug Rabson *lenp = len; 6575b45337dSDoug Rabson return error; 6585b45337dSDoug Rabson } 6595b45337dSDoug Rabson 6605b45337dSDoug Rabson /* 6614249382dSDoug Rabson * Run the isolation protocol. Use pnp_rd_port as the READ_DATA port 6624249382dSDoug Rabson * value (caller should try multiple READ_DATA locations before giving 6634249382dSDoug Rabson * up). Upon exiting, all cards are aware that they should use 6644249382dSDoug Rabson * pnp_rd_port as the READ_DATA port. 6654249382dSDoug Rabson * 6664249382dSDoug Rabson * In the first pass, a csn is assigned to each board and pnp_id's 6674249382dSDoug Rabson * are saved to an array, pnp_devices. In the second pass, each 6684249382dSDoug Rabson * card is woken up and the device configuration is called. 6694249382dSDoug Rabson */ 6704249382dSDoug Rabson static int 6714249382dSDoug Rabson pnp_isolation_protocol(device_t parent) 6724249382dSDoug Rabson { 6734249382dSDoug Rabson int csn; 6744249382dSDoug Rabson pnp_id id; 6755b45337dSDoug Rabson int found = 0, len; 6765b45337dSDoug Rabson u_char *resources = 0; 6775b45337dSDoug Rabson int space = 0; 6785b45337dSDoug Rabson int error; 6794249382dSDoug Rabson 6804249382dSDoug Rabson /* 6814249382dSDoug Rabson * Put all cards into the Sleep state so that we can clear 6824249382dSDoug Rabson * their CSNs. 6834249382dSDoug Rabson */ 6844249382dSDoug Rabson pnp_send_initiation_key(); 6854249382dSDoug Rabson 6864249382dSDoug Rabson /* 6874249382dSDoug Rabson * Clear the CSN for all cards. 6884249382dSDoug Rabson */ 6894249382dSDoug Rabson pnp_write(PNP_CONFIG_CONTROL, PNP_CONFIG_CONTROL_RESET_CSN); 6904249382dSDoug Rabson 6914249382dSDoug Rabson /* 6924249382dSDoug Rabson * Move all cards to the Isolation state. 6934249382dSDoug Rabson */ 6944249382dSDoug Rabson pnp_write(PNP_WAKE, 0); 6954249382dSDoug Rabson 6964249382dSDoug Rabson /* 6974249382dSDoug Rabson * Tell them where the read point is going to be this time. 6984249382dSDoug Rabson */ 6994249382dSDoug Rabson pnp_write(PNP_SET_RD_DATA, pnp_rd_port); 7004249382dSDoug Rabson 7014249382dSDoug Rabson for (csn = 1; csn < PNP_MAX_CARDS; csn++) { 7024249382dSDoug Rabson /* 7034249382dSDoug Rabson * Start the serial isolation protocol. 7044249382dSDoug Rabson */ 7054249382dSDoug Rabson outb(_PNP_ADDRESS, PNP_SERIAL_ISOLATION); 7064249382dSDoug Rabson DELAY(1000); /* Delay 1 msec */ 7074249382dSDoug Rabson 7084249382dSDoug Rabson if (pnp_get_serial(&id)) { 7094249382dSDoug Rabson /* 7104249382dSDoug Rabson * We have read the id from a card 7114249382dSDoug Rabson * successfully. The card which won the 7124249382dSDoug Rabson * isolation protocol will be in Isolation 7135b45337dSDoug Rabson * mode and all others will be in Sleep. 7144249382dSDoug Rabson * Program the CSN of the isolated card 7154249382dSDoug Rabson * (taking it to Config state) and read its 7164249382dSDoug Rabson * resources, creating devices as we find 7174249382dSDoug Rabson * logical devices on the card. 7184249382dSDoug Rabson */ 7194249382dSDoug Rabson pnp_write(PNP_SET_CSN, csn); 7205b45337dSDoug Rabson error = pnp_read_resources(&resources, 7215b45337dSDoug Rabson &space, 7225b45337dSDoug Rabson &len); 7235b45337dSDoug Rabson if (error) 7245b45337dSDoug Rabson break; 7255b45337dSDoug Rabson pnp_create_devices(parent, &id, csn, 7265b45337dSDoug Rabson resources, len); 7274249382dSDoug Rabson found++; 7284249382dSDoug Rabson } else 7294249382dSDoug Rabson break; 7304249382dSDoug Rabson 7314249382dSDoug Rabson /* 7324249382dSDoug Rabson * Put this card back to the Sleep state and 7334249382dSDoug Rabson * simultaneously move all cards which don't have a 7344249382dSDoug Rabson * CSN yet to Isolation state. 7354249382dSDoug Rabson */ 7364249382dSDoug Rabson pnp_write(PNP_WAKE, 0); 7374249382dSDoug Rabson } 7384249382dSDoug Rabson 7394249382dSDoug Rabson /* 7404249382dSDoug Rabson * Unless we have chosen the wrong read port, all cards will 7414249382dSDoug Rabson * be in Sleep state. Put them back into WaitForKey for 7424249382dSDoug Rabson * now. Their resources will be programmed later. 7434249382dSDoug Rabson */ 7444249382dSDoug Rabson pnp_write(PNP_CONFIG_CONTROL, PNP_CONFIG_CONTROL_WAIT_FOR_KEY); 7454249382dSDoug Rabson 7465b45337dSDoug Rabson /* 7475b45337dSDoug Rabson * Cleanup. 7485b45337dSDoug Rabson */ 7495b45337dSDoug Rabson if (resources) 7505b45337dSDoug Rabson free(resources, M_TEMP); 7515b45337dSDoug Rabson 7524249382dSDoug Rabson return found; 7534249382dSDoug Rabson } 7544249382dSDoug Rabson 7554249382dSDoug Rabson 7564249382dSDoug Rabson /* 7574249382dSDoug Rabson * pnp_identify() 7584249382dSDoug Rabson * 7594249382dSDoug Rabson * autoconfiguration of pnp devices. This routine just runs the 7604249382dSDoug Rabson * isolation protocol over several ports, until one is successful. 7614249382dSDoug Rabson * 7624249382dSDoug Rabson * may be called more than once ? 7634249382dSDoug Rabson * 7644249382dSDoug Rabson */ 7654249382dSDoug Rabson 7664249382dSDoug Rabson static void 7674249382dSDoug Rabson pnp_identify(driver_t *driver, device_t parent) 7684249382dSDoug Rabson { 7694249382dSDoug Rabson int num_pnp_devs; 7704249382dSDoug Rabson 7714249382dSDoug Rabson #if 0 7724249382dSDoug Rabson if (pnp_ldn_overrides[0].csn == 0) { 7734249382dSDoug Rabson if (bootverbose) 7744249382dSDoug Rabson printf("Initializing PnP override table\n"); 7754249382dSDoug Rabson bzero (pnp_ldn_overrides, sizeof(pnp_ldn_overrides)); 7764249382dSDoug Rabson pnp_ldn_overrides[0].csn = 255 ; 7774249382dSDoug Rabson } 7784249382dSDoug Rabson #endif 7794249382dSDoug Rabson 7804249382dSDoug Rabson /* Try various READ_DATA ports from 0x203-0x3ff */ 7814249382dSDoug Rabson for (pnp_rd_port = 0x80; (pnp_rd_port < 0xff); pnp_rd_port += 0x10) { 7824249382dSDoug Rabson if (bootverbose) 7834249382dSDoug Rabson printf("Trying Read_Port at %x\n", (pnp_rd_port << 2) | 0x3); 7844249382dSDoug Rabson 7854249382dSDoug Rabson num_pnp_devs = pnp_isolation_protocol(parent); 7864249382dSDoug Rabson if (num_pnp_devs) 7874249382dSDoug Rabson break; 7884249382dSDoug Rabson } 7894249382dSDoug Rabson } 7904249382dSDoug Rabson 7914249382dSDoug Rabson static device_method_t pnp_methods[] = { 7924249382dSDoug Rabson /* Device interface */ 7934249382dSDoug Rabson DEVMETHOD(device_identify, pnp_identify), 7944249382dSDoug Rabson 7954249382dSDoug Rabson { 0, 0 } 7964249382dSDoug Rabson }; 7974249382dSDoug Rabson 7984249382dSDoug Rabson static driver_t pnp_driver = { 7994249382dSDoug Rabson "pnp", 8004249382dSDoug Rabson pnp_methods, 8014249382dSDoug Rabson 1, /* no softc */ 8024249382dSDoug Rabson }; 8034249382dSDoug Rabson 8044249382dSDoug Rabson static devclass_t pnp_devclass; 8054249382dSDoug Rabson 8064249382dSDoug Rabson DRIVER_MODULE(pnp, isa, pnp_driver, pnp_devclass, 0, 0); 807