2 * Product specific probe and attach routines for:
3 * 3940, 2940, aic7895, aic7890, aic7880,
4 * aic7870, aic7860 and aic7850 SCSI controllers
6 * Copyright (c) 1994-2001 Justin T. Gibbs.
7 * Copyright (c) 2000-2001 Adaptec Inc.
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions, and the following disclaimer,
15 * without modification.
16 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
17 * substantially similar to the "NO WARRANTY" disclaimer below
18 * ("Disclaimer") and any redistribution must be conditioned upon
19 * including a substantially similar Disclaimer requirement for further
20 * binary redistribution.
21 * 3. Neither the names of the above-listed copyright holders nor the names
22 * of any contributors may be used to endorse or promote products derived
23 * from this software without specific prior written permission.
25 * Alternatively, this software may be distributed under the terms of the
26 * GNU General Public License ("GPL") version 2 as published by the Free
27 * Software Foundation.
30 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
31 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
32 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
33 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
34 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
35 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
36 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
37 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
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
40 * POSSIBILITY OF SUCH DAMAGES.
42 * $Id: //depot/aic7xxx/aic7xxx/aic7xxx_pci.c#69 $
48 #include "aic7xxx_osm.h"
49 #include "aic7xxx_inline.h"
50 #include "aic7xxx_93cx6.h"
52 #include <dev/aic7xxx/aic7xxx_osm.h>
53 #include <dev/aic7xxx/aic7xxx_inline.h>
54 #include <dev/aic7xxx/aic7xxx_93cx6.h>
57 #include "aic7xxx_pci.h"
59 static __inline
uint64_t
60 ahc_compose_id(u_int device
, u_int vendor
, u_int subdevice
, u_int subvendor
)
66 | ((uint64_t)vendor
<< 32)
67 | ((uint64_t)device
<< 48);
72 #define AHC_PCI_IOADDR PCIR_MAPS /* I/O Address */
73 #define AHC_PCI_MEMADDR (PCIR_MAPS + 4) /* Mem I/O Address */
75 #define DEVID_9005_TYPE(id) ((id) & 0xF)
76 #define DEVID_9005_TYPE_HBA 0x0 /* Standard Card */
77 #define DEVID_9005_TYPE_AAA 0x3 /* RAID Card */
78 #define DEVID_9005_TYPE_SISL 0x5 /* Container ROMB */
79 #define DEVID_9005_TYPE_MB 0xF /* On Motherboard */
81 #define DEVID_9005_MAXRATE(id) (((id) & 0x30) >> 4)
82 #define DEVID_9005_MAXRATE_U160 0x0
83 #define DEVID_9005_MAXRATE_ULTRA2 0x1
84 #define DEVID_9005_MAXRATE_ULTRA 0x2
85 #define DEVID_9005_MAXRATE_FAST 0x3
87 #define DEVID_9005_MFUNC(id) (((id) & 0x40) >> 6)
89 #define DEVID_9005_CLASS(id) (((id) & 0xFF00) >> 8)
90 #define DEVID_9005_CLASS_SPI 0x0 /* Parallel SCSI */
92 #define SUBID_9005_TYPE(id) ((id) & 0xF)
93 #define SUBID_9005_TYPE_MB 0xF /* On Motherboard */
94 #define SUBID_9005_TYPE_CARD 0x0 /* Standard Card */
95 #define SUBID_9005_TYPE_LCCARD 0x1 /* Low Cost Card */
96 #define SUBID_9005_TYPE_RAID 0x3 /* Combined with Raid */
98 #define SUBID_9005_TYPE_KNOWN(id) \
99 ((((id) & 0xF) == SUBID_9005_TYPE_MB) \
100 || (((id) & 0xF) == SUBID_9005_TYPE_CARD) \
101 || (((id) & 0xF) == SUBID_9005_TYPE_LCCARD) \
102 || (((id) & 0xF) == SUBID_9005_TYPE_RAID))
104 #define SUBID_9005_MAXRATE(id) (((id) & 0x30) >> 4)
105 #define SUBID_9005_MAXRATE_ULTRA2 0x0
106 #define SUBID_9005_MAXRATE_ULTRA 0x1
107 #define SUBID_9005_MAXRATE_U160 0x2
108 #define SUBID_9005_MAXRATE_RESERVED 0x3
110 #define SUBID_9005_SEEPTYPE(id) \
111 ((SUBID_9005_TYPE(id) == SUBID_9005_TYPE_MB) \
112 ? ((id) & 0xC0) >> 6 \
113 : ((id) & 0x300) >> 8)
114 #define SUBID_9005_SEEPTYPE_NONE 0x0
115 #define SUBID_9005_SEEPTYPE_1K 0x1
116 #define SUBID_9005_SEEPTYPE_2K_4K 0x2
117 #define SUBID_9005_SEEPTYPE_RESERVED 0x3
118 #define SUBID_9005_AUTOTERM(id) \
119 ((SUBID_9005_TYPE(id) == SUBID_9005_TYPE_MB) \
120 ? (((id) & 0x400) >> 10) == 0 \
121 : (((id) & 0x40) >> 6) == 0)
123 #define SUBID_9005_NUMCHAN(id) \
124 ((SUBID_9005_TYPE(id) == SUBID_9005_TYPE_MB) \
125 ? ((id) & 0x300) >> 8 \
126 : ((id) & 0xC00) >> 10)
128 #define SUBID_9005_LEGACYCONN(id) \
129 ((SUBID_9005_TYPE(id) == SUBID_9005_TYPE_MB) \
131 : ((id) & 0x80) >> 7)
133 #define SUBID_9005_MFUNCENB(id) \
134 ((SUBID_9005_TYPE(id) == SUBID_9005_TYPE_MB) \
135 ? ((id) & 0x800) >> 11 \
136 : ((id) & 0x1000) >> 12)
138 * Informational only. Should use chip register to be
139 * certain, but may be use in identification strings.
141 #define SUBID_9005_CARD_SCSIWIDTH_MASK 0x2000
142 #define SUBID_9005_CARD_PCIWIDTH_MASK 0x4000
143 #define SUBID_9005_CARD_SEDIFF_MASK 0x8000
145 static ahc_device_setup_t ahc_aic785X_setup
;
146 static ahc_device_setup_t ahc_aic7860_setup
;
147 static ahc_device_setup_t ahc_apa1480_setup
;
148 static ahc_device_setup_t ahc_aic7870_setup
;
149 static ahc_device_setup_t ahc_aha394X_setup
;
150 static ahc_device_setup_t ahc_aha494X_setup
;
151 static ahc_device_setup_t ahc_aha398X_setup
;
152 static ahc_device_setup_t ahc_aic7880_setup
;
153 static ahc_device_setup_t ahc_aha2940Pro_setup
;
154 static ahc_device_setup_t ahc_aha394XU_setup
;
155 static ahc_device_setup_t ahc_aha398XU_setup
;
156 static ahc_device_setup_t ahc_aic7890_setup
;
157 static ahc_device_setup_t ahc_aic7892_setup
;
158 static ahc_device_setup_t ahc_aic7895_setup
;
159 static ahc_device_setup_t ahc_aic7896_setup
;
160 static ahc_device_setup_t ahc_aic7899_setup
;
161 static ahc_device_setup_t ahc_aha29160C_setup
;
162 static ahc_device_setup_t ahc_raid_setup
;
163 static ahc_device_setup_t ahc_aha394XX_setup
;
164 static ahc_device_setup_t ahc_aha494XX_setup
;
165 static ahc_device_setup_t ahc_aha398XX_setup
;
167 struct ahc_pci_identity ahc_pci_ident_table
[] =
169 /* aic7850 based controllers */
171 ID_AHA_2902_04_10_15_20C_30C
,
173 "Adaptec 2902/04/10/15/20C/30C SCSI adapter",
176 /* aic7860 based controllers */
180 "Adaptec 2930CU SCSI adapter",
184 ID_AHA_1480A
& ID_DEV_VENDOR_MASK
,
186 "Adaptec 1480A Ultra SCSI adapter",
190 ID_AHA_2940AU_0
& ID_DEV_VENDOR_MASK
,
192 "Adaptec 2940A Ultra SCSI adapter",
196 ID_AHA_2940AU_CN
& ID_DEV_VENDOR_MASK
,
198 "Adaptec 2940A/CN Ultra SCSI adapter",
202 ID_AHA_2930C_VAR
& ID_DEV_VENDOR_MASK
,
204 "Adaptec 2930C Ultra SCSI adapter (VAR)",
207 /* aic7870 based controllers */
211 "Adaptec 2940 SCSI adapter",
217 "Adaptec 3940 SCSI adapter",
223 "Adaptec 398X SCSI RAID adapter",
229 "Adaptec 2944 SCSI adapter",
235 "Adaptec 3944 SCSI adapter",
241 "Adaptec 4944 SCSI adapter",
244 /* aic7880 based controllers */
246 ID_AHA_2940U
& ID_DEV_VENDOR_MASK
,
248 "Adaptec 2940 Ultra SCSI adapter",
252 ID_AHA_3940U
& ID_DEV_VENDOR_MASK
,
254 "Adaptec 3940 Ultra SCSI adapter",
258 ID_AHA_2944U
& ID_DEV_VENDOR_MASK
,
260 "Adaptec 2944 Ultra SCSI adapter",
264 ID_AHA_3944U
& ID_DEV_VENDOR_MASK
,
266 "Adaptec 3944 Ultra SCSI adapter",
270 ID_AHA_398XU
& ID_DEV_VENDOR_MASK
,
272 "Adaptec 398X Ultra SCSI RAID adapter",
277 * XXX Don't know the slot numbers
278 * so we can't identify channels
280 ID_AHA_4944U
& ID_DEV_VENDOR_MASK
,
282 "Adaptec 4944 Ultra SCSI adapter",
286 ID_AHA_2930U
& ID_DEV_VENDOR_MASK
,
288 "Adaptec 2930 Ultra SCSI adapter",
292 ID_AHA_2940U_PRO
& ID_DEV_VENDOR_MASK
,
294 "Adaptec 2940 Pro Ultra SCSI adapter",
298 ID_AHA_2940U_CN
& ID_DEV_VENDOR_MASK
,
300 "Adaptec 2940/CN Ultra SCSI adapter",
303 /* Ignore all SISL (AAC on MB) based controllers. */
310 /* aic7890 based controllers */
314 "Adaptec 2930 Ultra2 SCSI adapter",
320 "Adaptec 2940B Ultra2 SCSI adapter",
326 "Adaptec 2940 Ultra2 SCSI adapter (OEM)",
332 "Adaptec 2940 Ultra2 SCSI adapter",
338 "Adaptec 2950 Ultra2 SCSI adapter",
344 "Adaptec aic7890/91 Ultra2 SCSI adapter (ARO)",
350 "Adaptec AAA-131 Ultra2 RAID adapter",
353 /* aic7892 based controllers */
357 "Adaptec 29160 Ultra160 SCSI adapter",
363 "Adaptec (Compaq OEM) 29160 Ultra160 SCSI adapter",
369 "Adaptec 29160N Ultra160 SCSI adapter",
375 "Adaptec 29160C Ultra160 SCSI adapter",
381 "Adaptec 29160B Ultra160 SCSI adapter",
387 "Adaptec 19160B Ultra160 SCSI adapter",
393 "Adaptec aic7892 Ultra160 SCSI adapter (ARO)",
396 /* aic7895 based controllers */
400 "Adaptec 2940/DUAL Ultra SCSI adapter",
406 "Adaptec 3940A Ultra SCSI adapter",
412 "Adaptec 3944A Ultra SCSI adapter",
418 "Adaptec aic7895 Ultra SCSI adapter (ARO)",
421 /* aic7896/97 based controllers */
425 "Adaptec 3950B Ultra2 SCSI adapter",
431 "Adaptec 3950B Ultra2 SCSI adapter",
437 "Adaptec 3950D Ultra2 SCSI adapter",
443 "Adaptec 3950D Ultra2 SCSI adapter",
449 "Adaptec aic7896/97 Ultra2 SCSI adapter (ARO)",
452 /* aic7899 based controllers */
456 "Adaptec 3960D Ultra160 SCSI adapter",
462 "Adaptec (Compaq OEM) 3960D Ultra160 SCSI adapter",
468 "Adaptec aic7899 Ultra160 SCSI adapter (ARO)",
471 /* Generic chip probes for devices we don't know 'exactly' */
473 ID_AIC7850
& ID_DEV_VENDOR_MASK
,
475 "Adaptec aic7850 SCSI adapter",
479 ID_AIC7855
& ID_DEV_VENDOR_MASK
,
481 "Adaptec aic7855 SCSI adapter",
485 ID_AIC7859
& ID_DEV_VENDOR_MASK
,
487 "Adaptec aic7859 SCSI adapter",
491 ID_AIC7860
& ID_DEV_VENDOR_MASK
,
493 "Adaptec aic7860 Ultra SCSI adapter",
497 ID_AIC7870
& ID_DEV_VENDOR_MASK
,
499 "Adaptec aic7870 SCSI adapter",
503 ID_AIC7880
& ID_DEV_VENDOR_MASK
,
505 "Adaptec aic7880 Ultra SCSI adapter",
509 ID_AIC7890
& ID_9005_GENERIC_MASK
,
510 ID_9005_GENERIC_MASK
,
511 "Adaptec aic7890/91 Ultra2 SCSI adapter",
515 ID_AIC7892
& ID_9005_GENERIC_MASK
,
516 ID_9005_GENERIC_MASK
,
517 "Adaptec aic7892 Ultra160 SCSI adapter",
521 ID_AIC7895
& ID_DEV_VENDOR_MASK
,
523 "Adaptec aic7895 Ultra SCSI adapter",
527 ID_AIC7896
& ID_9005_GENERIC_MASK
,
528 ID_9005_GENERIC_MASK
,
529 "Adaptec aic7896/97 Ultra2 SCSI adapter",
533 ID_AIC7899
& ID_9005_GENERIC_MASK
,
534 ID_9005_GENERIC_MASK
,
535 "Adaptec aic7899 Ultra160 SCSI adapter",
539 ID_AIC7810
& ID_DEV_VENDOR_MASK
,
541 "Adaptec aic7810 RAID memory controller",
545 ID_AIC7815
& ID_DEV_VENDOR_MASK
,
547 "Adaptec aic7815 RAID memory controller",
552 const u_int ahc_num_pci_devs
= NUM_ELEMENTS(ahc_pci_ident_table
);
554 #define AHC_394X_SLOT_CHANNEL_A 4
555 #define AHC_394X_SLOT_CHANNEL_B 5
557 #define AHC_398X_SLOT_CHANNEL_A 4
558 #define AHC_398X_SLOT_CHANNEL_B 8
559 #define AHC_398X_SLOT_CHANNEL_C 12
561 #define AHC_494X_SLOT_CHANNEL_A 4
562 #define AHC_494X_SLOT_CHANNEL_B 5
563 #define AHC_494X_SLOT_CHANNEL_C 6
564 #define AHC_494X_SLOT_CHANNEL_D 7
566 #define DEVCONFIG 0x40
567 #define PCIERRGENDIS 0x80000000ul
568 #define SCBSIZE32 0x00010000ul /* aic789X only */
569 #define REXTVALID 0x00001000ul /* ultra cards only */
570 #define MPORTMODE 0x00000400ul /* aic7870+ only */
571 #define RAMPSM 0x00000200ul /* aic7870+ only */
572 #define VOLSENSE 0x00000100ul
573 #define PCI64BIT 0x00000080ul /* 64Bit PCI bus (Ultra2 Only)*/
574 #define SCBRAMSEL 0x00000080ul
575 #define MRDCEN 0x00000040ul
576 #define EXTSCBTIME 0x00000020ul /* aic7870 only */
577 #define EXTSCBPEN 0x00000010ul /* aic7870 only */
578 #define BERREN 0x00000008ul
579 #define DACEN 0x00000004ul
580 #define STPWLEVEL 0x00000002ul
581 #define DIFACTNEGEN 0x00000001ul /* aic7870 only */
583 #define CSIZE_LATTIME 0x0c
584 #define CACHESIZE 0x0000003ful /* only 5 bits */
585 #define LATTIME 0x0000ff00ul
587 /* PCI STATUS definitions */
595 static int ahc_9005_subdevinfo_valid(uint16_t vendor
, uint16_t device
,
596 uint16_t subvendor
, uint16_t subdevice
);
597 static int ahc_ext_scbram_present(struct ahc_softc
*ahc
);
598 static void ahc_scbram_config(struct ahc_softc
*ahc
, int enable
,
599 int pcheck
, int fast
, int large
);
600 static void ahc_probe_ext_scbram(struct ahc_softc
*ahc
);
601 static void check_extport(struct ahc_softc
*ahc
, u_int
*sxfrctl1
);
602 static void ahc_parse_pci_eeprom(struct ahc_softc
*ahc
,
603 struct seeprom_config
*sc
);
604 static void configure_termination(struct ahc_softc
*ahc
,
605 struct seeprom_descriptor
*sd
,
606 u_int adapter_control
,
609 static void ahc_new_term_detect(struct ahc_softc
*ahc
,
614 int *eeprom_present
);
615 static void aic787X_cable_detect(struct ahc_softc
*ahc
, int *internal50_present
,
616 int *internal68_present
,
617 int *externalcable_present
,
618 int *eeprom_present
);
619 static void aic785X_cable_detect(struct ahc_softc
*ahc
, int *internal50_present
,
620 int *externalcable_present
,
621 int *eeprom_present
);
622 static void write_brdctl(struct ahc_softc
*ahc
, uint8_t value
);
623 static uint8_t read_brdctl(struct ahc_softc
*ahc
);
624 static void ahc_pci_intr(struct ahc_softc
*ahc
);
625 static int ahc_pci_chip_init(struct ahc_softc
*ahc
);
626 static int ahc_pci_suspend(struct ahc_softc
*ahc
);
627 static int ahc_pci_resume(struct ahc_softc
*ahc
);
630 ahc_9005_subdevinfo_valid(uint16_t device
, uint16_t vendor
,
631 uint16_t subdevice
, uint16_t subvendor
)
635 /* Default to invalid. */
638 && subvendor
== 0x9005
639 && subdevice
!= device
640 && SUBID_9005_TYPE_KNOWN(subdevice
) != 0) {
642 switch (SUBID_9005_TYPE(subdevice
)) {
643 case SUBID_9005_TYPE_MB
:
645 case SUBID_9005_TYPE_CARD
:
646 case SUBID_9005_TYPE_LCCARD
:
648 * Currently only trust Adaptec cards to
649 * get the sub device info correct.
651 if (DEVID_9005_TYPE(device
) == DEVID_9005_TYPE_HBA
)
654 case SUBID_9005_TYPE_RAID
:
663 struct ahc_pci_identity
*
664 ahc_find_pci_device(ahc_dev_softc_t pci
)
671 struct ahc_pci_identity
*entry
;
674 vendor
= ahc_pci_read_config(pci
, PCIR_DEVVENDOR
, /*bytes*/2);
675 device
= ahc_pci_read_config(pci
, PCIR_DEVICE
, /*bytes*/2);
676 subvendor
= ahc_pci_read_config(pci
, PCIR_SUBVEND_0
, /*bytes*/2);
677 subdevice
= ahc_pci_read_config(pci
, PCIR_SUBDEV_0
, /*bytes*/2);
678 full_id
= ahc_compose_id(device
, vendor
, subdevice
, subvendor
);
681 * If the second function is not hooked up, ignore it.
682 * Unfortunately, not all MB vendors implement the
683 * subdevice ID as per the Adaptec spec, so do our best
684 * to sanity check it prior to accepting the subdevice
687 if (ahc_get_pci_function(pci
) > 0
688 && ahc_9005_subdevinfo_valid(vendor
, device
, subvendor
, subdevice
)
689 && SUBID_9005_MFUNCENB(subdevice
) == 0)
692 for (i
= 0; i
< ahc_num_pci_devs
; i
++) {
693 entry
= &ahc_pci_ident_table
[i
];
694 if (entry
->full_id
== (full_id
& entry
->id_mask
)) {
695 /* Honor exclusion entries. */
696 if (entry
->name
== NULL
)
705 ahc_pci_config(struct ahc_softc
*ahc
, struct ahc_pci_identity
*entry
)
717 error
= entry
->setup(ahc
);
720 ahc
->chip
|= AHC_PCI
;
721 ahc
->description
= entry
->name
;
723 pci_set_power_state(ahc
->dev_softc
, AHC_POWER_STATE_D0
);
725 error
= ahc_pci_map_registers(ahc
);
730 * Before we continue probing the card, ensure that
731 * its interrupts are *disabled*. We don't want
732 * a misstep to hang the machine in an interrupt
735 ahc_intr_enable(ahc
, FALSE
);
737 devconfig
= ahc_pci_read_config(ahc
->dev_softc
, DEVCONFIG
, /*bytes*/4);
740 * If we need to support high memory, enable dual
741 * address cycles. This bit must be set to enable
742 * high address bit generation even if we are on a
743 * 64bit bus (PCI64BIT set in devconfig).
745 if ((ahc
->flags
& AHC_39BIT_ADDRESSING
) != 0) {
748 printf("%s: Enabling 39Bit Addressing\n",
753 /* Ensure that pci error generation, a test feature, is disabled. */
754 devconfig
|= PCIERRGENDIS
;
756 ahc_pci_write_config(ahc
->dev_softc
, DEVCONFIG
, devconfig
, /*bytes*/4);
758 /* Ensure busmastering is enabled */
759 command
= ahc_pci_read_config(ahc
->dev_softc
, PCIR_COMMAND
, /*bytes*/2);
760 command
|= PCIM_CMD_BUSMASTEREN
;
762 ahc_pci_write_config(ahc
->dev_softc
, PCIR_COMMAND
, command
, /*bytes*/2);
764 /* On all PCI adapters, we allow SCB paging */
765 ahc
->flags
|= AHC_PAGESCBS
;
767 error
= ahc_softc_init(ahc
);
772 * Disable PCI parity error checking. Users typically
773 * do this to work around broken PCI chipsets that get
774 * the parity timing wrong and thus generate lots of spurious
775 * errors. The chip only allows us to disable *all* parity
776 * error reporting when doing this, so CIO bus, scb ram, and
777 * scratch ram parity errors will be ignored too.
779 if ((ahc
->flags
& AHC_DISABLE_PCI_PERR
) != 0)
780 ahc
->seqctl
|= FAILDIS
;
782 ahc
->bus_intr
= ahc_pci_intr
;
783 ahc
->bus_chip_init
= ahc_pci_chip_init
;
784 ahc
->bus_suspend
= ahc_pci_suspend
;
785 ahc
->bus_resume
= ahc_pci_resume
;
787 /* Remeber how the card was setup in case there is no SEEPROM */
788 if ((ahc_inb(ahc
, HCNTRL
) & POWRDN
) == 0) {
790 if ((ahc
->features
& AHC_ULTRA2
) != 0)
791 our_id
= ahc_inb(ahc
, SCSIID_ULTRA2
) & OID
;
793 our_id
= ahc_inb(ahc
, SCSIID
) & OID
;
794 sxfrctl1
= ahc_inb(ahc
, SXFRCTL1
) & STPWEN
;
795 scsiseq
= ahc_inb(ahc
, SCSISEQ
);
802 error
= ahc_reset(ahc
, /*reinit*/FALSE
);
806 if ((ahc
->features
& AHC_DT
) != 0) {
809 /* Perform ALT-Mode Setup */
810 sfunct
= ahc_inb(ahc
, SFUNCT
) & ~ALT_MODE
;
811 ahc_outb(ahc
, SFUNCT
, sfunct
| ALT_MODE
);
812 ahc_outb(ahc
, OPTIONMODE
,
813 OPTIONMODE_DEFAULTS
|AUTOACKEN
|BUSFREEREV
|EXPPHASEDIS
);
814 ahc_outb(ahc
, SFUNCT
, sfunct
);
816 /* Normal mode setup */
817 ahc_outb(ahc
, CRCCONTROL1
, CRCVALCHKEN
|CRCENDCHKEN
|CRCREQCHKEN
821 dscommand0
= ahc_inb(ahc
, DSCOMMAND0
);
822 dscommand0
|= MPARCKEN
|CACHETHEN
;
823 if ((ahc
->features
& AHC_ULTRA2
) != 0) {
826 * DPARCKEN doesn't work correctly on
827 * some MBs so don't use it.
829 dscommand0
&= ~DPARCKEN
;
833 * Handle chips that must have cache line
834 * streaming (dis/en)abled.
836 if ((ahc
->bugs
& AHC_CACHETHEN_DIS_BUG
) != 0)
837 dscommand0
|= CACHETHEN
;
839 if ((ahc
->bugs
& AHC_CACHETHEN_BUG
) != 0)
840 dscommand0
&= ~CACHETHEN
;
842 ahc_outb(ahc
, DSCOMMAND0
, dscommand0
);
845 ahc_pci_read_config(ahc
->dev_softc
, CSIZE_LATTIME
,
846 /*bytes*/1) & CACHESIZE
;
847 ahc
->pci_cachesize
*= 4;
849 if ((ahc
->bugs
& AHC_PCI_2_1_RETRY_BUG
) != 0
850 && ahc
->pci_cachesize
== 4) {
852 ahc_pci_write_config(ahc
->dev_softc
, CSIZE_LATTIME
,
854 ahc
->pci_cachesize
= 0;
858 * We cannot perform ULTRA speeds without the presense
859 * of the external precision resistor.
861 if ((ahc
->features
& AHC_ULTRA
) != 0) {
864 devconfig
= ahc_pci_read_config(ahc
->dev_softc
,
865 DEVCONFIG
, /*bytes*/4);
866 if ((devconfig
& REXTVALID
) == 0)
867 ahc
->features
&= ~AHC_ULTRA
;
870 /* See if we have a SEEPROM and perform auto-term */
871 check_extport(ahc
, &sxfrctl1
);
874 * Take the LED out of diagnostic mode
876 sblkctl
= ahc_inb(ahc
, SBLKCTL
);
877 ahc_outb(ahc
, SBLKCTL
, (sblkctl
& ~(DIAGLEDEN
|DIAGLEDON
)));
879 if ((ahc
->features
& AHC_ULTRA2
) != 0) {
880 ahc_outb(ahc
, DFF_THRSH
, RD_DFTHRSH_MAX
|WR_DFTHRSH_MAX
);
882 ahc_outb(ahc
, DSPCISTATUS
, DFTHRSH_100
);
885 if (ahc
->flags
& AHC_USEDEFAULTS
) {
887 * PCI Adapter default setup
888 * Should only be used if the adapter does not have
891 /* See if someone else set us up already */
892 if ((ahc
->flags
& AHC_NO_BIOS_INIT
) == 0
894 printf("%s: Using left over BIOS settings\n",
896 ahc
->flags
&= ~AHC_USEDEFAULTS
;
897 ahc
->flags
|= AHC_BIOS_ENABLED
;
900 * Assume only one connector and always turn
906 ahc_outb(ahc
, SCSICONF
, our_id
|ENSPCHK
|RESET_SCSI
);
908 ahc
->our_id
= our_id
;
912 * Take a look to see if we have external SRAM.
913 * We currently do not attempt to use SRAM that is
914 * shared among multiple controllers.
916 ahc_probe_ext_scbram(ahc
);
919 * Record our termination setting for the
920 * generic initialization routine.
922 if ((sxfrctl1
& STPWEN
) != 0)
923 ahc
->flags
|= AHC_TERM_ENB_A
;
926 * Save chip register configuration data for chip resets
927 * that occur during runtime and resume events.
929 ahc
->bus_softc
.pci_softc
.devconfig
=
930 ahc_pci_read_config(ahc
->dev_softc
, DEVCONFIG
, /*bytes*/4);
931 ahc
->bus_softc
.pci_softc
.command
=
932 ahc_pci_read_config(ahc
->dev_softc
, PCIR_COMMAND
, /*bytes*/1);
933 ahc
->bus_softc
.pci_softc
.csize_lattime
=
934 ahc_pci_read_config(ahc
->dev_softc
, CSIZE_LATTIME
, /*bytes*/1);
935 ahc
->bus_softc
.pci_softc
.dscommand0
= ahc_inb(ahc
, DSCOMMAND0
);
936 ahc
->bus_softc
.pci_softc
.dspcistatus
= ahc_inb(ahc
, DSPCISTATUS
);
937 if ((ahc
->features
& AHC_DT
) != 0) {
940 sfunct
= ahc_inb(ahc
, SFUNCT
) & ~ALT_MODE
;
941 ahc_outb(ahc
, SFUNCT
, sfunct
| ALT_MODE
);
942 ahc
->bus_softc
.pci_softc
.optionmode
= ahc_inb(ahc
, OPTIONMODE
);
943 ahc
->bus_softc
.pci_softc
.targcrccnt
= ahc_inw(ahc
, TARGCRCCNT
);
944 ahc_outb(ahc
, SFUNCT
, sfunct
);
945 ahc
->bus_softc
.pci_softc
.crccontrol1
=
946 ahc_inb(ahc
, CRCCONTROL1
);
948 if ((ahc
->features
& AHC_MULTI_FUNC
) != 0)
949 ahc
->bus_softc
.pci_softc
.scbbaddr
= ahc_inb(ahc
, SCBBADDR
);
951 if ((ahc
->features
& AHC_ULTRA2
) != 0)
952 ahc
->bus_softc
.pci_softc
.dff_thrsh
= ahc_inb(ahc
, DFF_THRSH
);
954 /* Core initialization */
955 error
= ahc_init(ahc
);
960 * Allow interrupts now that we are completely setup.
962 error
= ahc_pci_map_int(ahc
);
971 * Test for the presense of external sram in an
972 * "unshared" configuration.
975 ahc_ext_scbram_present(struct ahc_softc
*ahc
)
982 chip
= ahc
->chip
& AHC_CHIPID_MASK
;
983 devconfig
= ahc_pci_read_config(ahc
->dev_softc
,
984 DEVCONFIG
, /*bytes*/4);
985 single_user
= (devconfig
& MPORTMODE
) != 0;
987 if ((ahc
->features
& AHC_ULTRA2
) != 0)
988 ramps
= (ahc_inb(ahc
, DSCOMMAND0
) & RAMPS
) != 0;
989 else if (chip
== AHC_AIC7895
|| chip
== AHC_AIC7895C
)
991 * External SCBRAM arbitration is flakey
992 * on these chips. Unfortunately this means
993 * we don't use the extra SCB ram space on the
997 else if (chip
>= AHC_AIC7870
)
998 ramps
= (devconfig
& RAMPSM
) != 0;
1002 if (ramps
&& single_user
)
1008 * Enable external scbram.
1011 ahc_scbram_config(struct ahc_softc
*ahc
, int enable
, int pcheck
,
1012 int fast
, int large
)
1016 if (ahc
->features
& AHC_MULTI_FUNC
) {
1018 * Set the SCB Base addr (highest address bit)
1019 * depending on which channel we are.
1021 ahc_outb(ahc
, SCBBADDR
, ahc_get_pci_function(ahc
->dev_softc
));
1024 ahc
->flags
&= ~AHC_LSCBS_ENABLED
;
1026 ahc
->flags
|= AHC_LSCBS_ENABLED
;
1027 devconfig
= ahc_pci_read_config(ahc
->dev_softc
, DEVCONFIG
, /*bytes*/4);
1028 if ((ahc
->features
& AHC_ULTRA2
) != 0) {
1031 dscommand0
= ahc_inb(ahc
, DSCOMMAND0
);
1033 dscommand0
&= ~INTSCBRAMSEL
;
1035 dscommand0
|= INTSCBRAMSEL
;
1037 dscommand0
&= ~USCBSIZE32
;
1039 dscommand0
|= USCBSIZE32
;
1040 ahc_outb(ahc
, DSCOMMAND0
, dscommand0
);
1043 devconfig
&= ~EXTSCBTIME
;
1045 devconfig
|= EXTSCBTIME
;
1047 devconfig
&= ~SCBRAMSEL
;
1049 devconfig
|= SCBRAMSEL
;
1051 devconfig
&= ~SCBSIZE32
;
1053 devconfig
|= SCBSIZE32
;
1056 devconfig
|= EXTSCBPEN
;
1058 devconfig
&= ~EXTSCBPEN
;
1060 ahc_pci_write_config(ahc
->dev_softc
, DEVCONFIG
, devconfig
, /*bytes*/4);
1064 * Take a look to see if we have external SRAM.
1065 * We currently do not attempt to use SRAM that is
1066 * shared among multiple controllers.
1069 ahc_probe_ext_scbram(struct ahc_softc
*ahc
)
1084 if (ahc_ext_scbram_present(ahc
) == 0)
1088 * Probe for the best parameters to use.
1090 ahc_scbram_config(ahc
, /*enable*/TRUE
, pcheck
, fast
, large
);
1091 num_scbs
= ahc_probe_scbs(ahc
);
1092 if (num_scbs
== 0) {
1093 /* The SRAM wasn't really present. */
1099 * Clear any outstanding parity error
1100 * and ensure that parity error reporting
1103 ahc_outb(ahc
, SEQCTL
, 0);
1104 ahc_outb(ahc
, CLRINT
, CLRPARERR
);
1105 ahc_outb(ahc
, CLRINT
, CLRBRKADRINT
);
1107 /* Now see if we can do parity */
1108 ahc_scbram_config(ahc
, enable
, /*pcheck*/TRUE
, fast
, large
);
1109 num_scbs
= ahc_probe_scbs(ahc
);
1110 if ((ahc_inb(ahc
, INTSTAT
) & BRKADRINT
) == 0
1111 || (ahc_inb(ahc
, ERROR
) & MPARERR
) == 0)
1114 /* Clear any resulting parity error */
1115 ahc_outb(ahc
, CLRINT
, CLRPARERR
);
1116 ahc_outb(ahc
, CLRINT
, CLRBRKADRINT
);
1118 /* Now see if we can do fast timing */
1119 ahc_scbram_config(ahc
, enable
, pcheck
, /*fast*/TRUE
, large
);
1120 test_num_scbs
= ahc_probe_scbs(ahc
);
1121 if (test_num_scbs
== num_scbs
1122 && ((ahc_inb(ahc
, INTSTAT
) & BRKADRINT
) == 0
1123 || (ahc_inb(ahc
, ERROR
) & MPARERR
) == 0))
1127 * See if we can use large SCBs and still maintain
1128 * the same overall count of SCBs.
1130 if ((ahc
->features
& AHC_LARGE_SCBS
) != 0) {
1131 ahc_scbram_config(ahc
, enable
, pcheck
, fast
, /*large*/TRUE
);
1132 test_num_scbs
= ahc_probe_scbs(ahc
);
1133 if (test_num_scbs
>= num_scbs
) {
1135 num_scbs
= test_num_scbs
;
1136 if (num_scbs
>= 64) {
1138 * We have enough space to move the
1139 * "busy targets table" into SCB space
1140 * and make it qualify all the way to the
1143 ahc
->flags
|= AHC_SCB_BTT
;
1149 * Disable parity error reporting until we
1150 * can load instruction ram.
1152 ahc_outb(ahc
, SEQCTL
, PERRORDIS
|FAILDIS
);
1153 /* Clear any latched parity error */
1154 ahc_outb(ahc
, CLRINT
, CLRPARERR
);
1155 ahc_outb(ahc
, CLRINT
, CLRBRKADRINT
);
1156 if (bootverbose
&& enable
) {
1157 printf("%s: External SRAM, %s access%s, %dbytes/SCB\n",
1158 ahc_name(ahc
), fast
? "fast" : "slow",
1159 pcheck
? ", parity checking enabled" : "",
1162 ahc_scbram_config(ahc
, enable
, pcheck
, fast
, large
);
1166 * Perform some simple tests that should catch situations where
1167 * our registers are invalidly mapped.
1170 ahc_pci_test_register_access(struct ahc_softc
*ahc
)
1180 * Enable PCI error interrupt status, but suppress NMIs
1181 * generated by SERR raised due to target aborts.
1183 cmd
= ahc_pci_read_config(ahc
->dev_softc
, PCIR_COMMAND
, /*bytes*/2);
1184 ahc_pci_write_config(ahc
->dev_softc
, PCIR_COMMAND
,
1185 cmd
& ~PCIM_CMD_SERRESPEN
, /*bytes*/2);
1188 * First a simple test to see if any
1189 * registers can be read. Reading
1190 * HCNTRL has no side effects and has
1191 * at least one bit that is guaranteed to
1192 * be zero so it is a good register to
1193 * use for this test.
1195 hcntrl
= ahc_inb(ahc
, HCNTRL
);
1200 * Next create a situation where write combining
1201 * or read prefetching could be initiated by the
1202 * CPU or host bridge. Our device does not support
1203 * either, so look for data corruption and/or flagged
1204 * PCI errors. First pause without causing another
1208 ahc_outb(ahc
, HCNTRL
, hcntrl
|PAUSE
);
1209 while (ahc_is_paused(ahc
) == 0)
1212 /* Clear any PCI errors that occurred before our driver attached. */
1213 status1
= ahc_pci_read_config(ahc
->dev_softc
,
1214 PCIR_STATUS
+ 1, /*bytes*/1);
1215 ahc_pci_write_config(ahc
->dev_softc
, PCIR_STATUS
+ 1,
1216 status1
, /*bytes*/1);
1217 ahc_outb(ahc
, CLRINT
, CLRPARERR
);
1219 ahc_outb(ahc
, SEQCTL
, PERRORDIS
);
1220 ahc_outb(ahc
, SCBPTR
, 0);
1221 ahc_outl(ahc
, SCB_BASE
, 0x5aa555aa);
1222 if (ahc_inl(ahc
, SCB_BASE
) != 0x5aa555aa)
1225 status1
= ahc_pci_read_config(ahc
->dev_softc
,
1226 PCIR_STATUS
+ 1, /*bytes*/1);
1227 if ((status1
& STA
) != 0)
1233 /* Silently clear any latched errors. */
1234 status1
= ahc_pci_read_config(ahc
->dev_softc
,
1235 PCIR_STATUS
+ 1, /*bytes*/1);
1236 ahc_pci_write_config(ahc
->dev_softc
, PCIR_STATUS
+ 1,
1237 status1
, /*bytes*/1);
1238 ahc_outb(ahc
, CLRINT
, CLRPARERR
);
1239 ahc_outb(ahc
, SEQCTL
, PERRORDIS
|FAILDIS
);
1240 ahc_pci_write_config(ahc
->dev_softc
, PCIR_COMMAND
, cmd
, /*bytes*/2);
1245 * Check the external port logic for a serial eeprom
1246 * and termination/cable detection contrls.
1249 check_extport(struct ahc_softc
*ahc
, u_int
*sxfrctl1
)
1251 struct seeprom_descriptor sd
;
1252 struct seeprom_config
*sc
;
1257 sd
.sd_control_offset
= SEECTL
;
1258 sd
.sd_status_offset
= SEECTL
;
1259 sd
.sd_dataout_offset
= SEECTL
;
1260 sc
= ahc
->seep_config
;
1263 * For some multi-channel devices, the c46 is simply too
1264 * small to work. For the other controller types, we can
1265 * get our information from either SEEPROM type. Set the
1266 * type to start our probe with accordingly.
1268 if (ahc
->flags
& AHC_LARGE_SEEPROM
)
1269 sd
.sd_chip
= C56_66
;
1280 have_seeprom
= ahc_acquire_seeprom(ahc
, &sd
);
1284 printf("%s: Reading SEEPROM...", ahc_name(ahc
));
1289 start_addr
= 32 * (ahc
->channel
- 'A');
1291 have_seeprom
= ahc_read_seeprom(&sd
, (uint16_t *)sc
,
1296 have_seeprom
= ahc_verify_cksum(sc
);
1298 if (have_seeprom
!= 0 || sd
.sd_chip
== C56_66
) {
1300 if (have_seeprom
== 0)
1301 printf ("checksum error\n");
1307 sd
.sd_chip
= C56_66
;
1309 ahc_release_seeprom(&sd
);
1312 if (!have_seeprom
) {
1314 * Pull scratch ram settings and treat them as
1315 * if they are the contents of an seeprom if
1316 * the 'ADPT' signature is found in SCB2.
1317 * We manually compose the data as 16bit values
1318 * to avoid endian issues.
1320 ahc_outb(ahc
, SCBPTR
, 2);
1321 if (ahc_inb(ahc
, SCB_BASE
) == 'A'
1322 && ahc_inb(ahc
, SCB_BASE
+ 1) == 'D'
1323 && ahc_inb(ahc
, SCB_BASE
+ 2) == 'P'
1324 && ahc_inb(ahc
, SCB_BASE
+ 3) == 'T') {
1328 sc_data
= (uint16_t *)sc
;
1329 for (i
= 0; i
< 32; i
++, sc_data
++) {
1333 *sc_data
= ahc_inb(ahc
, SRAM_BASE
+ j
)
1334 | ahc_inb(ahc
, SRAM_BASE
+ j
+ 1) << 8;
1336 have_seeprom
= ahc_verify_cksum(sc
);
1338 ahc
->flags
|= AHC_SCB_CONFIG_USED
;
1341 * Clear any SCB parity errors in case this data and
1342 * its associated parity was not initialized by the BIOS
1344 ahc_outb(ahc
, CLRINT
, CLRPARERR
);
1345 ahc_outb(ahc
, CLRINT
, CLRBRKADRINT
);
1348 if (!have_seeprom
) {
1350 printf("%s: No SEEPROM available.\n", ahc_name(ahc
));
1351 ahc
->flags
|= AHC_USEDEFAULTS
;
1352 free(ahc
->seep_config
, M_DEVBUF
);
1353 ahc
->seep_config
= NULL
;
1356 ahc_parse_pci_eeprom(ahc
, sc
);
1360 * Cards that have the external logic necessary to talk to
1361 * a SEEPROM, are almost certain to have the remaining logic
1362 * necessary for auto-termination control. This assumption
1363 * hasn't failed yet...
1365 have_autoterm
= have_seeprom
;
1368 * Some low-cost chips have SEEPROM and auto-term control built
1369 * in, instead of using a GAL. They can tell us directly
1370 * if the termination logic is enabled.
1372 if ((ahc
->features
& AHC_SPIOCAP
) != 0) {
1373 if ((ahc_inb(ahc
, SPIOCAP
) & SSPIOCPS
) == 0)
1374 have_autoterm
= FALSE
;
1377 if (have_autoterm
) {
1378 ahc
->flags
|= AHC_HAS_TERM_LOGIC
;
1379 ahc_acquire_seeprom(ahc
, &sd
);
1380 configure_termination(ahc
, &sd
, sc
->adapter_control
, sxfrctl1
);
1381 ahc_release_seeprom(&sd
);
1382 } else if (have_seeprom
) {
1383 *sxfrctl1
&= ~STPWEN
;
1384 if ((sc
->adapter_control
& CFSTERM
) != 0)
1385 *sxfrctl1
|= STPWEN
;
1387 printf("%s: Low byte termination %sabled\n",
1389 (*sxfrctl1
& STPWEN
) ? "en" : "dis");
1394 ahc_parse_pci_eeprom(struct ahc_softc
*ahc
, struct seeprom_config
*sc
)
1397 * Put the data we've collected down into SRAM
1398 * where ahc_init will find it.
1401 int max_targ
= sc
->max_targets
& CFMAXTARG
;
1403 uint16_t discenable
;
1408 if ((sc
->adapter_control
& CFULTRAEN
) != 0) {
1410 * Determine if this adapter has a "newstyle"
1413 for (i
= 0; i
< max_targ
; i
++) {
1414 if ((sc
->device_flags
[i
] & CFSYNCHISULTRA
) != 0) {
1415 ahc
->flags
|= AHC_NEWEEPROM_FMT
;
1421 for (i
= 0; i
< max_targ
; i
++) {
1423 uint16_t target_mask
;
1425 target_mask
= 0x01 << i
;
1426 if (sc
->device_flags
[i
] & CFDISC
)
1427 discenable
|= target_mask
;
1428 if ((ahc
->flags
& AHC_NEWEEPROM_FMT
) != 0) {
1429 if ((sc
->device_flags
[i
] & CFSYNCHISULTRA
) != 0)
1430 ultraenb
|= target_mask
;
1431 } else if ((sc
->adapter_control
& CFULTRAEN
) != 0) {
1432 ultraenb
|= target_mask
;
1434 if ((sc
->device_flags
[i
] & CFXFER
) == 0x04
1435 && (ultraenb
& target_mask
) != 0) {
1436 /* Treat 10MHz as a non-ultra speed */
1437 sc
->device_flags
[i
] &= ~CFXFER
;
1438 ultraenb
&= ~target_mask
;
1440 if ((ahc
->features
& AHC_ULTRA2
) != 0) {
1443 if (sc
->device_flags
[i
] & CFSYNCH
)
1444 offset
= MAX_OFFSET_ULTRA2
;
1447 ahc_outb(ahc
, TARG_OFFSET
+ i
, offset
);
1450 * The ultra enable bits contain the
1451 * high bit of the ultra2 sync rate
1454 scsirate
= (sc
->device_flags
[i
] & CFXFER
)
1455 | ((ultraenb
& target_mask
) ? 0x8 : 0x0);
1456 if (sc
->device_flags
[i
] & CFWIDEB
)
1457 scsirate
|= WIDEXFER
;
1459 scsirate
= (sc
->device_flags
[i
] & CFXFER
) << 4;
1460 if (sc
->device_flags
[i
] & CFSYNCH
)
1462 if (sc
->device_flags
[i
] & CFWIDEB
)
1463 scsirate
|= WIDEXFER
;
1465 ahc_outb(ahc
, TARG_SCSIRATE
+ i
, scsirate
);
1467 ahc
->our_id
= sc
->brtime_id
& CFSCSIID
;
1469 scsi_conf
= (ahc
->our_id
& 0x7);
1470 if (sc
->adapter_control
& CFSPARITY
)
1471 scsi_conf
|= ENSPCHK
;
1472 if (sc
->adapter_control
& CFRESETB
)
1473 scsi_conf
|= RESET_SCSI
;
1475 ahc
->flags
|= (sc
->adapter_control
& CFBOOTCHAN
) >> CFBOOTCHANSHIFT
;
1477 if (sc
->bios_control
& CFEXTEND
)
1478 ahc
->flags
|= AHC_EXTENDED_TRANS_A
;
1480 if (sc
->bios_control
& CFBIOSEN
)
1481 ahc
->flags
|= AHC_BIOS_ENABLED
;
1482 if (ahc
->features
& AHC_ULTRA
1483 && (ahc
->flags
& AHC_NEWEEPROM_FMT
) == 0) {
1484 /* Should we enable Ultra mode? */
1485 if (!(sc
->adapter_control
& CFULTRAEN
))
1486 /* Treat us as a non-ultra card */
1490 if (sc
->signature
== CFSIGNATURE
1491 || sc
->signature
== CFSIGNATURE2
) {
1494 /* Honor the STPWLEVEL settings */
1495 devconfig
= ahc_pci_read_config(ahc
->dev_softc
,
1496 DEVCONFIG
, /*bytes*/4);
1497 devconfig
&= ~STPWLEVEL
;
1498 if ((sc
->bios_control
& CFSTPWLEVEL
) != 0)
1499 devconfig
|= STPWLEVEL
;
1500 ahc_pci_write_config(ahc
->dev_softc
, DEVCONFIG
,
1501 devconfig
, /*bytes*/4);
1503 /* Set SCSICONF info */
1504 ahc_outb(ahc
, SCSICONF
, scsi_conf
);
1505 ahc_outb(ahc
, DISC_DSB
, ~(discenable
& 0xff));
1506 ahc_outb(ahc
, DISC_DSB
+ 1, ~((discenable
>> 8) & 0xff));
1507 ahc_outb(ahc
, ULTRA_ENB
, ultraenb
& 0xff);
1508 ahc_outb(ahc
, ULTRA_ENB
+ 1, (ultraenb
>> 8) & 0xff);
1512 configure_termination(struct ahc_softc
*ahc
,
1513 struct seeprom_descriptor
*sd
,
1514 u_int adapter_control
,
1522 * Update the settings in sxfrctl1 to match the
1523 * termination settings
1528 * SEECS must be on for the GALS to latch
1529 * the data properly. Be sure to leave MS
1530 * on or we will release the seeprom.
1532 SEEPROM_OUTB(sd
, sd
->sd_MS
| sd
->sd_CS
);
1533 if ((adapter_control
& CFAUTOTERM
) != 0
1534 || (ahc
->features
& AHC_NEW_TERMCTL
) != 0) {
1535 int internal50_present
;
1536 int internal68_present
;
1537 int externalcable_present
;
1549 if ((ahc
->features
& AHC_NEW_TERMCTL
) != 0) {
1550 ahc_new_term_detect(ahc
, &enableSEC_low
,
1555 if ((adapter_control
& CFSEAUTOTERM
) == 0) {
1557 printf("%s: Manual SE Termination\n",
1559 enableSEC_low
= (adapter_control
& CFSELOWTERM
);
1561 (adapter_control
& CFSEHIGHTERM
);
1563 if ((adapter_control
& CFAUTOTERM
) == 0) {
1565 printf("%s: Manual LVD Termination\n",
1567 enablePRI_low
= (adapter_control
& CFSTERM
);
1568 enablePRI_high
= (adapter_control
& CFWSTERM
);
1570 /* Make the table calculations below happy */
1571 internal50_present
= 0;
1572 internal68_present
= 1;
1573 externalcable_present
= 1;
1574 } else if ((ahc
->features
& AHC_SPIOCAP
) != 0) {
1575 aic785X_cable_detect(ahc
, &internal50_present
,
1576 &externalcable_present
,
1578 /* Can never support a wide connector. */
1579 internal68_present
= 0;
1581 aic787X_cable_detect(ahc
, &internal50_present
,
1582 &internal68_present
,
1583 &externalcable_present
,
1587 if ((ahc
->features
& AHC_WIDE
) == 0)
1588 internal68_present
= 0;
1591 && (ahc
->features
& AHC_ULTRA2
) == 0) {
1592 printf("%s: internal 50 cable %s present",
1594 internal50_present
? "is":"not");
1596 if ((ahc
->features
& AHC_WIDE
) != 0)
1597 printf(", internal 68 cable %s present",
1598 internal68_present
? "is":"not");
1599 printf("\n%s: external cable %s present\n",
1601 externalcable_present
? "is":"not");
1604 printf("%s: BIOS eeprom %s present\n",
1605 ahc_name(ahc
), eeprom_present
? "is" : "not");
1607 if ((ahc
->flags
& AHC_INT50_SPEEDFLEX
) != 0) {
1609 * The 50 pin connector is a separate bus,
1610 * so force it to always be terminated.
1611 * In the future, perform current sensing
1612 * to determine if we are in the middle of
1613 * a properly terminated bus.
1615 internal50_present
= 0;
1619 * Now set the termination based on what
1621 * Flash Enable = BRDDAT7
1622 * Secondary High Term Enable = BRDDAT6
1623 * Secondary Low Term Enable = BRDDAT5 (7890)
1624 * Primary High Term Enable = BRDDAT4 (7890)
1626 if ((ahc
->features
& AHC_ULTRA2
) == 0
1627 && (internal50_present
!= 0)
1628 && (internal68_present
!= 0)
1629 && (externalcable_present
!= 0)) {
1630 printf("%s: Illegal cable configuration!!. "
1631 "Only two connectors on the "
1632 "adapter may be used at a "
1633 "time!\n", ahc_name(ahc
));
1636 * Pretend there are no cables in the hope
1637 * that having all of the termination on
1638 * gives us a more stable bus.
1640 internal50_present
= 0;
1641 internal68_present
= 0;
1642 externalcable_present
= 0;
1645 if ((ahc
->features
& AHC_WIDE
) != 0
1646 && ((externalcable_present
== 0)
1647 || (internal68_present
== 0)
1648 || (enableSEC_high
!= 0))) {
1651 if ((ahc
->flags
& AHC_INT50_SPEEDFLEX
) != 0)
1652 printf("%s: 68 pin termination "
1653 "Enabled\n", ahc_name(ahc
));
1655 printf("%s: %sHigh byte termination "
1656 "Enabled\n", ahc_name(ahc
),
1657 enableSEC_high
? "Secondary "
1662 sum
= internal50_present
+ internal68_present
1663 + externalcable_present
;
1664 if (sum
< 2 || (enableSEC_low
!= 0)) {
1665 if ((ahc
->features
& AHC_ULTRA2
) != 0)
1668 *sxfrctl1
|= STPWEN
;
1670 if ((ahc
->flags
& AHC_INT50_SPEEDFLEX
) != 0)
1671 printf("%s: 50 pin termination "
1672 "Enabled\n", ahc_name(ahc
));
1674 printf("%s: %sLow byte termination "
1675 "Enabled\n", ahc_name(ahc
),
1676 enableSEC_low
? "Secondary "
1681 if (enablePRI_low
!= 0) {
1682 *sxfrctl1
|= STPWEN
;
1684 printf("%s: Primary Low Byte termination "
1685 "Enabled\n", ahc_name(ahc
));
1689 * Setup STPWEN before setting up the rest of
1690 * the termination per the tech note on the U160 cards.
1692 ahc_outb(ahc
, SXFRCTL1
, *sxfrctl1
);
1694 if (enablePRI_high
!= 0) {
1697 printf("%s: Primary High Byte "
1698 "termination Enabled\n",
1702 write_brdctl(ahc
, brddat
);
1705 if ((adapter_control
& CFSTERM
) != 0) {
1706 *sxfrctl1
|= STPWEN
;
1709 printf("%s: %sLow byte termination Enabled\n",
1711 (ahc
->features
& AHC_ULTRA2
) ? "Primary "
1715 if ((adapter_control
& CFWSTERM
) != 0
1716 && (ahc
->features
& AHC_WIDE
) != 0) {
1719 printf("%s: %sHigh byte termination Enabled\n",
1721 (ahc
->features
& AHC_ULTRA2
)
1722 ? "Secondary " : "");
1726 * Setup STPWEN before setting up the rest of
1727 * the termination per the tech note on the U160 cards.
1729 ahc_outb(ahc
, SXFRCTL1
, *sxfrctl1
);
1731 if ((ahc
->features
& AHC_WIDE
) != 0)
1732 write_brdctl(ahc
, brddat
);
1734 SEEPROM_OUTB(sd
, sd
->sd_MS
); /* Clear CS */
1738 ahc_new_term_detect(struct ahc_softc
*ahc
, int *enableSEC_low
,
1739 int *enableSEC_high
, int *enablePRI_low
,
1740 int *enablePRI_high
, int *eeprom_present
)
1746 * BRDDAT6 = Enable Secondary High Byte termination
1747 * BRDDAT5 = Enable Secondary Low Byte termination
1748 * BRDDAT4 = Enable Primary high byte termination
1749 * BRDDAT3 = Enable Primary low byte termination
1751 brdctl
= read_brdctl(ahc
);
1752 *eeprom_present
= brdctl
& BRDDAT7
;
1753 *enableSEC_high
= (brdctl
& BRDDAT6
);
1754 *enableSEC_low
= (brdctl
& BRDDAT5
);
1755 *enablePRI_high
= (brdctl
& BRDDAT4
);
1756 *enablePRI_low
= (brdctl
& BRDDAT3
);
1760 aic787X_cable_detect(struct ahc_softc
*ahc
, int *internal50_present
,
1761 int *internal68_present
, int *externalcable_present
,
1762 int *eeprom_present
)
1767 * First read the status of our cables.
1768 * Set the rom bank to 0 since the
1769 * bank setting serves as a multiplexor
1770 * for the cable detection logic.
1771 * BRDDAT5 controls the bank switch.
1773 write_brdctl(ahc
, 0);
1776 * Now read the state of the internal
1777 * connectors. BRDDAT6 is INT50 and
1780 brdctl
= read_brdctl(ahc
);
1781 *internal50_present
= (brdctl
& BRDDAT6
) ? 0 : 1;
1782 *internal68_present
= (brdctl
& BRDDAT7
) ? 0 : 1;
1785 * Set the rom bank to 1 and determine
1786 * the other signals.
1788 write_brdctl(ahc
, BRDDAT5
);
1791 * Now read the state of the external
1792 * connectors. BRDDAT6 is EXT68 and
1793 * BRDDAT7 is EPROMPS.
1795 brdctl
= read_brdctl(ahc
);
1796 *externalcable_present
= (brdctl
& BRDDAT6
) ? 0 : 1;
1797 *eeprom_present
= (brdctl
& BRDDAT7
) ? 1 : 0;
1801 aic785X_cable_detect(struct ahc_softc
*ahc
, int *internal50_present
,
1802 int *externalcable_present
, int *eeprom_present
)
1807 spiocap
= ahc_inb(ahc
, SPIOCAP
);
1808 spiocap
&= ~SOFTCMDEN
;
1809 spiocap
|= EXT_BRDCTL
;
1810 ahc_outb(ahc
, SPIOCAP
, spiocap
);
1811 ahc_outb(ahc
, BRDCTL
, BRDRW
|BRDCS
);
1812 ahc_flush_device_writes(ahc
);
1814 ahc_outb(ahc
, BRDCTL
, 0);
1815 ahc_flush_device_writes(ahc
);
1817 brdctl
= ahc_inb(ahc
, BRDCTL
);
1818 *internal50_present
= (brdctl
& BRDDAT5
) ? 0 : 1;
1819 *externalcable_present
= (brdctl
& BRDDAT6
) ? 0 : 1;
1820 *eeprom_present
= (ahc_inb(ahc
, SPIOCAP
) & EEPROM
) ? 1 : 0;
1824 ahc_acquire_seeprom(struct ahc_softc
*ahc
, struct seeprom_descriptor
*sd
)
1828 if ((ahc
->features
& AHC_SPIOCAP
) != 0
1829 && (ahc_inb(ahc
, SPIOCAP
) & SEEPROM
) == 0)
1833 * Request access of the memory port. When access is
1834 * granted, SEERDY will go high. We use a 1 second
1835 * timeout which should be near 1 second more than
1836 * is needed. Reason: after the chip reset, there
1837 * should be no contention.
1839 SEEPROM_OUTB(sd
, sd
->sd_MS
);
1840 wait
= 1000; /* 1 second timeout in msec */
1841 while (--wait
&& ((SEEPROM_STATUS_INB(sd
) & sd
->sd_RDY
) == 0)) {
1842 ahc_delay(1000); /* delay 1 msec */
1844 if ((SEEPROM_STATUS_INB(sd
) & sd
->sd_RDY
) == 0) {
1845 SEEPROM_OUTB(sd
, 0);
1852 ahc_release_seeprom(struct seeprom_descriptor
*sd
)
1854 /* Release access to the memory port and the serial EEPROM. */
1855 SEEPROM_OUTB(sd
, 0);
1859 write_brdctl(struct ahc_softc
*ahc
, uint8_t value
)
1863 if ((ahc
->chip
& AHC_CHIPID_MASK
) == AHC_AIC7895
) {
1865 if (ahc
->channel
== 'B')
1867 } else if ((ahc
->features
& AHC_ULTRA2
) != 0) {
1870 brdctl
= BRDSTB
|BRDCS
;
1872 ahc_outb(ahc
, BRDCTL
, brdctl
);
1873 ahc_flush_device_writes(ahc
);
1875 ahc_outb(ahc
, BRDCTL
, brdctl
);
1876 ahc_flush_device_writes(ahc
);
1877 if ((ahc
->features
& AHC_ULTRA2
) != 0)
1878 brdctl
|= BRDSTB_ULTRA2
;
1881 ahc_outb(ahc
, BRDCTL
, brdctl
);
1882 ahc_flush_device_writes(ahc
);
1883 if ((ahc
->features
& AHC_ULTRA2
) != 0)
1887 ahc_outb(ahc
, BRDCTL
, brdctl
);
1891 read_brdctl(struct ahc_softc
*ahc
)
1896 if ((ahc
->chip
& AHC_CHIPID_MASK
) == AHC_AIC7895
) {
1898 if (ahc
->channel
== 'B')
1900 } else if ((ahc
->features
& AHC_ULTRA2
) != 0) {
1901 brdctl
= BRDRW_ULTRA2
;
1903 brdctl
= BRDRW
|BRDCS
;
1905 ahc_outb(ahc
, BRDCTL
, brdctl
);
1906 ahc_flush_device_writes(ahc
);
1907 value
= ahc_inb(ahc
, BRDCTL
);
1908 ahc_outb(ahc
, BRDCTL
, 0);
1913 ahc_pci_intr(struct ahc_softc
*ahc
)
1918 error
= ahc_inb(ahc
, ERROR
);
1919 if ((error
& PCIERRSTAT
) == 0)
1922 status1
= ahc_pci_read_config(ahc
->dev_softc
,
1923 PCIR_STATUS
+ 1, /*bytes*/1);
1925 printf("%s: PCI error Interrupt at seqaddr = 0x%x\n",
1927 ahc_inb(ahc
, SEQADDR0
) | (ahc_inb(ahc
, SEQADDR1
) << 8));
1929 if (status1
& DPE
) {
1930 ahc
->pci_target_perr_count
++;
1931 printf("%s: Data Parity Error Detected during address "
1932 "or write data phase\n", ahc_name(ahc
));
1934 if (status1
& SSE
) {
1935 printf("%s: Signal System Error Detected\n", ahc_name(ahc
));
1937 if (status1
& RMA
) {
1938 printf("%s: Received a Master Abort\n", ahc_name(ahc
));
1940 if (status1
& RTA
) {
1941 printf("%s: Received a Target Abort\n", ahc_name(ahc
));
1943 if (status1
& STA
) {
1944 printf("%s: Signaled a Target Abort\n", ahc_name(ahc
));
1946 if (status1
& DPR
) {
1947 printf("%s: Data Parity Error has been reported via PERR#\n",
1951 /* Clear latched errors. */
1952 ahc_pci_write_config(ahc
->dev_softc
, PCIR_STATUS
+ 1,
1953 status1
, /*bytes*/1);
1955 if ((status1
& (DPE
|SSE
|RMA
|RTA
|STA
|DPR
)) == 0) {
1956 printf("%s: Latched PCIERR interrupt with "
1957 "no status bits set\n", ahc_name(ahc
));
1959 ahc_outb(ahc
, CLRINT
, CLRPARERR
);
1962 if (ahc
->pci_target_perr_count
> AHC_PCI_TARGET_PERR_THRESH
) {
1964 "%s: WARNING WARNING WARNING WARNING\n"
1965 "%s: Too many PCI parity errors observed as a target.\n"
1966 "%s: Some device on this bus is generating bad parity.\n"
1967 "%s: This is an error *observed by*, not *generated by*, this controller.\n"
1968 "%s: PCI parity error checking has been disabled.\n"
1969 "%s: WARNING WARNING WARNING WARNING\n",
1970 ahc_name(ahc
), ahc_name(ahc
), ahc_name(ahc
),
1971 ahc_name(ahc
), ahc_name(ahc
), ahc_name(ahc
));
1972 ahc
->seqctl
|= FAILDIS
;
1973 ahc_outb(ahc
, SEQCTL
, ahc
->seqctl
);
1979 ahc_pci_chip_init(struct ahc_softc
*ahc
)
1981 ahc_outb(ahc
, DSCOMMAND0
, ahc
->bus_softc
.pci_softc
.dscommand0
);
1982 ahc_outb(ahc
, DSPCISTATUS
, ahc
->bus_softc
.pci_softc
.dspcistatus
);
1983 if ((ahc
->features
& AHC_DT
) != 0) {
1986 sfunct
= ahc_inb(ahc
, SFUNCT
) & ~ALT_MODE
;
1987 ahc_outb(ahc
, SFUNCT
, sfunct
| ALT_MODE
);
1988 ahc_outb(ahc
, OPTIONMODE
, ahc
->bus_softc
.pci_softc
.optionmode
);
1989 ahc_outw(ahc
, TARGCRCCNT
, ahc
->bus_softc
.pci_softc
.targcrccnt
);
1990 ahc_outb(ahc
, SFUNCT
, sfunct
);
1991 ahc_outb(ahc
, CRCCONTROL1
,
1992 ahc
->bus_softc
.pci_softc
.crccontrol1
);
1994 if ((ahc
->features
& AHC_MULTI_FUNC
) != 0)
1995 ahc_outb(ahc
, SCBBADDR
, ahc
->bus_softc
.pci_softc
.scbbaddr
);
1997 if ((ahc
->features
& AHC_ULTRA2
) != 0)
1998 ahc_outb(ahc
, DFF_THRSH
, ahc
->bus_softc
.pci_softc
.dff_thrsh
);
2000 return (ahc_chip_init(ahc
));
2004 ahc_pci_suspend(struct ahc_softc
*ahc
)
2006 return (ahc_suspend(ahc
));
2010 ahc_pci_resume(struct ahc_softc
*ahc
)
2013 pci_set_power_state(ahc
->dev_softc
, AHC_POWER_STATE_D0
);
2016 * We assume that the OS has restored our register
2017 * mappings, etc. Just update the config space registers
2018 * that the OS doesn't know about and rely on our chip
2019 * reset handler to handle the rest.
2021 ahc_pci_write_config(ahc
->dev_softc
, DEVCONFIG
, /*bytes*/4,
2022 ahc
->bus_softc
.pci_softc
.devconfig
);
2023 ahc_pci_write_config(ahc
->dev_softc
, PCIR_COMMAND
, /*bytes*/1,
2024 ahc
->bus_softc
.pci_softc
.command
);
2025 ahc_pci_write_config(ahc
->dev_softc
, CSIZE_LATTIME
, /*bytes*/1,
2026 ahc
->bus_softc
.pci_softc
.csize_lattime
);
2027 if ((ahc
->flags
& AHC_HAS_TERM_LOGIC
) != 0) {
2028 struct seeprom_descriptor sd
;
2032 sd
.sd_control_offset
= SEECTL
;
2033 sd
.sd_status_offset
= SEECTL
;
2034 sd
.sd_dataout_offset
= SEECTL
;
2036 ahc_acquire_seeprom(ahc
, &sd
);
2037 configure_termination(ahc
, &sd
,
2038 ahc
->seep_config
->adapter_control
,
2040 ahc_release_seeprom(&sd
);
2042 return (ahc_resume(ahc
));
2046 ahc_aic785X_setup(struct ahc_softc
*ahc
)
2048 ahc_dev_softc_t pci
;
2051 pci
= ahc
->dev_softc
;
2053 ahc
->chip
= AHC_AIC7850
;
2054 ahc
->features
= AHC_AIC7850_FE
;
2055 ahc
->bugs
|= AHC_TMODE_WIDEODD_BUG
|AHC_CACHETHEN_BUG
|AHC_PCI_MWI_BUG
;
2056 rev
= ahc_pci_read_config(pci
, PCIR_REVID
, /*bytes*/1);
2058 ahc
->bugs
|= AHC_PCI_2_1_RETRY_BUG
;
2059 ahc
->instruction_ram_size
= 512;
2064 ahc_aic7860_setup(struct ahc_softc
*ahc
)
2066 ahc_dev_softc_t pci
;
2069 pci
= ahc
->dev_softc
;
2071 ahc
->chip
= AHC_AIC7860
;
2072 ahc
->features
= AHC_AIC7860_FE
;
2073 ahc
->bugs
|= AHC_TMODE_WIDEODD_BUG
|AHC_CACHETHEN_BUG
|AHC_PCI_MWI_BUG
;
2074 rev
= ahc_pci_read_config(pci
, PCIR_REVID
, /*bytes*/1);
2076 ahc
->bugs
|= AHC_PCI_2_1_RETRY_BUG
;
2077 ahc
->instruction_ram_size
= 512;
2082 ahc_apa1480_setup(struct ahc_softc
*ahc
)
2086 error
= ahc_aic7860_setup(ahc
);
2089 ahc
->features
|= AHC_REMOVABLE
;
2094 ahc_aic7870_setup(struct ahc_softc
*ahc
)
2098 ahc
->chip
= AHC_AIC7870
;
2099 ahc
->features
= AHC_AIC7870_FE
;
2100 ahc
->bugs
|= AHC_TMODE_WIDEODD_BUG
|AHC_CACHETHEN_BUG
|AHC_PCI_MWI_BUG
;
2101 ahc
->instruction_ram_size
= 512;
2106 ahc_aha394X_setup(struct ahc_softc
*ahc
)
2110 error
= ahc_aic7870_setup(ahc
);
2112 error
= ahc_aha394XX_setup(ahc
);
2117 ahc_aha398X_setup(struct ahc_softc
*ahc
)
2121 error
= ahc_aic7870_setup(ahc
);
2123 error
= ahc_aha398XX_setup(ahc
);
2128 ahc_aha494X_setup(struct ahc_softc
*ahc
)
2132 error
= ahc_aic7870_setup(ahc
);
2134 error
= ahc_aha494XX_setup(ahc
);
2139 ahc_aic7880_setup(struct ahc_softc
*ahc
)
2141 ahc_dev_softc_t pci
;
2144 pci
= ahc
->dev_softc
;
2146 ahc
->chip
= AHC_AIC7880
;
2147 ahc
->features
= AHC_AIC7880_FE
;
2148 ahc
->bugs
|= AHC_TMODE_WIDEODD_BUG
;
2149 rev
= ahc_pci_read_config(pci
, PCIR_REVID
, /*bytes*/1);
2151 ahc
->bugs
|= AHC_PCI_2_1_RETRY_BUG
;
2153 ahc
->bugs
|= AHC_CACHETHEN_BUG
|AHC_PCI_MWI_BUG
;
2155 ahc
->instruction_ram_size
= 512;
2160 ahc_aha2940Pro_setup(struct ahc_softc
*ahc
)
2163 ahc
->flags
|= AHC_INT50_SPEEDFLEX
;
2164 return (ahc_aic7880_setup(ahc
));
2168 ahc_aha394XU_setup(struct ahc_softc
*ahc
)
2172 error
= ahc_aic7880_setup(ahc
);
2174 error
= ahc_aha394XX_setup(ahc
);
2179 ahc_aha398XU_setup(struct ahc_softc
*ahc
)
2183 error
= ahc_aic7880_setup(ahc
);
2185 error
= ahc_aha398XX_setup(ahc
);
2190 ahc_aic7890_setup(struct ahc_softc
*ahc
)
2192 ahc_dev_softc_t pci
;
2195 pci
= ahc
->dev_softc
;
2197 ahc
->chip
= AHC_AIC7890
;
2198 ahc
->features
= AHC_AIC7890_FE
;
2199 ahc
->flags
|= AHC_NEWEEPROM_FMT
;
2200 rev
= ahc_pci_read_config(pci
, PCIR_REVID
, /*bytes*/1);
2202 ahc
->bugs
|= AHC_AUTOFLUSH_BUG
|AHC_CACHETHEN_BUG
;
2203 ahc
->instruction_ram_size
= 768;
2208 ahc_aic7892_setup(struct ahc_softc
*ahc
)
2212 ahc
->chip
= AHC_AIC7892
;
2213 ahc
->features
= AHC_AIC7892_FE
;
2214 ahc
->flags
|= AHC_NEWEEPROM_FMT
;
2215 ahc
->bugs
|= AHC_SCBCHAN_UPLOAD_BUG
;
2216 ahc
->instruction_ram_size
= 1024;
2221 ahc_aic7895_setup(struct ahc_softc
*ahc
)
2223 ahc_dev_softc_t pci
;
2226 pci
= ahc
->dev_softc
;
2227 ahc
->channel
= ahc_get_pci_function(pci
) == 1 ? 'B' : 'A';
2229 * The 'C' revision of the aic7895 has a few additional features.
2231 rev
= ahc_pci_read_config(pci
, PCIR_REVID
, /*bytes*/1);
2233 ahc
->chip
= AHC_AIC7895C
;
2234 ahc
->features
= AHC_AIC7895C_FE
;
2238 ahc
->chip
= AHC_AIC7895
;
2239 ahc
->features
= AHC_AIC7895_FE
;
2242 * The BIOS disables the use of MWI transactions
2243 * since it does not have the MWI bug work around
2244 * we have. Disabling MWI reduces performance, so
2247 command
= ahc_pci_read_config(pci
, PCIR_COMMAND
, /*bytes*/1);
2248 command
|= PCIM_CMD_MWRICEN
;
2249 ahc_pci_write_config(pci
, PCIR_COMMAND
, command
, /*bytes*/1);
2250 ahc
->bugs
|= AHC_PCI_MWI_BUG
;
2253 * XXX Does CACHETHEN really not work??? What about PCI retry?
2254 * on C level chips. Need to test, but for now, play it safe.
2256 ahc
->bugs
|= AHC_TMODE_WIDEODD_BUG
|AHC_PCI_2_1_RETRY_BUG
2257 | AHC_CACHETHEN_BUG
;
2263 * Cachesize must also be zero due to stray DAC
2264 * problem when sitting behind some bridges.
2266 ahc_pci_write_config(pci
, CSIZE_LATTIME
, 0, /*bytes*/1);
2267 devconfig
= ahc_pci_read_config(pci
, DEVCONFIG
, /*bytes*/1);
2268 devconfig
|= MRDCEN
;
2269 ahc_pci_write_config(pci
, DEVCONFIG
, devconfig
, /*bytes*/1);
2271 ahc
->flags
|= AHC_NEWEEPROM_FMT
;
2272 ahc
->instruction_ram_size
= 512;
2277 ahc_aic7896_setup(struct ahc_softc
*ahc
)
2279 ahc_dev_softc_t pci
;
2281 pci
= ahc
->dev_softc
;
2282 ahc
->channel
= ahc_get_pci_function(pci
) == 1 ? 'B' : 'A';
2283 ahc
->chip
= AHC_AIC7896
;
2284 ahc
->features
= AHC_AIC7896_FE
;
2285 ahc
->flags
|= AHC_NEWEEPROM_FMT
;
2286 ahc
->bugs
|= AHC_CACHETHEN_DIS_BUG
;
2287 ahc
->instruction_ram_size
= 768;
2292 ahc_aic7899_setup(struct ahc_softc
*ahc
)
2294 ahc_dev_softc_t pci
;
2296 pci
= ahc
->dev_softc
;
2297 ahc
->channel
= ahc_get_pci_function(pci
) == 1 ? 'B' : 'A';
2298 ahc
->chip
= AHC_AIC7899
;
2299 ahc
->features
= AHC_AIC7899_FE
;
2300 ahc
->flags
|= AHC_NEWEEPROM_FMT
;
2301 ahc
->bugs
|= AHC_SCBCHAN_UPLOAD_BUG
;
2302 ahc
->instruction_ram_size
= 1024;
2307 ahc_aha29160C_setup(struct ahc_softc
*ahc
)
2311 error
= ahc_aic7899_setup(ahc
);
2314 ahc
->features
|= AHC_REMOVABLE
;
2319 ahc_raid_setup(struct ahc_softc
*ahc
)
2321 printf("RAID functionality unsupported\n");
2326 ahc_aha394XX_setup(struct ahc_softc
*ahc
)
2328 ahc_dev_softc_t pci
;
2330 pci
= ahc
->dev_softc
;
2331 switch (ahc_get_pci_slot(pci
)) {
2332 case AHC_394X_SLOT_CHANNEL_A
:
2335 case AHC_394X_SLOT_CHANNEL_B
:
2339 printf("adapter at unexpected slot %d\n"
2340 "unable to map to a channel\n",
2341 ahc_get_pci_slot(pci
));
2348 ahc_aha398XX_setup(struct ahc_softc
*ahc
)
2350 ahc_dev_softc_t pci
;
2352 pci
= ahc
->dev_softc
;
2353 switch (ahc_get_pci_slot(pci
)) {
2354 case AHC_398X_SLOT_CHANNEL_A
:
2357 case AHC_398X_SLOT_CHANNEL_B
:
2360 case AHC_398X_SLOT_CHANNEL_C
:
2364 printf("adapter at unexpected slot %d\n"
2365 "unable to map to a channel\n",
2366 ahc_get_pci_slot(pci
));
2370 ahc
->flags
|= AHC_LARGE_SEEPROM
;
2375 ahc_aha494XX_setup(struct ahc_softc
*ahc
)
2377 ahc_dev_softc_t pci
;
2379 pci
= ahc
->dev_softc
;
2380 switch (ahc_get_pci_slot(pci
)) {
2381 case AHC_494X_SLOT_CHANNEL_A
:
2384 case AHC_494X_SLOT_CHANNEL_B
:
2387 case AHC_494X_SLOT_CHANNEL_C
:
2390 case AHC_494X_SLOT_CHANNEL_D
:
2394 printf("adapter at unexpected slot %d\n"
2395 "unable to map to a channel\n",
2396 ahc_get_pci_slot(pci
));
2399 ahc
->flags
|= AHC_LARGE_SEEPROM
;