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 * 28c3aac50fSPeter Wemm * $FreeBSD$ 291a4290e7SDoug Rabson */ 301a4290e7SDoug Rabson 31cfa84f46SDoug Rabson #ifndef _ISA_ISAVAR_H_ 32cfa84f46SDoug Rabson #define _ISA_ISAVAR_H_ 33cfa84f46SDoug Rabson 344249382dSDoug Rabson struct isa_config; 354249382dSDoug Rabson struct isa_pnp_id; 364249382dSDoug Rabson typedef void isa_config_cb(void *arg, struct isa_config *config, int enable); 374249382dSDoug Rabson 38a3be63b3SDoug Rabson #include "isa_if.h" 394249382dSDoug Rabson #include <isa/pnpvar.h> 40cfa84f46SDoug Rabson 41c4473420SPeter Wemm #ifdef _KERNEL 42a3be63b3SDoug Rabson 43bea6af4dSDoug Rabson /* 44993fd0c5SWarner Losh * ISA devices are partially ordered. This is to ensure that hardwired 45993fd0c5SWarner Losh * devices the BIOS tells us are there appear first, then speculative 46993fd0c5SWarner Losh * devices that are sensitive to the probe order, then devices that 47993fd0c5SWarner Losh * are hinted to be there, then the most flexible devices which support 48993fd0c5SWarner Losh * the ISA bus PNP standard. 49bea6af4dSDoug Rabson */ 50993fd0c5SWarner Losh #define ISA_ORDER_PNPBIOS 10 /* plug-and-play BIOS inflexible hardware */ 51993fd0c5SWarner Losh #define ISA_ORDER_SENSITIVE 20 /* legacy sensitive hardware */ 52993fd0c5SWarner Losh #define ISA_ORDER_SPECULATIVE 30 /* legacy non-sensitive hardware */ 53132580b5SWarner Losh #define ISA_ORDER_PNP 40 /* plug-and-play flexible hardware */ 54bea6af4dSDoug Rabson 5508764b84SMike Smith /* 5608764b84SMike Smith * Limits on resources that we can manage 5708764b84SMike Smith */ 584f9d49f1SGary Jennejohn #define ISA_NPORT 50 5908764b84SMike Smith #define ISA_NMEM 50 6008764b84SMike Smith #define ISA_NIRQ 50 6108764b84SMike Smith #define ISA_NDRQ 50 6208764b84SMike Smith 6308764b84SMike Smith /* 6408764b84SMike Smith * Limits on resources the hardware can actually handle 6508764b84SMike Smith */ 6608764b84SMike Smith #define ISA_PNP_NPORT 8 6708764b84SMike Smith #define ISA_PNP_NMEM 4 6808764b84SMike Smith #define ISA_PNP_NIRQ 2 6908764b84SMike Smith #define ISA_PNP_NDRQ 2 7008b6a4cbSDoug Rabson 71d8b47cbbSPoul-Henning Kamp #define ISADMA_READ 0x00100000 72d8b47cbbSPoul-Henning Kamp #define ISADMA_WRITE 0 73d8b47cbbSPoul-Henning Kamp #define ISADMA_RAW 0x00080000 744249382dSDoug Rabson /* 754249382dSDoug Rabson * Plug and play cards can support a range of resource 764249382dSDoug Rabson * configurations. This structure is used by the isapnp parser to 774249382dSDoug Rabson * inform the isa bus about the resource possibilities of the 784249382dSDoug Rabson * device. Each different alternative should be supplied by calling 794249382dSDoug Rabson * ISA_ADD_CONFIG(). 804249382dSDoug Rabson */ 814249382dSDoug Rabson struct isa_range { 82f2b1ec3aSJohn Baldwin uint32_t ir_start; 83f2b1ec3aSJohn Baldwin uint32_t ir_end; 84f2b1ec3aSJohn Baldwin uint32_t ir_size; 85f2b1ec3aSJohn Baldwin uint32_t ir_align; 864249382dSDoug Rabson }; 874249382dSDoug Rabson 884249382dSDoug Rabson struct isa_config { 894249382dSDoug Rabson struct isa_range ic_mem[ISA_NMEM]; 904249382dSDoug Rabson struct isa_range ic_port[ISA_NPORT]; 91f2b1ec3aSJohn Baldwin uint32_t ic_irqmask[ISA_NIRQ]; 92f2b1ec3aSJohn Baldwin uint32_t ic_drqmask[ISA_NDRQ]; 934249382dSDoug Rabson int ic_nmem; 944249382dSDoug Rabson int ic_nport; 954249382dSDoug Rabson int ic_nirq; 964249382dSDoug Rabson int ic_ndrq; 974249382dSDoug Rabson }; 984249382dSDoug Rabson 994249382dSDoug Rabson /* 1004249382dSDoug Rabson * Used to build lists of IDs and description strings for PnP drivers. 1014249382dSDoug Rabson */ 1024249382dSDoug Rabson struct isa_pnp_id { 103f2b1ec3aSJohn Baldwin uint32_t ip_id; 1044249382dSDoug Rabson const char *ip_desc; 1054249382dSDoug Rabson }; 1064249382dSDoug Rabson 1071a4290e7SDoug Rabson enum isa_device_ivars { 1081a4290e7SDoug Rabson ISA_IVAR_PORT, 10908b6a4cbSDoug Rabson ISA_IVAR_PORT_0 = ISA_IVAR_PORT, 11008b6a4cbSDoug Rabson ISA_IVAR_PORT_1, 1111a4290e7SDoug Rabson ISA_IVAR_PORTSIZE, 11208b6a4cbSDoug Rabson ISA_IVAR_PORTSIZE_0 = ISA_IVAR_PORTSIZE, 11308b6a4cbSDoug Rabson ISA_IVAR_PORTSIZE_1, 11408b6a4cbSDoug Rabson ISA_IVAR_MADDR, 11508b6a4cbSDoug Rabson ISA_IVAR_MADDR_0 = ISA_IVAR_MADDR, 11608b6a4cbSDoug Rabson ISA_IVAR_MADDR_1, 11763e30378SJohn Baldwin ISA_IVAR_MEMSIZE, 11863e30378SJohn Baldwin ISA_IVAR_MEMSIZE_0 = ISA_IVAR_MEMSIZE, 11963e30378SJohn Baldwin ISA_IVAR_MEMSIZE_1, 12008b6a4cbSDoug Rabson ISA_IVAR_IRQ, 12108b6a4cbSDoug Rabson ISA_IVAR_IRQ_0 = ISA_IVAR_IRQ, 12208b6a4cbSDoug Rabson ISA_IVAR_IRQ_1, 12308b6a4cbSDoug Rabson ISA_IVAR_DRQ, 12408b6a4cbSDoug Rabson ISA_IVAR_DRQ_0 = ISA_IVAR_DRQ, 125cfa84f46SDoug Rabson ISA_IVAR_DRQ_1, 126cfa84f46SDoug Rabson ISA_IVAR_VENDORID, 127cfa84f46SDoug Rabson ISA_IVAR_SERIAL, 128cfa84f46SDoug Rabson ISA_IVAR_LOGICALID, 1297abb4662SKazutaka YOKOTA ISA_IVAR_COMPATID, 130132580b5SWarner Losh ISA_IVAR_CONFIGATTR, 131132580b5SWarner Losh ISA_IVAR_PNP_CSN, 132132580b5SWarner Losh ISA_IVAR_PNP_LDN, 133132580b5SWarner Losh ISA_IVAR_PNPBIOS_HANDLE 1341a4290e7SDoug Rabson }; 1351a4290e7SDoug Rabson 1361a4290e7SDoug Rabson /* 137c3959391SKazutaka YOKOTA * ISA_IVAR_CONFIGATTR bits 138c3959391SKazutaka YOKOTA */ 139c3959391SKazutaka YOKOTA #define ISACFGATTR_CANDISABLE (1 << 0) /* can be disabled */ 140c3959391SKazutaka YOKOTA #define ISACFGATTR_DYNAMIC (1 << 1) /* dynamic configuration */ 1412ca94fcaSMatthew N. Dodd #define ISACFGATTR_HINTS (1 << 3) /* source of config is hints */ 142c3959391SKazutaka YOKOTA 1435fe4723cSWarner Losh #define ISA_PNP_DESCR "E:pnpid;D:#" 1445fe4723cSWarner Losh #define ISA_PNP_INFO(t) \ 145329e817fSWarner Losh MODULE_PNP_INFO(ISA_PNP_DESCR, isa, t, t, nitems(t) - 1); \ 1465fe4723cSWarner Losh 147c3959391SKazutaka YOKOTA /* 1481a4290e7SDoug Rabson * Simplified accessors for isa devices 1491a4290e7SDoug Rabson */ 15063e30378SJohn Baldwin #define ISA_ACCESSOR(var, ivar, type) \ 15163e30378SJohn Baldwin __BUS_ACCESSOR(isa, var, ISA, ivar, type) 1521a4290e7SDoug Rabson 1531a4290e7SDoug Rabson ISA_ACCESSOR(port, PORT, int) 1541a4290e7SDoug Rabson ISA_ACCESSOR(portsize, PORTSIZE, int) 1551a4290e7SDoug Rabson ISA_ACCESSOR(irq, IRQ, int) 1566182fdbdSPeter Wemm ISA_ACCESSOR(drq, DRQ, int) 1576182fdbdSPeter Wemm ISA_ACCESSOR(maddr, MADDR, int) 15863e30378SJohn Baldwin ISA_ACCESSOR(msize, MEMSIZE, int) 159cfa84f46SDoug Rabson ISA_ACCESSOR(vendorid, VENDORID, int) 160cfa84f46SDoug Rabson ISA_ACCESSOR(serial, SERIAL, int) 161cfa84f46SDoug Rabson ISA_ACCESSOR(logicalid, LOGICALID, int) 162cfa84f46SDoug Rabson ISA_ACCESSOR(compatid, COMPATID, int) 1637abb4662SKazutaka YOKOTA ISA_ACCESSOR(configattr, CONFIGATTR, int) 164132580b5SWarner Losh ISA_ACCESSOR(pnp_csn, PNP_CSN, int) 165132580b5SWarner Losh ISA_ACCESSOR(pnp_ldn, PNP_LDN, int) 166132580b5SWarner Losh ISA_ACCESSOR(pnpbios_handle, PNPBIOS_HANDLE, int) 167cfa84f46SDoug Rabson 1684249382dSDoug Rabson extern void isa_probe_children(device_t dev); 1694249382dSDoug Rabson 1700c3c54daSPoul-Henning Kamp void isa_dmacascade(int chan); 1710c3c54daSPoul-Henning Kamp void isa_dmadone(int flags, caddr_t addr, int nbytes, int chan); 1720c3c54daSPoul-Henning Kamp int isa_dma_init(int chan, u_int bouncebufsize, int flag); 1730c3c54daSPoul-Henning Kamp void isa_dmastart(int flags, caddr_t addr, u_int nbytes, int chan); 1740c3c54daSPoul-Henning Kamp int isa_dma_acquire(int chan); 1750c3c54daSPoul-Henning Kamp void isa_dma_release(int chan); 1760c3c54daSPoul-Henning Kamp int isa_dmastatus(int chan); 1770c3c54daSPoul-Henning Kamp int isa_dmastop(int chan); 1780c3c54daSPoul-Henning Kamp int isa_dmatc(int chan); 179cfa84f46SDoug Rabson 1807ce1979bSPoul-Henning Kamp #define isa_dmainit(chan, size) do { \ 1817ce1979bSPoul-Henning Kamp if (isa_dma_init(chan, size, M_NOWAIT)) \ 1827ce1979bSPoul-Henning Kamp printf("WARNING: isa_dma_init(%d, %ju) failed\n", \ 1837ce1979bSPoul-Henning Kamp (int)(chan), (uintmax_t)(size)); \ 1847ce1979bSPoul-Henning Kamp } while (0) 1857ce1979bSPoul-Henning Kamp 1860d484d24SJohn Baldwin void isa_hinted_child(device_t parent, const char *name, int unit); 1870d484d24SJohn Baldwin void isa_hint_device_unit(device_t bus, device_t child, const char *name, 1880d484d24SJohn Baldwin int *unitp); 189c37faf26SJohn Baldwin int isab_attach(device_t dev); 190c37faf26SJohn Baldwin 191c4473420SPeter Wemm #endif /* _KERNEL */ 192cfa84f46SDoug Rabson 193cfa84f46SDoug Rabson #endif /* !_ISA_ISAVAR_H_ */ 194