PCIE技术介绍
PCI使用了树形拓扑,树根和处理器桥接,各种IO外设成为叶子节点挂在树上,中间节点为PCI-PCI桥,支持即插即用。
PCIE拓补图如下:
Root complex (RC) – Connects the CPU to the PCIe topology
Switch – Connects more than two ports and acts as a packet router
Bridge – Connects different buses, for example, PCIe to PCIe, or PCIe to peripheral component interconnect (PCI)
Endpoint (EP) – Resides at the bottom of the PCIe topology tree structure and has only an upstream port
Legacy EP – Uses older PCI bus operations to support backward compatibility
The following are a few of the common PCIe terms:
Lane – Serial send and receive path that consists of four wires; two each for differential Tx and Rx
Link – Connects two devices; can have up to 32 lanes
Link width – Number of lanes contained in a link
PCIE实现
仅从wifi部分来看,qcom的cnss使用了mhi的其中一个节点RC0,RC1、RC2未启用。
PCIE枚举过程
当系统启动时,AP侧的系统软件仅仅知道bus 0 的存在,并不知道bus0下边接入了多少个EP和legacy EP。所以需要一个漫长的枚举过程确定设备数量。
下图时一个例子,架设bus0下接入了很长的树状节点,那么需要一个长时间的扫描才知道bus1 - bus6存在。
QCOM平台扫描bus、添加pci设备如下:
Pcie时序
WCN中的PCIE
Pcie注册软件时序
- Pci driver跟随内核启动,注册bus到设备集合中
- Pci driver被cnss注册,调用bus的probe方法后回调cnss实现的pci driver probe方法
- Probe回调过后,cnss解析dts中无线相关配置,配置pci设备
- PCI扫描RC0下所有的设备节点,监控所有EP controller之间的信息交换
- PCI suspend和resume通过直接读写寄存器的形式发送通知跟wcn芯片
关于Probe方法
Probe的回调机制总是让人感觉有些里不顺,究竟是driver直接回调probe函数,还是先调用设备的probe方法后再回调自身的probe函数。
driver_register -->注册driver
-> bus_add_driver -->添加driver结构体到系统中
->driver_attach -->调用bus的match函数指针,匹配设备
-> really_probe -->判断立刻调用probe还是异步延后
->dev->bus->probe -->如果bus实现了probe,调用bus的
PCIE在qcom平台上广泛使用,主要作为BP和AP的桥梁。PCIE模块影响着性能、功耗、稳定性以及整机硬件表现。
本文档仅介绍高通平台中WCN对于PCIE的应用。MTK使用总线为AXI,为ARM制定的规范。