Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'pci-v6.9-changes' of git://git.kernel.org/pub/scm/linux/kernel/git/pci/pci

Pull PCI updates from Bjorn Helgaas:
"Enumeration:

- Consolidate interrupt related code in irq.c (Ilpo Järvinen)

- Reduce kernel size by replacing sysfs resource macros with
functions (Ilpo Järvinen)

- Reduce kernel size by compiling sysfs support only when
CONFIG_SYSFS=y (Lukas Wunner)

- Avoid using Extended Tags on 3ware-9650SE Root Port to work around
an apparent hardware defect (Jörg Wedekind)

Resource management:

- Fix an MMIO mapping leak in pci_iounmap() (Philipp Stanner)

- Move pci_iomap.c and other PCI-specific devres code to drivers/pci
(Philipp Stanner)

- Consolidate PCI devres code in devres.c (Philipp Stanner)

Power management:

- Avoid D3cold on Asus B1400 PCI-NVMe bridge, where firmware doesn't
know how to return correctly to D0, and remove previous quirk that
wasn't as specific (Daniel Drake)

- Allow runtime PM when the driver enables it but doesn't need any
runtime PM callbacks (Raag Jadav)

- Drain runtime-idle callbacks before driver removal to avoid races
between .remove() and .runtime_idle(), which caused intermittent
page faults when the rtsx .runtime_idle() accessed registers that
its .remove() had already unmapped (Rafael J. Wysocki)

Virtualization:

- Avoid Secondary Bus Reset on LSI FW643 so it can be assigned to VMs
with VFIO, e.g., for professional audio software on many Apple
machines, at the cost of leaking state between VMs (Edmund Raile)

Error handling:

- Print all logged TLP Prefixes, not just the first, after AER or DPC
errors (Ilpo Järvinen)

- Quirk the DPC PIO log size for Intel Raptor Lake Root Ports, which
still don't advertise a legal size (Paul Menzel)

- Ignore expected DPC Surprise Down errors on hot removal (Smita
Koralahalli)

- Block runtime suspend while handling AER errors to avoid races that
prevent the device form being resumed from D3hot (Stanislaw
Gruszka)

Peer-to-peer DMA:

- Use atomic XA allocation in RCU read section (Christophe JAILLET)

ASPM:

- Collect bits of ASPM-related code that we need even without
CONFIG_PCIEASPM into aspm.c (David E. Box)

- Save/restore L1 PM Substates config for suspend/resume (David E.
Box)

- Update save_save when ASPM config is changed, so a .slot_reset()
during error recovery restores the changed config, not the
.probe()-time config (Vidya Sagar)

Endpoint framework:

- Refactor and improve pci_epf_alloc_space() API (Niklas Cassel)

- Clean up endpoint BAR descriptions (Niklas Cassel)

- Fix ntb_register_device() name leak in error path (Yang Yingliang)

- Return actual error code for pci_vntb_probe() failure (Yang
Yingliang)

Broadcom STB PCIe controller driver:

- Fix MDIO write polling, which previously never waited for
completion (Jonathan Bell)

Cadence PCIe endpoint driver:

- Clear the ARI "Next Function Number" of last function (Jasko-EXT
Wojciech)

Freescale i.MX6 PCIe controller driver:

- Simplify by replacing switch statements with function pointers for
different hardware variants (Frank Li)

- Simplify by using clk_bulk*() API (Frank Li)

- Remove redundant DT clock and reg/reg-name details (Frank Li)

- Add i.MX95 DT and driver support for both Root Complex and Endpoint
mode (Frank Li)

Microsoft Hyper-V host bridge driver:

- Reduce memory usage by limiting ring buffer size to 16KB instead of
4 pages (Michael Kelley)

Qualcomm PCIe controller driver:

- Add X1E80100 DT and driver support (Abel Vesa)

- Add DT 'required-opps' for SoCs that require a minimum performance
level (Johan Hovold)

- Make DT 'msi-map-mask' optional, depending on how MSI interrupts
are mapped (Johan Hovold)

- Disable ASPM L0s for sc8280xp, sa8540p and sa8295p because the PHY
configuration isn't tuned correctly for L0s (Johan Hovold)

- Split dt-binding qcom,pcie.yaml into qcom,pcie-common.yaml and
separate files for SA8775p, SC7280, SC8180X, SC8280XP, SM8150,
SM8250, SM8350, SM8450, SM8550 for easier reviewing (Krzysztof
Kozlowski)

- Enable BDF to SID translation by disabling bypass mode (Manivannan
Sadhasivam)

- Add endpoint MHI support for Snapdragon SA8775P SoC (Mrinmay
Sarkar)

Synopsys DesignWare PCIe controller driver:

- Allocate 64-bit MSI address if no 32-bit address is available (Ajay
Agarwal)

- Fix endpoint Resizable BAR to actually advertise the required 1MB
size (Niklas Cassel)

MicroSemi Switchtec management driver:

- Release resources if the .probe() fails (Christophe JAILLET)

Miscellaneous:

- Make pcie_port_bus_type const (Ricardo B. Marliere)"

* tag 'pci-v6.9-changes' of git://git.kernel.org/pub/scm/linux/kernel/git/pci/pci: (77 commits)
PCI/ASPM: Update save_state when configuration changes
PCI/ASPM: Disable L1 before configuring L1 Substates
PCI/ASPM: Call pci_save_ltr_state() from pci_save_pcie_state()
PCI/ASPM: Save L1 PM Substates Capability for suspend/resume
PCI: hv: Fix ring buffer size calculation
PCI: dwc: endpoint: Fix advertised resizable BAR size
PCI: cadence: Clear the ARI Capability Next Function Number of the last function
PCI: dwc: Strengthen the MSI address allocation logic
PCI: brcmstb: Fix broken brcm_pcie_mdio_write() polling
PCI: qcom: Add X1E80100 PCIe support
dt-bindings: PCI: qcom: Document the X1E80100 PCIe Controller
PCI: qcom: Enable BDF to SID translation properly
PCI/AER: Generalize TLP Header Log reading
PCI/AER: Use explicit register size for PCI_ERR_CAP
PCI: qcom: Disable ASPM L0s for sc8280xp, sa8540p and sa8295p
dt-bindings: PCI: qcom: Do not require 'msi-map-mask'
dt-bindings: PCI: qcom: Allow 'required-opps'
PCI/AER: Block runtime suspend when handling errors
PCI/ASPM: Move pci_save_ltr_state() to aspm.c
PCI/ASPM: Always build aspm.c
...

+3796 -1774
+9 -9
Documentation/ABI/testing/sysfs-bus-pci-devices-aer_stats
··· 11 11 12 12 What: /sys/bus/pci/devices/<dev>/aer_dev_correctable 13 13 Date: July 2018 14 - KernelVersion: 4.19.0 14 + KernelVersion: 4.19.0 15 15 Contact: linux-pci@vger.kernel.org, rajatja@google.com 16 16 Description: List of correctable errors seen and reported by this 17 17 PCI device using ERR_COR. Note that since multiple errors may ··· 32 32 33 33 What: /sys/bus/pci/devices/<dev>/aer_dev_fatal 34 34 Date: July 2018 35 - KernelVersion: 4.19.0 35 + KernelVersion: 4.19.0 36 36 Contact: linux-pci@vger.kernel.org, rajatja@google.com 37 37 Description: List of uncorrectable fatal errors seen and reported by this 38 38 PCI device using ERR_FATAL. Note that since multiple errors may ··· 62 62 63 63 What: /sys/bus/pci/devices/<dev>/aer_dev_nonfatal 64 64 Date: July 2018 65 - KernelVersion: 4.19.0 65 + KernelVersion: 4.19.0 66 66 Contact: linux-pci@vger.kernel.org, rajatja@google.com 67 67 Description: List of uncorrectable nonfatal errors seen and reported by this 68 68 PCI device using ERR_NONFATAL. Note that since multiple errors ··· 100 100 device, so these counters include them and are thus cumulative of all the error 101 101 messages on the PCI hierarchy originating at that root port. 102 102 103 - What: /sys/bus/pci/devices/<dev>/aer_stats/aer_rootport_total_err_cor 103 + What: /sys/bus/pci/devices/<dev>/aer_rootport_total_err_cor 104 104 Date: July 2018 105 - KernelVersion: 4.19.0 105 + KernelVersion: 4.19.0 106 106 Contact: linux-pci@vger.kernel.org, rajatja@google.com 107 107 Description: Total number of ERR_COR messages reported to rootport. 108 108 109 - What: /sys/bus/pci/devices/<dev>/aer_stats/aer_rootport_total_err_fatal 109 + What: /sys/bus/pci/devices/<dev>/aer_rootport_total_err_fatal 110 110 Date: July 2018 111 - KernelVersion: 4.19.0 111 + KernelVersion: 4.19.0 112 112 Contact: linux-pci@vger.kernel.org, rajatja@google.com 113 113 Description: Total number of ERR_FATAL messages reported to rootport. 114 114 115 - What: /sys/bus/pci/devices/<dev>/aer_stats/aer_rootport_total_err_nonfatal 115 + What: /sys/bus/pci/devices/<dev>/aer_rootport_total_err_nonfatal 116 116 Date: July 2018 117 - KernelVersion: 4.19.0 117 + KernelVersion: 4.19.0 118 118 Contact: linux-pci@vger.kernel.org, rajatja@google.com 119 119 Description: Total number of ERR_NONFATAL messages reported to rootport.
+1 -16
Documentation/devicetree/bindings/pci/fsl,imx6q-pcie-common.yaml
··· 150 150 - {} 151 151 - const: pcie_phy 152 152 - const: pcie_aux 153 - - if: 154 - properties: 155 - compatible: 156 - not: 157 - contains: 158 - enum: 159 - - fsl,imx6sx-pcie 160 - - fsl,imx8mq-pcie 161 - - fsl,imx6sx-pcie-ep 162 - - fsl,imx8mq-pcie-ep 163 - then: 164 - properties: 165 - clocks: 166 - maxItems: 3 167 - clock-names: 168 - maxItems: 3 169 153 170 154 - if: 171 155 properties: ··· 207 223 - fsl,imx6sx-pcie 208 224 - fsl,imx6q-pcie 209 225 - fsl,imx6qp-pcie 226 + - fsl,imx95-pcie 210 227 - fsl,imx6sx-pcie-ep 211 228 - fsl,imx6q-pcie-ep 212 229 - fsl,imx6qp-pcie-ep
+38 -8
Documentation/devicetree/bindings/pci/fsl,imx6q-pcie-ep.yaml
··· 22 22 - fsl,imx8mm-pcie-ep 23 23 - fsl,imx8mq-pcie-ep 24 24 - fsl,imx8mp-pcie-ep 25 - 26 - reg: 27 - minItems: 2 28 - 29 - reg-names: 30 - items: 31 - - const: dbi 32 - - const: addr_space 25 + - fsl,imx95-pcie-ep 33 26 34 27 clocks: 35 28 minItems: 3 ··· 59 66 properties: 60 67 compatible: 61 68 enum: 69 + - fsl,imx8mm-pcie-ep 62 70 - fsl,imx8mq-pcie-ep 71 + - fsl,imx8mp-pcie-ep 72 + then: 73 + properties: 74 + reg: 75 + minItems: 2 76 + maxItems: 2 77 + reg-names: 78 + items: 79 + - const: dbi 80 + - const: addr_space 81 + 82 + - if: 83 + properties: 84 + compatible: 85 + enum: 86 + - fsl,imx95-pcie-ep 87 + then: 88 + properties: 89 + reg: 90 + minItems: 6 91 + maxItems: 6 92 + reg-names: 93 + items: 94 + - const: dbi 95 + - const: atu 96 + - const: dbi2 97 + - const: app 98 + - const: dma 99 + - const: addr_space 100 + 101 + - if: 102 + properties: 103 + compatible: 104 + enum: 105 + - fsl,imx8mq-pcie-ep 106 + - fsl,imx95-pcie-ep 63 107 then: 64 108 properties: 65 109 clocks:
+39 -10
Documentation/devicetree/bindings/pci/fsl,imx6q-pcie.yaml
··· 29 29 - fsl,imx8mq-pcie 30 30 - fsl,imx8mm-pcie 31 31 - fsl,imx8mp-pcie 32 - 33 - reg: 34 - items: 35 - - description: Data Bus Interface (DBI) registers. 36 - - description: PCIe configuration space region. 37 - 38 - reg-names: 39 - items: 40 - - const: dbi 41 - - const: config 32 + - fsl,imx95-pcie 42 33 43 34 clocks: 44 35 minItems: 3 ··· 85 94 properties: 86 95 compatible: 87 96 enum: 97 + - fsl,imx6q-pcie 98 + - fsl,imx6sx-pcie 99 + - fsl,imx6qp-pcie 100 + - fsl,imx7d-pcie 101 + - fsl,imx8mq-pcie 102 + - fsl,imx8mm-pcie 103 + - fsl,imx8mp-pcie 104 + then: 105 + properties: 106 + reg: 107 + maxItems: 2 108 + reg-names: 109 + items: 110 + - const: dbi 111 + - const: config 112 + 113 + - if: 114 + properties: 115 + compatible: 116 + enum: 117 + - fsl,imx95-pcie 118 + then: 119 + properties: 120 + reg: 121 + minItems: 4 122 + maxItems: 4 123 + reg-names: 124 + items: 125 + - const: dbi 126 + - const: config 127 + - const: atu 128 + - const: app 129 + 130 + - if: 131 + properties: 132 + compatible: 133 + enum: 88 134 - fsl,imx6sx-pcie 89 135 then: 90 136 properties: ··· 139 111 compatible: 140 112 enum: 141 113 - fsl,imx8mq-pcie 114 + - fsl,imx95-pcie 142 115 then: 143 116 properties: 144 117 clocks:
+100
Documentation/devicetree/bindings/pci/qcom,pcie-common.yaml
··· 1 + # SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) 2 + %YAML 1.2 3 + --- 4 + $id: http://devicetree.org/schemas/pci/qcom,pcie-common.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: Qualcomm PCI Express Root Complex Common Properties 8 + 9 + maintainers: 10 + - Bjorn Andersson <andersson@kernel.org> 11 + - Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org> 12 + 13 + properties: 14 + reg: 15 + minItems: 4 16 + maxItems: 6 17 + 18 + reg-names: 19 + minItems: 4 20 + maxItems: 6 21 + 22 + interrupts: 23 + minItems: 1 24 + maxItems: 8 25 + 26 + interrupt-names: 27 + minItems: 1 28 + maxItems: 8 29 + 30 + iommu-map: 31 + minItems: 1 32 + maxItems: 16 33 + 34 + clocks: 35 + minItems: 3 36 + maxItems: 13 37 + 38 + clock-names: 39 + minItems: 3 40 + maxItems: 13 41 + 42 + dma-coherent: true 43 + 44 + interconnects: 45 + maxItems: 2 46 + 47 + interconnect-names: 48 + items: 49 + - const: pcie-mem 50 + - const: cpu-pcie 51 + 52 + phys: 53 + maxItems: 1 54 + 55 + phy-names: 56 + items: 57 + - const: pciephy 58 + 59 + power-domains: 60 + maxItems: 1 61 + 62 + required-opps: 63 + maxItems: 1 64 + 65 + resets: 66 + minItems: 1 67 + maxItems: 12 68 + 69 + reset-names: 70 + minItems: 1 71 + maxItems: 12 72 + 73 + perst-gpios: 74 + description: GPIO controlled connection to PERST# signal 75 + maxItems: 1 76 + 77 + wake-gpios: 78 + description: GPIO controlled connection to WAKE# signal 79 + maxItems: 1 80 + 81 + required: 82 + - reg 83 + - reg-names 84 + - interrupt-map-mask 85 + - interrupt-map 86 + - clocks 87 + - clock-names 88 + 89 + anyOf: 90 + - required: 91 + - interrupts 92 + - interrupt-names 93 + - "#interrupt-cells" 94 + - required: 95 + - msi-map 96 + 97 + allOf: 98 + - $ref: /schemas/pci/pci-bus.yaml# 99 + 100 + additionalProperties: true
+166
Documentation/devicetree/bindings/pci/qcom,pcie-sa8775p.yaml
··· 1 + # SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) 2 + %YAML 1.2 3 + --- 4 + $id: http://devicetree.org/schemas/pci/qcom,pcie-sa8775p.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: Qualcomm SA8775p PCI Express Root Complex 8 + 9 + maintainers: 10 + - Bjorn Andersson <andersson@kernel.org> 11 + - Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org> 12 + 13 + description: 14 + Qualcomm SA8775p SoC PCIe root complex controller is based on the Synopsys 15 + DesignWare PCIe IP. 16 + 17 + properties: 18 + compatible: 19 + const: qcom,pcie-sa8775p 20 + 21 + reg: 22 + minItems: 6 23 + maxItems: 6 24 + 25 + reg-names: 26 + items: 27 + - const: parf # Qualcomm specific registers 28 + - const: dbi # DesignWare PCIe registers 29 + - const: elbi # External local bus interface registers 30 + - const: atu # ATU address space 31 + - const: config # PCIe configuration space 32 + - const: mhi # MHI registers 33 + 34 + clocks: 35 + minItems: 5 36 + maxItems: 5 37 + 38 + clock-names: 39 + items: 40 + - const: aux # Auxiliary clock 41 + - const: cfg # Configuration clock 42 + - const: bus_master # Master AXI clock 43 + - const: bus_slave # Slave AXI clock 44 + - const: slave_q2a # Slave Q2A clock 45 + 46 + interrupts: 47 + minItems: 8 48 + maxItems: 8 49 + 50 + interrupt-names: 51 + items: 52 + - const: msi0 53 + - const: msi1 54 + - const: msi2 55 + - const: msi3 56 + - const: msi4 57 + - const: msi5 58 + - const: msi6 59 + - const: msi7 60 + 61 + resets: 62 + maxItems: 1 63 + 64 + reset-names: 65 + items: 66 + - const: pci 67 + 68 + required: 69 + - interconnects 70 + - interconnect-names 71 + 72 + allOf: 73 + - $ref: qcom,pcie-common.yaml# 74 + 75 + unevaluatedProperties: false 76 + 77 + examples: 78 + - | 79 + #include <dt-bindings/clock/qcom,sa8775p-gcc.h> 80 + #include <dt-bindings/clock/qcom,rpmh.h> 81 + #include <dt-bindings/gpio/gpio.h> 82 + #include <dt-bindings/interrupt-controller/arm-gic.h> 83 + #include <dt-bindings/interconnect/qcom,sa8775p-rpmh.h> 84 + 85 + soc { 86 + #address-cells = <2>; 87 + #size-cells = <2>; 88 + 89 + pcie@1c00000 { 90 + compatible = "qcom,pcie-sa8775p"; 91 + reg = <0x0 0x01c00000 0x0 0x3000>, 92 + <0x0 0x40000000 0x0 0xf20>, 93 + <0x0 0x40000f20 0x0 0xa8>, 94 + <0x0 0x40001000 0x0 0x4000>, 95 + <0x0 0x40100000 0x0 0x100000>, 96 + <0x0 0x01c03000 0x0 0x1000>; 97 + reg-names = "parf", "dbi", "elbi", "atu", "config", "mhi"; 98 + ranges = <0x01000000 0x0 0x00000000 0x0 0x40200000 0x0 0x100000>, 99 + <0x02000000 0x0 0x40300000 0x0 0x40300000 0x0 0x1fd00000>; 100 + 101 + bus-range = <0x00 0xff>; 102 + device_type = "pci"; 103 + linux,pci-domain = <0>; 104 + num-lanes = <2>; 105 + 106 + #address-cells = <3>; 107 + #size-cells = <2>; 108 + 109 + assigned-clocks = <&gcc GCC_PCIE_0_AUX_CLK>; 110 + assigned-clock-rates = <19200000>; 111 + 112 + clocks = <&gcc GCC_PCIE_0_AUX_CLK>, 113 + <&gcc GCC_PCIE_0_CFG_AHB_CLK>, 114 + <&gcc GCC_PCIE_0_MSTR_AXI_CLK>, 115 + <&gcc GCC_PCIE_0_SLV_AXI_CLK>, 116 + <&gcc GCC_PCIE_0_SLV_Q2A_AXI_CLK>; 117 + clock-names = "aux", 118 + "cfg", 119 + "bus_master", 120 + "bus_slave", 121 + "slave_q2a"; 122 + 123 + dma-coherent; 124 + 125 + interrupts = <GIC_SPI 307 IRQ_TYPE_LEVEL_HIGH>, 126 + <GIC_SPI 308 IRQ_TYPE_LEVEL_HIGH>, 127 + <GIC_SPI 309 IRQ_TYPE_LEVEL_HIGH>, 128 + <GIC_SPI 312 IRQ_TYPE_LEVEL_HIGH>, 129 + <GIC_SPI 313 IRQ_TYPE_LEVEL_HIGH>, 130 + <GIC_SPI 314 IRQ_TYPE_LEVEL_HIGH>, 131 + <GIC_SPI 374 IRQ_TYPE_LEVEL_HIGH>, 132 + <GIC_SPI 375 IRQ_TYPE_LEVEL_HIGH>; 133 + interrupt-names = "msi0", 134 + "msi1", 135 + "msi2", 136 + "msi3", 137 + "msi4", 138 + "msi5", 139 + "msi6", 140 + "msi7"; 141 + #interrupt-cells = <1>; 142 + interrupt-map-mask = <0 0 0 0x7>; 143 + interrupt-map = <0 0 0 1 &intc GIC_SPI 434 IRQ_TYPE_LEVEL_HIGH>, 144 + <0 0 0 2 &intc GIC_SPI 435 IRQ_TYPE_LEVEL_HIGH>, 145 + <0 0 0 3 &intc GIC_SPI 438 IRQ_TYPE_LEVEL_HIGH>, 146 + <0 0 0 4 &intc GIC_SPI 439 IRQ_TYPE_LEVEL_HIGH>; 147 + 148 + interconnects = <&pcie_anoc MASTER_PCIE_0 0 &mc_virt SLAVE_EBI1 0>, 149 + <&gem_noc MASTER_APPSS_PROC 0 &config_noc SLAVE_PCIE_0 0>; 150 + interconnect-names = "pcie-mem", "cpu-pcie"; 151 + 152 + iommu-map = <0x0 &pcie_smmu 0x0000 0x1>, 153 + <0x100 &pcie_smmu 0x0001 0x1>; 154 + 155 + phys = <&pcie0_phy>; 156 + phy-names = "pciephy"; 157 + 158 + power-domains = <&gcc PCIE_0_GDSC>; 159 + 160 + resets = <&gcc GCC_PCIE_0_BCR>; 161 + reset-names = "pci"; 162 + 163 + perst-gpios = <&tlmm 2 GPIO_ACTIVE_LOW>; 164 + wake-gpios = <&tlmm 0 GPIO_ACTIVE_HIGH>; 165 + }; 166 + };
+166
Documentation/devicetree/bindings/pci/qcom,pcie-sc7280.yaml
··· 1 + # SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) 2 + %YAML 1.2 3 + --- 4 + $id: http://devicetree.org/schemas/pci/qcom,pcie-sc7280.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: Qualcomm SC7280 PCI Express Root Complex 8 + 9 + maintainers: 10 + - Bjorn Andersson <andersson@kernel.org> 11 + - Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org> 12 + 13 + description: 14 + Qualcomm SC7280 SoC PCIe root complex controller is based on the Synopsys 15 + DesignWare PCIe IP. 16 + 17 + properties: 18 + compatible: 19 + const: qcom,pcie-sc7280 20 + 21 + reg: 22 + minItems: 5 23 + maxItems: 6 24 + 25 + reg-names: 26 + minItems: 5 27 + items: 28 + - const: parf # Qualcomm specific registers 29 + - const: dbi # DesignWare PCIe registers 30 + - const: elbi # External local bus interface registers 31 + - const: atu # ATU address space 32 + - const: config # PCIe configuration space 33 + - const: mhi # MHI registers 34 + 35 + clocks: 36 + minItems: 13 37 + maxItems: 13 38 + 39 + clock-names: 40 + items: 41 + - const: pipe # PIPE clock 42 + - const: pipe_mux # PIPE MUX 43 + - const: phy_pipe # PIPE output clock 44 + - const: ref # REFERENCE clock 45 + - const: aux # Auxiliary clock 46 + - const: cfg # Configuration clock 47 + - const: bus_master # Master AXI clock 48 + - const: bus_slave # Slave AXI clock 49 + - const: slave_q2a # Slave Q2A clock 50 + - const: tbu # PCIe TBU clock 51 + - const: ddrss_sf_tbu # PCIe SF TBU clock 52 + - const: aggre0 # Aggre NoC PCIe CENTER SF AXI clock 53 + - const: aggre1 # Aggre NoC PCIe1 AXI clock 54 + 55 + interrupts: 56 + maxItems: 1 57 + 58 + interrupt-names: 59 + items: 60 + - const: msi 61 + 62 + resets: 63 + maxItems: 1 64 + 65 + reset-names: 66 + items: 67 + - const: pci 68 + 69 + vddpe-3v3-supply: 70 + description: PCIe endpoint power supply 71 + 72 + allOf: 73 + - $ref: qcom,pcie-common.yaml# 74 + 75 + unevaluatedProperties: false 76 + 77 + examples: 78 + - | 79 + #include <dt-bindings/clock/qcom,gcc-sc7280.h> 80 + #include <dt-bindings/clock/qcom,rpmh.h> 81 + #include <dt-bindings/gpio/gpio.h> 82 + #include <dt-bindings/interrupt-controller/arm-gic.h> 83 + 84 + soc { 85 + #address-cells = <2>; 86 + #size-cells = <2>; 87 + 88 + pcie@1c08000 { 89 + compatible = "qcom,pcie-sc7280"; 90 + reg = <0 0x01c08000 0 0x3000>, 91 + <0 0x40000000 0 0xf1d>, 92 + <0 0x40000f20 0 0xa8>, 93 + <0 0x40001000 0 0x1000>, 94 + <0 0x40100000 0 0x100000>; 95 + reg-names = "parf", "dbi", "elbi", "atu", "config"; 96 + ranges = <0x01000000 0x0 0x00000000 0x0 0x40200000 0x0 0x100000>, 97 + <0x02000000 0x0 0x40300000 0x0 0x40300000 0x0 0x1fd00000>; 98 + 99 + bus-range = <0x00 0xff>; 100 + device_type = "pci"; 101 + linux,pci-domain = <1>; 102 + num-lanes = <2>; 103 + 104 + #address-cells = <3>; 105 + #size-cells = <2>; 106 + 107 + assigned-clocks = <&gcc GCC_PCIE_1_AUX_CLK>; 108 + assigned-clock-rates = <19200000>; 109 + 110 + clocks = <&gcc GCC_PCIE_1_PIPE_CLK>, 111 + <&gcc GCC_PCIE_1_PIPE_CLK_SRC>, 112 + <&pcie1_phy>, 113 + <&rpmhcc RPMH_CXO_CLK>, 114 + <&gcc GCC_PCIE_1_AUX_CLK>, 115 + <&gcc GCC_PCIE_1_CFG_AHB_CLK>, 116 + <&gcc GCC_PCIE_1_MSTR_AXI_CLK>, 117 + <&gcc GCC_PCIE_1_SLV_AXI_CLK>, 118 + <&gcc GCC_PCIE_1_SLV_Q2A_AXI_CLK>, 119 + <&gcc GCC_AGGRE_NOC_PCIE_TBU_CLK>, 120 + <&gcc GCC_DDRSS_PCIE_SF_CLK>, 121 + <&gcc GCC_AGGRE_NOC_PCIE_CENTER_SF_AXI_CLK>, 122 + <&gcc GCC_AGGRE_NOC_PCIE_1_AXI_CLK>; 123 + 124 + clock-names = "pipe", 125 + "pipe_mux", 126 + "phy_pipe", 127 + "ref", 128 + "aux", 129 + "cfg", 130 + "bus_master", 131 + "bus_slave", 132 + "slave_q2a", 133 + "tbu", 134 + "ddrss_sf_tbu", 135 + "aggre0", 136 + "aggre1"; 137 + 138 + dma-coherent; 139 + 140 + interrupts = <GIC_SPI 307 IRQ_TYPE_LEVEL_HIGH>; 141 + interrupt-names = "msi"; 142 + #interrupt-cells = <1>; 143 + interrupt-map-mask = <0 0 0 0x7>; 144 + interrupt-map = <0 0 0 1 &intc 0 0 0 434 IRQ_TYPE_LEVEL_HIGH>, 145 + <0 0 0 2 &intc 0 0 0 435 IRQ_TYPE_LEVEL_HIGH>, 146 + <0 0 0 3 &intc 0 0 0 438 IRQ_TYPE_LEVEL_HIGH>, 147 + <0 0 0 4 &intc 0 0 0 439 IRQ_TYPE_LEVEL_HIGH>; 148 + 149 + iommu-map = <0x0 &apps_smmu 0x1c80 0x1>, 150 + <0x100 &apps_smmu 0x1c81 0x1>; 151 + 152 + phys = <&pcie1_phy>; 153 + phy-names = "pciephy"; 154 + 155 + pinctrl-names = "default"; 156 + pinctrl-0 = <&pcie1_clkreq_n>; 157 + 158 + power-domains = <&gcc GCC_PCIE_1_GDSC>; 159 + 160 + resets = <&gcc GCC_PCIE_1_BCR>; 161 + reset-names = "pci"; 162 + 163 + perst-gpios = <&tlmm 2 GPIO_ACTIVE_LOW>; 164 + vddpe-3v3-supply = <&pp3300_ssd>; 165 + }; 166 + };
+170
Documentation/devicetree/bindings/pci/qcom,pcie-sc8180x.yaml
··· 1 + # SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) 2 + %YAML 1.2 3 + --- 4 + $id: http://devicetree.org/schemas/pci/qcom,pcie-sc8180x.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: Qualcomm SC8180x PCI Express Root Complex 8 + 9 + maintainers: 10 + - Bjorn Andersson <andersson@kernel.org> 11 + - Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org> 12 + 13 + description: 14 + Qualcomm SC8180x SoC PCIe root complex controller is based on the Synopsys 15 + DesignWare PCIe IP. 16 + 17 + properties: 18 + compatible: 19 + const: qcom,pcie-sc8180x 20 + 21 + reg: 22 + minItems: 5 23 + maxItems: 6 24 + 25 + reg-names: 26 + minItems: 5 27 + items: 28 + - const: parf # Qualcomm specific registers 29 + - const: dbi # DesignWare PCIe registers 30 + - const: elbi # External local bus interface registers 31 + - const: atu # ATU address space 32 + - const: config # PCIe configuration space 33 + - const: mhi # MHI registers 34 + 35 + clocks: 36 + minItems: 8 37 + maxItems: 8 38 + 39 + clock-names: 40 + items: 41 + - const: pipe # PIPE clock 42 + - const: aux # Auxiliary clock 43 + - const: cfg # Configuration clock 44 + - const: bus_master # Master AXI clock 45 + - const: bus_slave # Slave AXI clock 46 + - const: slave_q2a # Slave Q2A clock 47 + - const: ref # REFERENCE clock 48 + - const: tbu # PCIe TBU clock 49 + 50 + interrupts: 51 + minItems: 8 52 + maxItems: 8 53 + 54 + interrupt-names: 55 + items: 56 + - const: msi0 57 + - const: msi1 58 + - const: msi2 59 + - const: msi3 60 + - const: msi4 61 + - const: msi5 62 + - const: msi6 63 + - const: msi7 64 + 65 + resets: 66 + maxItems: 1 67 + 68 + reset-names: 69 + items: 70 + - const: pci 71 + 72 + allOf: 73 + - $ref: qcom,pcie-common.yaml# 74 + 75 + unevaluatedProperties: false 76 + 77 + examples: 78 + - | 79 + #include <dt-bindings/clock/qcom,gcc-sc8180x.h> 80 + #include <dt-bindings/interconnect/qcom,sc8180x.h> 81 + #include <dt-bindings/interrupt-controller/arm-gic.h> 82 + 83 + soc { 84 + #address-cells = <2>; 85 + #size-cells = <2>; 86 + 87 + pcie@1c00000 { 88 + compatible = "qcom,pcie-sc8180x"; 89 + reg = <0 0x01c00000 0 0x3000>, 90 + <0 0x60000000 0 0xf1d>, 91 + <0 0x60000f20 0 0xa8>, 92 + <0 0x60001000 0 0x1000>, 93 + <0 0x60100000 0 0x100000>; 94 + reg-names = "parf", 95 + "dbi", 96 + "elbi", 97 + "atu", 98 + "config"; 99 + ranges = <0x01000000 0x0 0x60200000 0x0 0x60200000 0x0 0x100000>, 100 + <0x02000000 0x0 0x60300000 0x0 0x60300000 0x0 0x3d00000>; 101 + 102 + bus-range = <0x00 0xff>; 103 + device_type = "pci"; 104 + linux,pci-domain = <0>; 105 + num-lanes = <2>; 106 + 107 + #address-cells = <3>; 108 + #size-cells = <2>; 109 + 110 + assigned-clocks = <&gcc GCC_PCIE_0_AUX_CLK>; 111 + assigned-clock-rates = <19200000>; 112 + 113 + clocks = <&gcc GCC_PCIE_0_PIPE_CLK>, 114 + <&gcc GCC_PCIE_0_AUX_CLK>, 115 + <&gcc GCC_PCIE_0_CFG_AHB_CLK>, 116 + <&gcc GCC_PCIE_0_MSTR_AXI_CLK>, 117 + <&gcc GCC_PCIE_0_SLV_AXI_CLK>, 118 + <&gcc GCC_PCIE_0_SLV_Q2A_AXI_CLK>, 119 + <&gcc GCC_PCIE_0_CLKREF_CLK>, 120 + <&gcc GCC_AGGRE_NOC_PCIE_TBU_CLK>; 121 + clock-names = "pipe", 122 + "aux", 123 + "cfg", 124 + "bus_master", 125 + "bus_slave", 126 + "slave_q2a", 127 + "ref", 128 + "tbu"; 129 + 130 + dma-coherent; 131 + 132 + interrupts = <GIC_SPI 141 IRQ_TYPE_LEVEL_HIGH>, 133 + <GIC_SPI 142 IRQ_TYPE_LEVEL_HIGH>, 134 + <GIC_SPI 143 IRQ_TYPE_LEVEL_HIGH>, 135 + <GIC_SPI 144 IRQ_TYPE_LEVEL_HIGH>, 136 + <GIC_SPI 145 IRQ_TYPE_LEVEL_HIGH>, 137 + <GIC_SPI 146 IRQ_TYPE_LEVEL_HIGH>, 138 + <GIC_SPI 147 IRQ_TYPE_LEVEL_HIGH>, 139 + <GIC_SPI 148 IRQ_TYPE_LEVEL_HIGH>; 140 + interrupt-names = "msi0", 141 + "msi1", 142 + "msi2", 143 + "msi3", 144 + "msi4", 145 + "msi5", 146 + "msi6", 147 + "msi7"; 148 + #interrupt-cells = <1>; 149 + interrupt-map-mask = <0 0 0 0x7>; 150 + interrupt-map = <0 0 0 1 &intc 0 149 IRQ_TYPE_LEVEL_HIGH>, /* int_a */ 151 + <0 0 0 2 &intc 0 150 IRQ_TYPE_LEVEL_HIGH>, /* int_b */ 152 + <0 0 0 3 &intc 0 151 IRQ_TYPE_LEVEL_HIGH>, /* int_c */ 153 + <0 0 0 4 &intc 0 152 IRQ_TYPE_LEVEL_HIGH>; /* int_d */ 154 + 155 + interconnects = <&aggre2_noc MASTER_PCIE 0 &mc_virt SLAVE_EBI_CH0 0>, 156 + <&gem_noc MASTER_AMPSS_M0 0 &config_noc SLAVE_PCIE_0 0>; 157 + interconnect-names = "pcie-mem", "cpu-pcie"; 158 + 159 + iommu-map = <0x0 &apps_smmu 0x1d80 0x1>, 160 + <0x100 &apps_smmu 0x1d81 0x1>; 161 + 162 + phys = <&pcie0_phy>; 163 + phy-names = "pciephy"; 164 + 165 + power-domains = <&gcc PCIE_0_GDSC>; 166 + 167 + resets = <&gcc GCC_PCIE_0_BCR>; 168 + reset-names = "pci"; 169 + }; 170 + };
+180
Documentation/devicetree/bindings/pci/qcom,pcie-sc8280xp.yaml
··· 1 + # SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) 2 + %YAML 1.2 3 + --- 4 + $id: http://devicetree.org/schemas/pci/qcom,pcie-sc8280xp.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: Qualcomm SC8280XP PCI Express Root Complex 8 + 9 + maintainers: 10 + - Bjorn Andersson <andersson@kernel.org> 11 + - Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org> 12 + 13 + description: 14 + Qualcomm SC8280XP SoC PCIe root complex controller is based on the Synopsys 15 + DesignWare PCIe IP. 16 + 17 + properties: 18 + compatible: 19 + enum: 20 + - qcom,pcie-sa8540p 21 + - qcom,pcie-sc8280xp 22 + 23 + reg: 24 + minItems: 5 25 + maxItems: 6 26 + 27 + reg-names: 28 + minItems: 5 29 + items: 30 + - const: parf # Qualcomm specific registers 31 + - const: dbi # DesignWare PCIe registers 32 + - const: elbi # External local bus interface registers 33 + - const: atu # ATU address space 34 + - const: config # PCIe configuration space 35 + - const: mhi # MHI registers 36 + 37 + clocks: 38 + minItems: 8 39 + maxItems: 9 40 + 41 + clock-names: 42 + minItems: 8 43 + items: 44 + - const: aux # Auxiliary clock 45 + - const: cfg # Configuration clock 46 + - const: bus_master # Master AXI clock 47 + - const: bus_slave # Slave AXI clock 48 + - const: slave_q2a # Slave Q2A clock 49 + - const: ddrss_sf_tbu # PCIe SF TBU clock 50 + - const: noc_aggr_4 # NoC aggregate 4 clock 51 + - const: noc_aggr_south_sf # NoC aggregate South SF clock 52 + - const: cnoc_qx # Configuration NoC QX clock 53 + 54 + resets: 55 + maxItems: 1 56 + 57 + reset-names: 58 + items: 59 + - const: pci 60 + 61 + vddpe-3v3-supply: 62 + description: A phandle to the PCIe endpoint power supply 63 + 64 + required: 65 + - interconnects 66 + - interconnect-names 67 + 68 + allOf: 69 + - $ref: qcom,pcie-common.yaml# 70 + - if: 71 + properties: 72 + compatible: 73 + contains: 74 + enum: 75 + - qcom,pcie-sc8280xp 76 + then: 77 + properties: 78 + interrupts: 79 + minItems: 4 80 + maxItems: 4 81 + interrupt-names: 82 + items: 83 + - const: msi0 84 + - const: msi1 85 + - const: msi2 86 + - const: msi3 87 + else: 88 + properties: 89 + interrupts: 90 + maxItems: 1 91 + interrupt-names: 92 + items: 93 + - const: msi 94 + 95 + unevaluatedProperties: false 96 + 97 + examples: 98 + - | 99 + #include <dt-bindings/clock/qcom,gcc-sc8280xp.h> 100 + #include <dt-bindings/gpio/gpio.h> 101 + #include <dt-bindings/interconnect/qcom,sc8280xp.h> 102 + #include <dt-bindings/interrupt-controller/arm-gic.h> 103 + 104 + soc { 105 + #address-cells = <2>; 106 + #size-cells = <2>; 107 + 108 + pcie@1c20000 { 109 + compatible = "qcom,pcie-sc8280xp"; 110 + reg = <0x0 0x01c20000 0x0 0x3000>, 111 + <0x0 0x3c000000 0x0 0xf1d>, 112 + <0x0 0x3c000f20 0x0 0xa8>, 113 + <0x0 0x3c001000 0x0 0x1000>, 114 + <0x0 0x3c100000 0x0 0x100000>, 115 + <0x0 0x01c23000 0x0 0x1000>; 116 + reg-names = "parf", "dbi", "elbi", "atu", "config", "mhi"; 117 + ranges = <0x01000000 0x0 0x00000000 0x0 0x3c200000 0x0 0x100000>, 118 + <0x02000000 0x0 0x3c300000 0x0 0x3c300000 0x0 0x1d00000>; 119 + 120 + bus-range = <0x00 0xff>; 121 + device_type = "pci"; 122 + linux,pci-domain = <2>; 123 + num-lanes = <4>; 124 + 125 + #address-cells = <3>; 126 + #size-cells = <2>; 127 + 128 + assigned-clocks = <&gcc GCC_PCIE_2A_AUX_CLK>; 129 + assigned-clock-rates = <19200000>; 130 + clocks = <&gcc GCC_PCIE_2A_AUX_CLK>, 131 + <&gcc GCC_PCIE_2A_CFG_AHB_CLK>, 132 + <&gcc GCC_PCIE_2A_MSTR_AXI_CLK>, 133 + <&gcc GCC_PCIE_2A_SLV_AXI_CLK>, 134 + <&gcc GCC_PCIE_2A_SLV_Q2A_AXI_CLK>, 135 + <&gcc GCC_DDRSS_PCIE_SF_TBU_CLK>, 136 + <&gcc GCC_AGGRE_NOC_PCIE_4_AXI_CLK>, 137 + <&gcc GCC_AGGRE_NOC_PCIE_SOUTH_SF_AXI_CLK>; 138 + clock-names = "aux", 139 + "cfg", 140 + "bus_master", 141 + "bus_slave", 142 + "slave_q2a", 143 + "ddrss_sf_tbu", 144 + "noc_aggr_4", 145 + "noc_aggr_south_sf"; 146 + 147 + dma-coherent; 148 + 149 + interrupts = <GIC_SPI 86 IRQ_TYPE_LEVEL_HIGH>, 150 + <GIC_SPI 523 IRQ_TYPE_LEVEL_HIGH>, 151 + <GIC_SPI 524 IRQ_TYPE_LEVEL_HIGH>, 152 + <GIC_SPI 525 IRQ_TYPE_LEVEL_HIGH>; 153 + interrupt-names = "msi0", "msi1", "msi2", "msi3"; 154 + #interrupt-cells = <1>; 155 + interrupt-map-mask = <0 0 0 0x7>; 156 + interrupt-map = <0 0 0 1 &intc 0 0 GIC_SPI 530 IRQ_TYPE_LEVEL_HIGH>, 157 + <0 0 0 2 &intc 0 0 GIC_SPI 531 IRQ_TYPE_LEVEL_HIGH>, 158 + <0 0 0 3 &intc 0 0 GIC_SPI 532 IRQ_TYPE_LEVEL_HIGH>, 159 + <0 0 0 4 &intc 0 0 GIC_SPI 533 IRQ_TYPE_LEVEL_HIGH>; 160 + 161 + interconnects = <&aggre2_noc MASTER_PCIE_2A 0 &mc_virt SLAVE_EBI1 0>, 162 + <&gem_noc MASTER_APPSS_PROC 0 &config_noc SLAVE_PCIE_2A 0>; 163 + interconnect-names = "pcie-mem", "cpu-pcie"; 164 + 165 + phys = <&pcie2a_phy>; 166 + phy-names = "pciephy"; 167 + 168 + pinctrl-0 = <&pcie2a_default>; 169 + pinctrl-names = "default"; 170 + 171 + power-domains = <&gcc PCIE_2A_GDSC>; 172 + 173 + resets = <&gcc GCC_PCIE_2A_BCR>; 174 + reset-names = "pci"; 175 + 176 + perst-gpios = <&tlmm 143 GPIO_ACTIVE_LOW>; 177 + wake-gpios = <&tlmm 145 GPIO_ACTIVE_LOW>; 178 + vddpe-3v3-supply = <&vreg_nvme>; 179 + }; 180 + };
+158
Documentation/devicetree/bindings/pci/qcom,pcie-sm8150.yaml
··· 1 + # SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) 2 + %YAML 1.2 3 + --- 4 + $id: http://devicetree.org/schemas/pci/qcom,pcie-sm8150.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: Qualcomm SM8150 PCI Express Root Complex 8 + 9 + maintainers: 10 + - Bjorn Andersson <andersson@kernel.org> 11 + - Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org> 12 + 13 + description: 14 + Qualcomm SM8150 SoC PCIe root complex controller is based on the Synopsys 15 + DesignWare PCIe IP. 16 + 17 + properties: 18 + compatible: 19 + const: qcom,pcie-sm8150 20 + 21 + reg: 22 + minItems: 5 23 + maxItems: 6 24 + 25 + reg-names: 26 + minItems: 5 27 + items: 28 + - const: parf # Qualcomm specific registers 29 + - const: dbi # DesignWare PCIe registers 30 + - const: elbi # External local bus interface registers 31 + - const: atu # ATU address space 32 + - const: config # PCIe configuration space 33 + - const: mhi # MHI registers 34 + 35 + clocks: 36 + minItems: 8 37 + maxItems: 8 38 + 39 + clock-names: 40 + items: 41 + - const: pipe # PIPE clock 42 + - const: aux # Auxiliary clock 43 + - const: cfg # Configuration clock 44 + - const: bus_master # Master AXI clock 45 + - const: bus_slave # Slave AXI clock 46 + - const: slave_q2a # Slave Q2A clock 47 + - const: tbu # PCIe TBU clock 48 + - const: ref # REFERENCE clock 49 + 50 + interrupts: 51 + minItems: 8 52 + maxItems: 8 53 + 54 + interrupt-names: 55 + items: 56 + - const: msi0 57 + - const: msi1 58 + - const: msi2 59 + - const: msi3 60 + - const: msi4 61 + - const: msi5 62 + - const: msi6 63 + - const: msi7 64 + 65 + resets: 66 + maxItems: 1 67 + 68 + reset-names: 69 + items: 70 + - const: pci 71 + 72 + allOf: 73 + - $ref: qcom,pcie-common.yaml# 74 + 75 + unevaluatedProperties: false 76 + 77 + examples: 78 + - | 79 + #include <dt-bindings/clock/qcom,gcc-sm8150.h> 80 + #include <dt-bindings/clock/qcom,rpmh.h> 81 + #include <dt-bindings/gpio/gpio.h> 82 + #include <dt-bindings/interconnect/qcom,sm8150.h> 83 + #include <dt-bindings/interrupt-controller/arm-gic.h> 84 + 85 + soc { 86 + #address-cells = <2>; 87 + #size-cells = <2>; 88 + pcie@1c00000 { 89 + compatible = "qcom,pcie-sm8150"; 90 + reg = <0 0x01c00000 0 0x3000>, 91 + <0 0x60000000 0 0xf1d>, 92 + <0 0x60000f20 0 0xa8>, 93 + <0 0x60001000 0 0x1000>, 94 + <0 0x60100000 0 0x100000>; 95 + reg-names = "parf", "dbi", "elbi", "atu", "config"; 96 + ranges = <0x01000000 0x0 0x00000000 0x0 0x60200000 0x0 0x100000>, 97 + <0x02000000 0x0 0x60300000 0x0 0x60300000 0x0 0x3d00000>; 98 + 99 + bus-range = <0x00 0xff>; 100 + device_type = "pci"; 101 + linux,pci-domain = <0>; 102 + num-lanes = <1>; 103 + 104 + #address-cells = <3>; 105 + #size-cells = <2>; 106 + 107 + clocks = <&gcc GCC_PCIE_0_PIPE_CLK>, 108 + <&gcc GCC_PCIE_0_AUX_CLK>, 109 + <&gcc GCC_PCIE_0_CFG_AHB_CLK>, 110 + <&gcc GCC_PCIE_0_MSTR_AXI_CLK>, 111 + <&gcc GCC_PCIE_0_SLV_AXI_CLK>, 112 + <&gcc GCC_PCIE_0_SLV_Q2A_AXI_CLK>, 113 + <&gcc GCC_AGGRE_NOC_PCIE_TBU_CLK>, 114 + <&rpmhcc RPMH_CXO_CLK>; 115 + clock-names = "pipe", 116 + "aux", 117 + "cfg", 118 + "bus_master", 119 + "bus_slave", 120 + "slave_q2a", 121 + "tbu", 122 + "ref"; 123 + 124 + interrupts = <GIC_SPI 141 IRQ_TYPE_LEVEL_HIGH>, 125 + <GIC_SPI 142 IRQ_TYPE_LEVEL_HIGH>, 126 + <GIC_SPI 143 IRQ_TYPE_LEVEL_HIGH>, 127 + <GIC_SPI 144 IRQ_TYPE_LEVEL_HIGH>, 128 + <GIC_SPI 145 IRQ_TYPE_LEVEL_HIGH>, 129 + <GIC_SPI 146 IRQ_TYPE_LEVEL_HIGH>, 130 + <GIC_SPI 147 IRQ_TYPE_LEVEL_HIGH>, 131 + <GIC_SPI 148 IRQ_TYPE_LEVEL_HIGH>; 132 + interrupt-names = "msi0", "msi1", "msi2", "msi3", 133 + "msi4", "msi5", "msi6", "msi7"; 134 + #interrupt-cells = <1>; 135 + interrupt-map-mask = <0 0 0 0x7>; 136 + interrupt-map = <0 0 0 1 &intc 0 149 IRQ_TYPE_LEVEL_HIGH>, /* int_a */ 137 + <0 0 0 2 &intc 0 150 IRQ_TYPE_LEVEL_HIGH>, /* int_b */ 138 + <0 0 0 3 &intc 0 151 IRQ_TYPE_LEVEL_HIGH>, /* int_c */ 139 + <0 0 0 4 &intc 0 152 IRQ_TYPE_LEVEL_HIGH>; /* int_d */ 140 + 141 + iommu-map = <0x0 &apps_smmu 0x1d80 0x1>, 142 + <0x100 &apps_smmu 0x1d81 0x1>; 143 + 144 + phys = <&pcie0_phy>; 145 + phy-names = "pciephy"; 146 + 147 + pinctrl-0 = <&pcie0_default_state>; 148 + pinctrl-names = "default"; 149 + 150 + power-domains = <&gcc PCIE_0_GDSC>; 151 + 152 + resets = <&gcc GCC_PCIE_0_BCR>; 153 + reset-names = "pci"; 154 + 155 + perst-gpios = <&tlmm 35 GPIO_ACTIVE_HIGH>; 156 + wake-gpios = <&tlmm 37 GPIO_ACTIVE_HIGH>; 157 + }; 158 + };
+173
Documentation/devicetree/bindings/pci/qcom,pcie-sm8250.yaml
··· 1 + # SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) 2 + %YAML 1.2 3 + --- 4 + $id: http://devicetree.org/schemas/pci/qcom,pcie-sm8250.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: Qualcomm SM8250 PCI Express Root Complex 8 + 9 + maintainers: 10 + - Bjorn Andersson <andersson@kernel.org> 11 + - Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org> 12 + 13 + description: 14 + Qualcomm SM8250 SoC PCIe root complex controller is based on the Synopsys 15 + DesignWare PCIe IP. 16 + 17 + properties: 18 + compatible: 19 + const: qcom,pcie-sm8250 20 + 21 + reg: 22 + minItems: 5 23 + maxItems: 6 24 + 25 + reg-names: 26 + minItems: 5 27 + items: 28 + - const: parf # Qualcomm specific registers 29 + - const: dbi # DesignWare PCIe registers 30 + - const: elbi # External local bus interface registers 31 + - const: atu # ATU address space 32 + - const: config # PCIe configuration space 33 + - const: mhi # MHI registers 34 + 35 + clocks: 36 + minItems: 8 37 + maxItems: 9 38 + 39 + clock-names: 40 + # Unfortunately the "optional" ref clock is used in the middle of the list 41 + oneOf: 42 + - items: 43 + - const: pipe # PIPE clock 44 + - const: aux # Auxiliary clock 45 + - const: cfg # Configuration clock 46 + - const: bus_master # Master AXI clock 47 + - const: bus_slave # Slave AXI clock 48 + - const: slave_q2a # Slave Q2A clock 49 + - const: ref # REFERENCE clock 50 + - const: tbu # PCIe TBU clock 51 + - const: ddrss_sf_tbu # PCIe SF TBU clock 52 + - items: 53 + - const: pipe # PIPE clock 54 + - const: aux # Auxiliary clock 55 + - const: cfg # Configuration clock 56 + - const: bus_master # Master AXI clock 57 + - const: bus_slave # Slave AXI clock 58 + - const: slave_q2a # Slave Q2A clock 59 + - const: tbu # PCIe TBU clock 60 + - const: ddrss_sf_tbu # PCIe SF TBU clock 61 + 62 + interrupts: 63 + minItems: 8 64 + maxItems: 8 65 + 66 + interrupt-names: 67 + items: 68 + - const: msi0 69 + - const: msi1 70 + - const: msi2 71 + - const: msi3 72 + - const: msi4 73 + - const: msi5 74 + - const: msi6 75 + - const: msi7 76 + 77 + resets: 78 + maxItems: 1 79 + 80 + reset-names: 81 + items: 82 + - const: pci 83 + 84 + allOf: 85 + - $ref: qcom,pcie-common.yaml# 86 + 87 + unevaluatedProperties: false 88 + 89 + examples: 90 + - | 91 + #include <dt-bindings/clock/qcom,gcc-sm8250.h> 92 + #include <dt-bindings/gpio/gpio.h> 93 + #include <dt-bindings/interconnect/qcom,sm8250.h> 94 + #include <dt-bindings/interrupt-controller/arm-gic.h> 95 + 96 + soc { 97 + #address-cells = <2>; 98 + #size-cells = <2>; 99 + 100 + pcie@1c00000 { 101 + compatible = "qcom,pcie-sm8250"; 102 + reg = <0 0x01c00000 0 0x3000>, 103 + <0 0x60000000 0 0xf1d>, 104 + <0 0x60000f20 0 0xa8>, 105 + <0 0x60001000 0 0x1000>, 106 + <0 0x60100000 0 0x100000>, 107 + <0 0x01c03000 0 0x1000>; 108 + reg-names = "parf", "dbi", "elbi", "atu", "config", "mhi"; 109 + ranges = <0x01000000 0x0 0x00000000 0x0 0x60200000 0x0 0x100000>, 110 + <0x02000000 0x0 0x60300000 0x0 0x60300000 0x0 0x3d00000>; 111 + 112 + bus-range = <0x00 0xff>; 113 + device_type = "pci"; 114 + linux,pci-domain = <0>; 115 + num-lanes = <1>; 116 + 117 + #address-cells = <3>; 118 + #size-cells = <2>; 119 + 120 + clocks = <&gcc GCC_PCIE_0_PIPE_CLK>, 121 + <&gcc GCC_PCIE_0_AUX_CLK>, 122 + <&gcc GCC_PCIE_0_CFG_AHB_CLK>, 123 + <&gcc GCC_PCIE_0_MSTR_AXI_CLK>, 124 + <&gcc GCC_PCIE_0_SLV_AXI_CLK>, 125 + <&gcc GCC_PCIE_0_SLV_Q2A_AXI_CLK>, 126 + <&gcc GCC_AGGRE_NOC_PCIE_TBU_CLK>, 127 + <&gcc GCC_DDRSS_PCIE_SF_TBU_CLK>; 128 + clock-names = "pipe", 129 + "aux", 130 + "cfg", 131 + "bus_master", 132 + "bus_slave", 133 + "slave_q2a", 134 + "tbu", 135 + "ddrss_sf_tbu"; 136 + 137 + dma-coherent; 138 + 139 + interrupts = <GIC_SPI 141 IRQ_TYPE_LEVEL_HIGH>, 140 + <GIC_SPI 142 IRQ_TYPE_LEVEL_HIGH>, 141 + <GIC_SPI 143 IRQ_TYPE_LEVEL_HIGH>, 142 + <GIC_SPI 144 IRQ_TYPE_LEVEL_HIGH>, 143 + <GIC_SPI 145 IRQ_TYPE_LEVEL_HIGH>, 144 + <GIC_SPI 146 IRQ_TYPE_LEVEL_HIGH>, 145 + <GIC_SPI 147 IRQ_TYPE_LEVEL_HIGH>, 146 + <GIC_SPI 148 IRQ_TYPE_LEVEL_HIGH>; 147 + interrupt-names = "msi0", "msi1", "msi2", "msi3", 148 + "msi4", "msi5", "msi6", "msi7"; 149 + #interrupt-cells = <1>; 150 + interrupt-map-mask = <0 0 0 0x7>; 151 + interrupt-map = <0 0 0 1 &intc 0 149 IRQ_TYPE_LEVEL_HIGH>, /* int_a */ 152 + <0 0 0 2 &intc 0 150 IRQ_TYPE_LEVEL_HIGH>, /* int_b */ 153 + <0 0 0 3 &intc 0 151 IRQ_TYPE_LEVEL_HIGH>, /* int_c */ 154 + <0 0 0 4 &intc 0 152 IRQ_TYPE_LEVEL_HIGH>; /* int_d */ 155 + 156 + iommu-map = <0x0 &apps_smmu 0x1c00 0x1>, 157 + <0x100 &apps_smmu 0x1c01 0x1>; 158 + 159 + phys = <&pcie0_phy>; 160 + phy-names = "pciephy"; 161 + 162 + pinctrl-0 = <&pcie0_default_state>; 163 + pinctrl-names = "default"; 164 + 165 + power-domains = <&gcc PCIE_0_GDSC>; 166 + 167 + resets = <&gcc GCC_PCIE_0_BCR>; 168 + reset-names = "pci"; 169 + 170 + perst-gpios = <&tlmm 79 GPIO_ACTIVE_LOW>; 171 + wake-gpios = <&tlmm 81 GPIO_ACTIVE_HIGH>; 172 + }; 173 + };
+184
Documentation/devicetree/bindings/pci/qcom,pcie-sm8350.yaml
··· 1 + # SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) 2 + %YAML 1.2 3 + --- 4 + $id: http://devicetree.org/schemas/pci/qcom,pcie-sm8350.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: Qualcomm SM8350 PCI Express Root Complex 8 + 9 + maintainers: 10 + - Bjorn Andersson <andersson@kernel.org> 11 + - Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org> 12 + 13 + description: 14 + Qualcomm SM8350 SoC PCIe root complex controller is based on the Synopsys 15 + DesignWare PCIe IP. 16 + 17 + properties: 18 + compatible: 19 + const: qcom,pcie-sm8350 20 + 21 + reg: 22 + minItems: 5 23 + maxItems: 6 24 + 25 + reg-names: 26 + minItems: 5 27 + items: 28 + - const: parf # Qualcomm specific registers 29 + - const: dbi # DesignWare PCIe registers 30 + - const: elbi # External local bus interface registers 31 + - const: atu # ATU address space 32 + - const: config # PCIe configuration space 33 + - const: mhi # MHI registers 34 + 35 + clocks: 36 + minItems: 8 37 + maxItems: 9 38 + 39 + clock-names: 40 + minItems: 8 41 + items: 42 + - const: aux # Auxiliary clock 43 + - const: cfg # Configuration clock 44 + - const: bus_master # Master AXI clock 45 + - const: bus_slave # Slave AXI clock 46 + - const: slave_q2a # Slave Q2A clock 47 + - const: tbu # PCIe TBU clock 48 + - const: ddrss_sf_tbu # PCIe SF TBU clock 49 + - const: aggre1 # Aggre NoC PCIe1 AXI clock 50 + - const: aggre0 # Aggre NoC PCIe0 AXI clock 51 + 52 + interrupts: 53 + minItems: 8 54 + maxItems: 8 55 + 56 + interrupt-names: 57 + items: 58 + - const: msi0 59 + - const: msi1 60 + - const: msi2 61 + - const: msi3 62 + - const: msi4 63 + - const: msi5 64 + - const: msi6 65 + - const: msi7 66 + 67 + resets: 68 + maxItems: 1 69 + 70 + reset-names: 71 + items: 72 + - const: pci 73 + 74 + oneOf: 75 + - properties: 76 + interrupts: 77 + maxItems: 1 78 + interrupt-names: 79 + items: 80 + - const: msi 81 + 82 + - properties: 83 + interrupts: 84 + minItems: 8 85 + interrupt-names: 86 + items: 87 + - const: msi0 88 + - const: msi1 89 + - const: msi2 90 + - const: msi3 91 + - const: msi4 92 + - const: msi5 93 + - const: msi6 94 + - const: msi7 95 + 96 + allOf: 97 + - $ref: qcom,pcie-common.yaml# 98 + 99 + unevaluatedProperties: false 100 + 101 + examples: 102 + - | 103 + #include <dt-bindings/clock/qcom,gcc-sm8350.h> 104 + #include <dt-bindings/gpio/gpio.h> 105 + #include <dt-bindings/interconnect/qcom,sm8350.h> 106 + #include <dt-bindings/interrupt-controller/arm-gic.h> 107 + 108 + soc { 109 + #address-cells = <2>; 110 + #size-cells = <2>; 111 + 112 + pcie@1c00000 { 113 + compatible = "qcom,pcie-sm8350"; 114 + reg = <0 0x01c00000 0 0x3000>, 115 + <0 0x60000000 0 0xf1d>, 116 + <0 0x60000f20 0 0xa8>, 117 + <0 0x60001000 0 0x1000>, 118 + <0 0x60100000 0 0x100000>; 119 + reg-names = "parf", "dbi", "elbi", "atu", "config"; 120 + ranges = <0x01000000 0x0 0x00000000 0x0 0x60200000 0x0 0x100000>, 121 + <0x02000000 0x0 0x60300000 0x0 0x60300000 0x0 0x3d00000>; 122 + 123 + bus-range = <0x00 0xff>; 124 + device_type = "pci"; 125 + linux,pci-domain = <0>; 126 + num-lanes = <1>; 127 + 128 + #address-cells = <3>; 129 + #size-cells = <2>; 130 + 131 + clocks = <&gcc GCC_PCIE_0_AUX_CLK>, 132 + <&gcc GCC_PCIE_0_CFG_AHB_CLK>, 133 + <&gcc GCC_PCIE_0_MSTR_AXI_CLK>, 134 + <&gcc GCC_PCIE_0_SLV_AXI_CLK>, 135 + <&gcc GCC_PCIE_0_SLV_Q2A_AXI_CLK>, 136 + <&gcc GCC_AGGRE_NOC_PCIE_TBU_CLK>, 137 + <&gcc GCC_DDRSS_PCIE_SF_TBU_CLK>, 138 + <&gcc GCC_AGGRE_NOC_PCIE_1_AXI_CLK>, 139 + <&gcc GCC_AGGRE_NOC_PCIE_0_AXI_CLK>; 140 + clock-names = "aux", 141 + "cfg", 142 + "bus_master", 143 + "bus_slave", 144 + "slave_q2a", 145 + "tbu", 146 + "ddrss_sf_tbu", 147 + "aggre1", 148 + "aggre0"; 149 + 150 + interrupts = <GIC_SPI 141 IRQ_TYPE_LEVEL_HIGH>, 151 + <GIC_SPI 142 IRQ_TYPE_LEVEL_HIGH>, 152 + <GIC_SPI 143 IRQ_TYPE_LEVEL_HIGH>, 153 + <GIC_SPI 144 IRQ_TYPE_LEVEL_HIGH>, 154 + <GIC_SPI 145 IRQ_TYPE_LEVEL_HIGH>, 155 + <GIC_SPI 146 IRQ_TYPE_LEVEL_HIGH>, 156 + <GIC_SPI 147 IRQ_TYPE_LEVEL_HIGH>, 157 + <GIC_SPI 148 IRQ_TYPE_LEVEL_HIGH>; 158 + interrupt-names = "msi0", "msi1", "msi2", "msi3", 159 + "msi4", "msi5", "msi6", "msi7"; 160 + #interrupt-cells = <1>; 161 + interrupt-map-mask = <0 0 0 0x7>; 162 + interrupt-map = <0 0 0 1 &intc 0 149 IRQ_TYPE_LEVEL_HIGH>, /* int_a */ 163 + <0 0 0 2 &intc 0 150 IRQ_TYPE_LEVEL_HIGH>, /* int_b */ 164 + <0 0 0 3 &intc 0 151 IRQ_TYPE_LEVEL_HIGH>, /* int_c */ 165 + <0 0 0 4 &intc 0 152 IRQ_TYPE_LEVEL_HIGH>; /* int_d */ 166 + 167 + iommu-map = <0x0 &apps_smmu 0x1c00 0x1>, 168 + <0x100 &apps_smmu 0x1c01 0x1>; 169 + 170 + phys = <&pcie0_phy>; 171 + phy-names = "pciephy"; 172 + 173 + pinctrl-0 = <&pcie0_default_state>; 174 + pinctrl-names = "default"; 175 + 176 + power-domains = <&gcc PCIE_0_GDSC>; 177 + 178 + resets = <&gcc GCC_PCIE_0_BCR>; 179 + reset-names = "pci"; 180 + 181 + perst-gpios = <&tlmm 94 GPIO_ACTIVE_LOW>; 182 + wake-gpios = <&tlmm 96 GPIO_ACTIVE_HIGH>; 183 + }; 184 + };
+178
Documentation/devicetree/bindings/pci/qcom,pcie-sm8450.yaml
··· 1 + # SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) 2 + %YAML 1.2 3 + --- 4 + $id: http://devicetree.org/schemas/pci/qcom,pcie-sm8450.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: Qualcomm SM8450 PCI Express Root Complex 8 + 9 + maintainers: 10 + - Bjorn Andersson <andersson@kernel.org> 11 + - Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org> 12 + 13 + description: 14 + Qualcomm SM8450 SoC PCIe root complex controller is based on the Synopsys 15 + DesignWare PCIe IP. 16 + 17 + properties: 18 + compatible: 19 + enum: 20 + - qcom,pcie-sm8450-pcie0 21 + - qcom,pcie-sm8450-pcie1 22 + 23 + reg: 24 + minItems: 5 25 + maxItems: 6 26 + 27 + reg-names: 28 + minItems: 5 29 + items: 30 + - const: parf # Qualcomm specific registers 31 + - const: dbi # DesignWare PCIe registers 32 + - const: elbi # External local bus interface registers 33 + - const: atu # ATU address space 34 + - const: config # PCIe configuration space 35 + - const: mhi # MHI registers 36 + 37 + clocks: 38 + minItems: 11 39 + maxItems: 12 40 + 41 + clock-names: 42 + minItems: 11 43 + items: 44 + - const: pipe # PIPE clock 45 + - const: pipe_mux # PIPE MUX 46 + - const: phy_pipe # PIPE output clock 47 + - const: ref # REFERENCE clock 48 + - const: aux # Auxiliary clock 49 + - const: cfg # Configuration clock 50 + - const: bus_master # Master AXI clock 51 + - const: bus_slave # Slave AXI clock 52 + - const: slave_q2a # Slave Q2A clock 53 + - const: ddrss_sf_tbu # PCIe SF TBU clock 54 + - enum: [aggre0, aggre1] # Aggre NoC PCIe0/1 AXI clock 55 + - const: aggre1 # Aggre NoC PCIe1 AXI clock 56 + 57 + interrupts: 58 + minItems: 8 59 + maxItems: 8 60 + 61 + interrupt-names: 62 + items: 63 + - const: msi0 64 + - const: msi1 65 + - const: msi2 66 + - const: msi3 67 + - const: msi4 68 + - const: msi5 69 + - const: msi6 70 + - const: msi7 71 + 72 + resets: 73 + maxItems: 1 74 + 75 + reset-names: 76 + items: 77 + - const: pci 78 + 79 + allOf: 80 + - $ref: qcom,pcie-common.yaml# 81 + 82 + unevaluatedProperties: false 83 + 84 + examples: 85 + - | 86 + #include <dt-bindings/clock/qcom,gcc-sm8450.h> 87 + #include <dt-bindings/clock/qcom,rpmh.h> 88 + #include <dt-bindings/gpio/gpio.h> 89 + #include <dt-bindings/interconnect/qcom,sm8450.h> 90 + #include <dt-bindings/interrupt-controller/arm-gic.h> 91 + 92 + soc { 93 + #address-cells = <2>; 94 + #size-cells = <2>; 95 + 96 + pcie@1c00000 { 97 + compatible = "qcom,pcie-sm8450-pcie0"; 98 + reg = <0 0x01c00000 0 0x3000>, 99 + <0 0x60000000 0 0xf1d>, 100 + <0 0x60000f20 0 0xa8>, 101 + <0 0x60001000 0 0x1000>, 102 + <0 0x60100000 0 0x100000>; 103 + reg-names = "parf", "dbi", "elbi", "atu", "config"; 104 + ranges = <0x01000000 0x0 0x00000000 0x0 0x60200000 0x0 0x100000>, 105 + <0x02000000 0x0 0x60300000 0x0 0x60300000 0x0 0x3d00000>; 106 + 107 + bus-range = <0x00 0xff>; 108 + device_type = "pci"; 109 + linux,pci-domain = <0>; 110 + max-link-speed = <2>; 111 + num-lanes = <1>; 112 + 113 + #address-cells = <3>; 114 + #size-cells = <2>; 115 + 116 + clocks = <&gcc GCC_PCIE_0_PIPE_CLK>, 117 + <&gcc GCC_PCIE_0_PIPE_CLK_SRC>, 118 + <&pcie0_phy>, 119 + <&rpmhcc RPMH_CXO_CLK>, 120 + <&gcc GCC_PCIE_0_AUX_CLK>, 121 + <&gcc GCC_PCIE_0_CFG_AHB_CLK>, 122 + <&gcc GCC_PCIE_0_MSTR_AXI_CLK>, 123 + <&gcc GCC_PCIE_0_SLV_AXI_CLK>, 124 + <&gcc GCC_PCIE_0_SLV_Q2A_AXI_CLK>, 125 + <&gcc GCC_DDRSS_PCIE_SF_TBU_CLK>, 126 + <&gcc GCC_AGGRE_NOC_PCIE_0_AXI_CLK>, 127 + <&gcc GCC_AGGRE_NOC_PCIE_1_AXI_CLK>; 128 + clock-names = "pipe", 129 + "pipe_mux", 130 + "phy_pipe", 131 + "ref", 132 + "aux", 133 + "cfg", 134 + "bus_master", 135 + "bus_slave", 136 + "slave_q2a", 137 + "ddrss_sf_tbu", 138 + "aggre0", 139 + "aggre1"; 140 + 141 + interrupts = <GIC_SPI 141 IRQ_TYPE_LEVEL_HIGH>, 142 + <GIC_SPI 142 IRQ_TYPE_LEVEL_HIGH>, 143 + <GIC_SPI 143 IRQ_TYPE_LEVEL_HIGH>, 144 + <GIC_SPI 144 IRQ_TYPE_LEVEL_HIGH>, 145 + <GIC_SPI 145 IRQ_TYPE_LEVEL_HIGH>, 146 + <GIC_SPI 146 IRQ_TYPE_LEVEL_HIGH>, 147 + <GIC_SPI 147 IRQ_TYPE_LEVEL_HIGH>, 148 + <GIC_SPI 148 IRQ_TYPE_LEVEL_HIGH>; 149 + interrupt-names = "msi0", "msi1", "msi2", "msi3", 150 + "msi4", "msi5", "msi6", "msi7"; 151 + #interrupt-cells = <1>; 152 + interrupt-map-mask = <0 0 0 0x7>; 153 + interrupt-map = <0 0 0 1 &intc 0 0 0 149 IRQ_TYPE_LEVEL_HIGH>, /* int_a */ 154 + <0 0 0 2 &intc 0 0 0 150 IRQ_TYPE_LEVEL_HIGH>, /* int_b */ 155 + <0 0 0 3 &intc 0 0 0 151 IRQ_TYPE_LEVEL_HIGH>, /* int_c */ 156 + <0 0 0 4 &intc 0 0 0 152 IRQ_TYPE_LEVEL_HIGH>; /* int_d */ 157 + msi-map = <0x0 &gic_its 0x5981 0x1>, 158 + <0x100 &gic_its 0x5980 0x1>; 159 + msi-map-mask = <0xff00>; 160 + 161 + iommu-map = <0x0 &apps_smmu 0x1c00 0x1>, 162 + <0x100 &apps_smmu 0x1c01 0x1>; 163 + 164 + phys = <&pcie0_phy>; 165 + phy-names = "pciephy"; 166 + 167 + pinctrl-0 = <&pcie0_default_state>; 168 + pinctrl-names = "default"; 169 + 170 + power-domains = <&gcc PCIE_0_GDSC>; 171 + 172 + resets = <&gcc GCC_PCIE_0_BCR>; 173 + reset-names = "pci"; 174 + 175 + perst-gpios = <&tlmm 94 GPIO_ACTIVE_LOW>; 176 + wake-gpios = <&tlmm 96 GPIO_ACTIVE_HIGH>; 177 + }; 178 + };
+171
Documentation/devicetree/bindings/pci/qcom,pcie-sm8550.yaml
··· 1 + # SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) 2 + %YAML 1.2 3 + --- 4 + $id: http://devicetree.org/schemas/pci/qcom,pcie-sm8550.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: Qualcomm SM8550 PCI Express Root Complex 8 + 9 + maintainers: 10 + - Bjorn Andersson <andersson@kernel.org> 11 + - Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org> 12 + 13 + description: 14 + Qualcomm SM8550 SoC (and compatible) PCIe root complex controller is based on 15 + the Synopsys DesignWare PCIe IP. 16 + 17 + properties: 18 + compatible: 19 + oneOf: 20 + - const: qcom,pcie-sm8550 21 + - items: 22 + - enum: 23 + - qcom,pcie-sm8650 24 + - const: qcom,pcie-sm8550 25 + 26 + reg: 27 + minItems: 5 28 + maxItems: 6 29 + 30 + reg-names: 31 + minItems: 5 32 + items: 33 + - const: parf # Qualcomm specific registers 34 + - const: dbi # DesignWare PCIe registers 35 + - const: elbi # External local bus interface registers 36 + - const: atu # ATU address space 37 + - const: config # PCIe configuration space 38 + - const: mhi # MHI registers 39 + 40 + clocks: 41 + minItems: 7 42 + maxItems: 8 43 + 44 + clock-names: 45 + minItems: 7 46 + items: 47 + - const: aux # Auxiliary clock 48 + - const: cfg # Configuration clock 49 + - const: bus_master # Master AXI clock 50 + - const: bus_slave # Slave AXI clock 51 + - const: slave_q2a # Slave Q2A clock 52 + - const: ddrss_sf_tbu # PCIe SF TBU clock 53 + - const: noc_aggr # Aggre NoC PCIe AXI clock 54 + - const: cnoc_sf_axi # Config NoC PCIe1 AXI clock 55 + 56 + interrupts: 57 + minItems: 8 58 + maxItems: 8 59 + 60 + interrupt-names: 61 + items: 62 + - const: msi0 63 + - const: msi1 64 + - const: msi2 65 + - const: msi3 66 + - const: msi4 67 + - const: msi5 68 + - const: msi6 69 + - const: msi7 70 + 71 + resets: 72 + minItems: 1 73 + maxItems: 2 74 + 75 + reset-names: 76 + minItems: 1 77 + items: 78 + - const: pci # PCIe core reset 79 + - const: link_down # PCIe link down reset 80 + 81 + allOf: 82 + - $ref: qcom,pcie-common.yaml# 83 + 84 + unevaluatedProperties: false 85 + 86 + examples: 87 + - | 88 + #include <dt-bindings/clock/qcom,sm8550-gcc.h> 89 + #include <dt-bindings/gpio/gpio.h> 90 + #include <dt-bindings/interconnect/qcom,sm8550-rpmh.h> 91 + #include <dt-bindings/interrupt-controller/arm-gic.h> 92 + 93 + soc { 94 + #address-cells = <2>; 95 + #size-cells = <2>; 96 + 97 + pcie@1c00000 { 98 + compatible = "qcom,pcie-sm8550"; 99 + reg = <0 0x01c00000 0 0x3000>, 100 + <0 0x60000000 0 0xf1d>, 101 + <0 0x60000f20 0 0xa8>, 102 + <0 0x60001000 0 0x1000>, 103 + <0 0x60100000 0 0x100000>; 104 + reg-names = "parf", "dbi", "elbi", "atu", "config"; 105 + ranges = <0x01000000 0x0 0x00000000 0x0 0x60200000 0x0 0x100000>, 106 + <0x02000000 0x0 0x60300000 0x0 0x60300000 0x0 0x3d00000>; 107 + 108 + bus-range = <0x00 0xff>; 109 + device_type = "pci"; 110 + linux,pci-domain = <0>; 111 + num-lanes = <2>; 112 + 113 + #address-cells = <3>; 114 + #size-cells = <2>; 115 + 116 + clocks = <&gcc GCC_PCIE_0_AUX_CLK>, 117 + <&gcc GCC_PCIE_0_CFG_AHB_CLK>, 118 + <&gcc GCC_PCIE_0_MSTR_AXI_CLK>, 119 + <&gcc GCC_PCIE_0_SLV_AXI_CLK>, 120 + <&gcc GCC_PCIE_0_SLV_Q2A_AXI_CLK>, 121 + <&gcc GCC_DDRSS_PCIE_SF_QTB_CLK>, 122 + <&gcc GCC_AGGRE_NOC_PCIE_AXI_CLK>; 123 + clock-names = "aux", 124 + "cfg", 125 + "bus_master", 126 + "bus_slave", 127 + "slave_q2a", 128 + "ddrss_sf_tbu", 129 + "noc_aggr"; 130 + 131 + dma-coherent; 132 + 133 + interrupts = <GIC_SPI 141 IRQ_TYPE_LEVEL_HIGH>, 134 + <GIC_SPI 142 IRQ_TYPE_LEVEL_HIGH>, 135 + <GIC_SPI 143 IRQ_TYPE_LEVEL_HIGH>, 136 + <GIC_SPI 144 IRQ_TYPE_LEVEL_HIGH>, 137 + <GIC_SPI 145 IRQ_TYPE_LEVEL_HIGH>, 138 + <GIC_SPI 146 IRQ_TYPE_LEVEL_HIGH>, 139 + <GIC_SPI 147 IRQ_TYPE_LEVEL_HIGH>, 140 + <GIC_SPI 148 IRQ_TYPE_LEVEL_HIGH>; 141 + interrupt-names = "msi0", "msi1", "msi2", "msi3", 142 + "msi4", "msi5", "msi6", "msi7"; 143 + #interrupt-cells = <1>; 144 + interrupt-map-mask = <0 0 0 0x7>; 145 + interrupt-map = <0 0 0 1 &intc 0 0 0 149 IRQ_TYPE_LEVEL_HIGH>, /* int_a */ 146 + <0 0 0 2 &intc 0 0 0 150 IRQ_TYPE_LEVEL_HIGH>, /* int_b */ 147 + <0 0 0 3 &intc 0 0 0 151 IRQ_TYPE_LEVEL_HIGH>, /* int_c */ 148 + <0 0 0 4 &intc 0 0 0 152 IRQ_TYPE_LEVEL_HIGH>; /* int_d */ 149 + 150 + interconnects = <&pcie_noc MASTER_PCIE_0 0 &mc_virt SLAVE_EBI1 0>, 151 + <&gem_noc MASTER_APPSS_PROC 0 &cnoc_main SLAVE_PCIE_0 0>; 152 + interconnect-names = "pcie-mem", "cpu-pcie"; 153 + 154 + iommu-map = <0x0 &apps_smmu 0x1400 0x1>, 155 + <0x100 &apps_smmu 0x1401 0x1>; 156 + 157 + phys = <&pcie0_phy>; 158 + phy-names = "pciephy"; 159 + 160 + pinctrl-0 = <&pcie0_default_state>; 161 + pinctrl-names = "default"; 162 + 163 + power-domains = <&gcc PCIE_0_GDSC>; 164 + 165 + resets = <&gcc GCC_PCIE_0_BCR>; 166 + reset-names = "pci"; 167 + 168 + perst-gpios = <&tlmm 94 GPIO_ACTIVE_LOW>; 169 + wake-gpios = <&tlmm 96 GPIO_ACTIVE_HIGH>; 170 + }; 171 + };
+165
Documentation/devicetree/bindings/pci/qcom,pcie-x1e80100.yaml
··· 1 + # SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) 2 + %YAML 1.2 3 + --- 4 + $id: http://devicetree.org/schemas/pci/qcom,pcie-x1e80100.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: Qualcomm X1E80100 PCI Express Root Complex 8 + 9 + maintainers: 10 + - Bjorn Andersson <andersson@kernel.org> 11 + - Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org> 12 + 13 + description: 14 + Qualcomm X1E80100 SoC (and compatible) PCIe root complex controller is based on 15 + the Synopsys DesignWare PCIe IP. 16 + 17 + properties: 18 + compatible: 19 + const: qcom,pcie-x1e80100 20 + 21 + reg: 22 + minItems: 5 23 + maxItems: 6 24 + 25 + reg-names: 26 + minItems: 5 27 + items: 28 + - const: parf # Qualcomm specific registers 29 + - const: dbi # DesignWare PCIe registers 30 + - const: elbi # External local bus interface registers 31 + - const: atu # ATU address space 32 + - const: config # PCIe configuration space 33 + - const: mhi # MHI registers 34 + 35 + clocks: 36 + minItems: 7 37 + maxItems: 7 38 + 39 + clock-names: 40 + items: 41 + - const: aux # Auxiliary clock 42 + - const: cfg # Configuration clock 43 + - const: bus_master # Master AXI clock 44 + - const: bus_slave # Slave AXI clock 45 + - const: slave_q2a # Slave Q2A clock 46 + - const: noc_aggr # Aggre NoC PCIe AXI clock 47 + - const: cnoc_sf_axi # Config NoC PCIe1 AXI clock 48 + 49 + interrupts: 50 + minItems: 8 51 + maxItems: 8 52 + 53 + interrupt-names: 54 + items: 55 + - const: msi0 56 + - const: msi1 57 + - const: msi2 58 + - const: msi3 59 + - const: msi4 60 + - const: msi5 61 + - const: msi6 62 + - const: msi7 63 + 64 + resets: 65 + minItems: 1 66 + maxItems: 2 67 + 68 + reset-names: 69 + minItems: 1 70 + items: 71 + - const: pci # PCIe core reset 72 + - const: link_down # PCIe link down reset 73 + 74 + allOf: 75 + - $ref: qcom,pcie-common.yaml# 76 + 77 + unevaluatedProperties: false 78 + 79 + examples: 80 + - | 81 + #include <dt-bindings/clock/qcom,x1e80100-gcc.h> 82 + #include <dt-bindings/gpio/gpio.h> 83 + #include <dt-bindings/interconnect/qcom,x1e80100-rpmh.h> 84 + #include <dt-bindings/interrupt-controller/arm-gic.h> 85 + 86 + soc { 87 + #address-cells = <2>; 88 + #size-cells = <2>; 89 + 90 + pcie@1c08000 { 91 + compatible = "qcom,pcie-x1e80100"; 92 + reg = <0 0x01c08000 0 0x3000>, 93 + <0 0x7c000000 0 0xf1d>, 94 + <0 0x7c000f40 0 0xa8>, 95 + <0 0x7c001000 0 0x1000>, 96 + <0 0x7c100000 0 0x100000>, 97 + <0 0x01c0b000 0 0x1000>; 98 + reg-names = "parf", "dbi", "elbi", "atu", "config", "mhi"; 99 + ranges = <0x01000000 0x0 0x00000000 0x0 0x60200000 0x0 0x100000>, 100 + <0x02000000 0x0 0x60300000 0x0 0x60300000 0x0 0x3d00000>; 101 + 102 + bus-range = <0x00 0xff>; 103 + device_type = "pci"; 104 + linux,pci-domain = <0>; 105 + num-lanes = <2>; 106 + 107 + #address-cells = <3>; 108 + #size-cells = <2>; 109 + 110 + clocks = <&gcc GCC_PCIE_4_AUX_CLK>, 111 + <&gcc GCC_PCIE_4_CFG_AHB_CLK>, 112 + <&gcc GCC_PCIE_4_MSTR_AXI_CLK>, 113 + <&gcc GCC_PCIE_4_SLV_AXI_CLK>, 114 + <&gcc GCC_PCIE_4_SLV_Q2A_AXI_CLK>, 115 + <&gcc GCC_CFG_NOC_PCIE_ANOC_NORTH_AHB_CLK>, 116 + <&gcc GCC_CNOC_PCIE_NORTH_SF_AXI_CLK>; 117 + clock-names = "aux", 118 + "cfg", 119 + "bus_master", 120 + "bus_slave", 121 + "slave_q2a", 122 + "noc_aggr", 123 + "cnoc_sf_axi"; 124 + 125 + dma-coherent; 126 + 127 + interrupts = <GIC_SPI 141 IRQ_TYPE_LEVEL_HIGH>, 128 + <GIC_SPI 142 IRQ_TYPE_LEVEL_HIGH>, 129 + <GIC_SPI 143 IRQ_TYPE_LEVEL_HIGH>, 130 + <GIC_SPI 144 IRQ_TYPE_LEVEL_HIGH>, 131 + <GIC_SPI 145 IRQ_TYPE_LEVEL_HIGH>, 132 + <GIC_SPI 146 IRQ_TYPE_LEVEL_HIGH>, 133 + <GIC_SPI 147 IRQ_TYPE_LEVEL_HIGH>, 134 + <GIC_SPI 148 IRQ_TYPE_LEVEL_HIGH>; 135 + interrupt-names = "msi0", "msi1", "msi2", "msi3", 136 + "msi4", "msi5", "msi6", "msi7"; 137 + #interrupt-cells = <1>; 138 + interrupt-map-mask = <0 0 0 0x7>; 139 + interrupt-map = <0 0 0 1 &intc 0 0 0 149 IRQ_TYPE_LEVEL_HIGH>, /* int_a */ 140 + <0 0 0 2 &intc 0 0 0 150 IRQ_TYPE_LEVEL_HIGH>, /* int_b */ 141 + <0 0 0 3 &intc 0 0 0 151 IRQ_TYPE_LEVEL_HIGH>, /* int_c */ 142 + <0 0 0 4 &intc 0 0 0 152 IRQ_TYPE_LEVEL_HIGH>; /* int_d */ 143 + 144 + interconnects = <&pcie_noc MASTER_PCIE_4 0 &mc_virt SLAVE_EBI1 0>, 145 + <&gem_noc MASTER_APPSS_PROC 0 &cnoc_main SLAVE_PCIE_4 0>; 146 + interconnect-names = "pcie-mem", "cpu-pcie"; 147 + 148 + iommu-map = <0x0 &apps_smmu 0x1400 0x1>, 149 + <0x100 &apps_smmu 0x1401 0x1>; 150 + 151 + phys = <&pcie4_phy>; 152 + phy-names = "pciephy"; 153 + 154 + pinctrl-0 = <&pcie0_default_state>; 155 + pinctrl-names = "default"; 156 + 157 + power-domains = <&gcc GCC_PCIE_4_GDSC>; 158 + 159 + resets = <&gcc GCC_PCIE_4_BCR>; 160 + reset-names = "pci"; 161 + 162 + perst-gpios = <&tlmm 94 GPIO_ACTIVE_LOW>; 163 + wake-gpios = <&tlmm 96 GPIO_ACTIVE_HIGH>; 164 + }; 165 + };
+3 -375
Documentation/devicetree/bindings/pci/qcom,pcie.yaml
··· 28 28 - qcom,pcie-ipq8074-gen3 29 29 - qcom,pcie-msm8996 30 30 - qcom,pcie-qcs404 31 - - qcom,pcie-sa8540p 32 - - qcom,pcie-sa8775p 33 - - qcom,pcie-sc7280 34 - - qcom,pcie-sc8180x 35 - - qcom,pcie-sc8280xp 36 31 - qcom,pcie-sdm845 37 32 - qcom,pcie-sdx55 38 - - qcom,pcie-sm8150 39 - - qcom,pcie-sm8250 40 - - qcom,pcie-sm8350 41 - - qcom,pcie-sm8450-pcie0 42 - - qcom,pcie-sm8450-pcie1 43 - - qcom,pcie-sm8550 44 - - items: 45 - - enum: 46 - - qcom,pcie-sm8650 47 - - const: qcom,pcie-sm8550 48 33 - items: 49 34 - const: qcom,pcie-msm8998 50 35 - const: qcom,pcie-msm8996 ··· 91 106 vdda_refclk-supply: 92 107 description: A phandle to the core analog power supply for IC which generates reference clock 93 108 94 - vddpe-3v3-supply: 95 - description: A phandle to the PCIe endpoint power supply 96 - 97 109 phys: 98 110 maxItems: 1 99 111 ··· 103 121 104 122 perst-gpios: 105 123 description: GPIO controlled connection to PERST# signal 124 + maxItems: 1 125 + 126 + required-opps: 106 127 maxItems: 1 107 128 108 129 wake-gpios: ··· 128 143 - "#interrupt-cells" 129 144 - required: 130 145 - msi-map 131 - - msi-map-mask 132 146 133 147 allOf: 134 148 - $ref: /schemas/pci/pci-bus.yaml# ··· 201 217 compatible: 202 218 contains: 203 219 enum: 204 - - qcom,pcie-sa8775p 205 - - qcom,pcie-sc7280 206 - - qcom,pcie-sc8180x 207 - - qcom,pcie-sc8280xp 208 220 - qcom,pcie-sdx55 209 - - qcom,pcie-sm8250 210 - - qcom,pcie-sm8350 211 - - qcom,pcie-sm8450-pcie0 212 - - qcom,pcie-sm8450-pcie1 213 - - qcom,pcie-sm8550 214 221 then: 215 222 properties: 216 223 reg: ··· 431 456 compatible: 432 457 contains: 433 458 enum: 434 - - qcom,pcie-sc7280 435 - then: 436 - properties: 437 - clocks: 438 - minItems: 13 439 - maxItems: 13 440 - clock-names: 441 - items: 442 - - const: pipe # PIPE clock 443 - - const: pipe_mux # PIPE MUX 444 - - const: phy_pipe # PIPE output clock 445 - - const: ref # REFERENCE clock 446 - - const: aux # Auxiliary clock 447 - - const: cfg # Configuration clock 448 - - const: bus_master # Master AXI clock 449 - - const: bus_slave # Slave AXI clock 450 - - const: slave_q2a # Slave Q2A clock 451 - - const: tbu # PCIe TBU clock 452 - - const: ddrss_sf_tbu # PCIe SF TBU clock 453 - - const: aggre0 # Aggre NoC PCIe CENTER SF AXI clock 454 - - const: aggre1 # Aggre NoC PCIe1 AXI clock 455 - resets: 456 - maxItems: 1 457 - reset-names: 458 - items: 459 - - const: pci # PCIe core reset 460 - 461 - - if: 462 - properties: 463 - compatible: 464 - contains: 465 - enum: 466 - - qcom,pcie-sc8180x 467 - then: 468 - properties: 469 - clocks: 470 - minItems: 8 471 - maxItems: 8 472 - clock-names: 473 - items: 474 - - const: pipe # PIPE clock 475 - - const: aux # Auxiliary clock 476 - - const: cfg # Configuration clock 477 - - const: bus_master # Master AXI clock 478 - - const: bus_slave # Slave AXI clock 479 - - const: slave_q2a # Slave Q2A clock 480 - - const: ref # REFERENCE clock 481 - - const: tbu # PCIe TBU clock 482 - resets: 483 - maxItems: 1 484 - reset-names: 485 - items: 486 - - const: pci # PCIe core reset 487 - 488 - - if: 489 - properties: 490 - compatible: 491 - contains: 492 - enum: 493 459 - qcom,pcie-sdm845 494 460 then: 495 461 oneOf: ··· 474 558 compatible: 475 559 contains: 476 560 enum: 477 - - qcom,pcie-sm8150 478 - then: 479 - properties: 480 - clocks: 481 - minItems: 8 482 - maxItems: 8 483 - clock-names: 484 - items: 485 - - const: pipe # PIPE clock 486 - - const: aux # Auxiliary clock 487 - - const: cfg # Configuration clock 488 - - const: bus_master # Master AXI clock 489 - - const: bus_slave # Slave AXI clock 490 - - const: slave_q2a # Slave Q2A clock 491 - - const: tbu # PCIe TBU clock 492 - - const: ref # REFERENCE clock 493 - resets: 494 - maxItems: 1 495 - reset-names: 496 - items: 497 - - const: pci # PCIe core reset 498 - 499 - - if: 500 - properties: 501 - compatible: 502 - contains: 503 - enum: 504 - - qcom,pcie-sm8250 505 - then: 506 - oneOf: 507 - # Unfortunately the "optional" ref clock is used in the middle of the list 508 - - properties: 509 - clocks: 510 - minItems: 9 511 - maxItems: 9 512 - clock-names: 513 - items: 514 - - const: pipe # PIPE clock 515 - - const: aux # Auxiliary clock 516 - - const: cfg # Configuration clock 517 - - const: bus_master # Master AXI clock 518 - - const: bus_slave # Slave AXI clock 519 - - const: slave_q2a # Slave Q2A clock 520 - - const: ref # REFERENCE clock 521 - - const: tbu # PCIe TBU clock 522 - - const: ddrss_sf_tbu # PCIe SF TBU clock 523 - - properties: 524 - clocks: 525 - minItems: 8 526 - maxItems: 8 527 - clock-names: 528 - items: 529 - - const: pipe # PIPE clock 530 - - const: aux # Auxiliary clock 531 - - const: cfg # Configuration clock 532 - - const: bus_master # Master AXI clock 533 - - const: bus_slave # Slave AXI clock 534 - - const: slave_q2a # Slave Q2A clock 535 - - const: tbu # PCIe TBU clock 536 - - const: ddrss_sf_tbu # PCIe SF TBU clock 537 - properties: 538 - resets: 539 - maxItems: 1 540 - reset-names: 541 - items: 542 - - const: pci # PCIe core reset 543 - 544 - - if: 545 - properties: 546 - compatible: 547 - contains: 548 - enum: 549 - - qcom,pcie-sm8350 550 - then: 551 - properties: 552 - clocks: 553 - minItems: 8 554 - maxItems: 9 555 - clock-names: 556 - minItems: 8 557 - items: 558 - - const: aux # Auxiliary clock 559 - - const: cfg # Configuration clock 560 - - const: bus_master # Master AXI clock 561 - - const: bus_slave # Slave AXI clock 562 - - const: slave_q2a # Slave Q2A clock 563 - - const: tbu # PCIe TBU clock 564 - - const: ddrss_sf_tbu # PCIe SF TBU clock 565 - - const: aggre1 # Aggre NoC PCIe1 AXI clock 566 - - const: aggre0 # Aggre NoC PCIe0 AXI clock 567 - resets: 568 - maxItems: 1 569 - reset-names: 570 - items: 571 - - const: pci # PCIe core reset 572 - 573 - - if: 574 - properties: 575 - compatible: 576 - contains: 577 - enum: 578 - - qcom,pcie-sm8450-pcie0 579 - then: 580 - properties: 581 - clocks: 582 - minItems: 12 583 - maxItems: 12 584 - clock-names: 585 - items: 586 - - const: pipe # PIPE clock 587 - - const: pipe_mux # PIPE MUX 588 - - const: phy_pipe # PIPE output clock 589 - - const: ref # REFERENCE clock 590 - - const: aux # Auxiliary clock 591 - - const: cfg # Configuration clock 592 - - const: bus_master # Master AXI clock 593 - - const: bus_slave # Slave AXI clock 594 - - const: slave_q2a # Slave Q2A clock 595 - - const: ddrss_sf_tbu # PCIe SF TBU clock 596 - - const: aggre0 # Aggre NoC PCIe0 AXI clock 597 - - const: aggre1 # Aggre NoC PCIe1 AXI clock 598 - resets: 599 - maxItems: 1 600 - reset-names: 601 - items: 602 - - const: pci # PCIe core reset 603 - 604 - - if: 605 - properties: 606 - compatible: 607 - contains: 608 - enum: 609 - - qcom,pcie-sm8450-pcie1 610 - then: 611 - properties: 612 - clocks: 613 - minItems: 11 614 - maxItems: 11 615 - clock-names: 616 - items: 617 - - const: pipe # PIPE clock 618 - - const: pipe_mux # PIPE MUX 619 - - const: phy_pipe # PIPE output clock 620 - - const: ref # REFERENCE clock 621 - - const: aux # Auxiliary clock 622 - - const: cfg # Configuration clock 623 - - const: bus_master # Master AXI clock 624 - - const: bus_slave # Slave AXI clock 625 - - const: slave_q2a # Slave Q2A clock 626 - - const: ddrss_sf_tbu # PCIe SF TBU clock 627 - - const: aggre1 # Aggre NoC PCIe1 AXI clock 628 - resets: 629 - maxItems: 1 630 - reset-names: 631 - items: 632 - - const: pci # PCIe core reset 633 - 634 - - if: 635 - properties: 636 - compatible: 637 - contains: 638 - enum: 639 - - qcom,pcie-sm8550 640 - then: 641 - properties: 642 - clocks: 643 - minItems: 7 644 - maxItems: 8 645 - clock-names: 646 - minItems: 7 647 - items: 648 - - const: aux # Auxiliary clock 649 - - const: cfg # Configuration clock 650 - - const: bus_master # Master AXI clock 651 - - const: bus_slave # Slave AXI clock 652 - - const: slave_q2a # Slave Q2A clock 653 - - const: ddrss_sf_tbu # PCIe SF TBU clock 654 - - const: noc_aggr # Aggre NoC PCIe AXI clock 655 - - const: cnoc_sf_axi # Config NoC PCIe1 AXI clock 656 - resets: 657 - minItems: 1 658 - maxItems: 2 659 - reset-names: 660 - minItems: 1 661 - items: 662 - - const: pci # PCIe core reset 663 - - const: link_down # PCIe link down reset 664 - 665 - - if: 666 - properties: 667 - compatible: 668 - contains: 669 - enum: 670 - - qcom,pcie-sa8540p 671 - - qcom,pcie-sc8280xp 672 - then: 673 - properties: 674 - clocks: 675 - minItems: 8 676 - maxItems: 9 677 - clock-names: 678 - minItems: 8 679 - items: 680 - - const: aux # Auxiliary clock 681 - - const: cfg # Configuration clock 682 - - const: bus_master # Master AXI clock 683 - - const: bus_slave # Slave AXI clock 684 - - const: slave_q2a # Slave Q2A clock 685 - - const: ddrss_sf_tbu # PCIe SF TBU clock 686 - - const: noc_aggr_4 # NoC aggregate 4 clock 687 - - const: noc_aggr_south_sf # NoC aggregate South SF clock 688 - - const: cnoc_qx # Configuration NoC QX clock 689 - resets: 690 - maxItems: 1 691 - reset-names: 692 - items: 693 - - const: pci # PCIe core reset 694 - 695 - - if: 696 - properties: 697 - compatible: 698 - contains: 699 - enum: 700 561 - qcom,pcie-sdx55 701 562 then: 702 563 properties: ··· 494 801 reset-names: 495 802 items: 496 803 - const: pci # PCIe core reset 497 - 498 - - if: 499 - properties: 500 - compatible: 501 - contains: 502 - enum: 503 - - qcom,pcie-sa8775p 504 - then: 505 - properties: 506 - clocks: 507 - minItems: 5 508 - maxItems: 5 509 - clock-names: 510 - items: 511 - - const: aux # Auxiliary clock 512 - - const: cfg # Configuration clock 513 - - const: bus_master # Master AXI clock 514 - - const: bus_slave # Slave AXI clock 515 - - const: slave_q2a # Slave Q2A clock 516 - resets: 517 - maxItems: 1 518 - reset-names: 519 - items: 520 - - const: pci # PCIe core reset 521 - 522 - - if: 523 - properties: 524 - compatible: 525 - contains: 526 - enum: 527 - - qcom,pcie-sa8540p 528 - - qcom,pcie-sa8775p 529 - - qcom,pcie-sc8280xp 530 - then: 531 - required: 532 - - interconnects 533 - - interconnect-names 534 804 535 805 - if: 536 806 not: ··· 530 874 contains: 531 875 enum: 532 876 - qcom,pcie-msm8996 533 - - qcom,pcie-sa8775p 534 - - qcom,pcie-sc7280 535 - - qcom,pcie-sc8180x 536 877 - qcom,pcie-sdm845 537 - - qcom,pcie-sm8150 538 - - qcom,pcie-sm8250 539 - - qcom,pcie-sm8350 540 - - qcom,pcie-sm8450-pcie0 541 - - qcom,pcie-sm8450-pcie1 542 - - qcom,pcie-sm8550 543 878 then: 544 879 oneOf: 545 880 - properties: ··· 558 911 compatible: 559 912 contains: 560 913 enum: 561 - - qcom,pcie-sc8280xp 562 - then: 563 - properties: 564 - interrupts: 565 - minItems: 4 566 - maxItems: 4 567 - interrupt-names: 568 - items: 569 - - const: msi0 570 - - const: msi1 571 - - const: msi2 572 - - const: msi3 573 - 574 - - if: 575 - properties: 576 - compatible: 577 - contains: 578 - enum: 579 914 - qcom,pcie-apq8064 580 915 - qcom,pcie-apq8084 581 916 - qcom,pcie-ipq4019 ··· 567 938 - qcom,pcie-ipq8074 568 939 - qcom,pcie-ipq8074-gen3 569 940 - qcom,pcie-qcs404 570 - - qcom,pcie-sa8540p 571 941 then: 572 942 properties: 573 943 interrupts:
-3
Documentation/driver-api/device-io.rst
··· 517 517 518 518 .. kernel-doc:: arch/x86/include/asm/io.h 519 519 :internal: 520 - 521 - .. kernel-doc:: lib/pci_iomap.c 522 - :export:
+6
Documentation/driver-api/pci/pci.rst
··· 4 4 .. kernel-doc:: drivers/pci/pci.c 5 5 :export: 6 6 7 + .. kernel-doc:: drivers/pci/iomap.c 8 + :export: 9 + 10 + .. kernel-doc:: drivers/pci/devres.c 11 + :export: 12 + 7 13 .. kernel-doc:: drivers/pci/pci-driver.c 8 14 :export: 9 15
-1
MAINTAINERS
··· 17018 17018 F: include/linux/of_pci.h 17019 17019 F: include/linux/pci* 17020 17020 F: include/uapi/linux/pci* 17021 - F: lib/pci* 17022 17021 17023 17022 PCIE DRIVER FOR AMAZON ANNAPURNA LABS 17024 17023 M: Jonathan Chocron <jonnyc@amazon.com>
+48
arch/x86/pci/fixup.c
··· 907 907 DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x5ad6, chromeos_save_apl_pci_l1ss_capability); 908 908 DECLARE_PCI_FIXUP_RESUME(PCI_VENDOR_ID_INTEL, 0x5ad6, chromeos_fixup_apl_pci_l1ss_capability); 909 909 910 + /* 911 + * Disable D3cold on Asus B1400 PCI-NVMe bridge 912 + * 913 + * On this platform with VMD off, the NVMe device cannot successfully power 914 + * back on from D3cold. This appears to be an untested transition by the 915 + * vendor: Windows leaves the NVMe and parent bridge in D0 during suspend. 916 + * 917 + * We disable D3cold on the parent bridge for simplicity, and the fact that 918 + * both parent bridge and NVMe device share the same power resource. 919 + * 920 + * This is only needed on BIOS versions before 308; the newer versions flip 921 + * StorageD3Enable from 1 to 0. 922 + */ 923 + static const struct dmi_system_id asus_nvme_broken_d3cold_table[] = { 924 + { 925 + .matches = { 926 + DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), 927 + DMI_MATCH(DMI_BIOS_VERSION, "B1400CEAE.304"), 928 + }, 929 + }, 930 + { 931 + .matches = { 932 + DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), 933 + DMI_MATCH(DMI_BIOS_VERSION, "B1400CEAE.305"), 934 + }, 935 + }, 936 + { 937 + .matches = { 938 + DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), 939 + DMI_MATCH(DMI_BIOS_VERSION, "B1400CEAE.306"), 940 + }, 941 + }, 942 + { 943 + .matches = { 944 + DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), 945 + DMI_MATCH(DMI_BIOS_VERSION, "B1400CEAE.307"), 946 + }, 947 + }, 948 + {} 949 + }; 950 + 951 + static void asus_disable_nvme_d3cold(struct pci_dev *pdev) 952 + { 953 + if (dmi_check_system(asus_nvme_broken_d3cold_table) > 0) 954 + pci_d3cold_disable(pdev); 955 + } 956 + DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x9a09, asus_disable_nvme_d3cold); 957 + 910 958 #ifdef CONFIG_SUSPEND 911 959 /* 912 960 * Root Ports on some AMD SoCs advertise PME_Support for D3hot and D3cold, but
-12
drivers/acpi/sleep.c
··· 385 385 DMI_MATCH(DMI_PRODUCT_NAME, "20GGA00L00"), 386 386 }, 387 387 }, 388 - /* 389 - * ASUS B1400CEAE hangs on resume from suspend (see 390 - * https://bugzilla.kernel.org/show_bug.cgi?id=215742). 391 - */ 392 - { 393 - .callback = init_default_s3, 394 - .ident = "ASUS B1400CEAE", 395 - .matches = { 396 - DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), 397 - DMI_MATCH(DMI_PRODUCT_NAME, "ASUS EXPERTBOOK B1400CEAE"), 398 - }, 399 - }, 400 388 {}, 401 389 }; 402 390
+2 -2
drivers/firmware/efi/cper.c
··· 445 445 printk("%saer_uncor_severity: 0x%08x\n", 446 446 pfx, aer->uncor_severity); 447 447 printk("%sTLP Header: %08x %08x %08x %08x\n", pfx, 448 - aer->header_log.dw0, aer->header_log.dw1, 449 - aer->header_log.dw2, aer->header_log.dw3); 448 + aer->header_log.dw[0], aer->header_log.dw[1], 449 + aer->header_log.dw[2], aer->header_log.dw[3]); 450 450 } 451 451 } 452 452
+7 -1
drivers/ntb/core.c
··· 100 100 101 101 int ntb_register_device(struct ntb_dev *ntb) 102 102 { 103 + int ret; 104 + 103 105 if (!ntb) 104 106 return -EINVAL; 105 107 if (!ntb->pdev) ··· 122 120 ntb->ctx_ops = NULL; 123 121 spin_lock_init(&ntb->ctx_lock); 124 122 125 - return device_register(&ntb->dev); 123 + ret = device_register(&ntb->dev); 124 + if (ret) 125 + put_device(&ntb->dev); 126 + 127 + return ret; 126 128 } 127 129 EXPORT_SYMBOL(ntb_register_device); 128 130
+5
drivers/pci/Kconfig
··· 13 13 select HAVE_PCI 14 14 select PCI 15 15 16 + # select this to provide a generic PCI iomap, 17 + # without PCI itself having to be defined 18 + config GENERIC_PCI_IOMAP 19 + bool 20 + 16 21 menuconfig PCI 17 22 bool "PCI support" 18 23 depends on HAVE_PCI
+4 -3
drivers/pci/Makefile
··· 4 4 5 5 obj-$(CONFIG_PCI) += access.o bus.o probe.o host-bridge.o \ 6 6 remove.o pci.o pci-driver.o search.o \ 7 - pci-sysfs.o rom.o setup-res.o irq.o vpd.o \ 8 - setup-bus.o vc.o mmap.o setup-irq.o 7 + rom.o setup-res.o irq.o vpd.o \ 8 + setup-bus.o vc.o mmap.o devres.o 9 9 10 10 obj-$(CONFIG_PCI) += msi/ 11 11 obj-$(CONFIG_PCI) += pcie/ 12 12 13 13 ifdef CONFIG_PCI 14 14 obj-$(CONFIG_PROC_FS) += proc.o 15 - obj-$(CONFIG_SYSFS) += slot.o 15 + obj-$(CONFIG_SYSFS) += pci-sysfs.o slot.o 16 16 obj-$(CONFIG_ACPI) += pci-acpi.o 17 + obj-$(CONFIG_GENERIC_PCI_IOMAP) += iomap.o 17 18 endif 18 19 19 20 obj-$(CONFIG_OF) += of.o
+13 -1
drivers/pci/controller/cadence/pcie-cadence-ep.c
··· 565 565 struct cdns_pcie *pcie = &ep->pcie; 566 566 struct device *dev = pcie->dev; 567 567 int max_epfs = sizeof(epc->function_num_map) * 8; 568 - int ret, value, epf; 568 + int ret, epf, last_fn; 569 + u32 reg, value; 569 570 570 571 /* 571 572 * BIT(0) is hardwired to 1, hence function 0 is always enabled 572 573 * and can't be disabled anyway. 573 574 */ 574 575 cdns_pcie_writel(pcie, CDNS_PCIE_LM_EP_FUNC_CFG, epc->function_num_map); 576 + 577 + /* 578 + * Next function field in ARI_CAP_AND_CTR register for last function 579 + * should be 0. 580 + * Clearing Next Function Number field for the last function used. 581 + */ 582 + last_fn = find_last_bit(&epc->function_num_map, BITS_PER_LONG); 583 + reg = CDNS_PCIE_CORE_PF_I_ARI_CAP_AND_CTRL(last_fn); 584 + value = cdns_pcie_readl(pcie, reg); 585 + value &= ~CDNS_PCIE_ARI_CAP_NFN_MASK; 586 + cdns_pcie_writel(pcie, reg, value); 575 587 576 588 if (ep->quirk_disable_flr) { 577 589 for (epf = 0; epf < max_epfs; epf++) {
+6
drivers/pci/controller/cadence/pcie-cadence.h
··· 131 131 #define CDNS_PCIE_EP_FUNC_SRIOV_CAP_OFFSET 0x200 132 132 133 133 /* 134 + * Endpoint PF Registers 135 + */ 136 + #define CDNS_PCIE_CORE_PF_I_ARI_CAP_AND_CTRL(fn) (0x144 + (fn) * 0x1000) 137 + #define CDNS_PCIE_ARI_CAP_NFN_MASK GENMASK(15, 8) 138 + 139 + /* 134 140 * Root Port Registers (PCI configuration space for the root port function) 135 141 */ 136 142 #define CDNS_PCIE_RP_BASE 0x00200000
+357 -279
drivers/pci/controller/dwc/pci-imx6.c
··· 42 42 #define IMX8MQ_GPR12_PCIE2_CTRL_DEVICE_TYPE GENMASK(11, 8) 43 43 #define IMX8MQ_PCIE2_BASE_ADDR 0x33c00000 44 44 45 + #define IMX95_PCIE_PHY_GEN_CTRL 0x0 46 + #define IMX95_PCIE_REF_USE_PAD BIT(17) 47 + 48 + #define IMX95_PCIE_SS_RW_REG_0 0xf0 49 + #define IMX95_PCIE_REF_CLKEN BIT(23) 50 + #define IMX95_PCIE_PHY_CR_PARA_SEL BIT(9) 51 + 52 + #define IMX95_PE0_GEN_CTRL_1 0x1050 53 + #define IMX95_PCIE_DEVICE_TYPE GENMASK(3, 0) 54 + 55 + #define IMX95_PE0_GEN_CTRL_3 0x1058 56 + #define IMX95_PCIE_LTSSM_EN BIT(0) 57 + 45 58 #define to_imx6_pcie(x) dev_get_drvdata((x)->dev) 46 59 47 60 enum imx6_pcie_variants { ··· 65 52 IMX8MQ, 66 53 IMX8MM, 67 54 IMX8MP, 55 + IMX95, 68 56 IMX8MQ_EP, 69 57 IMX8MM_EP, 70 58 IMX8MP_EP, 59 + IMX95_EP, 71 60 }; 72 61 73 62 #define IMX6_PCIE_FLAG_IMX6_PHY BIT(0) 74 63 #define IMX6_PCIE_FLAG_IMX6_SPEED_CHANGE BIT(1) 75 64 #define IMX6_PCIE_FLAG_SUPPORTS_SUSPEND BIT(2) 65 + #define IMX6_PCIE_FLAG_HAS_PHYDRV BIT(3) 66 + #define IMX6_PCIE_FLAG_HAS_APP_RESET BIT(4) 67 + #define IMX6_PCIE_FLAG_HAS_PHY_RESET BIT(5) 68 + #define IMX6_PCIE_FLAG_HAS_SERDES BIT(6) 69 + #define IMX6_PCIE_FLAG_SUPPORT_64BIT BIT(7) 70 + 71 + #define imx6_check_flag(pci, val) (pci->drvdata->flags & val) 72 + 73 + #define IMX6_PCIE_MAX_CLKS 6 74 + 75 + #define IMX6_PCIE_MAX_INSTANCES 2 76 + 77 + struct imx6_pcie; 76 78 77 79 struct imx6_pcie_drvdata { 78 80 enum imx6_pcie_variants variant; ··· 95 67 u32 flags; 96 68 int dbi_length; 97 69 const char *gpr; 70 + const char * const *clk_names; 71 + const u32 clks_cnt; 72 + const u32 ltssm_off; 73 + const u32 ltssm_mask; 74 + const u32 mode_off[IMX6_PCIE_MAX_INSTANCES]; 75 + const u32 mode_mask[IMX6_PCIE_MAX_INSTANCES]; 76 + const struct pci_epc_features *epc_features; 77 + int (*init_phy)(struct imx6_pcie *pcie); 98 78 }; 99 79 100 80 struct imx6_pcie { ··· 110 74 int reset_gpio; 111 75 bool gpio_active_high; 112 76 bool link_is_up; 113 - struct clk *pcie_bus; 114 - struct clk *pcie_phy; 115 - struct clk *pcie_inbound_axi; 116 - struct clk *pcie; 117 - struct clk *pcie_aux; 77 + struct clk_bulk_data clks[IMX6_PCIE_MAX_CLKS]; 118 78 struct regmap *iomuxc_gpr; 119 79 u16 msi_ctrl; 120 80 u32 controller_id; ··· 197 165 return imx6_pcie->controller_id == 1 ? IOMUXC_GPR16 : IOMUXC_GPR14; 198 166 } 199 167 168 + static int imx95_pcie_init_phy(struct imx6_pcie *imx6_pcie) 169 + { 170 + regmap_update_bits(imx6_pcie->iomuxc_gpr, 171 + IMX95_PCIE_SS_RW_REG_0, 172 + IMX95_PCIE_PHY_CR_PARA_SEL, 173 + IMX95_PCIE_PHY_CR_PARA_SEL); 174 + 175 + regmap_update_bits(imx6_pcie->iomuxc_gpr, 176 + IMX95_PCIE_PHY_GEN_CTRL, 177 + IMX95_PCIE_REF_USE_PAD, 0); 178 + regmap_update_bits(imx6_pcie->iomuxc_gpr, 179 + IMX95_PCIE_SS_RW_REG_0, 180 + IMX95_PCIE_REF_CLKEN, 181 + IMX95_PCIE_REF_CLKEN); 182 + 183 + return 0; 184 + } 185 + 200 186 static void imx6_pcie_configure_type(struct imx6_pcie *imx6_pcie) 201 187 { 202 - unsigned int mask, val, mode; 188 + const struct imx6_pcie_drvdata *drvdata = imx6_pcie->drvdata; 189 + unsigned int mask, val, mode, id; 203 190 204 - if (imx6_pcie->drvdata->mode == DW_PCIE_EP_TYPE) 191 + if (drvdata->mode == DW_PCIE_EP_TYPE) 205 192 mode = PCI_EXP_TYPE_ENDPOINT; 206 193 else 207 194 mode = PCI_EXP_TYPE_ROOT_PORT; 208 195 209 - switch (imx6_pcie->drvdata->variant) { 210 - case IMX8MQ: 211 - case IMX8MQ_EP: 212 - if (imx6_pcie->controller_id == 1) { 213 - mask = IMX8MQ_GPR12_PCIE2_CTRL_DEVICE_TYPE; 214 - val = FIELD_PREP(IMX8MQ_GPR12_PCIE2_CTRL_DEVICE_TYPE, 215 - mode); 216 - } else { 217 - mask = IMX6Q_GPR12_DEVICE_TYPE; 218 - val = FIELD_PREP(IMX6Q_GPR12_DEVICE_TYPE, mode); 219 - } 220 - break; 221 - default: 222 - mask = IMX6Q_GPR12_DEVICE_TYPE; 223 - val = FIELD_PREP(IMX6Q_GPR12_DEVICE_TYPE, mode); 224 - break; 225 - } 196 + id = imx6_pcie->controller_id; 226 197 227 - regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR12, mask, val); 198 + /* If mode_mask[id] is zero, means each controller have its individual gpr */ 199 + if (!drvdata->mode_mask[id]) 200 + id = 0; 201 + 202 + mask = drvdata->mode_mask[id]; 203 + val = mode << (ffs(mask) - 1); 204 + 205 + regmap_update_bits(imx6_pcie->iomuxc_gpr, drvdata->mode_off[id], mask, val); 228 206 } 229 207 230 208 static int pcie_phy_poll_ack(struct imx6_pcie *imx6_pcie, bool exp_val) ··· 362 320 return 0; 363 321 } 364 322 365 - static void imx6_pcie_init_phy(struct imx6_pcie *imx6_pcie) 323 + static int imx8mq_pcie_init_phy(struct imx6_pcie *imx6_pcie) 366 324 { 367 - switch (imx6_pcie->drvdata->variant) { 368 - case IMX8MM: 369 - case IMX8MM_EP: 370 - case IMX8MP: 371 - case IMX8MP_EP: 372 - /* 373 - * The PHY initialization had been done in the PHY 374 - * driver, break here directly. 375 - */ 376 - break; 377 - case IMX8MQ: 378 - case IMX8MQ_EP: 379 - /* 380 - * TODO: Currently this code assumes external 381 - * oscillator is being used 382 - */ 325 + /* TODO: Currently this code assumes external oscillator is being used */ 326 + regmap_update_bits(imx6_pcie->iomuxc_gpr, 327 + imx6_pcie_grp_offset(imx6_pcie), 328 + IMX8MQ_GPR_PCIE_REF_USE_PAD, 329 + IMX8MQ_GPR_PCIE_REF_USE_PAD); 330 + /* 331 + * Regarding the datasheet, the PCIE_VPH is suggested to be 1.8V. If the PCIE_VPH is 332 + * supplied by 3.3V, the VREG_BYPASS should be cleared to zero. 333 + */ 334 + if (imx6_pcie->vph && regulator_get_voltage(imx6_pcie->vph) > 3000000) 383 335 regmap_update_bits(imx6_pcie->iomuxc_gpr, 384 336 imx6_pcie_grp_offset(imx6_pcie), 385 - IMX8MQ_GPR_PCIE_REF_USE_PAD, 386 - IMX8MQ_GPR_PCIE_REF_USE_PAD); 387 - /* 388 - * Regarding the datasheet, the PCIE_VPH is suggested 389 - * to be 1.8V. If the PCIE_VPH is supplied by 3.3V, the 390 - * VREG_BYPASS should be cleared to zero. 391 - */ 392 - if (imx6_pcie->vph && 393 - regulator_get_voltage(imx6_pcie->vph) > 3000000) 394 - regmap_update_bits(imx6_pcie->iomuxc_gpr, 395 - imx6_pcie_grp_offset(imx6_pcie), 396 - IMX8MQ_GPR_PCIE_VREG_BYPASS, 397 - 0); 398 - break; 399 - case IMX7D: 400 - regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR12, 401 - IMX7D_GPR12_PCIE_PHY_REFCLK_SEL, 0); 402 - break; 403 - case IMX6SX: 404 - regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR12, 405 - IMX6SX_GPR12_PCIE_RX_EQ_MASK, 406 - IMX6SX_GPR12_PCIE_RX_EQ_2); 407 - fallthrough; 408 - default: 409 - regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR12, 337 + IMX8MQ_GPR_PCIE_VREG_BYPASS, 338 + 0); 339 + 340 + return 0; 341 + } 342 + 343 + static int imx7d_pcie_init_phy(struct imx6_pcie *imx6_pcie) 344 + { 345 + regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR12, IMX7D_GPR12_PCIE_PHY_REFCLK_SEL, 0); 346 + 347 + return 0; 348 + } 349 + 350 + static int imx6_pcie_init_phy(struct imx6_pcie *imx6_pcie) 351 + { 352 + regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR12, 410 353 IMX6Q_GPR12_PCIE_CTL_2, 0 << 10); 411 354 412 - /* configure constant input signal to the pcie ctrl and phy */ 413 - regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR12, 414 - IMX6Q_GPR12_LOS_LEVEL, 9 << 4); 355 + /* configure constant input signal to the pcie ctrl and phy */ 356 + regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR12, 357 + IMX6Q_GPR12_LOS_LEVEL, 9 << 4); 415 358 416 - regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR8, 417 - IMX6Q_GPR8_TX_DEEMPH_GEN1, 418 - imx6_pcie->tx_deemph_gen1 << 0); 419 - regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR8, 420 - IMX6Q_GPR8_TX_DEEMPH_GEN2_3P5DB, 421 - imx6_pcie->tx_deemph_gen2_3p5db << 6); 422 - regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR8, 423 - IMX6Q_GPR8_TX_DEEMPH_GEN2_6DB, 424 - imx6_pcie->tx_deemph_gen2_6db << 12); 425 - regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR8, 426 - IMX6Q_GPR8_TX_SWING_FULL, 427 - imx6_pcie->tx_swing_full << 18); 428 - regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR8, 429 - IMX6Q_GPR8_TX_SWING_LOW, 430 - imx6_pcie->tx_swing_low << 25); 431 - break; 432 - } 359 + regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR8, 360 + IMX6Q_GPR8_TX_DEEMPH_GEN1, 361 + imx6_pcie->tx_deemph_gen1 << 0); 362 + regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR8, 363 + IMX6Q_GPR8_TX_DEEMPH_GEN2_3P5DB, 364 + imx6_pcie->tx_deemph_gen2_3p5db << 6); 365 + regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR8, 366 + IMX6Q_GPR8_TX_DEEMPH_GEN2_6DB, 367 + imx6_pcie->tx_deemph_gen2_6db << 12); 368 + regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR8, 369 + IMX6Q_GPR8_TX_SWING_FULL, 370 + imx6_pcie->tx_swing_full << 18); 371 + regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR8, 372 + IMX6Q_GPR8_TX_SWING_LOW, 373 + imx6_pcie->tx_swing_low << 25); 374 + return 0; 375 + } 433 376 434 - imx6_pcie_configure_type(imx6_pcie); 377 + static int imx6sx_pcie_init_phy(struct imx6_pcie *imx6_pcie) 378 + { 379 + regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR12, 380 + IMX6SX_GPR12_PCIE_RX_EQ_MASK, IMX6SX_GPR12_PCIE_RX_EQ_2); 381 + 382 + return imx6_pcie_init_phy(imx6_pcie); 435 383 } 436 384 437 385 static void imx7d_pcie_wait_for_phy_pll_lock(struct imx6_pcie *imx6_pcie) ··· 439 407 440 408 static int imx6_setup_phy_mpll(struct imx6_pcie *imx6_pcie) 441 409 { 442 - unsigned long phy_rate = clk_get_rate(imx6_pcie->pcie_phy); 410 + unsigned long phy_rate = 0; 443 411 int mult, div; 444 412 u16 val; 413 + int i; 445 414 446 415 if (!(imx6_pcie->drvdata->flags & IMX6_PCIE_FLAG_IMX6_PHY)) 447 416 return 0; 417 + 418 + for (i = 0; i < imx6_pcie->drvdata->clks_cnt; i++) 419 + if (strncmp(imx6_pcie->clks[i].id, "pcie_phy", 8) == 0) 420 + phy_rate = clk_get_rate(imx6_pcie->clks[i].clk); 448 421 449 422 switch (phy_rate) { 450 423 case 125000000: ··· 587 550 588 551 static int imx6_pcie_enable_ref_clk(struct imx6_pcie *imx6_pcie) 589 552 { 590 - struct dw_pcie *pci = imx6_pcie->pci; 591 - struct device *dev = pci->dev; 592 553 unsigned int offset; 593 554 int ret = 0; 594 555 595 556 switch (imx6_pcie->drvdata->variant) { 596 557 case IMX6SX: 597 - ret = clk_prepare_enable(imx6_pcie->pcie_inbound_axi); 598 - if (ret) { 599 - dev_err(dev, "unable to enable pcie_axi clock\n"); 600 - break; 601 - } 602 - 603 558 regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR12, 604 559 IMX6SX_GPR12_PCIE_TEST_POWERDOWN, 0); 605 560 break; ··· 611 582 IMX6Q_GPR1_PCIE_REF_CLK_EN, 1 << 16); 612 583 break; 613 584 case IMX7D: 585 + case IMX95: 586 + case IMX95_EP: 614 587 break; 615 588 case IMX8MM: 616 589 case IMX8MM_EP: ··· 620 589 case IMX8MQ_EP: 621 590 case IMX8MP: 622 591 case IMX8MP_EP: 623 - ret = clk_prepare_enable(imx6_pcie->pcie_aux); 624 - if (ret) { 625 - dev_err(dev, "unable to enable pcie_aux clock\n"); 626 - break; 627 - } 628 - 629 592 offset = imx6_pcie_grp_offset(imx6_pcie); 630 593 /* 631 594 * Set the over ride low and enabled ··· 640 615 static void imx6_pcie_disable_ref_clk(struct imx6_pcie *imx6_pcie) 641 616 { 642 617 switch (imx6_pcie->drvdata->variant) { 643 - case IMX6SX: 644 - clk_disable_unprepare(imx6_pcie->pcie_inbound_axi); 645 - break; 646 618 case IMX6QP: 647 619 case IMX6Q: 648 620 regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR1, ··· 653 631 IMX7D_GPR12_PCIE_PHY_REFCLK_SEL, 654 632 IMX7D_GPR12_PCIE_PHY_REFCLK_SEL); 655 633 break; 656 - case IMX8MM: 657 - case IMX8MM_EP: 658 - case IMX8MQ: 659 - case IMX8MQ_EP: 660 - case IMX8MP: 661 - case IMX8MP_EP: 662 - clk_disable_unprepare(imx6_pcie->pcie_aux); 663 - break; 664 634 default: 665 635 break; 666 636 } ··· 664 650 struct device *dev = pci->dev; 665 651 int ret; 666 652 667 - ret = clk_prepare_enable(imx6_pcie->pcie_phy); 668 - if (ret) { 669 - dev_err(dev, "unable to enable pcie_phy clock\n"); 653 + ret = clk_bulk_prepare_enable(imx6_pcie->drvdata->clks_cnt, imx6_pcie->clks); 654 + if (ret) 670 655 return ret; 671 - } 672 - 673 - ret = clk_prepare_enable(imx6_pcie->pcie_bus); 674 - if (ret) { 675 - dev_err(dev, "unable to enable pcie_bus clock\n"); 676 - goto err_pcie_bus; 677 - } 678 - 679 - ret = clk_prepare_enable(imx6_pcie->pcie); 680 - if (ret) { 681 - dev_err(dev, "unable to enable pcie clock\n"); 682 - goto err_pcie; 683 - } 684 656 685 657 ret = imx6_pcie_enable_ref_clk(imx6_pcie); 686 658 if (ret) { ··· 679 679 return 0; 680 680 681 681 err_ref_clk: 682 - clk_disable_unprepare(imx6_pcie->pcie); 683 - err_pcie: 684 - clk_disable_unprepare(imx6_pcie->pcie_bus); 685 - err_pcie_bus: 686 - clk_disable_unprepare(imx6_pcie->pcie_phy); 682 + clk_bulk_disable_unprepare(imx6_pcie->drvdata->clks_cnt, imx6_pcie->clks); 687 683 688 684 return ret; 689 685 } ··· 687 691 static void imx6_pcie_clk_disable(struct imx6_pcie *imx6_pcie) 688 692 { 689 693 imx6_pcie_disable_ref_clk(imx6_pcie); 690 - clk_disable_unprepare(imx6_pcie->pcie); 691 - clk_disable_unprepare(imx6_pcie->pcie_bus); 692 - clk_disable_unprepare(imx6_pcie->pcie_phy); 694 + clk_bulk_disable_unprepare(imx6_pcie->drvdata->clks_cnt, imx6_pcie->clks); 693 695 } 694 696 695 697 static void imx6_pcie_assert_core_reset(struct imx6_pcie *imx6_pcie) 696 698 { 699 + reset_control_assert(imx6_pcie->pciephy_reset); 700 + reset_control_assert(imx6_pcie->apps_reset); 701 + 697 702 switch (imx6_pcie->drvdata->variant) { 698 - case IMX7D: 699 - case IMX8MQ: 700 - case IMX8MQ_EP: 701 - reset_control_assert(imx6_pcie->pciephy_reset); 702 - fallthrough; 703 - case IMX8MM: 704 - case IMX8MM_EP: 705 - case IMX8MP: 706 - case IMX8MP_EP: 707 - reset_control_assert(imx6_pcie->apps_reset); 708 - break; 709 703 case IMX6SX: 710 704 regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR12, 711 705 IMX6SX_GPR12_PCIE_TEST_POWERDOWN, ··· 716 730 regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR1, 717 731 IMX6Q_GPR1_PCIE_REF_CLK_EN, 0 << 16); 718 732 break; 733 + default: 734 + break; 719 735 } 720 736 721 737 /* Some boards don't have PCIe reset GPIO. */ ··· 731 743 struct dw_pcie *pci = imx6_pcie->pci; 732 744 struct device *dev = pci->dev; 733 745 734 - switch (imx6_pcie->drvdata->variant) { 735 - case IMX8MQ: 736 - case IMX8MQ_EP: 737 - reset_control_deassert(imx6_pcie->pciephy_reset); 738 - break; 739 - case IMX7D: 740 - reset_control_deassert(imx6_pcie->pciephy_reset); 746 + reset_control_deassert(imx6_pcie->pciephy_reset); 741 747 748 + switch (imx6_pcie->drvdata->variant) { 749 + case IMX7D: 742 750 /* Workaround for ERR010728, failure of PCI-e PLL VCO to 743 751 * oscillate, especially when cold. This turns off "Duty-cycle 744 752 * Corrector" and other mysterious undocumented things. ··· 766 782 767 783 usleep_range(200, 500); 768 784 break; 769 - case IMX6Q: /* Nothing to do */ 770 - case IMX8MM: 771 - case IMX8MM_EP: 772 - case IMX8MP: 773 - case IMX8MP_EP: 785 + default: 774 786 break; 775 787 } 776 788 ··· 804 824 static void imx6_pcie_ltssm_enable(struct device *dev) 805 825 { 806 826 struct imx6_pcie *imx6_pcie = dev_get_drvdata(dev); 827 + const struct imx6_pcie_drvdata *drvdata = imx6_pcie->drvdata; 807 828 808 - switch (imx6_pcie->drvdata->variant) { 809 - case IMX6Q: 810 - case IMX6SX: 811 - case IMX6QP: 812 - regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR12, 813 - IMX6Q_GPR12_PCIE_CTL_2, 814 - IMX6Q_GPR12_PCIE_CTL_2); 815 - break; 816 - case IMX7D: 817 - case IMX8MQ: 818 - case IMX8MQ_EP: 819 - case IMX8MM: 820 - case IMX8MM_EP: 821 - case IMX8MP: 822 - case IMX8MP_EP: 823 - reset_control_deassert(imx6_pcie->apps_reset); 824 - break; 825 - } 829 + if (drvdata->ltssm_mask) 830 + regmap_update_bits(imx6_pcie->iomuxc_gpr, drvdata->ltssm_off, drvdata->ltssm_mask, 831 + drvdata->ltssm_mask); 832 + 833 + reset_control_deassert(imx6_pcie->apps_reset); 826 834 } 827 835 828 836 static void imx6_pcie_ltssm_disable(struct device *dev) 829 837 { 830 838 struct imx6_pcie *imx6_pcie = dev_get_drvdata(dev); 839 + const struct imx6_pcie_drvdata *drvdata = imx6_pcie->drvdata; 831 840 832 - switch (imx6_pcie->drvdata->variant) { 833 - case IMX6Q: 834 - case IMX6SX: 835 - case IMX6QP: 836 - regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR12, 837 - IMX6Q_GPR12_PCIE_CTL_2, 0); 838 - break; 839 - case IMX7D: 840 - case IMX8MQ: 841 - case IMX8MQ_EP: 842 - case IMX8MM: 843 - case IMX8MM_EP: 844 - case IMX8MP: 845 - case IMX8MP_EP: 846 - reset_control_assert(imx6_pcie->apps_reset); 847 - break; 848 - } 841 + if (drvdata->ltssm_mask) 842 + regmap_update_bits(imx6_pcie->iomuxc_gpr, drvdata->ltssm_off, 843 + drvdata->ltssm_mask, 0); 844 + 845 + reset_control_assert(imx6_pcie->apps_reset); 849 846 } 850 847 851 848 static int imx6_pcie_start_link(struct dw_pcie *pci) ··· 934 977 } 935 978 936 979 imx6_pcie_assert_core_reset(imx6_pcie); 937 - imx6_pcie_init_phy(imx6_pcie); 980 + 981 + if (imx6_pcie->drvdata->init_phy) 982 + imx6_pcie->drvdata->init_phy(imx6_pcie); 983 + 984 + imx6_pcie_configure_type(imx6_pcie); 938 985 939 986 ret = imx6_pcie_clk_enable(imx6_pcie); 940 987 if (ret) { ··· 1042 1081 .linkup_notifier = false, 1043 1082 .msi_capable = true, 1044 1083 .msix_capable = false, 1045 - .reserved_bar = 1 << BAR_1 | 1 << BAR_3, 1084 + .bar[BAR_1] = { .type = BAR_RESERVED, }, 1085 + .bar[BAR_3] = { .type = BAR_RESERVED, }, 1046 1086 .align = SZ_64K, 1087 + }; 1088 + 1089 + /* 1090 + * BAR# | Default BAR enable | Default BAR Type | Default BAR Size | BAR Sizing Scheme 1091 + * ================================================================================================ 1092 + * BAR0 | Enable | 64-bit | 1 MB | Programmable Size 1093 + * BAR1 | Disable | 32-bit | 64 KB | Fixed Size 1094 + * BAR1 should be disabled if BAR0 is 64bit. 1095 + * BAR2 | Enable | 32-bit | 1 MB | Programmable Size 1096 + * BAR3 | Enable | 32-bit | 64 KB | Programmable Size 1097 + * BAR4 | Enable | 32-bit | 1M | Programmable Size 1098 + * BAR5 | Enable | 32-bit | 64 KB | Programmable Size 1099 + */ 1100 + static const struct pci_epc_features imx95_pcie_epc_features = { 1101 + .msi_capable = true, 1102 + .bar[BAR_1] = { .type = BAR_FIXED, .fixed_size = SZ_64K, }, 1103 + .align = SZ_4K, 1047 1104 }; 1048 1105 1049 1106 static const struct pci_epc_features* 1050 1107 imx6_pcie_ep_get_features(struct dw_pcie_ep *ep) 1051 1108 { 1052 - return &imx8m_pcie_epc_features; 1109 + struct dw_pcie *pci = to_dw_pcie_from_ep(ep); 1110 + struct imx6_pcie *imx6_pcie = to_imx6_pcie(pci); 1111 + 1112 + return imx6_pcie->drvdata->epc_features; 1053 1113 } 1054 1114 1055 1115 static const struct dw_pcie_ep_ops pcie_ep_ops = { ··· 1085 1103 int ret; 1086 1104 unsigned int pcie_dbi2_offset; 1087 1105 struct dw_pcie_ep *ep; 1088 - struct resource *res; 1089 1106 struct dw_pcie *pci = imx6_pcie->pci; 1090 1107 struct dw_pcie_rp *pp = &pci->pp; 1091 1108 struct device *dev = pci->dev; ··· 1103 1122 pcie_dbi2_offset = SZ_4K; 1104 1123 break; 1105 1124 } 1106 - pci->dbi_base2 = pci->dbi_base + pcie_dbi2_offset; 1107 - res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "addr_space"); 1108 - if (!res) 1109 - return -EINVAL; 1110 1125 1111 - ep->phys_base = res->start; 1112 - ep->addr_size = resource_size(res); 1113 - ep->page_size = SZ_64K; 1126 + pci->dbi_base2 = pci->dbi_base + pcie_dbi2_offset; 1127 + 1128 + /* 1129 + * FIXME: Ideally, dbi2 base address should come from DT. But since only IMX95 is defining 1130 + * "dbi2" in DT, "dbi_base2" is set to NULL here for that platform alone so that the DWC 1131 + * core code can fetch that from DT. But once all platform DTs were fixed, this and the 1132 + * above "dbi_base2" setting should be removed. 1133 + */ 1134 + if (device_property_match_string(dev, "reg-names", "dbi2") >= 0) 1135 + pci->dbi_base2 = NULL; 1136 + 1137 + if (imx6_check_flag(imx6_pcie, IMX6_PCIE_FLAG_SUPPORT_64BIT)) 1138 + dma_set_mask_and_coherent(dev, DMA_BIT_MASK(64)); 1114 1139 1115 1140 ret = dw_pcie_ep_init(ep); 1116 1141 if (ret) { ··· 1238 1251 struct device_node *node = dev->of_node; 1239 1252 int ret; 1240 1253 u16 val; 1254 + int i; 1241 1255 1242 1256 imx6_pcie = devm_kzalloc(dev, sizeof(*imx6_pcie), GFP_KERNEL); 1243 1257 if (!imx6_pcie) ··· 1292 1304 return imx6_pcie->reset_gpio; 1293 1305 } 1294 1306 1307 + if (imx6_pcie->drvdata->clks_cnt >= IMX6_PCIE_MAX_CLKS) 1308 + return dev_err_probe(dev, -ENOMEM, "clks_cnt is too big\n"); 1309 + 1310 + for (i = 0; i < imx6_pcie->drvdata->clks_cnt; i++) 1311 + imx6_pcie->clks[i].id = imx6_pcie->drvdata->clk_names[i]; 1312 + 1295 1313 /* Fetch clocks */ 1296 - imx6_pcie->pcie_bus = devm_clk_get(dev, "pcie_bus"); 1297 - if (IS_ERR(imx6_pcie->pcie_bus)) 1298 - return dev_err_probe(dev, PTR_ERR(imx6_pcie->pcie_bus), 1299 - "pcie_bus clock source missing or invalid\n"); 1314 + ret = devm_clk_bulk_get(dev, imx6_pcie->drvdata->clks_cnt, imx6_pcie->clks); 1315 + if (ret) 1316 + return ret; 1300 1317 1301 - imx6_pcie->pcie = devm_clk_get(dev, "pcie"); 1302 - if (IS_ERR(imx6_pcie->pcie)) 1303 - return dev_err_probe(dev, PTR_ERR(imx6_pcie->pcie), 1304 - "pcie clock source missing or invalid\n"); 1305 - 1306 - switch (imx6_pcie->drvdata->variant) { 1307 - case IMX6SX: 1308 - imx6_pcie->pcie_inbound_axi = devm_clk_get(dev, 1309 - "pcie_inbound_axi"); 1310 - if (IS_ERR(imx6_pcie->pcie_inbound_axi)) 1311 - return dev_err_probe(dev, PTR_ERR(imx6_pcie->pcie_inbound_axi), 1312 - "pcie_inbound_axi clock missing or invalid\n"); 1313 - break; 1314 - case IMX8MQ: 1315 - case IMX8MQ_EP: 1316 - imx6_pcie->pcie_aux = devm_clk_get(dev, "pcie_aux"); 1317 - if (IS_ERR(imx6_pcie->pcie_aux)) 1318 - return dev_err_probe(dev, PTR_ERR(imx6_pcie->pcie_aux), 1319 - "pcie_aux clock source missing or invalid\n"); 1320 - fallthrough; 1321 - case IMX7D: 1322 - if (dbi_base->start == IMX8MQ_PCIE2_BASE_ADDR) 1323 - imx6_pcie->controller_id = 1; 1324 - 1325 - imx6_pcie->pciephy_reset = devm_reset_control_get_exclusive(dev, 1326 - "pciephy"); 1327 - if (IS_ERR(imx6_pcie->pciephy_reset)) { 1328 - dev_err(dev, "Failed to get PCIEPHY reset control\n"); 1329 - return PTR_ERR(imx6_pcie->pciephy_reset); 1330 - } 1331 - 1332 - imx6_pcie->apps_reset = devm_reset_control_get_exclusive(dev, 1333 - "apps"); 1334 - if (IS_ERR(imx6_pcie->apps_reset)) { 1335 - dev_err(dev, "Failed to get PCIE APPS reset control\n"); 1336 - return PTR_ERR(imx6_pcie->apps_reset); 1337 - } 1338 - break; 1339 - case IMX8MM: 1340 - case IMX8MM_EP: 1341 - case IMX8MP: 1342 - case IMX8MP_EP: 1343 - imx6_pcie->pcie_aux = devm_clk_get(dev, "pcie_aux"); 1344 - if (IS_ERR(imx6_pcie->pcie_aux)) 1345 - return dev_err_probe(dev, PTR_ERR(imx6_pcie->pcie_aux), 1346 - "pcie_aux clock source missing or invalid\n"); 1347 - imx6_pcie->apps_reset = devm_reset_control_get_exclusive(dev, 1348 - "apps"); 1349 - if (IS_ERR(imx6_pcie->apps_reset)) 1350 - return dev_err_probe(dev, PTR_ERR(imx6_pcie->apps_reset), 1351 - "failed to get pcie apps reset control\n"); 1352 - 1318 + if (imx6_check_flag(imx6_pcie, IMX6_PCIE_FLAG_HAS_PHYDRV)) { 1353 1319 imx6_pcie->phy = devm_phy_get(dev, "pcie-phy"); 1354 1320 if (IS_ERR(imx6_pcie->phy)) 1355 1321 return dev_err_probe(dev, PTR_ERR(imx6_pcie->phy), 1356 1322 "failed to get pcie phy\n"); 1323 + } 1357 1324 1325 + if (imx6_check_flag(imx6_pcie, IMX6_PCIE_FLAG_HAS_APP_RESET)) { 1326 + imx6_pcie->apps_reset = devm_reset_control_get_exclusive(dev, "apps"); 1327 + if (IS_ERR(imx6_pcie->apps_reset)) 1328 + return dev_err_probe(dev, PTR_ERR(imx6_pcie->apps_reset), 1329 + "failed to get pcie apps reset control\n"); 1330 + } 1331 + 1332 + if (imx6_check_flag(imx6_pcie, IMX6_PCIE_FLAG_HAS_PHY_RESET)) { 1333 + imx6_pcie->pciephy_reset = devm_reset_control_get_exclusive(dev, "pciephy"); 1334 + if (IS_ERR(imx6_pcie->pciephy_reset)) 1335 + return dev_err_probe(dev, PTR_ERR(imx6_pcie->pciephy_reset), 1336 + "Failed to get PCIEPHY reset control\n"); 1337 + } 1338 + 1339 + switch (imx6_pcie->drvdata->variant) { 1340 + case IMX8MQ: 1341 + case IMX8MQ_EP: 1342 + case IMX7D: 1343 + if (dbi_base->start == IMX8MQ_PCIE2_BASE_ADDR) 1344 + imx6_pcie->controller_id = 1; 1358 1345 break; 1359 1346 default: 1360 1347 break; 1361 1348 } 1362 - /* Don't fetch the pcie_phy clock, if it has abstract PHY driver */ 1363 - if (imx6_pcie->phy == NULL) { 1364 - imx6_pcie->pcie_phy = devm_clk_get(dev, "pcie_phy"); 1365 - if (IS_ERR(imx6_pcie->pcie_phy)) 1366 - return dev_err_probe(dev, PTR_ERR(imx6_pcie->pcie_phy), 1367 - "pcie_phy clock source missing or invalid\n"); 1368 - } 1369 - 1370 1349 1371 1350 /* Grab turnoff reset */ 1372 1351 imx6_pcie->turnoff_reset = devm_reset_control_get_optional_exclusive(dev, "turnoff"); ··· 1342 1387 return PTR_ERR(imx6_pcie->turnoff_reset); 1343 1388 } 1344 1389 1390 + if (imx6_pcie->drvdata->gpr) { 1345 1391 /* Grab GPR config register range */ 1346 - imx6_pcie->iomuxc_gpr = 1347 - syscon_regmap_lookup_by_compatible(imx6_pcie->drvdata->gpr); 1348 - if (IS_ERR(imx6_pcie->iomuxc_gpr)) { 1349 - dev_err(dev, "unable to find iomuxc registers\n"); 1350 - return PTR_ERR(imx6_pcie->iomuxc_gpr); 1392 + imx6_pcie->iomuxc_gpr = 1393 + syscon_regmap_lookup_by_compatible(imx6_pcie->drvdata->gpr); 1394 + if (IS_ERR(imx6_pcie->iomuxc_gpr)) 1395 + return dev_err_probe(dev, PTR_ERR(imx6_pcie->iomuxc_gpr), 1396 + "unable to find iomuxc registers\n"); 1397 + } 1398 + 1399 + if (imx6_check_flag(imx6_pcie, IMX6_PCIE_FLAG_HAS_SERDES)) { 1400 + void __iomem *off = devm_platform_ioremap_resource_byname(pdev, "app"); 1401 + 1402 + if (IS_ERR(off)) 1403 + return dev_err_probe(dev, PTR_ERR(off), 1404 + "unable to find serdes registers\n"); 1405 + 1406 + static const struct regmap_config regmap_config = { 1407 + .reg_bits = 32, 1408 + .val_bits = 32, 1409 + .reg_stride = 4, 1410 + }; 1411 + 1412 + imx6_pcie->iomuxc_gpr = devm_regmap_init_mmio(dev, off, &regmap_config); 1413 + if (IS_ERR(imx6_pcie->iomuxc_gpr)) 1414 + return dev_err_probe(dev, PTR_ERR(imx6_pcie->iomuxc_gpr), 1415 + "unable to find iomuxc registers\n"); 1351 1416 } 1352 1417 1353 1418 /* Grab PCIe PHY Tx Settings */ ··· 1444 1469 imx6_pcie_assert_core_reset(imx6_pcie); 1445 1470 } 1446 1471 1472 + static const char * const imx6q_clks[] = {"pcie_bus", "pcie", "pcie_phy"}; 1473 + static const char * const imx8mm_clks[] = {"pcie_bus", "pcie", "pcie_aux"}; 1474 + static const char * const imx8mq_clks[] = {"pcie_bus", "pcie", "pcie_phy", "pcie_aux"}; 1475 + static const char * const imx6sx_clks[] = {"pcie_bus", "pcie", "pcie_phy", "pcie_inbound_axi"}; 1476 + 1447 1477 static const struct imx6_pcie_drvdata drvdata[] = { 1448 1478 [IMX6Q] = { 1449 1479 .variant = IMX6Q, ··· 1456 1476 IMX6_PCIE_FLAG_IMX6_SPEED_CHANGE, 1457 1477 .dbi_length = 0x200, 1458 1478 .gpr = "fsl,imx6q-iomuxc-gpr", 1479 + .clk_names = imx6q_clks, 1480 + .clks_cnt = ARRAY_SIZE(imx6q_clks), 1481 + .ltssm_off = IOMUXC_GPR12, 1482 + .ltssm_mask = IMX6Q_GPR12_PCIE_CTL_2, 1483 + .mode_off[0] = IOMUXC_GPR12, 1484 + .mode_mask[0] = IMX6Q_GPR12_DEVICE_TYPE, 1485 + .init_phy = imx6_pcie_init_phy, 1459 1486 }, 1460 1487 [IMX6SX] = { 1461 1488 .variant = IMX6SX, ··· 1470 1483 IMX6_PCIE_FLAG_IMX6_SPEED_CHANGE | 1471 1484 IMX6_PCIE_FLAG_SUPPORTS_SUSPEND, 1472 1485 .gpr = "fsl,imx6q-iomuxc-gpr", 1486 + .clk_names = imx6sx_clks, 1487 + .clks_cnt = ARRAY_SIZE(imx6sx_clks), 1488 + .ltssm_off = IOMUXC_GPR12, 1489 + .ltssm_mask = IMX6Q_GPR12_PCIE_CTL_2, 1490 + .mode_off[0] = IOMUXC_GPR12, 1491 + .mode_mask[0] = IMX6Q_GPR12_DEVICE_TYPE, 1492 + .init_phy = imx6sx_pcie_init_phy, 1473 1493 }, 1474 1494 [IMX6QP] = { 1475 1495 .variant = IMX6QP, ··· 1485 1491 IMX6_PCIE_FLAG_SUPPORTS_SUSPEND, 1486 1492 .dbi_length = 0x200, 1487 1493 .gpr = "fsl,imx6q-iomuxc-gpr", 1494 + .clk_names = imx6q_clks, 1495 + .clks_cnt = ARRAY_SIZE(imx6q_clks), 1496 + .ltssm_off = IOMUXC_GPR12, 1497 + .ltssm_mask = IMX6Q_GPR12_PCIE_CTL_2, 1498 + .mode_off[0] = IOMUXC_GPR12, 1499 + .mode_mask[0] = IMX6Q_GPR12_DEVICE_TYPE, 1500 + .init_phy = imx6_pcie_init_phy, 1488 1501 }, 1489 1502 [IMX7D] = { 1490 1503 .variant = IMX7D, 1491 - .flags = IMX6_PCIE_FLAG_SUPPORTS_SUSPEND, 1504 + .flags = IMX6_PCIE_FLAG_SUPPORTS_SUSPEND | 1505 + IMX6_PCIE_FLAG_HAS_APP_RESET | 1506 + IMX6_PCIE_FLAG_HAS_PHY_RESET, 1492 1507 .gpr = "fsl,imx7d-iomuxc-gpr", 1508 + .clk_names = imx6q_clks, 1509 + .clks_cnt = ARRAY_SIZE(imx6q_clks), 1510 + .mode_off[0] = IOMUXC_GPR12, 1511 + .mode_mask[0] = IMX6Q_GPR12_DEVICE_TYPE, 1512 + .init_phy = imx7d_pcie_init_phy, 1493 1513 }, 1494 1514 [IMX8MQ] = { 1495 1515 .variant = IMX8MQ, 1516 + .flags = IMX6_PCIE_FLAG_HAS_APP_RESET | 1517 + IMX6_PCIE_FLAG_HAS_PHY_RESET, 1496 1518 .gpr = "fsl,imx8mq-iomuxc-gpr", 1519 + .clk_names = imx8mq_clks, 1520 + .clks_cnt = ARRAY_SIZE(imx8mq_clks), 1521 + .mode_off[0] = IOMUXC_GPR12, 1522 + .mode_mask[0] = IMX6Q_GPR12_DEVICE_TYPE, 1523 + .mode_off[1] = IOMUXC_GPR12, 1524 + .mode_mask[1] = IMX8MQ_GPR12_PCIE2_CTRL_DEVICE_TYPE, 1525 + .init_phy = imx8mq_pcie_init_phy, 1497 1526 }, 1498 1527 [IMX8MM] = { 1499 1528 .variant = IMX8MM, 1500 - .flags = IMX6_PCIE_FLAG_SUPPORTS_SUSPEND, 1529 + .flags = IMX6_PCIE_FLAG_SUPPORTS_SUSPEND | 1530 + IMX6_PCIE_FLAG_HAS_PHYDRV | 1531 + IMX6_PCIE_FLAG_HAS_APP_RESET, 1501 1532 .gpr = "fsl,imx8mm-iomuxc-gpr", 1533 + .clk_names = imx8mm_clks, 1534 + .clks_cnt = ARRAY_SIZE(imx8mm_clks), 1535 + .mode_off[0] = IOMUXC_GPR12, 1536 + .mode_mask[0] = IMX6Q_GPR12_DEVICE_TYPE, 1502 1537 }, 1503 1538 [IMX8MP] = { 1504 1539 .variant = IMX8MP, 1505 - .flags = IMX6_PCIE_FLAG_SUPPORTS_SUSPEND, 1540 + .flags = IMX6_PCIE_FLAG_SUPPORTS_SUSPEND | 1541 + IMX6_PCIE_FLAG_HAS_PHYDRV | 1542 + IMX6_PCIE_FLAG_HAS_APP_RESET, 1506 1543 .gpr = "fsl,imx8mp-iomuxc-gpr", 1544 + .clk_names = imx8mm_clks, 1545 + .clks_cnt = ARRAY_SIZE(imx8mm_clks), 1546 + .mode_off[0] = IOMUXC_GPR12, 1547 + .mode_mask[0] = IMX6Q_GPR12_DEVICE_TYPE, 1548 + }, 1549 + [IMX95] = { 1550 + .variant = IMX95, 1551 + .flags = IMX6_PCIE_FLAG_HAS_SERDES, 1552 + .clk_names = imx8mq_clks, 1553 + .clks_cnt = ARRAY_SIZE(imx8mq_clks), 1554 + .ltssm_off = IMX95_PE0_GEN_CTRL_3, 1555 + .ltssm_mask = IMX95_PCIE_LTSSM_EN, 1556 + .mode_off[0] = IMX95_PE0_GEN_CTRL_1, 1557 + .mode_mask[0] = IMX95_PCIE_DEVICE_TYPE, 1558 + .init_phy = imx95_pcie_init_phy, 1507 1559 }, 1508 1560 [IMX8MQ_EP] = { 1509 1561 .variant = IMX8MQ_EP, 1562 + .flags = IMX6_PCIE_FLAG_HAS_APP_RESET | 1563 + IMX6_PCIE_FLAG_HAS_PHY_RESET, 1510 1564 .mode = DW_PCIE_EP_TYPE, 1511 1565 .gpr = "fsl,imx8mq-iomuxc-gpr", 1566 + .clk_names = imx8mq_clks, 1567 + .clks_cnt = ARRAY_SIZE(imx8mq_clks), 1568 + .mode_off[0] = IOMUXC_GPR12, 1569 + .mode_mask[0] = IMX6Q_GPR12_DEVICE_TYPE, 1570 + .mode_off[1] = IOMUXC_GPR12, 1571 + .mode_mask[1] = IMX8MQ_GPR12_PCIE2_CTRL_DEVICE_TYPE, 1572 + .epc_features = &imx8m_pcie_epc_features, 1573 + .init_phy = imx8mq_pcie_init_phy, 1512 1574 }, 1513 1575 [IMX8MM_EP] = { 1514 1576 .variant = IMX8MM_EP, 1577 + .flags = IMX6_PCIE_FLAG_HAS_PHYDRV, 1515 1578 .mode = DW_PCIE_EP_TYPE, 1516 1579 .gpr = "fsl,imx8mm-iomuxc-gpr", 1580 + .clk_names = imx8mm_clks, 1581 + .clks_cnt = ARRAY_SIZE(imx8mm_clks), 1582 + .mode_off[0] = IOMUXC_GPR12, 1583 + .mode_mask[0] = IMX6Q_GPR12_DEVICE_TYPE, 1584 + .epc_features = &imx8m_pcie_epc_features, 1517 1585 }, 1518 1586 [IMX8MP_EP] = { 1519 1587 .variant = IMX8MP_EP, 1588 + .flags = IMX6_PCIE_FLAG_HAS_PHYDRV, 1520 1589 .mode = DW_PCIE_EP_TYPE, 1521 1590 .gpr = "fsl,imx8mp-iomuxc-gpr", 1591 + .clk_names = imx8mm_clks, 1592 + .clks_cnt = ARRAY_SIZE(imx8mm_clks), 1593 + .mode_off[0] = IOMUXC_GPR12, 1594 + .mode_mask[0] = IMX6Q_GPR12_DEVICE_TYPE, 1595 + .epc_features = &imx8m_pcie_epc_features, 1596 + }, 1597 + [IMX95_EP] = { 1598 + .variant = IMX95_EP, 1599 + .flags = IMX6_PCIE_FLAG_HAS_SERDES | 1600 + IMX6_PCIE_FLAG_SUPPORT_64BIT, 1601 + .clk_names = imx8mq_clks, 1602 + .clks_cnt = ARRAY_SIZE(imx8mq_clks), 1603 + .ltssm_off = IMX95_PE0_GEN_CTRL_3, 1604 + .ltssm_mask = IMX95_PCIE_LTSSM_EN, 1605 + .mode_off[0] = IMX95_PE0_GEN_CTRL_1, 1606 + .mode_mask[0] = IMX95_PCIE_DEVICE_TYPE, 1607 + .init_phy = imx95_pcie_init_phy, 1608 + .epc_features = &imx95_pcie_epc_features, 1609 + .mode = DW_PCIE_EP_TYPE, 1522 1610 }, 1523 1611 }; 1524 1612 ··· 1612 1536 { .compatible = "fsl,imx8mq-pcie", .data = &drvdata[IMX8MQ], }, 1613 1537 { .compatible = "fsl,imx8mm-pcie", .data = &drvdata[IMX8MM], }, 1614 1538 { .compatible = "fsl,imx8mp-pcie", .data = &drvdata[IMX8MP], }, 1539 + { .compatible = "fsl,imx95-pcie", .data = &drvdata[IMX95], }, 1615 1540 { .compatible = "fsl,imx8mq-pcie-ep", .data = &drvdata[IMX8MQ_EP], }, 1616 1541 { .compatible = "fsl,imx8mm-pcie-ep", .data = &drvdata[IMX8MM_EP], }, 1617 1542 { .compatible = "fsl,imx8mp-pcie-ep", .data = &drvdata[IMX8MP_EP], }, 1543 + { .compatible = "fsl,imx95-pcie-ep", .data = &drvdata[IMX95_EP], }, 1618 1544 {}, 1619 1545 }; 1620 1546
+6 -6
drivers/pci/controller/dwc/pci-keystone.c
··· 924 924 .linkup_notifier = false, 925 925 .msi_capable = true, 926 926 .msix_capable = true, 927 - .reserved_bar = 1 << BAR_0 | 1 << BAR_1, 928 - .bar_fixed_64bit = 1 << BAR_0, 929 - .bar_fixed_size[2] = SZ_1M, 930 - .bar_fixed_size[3] = SZ_64K, 931 - .bar_fixed_size[4] = 256, 932 - .bar_fixed_size[5] = SZ_1M, 927 + .bar[BAR_0] = { .type = BAR_RESERVED, }, 928 + .bar[BAR_1] = { .type = BAR_RESERVED, }, 929 + .bar[BAR_2] = { .type = BAR_FIXED, .fixed_size = SZ_1M, }, 930 + .bar[BAR_3] = { .type = BAR_FIXED, .fixed_size = SZ_64K, }, 931 + .bar[BAR_4] = { .type = BAR_FIXED, .fixed_size = 256, }, 932 + .bar[BAR_5] = { .type = BAR_FIXED, .fixed_size = SZ_1M, }, 933 933 .align = SZ_1M, 934 934 }; 935 935
+4 -1
drivers/pci/controller/dwc/pci-layerscape-ep.c
··· 250 250 pci->dev = dev; 251 251 pci->ops = pcie->drvdata->dw_pcie_ops; 252 252 253 - ls_epc->bar_fixed_64bit = (1 << BAR_2) | (1 << BAR_4); 253 + ls_epc->bar[BAR_2].only_64bit = true; 254 + ls_epc->bar[BAR_3].type = BAR_RESERVED; 255 + ls_epc->bar[BAR_4].only_64bit = true; 256 + ls_epc->bar[BAR_5].type = BAR_RESERVED; 254 257 ls_epc->linkup_notifier = true; 255 258 256 259 pcie->pci = pci;
+6 -1
drivers/pci/controller/dwc/pcie-designware-ep.c
··· 629 629 nbars = (reg & PCI_REBAR_CTRL_NBAR_MASK) >> 630 630 PCI_REBAR_CTRL_NBAR_SHIFT; 631 631 632 + /* 633 + * PCIe r6.0, sec 7.8.6.2 require us to support at least one 634 + * size in the range from 1 MB to 512 GB. Advertise support 635 + * for 1 MB BAR size only. 636 + */ 632 637 for (i = 0; i < nbars; i++, offset += PCI_REBAR_CTRL) 633 - dw_pcie_writel_dbi(pci, offset + PCI_REBAR_CAP, 0x0); 638 + dw_pcie_writel_dbi(pci, offset + PCI_REBAR_CAP, BIT(4)); 634 639 } 635 640 636 641 /*
+13 -8
drivers/pci/controller/dwc/pcie-designware-host.c
··· 328 328 struct dw_pcie *pci = to_dw_pcie_from_pp(pp); 329 329 struct device *dev = pci->dev; 330 330 struct platform_device *pdev = to_platform_device(dev); 331 - u64 *msi_vaddr; 331 + u64 *msi_vaddr = NULL; 332 332 int ret; 333 333 u32 ctrl, num_ctrls; 334 334 ··· 379 379 * memory. 380 380 */ 381 381 ret = dma_set_coherent_mask(dev, DMA_BIT_MASK(32)); 382 - if (ret) 383 - dev_warn(dev, "Failed to set DMA mask to 32-bit. Devices with only 32-bit MSI support may not work properly\n"); 382 + if (!ret) 383 + msi_vaddr = dmam_alloc_coherent(dev, sizeof(u64), &pp->msi_data, 384 + GFP_KERNEL); 384 385 385 - msi_vaddr = dmam_alloc_coherent(dev, sizeof(u64), &pp->msi_data, 386 - GFP_KERNEL); 387 386 if (!msi_vaddr) { 388 - dev_err(dev, "Failed to alloc and map MSI data\n"); 389 - dw_pcie_free_msi(pp); 390 - return -ENOMEM; 387 + dev_warn(dev, "Failed to allocate 32-bit MSI address\n"); 388 + dma_set_coherent_mask(dev, DMA_BIT_MASK(64)); 389 + msi_vaddr = dmam_alloc_coherent(dev, sizeof(u64), &pp->msi_data, 390 + GFP_KERNEL); 391 + if (!msi_vaddr) { 392 + dev_err(dev, "Failed to allocate MSI address\n"); 393 + dw_pcie_free_msi(pp); 394 + return -ENOMEM; 395 + } 391 396 } 392 397 393 398 return 0;
+6 -2
drivers/pci/controller/dwc/pcie-keembay.c
··· 312 312 .linkup_notifier = false, 313 313 .msi_capable = true, 314 314 .msix_capable = true, 315 - .reserved_bar = BIT(BAR_1) | BIT(BAR_3) | BIT(BAR_5), 316 - .bar_fixed_64bit = BIT(BAR_0) | BIT(BAR_2) | BIT(BAR_4), 315 + .bar[BAR_0] = { .only_64bit = true, }, 316 + .bar[BAR_1] = { .type = BAR_RESERVED, }, 317 + .bar[BAR_2] = { .only_64bit = true, }, 318 + .bar[BAR_3] = { .type = BAR_RESERVED, }, 319 + .bar[BAR_4] = { .only_64bit = true, }, 320 + .bar[BAR_5] = { .type = BAR_RESERVED, }, 317 321 .align = SZ_16K, 318 322 }; 319 323
+40 -2
drivers/pci/controller/dwc/pcie-qcom.c
··· 53 53 #define PARF_SLV_ADDR_SPACE_SIZE 0x358 54 54 #define PARF_DEVICE_TYPE 0x1000 55 55 #define PARF_BDF_TO_SID_TABLE_N 0x2000 56 + #define PARF_BDF_TO_SID_CFG 0x2c00 56 57 57 58 /* ELBI registers */ 58 59 #define ELBI_SYS_CTRL 0x04 ··· 120 119 121 120 /* PARF_DEVICE_TYPE register fields */ 122 121 #define DEVICE_TYPE_RC 0x4 122 + 123 + /* PARF_BDF_TO_SID_CFG fields */ 124 + #define BDF_TO_SID_BYPASS BIT(0) 123 125 124 126 /* ELBI_SYS_CTRL register fields */ 125 127 #define ELBI_SYS_CTRL_LT_ENABLE BIT(0) ··· 233 229 234 230 struct qcom_pcie_cfg { 235 231 const struct qcom_pcie_ops *ops; 232 + bool no_l0s; 236 233 }; 237 234 238 235 struct qcom_pcie { ··· 275 270 pcie->cfg->ops->ltssm_enable(pcie); 276 271 277 272 return 0; 273 + } 274 + 275 + static void qcom_pcie_clear_aspm_l0s(struct dw_pcie *pci) 276 + { 277 + struct qcom_pcie *pcie = to_qcom_pcie(pci); 278 + u16 offset; 279 + u32 val; 280 + 281 + if (!pcie->cfg->no_l0s) 282 + return; 283 + 284 + offset = dw_pcie_find_capability(pci, PCI_CAP_ID_EXP); 285 + 286 + dw_pcie_dbi_ro_wr_en(pci); 287 + 288 + val = readl(pci->dbi_base + offset + PCI_EXP_LNKCAP); 289 + val &= ~PCI_EXP_LNKCAP_ASPM_L0S; 290 + writel(val, pci->dbi_base + offset + PCI_EXP_LNKCAP); 291 + 292 + dw_pcie_dbi_ro_wr_dis(pci); 278 293 } 279 294 280 295 static void qcom_pcie_clear_hpc(struct dw_pcie *pci) ··· 986 961 987 962 static int qcom_pcie_post_init_2_7_0(struct qcom_pcie *pcie) 988 963 { 964 + qcom_pcie_clear_aspm_l0s(pcie->pci); 989 965 qcom_pcie_clear_hpc(pcie->pci); 990 966 991 967 return 0; ··· 1034 1008 u8 qcom_pcie_crc8_table[CRC8_TABLE_SIZE]; 1035 1009 int i, nr_map, size = 0; 1036 1010 u32 smmu_sid_base; 1011 + u32 val; 1037 1012 1038 1013 of_get_property(dev->of_node, "iommu-map", &size); 1039 1014 if (!size) 1040 1015 return 0; 1016 + 1017 + /* Enable BDF to SID translation by disabling bypass mode (default) */ 1018 + val = readl(pcie->parf + PARF_BDF_TO_SID_CFG); 1019 + val &= ~BDF_TO_SID_BYPASS; 1020 + writel(val, pcie->parf + PARF_BDF_TO_SID_CFG); 1041 1021 1042 1022 map = kzalloc(size, GFP_KERNEL); 1043 1023 if (!map) ··· 1390 1358 .ops = &ops_2_9_0, 1391 1359 }; 1392 1360 1361 + static const struct qcom_pcie_cfg cfg_sc8280xp = { 1362 + .ops = &ops_1_9_0, 1363 + .no_l0s = true, 1364 + }; 1365 + 1393 1366 static const struct dw_pcie_ops dw_pcie_ops = { 1394 1367 .link_up = qcom_pcie_link_up, 1395 1368 .start_link = qcom_pcie_start_link, ··· 1666 1629 { .compatible = "qcom,pcie-ipq8074-gen3", .data = &cfg_2_9_0 }, 1667 1630 { .compatible = "qcom,pcie-msm8996", .data = &cfg_2_3_2 }, 1668 1631 { .compatible = "qcom,pcie-qcs404", .data = &cfg_2_4_0 }, 1669 - { .compatible = "qcom,pcie-sa8540p", .data = &cfg_1_9_0 }, 1632 + { .compatible = "qcom,pcie-sa8540p", .data = &cfg_sc8280xp }, 1670 1633 { .compatible = "qcom,pcie-sa8775p", .data = &cfg_1_9_0}, 1671 1634 { .compatible = "qcom,pcie-sc7280", .data = &cfg_1_9_0 }, 1672 1635 { .compatible = "qcom,pcie-sc8180x", .data = &cfg_1_9_0 }, 1673 - { .compatible = "qcom,pcie-sc8280xp", .data = &cfg_1_9_0 }, 1636 + { .compatible = "qcom,pcie-sc8280xp", .data = &cfg_sc8280xp }, 1674 1637 { .compatible = "qcom,pcie-sdm845", .data = &cfg_2_7_0 }, 1675 1638 { .compatible = "qcom,pcie-sdx55", .data = &cfg_1_9_0 }, 1676 1639 { .compatible = "qcom,pcie-sm8150", .data = &cfg_1_9_0 }, ··· 1679 1642 { .compatible = "qcom,pcie-sm8450-pcie0", .data = &cfg_1_9_0 }, 1680 1643 { .compatible = "qcom,pcie-sm8450-pcie1", .data = &cfg_1_9_0 }, 1681 1644 { .compatible = "qcom,pcie-sm8550", .data = &cfg_1_9_0 }, 1645 + { .compatible = "qcom,pcie-x1e80100", .data = &cfg_1_9_0 }, 1682 1646 { } 1683 1647 }; 1684 1648
+3 -1
drivers/pci/controller/dwc/pcie-rcar-gen4.c
··· 383 383 .linkup_notifier = false, 384 384 .msi_capable = true, 385 385 .msix_capable = false, 386 - .reserved_bar = 1 << BAR_1 | 1 << BAR_3 | 1 << BAR_5, 386 + .bar[BAR_1] = { .type = BAR_RESERVED, }, 387 + .bar[BAR_3] = { .type = BAR_RESERVED, }, 388 + .bar[BAR_5] = { .type = BAR_RESERVED, }, 387 389 .align = SZ_1M, 388 390 }; 389 391
+7 -3
drivers/pci/controller/dwc/pcie-tegra194.c
··· 2007 2007 .core_init_notifier = true, 2008 2008 .msi_capable = false, 2009 2009 .msix_capable = false, 2010 - .reserved_bar = 1 << BAR_2 | 1 << BAR_3 | 1 << BAR_4 | 1 << BAR_5, 2011 - .bar_fixed_64bit = 1 << BAR_0, 2012 - .bar_fixed_size[0] = SZ_1M, 2010 + .bar[BAR_0] = { .type = BAR_FIXED, .fixed_size = SZ_1M, 2011 + .only_64bit = true, }, 2012 + .bar[BAR_1] = { .type = BAR_RESERVED, }, 2013 + .bar[BAR_2] = { .type = BAR_RESERVED, }, 2014 + .bar[BAR_3] = { .type = BAR_RESERVED, }, 2015 + .bar[BAR_4] = { .type = BAR_RESERVED, }, 2016 + .bar[BAR_5] = { .type = BAR_RESERVED, }, 2013 2017 }; 2014 2018 2015 2019 static const struct pci_epc_features*
+12 -3
drivers/pci/controller/dwc/pcie-uniphier-ep.c
··· 411 411 .msi_capable = true, 412 412 .msix_capable = false, 413 413 .align = 1 << 16, 414 - .bar_fixed_64bit = BIT(BAR_0) | BIT(BAR_2) | BIT(BAR_4), 415 - .reserved_bar = BIT(BAR_4), 414 + .bar[BAR_0] = { .only_64bit = true, }, 415 + .bar[BAR_1] = { .type = BAR_RESERVED, }, 416 + .bar[BAR_2] = { .only_64bit = true, }, 417 + .bar[BAR_3] = { .type = BAR_RESERVED, }, 418 + .bar[BAR_4] = { .type = BAR_RESERVED, }, 419 + .bar[BAR_5] = { .type = BAR_RESERVED, }, 416 420 }, 417 421 }; 418 422 ··· 429 425 .msi_capable = true, 430 426 .msix_capable = false, 431 427 .align = 1 << 12, 432 - .bar_fixed_64bit = BIT(BAR_0) | BIT(BAR_2) | BIT(BAR_4), 428 + .bar[BAR_0] = { .only_64bit = true, }, 429 + .bar[BAR_1] = { .type = BAR_RESERVED, }, 430 + .bar[BAR_2] = { .only_64bit = true, }, 431 + .bar[BAR_3] = { .type = BAR_RESERVED, }, 432 + .bar[BAR_4] = { .only_64bit = true, }, 433 + .bar[BAR_5] = { .type = BAR_RESERVED, }, 433 434 }, 434 435 }; 435 436
+2 -1
drivers/pci/controller/pci-hyperv.c
··· 49 49 #include <linux/refcount.h> 50 50 #include <linux/irqdomain.h> 51 51 #include <linux/acpi.h> 52 + #include <linux/sizes.h> 52 53 #include <asm/mshyperv.h> 53 54 54 55 /* ··· 466 465 u32 status; 467 466 } __packed; 468 467 469 - static int pci_ring_size = (4 * PAGE_SIZE); 468 + static int pci_ring_size = VMBUS_RING_SIZE(SZ_16K); 470 469 471 470 /* 472 471 * Driver specific state.
+1 -1
drivers/pci/controller/pcie-brcmstb.c
··· 336 336 readl(base + PCIE_RC_DL_MDIO_ADDR); 337 337 writel(MDIO_DATA_DONE_MASK | wrdata, base + PCIE_RC_DL_MDIO_WR_DATA); 338 338 339 - err = readw_poll_timeout_atomic(base + PCIE_RC_DL_MDIO_WR_DATA, data, 339 + err = readl_poll_timeout_atomic(base + PCIE_RC_DL_MDIO_WR_DATA, data, 340 340 MDIO_WT_DONE(data), 10, 100); 341 341 return err; 342 342 }
+9 -5
drivers/pci/controller/pcie-rcar-ep.c
··· 440 440 .msi_capable = true, 441 441 .msix_capable = false, 442 442 /* use 64-bit BARs so mark BAR[1,3,5] as reserved */ 443 - .reserved_bar = 1 << BAR_1 | 1 << BAR_3 | 1 << BAR_5, 444 - .bar_fixed_64bit = 1 << BAR_0 | 1 << BAR_2 | 1 << BAR_4, 445 - .bar_fixed_size[0] = 128, 446 - .bar_fixed_size[2] = 256, 447 - .bar_fixed_size[4] = 256, 443 + .bar[BAR_0] = { .type = BAR_FIXED, .fixed_size = 128, 444 + .only_64bit = true, }, 445 + .bar[BAR_1] = { .type = BAR_RESERVED, }, 446 + .bar[BAR_2] = { .type = BAR_FIXED, .fixed_size = 256, 447 + .only_64bit = true, }, 448 + .bar[BAR_3] = { .type = BAR_RESERVED, }, 449 + .bar[BAR_4] = { .type = BAR_FIXED, .fixed_size = 256, 450 + .only_64bit = true, }, 451 + .bar[BAR_5] = { .type = BAR_RESERVED, }, 448 452 }; 449 453 450 454 static const struct pci_epc_features*
+448
drivers/pci/devres.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + #include <linux/device.h> 3 + #include <linux/pci.h> 4 + #include "pci.h" 5 + 6 + /* 7 + * PCI iomap devres 8 + */ 9 + #define PCIM_IOMAP_MAX PCI_STD_NUM_BARS 10 + 11 + struct pcim_iomap_devres { 12 + void __iomem *table[PCIM_IOMAP_MAX]; 13 + }; 14 + 15 + 16 + static void devm_pci_unmap_iospace(struct device *dev, void *ptr) 17 + { 18 + struct resource **res = ptr; 19 + 20 + pci_unmap_iospace(*res); 21 + } 22 + 23 + /** 24 + * devm_pci_remap_iospace - Managed pci_remap_iospace() 25 + * @dev: Generic device to remap IO address for 26 + * @res: Resource describing the I/O space 27 + * @phys_addr: physical address of range to be mapped 28 + * 29 + * Managed pci_remap_iospace(). Map is automatically unmapped on driver 30 + * detach. 31 + */ 32 + int devm_pci_remap_iospace(struct device *dev, const struct resource *res, 33 + phys_addr_t phys_addr) 34 + { 35 + const struct resource **ptr; 36 + int error; 37 + 38 + ptr = devres_alloc(devm_pci_unmap_iospace, sizeof(*ptr), GFP_KERNEL); 39 + if (!ptr) 40 + return -ENOMEM; 41 + 42 + error = pci_remap_iospace(res, phys_addr); 43 + if (error) { 44 + devres_free(ptr); 45 + } else { 46 + *ptr = res; 47 + devres_add(dev, ptr); 48 + } 49 + 50 + return error; 51 + } 52 + EXPORT_SYMBOL(devm_pci_remap_iospace); 53 + 54 + /** 55 + * devm_pci_remap_cfgspace - Managed pci_remap_cfgspace() 56 + * @dev: Generic device to remap IO address for 57 + * @offset: Resource address to map 58 + * @size: Size of map 59 + * 60 + * Managed pci_remap_cfgspace(). Map is automatically unmapped on driver 61 + * detach. 62 + */ 63 + void __iomem *devm_pci_remap_cfgspace(struct device *dev, 64 + resource_size_t offset, 65 + resource_size_t size) 66 + { 67 + void __iomem **ptr, *addr; 68 + 69 + ptr = devres_alloc(devm_ioremap_release, sizeof(*ptr), GFP_KERNEL); 70 + if (!ptr) 71 + return NULL; 72 + 73 + addr = pci_remap_cfgspace(offset, size); 74 + if (addr) { 75 + *ptr = addr; 76 + devres_add(dev, ptr); 77 + } else 78 + devres_free(ptr); 79 + 80 + return addr; 81 + } 82 + EXPORT_SYMBOL(devm_pci_remap_cfgspace); 83 + 84 + /** 85 + * devm_pci_remap_cfg_resource - check, request region and ioremap cfg resource 86 + * @dev: generic device to handle the resource for 87 + * @res: configuration space resource to be handled 88 + * 89 + * Checks that a resource is a valid memory region, requests the memory 90 + * region and ioremaps with pci_remap_cfgspace() API that ensures the 91 + * proper PCI configuration space memory attributes are guaranteed. 92 + * 93 + * All operations are managed and will be undone on driver detach. 94 + * 95 + * Returns a pointer to the remapped memory or an ERR_PTR() encoded error code 96 + * on failure. Usage example:: 97 + * 98 + * res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 99 + * base = devm_pci_remap_cfg_resource(&pdev->dev, res); 100 + * if (IS_ERR(base)) 101 + * return PTR_ERR(base); 102 + */ 103 + void __iomem *devm_pci_remap_cfg_resource(struct device *dev, 104 + struct resource *res) 105 + { 106 + resource_size_t size; 107 + const char *name; 108 + void __iomem *dest_ptr; 109 + 110 + BUG_ON(!dev); 111 + 112 + if (!res || resource_type(res) != IORESOURCE_MEM) { 113 + dev_err(dev, "invalid resource\n"); 114 + return IOMEM_ERR_PTR(-EINVAL); 115 + } 116 + 117 + size = resource_size(res); 118 + 119 + if (res->name) 120 + name = devm_kasprintf(dev, GFP_KERNEL, "%s %s", dev_name(dev), 121 + res->name); 122 + else 123 + name = devm_kstrdup(dev, dev_name(dev), GFP_KERNEL); 124 + if (!name) 125 + return IOMEM_ERR_PTR(-ENOMEM); 126 + 127 + if (!devm_request_mem_region(dev, res->start, size, name)) { 128 + dev_err(dev, "can't request region for resource %pR\n", res); 129 + return IOMEM_ERR_PTR(-EBUSY); 130 + } 131 + 132 + dest_ptr = devm_pci_remap_cfgspace(dev, res->start, size); 133 + if (!dest_ptr) { 134 + dev_err(dev, "ioremap failed for resource %pR\n", res); 135 + devm_release_mem_region(dev, res->start, size); 136 + dest_ptr = IOMEM_ERR_PTR(-ENOMEM); 137 + } 138 + 139 + return dest_ptr; 140 + } 141 + EXPORT_SYMBOL(devm_pci_remap_cfg_resource); 142 + 143 + /** 144 + * pcim_set_mwi - a device-managed pci_set_mwi() 145 + * @dev: the PCI device for which MWI is enabled 146 + * 147 + * Managed pci_set_mwi(). 148 + * 149 + * RETURNS: An appropriate -ERRNO error value on error, or zero for success. 150 + */ 151 + int pcim_set_mwi(struct pci_dev *dev) 152 + { 153 + struct pci_devres *dr; 154 + 155 + dr = find_pci_dr(dev); 156 + if (!dr) 157 + return -ENOMEM; 158 + 159 + dr->mwi = 1; 160 + return pci_set_mwi(dev); 161 + } 162 + EXPORT_SYMBOL(pcim_set_mwi); 163 + 164 + 165 + static void pcim_release(struct device *gendev, void *res) 166 + { 167 + struct pci_dev *dev = to_pci_dev(gendev); 168 + struct pci_devres *this = res; 169 + int i; 170 + 171 + for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) 172 + if (this->region_mask & (1 << i)) 173 + pci_release_region(dev, i); 174 + 175 + if (this->mwi) 176 + pci_clear_mwi(dev); 177 + 178 + if (this->restore_intx) 179 + pci_intx(dev, this->orig_intx); 180 + 181 + if (this->enabled && !this->pinned) 182 + pci_disable_device(dev); 183 + } 184 + 185 + /* 186 + * TODO: After the last four callers in pci.c are ported, find_pci_dr() 187 + * needs to be made static again. 188 + */ 189 + struct pci_devres *find_pci_dr(struct pci_dev *pdev) 190 + { 191 + if (pci_is_managed(pdev)) 192 + return devres_find(&pdev->dev, pcim_release, NULL, NULL); 193 + return NULL; 194 + } 195 + 196 + static struct pci_devres *get_pci_dr(struct pci_dev *pdev) 197 + { 198 + struct pci_devres *dr, *new_dr; 199 + 200 + dr = devres_find(&pdev->dev, pcim_release, NULL, NULL); 201 + if (dr) 202 + return dr; 203 + 204 + new_dr = devres_alloc(pcim_release, sizeof(*new_dr), GFP_KERNEL); 205 + if (!new_dr) 206 + return NULL; 207 + return devres_get(&pdev->dev, new_dr, NULL, NULL); 208 + } 209 + 210 + /** 211 + * pcim_enable_device - Managed pci_enable_device() 212 + * @pdev: PCI device to be initialized 213 + * 214 + * Managed pci_enable_device(). 215 + */ 216 + int pcim_enable_device(struct pci_dev *pdev) 217 + { 218 + struct pci_devres *dr; 219 + int rc; 220 + 221 + dr = get_pci_dr(pdev); 222 + if (unlikely(!dr)) 223 + return -ENOMEM; 224 + if (dr->enabled) 225 + return 0; 226 + 227 + rc = pci_enable_device(pdev); 228 + if (!rc) { 229 + pdev->is_managed = 1; 230 + dr->enabled = 1; 231 + } 232 + return rc; 233 + } 234 + EXPORT_SYMBOL(pcim_enable_device); 235 + 236 + /** 237 + * pcim_pin_device - Pin managed PCI device 238 + * @pdev: PCI device to pin 239 + * 240 + * Pin managed PCI device @pdev. Pinned device won't be disabled on 241 + * driver detach. @pdev must have been enabled with 242 + * pcim_enable_device(). 243 + */ 244 + void pcim_pin_device(struct pci_dev *pdev) 245 + { 246 + struct pci_devres *dr; 247 + 248 + dr = find_pci_dr(pdev); 249 + WARN_ON(!dr || !dr->enabled); 250 + if (dr) 251 + dr->pinned = 1; 252 + } 253 + EXPORT_SYMBOL(pcim_pin_device); 254 + 255 + static void pcim_iomap_release(struct device *gendev, void *res) 256 + { 257 + struct pci_dev *dev = to_pci_dev(gendev); 258 + struct pcim_iomap_devres *this = res; 259 + int i; 260 + 261 + for (i = 0; i < PCIM_IOMAP_MAX; i++) 262 + if (this->table[i]) 263 + pci_iounmap(dev, this->table[i]); 264 + } 265 + 266 + /** 267 + * pcim_iomap_table - access iomap allocation table 268 + * @pdev: PCI device to access iomap table for 269 + * 270 + * Access iomap allocation table for @dev. If iomap table doesn't 271 + * exist and @pdev is managed, it will be allocated. All iomaps 272 + * recorded in the iomap table are automatically unmapped on driver 273 + * detach. 274 + * 275 + * This function might sleep when the table is first allocated but can 276 + * be safely called without context and guaranteed to succeed once 277 + * allocated. 278 + */ 279 + void __iomem * const *pcim_iomap_table(struct pci_dev *pdev) 280 + { 281 + struct pcim_iomap_devres *dr, *new_dr; 282 + 283 + dr = devres_find(&pdev->dev, pcim_iomap_release, NULL, NULL); 284 + if (dr) 285 + return dr->table; 286 + 287 + new_dr = devres_alloc_node(pcim_iomap_release, sizeof(*new_dr), GFP_KERNEL, 288 + dev_to_node(&pdev->dev)); 289 + if (!new_dr) 290 + return NULL; 291 + dr = devres_get(&pdev->dev, new_dr, NULL, NULL); 292 + return dr->table; 293 + } 294 + EXPORT_SYMBOL(pcim_iomap_table); 295 + 296 + /** 297 + * pcim_iomap - Managed pcim_iomap() 298 + * @pdev: PCI device to iomap for 299 + * @bar: BAR to iomap 300 + * @maxlen: Maximum length of iomap 301 + * 302 + * Managed pci_iomap(). Map is automatically unmapped on driver 303 + * detach. 304 + */ 305 + void __iomem *pcim_iomap(struct pci_dev *pdev, int bar, unsigned long maxlen) 306 + { 307 + void __iomem **tbl; 308 + 309 + BUG_ON(bar >= PCIM_IOMAP_MAX); 310 + 311 + tbl = (void __iomem **)pcim_iomap_table(pdev); 312 + if (!tbl || tbl[bar]) /* duplicate mappings not allowed */ 313 + return NULL; 314 + 315 + tbl[bar] = pci_iomap(pdev, bar, maxlen); 316 + return tbl[bar]; 317 + } 318 + EXPORT_SYMBOL(pcim_iomap); 319 + 320 + /** 321 + * pcim_iounmap - Managed pci_iounmap() 322 + * @pdev: PCI device to iounmap for 323 + * @addr: Address to unmap 324 + * 325 + * Managed pci_iounmap(). @addr must have been mapped using pcim_iomap(). 326 + */ 327 + void pcim_iounmap(struct pci_dev *pdev, void __iomem *addr) 328 + { 329 + void __iomem **tbl; 330 + int i; 331 + 332 + pci_iounmap(pdev, addr); 333 + 334 + tbl = (void __iomem **)pcim_iomap_table(pdev); 335 + BUG_ON(!tbl); 336 + 337 + for (i = 0; i < PCIM_IOMAP_MAX; i++) 338 + if (tbl[i] == addr) { 339 + tbl[i] = NULL; 340 + return; 341 + } 342 + WARN_ON(1); 343 + } 344 + EXPORT_SYMBOL(pcim_iounmap); 345 + 346 + /** 347 + * pcim_iomap_regions - Request and iomap PCI BARs 348 + * @pdev: PCI device to map IO resources for 349 + * @mask: Mask of BARs to request and iomap 350 + * @name: Name used when requesting regions 351 + * 352 + * Request and iomap regions specified by @mask. 353 + */ 354 + int pcim_iomap_regions(struct pci_dev *pdev, int mask, const char *name) 355 + { 356 + void __iomem * const *iomap; 357 + int i, rc; 358 + 359 + iomap = pcim_iomap_table(pdev); 360 + if (!iomap) 361 + return -ENOMEM; 362 + 363 + for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) { 364 + unsigned long len; 365 + 366 + if (!(mask & (1 << i))) 367 + continue; 368 + 369 + rc = -EINVAL; 370 + len = pci_resource_len(pdev, i); 371 + if (!len) 372 + goto err_inval; 373 + 374 + rc = pci_request_region(pdev, i, name); 375 + if (rc) 376 + goto err_inval; 377 + 378 + rc = -ENOMEM; 379 + if (!pcim_iomap(pdev, i, 0)) 380 + goto err_region; 381 + } 382 + 383 + return 0; 384 + 385 + err_region: 386 + pci_release_region(pdev, i); 387 + err_inval: 388 + while (--i >= 0) { 389 + if (!(mask & (1 << i))) 390 + continue; 391 + pcim_iounmap(pdev, iomap[i]); 392 + pci_release_region(pdev, i); 393 + } 394 + 395 + return rc; 396 + } 397 + EXPORT_SYMBOL(pcim_iomap_regions); 398 + 399 + /** 400 + * pcim_iomap_regions_request_all - Request all BARs and iomap specified ones 401 + * @pdev: PCI device to map IO resources for 402 + * @mask: Mask of BARs to iomap 403 + * @name: Name used when requesting regions 404 + * 405 + * Request all PCI BARs and iomap regions specified by @mask. 406 + */ 407 + int pcim_iomap_regions_request_all(struct pci_dev *pdev, int mask, 408 + const char *name) 409 + { 410 + int request_mask = ((1 << 6) - 1) & ~mask; 411 + int rc; 412 + 413 + rc = pci_request_selected_regions(pdev, request_mask, name); 414 + if (rc) 415 + return rc; 416 + 417 + rc = pcim_iomap_regions(pdev, mask, name); 418 + if (rc) 419 + pci_release_selected_regions(pdev, request_mask); 420 + return rc; 421 + } 422 + EXPORT_SYMBOL(pcim_iomap_regions_request_all); 423 + 424 + /** 425 + * pcim_iounmap_regions - Unmap and release PCI BARs 426 + * @pdev: PCI device to map IO resources for 427 + * @mask: Mask of BARs to unmap and release 428 + * 429 + * Unmap and release regions specified by @mask. 430 + */ 431 + void pcim_iounmap_regions(struct pci_dev *pdev, int mask) 432 + { 433 + void __iomem * const *iomap; 434 + int i; 435 + 436 + iomap = pcim_iomap_table(pdev); 437 + if (!iomap) 438 + return; 439 + 440 + for (i = 0; i < PCIM_IOMAP_MAX; i++) { 441 + if (!(mask & (1 << i))) 442 + continue; 443 + 444 + pcim_iounmap(pdev, iomap[i]); 445 + pci_release_region(pdev, i); 446 + } 447 + } 448 + EXPORT_SYMBOL(pcim_iounmap_regions);
+19 -2
drivers/pci/endpoint/functions/pci-epf-mhi.c
··· 123 123 .flags = MHI_EPF_USE_DMA, 124 124 }; 125 125 126 + static struct pci_epf_header sa8775p_header = { 127 + .vendorid = PCI_VENDOR_ID_QCOM, 128 + .deviceid = 0x0306, /* FIXME: Update deviceid for sa8775p EP */ 129 + .baseclass_code = PCI_CLASS_OTHERS, 130 + .interrupt_pin = PCI_INTERRUPT_INTA, 131 + }; 132 + 133 + static const struct pci_epf_mhi_ep_info sa8775p_info = { 134 + .config = &mhi_v1_config, 135 + .epf_header = &sa8775p_header, 136 + .bar_num = BAR_0, 137 + .epf_flags = PCI_BASE_ADDRESS_MEM_TYPE_32, 138 + .msi_count = 32, 139 + .mru = 0x8000, 140 + }; 141 + 126 142 struct pci_epf_mhi { 127 143 const struct pci_epc_features *epc_features; 128 144 const struct pci_epf_mhi_ep_info *info; ··· 929 913 } 930 914 931 915 static const struct pci_epf_device_id pci_epf_mhi_ids[] = { 932 - { .name = "sdx55", .driver_data = (kernel_ulong_t)&sdx55_info }, 933 - { .name = "sm8450", .driver_data = (kernel_ulong_t)&sm8450_info }, 916 + { .name = "pci_epf_mhi_sa8775p", .driver_data = (kernel_ulong_t)&sa8775p_info }, 917 + { .name = "pci_epf_mhi_sdx55", .driver_data = (kernel_ulong_t)&sdx55_info }, 918 + { .name = "pci_epf_mhi_sm8450", .driver_data = (kernel_ulong_t)&sm8450_info }, 934 919 {}, 935 920 }; 936 921
+3 -3
drivers/pci/endpoint/functions/pci-epf-ntb.c
··· 1012 1012 1013 1013 epc_features = ntb_epc->epc_features; 1014 1014 barno = ntb_epc->epf_ntb_bar[BAR_CONFIG]; 1015 - size = epc_features->bar_fixed_size[barno]; 1015 + size = epc_features->bar[barno].fixed_size; 1016 1016 align = epc_features->align; 1017 1017 1018 1018 peer_ntb_epc = ntb->epc[!type]; 1019 1019 peer_epc_features = peer_ntb_epc->epc_features; 1020 1020 peer_barno = ntb_epc->epf_ntb_bar[BAR_PEER_SPAD]; 1021 - peer_size = peer_epc_features->bar_fixed_size[peer_barno]; 1021 + peer_size = peer_epc_features->bar[peer_barno].fixed_size; 1022 1022 1023 1023 /* Check if epc_features is populated incorrectly */ 1024 1024 if ((!IS_ALIGNED(size, align))) ··· 1067 1067 else if (size < ctrl_size + spad_size) 1068 1068 return -EINVAL; 1069 1069 1070 - base = pci_epf_alloc_space(epf, size, barno, align, type); 1070 + base = pci_epf_alloc_space(epf, size, barno, epc_features, type); 1071 1071 if (!base) { 1072 1072 dev_err(dev, "%s intf: Config/Status/SPAD alloc region fail\n", 1073 1073 pci_epc_interface_string(type));
+5 -16
drivers/pci/endpoint/functions/pci-epf-test.c
··· 729 729 */ 730 730 add = (epf_bar->flags & PCI_BASE_ADDRESS_MEM_TYPE_64) ? 2 : 1; 731 731 732 - if (!!(epc_features->reserved_bar & (1 << bar))) 732 + if (epc_features->bar[bar].type == BAR_RESERVED) 733 733 continue; 734 734 735 735 ret = pci_epc_set_bar(epc, epf->func_no, epf->vfunc_no, ··· 841 841 } 842 842 test_reg_size = test_reg_bar_size + msix_table_size + pba_size; 843 843 844 - if (epc_features->bar_fixed_size[test_reg_bar]) { 845 - if (test_reg_size > bar_size[test_reg_bar]) 846 - return -ENOMEM; 847 - test_reg_size = bar_size[test_reg_bar]; 848 - } 849 - 850 844 base = pci_epf_alloc_space(epf, test_reg_size, test_reg_bar, 851 - epc_features->align, PRIMARY_INTERFACE); 845 + epc_features, PRIMARY_INTERFACE); 852 846 if (!base) { 853 847 dev_err(dev, "Failed to allocated register space\n"); 854 848 return -ENOMEM; ··· 856 862 if (bar == test_reg_bar) 857 863 continue; 858 864 859 - if (!!(epc_features->reserved_bar & (1 << bar))) 865 + if (epc_features->bar[bar].type == BAR_RESERVED) 860 866 continue; 861 867 862 868 base = pci_epf_alloc_space(epf, bar_size[bar], bar, 863 - epc_features->align, 864 - PRIMARY_INTERFACE); 869 + epc_features, PRIMARY_INTERFACE); 865 870 if (!base) 866 871 dev_err(dev, "Failed to allocate space for BAR%d\n", 867 872 bar); ··· 874 881 const struct pci_epc_features *epc_features) 875 882 { 876 883 struct pci_epf_bar *epf_bar; 877 - bool bar_fixed_64bit; 878 884 int i; 879 885 880 886 for (i = 0; i < PCI_STD_NUM_BARS; i++) { 881 887 epf_bar = &epf->bar[i]; 882 - bar_fixed_64bit = !!(epc_features->bar_fixed_64bit & (1 << i)); 883 - if (bar_fixed_64bit) 888 + if (epc_features->bar[i].only_64bit) 884 889 epf_bar->flags |= PCI_BASE_ADDRESS_MEM_TYPE_64; 885 - if (epc_features->bar_fixed_size[i]) 886 - bar_size[i] = epc_features->bar_fixed_size[i]; 887 890 } 888 891 } 889 892
+5 -20
drivers/pci/endpoint/functions/pci-epf-vntb.c
··· 422 422 epf->func_no, 423 423 epf->vfunc_no); 424 424 barno = ntb->epf_ntb_bar[BAR_CONFIG]; 425 - size = epc_features->bar_fixed_size[barno]; 425 + size = epc_features->bar[barno].fixed_size; 426 426 align = epc_features->align; 427 427 428 428 if ((!IS_ALIGNED(size, align))) ··· 446 446 else if (size < ctrl_size + spad_size) 447 447 return -EINVAL; 448 448 449 - base = pci_epf_alloc_space(epf, size, barno, align, 0); 449 + base = pci_epf_alloc_space(epf, size, barno, epc_features, 0); 450 450 if (!base) { 451 451 dev_err(dev, "Config/Status/SPAD alloc region fail\n"); 452 452 return -ENOMEM; ··· 527 527 static int epf_ntb_db_bar_init(struct epf_ntb *ntb) 528 528 { 529 529 const struct pci_epc_features *epc_features; 530 - u32 align; 531 530 struct device *dev = &ntb->epf->dev; 532 531 int ret; 533 532 struct pci_epf_bar *epf_bar; ··· 537 538 epc_features = pci_epc_get_features(ntb->epf->epc, 538 539 ntb->epf->func_no, 539 540 ntb->epf->vfunc_no); 540 - align = epc_features->align; 541 - 542 - if (size < 128) 543 - size = 128; 544 - 545 - if (align) 546 - size = ALIGN(size, align); 547 - else 548 - size = roundup_pow_of_two(size); 549 - 550 541 barno = ntb->epf_ntb_bar[BAR_DB]; 551 542 552 - mw_addr = pci_epf_alloc_space(ntb->epf, size, barno, align, 0); 543 + mw_addr = pci_epf_alloc_space(ntb->epf, size, barno, epc_features, 0); 553 544 if (!mw_addr) { 554 545 dev_err(dev, "Failed to allocate OB address\n"); 555 546 return -ENOMEM; ··· 1258 1269 ret = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(32)); 1259 1270 if (ret) { 1260 1271 dev_err(dev, "Cannot set DMA mask\n"); 1261 - return -EINVAL; 1272 + return ret; 1262 1273 } 1263 1274 1264 1275 ret = ntb_register_device(&ndev->ntb); 1265 1276 if (ret) { 1266 1277 dev_err(dev, "Failed to register NTB device\n"); 1267 - goto err_register_dev; 1278 + return ret; 1268 1279 } 1269 1280 1270 1281 dev_dbg(dev, "PCI Virtual NTB driver loaded\n"); 1271 1282 return 0; 1272 - 1273 - err_register_dev: 1274 - put_device(&ndev->ntb.dev); 1275 - return -EINVAL; 1276 1283 } 1277 1284 1278 1285 static struct pci_device_id pci_vntb_table[] = {
+10 -15
drivers/pci/endpoint/pci-epc-core.c
··· 87 87 * @epc_features: pci_epc_features structure that holds the reserved bar bitmap 88 88 * 89 89 * Invoke to get the first unreserved BAR that can be used by the endpoint 90 - * function. For any incorrect value in reserved_bar return '0'. 90 + * function. 91 91 */ 92 92 enum pci_barno 93 93 pci_epc_get_first_free_bar(const struct pci_epc_features *epc_features) ··· 102 102 * @bar: the starting BAR number from where unreserved BAR should be searched 103 103 * 104 104 * Invoke to get the next unreserved BAR starting from @bar that can be used 105 - * for endpoint function. For any incorrect value in reserved_bar return '0'. 105 + * for endpoint function. 106 106 */ 107 107 enum pci_barno pci_epc_get_next_free_bar(const struct pci_epc_features 108 108 *epc_features, enum pci_barno bar) 109 109 { 110 - unsigned long free_bar; 110 + int i; 111 111 112 112 if (!epc_features) 113 113 return BAR_0; 114 114 115 115 /* If 'bar - 1' is a 64-bit BAR, move to the next BAR */ 116 - if ((epc_features->bar_fixed_64bit << 1) & 1 << bar) 116 + if (bar > 0 && epc_features->bar[bar - 1].only_64bit) 117 117 bar++; 118 118 119 - /* Find if the reserved BAR is also a 64-bit BAR */ 120 - free_bar = epc_features->reserved_bar & epc_features->bar_fixed_64bit; 119 + for (i = bar; i < PCI_STD_NUM_BARS; i++) { 120 + /* If the BAR is not reserved, return it. */ 121 + if (epc_features->bar[i].type != BAR_RESERVED) 122 + return i; 123 + } 121 124 122 - /* Set the adjacent bit if the reserved BAR is also a 64-bit BAR */ 123 - free_bar <<= 1; 124 - free_bar |= epc_features->reserved_bar; 125 - 126 - free_bar = find_next_zero_bit(&free_bar, 6, bar); 127 - if (free_bar > 5) 128 - return NO_BAR; 129 - 130 - return free_bar; 125 + return NO_BAR; 131 126 } 132 127 EXPORT_SYMBOL_GPL(pci_epc_get_next_free_bar); 133 128
+16 -4
drivers/pci/endpoint/pci-epf-core.c
··· 17 17 18 18 static DEFINE_MUTEX(pci_epf_mutex); 19 19 20 - static struct bus_type pci_epf_bus_type; 20 + static const struct bus_type pci_epf_bus_type; 21 21 static const struct device_type pci_epf_type; 22 22 23 23 /** ··· 251 251 * @epf: the EPF device to whom allocate the memory 252 252 * @size: the size of the memory that has to be allocated 253 253 * @bar: the BAR number corresponding to the allocated register space 254 - * @align: alignment size for the allocation region 254 + * @epc_features: the features provided by the EPC specific to this EPF 255 255 * @type: Identifies if the allocation is for primary EPC or secondary EPC 256 256 * 257 257 * Invoke to allocate memory for the PCI EPF register space. 258 258 */ 259 259 void *pci_epf_alloc_space(struct pci_epf *epf, size_t size, enum pci_barno bar, 260 - size_t align, enum pci_epc_interface_type type) 260 + const struct pci_epc_features *epc_features, 261 + enum pci_epc_interface_type type) 261 262 { 263 + u64 bar_fixed_size = epc_features->bar[bar].fixed_size; 264 + size_t align = epc_features->align; 262 265 struct pci_epf_bar *epf_bar; 263 266 dma_addr_t phys_addr; 264 267 struct pci_epc *epc; ··· 270 267 271 268 if (size < 128) 272 269 size = 128; 270 + 271 + if (epc_features->bar[bar].type == BAR_FIXED && bar_fixed_size) { 272 + if (size > bar_fixed_size) { 273 + dev_err(&epf->dev, 274 + "requested BAR size is larger than fixed size\n"); 275 + return NULL; 276 + } 277 + size = bar_fixed_size; 278 + } 273 279 274 280 if (align) 275 281 size = ALIGN(size, align); ··· 519 507 epf->driver = NULL; 520 508 } 521 509 522 - static struct bus_type pci_epf_bus_type = { 510 + static const struct bus_type pci_epf_bus_type = { 523 511 .name = "pci-epf", 524 512 .match = pci_epf_device_match, 525 513 .probe = pci_epf_device_probe,
+204
drivers/pci/irq.c
··· 8 8 9 9 #include <linux/device.h> 10 10 #include <linux/kernel.h> 11 + #include <linux/errno.h> 11 12 #include <linux/export.h> 13 + #include <linux/interrupt.h> 12 14 #include <linux/pci.h> 15 + 16 + #include "pci.h" 13 17 14 18 /** 15 19 * pci_request_irq - allocate an interrupt line for a PCI device ··· 78 74 kfree(free_irq(pci_irq_vector(dev, nr), dev_id)); 79 75 } 80 76 EXPORT_SYMBOL(pci_free_irq); 77 + 78 + /** 79 + * pci_swizzle_interrupt_pin - swizzle INTx for device behind bridge 80 + * @dev: the PCI device 81 + * @pin: the INTx pin (1=INTA, 2=INTB, 3=INTC, 4=INTD) 82 + * 83 + * Perform INTx swizzling for a device behind one level of bridge. This is 84 + * required by section 9.1 of the PCI-to-PCI bridge specification for devices 85 + * behind bridges on add-in cards. For devices with ARI enabled, the slot 86 + * number is always 0 (see the Implementation Note in section 2.2.8.1 of 87 + * the PCI Express Base Specification, Revision 2.1) 88 + */ 89 + u8 pci_swizzle_interrupt_pin(const struct pci_dev *dev, u8 pin) 90 + { 91 + int slot; 92 + 93 + if (pci_ari_enabled(dev->bus)) 94 + slot = 0; 95 + else 96 + slot = PCI_SLOT(dev->devfn); 97 + 98 + return (((pin - 1) + slot) % 4) + 1; 99 + } 100 + 101 + int pci_get_interrupt_pin(struct pci_dev *dev, struct pci_dev **bridge) 102 + { 103 + u8 pin; 104 + 105 + pin = dev->pin; 106 + if (!pin) 107 + return -1; 108 + 109 + while (!pci_is_root_bus(dev->bus)) { 110 + pin = pci_swizzle_interrupt_pin(dev, pin); 111 + dev = dev->bus->self; 112 + } 113 + *bridge = dev; 114 + return pin; 115 + } 116 + 117 + /** 118 + * pci_common_swizzle - swizzle INTx all the way to root bridge 119 + * @dev: the PCI device 120 + * @pinp: pointer to the INTx pin value (1=INTA, 2=INTB, 3=INTD, 4=INTD) 121 + * 122 + * Perform INTx swizzling for a device. This traverses through all PCI-to-PCI 123 + * bridges all the way up to a PCI root bus. 124 + */ 125 + u8 pci_common_swizzle(struct pci_dev *dev, u8 *pinp) 126 + { 127 + u8 pin = *pinp; 128 + 129 + while (!pci_is_root_bus(dev->bus)) { 130 + pin = pci_swizzle_interrupt_pin(dev, pin); 131 + dev = dev->bus->self; 132 + } 133 + *pinp = pin; 134 + return PCI_SLOT(dev->devfn); 135 + } 136 + EXPORT_SYMBOL_GPL(pci_common_swizzle); 137 + 138 + void pci_assign_irq(struct pci_dev *dev) 139 + { 140 + u8 pin; 141 + u8 slot = -1; 142 + int irq = 0; 143 + struct pci_host_bridge *hbrg = pci_find_host_bridge(dev->bus); 144 + 145 + if (!(hbrg->map_irq)) { 146 + pci_dbg(dev, "runtime IRQ mapping not provided by arch\n"); 147 + return; 148 + } 149 + 150 + /* 151 + * If this device is not on the primary bus, we need to figure out 152 + * which interrupt pin it will come in on. We know which slot it 153 + * will come in on because that slot is where the bridge is. Each 154 + * time the interrupt line passes through a PCI-PCI bridge we must 155 + * apply the swizzle function. 156 + */ 157 + pci_read_config_byte(dev, PCI_INTERRUPT_PIN, &pin); 158 + /* Cope with illegal. */ 159 + if (pin > 4) 160 + pin = 1; 161 + 162 + if (pin) { 163 + /* Follow the chain of bridges, swizzling as we go. */ 164 + if (hbrg->swizzle_irq) 165 + slot = (*(hbrg->swizzle_irq))(dev, &pin); 166 + 167 + /* 168 + * If a swizzling function is not used, map_irq() must 169 + * ignore slot. 170 + */ 171 + irq = (*(hbrg->map_irq))(dev, slot, pin); 172 + if (irq == -1) 173 + irq = 0; 174 + } 175 + dev->irq = irq; 176 + 177 + pci_dbg(dev, "assign IRQ: got %d\n", dev->irq); 178 + 179 + /* 180 + * Always tell the device, so the driver knows what is the real IRQ 181 + * to use; the device does not use it. 182 + */ 183 + pci_write_config_byte(dev, PCI_INTERRUPT_LINE, irq); 184 + } 185 + 186 + static bool pci_check_and_set_intx_mask(struct pci_dev *dev, bool mask) 187 + { 188 + struct pci_bus *bus = dev->bus; 189 + bool mask_updated = true; 190 + u32 cmd_status_dword; 191 + u16 origcmd, newcmd; 192 + unsigned long flags; 193 + bool irq_pending; 194 + 195 + /* 196 + * We do a single dword read to retrieve both command and status. 197 + * Document assumptions that make this possible. 198 + */ 199 + BUILD_BUG_ON(PCI_COMMAND % 4); 200 + BUILD_BUG_ON(PCI_COMMAND + 2 != PCI_STATUS); 201 + 202 + raw_spin_lock_irqsave(&pci_lock, flags); 203 + 204 + bus->ops->read(bus, dev->devfn, PCI_COMMAND, 4, &cmd_status_dword); 205 + 206 + irq_pending = (cmd_status_dword >> 16) & PCI_STATUS_INTERRUPT; 207 + 208 + /* 209 + * Check interrupt status register to see whether our device 210 + * triggered the interrupt (when masking) or the next IRQ is 211 + * already pending (when unmasking). 212 + */ 213 + if (mask != irq_pending) { 214 + mask_updated = false; 215 + goto done; 216 + } 217 + 218 + origcmd = cmd_status_dword; 219 + newcmd = origcmd & ~PCI_COMMAND_INTX_DISABLE; 220 + if (mask) 221 + newcmd |= PCI_COMMAND_INTX_DISABLE; 222 + if (newcmd != origcmd) 223 + bus->ops->write(bus, dev->devfn, PCI_COMMAND, 2, newcmd); 224 + 225 + done: 226 + raw_spin_unlock_irqrestore(&pci_lock, flags); 227 + 228 + return mask_updated; 229 + } 230 + 231 + /** 232 + * pci_check_and_mask_intx - mask INTx on pending interrupt 233 + * @dev: the PCI device to operate on 234 + * 235 + * Check if the device dev has its INTx line asserted, mask it and return 236 + * true in that case. False is returned if no interrupt was pending. 237 + */ 238 + bool pci_check_and_mask_intx(struct pci_dev *dev) 239 + { 240 + return pci_check_and_set_intx_mask(dev, true); 241 + } 242 + EXPORT_SYMBOL_GPL(pci_check_and_mask_intx); 243 + 244 + /** 245 + * pci_check_and_unmask_intx - unmask INTx if no interrupt is pending 246 + * @dev: the PCI device to operate on 247 + * 248 + * Check if the device dev has its INTx line asserted, unmask it if not and 249 + * return true. False is returned and the mask remains active if there was 250 + * still an interrupt pending. 251 + */ 252 + bool pci_check_and_unmask_intx(struct pci_dev *dev) 253 + { 254 + return pci_check_and_set_intx_mask(dev, false); 255 + } 256 + EXPORT_SYMBOL_GPL(pci_check_and_unmask_intx); 257 + 258 + /** 259 + * pcibios_penalize_isa_irq - penalize an ISA IRQ 260 + * @irq: ISA IRQ to penalize 261 + * @active: IRQ active or not 262 + * 263 + * Permits the platform to provide architecture-specific functionality when 264 + * penalizing ISA IRQs. This is the default implementation. Architecture 265 + * implementations can override this. 266 + */ 267 + void __weak pcibios_penalize_isa_irq(int irq, int active) {} 268 + 269 + int __weak pcibios_alloc_irq(struct pci_dev *dev) 270 + { 271 + return 0; 272 + } 273 + 274 + void __weak pcibios_free_irq(struct pci_dev *dev) 275 + { 276 + }
+29
drivers/pci/mmap.c
··· 11 11 #include <linux/mm.h> 12 12 #include <linux/pci.h> 13 13 14 + #include "pci.h" 15 + 14 16 #ifdef ARCH_GENERIC_PCI_MMAP_RESOURCE 15 17 16 18 static const struct vm_operations_struct pci_phys_vm_ops = { ··· 49 47 return io_remap_pfn_range(vma, vma->vm_start, vma->vm_pgoff, 50 48 vma->vm_end - vma->vm_start, 51 49 vma->vm_page_prot); 50 + } 51 + 52 + #endif 53 + 54 + #if (defined(CONFIG_SYSFS) || defined(CONFIG_PROC_FS)) && \ 55 + (defined(HAVE_PCI_MMAP) || defined(ARCH_GENERIC_PCI_MMAP_RESOURCE)) 56 + 57 + int pci_mmap_fits(struct pci_dev *pdev, int resno, struct vm_area_struct *vma, 58 + enum pci_mmap_api mmap_api) 59 + { 60 + resource_size_t pci_start = 0, pci_end; 61 + unsigned long nr, start, size; 62 + 63 + if (pci_resource_len(pdev, resno) == 0) 64 + return 0; 65 + nr = vma_pages(vma); 66 + start = vma->vm_pgoff; 67 + size = ((pci_resource_len(pdev, resno) - 1) >> PAGE_SHIFT) + 1; 68 + if (mmap_api == PCI_MMAP_PROCFS) { 69 + pci_resource_to_user(pdev, resno, &pdev->resource[resno], 70 + &pci_start, &pci_end); 71 + pci_start >>= PAGE_SHIFT; 72 + } 73 + if (start >= pci_start && start < pci_start + size && 74 + start + nr <= pci_start + size) 75 + return 1; 76 + return 0; 52 77 } 53 78 54 79 #endif
+1 -1
drivers/pci/p2pdma.c
··· 661 661 p2pdma = rcu_dereference(provider->p2pdma); 662 662 if (p2pdma) 663 663 xa_store(&p2pdma->map_types, map_types_idx(client), 664 - xa_mk_value(map_type), GFP_KERNEL); 664 + xa_mk_value(map_type), GFP_ATOMIC); 665 665 rcu_read_unlock(); 666 666 return map_type; 667 667 }
+9 -14
drivers/pci/pci-driver.c
··· 419 419 return error; 420 420 } 421 421 422 - int __weak pcibios_alloc_irq(struct pci_dev *dev) 423 - { 424 - return 0; 425 - } 426 - 427 - void __weak pcibios_free_irq(struct pci_dev *dev) 428 - { 429 - } 430 - 431 422 #ifdef CONFIG_PCI_IOV 432 423 static inline bool pci_device_can_probe(struct pci_dev *pdev) 433 424 { ··· 464 473 465 474 if (drv->remove) { 466 475 pm_runtime_get_sync(dev); 476 + /* 477 + * If the driver provides a .runtime_idle() callback and it has 478 + * started to run already, it may continue to run in parallel 479 + * with the code below, so wait until all of the runtime PM 480 + * activity has completed. 481 + */ 482 + pm_runtime_barrier(dev); 467 483 drv->remove(pci_dev); 468 484 pm_runtime_put_noidle(dev); 469 485 } ··· 1380 1382 if (!pci_dev->driver) 1381 1383 return 0; 1382 1384 1383 - if (!pm) 1384 - return -ENOSYS; 1385 - 1386 - if (pm->runtime_idle) 1385 + if (pm && pm->runtime_idle) 1387 1386 return pm->runtime_idle(dev); 1388 1387 1389 1388 return 0; ··· 1709 1714 return 1; 1710 1715 } 1711 1716 1712 - struct bus_type pcie_port_bus_type = { 1717 + const struct bus_type pcie_port_bus_type = { 1713 1718 .name = "pci_express", 1714 1719 .match = pcie_port_bus_match, 1715 1720 };
+75 -92
drivers/pci/pci-sysfs.c
··· 1022 1022 #endif /* HAVE_PCI_LEGACY */ 1023 1023 1024 1024 #if defined(HAVE_PCI_MMAP) || defined(ARCH_GENERIC_PCI_MMAP_RESOURCE) 1025 - 1026 - int pci_mmap_fits(struct pci_dev *pdev, int resno, struct vm_area_struct *vma, 1027 - enum pci_mmap_api mmap_api) 1028 - { 1029 - unsigned long nr, start, size; 1030 - resource_size_t pci_start = 0, pci_end; 1031 - 1032 - if (pci_resource_len(pdev, resno) == 0) 1033 - return 0; 1034 - nr = vma_pages(vma); 1035 - start = vma->vm_pgoff; 1036 - size = ((pci_resource_len(pdev, resno) - 1) >> PAGE_SHIFT) + 1; 1037 - if (mmap_api == PCI_MMAP_PROCFS) { 1038 - pci_resource_to_user(pdev, resno, &pdev->resource[resno], 1039 - &pci_start, &pci_end); 1040 - pci_start >>= PAGE_SHIFT; 1041 - } 1042 - if (start >= pci_start && start < pci_start + size && 1043 - start + nr <= pci_start + size) 1044 - return 1; 1045 - return 0; 1046 - } 1047 - 1048 1025 /** 1049 1026 * pci_mmap_resource - map a PCI resource into user memory space 1050 1027 * @kobj: kobject for mapping ··· 1387 1410 .is_visible = pci_dev_reset_attr_is_visible, 1388 1411 }; 1389 1412 1413 + static ssize_t __resource_resize_show(struct device *dev, int n, char *buf) 1414 + { 1415 + struct pci_dev *pdev = to_pci_dev(dev); 1416 + ssize_t ret; 1417 + 1418 + pci_config_pm_runtime_get(pdev); 1419 + 1420 + ret = sysfs_emit(buf, "%016llx\n", 1421 + (u64)pci_rebar_get_possible_sizes(pdev, n)); 1422 + 1423 + pci_config_pm_runtime_put(pdev); 1424 + 1425 + return ret; 1426 + } 1427 + 1428 + static ssize_t __resource_resize_store(struct device *dev, int n, 1429 + const char *buf, size_t count) 1430 + { 1431 + struct pci_dev *pdev = to_pci_dev(dev); 1432 + unsigned long size, flags; 1433 + int ret, i; 1434 + u16 cmd; 1435 + 1436 + if (kstrtoul(buf, 0, &size) < 0) 1437 + return -EINVAL; 1438 + 1439 + device_lock(dev); 1440 + if (dev->driver) { 1441 + ret = -EBUSY; 1442 + goto unlock; 1443 + } 1444 + 1445 + pci_config_pm_runtime_get(pdev); 1446 + 1447 + if ((pdev->class >> 8) == PCI_CLASS_DISPLAY_VGA) { 1448 + ret = aperture_remove_conflicting_pci_devices(pdev, 1449 + "resourceN_resize"); 1450 + if (ret) 1451 + goto pm_put; 1452 + } 1453 + 1454 + pci_read_config_word(pdev, PCI_COMMAND, &cmd); 1455 + pci_write_config_word(pdev, PCI_COMMAND, 1456 + cmd & ~PCI_COMMAND_MEMORY); 1457 + 1458 + flags = pci_resource_flags(pdev, n); 1459 + 1460 + pci_remove_resource_files(pdev); 1461 + 1462 + for (i = 0; i < PCI_STD_NUM_BARS; i++) { 1463 + if (pci_resource_len(pdev, i) && 1464 + pci_resource_flags(pdev, i) == flags) 1465 + pci_release_resource(pdev, i); 1466 + } 1467 + 1468 + ret = pci_resize_resource(pdev, n, size); 1469 + 1470 + pci_assign_unassigned_bus_resources(pdev->bus); 1471 + 1472 + if (pci_create_resource_files(pdev)) 1473 + pci_warn(pdev, "Failed to recreate resource files after BAR resizing\n"); 1474 + 1475 + pci_write_config_word(pdev, PCI_COMMAND, cmd); 1476 + pm_put: 1477 + pci_config_pm_runtime_put(pdev); 1478 + unlock: 1479 + device_unlock(dev); 1480 + 1481 + return ret ? ret : count; 1482 + } 1483 + 1390 1484 #define pci_dev_resource_resize_attr(n) \ 1391 1485 static ssize_t resource##n##_resize_show(struct device *dev, \ 1392 1486 struct device_attribute *attr, \ 1393 - char * buf) \ 1487 + char *buf) \ 1394 1488 { \ 1395 - struct pci_dev *pdev = to_pci_dev(dev); \ 1396 - ssize_t ret; \ 1397 - \ 1398 - pci_config_pm_runtime_get(pdev); \ 1399 - \ 1400 - ret = sysfs_emit(buf, "%016llx\n", \ 1401 - (u64)pci_rebar_get_possible_sizes(pdev, n)); \ 1402 - \ 1403 - pci_config_pm_runtime_put(pdev); \ 1404 - \ 1405 - return ret; \ 1489 + return __resource_resize_show(dev, n, buf); \ 1406 1490 } \ 1407 - \ 1408 1491 static ssize_t resource##n##_resize_store(struct device *dev, \ 1409 1492 struct device_attribute *attr,\ 1410 1493 const char *buf, size_t count)\ 1411 1494 { \ 1412 - struct pci_dev *pdev = to_pci_dev(dev); \ 1413 - unsigned long size, flags; \ 1414 - int ret, i; \ 1415 - u16 cmd; \ 1416 - \ 1417 - if (kstrtoul(buf, 0, &size) < 0) \ 1418 - return -EINVAL; \ 1419 - \ 1420 - device_lock(dev); \ 1421 - if (dev->driver) { \ 1422 - ret = -EBUSY; \ 1423 - goto unlock; \ 1424 - } \ 1425 - \ 1426 - pci_config_pm_runtime_get(pdev); \ 1427 - \ 1428 - if ((pdev->class >> 8) == PCI_CLASS_DISPLAY_VGA) { \ 1429 - ret = aperture_remove_conflicting_pci_devices(pdev, \ 1430 - "resourceN_resize"); \ 1431 - if (ret) \ 1432 - goto pm_put; \ 1433 - } \ 1434 - \ 1435 - pci_read_config_word(pdev, PCI_COMMAND, &cmd); \ 1436 - pci_write_config_word(pdev, PCI_COMMAND, \ 1437 - cmd & ~PCI_COMMAND_MEMORY); \ 1438 - \ 1439 - flags = pci_resource_flags(pdev, n); \ 1440 - \ 1441 - pci_remove_resource_files(pdev); \ 1442 - \ 1443 - for (i = 0; i < PCI_STD_NUM_BARS; i++) { \ 1444 - if (pci_resource_len(pdev, i) && \ 1445 - pci_resource_flags(pdev, i) == flags) \ 1446 - pci_release_resource(pdev, i); \ 1447 - } \ 1448 - \ 1449 - ret = pci_resize_resource(pdev, n, size); \ 1450 - \ 1451 - pci_assign_unassigned_bus_resources(pdev->bus); \ 1452 - \ 1453 - if (pci_create_resource_files(pdev)) \ 1454 - pci_warn(pdev, "Failed to recreate resource files after BAR resizing\n");\ 1455 - \ 1456 - pci_write_config_word(pdev, PCI_COMMAND, cmd); \ 1457 - pm_put: \ 1458 - pci_config_pm_runtime_put(pdev); \ 1459 - unlock: \ 1460 - device_unlock(dev); \ 1461 - \ 1462 - return ret ? ret : count; \ 1495 + return __resource_resize_store(dev, n, buf, count); \ 1463 1496 } \ 1464 1497 static DEVICE_ATTR_RW(resource##n##_resize) 1465 1498 ··· 1647 1660 .is_visible = pcie_dev_attrs_are_visible, 1648 1661 }; 1649 1662 1650 - static const struct attribute_group *pci_dev_attr_groups[] = { 1663 + const struct attribute_group *pci_dev_attr_groups[] = { 1651 1664 &pci_dev_attr_group, 1652 1665 &pci_dev_hp_attr_group, 1653 1666 #ifdef CONFIG_PCI_IOV ··· 1663 1676 &aspm_ctrl_attr_group, 1664 1677 #endif 1665 1678 NULL, 1666 - }; 1667 - 1668 - const struct device_type pci_dev_type = { 1669 - .groups = pci_dev_attr_groups, 1670 1679 };
+38 -458
drivers/pci/pci.c
··· 24 24 #include <linux/log2.h> 25 25 #include <linux/logic_pio.h> 26 26 #include <linux/pm_wakeup.h> 27 - #include <linux/interrupt.h> 28 27 #include <linux/device.h> 29 28 #include <linux/pm_runtime.h> 30 29 #include <linux/pci_hotplug.h> ··· 1067 1068 } 1068 1069 1069 1070 /** 1071 + * pcie_read_tlp_log - read TLP Header Log 1072 + * @dev: PCIe device 1073 + * @where: PCI Config offset of TLP Header Log 1074 + * @tlp_log: TLP Log structure to fill 1075 + * 1076 + * Fill @tlp_log from TLP Header Log registers, e.g., AER or DPC. 1077 + * 1078 + * Return: 0 on success and filled TLP Log structure, <0 on error. 1079 + */ 1080 + int pcie_read_tlp_log(struct pci_dev *dev, int where, 1081 + struct pcie_tlp_log *tlp_log) 1082 + { 1083 + int i, ret; 1084 + 1085 + memset(tlp_log, 0, sizeof(*tlp_log)); 1086 + 1087 + for (i = 0; i < 4; i++) { 1088 + ret = pci_read_config_dword(dev, where + i * 4, 1089 + &tlp_log->dw[i]); 1090 + if (ret) 1091 + return pcibios_err_to_errno(ret); 1092 + } 1093 + 1094 + return 0; 1095 + } 1096 + EXPORT_SYMBOL_GPL(pcie_read_tlp_log); 1097 + 1098 + /** 1070 1099 * pci_restore_bars - restore a device's BAR values (e.g. after wake-up) 1071 1100 * @dev: PCI device to have its BARs restored 1072 1101 * ··· 1676 1649 pcie_capability_read_word(dev, PCI_EXP_LNKCTL2, &cap[i++]); 1677 1650 pcie_capability_read_word(dev, PCI_EXP_SLTCTL2, &cap[i++]); 1678 1651 1652 + pci_save_aspm_l1ss_state(dev); 1653 + pci_save_ltr_state(dev); 1654 + 1679 1655 return 0; 1680 - } 1681 - 1682 - void pci_bridge_reconfigure_ltr(struct pci_dev *dev) 1683 - { 1684 - #ifdef CONFIG_PCIEASPM 1685 - struct pci_dev *bridge; 1686 - u32 ctl; 1687 - 1688 - bridge = pci_upstream_bridge(dev); 1689 - if (bridge && bridge->ltr_path) { 1690 - pcie_capability_read_dword(bridge, PCI_EXP_DEVCTL2, &ctl); 1691 - if (!(ctl & PCI_EXP_DEVCTL2_LTR_EN)) { 1692 - pci_dbg(bridge, "re-enabling LTR\n"); 1693 - pcie_capability_set_word(bridge, PCI_EXP_DEVCTL2, 1694 - PCI_EXP_DEVCTL2_LTR_EN); 1695 - } 1696 - } 1697 - #endif 1698 1656 } 1699 1657 1700 1658 static void pci_restore_pcie_state(struct pci_dev *dev) ··· 1687 1675 int i = 0; 1688 1676 struct pci_cap_saved_state *save_state; 1689 1677 u16 *cap; 1678 + 1679 + /* 1680 + * Restore max latencies (in the LTR capability) before enabling 1681 + * LTR itself in PCI_EXP_DEVCTL2. 1682 + */ 1683 + pci_restore_ltr_state(dev); 1684 + pci_restore_aspm_l1ss_state(dev); 1690 1685 1691 1686 save_state = pci_find_saved_cap(dev, PCI_CAP_ID_EXP); 1692 1687 if (!save_state) ··· 1752 1733 pci_write_config_word(dev, pos + PCI_X_CMD, cap[i++]); 1753 1734 } 1754 1735 1755 - static void pci_save_ltr_state(struct pci_dev *dev) 1756 - { 1757 - int ltr; 1758 - struct pci_cap_saved_state *save_state; 1759 - u32 *cap; 1760 - 1761 - if (!pci_is_pcie(dev)) 1762 - return; 1763 - 1764 - ltr = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_LTR); 1765 - if (!ltr) 1766 - return; 1767 - 1768 - save_state = pci_find_saved_ext_cap(dev, PCI_EXT_CAP_ID_LTR); 1769 - if (!save_state) { 1770 - pci_err(dev, "no suspend buffer for LTR; ASPM issues possible after resume\n"); 1771 - return; 1772 - } 1773 - 1774 - /* Some broken devices only support dword access to LTR */ 1775 - cap = &save_state->cap.data[0]; 1776 - pci_read_config_dword(dev, ltr + PCI_LTR_MAX_SNOOP_LAT, cap); 1777 - } 1778 - 1779 - static void pci_restore_ltr_state(struct pci_dev *dev) 1780 - { 1781 - struct pci_cap_saved_state *save_state; 1782 - int ltr; 1783 - u32 *cap; 1784 - 1785 - save_state = pci_find_saved_ext_cap(dev, PCI_EXT_CAP_ID_LTR); 1786 - ltr = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_LTR); 1787 - if (!save_state || !ltr) 1788 - return; 1789 - 1790 - /* Some broken devices only support dword access to LTR */ 1791 - cap = &save_state->cap.data[0]; 1792 - pci_write_config_dword(dev, ltr + PCI_LTR_MAX_SNOOP_LAT, *cap); 1793 - } 1794 - 1795 1736 /** 1796 1737 * pci_save_state - save the PCI configuration space of a device before 1797 1738 * suspending ··· 1776 1797 if (i != 0) 1777 1798 return i; 1778 1799 1779 - pci_save_ltr_state(dev); 1780 1800 pci_save_dpc_state(dev); 1781 1801 pci_save_aer_state(dev); 1782 1802 pci_save_ptm_state(dev); ··· 1875 1897 { 1876 1898 if (!dev->state_saved) 1877 1899 return; 1878 - 1879 - /* 1880 - * Restore max latencies (in the LTR capability) before enabling 1881 - * LTR itself (in the PCIe capability). 1882 - */ 1883 - pci_restore_ltr_state(dev); 1884 1900 1885 1901 pci_restore_pcie_state(dev); 1886 1902 pci_restore_pasid_state(dev); ··· 2156 2184 EXPORT_SYMBOL(pci_enable_device); 2157 2185 2158 2186 /* 2159 - * Managed PCI resources. This manages device on/off, INTx/MSI/MSI-X 2160 - * on/off and BAR regions. pci_dev itself records MSI/MSI-X status, so 2161 - * there's no need to track it separately. pci_devres is initialized 2162 - * when a device is enabled using managed PCI device enable interface. 2163 - */ 2164 - struct pci_devres { 2165 - unsigned int enabled:1; 2166 - unsigned int pinned:1; 2167 - unsigned int orig_intx:1; 2168 - unsigned int restore_intx:1; 2169 - unsigned int mwi:1; 2170 - u32 region_mask; 2171 - }; 2172 - 2173 - static void pcim_release(struct device *gendev, void *res) 2174 - { 2175 - struct pci_dev *dev = to_pci_dev(gendev); 2176 - struct pci_devres *this = res; 2177 - int i; 2178 - 2179 - for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) 2180 - if (this->region_mask & (1 << i)) 2181 - pci_release_region(dev, i); 2182 - 2183 - if (this->mwi) 2184 - pci_clear_mwi(dev); 2185 - 2186 - if (this->restore_intx) 2187 - pci_intx(dev, this->orig_intx); 2188 - 2189 - if (this->enabled && !this->pinned) 2190 - pci_disable_device(dev); 2191 - } 2192 - 2193 - static struct pci_devres *get_pci_dr(struct pci_dev *pdev) 2194 - { 2195 - struct pci_devres *dr, *new_dr; 2196 - 2197 - dr = devres_find(&pdev->dev, pcim_release, NULL, NULL); 2198 - if (dr) 2199 - return dr; 2200 - 2201 - new_dr = devres_alloc(pcim_release, sizeof(*new_dr), GFP_KERNEL); 2202 - if (!new_dr) 2203 - return NULL; 2204 - return devres_get(&pdev->dev, new_dr, NULL, NULL); 2205 - } 2206 - 2207 - static struct pci_devres *find_pci_dr(struct pci_dev *pdev) 2208 - { 2209 - if (pci_is_managed(pdev)) 2210 - return devres_find(&pdev->dev, pcim_release, NULL, NULL); 2211 - return NULL; 2212 - } 2213 - 2214 - /** 2215 - * pcim_enable_device - Managed pci_enable_device() 2216 - * @pdev: PCI device to be initialized 2217 - * 2218 - * Managed pci_enable_device(). 2219 - */ 2220 - int pcim_enable_device(struct pci_dev *pdev) 2221 - { 2222 - struct pci_devres *dr; 2223 - int rc; 2224 - 2225 - dr = get_pci_dr(pdev); 2226 - if (unlikely(!dr)) 2227 - return -ENOMEM; 2228 - if (dr->enabled) 2229 - return 0; 2230 - 2231 - rc = pci_enable_device(pdev); 2232 - if (!rc) { 2233 - pdev->is_managed = 1; 2234 - dr->enabled = 1; 2235 - } 2236 - return rc; 2237 - } 2238 - EXPORT_SYMBOL(pcim_enable_device); 2239 - 2240 - /** 2241 - * pcim_pin_device - Pin managed PCI device 2242 - * @pdev: PCI device to pin 2243 - * 2244 - * Pin managed PCI device @pdev. Pinned device won't be disabled on 2245 - * driver detach. @pdev must have been enabled with 2246 - * pcim_enable_device(). 2247 - */ 2248 - void pcim_pin_device(struct pci_dev *pdev) 2249 - { 2250 - struct pci_devres *dr; 2251 - 2252 - dr = find_pci_dr(pdev); 2253 - WARN_ON(!dr || !dr->enabled); 2254 - if (dr) 2255 - dr->pinned = 1; 2256 - } 2257 - EXPORT_SYMBOL(pcim_pin_device); 2258 - 2259 - /* 2260 2187 * pcibios_device_add - provide arch specific hooks when adding device dev 2261 2188 * @dev: the PCI device being added 2262 2189 * ··· 2188 2317 * override this. 2189 2318 */ 2190 2319 void __weak pcibios_disable_device(struct pci_dev *dev) {} 2191 - 2192 - /** 2193 - * pcibios_penalize_isa_irq - penalize an ISA IRQ 2194 - * @irq: ISA IRQ to penalize 2195 - * @active: IRQ active or not 2196 - * 2197 - * Permits the platform to provide architecture-specific functionality when 2198 - * penalizing ISA IRQs. This is the default implementation. Architecture 2199 - * implementations can override this. 2200 - */ 2201 - void __weak pcibios_penalize_isa_irq(int irq, int active) {} 2202 2320 2203 2321 static void do_pci_disable_device(struct pci_dev *dev) 2204 2322 { ··· 3858 3998 EXPORT_SYMBOL(pci_enable_atomic_ops_to_root); 3859 3999 3860 4000 /** 3861 - * pci_swizzle_interrupt_pin - swizzle INTx for device behind bridge 3862 - * @dev: the PCI device 3863 - * @pin: the INTx pin (1=INTA, 2=INTB, 3=INTC, 4=INTD) 3864 - * 3865 - * Perform INTx swizzling for a device behind one level of bridge. This is 3866 - * required by section 9.1 of the PCI-to-PCI bridge specification for devices 3867 - * behind bridges on add-in cards. For devices with ARI enabled, the slot 3868 - * number is always 0 (see the Implementation Note in section 2.2.8.1 of 3869 - * the PCI Express Base Specification, Revision 2.1) 3870 - */ 3871 - u8 pci_swizzle_interrupt_pin(const struct pci_dev *dev, u8 pin) 3872 - { 3873 - int slot; 3874 - 3875 - if (pci_ari_enabled(dev->bus)) 3876 - slot = 0; 3877 - else 3878 - slot = PCI_SLOT(dev->devfn); 3879 - 3880 - return (((pin - 1) + slot) % 4) + 1; 3881 - } 3882 - 3883 - int pci_get_interrupt_pin(struct pci_dev *dev, struct pci_dev **bridge) 3884 - { 3885 - u8 pin; 3886 - 3887 - pin = dev->pin; 3888 - if (!pin) 3889 - return -1; 3890 - 3891 - while (!pci_is_root_bus(dev->bus)) { 3892 - pin = pci_swizzle_interrupt_pin(dev, pin); 3893 - dev = dev->bus->self; 3894 - } 3895 - *bridge = dev; 3896 - return pin; 3897 - } 3898 - 3899 - /** 3900 - * pci_common_swizzle - swizzle INTx all the way to root bridge 3901 - * @dev: the PCI device 3902 - * @pinp: pointer to the INTx pin value (1=INTA, 2=INTB, 3=INTD, 4=INTD) 3903 - * 3904 - * Perform INTx swizzling for a device. This traverses through all PCI-to-PCI 3905 - * bridges all the way up to a PCI root bus. 3906 - */ 3907 - u8 pci_common_swizzle(struct pci_dev *dev, u8 *pinp) 3908 - { 3909 - u8 pin = *pinp; 3910 - 3911 - while (!pci_is_root_bus(dev->bus)) { 3912 - pin = pci_swizzle_interrupt_pin(dev, pin); 3913 - dev = dev->bus->self; 3914 - } 3915 - *pinp = pin; 3916 - return PCI_SLOT(dev->devfn); 3917 - } 3918 - EXPORT_SYMBOL_GPL(pci_common_swizzle); 3919 - 3920 - /** 3921 4001 * pci_release_region - Release a PCI bar 3922 4002 * @pdev: PCI device whose resources were previously reserved by 3923 4003 * pci_request_region() ··· 4185 4385 } 4186 4386 EXPORT_SYMBOL(pci_unmap_iospace); 4187 4387 4188 - static void devm_pci_unmap_iospace(struct device *dev, void *ptr) 4189 - { 4190 - struct resource **res = ptr; 4191 - 4192 - pci_unmap_iospace(*res); 4193 - } 4194 - 4195 - /** 4196 - * devm_pci_remap_iospace - Managed pci_remap_iospace() 4197 - * @dev: Generic device to remap IO address for 4198 - * @res: Resource describing the I/O space 4199 - * @phys_addr: physical address of range to be mapped 4200 - * 4201 - * Managed pci_remap_iospace(). Map is automatically unmapped on driver 4202 - * detach. 4203 - */ 4204 - int devm_pci_remap_iospace(struct device *dev, const struct resource *res, 4205 - phys_addr_t phys_addr) 4206 - { 4207 - const struct resource **ptr; 4208 - int error; 4209 - 4210 - ptr = devres_alloc(devm_pci_unmap_iospace, sizeof(*ptr), GFP_KERNEL); 4211 - if (!ptr) 4212 - return -ENOMEM; 4213 - 4214 - error = pci_remap_iospace(res, phys_addr); 4215 - if (error) { 4216 - devres_free(ptr); 4217 - } else { 4218 - *ptr = res; 4219 - devres_add(dev, ptr); 4220 - } 4221 - 4222 - return error; 4223 - } 4224 - EXPORT_SYMBOL(devm_pci_remap_iospace); 4225 - 4226 - /** 4227 - * devm_pci_remap_cfgspace - Managed pci_remap_cfgspace() 4228 - * @dev: Generic device to remap IO address for 4229 - * @offset: Resource address to map 4230 - * @size: Size of map 4231 - * 4232 - * Managed pci_remap_cfgspace(). Map is automatically unmapped on driver 4233 - * detach. 4234 - */ 4235 - void __iomem *devm_pci_remap_cfgspace(struct device *dev, 4236 - resource_size_t offset, 4237 - resource_size_t size) 4238 - { 4239 - void __iomem **ptr, *addr; 4240 - 4241 - ptr = devres_alloc(devm_ioremap_release, sizeof(*ptr), GFP_KERNEL); 4242 - if (!ptr) 4243 - return NULL; 4244 - 4245 - addr = pci_remap_cfgspace(offset, size); 4246 - if (addr) { 4247 - *ptr = addr; 4248 - devres_add(dev, ptr); 4249 - } else 4250 - devres_free(ptr); 4251 - 4252 - return addr; 4253 - } 4254 - EXPORT_SYMBOL(devm_pci_remap_cfgspace); 4255 - 4256 - /** 4257 - * devm_pci_remap_cfg_resource - check, request region and ioremap cfg resource 4258 - * @dev: generic device to handle the resource for 4259 - * @res: configuration space resource to be handled 4260 - * 4261 - * Checks that a resource is a valid memory region, requests the memory 4262 - * region and ioremaps with pci_remap_cfgspace() API that ensures the 4263 - * proper PCI configuration space memory attributes are guaranteed. 4264 - * 4265 - * All operations are managed and will be undone on driver detach. 4266 - * 4267 - * Returns a pointer to the remapped memory or an ERR_PTR() encoded error code 4268 - * on failure. Usage example:: 4269 - * 4270 - * res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 4271 - * base = devm_pci_remap_cfg_resource(&pdev->dev, res); 4272 - * if (IS_ERR(base)) 4273 - * return PTR_ERR(base); 4274 - */ 4275 - void __iomem *devm_pci_remap_cfg_resource(struct device *dev, 4276 - struct resource *res) 4277 - { 4278 - resource_size_t size; 4279 - const char *name; 4280 - void __iomem *dest_ptr; 4281 - 4282 - BUG_ON(!dev); 4283 - 4284 - if (!res || resource_type(res) != IORESOURCE_MEM) { 4285 - dev_err(dev, "invalid resource\n"); 4286 - return IOMEM_ERR_PTR(-EINVAL); 4287 - } 4288 - 4289 - size = resource_size(res); 4290 - 4291 - if (res->name) 4292 - name = devm_kasprintf(dev, GFP_KERNEL, "%s %s", dev_name(dev), 4293 - res->name); 4294 - else 4295 - name = devm_kstrdup(dev, dev_name(dev), GFP_KERNEL); 4296 - if (!name) 4297 - return IOMEM_ERR_PTR(-ENOMEM); 4298 - 4299 - if (!devm_request_mem_region(dev, res->start, size, name)) { 4300 - dev_err(dev, "can't request region for resource %pR\n", res); 4301 - return IOMEM_ERR_PTR(-EBUSY); 4302 - } 4303 - 4304 - dest_ptr = devm_pci_remap_cfgspace(dev, res->start, size); 4305 - if (!dest_ptr) { 4306 - dev_err(dev, "ioremap failed for resource %pR\n", res); 4307 - devm_release_mem_region(dev, res->start, size); 4308 - dest_ptr = IOMEM_ERR_PTR(-ENOMEM); 4309 - } 4310 - 4311 - return dest_ptr; 4312 - } 4313 - EXPORT_SYMBOL(devm_pci_remap_cfg_resource); 4314 - 4315 4388 static void __pci_set_master(struct pci_dev *dev, bool enable) 4316 4389 { 4317 4390 u16 old_cmd, cmd; ··· 4335 4662 EXPORT_SYMBOL(pci_set_mwi); 4336 4663 4337 4664 /** 4338 - * pcim_set_mwi - a device-managed pci_set_mwi() 4339 - * @dev: the PCI device for which MWI is enabled 4340 - * 4341 - * Managed pci_set_mwi(). 4342 - * 4343 - * RETURNS: An appropriate -ERRNO error value on error, or zero for success. 4344 - */ 4345 - int pcim_set_mwi(struct pci_dev *dev) 4346 - { 4347 - struct pci_devres *dr; 4348 - 4349 - dr = find_pci_dr(dev); 4350 - if (!dr) 4351 - return -ENOMEM; 4352 - 4353 - dr->mwi = 1; 4354 - return pci_set_mwi(dev); 4355 - } 4356 - EXPORT_SYMBOL(pcim_set_mwi); 4357 - 4358 - /** 4359 4665 * pci_try_set_mwi - enables memory-write-invalidate PCI transaction 4360 4666 * @dev: the PCI device for which MWI is enabled 4361 4667 * ··· 4421 4769 } 4422 4770 } 4423 4771 EXPORT_SYMBOL_GPL(pci_intx); 4424 - 4425 - static bool pci_check_and_set_intx_mask(struct pci_dev *dev, bool mask) 4426 - { 4427 - struct pci_bus *bus = dev->bus; 4428 - bool mask_updated = true; 4429 - u32 cmd_status_dword; 4430 - u16 origcmd, newcmd; 4431 - unsigned long flags; 4432 - bool irq_pending; 4433 - 4434 - /* 4435 - * We do a single dword read to retrieve both command and status. 4436 - * Document assumptions that make this possible. 4437 - */ 4438 - BUILD_BUG_ON(PCI_COMMAND % 4); 4439 - BUILD_BUG_ON(PCI_COMMAND + 2 != PCI_STATUS); 4440 - 4441 - raw_spin_lock_irqsave(&pci_lock, flags); 4442 - 4443 - bus->ops->read(bus, dev->devfn, PCI_COMMAND, 4, &cmd_status_dword); 4444 - 4445 - irq_pending = (cmd_status_dword >> 16) & PCI_STATUS_INTERRUPT; 4446 - 4447 - /* 4448 - * Check interrupt status register to see whether our device 4449 - * triggered the interrupt (when masking) or the next IRQ is 4450 - * already pending (when unmasking). 4451 - */ 4452 - if (mask != irq_pending) { 4453 - mask_updated = false; 4454 - goto done; 4455 - } 4456 - 4457 - origcmd = cmd_status_dword; 4458 - newcmd = origcmd & ~PCI_COMMAND_INTX_DISABLE; 4459 - if (mask) 4460 - newcmd |= PCI_COMMAND_INTX_DISABLE; 4461 - if (newcmd != origcmd) 4462 - bus->ops->write(bus, dev->devfn, PCI_COMMAND, 2, newcmd); 4463 - 4464 - done: 4465 - raw_spin_unlock_irqrestore(&pci_lock, flags); 4466 - 4467 - return mask_updated; 4468 - } 4469 - 4470 - /** 4471 - * pci_check_and_mask_intx - mask INTx on pending interrupt 4472 - * @dev: the PCI device to operate on 4473 - * 4474 - * Check if the device dev has its INTx line asserted, mask it and return 4475 - * true in that case. False is returned if no interrupt was pending. 4476 - */ 4477 - bool pci_check_and_mask_intx(struct pci_dev *dev) 4478 - { 4479 - return pci_check_and_set_intx_mask(dev, true); 4480 - } 4481 - EXPORT_SYMBOL_GPL(pci_check_and_mask_intx); 4482 - 4483 - /** 4484 - * pci_check_and_unmask_intx - unmask INTx if no interrupt is pending 4485 - * @dev: the PCI device to operate on 4486 - * 4487 - * Check if the device dev has its INTx line asserted, unmask it if not and 4488 - * return true. False is returned and the mask remains active if there was 4489 - * still an interrupt pending. 4490 - */ 4491 - bool pci_check_and_unmask_intx(struct pci_dev *dev) 4492 - { 4493 - return pci_check_and_set_intx_mask(dev, false); 4494 - } 4495 - EXPORT_SYMBOL_GPL(pci_check_and_unmask_intx); 4496 4772 4497 4773 /** 4498 4774 * pci_wait_for_pending_transaction - wait for pending transaction
+48 -7
drivers/pci/pci.h
··· 31 31 32 32 /* Functions internal to the PCI core code */ 33 33 34 - int pci_create_sysfs_dev_files(struct pci_dev *pdev); 35 - void pci_remove_sysfs_dev_files(struct pci_dev *pdev); 36 - void pci_cleanup_rom(struct pci_dev *dev); 37 34 #ifdef CONFIG_DMI 38 35 extern const struct attribute_group pci_dev_smbios_attr_group; 39 36 #endif ··· 94 97 void pci_msix_init(struct pci_dev *dev); 95 98 bool pci_bridge_d3_possible(struct pci_dev *dev); 96 99 void pci_bridge_d3_update(struct pci_dev *dev); 97 - void pci_bridge_reconfigure_ltr(struct pci_dev *dev); 98 100 int pci_bridge_wait_for_secondary_bus(struct pci_dev *dev, char *reset_type); 99 101 100 102 static inline void pci_wakeup_event(struct pci_dev *dev) ··· 148 152 /* Functions for PCI Hotplug drivers to use */ 149 153 int pci_hp_add_bridge(struct pci_dev *dev); 150 154 151 - #ifdef HAVE_PCI_LEGACY 155 + #if defined(CONFIG_SYSFS) && defined(HAVE_PCI_LEGACY) 152 156 void pci_create_legacy_files(struct pci_bus *bus); 153 157 void pci_remove_legacy_files(struct pci_bus *bus); 154 158 #else ··· 181 185 return (dev->no_d1d2 || parent_dstates); 182 186 183 187 } 188 + 189 + #ifdef CONFIG_SYSFS 190 + int pci_create_sysfs_dev_files(struct pci_dev *pdev); 191 + void pci_remove_sysfs_dev_files(struct pci_dev *pdev); 184 192 extern const struct attribute_group *pci_dev_groups[]; 193 + extern const struct attribute_group *pci_dev_attr_groups[]; 185 194 extern const struct attribute_group *pcibus_groups[]; 186 - extern const struct device_type pci_dev_type; 187 195 extern const struct attribute_group *pci_bus_groups[]; 196 + #else 197 + static inline int pci_create_sysfs_dev_files(struct pci_dev *pdev) { return 0; } 198 + static inline void pci_remove_sysfs_dev_files(struct pci_dev *pdev) { } 199 + #define pci_dev_groups NULL 200 + #define pci_dev_attr_groups NULL 201 + #define pcibus_groups NULL 202 + #define pci_bus_groups NULL 203 + #endif 188 204 189 205 extern unsigned long pci_hotplug_io_size; 190 206 extern unsigned long pci_hotplug_mmio_size; ··· 412 404 413 405 unsigned int status; /* COR/UNCOR Error Status */ 414 406 unsigned int mask; /* COR/UNCOR Error Mask */ 415 - struct aer_header_log_regs tlp; /* TLP Header */ 407 + struct pcie_tlp_log tlp; /* TLP Header */ 416 408 }; 417 409 418 410 int aer_get_device_error_info(struct pci_dev *dev, struct aer_err_info *info); ··· 571 563 572 564 bool pcie_wait_for_link(struct pci_dev *pdev, bool active); 573 565 int pcie_retrain_link(struct pci_dev *pdev, bool use_lt); 566 + 567 + /* ASPM-related functionality we need even without CONFIG_PCIEASPM */ 568 + void pci_save_ltr_state(struct pci_dev *dev); 569 + void pci_restore_ltr_state(struct pci_dev *dev); 570 + void pci_configure_aspm_l1ss(struct pci_dev *dev); 571 + void pci_save_aspm_l1ss_state(struct pci_dev *dev); 572 + void pci_restore_aspm_l1ss_state(struct pci_dev *dev); 573 + 574 574 #ifdef CONFIG_PCIEASPM 575 575 void pcie_aspm_init_link_state(struct pci_dev *pdev); 576 576 void pcie_aspm_exit_link_state(struct pci_dev *pdev); 577 577 void pcie_aspm_pm_state_change(struct pci_dev *pdev, bool locked); 578 578 void pcie_aspm_powersave_config_link(struct pci_dev *pdev); 579 + void pci_configure_ltr(struct pci_dev *pdev); 580 + void pci_bridge_reconfigure_ltr(struct pci_dev *pdev); 579 581 #else 580 582 static inline void pcie_aspm_init_link_state(struct pci_dev *pdev) { } 581 583 static inline void pcie_aspm_exit_link_state(struct pci_dev *pdev) { } 582 584 static inline void pcie_aspm_pm_state_change(struct pci_dev *pdev, bool locked) { } 583 585 static inline void pcie_aspm_powersave_config_link(struct pci_dev *pdev) { } 586 + static inline void pci_configure_ltr(struct pci_dev *pdev) { } 587 + static inline void pci_bridge_reconfigure_ltr(struct pci_dev *pdev) { } 584 588 #endif 585 589 586 590 #ifdef CONFIG_PCIE_ECRC ··· 811 791 return PCI_UNKNOWN; 812 792 } 813 793 #endif 794 + 795 + /* 796 + * Managed PCI resources. This manages device on/off, INTx/MSI/MSI-X 797 + * on/off and BAR regions. pci_dev itself records MSI/MSI-X status, so 798 + * there's no need to track it separately. pci_devres is initialized 799 + * when a device is enabled using managed PCI device enable interface. 800 + * 801 + * TODO: Struct pci_devres and find_pci_dr() only need to be here because 802 + * they're used in pci.c. Port or move these functions to devres.c and 803 + * then remove them from here. 804 + */ 805 + struct pci_devres { 806 + unsigned int enabled:1; 807 + unsigned int pinned:1; 808 + unsigned int orig_intx:1; 809 + unsigned int restore_intx:1; 810 + unsigned int mwi:1; 811 + u32 region_mask; 812 + }; 813 + 814 + struct pci_devres *find_pci_dr(struct pci_dev *pdev); 814 815 815 816 /* 816 817 * Config Address for PCI Configuration Mechanism #1
+1 -1
drivers/pci/pcie/Makefile
··· 6 6 7 7 obj-$(CONFIG_PCIEPORTBUS) += pcieportdrv.o 8 8 9 - obj-$(CONFIG_PCIEASPM) += aspm.o 9 + obj-y += aspm.o 10 10 obj-$(CONFIG_PCIEAER) += aer.o err.o 11 11 obj-$(CONFIG_PCIEAER_INJECT) += aer_inject.o 12 12 obj-$(CONFIG_PCIE_PME) += pme.o
+6 -14
drivers/pci/pcie/aer.c
··· 664 664 } 665 665 } 666 666 667 - static void __print_tlp_header(struct pci_dev *dev, 668 - struct aer_header_log_regs *t) 667 + static void __print_tlp_header(struct pci_dev *dev, struct pcie_tlp_log *t) 669 668 { 670 669 pci_err(dev, " TLP Header: %08x %08x %08x %08x\n", 671 - t->dw0, t->dw1, t->dw2, t->dw3); 670 + t->dw[0], t->dw[1], t->dw[2], t->dw[3]); 672 671 } 673 672 674 673 static void __aer_print_error(struct pci_dev *dev, ··· 1209 1210 { 1210 1211 int type = pci_pcie_type(dev); 1211 1212 int aer = dev->aer_cap; 1212 - int temp; 1213 + u32 aercc; 1213 1214 1214 1215 /* Must reset in this function */ 1215 1216 info->status = 0; ··· 1240 1241 return 0; 1241 1242 1242 1243 /* Get First Error Pointer */ 1243 - pci_read_config_dword(dev, aer + PCI_ERR_CAP, &temp); 1244 - info->first_error = PCI_ERR_CAP_FEP(temp); 1244 + pci_read_config_dword(dev, aer + PCI_ERR_CAP, &aercc); 1245 + info->first_error = PCI_ERR_CAP_FEP(aercc); 1245 1246 1246 1247 if (info->status & AER_LOG_TLP_MASKS) { 1247 1248 info->tlp_header_valid = 1; 1248 - pci_read_config_dword(dev, 1249 - aer + PCI_ERR_HEADER_LOG, &info->tlp.dw0); 1250 - pci_read_config_dword(dev, 1251 - aer + PCI_ERR_HEADER_LOG + 4, &info->tlp.dw1); 1252 - pci_read_config_dword(dev, 1253 - aer + PCI_ERR_HEADER_LOG + 8, &info->tlp.dw2); 1254 - pci_read_config_dword(dev, 1255 - aer + PCI_ERR_HEADER_LOG + 12, &info->tlp.dw3); 1249 + pcie_read_tlp_log(dev, aer + PCI_ERR_HEADER_LOG, &info->tlp); 1256 1250 } 1257 1251 } 1258 1252
+267 -1
drivers/pci/pcie/aspm.c
··· 24 24 25 25 #include "../pci.h" 26 26 27 + void pci_save_ltr_state(struct pci_dev *dev) 28 + { 29 + int ltr; 30 + struct pci_cap_saved_state *save_state; 31 + u32 *cap; 32 + 33 + if (!pci_is_pcie(dev)) 34 + return; 35 + 36 + ltr = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_LTR); 37 + if (!ltr) 38 + return; 39 + 40 + save_state = pci_find_saved_ext_cap(dev, PCI_EXT_CAP_ID_LTR); 41 + if (!save_state) { 42 + pci_err(dev, "no suspend buffer for LTR; ASPM issues possible after resume\n"); 43 + return; 44 + } 45 + 46 + /* Some broken devices only support dword access to LTR */ 47 + cap = &save_state->cap.data[0]; 48 + pci_read_config_dword(dev, ltr + PCI_LTR_MAX_SNOOP_LAT, cap); 49 + } 50 + 51 + void pci_restore_ltr_state(struct pci_dev *dev) 52 + { 53 + struct pci_cap_saved_state *save_state; 54 + int ltr; 55 + u32 *cap; 56 + 57 + save_state = pci_find_saved_ext_cap(dev, PCI_EXT_CAP_ID_LTR); 58 + ltr = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_LTR); 59 + if (!save_state || !ltr) 60 + return; 61 + 62 + /* Some broken devices only support dword access to LTR */ 63 + cap = &save_state->cap.data[0]; 64 + pci_write_config_dword(dev, ltr + PCI_LTR_MAX_SNOOP_LAT, *cap); 65 + } 66 + 67 + void pci_configure_aspm_l1ss(struct pci_dev *pdev) 68 + { 69 + int rc; 70 + 71 + pdev->l1ss = pci_find_ext_capability(pdev, PCI_EXT_CAP_ID_L1SS); 72 + 73 + rc = pci_add_ext_cap_save_buffer(pdev, PCI_EXT_CAP_ID_L1SS, 74 + 2 * sizeof(u32)); 75 + if (rc) 76 + pci_err(pdev, "unable to allocate ASPM L1SS save buffer (%pe)\n", 77 + ERR_PTR(rc)); 78 + } 79 + 80 + void pci_save_aspm_l1ss_state(struct pci_dev *pdev) 81 + { 82 + struct pci_cap_saved_state *save_state; 83 + u16 l1ss = pdev->l1ss; 84 + u32 *cap; 85 + 86 + /* 87 + * Save L1 substate configuration. The ASPM L0s/L1 configuration 88 + * in PCI_EXP_LNKCTL_ASPMC is saved by pci_save_pcie_state(). 89 + */ 90 + if (!l1ss) 91 + return; 92 + 93 + save_state = pci_find_saved_ext_cap(pdev, PCI_EXT_CAP_ID_L1SS); 94 + if (!save_state) 95 + return; 96 + 97 + cap = &save_state->cap.data[0]; 98 + pci_read_config_dword(pdev, l1ss + PCI_L1SS_CTL2, cap++); 99 + pci_read_config_dword(pdev, l1ss + PCI_L1SS_CTL1, cap++); 100 + } 101 + 102 + void pci_restore_aspm_l1ss_state(struct pci_dev *pdev) 103 + { 104 + struct pci_cap_saved_state *pl_save_state, *cl_save_state; 105 + struct pci_dev *parent = pdev->bus->self; 106 + u32 *cap, pl_ctl1, pl_ctl2, pl_l1_2_enable; 107 + u32 cl_ctl1, cl_ctl2, cl_l1_2_enable; 108 + u16 clnkctl, plnkctl; 109 + 110 + /* 111 + * In case BIOS enabled L1.2 when resuming, we need to disable it first 112 + * on the downstream component before the upstream. So, don't attempt to 113 + * restore either until we are at the downstream component. 114 + */ 115 + if (pcie_downstream_port(pdev) || !parent) 116 + return; 117 + 118 + if (!pdev->l1ss || !parent->l1ss) 119 + return; 120 + 121 + cl_save_state = pci_find_saved_ext_cap(pdev, PCI_EXT_CAP_ID_L1SS); 122 + pl_save_state = pci_find_saved_ext_cap(parent, PCI_EXT_CAP_ID_L1SS); 123 + if (!cl_save_state || !pl_save_state) 124 + return; 125 + 126 + cap = &cl_save_state->cap.data[0]; 127 + cl_ctl2 = *cap++; 128 + cl_ctl1 = *cap; 129 + cap = &pl_save_state->cap.data[0]; 130 + pl_ctl2 = *cap++; 131 + pl_ctl1 = *cap; 132 + 133 + /* Make sure L0s/L1 are disabled before updating L1SS config */ 134 + pcie_capability_read_word(pdev, PCI_EXP_LNKCTL, &clnkctl); 135 + pcie_capability_read_word(parent, PCI_EXP_LNKCTL, &plnkctl); 136 + if (FIELD_GET(PCI_EXP_LNKCTL_ASPMC, clnkctl) || 137 + FIELD_GET(PCI_EXP_LNKCTL_ASPMC, plnkctl)) { 138 + pcie_capability_write_word(pdev, PCI_EXP_LNKCTL, 139 + clnkctl & ~PCI_EXP_LNKCTL_ASPMC); 140 + pcie_capability_write_word(parent, PCI_EXP_LNKCTL, 141 + plnkctl & ~PCI_EXP_LNKCTL_ASPMC); 142 + } 143 + 144 + /* 145 + * Disable L1.2 on this downstream endpoint device first, followed 146 + * by the upstream 147 + */ 148 + pci_clear_and_set_config_dword(pdev, pdev->l1ss + PCI_L1SS_CTL1, 149 + PCI_L1SS_CTL1_L1_2_MASK, 0); 150 + pci_clear_and_set_config_dword(parent, parent->l1ss + PCI_L1SS_CTL1, 151 + PCI_L1SS_CTL1_L1_2_MASK, 0); 152 + 153 + /* 154 + * In addition, Common_Mode_Restore_Time and LTR_L1.2_THRESHOLD 155 + * in PCI_L1SS_CTL1 must be programmed *before* setting the L1.2 156 + * enable bits, even though they're all in PCI_L1SS_CTL1. 157 + */ 158 + pl_l1_2_enable = pl_ctl1 & PCI_L1SS_CTL1_L1_2_MASK; 159 + pl_ctl1 &= ~PCI_L1SS_CTL1_L1_2_MASK; 160 + cl_l1_2_enable = cl_ctl1 & PCI_L1SS_CTL1_L1_2_MASK; 161 + cl_ctl1 &= ~PCI_L1SS_CTL1_L1_2_MASK; 162 + 163 + /* Write back without enables first (above we cleared them in ctl1) */ 164 + pci_write_config_dword(parent, parent->l1ss + PCI_L1SS_CTL2, pl_ctl2); 165 + pci_write_config_dword(pdev, pdev->l1ss + PCI_L1SS_CTL2, cl_ctl2); 166 + pci_write_config_dword(parent, parent->l1ss + PCI_L1SS_CTL1, pl_ctl1); 167 + pci_write_config_dword(pdev, pdev->l1ss + PCI_L1SS_CTL1, cl_ctl1); 168 + 169 + /* Then write back the enables */ 170 + if (pl_l1_2_enable || cl_l1_2_enable) { 171 + pci_write_config_dword(parent, parent->l1ss + PCI_L1SS_CTL1, 172 + pl_ctl1 | pl_l1_2_enable); 173 + pci_write_config_dword(pdev, pdev->l1ss + PCI_L1SS_CTL1, 174 + cl_ctl1 | cl_l1_2_enable); 175 + } 176 + 177 + /* Restore L0s/L1 if they were enabled */ 178 + if (FIELD_GET(PCI_EXP_LNKCTL_ASPMC, clnkctl) || 179 + FIELD_GET(PCI_EXP_LNKCTL_ASPMC, plnkctl)) { 180 + pcie_capability_write_word(parent, PCI_EXP_LNKCTL, clnkctl); 181 + pcie_capability_write_word(pdev, PCI_EXP_LNKCTL, plnkctl); 182 + } 183 + } 184 + 185 + #ifdef CONFIG_PCIEASPM 186 + 27 187 #ifdef MODULE_PARAM_PREFIX 28 188 #undef MODULE_PARAM_PREFIX 29 189 #endif ··· 301 141 return 0; 302 142 } 303 143 144 + static void pci_update_aspm_saved_state(struct pci_dev *dev) 145 + { 146 + struct pci_cap_saved_state *save_state; 147 + u16 *cap, lnkctl, aspm_ctl; 148 + 149 + save_state = pci_find_saved_cap(dev, PCI_CAP_ID_EXP); 150 + if (!save_state) 151 + return; 152 + 153 + pcie_capability_read_word(dev, PCI_EXP_LNKCTL, &lnkctl); 154 + 155 + /* 156 + * Update ASPM and CLKREQ bits of LNKCTL in save_state. We only 157 + * write PCI_EXP_LNKCTL_CCC during enumeration, so it shouldn't 158 + * change after being captured in save_state. 159 + */ 160 + aspm_ctl = lnkctl & (PCI_EXP_LNKCTL_ASPMC | PCI_EXP_LNKCTL_CLKREQ_EN); 161 + lnkctl &= ~(PCI_EXP_LNKCTL_ASPMC | PCI_EXP_LNKCTL_CLKREQ_EN); 162 + 163 + /* Depends on pci_save_pcie_state(): cap[1] is LNKCTL */ 164 + cap = (u16 *)&save_state->cap.data[0]; 165 + cap[1] = lnkctl | aspm_ctl; 166 + } 167 + 304 168 static void pcie_set_clkpm_nocheck(struct pcie_link_state *link, int enable) 305 169 { 306 170 struct pci_dev *child; 307 171 struct pci_bus *linkbus = link->pdev->subordinate; 308 172 u32 val = enable ? PCI_EXP_LNKCTL_CLKREQ_EN : 0; 309 173 310 - list_for_each_entry(child, &linkbus->devices, bus_list) 174 + list_for_each_entry(child, &linkbus->devices, bus_list) { 311 175 pcie_capability_clear_and_set_word(child, PCI_EXP_LNKCTL, 312 176 PCI_EXP_LNKCTL_CLKREQ_EN, 313 177 val); 178 + pci_update_aspm_saved_state(child); 179 + } 314 180 link->clkpm_enabled = !!enable; 315 181 } 316 182 ··· 955 769 pcie_config_aspm_dev(parent, upstream); 956 770 957 771 link->aspm_enabled = state; 772 + 773 + /* Update latest ASPM configuration in saved context */ 774 + pci_save_aspm_l1ss_state(link->downstream); 775 + pci_update_aspm_saved_state(link->downstream); 776 + pci_save_aspm_l1ss_state(parent); 777 + pci_update_aspm_saved_state(parent); 958 778 } 959 779 960 780 static void pcie_config_aspm_path(struct pcie_link_state *link) ··· 1128 936 mutex_unlock(&aspm_lock); 1129 937 out: 1130 938 up_read(&pci_bus_sem); 939 + } 940 + 941 + void pci_bridge_reconfigure_ltr(struct pci_dev *pdev) 942 + { 943 + struct pci_dev *bridge; 944 + u32 ctl; 945 + 946 + bridge = pci_upstream_bridge(pdev); 947 + if (bridge && bridge->ltr_path) { 948 + pcie_capability_read_dword(bridge, PCI_EXP_DEVCTL2, &ctl); 949 + if (!(ctl & PCI_EXP_DEVCTL2_LTR_EN)) { 950 + pci_dbg(bridge, "re-enabling LTR\n"); 951 + pcie_capability_set_word(bridge, PCI_EXP_DEVCTL2, 952 + PCI_EXP_DEVCTL2_LTR_EN); 953 + } 954 + } 955 + } 956 + 957 + void pci_configure_ltr(struct pci_dev *pdev) 958 + { 959 + struct pci_host_bridge *host = pci_find_host_bridge(pdev->bus); 960 + struct pci_dev *bridge; 961 + u32 cap, ctl; 962 + 963 + if (!pci_is_pcie(pdev)) 964 + return; 965 + 966 + pcie_capability_read_dword(pdev, PCI_EXP_DEVCAP2, &cap); 967 + if (!(cap & PCI_EXP_DEVCAP2_LTR)) 968 + return; 969 + 970 + pcie_capability_read_dword(pdev, PCI_EXP_DEVCTL2, &ctl); 971 + if (ctl & PCI_EXP_DEVCTL2_LTR_EN) { 972 + if (pci_pcie_type(pdev) == PCI_EXP_TYPE_ROOT_PORT) { 973 + pdev->ltr_path = 1; 974 + return; 975 + } 976 + 977 + bridge = pci_upstream_bridge(pdev); 978 + if (bridge && bridge->ltr_path) 979 + pdev->ltr_path = 1; 980 + 981 + return; 982 + } 983 + 984 + if (!host->native_ltr) 985 + return; 986 + 987 + /* 988 + * Software must not enable LTR in an Endpoint unless the Root 989 + * Complex and all intermediate Switches indicate support for LTR. 990 + * PCIe r4.0, sec 6.18. 991 + */ 992 + if (pci_pcie_type(pdev) == PCI_EXP_TYPE_ROOT_PORT) { 993 + pcie_capability_set_word(pdev, PCI_EXP_DEVCTL2, 994 + PCI_EXP_DEVCTL2_LTR_EN); 995 + pdev->ltr_path = 1; 996 + return; 997 + } 998 + 999 + /* 1000 + * If we're configuring a hot-added device, LTR was likely 1001 + * disabled in the upstream bridge, so re-enable it before enabling 1002 + * it in the new device. 1003 + */ 1004 + bridge = pci_upstream_bridge(pdev); 1005 + if (bridge && bridge->ltr_path) { 1006 + pci_bridge_reconfigure_ltr(pdev); 1007 + pcie_capability_set_word(pdev, PCI_EXP_DEVCTL2, 1008 + PCI_EXP_DEVCTL2_LTR_EN); 1009 + pdev->ltr_path = 1; 1010 + } 1131 1011 } 1132 1012 1133 1013 /* Recheck latencies and update aspm_capable for links under the root */ ··· 1711 1447 { 1712 1448 return aspm_support_enabled; 1713 1449 } 1450 + 1451 + #endif /* CONFIG_PCIEASPM */
+65 -11
drivers/pci/pcie/dpc.c
··· 190 190 static void dpc_process_rp_pio_error(struct pci_dev *pdev) 191 191 { 192 192 u16 cap = pdev->dpc_cap, dpc_status, first_error; 193 - u32 status, mask, sev, syserr, exc, dw0, dw1, dw2, dw3, log, prefix; 193 + u32 status, mask, sev, syserr, exc, log, prefix; 194 + struct pcie_tlp_log tlp_log; 194 195 int i; 195 196 196 197 pci_read_config_dword(pdev, cap + PCI_EXP_DPC_RP_PIO_STATUS, &status); ··· 217 216 218 217 if (pdev->dpc_rp_log_size < 4) 219 218 goto clear_status; 220 - pci_read_config_dword(pdev, cap + PCI_EXP_DPC_RP_PIO_HEADER_LOG, 221 - &dw0); 222 - pci_read_config_dword(pdev, cap + PCI_EXP_DPC_RP_PIO_HEADER_LOG + 4, 223 - &dw1); 224 - pci_read_config_dword(pdev, cap + PCI_EXP_DPC_RP_PIO_HEADER_LOG + 8, 225 - &dw2); 226 - pci_read_config_dword(pdev, cap + PCI_EXP_DPC_RP_PIO_HEADER_LOG + 12, 227 - &dw3); 219 + pcie_read_tlp_log(pdev, cap + PCI_EXP_DPC_RP_PIO_HEADER_LOG, &tlp_log); 228 220 pci_err(pdev, "TLP Header: %#010x %#010x %#010x %#010x\n", 229 - dw0, dw1, dw2, dw3); 221 + tlp_log.dw[0], tlp_log.dw[1], tlp_log.dw[2], tlp_log.dw[3]); 230 222 231 223 if (pdev->dpc_rp_log_size < 5) 232 224 goto clear_status; ··· 228 234 229 235 for (i = 0; i < pdev->dpc_rp_log_size - 5; i++) { 230 236 pci_read_config_dword(pdev, 231 - cap + PCI_EXP_DPC_RP_PIO_TLPPREFIX_LOG, &prefix); 237 + cap + PCI_EXP_DPC_RP_PIO_TLPPREFIX_LOG + i * 4, &prefix); 232 238 pci_err(pdev, "TLP Prefix Header: dw%d, %#010x\n", i, prefix); 233 239 } 234 240 clear_status: ··· 297 303 } 298 304 } 299 305 306 + static void pci_clear_surpdn_errors(struct pci_dev *pdev) 307 + { 308 + if (pdev->dpc_rp_extensions) 309 + pci_write_config_dword(pdev, pdev->dpc_cap + 310 + PCI_EXP_DPC_RP_PIO_STATUS, ~0); 311 + 312 + /* 313 + * In practice, Surprise Down errors have been observed to also set 314 + * error bits in the Status Register as well as the Fatal Error 315 + * Detected bit in the Device Status Register. 316 + */ 317 + pci_write_config_word(pdev, PCI_STATUS, 0xffff); 318 + 319 + pcie_capability_write_word(pdev, PCI_EXP_DEVSTA, PCI_EXP_DEVSTA_FED); 320 + } 321 + 322 + static void dpc_handle_surprise_removal(struct pci_dev *pdev) 323 + { 324 + if (!pcie_wait_for_link(pdev, false)) { 325 + pci_info(pdev, "Data Link Layer Link Active not cleared in 1000 msec\n"); 326 + goto out; 327 + } 328 + 329 + if (pdev->dpc_rp_extensions && dpc_wait_rp_inactive(pdev)) 330 + goto out; 331 + 332 + pci_aer_raw_clear_status(pdev); 333 + pci_clear_surpdn_errors(pdev); 334 + 335 + pci_write_config_word(pdev, pdev->dpc_cap + PCI_EXP_DPC_STATUS, 336 + PCI_EXP_DPC_STATUS_TRIGGER); 337 + 338 + out: 339 + clear_bit(PCI_DPC_RECOVERED, &pdev->priv_flags); 340 + wake_up_all(&dpc_completed_waitqueue); 341 + } 342 + 343 + static bool dpc_is_surprise_removal(struct pci_dev *pdev) 344 + { 345 + u16 status; 346 + 347 + if (!pdev->is_hotplug_bridge) 348 + return false; 349 + 350 + if (pci_read_config_word(pdev, pdev->aer_cap + PCI_ERR_UNCOR_STATUS, 351 + &status)) 352 + return false; 353 + 354 + return status & PCI_ERR_UNC_SURPDN; 355 + } 356 + 300 357 static irqreturn_t dpc_handler(int irq, void *context) 301 358 { 302 359 struct pci_dev *pdev = context; 360 + 361 + /* 362 + * According to PCIe r6.0 sec 6.7.6, errors are an expected side effect 363 + * of async removal and should be ignored by software. 364 + */ 365 + if (dpc_is_surprise_removal(pdev)) { 366 + dpc_handle_surprise_removal(pdev); 367 + return IRQ_HANDLED; 368 + } 303 369 304 370 dpc_process_error(pdev); 305 371
+20
drivers/pci/pcie/err.c
··· 13 13 #define dev_fmt(fmt) "AER: " fmt 14 14 15 15 #include <linux/pci.h> 16 + #include <linux/pm_runtime.h> 16 17 #include <linux/module.h> 17 18 #include <linux/kernel.h> 18 19 #include <linux/errno.h> ··· 83 82 pci_uevent_ers(dev, vote); 84 83 *result = merge_result(*result, vote); 85 84 device_unlock(&dev->dev); 85 + return 0; 86 + } 87 + 88 + static int pci_pm_runtime_get_sync(struct pci_dev *pdev, void *data) 89 + { 90 + pm_runtime_get_sync(&pdev->dev); 91 + return 0; 92 + } 93 + 94 + static int pci_pm_runtime_put(struct pci_dev *pdev, void *data) 95 + { 96 + pm_runtime_put(&pdev->dev); 86 97 return 0; 87 98 } 88 99 ··· 220 207 else 221 208 bridge = pci_upstream_bridge(dev); 222 209 210 + pci_walk_bridge(bridge, pci_pm_runtime_get_sync, NULL); 211 + 223 212 pci_dbg(bridge, "broadcast error_detected message\n"); 224 213 if (state == pci_channel_io_frozen) { 225 214 pci_walk_bridge(bridge, report_frozen_detected, &status); ··· 266 251 pcie_clear_device_status(dev); 267 252 pci_aer_clear_nonfatal_status(dev); 268 253 } 254 + 255 + pci_walk_bridge(bridge, pci_pm_runtime_put, NULL); 256 + 269 257 pci_info(bridge, "device recovery successful\n"); 270 258 return status; 271 259 272 260 failed: 261 + pci_walk_bridge(bridge, pci_pm_runtime_put, NULL); 262 + 273 263 pci_uevent_ers(bridge, PCI_ERS_RESULT_DISCONNECT); 274 264 275 265 /* TODO: Should kernel panic here? */
+1 -1
drivers/pci/pcie/portdrv.h
··· 96 96 int pcie_port_service_register(struct pcie_port_service_driver *new); 97 97 void pcie_port_service_unregister(struct pcie_port_service_driver *new); 98 98 99 - extern struct bus_type pcie_port_bus_type; 99 + extern const struct bus_type pcie_port_bus_type; 100 100 101 101 struct pci_dev; 102 102
+5 -61
drivers/pci/probe.c
··· 2209 2209 } 2210 2210 } 2211 2211 2212 - static void pci_configure_ltr(struct pci_dev *dev) 2213 - { 2214 - #ifdef CONFIG_PCIEASPM 2215 - struct pci_host_bridge *host = pci_find_host_bridge(dev->bus); 2216 - struct pci_dev *bridge; 2217 - u32 cap, ctl; 2218 - 2219 - if (!pci_is_pcie(dev)) 2220 - return; 2221 - 2222 - /* Read L1 PM substate capabilities */ 2223 - dev->l1ss = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_L1SS); 2224 - 2225 - pcie_capability_read_dword(dev, PCI_EXP_DEVCAP2, &cap); 2226 - if (!(cap & PCI_EXP_DEVCAP2_LTR)) 2227 - return; 2228 - 2229 - pcie_capability_read_dword(dev, PCI_EXP_DEVCTL2, &ctl); 2230 - if (ctl & PCI_EXP_DEVCTL2_LTR_EN) { 2231 - if (pci_pcie_type(dev) == PCI_EXP_TYPE_ROOT_PORT) { 2232 - dev->ltr_path = 1; 2233 - return; 2234 - } 2235 - 2236 - bridge = pci_upstream_bridge(dev); 2237 - if (bridge && bridge->ltr_path) 2238 - dev->ltr_path = 1; 2239 - 2240 - return; 2241 - } 2242 - 2243 - if (!host->native_ltr) 2244 - return; 2245 - 2246 - /* 2247 - * Software must not enable LTR in an Endpoint unless the Root 2248 - * Complex and all intermediate Switches indicate support for LTR. 2249 - * PCIe r4.0, sec 6.18. 2250 - */ 2251 - if (pci_pcie_type(dev) == PCI_EXP_TYPE_ROOT_PORT) { 2252 - pcie_capability_set_word(dev, PCI_EXP_DEVCTL2, 2253 - PCI_EXP_DEVCTL2_LTR_EN); 2254 - dev->ltr_path = 1; 2255 - return; 2256 - } 2257 - 2258 - /* 2259 - * If we're configuring a hot-added device, LTR was likely 2260 - * disabled in the upstream bridge, so re-enable it before enabling 2261 - * it in the new device. 2262 - */ 2263 - bridge = pci_upstream_bridge(dev); 2264 - if (bridge && bridge->ltr_path) { 2265 - pci_bridge_reconfigure_ltr(dev); 2266 - pcie_capability_set_word(dev, PCI_EXP_DEVCTL2, 2267 - PCI_EXP_DEVCTL2_LTR_EN); 2268 - dev->ltr_path = 1; 2269 - } 2270 - #endif 2271 - } 2272 - 2273 2212 static void pci_configure_eetlp_prefix(struct pci_dev *dev) 2274 2213 { 2275 2214 #ifdef CONFIG_PCI_PASID ··· 2259 2320 pci_configure_extended_tags(dev, NULL); 2260 2321 pci_configure_relaxed_ordering(dev); 2261 2322 pci_configure_ltr(dev); 2323 + pci_configure_aspm_l1ss(dev); 2262 2324 pci_configure_eetlp_prefix(dev); 2263 2325 pci_configure_serr(dev); 2264 2326 ··· 2296 2356 dev_dbg(dev, "device released\n"); 2297 2357 kfree(pci_dev); 2298 2358 } 2359 + 2360 + static const struct device_type pci_dev_type = { 2361 + .groups = pci_dev_attr_groups, 2362 + }; 2299 2363 2300 2364 struct pci_dev *pci_alloc_dev(struct pci_bus *bus) 2301 2365 {
+11
drivers/pci/quirks.c
··· 3766 3766 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_CAVIUM, 0xa100, quirk_no_bus_reset); 3767 3767 3768 3768 /* 3769 + * Apparently the LSI / Agere FW643 can't recover after a Secondary Bus 3770 + * Reset and requires a power-off or suspend/resume and rescan. Prevent 3771 + * use of that reset. 3772 + */ 3773 + DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_ATT, 0x5900, quirk_no_bus_reset); 3774 + DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_ATT, 0x5901, quirk_no_bus_reset); 3775 + 3776 + /* 3769 3777 * Some TI KeyStone C667X devices do not support bus/hot reset. The PCIESS 3770 3778 * automatically disables LTSSM when Secondary Bus Reset is received and 3771 3779 * the device stops working. Prevent bus reset for these devices. With ··· 5535 5527 5536 5528 pci_walk_bus(bridge->bus, pci_configure_extended_tags, NULL); 5537 5529 } 5530 + DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_3WARE, 0x1004, quirk_no_ext_tags); 5538 5531 DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_SERVERWORKS, 0x0132, quirk_no_ext_tags); 5539 5532 DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_SERVERWORKS, 0x0140, quirk_no_ext_tags); 5540 5533 DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_SERVERWORKS, 0x0141, quirk_no_ext_tags); ··· 6234 6225 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x9a2d, dpc_log_size); 6235 6226 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x9a2f, dpc_log_size); 6236 6227 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x9a31, dpc_log_size); 6228 + DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0xa73f, dpc_log_size); 6229 + DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0xa76e, dpc_log_size); 6237 6230 #endif 6238 6231 6239 6232 /*
-64
drivers/pci/setup-irq.c
··· 1 - // SPDX-License-Identifier: GPL-2.0 2 - /* 3 - * Support routines for initializing a PCI subsystem 4 - * 5 - * Extruded from code written by 6 - * Dave Rusling (david.rusling@reo.mts.dec.com) 7 - * David Mosberger (davidm@cs.arizona.edu) 8 - * David Miller (davem@redhat.com) 9 - */ 10 - 11 - #include <linux/kernel.h> 12 - #include <linux/pci.h> 13 - #include <linux/errno.h> 14 - #include <linux/ioport.h> 15 - #include <linux/cache.h> 16 - #include "pci.h" 17 - 18 - void pci_assign_irq(struct pci_dev *dev) 19 - { 20 - u8 pin; 21 - u8 slot = -1; 22 - int irq = 0; 23 - struct pci_host_bridge *hbrg = pci_find_host_bridge(dev->bus); 24 - 25 - if (!(hbrg->map_irq)) { 26 - pci_dbg(dev, "runtime IRQ mapping not provided by arch\n"); 27 - return; 28 - } 29 - 30 - /* 31 - * If this device is not on the primary bus, we need to figure out 32 - * which interrupt pin it will come in on. We know which slot it 33 - * will come in on because that slot is where the bridge is. Each 34 - * time the interrupt line passes through a PCI-PCI bridge we must 35 - * apply the swizzle function. 36 - */ 37 - pci_read_config_byte(dev, PCI_INTERRUPT_PIN, &pin); 38 - /* Cope with illegal. */ 39 - if (pin > 4) 40 - pin = 1; 41 - 42 - if (pin) { 43 - /* Follow the chain of bridges, swizzling as we go. */ 44 - if (hbrg->swizzle_irq) 45 - slot = (*(hbrg->swizzle_irq))(dev, &pin); 46 - 47 - /* 48 - * If a swizzling function is not used, map_irq() must 49 - * ignore slot. 50 - */ 51 - irq = (*(hbrg->map_irq))(dev, slot, pin); 52 - if (irq == -1) 53 - irq = 0; 54 - } 55 - dev->irq = irq; 56 - 57 - pci_dbg(dev, "assign IRQ: got %d\n", dev->irq); 58 - 59 - /* 60 - * Always tell the device, so the driver knows what is the real IRQ 61 - * to use; the device does not use it. 62 - */ 63 - pci_write_config_byte(dev, PCI_INTERRUPT_LINE, irq); 64 - }
+3 -1
drivers/pci/switch/switchtec.c
··· 1672 1672 rc = switchtec_init_isr(stdev); 1673 1673 if (rc) { 1674 1674 dev_err(&stdev->dev, "failed to init isr.\n"); 1675 - goto err_put; 1675 + goto err_exit_pci; 1676 1676 } 1677 1677 1678 1678 iowrite32(SWITCHTEC_EVENT_CLEAR | ··· 1693 1693 1694 1694 err_devadd: 1695 1695 stdev_kill(stdev); 1696 + err_exit_pci: 1697 + switchtec_exit_pci(stdev); 1696 1698 err_put: 1697 1699 ida_free(&switchtec_minor_ida, MINOR(stdev->dev.devt)); 1698 1700 put_device(&stdev->dev);
+5 -6
include/linux/aer.h
··· 18 18 19 19 struct pci_dev; 20 20 21 - struct aer_header_log_regs { 22 - u32 dw0; 23 - u32 dw1; 24 - u32 dw2; 25 - u32 dw3; 21 + struct pcie_tlp_log { 22 + u32 dw[4]; 26 23 }; 27 24 28 25 struct aer_capability_regs { ··· 30 33 u32 cor_status; 31 34 u32 cor_mask; 32 35 u32 cap_control; 33 - struct aer_header_log_regs header_log; 36 + struct pcie_tlp_log header_log; 34 37 u32 root_command; 35 38 u32 root_status; 36 39 u16 cor_err_source; 37 40 u16 uncor_err_source; 38 41 }; 42 + 43 + int pcie_read_tlp_log(struct pci_dev *dev, int where, struct pcie_tlp_log *log); 39 44 40 45 #if defined(CONFIG_PCIEAER) 41 46 int pci_aer_clear_nonfatal_status(struct pci_dev *dev);
+33 -6
include/linux/pci-epc.h
··· 146 146 }; 147 147 148 148 /** 149 + * @BAR_PROGRAMMABLE: The BAR mask can be configured by the EPC. 150 + * @BAR_FIXED: The BAR mask is fixed by the hardware. 151 + * @BAR_RESERVED: The BAR should not be touched by an EPF driver. 152 + */ 153 + enum pci_epc_bar_type { 154 + BAR_PROGRAMMABLE = 0, 155 + BAR_FIXED, 156 + BAR_RESERVED, 157 + }; 158 + 159 + /** 160 + * struct pci_epc_bar_desc - hardware description for a BAR 161 + * @type: the type of the BAR 162 + * @fixed_size: the fixed size, only applicable if type is BAR_FIXED_MASK. 163 + * @only_64bit: if true, an EPF driver is not allowed to choose if this BAR 164 + * should be configured as 32-bit or 64-bit, the EPF driver must 165 + * configure this BAR as 64-bit. Additionally, the BAR succeeding 166 + * this BAR must be set to type BAR_RESERVED. 167 + * 168 + * only_64bit should not be set on a BAR of type BAR_RESERVED. 169 + * (If BARx is a 64-bit BAR that an EPF driver is not allowed to 170 + * touch, then both BARx and BARx+1 must be set to type 171 + * BAR_RESERVED.) 172 + */ 173 + struct pci_epc_bar_desc { 174 + enum pci_epc_bar_type type; 175 + u64 fixed_size; 176 + bool only_64bit; 177 + }; 178 + 179 + /** 149 180 * struct pci_epc_features - features supported by a EPC device per function 150 181 * @linkup_notifier: indicate if the EPC device can notify EPF driver on link up 151 182 * @core_init_notifier: indicate cores that can notify about their availability 152 183 * for initialization 153 184 * @msi_capable: indicate if the endpoint function has MSI capability 154 185 * @msix_capable: indicate if the endpoint function has MSI-X capability 155 - * @reserved_bar: bitmap to indicate reserved BAR unavailable to function driver 156 - * @bar_fixed_64bit: bitmap to indicate fixed 64bit BARs 157 - * @bar_fixed_size: Array specifying the size supported by each BAR 186 + * @bar: array specifying the hardware description for each BAR 158 187 * @align: alignment size required for BAR buffer allocation 159 188 */ 160 189 struct pci_epc_features { ··· 191 162 unsigned int core_init_notifier : 1; 192 163 unsigned int msi_capable : 1; 193 164 unsigned int msix_capable : 1; 194 - u8 reserved_bar; 195 - u8 bar_fixed_64bit; 196 - u64 bar_fixed_size[PCI_STD_NUM_BARS]; 165 + struct pci_epc_bar_desc bar[PCI_STD_NUM_BARS]; 197 166 size_t align; 198 167 }; 199 168
+3 -1
include/linux/pci-epf.h
··· 15 15 #include <linux/pci.h> 16 16 17 17 struct pci_epf; 18 + struct pci_epc_features; 18 19 enum pci_epc_interface_type; 19 20 20 21 enum pci_barno { ··· 217 216 struct module *owner); 218 217 void pci_epf_unregister_driver(struct pci_epf_driver *driver); 219 218 void *pci_epf_alloc_space(struct pci_epf *epf, size_t size, enum pci_barno bar, 220 - size_t align, enum pci_epc_interface_type type); 219 + const struct pci_epc_features *epc_features, 220 + enum pci_epc_interface_type type); 221 221 void pci_epf_free_space(struct pci_epf *epf, void *addr, enum pci_barno bar, 222 222 enum pci_epc_interface_type type); 223 223 int pci_epf_bind(struct pci_epf *epf);
+1 -1
include/linux/pci.h
··· 390 390 unsigned int d3hot_delay; /* D3hot->D0 transition time in ms */ 391 391 unsigned int d3cold_delay; /* D3cold->D0 transition time in ms */ 392 392 393 + u16 l1ss; /* L1SS Capability pointer */ 393 394 #ifdef CONFIG_PCIEASPM 394 395 struct pcie_link_state *link_state; /* ASPM link state */ 395 - u16 l1ss; /* L1SS Capability pointer */ 396 396 unsigned int ltr_path:1; /* Latency Tolerance Reporting 397 397 supported from root to here */ 398 398 #endif
+5 -5
include/ras/ras_event.h
··· 300 300 const u32 status, 301 301 const u8 severity, 302 302 const u8 tlp_header_valid, 303 - struct aer_header_log_regs *tlp), 303 + struct pcie_tlp_log *tlp), 304 304 305 305 TP_ARGS(dev_name, status, severity, tlp_header_valid, tlp), 306 306 ··· 318 318 __entry->severity = severity; 319 319 __entry->tlp_header_valid = tlp_header_valid; 320 320 if (tlp_header_valid) { 321 - __entry->tlp_header[0] = tlp->dw0; 322 - __entry->tlp_header[1] = tlp->dw1; 323 - __entry->tlp_header[2] = tlp->dw2; 324 - __entry->tlp_header[3] = tlp->dw3; 321 + __entry->tlp_header[0] = tlp->dw[0]; 322 + __entry->tlp_header[1] = tlp->dw[1]; 323 + __entry->tlp_header[2] = tlp->dw[2]; 324 + __entry->tlp_header[3] = tlp->dw[3]; 325 325 } 326 326 ), 327 327
-3
lib/Kconfig
··· 70 70 config NO_GENERIC_PCI_IOPORT_MAP 71 71 bool 72 72 73 - config GENERIC_PCI_IOMAP 74 - bool 75 - 76 73 config GENERIC_IOMAP 77 74 bool 78 75 select GENERIC_PCI_IOMAP
-1
lib/Makefile
··· 152 152 obj-y += math/ crypto/ 153 153 154 154 obj-$(CONFIG_GENERIC_IOMAP) += iomap.o 155 - obj-$(CONFIG_GENERIC_PCI_IOMAP) += pci_iomap.o 156 155 obj-$(CONFIG_HAS_IOMEM) += iomap_copy.o devres.o 157 156 obj-$(CONFIG_CHECK_SIGNATURE) += check_signature.o 158 157 obj-$(CONFIG_DEBUG_LOCKING_API_SELFTESTS) += locking-selftest.o
+1 -207
lib/devres.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0 2 + #include <linux/device.h> 2 3 #include <linux/err.h> 3 - #include <linux/pci.h> 4 4 #include <linux/io.h> 5 5 #include <linux/gfp.h> 6 6 #include <linux/export.h> ··· 310 310 } 311 311 EXPORT_SYMBOL(devm_ioport_unmap); 312 312 #endif /* CONFIG_HAS_IOPORT_MAP */ 313 - 314 - #ifdef CONFIG_PCI 315 - /* 316 - * PCI iomap devres 317 - */ 318 - #define PCIM_IOMAP_MAX PCI_STD_NUM_BARS 319 - 320 - struct pcim_iomap_devres { 321 - void __iomem *table[PCIM_IOMAP_MAX]; 322 - }; 323 - 324 - static void pcim_iomap_release(struct device *gendev, void *res) 325 - { 326 - struct pci_dev *dev = to_pci_dev(gendev); 327 - struct pcim_iomap_devres *this = res; 328 - int i; 329 - 330 - for (i = 0; i < PCIM_IOMAP_MAX; i++) 331 - if (this->table[i]) 332 - pci_iounmap(dev, this->table[i]); 333 - } 334 - 335 - /** 336 - * pcim_iomap_table - access iomap allocation table 337 - * @pdev: PCI device to access iomap table for 338 - * 339 - * Access iomap allocation table for @dev. If iomap table doesn't 340 - * exist and @pdev is managed, it will be allocated. All iomaps 341 - * recorded in the iomap table are automatically unmapped on driver 342 - * detach. 343 - * 344 - * This function might sleep when the table is first allocated but can 345 - * be safely called without context and guaranteed to succeed once 346 - * allocated. 347 - */ 348 - void __iomem * const *pcim_iomap_table(struct pci_dev *pdev) 349 - { 350 - struct pcim_iomap_devres *dr, *new_dr; 351 - 352 - dr = devres_find(&pdev->dev, pcim_iomap_release, NULL, NULL); 353 - if (dr) 354 - return dr->table; 355 - 356 - new_dr = devres_alloc_node(pcim_iomap_release, sizeof(*new_dr), GFP_KERNEL, 357 - dev_to_node(&pdev->dev)); 358 - if (!new_dr) 359 - return NULL; 360 - dr = devres_get(&pdev->dev, new_dr, NULL, NULL); 361 - return dr->table; 362 - } 363 - EXPORT_SYMBOL(pcim_iomap_table); 364 - 365 - /** 366 - * pcim_iomap - Managed pcim_iomap() 367 - * @pdev: PCI device to iomap for 368 - * @bar: BAR to iomap 369 - * @maxlen: Maximum length of iomap 370 - * 371 - * Managed pci_iomap(). Map is automatically unmapped on driver 372 - * detach. 373 - */ 374 - void __iomem *pcim_iomap(struct pci_dev *pdev, int bar, unsigned long maxlen) 375 - { 376 - void __iomem **tbl; 377 - 378 - BUG_ON(bar >= PCIM_IOMAP_MAX); 379 - 380 - tbl = (void __iomem **)pcim_iomap_table(pdev); 381 - if (!tbl || tbl[bar]) /* duplicate mappings not allowed */ 382 - return NULL; 383 - 384 - tbl[bar] = pci_iomap(pdev, bar, maxlen); 385 - return tbl[bar]; 386 - } 387 - EXPORT_SYMBOL(pcim_iomap); 388 - 389 - /** 390 - * pcim_iounmap - Managed pci_iounmap() 391 - * @pdev: PCI device to iounmap for 392 - * @addr: Address to unmap 393 - * 394 - * Managed pci_iounmap(). @addr must have been mapped using pcim_iomap(). 395 - */ 396 - void pcim_iounmap(struct pci_dev *pdev, void __iomem *addr) 397 - { 398 - void __iomem **tbl; 399 - int i; 400 - 401 - pci_iounmap(pdev, addr); 402 - 403 - tbl = (void __iomem **)pcim_iomap_table(pdev); 404 - BUG_ON(!tbl); 405 - 406 - for (i = 0; i < PCIM_IOMAP_MAX; i++) 407 - if (tbl[i] == addr) { 408 - tbl[i] = NULL; 409 - return; 410 - } 411 - WARN_ON(1); 412 - } 413 - EXPORT_SYMBOL(pcim_iounmap); 414 - 415 - /** 416 - * pcim_iomap_regions - Request and iomap PCI BARs 417 - * @pdev: PCI device to map IO resources for 418 - * @mask: Mask of BARs to request and iomap 419 - * @name: Name used when requesting regions 420 - * 421 - * Request and iomap regions specified by @mask. 422 - */ 423 - int pcim_iomap_regions(struct pci_dev *pdev, int mask, const char *name) 424 - { 425 - void __iomem * const *iomap; 426 - int i, rc; 427 - 428 - iomap = pcim_iomap_table(pdev); 429 - if (!iomap) 430 - return -ENOMEM; 431 - 432 - for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) { 433 - unsigned long len; 434 - 435 - if (!(mask & (1 << i))) 436 - continue; 437 - 438 - rc = -EINVAL; 439 - len = pci_resource_len(pdev, i); 440 - if (!len) 441 - goto err_inval; 442 - 443 - rc = pci_request_region(pdev, i, name); 444 - if (rc) 445 - goto err_inval; 446 - 447 - rc = -ENOMEM; 448 - if (!pcim_iomap(pdev, i, 0)) 449 - goto err_region; 450 - } 451 - 452 - return 0; 453 - 454 - err_region: 455 - pci_release_region(pdev, i); 456 - err_inval: 457 - while (--i >= 0) { 458 - if (!(mask & (1 << i))) 459 - continue; 460 - pcim_iounmap(pdev, iomap[i]); 461 - pci_release_region(pdev, i); 462 - } 463 - 464 - return rc; 465 - } 466 - EXPORT_SYMBOL(pcim_iomap_regions); 467 - 468 - /** 469 - * pcim_iomap_regions_request_all - Request all BARs and iomap specified ones 470 - * @pdev: PCI device to map IO resources for 471 - * @mask: Mask of BARs to iomap 472 - * @name: Name used when requesting regions 473 - * 474 - * Request all PCI BARs and iomap regions specified by @mask. 475 - */ 476 - int pcim_iomap_regions_request_all(struct pci_dev *pdev, int mask, 477 - const char *name) 478 - { 479 - int request_mask = ((1 << 6) - 1) & ~mask; 480 - int rc; 481 - 482 - rc = pci_request_selected_regions(pdev, request_mask, name); 483 - if (rc) 484 - return rc; 485 - 486 - rc = pcim_iomap_regions(pdev, mask, name); 487 - if (rc) 488 - pci_release_selected_regions(pdev, request_mask); 489 - return rc; 490 - } 491 - EXPORT_SYMBOL(pcim_iomap_regions_request_all); 492 - 493 - /** 494 - * pcim_iounmap_regions - Unmap and release PCI BARs 495 - * @pdev: PCI device to map IO resources for 496 - * @mask: Mask of BARs to unmap and release 497 - * 498 - * Unmap and release regions specified by @mask. 499 - */ 500 - void pcim_iounmap_regions(struct pci_dev *pdev, int mask) 501 - { 502 - void __iomem * const *iomap; 503 - int i; 504 - 505 - iomap = pcim_iomap_table(pdev); 506 - if (!iomap) 507 - return; 508 - 509 - for (i = 0; i < PCIM_IOMAP_MAX; i++) { 510 - if (!(mask & (1 << i))) 511 - continue; 512 - 513 - pcim_iounmap(pdev, iomap[i]); 514 - pci_release_region(pdev, i); 515 - } 516 - } 517 - EXPORT_SYMBOL(pcim_iounmap_regions); 518 - #endif /* CONFIG_PCI */ 519 313 520 314 static void devm_arch_phys_ac_add_release(struct device *dev, void *res) 521 315 {
+1 -4
lib/pci_iomap.c drivers/pci/iomap.c
··· 9 9 10 10 #include <linux/export.h> 11 11 12 - #ifdef CONFIG_PCI 13 12 /** 14 13 * pci_iomap_range - create a virtual mapping cookie for a PCI BAR 15 14 * @dev: PCI device that owns the BAR ··· 169 170 170 171 if (addr >= start && addr < start + IO_SPACE_LIMIT) 171 172 return; 172 - iounmap(p); 173 173 #endif 174 + iounmap(p); 174 175 } 175 176 EXPORT_SYMBOL(pci_iounmap); 176 177 177 178 #endif /* ARCH_WANTS_GENERIC_PCI_IOUNMAP */ 178 - 179 - #endif /* CONFIG_PCI */