From: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
To: Niklas Cassel <cassel@kernel.org>
Cc: "Jingoo Han" <jingoohan1@gmail.com>,
"Bjorn Helgaas" <bhelgaas@google.com>,
"Lorenzo Pieralisi" <lpieralisi@kernel.org>,
"Krzysztof Wilczyński" <kw@linux.com>,
"Rob Herring" <robh@kernel.org>,
"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
"Conor Dooley" <conor+dt@kernel.org>,
"Heiko Stuebner" <heiko@sntech.de>,
"Kishon Vijay Abraham I" <kishon@kernel.org>,
"Arnd Bergmann" <arnd@arndb.de>,
"Damien Le Moal" <dlemoal@kernel.org>,
"Jon Lin" <jon.lin@rock-chips.com>,
"Shawn Lin" <shawn.lin@rock-chips.com>,
"Simon Xue" <xxm@rock-chips.com>,
linux-pci@vger.kernel.org, devicetree@vger.kernel.org,
linux-rockchip@lists.infradead.org
Subject: Re: [PATCH v2 11/14] PCI: dw-rockchip: Add endpoint mode support
Date: Sat, 4 May 2024 23:02:01 +0530 [thread overview]
Message-ID: <20240504173201.GH4315@thinkpad> (raw)
In-Reply-To: <20240430-rockchip-pcie-ep-v1-v2-11-a0f5ee2a77b6@kernel.org>
On Tue, Apr 30, 2024 at 02:01:08PM +0200, Niklas Cassel wrote:
> The PCIe controller in rk3568 and rk3588 can operate in endpoint mode.
> This endpoint mode support heavily leverages the existing code in
> pcie-designware-ep.c.
>
> Add support for endpoint mode to the existing pcie-dw-rockchip glue
> driver.
>
> Signed-off-by: Niklas Cassel <cassel@kernel.org>
> ---
> drivers/pci/controller/dwc/Kconfig | 17 ++-
> drivers/pci/controller/dwc/pcie-dw-rockchip.c | 177 ++++++++++++++++++++++++++
> 2 files changed, 191 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/pci/controller/dwc/Kconfig b/drivers/pci/controller/dwc/Kconfig
> index 8afacc90c63b..9fae0d977271 100644
> --- a/drivers/pci/controller/dwc/Kconfig
> +++ b/drivers/pci/controller/dwc/Kconfig
> @@ -311,16 +311,27 @@ config PCIE_RCAR_GEN4_EP
> SoCs. To compile this driver as a module, choose M here: the module
> will be called pcie-rcar-gen4.ko. This uses the DesignWare core.
>
> +config PCIE_ROCKCHIP_DW
> + bool
> +
> config PCIE_ROCKCHIP_DW_HOST
> - bool "Rockchip DesignWare PCIe controller"
> - select PCIE_DW
> + bool "Rockchip DesignWare PCIe controller (host mode)"
> select PCIE_DW_HOST
> depends on PCI_MSI
> depends on ARCH_ROCKCHIP || COMPILE_TEST
> depends on OF
> help
> Enables support for the DesignWare PCIe controller in the
> - Rockchip SoC except RK3399.
> + Rockchip SoC (except RK3399) to work in host mode.
Just curious. RK3399 is an exception because lack of driver support or it
doesn't support EP mode at all?
> +
> +config PCIE_ROCKCHIP_DW_EP
> + bool "Rockchip DesignWare PCIe controller (endpoint mode)"
> + select PCIE_DW_EP
> + depends on ARCH_ROCKCHIP || COMPILE_TEST
> + depends on OF
> + help
> + Enables support for the DesignWare PCIe controller in the
> + Rockchip SoC (except RK3399) to work in endpoint mode.
>
> config PCI_EXYNOS
> tristate "Samsung Exynos PCIe controller"
> diff --git a/drivers/pci/controller/dwc/pcie-dw-rockchip.c b/drivers/pci/controller/dwc/pcie-dw-rockchip.c
> index f38d267e4e64..7614c20c7112 100644
> --- a/drivers/pci/controller/dwc/pcie-dw-rockchip.c
> +++ b/drivers/pci/controller/dwc/pcie-dw-rockchip.c
> @@ -34,10 +34,16 @@
> #define to_rockchip_pcie(x) dev_get_drvdata((x)->dev)
>
> #define PCIE_CLIENT_RC_MODE HIWORD_UPDATE_BIT(0x40)
> +#define PCIE_CLIENT_EP_MODE HIWORD_UPDATE(0xf0, 0x0)
> #define PCIE_CLIENT_ENABLE_LTSSM HIWORD_UPDATE_BIT(0xc)
> +#define PCIE_CLIENT_DISABLE_LTSSM HIWORD_UPDATE(0x0c, 0x8)
> +#define PCIE_CLIENT_INTR_STATUS_MISC 0x10
> +#define PCIE_CLIENT_INTR_MASK_MISC 0x24
> #define PCIE_SMLH_LINKUP BIT(16)
> #define PCIE_RDLH_LINKUP BIT(17)
> #define PCIE_LINKUP (PCIE_SMLH_LINKUP | PCIE_RDLH_LINKUP)
> +#define PCIE_RDLH_LINK_UP_CHGED BIT(1)
> +#define PCIE_LINK_REQ_RST_NOT_INT BIT(2)
> #define PCIE_L0S_ENTRY 0x11
> #define PCIE_CLIENT_GENERAL_CONTROL 0x0
> #define PCIE_CLIENT_INTR_STATUS_LEGACY 0x8
> @@ -159,6 +165,12 @@ static void rockchip_pcie_enable_ltssm(struct rockchip_pcie *rockchip)
> PCIE_CLIENT_GENERAL_CONTROL);
> }
>
> +static void rockchip_pcie_disable_ltssm(struct rockchip_pcie *rockchip)
> +{
> + rockchip_pcie_writel_apb(rockchip, PCIE_CLIENT_DISABLE_LTSSM,
> + PCIE_CLIENT_GENERAL_CONTROL);
> +}
> +
> static int rockchip_pcie_link_up(struct dw_pcie *pci)
> {
> struct rockchip_pcie *rockchip = to_rockchip_pcie(pci);
> @@ -195,6 +207,13 @@ static int rockchip_pcie_start_link(struct dw_pcie *pci)
> return 0;
> }
>
> +static void rockchip_pcie_stop_link(struct dw_pcie *pci)
> +{
> + struct rockchip_pcie *rockchip = to_rockchip_pcie(pci);
> +
> + rockchip_pcie_disable_ltssm(rockchip);
> +}
> +
> static int rockchip_pcie_host_init(struct dw_pcie_rp *pp)
> {
> struct dw_pcie *pci = to_dw_pcie_from_pp(pp);
> @@ -220,6 +239,59 @@ static const struct dw_pcie_host_ops rockchip_pcie_host_ops = {
> .init = rockchip_pcie_host_init,
> };
>
> +static void rockchip_pcie_ep_init(struct dw_pcie_ep *ep)
> +{
> + struct dw_pcie *pci = to_dw_pcie_from_ep(ep);
> + enum pci_barno bar;
> +
> + for (bar = 0; bar < PCI_STD_NUM_BARS; bar++)
> + dw_pcie_ep_reset_bar(pci, bar);
> +};
> +
> +static int rockchip_pcie_raise_irq(struct dw_pcie_ep *ep, u8 func_no,
> + unsigned int type, u16 interrupt_num)
> +{
> + struct dw_pcie *pci = to_dw_pcie_from_ep(ep);
> +
> + switch (type) {
> + case PCI_IRQ_INTX:
> + return dw_pcie_ep_raise_intx_irq(ep, func_no);
> + case PCI_IRQ_MSI:
> + return dw_pcie_ep_raise_msi_irq(ep, func_no, interrupt_num);
> + case PCI_IRQ_MSIX:
> + return dw_pcie_ep_raise_msix_irq(ep, func_no, interrupt_num);
> + default:
> + dev_err(pci->dev, "UNKNOWN IRQ type\n");
> + }
> +
> + return 0;
> +}
> +
> +static const struct pci_epc_features rockchip_pcie_epc_features = {
> + .linkup_notifier = true,
> + .msi_capable = true,
> + .msix_capable = true,
> + .align = SZ_64K,
> + .bar[BAR_0] = { .type = BAR_FIXED, .fixed_size = SZ_1M, },
> + .bar[BAR_1] = { .type = BAR_FIXED, .fixed_size = SZ_1M, },
> + .bar[BAR_2] = { .type = BAR_FIXED, .fixed_size = SZ_1M, },
> + .bar[BAR_3] = { .type = BAR_FIXED, .fixed_size = SZ_1M, },
> + .bar[BAR_4] = { .type = BAR_RESERVED, },
You have documented the reason for this in cover letter. But it'd be good if you
do the same in commit message also.
> + .bar[BAR_5] = { .type = BAR_FIXED, .fixed_size = SZ_1M, },
> +};
> +
> +static const struct pci_epc_features *
> +rockchip_pcie_get_features(struct dw_pcie_ep *ep)
> +{
> + return &rockchip_pcie_epc_features;
> +}
> +
> +static const struct dw_pcie_ep_ops rockchip_pcie_ep_ops = {
> + .init = rockchip_pcie_ep_init,
> + .raise_irq = rockchip_pcie_raise_irq,
> + .get_features = rockchip_pcie_get_features,
> +};
> +
> static int rockchip_pcie_clk_init(struct rockchip_pcie *rockchip)
> {
> struct device *dev = rockchip->pci.dev;
> @@ -284,8 +356,39 @@ static void rockchip_pcie_phy_deinit(struct rockchip_pcie *rockchip)
> static const struct dw_pcie_ops dw_pcie_ops = {
> .link_up = rockchip_pcie_link_up,
> .start_link = rockchip_pcie_start_link,
> + .stop_link = rockchip_pcie_stop_link,
> };
>
> +static irqreturn_t rockchip_pcie_ep_sys_irq_thread(int irq, void *arg)
> +{
> + struct rockchip_pcie *rockchip = arg;
> + struct dw_pcie *pci = &rockchip->pci;
> + struct device *dev = pci->dev;
> + u32 reg, val;
> +
> + reg = rockchip_pcie_readl_apb(rockchip, PCIE_CLIENT_INTR_STATUS_MISC);
> +
> + dev_dbg(dev, "PCIE_CLIENT_INTR_STATUS_MISC: %#x\n", reg);
> + dev_dbg(dev, "LTSSM_STATUS: %#x\n", rockchip_pcie_ltssm(rockchip));
> +
> + if (reg & PCIE_LINK_REQ_RST_NOT_INT) {
> + dev_dbg(dev, "hot reset or link-down reset\n");
'hot reset' means the host doing a hot reset?
Rest LGTM!
- Mani
--
மணிவண்ணன் சதாசிவம்
next prev parent reply other threads:[~2024-05-04 17:32 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-30 12:00 [PATCH v2 00/14] PCI: dw-rockchip: Add endpoint mode support Niklas Cassel
2024-04-30 12:00 ` [PATCH v2 01/14] dt-bindings: PCI: snps,dw-pcie-ep: Add vendor specific reg-name Niklas Cassel
2024-04-30 12:00 ` [PATCH v2 02/14] dt-bindings: PCI: snps,dw-pcie-ep: Add vendor specific interrupt-names Niklas Cassel
2024-04-30 12:01 ` [PATCH v2 03/14] dt-bindings: PCI: snps,dw-pcie-ep: Add tx_int{a,b,c,d} legacy irqs Niklas Cassel
2024-04-30 12:01 ` [PATCH v2 04/14] dt-bindings: PCI: rockchip-dw-pcie: Prepare for Endpoint mode support Niklas Cassel
2024-05-07 15:48 ` Rob Herring (Arm)
2024-04-30 12:01 ` [PATCH v2 05/14] dt-bindings: PCI: rockchip-dw-pcie: Fix description of legacy irq Niklas Cassel
2024-05-07 15:49 ` Rob Herring (Arm)
2024-04-30 12:01 ` [PATCH v2 06/14] dt-bindings: rockchip: Add DesignWare based PCIe Endpoint controller Niklas Cassel
2024-05-07 15:49 ` Rob Herring (Arm)
2024-04-30 12:01 ` [PATCH v2 07/14] PCI: dw-rockchip: Fix weird indentation Niklas Cassel
2024-05-04 17:10 ` Manivannan Sadhasivam
2024-04-30 12:01 ` [PATCH v2 08/14] PCI: dw-rockchip: Add rockchip_pcie_ltssm() helper Niklas Cassel
2024-05-04 17:13 ` Manivannan Sadhasivam
2024-05-07 23:55 ` Niklas Cassel
2024-04-30 12:01 ` [PATCH v2 09/14] PCI: dw-rockchip: Refactor the driver to prepare for EP mode Niklas Cassel
2024-05-04 17:19 ` Manivannan Sadhasivam
2024-04-30 12:01 ` [PATCH v2 10/14] PCI: dw-rockchip: Add explicit rockchip,rk3588-pcie compatible Niklas Cassel
2024-05-04 17:20 ` Manivannan Sadhasivam
2024-04-30 12:01 ` [PATCH v2 11/14] PCI: dw-rockchip: Add endpoint mode support Niklas Cassel
2024-05-04 17:32 ` Manivannan Sadhasivam [this message]
2024-05-07 23:50 ` Niklas Cassel
2024-04-30 12:01 ` [PATCH v2 12/14] misc: pci_endpoint_test: Add support for rockchip rk3588 Niklas Cassel
2024-05-04 17:33 ` Manivannan Sadhasivam
2024-04-30 12:01 ` [PATCH v2 13/14] arm64: dts: rockchip: Add PCIe endpoint mode support Niklas Cassel
2024-05-04 17:34 ` Manivannan Sadhasivam
2024-05-07 23:51 ` Niklas Cassel
2024-04-30 12:01 ` [PATCH v2 14/14] arm64: dts: rockchip: Add rock5b overlays for PCIe endpoint mode Niklas Cassel
2024-05-04 17:37 ` Manivannan Sadhasivam
2024-05-05 12:14 ` Heiko Stübner
2024-05-07 23:52 ` Niklas Cassel
2024-05-04 17:05 ` [PATCH v2 00/14] PCI: dw-rockchip: Add endpoint mode support Manivannan Sadhasivam
2024-05-07 23:48 ` Niklas Cassel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240504173201.GH4315@thinkpad \
--to=manivannan.sadhasivam@linaro.org \
--cc=arnd@arndb.de \
--cc=bhelgaas@google.com \
--cc=cassel@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dlemoal@kernel.org \
--cc=heiko@sntech.de \
--cc=jingoohan1@gmail.com \
--cc=jon.lin@rock-chips.com \
--cc=kishon@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=kw@linux.com \
--cc=linux-pci@vger.kernel.org \
--cc=linux-rockchip@lists.infradead.org \
--cc=lpieralisi@kernel.org \
--cc=robh@kernel.org \
--cc=shawn.lin@rock-chips.com \
--cc=xxm@rock-chips.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).