VIM3 Ubuntu Kernel PCIe Driver not load

  1. U-Boot config:
    kvim3#kbi init
    kvim3#kbi portmode r
    port mode is pcie
    kvim3#kbi portmode w 1
    set port mode to :pcie
  2. shell check mode
    root@Khadas:/sys/class# cat /sys/class/mcu/usb_pcie_switch_mode
    cat: /sys/class/mcu/usb_pcie_switch_mode: No such file or directory
    root@Khadas:/sys/class# ls /sys/class/mcu
    ls: cannot access ‘/sys/class/mcu’: No such file or directory
  3. dmesg check pci info
    root@Khadas:/sys/class# dmesg | grep pci
    root@Khadas:/sys/class#

You need to poweroff the board after change the mode to PCIe.

kvim3# kbi poweroff

And poweron again.

Can you update the kernel and try again?

$ sudo apt-get update
$ sudo apt-get upgrade
$ sync
$ sudo reboot

Hi,

here is the output following your advices:

khadas@Khadas:~$ sudo su
root@Khadas:/home/khadas# uname -a
Linux Khadas 4.9.190 #29 SMP PREEMPT Fri Nov 8 15:44:36 CST 2019 aarch64 aarch64 aarch64 GNU/Linux
[sudo] password for khadas:
root@Khadas:/home/khadas# cat /sys/class/mcu/usb_pcie_switch_mode
1
root@Khadas:/home/khadas# apt-get update
Hit:1 http://ports.ubuntu.com bionic InRelease
Get:2 http://ports.ubuntu.com bionic-security InRelease [88.7 kB]
Get:3 http://ports.ubuntu.com bionic-updates InRelease [88.7 kB]
Hit:4 https://dl.khadas.com/repos/vim3 bionic InRelease
Get:5 http://ports.ubuntu.com bionic-backports InRelease [74.6 kB]
Get:6 http://ports.ubuntu.com bionic-updates/main armhf Packages [728 kB]
Get:7 http://ports.ubuntu.com bionic-updates/main arm64 Packages [770 kB]
Get:8 http://ports.ubuntu.com bionic-updates/universe arm64 Packages [1,176 kB]
Get:9 http://ports.ubuntu.com bionic-updates/universe armhf Packages [1,101 kB]
Fetched 4,026 kB in 8min 52s (7,561 B/s)
Reading package lists... Done
root@Khadas:/home/khadas# apt-get upgrade
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
root@Khadas:/home/khadas# dmesg | grep pci
[    0.993773] ehci-pci: EHCI PCI platform driver
[    0.993861] ohci-pci: OHCI PCI platform driver

still can’t load pcie driver.
here is all boot message khadas_vim3_boot_log

Hello @zengjf

Can you check this:

# cat /proc/device-tree/pcieA@fc000000/status

Have you removed the power cable and re-connect again?

Hi @numbqq

i have restarted many times with the power cable. here is the device tree status, i don’t know why is disabled:

khadas@Khadas:/$ cat /proc/device-tree/pcieA@fc000000/status
disabled

I found that you use the SD card image, I need to check …

Can you try the eMMC image? It should work. https://dl.khadas.com/Firmware/VIM3/Ubuntu/EMMC/VIM3_Ubuntu-server-bionic_Linux-4.9_arm64_EMMC_V20190830.7z

OK, i need time to download the image and try it.

i read the vim3 dts, it looks really disabled by default. i have selected the pcie port, it should be okay for use. the u-boot should apply a dts overlay for set “disabled” to “okay” after load the dtb file.

  • arch/arm64/boot/dts/amlogic/kvim3_linux.dts
&pcie_A {
        reset-gpio = <&gpio GPIOA_8 GPIO_ACTIVE_HIGH>;
        status = "disabled";
};
  • arch/arm64/boot/dts/amlogic/mesong12b.dtsi
pcie_A: pcieA@fc000000 {
        compatible = "amlogic, amlogic-pcie-v2", "snps,dw-pcie";
        reg = <0x0 0xfc000000 0x0 0x400000
                0x0 0xff648000 0x0 0x2000
                0x0 0xfc400000 0x0 0x200000
                0x0 0xff646000 0x0 0x2000
                0x0 0xffd01080 0x0 0x10>;
        reg-names = "elbi", "cfg", "config", "phy", "reset";
        interrupts = <0 221 0>;
        #interrupt-cells = <1>;
        bus-range = <0x0 0xff>;
        #address-cells = <3>;
        #size-cells = <2>;
        interrupt-map-mask = <0 0 0 0>;
        interrupt-map = <0 0 0 0 &gic GIC_SPI 223 IRQ_TYPE_EDGE_RISING>;
        device_type = "pci";
        ranges = <0x81000000 0 0 0 0xfc600000 0x0 0x100000
                /* downstream I/O */
                0x82000000 0 0xfc700000 0x0 0xfc700000 0 0x1900000>;
                /* non-prefetchable memory */
        num-lanes = <1>;
        pcie-num = <1>;
        clocks = <&clkc CLKID_PCIE_PLL
                &clkc CLKID_PCIE_COMB
                &clkc CLKID_PCIE_PHY>;
        clock-names = "pcie_refpll",
                        "pcie",
                        "pcie_phy";
        /*reset-gpio-type 0:Shared pad(no reset)1:OD pad2:Normal pad*/
        gpio-type = <2>;
        pcie-apb-rst-bit = <15>;
        pcie-phy-rst-bit = <14>;
        pcie-ctrl-a-rst-bit = <12>;
        status = "disabled";
};

so i change the arch/arm64/boot/dts/amlogic/kvim3_linux.dts status “disabled” to “okay

&pcie_A {
        reset-gpio = <&gpio GPIOA_8 GPIO_ACTIVE_HIGH>;
        status = "okay";
};

it is working now

root@Khadas:/home/khadas# dmesg | grep pci
[ 0.557464] amlogic-pcie-v2 fc000000.pcieA: amlogic_pcie_probe!
[ 0.559710] OF: PCI: host bridge /pcieA@fc000000 ranges:
[ 0.560547] amlogic-pcie-v2 fc000000.pcieA: Set the RC Bus Master, Memory Space and I/O Space enables.
[ 0.560575] amlogic-pcie-v2 fc000000.pcieA: normal gpio
[ 0.560610] amlogic-pcie-v2 fc000000.pcieA: GPIO normal: amlogic_pcie_assert_reset
[ 0.650419] amlogic-pcie-v2 fc000000.pcieA: Error: Wait linkup timeout.
[ 0.822574] amlogic-pcie-v2 fc000000.pcieA: Error: Wait linkup timeout.
[ 0.994740] amlogic-pcie-v2 fc000000.pcieA: Error: Wait linkup timeout.
[ 1.166898] amlogic-pcie-v2 fc000000.pcieA: Error: Wait linkup timeout.
[ 1.343052] amlogic-pcie-v2 fc000000.pcieA: Error: Wait linkup timeout.
[ 1.519203] amlogic-pcie-v2 fc000000.pcieA: Error: Wait linkup timeout.
[ 1.695356] amlogic-pcie-v2 fc000000.pcieA: Error: Wait linkup timeout.
[ 1.871507] amlogic-pcie-v2 fc000000.pcieA: Error: Wait linkup timeout.
[ 2.047658] amlogic-pcie-v2 fc000000.pcieA: Error: Wait linkup timeout.
[ 2.223810] amlogic-pcie-v2 fc000000.pcieA: Error: Wait linkup timeout.
[ 2.318274] amlogic-pcie-v2 fc000000.pcieA: phy link never came up
[ 2.318418] amlogic-pcie-v2 fc000000.pcieA: PCI host bridge to bus 0000:00
[ 2.318442] pci_bus 0000:00: root bus resource [bus 00-ff]
[ 2.318461] pci_bus 0000:00: root bus resource [io 0x0000-0xfffff]
[ 2.318480] pci_bus 0000:00: root bus resource [mem 0xfc700000-0xfdffffff]
[ 2.318520] amlogic-pcie-v2 fc000000.pcieA: link timeout, disable PCIE PLL
[ 2.318543] amlogic-pcie-v2 fc000000.pcieA: power down pcie phy
[ 2.740754] ehci-pci: EHCI PCI platform driver
[ 2.740843] ohci-pci: OHCI PCI platform driver
[ 5.491581] amlogic-new-usb3-v2 ffe09080.usb3phy: pci-e driver probe, disable USB 3.0 function!!!

Thank you for your tips. @numbqq

Yes, the default status is disabled. We dynamic change the status in u-boot before loading the kernel.

Of cause, if you don’t use the USB 3.0, you can edit the DTS to ensable the PCIe directly.