From: Bjorn Helgaas <helgaas@kernel.org>
To: Lorenzo Bianconi <lorenzo@kernel.org>
Cc: linux-pci@vger.kernel.org, ryder.lee@mediatek.com,
lpieralisi@kernel.org, kw@linux.com, robh@kernel.org,
bhelgaas@google.com, linux-mediatek@lists.infradead.org,
lorenzo.bianconi83@gmail.com,
linux-arm-kernel@lists.infradead.org,
krzysztof.kozlowski+dt@linaro.org, devicetree@vger.kernel.org,
nbd@nbd.name, dd@embedd.com, upstream@airoha.com,
angelogioacchino.delregno@collabora.com
Subject: Re: [PATCH 4/4] PCI: mediatek-gen3: Add Airoha EN7581 support
Date: Fri, 21 Jun 2024 13:02:50 -0500 [thread overview]
Message-ID: <20240621180250.GA1396831@bhelgaas> (raw)
In-Reply-To: <f044eb44654522801d4a93e94918a32c72c4c49f.1718980864.git.lorenzo@kernel.org>
On Fri, Jun 21, 2024 at 04:48:50PM +0200, Lorenzo Bianconi wrote:
> Introduce support for Airoha EN7581 pcie controller to mediatek-gen3
> pcie controller driver.
s/pcie/PCIe/ (twice)
> Tested-by: Zhengping Zhang <zhengping.zhang@airoha.com>
> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
> ---
> drivers/pci/controller/Kconfig | 2 +-
> drivers/pci/controller/pcie-mediatek-gen3.c | 84 ++++++++++++++++++++-
> 2 files changed, 84 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/pci/controller/Kconfig b/drivers/pci/controller/Kconfig
> index e534c02ee34f..3bd6c9430010 100644
> --- a/drivers/pci/controller/Kconfig
> +++ b/drivers/pci/controller/Kconfig
> @@ -196,7 +196,7 @@ config PCIE_MEDIATEK
>
> config PCIE_MEDIATEK_GEN3
> tristate "MediaTek Gen3 PCIe controller"
> - depends on ARCH_MEDIATEK || COMPILE_TEST
> + depends on ARCH_AIROHA || ARCH_MEDIATEK || COMPILE_TEST
> depends on PCI_MSI
> help
> Adds support for PCIe Gen3 MAC controller for MediaTek SoCs.
> diff --git a/drivers/pci/controller/pcie-mediatek-gen3.c b/drivers/pci/controller/pcie-mediatek-gen3.c
> index 9842617795a9..2dacfed665c6 100644
> --- a/drivers/pci/controller/pcie-mediatek-gen3.c
> +++ b/drivers/pci/controller/pcie-mediatek-gen3.c
> @@ -7,6 +7,7 @@
> */
>
> #include <linux/clk.h>
> +#include <linux/clk-provider.h>
> #include <linux/delay.h>
> #include <linux/iopoll.h>
> #include <linux/irq.h>
> @@ -21,6 +22,8 @@
> #include <linux/pm_domain.h>
> #include <linux/pm_runtime.h>
> #include <linux/reset.h>
> +#include <linux/of_pci.h>
> +#include <linux/of_device.h>
Existing list of includes is sorted. Preserve that sorted order.
> +static int mtk_pcie_en7581_power_up(struct mtk_gen3_pcie *pcie)
> +{
> + struct device *dev = pcie->dev;
> + int err;
> +
> + writel_relaxed(0x23020133, pcie->base + 0x10044);
> + writel_relaxed(0x50500032, pcie->base + 0x15030);
> + writel_relaxed(0x50500032, pcie->base + 0x15130);
Magic. Needs #defines at least for the registers. These offsets are
HUGE, far bigger than the existing offsets:
#define PCIE_CFGNUM_REG 0x140
#define PCIE_CFG_OFFSET_ADDR 0x1000
#define PCIE_TRANS_TABLE_BASE_REG 0x800
#define PCIE_MSI_SET_BASE_REG 0xc00
#define PCIE_MSI_SET_ADDR_HI_BASE 0xc80
#define PCIE_MSI_SET_ENABLE_REG 0x190
#define PCIE_INT_ENABLE_REG 0x180
#define PCIE_SETTING_REG 0x80
#define PCIE_PCI_IDS_1 0x9c
#define PCIE_MISC_CTRL_REG 0x348
#define PCIE_RST_CTRL_REG 0x148
#define PCIE_LINK_STATUS_REG 0x154
#define PCIE_LTSSM_STATUS_REG 0x150
#define PCIE_INT_STATUS_REG 0x184
> + err = phy_init(pcie->phy);
> + if (err) {
> + dev_err(dev, "failed to initialize PHY\n");
> + return err;
> + }
> + mdelay(30);
Source? Cite the spec that requires this delay and add a #define if
possible.
> + err = phy_power_on(pcie->phy);
> + if (err) {
> + dev_err(dev, "failed to power on PHY\n");
> + goto err_phy_on;
> + }
> +
> + err = reset_control_bulk_deassert(pcie->soc->phy_resets.num_rsts,
> + pcie->phy_resets);
> + if (err) {
> + dev_err(dev, "failed to deassert PHYs\n");
> + goto err_phy_deassert;
> + }
> + usleep_range(5000, 10000);
Source?
> + pm_runtime_enable(dev);
> + pm_runtime_get_sync(dev);
> +
> + err = clk_bulk_prepare(pcie->num_clks, pcie->clks);
> + if (err) {
> + dev_err(dev, "failed to prepare clock\n");
> + goto err_clk_prepare;
> + }
> +
> + writel_relaxed(0x41474147, pcie->base + PCIE_EQ_PRESET_01_REF);
> + writel_relaxed(0x1018020f, pcie->base + PCIE_PIPE4_PIE8_REG);
> + mdelay(10);
Source?
next prev parent reply other threads:[~2024-06-21 18:02 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-21 14:48 [PATCH 0/4] Add Airoha EN7581 PCIE support Lorenzo Bianconi
2024-06-21 14:48 ` [PATCH 1/4] dt-bindings: PCI: mediatek-gen3: add support for Airoha EN7581 Lorenzo Bianconi
2024-06-22 12:04 ` Conor Dooley
2024-06-23 9:31 ` Lorenzo Bianconi
2024-06-21 14:48 ` [PATCH 2/4] PCI: mediatek-gen3: Add mtk_pcie_soc data structure Lorenzo Bianconi
2024-06-24 7:57 ` AngeloGioacchino Del Regno
2024-06-27 6:50 ` Lorenzo Bianconi
2024-06-21 14:48 ` [PATCH 3/4] PCI: mediatek-gen3: rely on reset_bulk APIs for phy reset lines Lorenzo Bianconi
2024-06-21 17:51 ` Bjorn Helgaas
2024-06-21 21:43 ` Lorenzo Bianconi
2024-06-24 8:01 ` AngeloGioacchino Del Regno
2024-06-27 7:03 ` Lorenzo Bianconi
2024-06-21 14:48 ` [PATCH 4/4] PCI: mediatek-gen3: Add Airoha EN7581 support Lorenzo Bianconi
2024-06-21 18:02 ` Bjorn Helgaas [this message]
2024-06-21 22:03 ` Lorenzo Bianconi
2024-06-24 7:55 ` AngeloGioacchino Del Regno
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=20240621180250.GA1396831@bhelgaas \
--to=helgaas@kernel.org \
--cc=angelogioacchino.delregno@collabora.com \
--cc=bhelgaas@google.com \
--cc=dd@embedd.com \
--cc=devicetree@vger.kernel.org \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=kw@linux.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=linux-pci@vger.kernel.org \
--cc=lorenzo.bianconi83@gmail.com \
--cc=lorenzo@kernel.org \
--cc=lpieralisi@kernel.org \
--cc=nbd@nbd.name \
--cc=robh@kernel.org \
--cc=ryder.lee@mediatek.com \
--cc=upstream@airoha.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).