New version, with changes from Justin Gibbs and Noriyuki Soda.
This commit is contained in:
parent
81ba0732e0
commit
19b0b9502f
|
@ -0,0 +1,537 @@
|
|||
/*
|
||||
* Product specific probe and attach routines for:
|
||||
* 27/284X and aic7770 motherboard SCSI controllers
|
||||
*
|
||||
* Copyright (c) 1994, 1995, 1996 Justin T. Gibbs.
|
||||
* 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.
|
||||
* 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. The name of the author may not be used to endorse or promote products
|
||||
* 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.
|
||||
*
|
||||
* $Id: ahc_eisa.c,v 1.1 1996/05/16 03:48:14 mycroft Exp $
|
||||
*/
|
||||
|
||||
#if defined(__FreeBSD__)
|
||||
#include <eisa.h>
|
||||
#endif
|
||||
#if NEISA > 0 || defined(__NetBSD__)
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#if defined(__FreeBSD__)
|
||||
#include <sys/devconf.h>
|
||||
#endif
|
||||
#include <sys/kernel.h>
|
||||
|
||||
#if defined(__NetBSD__)
|
||||
#include <sys/device.h>
|
||||
#include <machine/bus.h>
|
||||
#include <machine/intr.h>
|
||||
#endif /* defined(__NetBSD__) */
|
||||
|
||||
#include <scsi/scsi_all.h>
|
||||
#include <scsi/scsiconf.h>
|
||||
|
||||
#if defined(__FreeBSD__)
|
||||
|
||||
#include <machine/clock.h>
|
||||
|
||||
#include <i386/eisa/eisaconf.h>
|
||||
#include <i386/scsi/aic7xxx.h>
|
||||
#include <dev/aic7xxx/aic7xxx_reg.h>
|
||||
|
||||
#define EISA_DEVICE_ID_ADAPTEC_AIC7770 0x04907770
|
||||
#define EISA_DEVICE_ID_ADAPTEC_274x 0x04907771
|
||||
#define EISA_DEVICE_ID_ADAPTEC_284xB 0x04907756 /* BIOS enabled */
|
||||
#define EISA_DEVICE_ID_ADAPTEC_284x 0x04907757 /* BIOS disabled*/
|
||||
|
||||
#elif defined(__NetBSD__)
|
||||
|
||||
#include <dev/eisa/eisareg.h>
|
||||
#include <dev/eisa/eisavar.h>
|
||||
#include <dev/eisa/eisadevs.h>
|
||||
|
||||
#include <dev/ic/aic7xxxreg.h>
|
||||
#include <dev/ic/aic7xxxvar.h>
|
||||
|
||||
#endif /* defined(__NetBSD__) */
|
||||
|
||||
#define AHC_EISA_SLOT_OFFSET 0xc00
|
||||
#define AHC_EISA_IOSIZE 0x100
|
||||
#define INTDEF 0x5cul /* Interrupt Definition Register */
|
||||
|
||||
#if defined(__FreeBSD__)
|
||||
|
||||
static int aic7770probe __P((void));
|
||||
static int aic7770_attach __P((struct eisa_device *e_dev));
|
||||
|
||||
static struct eisa_driver ahc_eisa_driver = {
|
||||
"ahc",
|
||||
aic7770probe,
|
||||
aic7770_attach,
|
||||
/*shutdown*/NULL,
|
||||
&ahc_unit
|
||||
};
|
||||
|
||||
DATA_SET (eisadriver_set, ahc_eisa_driver);
|
||||
|
||||
static struct kern_devconf kdc_aic7770 = {
|
||||
0, 0, 0, /* filled in by dev_attach */
|
||||
"ahc", 0, { MDDT_EISA, 0, "bio" },
|
||||
eisa_generic_externalize, 0, 0, EISA_EXTERNALLEN,
|
||||
&kdc_eisa0, /* parent */
|
||||
0, /* parentdata */
|
||||
DC_UNCONFIGURED, /* always start out here */
|
||||
NULL,
|
||||
DC_CLS_MISC /* host adapters aren't special */
|
||||
};
|
||||
|
||||
|
||||
static char *aic7770_match __P((eisa_id_t type));
|
||||
|
||||
static char*
|
||||
aic7770_match(type)
|
||||
eisa_id_t type;
|
||||
{
|
||||
switch(type) {
|
||||
case EISA_DEVICE_ID_ADAPTEC_AIC7770:
|
||||
return ("Adaptec aic7770 SCSI host adapter");
|
||||
break;
|
||||
case EISA_DEVICE_ID_ADAPTEC_274x:
|
||||
return ("Adaptec 274X SCSI host adapter");
|
||||
break;
|
||||
case EISA_DEVICE_ID_ADAPTEC_284xB:
|
||||
case EISA_DEVICE_ID_ADAPTEC_284x:
|
||||
return ("Adaptec 284X SCSI host adapter");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
static int
|
||||
aic7770probe(void)
|
||||
{
|
||||
u_long iobase;
|
||||
char intdef;
|
||||
u_long irq;
|
||||
struct eisa_device *e_dev = NULL;
|
||||
int count;
|
||||
|
||||
count = 0;
|
||||
while ((e_dev = eisa_match_dev(e_dev, aic7770_match))) {
|
||||
iobase = (e_dev->ioconf.slot * EISA_SLOT_SIZE)
|
||||
+ AHC_EISA_SLOT_OFFSET;
|
||||
ahc_reset(iobase);
|
||||
|
||||
eisa_add_iospace(e_dev, iobase, AHC_EISA_IOSIZE, RESVADDR_NONE);
|
||||
intdef = inb(INTDEF + iobase);
|
||||
switch (intdef & 0xf) {
|
||||
case 9:
|
||||
irq = 9;
|
||||
break;
|
||||
case 10:
|
||||
irq = 10;
|
||||
break;
|
||||
case 11:
|
||||
irq = 11;
|
||||
break;
|
||||
case 12:
|
||||
irq = 12;
|
||||
break;
|
||||
case 14:
|
||||
irq = 14;
|
||||
break;
|
||||
case 15:
|
||||
irq = 15;
|
||||
break;
|
||||
default:
|
||||
printf("aic7770 at slot %d: illegal "
|
||||
"irq setting %d\n", e_dev->ioconf.slot,
|
||||
intdef);
|
||||
continue;
|
||||
}
|
||||
eisa_add_intr(e_dev, irq);
|
||||
eisa_registerdev(e_dev, &ahc_eisa_driver, &kdc_aic7770);
|
||||
if(e_dev->id == EISA_DEVICE_ID_ADAPTEC_284xB
|
||||
|| e_dev->id == EISA_DEVICE_ID_ADAPTEC_284x) {
|
||||
/* Our real parent is the isa bus. Say so. */
|
||||
e_dev->kdc->kdc_parent = &kdc_isa0;
|
||||
}
|
||||
count++;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
#elif defined(__NetBSD__)
|
||||
|
||||
#define bootverbose 1
|
||||
|
||||
int ahc_eisa_match __P((struct device *, void *, void *));
|
||||
void ahc_eisa_attach __P((struct device *, struct device *, void *));
|
||||
|
||||
|
||||
struct cfattach ahc_eisa_ca = {
|
||||
sizeof(struct ahc_data), ahc_eisa_match, ahc_eisa_attach
|
||||
};
|
||||
|
||||
/*
|
||||
* Return irq setting of the board, otherwise -1.
|
||||
*/
|
||||
int
|
||||
ahc_eisa_irq(bc, ioh)
|
||||
bus_chipset_tag_t bc;
|
||||
bus_io_handle_t ioh;
|
||||
{
|
||||
int irq;
|
||||
u_char intdef;
|
||||
|
||||
ahc_reset("ahc_eisa", bc, ioh);
|
||||
intdef = bus_io_read_1(bc, ioh, INTDEF);
|
||||
switch (irq = (intdef & 0xf)) {
|
||||
case 9:
|
||||
case 10:
|
||||
case 11:
|
||||
case 12:
|
||||
case 14:
|
||||
case 15:
|
||||
break;
|
||||
default:
|
||||
printf("ahc_eisa_irq: illegal irq setting %d\n", intdef);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Note that we are going and return (to probe) */
|
||||
return irq;
|
||||
}
|
||||
|
||||
/*
|
||||
* 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_eisa_match(parent, match, aux)
|
||||
struct device *parent;
|
||||
void *match, *aux;
|
||||
{
|
||||
struct eisa_attach_args *ea = aux;
|
||||
bus_io_handle_t ioh;
|
||||
int irq;
|
||||
|
||||
/* must match one of our known ID strings */
|
||||
if (strcmp(ea->ea_idstring, "ADP7770") &&
|
||||
strcmp(ea->ea_idstring, "ADP7771") &&
|
||||
strcmp(ea->ea_idstring, "ADP7756") && /* XXX - not EISA, but VL */
|
||||
strcmp(ea->ea_idstring, "ADP7757")) /* XXX - not EISA, but VL */
|
||||
return (0);
|
||||
|
||||
#ifdef notyet
|
||||
if (bus_io_map(ea->ea_bc, EISA_SLOT_ADDR(ea->ea_slot), EISA_SLOT_SIZE,
|
||||
&ioh))
|
||||
return (0);
|
||||
/* This won't compile as-is, anyway. */
|
||||
bus_io_write_1(ea->ea_bc, ioh, EISA_CONTROL, EISA_ENABLE | EISA_RESET);
|
||||
delay(10);
|
||||
bus_io_write_1(ea->ea_bc, ioh, EISA_CONTROL, EISA_ENABLE);
|
||||
/* Wait for reset? */
|
||||
delay(1000);
|
||||
bus_io_unmap(ea->ea_bc, ioh, EISA_SLOT_SIZE);
|
||||
#endif
|
||||
|
||||
if (bus_io_map(ea->ea_bc,
|
||||
EISA_SLOT_ADDR(ea->ea_slot) + AHC_EISA_SLOT_OFFSET,
|
||||
AHC_EISA_IOSIZE, &ioh))
|
||||
return (0);
|
||||
irq = ahc_eisa_irq(ea->ea_bc, ioh);
|
||||
bus_io_unmap(ea->ea_bc, ioh, EISA_SLOT_SIZE);
|
||||
return (irq >= 0);
|
||||
}
|
||||
|
||||
#endif /* defined(__NetBSD__) */
|
||||
|
||||
#if defined(__FreeBSD__)
|
||||
static int
|
||||
aic7770_attach(e_dev)
|
||||
struct eisa_device *e_dev;
|
||||
#elif defined(__NetBSD__)
|
||||
void
|
||||
ahc_eisa_attach(parent, self, aux)
|
||||
struct device *parent, *self;
|
||||
void *aux;
|
||||
#endif
|
||||
{
|
||||
ahc_type type;
|
||||
|
||||
#if defined(__FreeBSD__)
|
||||
struct ahc_data *ahc;
|
||||
resvaddr_t *iospace;
|
||||
int unit = e_dev->unit;
|
||||
int irq = ffs(e_dev->ioconf.irq) - 1;
|
||||
|
||||
iospace = e_dev->ioconf.ioaddrs.lh_first;
|
||||
|
||||
if(!iospace)
|
||||
return -1;
|
||||
|
||||
switch(e_dev->id) {
|
||||
case EISA_DEVICE_ID_ADAPTEC_AIC7770:
|
||||
type = AHC_AIC7770;
|
||||
break;
|
||||
case EISA_DEVICE_ID_ADAPTEC_274x:
|
||||
type = AHC_274;
|
||||
break;
|
||||
case EISA_DEVICE_ID_ADAPTEC_284xB:
|
||||
case EISA_DEVICE_ID_ADAPTEC_284x:
|
||||
type = AHC_284;
|
||||
break;
|
||||
default:
|
||||
printf("aic7770_attach: Unknown device type!\n");
|
||||
return -1;
|
||||
break;
|
||||
}
|
||||
|
||||
if(!(ahc = ahc_alloc(unit, iospace->addr, type, AHC_FNONE)))
|
||||
return -1;
|
||||
|
||||
eisa_reg_start(e_dev);
|
||||
if(eisa_reg_iospace(e_dev, iospace)) {
|
||||
ahc_free(ahc);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* The IRQMS bit enables level sensitive interrupts. Only allow
|
||||
* IRQ sharing if it's set.
|
||||
*/
|
||||
if(eisa_reg_intr(e_dev, irq, ahc_intr, (void *)ahc, &bio_imask,
|
||||
/*shared ==*/ahc->pause & IRQMS)) {
|
||||
ahc_free(ahc);
|
||||
return -1;
|
||||
}
|
||||
eisa_reg_end(e_dev);
|
||||
|
||||
#elif defined(__NetBSD__)
|
||||
|
||||
struct ahc_data *ahc = (void *)self;
|
||||
const char *model;
|
||||
struct eisa_attach_args *ea = aux;
|
||||
bus_io_handle_t ioh;
|
||||
eisa_intr_handle_t ih;
|
||||
const char *intrstr;
|
||||
int irq;
|
||||
|
||||
if (bus_io_map(ea->ea_bc,
|
||||
EISA_SLOT_ADDR(ea->ea_slot) + AHC_EISA_SLOT_OFFSET,
|
||||
AHC_EISA_IOSIZE, &ioh))
|
||||
panic("ahc_eisa_attach: could not map I/O addresses");
|
||||
if ((irq = ahc_eisa_irq(ea->ea_bc, ioh)) < 0)
|
||||
panic("ahc_eisa_attach: ahc_eisa_irq failed!");
|
||||
|
||||
if (strcmp(ea->ea_idstring, "ADP7770") == 0) {
|
||||
model = EISA_PRODUCT_ADP7770;
|
||||
type = AHC_AIC7770;
|
||||
} else if (strcmp(ea->ea_idstring, "ADP7771") == 0) {
|
||||
model = EISA_PRODUCT_ADP7771;
|
||||
type = AHC_274;
|
||||
} else if (strcmp(ea->ea_idstring, "ADP7756") == 0) {
|
||||
model = EISA_PRODUCT_ADP7756;
|
||||
type = AHC_284;
|
||||
} else if (strcmp(ea->ea_idstring, "ADP7757") == 0) {
|
||||
model = EISA_PRODUCT_ADP7757;
|
||||
type = AHC_284;
|
||||
} else {
|
||||
panic("ahc_eisa_attach: Unknown device type %s\n",
|
||||
ea->ea_idstring);
|
||||
}
|
||||
printf(": %s\n", model);
|
||||
|
||||
ahc_construct(ahc, ea->ea_bc, ioh, type, AHC_FNONE);
|
||||
if (eisa_intr_map(ea->ea_ec, irq, &ih)) {
|
||||
printf("%s: couldn't map interrupt (%d)\n",
|
||||
ahc->sc_dev.dv_xname, irq);
|
||||
return;
|
||||
}
|
||||
#endif /* defined(__NetBSD__) */
|
||||
|
||||
/*
|
||||
* Tell the user what type of interrupts we're using.
|
||||
* usefull for debugging irq problems
|
||||
*/
|
||||
if(bootverbose) {
|
||||
printf(
|
||||
"%s: Using %s Interrupts\n",
|
||||
ahc_name(ahc),
|
||||
ahc->pause & IRQMS ?
|
||||
"Level Sensitive" : "Edge Triggered");
|
||||
}
|
||||
|
||||
/*
|
||||
* Now that we know we own the resources we need, do the
|
||||
* card initialization.
|
||||
*
|
||||
* First, the aic7770 card specific setup.
|
||||
*/
|
||||
switch( ahc->type ) {
|
||||
case AHC_AIC7770:
|
||||
case AHC_274:
|
||||
{
|
||||
u_char biosctrl = AHC_INB(ahc, HA_274_BIOSCTRL);
|
||||
|
||||
/* Get the primary channel information */
|
||||
ahc->flags |= (biosctrl & CHANNEL_B_PRIMARY);
|
||||
|
||||
if((biosctrl & BIOSMODE) == BIOSDISABLED)
|
||||
ahc->flags |= AHC_USEDEFAULTS;
|
||||
break;
|
||||
}
|
||||
case AHC_284:
|
||||
{
|
||||
/* XXX
|
||||
* All values are automagically intialized at
|
||||
* POST for these cards, so we can always rely
|
||||
* on the Scratch Ram values. However, we should
|
||||
* read the SEEPROM here (Dan has the code to do
|
||||
* it) so we can say what kind of translation the
|
||||
* BIOS is using. Printing out the geometry could
|
||||
* save a lot of users the grief of failed installs.
|
||||
*/
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
* See if we have a Rev E or higher aic7770. Anything below a
|
||||
* Rev E will have a R/O autoflush disable configuration bit.
|
||||
* It's still not clear exactly what is differenent about the Rev E.
|
||||
* We think it allows 8 bit entries in the QOUTFIFO to support
|
||||
* "paging" SCBs so you can have more than 4 commands active at
|
||||
* once.
|
||||
*/
|
||||
{
|
||||
char *id_string;
|
||||
u_char sblkctl;
|
||||
u_char sblkctl_orig;
|
||||
|
||||
sblkctl_orig = AHC_INB(ahc, SBLKCTL);
|
||||
sblkctl = sblkctl_orig ^ AUTOFLUSHDIS;
|
||||
AHC_OUTB(ahc, SBLKCTL, sblkctl);
|
||||
sblkctl = AHC_INB(ahc, SBLKCTL);
|
||||
if(sblkctl != sblkctl_orig)
|
||||
{
|
||||
id_string = "aic7770 >= Rev E, ";
|
||||
/*
|
||||
* Ensure autoflush is enabled
|
||||
*/
|
||||
sblkctl &= ~AUTOFLUSHDIS;
|
||||
AHC_OUTB(ahc, SBLKCTL, sblkctl);
|
||||
|
||||
/* Allow paging on this adapter */
|
||||
ahc->flags |= AHC_PAGESCBS;
|
||||
}
|
||||
else
|
||||
id_string = "aic7770 <= Rev C, ";
|
||||
|
||||
printf("%s: %s", ahc_name(ahc), id_string);
|
||||
}
|
||||
|
||||
/* Setup the FIFO threshold and the bus off time */
|
||||
{
|
||||
u_char hostconf = AHC_INB(ahc, HOSTCONF);
|
||||
AHC_OUTB(ahc, BUSSPD, hostconf & DFTHRSH);
|
||||
AHC_OUTB(ahc, BUSTIME, (hostconf << 2) & BOFF);
|
||||
}
|
||||
|
||||
/*
|
||||
* Generic aic7xxx initialization.
|
||||
*/
|
||||
if(ahc_init(ahc)){
|
||||
#if defined(__FreeBSD__)
|
||||
ahc_free(ahc);
|
||||
/*
|
||||
* The board's IRQ line is not yet enabled so it's safe
|
||||
* to release the irq.
|
||||
*/
|
||||
eisa_release_intr(e_dev, irq, ahc_intr);
|
||||
return -1;
|
||||
#elif defined(__NetBSD__)
|
||||
ahc_free(ahc);
|
||||
return;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
* Enable the board's BUS drivers
|
||||
*/
|
||||
AHC_OUTB(ahc, BCTL, ENABLE);
|
||||
|
||||
#if defined(__FreeBSD__)
|
||||
/*
|
||||
* Enable our interrupt handler.
|
||||
*/
|
||||
if(eisa_enable_intr(e_dev, irq)) {
|
||||
ahc_free(ahc);
|
||||
eisa_release_intr(e_dev, irq, ahc_intr);
|
||||
return -1;
|
||||
}
|
||||
|
||||
e_dev->kdc->kdc_state = DC_BUSY; /* host adapters always busy */
|
||||
#elif defined(__NetBSD__)
|
||||
intrstr = eisa_intr_string(ea->ea_ec, ih);
|
||||
/*
|
||||
* The IRQMS bit enables level sensitive interrupts only allow
|
||||
* IRQ sharing if its set.
|
||||
*/
|
||||
ahc->sc_ih = eisa_intr_establish(ea->ea_ec, ih,
|
||||
ahc->pause & IRQMS ? IST_LEVEL : IST_EDGE, IPL_BIO, ahc_intr, ahc
|
||||
#ifdef __OpenBSD__
|
||||
, ahc->sc_dev.dv_xname
|
||||
#endif
|
||||
);
|
||||
if (ahc->sc_ih == NULL) {
|
||||
printf("%s: couldn't establish interrupt",
|
||||
ahc->sc_dev.dv_xname);
|
||||
if (intrstr != NULL)
|
||||
printf(" at %s", intrstr);
|
||||
printf("\n");
|
||||
ahc_free(ahc);
|
||||
return;
|
||||
}
|
||||
if (intrstr != NULL)
|
||||
printf("%s: interrupting at %s\n", ahc->sc_dev.dv_xname,
|
||||
intrstr);
|
||||
#endif /* defined(__NetBSD__) */
|
||||
|
||||
/* Attach sub-devices - always succeeds */
|
||||
ahc_attach(ahc);
|
||||
|
||||
#if defined(__FreeBSD__)
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif /* NEISA > 0 */
|
|
@ -1,4 +1,4 @@
|
|||
# $NetBSD: files.eisa,v 1.8 1996/04/25 02:16:39 thorpej Exp $
|
||||
# $NetBSD: files.eisa,v 1.9 1996/05/16 03:48:16 mycroft Exp $
|
||||
#
|
||||
# Config.new file and device description for machine-independent EISA code.
|
||||
# Included by ports that need it. Requires that the SCSI files be
|
||||
|
@ -13,6 +13,11 @@ device ahb: scsi
|
|||
attach ahb at eisa
|
||||
file dev/eisa/aha1742.c ahb
|
||||
|
||||
# Adaptec AHA-27/284X and aic7770 motherboard SCSI controllers
|
||||
# device declaration in sys/conf/files
|
||||
attach ahc at eisa with ahc_eisa
|
||||
file dev/eisa/ahc_eisa.c ahc_eisa
|
||||
|
||||
# 3Com 3c579 and 3c509 masquerading as EISA Ethernet Controllers
|
||||
# device declaration in sys/conf/files
|
||||
attach ep at eisa with ep_eisa
|
||||
|
|
|
@ -1,189 +0,0 @@
|
|||
/* $NetBSD: aha284x.c,v 1.5 1996/05/12 23:51:31 mycroft Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1996 Michael Graff. 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, 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 Michael Graff.
|
||||
* 4. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/device.h>
|
||||
|
||||
#include <scsi/scsi_all.h>
|
||||
#include <scsi/scsiconf.h>
|
||||
|
||||
#include <dev/isa/isavar.h>
|
||||
|
||||
#include <dev/ic/aic7xxxvar.h>
|
||||
|
||||
#include <machine/intr.h>
|
||||
#include <machine/pio.h>
|
||||
|
||||
static int ahe_probe __P((struct device *, void *, void *));
|
||||
static void ahe_attach __P((struct device *, struct device *, void *));
|
||||
|
||||
struct cfattach ahe_ca = {
|
||||
sizeof(struct ahc_softc), ahe_probe, ahe_attach
|
||||
};
|
||||
|
||||
struct cfdriver ahe_cd = {
|
||||
NULL, "ahe", DV_DULL
|
||||
};
|
||||
|
||||
/*
|
||||
* shouldn't this be in aic7xxxvar.h?
|
||||
*/
|
||||
int ahcintr __P((void *));
|
||||
|
||||
/*
|
||||
* Standard EISA Host ID regs (Offset from slot base)
|
||||
* These seem to work on the aha284x as well (VLB card)
|
||||
*/
|
||||
#define HID0 0xC80 /* 0,1: msb of ID2, 2-7: ID1 */
|
||||
#define HID1 0xC81 /* 0-4: ID3, 5-7: LSB ID2 */
|
||||
#define HID2 0xC82 /* product */
|
||||
#define HID3 0xC83 /* firmware revision */
|
||||
|
||||
#define CHAR1(B1,B2) (((B1>>2) & 0x1F) | '@')
|
||||
#define CHAR2(B1,B2) (((B1<<3) & 0x18) | ((B2>>5) & 0x7)|'@')
|
||||
#define CHAR3(B1,B2) ((B2 & 0x1F) | '@')
|
||||
|
||||
typedef struct {
|
||||
ahc_type type;
|
||||
unsigned char id; /* The Last EISA Host ID reg */
|
||||
} aic7770_sig;
|
||||
|
||||
aic7770_sig valid_ids[] = {
|
||||
/* Entries of other tested adaptors should be added here */
|
||||
{ AHC_274, 0x70 }, /*aic7770 on Motherboard*/
|
||||
{ AHC_274, 0x71 }, /*274x*/
|
||||
{ AHC_284, 0x56 }, /*284x, BIOS enabled*/
|
||||
{ AHC_284, 0x57 } /*284x, BIOS disabled*/
|
||||
};
|
||||
|
||||
int
|
||||
ahe_probe(parent, match, aux)
|
||||
struct device *parent;
|
||||
void *match, *aux;
|
||||
{
|
||||
struct ahc_softc *ahc = match;
|
||||
struct isa_attach_args *ia = aux;
|
||||
|
||||
char intdef;
|
||||
int iobase;
|
||||
u_char sig_id[4];
|
||||
int i;
|
||||
|
||||
#ifdef NEWCONFIG
|
||||
if (ia->ia_iobase == IOBASEUNK)
|
||||
return 0;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Make the offsets the same as for EISA
|
||||
*
|
||||
* I have NO idea why the values in aic7xxx.c are all 0xc00 too
|
||||
* high, but this hack fixes it. This is the same hack that's in
|
||||
* the 294x pci code.
|
||||
*/
|
||||
iobase = ia->ia_iobase - 0xc00;
|
||||
|
||||
for (i = 0; i < sizeof(sig_id); i++) {
|
||||
/*
|
||||
* An outb is required to prime these
|
||||
* registers on VL cards
|
||||
*/
|
||||
outb(iobase + HID0, HID0 + i);
|
||||
sig_id[i] = inb(iobase + HID0 + i);
|
||||
}
|
||||
|
||||
if (sig_id[0] == 0xff)
|
||||
return 0;
|
||||
|
||||
if (CHAR1(sig_id[0], sig_id[1]) != 'A'
|
||||
|| CHAR2(sig_id[0], sig_id[1]) != 'D'
|
||||
|| CHAR3(sig_id[0], sig_id[1]) != 'P'
|
||||
|| sig_id[2] != 0x77)
|
||||
return 0;
|
||||
|
||||
ahc->type = 0;
|
||||
|
||||
for (i = 0; i < sizeof(valid_ids)/sizeof(aic7770_sig); i++)
|
||||
if (sig_id[3] == valid_ids[i].id) {
|
||||
ahc->type = valid_ids[i].type;
|
||||
break;
|
||||
}
|
||||
|
||||
if (ahc->type == 0)
|
||||
printf("%s: Unknown board type 0x%02x\n",
|
||||
ahc->sc_dev.dv_xname, sig_id[3]);
|
||||
|
||||
if (ahcprobe(ahc, iobase) == 0)
|
||||
return 0;
|
||||
|
||||
/*
|
||||
* set up some other isa variables and make certain the irq the
|
||||
* card is set at matches the one in the configuration file,
|
||||
* it is wa defined there
|
||||
*/
|
||||
|
||||
ia->ia_iosize = 0x100; /* address range for the card */
|
||||
|
||||
if (ia->ia_irq == IRQUNK)
|
||||
ia->ia_irq = ahc->sc_irq; /* probed from the card */
|
||||
else
|
||||
if (ia->ia_irq != ahc->sc_irq) {
|
||||
printf("%s: irq mismatch; kernel configured %d != board configured %d\n",
|
||||
ahc->sc_dev.dv_xname, ia->ia_irq, ahc->sc_irq);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Must be ok... */
|
||||
return 1;
|
||||
}
|
||||
|
||||
void
|
||||
ahe_attach(parent, self, aux)
|
||||
struct device *parent, *self;
|
||||
void *aux;
|
||||
{
|
||||
struct ahc_softc *ahc = (void *)self;
|
||||
struct isa_attach_args *ia = aux;
|
||||
|
||||
#ifdef NEWCONFIG
|
||||
isa_establish(&ahc->sc_id, &ahc->sc_dev);
|
||||
#endif
|
||||
ahc->sc_ih = isa_intr_establish(ia->ia_ic, ia->ia_irq, IST_EDGE,
|
||||
IPL_BIO, ahcintr, ahc);
|
||||
|
||||
/*
|
||||
* attach the devices on the bus
|
||||
*/
|
||||
ahcattach(ahc);
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
# $NetBSD: files.isa,v 1.20 1996/05/07 01:50:09 thorpej Exp $
|
||||
# $NetBSD: files.isa,v 1.21 1996/05/16 03:45:55 mycroft Exp $
|
||||
#
|
||||
# Config.new file and device description for machine-independent ISA code.
|
||||
# Included by ports that need it. Requires that the SCSI files be
|
||||
|
@ -69,16 +69,11 @@ device aha: scsi, isadma
|
|||
attach aha at isa
|
||||
file dev/isa/aha.c aha
|
||||
|
||||
# Adapctec AIC-6[32]60 ICs
|
||||
# Adaptec AIC-6[32]60 ICs
|
||||
device aic: scsi, isadma
|
||||
attach aic at isa
|
||||
file dev/isa/aic6360.c aic
|
||||
|
||||
# Adaptec 7770-based EISA, VLB, etc. controllers
|
||||
device ahe: scsi, aic7xxx
|
||||
attach ahe at isa
|
||||
file dev/isa/aha284x.c ahe
|
||||
|
||||
# BusLogic BT-74x EISA family (XXX; should be EISA. it's special)
|
||||
device bt: scsi, isadma
|
||||
attach bt at isa
|
||||
|
|
|
@ -4,7 +4,7 @@ PATH: $S/dev/microcode/aic7xxx
|
|||
aic7xxx.o: aic7xxx_seq.h
|
||||
|
||||
aic7xxx_seq.h: aic7xxx_asm $S/dev/microcode/aic7xxx/aic7xxx.seq
|
||||
./aic7xxx_asm -v -o ${.TARGET} $S/dev/microcode/aic7xxx/aic7xxx.seq
|
||||
./aic7xxx_asm -o ${.TARGET} $S/dev/microcode/aic7xxx/aic7xxx.seq
|
||||
|
||||
aic7xxx_asm: $S/dev/microcode/aic7xxx/aic7xxx_asm.c
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -43,12 +43,13 @@
|
|||
* are token separators.
|
||||
*
|
||||
*-M*************************************************************************/
|
||||
static char id[] = "$Id: aic7xxx_asm.c,v 1.2 1996/04/29 19:30:50 christos Exp $";
|
||||
static char id[] = "$Id: aic7xxx_asm.c,v 1.3 1996/05/16 03:51:48 mycroft Exp $";
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#define MEMORY 448
|
||||
#define MAXLINE 1024
|
||||
|
@ -67,45 +68,17 @@ static char id[] = "$Id: aic7xxx_asm.c,v 1.2 1996/04/29 19:30:50 christos Exp $"
|
|||
int debug;
|
||||
int lineno, LC;
|
||||
char *filename;
|
||||
FILE *ifp, *ofp;
|
||||
unsigned char M[MEMORY][4];
|
||||
|
||||
typedef struct sym_t {
|
||||
struct sym_t *next; /* MUST BE FIRST */
|
||||
char *name;
|
||||
int value;
|
||||
int npatch;
|
||||
int *patch;
|
||||
} sym_t;
|
||||
|
||||
void error __P((char *));
|
||||
void *Malloc __P((size_t));
|
||||
void *Realloc __P((void *, size_t));
|
||||
char *Strdup __P((const char *));
|
||||
|
||||
void define __P((char *, int));
|
||||
sym_t *lookup __P((char *));
|
||||
void patch __P((sym_t *, int));
|
||||
void backpatch __P((void));
|
||||
void output __P((FILE *));
|
||||
char **getl __P((int *));
|
||||
int eval_operand __P((char **, int));
|
||||
int eval_sdi __P((char **, int));
|
||||
int eval_addr __P((char **, int));
|
||||
int crack __P((char **, int));
|
||||
void assemble __P((void));
|
||||
|
||||
void
|
||||
error(s)
|
||||
char *s;
|
||||
void
|
||||
error(char *s)
|
||||
{
|
||||
fprintf(stderr, "%s: %s at line %d\n", filename, s, lineno);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
void *
|
||||
Malloc(size)
|
||||
size_t size;
|
||||
Malloc(size_t size)
|
||||
{
|
||||
void *p = malloc(size);
|
||||
if (!p)
|
||||
|
@ -114,9 +87,7 @@ Malloc(size)
|
|||
}
|
||||
|
||||
void *
|
||||
Realloc(ptr, size)
|
||||
void *ptr;
|
||||
size_t size;
|
||||
Realloc(void *ptr, size_t size)
|
||||
{
|
||||
void *p = realloc(ptr, size);
|
||||
if (!p)
|
||||
|
@ -125,21 +96,25 @@ Realloc(ptr, size)
|
|||
}
|
||||
|
||||
char *
|
||||
Strdup(s)
|
||||
const char *s;
|
||||
Strdup(char *s)
|
||||
{
|
||||
size_t l = strlen(s) + 1;
|
||||
char *p = Malloc(l);
|
||||
memcpy(p, s, l);
|
||||
char *p = (char *)Malloc(strlen(s) + 1);
|
||||
strcpy(p, s);
|
||||
return(p);
|
||||
}
|
||||
|
||||
typedef struct sym_t {
|
||||
struct sym_t *next; /* MUST BE FIRST */
|
||||
char *name;
|
||||
int value;
|
||||
int npatch;
|
||||
int *patch;
|
||||
} sym_t;
|
||||
|
||||
sym_t *head;
|
||||
|
||||
void
|
||||
define(name, value)
|
||||
char *name;
|
||||
int value;
|
||||
define(char *name, int value)
|
||||
{
|
||||
sym_t *p, *q;
|
||||
|
||||
|
@ -166,8 +141,7 @@ define(name, value)
|
|||
}
|
||||
|
||||
sym_t *
|
||||
lookup(name)
|
||||
char *name;
|
||||
lookup(char *name)
|
||||
{
|
||||
sym_t *p;
|
||||
|
||||
|
@ -177,10 +151,8 @@ lookup(name)
|
|||
return(NULL);
|
||||
}
|
||||
|
||||
void
|
||||
patch(p, location)
|
||||
sym_t *p;
|
||||
int location;
|
||||
void
|
||||
patch(sym_t *p, int location)
|
||||
{
|
||||
p->npatch += 1;
|
||||
p->patch = (int *)Realloc(p->patch, p->npatch * sizeof(int *));
|
||||
|
@ -188,7 +160,7 @@ patch(p, location)
|
|||
p->patch[p->npatch - 1] = location;
|
||||
}
|
||||
|
||||
void backpatch()
|
||||
void backpatch(void)
|
||||
{
|
||||
int i;
|
||||
sym_t *p;
|
||||
|
@ -228,8 +200,7 @@ void backpatch()
|
|||
* since the sequencer RAM is loaded that way.
|
||||
*/
|
||||
void
|
||||
output(fp)
|
||||
FILE *fp;
|
||||
output(FILE *fp)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
@ -243,8 +214,7 @@ output(fp)
|
|||
}
|
||||
|
||||
char **
|
||||
getl(n)
|
||||
int *n;
|
||||
getl(int *n)
|
||||
{
|
||||
int i;
|
||||
char *p, *quote;
|
||||
|
@ -253,7 +223,7 @@ getl(n)
|
|||
|
||||
i = 0;
|
||||
|
||||
while (fgets(buf, sizeof(buf), ifp)) {
|
||||
while (fgets(buf, sizeof(buf), stdin)) {
|
||||
|
||||
lineno += 1;
|
||||
|
||||
|
@ -274,7 +244,7 @@ rescan:
|
|||
else
|
||||
error("too many tokens");
|
||||
if (quote) {
|
||||
quote++;
|
||||
quote++;
|
||||
p = strchr(quote, '\"');
|
||||
if (!p)
|
||||
error("unterminated string constant");
|
||||
|
@ -286,7 +256,7 @@ rescan:
|
|||
else
|
||||
error("too many tokens");
|
||||
goto rescan;
|
||||
}
|
||||
}
|
||||
if (i) {
|
||||
*n = i;
|
||||
return(a);
|
||||
|
@ -366,10 +336,8 @@ struct {
|
|||
{ 0, 0, 0, 0, 0, 0, 0, 0 }
|
||||
};
|
||||
|
||||
int
|
||||
eval_operand(a, spec)
|
||||
char **a;
|
||||
int spec;
|
||||
int
|
||||
eval_operand(char **a, int spec)
|
||||
{
|
||||
int i;
|
||||
unsigned int want = spec & (LO|LA|LX);
|
||||
|
@ -405,9 +373,7 @@ eval_operand(a, spec)
|
|||
}
|
||||
|
||||
int
|
||||
eval_sdi(a, spec)
|
||||
char **a;
|
||||
int spec;
|
||||
eval_sdi(char **a, int spec)
|
||||
{
|
||||
sym_t *p;
|
||||
unsigned val;
|
||||
|
@ -477,9 +443,7 @@ eval_sdi(a, spec)
|
|||
}
|
||||
|
||||
int
|
||||
eval_addr(a, spec)
|
||||
char **a;
|
||||
int spec;
|
||||
eval_addr(char **a, int spec)
|
||||
{
|
||||
sym_t *p;
|
||||
|
||||
|
@ -504,9 +468,7 @@ eval_addr(a, spec)
|
|||
}
|
||||
|
||||
int
|
||||
crack(a, n)
|
||||
char **a;
|
||||
int n;
|
||||
crack(char **a, int n)
|
||||
{
|
||||
int i;
|
||||
int I_imm, I_addr;
|
||||
|
@ -574,7 +536,7 @@ crack(a, n)
|
|||
#undef A
|
||||
|
||||
void
|
||||
assemble()
|
||||
assemble(FILE *ofile)
|
||||
{
|
||||
int n;
|
||||
char **a;
|
||||
|
@ -597,7 +559,7 @@ assemble()
|
|||
continue;
|
||||
|
||||
if (n == 3 && !strcmp("VERSION", *a))
|
||||
fprintf(ofp, "#define %s \"%s\"\n", a[1], a[2]);
|
||||
fprintf(ofile, "#define %s \"%s\"\n", a[1], a[2]);
|
||||
else {
|
||||
if (n == 3 && !strcmp("=", a[1]))
|
||||
define(*a, strtol(a[2], NULL, 0));
|
||||
|
@ -607,7 +569,7 @@ assemble()
|
|||
}
|
||||
|
||||
backpatch();
|
||||
output(ofp);
|
||||
output(ofile);
|
||||
|
||||
if (debug)
|
||||
output(stderr);
|
||||
|
@ -615,12 +577,15 @@ assemble()
|
|||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{ int my_version_print_flag;
|
||||
{
|
||||
int c;
|
||||
int pid;
|
||||
int ifile;
|
||||
FILE *ofile;
|
||||
int fd[2];
|
||||
|
||||
my_version_print_flag=0;
|
||||
|
||||
while ((c = getopt(argc, argv, "dho:vD")) != EOF) {
|
||||
ofile = NULL;
|
||||
while ((c = getopt(argc, argv, "dho:vD:")) != EOF) {
|
||||
switch (c) {
|
||||
case 'd':
|
||||
debug = !0;
|
||||
|
@ -637,23 +602,20 @@ main(int argc, char **argv)
|
|||
break;
|
||||
}
|
||||
case 'o':
|
||||
ofp = fopen(optarg, "w");
|
||||
if (!ofp) {
|
||||
|
||||
if ((ofile = fopen(optarg, "w")) == NULL) {
|
||||
perror(optarg);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
break;
|
||||
case 'h':
|
||||
printf("usage: %s [-d] [-Dname] [-ooutput] input\n",
|
||||
printf("usage: %s [-d] [-Dname] [-ooutput] input\n",
|
||||
*argv);
|
||||
exit(EXIT_SUCCESS);
|
||||
break;
|
||||
case 'v':
|
||||
if (!my_version_print_flag)
|
||||
{ printf("%s\n",id);
|
||||
|
||||
my_version_print_flag=1;
|
||||
}
|
||||
printf("%s\n", id);
|
||||
exit(EXIT_SUCCESS);
|
||||
break;
|
||||
default:
|
||||
exit(EXIT_FAILURE);
|
||||
|
@ -662,28 +624,62 @@ main(int argc, char **argv)
|
|||
}
|
||||
|
||||
if (argc - optind != 1) {
|
||||
if (my_version_print_flag)
|
||||
{ exit(EXIT_SUCCESS);
|
||||
}
|
||||
fprintf(stderr, "%s: must have one input file\n", *argv);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
filename = argv[optind];
|
||||
|
||||
ifp = fopen(filename, "r");
|
||||
if (!ifp) {
|
||||
|
||||
if ((ifile = open(filename, O_RDONLY)) < 0) {
|
||||
perror(filename);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (!ofp) {
|
||||
ofp = fopen(ADOTOUT, "w");
|
||||
if (!ofp) {
|
||||
if (!ofile) {
|
||||
if ((ofile = fopen(ADOTOUT, "w")) == NULL) {
|
||||
perror(ADOTOUT);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
assemble();
|
||||
exit(EXIT_SUCCESS);
|
||||
if (pipe(fd) < 0) {
|
||||
perror("pipe failed");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if ((pid = fork()) < 0 ) {
|
||||
perror("fork failed");
|
||||
exit(1);
|
||||
}
|
||||
else if (pid > 0) { /* Parent */
|
||||
close(fd[1]); /* Close write end */
|
||||
if (fd[0] != STDIN_FILENO) {
|
||||
if (dup2(fd[0], STDIN_FILENO) != STDIN_FILENO) {
|
||||
perror("dup2 error on stdin");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
close(fd[0]);
|
||||
}
|
||||
assemble(ofile);
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
else { /* Child */
|
||||
close(fd[0]); /* Close Read end */
|
||||
if (fd[1] != STDOUT_FILENO) {
|
||||
if (dup2(fd[1], STDOUT_FILENO) != STDOUT_FILENO) {
|
||||
perror("dup2 error on stdout");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
close(fd[1]);
|
||||
}
|
||||
if (ifile != STDIN_FILENO) {
|
||||
if (dup2(ifile, STDIN_FILENO) != STDIN_FILENO) {
|
||||
perror("dup2 error on stdin");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
close(ifile);
|
||||
}
|
||||
execl("/usr/bin/cpp", "/usr/bin/cpp", "-P", "-", "-", NULL);
|
||||
}
|
||||
return(EXIT_SUCCESS);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,715 @@
|
|||
/*
|
||||
* Product specific probe and attach routines for:
|
||||
* 3940, 2940, aic7880, aic7870, aic7860 and aic7850 SCSI controllers
|
||||
*
|
||||
* Copyright (c) 1995, 1996 Justin T. Gibbs.
|
||||
* 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.
|
||||
* 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. The name of the author may not be used to endorse or promote products
|
||||
* 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.
|
||||
*
|
||||
* $Id: ahc_pci.c,v 1.1 1996/05/16 03:44:13 mycroft Exp $
|
||||
*/
|
||||
|
||||
#if defined(__FreeBSD__)
|
||||
#include <pci.h>
|
||||
#endif
|
||||
#if NPCI > 0 || defined(__NetBSD__)
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/queue.h>
|
||||
#if defined(__NetBSD__)
|
||||
#include <sys/device.h>
|
||||
#include <machine/bus.h>
|
||||
#ifdef __alpha__
|
||||
#include <machine/intr.h>
|
||||
#endif
|
||||
#endif /* defined(__NetBSD__) */
|
||||
|
||||
#include <scsi/scsi_all.h>
|
||||
#include <scsi/scsiconf.h>
|
||||
|
||||
#if defined(__FreeBSD__)
|
||||
|
||||
#include <pci/pcireg.h>
|
||||
#include <pci/pcivar.h>
|
||||
|
||||
#include <machine/clock.h>
|
||||
|
||||
#include <i386/scsi/aic7xxx.h>
|
||||
#include <i386/scsi/93cx6.h>
|
||||
|
||||
#include <dev/aic7xxx/aic7xxx_reg.h>
|
||||
|
||||
#define PCI_BASEADR0 PCI_MAP_REG_START
|
||||
|
||||
#elif defined(__NetBSD__)
|
||||
|
||||
#include <dev/pci/pcireg.h>
|
||||
#include <dev/pci/pcivar.h>
|
||||
|
||||
#include <dev/ic/aic7xxxreg.h>
|
||||
#include <dev/ic/aic7xxxvar.h>
|
||||
#include <dev/ic/smc93cx6var.h>
|
||||
|
||||
#define bootverbose 1
|
||||
#define PCI_BASEADR0 PCI_MAPREG_START
|
||||
|
||||
#endif /* defined(__NetBSD__) */
|
||||
|
||||
#define PCI_DEVICE_ID_ADAPTEC_3940U 0x82789004ul
|
||||
#define PCI_DEVICE_ID_ADAPTEC_2944U 0x84789004ul
|
||||
#define PCI_DEVICE_ID_ADAPTEC_2940U 0x81789004ul
|
||||
#define PCI_DEVICE_ID_ADAPTEC_3940 0x72789004ul
|
||||
#define PCI_DEVICE_ID_ADAPTEC_2944 0x74789004ul
|
||||
#define PCI_DEVICE_ID_ADAPTEC_2940 0x71789004ul
|
||||
#define PCI_DEVICE_ID_ADAPTEC_AIC7880 0x80789004ul
|
||||
#define PCI_DEVICE_ID_ADAPTEC_AIC7870 0x70789004ul
|
||||
#define PCI_DEVICE_ID_ADAPTEC_AIC7860 0x60789004ul
|
||||
#define PCI_DEVICE_ID_ADAPTEC_AIC7855 0x55789004ul
|
||||
#define PCI_DEVICE_ID_ADAPTEC_AIC7850 0x50789004ul
|
||||
|
||||
#define DEVCONFIG 0x40
|
||||
#define MPORTMODE 0x00000400ul /* aic7870 only */
|
||||
#define RAMPSM 0x00000200ul /* aic7870 only */
|
||||
#define VOLSENSE 0x00000100ul
|
||||
#define SCBRAMSEL 0x00000080ul
|
||||
#define MRDCEN 0x00000040ul
|
||||
#define EXTSCBTIME 0x00000020ul /* aic7870 only */
|
||||
#define EXTSCBPEN 0x00000010ul /* aic7870 only */
|
||||
#define BERREN 0x00000008ul
|
||||
#define DACEN 0x00000004ul
|
||||
#define STPWLEVEL 0x00000002ul
|
||||
#define DIFACTNEGEN 0x00000001ul /* aic7870 only */
|
||||
|
||||
#define CSIZE_LATTIME 0x0c
|
||||
#define CACHESIZE 0x0000003ful /* only 5 bits */
|
||||
#define LATTIME 0x0000ff00ul
|
||||
|
||||
/*
|
||||
* Define the format of the aic78X0 SEEPROM registers (16 bits).
|
||||
*
|
||||
*/
|
||||
|
||||
struct seeprom_config {
|
||||
|
||||
/*
|
||||
* SCSI ID Configuration Flags
|
||||
*/
|
||||
#define CFXFER 0x0007 /* synchronous transfer rate */
|
||||
#define CFSYNCH 0x0008 /* enable synchronous transfer */
|
||||
#define CFDISC 0x0010 /* enable disconnection */
|
||||
#define CFWIDEB 0x0020 /* wide bus device */
|
||||
/* UNUSED 0x00C0 */
|
||||
#define CFSTART 0x0100 /* send start unit SCSI command */
|
||||
#define CFINCBIOS 0x0200 /* include in BIOS scan */
|
||||
#define CFRNFOUND 0x0400 /* report even if not found */
|
||||
/* UNUSED 0xf800 */
|
||||
u_int16_t device_flags[16]; /* words 0-15 */
|
||||
|
||||
/*
|
||||
* BIOS Control Bits
|
||||
*/
|
||||
#define CFSUPREM 0x0001 /* support all removeable drives */
|
||||
#define CFSUPREMB 0x0002 /* support removeable drives for boot only */
|
||||
#define CFBIOSEN 0x0004 /* BIOS enabled */
|
||||
/* UNUSED 0x0008 */
|
||||
#define CFSM2DRV 0x0010 /* support more than two drives */
|
||||
/* UNUSED 0x0060 */
|
||||
#define CFEXTEND 0x0080 /* extended translation enabled */
|
||||
/* UNUSED 0xff00 */
|
||||
u_int16_t bios_control; /* word 16 */
|
||||
|
||||
/*
|
||||
* Host Adapter Control Bits
|
||||
*/
|
||||
/* UNUSED 0x0001 */
|
||||
#define CFULTRAEN 0x0002 /* Ultra SCSI speed enable (Ultra cards) */
|
||||
#define CFSTERM 0x0004 /* SCSI low byte termination (non-wide cards) */
|
||||
#define CFWSTERM 0x0008 /* SCSI high byte termination (wide card) */
|
||||
#define CFSPARITY 0x0010 /* SCSI parity */
|
||||
/* UNUSED 0x0020 */
|
||||
#define CFRESETB 0x0040 /* reset SCSI bus at IC initialization */
|
||||
/* UNUSED 0xff80 */
|
||||
u_int16_t adapter_control; /* word 17 */
|
||||
|
||||
/*
|
||||
* Bus Release, Host Adapter ID
|
||||
*/
|
||||
#define CFSCSIID 0x000f /* host adapter SCSI ID */
|
||||
/* UNUSED 0x00f0 */
|
||||
#define CFBRTIME 0xff00 /* bus release time */
|
||||
u_int16_t brtime_id; /* word 18 */
|
||||
|
||||
/*
|
||||
* Maximum targets
|
||||
*/
|
||||
#define CFMAXTARG 0x00ff /* maximum targets */
|
||||
/* UNUSED 0xff00 */
|
||||
u_int16_t max_targets; /* word 19 */
|
||||
|
||||
u_int16_t res_1[11]; /* words 20-30 */
|
||||
u_int16_t checksum; /* word 31 */
|
||||
};
|
||||
|
||||
static void load_seeprom __P((struct ahc_data *ahc));
|
||||
|
||||
static u_char aic3940_count;
|
||||
|
||||
#if defined(__FreeBSD__)
|
||||
|
||||
static char* aic7870_probe __P((pcici_t tag, pcidi_t type));
|
||||
static void aic7870_attach __P((pcici_t config_id, int unit));
|
||||
|
||||
static struct pci_device ahc_pci_driver = {
|
||||
"ahc",
|
||||
aic7870_probe,
|
||||
aic7870_attach,
|
||||
&ahc_unit,
|
||||
NULL
|
||||
};
|
||||
|
||||
DATA_SET (pcidevice_set, ahc_pci_driver);
|
||||
|
||||
static char*
|
||||
aic7870_probe (pcici_t tag, pcidi_t type)
|
||||
{
|
||||
switch(type) {
|
||||
case PCI_DEVICE_ID_ADAPTEC_3940U:
|
||||
return ("Adaptec 3940 Ultra SCSI host adapter");
|
||||
break;
|
||||
case PCI_DEVICE_ID_ADAPTEC_3940:
|
||||
return ("Adaptec 3940 SCSI host adapter");
|
||||
break;
|
||||
case PCI_DEVICE_ID_ADAPTEC_2944U:
|
||||
return ("Adaptec 2944 Ultra SCSI host adapter");
|
||||
break;
|
||||
case PCI_DEVICE_ID_ADAPTEC_2940U:
|
||||
return ("Adaptec 2940 Ultra SCSI host adapter");
|
||||
break;
|
||||
case PCI_DEVICE_ID_ADAPTEC_2944:
|
||||
return ("Adaptec 2944 SCSI host adapter");
|
||||
break;
|
||||
case PCI_DEVICE_ID_ADAPTEC_2940:
|
||||
return ("Adaptec 2940 SCSI host adapter");
|
||||
break;
|
||||
case PCI_DEVICE_ID_ADAPTEC_AIC7880:
|
||||
return ("Adaptec aic7880 Ultra SCSI host adapter");
|
||||
break;
|
||||
case PCI_DEVICE_ID_ADAPTEC_AIC7870:
|
||||
return ("Adaptec aic7870 SCSI host adapter");
|
||||
break;
|
||||
case PCI_DEVICE_ID_ADAPTEC_AIC7860:
|
||||
return ("Adaptec aic7860 SCSI host adapter");
|
||||
break;
|
||||
case PCI_DEVICE_ID_ADAPTEC_AIC7855:
|
||||
return ("Adaptec aic7855 SCSI host adapter");
|
||||
break;
|
||||
case PCI_DEVICE_ID_ADAPTEC_AIC7850:
|
||||
return ("Adaptec aic7850 SCSI host adapter");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return (0);
|
||||
|
||||
}
|
||||
|
||||
#elif defined(__NetBSD__)
|
||||
|
||||
int ahc_pci_probe __P((struct device *, void *, void *));
|
||||
void ahc_pci_attach __P((struct device *, struct device *, void *));
|
||||
|
||||
struct cfattach ahc_pci_ca = {
|
||||
sizeof(struct ahc_data), ahc_pci_probe, ahc_pci_attach
|
||||
};
|
||||
|
||||
int
|
||||
ahc_pci_probe(parent, match, aux)
|
||||
struct device *parent;
|
||||
void *match, *aux;
|
||||
{
|
||||
struct pci_attach_args *pa = aux;
|
||||
|
||||
switch (pa->pa_id) {
|
||||
case PCI_DEVICE_ID_ADAPTEC_3940U:
|
||||
case PCI_DEVICE_ID_ADAPTEC_2944U:
|
||||
case PCI_DEVICE_ID_ADAPTEC_2940U:
|
||||
case PCI_DEVICE_ID_ADAPTEC_3940:
|
||||
case PCI_DEVICE_ID_ADAPTEC_2944:
|
||||
case PCI_DEVICE_ID_ADAPTEC_2940:
|
||||
case PCI_DEVICE_ID_ADAPTEC_AIC7880:
|
||||
case PCI_DEVICE_ID_ADAPTEC_AIC7870:
|
||||
case PCI_DEVICE_ID_ADAPTEC_AIC7860:
|
||||
case PCI_DEVICE_ID_ADAPTEC_AIC7855:
|
||||
case PCI_DEVICE_ID_ADAPTEC_AIC7850:
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#endif /* defined(__NetBSD__) */
|
||||
|
||||
#if defined(__FreeBSD__)
|
||||
static void
|
||||
aic7870_attach(config_id, unit)
|
||||
pcici_t config_id;
|
||||
int unit;
|
||||
#elif defined(__NetBSD__)
|
||||
void
|
||||
ahc_pci_attach(parent, self, aux)
|
||||
struct device *parent, *self;
|
||||
void *aux;
|
||||
#endif
|
||||
{
|
||||
#if defined(__FreeBSD__)
|
||||
u_long io_port;
|
||||
#elif defined(__NetBSD__)
|
||||
struct pci_attach_args *pa = aux;
|
||||
struct ahc_data *ahc = (void *)self;
|
||||
int unit = ahc->sc_dev.dv_unit;
|
||||
bus_io_addr_t iobase;
|
||||
bus_io_size_t iosize;
|
||||
bus_io_handle_t ioh;
|
||||
pci_intr_handle_t ih;
|
||||
const char *intrstr;
|
||||
#endif
|
||||
u_long id;
|
||||
unsigned opri = 0;
|
||||
ahc_type ahc_t = AHC_NONE;
|
||||
ahc_flag ahc_f = AHC_FNONE;
|
||||
#if defined(__FreeBSD__)
|
||||
struct ahc_data *ahc;
|
||||
#endif
|
||||
u_char ultra_enb = 0;
|
||||
u_char our_id = 0;
|
||||
|
||||
#if defined(__FreeBSD__)
|
||||
if(!(io_port = pci_conf_read(config_id, PCI_BASEADR0)))
|
||||
return;
|
||||
/*
|
||||
* The first bit of PCI_BASEADR0 is always
|
||||
* set hence we mask it off.
|
||||
*/
|
||||
io_port &= 0xfffffffe;
|
||||
#elif defined(__NetBSD__)
|
||||
if (pci_io_find(pa->pa_pc, pa->pa_tag, PCI_BASEADR0, &iobase, &iosize))
|
||||
return;
|
||||
if (bus_io_map(pa->pa_bc, iobase, iosize, &ioh))
|
||||
return;
|
||||
#endif
|
||||
|
||||
#if defined(__FreeBSD__)
|
||||
switch ((id = pci_conf_read(config_id, PCI_ID_REG))) {
|
||||
#elif defined(__NetBSD__)
|
||||
switch (id = pa->pa_id) {
|
||||
#endif
|
||||
case PCI_DEVICE_ID_ADAPTEC_3940U:
|
||||
case PCI_DEVICE_ID_ADAPTEC_3940:
|
||||
if (id == PCI_DEVICE_ID_ADAPTEC_3940U)
|
||||
ahc_t = AHC_394U;
|
||||
else
|
||||
ahc_t = AHC_394;
|
||||
aic3940_count++;
|
||||
if(!(aic3940_count & 0x01))
|
||||
/* Even count implies second channel */
|
||||
ahc_f |= AHC_CHNLB;
|
||||
break;
|
||||
case PCI_DEVICE_ID_ADAPTEC_2944U:
|
||||
case PCI_DEVICE_ID_ADAPTEC_2940U:
|
||||
ahc_t = AHC_294U;
|
||||
break;
|
||||
case PCI_DEVICE_ID_ADAPTEC_2944:
|
||||
case PCI_DEVICE_ID_ADAPTEC_2940:
|
||||
ahc_t = AHC_294;
|
||||
break;
|
||||
case PCI_DEVICE_ID_ADAPTEC_AIC7880:
|
||||
ahc_t = AHC_AIC7880;
|
||||
break;
|
||||
case PCI_DEVICE_ID_ADAPTEC_AIC7870:
|
||||
ahc_t = AHC_AIC7870;
|
||||
break;
|
||||
case PCI_DEVICE_ID_ADAPTEC_AIC7860:
|
||||
ahc_t = AHC_AIC7860;
|
||||
break;
|
||||
case PCI_DEVICE_ID_ADAPTEC_AIC7855:
|
||||
case PCI_DEVICE_ID_ADAPTEC_AIC7850:
|
||||
ahc_t = AHC_AIC7850;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
/* On all PCI adapters, we allow SCB paging */
|
||||
ahc_f |= AHC_PAGESCBS;
|
||||
|
||||
/* Remeber how the card was setup in case there is no SEEPROM */
|
||||
#if defined(__FreeBSD__)
|
||||
our_id = inb(SCSIID + io_port) & OID;
|
||||
if(ahc_t & AHC_ULTRA)
|
||||
ultra_enb = inb(SXFRCTL0 + io_port) & ULTRAEN;
|
||||
#else
|
||||
our_id = bus_io_read_1(pa->pa_bc, ioh, SCSIID) & OID;
|
||||
if(ahc_t & AHC_ULTRA)
|
||||
ultra_enb = bus_io_read_1(pa->pa_bc, ioh, SXFRCTL0) & ULTRAEN;
|
||||
#endif
|
||||
|
||||
#if defined(__FreeBSD__)
|
||||
ahc_reset(io_port);
|
||||
#elif defined(__NetBSD__)
|
||||
printf("\n");
|
||||
ahc_reset(ahc->sc_dev.dv_xname, pa->pa_bc, ioh);
|
||||
#endif
|
||||
|
||||
if(ahc_t & AHC_AIC7870){
|
||||
#if defined(__FreeBSD__)
|
||||
u_long devconfig = pci_conf_read(config_id, DEVCONFIG);
|
||||
#elif defined(__NetBSD__)
|
||||
u_long devconfig =
|
||||
pci_conf_read(pa->pa_pc, pa->pa_tag, DEVCONFIG);
|
||||
#endif
|
||||
|
||||
if(devconfig & (RAMPSM)) {
|
||||
/*
|
||||
* External SRAM present. Have the probe walk
|
||||
* the SCBs to see how much SRAM we have and set
|
||||
* the number of SCBs accordingly. We have to
|
||||
* turn off SCBRAMSEL to access the external
|
||||
* SCB SRAM.
|
||||
*
|
||||
* It seems that early versions of the aic7870
|
||||
* didn't use these bits, hence the hack for the
|
||||
* 3940 above. I would guess that recent 3940s
|
||||
* using later aic7870 or aic7880 chips do
|
||||
* actually set RAMPSM.
|
||||
*
|
||||
* The documentation isn't clear, but it sounds
|
||||
* like the value written to devconfig must not
|
||||
* have RAMPSM set. The second sixteen bits of
|
||||
* the register are R/O anyway, so it shouldn't
|
||||
* affect RAMPSM either way.
|
||||
*/
|
||||
devconfig &= ~(RAMPSM|SCBRAMSEL);
|
||||
#if defined(__FreeBSD__)
|
||||
pci_conf_write(config_id, DEVCONFIG, devconfig);
|
||||
#elif defined(__NetBSD__)
|
||||
pci_conf_write(pa->pa_pc, pa->pa_tag,
|
||||
DEVCONFIG, devconfig);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Ensure that we are using good values for the PCI burst size
|
||||
* and latency timer.
|
||||
*/
|
||||
{
|
||||
#if defined(__FreeBSD__)
|
||||
u_long csize_lattime = pci_conf_read(config_id, CSIZE_LATTIME);
|
||||
#elif defined(__NetBSD__)
|
||||
u_long csize_lattime =
|
||||
pci_conf_read(pa->pa_pc, pa->pa_tag, CSIZE_LATTIME);
|
||||
#endif
|
||||
|
||||
if((csize_lattime & CACHESIZE) == 0) {
|
||||
/* default to 8DWDs. What's the PCI define for this? */
|
||||
csize_lattime |= 8;
|
||||
}
|
||||
if((csize_lattime & LATTIME) == 0) {
|
||||
/* Default to 64 PCLKS (is this a good value?) */
|
||||
/* This may also be availble in the SEEPROM?? */
|
||||
csize_lattime |= (64 << 8);
|
||||
}
|
||||
if(bootverbose)
|
||||
printf("ahc%d: BurstLen = %ldDWDs, "
|
||||
"Latency Timer = %ldPCLKS\n",
|
||||
unit,
|
||||
csize_lattime & CACHESIZE,
|
||||
(csize_lattime >> 8) & 0xff);
|
||||
#if defined(__FreeBSD__)
|
||||
pci_conf_write(config_id, CSIZE_LATTIME, csize_lattime);
|
||||
#elif defined(__NetBSD__)
|
||||
pci_conf_write(pa->pa_pc, pa->pa_tag, CSIZE_LATTIME,
|
||||
csize_lattime);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined(__FreeBSD__)
|
||||
if(!(ahc = ahc_alloc(unit, io_port, ahc_t, ahc_f)))
|
||||
return; /* XXX PCI code should take return status */
|
||||
|
||||
if(!(pci_map_int(config_id, ahc_intr, (void *)ahc, &bio_imask))) {
|
||||
ahc_free(ahc);
|
||||
return;
|
||||
}
|
||||
#elif defined(__NetBSD__)
|
||||
ahc_construct(ahc, pa->pa_bc, ioh, ahc_t, ahc_f);
|
||||
|
||||
if (pci_intr_map(pa->pa_pc, pa->pa_intrtag, pa->pa_intrpin,
|
||||
pa->pa_intrline, &ih)) {
|
||||
printf("%s: couldn't map interrupt\n", ahc->sc_dev.dv_xname);
|
||||
ahc_free(ahc);
|
||||
return;
|
||||
}
|
||||
intrstr = pci_intr_string(pa->pa_pc, ih);
|
||||
ahc->sc_ih = pci_intr_establish(pa->pa_pc, ih, IPL_BIO, ahc_intr, ahc
|
||||
#ifdef __OpenBSD__
|
||||
, ahc->sc_dev.dv_xname
|
||||
#endif
|
||||
);
|
||||
if (ahc->sc_ih == NULL) {
|
||||
printf("%s: couldn't establish interrupt",
|
||||
ahc->sc_dev.dv_xname);
|
||||
if (intrstr != NULL)
|
||||
printf(" at %s", intrstr);
|
||||
printf("\n");
|
||||
ahc_free(ahc);
|
||||
return;
|
||||
}
|
||||
if (intrstr != NULL)
|
||||
printf("%s: interrupting at %s\n", ahc->sc_dev.dv_xname,
|
||||
intrstr);
|
||||
#endif
|
||||
/*
|
||||
* Protect ourself from spurrious interrupts during
|
||||
* intialization.
|
||||
*/
|
||||
opri = splbio();
|
||||
|
||||
/*
|
||||
* Do aic7870/aic7880/aic7850 specific initialization
|
||||
*/
|
||||
{
|
||||
u_char sblkctl;
|
||||
char *id_string;
|
||||
|
||||
switch(ahc->type) {
|
||||
case AHC_394U:
|
||||
case AHC_294U:
|
||||
case AHC_AIC7880:
|
||||
{
|
||||
id_string = "aic7880 ";
|
||||
load_seeprom(ahc);
|
||||
break;
|
||||
}
|
||||
case AHC_394:
|
||||
case AHC_294:
|
||||
case AHC_AIC7870:
|
||||
{
|
||||
id_string = "aic7870 ";
|
||||
load_seeprom(ahc);
|
||||
break;
|
||||
}
|
||||
case AHC_AIC7860:
|
||||
{
|
||||
id_string = "aic7860 ";
|
||||
/*
|
||||
* Use defaults, if the chip wasn't initialized by
|
||||
* a BIOS.
|
||||
*/
|
||||
ahc->flags |= AHC_USEDEFAULTS;
|
||||
break;
|
||||
}
|
||||
case AHC_AIC7850:
|
||||
{
|
||||
id_string = "aic7850 ";
|
||||
/*
|
||||
* Use defaults, if the chip wasn't initialized by
|
||||
* a BIOS.
|
||||
*/
|
||||
ahc->flags |= AHC_USEDEFAULTS;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
printf("ahc: Unknown controller type. Ignoring.\n");
|
||||
ahc_free(ahc);
|
||||
splx(opri);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Take the LED out of diagnostic mode
|
||||
*/
|
||||
sblkctl = AHC_INB(ahc, SBLKCTL);
|
||||
AHC_OUTB(ahc, SBLKCTL, (sblkctl & ~(DIAGLEDEN|DIAGLEDON)));
|
||||
|
||||
/*
|
||||
* I don't know where this is set in the SEEPROM or by the
|
||||
* BIOS, so we default to 100%.
|
||||
*/
|
||||
AHC_OUTB(ahc, DSPCISTATUS, DFTHRSH_100);
|
||||
|
||||
if(ahc->flags & AHC_USEDEFAULTS) {
|
||||
/*
|
||||
* PCI Adapter default setup
|
||||
* Should only be used if the adapter does not have
|
||||
* an SEEPROM.
|
||||
*/
|
||||
/* See if someone else set us up already */
|
||||
u_long i;
|
||||
for(i = TARG_SCRATCH; i < 0x60; i++) {
|
||||
if(AHC_INB(ahc, i) != 0xff)
|
||||
break;
|
||||
}
|
||||
if(i != 0x60) {
|
||||
printf("%s: Using left over BIOS settings\n",
|
||||
ahc_name(ahc));
|
||||
ahc->flags &= ~AHC_USEDEFAULTS;
|
||||
}
|
||||
else
|
||||
our_id = 0x07;
|
||||
AHC_OUTB(ahc, SCSICONF,
|
||||
(our_id & 0x07)|ENSPCHK|RESET_SCSI);
|
||||
/* In case we are a wide card */
|
||||
AHC_OUTB(ahc, SCSICONF + 1, our_id);
|
||||
|
||||
if(!ultra_enb || (ahc->flags & AHC_USEDEFAULTS)) {
|
||||
/*
|
||||
* If there wasn't a BIOS or the board
|
||||
* wasn't in this mode to begin with,
|
||||
* turn off ultra.
|
||||
*/
|
||||
ahc->type &= ~AHC_ULTRA;
|
||||
}
|
||||
}
|
||||
|
||||
printf("%s: %s", ahc_name(ahc), id_string);
|
||||
}
|
||||
|
||||
if(ahc_init(ahc)){
|
||||
ahc_free(ahc);
|
||||
splx(opri);
|
||||
return; /* XXX PCI code should take return status */
|
||||
}
|
||||
splx(opri);
|
||||
|
||||
ahc_attach(ahc);
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Read the SEEPROM. Return 0 on failure
|
||||
*/
|
||||
void
|
||||
load_seeprom(ahc)
|
||||
struct ahc_data *ahc;
|
||||
{
|
||||
struct seeprom_descriptor sd;
|
||||
struct seeprom_config sc;
|
||||
u_short *scarray = (u_short *)≻
|
||||
u_short checksum = 0;
|
||||
u_char scsi_conf;
|
||||
u_char host_id;
|
||||
int have_seeprom;
|
||||
|
||||
#if defined(__FreeBSD__)
|
||||
sd.sd_iobase = ahc->baseport + SEECTL;
|
||||
#elif defined(__NetBSD__)
|
||||
sd.sd_bc = ahc->sc_bc;
|
||||
sd.sd_ioh = ahc->sc_ioh;
|
||||
sd.sd_offset = SEECTL;
|
||||
#endif
|
||||
sd.sd_MS = SEEMS;
|
||||
sd.sd_RDY = SEERDY;
|
||||
sd.sd_CS = SEECS;
|
||||
sd.sd_CK = SEECK;
|
||||
sd.sd_DO = SEEDO;
|
||||
sd.sd_DI = SEEDI;
|
||||
|
||||
if(bootverbose)
|
||||
printf("%s: Reading SEEPROM...", ahc_name(ahc));
|
||||
have_seeprom = acquire_seeprom(&sd);
|
||||
if (have_seeprom) {
|
||||
have_seeprom = read_seeprom(&sd,
|
||||
(u_int16_t *)&sc,
|
||||
ahc->flags & AHC_CHNLB,
|
||||
sizeof(sc)/2);
|
||||
release_seeprom(&sd);
|
||||
if (have_seeprom) {
|
||||
/* Check checksum */
|
||||
int i;
|
||||
|
||||
for (i = 0;i < (sizeof(sc)/2 - 1);i = i + 1)
|
||||
checksum = checksum + scarray[i];
|
||||
if (checksum != sc.checksum) {
|
||||
if(bootverbose)
|
||||
printf ("checksum error");
|
||||
have_seeprom = 0;
|
||||
}
|
||||
else if(bootverbose)
|
||||
printf("done.\n");
|
||||
}
|
||||
}
|
||||
if (!have_seeprom) {
|
||||
if(bootverbose)
|
||||
printf("\n%s: No SEEPROM availible\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 = sc.max_targets & CFMAXTARG;
|
||||
|
||||
for(i = 0; i <= max_targ; i++){
|
||||
u_char 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)
|
||||
ahc->discenable |= (0x01 << i);
|
||||
AHC_OUTB(ahc, TARG_SCRATCH+i, target_settings);
|
||||
}
|
||||
AHC_OUTB(ahc, DISC_DSB, ~(ahc->discenable & 0xff));
|
||||
AHC_OUTB(ahc, DISC_DSB + 1, ~((ahc->discenable >> 8) & 0xff));
|
||||
|
||||
host_id = sc.brtime_id & CFSCSIID;
|
||||
|
||||
scsi_conf = (host_id & 0x7);
|
||||
if(sc.adapter_control & CFSPARITY)
|
||||
scsi_conf |= ENSPCHK;
|
||||
if(sc.adapter_control & CFRESETB)
|
||||
scsi_conf |= RESET_SCSI;
|
||||
|
||||
if(ahc->type & AHC_ULTRA) {
|
||||
/* Should we enable Ultra mode? */
|
||||
if(!(sc.adapter_control & CFULTRAEN))
|
||||
/* Treat us as a non-ultra card */
|
||||
ahc->type &= ~AHC_ULTRA;
|
||||
}
|
||||
/* Set the host ID */
|
||||
AHC_OUTB(ahc, SCSICONF, scsi_conf);
|
||||
/* In case we are a wide card */
|
||||
AHC_OUTB(ahc, SCSICONF + 1, host_id);
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* NPCI > 0 */
|
|
@ -1,115 +0,0 @@
|
|||
/* $NetBSD: aic7870.c,v 1.9 1996/05/13 00:03:02 mycroft Exp $ */
|
||||
|
||||
/*
|
||||
* Product specific probe and attach routines for:
|
||||
* 294X and aic7870 motherboard SCSI controllers
|
||||
*
|
||||
* Copyright (c) 1995 Justin T. Gibbs
|
||||
* 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.
|
||||
* 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. Absolutely no warranty of function or purpose is made by the author
|
||||
* Justin T. Gibbs.
|
||||
* 4. Modifications may be freely made to this file if the above conditions
|
||||
* are met.
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/device.h>
|
||||
|
||||
#include <machine/intr.h>
|
||||
|
||||
#include <scsi/scsi_all.h>
|
||||
#include <scsi/scsiconf.h>
|
||||
|
||||
#include <dev/pci/pcireg.h>
|
||||
#include <dev/pci/pcivar.h>
|
||||
#include <dev/pci/pcidevs.h>
|
||||
|
||||
#include <dev/ic/aic7xxxvar.h>
|
||||
|
||||
|
||||
#define PCI_BASEADR0 PCI_MAPREG_START
|
||||
#define PCI_VENDORID(x) ((x) & 0xFFFF)
|
||||
#define PCI_CHIPID(x) (((x) >> 16) & 0xFFFF)
|
||||
|
||||
static int aic7870_probe __P((struct device *, void *, void *));
|
||||
static void aic7870_attach __P((struct device *, struct device *, void *));
|
||||
|
||||
struct cfattach ahc_ca = {
|
||||
sizeof(struct ahc_softc), aic7870_probe, aic7870_attach
|
||||
};
|
||||
|
||||
struct cfdriver ahc_cd = {
|
||||
NULL, "ahc", DV_DULL
|
||||
};
|
||||
|
||||
int ahcintr __P((void *));
|
||||
|
||||
|
||||
int
|
||||
aic7870_probe(parent, match, aux)
|
||||
struct device *parent;
|
||||
void *match, *aux;
|
||||
{
|
||||
struct pci_attach_args *pa = aux;
|
||||
|
||||
if (PCI_VENDORID(pa->pa_id) != PCI_VENDOR_ADP)
|
||||
return 0;
|
||||
|
||||
switch (PCI_CHIPID(pa->pa_id)) {
|
||||
case PCI_PRODUCT_ADP_AIC7870:
|
||||
case PCI_PRODUCT_ADP_2940:
|
||||
case PCI_PRODUCT_ADP_2940U:
|
||||
return 1;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
aic7870_attach(parent, self, aux)
|
||||
struct device *parent, *self;
|
||||
void *aux;
|
||||
{
|
||||
struct pci_attach_args *pa = aux;
|
||||
struct ahc_softc *ahc = (void *)self;
|
||||
int iobase;
|
||||
|
||||
switch (PCI_CHIPID(pa->pa_id)) {
|
||||
case PCI_PRODUCT_ADP_AIC7870:
|
||||
ahc->type = AHC_AIC7870;
|
||||
break;
|
||||
|
||||
case PCI_PRODUCT_ADP_2940:
|
||||
case PCI_PRODUCT_ADP_2940U:
|
||||
ahc->type = AHC_294;
|
||||
break;
|
||||
}
|
||||
|
||||
if (pci_map_io(pa->pa_tag, PCI_BASEADR0, &iobase))
|
||||
return;
|
||||
|
||||
/*
|
||||
* Make the offsets the same as for EISA
|
||||
*/
|
||||
iobase -= 0xc00ul;
|
||||
|
||||
if (ahcprobe(ahc, iobase) == 0)
|
||||
return;
|
||||
|
||||
ahcattach(ahc);
|
||||
|
||||
ahc->sc_ih = pci_map_int(pa->pa_tag, IPL_BIO, ahcintr, ahc);
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
# $NetBSD: files.pci,v 1.15 1996/05/07 02:03:07 thorpej Exp $
|
||||
# $NetBSD: files.pci,v 1.16 1996/05/16 03:44:16 mycroft Exp $
|
||||
#
|
||||
# Config.new file and device description for machine-independent PCI code.
|
||||
# Included by ports that need it. Requires that the SCSI files be
|
||||
|
@ -9,10 +9,11 @@ attach pci at pcibus
|
|||
file dev/pci/pci.c pci needs-flag
|
||||
file dev/pci/pci_subr.c pci
|
||||
|
||||
# Adaptec 7870 chips
|
||||
device ahc: scsi, aic7xxx
|
||||
attach ahc at pci
|
||||
file dev/pci/aic7870.c ahc
|
||||
# Adaptec 3940, 2940, and aic78[5678]0 SCSI controllers
|
||||
# device declaration in sys/conf/files
|
||||
attach ahc at pci with ahc_pci
|
||||
file dev/pci/ahc_pci.c ahc_pci
|
||||
file dev/ic/smc93cx6.c ahc_pci
|
||||
|
||||
# Ethernet driver for DC21040-based boards
|
||||
device de: ether, ifnet
|
||||
|
|
Loading…
Reference in New Issue