Home | History | Annotate | Line # | Download | only in pci
siop_pci_common.c revision 1.17.4.1
      1  1.17.4.1      tron /*	$NetBSD: siop_pci_common.c,v 1.17.4.1 2005/03/17 17:40:00 tron Exp $	*/
      2       1.1    bouyer 
      3       1.1    bouyer /*
      4       1.1    bouyer  * Copyright (c) 2000 Manuel Bouyer.
      5       1.1    bouyer  *
      6       1.1    bouyer  * Redistribution and use in source and binary forms, with or without
      7       1.1    bouyer  * modification, are permitted provided that the following conditions
      8       1.1    bouyer  * are met:
      9       1.1    bouyer  * 1. Redistributions of source code must retain the above copyright
     10       1.1    bouyer  *    notice, this list of conditions and the following disclaimer.
     11       1.1    bouyer  * 2. Redistributions in binary form must reproduce the above copyright
     12       1.1    bouyer  *    notice, this list of conditions and the following disclaimer in the
     13       1.1    bouyer  *    documentation and/or other materials provided with the distribution.
     14       1.1    bouyer  * 3. All advertising materials mentioning features or use of this software
     15       1.1    bouyer  *    must display the following acknowledgement:
     16      1.15    bouyer  *	This product includes software developed by Manuel Bouyer.
     17       1.1    bouyer  * 4. The name of the author may not be used to endorse or promote products
     18       1.1    bouyer  *    derived from this software without specific prior written permission.
     19       1.1    bouyer  *
     20       1.1    bouyer  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     21       1.1    bouyer  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     22       1.1    bouyer  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     23       1.1    bouyer  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     24       1.1    bouyer  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     25       1.1    bouyer  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     26       1.1    bouyer  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     27       1.1    bouyer  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     28       1.1    bouyer  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     29       1.1    bouyer  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     30       1.1    bouyer  */
     31       1.1    bouyer 
     32       1.1    bouyer /* SYM53c8xx PCI-SCSI I/O Processors driver: PCI front-end */
     33       1.9     lukem 
     34       1.9     lukem #include <sys/cdefs.h>
     35  1.17.4.1      tron __KERNEL_RCSID(0, "$NetBSD: siop_pci_common.c,v 1.17.4.1 2005/03/17 17:40:00 tron Exp $");
     36       1.1    bouyer 
     37       1.1    bouyer #include <sys/param.h>
     38       1.1    bouyer #include <sys/systm.h>
     39       1.1    bouyer #include <sys/device.h>
     40       1.1    bouyer #include <sys/malloc.h>
     41       1.1    bouyer #include <sys/buf.h>
     42       1.1    bouyer #include <sys/kernel.h>
     43       1.1    bouyer 
     44       1.1    bouyer #include <machine/endian.h>
     45       1.1    bouyer 
     46       1.1    bouyer #include <dev/pci/pcireg.h>
     47       1.1    bouyer #include <dev/pci/pcivar.h>
     48       1.1    bouyer #include <dev/pci/pcidevs.h>
     49       1.1    bouyer 
     50       1.1    bouyer #include <dev/scsipi/scsipi_all.h>
     51       1.1    bouyer #include <dev/scsipi/scsipiconf.h>
     52       1.1    bouyer 
     53       1.1    bouyer #include <dev/ic/siopreg.h>
     54      1.11    bouyer #include <dev/ic/siopvar_common.h>
     55       1.1    bouyer #include <dev/pci/siop_pci_common.h>
     56       1.1    bouyer 
     57       1.1    bouyer /* List (array, really :) of chips we know how to handle */
     58       1.1    bouyer const struct siop_product_desc siop_products[] = {
     59       1.1    bouyer 	{ PCI_PRODUCT_SYMBIOS_810,
     60       1.1    bouyer 	0x00,
     61       1.1    bouyer 	"Symbios Logic 53c810 (fast scsi)",
     62       1.1    bouyer 	SF_PCI_RL | SF_CHIP_LS,
     63       1.3    bouyer 	4, 8, 3, 250, 0
     64       1.1    bouyer 	},
     65       1.1    bouyer 	{ PCI_PRODUCT_SYMBIOS_810,
     66       1.1    bouyer 	0x10,
     67       1.1    bouyer 	"Symbios Logic 53c810a (fast scsi)",
     68       1.1    bouyer 	SF_PCI_RL | SF_PCI_BOF | SF_CHIP_PF | SF_CHIP_LS,
     69       1.3    bouyer 	4, 8, 3, 250, 0
     70       1.1    bouyer 	},
     71       1.1    bouyer 	{ PCI_PRODUCT_SYMBIOS_815,
     72       1.1    bouyer 	0x00,
     73       1.1    bouyer 	"Symbios Logic 53c815 (fast scsi)",
     74       1.1    bouyer 	SF_PCI_RL | SF_PCI_BOF,
     75       1.3    bouyer 	4, 8, 3, 250, 0
     76       1.1    bouyer 	},
     77       1.1    bouyer 	{ PCI_PRODUCT_SYMBIOS_820,
     78       1.1    bouyer 	0x00,
     79       1.1    bouyer 	"Symbios Logic 53c820 (fast wide scsi)",
     80       1.1    bouyer 	SF_PCI_RL | SF_CHIP_LS | SF_BUS_WIDE,
     81       1.3    bouyer 	4, 8, 3, 250, 0
     82       1.1    bouyer 	},
     83       1.1    bouyer 	{ PCI_PRODUCT_SYMBIOS_825,
     84       1.1    bouyer 	0x00,
     85       1.1    bouyer 	"Symbios Logic 53c825 (fast wide scsi)",
     86       1.1    bouyer 	SF_PCI_RL | SF_PCI_BOF | SF_BUS_WIDE,
     87       1.3    bouyer 	4, 8, 3, 250, 0
     88       1.1    bouyer 	},
     89       1.1    bouyer 	{ PCI_PRODUCT_SYMBIOS_825,
     90       1.1    bouyer 	0x10,
     91       1.1    bouyer 	"Symbios Logic 53c825a (fast wide scsi)",
     92       1.1    bouyer 	SF_PCI_RL | SF_PCI_CLS | SF_PCI_WRI | SF_PCI_RM |
     93       1.1    bouyer 	SF_CHIP_FIFO | SF_CHIP_PF | SF_CHIP_RAM | SF_CHIP_LS | SF_CHIP_10REGS |
     94       1.1    bouyer 	SF_BUS_WIDE,
     95       1.3    bouyer 	7, 8, 3, 250, 4096
     96       1.1    bouyer 	},
     97       1.1    bouyer 	{ PCI_PRODUCT_SYMBIOS_860,
     98       1.1    bouyer 	0x00,
     99       1.1    bouyer 	"Symbios Logic 53c860 (ultra scsi)",
    100       1.1    bouyer 	SF_PCI_RL | SF_PCI_CLS | SF_PCI_WRI | SF_PCI_RM |
    101       1.1    bouyer 	SF_CHIP_PF | SF_CHIP_LS |
    102       1.1    bouyer 	SF_BUS_ULTRA,
    103       1.3    bouyer 	4, 8, 5, 125, 0
    104       1.1    bouyer 	},
    105       1.1    bouyer 	{ PCI_PRODUCT_SYMBIOS_875,
    106       1.1    bouyer 	0x00,
    107       1.1    bouyer 	"Symbios Logic 53c875 (ultra-wide scsi)",
    108       1.1    bouyer 	SF_PCI_RL | SF_PCI_CLS | SF_PCI_WRI | SF_PCI_RM |
    109       1.1    bouyer 	SF_CHIP_FIFO | SF_CHIP_PF | SF_CHIP_RAM | SF_CHIP_LS | SF_CHIP_10REGS |
    110       1.1    bouyer 	SF_BUS_ULTRA | SF_BUS_WIDE,
    111       1.3    bouyer 	7, 16, 5, 125, 4096
    112       1.1    bouyer 	},
    113       1.1    bouyer 	{ PCI_PRODUCT_SYMBIOS_875,
    114       1.1    bouyer 	0x02,
    115       1.1    bouyer 	"Symbios Logic 53c875 (ultra-wide scsi)",
    116       1.1    bouyer 	SF_PCI_RL | SF_PCI_CLS | SF_PCI_WRI | SF_PCI_RM |
    117       1.1    bouyer 	SF_CHIP_FIFO | SF_CHIP_PF | SF_CHIP_RAM | SF_CHIP_DBLR |
    118       1.1    bouyer 	SF_CHIP_LS | SF_CHIP_10REGS |
    119       1.1    bouyer 	SF_BUS_ULTRA | SF_BUS_WIDE,
    120       1.3    bouyer 	7, 16, 5, 125, 4096
    121       1.1    bouyer 	},
    122       1.1    bouyer 	{ PCI_PRODUCT_SYMBIOS_875J,
    123       1.1    bouyer 	0x00,
    124       1.1    bouyer 	"Symbios Logic 53c875j (ultra-wide scsi)",
    125       1.1    bouyer 	SF_PCI_RL | SF_PCI_CLS | SF_PCI_WRI | SF_PCI_RM |
    126       1.1    bouyer 	SF_CHIP_FIFO | SF_CHIP_PF | SF_CHIP_RAM | SF_CHIP_DBLR |
    127       1.1    bouyer 	SF_CHIP_LS | SF_CHIP_10REGS |
    128       1.1    bouyer 	SF_BUS_ULTRA | SF_BUS_WIDE,
    129       1.3    bouyer 	7, 16, 5, 125, 4096
    130       1.1    bouyer 	},
    131       1.1    bouyer 	{ PCI_PRODUCT_SYMBIOS_885,
    132       1.1    bouyer 	0x00,
    133       1.1    bouyer 	"Symbios Logic 53c885 (ultra-wide scsi)",
    134       1.1    bouyer 	SF_PCI_RL | SF_PCI_CLS | SF_PCI_WRI | SF_PCI_RM |
    135       1.1    bouyer 	SF_CHIP_FIFO | SF_CHIP_PF | SF_CHIP_RAM | SF_CHIP_DBLR |
    136       1.1    bouyer 	SF_CHIP_LS | SF_CHIP_10REGS |
    137       1.1    bouyer 	SF_BUS_ULTRA | SF_BUS_WIDE,
    138       1.3    bouyer 	7, 16, 5, 125, 4096
    139       1.1    bouyer 	},
    140       1.1    bouyer 	{ PCI_PRODUCT_SYMBIOS_895,
    141       1.1    bouyer 	0x00,
    142       1.1    bouyer 	"Symbios Logic 53c895 (ultra2-wide scsi)",
    143       1.1    bouyer 	SF_PCI_RL | SF_PCI_CLS | SF_PCI_WRI | SF_PCI_RM |
    144       1.1    bouyer 	SF_CHIP_FIFO | SF_CHIP_PF | SF_CHIP_RAM | SF_CHIP_QUAD |
    145       1.1    bouyer 	SF_CHIP_LS | SF_CHIP_10REGS |
    146       1.1    bouyer 	SF_BUS_ULTRA2 | SF_BUS_WIDE,
    147       1.3    bouyer 	7, 31, 7, 62, 4096
    148       1.1    bouyer 	},
    149       1.1    bouyer 	{ PCI_PRODUCT_SYMBIOS_896,
    150       1.1    bouyer 	0x00,
    151       1.1    bouyer 	"Symbios Logic 53c896 (ultra2-wide scsi)",
    152       1.1    bouyer 	SF_PCI_RL | SF_PCI_CLS | SF_PCI_WRI | SF_PCI_RM |
    153      1.12    bouyer 	SF_CHIP_LEDC | SF_CHIP_FIFO | SF_CHIP_PF | SF_CHIP_RAM | SF_CHIP_QUAD |
    154       1.1    bouyer 	SF_CHIP_LS | SF_CHIP_10REGS |
    155       1.1    bouyer 	SF_BUS_ULTRA2 | SF_BUS_WIDE,
    156       1.3    bouyer 	7, 31, 7, 62, 8192
    157       1.6   thorpej 	},
    158       1.6   thorpej 	{ PCI_PRODUCT_SYMBIOS_895A,
    159       1.6   thorpej 	0x00,
    160       1.6   thorpej 	"Symbios Logic 53c895a (ultra2-wide scsi)",
    161       1.6   thorpej 	SF_PCI_RL | SF_PCI_CLS | SF_PCI_WRI | SF_PCI_RM |
    162      1.12    bouyer 	SF_CHIP_LEDC | SF_CHIP_FIFO | SF_CHIP_PF | SF_CHIP_RAM | SF_CHIP_QUAD |
    163       1.6   thorpej 	SF_CHIP_LS | SF_CHIP_10REGS |
    164       1.6   thorpej 	SF_BUS_ULTRA2 | SF_BUS_WIDE,
    165       1.7    bouyer 	7, 31, 7, 62, 8192
    166       1.7    bouyer 	},
    167       1.7    bouyer 	{ PCI_PRODUCT_SYMBIOS_1010,
    168       1.7    bouyer 	0x00,
    169      1.16   thorpej 	"Symbios Logic 53c1010-33 rev 0 (ultra3-wide scsi)",
    170      1.14    bouyer 	SF_PCI_RL | SF_PCI_CLS | SF_PCI_WRI | SF_PCI_RM |
    171      1.14    bouyer 	SF_CHIP_LEDC | SF_CHIP_FIFO | SF_CHIP_PF | SF_CHIP_RAM |
    172      1.14    bouyer 	SF_CHIP_LS | SF_CHIP_10REGS | SF_CHIP_DFBC | SF_CHIP_DBLR |
    173      1.17    bouyer 	SF_CHIP_GEBUG |
    174      1.14    bouyer 	SF_BUS_ULTRA3 | SF_BUS_WIDE,
    175      1.14    bouyer 	7, 31, 0, 62, 8192
    176      1.14    bouyer 	},
    177      1.14    bouyer 	{ PCI_PRODUCT_SYMBIOS_1010,
    178      1.14    bouyer 	0x01,
    179      1.16   thorpej 	"Symbios Logic 53c1010-33 (ultra3-wide scsi)",
    180      1.10    briggs 	SF_PCI_RL | SF_PCI_CLS | SF_PCI_WRI | SF_PCI_RM |
    181      1.12    bouyer 	SF_CHIP_LEDC | SF_CHIP_FIFO | SF_CHIP_PF | SF_CHIP_RAM |
    182      1.14    bouyer 	SF_CHIP_LS | SF_CHIP_10REGS | SF_CHIP_DFBC | SF_CHIP_DBLR | SF_CHIP_DT |
    183      1.17    bouyer 	SF_CHIP_GEBUG |
    184      1.14    bouyer 	SF_BUS_ULTRA3 | SF_BUS_WIDE,
    185      1.14    bouyer 	7, 62, 0, 62, 8192
    186      1.10    briggs 	},
    187      1.10    briggs 	{ PCI_PRODUCT_SYMBIOS_1010_2,
    188      1.10    briggs 	0x00,
    189      1.16   thorpej 	"Symbios Logic 53c1010-66 (ultra3-wide scsi)",
    190       1.7    bouyer 	SF_PCI_RL | SF_PCI_CLS | SF_PCI_WRI | SF_PCI_RM |
    191      1.12    bouyer 	SF_CHIP_LEDC | SF_CHIP_FIFO | SF_CHIP_PF | SF_CHIP_RAM |
    192      1.14    bouyer 	SF_CHIP_LS | SF_CHIP_10REGS | SF_CHIP_DFBC | SF_CHIP_DBLR | SF_CHIP_DT |
    193  1.17.4.1      tron 	SF_CHIP_AAIP |
    194      1.14    bouyer 	SF_BUS_ULTRA3 | SF_BUS_WIDE,
    195      1.14    bouyer 	7, 62, 0, 62, 8192
    196       1.6   thorpej 	},
    197       1.6   thorpej 	{ PCI_PRODUCT_SYMBIOS_1510D,
    198       1.6   thorpej 	0x00,
    199       1.6   thorpej 	"Symbios Logic 53c1510d (ultra2-wide scsi)",
    200       1.6   thorpej 	SF_PCI_RL | SF_PCI_CLS | SF_PCI_WRI | SF_PCI_RM |
    201       1.6   thorpej 	SF_CHIP_FIFO | SF_CHIP_PF | SF_CHIP_RAM | SF_CHIP_QUAD |
    202       1.6   thorpej 	SF_CHIP_LS | SF_CHIP_10REGS |
    203       1.6   thorpej 	SF_BUS_ULTRA2 | SF_BUS_WIDE,
    204       1.6   thorpej 	7, 31, 7, 62, 4096
    205       1.1    bouyer 	},
    206       1.1    bouyer 	{ 0,
    207       1.1    bouyer 	0x00,
    208       1.1    bouyer 	NULL,
    209       1.1    bouyer 	0x00,
    210       1.3    bouyer 	0, 0, 0, 0, 0
    211       1.1    bouyer 	},
    212       1.1    bouyer };
    213       1.1    bouyer 
    214       1.1    bouyer const struct siop_product_desc *
    215       1.1    bouyer siop_lookup_product(id, rev)
    216       1.1    bouyer 	u_int32_t id;
    217       1.1    bouyer 	int rev;
    218       1.1    bouyer {
    219       1.1    bouyer 	const struct siop_product_desc *pp;
    220       1.1    bouyer 	const struct siop_product_desc *rp = NULL;
    221       1.1    bouyer 
    222       1.1    bouyer 	if (PCI_VENDOR(id) != PCI_VENDOR_SYMBIOS)
    223       1.1    bouyer 		return NULL;
    224       1.1    bouyer 
    225       1.1    bouyer 	for (pp = siop_products; pp->name != NULL; pp++) {
    226       1.1    bouyer 		if (PCI_PRODUCT(id) == pp->product && pp->revision <= rev)
    227       1.1    bouyer 			if (rp == NULL || pp->revision > rp->revision)
    228       1.1    bouyer 				rp = pp;
    229       1.1    bouyer 	}
    230       1.1    bouyer 	return rp;
    231       1.1    bouyer }
    232       1.1    bouyer 
    233       1.1    bouyer int
    234      1.11    bouyer siop_pci_attach_common(pci_sc, siop_sc, pa, intr)
    235      1.11    bouyer 	struct siop_pci_common_softc *pci_sc;
    236      1.11    bouyer 	struct siop_common_softc *siop_sc;
    237       1.1    bouyer 	struct pci_attach_args *pa;
    238      1.11    bouyer 	int (*intr) __P((void*));
    239      1.11    bouyer 
    240       1.1    bouyer {
    241       1.1    bouyer 	pci_chipset_tag_t pc = pa->pa_pc;
    242       1.1    bouyer 	pcitag_t tag = pa->pa_tag;
    243       1.1    bouyer 	const char *intrstr;
    244       1.1    bouyer 	pci_intr_handle_t intrhandle;
    245       1.1    bouyer 	bus_space_tag_t iot, memt;
    246       1.1    bouyer 	bus_space_handle_t ioh, memh;
    247       1.1    bouyer 	pcireg_t memtype;
    248       1.1    bouyer 	int memh_valid, ioh_valid;
    249       1.1    bouyer 	bus_addr_t ioaddr, memaddr;
    250       1.1    bouyer 
    251      1.11    bouyer 	pci_sc->sc_pp =
    252      1.11    bouyer 	    siop_lookup_product(pa->pa_id, PCI_REVISION(pa->pa_class));
    253      1.11    bouyer 	if (pci_sc->sc_pp == NULL) {
    254       1.1    bouyer 		printf("sym: broken match/attach!!\n");
    255       1.1    bouyer 		return 0;
    256       1.1    bouyer 	}
    257       1.2    bouyer 	/* copy interesting infos about the chip */
    258      1.11    bouyer 	siop_sc->features = pci_sc->sc_pp->features;
    259      1.13    bouyer #ifdef SIOP_SYMLED    /* XXX Should be a devprop! */
    260      1.13    bouyer 	siop_sc->features |= SF_CHIP_LED0;
    261      1.13    bouyer #endif
    262      1.11    bouyer 	siop_sc->maxburst = pci_sc->sc_pp->maxburst;
    263      1.11    bouyer 	siop_sc->maxoff = pci_sc->sc_pp->maxoff;
    264      1.11    bouyer 	siop_sc->clock_div = pci_sc->sc_pp->clock_div;
    265      1.11    bouyer 	siop_sc->clock_period = pci_sc->sc_pp->clock_period;
    266      1.11    bouyer 	siop_sc->ram_size = pci_sc->sc_pp->ram_size;
    267      1.11    bouyer 
    268      1.11    bouyer 	siop_sc->sc_reset = siop_pci_reset;
    269      1.11    bouyer 	printf(": %s\n", pci_sc->sc_pp->name);
    270      1.11    bouyer 	pci_sc->sc_pc = pc;
    271      1.11    bouyer 	pci_sc->sc_tag = tag;
    272      1.11    bouyer 	siop_sc->sc_dmat = pa->pa_dmat;
    273       1.1    bouyer 
    274       1.1    bouyer 	memtype = pci_mapreg_type(pa->pa_pc, pa->pa_tag, 0x14);
    275       1.1    bouyer 	switch (memtype) {
    276       1.1    bouyer 	case PCI_MAPREG_TYPE_MEM | PCI_MAPREG_MEM_TYPE_32BIT:
    277       1.1    bouyer 	case PCI_MAPREG_TYPE_MEM | PCI_MAPREG_MEM_TYPE_64BIT:
    278       1.1    bouyer 		memh_valid = (pci_mapreg_map(pa, 0x14, memtype, 0,
    279       1.1    bouyer 		    &memt, &memh, &memaddr, NULL) == 0);
    280       1.1    bouyer 		break;
    281       1.1    bouyer 	default:
    282       1.1    bouyer 		memh_valid = 0;
    283       1.1    bouyer 	}
    284       1.1    bouyer 
    285       1.1    bouyer 	ioh_valid = (pci_mapreg_map(pa, 0x10, PCI_MAPREG_TYPE_IO, 0,
    286       1.1    bouyer 	    &iot, &ioh, &ioaddr, NULL) == 0);
    287       1.1    bouyer 
    288       1.1    bouyer 	if (memh_valid) {
    289      1.11    bouyer 		siop_sc->sc_rt = memt;
    290      1.11    bouyer 		siop_sc->sc_rh = memh;
    291      1.11    bouyer 		siop_sc->sc_raddr = memaddr;
    292       1.1    bouyer 	} else if (ioh_valid) {
    293      1.11    bouyer 		siop_sc->sc_rt = iot;
    294      1.11    bouyer 		siop_sc->sc_rh = ioh;
    295      1.11    bouyer 		siop_sc->sc_raddr = ioaddr;
    296       1.1    bouyer 	} else {
    297       1.1    bouyer 		printf("%s: unable to map device registers\n",
    298      1.11    bouyer 		    siop_sc->sc_dev.dv_xname);
    299       1.1    bouyer 		return 0;
    300       1.1    bouyer 	}
    301       1.1    bouyer 
    302      1.11    bouyer 	if (siop_sc->features & SF_CHIP_RAM) {
    303       1.4      matt 		int bar;
    304       1.4      matt 		switch (memtype) {
    305       1.4      matt 		case PCI_MAPREG_TYPE_MEM | PCI_MAPREG_MEM_TYPE_32BIT:
    306       1.4      matt 			bar = 0x18;
    307       1.4      matt 			break;
    308       1.4      matt 		case PCI_MAPREG_TYPE_MEM | PCI_MAPREG_MEM_TYPE_64BIT:
    309       1.4      matt 			bar = 0x1c;
    310       1.4      matt 			break;
    311       1.4      matt 		}
    312       1.4      matt 		if (pci_mapreg_map(pa, bar, memtype, 0,
    313      1.11    bouyer                     &siop_sc->sc_ramt, &siop_sc->sc_ramh,
    314      1.11    bouyer 		    &siop_sc->sc_scriptaddr, NULL) == 0) {
    315       1.2    bouyer 			printf("%s: using on-board RAM\n",
    316      1.11    bouyer 			    siop_sc->sc_dev.dv_xname);
    317       1.2    bouyer 		} else {
    318       1.2    bouyer 			printf("%s: can't map on-board RAM\n",
    319      1.11    bouyer 			    siop_sc->sc_dev.dv_xname);
    320      1.11    bouyer 			siop_sc->features &= ~SF_CHIP_RAM;
    321       1.2    bouyer 		}
    322       1.2    bouyer 	}
    323       1.2    bouyer 
    324       1.5  sommerfe 	if (pci_intr_map(pa, &intrhandle) != 0) {
    325       1.1    bouyer 		printf("%s: couldn't map interrupt\n",
    326      1.11    bouyer 		    siop_sc->sc_dev.dv_xname);
    327       1.1    bouyer 		return 0;
    328       1.1    bouyer 	}
    329       1.1    bouyer 	intrstr = pci_intr_string(pa->pa_pc, intrhandle);
    330      1.11    bouyer 	pci_sc->sc_ih = pci_intr_establish(pa->pa_pc, intrhandle, IPL_BIO,
    331      1.11    bouyer 	    intr, siop_sc);
    332      1.11    bouyer 	if (pci_sc->sc_ih != NULL) {
    333       1.1    bouyer 		printf("%s: interrupting at %s\n",
    334      1.11    bouyer 		    siop_sc->sc_dev.dv_xname,
    335       1.1    bouyer 		    intrstr ? intrstr : "unknown interrupt");
    336       1.1    bouyer 	} else {
    337       1.1    bouyer 		printf("%s: couldn't establish interrupt",
    338      1.11    bouyer 		    siop_sc->sc_dev.dv_xname);
    339       1.1    bouyer 		if (intrstr != NULL)
    340       1.1    bouyer 			printf(" at %s", intrstr);
    341       1.1    bouyer 		printf("\n");
    342       1.1    bouyer 		return 0;
    343       1.1    bouyer 	}
    344       1.1    bouyer 	return 1;
    345       1.1    bouyer }
    346       1.1    bouyer 
    347       1.1    bouyer void
    348       1.1    bouyer siop_pci_reset(sc)
    349      1.11    bouyer 	struct siop_common_softc *sc;
    350       1.1    bouyer {
    351       1.1    bouyer 	int dmode;
    352       1.1    bouyer 
    353       1.1    bouyer 	dmode = bus_space_read_1(sc->sc_rt, sc->sc_rh, SIOP_DMODE);
    354       1.1    bouyer 	if (sc->features & SF_PCI_RL)
    355       1.1    bouyer 		dmode |= DMODE_ERL;
    356       1.1    bouyer 	if (sc->features & SF_PCI_RM)
    357       1.1    bouyer 		dmode |= DMODE_ERMP;
    358       1.1    bouyer 	if (sc->features & SF_PCI_BOF)
    359       1.1    bouyer 		dmode |= DMODE_BOF;
    360       1.1    bouyer 	if (sc->features & SF_PCI_CLS)
    361       1.1    bouyer 		bus_space_write_1(sc->sc_rt, sc->sc_rh, SIOP_DCNTL,
    362       1.1    bouyer 		    bus_space_read_1(sc->sc_rt, sc->sc_rh, SIOP_DCNTL) |
    363       1.1    bouyer 		    DCNTL_CLSE);
    364       1.1    bouyer 	if (sc->features & SF_PCI_WRI)
    365       1.1    bouyer 		bus_space_write_1(sc->sc_rt, sc->sc_rh, SIOP_CTEST3,
    366       1.1    bouyer 		    bus_space_read_1(sc->sc_rt, sc->sc_rh, SIOP_CTEST3) |
    367       1.1    bouyer 		    CTEST3_WRIE);
    368       1.1    bouyer 	if (sc->maxburst) {
    369       1.1    bouyer 		int ctest5 = bus_space_read_1(sc->sc_rt, sc->sc_rh,
    370       1.1    bouyer 		    SIOP_CTEST5);
    371       1.1    bouyer 		bus_space_write_1(sc->sc_rt, sc->sc_rh, SIOP_CTEST4,
    372       1.1    bouyer 		    bus_space_read_1(sc->sc_rt, sc->sc_rh, SIOP_CTEST4) &
    373       1.1    bouyer 		    ~CTEST4_BDIS);
    374       1.1    bouyer 		dmode &= ~DMODE_BL_MASK;
    375       1.1    bouyer 		dmode |= ((sc->maxburst - 1) << DMODE_BL_SHIFT) & DMODE_BL_MASK;
    376       1.1    bouyer 		ctest5 &= ~CTEST5_BBCK;
    377       1.1    bouyer 		ctest5 |= (sc->maxburst - 1) & CTEST5_BBCK;
    378       1.1    bouyer 		bus_space_write_1(sc->sc_rt, sc->sc_rh, SIOP_CTEST5, ctest5);
    379       1.1    bouyer 	} else {
    380       1.1    bouyer 		bus_space_write_1(sc->sc_rt, sc->sc_rh, SIOP_CTEST4,
    381       1.1    bouyer 		    bus_space_read_1(sc->sc_rt, sc->sc_rh, SIOP_CTEST4) |
    382       1.1    bouyer 		    CTEST4_BDIS);
    383       1.1    bouyer 	}
    384       1.1    bouyer 	bus_space_write_1(sc->sc_rt, sc->sc_rh, SIOP_DMODE, dmode);
    385       1.1    bouyer }
    386