Sync usage with man page.
[netbsd-mini2440.git] / sys / dev / mca / aha_mca.c
blob7f2abb6060dd857d0c873f1b45b0e5b101322af1
1 /* $NetBSD: aha_mca.c,v 1.21 2009/09/21 08:12:47 tsutsui Exp $ */
3 /*
4 * Copyright (c) 2000-2002 The NetBSD Foundation, Inc.
5 * Copyright (c) 1996-1999 Scott D. Telford.
6 * Copyright (c) 1994, 1996 Charles M. Hannum. All rights reserved.
7 * Portions:
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 Charles M. Hannum.
20 * 4. The name of the author may not be used to endorse or promote products
21 * derived from this software without specific prior written permission.
23 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
24 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
25 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
26 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
27 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
28 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
32 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 * Originally written by Julian Elischer (julian@tfs.com)
37 * for TRW Financial Systems for use under the MACH(2.5) operating system.
39 * TRW Financial Systems, in accordance with their agreement with Carnegie
40 * Mellon University, makes this software available to CMU to distribute
41 * or use in any manner that they see fit as long as this message is kept with
42 * the software. For this reason TFS also grants any other persons or
43 * organisations permission to use or modify this software.
45 * TFS supplies this software to be publicly redistributed
46 * on the understanding that TFS is not responsible for the correct
47 * functioning of this software in any circumstances.
51 * AHA-1640 MCA bus code by Scott Telford
54 #include <sys/cdefs.h>
55 __KERNEL_RCSID(0, "$NetBSD: aha_mca.c,v 1.21 2009/09/21 08:12:47 tsutsui Exp $");
57 #include <sys/param.h>
58 #include <sys/systm.h>
59 #include <sys/device.h>
61 #include <sys/bus.h>
62 #include <sys/intr.h>
64 #include <dev/scsipi/scsi_all.h>
65 #include <dev/scsipi/scsipi_all.h>
66 #include <dev/scsipi/scsiconf.h>
68 #include <dev/isa/isavar.h>
69 #include <dev/isa/isadmavar.h>
71 #include <dev/ic/ahareg.h>
72 #include <dev/ic/ahavar.h>
74 #include <dev/mca/mcareg.h>
75 #include <dev/mca/mcavar.h>
76 #include <dev/mca/mcadevs.h>
78 #define AHA_ISA_IOSIZE 4
80 static int aha_mca_probe(device_t, cfdata_t, void *);
81 static void aha_mca_attach(device_t, device_t, void *);
83 CFATTACH_DECL_NEW(aha_mca, sizeof(struct aha_softc),
84 aha_mca_probe, aha_mca_attach, NULL, NULL);
86 int
87 aha_mca_probe(device_t parent, cfdata_t match, void *aux)
89 register struct mca_attach_args *ma = aux;
91 if (ma->ma_id == MCA_PRODUCT_AHA1640)
92 return (1);
94 return (0);
98 void
99 aha_mca_attach(device_t parent, device_t self, void *aux)
101 struct mca_attach_args *ma = aux;
102 struct aha_softc *sc = device_private(self);
103 bus_space_tag_t iot = ma->ma_iot;
104 bus_space_handle_t ioh;
105 struct aha_probe_data apd;
106 mca_chipset_tag_t mc = ma->ma_mc;
107 bus_addr_t iobase;
109 sc->sc_dev =self;
112 * POS registers differ much between 8003 and 8013, so they are
113 * divided to two sections.
115 * POS register 2: (adf pos0)
116 * 7 6 5 4 3 2 1 0
117 * | 0 0 0 0 0 0 \__ enable: 0=adapter disabled, 1=adapter enabled
118 * \_______________ Adapter BIOS location
120 * POS register 3: (adf pos1)
121 * 7 6 5 4 3 2 1 0
122 * \_/ \___/ \___/
123 * | | \__ I/O Port Address (upper part)
124 * | |__________ Adapter BIOS location
125 * |_______________ I/O Port Address (lower part)
127 * POS register 4: (adf pos2)
128 * 7 6 5 4 3 2 1 0
129 * \___/ | | \___/
130 * | | | \__ IRQ: XXX+8
131 * | | |________ Sync xfer started by AHA-1640: 1=YES 2=NO
132 * | |__________ SCSI Parity Checking On/Off
133 * |______________ SCSI Address
135 * POS register 3: (adf pos3)
136 * 7 6 5 4 3 2 1 0
137 * | \_____/
138 * | \__ Arbitration lvl (DMA channel)
139 * |__________ Fairness On/Off
143 apd.sc_irq = (ma->ma_pos[4] & 0x7) + 8;
144 apd.sc_drq = ma->ma_pos[5] & 0xf;
145 apd.sc_scsi_dev = (ma->ma_pos[4] & 0xe0) >> 5;
147 printf(" slot %d irq %d drq %d: Adaptec AHA-1640 SCSI Adapter\n",
148 ma->ma_slot + 1,
149 apd.sc_irq, apd.sc_drq);
151 iobase = ((ma->ma_pos[3] & 0x03) << 8) + 0x30 +
152 ((ma->ma_pos[3] & 0x40) >> 4);
154 if (bus_space_map(iot, iobase, AHA_ISA_IOSIZE, 0, &ioh)) {
155 aprint_error_dev(self, "can't map i/o space\n");
156 return;
159 sc->sc_iot = iot;
160 sc->sc_ioh = ioh;
161 sc->sc_dmat = ma->ma_dmat;
164 * AHA1640 is bus-mastering card, does not need any assistance
165 * with DMA transfers by MCA DMA controller.
168 sc->sc_ih = mca_intr_establish(mc, apd.sc_irq, IPL_BIO, aha_intr, sc);
169 if (sc->sc_ih == NULL) {
170 aprint_error_dev(self, "couldn't establish interrupt\n");
171 return;
174 aha_attach(sc, &apd);