Merge in changes for NetBSD/OpenBSD.
NetBSD/OpenBSD support Submitted by:Noriyuki Soda <soda@sra.co.jp>, Pete Bentley <pete@demon.net>, Charles M. Hannum <mycroft@mit.edu>, Theo de Raadt <deraadt@theos.com>
This commit is contained in:
parent
0262313ddc
commit
c2d50bea44
@ -29,20 +29,32 @@
|
|||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* $Id: aic7770.c,v 1.27 1996/04/20 21:21:47 gibbs Exp $
|
* $Id: aic7770.c,v 1.28 1996/05/10 16:14:51 gibbs Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "eisa.h"
|
#if defined(__FreeBSD__)
|
||||||
#if NEISA > 0
|
#include <eisa.h>
|
||||||
|
#endif
|
||||||
|
#if NEISA > 0 || defined(__NetBSD__)
|
||||||
|
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include <sys/systm.h>
|
#include <sys/systm.h>
|
||||||
|
#if defined(__FreeBSD__)
|
||||||
#include <sys/devconf.h>
|
#include <sys/devconf.h>
|
||||||
|
#endif
|
||||||
#include <sys/kernel.h>
|
#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/scsi_all.h>
|
||||||
#include <scsi/scsiconf.h>
|
#include <scsi/scsiconf.h>
|
||||||
|
|
||||||
|
#if defined(__FreeBSD__)
|
||||||
|
|
||||||
#include <machine/clock.h>
|
#include <machine/clock.h>
|
||||||
|
|
||||||
#include <i386/eisa/eisaconf.h>
|
#include <i386/eisa/eisaconf.h>
|
||||||
@ -54,10 +66,23 @@
|
|||||||
#define EISA_DEVICE_ID_ADAPTEC_284xB 0x04907756 /* BIOS enabled */
|
#define EISA_DEVICE_ID_ADAPTEC_284xB 0x04907756 /* BIOS enabled */
|
||||||
#define EISA_DEVICE_ID_ADAPTEC_284x 0x04907757 /* BIOS disabled*/
|
#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_SLOT_OFFSET 0xc00
|
||||||
#define AHC_EISA_IOSIZE 0x100
|
#define AHC_EISA_IOSIZE 0x100
|
||||||
#define INTDEF 0x5cul /* Interrupt Definition Register */
|
#define INTDEF 0x5cul /* Interrupt Definition Register */
|
||||||
|
|
||||||
|
#if defined(__FreeBSD__)
|
||||||
|
|
||||||
static int aic7770probe __P((void));
|
static int aic7770probe __P((void));
|
||||||
static int aic7770_attach __P((struct eisa_device *e_dev));
|
static int aic7770_attach __P((struct eisa_device *e_dev));
|
||||||
|
|
||||||
@ -160,14 +185,99 @@ aic7770probe(void)
|
|||||||
return 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_chipset_tag_t bc = ea->ea_bc;
|
||||||
|
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);
|
||||||
|
|
||||||
|
if (bus_io_map(bc, EISA_SLOT_ADDR(ea->ea_slot) + AHC_EISA_SLOT_OFFSET,
|
||||||
|
AHC_EISA_IOSIZE, &ioh))
|
||||||
|
return (0);
|
||||||
|
|
||||||
|
irq = ahc_eisa_irq(bc, ioh);
|
||||||
|
|
||||||
|
bus_io_unmap(bc, ioh, AHC_EISA_IOSIZE);
|
||||||
|
|
||||||
|
return (irq >= 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* defined(__NetBSD__) */
|
||||||
|
|
||||||
|
#if defined(__FreeBSD__)
|
||||||
static int
|
static int
|
||||||
aic7770_attach(e_dev)
|
aic7770_attach(e_dev)
|
||||||
struct eisa_device *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;
|
ahc_type type;
|
||||||
|
|
||||||
|
#if defined(__FreeBSD__)
|
||||||
struct ahc_data *ahc;
|
struct ahc_data *ahc;
|
||||||
resvaddr_t *iospace;
|
resvaddr_t *iospace;
|
||||||
u_long iobase;
|
|
||||||
int unit = e_dev->unit;
|
int unit = e_dev->unit;
|
||||||
int irq = ffs(e_dev->ioconf.irq) - 1;
|
int irq = ffs(e_dev->ioconf.irq) - 1;
|
||||||
|
|
||||||
@ -176,8 +286,6 @@ aic7770_attach(e_dev)
|
|||||||
if(!iospace)
|
if(!iospace)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
iobase = iospace->addr;
|
|
||||||
|
|
||||||
switch(e_dev->id) {
|
switch(e_dev->id) {
|
||||||
case EISA_DEVICE_ID_ADAPTEC_AIC7770:
|
case EISA_DEVICE_ID_ADAPTEC_AIC7770:
|
||||||
type = AHC_AIC7770;
|
type = AHC_AIC7770;
|
||||||
@ -215,17 +323,58 @@ aic7770_attach(e_dev)
|
|||||||
}
|
}
|
||||||
eisa_reg_end(e_dev);
|
eisa_reg_end(e_dev);
|
||||||
|
|
||||||
|
#elif defined(__NetBSD__)
|
||||||
|
|
||||||
|
struct ahc_data *ahc = (void *)self;
|
||||||
|
struct eisa_attach_args *ea = aux;
|
||||||
|
bus_chipset_tag_t bc = ea->ea_bc;
|
||||||
|
bus_io_handle_t ioh;
|
||||||
|
int irq;
|
||||||
|
eisa_chipset_tag_t ec = ea->ea_ec;
|
||||||
|
eisa_intr_handle_t ih;
|
||||||
|
const char *model, *intrstr;
|
||||||
|
|
||||||
|
if (bus_io_map(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(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, bc, ioh, type, AHC_FNONE);
|
||||||
|
if (eisa_intr_map(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.
|
* Tell the user what type of interrupts we're using.
|
||||||
* usefull for debugging irq problems
|
* usefull for debugging irq problems
|
||||||
*/
|
*/
|
||||||
if(bootverbose) {
|
if(bootverbose) {
|
||||||
if(ahc->pause & IRQMS)
|
printf("%s: Using %s Interrupts\n",
|
||||||
printf("ahc%d: Using Level Sensitive "
|
ahc_name(ahc),
|
||||||
"Interrupts\n", unit);
|
ahc->pause & IRQMS ?
|
||||||
else
|
"Level Sensitive" : "Edge Triggered");
|
||||||
printf("ahc%d: Using Edge Triggered "
|
|
||||||
"Interrupts\n", unit);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -238,7 +387,7 @@ aic7770_attach(e_dev)
|
|||||||
case AHC_AIC7770:
|
case AHC_AIC7770:
|
||||||
case AHC_274:
|
case AHC_274:
|
||||||
{
|
{
|
||||||
u_char biosctrl = inb(HA_274_BIOSCTRL + iobase);
|
u_char biosctrl = AHC_INB(ahc, HA_274_BIOSCTRL);
|
||||||
|
|
||||||
/* Get the primary channel information */
|
/* Get the primary channel information */
|
||||||
ahc->flags |= (biosctrl & CHANNEL_B_PRIMARY);
|
ahc->flags |= (biosctrl & CHANNEL_B_PRIMARY);
|
||||||
@ -277,10 +426,10 @@ aic7770_attach(e_dev)
|
|||||||
u_char sblkctl;
|
u_char sblkctl;
|
||||||
u_char sblkctl_orig;
|
u_char sblkctl_orig;
|
||||||
|
|
||||||
sblkctl_orig = inb(SBLKCTL + iobase);
|
sblkctl_orig = AHC_INB(ahc, SBLKCTL);
|
||||||
sblkctl = sblkctl_orig ^ AUTOFLUSHDIS;
|
sblkctl = sblkctl_orig ^ AUTOFLUSHDIS;
|
||||||
outb(SBLKCTL + iobase, sblkctl);
|
AHC_OUTB(ahc, SBLKCTL, sblkctl);
|
||||||
sblkctl = inb(SBLKCTL + iobase);
|
sblkctl = AHC_INB(ahc, SBLKCTL);
|
||||||
if(sblkctl != sblkctl_orig)
|
if(sblkctl != sblkctl_orig)
|
||||||
{
|
{
|
||||||
id_string = "aic7770 >= Rev E, ";
|
id_string = "aic7770 >= Rev E, ";
|
||||||
@ -288,7 +437,7 @@ aic7770_attach(e_dev)
|
|||||||
* Ensure autoflush is enabled
|
* Ensure autoflush is enabled
|
||||||
*/
|
*/
|
||||||
sblkctl &= ~AUTOFLUSHDIS;
|
sblkctl &= ~AUTOFLUSHDIS;
|
||||||
outb(SBLKCTL + iobase, sblkctl);
|
AHC_OUTB(ahc, SBLKCTL, sblkctl);
|
||||||
|
|
||||||
/* Allow paging on this adapter */
|
/* Allow paging on this adapter */
|
||||||
ahc->flags |= AHC_PAGESCBS;
|
ahc->flags |= AHC_PAGESCBS;
|
||||||
@ -296,20 +445,21 @@ aic7770_attach(e_dev)
|
|||||||
else
|
else
|
||||||
id_string = "aic7770 <= Rev C, ";
|
id_string = "aic7770 <= Rev C, ";
|
||||||
|
|
||||||
printf("ahc%d: %s", unit, id_string);
|
printf("%s: %s", ahc_name(ahc), id_string);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Setup the FIFO threshold and the bus off time */
|
/* Setup the FIFO threshold and the bus off time */
|
||||||
{
|
{
|
||||||
u_char hostconf = inb(HOSTCONF + iobase);
|
u_char hostconf = AHC_INB(ahc, HOSTCONF);
|
||||||
outb(BUSSPD + iobase, hostconf & DFTHRSH);
|
AHC_OUTB(ahc, BUSSPD, hostconf & DFTHRSH);
|
||||||
outb(BUSTIME + iobase, (hostconf << 2) & BOFF);
|
AHC_OUTB(ahc, BUSTIME, (hostconf << 2) & BOFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Generic aic7xxx initialization.
|
* Generic aic7xxx initialization.
|
||||||
*/
|
*/
|
||||||
if(ahc_init(ahc)){
|
if(ahc_init(ahc)){
|
||||||
|
#if defined(__FreeBSD__)
|
||||||
ahc_free(ahc);
|
ahc_free(ahc);
|
||||||
/*
|
/*
|
||||||
* The board's IRQ line is not yet enabled so it's safe
|
* The board's IRQ line is not yet enabled so it's safe
|
||||||
@ -317,13 +467,18 @@ aic7770_attach(e_dev)
|
|||||||
*/
|
*/
|
||||||
eisa_release_intr(e_dev, irq, ahc_intr);
|
eisa_release_intr(e_dev, irq, ahc_intr);
|
||||||
return -1;
|
return -1;
|
||||||
|
#elif defined(__NetBSD__)
|
||||||
|
ahc_free(ahc);
|
||||||
|
return;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Enable the board's BUS drivers
|
* Enable the board's BUS drivers
|
||||||
*/
|
*/
|
||||||
outb(BCTL + iobase, ENABLE);
|
AHC_OUTB(ahc, BCTL, ENABLE);
|
||||||
|
|
||||||
|
#if defined(__FreeBSD__)
|
||||||
/*
|
/*
|
||||||
* Enable our interrupt handler.
|
* Enable our interrupt handler.
|
||||||
*/
|
*/
|
||||||
@ -334,11 +489,38 @@ aic7770_attach(e_dev)
|
|||||||
}
|
}
|
||||||
|
|
||||||
e_dev->kdc->kdc_state = DC_BUSY; /* host adapters always busy */
|
e_dev->kdc->kdc_state = DC_BUSY; /* host adapters always busy */
|
||||||
|
#elif defined(__NetBSD__)
|
||||||
|
intrstr = eisa_intr_string(ec, ih);
|
||||||
|
/*
|
||||||
|
* The IRQMS bit enables level sensitive interrupts only allow
|
||||||
|
* IRQ sharing if its set.
|
||||||
|
*/
|
||||||
|
ahc->sc_ih = eisa_intr_establish(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 */
|
/* Attach sub-devices - always succeeds */
|
||||||
ahc_attach(ahc);
|
ahc_attach(ahc);
|
||||||
|
|
||||||
|
#if defined(__FreeBSD__)
|
||||||
return 0;
|
return 0;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* NEISA > 0 */
|
#endif /* NEISA > 0 */
|
||||||
|
@ -29,20 +29,29 @@
|
|||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* $Id: aic7870.c,v 1.34 1996/05/21 18:38:41 gibbs Exp $
|
* $Id: aic7870.c,v 1.35 1996/05/23 15:02:18 gibbs Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#if defined(__FreeBSD__)
|
||||||
#include <pci.h>
|
#include <pci.h>
|
||||||
#if NPCI > 0
|
#endif
|
||||||
|
#if NPCI > 0 || defined(__NetBSD__)
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include <sys/systm.h>
|
#include <sys/systm.h>
|
||||||
#include <sys/malloc.h>
|
#include <sys/malloc.h>
|
||||||
#include <sys/kernel.h>
|
#include <sys/kernel.h>
|
||||||
#include <sys/queue.h>
|
#include <sys/queue.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/scsi_all.h>
|
||||||
#include <scsi/scsiconf.h>
|
#include <scsi/scsiconf.h>
|
||||||
|
|
||||||
|
#if defined(__FreeBSD__)
|
||||||
|
|
||||||
#include <pci/pcireg.h>
|
#include <pci/pcireg.h>
|
||||||
#include <pci/pcivar.h>
|
#include <pci/pcivar.h>
|
||||||
|
|
||||||
@ -54,6 +63,21 @@
|
|||||||
#include <dev/aic7xxx/aic7xxx_reg.h>
|
#include <dev/aic7xxx/aic7xxx_reg.h>
|
||||||
|
|
||||||
#define PCI_BASEADR0 PCI_MAP_REG_START
|
#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_3940U 0x82789004ul
|
||||||
#define PCI_DEVICE_ID_ADAPTEC_2944U 0x84789004ul
|
#define PCI_DEVICE_ID_ADAPTEC_2944U 0x84789004ul
|
||||||
#define PCI_DEVICE_ID_ADAPTEC_2940U 0x81789004ul
|
#define PCI_DEVICE_ID_ADAPTEC_2940U 0x81789004ul
|
||||||
@ -102,7 +126,7 @@ struct seeprom_config {
|
|||||||
#define CFINCBIOS 0x0200 /* include in BIOS scan */
|
#define CFINCBIOS 0x0200 /* include in BIOS scan */
|
||||||
#define CFRNFOUND 0x0400 /* report even if not found */
|
#define CFRNFOUND 0x0400 /* report even if not found */
|
||||||
/* UNUSED 0xf800 */
|
/* UNUSED 0xf800 */
|
||||||
unsigned short device_flags[16]; /* words 0-15 */
|
u_int16_t device_flags[16]; /* words 0-15 */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* BIOS Control Bits
|
* BIOS Control Bits
|
||||||
@ -115,7 +139,7 @@ struct seeprom_config {
|
|||||||
/* UNUSED 0x0060 */
|
/* UNUSED 0x0060 */
|
||||||
#define CFEXTEND 0x0080 /* extended translation enabled */
|
#define CFEXTEND 0x0080 /* extended translation enabled */
|
||||||
/* UNUSED 0xff00 */
|
/* UNUSED 0xff00 */
|
||||||
unsigned short bios_control; /* word 16 */
|
u_int16_t bios_control; /* word 16 */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Host Adapter Control Bits
|
* Host Adapter Control Bits
|
||||||
@ -128,7 +152,7 @@ struct seeprom_config {
|
|||||||
/* UNUSED 0x0020 */
|
/* UNUSED 0x0020 */
|
||||||
#define CFRESETB 0x0040 /* reset SCSI bus at IC initialization */
|
#define CFRESETB 0x0040 /* reset SCSI bus at IC initialization */
|
||||||
/* UNUSED 0xff80 */
|
/* UNUSED 0xff80 */
|
||||||
unsigned short adapter_control; /* word 17 */
|
u_int16_t adapter_control; /* word 17 */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Bus Release, Host Adapter ID
|
* Bus Release, Host Adapter ID
|
||||||
@ -136,31 +160,29 @@ struct seeprom_config {
|
|||||||
#define CFSCSIID 0x000f /* host adapter SCSI ID */
|
#define CFSCSIID 0x000f /* host adapter SCSI ID */
|
||||||
/* UNUSED 0x00f0 */
|
/* UNUSED 0x00f0 */
|
||||||
#define CFBRTIME 0xff00 /* bus release time */
|
#define CFBRTIME 0xff00 /* bus release time */
|
||||||
unsigned short brtime_id; /* word 18 */
|
u_int16_t brtime_id; /* word 18 */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Maximum targets
|
* Maximum targets
|
||||||
*/
|
*/
|
||||||
#define CFMAXTARG 0x00ff /* maximum targets */
|
#define CFMAXTARG 0x00ff /* maximum targets */
|
||||||
/* UNUSED 0xff00 */
|
/* UNUSED 0xff00 */
|
||||||
unsigned short max_targets; /* word 19 */
|
u_int16_t max_targets; /* word 19 */
|
||||||
|
|
||||||
unsigned short res_1[11]; /* words 20-30 */
|
|
||||||
unsigned short checksum; /* word 31 */
|
|
||||||
|
|
||||||
|
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 int acquire_seeprom __P((struct seeprom_descriptor *sd));
|
||||||
|
static void release_seeprom __P((struct seeprom_descriptor *sd));
|
||||||
|
|
||||||
|
static u_char aic3940_count;
|
||||||
|
|
||||||
|
#if defined(__FreeBSD__)
|
||||||
|
|
||||||
static char* aic7870_probe __P((pcici_t tag, pcidi_t type));
|
static char* aic7870_probe __P((pcici_t tag, pcidi_t type));
|
||||||
static void aic7870_attach __P((pcici_t config_id, int unit));
|
static void aic7870_attach __P((pcici_t config_id, int unit));
|
||||||
static void load_seeprom __P((struct ahc_data *ahc));
|
|
||||||
static int acquire_seeprom __P((u_long offset, u_short CS, u_short CK,
|
|
||||||
u_short DO, u_short DI, u_short RDY,
|
|
||||||
u_short MS));
|
|
||||||
static void release_seeprom __P((u_long offset, u_short CS, u_short CK,
|
|
||||||
u_short DO, u_short DI, u_short RDY,
|
|
||||||
u_short MS));
|
|
||||||
|
|
||||||
static u_char aic3940_count;
|
|
||||||
|
|
||||||
static struct pci_device ahc_pci_driver = {
|
static struct pci_device ahc_pci_driver = {
|
||||||
"ahc",
|
"ahc",
|
||||||
@ -216,20 +238,75 @@ aic7870_probe (pcici_t tag, pcidi_t type)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#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
|
static void
|
||||||
aic7870_attach(config_id, unit)
|
aic7870_attach(config_id, unit)
|
||||||
pcici_t config_id;
|
pcici_t config_id;
|
||||||
int unit;
|
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;
|
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;
|
u_long id;
|
||||||
unsigned opri = 0;
|
unsigned opri = 0;
|
||||||
ahc_type ahc_t = AHC_NONE;
|
ahc_type ahc_t = AHC_NONE;
|
||||||
ahc_flag ahc_f = AHC_FNONE;
|
ahc_flag ahc_f = AHC_FNONE;
|
||||||
|
#if defined(__FreeBSD__)
|
||||||
struct ahc_data *ahc;
|
struct ahc_data *ahc;
|
||||||
|
#endif
|
||||||
u_char ultra_enb = 0;
|
u_char ultra_enb = 0;
|
||||||
u_char our_id = 0;
|
u_char our_id = 0;
|
||||||
|
|
||||||
|
#if defined(__FreeBSD__)
|
||||||
if(!(io_port = pci_conf_read(config_id, PCI_BASEADR0)))
|
if(!(io_port = pci_conf_read(config_id, PCI_BASEADR0)))
|
||||||
return;
|
return;
|
||||||
/*
|
/*
|
||||||
@ -237,8 +314,18 @@ aic7870_attach(config_id, unit)
|
|||||||
* set hence we mask it off.
|
* set hence we mask it off.
|
||||||
*/
|
*/
|
||||||
io_port &= 0xfffffffe;
|
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))) {
|
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_3940U:
|
||||||
case PCI_DEVICE_ID_ADAPTEC_3940:
|
case PCI_DEVICE_ID_ADAPTEC_3940:
|
||||||
if (id == PCI_DEVICE_ID_ADAPTEC_3940U)
|
if (id == PCI_DEVICE_ID_ADAPTEC_3940U)
|
||||||
@ -279,14 +366,31 @@ aic7870_attach(config_id, unit)
|
|||||||
ahc_f |= AHC_PAGESCBS;
|
ahc_f |= AHC_PAGESCBS;
|
||||||
|
|
||||||
/* Remeber how the card was setup in case there is no SEEPROM */
|
/* Remeber how the card was setup in case there is no SEEPROM */
|
||||||
|
#if defined(__FreeBSD__)
|
||||||
our_id = inb(SCSIID + io_port) & OID;
|
our_id = inb(SCSIID + io_port) & OID;
|
||||||
if(ahc_t & AHC_ULTRA)
|
if(ahc_t & AHC_ULTRA)
|
||||||
ultra_enb = inb(SXFRCTL0 + io_port) & ULTRAEN;
|
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);
|
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(ahc_t & AHC_AIC7870){
|
||||||
|
#if defined(__FreeBSD__)
|
||||||
u_long devconfig = pci_conf_read(config_id, DEVCONFIG);
|
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)) {
|
if(devconfig & (RAMPSM)) {
|
||||||
/*
|
/*
|
||||||
* External SRAM present. Have the probe walk
|
* External SRAM present. Have the probe walk
|
||||||
@ -308,35 +412,16 @@ aic7870_attach(config_id, unit)
|
|||||||
* affect RAMPSM either way.
|
* affect RAMPSM either way.
|
||||||
*/
|
*/
|
||||||
devconfig &= ~(RAMPSM|SCBRAMSEL);
|
devconfig &= ~(RAMPSM|SCBRAMSEL);
|
||||||
|
#if defined(__FreeBSD__)
|
||||||
pci_conf_write(config_id, DEVCONFIG, devconfig);
|
pci_conf_write(config_id, DEVCONFIG, devconfig);
|
||||||
|
#elif defined(__NetBSD__)
|
||||||
|
pci_conf_write(pa->pa_pc, pa->pa_tag,
|
||||||
|
DEVCONFIG, devconfig);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
#if defined(__FreeBSD__)
|
||||||
* Ensure that we are using good values for the PCI burst size
|
|
||||||
* and latency timer.
|
|
||||||
*/
|
|
||||||
{
|
|
||||||
u_long csize_lattime = pci_conf_read(config_id, CSIZE_LATTIME);
|
|
||||||
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);
|
|
||||||
pci_conf_write(config_id, CSIZE_LATTIME, csize_lattime);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!(ahc = ahc_alloc(unit, io_port, ahc_t, ahc_f)))
|
if(!(ahc = ahc_alloc(unit, io_port, ahc_t, ahc_f)))
|
||||||
return; /* XXX PCI code should take return status */
|
return; /* XXX PCI code should take return status */
|
||||||
|
|
||||||
@ -344,6 +429,34 @@ aic7870_attach(config_id, unit)
|
|||||||
ahc_free(ahc);
|
ahc_free(ahc);
|
||||||
return;
|
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
|
* Protect ourself from spurrious interrupts during
|
||||||
* intialization.
|
* intialization.
|
||||||
@ -356,7 +469,6 @@ aic7870_attach(config_id, unit)
|
|||||||
{
|
{
|
||||||
u_char sblkctl;
|
u_char sblkctl;
|
||||||
char *id_string;
|
char *id_string;
|
||||||
u_long iobase = ahc->baseport;
|
|
||||||
|
|
||||||
switch(ahc->type) {
|
switch(ahc->type) {
|
||||||
case AHC_394U:
|
case AHC_394U:
|
||||||
@ -407,14 +519,14 @@ aic7870_attach(config_id, unit)
|
|||||||
/*
|
/*
|
||||||
* Take the LED out of diagnostic mode
|
* Take the LED out of diagnostic mode
|
||||||
*/
|
*/
|
||||||
sblkctl = inb(SBLKCTL + iobase);
|
sblkctl = AHC_INB(ahc, SBLKCTL);
|
||||||
outb(SBLKCTL + iobase, (sblkctl & ~(DIAGLEDEN|DIAGLEDON)));
|
AHC_OUTB(ahc, SBLKCTL, (sblkctl & ~(DIAGLEDEN|DIAGLEDON)));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* I don't know where this is set in the SEEPROM or by the
|
* I don't know where this is set in the SEEPROM or by the
|
||||||
* BIOS, so we default to 100%.
|
* BIOS, so we default to 100%.
|
||||||
*/
|
*/
|
||||||
outb(DSPCISTATUS + iobase, DFTHRSH_100);
|
AHC_OUTB(ahc, DSPCISTATUS, DFTHRSH_100);
|
||||||
|
|
||||||
if(ahc->flags & AHC_USEDEFAULTS) {
|
if(ahc->flags & AHC_USEDEFAULTS) {
|
||||||
/*
|
/*
|
||||||
@ -424,31 +536,31 @@ aic7870_attach(config_id, unit)
|
|||||||
*/
|
*/
|
||||||
/* See if someone else set us up already */
|
/* See if someone else set us up already */
|
||||||
u_long i;
|
u_long i;
|
||||||
for(i=io_port + TARG_SCRATCH; i < io_port + 0x60; i++) {
|
for(i = TARG_SCRATCH; i < 0x60; i++) {
|
||||||
if(inb(i) != 0x00)
|
if(AHC_INB(ahc, i) != 0x00)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if(i == io_port + TARG_SCRATCH) {
|
if(i == TARG_SCRATCH) {
|
||||||
/*
|
/*
|
||||||
* Try looking for all ones. You can get
|
* Try looking for all ones. You can get
|
||||||
* either.
|
* either.
|
||||||
*/
|
*/
|
||||||
for(i=io_port + TARG_SCRATCH;
|
for (i = TARG_SCRATCH; i < 0x60; i++) {
|
||||||
i < io_port + 0x60; i++) {
|
if(AHC_INB(ahc, i) != 0xff)
|
||||||
if(inb(i) != 0xff)
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(i != io_port + 0x60) {
|
if(i != 0x60) {
|
||||||
printf("ahc%d: Using left over BIOS settings\n",
|
printf("%s: Using left over BIOS settings\n",
|
||||||
ahc->unit);
|
ahc_name(ahc));
|
||||||
ahc->flags &= ~AHC_USEDEFAULTS;
|
ahc->flags &= ~AHC_USEDEFAULTS;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
our_id = 0x07;
|
our_id = 0x07;
|
||||||
outb(SCSICONF + io_port, (our_id & 0x07)|ENSPCHK|RESET_SCSI);
|
AHC_OUTB(ahc, SCSICONF,
|
||||||
|
(our_id & 0x07)|ENSPCHK|RESET_SCSI);
|
||||||
/* In case we are a wide card */
|
/* In case we are a wide card */
|
||||||
outb(SCSICONF + 1 + io_port, our_id);
|
AHC_OUTB(ahc, SCSICONF + 1, our_id);
|
||||||
|
|
||||||
if(!ultra_enb || (ahc->flags & AHC_USEDEFAULTS)) {
|
if(!ultra_enb || (ahc->flags & AHC_USEDEFAULTS)) {
|
||||||
/*
|
/*
|
||||||
@ -460,7 +572,7 @@ aic7870_attach(config_id, unit)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("ahc%d: %s", unit, id_string);
|
printf("%s: %s", ahc_name(ahc), id_string);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(ahc_init(ahc)){
|
if(ahc_init(ahc)){
|
||||||
@ -480,26 +592,37 @@ void
|
|||||||
load_seeprom(ahc)
|
load_seeprom(ahc)
|
||||||
struct ahc_data *ahc;
|
struct ahc_data *ahc;
|
||||||
{
|
{
|
||||||
|
struct seeprom_descriptor sd;
|
||||||
struct seeprom_config sc;
|
struct seeprom_config sc;
|
||||||
u_short *scarray = (u_short *)≻
|
u_short *scarray = (u_short *)≻
|
||||||
u_short checksum = 0;
|
u_short checksum = 0;
|
||||||
u_long iobase = ahc->baseport;
|
|
||||||
u_char scsi_conf;
|
u_char scsi_conf;
|
||||||
u_char host_id;
|
u_char host_id;
|
||||||
int have_seeprom;
|
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)
|
if(bootverbose)
|
||||||
printf("ahc%d: Reading SEEPROM...", ahc->unit);
|
printf("%s: Reading SEEPROM...", ahc_name(ahc));
|
||||||
have_seeprom = acquire_seeprom(iobase + SEECTL, SEECS,
|
have_seeprom = acquire_seeprom(&sd);
|
||||||
SEECK, SEEDO, SEEDI, SEERDY, SEEMS);
|
|
||||||
if (have_seeprom) {
|
if (have_seeprom) {
|
||||||
have_seeprom = read_seeprom(iobase + SEECTL,
|
have_seeprom = read_seeprom(&sd,
|
||||||
(u_short *)&sc,
|
(u_int16_t *)&sc,
|
||||||
ahc->flags & AHC_CHNLB,
|
ahc->flags & AHC_CHNLB,
|
||||||
sizeof(sc)/2, SEECS, SEECK, SEEDO,
|
sizeof(sc)/2);
|
||||||
SEEDI, SEERDY, SEEMS);
|
release_seeprom(&sd);
|
||||||
release_seeprom(iobase + SEECTL, SEECS, SEECK, SEEDO,
|
|
||||||
SEEDI, SEERDY, SEEMS);
|
|
||||||
if (have_seeprom) {
|
if (have_seeprom) {
|
||||||
/* Check checksum */
|
/* Check checksum */
|
||||||
int i;
|
int i;
|
||||||
@ -517,7 +640,7 @@ load_seeprom(ahc)
|
|||||||
}
|
}
|
||||||
if (!have_seeprom) {
|
if (!have_seeprom) {
|
||||||
if(bootverbose)
|
if(bootverbose)
|
||||||
printf("\nahc%d: No SEEPROM availible\n", ahc->unit);
|
printf("\n%s: No SEEPROM availible\n", ahc_name(ahc));
|
||||||
ahc->flags |= AHC_USEDEFAULTS;
|
ahc->flags |= AHC_USEDEFAULTS;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -537,10 +660,10 @@ load_seeprom(ahc)
|
|||||||
target_settings |= WIDEXFER;
|
target_settings |= WIDEXFER;
|
||||||
if (sc.device_flags[i] & CFDISC)
|
if (sc.device_flags[i] & CFDISC)
|
||||||
ahc->discenable |= (0x01 << i);
|
ahc->discenable |= (0x01 << i);
|
||||||
outb(TARG_SCRATCH+i+iobase, target_settings);
|
AHC_OUTB(ahc, TARG_SCRATCH+i, target_settings);
|
||||||
}
|
}
|
||||||
outb(DISC_DSB + iobase, ~(ahc->discenable & 0xff));
|
AHC_OUTB(ahc, DISC_DSB, ~(ahc->discenable & 0xff));
|
||||||
outb(DISC_DSB + iobase + 1, ~((ahc->discenable >> 8) & 0xff));
|
AHC_OUTB(ahc, DISC_DSB + 1, ~((ahc->discenable >> 8) & 0xff));
|
||||||
|
|
||||||
host_id = sc.brtime_id & CFSCSIID;
|
host_id = sc.brtime_id & CFSCSIID;
|
||||||
|
|
||||||
@ -557,25 +680,18 @@ load_seeprom(ahc)
|
|||||||
ahc->type &= ~AHC_ULTRA;
|
ahc->type &= ~AHC_ULTRA;
|
||||||
}
|
}
|
||||||
/* Set the host ID */
|
/* Set the host ID */
|
||||||
outb(SCSICONF + iobase, scsi_conf);
|
AHC_OUTB(ahc, SCSICONF, scsi_conf);
|
||||||
/* In case we are a wide card */
|
/* In case we are a wide card */
|
||||||
outb(SCSICONF + 1 + iobase, host_id);
|
AHC_OUTB(ahc, SCSICONF + 1, host_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
acquire_seeprom(offset, CS, CK, DO, DI, RDY, MS)
|
acquire_seeprom(sd)
|
||||||
u_long offset;
|
struct seeprom_descriptor *sd;
|
||||||
u_short CS; /* chip select */
|
|
||||||
u_short CK; /* clock */
|
|
||||||
u_short DO; /* data out */
|
|
||||||
u_short DI; /* data in */
|
|
||||||
u_short RDY; /* ready */
|
|
||||||
u_short MS; /* mode select */
|
|
||||||
{
|
{
|
||||||
int wait;
|
int wait;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Request access of the memory port. When access is
|
* Request access of the memory port. When access is
|
||||||
* granted, SEERDY will go high. We use a 1 second
|
* granted, SEERDY will go high. We use a 1 second
|
||||||
@ -583,30 +699,24 @@ acquire_seeprom(offset, CS, CK, DO, DI, RDY, MS)
|
|||||||
* is needed. Reason: after the chip reset, there
|
* is needed. Reason: after the chip reset, there
|
||||||
* should be no contention.
|
* should be no contention.
|
||||||
*/
|
*/
|
||||||
outb(offset, MS);
|
SEEPROM_OUTB(sd, sd->sd_MS);
|
||||||
wait = 1000; /* 1 second timeout in msec */
|
wait = 1000; /* 1 second timeout in msec */
|
||||||
while (--wait && ((inb(offset) & RDY) == 0)) {
|
while (--wait && ((SEEPROM_INB(sd) & sd->sd_RDY) == 0)) {
|
||||||
DELAY (1000); /* delay 1 msec */
|
DELAY (1000); /* delay 1 msec */
|
||||||
}
|
}
|
||||||
if ((inb(offset) & RDY) == 0) {
|
if ((SEEPROM_INB(sd) & sd->sd_RDY) == 0) {
|
||||||
outb (offset, 0);
|
SEEPROM_OUTB(sd, 0);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
return(1);
|
return(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
release_seeprom(offset, CS, CK, DO, DI, RDY, MS)
|
release_seeprom(sd)
|
||||||
u_long offset;
|
struct seeprom_descriptor *sd;
|
||||||
u_short CS; /* chip select */
|
|
||||||
u_short CK; /* clock */
|
|
||||||
u_short DO; /* data out */
|
|
||||||
u_short DI; /* data in */
|
|
||||||
u_short RDY; /* ready */
|
|
||||||
u_short MS; /* mode select */
|
|
||||||
{
|
{
|
||||||
/* Release access to the memory port and the serial EEPROM. */
|
/* Release access to the memory port and the serial EEPROM. */
|
||||||
outb(offset, 0);
|
SEEPROM_OUTB(sd, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* NPCI > 0 */
|
#endif /* NPCI > 0 */
|
||||||
|
Loading…
Reference in New Issue
Block a user