2000-09-24 16:37:03 +04:00
|
|
|
/* $NetBSD: ahc_isa.c,v 1.14 2000/09/24 12:37:04 jdolecek Exp $ */
|
1997-10-05 02:32:26 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Product specific probe and attach routines for:
|
2000-03-15 05:05:19 +03:00
|
|
|
* AHA-284X VL-bus SCSI controllers
|
1997-10-05 02:32:26 +04:00
|
|
|
*
|
2000-03-15 05:05:19 +03:00
|
|
|
* Copyright (c) 1994, 1995, 1996, 1997, 1998 Justin T. Gibbs.
|
1997-10-05 02:32:26 +04:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice immediately at the beginning of the file, without modification,
|
|
|
|
* this list of conditions, and the following disclaimer.
|
2000-03-15 05:05:19 +03:00
|
|
|
* 2. The name of the author may not be used to endorse or promote products
|
1997-10-05 02:32:26 +04:00
|
|
|
* derived from this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
|
|
|
|
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
2000-03-15 05:05:19 +03:00
|
|
|
*
|
|
|
|
* $FreeBSD: src/sys/dev/aic7xxx/ahc_eisa.c,v 1.15 2000/01/29 14:22:19 peter Exp $
|
1997-10-05 02:32:26 +04:00
|
|
|
*/
|
1997-10-04 21:22:49 +04:00
|
|
|
|
|
|
|
/*-
|
|
|
|
* Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This code is derived from software contributed to The NetBSD Foundation
|
|
|
|
* by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
|
|
|
|
* NASA Ames Research Center.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
|
|
|
* This product includes software developed by the NetBSD
|
|
|
|
* Foundation, Inc. and its contributors.
|
|
|
|
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
|
|
|
* contributors may be used to endorse or promote products derived
|
|
|
|
* from this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
|
|
|
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
|
|
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
|
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
|
|
|
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
* POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
1996-08-06 01:14:29 +04:00
|
|
|
|
|
|
|
/*
|
1997-10-05 02:32:26 +04:00
|
|
|
* Copyright (c) 1995, 1996 Christopher G. Demetriou
|
1996-08-06 01:14:29 +04:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
1997-10-05 02:32:26 +04:00
|
|
|
* notice, this list of conditions and the following disclaimer.
|
1996-08-06 01:14:29 +04:00
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
1997-10-05 02:32:26 +04:00
|
|
|
* This product includes software developed by Christopher G. Demetriou
|
|
|
|
* for the NetBSD Project.
|
1996-08-06 01:14:29 +04:00
|
|
|
* 4. The name of the author may not be used to endorse or promote products
|
1997-10-05 02:32:26 +04:00
|
|
|
* derived from this software without specific prior written permission
|
1996-08-06 01:14:29 +04:00
|
|
|
*
|
1997-10-05 02:32:26 +04:00
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
|
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
|
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
1996-08-06 01:14:29 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This front-end driver is really sort of a hack. The AHA-284X likes
|
|
|
|
* to masquerade as an EISA device. However, on VLbus machines with
|
|
|
|
* no EISA signature in the BIOS, the EISA bus will never be scanned.
|
|
|
|
* This is intended to catch the 284X controllers on those systems
|
|
|
|
* by looking in "EISA i/o space" for 284X controllers.
|
|
|
|
*
|
|
|
|
* This relies heavily on i/o port accounting. We also just use the
|
|
|
|
* EISA macros for everything ... it's a real waste to redefine them.
|
|
|
|
*
|
|
|
|
* Note: there isn't any #ifdef for FreeBSD in this file, since the
|
|
|
|
* FreeBSD EISA driver handles all cases of the 284X.
|
|
|
|
*
|
|
|
|
* -- Jason R. Thorpe <thorpej@NetBSD.ORG>
|
|
|
|
* July 12, 1996
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/kernel.h>
|
|
|
|
#include <sys/device.h>
|
|
|
|
#include <sys/queue.h>
|
|
|
|
#include <sys/malloc.h>
|
2000-09-24 16:37:03 +04:00
|
|
|
#include <sys/reboot.h>
|
1996-08-06 01:14:29 +04:00
|
|
|
|
|
|
|
#include <machine/bus.h>
|
|
|
|
#include <machine/intr.h>
|
|
|
|
|
1997-08-27 15:22:52 +04:00
|
|
|
#include <dev/scsipi/scsi_all.h>
|
|
|
|
#include <dev/scsipi/scsipi_all.h>
|
|
|
|
#include <dev/scsipi/scsiconf.h>
|
1996-08-06 01:14:29 +04:00
|
|
|
|
|
|
|
#include <dev/isa/isavar.h>
|
|
|
|
|
|
|
|
#include <dev/eisa/eisareg.h>
|
|
|
|
#include <dev/eisa/eisavar.h>
|
|
|
|
#include <dev/eisa/eisadevs.h>
|
|
|
|
|
2000-03-15 05:05:19 +03:00
|
|
|
#include <dev/microcode/aic7xxx/aic7xxx_reg.h>
|
1996-08-06 01:14:29 +04:00
|
|
|
#include <dev/ic/aic7xxxvar.h>
|
2000-03-15 05:05:19 +03:00
|
|
|
#include <dev/ic/aic77xxreg.h>
|
|
|
|
#include <dev/ic/aic77xxvar.h>
|
|
|
|
#include <dev/ic/smc93cx6var.h>
|
|
|
|
|
1996-08-06 01:14:29 +04:00
|
|
|
/* IO port address setting range as EISA slot number */
|
|
|
|
#define AHC_ISA_MIN_SLOT 0x1 /* from iobase = 0x1c00 */
|
|
|
|
#define AHC_ISA_MAX_SLOT 0xe /* to iobase = 0xec00 */
|
|
|
|
|
2000-03-15 05:05:19 +03:00
|
|
|
#define AHC_ISA_SLOT_OFFSET AHC_EISA_SLOT_OFFSET
|
|
|
|
#define AHC_ISA_IOSIZE AHC_EISA_IOSIZE
|
1996-08-06 01:14:29 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* I/O port offsets
|
|
|
|
*/
|
|
|
|
#define AHC_ISA_VID (EISA_SLOTOFF_VID - AHC_ISA_SLOT_OFFSET)
|
|
|
|
#define AHC_ISA_PID (EISA_SLOTOFF_PID - AHC_ISA_SLOT_OFFSET)
|
|
|
|
#define AHC_ISA_PRIMING AHC_ISA_VID /* enable vendor/product ID */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* AHC_ISA_PRIMING register values (write)
|
|
|
|
*/
|
|
|
|
#define AHC_ISA_PRIMING_VID(index) (AHC_ISA_VID + (index))
|
|
|
|
#define AHC_ISA_PRIMING_PID(index) (AHC_ISA_PID + (index))
|
|
|
|
|
1996-10-22 02:24:37 +04:00
|
|
|
int ahc_isa_idstring __P((bus_space_tag_t, bus_space_handle_t, char *));
|
|
|
|
int ahc_isa_match __P((struct isa_attach_args *, bus_addr_t));
|
1996-08-06 01:14:29 +04:00
|
|
|
|
1998-03-22 15:52:03 +03:00
|
|
|
int ahc_isa_probe __P((struct device *, struct cfdata *, void *));
|
1996-08-06 01:14:29 +04:00
|
|
|
void ahc_isa_attach __P((struct device *, struct device *, void *));
|
2000-03-15 05:05:19 +03:00
|
|
|
void aha2840_load_seeprom __P((struct ahc_softc *ahc));
|
1996-08-06 01:14:29 +04:00
|
|
|
|
|
|
|
struct cfattach ahc_isa_ca = {
|
2000-03-15 05:05:19 +03:00
|
|
|
sizeof(struct ahc_softc), ahc_isa_probe, ahc_isa_attach
|
1996-08-06 01:14:29 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This keeps track of which slots are to be checked next if the
|
|
|
|
* iobase locator is a wildcard. A simple static variable isn't enough,
|
|
|
|
* since it's conceivable that a system might have more than one ISA
|
|
|
|
* bus.
|
|
|
|
*
|
|
|
|
* The "bus" member is the unit number of the parent ISA bus, e.g. "0"
|
|
|
|
* for "isa0".
|
|
|
|
*/
|
|
|
|
struct ahc_isa_slot {
|
|
|
|
LIST_ENTRY(ahc_isa_slot) link;
|
|
|
|
int bus;
|
|
|
|
int slot;
|
|
|
|
};
|
|
|
|
static LIST_HEAD(, ahc_isa_slot) ahc_isa_all_slots;
|
|
|
|
static int ahc_isa_slot_initialized;
|
|
|
|
|
|
|
|
int
|
1996-10-22 02:24:37 +04:00
|
|
|
ahc_isa_idstring(iot, ioh, idstring)
|
|
|
|
bus_space_tag_t iot;
|
|
|
|
bus_space_handle_t ioh;
|
1996-08-06 01:14:29 +04:00
|
|
|
char *idstring;
|
|
|
|
{
|
|
|
|
u_int8_t vid[EISA_NVIDREGS], pid[EISA_NPIDREGS];
|
|
|
|
int i;
|
|
|
|
|
|
|
|
/* Get the vendor ID bytes */
|
|
|
|
for (i = 0; i < EISA_NVIDREGS; i++) {
|
1996-10-22 02:24:37 +04:00
|
|
|
bus_space_write_1(iot, ioh, AHC_ISA_PRIMING,
|
1996-08-06 01:14:29 +04:00
|
|
|
AHC_ISA_PRIMING_VID(i));
|
1996-10-22 02:24:37 +04:00
|
|
|
vid[i] = bus_space_read_1(iot, ioh, AHC_ISA_VID + i);
|
1996-08-06 01:14:29 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Check for device existence */
|
|
|
|
if (EISA_VENDID_NODEV(vid)) {
|
|
|
|
#if 0
|
1996-10-13 07:19:38 +04:00
|
|
|
printf("ahc_isa_idstring: no device at 0x%lx\n",
|
1996-08-06 01:14:29 +04:00
|
|
|
ioh); /* XXX knows about ioh guts */
|
1996-10-13 07:19:38 +04:00
|
|
|
printf("\t(0x%x, 0x%x)\n", vid[0], vid[1]);
|
1996-08-06 01:14:29 +04:00
|
|
|
#endif
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* And check that the firmware didn't biff something badly */
|
|
|
|
if (EISA_VENDID_IDDELAY(vid)) {
|
1996-10-13 07:19:38 +04:00
|
|
|
printf("ahc_isa_idstring: BIOS biffed it at 0x%lx\n",
|
1996-08-06 01:14:29 +04:00
|
|
|
ioh); /* XXX knows about ioh guts */
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Get the product ID bytes */
|
|
|
|
for (i = 0; i < EISA_NPIDREGS; i++) {
|
1996-10-22 02:24:37 +04:00
|
|
|
bus_space_write_1(iot, ioh, AHC_ISA_PRIMING,
|
1996-08-06 01:14:29 +04:00
|
|
|
AHC_ISA_PRIMING_PID(i));
|
1996-10-22 02:24:37 +04:00
|
|
|
pid[i] = bus_space_read_1(iot, ioh, AHC_ISA_PID + i);
|
1996-08-06 01:14:29 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Create the ID string from the vendor and product IDs */
|
|
|
|
idstring[0] = EISA_VENDID_0(vid);
|
|
|
|
idstring[1] = EISA_VENDID_1(vid);
|
|
|
|
idstring[2] = EISA_VENDID_2(vid);
|
|
|
|
idstring[3] = EISA_PRODID_0(pid);
|
|
|
|
idstring[4] = EISA_PRODID_1(pid);
|
|
|
|
idstring[5] = EISA_PRODID_2(pid);
|
|
|
|
idstring[6] = EISA_PRODID_3(pid);
|
|
|
|
idstring[7] = '\0'; /* sanity */
|
|
|
|
|
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
ahc_isa_match(ia, iobase)
|
|
|
|
struct isa_attach_args *ia;
|
1996-10-22 02:24:37 +04:00
|
|
|
bus_addr_t iobase;
|
1996-08-06 01:14:29 +04:00
|
|
|
{
|
1996-10-22 02:24:37 +04:00
|
|
|
bus_space_tag_t iot = ia->ia_iot;
|
|
|
|
bus_space_handle_t ioh;
|
1996-08-06 01:14:29 +04:00
|
|
|
int irq;
|
|
|
|
char idstring[EISA_IDSTRINGLEN];
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Get a mapping for the while slot-specific address
|
|
|
|
* space. If we can't, assume nothing's there, but
|
|
|
|
* warn about it.
|
|
|
|
*/
|
1996-10-22 02:24:37 +04:00
|
|
|
if (bus_space_map(iot, iobase, AHC_ISA_IOSIZE, 0, &ioh)) {
|
1996-08-06 01:14:29 +04:00
|
|
|
#if 0
|
|
|
|
/*
|
|
|
|
* Don't print anything out here, since this could
|
|
|
|
* be common on machines configured to look for
|
|
|
|
* ahc_eisa and ahc_isa.
|
|
|
|
*/
|
1996-10-13 07:19:38 +04:00
|
|
|
printf("ahc_isa_match: can't map I/O space for 0x%x\n",
|
1996-08-06 01:14:29 +04:00
|
|
|
iobase);
|
|
|
|
#endif
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
1996-10-22 02:24:37 +04:00
|
|
|
if (!ahc_isa_idstring(iot, ioh, idstring))
|
1996-08-06 01:14:29 +04:00
|
|
|
irq = -1; /* cannot get the ID string */
|
|
|
|
else if (strcmp(idstring, "ADP7756") &&
|
|
|
|
strcmp(idstring, "ADP7757"))
|
|
|
|
irq = -1; /* unknown ID strings */
|
|
|
|
else
|
2000-03-15 05:05:19 +03:00
|
|
|
irq = ahc_aic77xx_irq(iot, ioh);
|
1996-08-06 01:14:29 +04:00
|
|
|
|
1996-10-22 02:24:37 +04:00
|
|
|
bus_space_unmap(iot, ioh, AHC_ISA_IOSIZE);
|
1996-08-06 01:14:29 +04:00
|
|
|
|
|
|
|
if (irq < 0)
|
|
|
|
return (0);
|
|
|
|
|
|
|
|
if (ia->ia_irq != IRQUNK &&
|
|
|
|
ia->ia_irq != irq) {
|
1996-10-13 07:19:38 +04:00
|
|
|
printf("ahc_isa_match: irq mismatch (kernel %d, card %d)\n",
|
1996-08-06 01:14:29 +04:00
|
|
|
ia->ia_irq, irq);
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* We have a match */
|
|
|
|
ia->ia_iobase = iobase;
|
|
|
|
ia->ia_irq = irq;
|
|
|
|
ia->ia_iosize = AHC_ISA_IOSIZE;
|
|
|
|
ia->ia_msize = 0;
|
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Check the slots looking for a board we recognise
|
|
|
|
* If we find one, note it's address (slot) and call
|
|
|
|
* the actual probe routine to check it out.
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
ahc_isa_probe(parent, match, aux)
|
|
|
|
struct device *parent;
|
1998-03-22 15:52:03 +03:00
|
|
|
struct cfdata *match;
|
|
|
|
void *aux;
|
1996-08-06 01:14:29 +04:00
|
|
|
{
|
|
|
|
struct isa_attach_args *ia = aux;
|
|
|
|
struct ahc_isa_slot *as;
|
|
|
|
|
|
|
|
if (ahc_isa_slot_initialized == 0) {
|
|
|
|
LIST_INIT(&ahc_isa_all_slots);
|
|
|
|
ahc_isa_slot_initialized = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ia->ia_iobase != IOBASEUNK)
|
|
|
|
return (ahc_isa_match(ia, ia->ia_iobase));
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Find this bus's state. If we don't yet have a slot
|
|
|
|
* marker, allocate and initialize one.
|
|
|
|
*/
|
|
|
|
for (as = ahc_isa_all_slots.lh_first; as != NULL;
|
|
|
|
as = as->link.le_next)
|
|
|
|
if (as->bus == parent->dv_unit)
|
|
|
|
goto found_slot_marker;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Don't have one, so make one.
|
|
|
|
*/
|
|
|
|
as = (struct ahc_isa_slot *)
|
|
|
|
malloc(sizeof(struct ahc_isa_slot), M_DEVBUF, M_NOWAIT);
|
|
|
|
if (as == NULL)
|
|
|
|
panic("ahc_isa_probe: can't allocate slot marker");
|
|
|
|
|
|
|
|
as->bus = parent->dv_unit;
|
|
|
|
as->slot = AHC_ISA_MIN_SLOT;
|
|
|
|
LIST_INSERT_HEAD(&ahc_isa_all_slots, as, link);
|
|
|
|
|
|
|
|
found_slot_marker:
|
|
|
|
|
|
|
|
for (; as->slot <= AHC_ISA_MAX_SLOT; as->slot++) {
|
|
|
|
if (ahc_isa_match(ia, EISA_SLOT_ADDR(as->slot) +
|
|
|
|
AHC_ISA_SLOT_OFFSET)) {
|
|
|
|
as->slot++; /* next slot to search */
|
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* No matching cards were found. */
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ahc_isa_attach(parent, self, aux)
|
|
|
|
struct device *parent, *self;
|
|
|
|
void *aux;
|
|
|
|
{
|
2000-03-15 05:05:19 +03:00
|
|
|
struct ahc_softc *ahc = (void *)self;
|
1996-08-06 01:14:29 +04:00
|
|
|
struct isa_attach_args *ia = aux;
|
1996-10-22 02:24:37 +04:00
|
|
|
bus_space_tag_t iot = ia->ia_iot;
|
|
|
|
bus_space_handle_t ioh;
|
2000-03-15 05:05:19 +03:00
|
|
|
int irq, intrtype;
|
|
|
|
const char *intrtypestr;
|
1996-08-06 01:14:29 +04:00
|
|
|
char idstring[EISA_IDSTRINGLEN];
|
|
|
|
|
1997-10-21 00:07:57 +04:00
|
|
|
if (bus_space_map(iot, ia->ia_iobase, ia->ia_iosize, 0, &ioh)) {
|
|
|
|
printf(": can't map i/o space\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (!ahc_isa_idstring(iot, ioh, idstring)) {
|
|
|
|
printf(": can't read ID string\n");
|
2000-03-15 05:05:19 +03:00
|
|
|
goto free_io;
|
1997-10-21 00:07:57 +04:00
|
|
|
}
|
2000-03-15 05:05:19 +03:00
|
|
|
if ((irq = ahc_aic77xx_irq(iot, ioh)) < 0) {
|
|
|
|
printf(": ahc_aic77xx_irq failed\n");
|
|
|
|
goto free_io;
|
1997-10-21 00:07:57 +04:00
|
|
|
}
|
1996-08-06 01:14:29 +04:00
|
|
|
|
|
|
|
if (strcmp(idstring, "ADP7756") == 0) {
|
2000-03-15 05:05:19 +03:00
|
|
|
printf(": %s\n", EISA_PRODUCT_ADP7756);
|
1996-08-06 01:14:29 +04:00
|
|
|
} else if (strcmp(idstring, "ADP7757") == 0) {
|
2000-03-15 05:05:19 +03:00
|
|
|
printf(": %s\n", EISA_PRODUCT_ADP7757);
|
1996-08-06 01:14:29 +04:00
|
|
|
} else {
|
1997-10-21 00:07:57 +04:00
|
|
|
printf(": unknown device type %s\n", idstring);
|
2000-03-15 05:05:19 +03:00
|
|
|
goto free_io;
|
1996-08-06 01:14:29 +04:00
|
|
|
}
|
|
|
|
|
2000-03-15 05:05:19 +03:00
|
|
|
if (ahc_alloc(ahc, ioh, iot, ia->ia_dmat,
|
|
|
|
AHC_AIC7770|AHC_VL, AHC_AIC7770_FE, AHC_FNONE))
|
|
|
|
goto free_io;
|
1998-03-16 18:48:00 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Tell the bus-dma interface that we can do 32bit dma
|
2000-03-15 05:05:19 +03:00
|
|
|
* NOTE: this variable is first referenced in ahc_init().
|
1998-03-16 18:48:00 +03:00
|
|
|
*/
|
|
|
|
ahc->sc_dmaflags = ISABUS_DMA_32BIT;
|
1996-08-06 01:14:29 +04:00
|
|
|
|
2000-03-15 05:05:19 +03:00
|
|
|
ahc->channel = 'A';
|
|
|
|
ahc->channel_b = 'B';
|
|
|
|
if (ahc_reset(ahc) != 0)
|
|
|
|
goto free_ahc;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The IRQMS bit enables level sensitive interrupts. Only allow
|
|
|
|
* IRQ sharing if it's set.
|
|
|
|
* NOTE: ahc->pause is initialized in ahc_alloc().
|
|
|
|
*/
|
|
|
|
if (ahc->pause & IRQMS) {
|
|
|
|
intrtype = IST_LEVEL;
|
|
|
|
intrtypestr = "level sensitive";
|
|
|
|
} else {
|
|
|
|
intrtype = IST_EDGE;
|
|
|
|
intrtypestr = "edge triggered";
|
|
|
|
}
|
|
|
|
ahc->ih = isa_intr_establish(ia->ia_ic, irq,
|
|
|
|
intrtype, IPL_BIO, ahc_intr, ahc);
|
|
|
|
if (ahc->ih == NULL) {
|
|
|
|
printf("%s: couldn't establish %s interrupt\n",
|
|
|
|
ahc->sc_dev.dv_xname, intrtypestr);
|
|
|
|
goto free_ahc;
|
|
|
|
}
|
|
|
|
|
1996-08-06 01:14:29 +04:00
|
|
|
/*
|
|
|
|
* Tell the user what type of interrupts we're using.
|
|
|
|
* usefull for debugging irq problems
|
|
|
|
*/
|
2000-03-15 05:05:19 +03:00
|
|
|
if (bootverbose) {
|
|
|
|
printf("%s: Using %s interrupts\n",
|
|
|
|
ahc->sc_dev.dv_xname, intrtypestr);
|
|
|
|
}
|
1996-08-06 01:14:29 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Now that we know we own the resources we need, do the
|
|
|
|
* card initialization.
|
|
|
|
*/
|
2000-03-15 05:05:19 +03:00
|
|
|
aha2840_load_seeprom(ahc);
|
|
|
|
|
|
|
|
/* Attach sub-devices */
|
|
|
|
if (ahc_aic77xx_attach(ahc) == 0)
|
|
|
|
return; /* succeed */
|
|
|
|
|
|
|
|
/* failed */
|
|
|
|
isa_intr_disestablish(ia->ia_ic, ahc->ih);
|
|
|
|
free_ahc:
|
|
|
|
ahc_free(ahc);
|
|
|
|
free_io:
|
|
|
|
bus_space_unmap(iot, ioh, ia->ia_iosize);
|
|
|
|
}
|
1996-08-06 01:14:29 +04:00
|
|
|
|
2000-03-15 05:05:19 +03:00
|
|
|
/*
|
|
|
|
* Read the 284x SEEPROM.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
aha2840_load_seeprom(struct ahc_softc *ahc)
|
|
|
|
{
|
|
|
|
struct seeprom_descriptor sd;
|
|
|
|
struct seeprom_config sc;
|
|
|
|
u_int16_t checksum = 0;
|
|
|
|
u_int8_t scsi_conf;
|
|
|
|
int have_seeprom;
|
|
|
|
|
|
|
|
sd.sd_tag = ahc->tag;
|
|
|
|
sd.sd_bsh = ahc->bsh;
|
|
|
|
sd.sd_control_offset = SEECTL_2840;
|
|
|
|
sd.sd_status_offset = STATUS_2840;
|
|
|
|
sd.sd_dataout_offset = STATUS_2840;
|
|
|
|
sd.sd_chip = C46;
|
|
|
|
sd.sd_MS = 0;
|
|
|
|
sd.sd_RDY = EEPROM_TF;
|
|
|
|
sd.sd_CS = CS_2840;
|
|
|
|
sd.sd_CK = CK_2840;
|
|
|
|
sd.sd_DO = DO_2840;
|
|
|
|
sd.sd_DI = DI_2840;
|
|
|
|
|
|
|
|
if (bootverbose)
|
|
|
|
printf("%s: Reading SEEPROM...", ahc_name(ahc));
|
|
|
|
have_seeprom = read_seeprom(&sd,
|
|
|
|
(u_int16_t *)&sc,
|
|
|
|
/*start_addr*/0,
|
|
|
|
sizeof(sc)/2);
|
|
|
|
|
|
|
|
if (have_seeprom) {
|
|
|
|
/* Check checksum */
|
|
|
|
int i;
|
|
|
|
int maxaddr = (sizeof(sc)/2) - 1;
|
|
|
|
u_int16_t *scarray = (u_int16_t *)≻
|
|
|
|
|
|
|
|
for (i = 0; i < maxaddr; i++)
|
|
|
|
checksum = checksum + scarray[i];
|
|
|
|
if (checksum != sc.checksum) {
|
|
|
|
if(bootverbose)
|
|
|
|
printf ("checksum error\n");
|
|
|
|
have_seeprom = 0;
|
|
|
|
} else if (bootverbose) {
|
|
|
|
printf("done.\n");
|
1996-08-06 01:14:29 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-03-15 05:05:19 +03:00
|
|
|
if (!have_seeprom) {
|
|
|
|
if (bootverbose)
|
|
|
|
printf("%s: No SEEPROM available\n", ahc_name(ahc));
|
|
|
|
ahc->flags |= AHC_USEDEFAULTS;
|
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* Put the data we've collected down into SRAM
|
|
|
|
* where ahc_init will find it.
|
|
|
|
*/
|
|
|
|
int i;
|
|
|
|
int max_targ = (ahc->features & AHC_WIDE) != 0 ? 16 : 8;
|
|
|
|
u_int16_t discenable;
|
|
|
|
|
|
|
|
discenable = 0;
|
|
|
|
for (i = 0; i < max_targ; i++){
|
|
|
|
u_int8_t target_settings;
|
|
|
|
target_settings = (sc.device_flags[i] & CFXFER) << 4;
|
|
|
|
if (sc.device_flags[i] & CFSYNCH)
|
|
|
|
target_settings |= SOFS;
|
|
|
|
if (sc.device_flags[i] & CFWIDEB)
|
|
|
|
target_settings |= WIDEXFER;
|
|
|
|
if (sc.device_flags[i] & CFDISC)
|
|
|
|
discenable |= (0x01 << i);
|
|
|
|
ahc_outb(ahc, TARG_SCSIRATE + i, target_settings);
|
|
|
|
}
|
|
|
|
ahc_outb(ahc, DISC_DSB, ~(discenable & 0xff));
|
|
|
|
ahc_outb(ahc, DISC_DSB + 1, ~((discenable >> 8) & 0xff));
|
1996-08-06 01:14:29 +04:00
|
|
|
|
2000-03-15 05:05:19 +03:00
|
|
|
ahc->our_id = sc.brtime_id & CFSCSIID;
|
1996-08-06 01:14:29 +04:00
|
|
|
|
2000-03-15 05:05:19 +03:00
|
|
|
scsi_conf = (ahc->our_id & 0x7);
|
|
|
|
if (sc.adapter_control & CFSPARITY)
|
|
|
|
scsi_conf |= ENSPCHK;
|
|
|
|
if (sc.adapter_control & CFRESETB)
|
|
|
|
scsi_conf |= RESET_SCSI;
|
1996-08-06 01:14:29 +04:00
|
|
|
|
2000-03-15 05:05:19 +03:00
|
|
|
if (sc.bios_control & CF284XEXTEND)
|
|
|
|
ahc->flags |= AHC_EXTENDED_TRANS_A;
|
|
|
|
/* Set SCSICONF info */
|
|
|
|
ahc_outb(ahc, SCSICONF, scsi_conf);
|
1996-08-06 01:14:29 +04:00
|
|
|
|
2000-03-15 05:05:19 +03:00
|
|
|
if (sc.adapter_control & CF284XSTERM)
|
|
|
|
ahc->flags |= AHC_TERM_ENB_A;
|
|
|
|
}
|
1996-08-06 01:14:29 +04:00
|
|
|
}
|