€•hÐŒsphinx.addnodes”Œdocument”“”)”}”(Œ rawsource”Œ”Œchildren”]”(Œ translations”Œ LanguagesNode”“”)”}”(hhh]”(hŒ pending_xref”“”)”}”(hhh]”Œdocutils.nodes”ŒText”“”ŒChinese (Simplified)”…””}”Œparent”hsbaŒ attributes”}”(Œids”]”Œclasses”]”Œnames”]”Œdupnames”]”Œbackrefs”]”Œ refdomain”Œstd”Œreftype”Œdoc”Œ reftarget”Œ9/translations/zh_CN/PCI/controller/pci-controller-drivers”Œmodname”NŒ classname”NŒ refexplicit”ˆuŒtagname”hhh ubh)”}”(hhh]”hŒChinese (Traditional)”…””}”hh2sbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ9/translations/zh_TW/PCI/controller/pci-controller-drivers”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒItalian”…””}”hhFsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ9/translations/it_IT/PCI/controller/pci-controller-drivers”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒJapanese”…””}”hhZsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ9/translations/ja_JP/PCI/controller/pci-controller-drivers”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒKorean”…””}”hhnsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ9/translations/ko_KR/PCI/controller/pci-controller-drivers”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒPortuguese (Brazilian)”…””}”hh‚sbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ9/translations/pt_BR/PCI/controller/pci-controller-drivers”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒSpanish”…””}”hh–sbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ9/translations/sp_SP/PCI/controller/pci-controller-drivers”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubeh}”(h]”h ]”h"]”h$]”h&]”Œcurrent_language”ŒEnglish”uh1h hhŒ _document”hŒsource”NŒline”NubhŒcomment”“”)”}”(hŒ SPDX-License-Identifier: GPL-2.0”h]”hŒ SPDX-License-Identifier: GPL-2.0”…””}”hh·sbah}”(h]”h ]”h"]”h$]”h&]”Œ xml:space”Œpreserve”uh1hµhhh²hh³ŒS/var/lib/git/docbuild/linux/Documentation/PCI/controller/pci-controller-drivers.rst”h´KubhŒsection”“”)”}”(hhh]”(hŒtitle”“”)”}”(hŒ#Writing PCI Host Controller Drivers”h]”hŒ#Writing PCI Host Controller Drivers”…””}”(hhÏh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÍhhÊh²hh³hÇh´KubhŒ field_list”“”)”}”(hhh]”hŒfield”“”)”}”(hhh]”(hŒ field_name”“”)”}”(hŒAuthor”h]”hŒAuthor”…””}”(hhéh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hçhhäh³hÇh´KubhŒ field_body”“”)”}”(hŒ?Manivannan Sadhasivam ”h]”hŒ paragraph”“”)”}”(hŒ>Manivannan Sadhasivam ”h]”(hŒManivannan Sadhasivam <”…””}”(hhÿh²hh³Nh´NubhŒ reference”“”)”}”(hŒ&manivannan.sadhasivam@oss.qualcomm.com”h]”hŒ&manivannan.sadhasivam@oss.qualcomm.com”…””}”(hj h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”Œrefuri”Œ-mailto:manivannan.sadhasivam@oss.qualcomm.com”uh1jhhÿubhŒ>”…””}”(hhÿh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hýh³hÇh´Khhùubah}”(h]”h ]”h"]”h$]”h&]”uh1h÷hhäubeh}”(h]”h ]”h"]”h$]”h&]”uh1hâh³hÇh´Khhßh²hubah}”(h]”h ]”h"]”h$]”h&]”uh1hÝhhÊh²hh³hÇh´KubhÉ)”}”(hhh]”(hÎ)”}”(hŒ Introduction”h]”hŒ Introduction”…””}”(hj8h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÍhj5h²hh³hÇh´K ubhþ)”}”(hŒÓA PCI Host Controller driver controls PCI Root Complex (RC) hardware. The Root Complex hardware comprises a single PCI Host Bridge and one or more Root Port or Root Complex Integrated Endpoint (RCiEP) devices::”h]”hŒÒA PCI Host Controller driver controls PCI Root Complex (RC) hardware. The Root Complex hardware comprises a single PCI Host Bridge and one or more Root Port or Root Complex Integrated Endpoint (RCiEP) devices:”…””}”(hjFh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hýh³hÇh´K hj5h²hubhŒ literal_block”“”)”}”(hX +------------------+ | CPU | +------------------+ | +--------------------------------------------+ | | Root | | +------------------+ Complex | | | Host Bridge | | | +------------------+ | | | | | Bus 0 | | | +------------|----------+ | | | | | | | +----------+ +----------+ +-------+ | | | Root | | Root | | RCiEP | | | | Port | | Port | +-------+ | | +----------+ +----------+ | | | | | | Bus 1 | Bus 2 | | | | | | +-------|-------------|----------------------+ | | +-----------+ +-----------+ | Endpoint | | Endpoint | +-----------+ +-----------+”h]”hX +------------------+ | CPU | +------------------+ | +--------------------------------------------+ | | Root | | +------------------+ Complex | | | Host Bridge | | | +------------------+ | | | | | Bus 0 | | | +------------|----------+ | | | | | | | +----------+ +----------+ +-------+ | | | Root | | Root | | RCiEP | | | | Port | | Port | +-------+ | | +----------+ +----------+ | | | | | | Bus 1 | Bus 2 | | | | | | +-------|-------------|----------------------+ | | +-----------+ +-----------+ | Endpoint | | Endpoint | +-----------+ +-----------+”…””}”hjVsbah}”(h]”h ]”h"]”h$]”h&]”hÅhÆuh1jTh³hÇh´Khj5h²hubhþ)”}”(hŒ9Host Bridge: Used to connect CPU(s) to the PCI hierarchy.”h]”hŒ9Host Bridge: Used to connect CPU(s) to the PCI hierarchy.”…””}”(hjdh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hýh³hÇh´K*hj5h²hubhþ)”}”(hŒJRoot Port: Virtual PCI-PCI bridge connecting the Host Bridge to a PCI bus.”h]”hŒJRoot Port: Virtual PCI-PCI bridge connecting the Host Bridge to a PCI bus.”…””}”(hjrh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hýh³hÇh´K,hj5h²hubhþ)”}”(hŒORCiEP: Embedded PCIe Endpoint inside Root Complex connected to the Host Bridge.”h]”hŒORCiEP: Embedded PCIe Endpoint inside Root Complex connected to the Host Bridge.”…””}”(hj€h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hýh³hÇh´K.hj5h²hubhþ)”}”(hŒ>Endpoint: PCIe device connected to a Root Port through a Link.”h]”hŒ>Endpoint: PCIe device connected to a Root Port through a Link.”…””}”(hjŽh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hýh³hÇh´K1hj5h²hubeh}”(h]”Œ introduction”ah ]”h"]”Œ introduction”ah$]”h&]”uh1hÈhhÊh²hh³hÇh´K ubhÉ)”}”(hhh]”(hÎ)”}”(hŒ Enumeration”h]”hŒ Enumeration”…””}”(hj§h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÍhj¤h²hh³hÇh´K4ubhþ)”}”(hŒÿThe Host Bridge device is not discoverable, so it is typically enumerated with the help of firmware interfaces like ACPI or Devicetree. But the Root Port and RCiEP devices are discoverable through the standard enumeration process defined in the PCIe spec.”h]”hŒÿThe Host Bridge device is not discoverable, so it is typically enumerated with the help of firmware interfaces like ACPI or Devicetree. But the Root Port and RCiEP devices are discoverable through the standard enumeration process defined in the PCIe spec.”…””}”(hjµh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hýh³hÇh´K6hj¤h²hubhþ)”}”(hXA Host Controller driver usually configures both Host Bridge and Root Port(s) based on platform requirements. In the case of ACPI on standardized platforms (e.g. x86), no platform-specific host controller driver is required as the firmware configures the Root Complex before OS boot and exposes the resource information through ACPI tables. For more info, refer to :doc:`../acpi-info`.”h]”(hXmA Host Controller driver usually configures both Host Bridge and Root Port(s) based on platform requirements. In the case of ACPI on standardized platforms (e.g. x86), no platform-specific host controller driver is required as the firmware configures the Root Complex before OS boot and exposes the resource information through ACPI tables. For more info, refer to ”…””}”(hjÃh²hh³Nh´Nubh)”}”(hŒ:doc:`../acpi-info`”h]”hŒinline”“”)”}”(hjÍh]”hŒ ../acpi-info”…””}”(hjÑh²hh³Nh´Nubah}”(h]”h ]”(Œxref”Œstd”Œstd-doc”eh"]”h$]”h&]”uh1jÏhjËubah}”(h]”h ]”h"]”h$]”h&]”Œrefdoc”Œ%PCI/controller/pci-controller-drivers”Œ refdomain”jÜŒreftype”Œdoc”Œ refexplicit”‰Œrefwarn”ˆŒ reftarget”Œ ../acpi-info”uh1hh³hÇh´K;hjÃubhŒ.”…””}”(hjÃh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hýh³hÇh´K;hj¤h²hubhþ)”}”(hX„For Devicetree platforms, a dedicated host controller driver is often required because the Root Complex hardware typically needs vendor-specific initialization like PHY, clocks, power domains, and there is no standard mechanism equivalent to ACPI/MCFG to convey resource information to the OS. So on these platforms, Root Complex hardware is enumerated through Devicetree nodes as below::”h]”hXƒFor Devicetree platforms, a dedicated host controller driver is often required because the Root Complex hardware typically needs vendor-specific initialization like PHY, clocks, power domains, and there is no standard mechanism equivalent to ACPI/MCFG to convey resource information to the OS. So on these platforms, Root Complex hardware is enumerated through Devicetree nodes as below:”…””}”(hjúh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hýh³hÇh´KBhj¤h²hubjU)”}”(hX×pcie@10000000 { compatible = "vendor,soc-pcie"; reg = <0x0 0x10000000 0x0 0x1000>, <0x0 0x10001000 0x0 0x1000>; reg-names = "cfg", "app"; device_type = "pci"; bus-range = <0x00 0xff>; linux,pci-domain = <0>; num-lanes = <4>; #address-cells = <3>; #size-cells = <2>; ranges = <0x01000000 0x0 0x00000000 0x0 0x20000000 0x0 0x00100000>, <0x02000000 0x0 0x20100000 0x0 0x20100000 0x0 0x1ff00000>; dma-ranges = <0x02000000 0x0 0x0 0x0 0x0 0x0 0x80000000>; clocks = <&clkc PCIE_CORE_CLK>, <&clkc PCIE_AUX_CLK>; clock-names = "core", "aux"; resets = <&reset PCIE_RESET>; power-domains = <&power PCIE_PD>; #interrupt-cells = <1>; interrupt-map-mask = <0 0 0 0x7>; interrupt-map = <0 0 0 1 &gic 0 0 GIC_SPI 100 IRQ_TYPE_LEVEL_HIGH>, <0 0 0 2 &gic 0 0 GIC_SPI 101 IRQ_TYPE_LEVEL_HIGH>, <0 0 0 3 &gic 0 0 GIC_SPI 102 IRQ_TYPE_LEVEL_HIGH>, <0 0 0 4 &gic 0 0 GIC_SPI 103 IRQ_TYPE_LEVEL_HIGH>; interrupts = ; interrupt-names = "msi"; pcie@0 { compatible = "pciclass,0604"; device_type = "pci"; reg = <0x0 0x0 0x0 0x0 0x0>; bus-range = <0x01 0xff>; #address-cells = <3>; #size-cells = <2>; ranges; phys = <&pcie_phy>; reset-gpios = <&gpio 10 GPIO_ACTIVE_LOW>; wake-gpios = <&gpio 11 GPIO_ACTIVE_LOW>; }; };”h]”hX×pcie@10000000 { compatible = "vendor,soc-pcie"; reg = <0x0 0x10000000 0x0 0x1000>, <0x0 0x10001000 0x0 0x1000>; reg-names = "cfg", "app"; device_type = "pci"; bus-range = <0x00 0xff>; linux,pci-domain = <0>; num-lanes = <4>; #address-cells = <3>; #size-cells = <2>; ranges = <0x01000000 0x0 0x00000000 0x0 0x20000000 0x0 0x00100000>, <0x02000000 0x0 0x20100000 0x0 0x20100000 0x0 0x1ff00000>; dma-ranges = <0x02000000 0x0 0x0 0x0 0x0 0x0 0x80000000>; clocks = <&clkc PCIE_CORE_CLK>, <&clkc PCIE_AUX_CLK>; clock-names = "core", "aux"; resets = <&reset PCIE_RESET>; power-domains = <&power PCIE_PD>; #interrupt-cells = <1>; interrupt-map-mask = <0 0 0 0x7>; interrupt-map = <0 0 0 1 &gic 0 0 GIC_SPI 100 IRQ_TYPE_LEVEL_HIGH>, <0 0 0 2 &gic 0 0 GIC_SPI 101 IRQ_TYPE_LEVEL_HIGH>, <0 0 0 3 &gic 0 0 GIC_SPI 102 IRQ_TYPE_LEVEL_HIGH>, <0 0 0 4 &gic 0 0 GIC_SPI 103 IRQ_TYPE_LEVEL_HIGH>; interrupts = ; interrupt-names = "msi"; pcie@0 { compatible = "pciclass,0604"; device_type = "pci"; reg = <0x0 0x0 0x0 0x0 0x0>; bus-range = <0x01 0xff>; #address-cells = <3>; #size-cells = <2>; ranges; phys = <&pcie_phy>; reset-gpios = <&gpio 10 GPIO_ACTIVE_LOW>; wake-gpios = <&gpio 11 GPIO_ACTIVE_LOW>; }; };”…””}”hjsbah}”(h]”h ]”h"]”h$]”h&]”hÅhÆuh1jTh³hÇh´KIhj¤h²hubhþ)”}”(hX¤Note the presence of two nodes in the above example. The ``pcie@10000000`` node represents a PCI Host Bridge device, and ``pcie@0`` represents a single Root Port device. The Host Bridge node should contain properties associated with the Host Bridge device such as ranges, interrupts, clocks, power-domains etc... and the Root Port node should contain port-specific properties such as phys, reset-gpios, wake-gpios etc...”h]”(hŒ9Note the presence of two nodes in the above example. The ”…””}”(hjh²hh³Nh´NubhŒliteral”“”)”}”(hŒ``pcie@10000000``”h]”hŒ pcie@10000000”…””}”(hj h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjubhŒ/ node represents a PCI Host Bridge device, and ”…””}”(hjh²hh³Nh´Nubj)”}”(hŒ ``pcie@0``”h]”hŒpcie@0”…””}”(hj2h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjubhX! represents a single Root Port device. The Host Bridge node should contain properties associated with the Host Bridge device such as ranges, interrupts, clocks, power-domains etc... and the Root Port node should contain port-specific properties such as phys, reset-gpios, wake-gpios etc...”…””}”(hjh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hýh³hÇh´Kzhj¤h²hubhþ)”}”(hŒ‚NOTE: Legacy Devicetrees used a single node to describe both Host Bridge and Root Port devices, but that design is now deprecated.”h]”hŒ‚NOTE: Legacy Devicetrees used a single node to describe both Host Bridge and Root Port devices, but that design is now deprecated.”…””}”(hjJh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hýh³hÇh´Khj¤h²hubeh}”(h]”Œ enumeration”ah ]”h"]”Œ enumeration”ah$]”h&]”uh1hÈhhÊh²hh³hÇh´K4ubhÉ)”}”(hhh]”(hÎ)”}”(hŒ Driver Design”h]”hŒ Driver Design”…””}”(hjch²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÍhj`h²hh³hÇh´K…ubhÉ)”}”(hhh]”(hÎ)”}”(hŒ Prerequisites”h]”hŒ Prerequisites”…””}”(hjth²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÍhjqh²hh³hÇh´Kˆubhþ)”}”(hX>Before starting to write a new Host Controller driver, check if any of the existing drivers can be reused. For example, if the Root Complex supports the Enhanced Configuration Access Mechanism (ECAM) and the bootloader has configured the ECAM mapping before OS boot, the ``CONFIG_PCI_HOST_GENERIC`` driver can be used.”h]”(hXBefore starting to write a new Host Controller driver, check if any of the existing drivers can be reused. For example, if the Root Complex supports the Enhanced Configuration Access Mechanism (ECAM) and the bootloader has configured the ECAM mapping before OS boot, the ”…””}”(hj‚h²hh³Nh´Nubj)”}”(hŒ``CONFIG_PCI_HOST_GENERIC``”h]”hŒCONFIG_PCI_HOST_GENERIC”…””}”(hjŠh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhj‚ubhŒ driver can be used.”…””}”(hj‚h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hýh³hÇh´KŠhjqh²hubhþ)”}”(hXIf the Root Complex hardware (IP) is from IP vendors such as Synopsys or Cadence, the existing ``CONFIG_PCIE_DW_PLAT_HOST`` and ``CONFIG_PCIE_CADENCE_PLAT_HOST`` drivers can be reused. If not, then check if any of the existing glue drivers available for these IPs could be reused.”h]”(hŒ_If the Root Complex hardware (IP) is from IP vendors such as Synopsys or Cadence, the existing ”…””}”(hj¢h²hh³Nh´Nubj)”}”(hŒ``CONFIG_PCIE_DW_PLAT_HOST``”h]”hŒCONFIG_PCIE_DW_PLAT_HOST”…””}”(hjªh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhj¢ubhŒ and ”…””}”(hj¢h²hh³Nh´Nubj)”}”(hŒ!``CONFIG_PCIE_CADENCE_PLAT_HOST``”h]”hŒCONFIG_PCIE_CADENCE_PLAT_HOST”…””}”(hj¼h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhj¢ubhŒw drivers can be reused. If not, then check if any of the existing glue drivers available for these IPs could be reused.”…””}”(hj¢h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hýh³hÇh´Khjqh²hubhþ)”}”(hŒóIf the Root Complex hardware is designed in-house by the SoC vendor, check if there is an existing driver from the vendor for their previous generation Root Complex hardware. Often, the existing driver can be reused with minimal modifications.”h]”hŒóIf the Root Complex hardware is designed in-house by the SoC vendor, check if there is an existing driver from the vendor for their previous generation Root Complex hardware. Often, the existing driver can be reused with minimal modifications.”…””}”(hjÔh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hýh³hÇh´K–hjqh²hubhþ)”}”(hŒlOnly if the Root Complex doesn't satisfy above prerequisites should a new Host Controller driver be written.”h]”hŒnOnly if the Root Complex doesn’t satisfy above prerequisites should a new Host Controller driver be written.”…””}”(hjâh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hýh³hÇh´K›hjqh²hubeh}”(h]”Œ prerequisites”ah ]”h"]”Œ prerequisites”ah$]”h&]”uh1hÈhj`h²hh³hÇh´KˆubhÉ)”}”(hhh]”(hÎ)”}”(hŒProbe”h]”hŒProbe”…””}”(hjûh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÍhjøh²hh³hÇh´KŸubhþ)”}”(hŒ«During the Host Controller driver probe(), it initializes the Root Complex hardware and registers the Host Bridge with the PCI core. The typical steps are described below.”h]”hŒ«During the Host Controller driver probe(), it initializes the Root Complex hardware and registers the Host Bridge with the PCI core. The typical steps are described below.”…””}”(hj h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hýh³hÇh´K¡hjøh²hubhÉ)”}”(hhh]”(hÎ)”}”(hŒInitialize Resources”h]”hŒInitialize Resources”…””}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÍhjh²hh³hÇh´K¦ubhþ)”}”(hŒøAt the start of the probe(), initialize Host Bridge-specific resources such as clocks, PHYs, regulators, and resets. These resources are described in the Host Bridge Devicetree node and should be brought up before accessing the controller hardware.”h]”hŒøAt the start of the probe(), initialize Host Bridge-specific resources such as clocks, PHYs, regulators, and resets. These resources are described in the Host Bridge Devicetree node and should be brought up before accessing the controller hardware.”…””}”(hj(h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hýh³hÇh´K¨hjh²hubhþ)”}”(hŒˆNOTE: Use the devm_*() managed APIs wherever possible so the resources are released automatically on probe failure and on driver detach.”h]”hŒˆNOTE: Use the devm_*() managed APIs wherever possible so the resources are released automatically on probe failure and on driver detach.”…””}”(hj6h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hýh³hÇh´K­hjh²hubeh}”(h]”Œinitialize-resources”ah ]”h"]”Œinitialize resources”ah$]”h&]”uh1hÈhjøh²hh³hÇh´K¦ubhÉ)”}”(hhh]”(hÎ)”}”(hŒConfiguration Space Access”h]”hŒConfiguration Space Access”…””}”(hjOh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÍhjLh²hh³hÇh´K±ubhþ)”}”(hXThe PCI core accesses the Configuration Space of the enumerated devices through the callbacks provided by the driver in struct pci_ops. These callbacks abstract how the Root Complex generates a Configuration Request for a given Bus, Device and Function number.”h]”hXThe PCI core accesses the Configuration Space of the enumerated devices through the callbacks provided by the driver in struct pci_ops. These callbacks abstract how the Root Complex generates a Configuration Request for a given Bus, Device and Function number.”…””}”(hj]h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hýh³hÇh´K³hjLh²hubhþ)”}”(hXIf the Root Complex supports ECAM, the generic accessors can be reused by using pci_ecam_map_bus() along with pci_generic_config_read() and pci_generic_config_write(). Such drivers can often be built on top of pci_host_common_probe() without providing any custom accessors.”h]”hXIf the Root Complex supports ECAM, the generic accessors can be reused by using pci_ecam_map_bus() along with pci_generic_config_read() and pci_generic_config_write(). Such drivers can often be built on top of pci_host_common_probe() without providing any custom accessors.”…””}”(hjkh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hýh³hÇh´K¸hjLh²hubeh}”(h]”Œconfiguration-space-access”ah ]”h"]”Œconfiguration space access”ah$]”h&]”uh1hÈhjøh²hh³hÇh´K±ubhÉ)”}”(hhh]”(hÎ)”}”(hŒSetup Address Translation”h]”hŒSetup Address Translation”…””}”(hj„h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÍhjh²hh³hÇh´K¾ubhþ)”}”(hŒqThe Host Bridge translates accesses between the CPU address domain and the PCI address domain in both directions:”h]”hŒqThe Host Bridge translates accesses between the CPU address domain and the PCI address domain in both directions:”…””}”(hj’h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hýh³hÇh´KÀhjh²hubhŒ bullet_list”“”)”}”(hhh]”(hŒ list_item”“”)”}”(hŒìOutbound: CPU addresses are translated to PCI bus addresses for the Memory and I/O accesses initiated by the CPU towards the downstream devices. These windows are derived from the ``ranges`` property of the Host Bridge Devicetree node. ”h]”hþ)”}”(hŒëOutbound: CPU addresses are translated to PCI bus addresses for the Memory and I/O accesses initiated by the CPU towards the downstream devices. These windows are derived from the ``ranges`` property of the Host Bridge Devicetree node.”h]”(hŒ´Outbound: CPU addresses are translated to PCI bus addresses for the Memory and I/O accesses initiated by the CPU towards the downstream devices. These windows are derived from the ”…””}”(hj«h²hh³Nh´Nubj)”}”(hŒ ``ranges``”h]”hŒranges”…””}”(hj³h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhj«ubhŒ- property of the Host Bridge Devicetree node.”…””}”(hj«h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hýh³hÇh´KÃhj§ubah}”(h]”h ]”h"]”h$]”h&]”uh1j¥hj¢h²hh³hÇh´Nubj¦)”}”(hŒÅInbound: PCI bus addresses are translated to system memory addresses for the accesses (such as DMA) initiated by the downstream devices. These windows are derived from the ``dma-ranges`` property. ”h]”hþ)”}”(hŒÄInbound: PCI bus addresses are translated to system memory addresses for the accesses (such as DMA) initiated by the downstream devices. These windows are derived from the ``dma-ranges`` property.”h]”(hŒ¬Inbound: PCI bus addresses are translated to system memory addresses for the accesses (such as DMA) initiated by the downstream devices. These windows are derived from the ”…””}”(hjÕh²hh³Nh´Nubj)”}”(hŒ``dma-ranges``”h]”hŒ dma-ranges”…””}”(hjÝh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjÕubhŒ property.”…””}”(hjÕh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hýh³hÇh´KÈhjÑubah}”(h]”h ]”h"]”h$]”h&]”uh1j¥hj¢h²hh³hÇh´Nubeh}”(h]”h ]”h"]”h$]”h&]”Œbullet”Œ-”uh1j h³hÇh´KÃhjh²hubhþ)”}”(hX,The PCI core parses ``ranges`` and ``dma-ranges`` into the Host Bridge resource lists, and the driver programs one translation window per entry. Note that the CPU address and the PCI bus address of a window may differ, so the offset between them has to be accounted for while programming the windows.”h]”(hŒThe PCI core parses ”…””}”(hjh²hh³Nh´Nubj)”}”(hŒ ``ranges``”h]”hŒranges”…””}”(hj h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjubhŒ and ”…””}”(hjh²hh³Nh´Nubj)”}”(hŒ``dma-ranges``”h]”hŒ dma-ranges”…””}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjubhŒû into the Host Bridge resource lists, and the driver programs one translation window per entry. Note that the CPU address and the PCI bus address of a window may differ, so the offset between them has to be accounted for while programming the windows.”…””}”(hjh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hýh³hÇh´KÌhjh²hubhþ)”}”(hŒ¸NOTE: If the hardware supports ECAM, it is strongly recommended to use ECAM for the Configuration Space so a translation window need not be reprogrammed for every Configuration access.”h]”hŒ¸NOTE: If the hardware supports ECAM, it is strongly recommended to use ECAM for the Configuration Space so a translation window need not be reprogrammed for every Configuration access.”…””}”(hj5h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hýh³hÇh´KÒhjh²hubeh}”(h]”Œsetup-address-translation”ah ]”h"]”Œsetup address translation”ah$]”h&]”uh1hÈhjøh²hh³hÇh´K¾ubhÉ)”}”(hhh]”(hÎ)”}”(hŒInterrupt Handling”h]”hŒInterrupt Handling”…””}”(hjNh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÍhjKh²hh³hÇh´K×ubhþ)”}”(hŒ·Downstream devices can signal interrupts either through INTx or through Message Signaled Interrupts (MSI/MSI-X). The driver has to enable the mechanisms supported by the Root Complex.”h]”hŒ·Downstream devices can signal interrupts either through INTx or through Message Signaled Interrupts (MSI/MSI-X). The driver has to enable the mechanisms supported by the Root Complex.”…””}”(hj\h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hýh³hÇh´KÙhjKh²hubhþ)”}”(hX+INTx interrupts are conveyed to the Root Complex through the Assert_INTx and Deassert_INTx messages and are then reported as system interrupts. The driver typically creates an IRQ domain for the four interrupts (INTA to INTD) and demultiplexes an incoming interrupt to the corresponding virtual IRQ.”h]”hX+INTx interrupts are conveyed to the Root Complex through the Assert_INTx and Deassert_INTx messages and are then reported as system interrupts. The driver typically creates an IRQ domain for the four interrupts (INTA to INTD) and demultiplexes an incoming interrupt to the corresponding virtual IRQ.”…””}”(hjjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hýh³hÇh´KÝhjKh²hubhþ)”}”(hŒŠAn MSI/MSI-X is signaled by the downstream device as a Memory Write to a Root Complex-specific address. There are two ways to handle them:”h]”hŒŠAn MSI/MSI-X is signaled by the downstream device as a Memory Write to a Root Complex-specific address. There are two ways to handle them:”…””}”(hjxh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hýh³hÇh´KãhjKh²hubj¡)”}”(hhh]”(j¦)”}”(hŒñIf the Root Complex integrates its own MSI controller, the driver has to create an MSI IRQ domain, program the MSI target address and demultiplex the incoming MSIs to the corresponding virtual IRQs. MSI-X is handled through the same domain. ”h]”hþ)”}”(hŒðIf the Root Complex integrates its own MSI controller, the driver has to create an MSI IRQ domain, program the MSI target address and demultiplex the incoming MSIs to the corresponding virtual IRQs. MSI-X is handled through the same domain.”h]”hŒðIf the Root Complex integrates its own MSI controller, the driver has to create an MSI IRQ domain, program the MSI target address and demultiplex the incoming MSIs to the corresponding virtual IRQs. MSI-X is handled through the same domain.”…””}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hýh³hÇh´Kæhj‰ubah}”(h]”h ]”h"]”h$]”h&]”uh1j¥hj†h²hh³hÇh´Nubj¦)”}”(hŒÓIf the MSIs are handled by an external interrupt controller (such as the GIC ITS), the Root Complex Devicetree node needs to have an ``msi-parent`` property and the driver need not implement an MSI controller. ”h]”hþ)”}”(hŒÑIf the MSIs are handled by an external interrupt controller (such as the GIC ITS), the Root Complex Devicetree node needs to have an ``msi-parent`` property and the driver need not implement an MSI controller.”h]”(hŒ…If the MSIs are handled by an external interrupt controller (such as the GIC ITS), the Root Complex Devicetree node needs to have an ”…””}”(hj¥h²hh³Nh´Nubj)”}”(hŒ``msi-parent``”h]”hŒ msi-parent”…””}”(hj­h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhj¥ubhŒ> property and the driver need not implement an MSI controller.”…””}”(hj¥h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hýh³hÇh´Këhj¡ubah}”(h]”h ]”h"]”h$]”h&]”uh1j¥hj†h²hh³hÇh´Nubeh}”(h]”h ]”h"]”h$]”h&]”jjuh1j h³hÇh´KæhjKh²hubeh}”(h]”Œinterrupt-handling”ah ]”h"]”Œinterrupt handling”ah$]”h&]”uh1hÈhjøh²hh³hÇh´K×ubhÉ)”}”(hhh]”(hÎ)”}”(hŒPowering up the Slot/Endpoint”h]”hŒPowering up the Slot/Endpoint”…””}”(hjÜh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÍhjÙh²hh³hÇh´Kòubhþ)”}”(hXPower ON any slots or Endpoints connected to the bus with the help of the PWRCTRL subsystem APIs such as pci_pwrctrl_create_devices() and pci_pwrctrl_power_on_devices(). Note that this requires defining the supplies in the Root Port or Endpoint Devicetree node.”h]”hXPower ON any slots or Endpoints connected to the bus with the help of the PWRCTRL subsystem APIs such as pci_pwrctrl_create_devices() and pci_pwrctrl_power_on_devices(). Note that this requires defining the supplies in the Root Port or Endpoint Devicetree node.”…””}”(hjêh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hýh³hÇh´KôhjÙh²hubeh}”(h]”Œpowering-up-the-slot-endpoint”ah ]”h"]”Œpowering up the slot/endpoint”ah$]”h&]”uh1hÈhjøh²hh³hÇh´KòubhÉ)”}”(hhh]”(hÎ)”}”(hŒ Link Training”h]”hŒ Link Training”…””}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÍhjh²hh³hÇh´Kúubhþ)”}”(hX'Once the resources are initialized, the driver has to initiate Link training by enabling the LTSSM (Link Training and Status State Machine) of the Root Port. If a PERST# signal is present, it should be deasserted to bring the downstream device out of fundamental reset before enabling the LTSSM.”h]”hX'Once the resources are initialized, the driver has to initiate Link training by enabling the LTSSM (Link Training and Status State Machine) of the Root Port. If a PERST# signal is present, it should be deasserted to bring the downstream device out of fundamental reset before enabling the LTSSM.”…””}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hýh³hÇh´Kühjh²hubhþ)”}”(hXnBefore PERST# is deasserted, the driver must satisfy the power sequencing delays defined by the PCI Express Card Electromechanical (CEM) Specification. The power supplies must be stable for at least T_PVPERL (``PCIE_T_PVPERL_MS``, 100 ms) and the reference clock must be stable for at least T_PERST-CLK (``PCIE_T_PERST_CLK_US``, 100 us) before PERST# is deasserted.”h]”(hŒÒBefore PERST# is deasserted, the driver must satisfy the power sequencing delays defined by the PCI Express Card Electromechanical (CEM) Specification. The power supplies must be stable for at least T_PVPERL (”…””}”(hjh²hh³Nh´Nubj)”}”(hŒ``PCIE_T_PVPERL_MS``”h]”hŒPCIE_T_PVPERL_MS”…””}”(hj'h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjubhŒK, 100 ms) and the reference clock must be stable for at least T_PERST-CLK (”…””}”(hjh²hh³Nh´Nubj)”}”(hŒ``PCIE_T_PERST_CLK_US``”h]”hŒPCIE_T_PERST_CLK_US”…””}”(hj9h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjubhŒ&, 100 us) before PERST# is deasserted.”…””}”(hjh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hýh³hÇh´Mhjh²hubhþ)”}”(hŒˆAfter the LTSSM is enabled, the driver should wait (with a timeout) for the LTSSM to reach the L0 state, indicating that the Link is up.”h]”hŒˆAfter the LTSSM is enabled, the driver should wait (with a timeout) for the LTSSM to reach the L0 state, indicating that the Link is up.”…””}”(hjQh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hýh³hÇh´M hjh²hubhþ)”}”(hXøOnce the Link is up, the PCI Express Base Specification (Conventional Reset) requires software to wait for at least ``PCIE_RESET_CONFIG_WAIT_MS`` (100 ms) before sending the first Configuration Request to the downstream device. For a Link operating up to 5.0 GT/s, this delay is counted from the exit of the Conventional Reset (PERST# deassertion), while for a Link operating above 5.0 GT/s it is counted from the completion of Link training. The driver should honor this delay before the bus is scanned.”h]”(hŒtOnce the Link is up, the PCI Express Base Specification (Conventional Reset) requires software to wait for at least ”…””}”(hj_h²hh³Nh´Nubj)”}”(hŒ``PCIE_RESET_CONFIG_WAIT_MS``”h]”hŒPCIE_RESET_CONFIG_WAIT_MS”…””}”(hjgh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhj_ubhXg (100 ms) before sending the first Configuration Request to the downstream device. For a Link operating up to 5.0 GT/s, this delay is counted from the exit of the Conventional Reset (PERST# deassertion), while for a Link operating above 5.0 GT/s it is counted from the completion of Link training. The driver should honor this delay before the bus is scanned.”…””}”(hj_h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hýh³hÇh´M hjh²hubhþ)”}”(hX6NOTE: A failure to establish the Link should NOT be treated as a probe failure unless the Root Port is not Hotplug capable. If the Root Port is Hotplug capable, then the driver should still register the Host Bridge and scan the bus, so that the downstream device can be discovered later when the Link comes up.”h]”hX6NOTE: A failure to establish the Link should NOT be treated as a probe failure unless the Root Port is not Hotplug capable. If the Root Port is Hotplug capable, then the driver should still register the Host Bridge and scan the bus, so that the downstream device can be discovered later when the Link comes up.”…””}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hýh³hÇh´Mhjh²hubeh}”(h]”Œ link-training”ah ]”h"]”Œ link training”ah$]”h&]”uh1hÈhjøh²hh³hÇh´KúubhÉ)”}”(hhh]”(hÎ)”}”(hŒRegister the Host Bridge”h]”hŒRegister the Host Bridge”…””}”(hj˜h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÍhj•h²hh³hÇh´Mubhþ)”}”(hXzFinally, allocate the Host Bridge device with devm_pci_alloc_host_bridge(), assign the Configuration Space accessors (struct pci_ops) to it, and start the bus scan by calling pci_host_probe(). This is the last step of the probe(). pci_host_probe() creates the Root bus for the Host Bridge and scans/enumerates all the Root Port, RCiEP and Endpoint devices connected to the bus.”h]”hXzFinally, allocate the Host Bridge device with devm_pci_alloc_host_bridge(), assign the Configuration Space accessors (struct pci_ops) to it, and start the bus scan by calling pci_host_probe(). This is the last step of the probe(). pci_host_probe() creates the Root bus for the Host Bridge and scans/enumerates all the Root Port, RCiEP and Endpoint devices connected to the bus.”…””}”(hj¦h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hýh³hÇh´Mhj•h²hubhþ)”}”(hŒˆIf the Root Complex IP is from a known IP vendor, the IP specific helpers should be reused for the above operations wherever applicable.”h]”hŒˆIf the Root Complex IP is from a known IP vendor, the IP specific helpers should be reused for the above operations wherever applicable.”…””}”(hj´h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hýh³hÇh´M$hj•h²hubeh}”(h]”Œregister-the-host-bridge”ah ]”h"]”Œregister the host bridge”ah$]”h&]”uh1hÈhjøh²hh³hÇh´Mubeh}”(h]”Œprobe”ah ]”h"]”Œprobe”ah$]”h&]”uh1hÈhj`h²hh³hÇh´KŸubhÉ)”}”(hhh]”(hÎ)”}”(hŒPower Management”h]”hŒPower Management”…””}”(hjÕh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÍhjÒh²hh³hÇh´M(ubhþ)”}”(hŒøA Host Controller driver participates in both runtime and system-wide power management. In both cases, the driver is responsible for the power state of the Root Complex hardware, while the PCI core manages the power state of the enumerated devices.”h]”hŒøA Host Controller driver participates in both runtime and system-wide power management. In both cases, the driver is responsible for the power state of the Root Complex hardware, while the PCI core manages the power state of the enumerated devices.”…””}”(hjãh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hýh³hÇh´M*hjÒh²hubhÉ)”}”(hhh]”(hÎ)”}”(hŒ Runtime PM”h]”hŒ Runtime PM”…””}”(hjôh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÍhjñh²hh³hÇh´M0ubhþ)”}”(hX1Runtime PM allows the Root Complex hardware to be powered down when it is idle. The driver typically enables runtime PM with pm_runtime_enable() and takes a reference with pm_runtime_get_sync() during probe(), so that the controller stays powered while it is in use. The reference is dropped in remove().”h]”hX1Runtime PM allows the Root Complex hardware to be powered down when it is idle. The driver typically enables runtime PM with pm_runtime_enable() and takes a reference with pm_runtime_get_sync() during probe(), so that the controller stays powered while it is in use. The reference is dropped in remove().”…””}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hýh³hÇh´M2hjñh²hubhþ)”}”(hXjIf the Root Complex can be powered down when idle, the driver implements the runtime_suspend and runtime_resume callbacks to disable and enable the controller resources such as the clocks, PHYs, and power domain. These callbacks should manage only the controller resources and must not touch the state of the enumerated devices, which is handled by the PCI core.”h]”hXjIf the Root Complex can be powered down when idle, the driver implements the runtime_suspend and runtime_resume callbacks to disable and enable the controller resources such as the clocks, PHYs, and power domain. These callbacks should manage only the controller resources and must not touch the state of the enumerated devices, which is handled by the PCI core.”…””}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hýh³hÇh´M8hjñh²hubeh}”(h]”Œ runtime-pm”ah ]”h"]”Œ runtime pm”ah$]”h&]”uh1hÈhjÒh²hh³hÇh´M0ubhÉ)”}”(hhh]”(hÎ)”}”(hŒ System PM”h]”hŒ System PM”…””}”(hj)h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÍhj&h²hh³hÇh´M?ubhþ)”}”(hŒ‹During system suspend and resume, the driver has to save and restore the state of the Root Complex and put the Link into a low power state.”h]”hŒ‹During system suspend and resume, the driver has to save and restore the state of the Root Complex and put the Link into a low power state.”…””}”(hj7h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hýh³hÇh´MAhj&h²hubhþ)”}”(hXLThese operations are performed in the _noirq() PM callbacks (for example, using NOIRQ_SYSTEM_SLEEP_PM_OPS()), because the controller resources such as the clocks and PHY are shared by all the child devices. Suspending them earlier would break the child devices whose own suspend callbacks may still access their Configuration Space.”h]”hXLThese operations are performed in the _noirq() PM callbacks (for example, using NOIRQ_SYSTEM_SLEEP_PM_OPS()), because the controller resources such as the clocks and PHY are shared by all the child devices. Suspending them earlier would break the child devices whose own suspend callbacks may still access their Configuration Space.”…””}”(hjEh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hýh³hÇh´MDhj&h²hubhþ)”}”(hŒ+In the suspend callback, the driver should:”h]”hŒ+In the suspend callback, the driver should:”…””}”(hjSh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hýh³hÇh´MJhj&h²hubj¡)”}”(hhh]”(j¦)”}”(hŒqBroadcast a PME_Turn_Off message and wait for the PME_TO_Ack, so that the Link can transition to the L2/L3 state.”h]”hþ)”}”(hŒqBroadcast a PME_Turn_Off message and wait for the PME_TO_Ack, so that the Link can transition to the L2/L3 state.”h]”hŒqBroadcast a PME_Turn_Off message and wait for the PME_TO_Ack, so that the Link can transition to the L2/L3 state.”…””}”(hjhh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hýh³hÇh´MLhjdubah}”(h]”h ]”h"]”h$]”h&]”uh1j¥hjah²hh³hÇh´Nubj¦)”}”(hŒ]Stop the LTSSM and disable the controller resources such as the clocks, PHY and power domain.”h]”hþ)”}”(hŒ]Stop the LTSSM and disable the controller resources such as the clocks, PHY and power domain.”h]”hŒ]Stop the LTSSM and disable the controller resources such as the clocks, PHY and power domain.”…””}”(hj€h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hýh³hÇh´MNhj|ubah}”(h]”h ]”h"]”h$]”h&]”uh1j¥hjah²hh³hÇh´Nubj¦)”}”(hŒJSave any controller state that is not retained across the low power state.”h]”hþ)”}”(hŒJSave any controller state that is not retained across the low power state.”h]”hŒJSave any controller state that is not retained across the low power state.”…””}”(hj˜h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hýh³hÇh´MPhj”ubah}”(h]”h ]”h"]”h$]”h&]”uh1j¥hjah²hh³hÇh´Nubj¦)”}”(hŒHPower off the downstream devices using pci_pwrctrl_power_off_devices(). ”h]”hþ)”}”(hŒGPower off the downstream devices using pci_pwrctrl_power_off_devices().”h]”hŒGPower off the downstream devices using pci_pwrctrl_power_off_devices().”…””}”(hj°h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hýh³hÇh´MRhj¬ubah}”(h]”h ]”h"]”h$]”h&]”uh1j¥hjah²hh³hÇh´Nubeh}”(h]”h ]”h"]”h$]”h&]”jjuh1j h³hÇh´MLhj&h²hubhþ)”}”(hŒÒIn the resume callback, the driver should reverse the above by enabling the controller resources, restoring the saved state, re-initializing the Root Complex and re-establishing the Link as done during probe().”h]”hŒÒIn the resume callback, the driver should reverse the above by enabling the controller resources, restoring the saved state, re-initializing the Root Complex and re-establishing the Link as done during probe().”…””}”(hjÊh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hýh³hÇh´MThj&h²hubhþ)”}”(hŒùNOTE: If the Link is in the ASPM L1 (or L1 substates) state, some drivers keep the Link in L1 across suspend for a faster resume, instead of transitioning it to L2/L3. This is a driver policy decision based on the platform and the devices connected.”h]”hŒùNOTE: If the Link is in the ASPM L1 (or L1 substates) state, some drivers keep the Link in L1 across suspend for a faster resume, instead of transitioning it to L2/L3. This is a driver policy decision based on the platform and the devices connected.”…””}”(hjØh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hýh³hÇh´MXhj&h²hubeh}”(h]”Œ system-pm”ah ]”h"]”Œ system pm”ah$]”h&]”uh1hÈhjÒh²hh³hÇh´M?ubeh}”(h]”Œpower-management”ah ]”h"]”Œpower management”ah$]”h&]”uh1hÈhj`h²hh³hÇh´M(ubhÉ)”}”(hhh]”(hÎ)”}”(hŒShutdown”h]”hŒShutdown”…””}”(hjùh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÍhjöh²hh³hÇh´M^ubhþ)”}”(hŒíThe shutdown() callback is invoked during system reboot or when transitioning to a new kernel through kexec. Its purpose is to quiesce the Root Complex so that the downstream devices cannot corrupt the memory or interrupt the new kernel.”h]”hŒíThe shutdown() callback is invoked during system reboot or when transitioning to a new kernel through kexec. Its purpose is to quiesce the Root Complex so that the downstream devices cannot corrupt the memory or interrupt the new kernel.”…””}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hýh³hÇh´M`hjöh²hubhþ)”}”(hŒThe driver should:”h]”hŒThe driver should:”…””}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hýh³hÇh´Mehjöh²hubj¡)”}”(hhh]”(j¦)”}”(hŒ€Disable the interrupts (INTx and MSI) reported by the Root Complex so that no spurious interrupt is delivered to the new kernel.”h]”hþ)”}”(hŒ€Disable the interrupts (INTx and MSI) reported by the Root Complex so that no spurious interrupt is delivered to the new kernel.”h]”hŒ€Disable the interrupts (INTx and MSI) reported by the Root Complex so that no spurious interrupt is delivered to the new kernel.”…””}”(hj*h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hýh³hÇh´Mghj&ubah}”(h]”h ]”h"]”h$]”h&]”uh1j¥hj#h²hh³hÇh´Nubj¦)”}”(hŒBroadcast a PME_Turn_Off message and stop the LTSSM to bring the Link down so that any in-flight DMA from the downstream devices is stopped before the reset.”h]”hþ)”}”(hŒBroadcast a PME_Turn_Off message and stop the LTSSM to bring the Link down so that any in-flight DMA from the downstream devices is stopped before the reset.”h]”hŒBroadcast a PME_Turn_Off message and stop the LTSSM to bring the Link down so that any in-flight DMA from the downstream devices is stopped before the reset.”…””}”(hjBh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hýh³hÇh´Mihj>ubah}”(h]”h ]”h"]”h$]”h&]”uh1j¥hj#h²hh³hÇh´Nubj¦)”}”(hŒ%Power down the controller resources. ”h]”hþ)”}”(hŒ$Power down the controller resources.”h]”hŒ$Power down the controller resources.”…””}”(hjZh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hýh³hÇh´MlhjVubah}”(h]”h ]”h"]”h$]”h&]”uh1j¥hj#h²hh³hÇh´Nubeh}”(h]”h ]”h"]”h$]”h&]”jjuh1j h³hÇh´Mghjöh²hubhþ)”}”(hŒ†Unlike remove(), shutdown() does not need to tear down the software state such as the Root bus, since the system is going down anyway.”h]”hŒ†Unlike remove(), shutdown() does not need to tear down the software state such as the Root bus, since the system is going down anyway.”…””}”(hjth²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hýh³hÇh´Mnhjöh²hubhþ)”}”(hŒ­NOTE: shutdown() is optional. It is mainly required on platforms where the downstream devices could perform DMA or raise interrupts during the transition to reboot or kexec.”h]”hŒ­NOTE: shutdown() is optional. It is mainly required on platforms where the downstream devices could perform DMA or raise interrupts during the transition to reboot or kexec.”…””}”(hj‚h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hýh³hÇh´Mqhjöh²hubeh}”(h]”Œshutdown”ah ]”h"]”Œshutdown”ah$]”h&]”uh1hÈhj`h²hh³hÇh´M^ubhÉ)”}”(hhh]”(hÎ)”}”(hŒRemove”h]”hŒRemove”…””}”(hj›h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÍhj˜h²hh³hÇh´Mvubhþ)”}”(hŒsremove() is called when the driver is detached, and it should undo everything done in probe() in the reverse order.”h]”hŒsremove() is called when the driver is detached, and it should undo everything done in probe() in the reverse order.”…””}”(hj©h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hýh³hÇh´Mxhj˜h²hubhþ)”}”(hXThe first step is to remove the enumerated devices and the Root bus, by calling pci_stop_root_bus() followed by pci_remove_root_bus() under the pci_lock_rescan_remove() lock. This detaches all the child devices before the controller resources are released.”h]”hXThe first step is to remove the enumerated devices and the Root bus, by calling pci_stop_root_bus() followed by pci_remove_root_bus() under the pci_lock_rescan_remove() lock. This detaches all the child devices before the controller resources are released.”…””}”(hj·h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hýh³hÇh´M{hj˜h²hubhþ)”}”(hŒ,After the bus is removed, the driver should:”h]”hŒ,After the bus is removed, the driver should:”…””}”(hjÅh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hýh³hÇh´M€hj˜h²hubj¡)”}”(hhh]”(j¦)”}”(hŒ4Disable the interrupts reported by the Root Complex.”h]”hþ)”}”(hjØh]”hŒ4Disable the interrupts reported by the Root Complex.”…””}”(hjÚh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hýh³hÇh´M‚hjÖubah}”(h]”h ]”h"]”h$]”h&]”uh1j¥hjÓh²hh³hÇh´Nubj¦)”}”(hŒ&Stop the LTSSM to bring the Link down.”h]”hþ)”}”(hjïh]”hŒ&Stop the LTSSM to bring the Link down.”…””}”(hjñh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hýh³hÇh´Mƒhjíubah}”(h]”h ]”h"]”h$]”h&]”uh1j¥hjÓh²hh³hÇh´Nubj¦)”}”(hŒAPower down the PHY and disable the clocks, regulators and resets.”h]”hþ)”}”(hjh]”hŒAPower down the PHY and disable the clocks, regulators and resets.”…””}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hýh³hÇh´M„hjubah}”(h]”h ]”h"]”h$]”h&]”uh1j¥hjÓh²hh³hÇh´Nubj¦)”}”(hŒkDrop the runtime PM reference with pm_runtime_put_sync() and disable runtime PM with pm_runtime_disable(). ”h]”hþ)”}”(hŒjDrop the runtime PM reference with pm_runtime_put_sync() and disable runtime PM with pm_runtime_disable().”h]”hŒjDrop the runtime PM reference with pm_runtime_put_sync() and disable runtime PM with pm_runtime_disable().”…””}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hýh³hÇh´M…hjubah}”(h]”h ]”h"]”h$]”h&]”uh1j¥hjÓh²hh³hÇh´Nubeh}”(h]”h ]”h"]”h$]”h&]”jjuh1j h³hÇh´M‚hj˜h²hubhþ)”}”(hŒResources allocated through the devm_*() APIs are released automatically after remove() returns and need not be freed explicitly.”h]”hŒResources allocated through the devm_*() APIs are released automatically after remove() returns and need not be freed explicitly.”…””}”(hj9h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hýh³hÇh´Mˆhj˜h²hubhþ)”}”(hXNOTE: A Host Controller driver is encouraged to be built as a loadable module, but it should not be removed at runtime if it implements its own IRQ domains such as MSI or INTx controllers. The IRQ mappings created for such domains can persist even after the interrupts are released and cannot be disposed of safely, so tearing down the IRQ domains on removal is fragile. Such drivers should therefore prevent their removal. See the following thread for more details: https://lore.kernel.org/linux-pci/87k085xekg.wl-maz@kernel.org/”h]”(hXÓNOTE: A Host Controller driver is encouraged to be built as a loadable module, but it should not be removed at runtime if it implements its own IRQ domains such as MSI or INTx controllers. The IRQ mappings created for such domains can persist even after the interrupts are released and cannot be disposed of safely, so tearing down the IRQ domains on removal is fragile. Such drivers should therefore prevent their removal. See the following thread for more details: ”…””}”(hjGh²hh³Nh´Nubj)”}”(hŒ?https://lore.kernel.org/linux-pci/87k085xekg.wl-maz@kernel.org/”h]”hŒ?https://lore.kernel.org/linux-pci/87k085xekg.wl-maz@kernel.org/”…””}”(hjOh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”Œrefuri”jQuh1jhjGubeh}”(h]”h ]”h"]”h$]”h&]”uh1hýh³hÇh´M‹hj˜h²hubeh}”(h]”Œremove”ah ]”h"]”Œremove”ah$]”h&]”uh1hÈhj`h²hh³hÇh´Mvubeh}”(h]”Œ driver-design”ah ]”h"]”Œ driver design”ah$]”h&]”uh1hÈhhÊh²hh³hÇh´K…ubeh}”(h]”Œ#writing-pci-host-controller-drivers”ah ]”h"]”Œ#writing pci host controller drivers”ah$]”h&]”uh1hÈhhh²hh³hÇh´Kubeh}”(h]”h ]”h"]”h$]”h&]”Œsource”hÇuh1hŒcurrent_source”NŒ current_line”NŒsettings”Œdocutils.frontend”ŒValues”“”)”}”(hÍNŒ generator”NŒ datestamp”NŒ source_link”NŒ source_url”NŒ toc_backlinks”Œentry”Œfootnote_backlinks”KŒ sectnum_xform”KŒstrip_comments”NŒstrip_elements_with_classes”NŒ strip_classes”NŒ report_level”KŒ halt_level”KŒexit_status_level”KŒdebug”NŒwarning_stream”NŒ traceback”ˆŒinput_encoding”Œ utf-8-sig”Œinput_encoding_error_handler”Œstrict”Œoutput_encoding”Œutf-8”Œoutput_encoding_error_handler”jŸŒerror_encoding”Œutf-8”Œerror_encoding_error_handler”Œbackslashreplace”Œ language_code”Œen”Œrecord_dependencies”NŒconfig”NŒ id_prefix”hŒauto_id_prefix”Œid”Œ dump_settings”NŒdump_internals”NŒdump_transforms”NŒdump_pseudo_xml”NŒexpose_internals”NŒstrict_visitor”NŒ_disable_config”NŒ_source”hÇŒ _destination”NŒ _config_files”]”Œ7/var/lib/git/docbuild/linux/Documentation/docutils.conf”aŒfile_insertion_enabled”ˆŒ raw_enabled”KŒline_length_limit”M'Œpep_references”NŒ pep_base_url”Œhttps://peps.python.org/”Œpep_file_url_template”Œpep-%04d”Œrfc_references”NŒ rfc_base_url”Œ&https://datatracker.ietf.org/doc/html/”Œ tab_width”KŒtrim_footnote_reference_space”‰Œsyntax_highlight”Œlong”Œ smart_quotes”ˆŒsmartquotes_locales”]”Œcharacter_level_inline_markup”‰Œdoctitle_xform”‰Œ docinfo_xform”KŒsectsubtitle_xform”‰Œ image_loading”Œlink”Œembed_stylesheet”‰Œcloak_email_addresses”ˆŒsection_self_link”‰Œenv”NubŒreporter”NŒindirect_targets”]”Œsubstitution_defs”}”Œsubstitution_names”}”Œrefnames”}”Œrefids”}”Œnameids”}”(jyjvj¡jžj]jZjqjnjõjòjÏjÌjIjFj~j{jHjEjÖjÓjýjúj’jjÇjÄjójðj#j jëjèj•j’jijfuŒ nametypes”}”(jy‰j¡‰j]‰jq‰jõ‰jωjI‰j~‰jH‰jÖ‰jý‰j’‰jljjó‰j#‰jë‰j•‰ji‰uh}”(jvhÊjžj5jZj¤jnj`jòjqjÌjøjFjj{jLjEjjÓjKjújÙjjjÄj•jðjÒj jñjèj&j’jöjfj˜uŒ footnote_refs”}”Œ citation_refs”}”Œ autofootnotes”]”Œautofootnote_refs”]”Œsymbol_footnotes”]”Œsymbol_footnote_refs”]”Œ footnotes”]”Œ citations”]”Œautofootnote_start”KŒsymbol_footnote_start”KŒ id_counter”Œ collections”ŒCounter”“”}”…”R”Œparse_messages”]”Œtransform_messages”]”Œ transformer”NŒ include_log”]”Œ decoration”Nh²hub.