| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: pci_subr.c,v 1.186 2017/06/08 03:39:18 msaitoh Exp $ */ | | 1 | /* $NetBSD: pci_subr.c,v 1.187 2017/06/15 05:42:27 msaitoh Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright (c) 1997 Zubin D. Dittia. All rights reserved. | | 4 | * Copyright (c) 1997 Zubin D. Dittia. All rights reserved. |
5 | * Copyright (c) 1995, 1996, 1998, 2000 | | 5 | * Copyright (c) 1995, 1996, 1998, 2000 |
6 | * Christopher G. Demetriou. All rights reserved. | | 6 | * Christopher G. Demetriou. All rights reserved. |
7 | * Copyright (c) 1994 Charles M. Hannum. All rights reserved. | | 7 | * Copyright (c) 1994 Charles M. Hannum. All rights reserved. |
8 | * | | 8 | * |
9 | * Redistribution and use in source and binary forms, with or without | | 9 | * Redistribution and use in source and binary forms, with or without |
10 | * modification, are permitted provided that the following conditions | | 10 | * modification, are permitted provided that the following conditions |
11 | * are met: | | 11 | * are met: |
12 | * 1. Redistributions of source code must retain the above copyright | | 12 | * 1. Redistributions of source code must retain the above copyright |
13 | * notice, this list of conditions and the following disclaimer. | | 13 | * notice, this list of conditions and the following disclaimer. |
14 | * 2. Redistributions in binary form must reproduce the above copyright | | 14 | * 2. Redistributions in binary form must reproduce the above copyright |
| @@ -30,27 +30,27 @@ | | | @@ -30,27 +30,27 @@ |
30 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | | 30 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
31 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | | 31 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
32 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | | 32 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
33 | */ | | 33 | */ |
34 | | | 34 | |
35 | /* | | 35 | /* |
36 | * PCI autoconfiguration support functions. | | 36 | * PCI autoconfiguration support functions. |
37 | * | | 37 | * |
38 | * Note: This file is also built into a userland library (libpci). | | 38 | * Note: This file is also built into a userland library (libpci). |
39 | * Pay attention to this when you make modifications. | | 39 | * Pay attention to this when you make modifications. |
40 | */ | | 40 | */ |
41 | | | 41 | |
42 | #include <sys/cdefs.h> | | 42 | #include <sys/cdefs.h> |
43 | __KERNEL_RCSID(0, "$NetBSD: pci_subr.c,v 1.186 2017/06/08 03:39:18 msaitoh Exp $"); | | 43 | __KERNEL_RCSID(0, "$NetBSD: pci_subr.c,v 1.187 2017/06/15 05:42:27 msaitoh Exp $"); |
44 | | | 44 | |
45 | #ifdef _KERNEL_OPT | | 45 | #ifdef _KERNEL_OPT |
46 | #include "opt_pci.h" | | 46 | #include "opt_pci.h" |
47 | #endif | | 47 | #endif |
48 | | | 48 | |
49 | #include <sys/param.h> | | 49 | #include <sys/param.h> |
50 | | | 50 | |
51 | #ifdef _KERNEL | | 51 | #ifdef _KERNEL |
52 | #include <sys/systm.h> | | 52 | #include <sys/systm.h> |
53 | #include <sys/intr.h> | | 53 | #include <sys/intr.h> |
54 | #include <sys/module.h> | | 54 | #include <sys/module.h> |
55 | #else | | 55 | #else |
56 | #include <pci.h> | | 56 | #include <pci.h> |
| @@ -1897,28 +1897,30 @@ pci_conf_print_pcie_cap(const pcireg_t * | | | @@ -1897,28 +1897,30 @@ pci_conf_print_pcie_cap(const pcireg_t * |
1897 | printf(" Negotiated Link Width: x%u lanes\n", | | 1897 | printf(" Negotiated Link Width: x%u lanes\n", |
1898 | (unsigned int)__SHIFTOUT(reg, PCIE_LCSR_NLW)); | | 1898 | (unsigned int)__SHIFTOUT(reg, PCIE_LCSR_NLW)); |
1899 | onoff("Training Error", reg, PCIE_LCSR_LINKTRAIN_ERR); | | 1899 | onoff("Training Error", reg, PCIE_LCSR_LINKTRAIN_ERR); |
1900 | onoff("Link Training", reg, PCIE_LCSR_LINKTRAIN); | | 1900 | onoff("Link Training", reg, PCIE_LCSR_LINKTRAIN); |
1901 | onoff("Slot Clock Configuration", reg, PCIE_LCSR_SLOTCLKCFG); | | 1901 | onoff("Slot Clock Configuration", reg, PCIE_LCSR_SLOTCLKCFG); |
1902 | onoff("Data Link Layer Link Active", reg, PCIE_LCSR_DLACTIVE); | | 1902 | onoff("Data Link Layer Link Active", reg, PCIE_LCSR_DLACTIVE); |
1903 | onoff("Link Bandwidth Management Status", reg, | | 1903 | onoff("Link Bandwidth Management Status", reg, |
1904 | PCIE_LCSR_LINK_BW_MGMT); | | 1904 | PCIE_LCSR_LINK_BW_MGMT); |
1905 | onoff("Link Autonomous Bandwidth Status", reg, | | 1905 | onoff("Link Autonomous Bandwidth Status", reg, |
1906 | PCIE_LCSR_LINK_AUTO_BW); | | 1906 | PCIE_LCSR_LINK_AUTO_BW); |
1907 | } | | 1907 | } |
1908 | | | 1908 | |
1909 | if (check_slot == true) { | | 1909 | if (check_slot == true) { |
| | | 1910 | pcireg_t slcap; |
| | | 1911 | |
1910 | /* Slot Capability Register */ | | 1912 | /* Slot Capability Register */ |
1911 | reg = regs[o2i(capoff + PCIE_SLCAP)]; | | 1913 | slcap = reg = regs[o2i(capoff + PCIE_SLCAP)]; |
1912 | printf(" Slot Capability Register: 0x%08x\n", reg); | | 1914 | printf(" Slot Capability Register: 0x%08x\n", reg); |
1913 | onoff("Attention Button Present", reg, PCIE_SLCAP_ABP); | | 1915 | onoff("Attention Button Present", reg, PCIE_SLCAP_ABP); |
1914 | onoff("Power Controller Present", reg, PCIE_SLCAP_PCP); | | 1916 | onoff("Power Controller Present", reg, PCIE_SLCAP_PCP); |
1915 | onoff("MRL Sensor Present", reg, PCIE_SLCAP_MSP); | | 1917 | onoff("MRL Sensor Present", reg, PCIE_SLCAP_MSP); |
1916 | onoff("Attention Indicator Present", reg, PCIE_SLCAP_AIP); | | 1918 | onoff("Attention Indicator Present", reg, PCIE_SLCAP_AIP); |
1917 | onoff("Power Indicator Present", reg, PCIE_SLCAP_PIP); | | 1919 | onoff("Power Indicator Present", reg, PCIE_SLCAP_PIP); |
1918 | onoff("Hot-Plug Surprise", reg, PCIE_SLCAP_HPS); | | 1920 | onoff("Hot-Plug Surprise", reg, PCIE_SLCAP_HPS); |
1919 | onoff("Hot-Plug Capable", reg, PCIE_SLCAP_HPC); | | 1921 | onoff("Hot-Plug Capable", reg, PCIE_SLCAP_HPC); |
1920 | printf(" Slot Power Limit Value: "); | | 1922 | printf(" Slot Power Limit Value: "); |
1921 | pci_conf_print_pcie_power(__SHIFTOUT(reg, PCIE_SLCAP_SPLV), | | 1923 | pci_conf_print_pcie_power(__SHIFTOUT(reg, PCIE_SLCAP_SPLV), |
1922 | __SHIFTOUT(reg, PCIE_SLCAP_SPLS)); | | 1924 | __SHIFTOUT(reg, PCIE_SLCAP_SPLS)); |
1923 | onoff("Electromechanical Interlock Present", reg, | | 1925 | onoff("Electromechanical Interlock Present", reg, |
1924 | PCIE_SLCAP_EIP); | | 1926 | PCIE_SLCAP_EIP); |
| @@ -1926,55 +1928,64 @@ pci_conf_print_pcie_cap(const pcireg_t * | | | @@ -1926,55 +1928,64 @@ pci_conf_print_pcie_cap(const pcireg_t * |
1926 | printf(" Physical Slot Number: %d\n", | | 1928 | printf(" Physical Slot Number: %d\n", |
1927 | (unsigned int)(reg & PCIE_SLCAP_PSN) >> 19); | | 1929 | (unsigned int)(reg & PCIE_SLCAP_PSN) >> 19); |
1928 | | | 1930 | |
1929 | /* Slot Control Register */ | | 1931 | /* Slot Control Register */ |
1930 | reg = regs[o2i(capoff + PCIE_SLCSR)]; | | 1932 | reg = regs[o2i(capoff + PCIE_SLCSR)]; |
1931 | printf(" Slot Control Register: 0x%04x\n", reg & 0xffff); | | 1933 | printf(" Slot Control Register: 0x%04x\n", reg & 0xffff); |
1932 | onoff("Attention Button Pressed Enabled", reg, PCIE_SLCSR_ABE); | | 1934 | onoff("Attention Button Pressed Enabled", reg, PCIE_SLCSR_ABE); |
1933 | onoff("Power Fault Detected Enabled", reg, PCIE_SLCSR_PFE); | | 1935 | onoff("Power Fault Detected Enabled", reg, PCIE_SLCSR_PFE); |
1934 | onoff("MRL Sensor Changed Enabled", reg, PCIE_SLCSR_MSE); | | 1936 | onoff("MRL Sensor Changed Enabled", reg, PCIE_SLCSR_MSE); |
1935 | onoff("Presence Detect Changed Enabled", reg, PCIE_SLCSR_PDE); | | 1937 | onoff("Presence Detect Changed Enabled", reg, PCIE_SLCSR_PDE); |
1936 | onoff("Command Completed Interrupt Enabled", reg, | | 1938 | onoff("Command Completed Interrupt Enabled", reg, |
1937 | PCIE_SLCSR_CCE); | | 1939 | PCIE_SLCSR_CCE); |
1938 | onoff("Hot-Plug Interrupt Enabled", reg, PCIE_SLCSR_HPE); | | 1940 | onoff("Hot-Plug Interrupt Enabled", reg, PCIE_SLCSR_HPE); |
1939 | printf(" Attention Indicator Control: "); | | 1941 | /* |
1940 | switch ((reg & PCIE_SLCSR_AIC) >> 6) { | | 1942 | * For Attention Indicator Control and Power Indicator Control, |
1941 | case 0x0: | | 1943 | * it's allowed to be a read only value 0 if corresponding |
1942 | printf("reserved\n"); | | 1944 | * capability register bit is 0. |
1943 | break; | | 1945 | */ |
1944 | case PCIE_SLCSR_IND_ON: | | 1946 | if (slcap & PCIE_SLCAP_AIP) { |
1945 | printf("on\n"); | | 1947 | printf(" Attention Indicator Control: "); |
1946 | break; | | 1948 | switch ((reg & PCIE_SLCSR_AIC) >> 6) { |
1947 | case PCIE_SLCSR_IND_BLINK: | | 1949 | case 0x0: |
1948 | printf("blink\n"); | | 1950 | printf("reserved\n"); |
1949 | break; | | 1951 | break; |
1950 | case PCIE_SLCSR_IND_OFF: | | 1952 | case PCIE_SLCSR_IND_ON: |
1951 | printf("off\n"); | | 1953 | printf("on\n"); |
1952 | break; | | 1954 | break; |
| | | 1955 | case PCIE_SLCSR_IND_BLINK: |
| | | 1956 | printf("blink\n"); |
| | | 1957 | break; |
| | | 1958 | case PCIE_SLCSR_IND_OFF: |
| | | 1959 | printf("off\n"); |
| | | 1960 | break; |
| | | 1961 | } |
1953 | } | | 1962 | } |
1954 | printf(" Power Indicator Control: "); | | 1963 | if (slcap & PCIE_SLCAP_PIP) { |
1955 | switch ((reg & PCIE_SLCSR_PIC) >> 8) { | | 1964 | printf(" Power Indicator Control: "); |
1956 | case 0x0: | | 1965 | switch ((reg & PCIE_SLCSR_PIC) >> 8) { |
1957 | printf("reserved\n"); | | 1966 | case 0x0: |
1958 | break; | | 1967 | printf("reserved\n"); |
1959 | case PCIE_SLCSR_IND_ON: | | 1968 | break; |
1960 | printf("on\n"); | | 1969 | case PCIE_SLCSR_IND_ON: |
1961 | break; | | 1970 | printf("on\n"); |
1962 | case PCIE_SLCSR_IND_BLINK: | | 1971 | break; |
1963 | printf("blink\n"); | | 1972 | case PCIE_SLCSR_IND_BLINK: |
1964 | break; | | 1973 | printf("blink\n"); |
1965 | case PCIE_SLCSR_IND_OFF: | | 1974 | break; |
1966 | printf("off\n"); | | 1975 | case PCIE_SLCSR_IND_OFF: |
1967 | break; | | 1976 | printf("off\n"); |
| | | 1977 | break; |
| | | 1978 | } |
1968 | } | | 1979 | } |
1969 | printf(" Power Controller Control: Power %s\n", | | 1980 | printf(" Power Controller Control: Power %s\n", |
1970 | reg & PCIE_SLCSR_PCC ? "off" : "on"); | | 1981 | reg & PCIE_SLCSR_PCC ? "off" : "on"); |
1971 | onoff("Electromechanical Interlock Control", | | 1982 | onoff("Electromechanical Interlock Control", |
1972 | reg, PCIE_SLCSR_EIC); | | 1983 | reg, PCIE_SLCSR_EIC); |
1973 | onoff("Data Link Layer State Changed Enable", reg, | | 1984 | onoff("Data Link Layer State Changed Enable", reg, |
1974 | PCIE_SLCSR_DLLSCE); | | 1985 | PCIE_SLCSR_DLLSCE); |
1975 | onoff("Auto Slot Power Limit Disable", reg, | | 1986 | onoff("Auto Slot Power Limit Disable", reg, |
1976 | PCIE_SLCSR_AUTOSPLDIS); | | 1987 | PCIE_SLCSR_AUTOSPLDIS); |
1977 | | | 1988 | |
1978 | /* Slot Status Register */ | | 1989 | /* Slot Status Register */ |
1979 | printf(" Slot Status Register: 0x%04x\n", reg >> 16); | | 1990 | printf(" Slot Status Register: 0x%04x\n", reg >> 16); |
1980 | onoff("Attention Button Pressed", reg, PCIE_SLCSR_ABP); | | 1991 | onoff("Attention Button Pressed", reg, PCIE_SLCSR_ABP); |