From: Hal Feng <hal.feng@starfivetech.com>
To: Leo <ycliang@andestech.com>, Tom Rini <trini@konsulko.com>,
Sumit Garg <sumit.garg@linaro.org>,
Rick Chen <rick@andestech.com>,
Heinrich Schuchardt <xypron.glpk@gmx.de>,
H Bell <dmoo_dv@protonmail.com>, E Shattow <lucent@gmail.com>,
Conor Dooley <conor.dooley@microchip.com>,
Nam Cao <namcao@linutronix.de>, Bo Gan <ganboing@gmail.com>
Cc: Emil Renner Berthing <emil.renner.berthing@canonical.com>,
Minda Chen <minda.chen@starfivetech.com>,
Hal Feng <hal.feng@starfivetech.com>,
u-boot@lists.denx.de
Subject: [PATCH v6 03/11] pcie: starfive: Make the driver compatible with upstream DT
Date: Mon, 25 Nov 2024 08:31:57 +0800 [thread overview]
Message-ID: <20241125003205.75327-4-hal.feng@starfivetech.com> (raw)
In-Reply-To: <20241125003205.75327-1-hal.feng@starfivetech.com>
There are difference between upstream DT and the old DT
in terms of reg base, reset gpio and syscon. Make the driver
compatible with upstream DT.
Tested-by: E Shattow <lucent@gmail.com>
Signed-off-by: Hal Feng <hal.feng@starfivetech.com>
---
drivers/pci/pcie_starfive_jh7110.c | 59 +++++++++++++++---------------
1 file changed, 30 insertions(+), 29 deletions(-)
diff --git a/drivers/pci/pcie_starfive_jh7110.c b/drivers/pci/pcie_starfive_jh7110.c
index 569fbfd35c..51aca7359f 100644
--- a/drivers/pci/pcie_starfive_jh7110.c
+++ b/drivers/pci/pcie_starfive_jh7110.c
@@ -25,13 +25,19 @@
#include "pcie_plda_common.h"
/* system control */
-#define STG_SYSCON_K_RP_NEP_MASK BIT(8)
+#define STG_SYSCON_PCIE0_BASE 0x48
+#define STG_SYSCON_PCIE1_BASE 0x1f8
+
+#define STG_SYSCON_AR_OFFSET 0x78
#define STG_SYSCON_AXI4_SLVL_ARFUNC_MASK GENMASK(22, 8)
#define STG_SYSCON_AXI4_SLVL_ARFUNC_SHIFT 8
+#define STG_SYSCON_AW_OFFSET 0x7c
#define STG_SYSCON_AXI4_SLVL_AWFUNC_MASK GENMASK(14, 0)
#define STG_SYSCON_CLKREQ_MASK BIT(22)
#define STG_SYSCON_CKREF_SRC_SHIFT 18
#define STG_SYSCON_CKREF_SRC_MASK GENMASK(19, 18)
+#define STG_SYSCON_RP_NEP_OFFSET 0xe8
+#define STG_SYSCON_K_RP_NEP_MASK BIT(8)
DECLARE_GLOBAL_DATA_PTR;
@@ -41,9 +47,7 @@ struct starfive_pcie {
struct reset_ctl_bulk rsts;
struct gpio_desc reset_gpio;
struct regmap *regmap;
- u32 stg_arfun;
- u32 stg_awfun;
- u32 stg_rp_nep;
+ unsigned int stg_pcie_base;
};
static int starfive_pcie_atr_init(struct starfive_pcie *priv)
@@ -92,7 +96,6 @@ static int starfive_pcie_get_syscon(struct udevice *dev)
struct starfive_pcie *priv = dev_get_priv(dev);
struct udevice *syscon;
struct ofnode_phandle_args syscfg_phandle;
- u32 cells[4];
int ret;
/* get corresponding syscon phandle */
@@ -117,20 +120,6 @@ static int starfive_pcie_get_syscon(struct udevice *dev)
return -ENODEV;
}
- /* get syscon register offset */
- ret = dev_read_u32_array(dev, "starfive,stg-syscon",
- cells, ARRAY_SIZE(cells));
- if (ret) {
- dev_err(dev, "Get syscon register err %d\n", ret);
- return -EINVAL;
- }
-
- dev_dbg(dev, "Get syscon values: %x, %x, %x\n",
- cells[1], cells[2], cells[3]);
- priv->stg_arfun = cells[1];
- priv->stg_awfun = cells[2];
- priv->stg_rp_nep = cells[3];
-
return 0;
}
@@ -138,8 +127,9 @@ static int starfive_pcie_parse_dt(struct udevice *dev)
{
struct starfive_pcie *priv = dev_get_priv(dev);
int ret;
+ u32 domain_nr;
- priv->plda.reg_base = (void *)dev_read_addr_name(dev, "reg");
+ priv->plda.reg_base = (void *)dev_read_addr_name(dev, "apb");
if (priv->plda.reg_base == (void __iomem *)FDT_ADDR_T_NONE) {
dev_err(dev, "Missing required reg address range\n");
return -EINVAL;
@@ -147,7 +137,7 @@ static int starfive_pcie_parse_dt(struct udevice *dev)
priv->plda.cfg_base =
(void *)dev_read_addr_size_name(dev,
- "config",
+ "cfg",
&priv->plda.cfg_size);
if (priv->plda.cfg_base == (void __iomem *)FDT_ADDR_T_NONE) {
dev_err(dev, "Missing required config address range");
@@ -172,7 +162,18 @@ static int starfive_pcie_parse_dt(struct udevice *dev)
return ret;
}
- ret = gpio_request_by_name(dev, "reset-gpios", 0, &priv->reset_gpio,
+ ret = dev_read_u32(dev, "linux,pci-domain", &domain_nr);
+ if (ret) {
+ dev_err(dev, "Can't get pci domain: %d\n", ret);
+ return ret;
+ }
+
+ if (domain_nr == 0)
+ priv->stg_pcie_base = STG_SYSCON_PCIE0_BASE;
+ else
+ priv->stg_pcie_base = STG_SYSCON_PCIE1_BASE;
+
+ ret = gpio_request_by_name(dev, "perst-gpios", 0, &priv->reset_gpio,
GPIOD_IS_OUT);
if (ret) {
dev_err(dev, "Can't get reset-gpio: %d\n", ret);
@@ -208,12 +209,12 @@ static int starfive_pcie_init_port(struct udevice *dev)
/* Disable physical functions except #0 */
for (i = 1; i < PLDA_FUNC_NUM; i++) {
regmap_update_bits(priv->regmap,
- priv->stg_arfun,
+ priv->stg_pcie_base + STG_SYSCON_AR_OFFSET,
STG_SYSCON_AXI4_SLVL_ARFUNC_MASK,
(i << PLDA_PHY_FUNC_SHIFT) <<
STG_SYSCON_AXI4_SLVL_ARFUNC_SHIFT);
regmap_update_bits(priv->regmap,
- priv->stg_awfun,
+ priv->stg_pcie_base + STG_SYSCON_AW_OFFSET,
STG_SYSCON_AXI4_SLVL_AWFUNC_MASK,
i << PLDA_PHY_FUNC_SHIFT);
@@ -222,11 +223,11 @@ static int starfive_pcie_init_port(struct udevice *dev)
/* Disable physical functions */
regmap_update_bits(priv->regmap,
- priv->stg_arfun,
+ priv->stg_pcie_base + STG_SYSCON_AR_OFFSET,
STG_SYSCON_AXI4_SLVL_ARFUNC_MASK,
0);
regmap_update_bits(priv->regmap,
- priv->stg_awfun,
+ priv->stg_pcie_base + STG_SYSCON_AW_OFFSET,
STG_SYSCON_AXI4_SLVL_AWFUNC_MASK,
0);
@@ -273,17 +274,17 @@ static int starfive_pcie_probe(struct udevice *dev)
return ret;
regmap_update_bits(priv->regmap,
- priv->stg_rp_nep,
+ priv->stg_pcie_base + STG_SYSCON_RP_NEP_OFFSET,
STG_SYSCON_K_RP_NEP_MASK,
STG_SYSCON_K_RP_NEP_MASK);
regmap_update_bits(priv->regmap,
- priv->stg_awfun,
+ priv->stg_pcie_base + STG_SYSCON_AW_OFFSET,
STG_SYSCON_CKREF_SRC_MASK,
2 << STG_SYSCON_CKREF_SRC_SHIFT);
regmap_update_bits(priv->regmap,
- priv->stg_awfun,
+ priv->stg_pcie_base + STG_SYSCON_AW_OFFSET,
STG_SYSCON_CLKREQ_MASK,
STG_SYSCON_CLKREQ_MASK);
--
2.43.2
next prev parent reply other threads:[~2024-11-25 0:42 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-25 0:31 [PATCH v6 00/11] Support OF_UPSTREAM for StarFive JH7110 Hal Feng
2024-11-25 0:31 ` [PATCH v6 01/11] dts: starfive: Switch to using upstream DT Hal Feng
2024-11-25 0:31 ` [PATCH v6 02/11] riscv: dts: jh7110: Make u-boot device trees adapting to " Hal Feng
2024-11-26 15:14 ` E Shattow
2024-11-25 0:31 ` Hal Feng [this message]
2024-11-25 0:31 ` [PATCH v6 04/11] riscv: dts: jh7110: Move common code to the new jh7110-common-u-boot.dtsi Hal Feng
2024-11-26 15:24 ` E Shattow
2024-11-25 0:31 ` [PATCH v6 05/11] riscv: dts: jh7110: Add u-boot device tree for JH7110 based boards Hal Feng
2024-11-26 13:15 ` E Shattow
2024-11-25 0:32 ` [PATCH v6 06/11] board: starfive: spl: Drop the unneeded DT modification code Hal Feng
2024-11-25 0:32 ` [PATCH v6 07/11] configs: visionfive2: Enable MULTI_DTB_FIT for JH7110 based board DT Hal Feng
2024-11-26 14:31 ` E Shattow
2024-11-25 0:32 ` [PATCH v6 08/11] riscv: dts: jh7110: Support multiple DTBs in a Fit image Hal Feng
2024-11-26 14:17 ` E Shattow
2024-11-25 0:32 ` [PATCH v6 09/11] board: starfive: spl: Fix the wrong use of CONFIG_IS_ENABLED() Hal Feng
2024-11-25 0:32 ` [PATCH v6 10/11] board: starfive: spl: Support multiple DTBs for JH7110 based boards Hal Feng
2024-11-25 0:32 ` [PATCH v6 11/11] riscv: cpu: jh7110: Sort the list of imply statements Hal Feng
2024-11-25 8:25 ` [PATCH v6 00/11] Support OF_UPSTREAM for StarFive JH7110 Anand Moon
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=20241125003205.75327-4-hal.feng@starfivetech.com \
--to=hal.feng@starfivetech.com \
--cc=conor.dooley@microchip.com \
--cc=dmoo_dv@protonmail.com \
--cc=emil.renner.berthing@canonical.com \
--cc=ganboing@gmail.com \
--cc=lucent@gmail.com \
--cc=minda.chen@starfivetech.com \
--cc=namcao@linutronix.de \
--cc=rick@andestech.com \
--cc=sumit.garg@linaro.org \
--cc=trini@konsulko.com \
--cc=u-boot@lists.denx.de \
--cc=xypron.glpk@gmx.de \
--cc=ycliang@andestech.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.