From: Manivannan Sadhasivam <mani@kernel.org>
To: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Cc: lpieralisi@kernel.org, kw@linux.com, robh@kernel.org,
bhelgaas@google.com, krzysztof.kozlowski+dt@linaro.org,
conor+dt@kernel.org, jingoohan1@gmail.com,
gustavo.pimentel@synopsys.com, marek.vasut+renesas@gmail.com,
linux-pci@vger.kernel.org, devicetree@vger.kernel.org,
linux-renesas-soc@vger.kernel.org,
Serge Semin <fancer.lancer@gmail.com>
Subject: Re: [PATCH v21 14/16] PCI: dwc: rcar-gen4: Add R-Car Gen4 PCIe Endpoint support
Date: Tue, 10 Oct 2023 17:36:57 +0530 [thread overview]
Message-ID: <20231010120657.GH4884@thinkpad> (raw)
In-Reply-To: <20230922065331.3806925-15-yoshihiro.shimoda.uh@renesas.com>
On Fri, Sep 22, 2023 at 03:53:29PM +0900, Yoshihiro Shimoda wrote:
> Add R-Car Gen4 PCIe controller for endpoint mode. This controller is based
> on Synopsys DesignWare PCIe.
>
> Link: https://lore.kernel.org/linux-pci/20230825093219.2685912-18-yoshihiro.shimoda.uh@renesas.com
> Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
- Mani
> Signed-off-by: Krzysztof Wilczyński <kwilczynski@kernel.org>
> Reviewed-by: Serge Semin <fancer.lancer@gmail.com>
> ---
> drivers/pci/controller/dwc/Kconfig | 11 ++
> drivers/pci/controller/dwc/pcie-rcar-gen4.c | 136 +++++++++++++++++++-
> 2 files changed, 144 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/pci/controller/dwc/Kconfig b/drivers/pci/controller/dwc/Kconfig
> index bc69fcab2e2a..e7fd37717998 100644
> --- a/drivers/pci/controller/dwc/Kconfig
> +++ b/drivers/pci/controller/dwc/Kconfig
> @@ -429,4 +429,15 @@ config PCIE_RCAR_GEN4_HOST
> 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_RCAR_GEN4_EP
> + tristate "Renesas R-Car Gen4 PCIe controller (endpoint mode)"
> + depends on ARCH_RENESAS || COMPILE_TEST
> + depends on PCI_ENDPOINT
> + select PCIE_DW_EP
> + select PCIE_RCAR_GEN4
> + help
> + Say Y here if you want PCIe controller (endpoint mode) on R-Car Gen4
> + 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.
> +
> endmenu
> diff --git a/drivers/pci/controller/dwc/pcie-rcar-gen4.c b/drivers/pci/controller/dwc/pcie-rcar-gen4.c
> index dfff6bb18932..68879b7308c5 100644
> --- a/drivers/pci/controller/dwc/pcie-rcar-gen4.c
> +++ b/drivers/pci/controller/dwc/pcie-rcar-gen4.c
> @@ -45,6 +45,9 @@
> #define RCAR_NUM_SPEED_CHANGE_RETRIES 10
> #define RCAR_MAX_LINK_SPEED 4
>
> +#define RCAR_GEN4_PCIE_EP_FUNC_DBI_OFFSET 0x1000
> +#define RCAR_GEN4_PCIE_EP_FUNC_DBI2_OFFSET 0x800
> +
> struct rcar_gen4_pcie {
> struct dw_pcie dw;
> void __iomem *base;
> @@ -53,6 +56,7 @@ struct rcar_gen4_pcie {
> };
> #define to_rcar_gen4_pcie(_dw) container_of(_dw, struct rcar_gen4_pcie, dw)
>
> +/* Common */
> static void rcar_gen4_pcie_ltssm_enable(struct rcar_gen4_pcie *rcar,
> bool enable)
> {
> @@ -310,6 +314,9 @@ static int rcar_gen4_add_dw_pcie_rp(struct rcar_gen4_pcie *rcar)
> {
> struct dw_pcie_rp *pp = &rcar->dw.pp;
>
> + if (!IS_ENABLED(CONFIG_PCIE_RCAR_GEN4_HOST))
> + return -ENODEV;
> +
> pp->num_vectors = MAX_MSI_IRQS;
> pp->ops = &rcar_gen4_pcie_host_ops;
> rcar->mode = DW_PCIE_RC_TYPE;
> @@ -322,8 +329,114 @@ static void rcar_gen4_remove_dw_pcie_rp(struct rcar_gen4_pcie *rcar)
> dw_pcie_host_deinit(&rcar->dw.pp);
> }
>
> +/* Endpoind mode */
> +static void rcar_gen4_pcie_ep_pre_init(struct dw_pcie_ep *ep)
> +{
> + struct dw_pcie *dw = to_dw_pcie_from_ep(ep);
> + struct rcar_gen4_pcie *rcar = to_rcar_gen4_pcie(dw);
> + int ret;
> +
> + ret = rcar_gen4_pcie_common_init(rcar);
> + if (ret)
> + return;
> +
> + writel(PCIEDMAINTSTSEN_INIT, rcar->base + PCIEDMAINTSTSEN);
> +}
> +
> +static void rcar_gen4_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 void rcar_gen4_pcie_ep_deinit(struct dw_pcie_ep *ep)
> +{
> + struct dw_pcie *dw = to_dw_pcie_from_ep(ep);
> + struct rcar_gen4_pcie *rcar = to_rcar_gen4_pcie(dw);
> +
> + writel(0, rcar->base + PCIEDMAINTSTSEN);
> + rcar_gen4_pcie_common_deinit(rcar);
> +}
> +
> +static int rcar_gen4_pcie_ep_raise_irq(struct dw_pcie_ep *ep, u8 func_no,
> + unsigned int type, u16 interrupt_num)
> +{
> + struct dw_pcie *dw = to_dw_pcie_from_ep(ep);
> +
> + switch (type) {
> + case PCI_IRQ_LEGACY:
> + return dw_pcie_ep_raise_legacy_irq(ep, func_no);
> + case PCI_IRQ_MSI:
> + return dw_pcie_ep_raise_msi_irq(ep, func_no, interrupt_num);
> + default:
> + dev_err(dw->dev, "Unknown IRQ type\n");
> + return -EINVAL;
> + }
> +
> + return 0;
> +}
> +
> +static const struct pci_epc_features rcar_gen4_pcie_epc_features = {
> + .linkup_notifier = false,
> + .msi_capable = true,
> + .msix_capable = false,
> + .reserved_bar = 1 << BAR_1 | 1 << BAR_3 | 1 << BAR_5,
> + .align = SZ_1M,
> +};
> +
> +static const struct pci_epc_features*
> +rcar_gen4_pcie_ep_get_features(struct dw_pcie_ep *ep)
> +{
> + return &rcar_gen4_pcie_epc_features;
> +}
> +
> +static unsigned int rcar_gen4_pcie_ep_func_conf_select(struct dw_pcie_ep *ep,
> + u8 func_no)
> +{
> + return func_no * RCAR_GEN4_PCIE_EP_FUNC_DBI_OFFSET;
> +}
> +
> +static unsigned int rcar_gen4_pcie_ep_get_dbi2_offset(struct dw_pcie_ep *ep,
> + u8 func_no)
> +{
> + return func_no * RCAR_GEN4_PCIE_EP_FUNC_DBI2_OFFSET;
> +}
> +
> +static const struct dw_pcie_ep_ops pcie_ep_ops = {
> + .pre_init = rcar_gen4_pcie_ep_pre_init,
> + .ep_init = rcar_gen4_pcie_ep_init,
> + .deinit = rcar_gen4_pcie_ep_deinit,
> + .raise_irq = rcar_gen4_pcie_ep_raise_irq,
> + .get_features = rcar_gen4_pcie_ep_get_features,
> + .func_conf_select = rcar_gen4_pcie_ep_func_conf_select,
> + .get_dbi2_offset = rcar_gen4_pcie_ep_get_dbi2_offset,
> +};
> +
> +static int rcar_gen4_add_dw_pcie_ep(struct rcar_gen4_pcie *rcar)
> +{
> + struct dw_pcie_ep *ep = &rcar->dw.ep;
> +
> + if (!IS_ENABLED(CONFIG_PCIE_RCAR_GEN4_EP))
> + return -ENODEV;
> +
> + rcar->mode = DW_PCIE_EP_TYPE;
> + ep->ops = &pcie_ep_ops;
> +
> + return dw_pcie_ep_init(ep);
> +}
> +
> +static void rcar_gen4_remove_dw_pcie_ep(struct rcar_gen4_pcie *rcar)
> +{
> + dw_pcie_ep_exit(&rcar->dw.ep);
> +}
> +
> +/* Common */
> static int rcar_gen4_pcie_probe(struct platform_device *pdev)
> {
> + enum dw_pcie_device_mode mode;
> struct rcar_gen4_pcie *rcar;
> int err;
>
> @@ -339,7 +452,13 @@ static int rcar_gen4_pcie_probe(struct platform_device *pdev)
> if (err)
> return err;
>
> - err = rcar_gen4_add_dw_pcie_rp(rcar);
> + mode = (enum dw_pcie_device_mode)of_device_get_match_data(&pdev->dev);
> +
> + if (mode == DW_PCIE_RC_TYPE)
> + err = rcar_gen4_add_dw_pcie_rp(rcar);
> + else if (mode == DW_PCIE_EP_TYPE)
> + err = rcar_gen4_add_dw_pcie_ep(rcar);
> +
> if (err)
> goto err_unprepare;
>
> @@ -355,12 +474,23 @@ static void rcar_gen4_pcie_remove(struct platform_device *pdev)
> {
> struct rcar_gen4_pcie *rcar = platform_get_drvdata(pdev);
>
> - rcar_gen4_remove_dw_pcie_rp(rcar);
> + if (rcar->mode == DW_PCIE_RC_TYPE)
> + rcar_gen4_remove_dw_pcie_rp(rcar);
> + else if (rcar->mode == DW_PCIE_EP_TYPE)
> + rcar_gen4_remove_dw_pcie_ep(rcar);
> +
> rcar_gen4_pcie_unprepare(rcar);
> }
>
> static const struct of_device_id rcar_gen4_pcie_of_match[] = {
> - { .compatible = "renesas,rcar-gen4-pcie", },
> + {
> + .compatible = "renesas,rcar-gen4-pcie",
> + .data = (void *)DW_PCIE_RC_TYPE,
> + },
> + {
> + .compatible = "renesas,rcar-gen4-pcie-ep",
> + .data = (void *)DW_PCIE_EP_TYPE,
> + },
> {},
> };
> MODULE_DEVICE_TABLE(of, rcar_gen4_pcie_of_match);
> --
> 2.25.1
>
--
மணிவண்ணன் சதாசிவம்
next prev parent reply other threads:[~2023-10-10 12:07 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-22 6:53 [PATCH v21 00/16] PCI: dwc: rcar-gen4: Add R-Car Gen4 PCIe support Yoshihiro Shimoda
2023-09-22 6:53 ` [PATCH v21 01/16] PCI: dwc: endpoint: Add multiple PFs support for dbi2 Yoshihiro Shimoda
2023-10-10 11:12 ` Manivannan Sadhasivam
2023-10-11 0:46 ` Yoshihiro Shimoda
2023-09-22 6:53 ` [PATCH v21 02/16] PCI: dwc: Add dw_pcie_link_set_max_link_width() Yoshihiro Shimoda
2023-09-22 6:53 ` [PATCH v21 03/16] PCI: dwc: Add missing PCI_EXP_LNKCAP_MLW handling Yoshihiro Shimoda
2023-10-10 11:14 ` Manivannan Sadhasivam
2023-09-22 6:53 ` [PATCH v21 04/16] PCI: tegra194: Drop PCI_EXP_LNKSTA_NLW setting Yoshihiro Shimoda
2023-09-22 6:53 ` [PATCH v21 05/16] PCI: dwc: Add EDMA_UNROLL capability flag Yoshihiro Shimoda
2023-09-22 6:53 ` [PATCH v21 06/16] PCI: dwc: Expose dw_pcie_ep_exit() to module Yoshihiro Shimoda
2023-09-22 6:53 ` [PATCH v21 07/16] PCI: dwc: Expose dw_pcie_write_dbi2() " Yoshihiro Shimoda
2023-10-10 11:15 ` Manivannan Sadhasivam
2023-09-22 6:53 ` [PATCH v21 08/16] PCI: dwc: endpoint: Introduce .pre_init() and .deinit() Yoshihiro Shimoda
2023-10-10 11:17 ` Manivannan Sadhasivam
2023-09-22 6:53 ` [PATCH v21 09/16] dt-bindings: PCI: dwc: Update maxItems of reg and reg-names Yoshihiro Shimoda
2023-09-22 6:53 ` [PATCH v21 10/16] dt-bindings: PCI: renesas: Add R-Car Gen4 PCIe Host Yoshihiro Shimoda
2023-10-10 11:25 ` Manivannan Sadhasivam
2023-10-11 0:54 ` Yoshihiro Shimoda
2023-10-11 4:43 ` Manivannan Sadhasivam
2023-09-22 6:53 ` [PATCH v21 11/16] dt-bindings: PCI: renesas: Add R-Car Gen4 PCIe Endpoint Yoshihiro Shimoda
2023-09-22 6:53 ` [PATCH v21 12/16] PCI: add T_PVPERL macro Yoshihiro Shimoda
2023-10-10 11:30 ` Manivannan Sadhasivam
2023-10-11 0:56 ` Yoshihiro Shimoda
2023-09-22 6:53 ` [PATCH v21 13/16] PCI: dwc: rcar-gen4: Add R-Car Gen4 PCIe controller support Yoshihiro Shimoda
2023-09-22 13:47 ` kernel test robot
2023-09-25 6:54 ` Yoshihiro Shimoda
2023-10-10 12:04 ` Manivannan Sadhasivam
2023-10-11 1:18 ` Yoshihiro Shimoda
2023-10-11 4:41 ` Manivannan Sadhasivam
2023-10-11 5:06 ` Yoshihiro Shimoda
2023-09-22 6:53 ` [PATCH v21 14/16] PCI: dwc: rcar-gen4: Add R-Car Gen4 PCIe Endpoint support Yoshihiro Shimoda
2023-10-10 12:06 ` Manivannan Sadhasivam [this message]
2023-09-22 6:53 ` [PATCH v21 15/16] MAINTAINERS: Update PCI DRIVER FOR RENESAS R-CAR for R-Car Gen4 Yoshihiro Shimoda
2023-09-22 6:53 ` [PATCH v21 16/16] misc: pci_endpoint_test: Add Device ID for R-Car S4-8 PCIe controller Yoshihiro Shimoda
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=20231010120657.GH4884@thinkpad \
--to=mani@kernel.org \
--cc=bhelgaas@google.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=fancer.lancer@gmail.com \
--cc=gustavo.pimentel@synopsys.com \
--cc=jingoohan1@gmail.com \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=kw@linux.com \
--cc=linux-pci@vger.kernel.org \
--cc=linux-renesas-soc@vger.kernel.org \
--cc=lpieralisi@kernel.org \
--cc=marek.vasut+renesas@gmail.com \
--cc=robh@kernel.org \
--cc=yoshihiro.shimoda.uh@renesas.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.