48 #include <dev/aic7xxx/aic79xx_osm.h>
49 #include <dev/aic7xxx/aic79xx_inline.h>
67 #define ID_AIC7902_PCI_REV_A4 0x3
68 #define ID_AIC7902_PCI_REV_B0 0x10
69 #define SUBID_HP 0x0E11
71 #define DEVID_9005_HOSTRAID(id) ((id) & 0x80)
73 #define DEVID_9005_TYPE(id) ((id) & 0xF)
74 #define DEVID_9005_TYPE_HBA 0x0
75 #define DEVID_9005_TYPE_HBA_2EXT 0x1
76 #define DEVID_9005_TYPE_IROC 0x8
77 #define DEVID_9005_TYPE_MB 0xF
79 #define DEVID_9005_MFUNC(id) ((id) & 0x10)
81 #define DEVID_9005_PACKETIZED(id) ((id) & 0x8000)
83 #define SUBID_9005_TYPE(id) ((id) & 0xF)
84 #define SUBID_9005_TYPE_HBA 0x0
85 #define SUBID_9005_TYPE_MB 0xF
87 #define SUBID_9005_AUTOTERM(id) (((id) & 0x10) == 0)
89 #define SUBID_9005_LEGACYCONN_FUNC(id) ((id) & 0x20)
91 #define SUBID_9005_SEEPTYPE(id) (((id) & 0x0C0) >> 6)
92 #define SUBID_9005_SEEPTYPE_NONE 0x0
93 #define SUBID_9005_SEEPTYPE_4K 0x1
106 "Adaptec 29320A Ultra320 SCSI adapter",
112 "Adaptec 29320ALP PCIx Ultra320 SCSI adapter",
118 "Adaptec 29320LPE PCIe Ultra320 SCSI adapter",
125 "Adaptec 29320LP Ultra320 SCSI adapter",
132 "Adaptec 29320 Ultra320 SCSI adapter",
138 "Adaptec 29320B Ultra320 SCSI adapter",
144 "Adaptec 39320 Ultra320 SCSI adapter",
150 "Adaptec 39320 Ultra320 SCSI adapter",
156 "Adaptec (Dell OEM) 39320 Ultra320 SCSI adapter",
162 "Adaptec 39320A Ultra320 SCSI adapter",
168 "Adaptec 39320D Ultra320 SCSI adapter",
174 "Adaptec (HP OEM) 39320D Ultra320 SCSI adapter",
180 "Adaptec 39320D Ultra320 SCSI adapter",
186 "Adaptec (HP OEM) 39320D Ultra320 SCSI adapter",
193 "Adaptec AIC7901 Ultra320 SCSI adapter",
199 "Adaptec AIC7901A Ultra320 SCSI adapter",
205 "Adaptec AIC7902 Ultra320 SCSI adapter",
212 #define DEVCONFIG 0x40
213 #define PCIXINITPAT 0x0000E000ul
214 #define PCIXINIT_PCI33_66 0x0000E000ul
215 #define PCIXINIT_PCIX50_66 0x0000C000ul
216 #define PCIXINIT_PCIX66_100 0x0000A000ul
217 #define PCIXINIT_PCIX100_133 0x00008000ul
218 #define PCI_BUS_MODES_INDEX(devconfig) \
219 (((devconfig) & PCIXINITPAT) >> 13)
220 static const char *pci_bus_modes[] =
222 "PCI bus mode unknown",
223 "PCI bus mode unknown",
224 "PCI bus mode unknown",
225 "PCI bus mode unknown",
232 #define TESTMODE 0x00000800ul
233 #define IRDY_RST 0x00000200ul
234 #define FRAME_RST 0x00000100ul
235 #define PCI64BIT 0x00000080ul
236 #define MRDCEN 0x00000040ul
237 #define ENDIANSEL 0x00000020ul
238 #define MIXQWENDIANEN 0x00000008ul
239 #define DACEN 0x00000004ul
240 #define STPWLEVEL 0x00000002ul
241 #define QWENDIANSEL 0x00000001ul
243 #define DEVCONFIG1 0x44
246 #define CSIZE_LATTIME 0x0c
247 #define CACHESIZE 0x000000fful
248 #define LATTIME 0x0000ff00ul
250 static int ahd_check_extport(
struct ahd_softc *ahd);
251 static void ahd_configure_termination(
struct ahd_softc *ahd,
252 u_int adapter_control);
253 static void ahd_pci_split_intr(
struct ahd_softc *ahd,
u_int intstat);
254 static void ahd_pci_intr(
struct ahd_softc *ahd);
271 full_id = ahd_compose_id(device,
282 for (i = 0; i < ahd_num_pci_devs; i++) {
283 entry = &ahd_pci_ident_table[
i];
303 shared_scb_data =
NULL;
313 error = entry->
setup(ahd);
341 printk(
"%s: Enabling 39Bit Addressing\n",
372 error = ahd_check_extport(ahd);
467 targpcistat =
ahd_inb(ahd, TARGPCISTAT);
468 ahd_outb(ahd, TARGPCISTAT, targpcistat);
483 targpcistat =
ahd_inb(ahd, TARGPCISTAT);
484 if ((targpcistat &
STA) != 0)
494 targpcistat =
ahd_inb(ahd, TARGPCISTAT);
497 ahd_outb(ahd, TARGPCISTAT, targpcistat);
531 printk(
"%s: Reading VPD from SEEPROM...",
535 start_addr = ((2 *
sizeof(*sc))
539 start_addr,
sizeof(
vpd)/2,
544 printk(
"%s: VPD parsing %s\n",
546 error == 0 ?
"successful" :
"failed");
549 printk(
"%s: Reading SEEPROM...", ahd_name(ahd));
552 start_addr = (
sizeof(*sc) / 2) * (ahd->
channel -
'A');
555 start_addr,
sizeof(*sc)/2,
559 printk(
"Unable to read SEEPROM\n");
565 if (have_seeprom == 0)
566 printk (
"checksum error\n");
586 if (nvram_scb != 0xFF
604 for (i = 0; i < 64; i += 2)
613 if (have_seeprom != 0
614 && (ahd_debug & AHD_DUMP_SEEPROM) != 0) {
618 printk(
"%s: Seeprom Contents:", ahd_name(ahd));
620 for (i = 0; i < (
sizeof(*sc)); i += 2)
621 printk(
"\n\t0x%.4x", sc_data[i]);
628 printk(
"%s: No SEEPROM available.\n", ahd_name(ahd));
641 ahd_configure_termination(ahd, adapter_control);
647 ahd_configure_termination(
struct ahd_softc *ahd,
u_int adapter_control)
659 printk(
"%s: STPWLEVEL is %s\n",
660 ahd_name(ahd), (devconfig &
STPWLEVEL) ?
"on" :
"off");
674 printk(
"%s: Manual Primary Termination\n",
677 if ((adapter_control &
CFSTERM) != 0)
679 if ((adapter_control &
CFWSTERM) != 0)
681 }
else if (error != 0) {
682 printk(
"%s: Primary Auto-Term Sensing failed! "
683 "Using Defaults.\n", ahd_name(ahd));
689 printk(
"%s: Manual Secondary Termination\n",
696 }
else if (error != 0) {
697 printk(
"%s: Secondary Auto-Term Sensing failed! "
698 "Using Defaults.\n", ahd_name(ahd));
717 printk(
"%s: Unable to set termination settings!\n",
720 printk(
"%s: Primary High byte termination %sabled\n",
724 printk(
"%s: Primary Low byte termination %sabled\n",
726 (termctl & FLX_TERMCTL_ENPRILOW) ?
"En" :
"Dis");
728 printk(
"%s: Secondary High byte termination %sabled\n",
732 printk(
"%s: Secondary Low byte termination %sabled\n",
746 static const char *split_status_source[] =
754 static const char *pci_status_source[] =
766 static const char *split_status_strings[] =
768 "%s: Received split response in %s.\n",
769 "%s: Received split completion error message in %s\n",
770 "%s: Receive overrun in %s\n",
771 "%s: Count not complete in %s\n",
772 "%s: Split completion data bucket in %s\n",
773 "%s: Split completion address error in %s\n",
774 "%s: Split completion byte count error in %s\n",
775 "%s: Signaled Target-abort to early terminate a split in %s\n"
778 static const char *pci_status_strings[] =
780 "%s: Data Parity Error has been reported via PERR# in %s\n",
781 "%s: Target initial wait state error in %s\n",
782 "%s: Split completion read data parity error in %s\n",
783 "%s: Split completion address attribute parity error in %s\n",
784 "%s: Received a Target Abort in %s\n",
785 "%s: Received a Master Abort in %s\n",
786 "%s: Signal System Error Detected in %s\n",
787 "%s: Address or Write Phase Parity Error Detected in %s.\n"
802 if ((intstat & SPLTINT) != 0)
803 ahd_pci_split_intr(ahd, intstat);
805 if ((intstat & PCIINT) == 0)
808 printk(
"%s: PCI error Interrupt\n", ahd_name(ahd));
812 for (i = 0, reg = DF0PCISTAT; i < 8; i++, reg++) {
821 for (i = 0; i < 8; i++) {
827 for (bit = 0; bit < 8; bit++) {
829 if ((pci_status[i] & (0x1 << bit)) != 0) {
830 static const char *
s;
832 s = pci_status_strings[
bit];
833 if (i == 7 && bit == 3)
834 s =
"%s: Signaled Target Abort\n";
835 printk(s, ahd_name(ahd), pci_status_source[i]);
865 printk(
"%s: PCI Split Interrupt - PCI-X status = 0x%x\n",
866 ahd_name(ahd), pcix_status);
868 for (i = 0; i < 4; i++) {
871 split_status[
i] =
ahd_inb(ahd, DCHSPLTSTAT0);
872 split_status1[
i] =
ahd_inb(ahd, DCHSPLTSTAT1);
874 ahd_outb(ahd, DCHSPLTSTAT0, split_status[i]);
875 ahd_outb(ahd, DCHSPLTSTAT1, split_status1[i]);
878 sg_split_status[
i] =
ahd_inb(ahd, SGSPLTSTAT0);
879 sg_split_status1[
i] =
ahd_inb(ahd, SGSPLTSTAT1);
881 ahd_outb(ahd, SGSPLTSTAT0, sg_split_status[i]);
882 ahd_outb(ahd, SGSPLTSTAT1, sg_split_status1[i]);
885 for (i = 0; i < 4; i++) {
888 for (bit = 0; bit < 8; bit++) {
890 if ((split_status[i] & (0x1 << bit)) != 0) {
891 static const char *
s;
893 s = split_status_strings[
bit];
895 split_status_source[i]);
901 if ((sg_split_status[i] & (0x1 << bit)) != 0) {
902 static const char *
s;
904 s = split_status_strings[
bit];
905 printk(s, ahd_name(ahd),
"SG");
924 return (ahd_aic790X_setup(ahd));
928 ahd_aic7901A_setup(
struct ahd_softc *ahd)
933 return (ahd_aic790X_setup(ahd));
941 return (ahd_aic790X_setup(ahd));
953 printk(
"%s: Unable to attach to unsupported chip revision %d\n",
958 ahd->
channel = ahd_get_pci_function(pci) +
'A';