On 16/11/2020 11:28, Qu Wenruo wrote: > > > On 2020/11/16 下午4:33, Neil Armstrong wrote: >> Hi, >> >> On 15/11/2020 04:39, Qu Wenruo wrote: >>> Although the plan is to make the bootloader (U-boot) to load overlay for >>> the device, but currently the board doesn't have the upstream support >>> yet. >> >> No need for that, automatic PCIe enable is now support on upstream U-Boot >> for VIM3 & VIM3L: >> https://github.com/u-boot/u-boot/commit/adbff64af7b7cee3e0007b75df2644090edaafcb > > Great. > > BTW, the upstream U-boot is supposed to replace the factory Uboot > compeletely, or just to be chainloaded from SDcard? Both, but you should replace the factory u-boot. You can easily boot to MaskROM by pressing the F button 3 times and boot from USB, so you can't brick the device and recover to the factory image whatever the state of the device. Neil > > Thanks, > Qu >> >> Neil >> >>> >>> This means even upstream kernel supports all the needed drivers, we still >>> can't initialize the pcie controller. >>> >>> As a workaround, make seperate device trees for pcie controller and usb3 >>> controller. >>> >>> Now user still need to go into the factory bootloader to switch the mux, >>> but they can easily boot the kernel with PCIE support by just swithcing >>> to the pcie device tree. >>> >>> And since we didn't modify the original dtb, the future upstream uboot >>> can still use overlay to switch mode using the same dtb file. >>> The added new pcie dtb will just be a workaround. >>> >>> Tested on my VIM3 pro board, now I can boot the root fs on the NVME >>> drive, with upstream kernel with the new pcie dtb. >>> >>> Signed-off-by: Qu Wenruo <wqu@xxxxxxxx> >>> --- >>> arch/arm64/boot/dts/amlogic/Makefile | 1 + >>> .../meson-g12b-a311d-khadas-vim3-pcie.dts | 39 +++++++++++++++++++ >>> .../amlogic/meson-g12b-a311d-khadas-vim3.dts | 23 +---------- >>> 3 files changed, 41 insertions(+), 22 deletions(-) >>> create mode 100644 arch/arm64/boot/dts/amlogic/meson-g12b-a311d-khadas-vim3-pcie.dts >>> >>> diff --git a/arch/arm64/boot/dts/amlogic/Makefile b/arch/arm64/boot/dts/amlogic/Makefile >>> index ced03946314f..a0b8d30539e2 100644 >>> --- a/arch/arm64/boot/dts/amlogic/Makefile >>> +++ b/arch/arm64/boot/dts/amlogic/Makefile >>> @@ -6,6 +6,7 @@ dtb-$(CONFIG_ARCH_MESON) += meson-g12a-x96-max.dtb >>> dtb-$(CONFIG_ARCH_MESON) += meson-g12b-gtking.dtb >>> dtb-$(CONFIG_ARCH_MESON) += meson-g12b-gtking-pro.dtb >>> dtb-$(CONFIG_ARCH_MESON) += meson-g12b-a311d-khadas-vim3.dtb >>> +dtb-$(CONFIG_ARCH_MESON) += meson-g12b-a311d-khadas-vim3-pcie.dtb >>> dtb-$(CONFIG_ARCH_MESON) += meson-g12b-s922x-khadas-vim3.dtb >>> dtb-$(CONFIG_ARCH_MESON) += meson-g12b-odroid-n2.dtb >>> dtb-$(CONFIG_ARCH_MESON) += meson-g12b-odroid-n2-plus.dtb >>> diff --git a/arch/arm64/boot/dts/amlogic/meson-g12b-a311d-khadas-vim3-pcie.dts b/arch/arm64/boot/dts/amlogic/meson-g12b-a311d-khadas-vim3-pcie.dts >>> new file mode 100644 >>> index 000000000000..93641a32eeec >>> --- /dev/null >>> +++ b/arch/arm64/boot/dts/amlogic/meson-g12b-a311d-khadas-vim3-pcie.dts >>> @@ -0,0 +1,39 @@ >>> +// SPDX-License-Identifier: (GPL-2.0+ OR MIT) >>> +/* >>> + * Copyright (c) 2019 BayLibre, SAS >>> + * Author: Neil Armstrong <narmstrong@xxxxxxxxxxxx> >>> + * Copyright (c) 2019 Christian Hewitt <christianshewitt@xxxxxxxxx> >>> + */ >>> + >>> +/dts-v1/; >>> + >>> +#include "meson-g12b-a311d.dtsi" >>> +#include "meson-khadas-vim3.dtsi" >>> +#include "meson-g12b-khadas-vim3.dtsi" >>> + >>> +/ { >>> + compatible = "khadas,vim3", "amlogic,a311d", "amlogic,g12b"; >>> +}; >>> + >>> +/* >>> + * The VIM3 on-board MCU can mux the PCIe/USB3.0 shared differential >>> + * lines using a FUSB340TMX USB 3.1 SuperSpeed Data Switch between >>> + * an USB3.0 Type A connector and a M.2 Key M slot. >>> + * The PHY driving these differential lines is shared between >>> + * the USB3.0 controller and the PCIe Controller, thus only >>> + * a single controller can use it. >>> + * >>> + * This is the PCIE device tree. >>> + * >>> + * Until upstream uboot can boot the board and modify the nodes before booting >>> + * It's much easier to just choose this device tree file to use PCIE controller. >>> + */ >>> + >>> +&pcie { >>> + status = "okay"; >>> +}; >>> + >>> +&usb { >>> + phys = <&usb2_phy0>, <&usb2_phy1>; >>> + phy-names = "usb2-phy0", "usb2-phy1"; >>> +}; >>> diff --git a/arch/arm64/boot/dts/amlogic/meson-g12b-a311d-khadas-vim3.dts b/arch/arm64/boot/dts/amlogic/meson-g12b-a311d-khadas-vim3.dts >>> index 124a80901084..9c111d76baec 100644 >>> --- a/arch/arm64/boot/dts/amlogic/meson-g12b-a311d-khadas-vim3.dts >>> +++ b/arch/arm64/boot/dts/amlogic/meson-g12b-a311d-khadas-vim3.dts >>> @@ -16,26 +16,5 @@ / { >>> }; >>> >>> /* >>> - * The VIM3 on-board MCU can mux the PCIe/USB3.0 shared differential >>> - * lines using a FUSB340TMX USB 3.1 SuperSpeed Data Switch between >>> - * an USB3.0 Type A connector and a M.2 Key M slot. >>> - * The PHY driving these differential lines is shared between >>> - * the USB3.0 controller and the PCIe Controller, thus only >>> - * a single controller can use it. >>> - * If the MCU is configured to mux the PCIe/USB3.0 differential lines >>> - * to the M.2 Key M slot, uncomment the following block to disable >>> - * USB3.0 from the USB Complex and enable the PCIe controller. >>> - * The End User is not expected to uncomment the following except for >>> - * testing purposes, but instead rely on the firmware/bootloader to >>> - * update these nodes accordingly if PCIe mode is selected by the MCU. >>> - */ >>> -/* >>> -&pcie { >>> - status = "okay"; >>> -}; >>> - >>> -&usb { >>> - phys = <&usb2_phy0>, <&usb2_phy1>; >>> - phy-names = "usb2-phy0", "usb2-phy1"; >>> -}; >>> + * Vim3 default to USB3.0 instead of PCIE controller. >>> */ >>> >> >