Rockchip RK3588 kernel dts解析之PCIe
文章目录
RK3588控制器
RK3588共有5个PCIe控制器:
- 1个4Lane控制器,DM模式可以支持作为EP使用
- 1个2Lane控制器,只能作为RC使用
- 3个1Lane控制器,只能作为RC使用
控制器在DTS对应节点名称
RK3588
控制器 | DTS节点名称 | 配对的PHY |
---|---|---|
PCIe Gen3 x 4Lane | pcie3x4:pcie@fe150000 | pcie30phy |
PCIe Gen3 x 2Lane | pcie3x2:pcie@fe160000 | pcie30phy |
PCIe Gen3 x 1Lane | pcie2x1l0:pcie@fe170000 | pcie30phy combphy1_ps |
PCIe Gen3 x 1Lane | pcie2x1l1:pcie@fe180000 | pcie30phy combphy2_psu |
PCIe Gen3 x 1Lane | pcie2x1l2:pcie@fe190000 | combphy0_ps |
RK3588S
控制器 | DTS节点名称 | 配对的PHY |
---|---|---|
PCIe Gen3 x 1Lane | pcie2x1l1:pcie@fe180000 | pcie30phy combphy2_psu |
PCIe Gen3 x 1Lane | pcie2x1l2:pcie@fe190000 | combphy0_ps |
RK3588 PHY
RK3588有两种PCIe PHY:
- 一种为pcie3.0PHY,含2个Port共4个Lane,可以根据实际需求拆分使用
- 一种是pcie2.0的PHY有3个,每个都是2.0 1Lane,跟SATA和USB combo使用
PHY在DTS中对应的节点名称
RK3588
PHY名称 | DTS节点名称 | 是否复用 |
---|---|---|
pcie30phy | phy@fee80000 | pcie专用 |
combphy0_ps | phy@fee00000 | 与SATA复用 |
combphy1_ps | phy@fee10000 | 与SATA复用 |
combphy2_psu | phy@fee20000 | 与SATA/USB3复用 |
RK3588S
PHY名称 | DTS节点名称 | 是否复用 |
---|---|---|
combphy0_ps | phy@fee00000 | 与SATA复用 |
combphy2_psu | phy@fee20000 | 与SATA/USB3复用 |
使用限制
- pcie30phy拆分后,pcie30x4控制器,工作于2Lane模式时只能固定配合pcie30phy的port0,工作于1Lane模式时,只能固定配合pcie30phy的port0lane0;
- pcie30phy拆分后,pcie30x2控制器,工作于2Lane模式时只能固定配合pcie30phy的port1,工作于1Lane模式时,只能固定配合pcie30phy的port1lane0;
- pcie30phy拆分为4个1Lane,pcie3phy的port0lane1只能固定配合pcie2x1l0控制器,pcie3phy的port1lane1只能固定配合pcie2x1l1控制器;
- pcie30x4控制器工作于EP模式,可以使用4Lane模式,或者2Lane模式使用pcie30phy的port0,pcie30phy的port1中2lane可以作为RC配合其他控制器使用。默认使用common clock作为reference clock时,无法实现pcie30phy port0的lane0工作于EP模式,lane1工作于RC模式配合其他控制器使用,因为Port0的两个lane是共用一个输入的reference clock,RC和EP同时使用clock可能会有冲突。
- RK3588 pcie30phy 如果只使用其中一个port,另一个port也需要供电,refclk等其他信号可接地。
DTS配置解析
pcie的配置大部分是固定的,需要在板级dts配置的变量并不多参考以下要点进行配置即可:
- 控制器/PHY使能:确定方案后,根据原理图选择使能正确的控制器和PHY,注意控制器的index和phy的index不一定是顺序匹配的,如RK3588的pcie2x1l0不是对应combphy0_ps;
- 控制器:部分控制器(如RK3588的pcie2x1l0和pcie2x1l1)有不止一个phy可选,按方案设计正确配置“phys”;
- 控制器:作为RC通常需要配置"reset-gpios", 该项对应原理图PCIE的"PERSTn"信号;
- 控制器:作为RC可能需要配置"vpcie3v3-supply",该项对应的是PCIE的"PWREN"gpio信号控制的fixed regulator;
- 控制器:作为EP使用时,需要修改"compatible"为EP模式对应字串;
- PHY:pcie30phy共4个lane,可拆分使用,需要根据方案正确配"rockchip,pcie30-phymode"模式;
参考设计硬件RK3588-EVB1 对应DTS:rk3588-evb1-lp4-v10.dts
硬件设计
pcie3.0 4Lane RC + 2个pcie 2.0(复用的PHY分别对应 MUX1:combphy1_ps 和MUX2:combphy2_psu )
软件DTS配置
PCIe的具体DTS配置在arch/arm64/boot/dts/rockchip/rk3588-evb1-lp4.dtsi
电源部分的配置:
pcie20_avdd0v85: pcie20-avdd0v85 {
compatible = "regulator-fixed";
regulator-name = "pcie20_avdd0v85";
regulator-boot-on;
regulator-always-on;
regulator-min-microvolt = <850000>;
regulator-max-microvolt = <850000>;
vin-supply = <&avdd_0v85_s0>;
};
pcie20_avdd1v8: pcie20-avdd1v8 {
compatible = "regulator-fixed";
regulator-name = "pcie20_avdd1v8";
regulator-boot-on;
regulator-always-on;
regulator-min-microvolt = <1800000>;
regulator-max-microvolt = <1800000>;
vin-supply = <&avcc_1v8_s0>;
};
pcie30_avdd0v75: pcie30-avdd0v75 {
compatible = "regulator-fixed";
regulator-name = "pcie30_avdd0v75";
regulator-boot-on;
regulator-always-on;
regulator-min-microvolt = <750000>;
regulator-max-microvolt = <750000>;
vin-supply = <&avdd_0v75_s0>;
};
pcie30_avdd1v8: pcie30-avdd1v8 {
compatible = "regulator-fixed";
regulator-name = "pcie30_avdd1v8";
regulator-boot-on;
regulator-always-on;
regulator-min-microvolt = <1800000>;
regulator-max-microvolt = <1800000>;
vin-supply = <&avcc_1v8_s0>;
};
# PCIe3.0的GPIO控制电源的配置
vcc3v3_pcie30: vcc3v3-pcie30 {
compatible = "regulator-fixed";
regulator-name = "vcc3v3_pcie30";
regulator-min-microvolt = <3300000>;
regulator-max-microvolt = <3300000>;
enable-active-high;
gpios = <&gpio3 RK_PC3 GPIO_ACTIVE_HIGH>;
startup-delay-us = <5000>;
vin-supply = <&vcc12v_dcin>;
};
PCIE控制器的配置
控制的详细配置在rk3588.dtsi中 ,对应的phy的指定也已经默认配置好,如需要重新配置phy可以修改
phys = <&pcie30phy>;
phys = <&combphy1_ps PHY_TYPE_PCIE>;
RK3588的pcie2x1l0和pcie2x1l1控制器可以路由到多个phy,需要注意的是不同的phy引用方式可能有差异,comboPHY需要同时指定phy的工作模式
用于WIFI模块
&pcie2x1l0 {
reset-gpios = <&gpio4 RK_PA5 GPIO_ACTIVE_HIGH>;
rockchip,skip-scan-in-resume;
status = "okay";
};
用于以太网模块
&pcie2x1l1 {
reset-gpios = <&gpio4 RK_PA2 GPIO_ACTIVE_HIGH>;
pinctrl-names = "default";
pinctrl-0 = <&rtl8111_isolate>;
status = "okay";
};
&pcie30phy {
rockchip,pcie30-phymode = <PHY_MODE_PCIE_AGGREGATION>;
status = "okay";
};
&pcie3x4 {
reset-gpios = <&gpio4 RK_PB6 GPIO_ACTIVE_HIGH>; //配置PCIE3.0的reset脚
vpcie3v3-supply = <&vcc3v3_pcie30>; //配置对应的电源
status = "okay";
};
PHY的配置
硬件原图上面对应的是MUX1
&combphy1_ps {
status = "okay";
};
硬件原图上面对应的是MUX2
&combphy2_psu {
status = "okay";
};
其他常见的PCIE配置对应的DTS配置实例
pcie3.0phy拆分2个2Lane RC, 3个PCIe 2.0 1Lane(comboPHY)
注意:如果pcie3.0phy拆分2个2Lane,但是只用一组的话,需要把另一组disabled,但是关掉的那组的pcie的电源还是要供着,否则会导致pcie异常无法使用。
/ {
vcc3v3_pcie30: vcc3v3-pcie30 {
compatible = "regulator-fixed";
regulator-name = "vcc3v3_pcie30";
regulator-min-microvolt = <3300000>;
regulator-max-microvolt = <3300000>;
enable-active-high;
gpios = <&gpio3 RK_PC3 GPIO_ACTIVE_HIGH>;
startup-delay-us = <5000>;
vin-supply = <&vcc12v_dcin>;
};
};
&combphy0_ps {
status = "okay";
};
&combphy1_ps {
status = "okay";
};
&combphy2_psu {
status = "okay";
};
&pcie2x1l0 {
phys = <&combphy1_ps PHY_TYPE_PCIE>;
reset-gpios = <&gpio4 RK_PA5 GPIO_ACTIVE_HIGH>;
vpcie3v3-supply = <&vcc3v3_pcie30>;
status = "okay";
};
&pcie2x1l1 {
phys = <&combphy2_psu PHY_TYPE_PCIE>;
reset-gpios = <&gpio4 RK_PA2 GPIO_ACTIVE_HIGH>;
vpcie3v3-supply = <&vcc3v3_pcie30>;
status = "okay";
};
&pcie2x1l2 {
reset-gpios = <&gpio4 RK_PC1 GPIO_ACTIVE_HIGH>;
vpcie3v3-supply = <&vcc3v3_pcie30>;
status = "okay";
};
&pcie30phy {
rockchip,pcie30-phymode = <PHY_MODE_PCIE_NANBNB>;
status = "okay";
};
//表示lane2/3
&pcie3x2 {
reset-gpios = <&gpio4 RK_PB0 GPIO_ACTIVE_HIGH>;
vpcie3v3-supply = <&vcc3v3_pcie30>;
status = "okay";
};
//表示lane0/1
&pcie3x4 {
num-lanes = <2>;
reset-gpios = <&gpio4 RK_PB6 GPIO_ACTIVE_HIGH>;
vpcie3v3-supply = <&vcc3v3_pcie30>;
status = "okay";
};
pcie3.0phy拆分为4个1Lane, 1个使用PCIe 2.0 1 Lane(comboPHY)
/ {
vcc3v3_pcie30: vcc3v3-pcie30 {
compatible = "regulator-fixed";
regulator-name = "vcc3v3_pcie30";
regulator-min-microvolt = <3300000>;
regulator-max-microvolt = <3300000>;
enable-active-high;
gpios = <&gpio3 RK_PC3 GPIO_ACTIVE_HIGH>;
startup-delay-us = <5000>;
vin-supply = <&vcc12v_dcin>;
};
};
&combphy0_ps {
status = "okay";
};
&pcie2x1l0 {
phys = <&pcie30phy>;
reset-gpios = <&gpio4 RK_PA5 GPIO_ACTIVE_HIGH>;
vpcie3v3-supply = <&vcc3v3_pcie30>;
status = "okay";
};
&pcie2x1l1 {
phys = <&pcie30phy>;
reset-gpios = <&gpio4 RK_PA2 GPIO_ACTIVE_HIGH>;
vpcie3v3-supply = <&vcc3v3_pcie30>;
status = "okay";
};
&pcie2x1l2 {
reset-gpios = <&gpio4 RK_PC1 GPIO_ACTIVE_HIGH>;
vpcie3v3-supply = <&vcc3v3_pcie30>;
status = "okay";
};
&pcie30phy {
rockchip,pcie30-phymode = <PHY_MODE_PCIE_NABIBI>;
status = "okay";
};
&pcie3x2 {
num-lanes = <1>;
reset-gpios = <&gpio4 RK_PB0 GPIO_ACTIVE_HIGH>;
vpcie3v3-supply = <&vcc3v3_pcie30>;
status = "okay";
};
&pcie3x4 {
num-lanes = <1>;
reset-gpios = <&gpio4 RK_PB6 GPIO_ACTIVE_HIGH>;
vpcie3v3-supply = <&vcc3v3_pcie30>;
status = "okay";
};
PCIE的详细说明文档可以参考Rockchip RK3588 Android SDK的如下文档
RKDocs/common/PCie/Rockchip_Developer_Guide_PCIe_CN.pdf