Add support for PCIe endpoint mode in Tegra194
Subsystems (5)
v3 cover Add support for PCIe endpoint mode in Tegra194
Tegra194 has three (C0, C4 & C5) dual mode PCIe controllers that can operate either in root port mode or in end point mode but only in one mode at a time. Platform P2972-0000 supports enabling endpoint mode for C5 controller. This patch series adds support for PCIe endpoint mode in both the driver as well as in DT.
This patch series depends on the changes made for Synopsys DesignWare endpoint mode subsystem that are currently under review
@ https://patchwork.kernel.org/project/linux-pci/list/?series=202211
which in turn depends on the patch made by Kishon
@ https://patchwork.kernel.org/patch/10975123/
which is also under review.
V3:
* Re-ordered patches in the series to make the driver change as the last patch
* Took care of Thierry's review comments
V2:
* Addressed Thierry & Bjorn's review comments
* Added EP mode specific binding documentation to already existing binding documentation file
* Removed patch that enables GPIO controller nodes explicitly as they are enabled already
Vidya Sagar (5):
soc/tegra: bpmp: Update ABI header
dt-bindings: PCI: tegra: Add DT support for PCIe EP nodes in Tegra194
arm64: tegra: Add PCIe endpoint controllers nodes for Tegra194
arm64: tegra: Add support for PCIe endpoint mode in P2972-0000
platform
PCI: tegra: Add support for PCIe endpoint mode in Tegra194
.../bindings/pci/nvidia,tegra194-pcie.txt | 125 ++- .../boot/dts/nvidia/tegra194-p2972-0000.dts | 18 + arch/arm64/boot/dts/nvidia/tegra194.dtsi | 99 +++ drivers/pci/controller/dwc/Kconfig | 30 +- drivers/pci/controller/dwc/pcie-tegra194.c | 770 +++++++++++++++++- include/soc/tegra/bpmp-abi.h | 10 +- 6 files changed, 1007 insertions(+), 45 deletions(-)
Signature · 1 line
2.17.1
PATCH v3 1/5 soc/tegra: bpmp: Update ABI header
Update the firmware header to support uninitialization of UPHY PLL when the PCIe controller is operating in endpoint mode and host cuts the PCIe reference clock.
---
V3:
* Added Acked-by: Thierry Reding <[email protected]>
V2:
* Changed Copyright year from 2019 to 2020
include/soc/tegra/bpmp-abi.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
include/soc/tegra/bpmp-abi.h +9 -1
@@ -1,6 +1,6 @@/* SPDX-License-Identifier: GPL-2.0-only */ /* -* Copyright (c) 2014-2018, NVIDIA CORPORATION. All rights reserved. +* Copyright (c) 2014-2020, NVIDIA CORPORATION. All rights reserved. */ #ifndef _ABI_BPMP_ABI_H_
@@ -2119,6 +2119,7 @@ enum {CMD_UPHY_PCIE_LANE_MARGIN_STATUS =2 ,CMD_UPHY_PCIE_EP_CONTROLLER_PLL_INIT =3 ,CMD_UPHY_PCIE_CONTROLLER_STATE =4 , +CMD_UPHY_PCIE_EP_CONTROLLER_PLL_OFF =5 , CMD_UPHY_MAX, };
@@ -2151,6 +2152,11 @@ struct cmd_uphy_pcie_controller_state_request {uint8_t enable; } __ABI_PACKED; +struct cmd_uphy_ep_controller_pll_off_request { +/** @brief EP controller number, valid: 0, 4, 5 */ +uint8_t ep_controller; +} __ABI_PACKED; +/** * @ingroup UPHY * @brief Request with #MRQ_UPHY
@@ -2165,6 +2171,7 @@ struct cmd_uphy_pcie_controller_state_request {* |CMD_UPHY_PCIE_LANE_MARGIN_STATUS | | * |CMD_UPHY_PCIE_EP_CONTROLLER_PLL_INIT |cmd_uphy_ep_controller_pll_init_request | * |CMD_UPHY_PCIE_CONTROLLER_STATE |cmd_uphy_pcie_controller_state_request | +* |CMD_UPHY_PCIE_EP_CONTROLLER_PLL_OFF |cmd_uphy_ep_controller_pll_off_request | * */
@@ -2178,6 +2185,7 @@ struct mrq_uphy_request {struct cmd_uphy_margin_control_request uphy_set_margin_control;struct cmd_uphy_ep_controller_pll_init_request ep_ctrlr_pll_init;struct cmd_uphy_pcie_controller_state_request controller_state; +struct cmd_uphy_ep_controller_pll_off_request ep_ctrlr_pll_off; } __UNION_ANON; } __ABI_PACKED;
Signature · 1 line
2.17.1
PATCH v3 2/5 dt-bindings: PCI: tegra: Add DT support for PCIe EP nodes in Tegra194
In reply to Vidya SagarAdd support for PCIe controllers that can operate in endpoint mode in Tegra194.
---
V3:
* Added Reviewed-by: Rob Herring <[email protected]>
V2:
* Addressed Thierry's review comments
* Merged EP specific information from tegra194-pcie-ep.txt to tegra194-pcie.txt itself
* Started using the standard 'reset-gpios' for PERST GPIO
* Added 'nvidia,refclk-select-gpios' to enable REFCLK signals
.../bindings/pci/nvidia,tegra194-pcie.txt | 125 ++++++++++++++---- 1 file changed, 99 insertions(+), 26 deletions(-)
Documentation/devicetree/bindings/pci/nvidia,tegra194-pcie.txt +99 -26
@@ -1,11 +1,11 @@ NVIDIA Tegra PCIe controller (Synopsys DesignWare Core based) -This PCIe host controller is based on the Synopsis Designware PCIe IP +This PCIe controller is based on the Synopsis Designware PCIe IP and thus inherits all the common properties defined in designware-pcie.txt. +Some of the controller instances are dual mode where in they can work either +in root port mode or endpoint mode but one at a time. Required properties: -- compatible: For Tegra19x, must contain "nvidia,tegra194-pcie". -- device_type: Must be "pci" - power-domains: A phandle to the node that controls power to the respective PCIe controller and a specifier name for the PCIe controller. Following are the specifiers for the different PCIe controllers
@@ -32,6 +32,32 @@ Required properties: entry for each entry in the interrupt-names property. - interrupt-names: Must include the following entries: "intr": The Tegra interrupt that is asserted for controller interrupts +- clocks: Must contain an entry for each entry in clock-names. + See ../clocks/clock-bindings.txt for details. +- clock-names: Must include the following entries: + - core +- resets: Must contain an entry for each entry in reset-names. + See ../reset/reset.txt for details. +- reset-names: Must include the following entries: + - apb + - core +- phys: Must contain a phandle to P2U PHY for each entry in phy-names. +- phy-names: Must include an entry for each active lane. + "p2u-N": where N ranges from 0 to one less than the total number of lanes +- nvidia,bpmp: Must contain a pair of phandle to BPMP controller node followed + by controller-id. Following are the controller ids for each controller. + 0: C0 + 1: C1 + 2: C2 + 3: C3 + 4: C4 + 5: C5 +- vddio-pex-ctl-supply: Regulator supply for PCIe side band signals + +RC mode: +- compatible: Tegra19x must contain "nvidia,tegra194-pcie" +- device_type: Must be "pci" for RC mode +- interrupt-names: Must include the following entries: "msi": The Tegra interrupt that is asserted when an MSI is received - bus-range: Range of bus numbers associated with this controller - #address-cells: Address representation for root ports (must be 3)
@@ -60,27 +86,15 @@ Required properties: - interrupt-map-mask and interrupt-map: Standard PCI IRQ mapping properties Please refer to the standard PCI bus binding document for a more detailed explanation. -- clocks: Must contain an entry for each entry in clock-names. - See ../clocks/clock-bindings.txt for details. -- clock-names: Must include the following entries: - - core -- resets: Must contain an entry for each entry in reset-names. - See ../reset/reset.txt for details. -- reset-names: Must include the following entries: - - apb - - core -- phys: Must contain a phandle to P2U PHY for each entry in phy-names. -- phy-names: Must include an entry for each active lane. - "p2u-N": where N ranges from 0 to one less than the total number of lanes -- nvidia,bpmp: Must contain a pair of phandle to BPMP controller node followed - by controller-id. Following are the controller ids for each controller. - 0: C0 - 1: C1 - 2: C2 - 3: C3 - 4: C4 - 5: C5 -- vddio-pex-ctl-supply: Regulator supply for PCIe side band signals + +EP mode: +In Tegra194, Only controllers C0, C4 & C5 support EP mode. +- compatible: Tegra19x must contain "nvidia,tegra194-pcie-ep" +- reg-names: Must include the following entries: + "addr_space": Used to map remote RC address space +- reset-gpios: Must contain a phandle to a GPIO controller followed by + GPIO that is being used as PERST input signal. Please refer to pci.txt + document. Optional properties: - pinctrl-names: A list of pinctrl state names.
@@ -104,6 +118,8 @@ Optional properties: specified in microseconds - nvidia,aspm-l0s-entrance-latency-us: ASPM L0s entrance latency to be specified in microseconds + +RC mode: - vpcie3v3-supply: A phandle to the regulator node that supplies 3.3V to the slot if the platform has one such slot. (Ex:- x16 slot owned by C5 controller in p2972-0000 platform).
@@ -111,11 +127,18 @@ Optional properties: if the platform has one such slot. (Ex:- x16 slot owned by C5 controller in p2972-0000 platform). +EP mode: +- nvidia,refclk-select-gpios: Must contain a phandle to a GPIO controller + followed by GPIO that is being used to enable REFCLK to controller from host + +NOTE:- On Tegra194's P2972-0000 platform, only C5 controller can be enabled to +operate in the endpoint mode because of the way the platform is designed. + Examples: ========= -Tegra194: --------- +Tegra194 RC mode: +----------------- pcie@14180000 { compatible = "nvidia,tegra194-pcie", "snps,dw-pcie";
@@ -169,3 +192,53 @@ Tegra194: <&p2u_hsio_5>; phy-names = "p2u-0", "p2u-1", "p2u-2", "p2u-3"; }; + +Tegra194 EP mode: +----------------- + + pcie_ep@141a0000 { + compatible = "nvidia,tegra194-pcie-ep", "snps,dw-pcie-ep"; + power-domains = <&bpmp TEGRA194_POWER_DOMAIN_PCIEX8A>; + reg = <0x00 0x141a0000 0x0 0x00020000 /* appl registers (128K) */ + 0x00 0x3a040000 0x0 0x00040000 /* iATU_DMA reg space (256K) */ + 0x00 0x3a080000 0x0 0x00040000 /* DBI reg space (256K) */ + 0x1c 0x00000000 0x4 0x00000000>; /* Address Space (16G) */ + reg-names = "appl", "atu_dma", "dbi", "addr_space"; + + num-lanes = <8>; + num-ib-windows = <2>; + num-ob-windows = <8>; + + pinctrl-names = "default"; + pinctrl-0 = <&clkreq_c5_bi_dir_state>; + + clocks = <&bpmp TEGRA194_CLK_PEX1_CORE_5>; + clock-names = "core"; + + resets = <&bpmp TEGRA194_RESET_PEX1_CORE_5_APB>, + <&bpmp TEGRA194_RESET_PEX1_CORE_5>; + reset-names = "apb", "core"; + + interrupts = <GIC_SPI 53 IRQ_TYPE_LEVEL_HIGH>; /* controller interrupt */ + interrupt-names = "intr"; + + nvidia,bpmp = <&bpmp 5>; + + nvidia,aspm-cmrt-us = <60>; + nvidia,aspm-pwr-on-t-us = <20>; + nvidia,aspm-l0s-entrance-latency-us = <3>; + + vddio-pex-ctl-supply = <&vdd_1v8ao>; + + reset-gpios = <&gpio TEGRA194_MAIN_GPIO(GG, 1) GPIO_ACTIVE_LOW>; + + nvidia,refclk-select-gpios = <&gpio_aon TEGRA194_AON_GPIO(AA, 5) + GPIO_ACTIVE_HIGH>; + + phys = <&p2u_nvhs_0>, <&p2u_nvhs_1>, <&p2u_nvhs_2>, + <&p2u_nvhs_3>, <&p2u_nvhs_4>, <&p2u_nvhs_5>, + <&p2u_nvhs_6>, <&p2u_nvhs_7>; + + phy-names = "p2u-0", "p2u-1", "p2u-2", "p2u-3", "p2u-4", + "p2u-5", "p2u-6", "p2u-7"; + };
Signature · 1 line
2.17.1
PATCH v3 3/5 arm64: tegra: Add PCIe endpoint controllers nodes for Tegra194
In reply to Vidya SagarAdd endpoint mode controllers nodes for the dual mode PCIe controllers present in Tegra194 SoC.
---
V3:
* None
V2:
* None
arch/arm64/boot/dts/nvidia/tegra194.dtsi | 99 ++++++++++++++++++++++++ 1 file changed, 99 insertions(+)
arch/arm64/boot/dts/nvidia/tegra194.dtsi +99 -0
@@ -1481,6 +1481,105 @@ 0x82000000 0x0 0x40000000 0x1f 0x40000000 0x0 0xc0000000>; /* non-prefetchable memory (3GB) */ }; + pcie_ep@14160000 { + compatible = "nvidia,tegra194-pcie-ep", "snps,dw-pcie-ep"; + power-domains = <&bpmp TEGRA194_POWER_DOMAIN_PCIEX4A>; + reg = <0x00 0x14160000 0x0 0x00020000 /* appl registers (128K) */ + 0x00 0x36040000 0x0 0x00040000 /* iATU_DMA reg space (256K) */ + 0x00 0x36080000 0x0 0x00040000 /* DBI reg space (256K) */ + 0x14 0x00000000 0x4 0x00000000>; /* Address Space (16G) */ + reg-names = "appl", "atu_dma", "dbi", "addr_space"; + + status = "disabled"; + + num-lanes = <4>; + num-ib-windows = <2>; + num-ob-windows = <8>; + + clocks = <&bpmp TEGRA194_CLK_PEX0_CORE_4>; + clock-names = "core"; + + resets = <&bpmp TEGRA194_RESET_PEX0_CORE_4_APB>, + <&bpmp TEGRA194_RESET_PEX0_CORE_4>; + reset-names = "apb", "core"; + + interrupts = <GIC_SPI 51 IRQ_TYPE_LEVEL_HIGH>; /* controller interrupt */ + interrupt-names = "intr"; + + nvidia,bpmp = <&bpmp 4>; + + nvidia,aspm-cmrt-us = <60>; + nvidia,aspm-pwr-on-t-us = <20>; + nvidia,aspm-l0s-entrance-latency-us = <3>; + }; + + pcie_ep@14180000 { + compatible = "nvidia,tegra194-pcie-ep", "snps,dw-pcie-ep"; + power-domains = <&bpmp TEGRA194_POWER_DOMAIN_PCIEX8B>; + reg = <0x00 0x14180000 0x0 0x00020000 /* appl registers (128K) */ + 0x00 0x38040000 0x0 0x00040000 /* iATU_DMA reg space (256K) */ + 0x00 0x38080000 0x0 0x00040000 /* DBI reg space (256K) */ + 0x18 0x00000000 0x4 0x00000000>; /* Address Space (16G) */ + reg-names = "appl", "atu_dma", "dbi", "addr_space"; + + status = "disabled"; + + num-lanes = <8>; + num-ib-windows = <2>; + num-ob-windows = <8>; + + clocks = <&bpmp TEGRA194_CLK_PEX0_CORE_0>; + clock-names = "core"; + + resets = <&bpmp TEGRA194_RESET_PEX0_CORE_0_APB>, + <&bpmp TEGRA194_RESET_PEX0_CORE_0>; + reset-names = "apb", "core"; + + interrupts = <GIC_SPI 72 IRQ_TYPE_LEVEL_HIGH>; /* controller interrupt */ + interrupt-names = "intr"; + + nvidia,bpmp = <&bpmp 0>; + + nvidia,aspm-cmrt-us = <60>; + nvidia,aspm-pwr-on-t-us = <20>; + nvidia,aspm-l0s-entrance-latency-us = <3>; + }; + + pcie_ep@141a0000 { + compatible = "nvidia,tegra194-pcie-ep", "snps,dw-pcie-ep"; + power-domains = <&bpmp TEGRA194_POWER_DOMAIN_PCIEX8A>; + reg = <0x00 0x141a0000 0x0 0x00020000 /* appl registers (128K) */ + 0x00 0x3a040000 0x0 0x00040000 /* iATU_DMA reg space (256K) */ + 0x00 0x3a080000 0x0 0x00040000 /* DBI reg space (256K) */ + 0x1c 0x00000000 0x4 0x00000000>; /* Address Space (16G) */ + reg-names = "appl", "atu_dma", "dbi", "addr_space"; + + status = "disabled"; + + num-lanes = <8>; + num-ib-windows = <2>; + num-ob-windows = <8>; + + pinctrl-names = "default"; + pinctrl-0 = <&clkreq_c5_bi_dir_state>; + + clocks = <&bpmp TEGRA194_CLK_PEX1_CORE_5>; + clock-names = "core"; + + resets = <&bpmp TEGRA194_RESET_PEX1_CORE_5_APB>, + <&bpmp TEGRA194_RESET_PEX1_CORE_5>; + reset-names = "apb", "core"; + + interrupts = <GIC_SPI 53 IRQ_TYPE_LEVEL_HIGH>; /* controller interrupt */ + interrupt-names = "intr"; + + nvidia,bpmp = <&bpmp 5>; + + nvidia,aspm-cmrt-us = <60>; + nvidia,aspm-pwr-on-t-us = <20>; + nvidia,aspm-l0s-entrance-latency-us = <3>; + }; + sysram@40000000 { compatible = "nvidia,tegra194-sysram", "mmio-sram"; reg = <0x0 0x40000000 0x0 0x50000>;
Signature · 1 line
2.17.1
PATCH v3 4/5 arm64: tegra: Add support for PCIe endpoint mode in P2972-0000 platform
In reply to Vidya SagarAdd endpoint mode support for PCIe C5 controller in P2972-0000 platform with information about supplies, PHY, PERST GPIO and GPIO that controls PCIe reference clock coming from the host system.
---
V3:
* None
V2:
* Addressed Thierry's review comments
* Changed 'nvidia,pex-rst-gpio' to 'reset-gpios'
* Added 'nvidia,refclk-select-gpios'
.../boot/dts/nvidia/tegra194-p2972-0000.dts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
arch/arm64/boot/dts/nvidia/tegra194-p2972-0000.dts +18 -0
@@ -136,6 +136,24 @@ "p2u-5", "p2u-6", "p2u-7"; }; + pcie_ep@141a0000 { + status = "disabled"; + + vddio-pex-ctl-supply = <&vdd_1v8ao>; + + reset-gpios = <&gpio TEGRA194_MAIN_GPIO(GG, 1) GPIO_ACTIVE_LOW>; + + nvidia,refclk-select-gpios = <&gpio_aon TEGRA194_AON_GPIO(AA, 5) + GPIO_ACTIVE_HIGH>; + + phys = <&p2u_nvhs_0>, <&p2u_nvhs_1>, <&p2u_nvhs_2>, + <&p2u_nvhs_3>, <&p2u_nvhs_4>, <&p2u_nvhs_5>, + <&p2u_nvhs_6>, <&p2u_nvhs_7>; + + phy-names = "p2u-0", "p2u-1", "p2u-2", "p2u-3", "p2u-4", + "p2u-5", "p2u-6", "p2u-7"; + }; + fan: fan { compatible = "pwm-fan"; pwms = <&pwm4 0 45334>;
Signature · 1 line
2.17.1
PATCH v3 5/5 PCI: tegra: Add support for PCIe endpoint mode in Tegra194
In reply to Vidya SagarAdd support for the endpoint mode of Synopsys DesignWare core based dual mode PCIe controllers present in Tegra194 SoC.
---
V3:
* Addressed Thierry's review comments
V2:
* Addressed Bjorn's review comments
* Made changes as part of addressing review comments for other patches
drivers/pci/controller/dwc/Kconfig | 30 +- drivers/pci/controller/dwc/pcie-tegra194.c | 770 ++++++++++++++++++++- 2 files changed, 782 insertions(+), 18 deletions(-)
drivers/pci/controller/dwc/Kconfig +27 -3
@@ -248,14 +248,38 @@ config PCI_MESON implement the driver. config PCIE_TEGRA194 - tristate "NVIDIA Tegra194 (and later) PCIe controller" + tristate + +config PCIE_TEGRA194_HOST + tristate "NVIDIA Tegra194 (and later) PCIe controller - Host Mode" depends on ARCH_TEGRA_194_SOC || COMPILE_TEST depends on PCI_MSI_IRQ_DOMAIN select PCIE_DW_HOST select PHY_TEGRA194_P2U + select PCIE_TEGRA194 + default y + help + Enables support for the PCIe controller in the NVIDIA Tegra194 SoC to + work in host mode. There are two instances of PCIe controllers in + Tegra194. This controller can work either as EP or RC. In order to + enable host-specific features PCIE_TEGRA194_HOST must be selected and + in order to enable device-specific features PCIE_TEGRA194_EP must be + selected. This uses the DesignWare core. + +config PCIE_TEGRA194_EP + tristate "NVIDIA Tegra194 (and later) PCIe controller - Endpoint Mode" + depends on ARCH_TEGRA_194_SOC || COMPILE_TEST + depends on PCI_ENDPOINT + select PCIE_DW_EP + select PHY_TEGRA194_P2U + select PCIE_TEGRA194 help - Say Y here if you want support for DesignWare core based PCIe host - controller found in NVIDIA Tegra194 SoC. + Enables support for the PCIe controller in the NVIDIA Tegra194 SoC to + work in host mode. There are two instances of PCIe controllers in + Tegra194. This controller can work either as EP or RC. In order to + enable host-specific features PCIE_TEGRA194_HOST must be selected and + in order to enable device-specific features PCIE_TEGRA194_EP must be + selected. This uses the DesignWare core. config PCIE_UNIPHIER bool "Socionext UniPhier PCIe controllers"
drivers/pci/controller/dwc/pcie-tegra194.c +755 -15
922 lines not on this page · raw message
Signature · 1 line
2.17.1
Re: [PATCH V3 5/5] PCI: tegra: Add support for PCIe endpoint mode in Tegra194
Quoted 7 lines · Vidya Sagar
Add support for the endpoint mode of Synopsys DesignWare core based dual mode PCIe controllers present in Tegra194 SoC.
Signed-off-by Vidya Sagar <[email protected]>---
V3:
* Addressed Thierry's review comments
I need his ACK to merge this series.
[...]
Quoted 73 lines
drivers/pci/controller/dwc/pcie-tegra194.c +73
-0+static int tegra_pcie_ep_work_thread (void *p) +{ +struct tegra_pcie_dw *pcie = (struct tegra_pcie_dw *)p; +u32 event; + +while (true) { +wait_event_interruptible (pcie->wq, + !kfifo_is_empty (&pcie->event_fifo)); + +if (kthread_should_stop ()) +break ; + +if (!kfifo_get (&pcie->event_fifo, &event)) { +dev_warn (pcie->dev,"EVENT FIFO is empty\n" ); +continue ; + } + +switch (event) { +case EP_PEX_RST_DEASSERT : +dev_info (pcie->dev,"EVENT: EP_PEX_RST_DEASSERT\n" ); +pex_ep_event_pex_rst_deassert (pcie); +break ; + +case EP_PEX_RST_ASSERT : +dev_info (pcie->dev,"EVENT: EP_PEX_RST_ASSERT\n" ); +pex_ep_event_pex_rst_assert (pcie); +break ; + +case EP_HOT_RST_DONE : +dev_info (pcie->dev,"EVENT: EP_HOT_RST_DONE\n" ); +pex_ep_event_hot_rst_done (pcie); +break ; + +case EP_BME_CHANGE : +dev_info (pcie->dev,"EVENT: EP_BME_CHANGE\n" ); +pex_ep_event_bme_change (pcie); +break ; + +case EP_EVENT_EXIT : +dev_info (pcie->dev,"EVENT: EP_EVENT_EXIT\n" ); +return 0 ; + +default : +dev_warn (pcie->dev,"Invalid PCIe EP event: %u\n" , + event); +break ; + } + } + +return 0 ; +} + +static irqreturn_t tegra_pcie_ep_pex_rst_irq (int irq,void *arg) +{ +struct tegra_pcie_dw *pcie = arg; + +if (gpiod_get_value (pcie->pex_rst_gpiod)) { +if (!kfifo_put (&pcie->event_fifo,EP_PEX_RST_ASSERT )) { +dev_err (pcie->dev,"EVENT FIFO is full\n" ); +return IRQ_HANDLED ; + } + }else { +if (!kfifo_put (&pcie->event_fifo,EP_PEX_RST_DEASSERT )) { +dev_err (pcie->dev,"EVENT FIFO is full\n" ); +return IRQ_HANDLED ; + } + } + +wake_up (&pcie->wq); + +return IRQ_HANDLED ; +} +
[...]
Quoted 38 lines
drivers/pci/controller/dwc/pcie-tegra194.c +38
-0+static int tegra_pcie_config_ep (struct tegra_pcie_dw *pcie, +struct platform_device *pdev) +{ +struct dw_pcie *pci = &pcie->pci; +struct device *dev = pcie->dev; +struct dw_pcie_ep *ep; +struct resource *res; +char *name; +int ret; + + ep = &pci->ep; + ep->ops = &pcie_ep_ops; + + res =platform_get_resource_byname (pdev,IORESOURCE_MEM ,"addr_space" ); +if (!res) +return -EINVAL ; + + ep->phys_base = res->start; + ep->addr_size =resource_size (res); + ep->page_size =SZ_64K ; + + ret =gpiod_set_debounce (pcie->pex_rst_gpiod,PERST_DEBOUNCE_TIME ); +if (ret <0 ) { +dev_err (dev,"Failed to set PERST GPIO debounce time: %d\n" , + ret); +return ret; + } + + ret =gpiod_to_irq (pcie->pex_rst_gpiod); +if (ret <0 ) { +dev_err (dev,"Failed to get IRQ for PERST GPIO: %d\n" , ret); +return ret; + } + pcie->pex_rst_irq = (unsigned int )ret; + + name =devm_kasprintf (dev,GFP_KERNEL ,"tegra_pcie_%u_pex_rst_irq" , + pcie->cid); +if (!name) {
drivers/pci/controller/dwc/pcie-tegra194.c static int tegra_pcie_config_rp(struct tegra_pcie_dw *pcie) · line 2088
Quoted 10 lines
drivers/pci/controller/dwc/pcie-tegra194.c +10
-0+dev_err (dev,"Failed to create PERST IRQ string\n" ); +return -ENOMEM ; + } + +irq_set_status_flags (pcie->pex_rst_irq,IRQ_NOAUTOEN ); + + ret =devm_request_irq (dev, pcie->pex_rst_irq, + tegra_pcie_ep_pex_rst_irq, +IRQF_TRIGGER_RISING |IRQF_TRIGGER_FALLING , + name, (void *)pcie);
I have the impression that a threaded IRQ is what you need, which will also remove some boilerplate in the process. Any reason why you can't use a threaded IRQ instead of a standalone kthread ?
Thanks,
Lorenzo
Re: [PATCH V3 5/5] PCI: tegra: Add support for PCIe endpoint mode in Tegra194
Quoted 136 lines · Lorenzo Pieralisi
External email: Use caution opening links or attachments
Quoted 7 lines · Vidya Sagar
Add support for the endpoint mode of Synopsys DesignWare core based dual mode PCIe controllers present in Tegra194 SoC.
Signed-off-by Vidya Sagar <[email protected]>---
V3:
* Addressed Thierry's review commentsI need his ACK to merge this series.
[...]
Quoted 73 lines
drivers/pci/controller/dwc/pcie-tegra194.c +73
-0+static int tegra_pcie_ep_work_thread (void *p) +{ +struct tegra_pcie_dw *pcie = (struct tegra_pcie_dw *)p; +u32 event; + +while (true) { +wait_event_interruptible (pcie->wq, + !kfifo_is_empty (&pcie->event_fifo)); + +if (kthread_should_stop ()) +break ; + +if (!kfifo_get (&pcie->event_fifo, &event)) { +dev_warn (pcie->dev,"EVENT FIFO is empty\n" ); +continue ; + } + +switch (event) { +case EP_PEX_RST_DEASSERT : +dev_info (pcie->dev,"EVENT: EP_PEX_RST_DEASSERT\n" ); +pex_ep_event_pex_rst_deassert (pcie); +break ; + +case EP_PEX_RST_ASSERT : +dev_info (pcie->dev,"EVENT: EP_PEX_RST_ASSERT\n" ); +pex_ep_event_pex_rst_assert (pcie); +break ; + +case EP_HOT_RST_DONE : +dev_info (pcie->dev,"EVENT: EP_HOT_RST_DONE\n" ); +pex_ep_event_hot_rst_done (pcie); +break ; + +case EP_BME_CHANGE : +dev_info (pcie->dev,"EVENT: EP_BME_CHANGE\n" ); +pex_ep_event_bme_change (pcie); +break ; + +case EP_EVENT_EXIT : +dev_info (pcie->dev,"EVENT: EP_EVENT_EXIT\n" ); +return 0 ; + +default : +dev_warn (pcie->dev,"Invalid PCIe EP event: %u\n" , + event); +break ; + } + } + +return 0 ; +} + +static irqreturn_t tegra_pcie_ep_pex_rst_irq (int irq,void *arg) +{ +struct tegra_pcie_dw *pcie = arg; + +if (gpiod_get_value (pcie->pex_rst_gpiod)) { +if (!kfifo_put (&pcie->event_fifo,EP_PEX_RST_ASSERT )) { +dev_err (pcie->dev,"EVENT FIFO is full\n" ); +return IRQ_HANDLED ; + } + }else { +if (!kfifo_put (&pcie->event_fifo,EP_PEX_RST_DEASSERT )) { +dev_err (pcie->dev,"EVENT FIFO is full\n" ); +return IRQ_HANDLED ; + } + } + +wake_up (&pcie->wq); + +return IRQ_HANDLED ; +} +[...]
Quoted 44 lines
drivers/pci/controller/dwc/pcie-tegra194.c +44
-0+static int tegra_pcie_config_ep (struct tegra_pcie_dw *pcie, +struct platform_device *pdev) +{ +struct dw_pcie *pci = &pcie->pci; +struct device *dev = pcie->dev; +struct dw_pcie_ep *ep; +struct resource *res; +char *name; +int ret; + + ep = &pci->ep; + ep->ops = &pcie_ep_ops; + + res =platform_get_resource_byname (pdev,IORESOURCE_MEM ,"addr_space" ); +if (!res) +return -EINVAL ; + + ep->phys_base = res->start; + ep->addr_size =resource_size (res); + ep->page_size =SZ_64K ; + + ret =gpiod_set_debounce (pcie->pex_rst_gpiod,PERST_DEBOUNCE_TIME ); +if (ret <0 ) { +dev_err (dev,"Failed to set PERST GPIO debounce time: %d\n" , + ret); +return ret; + } + + ret =gpiod_to_irq (pcie->pex_rst_gpiod); +if (ret <0 ) { +dev_err (dev,"Failed to get IRQ for PERST GPIO: %d\n" , ret); +return ret; + } + pcie->pex_rst_irq = (unsigned int )ret; + + name =devm_kasprintf (dev,GFP_KERNEL ,"tegra_pcie_%u_pex_rst_irq" , + pcie->cid); +if (!name) { +dev_err (dev,"Failed to create PERST IRQ string\n" ); +return -ENOMEM ; + } + +irq_set_status_flags (pcie->pex_rst_irq,IRQ_NOAUTOEN ); +
Quoted 8 lines
drivers/pci/controller/dwc/pcie-tegra194.c static int tegra_pcie_config_rp(struct tegra_pcie_dw *pcie) · line 2088
Quoted 4 lines
drivers/pci/controller/dwc/pcie-tegra194.c +4
-0+ ret =devm_request_irq (dev, pcie->pex_rst_irq, + tegra_pcie_ep_pex_rst_irq, +IRQF_TRIGGER_RISING |IRQF_TRIGGER_FALLING , + name, (void *)pcie);I have the impression that a threaded IRQ is what you need, which will also remove some boilerplate in the process. Any reason why you can't use a threaded IRQ instead of a standalone kthread ?
No reason specifically. We started with kthreads and continued with that. I'll post a new series with threaded IRQ. It should be doable.
Thanks,
Vidya Sagar
Quoted 4 lines
Thanks,
Lorenzo