11a4290e7SDoug Rabson /*- 2*4d846d26SWarner Losh * SPDX-License-Identifier: BSD-2-Clause 3fe267a55SPedro F. Giffuni * 41a4290e7SDoug Rabson * Copyright (c) 1998 Doug Rabson 51a4290e7SDoug Rabson * All rights reserved. 61a4290e7SDoug Rabson * 71a4290e7SDoug Rabson * Redistribution and use in source and binary forms, with or without 81a4290e7SDoug Rabson * modification, are permitted provided that the following conditions 91a4290e7SDoug Rabson * are met: 101a4290e7SDoug Rabson * 1. Redistributions of source code must retain the above copyright 111a4290e7SDoug Rabson * notice, this list of conditions and the following disclaimer. 121a4290e7SDoug Rabson * 2. Redistributions in binary form must reproduce the above copyright 131a4290e7SDoug Rabson * notice, this list of conditions and the following disclaimer in the 141a4290e7SDoug Rabson * documentation and/or other materials provided with the distribution. 151a4290e7SDoug Rabson * 161a4290e7SDoug Rabson * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 171a4290e7SDoug Rabson * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 181a4290e7SDoug Rabson * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 191a4290e7SDoug Rabson * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 201a4290e7SDoug Rabson * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 211a4290e7SDoug Rabson * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 221a4290e7SDoug Rabson * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 231a4290e7SDoug Rabson * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 241a4290e7SDoug Rabson * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 251a4290e7SDoug Rabson * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 261a4290e7SDoug Rabson * SUCH DAMAGE. 271a4290e7SDoug Rabson */ 281a4290e7SDoug Rabson 29cfa84f46SDoug Rabson #ifndef _ISA_ISAVAR_H_ 30cfa84f46SDoug Rabson #define _ISA_ISAVAR_H_ 31cfa84f46SDoug Rabson 324249382dSDoug Rabson struct isa_config; 334249382dSDoug Rabson struct isa_pnp_id; 344249382dSDoug Rabson typedef void isa_config_cb(void *arg, struct isa_config *config, int enable); 354249382dSDoug Rabson 36a3be63b3SDoug Rabson #include "isa_if.h" 374249382dSDoug Rabson #include <isa/pnpvar.h> 38cfa84f46SDoug Rabson 39c4473420SPeter Wemm #ifdef _KERNEL 40a3be63b3SDoug Rabson 41bea6af4dSDoug Rabson /* 42993fd0c5SWarner Losh * ISA devices are partially ordered. This is to ensure that hardwired 43993fd0c5SWarner Losh * devices the BIOS tells us are there appear first, then speculative 44993fd0c5SWarner Losh * devices that are sensitive to the probe order, then devices that 45993fd0c5SWarner Losh * are hinted to be there, then the most flexible devices which support 46993fd0c5SWarner Losh * the ISA bus PNP standard. 47bea6af4dSDoug Rabson */ 48993fd0c5SWarner Losh #define ISA_ORDER_PNPBIOS 10 /* plug-and-play BIOS inflexible hardware */ 49993fd0c5SWarner Losh #define ISA_ORDER_SENSITIVE 20 /* legacy sensitive hardware */ 50993fd0c5SWarner Losh #define ISA_ORDER_SPECULATIVE 30 /* legacy non-sensitive hardware */ 51132580b5SWarner Losh #define ISA_ORDER_PNP 40 /* plug-and-play flexible hardware */ 52bea6af4dSDoug Rabson 5308764b84SMike Smith /* 5408764b84SMike Smith * Limits on resources that we can manage 5508764b84SMike Smith */ 564f9d49f1SGary Jennejohn #define ISA_NPORT 50 5708764b84SMike Smith #define ISA_NMEM 50 5808764b84SMike Smith #define ISA_NIRQ 50 5908764b84SMike Smith #define ISA_NDRQ 50 6008764b84SMike Smith 6108764b84SMike Smith /* 6208764b84SMike Smith * Limits on resources the hardware can actually handle 6308764b84SMike Smith */ 6408764b84SMike Smith #define ISA_PNP_NPORT 8 6508764b84SMike Smith #define ISA_PNP_NMEM 4 6608764b84SMike Smith #define ISA_PNP_NIRQ 2 6708764b84SMike Smith #define ISA_PNP_NDRQ 2 6808b6a4cbSDoug Rabson 69d8b47cbbSPoul-Henning Kamp #define ISADMA_READ 0x00100000 70d8b47cbbSPoul-Henning Kamp #define ISADMA_WRITE 0 71d8b47cbbSPoul-Henning Kamp #define ISADMA_RAW 0x00080000 724249382dSDoug Rabson /* 734249382dSDoug Rabson * Plug and play cards can support a range of resource 744249382dSDoug Rabson * configurations. This structure is used by the isapnp parser to 754249382dSDoug Rabson * inform the isa bus about the resource possibilities of the 764249382dSDoug Rabson * device. Each different alternative should be supplied by calling 774249382dSDoug Rabson * ISA_ADD_CONFIG(). 784249382dSDoug Rabson */ 794249382dSDoug Rabson struct isa_range { 80f2b1ec3aSJohn Baldwin uint32_t ir_start; 81f2b1ec3aSJohn Baldwin uint32_t ir_end; 82f2b1ec3aSJohn Baldwin uint32_t ir_size; 83f2b1ec3aSJohn Baldwin uint32_t ir_align; 844249382dSDoug Rabson }; 854249382dSDoug Rabson 864249382dSDoug Rabson struct isa_config { 874249382dSDoug Rabson struct isa_range ic_mem[ISA_NMEM]; 884249382dSDoug Rabson struct isa_range ic_port[ISA_NPORT]; 89f2b1ec3aSJohn Baldwin uint32_t ic_irqmask[ISA_NIRQ]; 90f2b1ec3aSJohn Baldwin uint32_t ic_drqmask[ISA_NDRQ]; 914249382dSDoug Rabson int ic_nmem; 924249382dSDoug Rabson int ic_nport; 934249382dSDoug Rabson int ic_nirq; 944249382dSDoug Rabson int ic_ndrq; 954249382dSDoug Rabson }; 964249382dSDoug Rabson 974249382dSDoug Rabson /* 984249382dSDoug Rabson * Used to build lists of IDs and description strings for PnP drivers. 994249382dSDoug Rabson */ 1004249382dSDoug Rabson struct isa_pnp_id { 101f2b1ec3aSJohn Baldwin uint32_t ip_id; 1024249382dSDoug Rabson const char *ip_desc; 1034249382dSDoug Rabson }; 1044249382dSDoug Rabson 1051a4290e7SDoug Rabson enum isa_device_ivars { 1061a4290e7SDoug Rabson ISA_IVAR_PORT, 10708b6a4cbSDoug Rabson ISA_IVAR_PORT_0 = ISA_IVAR_PORT, 10808b6a4cbSDoug Rabson ISA_IVAR_PORT_1, 1091a4290e7SDoug Rabson ISA_IVAR_PORTSIZE, 11008b6a4cbSDoug Rabson ISA_IVAR_PORTSIZE_0 = ISA_IVAR_PORTSIZE, 11108b6a4cbSDoug Rabson ISA_IVAR_PORTSIZE_1, 11208b6a4cbSDoug Rabson ISA_IVAR_MADDR, 11308b6a4cbSDoug Rabson ISA_IVAR_MADDR_0 = ISA_IVAR_MADDR, 11408b6a4cbSDoug Rabson ISA_IVAR_MADDR_1, 11563e30378SJohn Baldwin ISA_IVAR_MEMSIZE, 11663e30378SJohn Baldwin ISA_IVAR_MEMSIZE_0 = ISA_IVAR_MEMSIZE, 11763e30378SJohn Baldwin ISA_IVAR_MEMSIZE_1, 11808b6a4cbSDoug Rabson ISA_IVAR_IRQ, 11908b6a4cbSDoug Rabson ISA_IVAR_IRQ_0 = ISA_IVAR_IRQ, 12008b6a4cbSDoug Rabson ISA_IVAR_IRQ_1, 12108b6a4cbSDoug Rabson ISA_IVAR_DRQ, 12208b6a4cbSDoug Rabson ISA_IVAR_DRQ_0 = ISA_IVAR_DRQ, 123cfa84f46SDoug Rabson ISA_IVAR_DRQ_1, 124cfa84f46SDoug Rabson ISA_IVAR_VENDORID, 125cfa84f46SDoug Rabson ISA_IVAR_SERIAL, 126cfa84f46SDoug Rabson ISA_IVAR_LOGICALID, 1277abb4662SKazutaka YOKOTA ISA_IVAR_COMPATID, 128132580b5SWarner Losh ISA_IVAR_CONFIGATTR, 129132580b5SWarner Losh ISA_IVAR_PNP_CSN, 130132580b5SWarner Losh ISA_IVAR_PNP_LDN, 131132580b5SWarner Losh ISA_IVAR_PNPBIOS_HANDLE 1321a4290e7SDoug Rabson }; 1331a4290e7SDoug Rabson 1341a4290e7SDoug Rabson /* 135c3959391SKazutaka YOKOTA * ISA_IVAR_CONFIGATTR bits 136c3959391SKazutaka YOKOTA */ 137c3959391SKazutaka YOKOTA #define ISACFGATTR_CANDISABLE (1 << 0) /* can be disabled */ 138c3959391SKazutaka YOKOTA #define ISACFGATTR_DYNAMIC (1 << 1) /* dynamic configuration */ 1392ca94fcaSMatthew N. Dodd #define ISACFGATTR_HINTS (1 << 3) /* source of config is hints */ 140c3959391SKazutaka YOKOTA 1415fe4723cSWarner Losh #define ISA_PNP_DESCR "E:pnpid;D:#" 1425fe4723cSWarner Losh #define ISA_PNP_INFO(t) \ 143329e817fSWarner Losh MODULE_PNP_INFO(ISA_PNP_DESCR, isa, t, t, nitems(t) - 1); \ 1445fe4723cSWarner Losh 145c3959391SKazutaka YOKOTA /* 1461a4290e7SDoug Rabson * Simplified accessors for isa devices 1471a4290e7SDoug Rabson */ 14863e30378SJohn Baldwin #define ISA_ACCESSOR(var, ivar, type) \ 14963e30378SJohn Baldwin __BUS_ACCESSOR(isa, var, ISA, ivar, type) 1501a4290e7SDoug Rabson 1511a4290e7SDoug Rabson ISA_ACCESSOR(port, PORT, int) 1521a4290e7SDoug Rabson ISA_ACCESSOR(portsize, PORTSIZE, int) 1531a4290e7SDoug Rabson ISA_ACCESSOR(irq, IRQ, int) 1546182fdbdSPeter Wemm ISA_ACCESSOR(drq, DRQ, int) 1556182fdbdSPeter Wemm ISA_ACCESSOR(maddr, MADDR, int) 15663e30378SJohn Baldwin ISA_ACCESSOR(msize, MEMSIZE, int) 157cfa84f46SDoug Rabson ISA_ACCESSOR(vendorid, VENDORID, int) 158cfa84f46SDoug Rabson ISA_ACCESSOR(serial, SERIAL, int) 159cfa84f46SDoug Rabson ISA_ACCESSOR(logicalid, LOGICALID, int) 160cfa84f46SDoug Rabson ISA_ACCESSOR(compatid, COMPATID, int) 1617abb4662SKazutaka YOKOTA ISA_ACCESSOR(configattr, CONFIGATTR, int) 162132580b5SWarner Losh ISA_ACCESSOR(pnp_csn, PNP_CSN, int) 163132580b5SWarner Losh ISA_ACCESSOR(pnp_ldn, PNP_LDN, int) 164132580b5SWarner Losh ISA_ACCESSOR(pnpbios_handle, PNPBIOS_HANDLE, int) 165cfa84f46SDoug Rabson 1664249382dSDoug Rabson extern void isa_probe_children(device_t dev); 1674249382dSDoug Rabson 1680c3c54daSPoul-Henning Kamp void isa_dmacascade(int chan); 1690c3c54daSPoul-Henning Kamp void isa_dmadone(int flags, caddr_t addr, int nbytes, int chan); 1700c3c54daSPoul-Henning Kamp int isa_dma_init(int chan, u_int bouncebufsize, int flag); 1710c3c54daSPoul-Henning Kamp void isa_dmastart(int flags, caddr_t addr, u_int nbytes, int chan); 1720c3c54daSPoul-Henning Kamp int isa_dma_acquire(int chan); 1730c3c54daSPoul-Henning Kamp void isa_dma_release(int chan); 1740c3c54daSPoul-Henning Kamp int isa_dmastatus(int chan); 1750c3c54daSPoul-Henning Kamp int isa_dmastop(int chan); 1760c3c54daSPoul-Henning Kamp int isa_dmatc(int chan); 177cfa84f46SDoug Rabson 1787ce1979bSPoul-Henning Kamp #define isa_dmainit(chan, size) do { \ 1797ce1979bSPoul-Henning Kamp if (isa_dma_init(chan, size, M_NOWAIT)) \ 1807ce1979bSPoul-Henning Kamp printf("WARNING: isa_dma_init(%d, %ju) failed\n", \ 1817ce1979bSPoul-Henning Kamp (int)(chan), (uintmax_t)(size)); \ 1827ce1979bSPoul-Henning Kamp } while (0) 1837ce1979bSPoul-Henning Kamp 1840d484d24SJohn Baldwin void isa_hinted_child(device_t parent, const char *name, int unit); 1850d484d24SJohn Baldwin void isa_hint_device_unit(device_t bus, device_t child, const char *name, 1860d484d24SJohn Baldwin int *unitp); 187c37faf26SJohn Baldwin int isab_attach(device_t dev); 188c37faf26SJohn Baldwin 189c4473420SPeter Wemm #endif /* _KERNEL */ 190cfa84f46SDoug Rabson 191cfa84f46SDoug Rabson #endif /* !_ISA_ISAVAR_H_ */ 192