Return to BSD News archive
Path: euryale.cc.adfa.oz.au!newshost.anu.edu.au!harbinger.cc.monash.edu.au!simtel!zombie.ncsc.mil!news.mathworks.com!uunet!in1.uu.net!news.iij.ad.jp!sranha.sra.co.jp!sranhc.sra.co.jp!sran230.sra.co.jp!soda From: soda@sra.CO.JP (Noriyuki Soda) Newsgroups: comp.unix.bsd.netbsd.misc Subject: Re: aha2840 port Date: 13 Oct 1995 20:13:34 GMT Organization: Software Research Associates, Inc., Japan Lines: 300 Distribution: world Message-ID: <SODA.95Oct14051335@sran230.sra.CO.JP> References: <4560u2$ad7@boson.epita.fr> NNTP-Posting-Host: sran230.sra.co.jp In-reply-to: laurent@epita.epita.fr's message of 7 Oct 1995 13:56:18 GMT >>>>> On 7 Oct 1995 13:56:18 GMT, laurent@epita.epita.fr (Laurent Genier) said: > I 'm looking for someone who succeeded in installing an adaptec 2840 > VLB under NetBSD-1.0 ou NetBSD-current. I'm using AHA-2840 VLB on NetBSD-current. Patches to Stefan's driver (*1) is the following. (This patch is based on FreeBSD's aic7770.c revision 1.15 by Justin T. Gibbs.) --- CUT HERE --- CUT HERE --- CUT HERE --- CUT HERE --- CUT HERE --- --- aic7870.c.org Sat Oct 14 05:19:31 1995 +++ aic7870.c Sat Oct 14 05:19:54 1995 @@ -29,103 +29,218 @@ #include <sys/device.h> #include <scsi/scsi_all.h> #include <scsi/scsiconf.h> + +#include "isa.h" +#include "pci.h" + +#include <dev/isa/isareg.h> +#if NISA > 0 +#include <dev/isa/isavar.h> +#include <dev/isa/isadmavar.h> +#endif + +#if NPCI > 0 #include <dev/pci/pcireg.h> #include <dev/pci/pcivar.h> +#endif + #include <dev/ic/aic7xxx.h> -#include <dev/isa/isareg.h> #include <i386/include/pio.h> #define DELAY(x) delay(x) +#if NISA > 0 +/* + * Standard EISA Host ID regs (Offset from slot base) + */ + +#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) | '@') + +#define EISA_MAX_SLOTS 16 /* XXX should be defined in a common header */ +static ahc_slot = 0; /* slot last board was found in */ + +typedef struct +{ + ahc_type type; + unsigned char id; /* The Last EISA Host ID reg */ +} aic7770_sig; + +#endif /* NISA */ +#if NPCI > 0 #define PCI_BASEADR0 PCI_MAP_REG_START #define PCI_DEVICE_ID_ADAPTEC_2940 0x71789004ul #define PCI_DEVICE_ID_ADAPTEC_AIC7870 0x70789004ul - static u_long aic7870_count; +#endif -static int aic7870_probe(); -static void aic7870_attach(); +static int aic7870_probe __P((struct device *parent, void *match, void *aux)); +static void aic7870_attach __P((struct device *parent, struct device *self, + void *aux)); struct cfdriver ahccd = { NULL, "ahc", aic7870_probe, aic7870_attach, DV_DULL, sizeof(struct ahc_softc) }; -extern -ahcintr(); - - int -aic7870_probe(parent, self, aux) - struct device *parent, *self; - void *aux; +aic7870_probe(parent, match, aux) + struct device *parent; + void *match, *aux; { - struct cfdata *cf = self->dv_cfdata; - struct pci_attach_args *pa = aux; - struct ahc_softc *ahc = (void *)self; + struct ahc_softc *sc = match; + extern struct cfdriver isacd, pcicd; +#if NISA > 0 + u_long port; + int i; + u_char sig_id[4]; + + aic7770_sig valid_ids[] = { + /* Entries of other tested adaptors should be added here */ + { AHC_274, 0x71 }, /*274x*/ + { AHC_274, 0x70 }, /*aic7770 on Motherboard*/ + { AHC_284, 0x56 }, /*284x, BIOS enabled*/ + { AHC_284, 0x57 } /*284x, BIOS disabled*/ + }; + + if (parent->dv_cfdata->cf_driver == &isacd) { + struct isa_attach_args *ia = aux; + + ahc_slot++; + while (ahc_slot < EISA_MAX_SLOTS) { + port = 0x1000 * ahc_slot; + for( i = 0; i < sizeof(sig_id); i++ ) + { + /* + * An outb is required to prime these + * registers on VL cards + */ + outb( port + HID0, HID0 + i ); + sig_id[i] = inb(port + HID0 + i); + } + if (sig_id[0] == 0xff) { + ahc_slot++; + continue; + } + /* Check manufacturer's ID. */ + 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)) { + for(i=0; i < sizeof(valid_ids)/sizeof(aic7770_sig);i++) + if ( sig_id[3] == valid_ids[i].id ) { + sc->type = valid_ids[i].type; + if (ahcprobe(sc, port)) { + if (ia->ia_irq != IRQUNK) { + if (ia->ia_irq != + sc->vect) { + printf("%s: irq mismatch; kernel configured %d != board configured %d\n", + sc->sc_dev.dv_xname, ia->ia_irq, sc->vect); + return 0; + } + } else + ia->ia_irq = sc->vect; + ia->ia_msize = 0; + ia->ia_iobase = + port + 0xc00; + /* XXX - should #def */ + ia->ia_iosize = 256; + /* IO_EISASIZE */ + return 1; + } + } + } + ahc_slot++; + } + } +#endif /* NISA */ + +#if NPCI > 0 + if (parent->dv_cfdata->cf_driver == &pcicd) { + struct pci_attach_args *pa = aux; #if 0 - if (!pci_targmatch(cf, pa)) - return 0; + if (!pci_targmatch(cf, pa)) + return 0; #endif - switch(pa->pa_id) { + switch(pa->pa_id) { case PCI_DEVICE_ID_ADAPTEC_2940: return 1; break; case PCI_DEVICE_ID_ADAPTEC_AIC7870: return 1; break; - default: - return (0); - break; - } + } + } +#endif /* NPCI */ + return 0; } void aic7870_attach(parent, self, aux) struct device *parent, *self; void *aux; { - struct pci_attach_args *pa = aux; - int retval; - struct ahc_softc *ahc = (void *)self; - u_long io_port; - unsigned opri = 0; + struct ahc_softc *sc = (void *)self; + unsigned opri; + extern struct cfdriver isacd, pcicd; + +#if NPCI > 0 + if (parent->dv_cfdata->cf_driver == &pcicd) { + struct pci_attach_args *pa = aux; + u_long io_port; - switch(pa->pa_id) { + switch(pa->pa_id) { case PCI_DEVICE_ID_ADAPTEC_2940: - ahc->type=AHC_294; + sc->type=AHC_294; break; case PCI_DEVICE_ID_ADAPTEC_AIC7870: - ahc->type=AHC_AIC7870; + sc->type=AHC_AIC7870; break; default: break; - } - if(!(io_port = pci_conf_read(pa->pa_tag, PCI_BASEADR0))) - return; - /* - * Make the offsets the same as for EISA - * The first bit of PCI_BASEADR0 is always - * set hence we subtract 0xc01 instead of the - * 0xc00 that you would expect. - */ - io_port -= 0xc01ul; - /*printf("ioport %x\n",io_port);/**/ - - if(ahcprobe(ahc,io_port)){ - if((ahc->sc_ih= - pci_map_int(pa->pa_tag, PCI_IPL_BIO, ahcintr, ahc))==NULL) { - return; } + if(!(io_port = pci_conf_read(pa->pa_tag, PCI_BASEADR0))) + return; /* - * Since ahc_attach will poll, protect ourself - * from the registered interrupt handler. + * Make the offsets the same as for EISA + * The first bit of PCI_BASEADR0 is always + * set hence we subtract 0xc01 instead of the + * 0xc00 that you would expect. */ - opri = splbio(); - ahc_attach(ahc); - splx(opri); + io_port -= 0xc01ul; + /*printf("ioport %x\n",io_port);/**/ + + if(!ahcprobe(sc,io_port)) + return; + if((sc->sc_ih = pci_map_int(pa->pa_tag, PCI_IPL_BIO, + ahcintr, sc)) == NULL) + return; + } +#endif /* NPCI */ + +#if NISA > 0 + if (parent->dv_cfdata->cf_driver == &isacd) { + struct isa_attach_args *ia = aux; + + sc->sc_ih = isa_intr_establish(ia->ia_irq, + ISA_IST_EDGE, ISA_IPL_BIO, + ahcintr, sc); } - return; +#endif /* NISA */ + + /* + * Since ahc_attach will poll, protect ourself + * from the registered interrupt handler. + */ + opri = splbio(); + ahc_attach(sc); + splx(opri); } --- CUT HERE --- CUT HERE --- CUT HERE --- CUT HERE --- CUT HERE --- You must add the following to /usr/src/sys/dev/pci/files.pci. (this is slightly different from Stefan's files.pci.add) --- CUT HERE --- CUT HERE --- CUT HERE --- CUT HERE --- CUT HERE --- # Adaptec AIC-7770/7870 ICs device ahc at isa, pci: scsi file dev/pci/aic7870.c ahc file dev/ic/aic7xxx.c ahc --- CUT HERE --- CUT HERE --- CUT HERE --- CUT HERE --- CUT HERE --- (*1) Stefan's AHA-2940 driver is found in ftp://ftp.uni-mainz.de/pub/NetBSD/misc_features/Stefan/kernel/scsi/aic7xxx_4NetBSD-current.tar.gz -- soda@sra.co.jp Software Research Associates, Inc., Japan (Noriyuki Soda) software tools and technology group