Skip to content

Commit

Permalink
enable nvme boot
Browse files Browse the repository at this point in the history
  patchset: rockchip: rk3568: Fix use of PCIe bifurcation​
  from Jonas Karlman <jonas@kwiboo.se>

Signed-off-by: John Clark <inindev@gmail.com>
  • Loading branch information
inindev committed Aug 2, 2023
1 parent 7a382f5 commit 49caead
Show file tree
Hide file tree
Showing 14 changed files with 644 additions and 37 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From c72243f69389ad1c5e6822edfe502f0cd26f5e0e Mon Sep 17 00:00:00 2001
From 468fa2e4245d62d1972c96e589532ea42c1dc946 Mon Sep 17 00:00:00 2001
From: John Clark <inindev@gmail.com>
Date: Tue, 7 Mar 2023 01:47:26 +0000
Subject: [PATCH 8/8] ignore build artifacts
Subject: [PATCH 01/14] ignore build artifacts

Signed-off-by: John Clark <inindev@gmail.com>
---
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From db7aad2228b6edefddbdc6a6a007228a165a30aa Mon Sep 17 00:00:00 2001
From 2fd436d9cd2373beb5c2e7e3a8fa86d51e728738 Mon Sep 17 00:00:00 2001
From: Simon Glass <sjg@chromium.org>
Date: Wed, 26 Jul 2023 21:01:21 -0600
Subject: [PATCH 3/8] bootflow: Export setup_fs()
Subject: [PATCH 02/14] bootflow: Export setup_fs()

This function is used in some bootmeth implementations. Export it.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
From 4ddffb37d72d598d92c96e1c1007d848c7a5f9db Mon Sep 17 00:00:00 2001
From 9873f94fe81973ff14b271556904a8e16c06884a Mon Sep 17 00:00:00 2001
From: Simon Glass <sjg@chromium.org>
Date: Wed, 26 Jul 2023 21:01:22 -0600
Subject: [PATCH 4/8] bootstd: Use a function to detect network in EFI bootmeth
Subject: [PATCH 03/14] bootstd: Use a function to detect network in EFI
bootmeth

This checks for a network-based bootflow in two places, one of which is
less than ideal. Move the correct test into a function and use it in both
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From e80924f0c106f41b656b56ef12e991416932a37d Mon Sep 17 00:00:00 2001
From 856a6620eda88844196e06815d9179321bbf90bf Mon Sep 17 00:00:00 2001
From: Simon Glass <sjg@chromium.org>
Date: Wed, 26 Jul 2023 21:01:23 -0600
Subject: [PATCH 5/8] bootstd: Avoid allocating memory for the EFI file
Subject: [PATCH 04/14] bootstd: Avoid allocating memory for the EFI file
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From 3f4ad683d2059aedbe6a71184b8154172ecd0c2b Mon Sep 17 00:00:00 2001
From e5781c814320fc69e7a93b5290f05541472c1e41 Mon Sep 17 00:00:00 2001
From: Simon Glass <sjg@chromium.org>
Date: Wed, 26 Jul 2023 21:01:24 -0600
Subject: [PATCH 6/8] bootstd: Init the size before reading the devicetree
Subject: [PATCH 05/14] bootstd: Init the size before reading the devicetree

The implementation in distro_efi_try_bootflow_files() does not pass a
valid size to bootmeth_common_read_file(), so this can fail if the
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From 6566c27aad5a6e3d57cfafe1434e022aa106ebac Mon Sep 17 00:00:00 2001
From 9a51a96db9031dbbd30950fbf393c89e52dca9d6 Mon Sep 17 00:00:00 2001
From: Simon Glass <sjg@chromium.org>
Date: Wed, 26 Jul 2023 21:01:25 -0600
Subject: [PATCH 7/8] bootstd: Init the size before reading extlinux file
Subject: [PATCH 06/14] bootstd: Init the size before reading extlinux file

The implementation in extlinux_pxe_getfile() does not pass a valid size
to bootmeth_read_file(), so this can fail if the uninited value happens to
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
From 2308ab75d263bef5282b0cda1ada5e5a9d9ee135 Mon Sep 17 00:00:00 2001
From 2497a5d2af2a0797e12e0d97d742a41eab980868 Mon Sep 17 00:00:00 2001
From: Jonas Karlman <jonas@kwiboo.se>
Date: Mon, 3 Jul 2023 19:38:26 +0000
Subject: [PATCH 2/8] fixup: rockchip: rk3568: Add support for FriendlyARM
Subject: [PATCH 07/14] fixup: rockchip: rk3568: Add support for FriendlyARM
NanoPi R5C

---
arch/arm/dts/rk3568-nanopi-r5c.dts | 2 +-
configs/nanopi-r5c-rk3568_defconfig | 14 ++++++++++----
2 files changed, 11 insertions(+), 5 deletions(-)
configs/nanopi-r5c-rk3568_defconfig | 18 ++++++++++++------
2 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/arch/arm/dts/rk3568-nanopi-r5c.dts b/arch/arm/dts/rk3568-nanopi-r5c.dts
index f70ca9f047..c718b8dbb9 100644
Expand All @@ -23,7 +23,7 @@ index f70ca9f047..c718b8dbb9 100644
};
};
diff --git a/configs/nanopi-r5c-rk3568_defconfig b/configs/nanopi-r5c-rk3568_defconfig
index 201b21ad77..5a620aa70b 100644
index 201b21ad77..833cff0e45 100644
--- a/configs/nanopi-r5c-rk3568_defconfig
+++ b/configs/nanopi-r5c-rk3568_defconfig
@@ -1,5 +1,6 @@
Expand Down Expand Up @@ -65,7 +65,14 @@ index 201b21ad77..5a620aa70b 100644
CONFIG_SPL_REGMAP=y
CONFIG_SPL_SYSCON=y
CONFIG_SPL_CLK=y
@@ -57,10 +63,11 @@ CONFIG_MMC_DW_ROCKCHIP=y
@@ -52,19 +58,20 @@ CONFIG_ROCKCHIP_GPIO=y
CONFIG_SYS_I2C_ROCKCHIP=y
CONFIG_MISC=y
CONFIG_SUPPORT_EMMC_RPMB=y
+CONFIG_MMC_HS200_SUPPORT=y
+CONFIG_SPL_MMC_HS200_SUPPORT=y
CONFIG_MMC_DW=y
CONFIG_MMC_DW_ROCKCHIP=y
CONFIG_MMC_SDHCI=y
CONFIG_MMC_SDHCI_SDMA=y
CONFIG_MMC_SDHCI_ROCKCHIP=y
Expand All @@ -75,10 +82,14 @@ index 201b21ad77..5a620aa70b 100644
+CONFIG_PCIE_DW_ROCKCHIP=y
CONFIG_PHY_ROCKCHIP_INNO_USB2=y
CONFIG_PHY_ROCKCHIP_NANENG_COMBOPHY=y
-CONFIG_POWER_DOMAIN=y
+CONFIG_SPL_PINCTRL=y
CONFIG_POWER_DOMAIN=y
CONFIG_DM_PMIC=y
CONFIG_PMIC_RK8XX=y
-CONFIG_SPL_DM_REGULATOR_FIXED=y
CONFIG_REGULATOR_RK8XX=y
CONFIG_PWM_ROCKCHIP=y
CONFIG_SPL_RAM=y
@@ -72,7 +79,6 @@ CONFIG_BAUDRATE=1500000
CONFIG_DEBUG_UART_SHIFT=2
CONFIG_SYS_NS16550_MEM32=y
Expand Down
Original file line number Diff line number Diff line change
@@ -1,36 +1,28 @@
From 9bdfd9829545d67b08f28ed7eddbfbfc4b8e7a42 Mon Sep 17 00:00:00 2001
From ad01fb4f8a5c29c7638941619052a4fc6b8961df Mon Sep 17 00:00:00 2001
From: Jonas Karlman <jonas@kwiboo.se>
Date: Mon, 3 Jul 2023 20:39:52 +0000
Subject: [PATCH 1/8] fixup: rockchip: rk3568: Add support for FriendlyARM
Subject: [PATCH 08/14] fixup: rockchip: rk3568: Add support for FriendlyARM
NanoPi R5S

---
arch/arm/dts/rk3568-nanopi-r5s-u-boot.dtsi | 6 +++++-
configs/nanopi-r5s-rk3568_defconfig | 15 +++++++++++----
2 files changed, 16 insertions(+), 5 deletions(-)
arch/arm/dts/rk3568-nanopi-r5s-u-boot.dtsi | 1 -
configs/nanopi-r5s-rk3568_defconfig | 19 +++++++++++++------
2 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/arch/arm/dts/rk3568-nanopi-r5s-u-boot.dtsi b/arch/arm/dts/rk3568-nanopi-r5s-u-boot.dtsi
index 0ecca85b20..7fdf13f5fc 100644
index 0ecca85b20..b170db40c8 100644
--- a/arch/arm/dts/rk3568-nanopi-r5s-u-boot.dtsi
+++ b/arch/arm/dts/rk3568-nanopi-r5s-u-boot.dtsi
@@ -11,10 +11,14 @@
@@ -11,7 +11,6 @@
/ {
chosen {
stdout-path = &uart2;
- u-boot,spl-boot-order = "same-as-spl", &sdmmc0, &sdhci;
};
};

+/* PCIe PHY driver in U-Boot does not support bifurcation */
+&pcie3x1 {
+ status = "disabled";
+};
+
&sdhci {
cap-mmc-highspeed;
mmc-ddr-1_8v;
diff --git a/configs/nanopi-r5s-rk3568_defconfig b/configs/nanopi-r5s-rk3568_defconfig
index 67b2843070..c653ea8ee8 100644
index 67b2843070..c278ce083d 100644
--- a/configs/nanopi-r5s-rk3568_defconfig
+++ b/configs/nanopi-r5s-rk3568_defconfig
@@ -1,5 +1,6 @@
Expand Down Expand Up @@ -72,7 +64,14 @@ index 67b2843070..c653ea8ee8 100644
CONFIG_SPL_REGMAP=y
CONFIG_SPL_SYSCON=y
CONFIG_SPL_CLK=y
@@ -57,10 +63,12 @@ CONFIG_MMC_DW_ROCKCHIP=y
@@ -52,19 +58,21 @@ CONFIG_ROCKCHIP_GPIO=y
CONFIG_SYS_I2C_ROCKCHIP=y
CONFIG_MISC=y
CONFIG_SUPPORT_EMMC_RPMB=y
+CONFIG_MMC_HS200_SUPPORT=y
+CONFIG_SPL_MMC_HS200_SUPPORT=y
CONFIG_MMC_DW=y
CONFIG_MMC_DW_ROCKCHIP=y
CONFIG_MMC_SDHCI=y
CONFIG_MMC_SDHCI_SDMA=y
CONFIG_MMC_SDHCI_ROCKCHIP=y
Expand All @@ -83,10 +82,14 @@ index 67b2843070..c653ea8ee8 100644
+CONFIG_PCIE_DW_ROCKCHIP=y
CONFIG_PHY_ROCKCHIP_INNO_USB2=y
CONFIG_PHY_ROCKCHIP_NANENG_COMBOPHY=y
-CONFIG_POWER_DOMAIN=y
+CONFIG_SPL_PINCTRL=y
CONFIG_POWER_DOMAIN=y
CONFIG_DM_PMIC=y
CONFIG_PMIC_RK8XX=y
-CONFIG_SPL_DM_REGULATOR_FIXED=y
CONFIG_REGULATOR_RK8XX=y
CONFIG_PWM_ROCKCHIP=y
CONFIG_SPL_RAM=y
@@ -72,7 +80,6 @@ CONFIG_BAUDRATE=1500000
CONFIG_DEBUG_UART_SHIFT=2
CONFIG_SYS_NS16550_MEM32=y
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
From 399d5627be47302104363aa9c80e87fee4c32071 Mon Sep 17 00:00:00 2001
From: Jonas Karlman <jonas@kwiboo.se>
Date: Tue, 1 Aug 2023 11:46:54 +0000
Subject: [PATCH 09/14] pci: pcie_dw_rockchip: Configure number of lanes and
link width speed

Set number of lanes and link width speed control register based on the
num-lanes property.

Code imported almost 1:1 from dw_pcie_setup in mainline linux.

Signed-off-by: Jonas Karlman <jonas@kwiboo.se>
---
drivers/pci/pcie_dw_rockchip.c | 58 +++++++++++++++++++++++++++++-----
1 file changed, 50 insertions(+), 8 deletions(-)

diff --git a/drivers/pci/pcie_dw_rockchip.c b/drivers/pci/pcie_dw_rockchip.c
index 1a35fae5c3..bc4635f671 100644
--- a/drivers/pci/pcie_dw_rockchip.c
+++ b/drivers/pci/pcie_dw_rockchip.c
@@ -18,6 +18,7 @@
#include <asm/io.h>
#include <asm-generic/gpio.h>
#include <dm/device_compat.h>
+#include <linux/bitfield.h>
#include <linux/iopoll.h>
#include <linux/delay.h>
#include <power/regulator.h>
@@ -43,6 +44,7 @@ struct rk_pcie {
struct reset_ctl_bulk rsts;
struct gpio_desc rst_gpio;
u32 gen;
+ u32 num_lanes;
};

/* Parameters for the waiting for iATU enabled routine */
@@ -152,12 +154,13 @@ static inline void rk_pcie_writel_apb(struct rk_pcie *rk_pcie, u32 reg,
* rk_pcie_configure() - Configure link capabilities and speed
*
* @rk_pcie: Pointer to the PCI controller state
- * @cap_speed: The capabilities and speed to configure
*
* Configure the link capabilities and speed in the PCIe root complex.
*/
-static void rk_pcie_configure(struct rk_pcie *pci, u32 cap_speed)
+static void rk_pcie_configure(struct rk_pcie *pci)
{
+ u32 val;
+
dw_pcie_dbi_write_enable(&pci->dw, true);

/* Disable BAR 0 and BAR 1 */
@@ -167,11 +170,49 @@ static void rk_pcie_configure(struct rk_pcie *pci, u32 cap_speed)
PCI_BASE_ADDRESS_1);

clrsetbits_le32(pci->dw.dbi_base + PCIE_LINK_CAPABILITY,
- TARGET_LINK_SPEED_MASK, cap_speed);
+ TARGET_LINK_SPEED_MASK, pci->gen);

clrsetbits_le32(pci->dw.dbi_base + PCIE_LINK_CTL_2,
- TARGET_LINK_SPEED_MASK, cap_speed);
+ TARGET_LINK_SPEED_MASK, pci->gen);
+
+ /* Set the number of lanes */
+ val = readl(pci->dw.dbi_base + PCIE_PORT_LINK_CONTROL);
+ val &= ~PORT_LINK_FAST_LINK_MODE;
+ val |= PORT_LINK_DLL_LINK_EN;
+ val &= ~PORT_LINK_MODE_MASK;
+ switch (pci->num_lanes) {
+ case 1:
+ val |= PORT_LINK_MODE_1_LANES;
+ break;
+ case 2:
+ val |= PORT_LINK_MODE_2_LANES;
+ break;
+ case 4:
+ val |= PORT_LINK_MODE_4_LANES;
+ break;
+ default:
+ dev_err(pci->dw.dev, "num-lanes %u: invalid value\n", pci->num_lanes);
+ goto out;
+ }
+ writel(val, pci->dw.dbi_base + PCIE_PORT_LINK_CONTROL);
+
+ /* Set link width speed control register */
+ val = readl(pci->dw.dbi_base + PCIE_LINK_WIDTH_SPEED_CONTROL);
+ val &= ~PORT_LOGIC_LINK_WIDTH_MASK;
+ switch (pci->num_lanes) {
+ case 1:
+ val |= PORT_LOGIC_LINK_WIDTH_1_LANES;
+ break;
+ case 2:
+ val |= PORT_LOGIC_LINK_WIDTH_2_LANES;
+ break;
+ case 4:
+ val |= PORT_LOGIC_LINK_WIDTH_4_LANES;
+ break;
+ }
+ writel(val, pci->dw.dbi_base + PCIE_LINK_WIDTH_SPEED_CONTROL);

+out:
dw_pcie_dbi_write_enable(&pci->dw, false);
}

@@ -231,11 +272,10 @@ static int is_link_up(struct rk_pcie *priv)
* rk_pcie_link_up() - Wait for the link to come up
*
* @rk_pcie: Pointer to the PCI controller state
- * @cap_speed: Desired link speed
*
* Return: 1 (true) for active line and negetive (false) for no link (timeout)
*/
-static int rk_pcie_link_up(struct rk_pcie *priv, u32 cap_speed)
+static int rk_pcie_link_up(struct rk_pcie *priv)
{
int retries;

@@ -245,7 +285,7 @@ static int rk_pcie_link_up(struct rk_pcie *priv, u32 cap_speed)
}

/* DW pre link configurations */
- rk_pcie_configure(priv, cap_speed);
+ rk_pcie_configure(priv);

rk_pcie_disable_ltssm(priv);
rk_pcie_link_status_clear(priv);
@@ -341,7 +381,7 @@ static int rockchip_pcie_init_port(struct udevice *dev)
rk_pcie_writel_apb(priv, 0x0, 0xf00040);
pcie_dw_setup_host(&priv->dw);

- ret = rk_pcie_link_up(priv, priv->gen);
+ ret = rk_pcie_link_up(priv);
if (ret < 0)
goto err_link_up;

@@ -419,6 +459,8 @@ static int rockchip_pcie_parse_dt(struct udevice *dev)
priv->gen = dev_read_u32_default(dev, "max-link-speed",
LINK_SPEED_GEN_3);

+ priv->num_lanes = dev_read_u32_default(dev, "num-lanes", 1);
+
return 0;

rockchip_pcie_parse_dt_err_phy_get_by_index:
--
2.40.1

Loading

0 comments on commit 49caead

Please sign in to comment.