From a246e21351778a93805b3f52302a420f4b268601 Mon Sep 17 00:00:00 2001 From: Stefan Agner Date: Thu, 8 Apr 2021 10:25:28 +0200 Subject: [PATCH 1/7] arm64: dts: meson: odroidc2: readd PHY reset properties The sync of the device tree and dt-bindings from Linux v5.6-rc2 11a48a5a18c6 ("Linux 5.6-rc2") causes Ethernet to break on some ODROID-C2. The PHY seems to need proper reset timing to be functional in U-Boot and Linux afterwards. Readd the old PHY reset bindings for dwmac until we support the new bindings in the PHY node. Fixes: dd5f2351e99a ("arm64: dts: meson: sync dt and bindings from v5.6-rc2") Signed-off-by: Stefan Agner Signed-off-by: Neil Armstrong --- arch/arm/dts/meson-gxbb-odroidc2-u-boot.dtsi | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/arch/arm/dts/meson-gxbb-odroidc2-u-boot.dtsi b/arch/arm/dts/meson-gxbb-odroidc2-u-boot.dtsi index 90087b00db..5a2be8171e 100644 --- a/arch/arm/dts/meson-gxbb-odroidc2-u-boot.dtsi +++ b/arch/arm/dts/meson-gxbb-odroidc2-u-boot.dtsi @@ -29,6 +29,12 @@ }; }; +ðmac { + snps,reset-gpio = <&gpio GPIOZ_14 0>; + snps,reset-delays-us = <0 10000 1000000>; + snps,reset-active-low; +}; + &usb0 { status = "disabled"; }; From 3034a1eda3ec3d718a4c26666c17f159747de62d Mon Sep 17 00:00:00 2001 From: Neil Armstrong Date: Thu, 25 Feb 2021 18:46:12 +0100 Subject: [PATCH 2/7] clk: meson-g12a: add PCIe gates Add missing gates used for PCIe. Signed-off-by: Neil Armstrong --- drivers/clk/meson/g12a.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/clk/meson/g12a.c b/drivers/clk/meson/g12a.c index 5058db1a47..e4fed8ddfb 100644 --- a/drivers/clk/meson/g12a.c +++ b/drivers/clk/meson/g12a.c @@ -120,7 +120,9 @@ static struct meson_gate gates[NUM_CLKS] = { MESON_GATE(CLKID_SD_EMMC_C, HHI_GCLK_MPEG0, 26), MESON_GATE(CLKID_ETH, HHI_GCLK_MPEG1, 3), MESON_GATE(CLKID_UART1, HHI_GCLK_MPEG1, 16), + MESON_GATE(CLKID_PCIE_COMB, HHI_GCLK_MPEG1, 24), MESON_GATE(CLKID_USB, HHI_GCLK_MPEG1, 25), + MESON_GATE(CLKID_PCIE_PHY, HHI_GCLK_MPEG1, 27), MESON_GATE(CLKID_HTX_PCLK, HHI_GCLK_MPEG2, 4), MESON_GATE(CLKID_USB1_DDR_BRIDGE, HHI_GCLK_MPEG2, 8), MESON_GATE(CLKID_VPU_INTR, HHI_GCLK_MPEG2, 25), From 320160cd97deffa92392b5dc71e2b8482c648229 Mon Sep 17 00:00:00 2001 From: Neil Armstrong Date: Thu, 25 Feb 2021 17:53:23 +0100 Subject: [PATCH 3/7] phy: meson-g12a-usb3-pcie: add support for PCIe ops Add the PCIe part of the G12A USB3 PCIe Combo PHY driver. Signed-off-by: Neil Armstrong --- drivers/phy/meson-g12a-usb3-pcie.c | 81 ++++++++++++++++++++++++++++-- 1 file changed, 77 insertions(+), 4 deletions(-) diff --git a/drivers/phy/meson-g12a-usb3-pcie.c b/drivers/phy/meson-g12a-usb3-pcie.c index 0433d93474..8f72b5a6a7 100644 --- a/drivers/phy/meson-g12a-usb3-pcie.c +++ b/drivers/phy/meson-g12a-usb3-pcie.c @@ -23,6 +23,9 @@ #include #include +#define PHY_TYPE_PCIE 2 +#define PHY_TYPE_USB3 4 + #define PHY_R0 0x00 #define PHY_R0_PCIE_POWER_STATE GENMASK(4, 0) #define PHY_R0_PCIE_USB3_SWITCH GENMASK(6, 5) @@ -55,6 +58,8 @@ #define PHY_R5_PHY_CR_ACK BIT(16) #define PHY_R5_PHY_BS_OUT BIT(17) +#define PCIE_RESET_DELAY 500 + struct phy_g12a_usb3_pcie_priv { struct regmap *regmap; #if CONFIG_IS_ENABLED(CLK) @@ -202,8 +207,6 @@ static int phy_meson_g12a_usb3_init(struct phy *phy) unsigned int data; int ret; - /* TOFIX Handle PCIE mode */ - ret = reset_assert_bulk(&priv->resets); udelay(1); ret |= reset_deassert_bulk(&priv->resets); @@ -296,9 +299,79 @@ static int phy_meson_g12a_usb3_exit(struct phy *phy) return reset_assert_bulk(&priv->resets); } +static int phy_meson_g12a_usb3_pcie_init(struct phy *phy) +{ + if (phy->id == PHY_TYPE_USB3) + return phy_meson_g12a_usb3_init(phy); + + return 0; +} + +static int phy_meson_g12a_usb3_pcie_exit(struct phy *phy) +{ + if (phy->id == PHY_TYPE_USB3) + return phy_meson_g12a_usb3_exit(phy); + + return 0; +} + +static int phy_meson_g12a_usb3_pcie_power_on(struct phy *phy) +{ + struct phy_g12a_usb3_pcie_priv *priv = dev_get_priv(phy->dev); + + if (phy->id == PHY_TYPE_USB3) + return 0; + + regmap_update_bits(priv->regmap, PHY_R0, + PHY_R0_PCIE_POWER_STATE, + FIELD_PREP(PHY_R0_PCIE_POWER_STATE, 0x1c)); + + return 0; +} + +static int phy_meson_g12a_usb3_pcie_power_off(struct phy *phy) +{ + struct phy_g12a_usb3_pcie_priv *priv = dev_get_priv(phy->dev); + + if (phy->id == PHY_TYPE_USB3) + return 0; + + regmap_update_bits(priv->regmap, PHY_R0, + PHY_R0_PCIE_POWER_STATE, + FIELD_PREP(PHY_R0_PCIE_POWER_STATE, 0x1d)); + + return 0; +} + +static int phy_meson_g12a_usb3_pcie_reset(struct phy *phy) +{ + struct phy_g12a_usb3_pcie_priv *priv = dev_get_priv(phy->dev); + int ret; + + if (phy->id == PHY_TYPE_USB3) + return 0; + + ret = reset_assert_bulk(&priv->resets); + if (ret) + return ret; + + udelay(PCIE_RESET_DELAY); + + ret = reset_deassert_bulk(&priv->resets); + if (ret) + return ret; + + udelay(PCIE_RESET_DELAY); + + return 0; +} + struct phy_ops meson_g12a_usb3_pcie_phy_ops = { - .init = phy_meson_g12a_usb3_init, - .exit = phy_meson_g12a_usb3_exit, + .init = phy_meson_g12a_usb3_pcie_init, + .exit = phy_meson_g12a_usb3_pcie_exit, + .power_on = phy_meson_g12a_usb3_pcie_power_on, + .power_off = phy_meson_g12a_usb3_pcie_power_off, + .reset = phy_meson_g12a_usb3_pcie_reset, }; int meson_g12a_usb3_pcie_phy_probe(struct udevice *dev) From 4a892b5554a8e13cea7e96eb84b3da96e10111b0 Mon Sep 17 00:00:00 2001 From: Neil Armstrong Date: Thu, 25 Feb 2021 18:47:05 +0100 Subject: [PATCH 4/7] arm: dts: meson-khadas-vim3: enable PCIe in U-boot Enable PCIe by default in u-boot, this should eventually be made dynamic in the runtime board config depending on the MCU configuration. Signed-off-by: Neil Armstrong --- arch/arm/dts/meson-khadas-vim3-u-boot.dtsi | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arch/arm/dts/meson-khadas-vim3-u-boot.dtsi b/arch/arm/dts/meson-khadas-vim3-u-boot.dtsi index 81fd5be378..24dbf8ca2c 100644 --- a/arch/arm/dts/meson-khadas-vim3-u-boot.dtsi +++ b/arch/arm/dts/meson-khadas-vim3-u-boot.dtsi @@ -10,6 +10,10 @@ }; }; +&pcie { + status = "okay"; +}; + &sd_emmc_c { status = "okay"; pinctrl-0 = <&emmc_ctrl_pins>, <&emmc_data_4b_pins>, <&emmc_ds_pins>; From ea001950af081ea5cf43378f67fdc6d594b5eb80 Mon Sep 17 00:00:00 2001 From: Neil Armstrong Date: Fri, 26 Feb 2021 14:47:06 +0100 Subject: [PATCH 5/7] configs: khadas-vim3: enable PCIe and NVMe Now we have PCIe, let's also enable NVMe to access an eventual NVMe SSDs connected on the M.2 slot. Signed-off-by: Neil Armstrong --- configs/khadas-vim3_defconfig | 5 +++++ configs/khadas-vim3l_defconfig | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/configs/khadas-vim3_defconfig b/configs/khadas-vim3_defconfig index cd0327c06b..bb41670cba 100644 --- a/configs/khadas-vim3_defconfig +++ b/configs/khadas-vim3_defconfig @@ -88,3 +88,8 @@ CONFIG_BMP_16BPP=y CONFIG_BMP_24BPP=y CONFIG_BMP_32BPP=y CONFIG_OF_LIBFDT_OVERLAY=y +CONFIG_PCI=y +CONFIG_CMD_PCI=y +CONFIG_DM_PCI=y +CONFIG_PCIE_DW_MESON=y +CONFIG_NVME=y diff --git a/configs/khadas-vim3l_defconfig b/configs/khadas-vim3l_defconfig index ef85f00dd8..59541e7671 100644 --- a/configs/khadas-vim3l_defconfig +++ b/configs/khadas-vim3l_defconfig @@ -88,3 +88,8 @@ CONFIG_BMP_16BPP=y CONFIG_BMP_24BPP=y CONFIG_BMP_32BPP=y CONFIG_OF_LIBFDT_OVERLAY=y +CONFIG_PCI=y +CONFIG_CMD_PCI=y +CONFIG_DM_PCI=y +CONFIG_PCIE_DW_MESON=y +CONFIG_NVME=y From 83752094d17a8a561d7a2a39879f9d7f49487e83 Mon Sep 17 00:00:00 2001 From: Neil Armstrong Date: Fri, 26 Feb 2021 15:17:36 +0100 Subject: [PATCH 6/7] configs: meson64: add NVME boot target Let's add a boot target for NVMe so we can do a full boot over NVMe. Signed-off-by: Neil Armstrong --- include/configs/meson64.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/include/configs/meson64.h b/include/configs/meson64.h index 7e97f89052..17ebccd2c4 100644 --- a/include/configs/meson64.h +++ b/include/configs/meson64.h @@ -58,6 +58,12 @@ #define BOOT_TARGET_DEVICES_USB(func) #endif +#ifdef CONFIG_CMD_NVME + #define BOOT_TARGET_NVME(func) func(NVME, nvme, 0) +#else + #define BOOT_TARGET_NVME(func) +#endif + #ifndef BOOT_TARGET_DEVICES #define BOOT_TARGET_DEVICES(func) \ func(ROMUSB, romusb, na) \ @@ -65,6 +71,7 @@ func(MMC, mmc, 1) \ func(MMC, mmc, 2) \ BOOT_TARGET_DEVICES_USB(func) \ + BOOT_TARGET_NVME(func) \ func(PXE, pxe, na) \ func(DHCP, dhcp, na) #endif From fcf3c9deae1acfda81051c8c211fcbefd4217e1d Mon Sep 17 00:00:00 2001 From: Neil Armstrong Date: Fri, 16 Apr 2021 14:22:31 +0200 Subject: [PATCH 7/7] boards: amlogic: update documentation for PCIe support Signed-off-by: Neil Armstrong --- doc/board/amlogic/index.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/board/amlogic/index.rst b/doc/board/amlogic/index.rst index 275c3664b7..8da7afddb4 100644 --- a/doc/board/amlogic/index.rst +++ b/doc/board/amlogic/index.rst @@ -70,6 +70,8 @@ This matrix concerns the actual source code version. +-------------------------------+-----------+-----------------+--------------+------------+------------+-------------+--------------+ | SoC (version) information | **Yes** | **Yes** | **Yes** | **Yes** | **Yes** | **Yes** | **Yes** | +-------------------------------+-----------+-----------------+--------------+------------+------------+-------------+--------------+ +| PCIe (+NVMe) | *N/A* | *N/A* | *N/A* | **Yes** | **Yes** | **Yes** | **Yes** | ++-------------------------------+-----------+-----------------+--------------+------------+------------+-------------+--------------+ Board Documentation -------------------