Deleted Added
full compact
aic7xxx_pci.c (76634) aic7xxx_pci.c (79874)
1/*
2 * Product specific probe and attach routines for:
3 * 3940, 2940, aic7895, aic7890, aic7880,
4 * aic7870, aic7860 and aic7850 SCSI controllers
5 *
6 * Copyright (c) 1995-2000 Justin T. Gibbs
7 * All rights reserved.
8 *

--- 16 unchanged lines hidden (view full) ---

25 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 *
1/*
2 * Product specific probe and attach routines for:
3 * 3940, 2940, aic7895, aic7890, aic7880,
4 * aic7870, aic7860 and aic7850 SCSI controllers
5 *
6 * Copyright (c) 1995-2000 Justin T. Gibbs
7 * All rights reserved.
8 *

--- 16 unchanged lines hidden (view full) ---

25 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 *
33 * $Id: //depot/src/aic7xxx/aic7xxx_pci.c#24 $
33 * $Id: //depot/src/aic7xxx/aic7xxx_pci.c#27 $
34 *
34 *
35 * $FreeBSD: head/sys/dev/aic7xxx/aic7xxx_pci.c 76634 2001-05-15 19:41:12Z gibbs $
35 * $FreeBSD: head/sys/dev/aic7xxx/aic7xxx_pci.c 79874 2001-07-18 21:39:48Z gibbs $
36 */
37
38#include <dev/aic7xxx/aic7xxx_freebsd.h>
39#include <dev/aic7xxx/aic7xxx_inline.h>
40#include <dev/aic7xxx/aic7xxx_93cx6.h>
41
42#define AHC_PCI_IOADDR PCIR_MAPS /* I/O Address */
43#define AHC_PCI_MEMADDR (PCIR_MAPS + 4) /* Mem I/O Address */

--- 579 unchanged lines hidden (view full) ---

623#define AHC_494X_SLOT_CHANNEL_A 4
624#define AHC_494X_SLOT_CHANNEL_B 5
625#define AHC_494X_SLOT_CHANNEL_C 6
626#define AHC_494X_SLOT_CHANNEL_D 7
627
628#define DEVCONFIG 0x40
629#define SCBSIZE32 0x00010000ul /* aic789X only */
630#define REXTVALID 0x00001000ul /* ultra cards only */
36 */
37
38#include <dev/aic7xxx/aic7xxx_freebsd.h>
39#include <dev/aic7xxx/aic7xxx_inline.h>
40#include <dev/aic7xxx/aic7xxx_93cx6.h>
41
42#define AHC_PCI_IOADDR PCIR_MAPS /* I/O Address */
43#define AHC_PCI_MEMADDR (PCIR_MAPS + 4) /* Mem I/O Address */

--- 579 unchanged lines hidden (view full) ---

623#define AHC_494X_SLOT_CHANNEL_A 4
624#define AHC_494X_SLOT_CHANNEL_B 5
625#define AHC_494X_SLOT_CHANNEL_C 6
626#define AHC_494X_SLOT_CHANNEL_D 7
627
628#define DEVCONFIG 0x40
629#define SCBSIZE32 0x00010000ul /* aic789X only */
630#define REXTVALID 0x00001000ul /* ultra cards only */
631#define MPORTMODE 0x00000400ul /* aic7870 only */
632#define RAMPSM 0x00000200ul /* aic7870 only */
631#define MPORTMODE 0x00000400ul /* aic7870+ only */
632#define RAMPSM 0x00000200ul /* aic7870+ only */
633#define VOLSENSE 0x00000100ul
633#define VOLSENSE 0x00000100ul
634#define PCI64BIT 0x00000080ul /* 64Bit PCI bus (Ultra2 Only)*/
634#define SCBRAMSEL 0x00000080ul
635#define MRDCEN 0x00000040ul
636#define EXTSCBTIME 0x00000020ul /* aic7870 only */
637#define EXTSCBPEN 0x00000010ul /* aic7870 only */
638#define BERREN 0x00000008ul
639#define DACEN 0x00000004ul
640#define STPWLEVEL 0x00000002ul
641#define DIFACTNEGEN 0x00000001ul /* aic7870 only */

--- 46 unchanged lines hidden (view full) ---

688 device = ahc_pci_read_config(pci, PCIR_DEVICE, /*bytes*/2);
689 subvendor = ahc_pci_read_config(pci, PCIR_SUBVEND_0, /*bytes*/2);
690 subdevice = ahc_pci_read_config(pci, PCIR_SUBDEV_0, /*bytes*/2);
691 full_id = ahc_compose_id(device,
692 vendor,
693 subdevice,
694 subvendor);
695
635#define SCBRAMSEL 0x00000080ul
636#define MRDCEN 0x00000040ul
637#define EXTSCBTIME 0x00000020ul /* aic7870 only */
638#define EXTSCBPEN 0x00000010ul /* aic7870 only */
639#define BERREN 0x00000008ul
640#define DACEN 0x00000004ul
641#define STPWLEVEL 0x00000002ul
642#define DIFACTNEGEN 0x00000001ul /* aic7870 only */

--- 46 unchanged lines hidden (view full) ---

689 device = ahc_pci_read_config(pci, PCIR_DEVICE, /*bytes*/2);
690 subvendor = ahc_pci_read_config(pci, PCIR_SUBVEND_0, /*bytes*/2);
691 subdevice = ahc_pci_read_config(pci, PCIR_SUBDEV_0, /*bytes*/2);
692 full_id = ahc_compose_id(device,
693 vendor,
694 subdevice,
695 subvendor);
696
696 /* If the second function is not hooked up, ignore it. */
697 /*
698 * If the second function is not hooked up, ignore it.
699 * Unfortunately, not all MB vendors implement the
700 * subdevice ID as per the Adaptec spec, so do our best
701 * to sanity check it prior to accepting the subdevice
702 * ID as valid.
703 */
697 if (ahc_get_pci_function(pci) > 0
698 && subvendor == 0x9005
704 if (ahc_get_pci_function(pci) > 0
705 && subvendor == 0x9005
706 && subdevice != device
699 && SUBID_9005_TYPE_KNOWN(subdevice) != 0
700 && SUBID_9005_MFUNCENB(subdevice) == 0)
701 return (NULL);
702
703 for (i = 0; i < ahc_num_pci_devs; i++) {
704 entry = &ahc_pci_ident_table[i];
705 if (entry->full_id == (full_id & entry->id_mask)) {
706 /* Honor exclusion entries. */
707 if (entry->name == NULL)
708 return (NULL);
709 return (entry);
710 }
711 }
712 return (NULL);
713}
714
715int
716ahc_pci_config(struct ahc_softc *ahc, struct ahc_pci_identity *entry)
717{
707 && SUBID_9005_TYPE_KNOWN(subdevice) != 0
708 && SUBID_9005_MFUNCENB(subdevice) == 0)
709 return (NULL);
710
711 for (i = 0; i < ahc_num_pci_devs; i++) {
712 entry = &ahc_pci_ident_table[i];
713 if (entry->full_id == (full_id & entry->id_mask)) {
714 /* Honor exclusion entries. */
715 if (entry->name == NULL)
716 return (NULL);
717 return (entry);
718 }
719 }
720 return (NULL);
721}
722
723int
724ahc_pci_config(struct ahc_softc *ahc, struct ahc_pci_identity *entry)
725{
718 struct ahc_probe_config probe_config;
719 struct scb_data *shared_scb_data;
720 u_int command;
721 u_int our_id = 0;
722 u_int sxfrctl1;
723 u_int scsiseq;
724 u_int dscommand0;
725 int error;
726 uint8_t sblkctl;
727
728 shared_scb_data = NULL;
726 struct scb_data *shared_scb_data;
727 u_int command;
728 u_int our_id = 0;
729 u_int sxfrctl1;
730 u_int scsiseq;
731 u_int dscommand0;
732 int error;
733 uint8_t sblkctl;
734
735 shared_scb_data = NULL;
729 ahc_init_probe_config(&probe_config);
730 error = entry->setup(ahc->dev_softc, &probe_config);
736 error = entry->setup(ahc);
731 if (error != 0)
732 return (error);
737 if (error != 0)
738 return (error);
733 probe_config.chip |= AHC_PCI;
734 probe_config.description = entry->name;
739 ahc->chip |= AHC_PCI;
740 ahc->description = entry->name;
735
736 error = ahc_pci_map_registers(ahc);
737 if (error != 0)
738 return (error);
739
740 ahc_power_state_change(ahc, AHC_POWER_STATE_D0);
741
741
742 error = ahc_pci_map_registers(ahc);
743 if (error != 0)
744 return (error);
745
746 ahc_power_state_change(ahc, AHC_POWER_STATE_D0);
747
748 /*
749 * If we need to support high memory, enable dual
750 * address cycles. This bit must be set to enable
751 * high address bit generation even if we are on a
752 * 64bit bus (PCI64BIT set in devconfig).
753 */
754 if ((ahc->flags & AHC_39BIT_ADDRESSING) != 0) {
755 uint32_t devconfig;
756
757 if (bootverbose)
758 printf("%s: Enabling 39Bit Addressing\n",
759 ahc_name(ahc));
760 devconfig = ahc_pci_read_config(ahc->dev_softc,
761 DEVCONFIG, /*bytes*/4);
762 devconfig |= DACEN;
763 ahc_pci_write_config(ahc->dev_softc, DEVCONFIG,
764 devconfig, /*bytes*/4);
765 }
766
742 /* Ensure busmastering is enabled */
743 command = ahc_pci_read_config(ahc->dev_softc, PCIR_COMMAND, /*bytes*/1);
744 command |= PCIM_CMD_BUSMASTEREN;
745 ahc_pci_write_config(ahc->dev_softc, PCIR_COMMAND, command, /*bytes*/1);
746
747 /* On all PCI adapters, we allow SCB paging */
767 /* Ensure busmastering is enabled */
768 command = ahc_pci_read_config(ahc->dev_softc, PCIR_COMMAND, /*bytes*/1);
769 command |= PCIM_CMD_BUSMASTEREN;
770 ahc_pci_write_config(ahc->dev_softc, PCIR_COMMAND, command, /*bytes*/1);
771
772 /* On all PCI adapters, we allow SCB paging */
748 probe_config.flags |= AHC_PAGESCBS;
773 ahc->flags |= AHC_PAGESCBS;
749
774
750 error = ahc_softc_init(ahc, &probe_config);
775 error = ahc_softc_init(ahc);
751 if (error != 0)
752 return (error);
753
754 ahc->bus_intr = ahc_pci_intr;
755
756 /* Remeber how the card was setup in case there is no SEEPROM */
757 if ((ahc_inb(ahc, HCNTRL) & POWRDN) == 0) {
758 ahc_pause(ahc);

--- 1000 unchanged lines hidden (view full) ---

1759 }
1760 if (status1 & STA) {
1761 printf("%s: Signaled a Target Abort\n", ahc_name(ahc));
1762 }
1763 if (status1 & DPR) {
1764 printf("%s: Data Parity Error has been reported via PERR#\n",
1765 ahc_name(ahc));
1766 }
776 if (error != 0)
777 return (error);
778
779 ahc->bus_intr = ahc_pci_intr;
780
781 /* Remeber how the card was setup in case there is no SEEPROM */
782 if ((ahc_inb(ahc, HCNTRL) & POWRDN) == 0) {
783 ahc_pause(ahc);

--- 1000 unchanged lines hidden (view full) ---

1784 }
1785 if (status1 & STA) {
1786 printf("%s: Signaled a Target Abort\n", ahc_name(ahc));
1787 }
1788 if (status1 & DPR) {
1789 printf("%s: Data Parity Error has been reported via PERR#\n",
1790 ahc_name(ahc));
1791 }
1767 if ((status1 & (DPE|SSE|RMA|RTA|STA|DPR)) == 0) {
1768 printf("%s: Latched PCIERR interrupt with "
1769 "no status bits set\n", ahc_name(ahc));
1770 }
1792
1793 /* Clear latched errors. */
1771 ahc_pci_write_config(ahc->dev_softc, PCIR_STATUS + 1,
1772 status1, /*bytes*/1);
1773
1794 ahc_pci_write_config(ahc->dev_softc, PCIR_STATUS + 1,
1795 status1, /*bytes*/1);
1796
1774 if (status1 & (DPR|RMA|RTA)) {
1797 if ((status1 & (DPE|SSE|RMA|RTA|STA|DPR)) == 0) {
1798 printf("%s: Latched PCIERR interrupt with "
1799 "no status bits set\n", ahc_name(ahc));
1800 } else {
1775 ahc_outb(ahc, CLRINT, CLRPARERR);
1776 }
1777
1778 ahc_unpause(ahc);
1779}
1780
1781static int
1801 ahc_outb(ahc, CLRINT, CLRPARERR);
1802 }
1803
1804 ahc_unpause(ahc);
1805}
1806
1807static int
1782ahc_aic785X_setup(ahc_dev_softc_t pci, struct ahc_probe_config *probe_config)
1808ahc_aic785X_setup(struct ahc_softc *ahc)
1783{
1809{
1810 ahc_dev_softc_t pci;
1784 uint8_t rev;
1785
1811 uint8_t rev;
1812
1786 probe_config->channel = 'A';
1787 probe_config->chip = AHC_AIC7850;
1788 probe_config->features = AHC_AIC7850_FE;
1789 probe_config->bugs |= AHC_TMODE_WIDEODD_BUG|AHC_CACHETHEN_BUG
1790 | AHC_PCI_MWI_BUG;
1813 pci = ahc->dev_softc;
1814 ahc->channel = 'A';
1815 ahc->chip = AHC_AIC7850;
1816 ahc->features = AHC_AIC7850_FE;
1817 ahc->bugs |= AHC_TMODE_WIDEODD_BUG|AHC_CACHETHEN_BUG|AHC_PCI_MWI_BUG;
1791 rev = ahc_pci_read_config(pci, PCIR_REVID, /*bytes*/1);
1792 if (rev >= 1)
1818 rev = ahc_pci_read_config(pci, PCIR_REVID, /*bytes*/1);
1819 if (rev >= 1)
1793 probe_config->bugs |= AHC_PCI_2_1_RETRY_BUG;
1820 ahc->bugs |= AHC_PCI_2_1_RETRY_BUG;
1794 return (0);
1795}
1796
1797static int
1821 return (0);
1822}
1823
1824static int
1798ahc_aic7860_setup(ahc_dev_softc_t pci, struct ahc_probe_config *probe_config)
1825ahc_aic7860_setup(struct ahc_softc *ahc)
1799{
1826{
1827 ahc_dev_softc_t pci;
1800 uint8_t rev;
1801
1828 uint8_t rev;
1829
1802 probe_config->channel = 'A';
1803 probe_config->chip = AHC_AIC7860;
1804 probe_config->features = AHC_AIC7860_FE;
1805 probe_config->bugs |= AHC_TMODE_WIDEODD_BUG|AHC_CACHETHEN_BUG
1806 | AHC_PCI_MWI_BUG;
1830 pci = ahc->dev_softc;
1831 ahc->channel = 'A';
1832 ahc->chip = AHC_AIC7860;
1833 ahc->features = AHC_AIC7860_FE;
1834 ahc->bugs |= AHC_TMODE_WIDEODD_BUG|AHC_CACHETHEN_BUG|AHC_PCI_MWI_BUG;
1807 rev = ahc_pci_read_config(pci, PCIR_REVID, /*bytes*/1);
1808 if (rev >= 1)
1835 rev = ahc_pci_read_config(pci, PCIR_REVID, /*bytes*/1);
1836 if (rev >= 1)
1809 probe_config->bugs |= AHC_PCI_2_1_RETRY_BUG;
1837 ahc->bugs |= AHC_PCI_2_1_RETRY_BUG;
1810 return (0);
1811}
1812
1813static int
1838 return (0);
1839}
1840
1841static int
1814ahc_apa1480_setup(ahc_dev_softc_t pci, struct ahc_probe_config *probe_config)
1842ahc_apa1480_setup(struct ahc_softc *ahc)
1815{
1843{
1844 ahc_dev_softc_t pci;
1816 int error;
1817
1845 int error;
1846
1818 error = ahc_aic7860_setup(pci, probe_config);
1847 pci = ahc->dev_softc;
1848 error = ahc_aic7860_setup(ahc);
1819 if (error != 0)
1820 return (error);
1849 if (error != 0)
1850 return (error);
1821 probe_config->features |= AHC_REMOVABLE;
1851 ahc->features |= AHC_REMOVABLE;
1822 return (0);
1823}
1824
1825static int
1852 return (0);
1853}
1854
1855static int
1826ahc_aic7870_setup(ahc_dev_softc_t pci, struct ahc_probe_config *probe_config)
1856ahc_aic7870_setup(struct ahc_softc *ahc)
1827{
1857{
1828 probe_config->channel = 'A';
1829 probe_config->chip = AHC_AIC7870;
1830 probe_config->features = AHC_AIC7870_FE;
1831 probe_config->bugs |= AHC_TMODE_WIDEODD_BUG|AHC_CACHETHEN_BUG
1832 | AHC_PCI_MWI_BUG;
1858 ahc_dev_softc_t pci;
1859
1860 pci = ahc->dev_softc;
1861 ahc->channel = 'A';
1862 ahc->chip = AHC_AIC7870;
1863 ahc->features = AHC_AIC7870_FE;
1864 ahc->bugs |= AHC_TMODE_WIDEODD_BUG|AHC_CACHETHEN_BUG|AHC_PCI_MWI_BUG;
1833 return (0);
1834}
1835
1836static int
1865 return (0);
1866}
1867
1868static int
1837ahc_aha394X_setup(ahc_dev_softc_t pci, struct ahc_probe_config *probe_config)
1869ahc_aha394X_setup(struct ahc_softc *ahc)
1838{
1839 int error;
1840
1870{
1871 int error;
1872
1841 error = ahc_aic7870_setup(pci, probe_config);
1873 error = ahc_aic7870_setup(ahc);
1842 if (error == 0)
1874 if (error == 0)
1843 error = ahc_aha394XX_setup(pci, probe_config);
1875 error = ahc_aha394XX_setup(ahc);
1844 return (error);
1845}
1846
1847static int
1876 return (error);
1877}
1878
1879static int
1848ahc_aha398X_setup(ahc_dev_softc_t pci, struct ahc_probe_config *probe_config)
1880ahc_aha398X_setup(struct ahc_softc *ahc)
1849{
1850 int error;
1851
1881{
1882 int error;
1883
1852 error = ahc_aic7870_setup(pci, probe_config);
1884 error = ahc_aic7870_setup(ahc);
1853 if (error == 0)
1885 if (error == 0)
1854 error = ahc_aha398XX_setup(pci, probe_config);
1886 error = ahc_aha398XX_setup(ahc);
1855 return (error);
1856}
1857
1858static int
1887 return (error);
1888}
1889
1890static int
1859ahc_aha494X_setup(ahc_dev_softc_t pci, struct ahc_probe_config *probe_config)
1891ahc_aha494X_setup(struct ahc_softc *ahc)
1860{
1861 int error;
1862
1892{
1893 int error;
1894
1863 error = ahc_aic7870_setup(pci, probe_config);
1895 error = ahc_aic7870_setup(ahc);
1864 if (error == 0)
1896 if (error == 0)
1865 error = ahc_aha494XX_setup(pci, probe_config);
1897 error = ahc_aha494XX_setup(ahc);
1866 return (error);
1867}
1868
1869static int
1898 return (error);
1899}
1900
1901static int
1870ahc_aic7880_setup(ahc_dev_softc_t pci, struct ahc_probe_config *probe_config)
1902ahc_aic7880_setup(struct ahc_softc *ahc)
1871{
1903{
1904 ahc_dev_softc_t pci;
1872 uint8_t rev;
1873
1905 uint8_t rev;
1906
1874 probe_config->channel = 'A';
1875 probe_config->chip = AHC_AIC7880;
1876 probe_config->features = AHC_AIC7880_FE;
1877 probe_config->bugs |= AHC_TMODE_WIDEODD_BUG;
1907 pci = ahc->dev_softc;
1908 ahc->channel = 'A';
1909 ahc->chip = AHC_AIC7880;
1910 ahc->features = AHC_AIC7880_FE;
1911 ahc->bugs |= AHC_TMODE_WIDEODD_BUG;
1878 rev = ahc_pci_read_config(pci, PCIR_REVID, /*bytes*/1);
1879 if (rev >= 1) {
1912 rev = ahc_pci_read_config(pci, PCIR_REVID, /*bytes*/1);
1913 if (rev >= 1) {
1880 probe_config->bugs |= AHC_PCI_2_1_RETRY_BUG;
1914 ahc->bugs |= AHC_PCI_2_1_RETRY_BUG;
1881 } else {
1915 } else {
1882 probe_config->bugs |= AHC_CACHETHEN_BUG|AHC_PCI_MWI_BUG;
1916 ahc->bugs |= AHC_CACHETHEN_BUG|AHC_PCI_MWI_BUG;
1883 }
1884 return (0);
1885}
1886
1887static int
1917 }
1918 return (0);
1919}
1920
1921static int
1888ahc_aha2940Pro_setup(ahc_dev_softc_t pci, struct ahc_probe_config *probe_config)
1922ahc_aha2940Pro_setup(struct ahc_softc *ahc)
1889{
1923{
1924 ahc_dev_softc_t pci;
1890 int error;
1891
1925 int error;
1926
1892 probe_config->flags |= AHC_INT50_SPEEDFLEX;
1893 error = ahc_aic7880_setup(pci, probe_config);
1927 pci = ahc->dev_softc;
1928 ahc->flags |= AHC_INT50_SPEEDFLEX;
1929 error = ahc_aic7880_setup(ahc);
1894 return (0);
1895}
1896
1897static int
1930 return (0);
1931}
1932
1933static int
1898ahc_aha394XU_setup(ahc_dev_softc_t pci, struct ahc_probe_config *probe_config)
1934ahc_aha394XU_setup(struct ahc_softc *ahc)
1899{
1900 int error;
1901
1935{
1936 int error;
1937
1902 error = ahc_aic7880_setup(pci, probe_config);
1938 error = ahc_aic7880_setup(ahc);
1903 if (error == 0)
1939 if (error == 0)
1904 error = ahc_aha394XX_setup(pci, probe_config);
1940 error = ahc_aha394XX_setup(ahc);
1905 return (error);
1906}
1907
1908static int
1941 return (error);
1942}
1943
1944static int
1909ahc_aha398XU_setup(ahc_dev_softc_t pci, struct ahc_probe_config *probe_config)
1945ahc_aha398XU_setup(struct ahc_softc *ahc)
1910{
1911 int error;
1912
1946{
1947 int error;
1948
1913 error = ahc_aic7880_setup(pci, probe_config);
1949 error = ahc_aic7880_setup(ahc);
1914 if (error == 0)
1950 if (error == 0)
1915 error = ahc_aha398XX_setup(pci, probe_config);
1951 error = ahc_aha398XX_setup(ahc);
1916 return (error);
1917}
1918
1919static int
1952 return (error);
1953}
1954
1955static int
1920ahc_aic7890_setup(ahc_dev_softc_t pci, struct ahc_probe_config *probe_config)
1956ahc_aic7890_setup(struct ahc_softc *ahc)
1921{
1957{
1958 ahc_dev_softc_t pci;
1922 uint8_t rev;
1923
1959 uint8_t rev;
1960
1924 probe_config->channel = 'A';
1925 probe_config->chip = AHC_AIC7890;
1926 probe_config->features = AHC_AIC7890_FE;
1927 probe_config->flags |= AHC_NEWEEPROM_FMT;
1961 pci = ahc->dev_softc;
1962 ahc->channel = 'A';
1963 ahc->chip = AHC_AIC7890;
1964 ahc->features = AHC_AIC7890_FE;
1965 ahc->flags |= AHC_NEWEEPROM_FMT;
1928 rev = ahc_pci_read_config(pci, PCIR_REVID, /*bytes*/1);
1929 if (rev == 0)
1966 rev = ahc_pci_read_config(pci, PCIR_REVID, /*bytes*/1);
1967 if (rev == 0)
1930 probe_config->bugs |= AHC_AUTOFLUSH_BUG|AHC_CACHETHEN_BUG;
1968 ahc->bugs |= AHC_AUTOFLUSH_BUG|AHC_CACHETHEN_BUG;
1931 return (0);
1932}
1933
1934static int
1969 return (0);
1970}
1971
1972static int
1935ahc_aic7892_setup(ahc_dev_softc_t pci, struct ahc_probe_config *probe_config)
1973ahc_aic7892_setup(struct ahc_softc *ahc)
1936{
1974{
1937 probe_config->channel = 'A';
1938 probe_config->chip = AHC_AIC7892;
1939 probe_config->features = AHC_AIC7892_FE;
1940 probe_config->flags |= AHC_NEWEEPROM_FMT;
1941 probe_config->bugs |= AHC_SCBCHAN_UPLOAD_BUG;
1975 ahc_dev_softc_t pci;
1976
1977 pci = ahc->dev_softc;
1978 ahc->channel = 'A';
1979 ahc->chip = AHC_AIC7892;
1980 ahc->features = AHC_AIC7892_FE;
1981 ahc->flags |= AHC_NEWEEPROM_FMT;
1982 ahc->bugs |= AHC_SCBCHAN_UPLOAD_BUG;
1942 return (0);
1943}
1944
1945static int
1983 return (0);
1984}
1985
1986static int
1946ahc_aic7895_setup(ahc_dev_softc_t pci, struct ahc_probe_config *probe_config)
1987ahc_aic7895_setup(struct ahc_softc *ahc)
1947{
1988{
1989 ahc_dev_softc_t pci;
1948 uint8_t rev;
1949
1990 uint8_t rev;
1991
1950 probe_config->channel = ahc_get_pci_function(pci) == 1 ? 'B' : 'A';
1992 pci = ahc->dev_softc;
1993 ahc->channel = ahc_get_pci_function(pci) == 1 ? 'B' : 'A';
1951 /*
1952 * The 'C' revision of the aic7895 has a few additional features.
1953 */
1954 rev = ahc_pci_read_config(pci, PCIR_REVID, /*bytes*/1);
1955 if (rev >= 4) {
1994 /*
1995 * The 'C' revision of the aic7895 has a few additional features.
1996 */
1997 rev = ahc_pci_read_config(pci, PCIR_REVID, /*bytes*/1);
1998 if (rev >= 4) {
1956 probe_config->chip = AHC_AIC7895C;
1957 probe_config->features = AHC_AIC7895C_FE;
1999 ahc->chip = AHC_AIC7895C;
2000 ahc->features = AHC_AIC7895C_FE;
1958 } else {
1959 u_int command;
1960
2001 } else {
2002 u_int command;
2003
1961 probe_config->chip = AHC_AIC7895;
1962 probe_config->features = AHC_AIC7895_FE;
2004 ahc->chip = AHC_AIC7895;
2005 ahc->features = AHC_AIC7895_FE;
1963
1964 /*
1965 * The BIOS disables the use of MWI transactions
1966 * since it does not have the MWI bug work around
1967 * we have. Disabling MWI reduces performance, so
1968 * turn it on again.
1969 */
1970 command = ahc_pci_read_config(pci, PCIR_COMMAND, /*bytes*/1);
1971 command |= PCIM_CMD_MWRICEN;
1972 ahc_pci_write_config(pci, PCIR_COMMAND, command, /*bytes*/1);
2006
2007 /*
2008 * The BIOS disables the use of MWI transactions
2009 * since it does not have the MWI bug work around
2010 * we have. Disabling MWI reduces performance, so
2011 * turn it on again.
2012 */
2013 command = ahc_pci_read_config(pci, PCIR_COMMAND, /*bytes*/1);
2014 command |= PCIM_CMD_MWRICEN;
2015 ahc_pci_write_config(pci, PCIR_COMMAND, command, /*bytes*/1);
1973 probe_config->bugs |= AHC_PCI_MWI_BUG;
2016 ahc->bugs |= AHC_PCI_MWI_BUG;
1974 }
1975 /*
1976 * XXX Does CACHETHEN really not work??? What about PCI retry?
1977 * on C level chips. Need to test, but for now, play it safe.
1978 */
2017 }
2018 /*
2019 * XXX Does CACHETHEN really not work??? What about PCI retry?
2020 * on C level chips. Need to test, but for now, play it safe.
2021 */
1979 probe_config->bugs |= AHC_TMODE_WIDEODD_BUG|AHC_PCI_2_1_RETRY_BUG
1980 | AHC_CACHETHEN_BUG;
2022 ahc->bugs |= AHC_TMODE_WIDEODD_BUG|AHC_PCI_2_1_RETRY_BUG
2023 | AHC_CACHETHEN_BUG;
1981
1982#if 0
1983 uint32_t devconfig;
1984
1985 /*
1986 * Cachesize must also be zero due to stray DAC
1987 * problem when sitting behind some bridges.
1988 */
1989 ahc_pci_write_config(pci, CSIZE_LATTIME, 0, /*bytes*/1);
1990 devconfig = ahc_pci_read_config(pci, DEVCONFIG, /*bytes*/1);
1991 devconfig |= MRDCEN;
1992 ahc_pci_write_config(pci, DEVCONFIG, devconfig, /*bytes*/1);
1993#endif
2024
2025#if 0
2026 uint32_t devconfig;
2027
2028 /*
2029 * Cachesize must also be zero due to stray DAC
2030 * problem when sitting behind some bridges.
2031 */
2032 ahc_pci_write_config(pci, CSIZE_LATTIME, 0, /*bytes*/1);
2033 devconfig = ahc_pci_read_config(pci, DEVCONFIG, /*bytes*/1);
2034 devconfig |= MRDCEN;
2035 ahc_pci_write_config(pci, DEVCONFIG, devconfig, /*bytes*/1);
2036#endif
1994 probe_config->flags |= AHC_NEWEEPROM_FMT;
2037 ahc->flags |= AHC_NEWEEPROM_FMT;
1995 return (0);
1996}
1997
1998static int
2038 return (0);
2039}
2040
2041static int
1999ahc_aic7896_setup(ahc_dev_softc_t pci, struct ahc_probe_config *probe_config)
2042ahc_aic7896_setup(struct ahc_softc *ahc)
2000{
2043{
2001 probe_config->channel = ahc_get_pci_function(pci) == 1 ? 'B' : 'A';
2002 probe_config->chip = AHC_AIC7896;
2003 probe_config->features = AHC_AIC7896_FE;
2004 probe_config->flags |= AHC_NEWEEPROM_FMT;
2005 probe_config->bugs |= AHC_CACHETHEN_DIS_BUG;
2044 ahc_dev_softc_t pci;
2045
2046 pci = ahc->dev_softc;
2047 ahc->channel = ahc_get_pci_function(pci) == 1 ? 'B' : 'A';
2048 ahc->chip = AHC_AIC7896;
2049 ahc->features = AHC_AIC7896_FE;
2050 ahc->flags |= AHC_NEWEEPROM_FMT;
2051 ahc->bugs |= AHC_CACHETHEN_DIS_BUG;
2006 return (0);
2007}
2008
2009static int
2052 return (0);
2053}
2054
2055static int
2010ahc_aic7899_setup(ahc_dev_softc_t pci, struct ahc_probe_config *probe_config)
2056ahc_aic7899_setup(struct ahc_softc *ahc)
2011{
2057{
2012 probe_config->channel = ahc_get_pci_function(pci) == 1 ? 'B' : 'A';
2013 probe_config->chip = AHC_AIC7899;
2014 probe_config->features = AHC_AIC7899_FE;
2015 probe_config->flags |= AHC_NEWEEPROM_FMT;
2016 probe_config->bugs |= AHC_SCBCHAN_UPLOAD_BUG;
2058 ahc_dev_softc_t pci;
2059
2060 pci = ahc->dev_softc;
2061 ahc->channel = ahc_get_pci_function(pci) == 1 ? 'B' : 'A';
2062 ahc->chip = AHC_AIC7899;
2063 ahc->features = AHC_AIC7899_FE;
2064 ahc->flags |= AHC_NEWEEPROM_FMT;
2065 ahc->bugs |= AHC_SCBCHAN_UPLOAD_BUG;
2017 return (0);
2018}
2019
2020static int
2066 return (0);
2067}
2068
2069static int
2021ahc_aha29160C_setup(ahc_dev_softc_t pci, struct ahc_probe_config *probe_config)
2070ahc_aha29160C_setup(struct ahc_softc *ahc)
2022{
2023 int error;
2024
2071{
2072 int error;
2073
2025 error = ahc_aic7899_setup(pci, probe_config);
2074 error = ahc_aic7899_setup(ahc);
2026 if (error != 0)
2027 return (error);
2075 if (error != 0)
2076 return (error);
2028 probe_config->features |= AHC_REMOVABLE;
2077 ahc->features |= AHC_REMOVABLE;
2029 return (0);
2030}
2031
2032static int
2078 return (0);
2079}
2080
2081static int
2033ahc_raid_setup(ahc_dev_softc_t pci, struct ahc_probe_config *probe_config)
2082ahc_raid_setup(struct ahc_softc *ahc)
2034{
2035 printf("RAID functionality unsupported\n");
2036 return (ENXIO);
2037}
2038
2039static int
2083{
2084 printf("RAID functionality unsupported\n");
2085 return (ENXIO);
2086}
2087
2088static int
2040ahc_aha394XX_setup(ahc_dev_softc_t pci, struct ahc_probe_config *probe_config)
2089ahc_aha394XX_setup(struct ahc_softc *ahc)
2041{
2090{
2091 ahc_dev_softc_t pci;
2092
2093 pci = ahc->dev_softc;
2042 switch (ahc_get_pci_slot(pci)) {
2043 case AHC_394X_SLOT_CHANNEL_A:
2094 switch (ahc_get_pci_slot(pci)) {
2095 case AHC_394X_SLOT_CHANNEL_A:
2044 probe_config->channel = 'A';
2096 ahc->channel = 'A';
2045 break;
2046 case AHC_394X_SLOT_CHANNEL_B:
2097 break;
2098 case AHC_394X_SLOT_CHANNEL_B:
2047 probe_config->channel = 'B';
2099 ahc->channel = 'B';
2048 break;
2049 default:
2050 printf("adapter at unexpected slot %d\n"
2051 "unable to map to a channel\n",
2052 ahc_get_pci_slot(pci));
2100 break;
2101 default:
2102 printf("adapter at unexpected slot %d\n"
2103 "unable to map to a channel\n",
2104 ahc_get_pci_slot(pci));
2053 probe_config->channel = 'A';
2105 ahc->channel = 'A';
2054 }
2055 return (0);
2056}
2057
2058static int
2106 }
2107 return (0);
2108}
2109
2110static int
2059ahc_aha398XX_setup(ahc_dev_softc_t pci, struct ahc_probe_config *probe_config)
2111ahc_aha398XX_setup(struct ahc_softc *ahc)
2060{
2112{
2113 ahc_dev_softc_t pci;
2114
2115 pci = ahc->dev_softc;
2061 switch (ahc_get_pci_slot(pci)) {
2062 case AHC_398X_SLOT_CHANNEL_A:
2116 switch (ahc_get_pci_slot(pci)) {
2117 case AHC_398X_SLOT_CHANNEL_A:
2063 probe_config->channel = 'A';
2118 ahc->channel = 'A';
2064 break;
2065 case AHC_398X_SLOT_CHANNEL_B:
2119 break;
2120 case AHC_398X_SLOT_CHANNEL_B:
2066 probe_config->channel = 'B';
2121 ahc->channel = 'B';
2067 break;
2068 case AHC_398X_SLOT_CHANNEL_C:
2122 break;
2123 case AHC_398X_SLOT_CHANNEL_C:
2069 probe_config->channel = 'C';
2124 ahc->channel = 'C';
2070 break;
2071 default:
2072 printf("adapter at unexpected slot %d\n"
2073 "unable to map to a channel\n",
2074 ahc_get_pci_slot(pci));
2125 break;
2126 default:
2127 printf("adapter at unexpected slot %d\n"
2128 "unable to map to a channel\n",
2129 ahc_get_pci_slot(pci));
2075 probe_config->channel = 'A';
2130 ahc->channel = 'A';
2076 break;
2077 }
2131 break;
2132 }
2078 probe_config->flags |= AHC_LARGE_SEEPROM;
2133 ahc->flags |= AHC_LARGE_SEEPROM;
2079 return (0);
2080}
2081
2082static int
2134 return (0);
2135}
2136
2137static int
2083ahc_aha494XX_setup(ahc_dev_softc_t pci, struct ahc_probe_config *probe_config)
2138ahc_aha494XX_setup(struct ahc_softc *ahc)
2084{
2139{
2140 ahc_dev_softc_t pci;
2141
2142 pci = ahc->dev_softc;
2085 switch (ahc_get_pci_slot(pci)) {
2086 case AHC_494X_SLOT_CHANNEL_A:
2143 switch (ahc_get_pci_slot(pci)) {
2144 case AHC_494X_SLOT_CHANNEL_A:
2087 probe_config->channel = 'A';
2145 ahc->channel = 'A';
2088 break;
2089 case AHC_494X_SLOT_CHANNEL_B:
2146 break;
2147 case AHC_494X_SLOT_CHANNEL_B:
2090 probe_config->channel = 'B';
2148 ahc->channel = 'B';
2091 break;
2092 case AHC_494X_SLOT_CHANNEL_C:
2149 break;
2150 case AHC_494X_SLOT_CHANNEL_C:
2093 probe_config->channel = 'C';
2151 ahc->channel = 'C';
2094 break;
2095 case AHC_494X_SLOT_CHANNEL_D:
2152 break;
2153 case AHC_494X_SLOT_CHANNEL_D:
2096 probe_config->channel = 'D';
2154 ahc->channel = 'D';
2097 break;
2098 default:
2099 printf("adapter at unexpected slot %d\n"
2100 "unable to map to a channel\n",
2101 ahc_get_pci_slot(pci));
2155 break;
2156 default:
2157 printf("adapter at unexpected slot %d\n"
2158 "unable to map to a channel\n",
2159 ahc_get_pci_slot(pci));
2102 probe_config->channel = 'A';
2160 ahc->channel = 'A';
2103 }
2161 }
2104 probe_config->flags |= AHC_LARGE_SEEPROM;
2162 ahc->flags |= AHC_LARGE_SEEPROM;
2105 return (0);
2106}
2163 return (0);
2164}