龙芯2k

LOONGSON-2K-PCIE的枚举问题

龙芯2K-Pcie控制器分析

2K有2个PCIE控制器, PCIE0有4个Port, 可以配置4个X1或者1个X4,作为X的时候只有Port0, PCIE1有2个port, 可以配置2个X1或者1个X4。但是为什么设备树配置6路PCIE, 并不是都当做下,而是通用配置6路, 这样不管6个X1还是几个X4都可以,
2.pcie-x4-i350网卡发现只有3个lan注册成功, Lan3在Probe failed, 是pcie的mem地址大小不够;
分析代码发现, 设备树的枚举应该是广度枚举,虽然设备树中给6个pcie-port都分配了mem和io地址, 但是实际的设备地址分配从0x40100000地址开始分配, 所以增大port的地址size
龙芯反馈采用广度枚举是为了地址对齐, 即枚举完所有的设备再开始分配地址,且设备树中给桥分配的地址是桥本身的配置各个空间地址和下游设备无关

设备树中pcie的配置, 注意地址分配

pcie0_port0@40100000 {
compatible = “loongson,ls-pcie”;
interrupt-parent = <&intc>;
interrupts = <40>;
#address-cells = <3>;
#size-cells = <2>;
bus-range = <0x1 0x3>;
ranges = <0x02000000 0x0 0x40100000 0x40100000 0x0 0x8000000 //mem 注意这个地址的大小,其实所有的PCIE设备地址分配都是从0x40100000开始的, 并不是pcieN下游的设备东PCIE-N的分配的地址开始的,这里也只是
0x01000000 0x0 0x18000000 0x18000000 0x0 0x0ff000>; //io
};

    pcie0_port1@50000000 {
        compatible = "loongson,ls-pcie";
        interrupt-parent = <&intc>;
        interrupts = <41>;
        #address-cells = <3>;
        #size-cells = <2>;
        bus-range = <0x4 0x6>;
        ranges = <0x02000000 0x0 0x50000000 0x50000000 0x0 0x4000000    //mem
                     0x01000000 0x0 0x18100000 0x18100000 0x0 0x0ff000>;  //io
    };

    pcie0_port2@54000000 {
        compatible = "loongson,ls-pcie";
        interrupt-parent = <&intc>;
        interrupts = <42>;
        #address-cells = <3>;
        #size-cells = <2>;
        bus-range = <0x8 0xa>;
        ranges = <0x02000000 0x0 0x54000000 0x54000000 0x0 0x4000000    //mem
                     0x01000000 0x0 0x18200000 0x18200000 0x0 0x100000>;  //io
    };

pcie0_port3@58000000 {
compatible = “loongson,ls-pcie”;
interrupt-parent = <&intc>;
interrupts = <43>;
#address-cells = <3>;
#size-cells = <2>;
bus-range = <0xc 0xe>;
ranges = <0x02000000 0x0 0x58000000 0x58000000 0x0 0x8000000 //mem
0x01000000 0x0 0x18300000 0x18300000 0x0 0x100000>; //io
};

    pcie1_port0@60000000 {
        compatible = "loongson,ls-pcie";
        interrupt-parent = <&intc>;
        interrupts = <44>;
        #address-cells = <3>;
        #size-cells = <2>;
        bus-range = <0x10 0x12>;
        ranges = <0x02000000 0x0 0x60000000 0x60000000 0x0 0x18000000   //mem
                     0x01000000 0x0 0x18400000 0x18400000 0x0 0x100000>;  //io
    };

    pcie1_port1@78000000 {
        compatible = "loongson,ls-pcie";
        interrupt-parent = <&intc>;
        interrupts = <45>;
        #address-cells = <3>;
        #size-cells = <2>;
        bus-range = <0x14 0x16>;
        ranges = <0x02000000 0x0 0x78000000 0x78000000 0x0 0x8000000    //mem
                     0x01000000 0x0 0x18500000 0x18500000 0x0 0x100000>;  //io

}

(2)比如设备枚举
root@Loongson:~# lspci
01:00.0 Ethernet controller: Intel Corporation I210 Gigabit Network Connection (rev 03)
04:00.0 Ethernet controller: Intel Corporation I210 Gigabit Network Connection (rev 03)
08:00.0 SATA controller: Marvell Technology Group Ltd. Device 9215 (rev 11)
14:00.0 Ethernet controller: Intel Corporation I350 Gigabit Network Connection (rev 01)
14:00.1 Ethernet controller: Intel Corporation I350 Gigabit Network Connection (rev 01)
14:00.2 Ethernet controller: Intel Corporation I350 Gigabit Network Connection (rev 01)
14:00.3 Ethernet controller: Intel Corporation I350 Gigabit Network Connection (rev 01)
root@Loongson:~# lspci -t //枚举树是逆序的,地址分配都是
-±[0000:14]-±00.0 //start_addr = 0x40400000 //pcie-x4-i350
| ±00.1 //start_addr = 0x40300000
| ±00.2 //start_addr = 0x40200000
| -00.3 //start_addr = 0x40100000
±[0000:08]—00.0 //start_addr = 0x40800000 //sata控制器
±[0000:04]—00.0 //start_addr = 0x40a00000 //pcie-x1-i210
±[0000:01]—00.0 //start_addr = 0x40d00000 //pcie-x1-i210
-[0000:00]-
设备地址分配:
[ 0.059920] Support PCI MSI interrupt
[ 0.061986] PCI host bridge /soc/pcie0_port0@40100000 ranges:
[ 0.062011] MEM 0x0000000040100000…0x00000000480fffff
[ 0.062022] IO 0x0000000018000000…0x00000000180fefff
[ 0.062252] PCI host bridge to bus 0000:01
[ 0.062270] pci_bus 0000:01: root bus resource [mem 0x40100000-0x480fffff]
[ 0.062279] pci_bus 0000:01: root bus resource [io 0x0000-0xfefff]
[ 0.062287] pci_bus 0000:01: root bus resource [bus 01-03]
[ 0.062347] pci 0000:01:00.0: [8086:1533] type 00 class 0x020000
[ 0.062416] pci 0000:01:00.0: reg 0x10: [mem 0x40d00000-0x40dfffff]
[ 0.062472] pci 0000:01:00.0: reg 0x1c: [mem 0x40e00000-0x40e03fff]
[ 0.062528] pci 0000:01:00.0: reg 0x30: [mem 0x40c00000-0x40cfffff pref]
[ 0.062661] pci 0000:01:00.0: PME# supported from D0 D3hot D3cold
[ 0.063818] PCI host bridge /soc/pcie0_port1@50000000 ranges:
[ 0.063839] MEM 0x0000000050000000…0x0000000053ffffff
[ 0.063849] IO 0x0000000018100000…0x00000000181fefff
[ 0.064033] PCI host bridge to bus 0000:04
[ 0.064044] pci_bus 0000:04: root bus resource [mem 0x50000000-0x53ffffff]
[ 0.064053] pci_bus 0000:04: root bus resource [io 0x100000-0x1fefff]
[ 0.064061] pci_bus 0000:04: root bus resource [bus 04-06]
[ 0.064105] pci 0000:04:00.0: [8086:1533] type 00 class 0x020000
[ 0.064161] pci 0000:04:00.0: reg 0x10: [mem 0x40a00000-0x40afffff]
[ 0.064241] pci 0000:04:00.0: reg 0x1c: [mem 0x40b00000-0x40b03fff]
[ 0.064297] pci 0000:04:00.0: reg 0x30: [mem 0x40900000-0x409fffff pref]
[ 0.064409] pci 0000:04:00.0: PME# supported from D0 D3hot D3cold
[ 0.065530] PCI host bridge /soc/pcie0_port2@54000000 ranges:
[ 0.065550] MEM 0x0000000054000000…0x0000000057ffffff
[ 0.065560] IO 0x0000000018200000…0x00000000182fffff
[ 0.065750] PCI host bridge to bus 0000:08
[ 0.065762] pci_bus 0000:08: root bus resource [mem 0x54000000-0x57ffffff]
[ 0.065770] pci_bus 0000:08: root bus resource [io 0x200000-0x2fffff]
[ 0.065777] pci_bus 0000:08: root bus resource [bus 08-0a]
[ 0.065809] pci 0000:08:00.0: [1b4b:9215] type 00 class 0x010601 //sata控制器
[ 0.065840] pci 0000:08:00.0: reg 0x10: [io 0x7038-0x703f]
[ 0.065855] pci 0000:08:00.0: reg 0x14: [io 0x7030-0x7033]
[ 0.065870] pci 0000:08:00.0: reg 0x18: [io 0x7028-0x702f]
[ 0.065884] pci 0000:08:00.0: reg 0x1c: [io 0x7020-0x7023]
[ 0.065897] pci 0000:08:00.0: reg 0x20: [io 0x7000-0x701f]
[ 0.065915] pci 0000:08:00.0: reg 0x24: [mem 0x40810000-0x408107ff]
[ 0.065930] pci 0000:08:00.0: reg 0x30: [mem 0x40800000-0x4080ffff pref]
[ 0.065988] pci 0000:08:00.0: PME# supported from D3hot
[ 0.067111] PCI host bridge /soc/pcie0_port3@58000000 ranges
[ 0.067133] MEM 0x0000000058000000…0x000000005fffffff
[ 0.067143] IO 0x0000000018300000…0x00000000183fffff
[ 0.067365] PCI host bridge to bus 0000:0c
[ 0.067376] pci_bus 0000:0c: root bus resource [mem 0x58000000-0x5fffffff]
[ 0.067384] pci_bus 0000:0c: root bus resource [io 0x300000-0x3fffff]
[ 0.067392] pci_bus 0000:0c: root bus resource [bus 0c-0e]
[ 0.068263] PCI host bridge /soc/pcie1_port0@60000000 ranges:
[ 0.068282] MEM 0x0000000060000000…0x0000000077ffffff
[ 0.068292] IO 0x0000000018400000…0x00000000184fffff
[ 0.068469] PCI host bridge to bus 0000:10
[ 0.068481] pci_bus 0000:10: root bus resource [mem 0x60000000-0x77ffffff]
[ 0.068488] pci_bus 0000:10: root bus resource [io 0x400000-0x4fffff]
[ 0.068496] pci_bus 0000:10: root bus resource [bus 10-12]
[ 0.069357] PCI host bridge /soc/pcie1_port1@78000000 ranges:
[ 0.069376] MEM 0x0000000078000000…0x000000007fffffff
[ 0.069385] IO 0x0000000018500000…0x00000000185fffff
[ 0.069569] PCI host bridge to bus 0000:14
[ 0.069579] pci_bus 0000:14: root bus resource [mem 0x78000000-0x7fffffff]
[ 0.069587] pci_bus 0000:14: root bus resource [io 0x500000-0x5fffff]
[ 0.069594] pci_bus 0000:14: root bus resource [bus 14-16]
[ 0.069632] pci 0000:14:00.0: [8086:1521] type 00 class 0x020000
[ 0.069679] pci 0000:14:00.0: reg 0x10: [mem 0x40400000-0x404fffff]
[ 0.069714] pci 0000:14:00.0: reg 0x1c: [mem 0x4058c000-0x4058ffff]
[ 0.069749] pci 0000:14:00.0: reg 0x30: [mem 0x40500000-0x4057ffff pref]
[ 0.069842] pci 0000:14:00.0: PME# supported from D0 D3hot D3cold
[ 0.069874] pci 0000:14:00.0: 4.000 Gb/s available PCIe bandwidth, limited by 5 GT/s x1 link at 0000:14:00.0 ()
[ 0.070109] pci 0000:14:00.1: [8086:1521] type 00 class 0x020000
[ 0.070175] pci 0000:14:00.1: reg 0x10: [mem 0x40300000-0x403fffff]
[ 0.070210] pci 0000:14:00.1: reg 0x1c: [mem 0x40588000-0x4058bfff]
[ 0.070321] pci 0000:14:00.1: PME# supported from D0 D3hot D3cold
[ 0.070556] pci 0000:14:00.2: [8086:1521] type 00 class 0x020000
[ 0.070597] pci 0000:14:00.2: reg 0x10: [mem 0x40200000-0x402fffff]
[ 0.070632] pci 0000:14:00.2: reg 0x1c: [mem 0x40584000-0x40587fff]
[ 0.070741] pci 0000:14:00.2: PME# supported from D0 D3hot D3cold
[ 0.070987] pci 0000:14:00.3: [8086:1521] type 00 class 0x020000
[ 0.071028] pci 0000:14:00.3: reg 0x10: [mem 0x40100000-0x401fffff]
[ 0.071063] pci 0000:14:00.3: reg 0x1c: [mem 0x40580000-0x40583fff]
[ 0.071191] pci 0000:14:00.3: PME# supported from D0 D3hot D3cold

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值