Tue May 5 09:51:24 2009 UTC ()
device_t/softc split


(cegger)
diff -r1.36 -r1.37 src/sys/arch/i386/isa/ahc_isa.c
diff -r1.26 -r1.27 src/sys/dev/cardbus/ahc_cardbus.c
diff -r1.36 -r1.37 src/sys/dev/eisa/ahc_eisa.c
diff -r1.27 -r1.28 src/sys/dev/ic/aic7xxx_osm.c
diff -r1.21 -r1.22 src/sys/dev/ic/aic7xxx_osm.h
diff -r1.55 -r1.56 src/sys/dev/ic/aic7xxxvar.h
diff -r1.64 -r1.65 src/sys/dev/pci/ahc_pci.c

cvs diff -r1.36 -r1.37 src/sys/arch/i386/isa/ahc_isa.c (expand / switch to unified diff)

--- src/sys/arch/i386/isa/ahc_isa.c 2009/05/04 12:14:31 1.36
+++ src/sys/arch/i386/isa/ahc_isa.c 2009/05/05 09:51:23 1.37
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: ahc_isa.c,v 1.36 2009/05/04 12:14:31 cegger Exp $ */ 1/* $NetBSD: ahc_isa.c,v 1.37 2009/05/05 09:51:23 cegger Exp $ */
2 2
3/* 3/*
4 * Product specific probe and attach routines for: 4 * Product specific probe and attach routines for:
5 * AHA-284X VL-bus SCSI controllers 5 * AHA-284X VL-bus SCSI controllers
6 * 6 *
7 * Copyright (c) 1994, 1995, 1996, 1997, 1998 Justin T. Gibbs. 7 * Copyright (c) 1994, 1995, 1996, 1997, 1998 Justin T. Gibbs.
8 * All rights reserved. 8 * All rights reserved.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice immediately at the beginning of the file, without modification, 14 * notice immediately at the beginning of the file, without modification,
@@ -100,27 +100,27 @@ @@ -100,27 +100,27 @@
100 * by looking in "EISA i/o space" for 284X controllers. 100 * by looking in "EISA i/o space" for 284X controllers.
101 * 101 *
102 * This relies heavily on i/o port accounting. We also just use the 102 * This relies heavily on i/o port accounting. We also just use the
103 * EISA macros for everything ... it's a real waste to redefine them. 103 * EISA macros for everything ... it's a real waste to redefine them.
104 * 104 *
105 * Note: there isn't any #ifdef for FreeBSD in this file, since the 105 * Note: there isn't any #ifdef for FreeBSD in this file, since the
106 * FreeBSD EISA driver handles all cases of the 284X. 106 * FreeBSD EISA driver handles all cases of the 284X.
107 * 107 *
108 * -- Jason R. Thorpe <thorpej@NetBSD.org> 108 * -- Jason R. Thorpe <thorpej@NetBSD.org>
109 * July 12, 1996 109 * July 12, 1996
110 */ 110 */
111 111
112#include <sys/cdefs.h> 112#include <sys/cdefs.h>
113__KERNEL_RCSID(0, "$NetBSD: ahc_isa.c,v 1.36 2009/05/04 12:14:31 cegger Exp $"); 113__KERNEL_RCSID(0, "$NetBSD: ahc_isa.c,v 1.37 2009/05/05 09:51:23 cegger Exp $");
114 114
115#include <sys/param.h> 115#include <sys/param.h>
116#include <sys/systm.h> 116#include <sys/systm.h>
117#include <sys/kernel.h> 117#include <sys/kernel.h>
118#include <sys/device.h> 118#include <sys/device.h>
119#include <sys/queue.h> 119#include <sys/queue.h>
120#include <sys/malloc.h> 120#include <sys/malloc.h>
121#include <sys/reboot.h> 121#include <sys/reboot.h>
122 122
123#include <machine/bus.h> 123#include <machine/bus.h>
124#include <machine/intr.h> 124#include <machine/intr.h>
125 125
126#include <dev/scsipi/scsi_all.h> 126#include <dev/scsipi/scsi_all.h>
@@ -157,27 +157,27 @@ __KERNEL_RCSID(0, "$NetBSD: ahc_isa.c,v  @@ -157,27 +157,27 @@ __KERNEL_RCSID(0, "$NetBSD: ahc_isa.c,v
157 * AHC_ISA_PRIMING register values (write) 157 * AHC_ISA_PRIMING register values (write)
158 */ 158 */
159#define AHC_ISA_PRIMING_VID(index) (AHC_ISA_VID + (index)) 159#define AHC_ISA_PRIMING_VID(index) (AHC_ISA_VID + (index))
160#define AHC_ISA_PRIMING_PID(index) (AHC_ISA_PID + (index)) 160#define AHC_ISA_PRIMING_PID(index) (AHC_ISA_PID + (index))
161 161
162int ahc_isa_idstring(bus_space_tag_t, bus_space_handle_t, char *); 162int ahc_isa_idstring(bus_space_tag_t, bus_space_handle_t, char *);
163int ahc_isa_match(struct isa_attach_args *, bus_addr_t); 163int ahc_isa_match(struct isa_attach_args *, bus_addr_t);
164 164
165int ahc_isa_probe(device_t, cfdata_t, void *); 165int ahc_isa_probe(device_t, cfdata_t, void *);
166void ahc_isa_attach(device_t, device_t, void *); 166void ahc_isa_attach(device_t, device_t, void *);
167void aha2840_load_seeprom(struct ahc_softc *ahc); 167void aha2840_load_seeprom(struct ahc_softc *ahc);
168static int verify_seeprom_cksum(struct seeprom_config *sc); 168static int verify_seeprom_cksum(struct seeprom_config *sc);
169 169
170CFATTACH_DECL(ahc_isa, sizeof(struct ahc_softc), 170CFATTACH_DECL_NEW(ahc_isa, sizeof(struct ahc_softc),
171 ahc_isa_probe, ahc_isa_attach, NULL, NULL); 171 ahc_isa_probe, ahc_isa_attach, NULL, NULL);
172 172
173/* 173/*
174 * This keeps track of which slots are to be checked next if the 174 * This keeps track of which slots are to be checked next if the
175 * iobase locator is a wildcard. A simple static variable isn't enough, 175 * iobase locator is a wildcard. A simple static variable isn't enough,
176 * since it's conceivable that a system might have more than one ISA 176 * since it's conceivable that a system might have more than one ISA
177 * bus. 177 * bus.
178 * 178 *
179 * The "bus" member is the unit number of the parent ISA bus, e.g. "0" 179 * The "bus" member is the unit number of the parent ISA bus, e.g. "0"
180 * for "isa0". 180 * for "isa0".
181 */ 181 */
182struct ahc_isa_slot { 182struct ahc_isa_slot {
183 LIST_ENTRY(ahc_isa_slot) link; 183 LIST_ENTRY(ahc_isa_slot) link;
@@ -361,26 +361,27 @@ ahc_isa_probe(device_t parent, cfdata_t  @@ -361,26 +361,27 @@ ahc_isa_probe(device_t parent, cfdata_t
361 361
362void 362void
363ahc_isa_attach(device_t parent, device_t self, void *aux) 363ahc_isa_attach(device_t parent, device_t self, void *aux)
364{ 364{
365 struct ahc_softc *ahc = device_private(self); 365 struct ahc_softc *ahc = device_private(self);
366 struct isa_attach_args *ia = aux; 366 struct isa_attach_args *ia = aux;
367 bus_space_tag_t iot = ia->ia_iot; 367 bus_space_tag_t iot = ia->ia_iot;
368 bus_space_handle_t ioh; 368 bus_space_handle_t ioh;
369 int irq, intrtype; 369 int irq, intrtype;
370 const char *intrtypestr; 370 const char *intrtypestr;
371 char idstring[EISA_IDSTRINGLEN]; 371 char idstring[EISA_IDSTRINGLEN];
372 u_char intdef; 372 u_char intdef;
373 373
 374 ahc->sc_dev = self;
374 aprint_naive(": SCSI controller\n"); 375 aprint_naive(": SCSI controller\n");
375 376
376 if (bus_space_map(iot, ia->ia_io[0].ir_addr, ia->ia_io[0].ir_size, 377 if (bus_space_map(iot, ia->ia_io[0].ir_addr, ia->ia_io[0].ir_size,
377 0, &ioh)) { 378 0, &ioh)) {
378 aprint_error(": can't map i/o space\n"); 379 aprint_error(": can't map i/o space\n");
379 return; 380 return;
380 } 381 }
381 if (!ahc_isa_idstring(iot, ioh, idstring)) { 382 if (!ahc_isa_idstring(iot, ioh, idstring)) {
382 aprint_error(": can't read ID string\n"); 383 aprint_error(": can't read ID string\n");
383 goto free_io; 384 goto free_io;
384 } 385 }
385 if ((irq = ahc_aic77xx_irq(iot, ioh)) < 0) { 386 if ((irq = ahc_aic77xx_irq(iot, ioh)) < 0) {
386 aprint_error(": ahc_aic77xx_irq failed\n"); 387 aprint_error(": ahc_aic77xx_irq failed\n");
@@ -392,27 +393,27 @@ ahc_isa_attach(device_t parent, device_t @@ -392,27 +393,27 @@ ahc_isa_attach(device_t parent, device_t
392 } else if (strcmp(idstring, "ADP7757") == 0) { 393 } else if (strcmp(idstring, "ADP7757") == 0) {
393 aprint_normal(": %s\n", EISA_PRODUCT_ADP7757); 394 aprint_normal(": %s\n", EISA_PRODUCT_ADP7757);
394 } else { 395 } else {
395 aprint_error(": unknown device type %s\n", idstring); 396 aprint_error(": unknown device type %s\n", idstring);
396 goto free_io; 397 goto free_io;
397 } 398 }
398 399
399 /* 400 /*
400 * Tell the bus-DMA interface that we can do 32bit DMA 401 * Tell the bus-DMA interface that we can do 32bit DMA
401 * NOTE: this variable is first referenced in ahc_init(). 402 * NOTE: this variable is first referenced in ahc_init().
402 */ 403 */
403 ahc->sc_dmaflags = ISABUS_DMA_32BIT; 404 ahc->sc_dmaflags = ISABUS_DMA_32BIT;
404 405
405 ahc_set_name(ahc, device_xname(&ahc->sc_dev)); 406 ahc_set_name(ahc, device_xname(ahc->sc_dev));
406 ahc->parent_dmat = ia->ia_dmat; 407 ahc->parent_dmat = ia->ia_dmat;
407 ahc->channel = 'A'; 408 ahc->channel = 'A';
408 ahc->chip = AHC_AIC7770|AHC_VL; 409 ahc->chip = AHC_AIC7770|AHC_VL;
409 ahc->features = AHC_AIC7770_FE; 410 ahc->features = AHC_AIC7770_FE;
410 ahc->bugs |= AHC_TMODE_WIDEODD_BUG; 411 ahc->bugs |= AHC_TMODE_WIDEODD_BUG;
411 ahc->flags |= AHC_PAGESCBS; 412 ahc->flags |= AHC_PAGESCBS;
412 ahc->tag = iot; 413 ahc->tag = iot;
413 ahc->bsh = ioh; 414 ahc->bsh = ioh;
414 415
415 if (ahc_softc_init(ahc) != 0) 416 if (ahc_softc_init(ahc) != 0)
416 goto free_io; 417 goto free_io;
417 418
418 ahc_intr_enable(ahc, false); 419 ahc_intr_enable(ahc, false);
@@ -422,37 +423,37 @@ ahc_isa_attach(device_t parent, device_t @@ -422,37 +423,37 @@ ahc_isa_attach(device_t parent, device_t
422 423
423 intdef = bus_space_read_1(iot, ioh, INTDEF); 424 intdef = bus_space_read_1(iot, ioh, INTDEF);
424 425
425 if (intdef & EDGE_TRIG) { 426 if (intdef & EDGE_TRIG) {
426 intrtype = IST_EDGE; 427 intrtype = IST_EDGE;
427 intrtypestr = "edge triggered"; 428 intrtypestr = "edge triggered";
428 } else { 429 } else {
429 intrtype = IST_LEVEL; 430 intrtype = IST_LEVEL;
430 intrtypestr = "level sensitive"; 431 intrtypestr = "level sensitive";
431 } 432 }
432 ahc->ih = isa_intr_establish(ia->ia_ic, irq, 433 ahc->ih = isa_intr_establish(ia->ia_ic, irq,
433 intrtype, IPL_BIO, ahc_intr, ahc); 434 intrtype, IPL_BIO, ahc_intr, ahc);
434 if (ahc->ih == NULL) { 435 if (ahc->ih == NULL) {
435 aprint_error_dev(&ahc->sc_dev, "couldn't establish %s interrupt\n", 436 aprint_error_dev(ahc->sc_dev, "couldn't establish %s interrupt\n",
436 intrtypestr); 437 intrtypestr);
437 goto free_io; 438 goto free_io;
438 } 439 }
439 440
440 /* 441 /*
441 * Tell the user what type of interrupts we're using. 442 * Tell the user what type of interrupts we're using.
442 * usefull for debugging irq problems 443 * usefull for debugging irq problems
443 */ 444 */
444 if (bootverbose) { 445 if (bootverbose) {
445 aprint_verbose_dev(&ahc->sc_dev, "Using %s interrupts\n", 446 aprint_verbose_dev(ahc->sc_dev, "Using %s interrupts\n",
446 intrtypestr); 447 intrtypestr);
447 } 448 }
448 449
449 /* 450 /*
450 * Now that we know we own the resources we need, do the  451 * Now that we know we own the resources we need, do the
451 * card initialization. 452 * card initialization.
452 */ 453 */
453 aha2840_load_seeprom(ahc); 454 aha2840_load_seeprom(ahc);
454 455
455 /* Attach sub-devices */ 456 /* Attach sub-devices */
456 if (ahc_aic77xx_attach(ahc) == 0) 457 if (ahc_aic77xx_attach(ahc) == 0)
457 return; /* succeed */ 458 return; /* succeed */
458 459

cvs diff -r1.26 -r1.27 src/sys/dev/cardbus/ahc_cardbus.c (expand / switch to unified diff)

--- src/sys/dev/cardbus/ahc_cardbus.c 2009/03/14 15:36:16 1.26
+++ src/sys/dev/cardbus/ahc_cardbus.c 2009/05/05 09:51:23 1.27
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: ahc_cardbus.c,v 1.26 2009/03/14 15:36:16 dsl Exp $ */ 1/* $NetBSD: ahc_cardbus.c,v 1.27 2009/05/05 09:51:23 cegger Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2000, 2005 The NetBSD Foundation, Inc. 4 * Copyright (c) 2000, 2005 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, 8 * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
9 * NASA Ames Research Center. 9 * NASA Ames Research Center.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions 12 * modification, are permitted provided that the following conditions
13 * are met: 13 * are met:
14 * 1. Redistributions of source code must retain the above copyright 14 * 1. Redistributions of source code must retain the above copyright
@@ -28,27 +28,27 @@ @@ -28,27 +28,27 @@
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE. 30 * POSSIBILITY OF SUCH DAMAGE.
31 */ 31 */
32 32
33/* 33/*
34 * CardBus front-end for the Adaptec AIC-7xxx family of SCSI controllers. 34 * CardBus front-end for the Adaptec AIC-7xxx family of SCSI controllers.
35 * 35 *
36 * TODO: 36 * TODO:
37 * - power management 37 * - power management
38 */ 38 */
39 39
40#include <sys/cdefs.h> 40#include <sys/cdefs.h>
41__KERNEL_RCSID(0, "$NetBSD: ahc_cardbus.c,v 1.26 2009/03/14 15:36:16 dsl Exp $"); 41__KERNEL_RCSID(0, "$NetBSD: ahc_cardbus.c,v 1.27 2009/05/05 09:51:23 cegger Exp $");
42 42
43#include "opt_ahc_cardbus.h" 43#include "opt_ahc_cardbus.h"
44 44
45#include <sys/param.h> 45#include <sys/param.h>
46#include <sys/systm.h> 46#include <sys/systm.h>
47#include <sys/malloc.h> 47#include <sys/malloc.h>
48#include <sys/kernel.h> 48#include <sys/kernel.h>
49#include <sys/queue.h> 49#include <sys/queue.h>
50#include <sys/device.h> 50#include <sys/device.h>
51 51
52#include <sys/bus.h> 52#include <sys/bus.h>
53#include <sys/intr.h> 53#include <sys/intr.h>
54 54
@@ -75,64 +75,63 @@ __KERNEL_RCSID(0, "$NetBSD: ahc_cardbus. @@ -75,64 +75,63 @@ __KERNEL_RCSID(0, "$NetBSD: ahc_cardbus.
75struct ahc_cardbus_softc { 75struct ahc_cardbus_softc {
76 struct ahc_softc sc_ahc; /* real AHC */ 76 struct ahc_softc sc_ahc; /* real AHC */
77 77
78 /* CardBus-specific goo. */ 78 /* CardBus-specific goo. */
79 cardbus_devfunc_t sc_ct; /* our CardBus devfuncs */ 79 cardbus_devfunc_t sc_ct; /* our CardBus devfuncs */
80 cardbus_intr_line_t sc_intrline; /* our interrupt line */ 80 cardbus_intr_line_t sc_intrline; /* our interrupt line */
81 cardbustag_t sc_tag; 81 cardbustag_t sc_tag;
82 82
83 int sc_cbenable; /* what CardBus access type to enable */ 83 int sc_cbenable; /* what CardBus access type to enable */
84 int sc_csr; /* CSR bits */ 84 int sc_csr; /* CSR bits */
85 bus_size_t sc_size; 85 bus_size_t sc_size;
86}; 86};
87 87
88int ahc_cardbus_match(struct device *, struct cfdata *, void *); 88int ahc_cardbus_match(device_t, cfdata_t, void *);
89void ahc_cardbus_attach(struct device *, struct device *, void *); 89void ahc_cardbus_attach(device_t, device_t, void *);
90int ahc_cardbus_detach(struct device *, int); 90int ahc_cardbus_detach(device_t, int);
91int ahc_activate(struct device *self, enum devact act); 91int ahc_activate(device_t self, enum devact act);
92 92
93CFATTACH_DECL(ahc_cardbus, sizeof(struct ahc_cardbus_softc), 93CFATTACH_DECL_NEW(ahc_cardbus, sizeof(struct ahc_cardbus_softc),
94 ahc_cardbus_match, ahc_cardbus_attach, ahc_cardbus_detach, ahc_activate); 94 ahc_cardbus_match, ahc_cardbus_attach, ahc_cardbus_detach, ahc_activate);
95 95
96int 96int
97ahc_cardbus_match(struct device *parent, struct cfdata *match, 97ahc_cardbus_match(device_t parent, cfdata_t match, void *aux)
98 void *aux) 
99{ 98{
100 struct cardbus_attach_args *ca = aux; 99 struct cardbus_attach_args *ca = aux;
101 100
102 if (CARDBUS_VENDOR(ca->ca_id) == PCI_VENDOR_ADP && 101 if (CARDBUS_VENDOR(ca->ca_id) == PCI_VENDOR_ADP &&
103 CARDBUS_PRODUCT(ca->ca_id) == PCI_PRODUCT_ADP_APA1480) 102 CARDBUS_PRODUCT(ca->ca_id) == PCI_PRODUCT_ADP_APA1480)
104 return (1); 103 return (1);
105 104
106 return (0); 105 return (0);
107} 106}
108 107
109void 108void
110ahc_cardbus_attach(struct device *parent, struct device *self, 109ahc_cardbus_attach(device_t parent, device_t self, void *aux)
111 void *aux) 
112{ 110{
113 struct cardbus_attach_args *ca = aux; 111 struct cardbus_attach_args *ca = aux;
114 struct ahc_cardbus_softc *csc = device_private(self); 112 struct ahc_cardbus_softc *csc = device_private(self);
115 struct ahc_softc *ahc = &csc->sc_ahc; 113 struct ahc_softc *ahc = &csc->sc_ahc;
116 cardbus_devfunc_t ct = ca->ca_ct; 114 cardbus_devfunc_t ct = ca->ca_ct;
117 cardbus_chipset_tag_t cc = ct->ct_cc; 115 cardbus_chipset_tag_t cc = ct->ct_cc;
118 cardbus_function_tag_t cf = ct->ct_cf; 116 cardbus_function_tag_t cf = ct->ct_cf;
119 bus_space_tag_t bst; 117 bus_space_tag_t bst;
120 bus_space_handle_t bsh; 118 bus_space_handle_t bsh;
121 pcireg_t reg; 119 pcireg_t reg;
122 u_int sxfrctl1 = 0; 120 u_int sxfrctl1 = 0;
123 u_char sblkctl; 121 u_char sblkctl;
124 122
125 123
 124 ahc->sc_dev = self;
126 csc->sc_ct = ct; 125 csc->sc_ct = ct;
127 csc->sc_tag = ca->ca_tag; 126 csc->sc_tag = ca->ca_tag;
128 csc->sc_intrline = ca->ca_intrline; 127 csc->sc_intrline = ca->ca_intrline;
129 128
130 printf(": Adaptec ADP-1480 SCSI\n"); 129 printf(": Adaptec ADP-1480 SCSI\n");
131 130
132 /* 131 /*
133 * Map the device. 132 * Map the device.
134 */ 133 */
135 csc->sc_csr = PCI_COMMAND_MASTER_ENABLE; 134 csc->sc_csr = PCI_COMMAND_MASTER_ENABLE;
136 if (Cardbus_mapreg_map(csc->sc_ct, AHC_CARDBUS_MMBA, 135 if (Cardbus_mapreg_map(csc->sc_ct, AHC_CARDBUS_MMBA,
137 PCI_MAPREG_TYPE_MEM|PCI_MAPREG_MEM_TYPE_32BIT, 0, 136 PCI_MAPREG_TYPE_MEM|PCI_MAPREG_MEM_TYPE_32BIT, 0,
138 &bst, &bsh, NULL, &csc->sc_size) == 0) { 137 &bst, &bsh, NULL, &csc->sc_size) == 0) {
@@ -159,27 +158,27 @@ ahc_cardbus_attach(struct device *parent @@ -159,27 +158,27 @@ ahc_cardbus_attach(struct device *parent
159 cardbus_conf_write(cc, cf, ca->ca_tag, PCI_COMMAND_STATUS_REG, reg); 158 cardbus_conf_write(cc, cf, ca->ca_tag, PCI_COMMAND_STATUS_REG, reg);
160 159
161 /* 160 /*
162 * Make sure the latency timer is set to some reasonable 161 * Make sure the latency timer is set to some reasonable
163 * value. 162 * value.
164 */ 163 */
165 reg = cardbus_conf_read(cc, cf, ca->ca_tag, PCI_BHLC_REG); 164 reg = cardbus_conf_read(cc, cf, ca->ca_tag, PCI_BHLC_REG);
166 if (PCI_LATTIMER(reg) < 0x20) { 165 if (PCI_LATTIMER(reg) < 0x20) {
167 reg &= ~(PCI_LATTIMER_MASK << PCI_LATTIMER_SHIFT); 166 reg &= ~(PCI_LATTIMER_MASK << PCI_LATTIMER_SHIFT);
168 reg |= (0x20 << PCI_LATTIMER_SHIFT); 167 reg |= (0x20 << PCI_LATTIMER_SHIFT);
169 cardbus_conf_write(cc, cf, ca->ca_tag, PCI_BHLC_REG, reg); 168 cardbus_conf_write(cc, cf, ca->ca_tag, PCI_BHLC_REG, reg);
170 } 169 }
171 170
172 ahc_set_name(ahc, device_xname(&ahc->sc_dev)); 171 ahc_set_name(ahc, device_xname(ahc->sc_dev));
173 172
174 ahc->parent_dmat = ca->ca_dmat; 173 ahc->parent_dmat = ca->ca_dmat;
175 ahc->tag = bst; 174 ahc->tag = bst;
176 ahc->bsh = bsh; 175 ahc->bsh = bsh;
177 176
178 /* 177 /*
179 * ADP-1480 is always an AIC-7860. 178 * ADP-1480 is always an AIC-7860.
180 */ 179 */
181 ahc->chip = AHC_AIC7860 | AHC_PCI; 180 ahc->chip = AHC_AIC7860 | AHC_PCI;
182 ahc->features = AHC_AIC7860_FE|AHC_REMOVABLE; 181 ahc->features = AHC_AIC7860_FE|AHC_REMOVABLE;
183 ahc->bugs |= AHC_TMODE_WIDEODD_BUG|AHC_CACHETHEN_BUG|AHC_PCI_MWI_BUG; 182 ahc->bugs |= AHC_TMODE_WIDEODD_BUG|AHC_CACHETHEN_BUG|AHC_PCI_MWI_BUG;
184 if (PCI_REVISION(ca->ca_class) >= 1) 183 if (PCI_REVISION(ca->ca_class) >= 1)
185 ahc->bugs |= AHC_PCI_2_1_RETRY_BUG; 184 ahc->bugs |= AHC_PCI_2_1_RETRY_BUG;
@@ -247,27 +246,27 @@ ahc_cardbus_attach(struct device *parent @@ -247,27 +246,27 @@ ahc_cardbus_attach(struct device *parent
247 */ 246 */
248 if ((sxfrctl1 & STPWEN) != 0) 247 if ((sxfrctl1 & STPWEN) != 0)
249 ahc->flags |= AHC_TERM_ENB_A; 248 ahc->flags |= AHC_TERM_ENB_A;
250 249
251 if (ahc_init(ahc)) { 250 if (ahc_init(ahc)) {
252 ahc_free(ahc); 251 ahc_free(ahc);
253 return; 252 return;
254 } 253 }
255 254
256 ahc_attach(ahc); 255 ahc_attach(ahc);
257} 256}
258 257
259int 258int
260ahc_cardbus_detach(struct device *self, int flags) 259ahc_cardbus_detach(device_t self, int flags)
261{ 260{
262 struct ahc_cardbus_softc *csc = device_private(self); 261 struct ahc_cardbus_softc *csc = device_private(self);
263 struct ahc_softc *ahc = &csc->sc_ahc; 262 struct ahc_softc *ahc = &csc->sc_ahc;
264 263
265 int rv; 264 int rv;
266 265
267 rv = ahc_detach((void *)ahc, flags); 266 rv = ahc_detach((void *)ahc, flags);
268 if (rv) 267 if (rv)
269 return rv; 268 return rv;
270 269
271 if (ahc->ih) { 270 if (ahc->ih) {
272 cardbus_intr_disestablish(csc->sc_ct->ct_cc, 271 cardbus_intr_disestablish(csc->sc_ct->ct_cc,
273 csc->sc_ct->ct_cf, ahc->ih); 272 csc->sc_ct->ct_cf, ahc->ih);
@@ -279,29 +278,29 @@ ahc_cardbus_detach(struct device *self,  @@ -279,29 +278,29 @@ ahc_cardbus_detach(struct device *self,
279 Cardbus_mapreg_unmap(csc->sc_ct, AHC_CARDBUS_MMBA, 278 Cardbus_mapreg_unmap(csc->sc_ct, AHC_CARDBUS_MMBA,
280 ahc->tag, ahc->bsh, csc->sc_size); 279 ahc->tag, ahc->bsh, csc->sc_size);
281 else if (csc->sc_cbenable == CARDBUS_IO_ENABLE) 280 else if (csc->sc_cbenable == CARDBUS_IO_ENABLE)
282 Cardbus_mapreg_unmap(csc->sc_ct, AHC_CARDBUS_IOBA, 281 Cardbus_mapreg_unmap(csc->sc_ct, AHC_CARDBUS_IOBA,
283 ahc->tag, ahc->bsh, csc->sc_size); 282 ahc->tag, ahc->bsh, csc->sc_size);
284 csc->sc_cbenable = 0; 283 csc->sc_cbenable = 0;
285 } 284 }
286 285
287 return (0); 286 return (0);
288} 287}
289 288
290 289
291int 290int
292ahc_activate(struct device *self, enum devact act) 291ahc_activate(device_t self, enum devact act)
293{ 292{
294 struct ahc_cardbus_softc *csc = (void*)self; 293 struct ahc_cardbus_softc *csc = device_private(self);
295 struct ahc_softc *ahc = &csc->sc_ahc; 294 struct ahc_softc *ahc = &csc->sc_ahc;
296 int s, rv = 0; 295 int s, rv = 0;
297 296
298 s = splhigh(); 297 s = splhigh();
299 switch (act) { 298 switch (act) {
300 case DVACT_ACTIVATE: 299 case DVACT_ACTIVATE:
301 rv = EOPNOTSUPP; 300 rv = EOPNOTSUPP;
302 break; 301 break;
303 302
304 case DVACT_DEACTIVATE: 303 case DVACT_DEACTIVATE:
305 if (ahc->sc_child != NULL) 304 if (ahc->sc_child != NULL)
306 rv = config_deactivate(ahc->sc_child); 305 rv = config_deactivate(ahc->sc_child);
307 break; 306 break;

cvs diff -r1.36 -r1.37 src/sys/dev/eisa/ahc_eisa.c (expand / switch to unified diff)

--- src/sys/dev/eisa/ahc_eisa.c 2008/04/06 08:54:43 1.36
+++ src/sys/dev/eisa/ahc_eisa.c 2009/05/05 09:51:23 1.37
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: ahc_eisa.c,v 1.36 2008/04/06 08:54:43 cegger Exp $ */ 1/* $NetBSD: ahc_eisa.c,v 1.37 2009/05/05 09:51:23 cegger Exp $ */
2 2
3/* 3/*
4 * Product specific probe and attach routines for: 4 * Product specific probe and attach routines for:
5 * 274X and aic7770 motherboard SCSI controllers 5 * 274X and aic7770 motherboard SCSI controllers
6 * 6 *
7 * Copyright (c) 1994, 1995, 1996, 1997, 1998 Justin T. Gibbs. 7 * Copyright (c) 1994, 1995, 1996, 1997, 1998 Justin T. Gibbs.
8 * All rights reserved. 8 * All rights reserved.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice immediately at the beginning of the file, without modification, 14 * notice immediately at the beginning of the file, without modification,
@@ -22,171 +22,172 @@ @@ -22,171 +22,172 @@
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR 22 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
23 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE. 29 * SUCH DAMAGE.
30 * 30 *
31 * $FreeBSD: src/sys/dev/aic7xxx/ahc_eisa.c,v 1.15 2000/01/29 14:22:19 peter Exp $ 31 * $FreeBSD: src/sys/dev/aic7xxx/ahc_eisa.c,v 1.15 2000/01/29 14:22:19 peter Exp $
32 */ 32 */
33 33
34#include <sys/cdefs.h> 34#include <sys/cdefs.h>
35__KERNEL_RCSID(0, "$NetBSD: ahc_eisa.c,v 1.36 2008/04/06 08:54:43 cegger Exp $"); 35__KERNEL_RCSID(0, "$NetBSD: ahc_eisa.c,v 1.37 2009/05/05 09:51:23 cegger Exp $");
36 36
37#include <sys/param.h> 37#include <sys/param.h>
38#include <sys/systm.h> 38#include <sys/systm.h>
39#include <sys/kernel.h> 39#include <sys/kernel.h>
40#include <sys/device.h> 40#include <sys/device.h>
41#include <sys/reboot.h> 41#include <sys/reboot.h>
42 42
43#include <sys/bus.h> 43#include <sys/bus.h>
44#include <sys/intr.h> 44#include <sys/intr.h>
45 45
46#include <dev/scsipi/scsi_all.h> 46#include <dev/scsipi/scsi_all.h>
47#include <dev/scsipi/scsipi_all.h> 47#include <dev/scsipi/scsipi_all.h>
48#include <dev/scsipi/scsiconf.h> 48#include <dev/scsipi/scsiconf.h>
49 49
50#include <dev/eisa/eisareg.h> 50#include <dev/eisa/eisareg.h>
51#include <dev/eisa/eisavar.h> 51#include <dev/eisa/eisavar.h>
52#include <dev/eisa/eisadevs.h> 52#include <dev/eisa/eisadevs.h>
53 53
54#include <dev/ic/aic7xxx_osm.h> 54#include <dev/ic/aic7xxx_osm.h>
55#include <dev/ic/aic7xxx_inline.h> 55#include <dev/ic/aic7xxx_inline.h>
56#include <dev/ic/aic77xxreg.h> 56#include <dev/ic/aic77xxreg.h>
57#include <dev/ic/aic77xxvar.h> 57#include <dev/ic/aic77xxvar.h>
58 58
59static int ahc_eisa_match(struct device *, struct cfdata *, void *); 59static int ahc_eisa_match(device_t, cfdata_t, void *);
60static void ahc_eisa_attach(struct device *, struct device *, void *); 60static void ahc_eisa_attach(device_t, device_t, void *);
61 61
62 62
63CFATTACH_DECL(ahc_eisa, sizeof(struct ahc_softc), 63CFATTACH_DECL_NEW(ahc_eisa, sizeof(struct ahc_softc),
64 ahc_eisa_match, ahc_eisa_attach, NULL, NULL); 64 ahc_eisa_match, ahc_eisa_attach, NULL, NULL);
65 65
66/* 66/*
67 * Check the slots looking for a board we recognise 67 * Check the slots looking for a board we recognise
68 * If we find one, note it's address (slot) and call 68 * If we find one, note it's address (slot) and call
69 * the actual probe routine to check it out. 69 * the actual probe routine to check it out.
70 */ 70 */
71static int 71static int
72ahc_eisa_match(struct device *parent, struct cfdata *match, 72ahc_eisa_match(device_t parent, cfdata_t match, void *aux)
73 void *aux) 
74{ 73{
75 struct eisa_attach_args *ea = aux; 74 struct eisa_attach_args *ea = aux;
76 bus_space_tag_t iot = ea->ea_iot; 75 bus_space_tag_t iot = ea->ea_iot;
77 bus_space_handle_t ioh; 76 bus_space_handle_t ioh;
78 int irq; 77 int irq;
79 78
80 /* must match one of our known ID strings */ 79 /* must match one of our known ID strings */
81 if (strcmp(ea->ea_idstring, "ADP7770") && 80 if (strcmp(ea->ea_idstring, "ADP7770") &&
82 strcmp(ea->ea_idstring, "ADP7771")) 81 strcmp(ea->ea_idstring, "ADP7771"))
83 return (0); 82 return (0);
84 83
85 if (bus_space_map(iot, EISA_SLOT_ADDR(ea->ea_slot) + 84 if (bus_space_map(iot, EISA_SLOT_ADDR(ea->ea_slot) +
86 AHC_EISA_SLOT_OFFSET, AHC_EISA_IOSIZE, 0, &ioh)) 85 AHC_EISA_SLOT_OFFSET, AHC_EISA_IOSIZE, 0, &ioh))
87 return (0); 86 return (0);
88 87
89 irq = ahc_aic77xx_irq(iot, ioh); 88 irq = ahc_aic77xx_irq(iot, ioh);
90 89
91 bus_space_unmap(iot, ioh, AHC_EISA_IOSIZE); 90 bus_space_unmap(iot, ioh, AHC_EISA_IOSIZE);
92 91
93 return (irq >= 0); 92 return (irq >= 0);
94} 93}
95 94
96static void 95static void
97ahc_eisa_attach(struct device *parent, struct device *self, void *aux) 96ahc_eisa_attach(device_t parent, device_t self, void *aux)
98{ 97{
99 struct ahc_softc *ahc = device_private(self); 98 struct ahc_softc *ahc = device_private(self);
100 struct eisa_attach_args *ea = aux; 99 struct eisa_attach_args *ea = aux;
101 eisa_chipset_tag_t ec = ea->ea_ec; 100 eisa_chipset_tag_t ec = ea->ea_ec;
102 eisa_intr_handle_t ih; 101 eisa_intr_handle_t ih;
103 bus_space_tag_t iot = ea->ea_iot; 102 bus_space_tag_t iot = ea->ea_iot;
104 bus_space_handle_t ioh; 103 bus_space_handle_t ioh;
105 int irq, intrtype; 104 int irq, intrtype;
106 const char *intrstr, *intrtypestr; 105 const char *intrstr, *intrtypestr;
107 u_int biosctrl; 106 u_int biosctrl;
108 u_int scsiconf; 107 u_int scsiconf;
109 u_int scsiconf1; 108 u_int scsiconf1;
110 u_char intdef; 109 u_char intdef;
111#ifdef AHC_DEBUG 110#ifdef AHC_DEBUG
112 int i; 111 int i;
113#endif 112#endif
114 113
 114 ahc->sc_dev = self;
 115
115 if (bus_space_map(iot, EISA_SLOT_ADDR(ea->ea_slot) + 116 if (bus_space_map(iot, EISA_SLOT_ADDR(ea->ea_slot) +
116 AHC_EISA_SLOT_OFFSET, AHC_EISA_IOSIZE, 0, &ioh)) { 117 AHC_EISA_SLOT_OFFSET, AHC_EISA_IOSIZE, 0, &ioh)) {
117 aprint_error_dev(&ahc->sc_dev, "could not map I/O addresses"); 118 aprint_error_dev(ahc->sc_dev, "could not map I/O addresses");
118 return; 119 return;
119 } 120 }
120 if ((irq = ahc_aic77xx_irq(iot, ioh)) < 0) { 121 if ((irq = ahc_aic77xx_irq(iot, ioh)) < 0) {
121 aprint_error_dev(&ahc->sc_dev, "ahc_aic77xx_irq failed!"); 122 aprint_error_dev(ahc->sc_dev, "ahc_aic77xx_irq failed!");
122 goto free_io; 123 goto free_io;
123 } 124 }
124 125
125 if (strcmp(ea->ea_idstring, "ADP7770") == 0) { 126 if (strcmp(ea->ea_idstring, "ADP7770") == 0) {
126 printf(": %s\n", EISA_PRODUCT_ADP7770); 127 printf(": %s\n", EISA_PRODUCT_ADP7770);
127 } else if (strcmp(ea->ea_idstring, "ADP7771") == 0) { 128 } else if (strcmp(ea->ea_idstring, "ADP7771") == 0) {
128 printf(": %s\n", EISA_PRODUCT_ADP7771); 129 printf(": %s\n", EISA_PRODUCT_ADP7771);
129 } else { 130 } else {
130 printf(": Unknown device type %s", ea->ea_idstring); 131 printf(": Unknown device type %s", ea->ea_idstring);
131 goto free_io; 132 goto free_io;
132 } 133 }
133 134
134 ahc_set_name(ahc, device_xname(&ahc->sc_dev)); 135 ahc_set_name(ahc, device_xname(ahc->sc_dev));
135 ahc->parent_dmat = ea->ea_dmat; 136 ahc->parent_dmat = ea->ea_dmat;
136 ahc->chip = AHC_AIC7770|AHC_EISA; 137 ahc->chip = AHC_AIC7770|AHC_EISA;
137 ahc->features = AHC_AIC7770_FE; 138 ahc->features = AHC_AIC7770_FE;
138 ahc->flags = AHC_PAGESCBS; 139 ahc->flags = AHC_PAGESCBS;
139 ahc->bugs = AHC_TMODE_WIDEODD_BUG; 140 ahc->bugs = AHC_TMODE_WIDEODD_BUG;
140 ahc->tag = iot; 141 ahc->tag = iot;
141 ahc->bsh = ioh; 142 ahc->bsh = ioh;
142 ahc->channel = 'A'; 143 ahc->channel = 'A';
143 144
144 if (ahc_softc_init(ahc) != 0) 145 if (ahc_softc_init(ahc) != 0)
145 goto free_io; 146 goto free_io;
146 147
147 ahc_intr_enable(ahc, FALSE); 148 ahc_intr_enable(ahc, FALSE);
148 149
149 if (ahc_reset(ahc) != 0) 150 if (ahc_reset(ahc) != 0)
150 goto free_io; 151 goto free_io;
151 152
152 if (eisa_intr_map(ec, irq, &ih)) { 153 if (eisa_intr_map(ec, irq, &ih)) {
153 aprint_error_dev(&ahc->sc_dev, "couldn't map interrupt (%d)\n", 154 aprint_error_dev(ahc->sc_dev, "couldn't map interrupt (%d)\n",
154 irq); 155 irq);
155 goto free_io; 156 goto free_io;
156 } 157 }
157 158
158 intdef = bus_space_read_1(iot, ioh, INTDEF); 159 intdef = bus_space_read_1(iot, ioh, INTDEF);
159 160
160 if (intdef & EDGE_TRIG) { 161 if (intdef & EDGE_TRIG) {
161 intrtype = IST_EDGE; 162 intrtype = IST_EDGE;
162 intrtypestr = "edge triggered"; 163 intrtypestr = "edge triggered";
163 } else { 164 } else {
164 intrtype = IST_LEVEL; 165 intrtype = IST_LEVEL;
165 intrtypestr = "level sensitive"; 166 intrtypestr = "level sensitive";
166 } 167 }
167 intrstr = eisa_intr_string(ec, ih); 168 intrstr = eisa_intr_string(ec, ih);
168 ahc->ih = eisa_intr_establish(ec, ih, 169 ahc->ih = eisa_intr_establish(ec, ih,
169 intrtype, IPL_BIO, ahc_intr, ahc); 170 intrtype, IPL_BIO, ahc_intr, ahc);
170 if (ahc->ih == NULL) { 171 if (ahc->ih == NULL) {
171 aprint_error_dev(&ahc->sc_dev, "couldn't establish %s interrupt", 172 aprint_error_dev(ahc->sc_dev, "couldn't establish %s interrupt",
172 intrtypestr); 173 intrtypestr);
173 if (intrstr != NULL) 174 if (intrstr != NULL)
174 printf(" at %s", intrstr); 175 printf(" at %s", intrstr);
175 printf("\n"); 176 printf("\n");
176 goto free_io; 177 goto free_io;
177 } 178 }
178 if (intrstr != NULL) 179 if (intrstr != NULL)
179 printf("%s: %s interrupting at %s\n", device_xname(&ahc->sc_dev), 180 printf("%s: %s interrupting at %s\n", device_xname(ahc->sc_dev),
180 intrtypestr, intrstr); 181 intrtypestr, intrstr);
181 182
182 /* 183 /*
183 * Now that we know we own the resources we need, do the 184 * Now that we know we own the resources we need, do the
184 * card initialization. 185 * card initialization.
185 * 186 *
186 * First, the aic7770 card specific setup. 187 * First, the aic7770 card specific setup.
187 */ 188 */
188 biosctrl = ahc_inb(ahc, HA_274_BIOSCTRL); 189 biosctrl = ahc_inb(ahc, HA_274_BIOSCTRL);
189 scsiconf = ahc_inb(ahc, SCSICONF); 190 scsiconf = ahc_inb(ahc, SCSICONF);
190 scsiconf1 = ahc_inb(ahc, SCSICONF + 1); 191 scsiconf1 = ahc_inb(ahc, SCSICONF + 1);
191 192
192#ifdef AHC_DEBUG 193#ifdef AHC_DEBUG

cvs diff -r1.27 -r1.28 src/sys/dev/ic/aic7xxx_osm.c (expand / switch to unified diff)

--- src/sys/dev/ic/aic7xxx_osm.c 2008/04/08 12:07:25 1.27
+++ src/sys/dev/ic/aic7xxx_osm.c 2009/05/05 09:51:24 1.28
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: aic7xxx_osm.c,v 1.27 2008/04/08 12:07:25 cegger Exp $ */ 1/* $NetBSD: aic7xxx_osm.c,v 1.28 2009/05/05 09:51:24 cegger Exp $ */
2 2
3/* 3/*
4 * Bus independent FreeBSD shim for the aic7xxx based adaptec SCSI controllers 4 * Bus independent FreeBSD shim for the aic7xxx based adaptec SCSI controllers
5 * 5 *
6 * Copyright (c) 1994-2001 Justin T. Gibbs. 6 * Copyright (c) 1994-2001 Justin T. Gibbs.
7 * All rights reserved. 7 * All rights reserved.
8 * 8 *
9 * Redistribution and use in source and binary forms, with or without 9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions 10 * modification, are permitted provided that the following conditions
11 * are met: 11 * are met:
12 * 1. Redistributions of source code must retain the above copyright 12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions, and the following disclaimer, 13 * notice, this list of conditions, and the following disclaimer,
14 * without modification. 14 * without modification.
@@ -29,27 +29,27 @@ @@ -29,27 +29,27 @@
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE. 31 * SUCH DAMAGE.
32 * 32 *
33 * //depot/aic7xxx/freebsd/dev/aic7xxx/aic7xxx_osm.c#12 $ 33 * //depot/aic7xxx/freebsd/dev/aic7xxx/aic7xxx_osm.c#12 $
34 * 34 *
35 * $FreeBSD: src/sys/dev/aic7xxx/aic7xxx_osm.c,v 1.31 2002/11/30 19:08:58 scottl Exp $ 35 * $FreeBSD: src/sys/dev/aic7xxx/aic7xxx_osm.c,v 1.31 2002/11/30 19:08:58 scottl Exp $
36 */ 36 */
37/* 37/*
38 * Ported from FreeBSD by Pascal Renauld, Network Storage Solutions, Inc. - April 2003 38 * Ported from FreeBSD by Pascal Renauld, Network Storage Solutions, Inc. - April 2003
39 */ 39 */
40 40
41#include <sys/cdefs.h> 41#include <sys/cdefs.h>
42__KERNEL_RCSID(0, "$NetBSD: aic7xxx_osm.c,v 1.27 2008/04/08 12:07:25 cegger Exp $"); 42__KERNEL_RCSID(0, "$NetBSD: aic7xxx_osm.c,v 1.28 2009/05/05 09:51:24 cegger Exp $");
43 43
44#include <dev/ic/aic7xxx_osm.h> 44#include <dev/ic/aic7xxx_osm.h>
45#include <dev/ic/aic7xxx_inline.h> 45#include <dev/ic/aic7xxx_inline.h>
46 46
47#ifndef AHC_TMODE_ENABLE 47#ifndef AHC_TMODE_ENABLE
48#define AHC_TMODE_ENABLE 0 48#define AHC_TMODE_ENABLE 0
49#endif 49#endif
50 50
51 51
52static void ahc_action(struct scsipi_channel *chan, scsipi_adapter_req_t req, void *arg); 52static void ahc_action(struct scsipi_channel *chan, scsipi_adapter_req_t req, void *arg);
53static void ahc_execute_scb(void *arg, bus_dma_segment_t *dm_segs, int nsegments); 53static void ahc_execute_scb(void *arg, bus_dma_segment_t *dm_segs, int nsegments);
54static int ahc_poll(struct ahc_softc *ahc, int wait); 54static int ahc_poll(struct ahc_softc *ahc, int wait);
55static void ahc_setup_data(struct ahc_softc *ahc, 55static void ahc_setup_data(struct ahc_softc *ahc,
@@ -66,64 +66,64 @@ static int ahc_ioctl(struct scsipi_chann @@ -66,64 +66,64 @@ static int ahc_ioctl(struct scsipi_chann
66int 66int
67ahc_attach(struct ahc_softc *ahc) 67ahc_attach(struct ahc_softc *ahc)
68{ 68{
69 u_long s; 69 u_long s;
70 int i; 70 int i;
71 char ahc_info[256]; 71 char ahc_info[256];
72 72
73 LIST_INIT(&ahc->pending_scbs); 73 LIST_INIT(&ahc->pending_scbs);
74 for (i = 0; i < AHC_NUM_TARGETS; i++) 74 for (i = 0; i < AHC_NUM_TARGETS; i++)
75 TAILQ_INIT(&ahc->untagged_queues[i]); 75 TAILQ_INIT(&ahc->untagged_queues[i]);
76 76
77 ahc_lock(ahc, &s); 77 ahc_lock(ahc, &s);
78 78
79 ahc->sc_adapter.adapt_dev = &ahc->sc_dev; 79 ahc->sc_adapter.adapt_dev = ahc->sc_dev;
80 ahc->sc_adapter.adapt_nchannels = (ahc->features & AHC_TWIN) ? 2 : 1; 80 ahc->sc_adapter.adapt_nchannels = (ahc->features & AHC_TWIN) ? 2 : 1;
81 81
82 ahc->sc_adapter.adapt_openings = ahc->scb_data->numscbs - 1; 82 ahc->sc_adapter.adapt_openings = ahc->scb_data->numscbs - 1;
83 ahc->sc_adapter.adapt_max_periph = 16; 83 ahc->sc_adapter.adapt_max_periph = 16;
84 84
85 ahc->sc_adapter.adapt_ioctl = ahc_ioctl; 85 ahc->sc_adapter.adapt_ioctl = ahc_ioctl;
86 ahc->sc_adapter.adapt_minphys = ahc_minphys; 86 ahc->sc_adapter.adapt_minphys = ahc_minphys;
87 ahc->sc_adapter.adapt_request = ahc_action; 87 ahc->sc_adapter.adapt_request = ahc_action;
88 88
89 ahc->sc_channel.chan_adapter = &ahc->sc_adapter; 89 ahc->sc_channel.chan_adapter = &ahc->sc_adapter;
90 ahc->sc_channel.chan_bustype = &scsi_bustype; 90 ahc->sc_channel.chan_bustype = &scsi_bustype;
91 ahc->sc_channel.chan_channel = 0; 91 ahc->sc_channel.chan_channel = 0;
92 ahc->sc_channel.chan_ntargets = (ahc->features & AHC_WIDE) ? 16 : 8; 92 ahc->sc_channel.chan_ntargets = (ahc->features & AHC_WIDE) ? 16 : 8;
93 ahc->sc_channel.chan_nluns = 8 /*AHC_NUM_LUNS*/; 93 ahc->sc_channel.chan_nluns = 8 /*AHC_NUM_LUNS*/;
94 ahc->sc_channel.chan_id = ahc->our_id; 94 ahc->sc_channel.chan_id = ahc->our_id;
95 ahc->sc_channel.chan_flags |= SCSIPI_CHAN_CANGROW; 95 ahc->sc_channel.chan_flags |= SCSIPI_CHAN_CANGROW;
96 96
97 if (ahc->features & AHC_TWIN) { 97 if (ahc->features & AHC_TWIN) {
98 ahc->sc_channel_b = ahc->sc_channel; 98 ahc->sc_channel_b = ahc->sc_channel;
99 ahc->sc_channel_b.chan_id = ahc->our_id_b; 99 ahc->sc_channel_b.chan_id = ahc->our_id_b;
100 ahc->sc_channel_b.chan_channel = 1; 100 ahc->sc_channel_b.chan_channel = 1;
101 } 101 }
102 102
103 ahc_controller_info(ahc, ahc_info, sizeof(ahc_info)); 103 ahc_controller_info(ahc, ahc_info, sizeof(ahc_info));
104 printf("%s: %s\n", device_xname(&ahc->sc_dev), ahc_info); 104 printf("%s: %s\n", device_xname(ahc->sc_dev), ahc_info);
105 105
106 if ((ahc->flags & AHC_PRIMARY_CHANNEL) == 0) { 106 if ((ahc->flags & AHC_PRIMARY_CHANNEL) == 0) {
107 ahc->sc_child = config_found((void *)&ahc->sc_dev, 107 ahc->sc_child = config_found(ahc->sc_dev,
108 &ahc->sc_channel, scsiprint); 108 &ahc->sc_channel, scsiprint);
109 if (ahc->features & AHC_TWIN) 109 if (ahc->features & AHC_TWIN)
110 ahc->sc_child_b = config_found((void *)&ahc->sc_dev, 110 ahc->sc_child_b = config_found(ahc->sc_dev,
111 &ahc->sc_channel_b, scsiprint); 111 &ahc->sc_channel_b, scsiprint);
112 } else { 112 } else {
113 if (ahc->features & AHC_TWIN) 113 if (ahc->features & AHC_TWIN)
114 ahc->sc_child = config_found((void *)&ahc->sc_dev, 114 ahc->sc_child = config_found(ahc->sc_dev,
115 &ahc->sc_channel_b, scsiprint); 115 &ahc->sc_channel_b, scsiprint);
116 ahc->sc_child_b = config_found((void *)&ahc->sc_dev, 116 ahc->sc_child_b = config_found(ahc->sc_dev,
117 &ahc->sc_channel, scsiprint); 117 &ahc->sc_channel, scsiprint);
118 } 118 }
119 119
120 ahc_intr_enable(ahc, TRUE); 120 ahc_intr_enable(ahc, TRUE);
121 121
122 if (ahc->flags & AHC_RESET_BUS_A) 122 if (ahc->flags & AHC_RESET_BUS_A)
123 ahc_reset_channel(ahc, 'A', TRUE); 123 ahc_reset_channel(ahc, 'A', TRUE);
124 if ((ahc->features & AHC_TWIN) && ahc->flags & AHC_RESET_BUS_B) 124 if ((ahc->features & AHC_TWIN) && ahc->flags & AHC_RESET_BUS_B)
125 ahc_reset_channel(ahc, 'B', TRUE); 125 ahc_reset_channel(ahc, 'B', TRUE);
126 126
127 ahc_unlock(ahc, &s); 127 ahc_unlock(ahc, &s);
128 return (1); 128 return (1);
129} 129}

cvs diff -r1.21 -r1.22 src/sys/dev/ic/aic7xxx_osm.h (expand / switch to unified diff)

--- src/sys/dev/ic/aic7xxx_osm.h 2009/03/15 15:52:12 1.21
+++ src/sys/dev/ic/aic7xxx_osm.h 2009/05/05 09:51:24 1.22
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: aic7xxx_osm.h,v 1.21 2009/03/15 15:52:12 cegger Exp $ */ 1/* $NetBSD: aic7xxx_osm.h,v 1.22 2009/05/05 09:51:24 cegger Exp $ */
2 2
3/* 3/*
4 * NetBSD platform specific driver option settings, data structures, 4 * NetBSD platform specific driver option settings, data structures,
5 * function declarations and includes. 5 * function declarations and includes.
6 * 6 *
7 * Copyright (c) 1994-2001 Justin T. Gibbs. 7 * Copyright (c) 1994-2001 Justin T. Gibbs.
8 * All rights reserved. 8 * All rights reserved.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions, and the following disclaimer, 14 * notice, this list of conditions, and the following disclaimer,
@@ -498,27 +498,27 @@ typedef enum @@ -498,27 +498,27 @@ typedef enum
498void ahc_power_state_change(struct ahc_softc *, ahc_power_state); 498void ahc_power_state_change(struct ahc_softc *, ahc_power_state);
499#endif 499#endif
500/******************************** VL/EISA *************************************/ 500/******************************** VL/EISA *************************************/
501int aic7770_map_registers(struct ahc_softc *, u_int); 501int aic7770_map_registers(struct ahc_softc *, u_int);
502int aic7770_map_int(struct ahc_softc *, int); 502int aic7770_map_int(struct ahc_softc *, int);
503 503
504/********************************* Debug **************************************/ 504/********************************* Debug **************************************/
505static __inline void ahc_print_path(struct ahc_softc *, struct scb *); 505static __inline void ahc_print_path(struct ahc_softc *, struct scb *);
506static __inline void ahc_platform_dump_card_state(struct ahc_softc *); 506static __inline void ahc_platform_dump_card_state(struct ahc_softc *);
507 507
508static __inline void 508static __inline void
509ahc_print_path(struct ahc_softc *ahc, struct scb *scb) 509ahc_print_path(struct ahc_softc *ahc, struct scb *scb)
510{ 510{
511 printf("%s:", device_xname(&ahc->sc_dev)); 511 printf("%s:", device_xname(ahc->sc_dev));
512} 512}
513 513
514static __inline void 514static __inline void
515ahc_platform_dump_card_state(struct ahc_softc *ahc) 515ahc_platform_dump_card_state(struct ahc_softc *ahc)
516{ 516{
517} 517}
518/**************************** Transfer Settings *******************************/ 518/**************************** Transfer Settings *******************************/
519void ahc_notify_xfer_settings_change(struct ahc_softc *, 519void ahc_notify_xfer_settings_change(struct ahc_softc *,
520 struct ahc_devinfo *); 520 struct ahc_devinfo *);
521void ahc_platform_set_tags(struct ahc_softc *, struct ahc_devinfo *, int); 521void ahc_platform_set_tags(struct ahc_softc *, struct ahc_devinfo *, int);
522 522
523/************************* Initialization/Teardown ****************************/ 523/************************* Initialization/Teardown ****************************/
524int ahc_platform_alloc(struct ahc_softc *, void *); 524int ahc_platform_alloc(struct ahc_softc *, void *);

cvs diff -r1.55 -r1.56 src/sys/dev/ic/aic7xxxvar.h (expand / switch to unified diff)

--- src/sys/dev/ic/aic7xxxvar.h 2008/02/11 21:43:46 1.55
+++ src/sys/dev/ic/aic7xxxvar.h 2009/05/05 09:51:24 1.56
@@ -27,27 +27,27 @@ @@ -27,27 +27,27 @@
27 * NO WARRANTY 27 * NO WARRANTY
28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
29 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 29 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR 30 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
31 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 31 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
32 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 32 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
33 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 33 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
34 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 34 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
35 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 35 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
36 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 36 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
37 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 37 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
38 * POSSIBILITY OF SUCH DAMAGES. 38 * POSSIBILITY OF SUCH DAMAGES.
39 * 39 *
40 * $Id: aic7xxxvar.h,v 1.55 2008/02/11 21:43:46 dyoung Exp $ 40 * $Id: aic7xxxvar.h,v 1.56 2009/05/05 09:51:24 cegger Exp $
41 * 41 *
42 * $FreeBSD: /repoman/r/ncvs/src/sys/dev/aic7xxx/aic7xxx.h,v 1.44 2003/01/20 20:44:55 gibbs Exp $ 42 * $FreeBSD: /repoman/r/ncvs/src/sys/dev/aic7xxx/aic7xxx.h,v 1.44 2003/01/20 20:44:55 gibbs Exp $
43 */ 43 */
44/* 44/*
45 * Ported from FreeBSD by Pascal Renauld, Network Storage Solutions, Inc. - April 2003 45 * Ported from FreeBSD by Pascal Renauld, Network Storage Solutions, Inc. - April 2003
46 */ 46 */
47 47
48#ifndef _AIC7XXXVAR_H_ 48#ifndef _AIC7XXXVAR_H_
49#define _AIC7XXXVAR_H_ 49#define _AIC7XXXVAR_H_
50 50
51#undef AHC_DEBUG 51#undef AHC_DEBUG
52 52
53/* Register Definitions */ 53/* Register Definitions */
@@ -1010,27 +1010,27 @@ struct ahc_suspend_state { @@ -1010,27 +1010,27 @@ struct ahc_suspend_state {
1010 /* hsmailbox */ 1010 /* hsmailbox */
1011 uint8_t crccontrol1; 1011 uint8_t crccontrol1;
1012 uint8_t scbbaddr; 1012 uint8_t scbbaddr;
1013 /* Host and sequencer SCB counts */ 1013 /* Host and sequencer SCB counts */
1014 uint8_t dff_thrsh; 1014 uint8_t dff_thrsh;
1015 uint8_t *scratch_ram; 1015 uint8_t *scratch_ram;
1016 uint8_t *btt; 1016 uint8_t *btt;
1017}; 1017};
1018 1018
1019typedef void (*ahc_bus_intr_t)(struct ahc_softc *); 1019typedef void (*ahc_bus_intr_t)(struct ahc_softc *);
1020typedef void ahc_callback_t (void *); 1020typedef void ahc_callback_t (void *);
1021 1021
1022struct ahc_softc { 1022struct ahc_softc {
1023 struct device sc_dev; 1023 device_t sc_dev;
1024 1024
1025 struct scsipi_channel sc_channel; 1025 struct scsipi_channel sc_channel;
1026 struct scsipi_channel sc_channel_b; 1026 struct scsipi_channel sc_channel_b;
1027 struct device * sc_child; 1027 struct device * sc_child;
1028 struct device * sc_child_b; 1028 struct device * sc_child_b;
1029 struct scsipi_adapter sc_adapter; 1029 struct scsipi_adapter sc_adapter;
1030 1030
1031 bus_space_tag_t tag; 1031 bus_space_tag_t tag;
1032 bus_space_handle_t bsh; 1032 bus_space_handle_t bsh;
1033 1033
1034#ifndef __linux__ 1034#ifndef __linux__
1035 bus_dma_tag_t buffer_dmat; /* dmat for buffer I/O */ 1035 bus_dma_tag_t buffer_dmat; /* dmat for buffer I/O */
1036#endif 1036#endif

cvs diff -r1.64 -r1.65 src/sys/dev/pci/ahc_pci.c (expand / switch to unified diff)

--- src/sys/dev/pci/ahc_pci.c 2009/01/03 03:43:22 1.64
+++ src/sys/dev/pci/ahc_pci.c 2009/05/05 09:51:24 1.65
@@ -29,38 +29,38 @@ @@ -29,38 +29,38 @@
29 * NO WARRANTY 29 * NO WARRANTY
30 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 30 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
31 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 31 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
32 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR 32 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
33 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 33 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
34 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 34 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
35 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 35 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
36 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 36 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
37 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 37 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
38 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 38 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
39 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 39 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
40 * POSSIBILITY OF SUCH DAMAGES. 40 * POSSIBILITY OF SUCH DAMAGES.
41 * 41 *
42 * $Id: ahc_pci.c,v 1.64 2009/01/03 03:43:22 yamt Exp $ 42 * $Id: ahc_pci.c,v 1.65 2009/05/05 09:51:24 cegger Exp $
43 * 43 *
44 * //depot/aic7xxx/aic7xxx/aic7xxx_pci.c#57 $ 44 * //depot/aic7xxx/aic7xxx/aic7xxx_pci.c#57 $
45 * 45 *
46 * $FreeBSD: /repoman/r/ncvs/src/sys/dev/aic7xxx/aic7xxx_pci.c,v 1.22 2003/01/20 20:44:55 gibbs Exp $ 46 * $FreeBSD: /repoman/r/ncvs/src/sys/dev/aic7xxx/aic7xxx_pci.c,v 1.22 2003/01/20 20:44:55 gibbs Exp $
47 */ 47 */
48/* 48/*
49 * Ported from FreeBSD by Pascal Renauld, Network Storage Solutions, Inc. - April 2003 49 * Ported from FreeBSD by Pascal Renauld, Network Storage Solutions, Inc. - April 2003
50 */ 50 */
51 51
52#include <sys/cdefs.h> 52#include <sys/cdefs.h>
53__KERNEL_RCSID(0, "$NetBSD: ahc_pci.c,v 1.64 2009/01/03 03:43:22 yamt Exp $"); 53__KERNEL_RCSID(0, "$NetBSD: ahc_pci.c,v 1.65 2009/05/05 09:51:24 cegger Exp $");
54 54
55#include <sys/param.h> 55#include <sys/param.h>
56#include <sys/systm.h> 56#include <sys/systm.h>
57#include <sys/malloc.h> 57#include <sys/malloc.h>
58#include <sys/kernel.h> 58#include <sys/kernel.h>
59#include <sys/queue.h> 59#include <sys/queue.h>
60#include <sys/device.h> 60#include <sys/device.h>
61#include <sys/reboot.h> 61#include <sys/reboot.h>
62 62
63#include <sys/bus.h> 63#include <sys/bus.h>
64#include <sys/intr.h> 64#include <sys/intr.h>
65 65
66#include <dev/pci/pcireg.h> 66#include <dev/pci/pcireg.h>
@@ -774,27 +774,28 @@ ahc_pci_attach(device_t parent, device_t @@ -774,27 +774,28 @@ ahc_pci_attach(device_t parent, device_t
774 bus_space_tag_t st, iot; 774 bus_space_tag_t st, iot;
775 bus_space_handle_t sh, ioh; 775 bus_space_handle_t sh, ioh;
776#ifdef AHC_ALLOW_MEMIO 776#ifdef AHC_ALLOW_MEMIO
777 int memh_valid; 777 int memh_valid;
778 bus_space_tag_t memt; 778 bus_space_tag_t memt;
779 bus_space_handle_t memh; 779 bus_space_handle_t memh;
780 pcireg_t memtype; 780 pcireg_t memtype;
781#endif 781#endif
782 pci_intr_handle_t ih; 782 pci_intr_handle_t ih;
783 const char *intrstr; 783 const char *intrstr;
784 struct ahc_pci_busdata *bd; 784 struct ahc_pci_busdata *bd;
785 bool override_ultra; 785 bool override_ultra;
786 786
787 ahc_set_name(ahc, device_xname(&ahc->sc_dev)); 787 ahc->sc_dev = self;
 788 ahc_set_name(ahc, device_xname(ahc->sc_dev));
788 ahc->parent_dmat = pa->pa_dmat; 789 ahc->parent_dmat = pa->pa_dmat;
789 790
790 command = pci_conf_read(pa->pa_pc, pa->pa_tag, PCI_COMMAND_STATUS_REG); 791 command = pci_conf_read(pa->pa_pc, pa->pa_tag, PCI_COMMAND_STATUS_REG);
791 subid = pci_conf_read(pa->pa_pc, pa->pa_tag, PCI_SUBSYS_ID_REG); 792 subid = pci_conf_read(pa->pa_pc, pa->pa_tag, PCI_SUBSYS_ID_REG);
792 entry = ahc_find_pci_device(pa->pa_id, subid, pa->pa_function); 793 entry = ahc_find_pci_device(pa->pa_id, subid, pa->pa_function);
793 if (entry == NULL) 794 if (entry == NULL)
794 return; 795 return;
795 printf(": %s\n", entry->name); 796 printf(": %s\n", entry->name);
796 797
797 /* Keep information about the PCI bus */ 798 /* Keep information about the PCI bus */
798 bd = malloc(sizeof (struct ahc_pci_busdata), M_DEVBUF, M_NOWAIT); 799 bd = malloc(sizeof (struct ahc_pci_busdata), M_DEVBUF, M_NOWAIT);
799 if (bd == NULL) { 800 if (bd == NULL) {
800 printf("%s: unable to allocate bus-specific data\n", 801 printf("%s: unable to allocate bus-specific data\n",
@@ -946,27 +947,27 @@ ahc_pci_attach(device_t parent, device_t @@ -946,27 +947,27 @@ ahc_pci_attach(device_t parent, device_t
946 /* Normal mode setup */ 947 /* Normal mode setup */
947 ahc_outb(ahc, CRCCONTROL1, CRCVALCHKEN|CRCENDCHKEN|CRCREQCHKEN 948 ahc_outb(ahc, CRCCONTROL1, CRCVALCHKEN|CRCENDCHKEN|CRCREQCHKEN
948 |TARGCRCENDEN); 949 |TARGCRCENDEN);
949 } 950 }
950 951
951 if (pci_intr_map(pa, &ih)) { 952 if (pci_intr_map(pa, &ih)) {
952 printf("%s: couldn't map interrupt\n", ahc_name(ahc)); 953 printf("%s: couldn't map interrupt\n", ahc_name(ahc));
953 ahc_free(ahc); 954 ahc_free(ahc);
954 return; 955 return;
955 } 956 }
956 intrstr = pci_intr_string(pa->pa_pc, ih); 957 intrstr = pci_intr_string(pa->pa_pc, ih);
957 ahc->ih = pci_intr_establish(pa->pa_pc, ih, IPL_BIO, ahc_intr, ahc); 958 ahc->ih = pci_intr_establish(pa->pa_pc, ih, IPL_BIO, ahc_intr, ahc);
958 if (ahc->ih == NULL) { 959 if (ahc->ih == NULL) {
959 aprint_error_dev(&ahc->sc_dev, 960 aprint_error_dev(ahc->sc_dev,
960 "couldn't establish interrupt\n"); 961 "couldn't establish interrupt\n");
961 if (intrstr != NULL) 962 if (intrstr != NULL)
962 printf(" at %s", intrstr); 963 printf(" at %s", intrstr);
963 printf("\n"); 964 printf("\n");
964 ahc_free(ahc); 965 ahc_free(ahc);
965 return; 966 return;
966 } 967 }
967 if (intrstr != NULL) 968 if (intrstr != NULL)
968 printf("%s: interrupting at %s\n", ahc_name(ahc), intrstr); 969 printf("%s: interrupting at %s\n", ahc_name(ahc), intrstr);
969 970
970 dscommand0 = ahc_inb(ahc, DSCOMMAND0); 971 dscommand0 = ahc_inb(ahc, DSCOMMAND0);
971 dscommand0 |= MPARCKEN|CACHETHEN; 972 dscommand0 |= MPARCKEN|CACHETHEN;
972 if ((ahc->features & AHC_ULTRA2) != 0) { 973 if ((ahc->features & AHC_ULTRA2) != 0) {
@@ -1052,27 +1053,27 @@ ahc_pci_attach(device_t parent, device_t @@ -1052,27 +1053,27 @@ ahc_pci_attach(device_t parent, device_t
1052 prop_bool_t usetd; 1053 prop_bool_t usetd;
1053 1054
1054 printf("%s: Using left over BIOS settings\n", 1055 printf("%s: Using left over BIOS settings\n",
1055 ahc_name(ahc)); 1056 ahc_name(ahc));
1056 ahc->flags &= ~AHC_USEDEFAULTS; 1057 ahc->flags &= ~AHC_USEDEFAULTS;
1057 /* 1058 /*
1058 * Ignore target device settings and use default 1059 * Ignore target device settings and use default
1059 * if BIOS initializes chip's SRAM with some 1060 * if BIOS initializes chip's SRAM with some
1060 * conservative settings (async, no tagged 1061 * conservative settings (async, no tagged
1061 * queuing etc.) and machine dependent device 1062 * queuing etc.) and machine dependent device
1062 * property is set. 1063 * property is set.
1063 */  1064 */
1064 usetd = prop_dictionary_get( 1065 usetd = prop_dictionary_get(
1065 device_properties(&ahc->sc_dev), 1066 device_properties(ahc->sc_dev),
1066 "aic7xxx-use-target-defaults"); 1067 "aic7xxx-use-target-defaults");
1067 if (usetd != NULL) { 1068 if (usetd != NULL) {
1068 KASSERT(prop_object_type(usetd) == 1069 KASSERT(prop_object_type(usetd) ==
1069 PROP_TYPE_BOOL); 1070 PROP_TYPE_BOOL);
1070 if (prop_bool_true(usetd)) 1071 if (prop_bool_true(usetd))
1071 ahc->flags |= AHC_USETARGETDEFAULTS; 1072 ahc->flags |= AHC_USETARGETDEFAULTS;
1072 } 1073 }
1073 ahc->flags |= AHC_BIOS_ENABLED; 1074 ahc->flags |= AHC_BIOS_ENABLED;
1074 } else { 1075 } else {
1075 /* 1076 /*
1076 * Assume only one connector and always turn 1077 * Assume only one connector and always turn
1077 * on termination. 1078 * on termination.
1078 */ 1079 */
@@ -1130,27 +1131,27 @@ ahc_pci_suspend(device_t dev PMF_FN_ARGS @@ -1130,27 +1131,27 @@ ahc_pci_suspend(device_t dev PMF_FN_ARGS
1130 1131
1131static bool 1132static bool
1132ahc_pci_resume(device_t dev PMF_FN_ARGS) 1133ahc_pci_resume(device_t dev PMF_FN_ARGS)
1133{ 1134{
1134#if 0 1135#if 0
1135 struct ahc_softc *sc = device_private(dev); 1136 struct ahc_softc *sc = device_private(dev);
1136 1137
1137 return (ahc_resume(sc) == 0); 1138 return (ahc_resume(sc) == 0);
1138#else 1139#else
1139 return true; 1140 return true;
1140#endif 1141#endif
1141} 1142}
1142 1143
1143CFATTACH_DECL(ahc_pci, sizeof(struct ahc_softc), 1144CFATTACH_DECL_NEW(ahc_pci, sizeof(struct ahc_softc),
1144 ahc_pci_probe, ahc_pci_attach, NULL, NULL); 1145 ahc_pci_probe, ahc_pci_attach, NULL, NULL);
1145 1146
1146static int 1147static int
1147ahc_9005_subdevinfo_valid(uint16_t device, uint16_t vendor, 1148ahc_9005_subdevinfo_valid(uint16_t device, uint16_t vendor,
1148 uint16_t subdevice, uint16_t subvendor) 1149 uint16_t subdevice, uint16_t subvendor)
1149{ 1150{
1150 int result; 1151 int result;
1151 1152
1152 /* Default to invalid. */ 1153 /* Default to invalid. */
1153 result = 0; 1154 result = 0;
1154 if (vendor == 0x9005 1155 if (vendor == 0x9005
1155 && subvendor == 0x9005 1156 && subvendor == 0x9005
1156 && subdevice != device 1157 && subdevice != device
@@ -1738,27 +1739,27 @@ ahc_aha29160C_setup(struct ahc_softc *ah @@ -1738,27 +1739,27 @@ ahc_aha29160C_setup(struct ahc_softc *ah
1738{ 1739{
1739 int error; 1740 int error;
1740 1741
1741 error = ahc_aic7899_setup(ahc); 1742 error = ahc_aic7899_setup(ahc);
1742 if (error != 0) 1743 if (error != 0)
1743 return (error); 1744 return (error);
1744 ahc->features |= AHC_REMOVABLE; 1745 ahc->features |= AHC_REMOVABLE;
1745 return (0); 1746 return (0);
1746} 1747}
1747 1748
1748static int 1749static int
1749ahc_raid_setup(struct ahc_softc *ahc) 1750ahc_raid_setup(struct ahc_softc *ahc)
1750{ 1751{
1751 aprint_normal_dev(&ahc->sc_dev, "RAID functionality unsupported\n"); 1752 aprint_normal_dev(ahc->sc_dev, "RAID functionality unsupported\n");
1752 return (ENXIO); 1753 return (ENXIO);
1753} 1754}
1754 1755
1755static int 1756static int
1756ahc_aha394XX_setup(struct ahc_softc *ahc) 1757ahc_aha394XX_setup(struct ahc_softc *ahc)
1757{ 1758{
1758 1759
1759 switch (ahc->bd->dev) { 1760 switch (ahc->bd->dev) {
1760 case AHC_394X_SLOT_CHANNEL_A: 1761 case AHC_394X_SLOT_CHANNEL_A:
1761 ahc->channel = 'A'; 1762 ahc->channel = 'A';
1762 break; 1763 break;
1763 case AHC_394X_SLOT_CHANNEL_B: 1764 case AHC_394X_SLOT_CHANNEL_B:
1764 ahc->channel = 'B'; 1765 ahc->channel = 'B';