All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bjorn Helgaas <helgaas@kernel.org>
To: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Cc: lpieralisi@kernel.org, robh+dt@kernel.org, kw@linux.com,
	bhelgaas@google.com, krzk+dt@kernel.org, geert+renesas@glider.be,
	magnus.damm@gmail.com, marek.vasut+renesas@gmail.com,
	linux-pci@vger.kernel.org, devicetree@vger.kernel.org,
	linux-renesas-soc@vger.kernel.org
Subject: Re: [PATCH 3/7] PCI: renesas: Add R-Car Gen4 PCIe Host support
Date: Mon, 13 Jun 2022 15:34:06 -0500	[thread overview]
Message-ID: <20220613203406.GA714216@bhelgaas> (raw)
In-Reply-To: <20220613115712.2831386-4-yoshihiro.shimoda.uh@renesas.com>

On Mon, Jun 13, 2022 at 08:57:08PM +0900, Yoshihiro Shimoda wrote:
> Add R-Car Gen4 PCIe Host support. This controller is based on
> Synopsys Designware PCIe.

You used "DesignWare" below, which I think is what Synopsys uses.

> Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
> ---
>  drivers/pci/controller/dwc/Kconfig            |   9 +
>  drivers/pci/controller/dwc/Makefile           |   1 +
>  .../pci/controller/dwc/pcie-rcar-gen4-host.c  | 235 ++++++++++++++++++
>  drivers/pci/controller/dwc/pcie-rcar-gen4.c   | 198 +++++++++++++++
>  drivers/pci/controller/dwc/pcie-rcar-gen4.h   |  59 +++++
>  5 files changed, 502 insertions(+)
>  create mode 100644 drivers/pci/controller/dwc/pcie-rcar-gen4-host.c
>  create mode 100644 drivers/pci/controller/dwc/pcie-rcar-gen4.c
>  create mode 100644 drivers/pci/controller/dwc/pcie-rcar-gen4.h
> 
> diff --git a/drivers/pci/controller/dwc/Kconfig b/drivers/pci/controller/dwc/Kconfig
> index 62ce3abf0f19..3ddccc9c38c5 100644
> --- a/drivers/pci/controller/dwc/Kconfig
> +++ b/drivers/pci/controller/dwc/Kconfig
> @@ -384,4 +384,13 @@ config PCIE_FU740
>  	  Say Y here if you want PCIe controller support for the SiFive
>  	  FU740.
>  
> +config PCIE_RCAR_GEN4
> +	bool "Renesas R-Car Gen4 PCIe Host controller"
> +	depends on ARCH_RENESAS || COMPILE_TEST
> +	depends on PCI_MSI_IRQ_DOMAIN
> +	select PCIE_DW_HOST
> +	help
> +	  Say Y here if you want PCIe host controller support on R-Car Gen4 SoCs.
> +	  This uses the DesignWare core.

> +++ b/drivers/pci/controller/dwc/pcie-rcar-gen4-host.c
> @@ -0,0 +1,235 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * PCIe host controller driver for Renesas R-Car Gen4 Series SoCs
> + * Copyright (C) 2022 Renesas Electronics Corporation
> + */
> +
> +#include <linux/interrupt.h>
> +#include <linux/module.h>
> +#include <linux/of_device.h>
> +#include <linux/pci.h>
> +#include <linux/platform_device.h>
> +
> +#include "pcie-rcar-gen4.h"
> +#include "pcie-designware.h"
> +
> +/* ASPM L1 PM Substates */
> +#define L1PSCAP(x)		(0x01bc + (x))

Looks like the stuff in pcie-rcar-gen4.h.  Should this go there?

> +	/* Set Max Link Width */

Superfluous comment, since the function name says the same thing.

> +	rcar_gen4_pcie_set_max_link_width(pci, pci->num_lanes);

> +/* Link Capabilities - Maximum Link Width */
> +#define  PCI_EXP_LNKCAP_MLW_X1	BIT(4)
> +#define  PCI_EXP_LNKCAP_MLW_X2	BIT(5)
> +#define  PCI_EXP_LNKCAP_MLW_X4	BIT(6)

I think we should define these in include/uapi/linux/pci_regs.h.
Use the same style as the other #defines there, i.e.,

  #define  PCI_EXP_LNKCAP_MLW_X1  0x00000010
  #define  PCI_EXP_LNKCAP_MLW_X2  0x00000020
  #define  PCI_EXP_LNKCAP_MLW_X4  0x00000040

> +/* Renesas-specific */
> +#define PCIEMSR0		0x0000
> +#define  BIFUR_MOD_SET_ON	(0x1 << 0)
> +#define  DEVICE_TYPE_EP		(0x0 << 2)
> +#define  DEVICE_TYPE_RC		(0x4 << 2)
> +
> +#define PCIEINTSTS0		0x0084
> +#define PCIEINTSTS0EN		0x0310
> +#define  MSI_CTRL_INT		BIT(26)
> +#define  SMLH_LINK_UP		BIT(7)
> +#define  RDLH_LINK_UP		BIT(6)

Is there a reason to mix the "(0x1 << 0)" style and the "BIT(26)"
styles?

> +extern u32 rcar_gen4_pcie_readl(struct rcar_gen4_pcie *pcie, u32 reg);
> +extern void rcar_gen4_pcie_writel(struct rcar_gen4_pcie *pcie, u32 reg, u32 val);
> +extern void rcar_gen4_pcie_set_max_link_width(struct dw_pcie *pci, int num_lanes);
> +extern int rcar_gen4_pcie_prepare(struct rcar_gen4_pcie *pcie);
> +extern void rcar_gen4_pcie_unprepare(struct rcar_gen4_pcie *pcie);
> +extern int rcar_gen4_pcie_pm_runtime_enable(struct device *dev);
> +extern void rcar_gen4_pcie_pm_runtime_disable(struct device *dev);
> +extern int rcar_gen4_pcie_devm_clk_and_reset_get(struct rcar_gen4_pcie *pcie,
> +						 struct device *dev);
> +extern struct rcar_gen4_pcie *rcar_gen4_pcie_devm_alloc(struct device *dev);

Don't bother with "extern" on function declarations; this would be the
only instance in drivers/pci/.

  reply	other threads:[~2022-06-13 20:59 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-13 11:57 [PATCH 0/7] treewide: PCI: renesas: Add R-Car Gen4 PCIe support Yoshihiro Shimoda
2022-06-13 11:57 ` [PATCH 1/7] dt-bindings: PCI: renesas: Add R-Car Gen4 PCIe Host Yoshihiro Shimoda
2022-06-13 17:34   ` Rob Herring
2022-06-13 17:53   ` Rob Herring
2022-06-15  8:48   ` Geert Uytterhoeven
2022-06-16 11:51     ` Yoshihiro Shimoda
2022-06-13 11:57 ` [PATCH 2/7] dt-bindings: PCI: renesas: Add R-Car Gen4 PCIe Endpoint Yoshihiro Shimoda
2022-06-13 17:34   ` Rob Herring
2022-06-13 21:53   ` Rob Herring
2022-06-15  8:50   ` Geert Uytterhoeven
2022-06-16 11:51     ` Yoshihiro Shimoda
2022-06-13 11:57 ` [PATCH 3/7] PCI: renesas: Add R-Car Gen4 PCIe Host support Yoshihiro Shimoda
2022-06-13 20:34   ` Bjorn Helgaas [this message]
2022-06-14 11:57     ` Yoshihiro Shimoda
2022-06-13 11:57 ` [PATCH 4/7] PCI: renesas: Add R-Car Gen4 PCIe Endpoint support Yoshihiro Shimoda
2022-06-13 21:50   ` Rob Herring
2022-06-14 11:58     ` Yoshihiro Shimoda
2022-06-14 19:42       ` Rob Herring
2022-06-15  8:10         ` Yoshihiro Shimoda
2022-06-13 11:57 ` [PATCH 5/7] MAINTAINERS: Update PCI DRIVER FOR RENESAS R-CAR for R-Car Gen4 Yoshihiro Shimoda
2022-06-13 11:57 ` [PATCH 6/7] arm64: dts: renesas: r8a779f0: Add PCIe Host and Endpoint nodes Yoshihiro Shimoda
2022-06-13 11:57 ` [PATCH 7/7] arm64: dts: renesas: r8a779f0: spider: Enable PCIe Host ch0 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=20220613203406.GA714216@bhelgaas \
    --to=helgaas@kernel.org \
    --cc=bhelgaas@google.com \
    --cc=devicetree@vger.kernel.org \
    --cc=geert+renesas@glider.be \
    --cc=krzk+dt@kernel.org \
    --cc=kw@linux.com \
    --cc=linux-pci@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=lpieralisi@kernel.org \
    --cc=magnus.damm@gmail.com \
    --cc=marek.vasut+renesas@gmail.com \
    --cc=robh+dt@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.