1.\" $NetBSD: ioasic.9,v 1.5 2002/02/13 08:18:42 ross Exp $ 2.\" 3.\" Copyright (c) 2000 The NetBSD Foundation, Inc. 4.\" All rights reserved. 5.\" 6.\" This code is derived from software contributed to The NetBSD Foundation 7.\" by Gregory McGarry. 8.\" 9.\" Redistribution and use in source and binary forms, with or without 10.\" modification, are permitted provided that the following conditions 11.\" are met: 12.\" 1. Redistributions of source code must retain the above copyright 13.\" notice, this list of conditions and the following disclaimer. 14.\" 2. Redistributions in binary form must reproduce the above copyright 15.\" notice, this list of conditions and the following disclaimer in the 16.\" documentation and/or other materials provided with the distribution. 17.\" 3. All advertising materials mentioning features or use of this software 18.\" must display the following acknowledgement: 19.\" This product includes software developed by the NetBSD 20.\" Foundation, Inc. and its contributors. 21.\" 4. Neither the name of The NetBSD Foundation nor the names of its 22.\" contributors may be used to endorse or promote products derived 23.\" from this software without specific prior written permission. 24.\" 25.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 26.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 27.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 28.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 29.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 30.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 31.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 32.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 33.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 34.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 35.\" POSSIBILITY OF SUCH DAMAGE. 36.\" 37.Dd August 6, 2000 38.Dt IOASIC 9 39.Os 40.Sh NAME 41.Nm IOASIC , 42.Nm ioasic_intr_establish , 43.Nm ioasic_intr_disestablish , 44.Nm ioasic_intr_evcnt , 45.Nm ioasic_attach_devs , 46.Nm ioasic_submatch 47.Nd baseboard I/O control ASIC for DEC TURBOchannel systems 48.Sh SYNOPSIS 49.Fd #include \*[Lt]machine/bus.h\*[Gt] 50.Fd #include \*[Lt]dev/tc/tcvar.h\*[Gt] 51.Fd #include \*[Lt]dev/tc/ioasicreg.h\*[Gt] 52.Fd #include \*[Lt]dev/tc/ioasicvar.h\*[Gt] 53.Ft void 54.Fn ioasic_intr_establish "struct device *dev" "void *cookie" "int level" \ 55"int (*handler)(void *)" "void *arg" 56.Ft void 57.Fn ioasic_intr_disestablish "struct device *dev" "void *cookie" 58.Ft const struct evcnt * 59.Fn ioasic_intr_evcnt "struct device *dev" "void *cookie" 60.Ft void 61.Fn ioasic_attach_devs "struct ioasic_softc *sc" \ 62"struct ioasic_dev *ioasic_devs" "int ioasic_ndevs" 63.Ft int 64.Fn ioasic_submatch "struct cfdata *match" "struct ioasicdev_attach_args *ia" 65.Sh DESCRIPTION 66The 67.Nm 68device provides support for the DEC proprietary IOCTL ASIC found on 69all DEC TURBOchannel machines with MIPS (DECstation 5000 series, 70excluding the 5000/200) and Alpha (3000-series) systems. The 71.Nm 72is memory-mapped into the TURBOchannel system slot to interface up to 73sixteen I/O devices. It connects the TURBOchannel to a 16-bit wide 74I/O bus and supplies various control signals to the devices that share 75this bus. 76.Pp 77The 78.Nm 79provides hardware DMA channels and interrupt support. DMA transfers 80are between one and four 32-bit words (16 bytes) in length, depending 81on the device. The 82.Nm 83stores the data in internal data registers. The data is transferred 84to and from the registers in 16-bit words to the device. Various 85interrupts are signalled on DMA pointer-related conditions. 86.Sh DATA TYPES 87Drivers for devices attached to the 88.Nm 89will make use of the following data types: 90.Bl -tag -width compact 91.It Fa struct ioasicdev_attach_args 92A structure used to inform the driver of the 93.Nm 94device properties. It contains the following members: 95.Bd -literal 96 char iada_modname 97 tc_offset_t iada_offset 98 tc_addr_t iada_addr 99 void *iada_cookie; 100.Ed 101.It Fa struct ioasic_softc 102The parent structure which contains at the following members which are 103useful for drivers: 104.Bd -literal 105 bus_space_tag_t sc_bst; 106 bus_space_handle_t sc_bsh; 107 bus_dma_tag_t sc_dmat; 108.Ed 109.It Fa struct ioasic_dev 110A structure describing the machine-dependent devices attached to the 111.Nm 112containing the following members: 113.Bd -literal 114 char *iad_modname; 115 tc_offset_t iad_offset; 116 void *iad_cookie; 117 u_int32_t iad_intrbits; 118.Ed 119.El 120.Sh FUNCTIONS 121.Bl -tag -width compact 122.It Fn ioasic_intr_establish "dev" "cookie" "level" "handler" "arg" 123Establish an interrupt handler with device 124.Fa dev 125for the interrupt described completely by 126.Fa cookie . 127The priority of the interrupt is specified by 128.Fa level . 129When the interrupt occurs the function 130.Fa handler 131is called with argument 132.Fa arg . 133.It Fn ioasic_intr_disestablish "dev" "cookie" 134Dis-establish the interrupt handler with device 135.Fa dev 136for the interrupt described complete ly 137.Fa cookie . 138.It Fn ioasic_intr_evcnt "dev" "cookie" 139Do interrupt event counting with device 140.Fa dev 141for the event described completely by 142.Fa cookie . 143.It Fn ioasic_attach_devs "sc" "ioasic_devs" "ioasic_ndevs" 144Configure each of the 145.Fa ioasic_ndevs 146devices in 147.Fa ioasic_devs . 148.It Fn ioasic_submatch "match" "ia" 149Check that the device offset is not OASIC_OFFSET_UNKNOWN. 150.El 151.Pp 152The 153.Fn ioasic_intr_establish , 154.Fn ioasic_intr_disestablish , 155and 156.Fn ioasic_intr_evcnt 157functions are likely to used by all 158.Nm 159device drivers. The 160.Fn ioasic_attach_devs 161function is used by ioasic driver internally and is of interest to 162driver writers because it must be aware of your device for it to be 163found during autoconfiguration. 164.Sh AUTOCONFIGURATION 165The IOASIC is a direct-connection bus. During autoconfiguration, 166machine-dependent code will provide an array of 167.Fa struct ioasic_devs 168describing devices attached to the 169.Nm 170to be used by the ioasic driver. The ioasic driver will pass this array to 171.Fn ioasic_attach_devs 172to attach the drivers with the devices. 173.Pp 174Drivers match the device using 175.Fa iada_modname . 176.Pp 177During attach, all drivers should use the parent's bus_space and 178bus_dma resources, and map the appropriate bus_space region using 179.Fn bus_space_subregion 180with 181.Fa iada_offset . 182.Sh DMA SUPPORT 183No additional support is provided for 184.Nm 185DMA beyond the facilities provided by the 186.Xr bus_dma 9 187interface. 188.Pp 189The 190.Nm 191provides two pairs of DMA address pointers (transmitting and 192receiving) for each DMA-capable device. The pair of address pointers 193point to consecutive (but not necesarily contiguous) DMA blocks of 194size IOASIC_DMA_BLOCKSIZE. Upon successful transfer of the first 195block, DMA continues to the next block and an interrupt is posted to 196signal an address pointer update. DMA transfers are enabled and 197disabled by bits inside the 198.Nm 199status (CSR) register. 200.Pp 201The interrupt handler must update the address pointers to point to the 202next block in the DMA transfer. The address pointer update must be 203completed before the completion of the second DMA block, otherwise a 204DMA overrun error condition will occur. 205.Sh CODE REFERENCES 206This section describes places within the 207.Nx 208source tree where actual code implementing or utilising the 209machine-independent IOASIC subsystem can be found. All pathnames are 210relative to 211.Pa /usr/src . 212.Pp 213The IOASIC subsystem itself is implemented within the file 214.Pa sys/dev/tc/ioasic_subr.c . 215Machine-dependent portions can be found in 216.Pa sys/arch/\*[Lt]arch\*[Gt]/tc/ioasic.c . 217.Sh SEE ALSO 218.Xr ioasic 4 , 219.Xr autoconf 9 , 220.Xr bus_dma 9 , 221.Xr bus_space 9 , 222.Xr driver 9 223