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#79 $
45 #include "aic7xxx_osm.h"
46 #include "aic7xxx_inline.h"
47 #include "aic7xxx_93cx6.h"
48 #include "aic7xxx_pci.h"
50 static inline uint64_t
51 ahc_compose_id(u_int device
, u_int vendor
, u_int subdevice
, u_int subvendor
)
57 | ((uint64_t)vendor
<< 32)
58 | ((uint64_t)device
<< 48);
63 #define AHC_PCI_IOADDR PCIR_MAPS /* I/O Address */
64 #define AHC_PCI_MEMADDR (PCIR_MAPS + 4) /* Mem I/O Address */
66 #define DEVID_9005_TYPE(id) ((id) & 0xF)
67 #define DEVID_9005_TYPE_HBA 0x0 /* Standard Card */
68 #define DEVID_9005_TYPE_AAA 0x3 /* RAID Card */
69 #define DEVID_9005_TYPE_SISL 0x5 /* Container ROMB */
70 #define DEVID_9005_TYPE_MB 0xF /* On Motherboard */
72 #define DEVID_9005_MAXRATE(id) (((id) & 0x30) >> 4)
73 #define DEVID_9005_MAXRATE_U160 0x0
74 #define DEVID_9005_MAXRATE_ULTRA2 0x1
75 #define DEVID_9005_MAXRATE_ULTRA 0x2
76 #define DEVID_9005_MAXRATE_FAST 0x3
78 #define DEVID_9005_MFUNC(id) (((id) & 0x40) >> 6)
80 #define DEVID_9005_CLASS(id) (((id) & 0xFF00) >> 8)
81 #define DEVID_9005_CLASS_SPI 0x0 /* Parallel SCSI */
83 #define SUBID_9005_TYPE(id) ((id) & 0xF)
84 #define SUBID_9005_TYPE_MB 0xF /* On Motherboard */
85 #define SUBID_9005_TYPE_CARD 0x0 /* Standard Card */
86 #define SUBID_9005_TYPE_LCCARD 0x1 /* Low Cost Card */
87 #define SUBID_9005_TYPE_RAID 0x3 /* Combined with Raid */
89 #define SUBID_9005_TYPE_KNOWN(id) \
90 ((((id) & 0xF) == SUBID_9005_TYPE_MB) \
91 || (((id) & 0xF) == SUBID_9005_TYPE_CARD) \
92 || (((id) & 0xF) == SUBID_9005_TYPE_LCCARD) \
93 || (((id) & 0xF) == SUBID_9005_TYPE_RAID))
95 #define SUBID_9005_MAXRATE(id) (((id) & 0x30) >> 4)
96 #define SUBID_9005_MAXRATE_ULTRA2 0x0
97 #define SUBID_9005_MAXRATE_ULTRA 0x1
98 #define SUBID_9005_MAXRATE_U160 0x2
99 #define SUBID_9005_MAXRATE_RESERVED 0x3
101 #define SUBID_9005_SEEPTYPE(id) \
102 ((SUBID_9005_TYPE(id) == SUBID_9005_TYPE_MB) \
103 ? ((id) & 0xC0) >> 6 \
104 : ((id) & 0x300) >> 8)
105 #define SUBID_9005_SEEPTYPE_NONE 0x0
106 #define SUBID_9005_SEEPTYPE_1K 0x1
107 #define SUBID_9005_SEEPTYPE_2K_4K 0x2
108 #define SUBID_9005_SEEPTYPE_RESERVED 0x3
109 #define SUBID_9005_AUTOTERM(id) \
110 ((SUBID_9005_TYPE(id) == SUBID_9005_TYPE_MB) \
111 ? (((id) & 0x400) >> 10) == 0 \
112 : (((id) & 0x40) >> 6) == 0)
114 #define SUBID_9005_NUMCHAN(id) \
115 ((SUBID_9005_TYPE(id) == SUBID_9005_TYPE_MB) \
116 ? ((id) & 0x300) >> 8 \
117 : ((id) & 0xC00) >> 10)
119 #define SUBID_9005_LEGACYCONN(id) \
120 ((SUBID_9005_TYPE(id) == SUBID_9005_TYPE_MB) \
122 : ((id) & 0x80) >> 7)
124 #define SUBID_9005_MFUNCENB(id) \
125 ((SUBID_9005_TYPE(id) == SUBID_9005_TYPE_MB) \
126 ? ((id) & 0x800) >> 11 \
127 : ((id) & 0x1000) >> 12)
129 * Informational only. Should use chip register to be
130 * certain, but may be use in identification strings.
132 #define SUBID_9005_CARD_SCSIWIDTH_MASK 0x2000
133 #define SUBID_9005_CARD_PCIWIDTH_MASK 0x4000
134 #define SUBID_9005_CARD_SEDIFF_MASK 0x8000
136 static ahc_device_setup_t ahc_aic785X_setup
;
137 static ahc_device_setup_t ahc_aic7860_setup
;
138 static ahc_device_setup_t ahc_apa1480_setup
;
139 static ahc_device_setup_t ahc_aic7870_setup
;
140 static ahc_device_setup_t ahc_aic7870h_setup
;
141 static ahc_device_setup_t ahc_aha394X_setup
;
142 static ahc_device_setup_t ahc_aha394Xh_setup
;
143 static ahc_device_setup_t ahc_aha494X_setup
;
144 static ahc_device_setup_t ahc_aha494Xh_setup
;
145 static ahc_device_setup_t ahc_aha398X_setup
;
146 static ahc_device_setup_t ahc_aic7880_setup
;
147 static ahc_device_setup_t ahc_aic7880h_setup
;
148 static ahc_device_setup_t ahc_aha2940Pro_setup
;
149 static ahc_device_setup_t ahc_aha394XU_setup
;
150 static ahc_device_setup_t ahc_aha394XUh_setup
;
151 static ahc_device_setup_t ahc_aha398XU_setup
;
152 static ahc_device_setup_t ahc_aic7890_setup
;
153 static ahc_device_setup_t ahc_aic7892_setup
;
154 static ahc_device_setup_t ahc_aic7895_setup
;
155 static ahc_device_setup_t ahc_aic7895h_setup
;
156 static ahc_device_setup_t ahc_aic7896_setup
;
157 static ahc_device_setup_t ahc_aic7899_setup
;
158 static ahc_device_setup_t ahc_aha29160C_setup
;
159 static ahc_device_setup_t ahc_raid_setup
;
160 static ahc_device_setup_t ahc_aha394XX_setup
;
161 static ahc_device_setup_t ahc_aha494XX_setup
;
162 static ahc_device_setup_t ahc_aha398XX_setup
;
164 static const struct ahc_pci_identity ahc_pci_ident_table
[] = {
165 /* aic7850 based controllers */
167 ID_AHA_2902_04_10_15_20C_30C
,
169 "Adaptec 2902/04/10/15/20C/30C SCSI adapter",
172 /* aic7860 based controllers */
176 "Adaptec 2930CU SCSI adapter",
180 ID_AHA_1480A
& ID_DEV_VENDOR_MASK
,
182 "Adaptec 1480A Ultra SCSI adapter",
186 ID_AHA_2940AU_0
& ID_DEV_VENDOR_MASK
,
188 "Adaptec 2940A Ultra SCSI adapter",
192 ID_AHA_2940AU_CN
& ID_DEV_VENDOR_MASK
,
194 "Adaptec 2940A/CN Ultra SCSI adapter",
198 ID_AHA_2930C_VAR
& ID_DEV_VENDOR_MASK
,
200 "Adaptec 2930C Ultra SCSI adapter (VAR)",
203 /* aic7870 based controllers */
207 "Adaptec 2940 SCSI adapter",
213 "Adaptec 3940 SCSI adapter",
219 "Adaptec 398X SCSI RAID adapter",
225 "Adaptec 2944 SCSI adapter",
231 "Adaptec 3944 SCSI adapter",
237 "Adaptec 4944 SCSI adapter",
240 /* aic7880 based controllers */
242 ID_AHA_2940U
& ID_DEV_VENDOR_MASK
,
244 "Adaptec 2940 Ultra SCSI adapter",
248 ID_AHA_3940U
& ID_DEV_VENDOR_MASK
,
250 "Adaptec 3940 Ultra SCSI adapter",
254 ID_AHA_2944U
& ID_DEV_VENDOR_MASK
,
256 "Adaptec 2944 Ultra SCSI adapter",
260 ID_AHA_3944U
& ID_DEV_VENDOR_MASK
,
262 "Adaptec 3944 Ultra SCSI adapter",
266 ID_AHA_398XU
& ID_DEV_VENDOR_MASK
,
268 "Adaptec 398X Ultra SCSI RAID adapter",
273 * XXX Don't know the slot numbers
274 * so we can't identify channels
276 ID_AHA_4944U
& ID_DEV_VENDOR_MASK
,
278 "Adaptec 4944 Ultra SCSI adapter",
282 ID_AHA_2930U
& ID_DEV_VENDOR_MASK
,
284 "Adaptec 2930 Ultra SCSI adapter",
288 ID_AHA_2940U_PRO
& ID_DEV_VENDOR_MASK
,
290 "Adaptec 2940 Pro Ultra SCSI adapter",
294 ID_AHA_2940U_CN
& ID_DEV_VENDOR_MASK
,
296 "Adaptec 2940/CN Ultra SCSI adapter",
299 /* Ignore all SISL (AAC on MB) based controllers. */
306 /* aic7890 based controllers */
310 "Adaptec 2930 Ultra2 SCSI adapter",
316 "Adaptec 2940B Ultra2 SCSI adapter",
322 "Adaptec 2940 Ultra2 SCSI adapter (OEM)",
328 "Adaptec 2940 Ultra2 SCSI adapter",
334 "Adaptec 2950 Ultra2 SCSI adapter",
340 "Adaptec aic7890/91 Ultra2 SCSI adapter (ARO)",
346 "Adaptec AAA-131 Ultra2 RAID adapter",
349 /* aic7892 based controllers */
353 "Adaptec 29160 Ultra160 SCSI adapter",
359 "Adaptec (Compaq OEM) 29160 Ultra160 SCSI adapter",
365 "Adaptec 29160N Ultra160 SCSI adapter",
371 "Adaptec 29160C Ultra160 SCSI adapter",
377 "Adaptec 29160B Ultra160 SCSI adapter",
383 "Adaptec 19160B Ultra160 SCSI adapter",
389 "Adaptec aic7892 Ultra160 SCSI adapter (ARO)",
395 "Adaptec 2915/30LP Ultra160 SCSI adapter",
398 /* aic7895 based controllers */
402 "Adaptec 2940/DUAL Ultra SCSI adapter",
408 "Adaptec 3940A Ultra SCSI adapter",
414 "Adaptec 3944A Ultra SCSI adapter",
420 "Adaptec aic7895 Ultra SCSI adapter (ARO)",
423 /* aic7896/97 based controllers */
427 "Adaptec 3950B Ultra2 SCSI adapter",
433 "Adaptec 3950B Ultra2 SCSI adapter",
439 "Adaptec 3950D Ultra2 SCSI adapter",
445 "Adaptec 3950D Ultra2 SCSI adapter",
451 "Adaptec aic7896/97 Ultra2 SCSI adapter (ARO)",
454 /* aic7899 based controllers */
458 "Adaptec 3960D Ultra160 SCSI adapter",
464 "Adaptec (Compaq OEM) 3960D Ultra160 SCSI adapter",
470 "Adaptec aic7899 Ultra160 SCSI adapter (ARO)",
473 /* Generic chip probes for devices we don't know 'exactly' */
475 ID_AIC7850
& ID_DEV_VENDOR_MASK
,
477 "Adaptec aic7850 SCSI adapter",
481 ID_AIC7855
& ID_DEV_VENDOR_MASK
,
483 "Adaptec aic7855 SCSI adapter",
487 ID_AIC7859
& ID_DEV_VENDOR_MASK
,
489 "Adaptec aic7859 SCSI adapter",
493 ID_AIC7860
& ID_DEV_VENDOR_MASK
,
495 "Adaptec aic7860 Ultra SCSI adapter",
499 ID_AIC7870
& ID_DEV_VENDOR_MASK
,
501 "Adaptec aic7870 SCSI adapter",
505 ID_AIC7880
& ID_DEV_VENDOR_MASK
,
507 "Adaptec aic7880 Ultra SCSI adapter",
511 ID_AIC7890
& ID_9005_GENERIC_MASK
,
512 ID_9005_GENERIC_MASK
,
513 "Adaptec aic7890/91 Ultra2 SCSI adapter",
517 ID_AIC7892
& ID_9005_GENERIC_MASK
,
518 ID_9005_GENERIC_MASK
,
519 "Adaptec aic7892 Ultra160 SCSI adapter",
523 ID_AIC7895
& ID_DEV_VENDOR_MASK
,
525 "Adaptec aic7895 Ultra SCSI adapter",
529 ID_AIC7896
& ID_9005_GENERIC_MASK
,
530 ID_9005_GENERIC_MASK
,
531 "Adaptec aic7896/97 Ultra2 SCSI adapter",
535 ID_AIC7899
& ID_9005_GENERIC_MASK
,
536 ID_9005_GENERIC_MASK
,
537 "Adaptec aic7899 Ultra160 SCSI adapter",
541 ID_AIC7810
& ID_DEV_VENDOR_MASK
,
543 "Adaptec aic7810 RAID memory controller",
547 ID_AIC7815
& ID_DEV_VENDOR_MASK
,
549 "Adaptec aic7815 RAID memory controller",
554 static const u_int ahc_num_pci_devs
= ARRAY_SIZE(ahc_pci_ident_table
);
556 #define AHC_394X_SLOT_CHANNEL_A 4
557 #define AHC_394X_SLOT_CHANNEL_B 5
559 #define AHC_398X_SLOT_CHANNEL_A 4
560 #define AHC_398X_SLOT_CHANNEL_B 8
561 #define AHC_398X_SLOT_CHANNEL_C 12
563 #define AHC_494X_SLOT_CHANNEL_A 4
564 #define AHC_494X_SLOT_CHANNEL_B 5
565 #define AHC_494X_SLOT_CHANNEL_C 6
566 #define AHC_494X_SLOT_CHANNEL_D 7
568 #define DEVCONFIG 0x40
569 #define PCIERRGENDIS 0x80000000ul
570 #define SCBSIZE32 0x00010000ul /* aic789X only */
571 #define REXTVALID 0x00001000ul /* ultra cards only */
572 #define MPORTMODE 0x00000400ul /* aic7870+ only */
573 #define RAMPSM 0x00000200ul /* aic7870+ only */
574 #define VOLSENSE 0x00000100ul
575 #define PCI64BIT 0x00000080ul /* 64Bit PCI bus (Ultra2 Only)*/
576 #define SCBRAMSEL 0x00000080ul
577 #define MRDCEN 0x00000040ul
578 #define EXTSCBTIME 0x00000020ul /* aic7870 only */
579 #define EXTSCBPEN 0x00000010ul /* aic7870 only */
580 #define BERREN 0x00000008ul
581 #define DACEN 0x00000004ul
582 #define STPWLEVEL 0x00000002ul
583 #define DIFACTNEGEN 0x00000001ul /* aic7870 only */
585 #define CSIZE_LATTIME 0x0c
586 #define CACHESIZE 0x0000003ful /* only 5 bits */
587 #define LATTIME 0x0000ff00ul
589 /* PCI STATUS definitions */
597 static int ahc_9005_subdevinfo_valid(uint16_t device
, uint16_t vendor
,
598 uint16_t subdevice
, uint16_t subvendor
);
599 static int ahc_ext_scbram_present(struct ahc_softc
*ahc
);
600 static void ahc_scbram_config(struct ahc_softc
*ahc
, int enable
,
601 int pcheck
, int fast
, int large
);
602 static void ahc_probe_ext_scbram(struct ahc_softc
*ahc
);
603 static void check_extport(struct ahc_softc
*ahc
, u_int
*sxfrctl1
);
604 static void ahc_parse_pci_eeprom(struct ahc_softc
*ahc
,
605 struct seeprom_config
*sc
);
606 static void configure_termination(struct ahc_softc
*ahc
,
607 struct seeprom_descriptor
*sd
,
608 u_int adapter_control
,
611 static void ahc_new_term_detect(struct ahc_softc
*ahc
,
616 int *eeprom_present
);
617 static void aic787X_cable_detect(struct ahc_softc
*ahc
, int *internal50_present
,
618 int *internal68_present
,
619 int *externalcable_present
,
620 int *eeprom_present
);
621 static void aic785X_cable_detect(struct ahc_softc
*ahc
, int *internal50_present
,
622 int *externalcable_present
,
623 int *eeprom_present
);
624 static void write_brdctl(struct ahc_softc
*ahc
, uint8_t value
);
625 static uint8_t read_brdctl(struct ahc_softc
*ahc
);
626 static void ahc_pci_intr(struct ahc_softc
*ahc
);
627 static int ahc_pci_chip_init(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 const struct ahc_pci_identity
*
664 ahc_find_pci_device(ahc_dev_softc_t pci
)
671 const 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
, PCI_SUBSYSTEM_VENDOR_ID
, /*bytes*/2);
677 subdevice
= ahc_pci_read_config(pci
, PCI_SUBSYSTEM_ID
, /*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(device
, vendor
, subdevice
, subvendor
)
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
, const 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 printk("%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
;
785 /* Remember how the card was setup in case there is no SEEPROM */
786 if ((ahc_inb(ahc
, HCNTRL
) & POWRDN
) == 0) {
788 if ((ahc
->features
& AHC_ULTRA2
) != 0)
789 our_id
= ahc_inb(ahc
, SCSIID_ULTRA2
) & OID
;
791 our_id
= ahc_inb(ahc
, SCSIID
) & OID
;
792 sxfrctl1
= ahc_inb(ahc
, SXFRCTL1
) & STPWEN
;
793 scsiseq
= ahc_inb(ahc
, SCSISEQ
);
800 error
= ahc_reset(ahc
, /*reinit*/FALSE
);
804 if ((ahc
->features
& AHC_DT
) != 0) {
807 /* Perform ALT-Mode Setup */
808 sfunct
= ahc_inb(ahc
, SFUNCT
) & ~ALT_MODE
;
809 ahc_outb(ahc
, SFUNCT
, sfunct
| ALT_MODE
);
810 ahc_outb(ahc
, OPTIONMODE
,
811 OPTIONMODE_DEFAULTS
|AUTOACKEN
|BUSFREEREV
|EXPPHASEDIS
);
812 ahc_outb(ahc
, SFUNCT
, sfunct
);
814 /* Normal mode setup */
815 ahc_outb(ahc
, CRCCONTROL1
, CRCVALCHKEN
|CRCENDCHKEN
|CRCREQCHKEN
819 dscommand0
= ahc_inb(ahc
, DSCOMMAND0
);
820 dscommand0
|= MPARCKEN
|CACHETHEN
;
821 if ((ahc
->features
& AHC_ULTRA2
) != 0) {
824 * DPARCKEN doesn't work correctly on
825 * some MBs so don't use it.
827 dscommand0
&= ~DPARCKEN
;
831 * Handle chips that must have cache line
832 * streaming (dis/en)abled.
834 if ((ahc
->bugs
& AHC_CACHETHEN_DIS_BUG
) != 0)
835 dscommand0
|= CACHETHEN
;
837 if ((ahc
->bugs
& AHC_CACHETHEN_BUG
) != 0)
838 dscommand0
&= ~CACHETHEN
;
840 ahc_outb(ahc
, DSCOMMAND0
, dscommand0
);
843 ahc_pci_read_config(ahc
->dev_softc
, CSIZE_LATTIME
,
844 /*bytes*/1) & CACHESIZE
;
845 ahc
->pci_cachesize
*= 4;
847 if ((ahc
->bugs
& AHC_PCI_2_1_RETRY_BUG
) != 0
848 && ahc
->pci_cachesize
== 4) {
850 ahc_pci_write_config(ahc
->dev_softc
, CSIZE_LATTIME
,
852 ahc
->pci_cachesize
= 0;
856 * We cannot perform ULTRA speeds without the presence
857 * of the external precision resistor.
859 if ((ahc
->features
& AHC_ULTRA
) != 0) {
862 devconfig
= ahc_pci_read_config(ahc
->dev_softc
,
863 DEVCONFIG
, /*bytes*/4);
864 if ((devconfig
& REXTVALID
) == 0)
865 ahc
->features
&= ~AHC_ULTRA
;
868 /* See if we have a SEEPROM and perform auto-term */
869 check_extport(ahc
, &sxfrctl1
);
872 * Take the LED out of diagnostic mode
874 sblkctl
= ahc_inb(ahc
, SBLKCTL
);
875 ahc_outb(ahc
, SBLKCTL
, (sblkctl
& ~(DIAGLEDEN
|DIAGLEDON
)));
877 if ((ahc
->features
& AHC_ULTRA2
) != 0) {
878 ahc_outb(ahc
, DFF_THRSH
, RD_DFTHRSH_MAX
|WR_DFTHRSH_MAX
);
880 ahc_outb(ahc
, DSPCISTATUS
, DFTHRSH_100
);
883 if (ahc
->flags
& AHC_USEDEFAULTS
) {
885 * PCI Adapter default setup
886 * Should only be used if the adapter does not have
889 /* See if someone else set us up already */
890 if ((ahc
->flags
& AHC_NO_BIOS_INIT
) == 0
892 printk("%s: Using left over BIOS settings\n",
894 ahc
->flags
&= ~AHC_USEDEFAULTS
;
895 ahc
->flags
|= AHC_BIOS_ENABLED
;
898 * Assume only one connector and always turn
904 ahc_outb(ahc
, SCSICONF
, our_id
|ENSPCHK
|RESET_SCSI
);
906 ahc
->our_id
= our_id
;
910 * Take a look to see if we have external SRAM.
911 * We currently do not attempt to use SRAM that is
912 * shared among multiple controllers.
914 ahc_probe_ext_scbram(ahc
);
917 * Record our termination setting for the
918 * generic initialization routine.
920 if ((sxfrctl1
& STPWEN
) != 0)
921 ahc
->flags
|= AHC_TERM_ENB_A
;
924 * Save chip register configuration data for chip resets
925 * that occur during runtime and resume events.
927 ahc
->bus_softc
.pci_softc
.devconfig
=
928 ahc_pci_read_config(ahc
->dev_softc
, DEVCONFIG
, /*bytes*/4);
929 ahc
->bus_softc
.pci_softc
.command
=
930 ahc_pci_read_config(ahc
->dev_softc
, PCIR_COMMAND
, /*bytes*/1);
931 ahc
->bus_softc
.pci_softc
.csize_lattime
=
932 ahc_pci_read_config(ahc
->dev_softc
, CSIZE_LATTIME
, /*bytes*/1);
933 ahc
->bus_softc
.pci_softc
.dscommand0
= ahc_inb(ahc
, DSCOMMAND0
);
934 ahc
->bus_softc
.pci_softc
.dspcistatus
= ahc_inb(ahc
, DSPCISTATUS
);
935 if ((ahc
->features
& AHC_DT
) != 0) {
938 sfunct
= ahc_inb(ahc
, SFUNCT
) & ~ALT_MODE
;
939 ahc_outb(ahc
, SFUNCT
, sfunct
| ALT_MODE
);
940 ahc
->bus_softc
.pci_softc
.optionmode
= ahc_inb(ahc
, OPTIONMODE
);
941 ahc
->bus_softc
.pci_softc
.targcrccnt
= ahc_inw(ahc
, TARGCRCCNT
);
942 ahc_outb(ahc
, SFUNCT
, sfunct
);
943 ahc
->bus_softc
.pci_softc
.crccontrol1
=
944 ahc_inb(ahc
, CRCCONTROL1
);
946 if ((ahc
->features
& AHC_MULTI_FUNC
) != 0)
947 ahc
->bus_softc
.pci_softc
.scbbaddr
= ahc_inb(ahc
, SCBBADDR
);
949 if ((ahc
->features
& AHC_ULTRA2
) != 0)
950 ahc
->bus_softc
.pci_softc
.dff_thrsh
= ahc_inb(ahc
, DFF_THRSH
);
952 /* Core initialization */
953 error
= ahc_init(ahc
);
959 * Allow interrupts now that we are completely setup.
961 return ahc_pci_map_int(ahc
);
965 * Test for the presence of external sram in an
966 * "unshared" configuration.
969 ahc_ext_scbram_present(struct ahc_softc
*ahc
)
976 chip
= ahc
->chip
& AHC_CHIPID_MASK
;
977 devconfig
= ahc_pci_read_config(ahc
->dev_softc
,
978 DEVCONFIG
, /*bytes*/4);
979 single_user
= (devconfig
& MPORTMODE
) != 0;
981 if ((ahc
->features
& AHC_ULTRA2
) != 0)
982 ramps
= (ahc_inb(ahc
, DSCOMMAND0
) & RAMPS
) != 0;
983 else if (chip
== AHC_AIC7895
|| chip
== AHC_AIC7895C
)
985 * External SCBRAM arbitration is flakey
986 * on these chips. Unfortunately this means
987 * we don't use the extra SCB ram space on the
991 else if (chip
>= AHC_AIC7870
)
992 ramps
= (devconfig
& RAMPSM
) != 0;
996 if (ramps
&& single_user
)
1002 * Enable external scbram.
1005 ahc_scbram_config(struct ahc_softc
*ahc
, int enable
, int pcheck
,
1006 int fast
, int large
)
1010 if (ahc
->features
& AHC_MULTI_FUNC
) {
1012 * Set the SCB Base addr (highest address bit)
1013 * depending on which channel we are.
1015 ahc_outb(ahc
, SCBBADDR
, ahc_get_pci_function(ahc
->dev_softc
));
1018 ahc
->flags
&= ~AHC_LSCBS_ENABLED
;
1020 ahc
->flags
|= AHC_LSCBS_ENABLED
;
1021 devconfig
= ahc_pci_read_config(ahc
->dev_softc
, DEVCONFIG
, /*bytes*/4);
1022 if ((ahc
->features
& AHC_ULTRA2
) != 0) {
1025 dscommand0
= ahc_inb(ahc
, DSCOMMAND0
);
1027 dscommand0
&= ~INTSCBRAMSEL
;
1029 dscommand0
|= INTSCBRAMSEL
;
1031 dscommand0
&= ~USCBSIZE32
;
1033 dscommand0
|= USCBSIZE32
;
1034 ahc_outb(ahc
, DSCOMMAND0
, dscommand0
);
1037 devconfig
&= ~EXTSCBTIME
;
1039 devconfig
|= EXTSCBTIME
;
1041 devconfig
&= ~SCBRAMSEL
;
1043 devconfig
|= SCBRAMSEL
;
1045 devconfig
&= ~SCBSIZE32
;
1047 devconfig
|= SCBSIZE32
;
1050 devconfig
|= EXTSCBPEN
;
1052 devconfig
&= ~EXTSCBPEN
;
1054 ahc_pci_write_config(ahc
->dev_softc
, DEVCONFIG
, devconfig
, /*bytes*/4);
1058 * Take a look to see if we have external SRAM.
1059 * We currently do not attempt to use SRAM that is
1060 * shared among multiple controllers.
1063 ahc_probe_ext_scbram(struct ahc_softc
*ahc
)
1078 if (ahc_ext_scbram_present(ahc
) == 0)
1082 * Probe for the best parameters to use.
1084 ahc_scbram_config(ahc
, /*enable*/TRUE
, pcheck
, fast
, large
);
1085 num_scbs
= ahc_probe_scbs(ahc
);
1086 if (num_scbs
== 0) {
1087 /* The SRAM wasn't really present. */
1093 * Clear any outstanding parity error
1094 * and ensure that parity error reporting
1097 ahc_outb(ahc
, SEQCTL
, 0);
1098 ahc_outb(ahc
, CLRINT
, CLRPARERR
);
1099 ahc_outb(ahc
, CLRINT
, CLRBRKADRINT
);
1101 /* Now see if we can do parity */
1102 ahc_scbram_config(ahc
, enable
, /*pcheck*/TRUE
, fast
, large
);
1103 num_scbs
= ahc_probe_scbs(ahc
);
1104 if ((ahc_inb(ahc
, INTSTAT
) & BRKADRINT
) == 0
1105 || (ahc_inb(ahc
, ERROR
) & MPARERR
) == 0)
1108 /* Clear any resulting parity error */
1109 ahc_outb(ahc
, CLRINT
, CLRPARERR
);
1110 ahc_outb(ahc
, CLRINT
, CLRBRKADRINT
);
1112 /* Now see if we can do fast timing */
1113 ahc_scbram_config(ahc
, enable
, pcheck
, /*fast*/TRUE
, large
);
1114 test_num_scbs
= ahc_probe_scbs(ahc
);
1115 if (test_num_scbs
== num_scbs
1116 && ((ahc_inb(ahc
, INTSTAT
) & BRKADRINT
) == 0
1117 || (ahc_inb(ahc
, ERROR
) & MPARERR
) == 0))
1121 * See if we can use large SCBs and still maintain
1122 * the same overall count of SCBs.
1124 if ((ahc
->features
& AHC_LARGE_SCBS
) != 0) {
1125 ahc_scbram_config(ahc
, enable
, pcheck
, fast
, /*large*/TRUE
);
1126 test_num_scbs
= ahc_probe_scbs(ahc
);
1127 if (test_num_scbs
>= num_scbs
) {
1129 num_scbs
= test_num_scbs
;
1130 if (num_scbs
>= 64) {
1132 * We have enough space to move the
1133 * "busy targets table" into SCB space
1134 * and make it qualify all the way to the
1137 ahc
->flags
|= AHC_SCB_BTT
;
1143 * Disable parity error reporting until we
1144 * can load instruction ram.
1146 ahc_outb(ahc
, SEQCTL
, PERRORDIS
|FAILDIS
);
1147 /* Clear any latched parity error */
1148 ahc_outb(ahc
, CLRINT
, CLRPARERR
);
1149 ahc_outb(ahc
, CLRINT
, CLRBRKADRINT
);
1150 if (bootverbose
&& enable
) {
1151 printk("%s: External SRAM, %s access%s, %dbytes/SCB\n",
1152 ahc_name(ahc
), fast
? "fast" : "slow",
1153 pcheck
? ", parity checking enabled" : "",
1156 ahc_scbram_config(ahc
, enable
, pcheck
, fast
, large
);
1160 * Perform some simple tests that should catch situations where
1161 * our registers are invalidly mapped.
1164 ahc_pci_test_register_access(struct ahc_softc
*ahc
)
1174 * Enable PCI error interrupt status, but suppress NMIs
1175 * generated by SERR raised due to target aborts.
1177 cmd
= ahc_pci_read_config(ahc
->dev_softc
, PCIR_COMMAND
, /*bytes*/2);
1178 ahc_pci_write_config(ahc
->dev_softc
, PCIR_COMMAND
,
1179 cmd
& ~PCIM_CMD_SERRESPEN
, /*bytes*/2);
1182 * First a simple test to see if any
1183 * registers can be read. Reading
1184 * HCNTRL has no side effects and has
1185 * at least one bit that is guaranteed to
1186 * be zero so it is a good register to
1187 * use for this test.
1189 hcntrl
= ahc_inb(ahc
, HCNTRL
);
1194 if ((hcntrl
& CHIPRST
) != 0) {
1196 * The chip has not been initialized since
1197 * PCI/EISA/VLB bus reset. Don't trust
1198 * "left over BIOS data".
1200 ahc
->flags
|= AHC_NO_BIOS_INIT
;
1204 * Next create a situation where write combining
1205 * or read prefetching could be initiated by the
1206 * CPU or host bridge. Our device does not support
1207 * either, so look for data corruption and/or flagged
1208 * PCI errors. First pause without causing another
1212 ahc_outb(ahc
, HCNTRL
, hcntrl
|PAUSE
);
1213 while (ahc_is_paused(ahc
) == 0)
1216 /* Clear any PCI errors that occurred before our driver attached. */
1217 status1
= ahc_pci_read_config(ahc
->dev_softc
,
1218 PCIR_STATUS
+ 1, /*bytes*/1);
1219 ahc_pci_write_config(ahc
->dev_softc
, PCIR_STATUS
+ 1,
1220 status1
, /*bytes*/1);
1221 ahc_outb(ahc
, CLRINT
, CLRPARERR
);
1223 ahc_outb(ahc
, SEQCTL
, PERRORDIS
);
1224 ahc_outb(ahc
, SCBPTR
, 0);
1225 ahc_outl(ahc
, SCB_BASE
, 0x5aa555aa);
1226 if (ahc_inl(ahc
, SCB_BASE
) != 0x5aa555aa)
1229 status1
= ahc_pci_read_config(ahc
->dev_softc
,
1230 PCIR_STATUS
+ 1, /*bytes*/1);
1231 if ((status1
& STA
) != 0)
1237 /* Silently clear any latched errors. */
1238 status1
= ahc_pci_read_config(ahc
->dev_softc
,
1239 PCIR_STATUS
+ 1, /*bytes*/1);
1240 ahc_pci_write_config(ahc
->dev_softc
, PCIR_STATUS
+ 1,
1241 status1
, /*bytes*/1);
1242 ahc_outb(ahc
, CLRINT
, CLRPARERR
);
1243 ahc_outb(ahc
, SEQCTL
, PERRORDIS
|FAILDIS
);
1244 ahc_pci_write_config(ahc
->dev_softc
, PCIR_COMMAND
, cmd
, /*bytes*/2);
1249 * Check the external port logic for a serial eeprom
1250 * and termination/cable detection contrls.
1253 check_extport(struct ahc_softc
*ahc
, u_int
*sxfrctl1
)
1255 struct seeprom_descriptor sd
;
1256 struct seeprom_config
*sc
;
1261 sd
.sd_control_offset
= SEECTL
;
1262 sd
.sd_status_offset
= SEECTL
;
1263 sd
.sd_dataout_offset
= SEECTL
;
1264 sc
= ahc
->seep_config
;
1267 * For some multi-channel devices, the c46 is simply too
1268 * small to work. For the other controller types, we can
1269 * get our information from either SEEPROM type. Set the
1270 * type to start our probe with accordingly.
1272 if (ahc
->flags
& AHC_LARGE_SEEPROM
)
1273 sd
.sd_chip
= C56_66
;
1284 have_seeprom
= ahc_acquire_seeprom(ahc
, &sd
);
1288 printk("%s: Reading SEEPROM...", ahc_name(ahc
));
1293 start_addr
= 32 * (ahc
->channel
- 'A');
1295 have_seeprom
= ahc_read_seeprom(&sd
, (uint16_t *)sc
,
1300 have_seeprom
= ahc_verify_cksum(sc
);
1302 if (have_seeprom
!= 0 || sd
.sd_chip
== C56_66
) {
1304 if (have_seeprom
== 0)
1305 printk ("checksum error\n");
1311 sd
.sd_chip
= C56_66
;
1313 ahc_release_seeprom(&sd
);
1315 /* Remember the SEEPROM type for later */
1316 if (sd
.sd_chip
== C56_66
)
1317 ahc
->flags
|= AHC_LARGE_SEEPROM
;
1320 if (!have_seeprom
) {
1322 * Pull scratch ram settings and treat them as
1323 * if they are the contents of an seeprom if
1324 * the 'ADPT' signature is found in SCB2.
1325 * We manually compose the data as 16bit values
1326 * to avoid endian issues.
1328 ahc_outb(ahc
, SCBPTR
, 2);
1329 if (ahc_inb(ahc
, SCB_BASE
) == 'A'
1330 && ahc_inb(ahc
, SCB_BASE
+ 1) == 'D'
1331 && ahc_inb(ahc
, SCB_BASE
+ 2) == 'P'
1332 && ahc_inb(ahc
, SCB_BASE
+ 3) == 'T') {
1336 sc_data
= (uint16_t *)sc
;
1337 for (i
= 0; i
< 32; i
++, sc_data
++) {
1341 *sc_data
= ahc_inb(ahc
, SRAM_BASE
+ j
)
1342 | ahc_inb(ahc
, SRAM_BASE
+ j
+ 1) << 8;
1344 have_seeprom
= ahc_verify_cksum(sc
);
1346 ahc
->flags
|= AHC_SCB_CONFIG_USED
;
1349 * Clear any SCB parity errors in case this data and
1350 * its associated parity was not initialized by the BIOS
1352 ahc_outb(ahc
, CLRINT
, CLRPARERR
);
1353 ahc_outb(ahc
, CLRINT
, CLRBRKADRINT
);
1356 if (!have_seeprom
) {
1358 printk("%s: No SEEPROM available.\n", ahc_name(ahc
));
1359 ahc
->flags
|= AHC_USEDEFAULTS
;
1360 kfree(ahc
->seep_config
);
1361 ahc
->seep_config
= NULL
;
1364 ahc_parse_pci_eeprom(ahc
, sc
);
1368 * Cards that have the external logic necessary to talk to
1369 * a SEEPROM, are almost certain to have the remaining logic
1370 * necessary for auto-termination control. This assumption
1371 * hasn't failed yet...
1373 have_autoterm
= have_seeprom
;
1376 * Some low-cost chips have SEEPROM and auto-term control built
1377 * in, instead of using a GAL. They can tell us directly
1378 * if the termination logic is enabled.
1380 if ((ahc
->features
& AHC_SPIOCAP
) != 0) {
1381 if ((ahc_inb(ahc
, SPIOCAP
) & SSPIOCPS
) == 0)
1382 have_autoterm
= FALSE
;
1385 if (have_autoterm
) {
1386 ahc
->flags
|= AHC_HAS_TERM_LOGIC
;
1387 ahc_acquire_seeprom(ahc
, &sd
);
1388 configure_termination(ahc
, &sd
, sc
->adapter_control
, sxfrctl1
);
1389 ahc_release_seeprom(&sd
);
1390 } else if (have_seeprom
) {
1391 *sxfrctl1
&= ~STPWEN
;
1392 if ((sc
->adapter_control
& CFSTERM
) != 0)
1393 *sxfrctl1
|= STPWEN
;
1395 printk("%s: Low byte termination %sabled\n",
1397 (*sxfrctl1
& STPWEN
) ? "en" : "dis");
1402 ahc_parse_pci_eeprom(struct ahc_softc
*ahc
, struct seeprom_config
*sc
)
1405 * Put the data we've collected down into SRAM
1406 * where ahc_init will find it.
1409 int max_targ
= sc
->max_targets
& CFMAXTARG
;
1411 uint16_t discenable
;
1416 if ((sc
->adapter_control
& CFULTRAEN
) != 0) {
1418 * Determine if this adapter has a "newstyle"
1421 for (i
= 0; i
< max_targ
; i
++) {
1422 if ((sc
->device_flags
[i
] & CFSYNCHISULTRA
) != 0) {
1423 ahc
->flags
|= AHC_NEWEEPROM_FMT
;
1429 for (i
= 0; i
< max_targ
; i
++) {
1431 uint16_t target_mask
;
1433 target_mask
= 0x01 << i
;
1434 if (sc
->device_flags
[i
] & CFDISC
)
1435 discenable
|= target_mask
;
1436 if ((ahc
->flags
& AHC_NEWEEPROM_FMT
) != 0) {
1437 if ((sc
->device_flags
[i
] & CFSYNCHISULTRA
) != 0)
1438 ultraenb
|= target_mask
;
1439 } else if ((sc
->adapter_control
& CFULTRAEN
) != 0) {
1440 ultraenb
|= target_mask
;
1442 if ((sc
->device_flags
[i
] & CFXFER
) == 0x04
1443 && (ultraenb
& target_mask
) != 0) {
1444 /* Treat 10MHz as a non-ultra speed */
1445 sc
->device_flags
[i
] &= ~CFXFER
;
1446 ultraenb
&= ~target_mask
;
1448 if ((ahc
->features
& AHC_ULTRA2
) != 0) {
1451 if (sc
->device_flags
[i
] & CFSYNCH
)
1452 offset
= MAX_OFFSET_ULTRA2
;
1455 ahc_outb(ahc
, TARG_OFFSET
+ i
, offset
);
1458 * The ultra enable bits contain the
1459 * high bit of the ultra2 sync rate
1462 scsirate
= (sc
->device_flags
[i
] & CFXFER
)
1463 | ((ultraenb
& target_mask
) ? 0x8 : 0x0);
1464 if (sc
->device_flags
[i
] & CFWIDEB
)
1465 scsirate
|= WIDEXFER
;
1467 scsirate
= (sc
->device_flags
[i
] & CFXFER
) << 4;
1468 if (sc
->device_flags
[i
] & CFSYNCH
)
1470 if (sc
->device_flags
[i
] & CFWIDEB
)
1471 scsirate
|= WIDEXFER
;
1473 ahc_outb(ahc
, TARG_SCSIRATE
+ i
, scsirate
);
1475 ahc
->our_id
= sc
->brtime_id
& CFSCSIID
;
1477 scsi_conf
= (ahc
->our_id
& 0x7);
1478 if (sc
->adapter_control
& CFSPARITY
)
1479 scsi_conf
|= ENSPCHK
;
1480 if (sc
->adapter_control
& CFRESETB
)
1481 scsi_conf
|= RESET_SCSI
;
1483 ahc
->flags
|= (sc
->adapter_control
& CFBOOTCHAN
) >> CFBOOTCHANSHIFT
;
1485 if (sc
->bios_control
& CFEXTEND
)
1486 ahc
->flags
|= AHC_EXTENDED_TRANS_A
;
1488 if (sc
->bios_control
& CFBIOSEN
)
1489 ahc
->flags
|= AHC_BIOS_ENABLED
;
1490 if (ahc
->features
& AHC_ULTRA
1491 && (ahc
->flags
& AHC_NEWEEPROM_FMT
) == 0) {
1492 /* Should we enable Ultra mode? */
1493 if (!(sc
->adapter_control
& CFULTRAEN
))
1494 /* Treat us as a non-ultra card */
1498 if (sc
->signature
== CFSIGNATURE
1499 || sc
->signature
== CFSIGNATURE2
) {
1502 /* Honor the STPWLEVEL settings */
1503 devconfig
= ahc_pci_read_config(ahc
->dev_softc
,
1504 DEVCONFIG
, /*bytes*/4);
1505 devconfig
&= ~STPWLEVEL
;
1506 if ((sc
->bios_control
& CFSTPWLEVEL
) != 0)
1507 devconfig
|= STPWLEVEL
;
1508 ahc_pci_write_config(ahc
->dev_softc
, DEVCONFIG
,
1509 devconfig
, /*bytes*/4);
1511 /* Set SCSICONF info */
1512 ahc_outb(ahc
, SCSICONF
, scsi_conf
);
1513 ahc_outb(ahc
, DISC_DSB
, ~(discenable
& 0xff));
1514 ahc_outb(ahc
, DISC_DSB
+ 1, ~((discenable
>> 8) & 0xff));
1515 ahc_outb(ahc
, ULTRA_ENB
, ultraenb
& 0xff);
1516 ahc_outb(ahc
, ULTRA_ENB
+ 1, (ultraenb
>> 8) & 0xff);
1520 configure_termination(struct ahc_softc
*ahc
,
1521 struct seeprom_descriptor
*sd
,
1522 u_int adapter_control
,
1530 * Update the settings in sxfrctl1 to match the
1531 * termination settings
1536 * SEECS must be on for the GALS to latch
1537 * the data properly. Be sure to leave MS
1538 * on or we will release the seeprom.
1540 SEEPROM_OUTB(sd
, sd
->sd_MS
| sd
->sd_CS
);
1541 if ((adapter_control
& CFAUTOTERM
) != 0
1542 || (ahc
->features
& AHC_NEW_TERMCTL
) != 0) {
1543 int internal50_present
;
1544 int internal68_present
;
1545 int externalcable_present
;
1557 if ((ahc
->features
& AHC_NEW_TERMCTL
) != 0) {
1558 ahc_new_term_detect(ahc
, &enableSEC_low
,
1563 if ((adapter_control
& CFSEAUTOTERM
) == 0) {
1565 printk("%s: Manual SE Termination\n",
1567 enableSEC_low
= (adapter_control
& CFSELOWTERM
);
1569 (adapter_control
& CFSEHIGHTERM
);
1571 if ((adapter_control
& CFAUTOTERM
) == 0) {
1573 printk("%s: Manual LVD Termination\n",
1575 enablePRI_low
= (adapter_control
& CFSTERM
);
1576 enablePRI_high
= (adapter_control
& CFWSTERM
);
1578 /* Make the table calculations below happy */
1579 internal50_present
= 0;
1580 internal68_present
= 1;
1581 externalcable_present
= 1;
1582 } else if ((ahc
->features
& AHC_SPIOCAP
) != 0) {
1583 aic785X_cable_detect(ahc
, &internal50_present
,
1584 &externalcable_present
,
1586 /* Can never support a wide connector. */
1587 internal68_present
= 0;
1589 aic787X_cable_detect(ahc
, &internal50_present
,
1590 &internal68_present
,
1591 &externalcable_present
,
1595 if ((ahc
->features
& AHC_WIDE
) == 0)
1596 internal68_present
= 0;
1599 && (ahc
->features
& AHC_ULTRA2
) == 0) {
1600 printk("%s: internal 50 cable %s present",
1602 internal50_present
? "is":"not");
1604 if ((ahc
->features
& AHC_WIDE
) != 0)
1605 printk(", internal 68 cable %s present",
1606 internal68_present
? "is":"not");
1607 printk("\n%s: external cable %s present\n",
1609 externalcable_present
? "is":"not");
1612 printk("%s: BIOS eeprom %s present\n",
1613 ahc_name(ahc
), eeprom_present
? "is" : "not");
1615 if ((ahc
->flags
& AHC_INT50_SPEEDFLEX
) != 0) {
1617 * The 50 pin connector is a separate bus,
1618 * so force it to always be terminated.
1619 * In the future, perform current sensing
1620 * to determine if we are in the middle of
1621 * a properly terminated bus.
1623 internal50_present
= 0;
1627 * Now set the termination based on what
1629 * Flash Enable = BRDDAT7
1630 * Secondary High Term Enable = BRDDAT6
1631 * Secondary Low Term Enable = BRDDAT5 (7890)
1632 * Primary High Term Enable = BRDDAT4 (7890)
1634 if ((ahc
->features
& AHC_ULTRA2
) == 0
1635 && (internal50_present
!= 0)
1636 && (internal68_present
!= 0)
1637 && (externalcable_present
!= 0)) {
1638 printk("%s: Illegal cable configuration!!. "
1639 "Only two connectors on the "
1640 "adapter may be used at a "
1641 "time!\n", ahc_name(ahc
));
1644 * Pretend there are no cables in the hope
1645 * that having all of the termination on
1646 * gives us a more stable bus.
1648 internal50_present
= 0;
1649 internal68_present
= 0;
1650 externalcable_present
= 0;
1653 if ((ahc
->features
& AHC_WIDE
) != 0
1654 && ((externalcable_present
== 0)
1655 || (internal68_present
== 0)
1656 || (enableSEC_high
!= 0))) {
1659 if ((ahc
->flags
& AHC_INT50_SPEEDFLEX
) != 0)
1660 printk("%s: 68 pin termination "
1661 "Enabled\n", ahc_name(ahc
));
1663 printk("%s: %sHigh byte termination "
1664 "Enabled\n", ahc_name(ahc
),
1665 enableSEC_high
? "Secondary "
1670 sum
= internal50_present
+ internal68_present
1671 + externalcable_present
;
1672 if (sum
< 2 || (enableSEC_low
!= 0)) {
1673 if ((ahc
->features
& AHC_ULTRA2
) != 0)
1676 *sxfrctl1
|= STPWEN
;
1678 if ((ahc
->flags
& AHC_INT50_SPEEDFLEX
) != 0)
1679 printk("%s: 50 pin termination "
1680 "Enabled\n", ahc_name(ahc
));
1682 printk("%s: %sLow byte termination "
1683 "Enabled\n", ahc_name(ahc
),
1684 enableSEC_low
? "Secondary "
1689 if (enablePRI_low
!= 0) {
1690 *sxfrctl1
|= STPWEN
;
1692 printk("%s: Primary Low Byte termination "
1693 "Enabled\n", ahc_name(ahc
));
1697 * Setup STPWEN before setting up the rest of
1698 * the termination per the tech note on the U160 cards.
1700 ahc_outb(ahc
, SXFRCTL1
, *sxfrctl1
);
1702 if (enablePRI_high
!= 0) {
1705 printk("%s: Primary High Byte "
1706 "termination Enabled\n",
1710 write_brdctl(ahc
, brddat
);
1713 if ((adapter_control
& CFSTERM
) != 0) {
1714 *sxfrctl1
|= STPWEN
;
1717 printk("%s: %sLow byte termination Enabled\n",
1719 (ahc
->features
& AHC_ULTRA2
) ? "Primary "
1723 if ((adapter_control
& CFWSTERM
) != 0
1724 && (ahc
->features
& AHC_WIDE
) != 0) {
1727 printk("%s: %sHigh byte termination Enabled\n",
1729 (ahc
->features
& AHC_ULTRA2
)
1730 ? "Secondary " : "");
1734 * Setup STPWEN before setting up the rest of
1735 * the termination per the tech note on the U160 cards.
1737 ahc_outb(ahc
, SXFRCTL1
, *sxfrctl1
);
1739 if ((ahc
->features
& AHC_WIDE
) != 0)
1740 write_brdctl(ahc
, brddat
);
1742 SEEPROM_OUTB(sd
, sd
->sd_MS
); /* Clear CS */
1746 ahc_new_term_detect(struct ahc_softc
*ahc
, int *enableSEC_low
,
1747 int *enableSEC_high
, int *enablePRI_low
,
1748 int *enablePRI_high
, int *eeprom_present
)
1754 * BRDDAT6 = Enable Secondary High Byte termination
1755 * BRDDAT5 = Enable Secondary Low Byte termination
1756 * BRDDAT4 = Enable Primary high byte termination
1757 * BRDDAT3 = Enable Primary low byte termination
1759 brdctl
= read_brdctl(ahc
);
1760 *eeprom_present
= brdctl
& BRDDAT7
;
1761 *enableSEC_high
= (brdctl
& BRDDAT6
);
1762 *enableSEC_low
= (brdctl
& BRDDAT5
);
1763 *enablePRI_high
= (brdctl
& BRDDAT4
);
1764 *enablePRI_low
= (brdctl
& BRDDAT3
);
1768 aic787X_cable_detect(struct ahc_softc
*ahc
, int *internal50_present
,
1769 int *internal68_present
, int *externalcable_present
,
1770 int *eeprom_present
)
1775 * First read the status of our cables.
1776 * Set the rom bank to 0 since the
1777 * bank setting serves as a multiplexor
1778 * for the cable detection logic.
1779 * BRDDAT5 controls the bank switch.
1781 write_brdctl(ahc
, 0);
1784 * Now read the state of the internal
1785 * connectors. BRDDAT6 is INT50 and
1788 brdctl
= read_brdctl(ahc
);
1789 *internal50_present
= (brdctl
& BRDDAT6
) ? 0 : 1;
1790 *internal68_present
= (brdctl
& BRDDAT7
) ? 0 : 1;
1793 * Set the rom bank to 1 and determine
1794 * the other signals.
1796 write_brdctl(ahc
, BRDDAT5
);
1799 * Now read the state of the external
1800 * connectors. BRDDAT6 is EXT68 and
1801 * BRDDAT7 is EPROMPS.
1803 brdctl
= read_brdctl(ahc
);
1804 *externalcable_present
= (brdctl
& BRDDAT6
) ? 0 : 1;
1805 *eeprom_present
= (brdctl
& BRDDAT7
) ? 1 : 0;
1809 aic785X_cable_detect(struct ahc_softc
*ahc
, int *internal50_present
,
1810 int *externalcable_present
, int *eeprom_present
)
1815 spiocap
= ahc_inb(ahc
, SPIOCAP
);
1816 spiocap
&= ~SOFTCMDEN
;
1817 spiocap
|= EXT_BRDCTL
;
1818 ahc_outb(ahc
, SPIOCAP
, spiocap
);
1819 ahc_outb(ahc
, BRDCTL
, BRDRW
|BRDCS
);
1820 ahc_flush_device_writes(ahc
);
1822 ahc_outb(ahc
, BRDCTL
, 0);
1823 ahc_flush_device_writes(ahc
);
1825 brdctl
= ahc_inb(ahc
, BRDCTL
);
1826 *internal50_present
= (brdctl
& BRDDAT5
) ? 0 : 1;
1827 *externalcable_present
= (brdctl
& BRDDAT6
) ? 0 : 1;
1828 *eeprom_present
= (ahc_inb(ahc
, SPIOCAP
) & EEPROM
) ? 1 : 0;
1832 ahc_acquire_seeprom(struct ahc_softc
*ahc
, struct seeprom_descriptor
*sd
)
1836 if ((ahc
->features
& AHC_SPIOCAP
) != 0
1837 && (ahc_inb(ahc
, SPIOCAP
) & SEEPROM
) == 0)
1841 * Request access of the memory port. When access is
1842 * granted, SEERDY will go high. We use a 1 second
1843 * timeout which should be near 1 second more than
1844 * is needed. Reason: after the chip reset, there
1845 * should be no contention.
1847 SEEPROM_OUTB(sd
, sd
->sd_MS
);
1848 wait
= 1000; /* 1 second timeout in msec */
1849 while (--wait
&& ((SEEPROM_STATUS_INB(sd
) & sd
->sd_RDY
) == 0)) {
1850 ahc_delay(1000); /* delay 1 msec */
1852 if ((SEEPROM_STATUS_INB(sd
) & sd
->sd_RDY
) == 0) {
1853 SEEPROM_OUTB(sd
, 0);
1860 ahc_release_seeprom(struct seeprom_descriptor
*sd
)
1862 /* Release access to the memory port and the serial EEPROM. */
1863 SEEPROM_OUTB(sd
, 0);
1867 write_brdctl(struct ahc_softc
*ahc
, uint8_t value
)
1871 if ((ahc
->chip
& AHC_CHIPID_MASK
) == AHC_AIC7895
) {
1873 if (ahc
->channel
== 'B')
1875 } else if ((ahc
->features
& AHC_ULTRA2
) != 0) {
1878 brdctl
= BRDSTB
|BRDCS
;
1880 ahc_outb(ahc
, BRDCTL
, brdctl
);
1881 ahc_flush_device_writes(ahc
);
1883 ahc_outb(ahc
, BRDCTL
, brdctl
);
1884 ahc_flush_device_writes(ahc
);
1885 if ((ahc
->features
& AHC_ULTRA2
) != 0)
1886 brdctl
|= BRDSTB_ULTRA2
;
1889 ahc_outb(ahc
, BRDCTL
, brdctl
);
1890 ahc_flush_device_writes(ahc
);
1891 if ((ahc
->features
& AHC_ULTRA2
) != 0)
1895 ahc_outb(ahc
, BRDCTL
, brdctl
);
1899 read_brdctl(struct ahc_softc
*ahc
)
1904 if ((ahc
->chip
& AHC_CHIPID_MASK
) == AHC_AIC7895
) {
1906 if (ahc
->channel
== 'B')
1908 } else if ((ahc
->features
& AHC_ULTRA2
) != 0) {
1909 brdctl
= BRDRW_ULTRA2
;
1911 brdctl
= BRDRW
|BRDCS
;
1913 ahc_outb(ahc
, BRDCTL
, brdctl
);
1914 ahc_flush_device_writes(ahc
);
1915 value
= ahc_inb(ahc
, BRDCTL
);
1916 ahc_outb(ahc
, BRDCTL
, 0);
1921 ahc_pci_intr(struct ahc_softc
*ahc
)
1926 error
= ahc_inb(ahc
, ERROR
);
1927 if ((error
& PCIERRSTAT
) == 0)
1930 status1
= ahc_pci_read_config(ahc
->dev_softc
,
1931 PCIR_STATUS
+ 1, /*bytes*/1);
1933 printk("%s: PCI error Interrupt at seqaddr = 0x%x\n",
1935 ahc_inb(ahc
, SEQADDR0
) | (ahc_inb(ahc
, SEQADDR1
) << 8));
1937 if (status1
& DPE
) {
1938 ahc
->pci_target_perr_count
++;
1939 printk("%s: Data Parity Error Detected during address "
1940 "or write data phase\n", ahc_name(ahc
));
1942 if (status1
& SSE
) {
1943 printk("%s: Signal System Error Detected\n", ahc_name(ahc
));
1945 if (status1
& RMA
) {
1946 printk("%s: Received a Master Abort\n", ahc_name(ahc
));
1948 if (status1
& RTA
) {
1949 printk("%s: Received a Target Abort\n", ahc_name(ahc
));
1951 if (status1
& STA
) {
1952 printk("%s: Signaled a Target Abort\n", ahc_name(ahc
));
1954 if (status1
& DPR
) {
1955 printk("%s: Data Parity Error has been reported via PERR#\n",
1959 /* Clear latched errors. */
1960 ahc_pci_write_config(ahc
->dev_softc
, PCIR_STATUS
+ 1,
1961 status1
, /*bytes*/1);
1963 if ((status1
& (DPE
|SSE
|RMA
|RTA
|STA
|DPR
)) == 0) {
1964 printk("%s: Latched PCIERR interrupt with "
1965 "no status bits set\n", ahc_name(ahc
));
1967 ahc_outb(ahc
, CLRINT
, CLRPARERR
);
1970 if (ahc
->pci_target_perr_count
> AHC_PCI_TARGET_PERR_THRESH
) {
1972 "%s: WARNING WARNING WARNING WARNING\n"
1973 "%s: Too many PCI parity errors observed as a target.\n"
1974 "%s: Some device on this bus is generating bad parity.\n"
1975 "%s: This is an error *observed by*, not *generated by*, this controller.\n"
1976 "%s: PCI parity error checking has been disabled.\n"
1977 "%s: WARNING WARNING WARNING WARNING\n",
1978 ahc_name(ahc
), ahc_name(ahc
), ahc_name(ahc
),
1979 ahc_name(ahc
), ahc_name(ahc
), ahc_name(ahc
));
1980 ahc
->seqctl
|= FAILDIS
;
1981 ahc_outb(ahc
, SEQCTL
, ahc
->seqctl
);
1987 ahc_pci_chip_init(struct ahc_softc
*ahc
)
1989 ahc_outb(ahc
, DSCOMMAND0
, ahc
->bus_softc
.pci_softc
.dscommand0
);
1990 ahc_outb(ahc
, DSPCISTATUS
, ahc
->bus_softc
.pci_softc
.dspcistatus
);
1991 if ((ahc
->features
& AHC_DT
) != 0) {
1994 sfunct
= ahc_inb(ahc
, SFUNCT
) & ~ALT_MODE
;
1995 ahc_outb(ahc
, SFUNCT
, sfunct
| ALT_MODE
);
1996 ahc_outb(ahc
, OPTIONMODE
, ahc
->bus_softc
.pci_softc
.optionmode
);
1997 ahc_outw(ahc
, TARGCRCCNT
, ahc
->bus_softc
.pci_softc
.targcrccnt
);
1998 ahc_outb(ahc
, SFUNCT
, sfunct
);
1999 ahc_outb(ahc
, CRCCONTROL1
,
2000 ahc
->bus_softc
.pci_softc
.crccontrol1
);
2002 if ((ahc
->features
& AHC_MULTI_FUNC
) != 0)
2003 ahc_outb(ahc
, SCBBADDR
, ahc
->bus_softc
.pci_softc
.scbbaddr
);
2005 if ((ahc
->features
& AHC_ULTRA2
) != 0)
2006 ahc_outb(ahc
, DFF_THRSH
, ahc
->bus_softc
.pci_softc
.dff_thrsh
);
2008 return (ahc_chip_init(ahc
));
2012 ahc_pci_resume(struct ahc_softc
*ahc
)
2015 * We assume that the OS has restored our register
2016 * mappings, etc. Just update the config space registers
2017 * that the OS doesn't know about and rely on our chip
2018 * reset handler to handle the rest.
2020 ahc_pci_write_config(ahc
->dev_softc
, DEVCONFIG
,
2021 ahc
->bus_softc
.pci_softc
.devconfig
, /*bytes*/4);
2022 ahc_pci_write_config(ahc
->dev_softc
, PCIR_COMMAND
,
2023 ahc
->bus_softc
.pci_softc
.command
, /*bytes*/1);
2024 ahc_pci_write_config(ahc
->dev_softc
, CSIZE_LATTIME
,
2025 ahc
->bus_softc
.pci_softc
.csize_lattime
, /*bytes*/1);
2026 if ((ahc
->flags
& AHC_HAS_TERM_LOGIC
) != 0) {
2027 struct seeprom_descriptor sd
;
2031 sd
.sd_control_offset
= SEECTL
;
2032 sd
.sd_status_offset
= SEECTL
;
2033 sd
.sd_dataout_offset
= SEECTL
;
2035 ahc_acquire_seeprom(ahc
, &sd
);
2036 configure_termination(ahc
, &sd
,
2037 ahc
->seep_config
->adapter_control
,
2039 ahc_release_seeprom(&sd
);
2044 ahc_aic785X_setup(struct ahc_softc
*ahc
)
2046 ahc_dev_softc_t pci
;
2049 pci
= ahc
->dev_softc
;
2051 ahc
->chip
= AHC_AIC7850
;
2052 ahc
->features
= AHC_AIC7850_FE
;
2053 ahc
->bugs
|= AHC_TMODE_WIDEODD_BUG
|AHC_CACHETHEN_BUG
|AHC_PCI_MWI_BUG
;
2054 rev
= ahc_pci_read_config(pci
, PCIR_REVID
, /*bytes*/1);
2056 ahc
->bugs
|= AHC_PCI_2_1_RETRY_BUG
;
2057 ahc
->instruction_ram_size
= 512;
2062 ahc_aic7860_setup(struct ahc_softc
*ahc
)
2064 ahc_dev_softc_t pci
;
2067 pci
= ahc
->dev_softc
;
2069 ahc
->chip
= AHC_AIC7860
;
2070 ahc
->features
= AHC_AIC7860_FE
;
2071 ahc
->bugs
|= AHC_TMODE_WIDEODD_BUG
|AHC_CACHETHEN_BUG
|AHC_PCI_MWI_BUG
;
2072 rev
= ahc_pci_read_config(pci
, PCIR_REVID
, /*bytes*/1);
2074 ahc
->bugs
|= AHC_PCI_2_1_RETRY_BUG
;
2075 ahc
->instruction_ram_size
= 512;
2080 ahc_apa1480_setup(struct ahc_softc
*ahc
)
2084 error
= ahc_aic7860_setup(ahc
);
2087 ahc
->features
|= AHC_REMOVABLE
;
2092 ahc_aic7870_setup(struct ahc_softc
*ahc
)
2096 ahc
->chip
= AHC_AIC7870
;
2097 ahc
->features
= AHC_AIC7870_FE
;
2098 ahc
->bugs
|= AHC_TMODE_WIDEODD_BUG
|AHC_CACHETHEN_BUG
|AHC_PCI_MWI_BUG
;
2099 ahc
->instruction_ram_size
= 512;
2104 ahc_aic7870h_setup(struct ahc_softc
*ahc
)
2106 int error
= ahc_aic7870_setup(ahc
);
2108 ahc
->features
|= AHC_HVD
;
2114 ahc_aha394X_setup(struct ahc_softc
*ahc
)
2118 error
= ahc_aic7870_setup(ahc
);
2120 error
= ahc_aha394XX_setup(ahc
);
2125 ahc_aha394Xh_setup(struct ahc_softc
*ahc
)
2127 int error
= ahc_aha394X_setup(ahc
);
2129 ahc
->features
|= AHC_HVD
;
2135 ahc_aha398X_setup(struct ahc_softc
*ahc
)
2139 error
= ahc_aic7870_setup(ahc
);
2141 error
= ahc_aha398XX_setup(ahc
);
2146 ahc_aha494X_setup(struct ahc_softc
*ahc
)
2150 error
= ahc_aic7870_setup(ahc
);
2152 error
= ahc_aha494XX_setup(ahc
);
2157 ahc_aha494Xh_setup(struct ahc_softc
*ahc
)
2159 int error
= ahc_aha494X_setup(ahc
);
2161 ahc
->features
|= AHC_HVD
;
2167 ahc_aic7880_setup(struct ahc_softc
*ahc
)
2169 ahc_dev_softc_t pci
;
2172 pci
= ahc
->dev_softc
;
2174 ahc
->chip
= AHC_AIC7880
;
2175 ahc
->features
= AHC_AIC7880_FE
;
2176 ahc
->bugs
|= AHC_TMODE_WIDEODD_BUG
;
2177 rev
= ahc_pci_read_config(pci
, PCIR_REVID
, /*bytes*/1);
2179 ahc
->bugs
|= AHC_PCI_2_1_RETRY_BUG
;
2181 ahc
->bugs
|= AHC_CACHETHEN_BUG
|AHC_PCI_MWI_BUG
;
2183 ahc
->instruction_ram_size
= 512;
2188 ahc_aic7880h_setup(struct ahc_softc
*ahc
)
2190 int error
= ahc_aic7880_setup(ahc
);
2192 ahc
->features
|= AHC_HVD
;
2199 ahc_aha2940Pro_setup(struct ahc_softc
*ahc
)
2202 ahc
->flags
|= AHC_INT50_SPEEDFLEX
;
2203 return (ahc_aic7880_setup(ahc
));
2207 ahc_aha394XU_setup(struct ahc_softc
*ahc
)
2211 error
= ahc_aic7880_setup(ahc
);
2213 error
= ahc_aha394XX_setup(ahc
);
2218 ahc_aha394XUh_setup(struct ahc_softc
*ahc
)
2220 int error
= ahc_aha394XU_setup(ahc
);
2222 ahc
->features
|= AHC_HVD
;
2228 ahc_aha398XU_setup(struct ahc_softc
*ahc
)
2232 error
= ahc_aic7880_setup(ahc
);
2234 error
= ahc_aha398XX_setup(ahc
);
2239 ahc_aic7890_setup(struct ahc_softc
*ahc
)
2241 ahc_dev_softc_t pci
;
2244 pci
= ahc
->dev_softc
;
2246 ahc
->chip
= AHC_AIC7890
;
2247 ahc
->features
= AHC_AIC7890_FE
;
2248 ahc
->flags
|= AHC_NEWEEPROM_FMT
;
2249 rev
= ahc_pci_read_config(pci
, PCIR_REVID
, /*bytes*/1);
2251 ahc
->bugs
|= AHC_AUTOFLUSH_BUG
|AHC_CACHETHEN_BUG
;
2252 ahc
->instruction_ram_size
= 768;
2257 ahc_aic7892_setup(struct ahc_softc
*ahc
)
2261 ahc
->chip
= AHC_AIC7892
;
2262 ahc
->features
= AHC_AIC7892_FE
;
2263 ahc
->flags
|= AHC_NEWEEPROM_FMT
;
2264 ahc
->bugs
|= AHC_SCBCHAN_UPLOAD_BUG
;
2265 ahc
->instruction_ram_size
= 1024;
2270 ahc_aic7895_setup(struct ahc_softc
*ahc
)
2272 ahc_dev_softc_t pci
;
2275 pci
= ahc
->dev_softc
;
2276 ahc
->channel
= ahc_get_pci_function(pci
) == 1 ? 'B' : 'A';
2278 * The 'C' revision of the aic7895 has a few additional features.
2280 rev
= ahc_pci_read_config(pci
, PCIR_REVID
, /*bytes*/1);
2282 ahc
->chip
= AHC_AIC7895C
;
2283 ahc
->features
= AHC_AIC7895C_FE
;
2287 ahc
->chip
= AHC_AIC7895
;
2288 ahc
->features
= AHC_AIC7895_FE
;
2291 * The BIOS disables the use of MWI transactions
2292 * since it does not have the MWI bug work around
2293 * we have. Disabling MWI reduces performance, so
2296 command
= ahc_pci_read_config(pci
, PCIR_COMMAND
, /*bytes*/1);
2297 command
|= PCIM_CMD_MWRICEN
;
2298 ahc_pci_write_config(pci
, PCIR_COMMAND
, command
, /*bytes*/1);
2299 ahc
->bugs
|= AHC_PCI_MWI_BUG
;
2302 * XXX Does CACHETHEN really not work??? What about PCI retry?
2303 * on C level chips. Need to test, but for now, play it safe.
2305 ahc
->bugs
|= AHC_TMODE_WIDEODD_BUG
|AHC_PCI_2_1_RETRY_BUG
2306 | AHC_CACHETHEN_BUG
;
2312 * Cachesize must also be zero due to stray DAC
2313 * problem when sitting behind some bridges.
2315 ahc_pci_write_config(pci
, CSIZE_LATTIME
, 0, /*bytes*/1);
2316 devconfig
= ahc_pci_read_config(pci
, DEVCONFIG
, /*bytes*/1);
2317 devconfig
|= MRDCEN
;
2318 ahc_pci_write_config(pci
, DEVCONFIG
, devconfig
, /*bytes*/1);
2320 ahc
->flags
|= AHC_NEWEEPROM_FMT
;
2321 ahc
->instruction_ram_size
= 512;
2326 ahc_aic7895h_setup(struct ahc_softc
*ahc
)
2328 int error
= ahc_aic7895_setup(ahc
);
2330 ahc
->features
|= AHC_HVD
;
2336 ahc_aic7896_setup(struct ahc_softc
*ahc
)
2338 ahc_dev_softc_t pci
;
2340 pci
= ahc
->dev_softc
;
2341 ahc
->channel
= ahc_get_pci_function(pci
) == 1 ? 'B' : 'A';
2342 ahc
->chip
= AHC_AIC7896
;
2343 ahc
->features
= AHC_AIC7896_FE
;
2344 ahc
->flags
|= AHC_NEWEEPROM_FMT
;
2345 ahc
->bugs
|= AHC_CACHETHEN_DIS_BUG
;
2346 ahc
->instruction_ram_size
= 768;
2351 ahc_aic7899_setup(struct ahc_softc
*ahc
)
2353 ahc_dev_softc_t pci
;
2355 pci
= ahc
->dev_softc
;
2356 ahc
->channel
= ahc_get_pci_function(pci
) == 1 ? 'B' : 'A';
2357 ahc
->chip
= AHC_AIC7899
;
2358 ahc
->features
= AHC_AIC7899_FE
;
2359 ahc
->flags
|= AHC_NEWEEPROM_FMT
;
2360 ahc
->bugs
|= AHC_SCBCHAN_UPLOAD_BUG
;
2361 ahc
->instruction_ram_size
= 1024;
2366 ahc_aha29160C_setup(struct ahc_softc
*ahc
)
2370 error
= ahc_aic7899_setup(ahc
);
2373 ahc
->features
|= AHC_REMOVABLE
;
2378 ahc_raid_setup(struct ahc_softc
*ahc
)
2380 printk("RAID functionality unsupported\n");
2385 ahc_aha394XX_setup(struct ahc_softc
*ahc
)
2387 ahc_dev_softc_t pci
;
2389 pci
= ahc
->dev_softc
;
2390 switch (ahc_get_pci_slot(pci
)) {
2391 case AHC_394X_SLOT_CHANNEL_A
:
2394 case AHC_394X_SLOT_CHANNEL_B
:
2398 printk("adapter at unexpected slot %d\n"
2399 "unable to map to a channel\n",
2400 ahc_get_pci_slot(pci
));
2407 ahc_aha398XX_setup(struct ahc_softc
*ahc
)
2409 ahc_dev_softc_t pci
;
2411 pci
= ahc
->dev_softc
;
2412 switch (ahc_get_pci_slot(pci
)) {
2413 case AHC_398X_SLOT_CHANNEL_A
:
2416 case AHC_398X_SLOT_CHANNEL_B
:
2419 case AHC_398X_SLOT_CHANNEL_C
:
2423 printk("adapter at unexpected slot %d\n"
2424 "unable to map to a channel\n",
2425 ahc_get_pci_slot(pci
));
2429 ahc
->flags
|= AHC_LARGE_SEEPROM
;
2434 ahc_aha494XX_setup(struct ahc_softc
*ahc
)
2436 ahc_dev_softc_t pci
;
2438 pci
= ahc
->dev_softc
;
2439 switch (ahc_get_pci_slot(pci
)) {
2440 case AHC_494X_SLOT_CHANNEL_A
:
2443 case AHC_494X_SLOT_CHANNEL_B
:
2446 case AHC_494X_SLOT_CHANNEL_C
:
2449 case AHC_494X_SLOT_CHANNEL_D
:
2453 printk("adapter at unexpected slot %d\n"
2454 "unable to map to a channel\n",
2455 ahc_get_pci_slot(pci
));
2458 ahc
->flags
|= AHC_LARGE_SEEPROM
;