1 /* $NetBSD: aic77xx.c,v 1.7 2007/10/19 11:59:46 ad Exp $ */
4 * Common routines for AHA-27/284X and aic7770 motherboard SCSI controllers.
6 * Copyright (c) 1994, 1995, 1996, 1997, 1998 Justin T. Gibbs.
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
12 * 1. Redistributions of source code must retain the above copyright
13 * notice immediately at the beginning of the file, without modification,
14 * this list of conditions, and the following disclaimer.
15 * 2. The name of the author may not be used to endorse or promote products
16 * derived from this software without specific prior written permission.
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
19 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
22 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * $FreeBSD: src/sys/dev/aic7xxx/ahc_eisa.c,v 1.15 2000/01/29 14:22:19 peter Exp $
33 #include <sys/cdefs.h>
34 __KERNEL_RCSID(0, "$NetBSD: aic77xx.c,v 1.7 2007/10/19 11:59:46 ad Exp $");
36 #include <sys/param.h>
37 #include <sys/systm.h>
38 #include <sys/device.h>
43 #include <dev/scsipi/scsi_all.h>
44 #include <dev/scsipi/scsipi_all.h>
45 #include <dev/scsipi/scsiconf.h>
47 #include <dev/ic/aic7xxx_osm.h>
48 #include <dev/ic/aic7xxx_inline.h>
49 #include <dev/ic/aic77xxreg.h>
50 #include <dev/ic/aic77xxvar.h>
53 * Return irq setting of the board, otherwise -1.
56 ahc_aic77xx_irq(bus_space_tag_t iot
, bus_space_handle_t ioh
)
62 /* Pause the card preseving the IRQ type */
63 hcntrl
= bus_space_read_1(iot
, ioh
, HCNTRL
) & IRQMS
;
64 bus_space_write_1(iot
, ioh
, HCNTRL
, hcntrl
| PAUSE
);
66 intdef
= bus_space_read_1(iot
, ioh
, INTDEF
);
67 irq
= (intdef
& INTDEF_IRQ_MASK
);
77 printf("ahc_aic77xx_irq: illegal irq setting %d\n", intdef
);
85 ahc_aic77xx_attach(struct ahc_softc
*ahc
)
88 u_int8_t sblkctl_orig
;
92 * See if we have a Rev E or higher aic7770. Anything below a
93 * Rev E will have a R/O autoflush disable configuration bit.
95 sblkctl_orig
= ahc_inb(ahc
, SBLKCTL
);
96 sblkctl
= sblkctl_orig
^ AUTOFLUSHDIS
;
97 ahc_outb(ahc
, SBLKCTL
, sblkctl
);
98 sblkctl
= ahc_inb(ahc
, SBLKCTL
);
99 if (sblkctl
!= sblkctl_orig
) {
100 printf("%s: aic7770 >= Rev E: R/O autoflush enabled\n",
103 * Ensure autoflush is enabled
105 sblkctl
&= ~AUTOFLUSHDIS
;
106 ahc_outb(ahc
, SBLKCTL
, sblkctl
);
109 /* Setup the FIFO threshold and the bus off time */
110 hostconf
= ahc_inb(ahc
, HOSTCONF
);
111 ahc_outb(ahc
, BUSSPD
, hostconf
& DFTHRSH
);
112 ahc_outb(ahc
, BUSTIME
, (hostconf
<< 2) & BOFF
);
115 * Generic aic7xxx initialization.
119 * The board's IRQ line is not yet enabled so it's safe
120 * to release the irq.
126 * Enable the board's BUS drivers
128 ahc_outb(ahc
, BCTL
, ENABLE
);
130 /* Attach sub-devices - always succeeds */