This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

C6657 PCIE 问题咨询



Hi  各位管理好

咨询下,我使用STK 6657 中的 PCIE_test 例程进行PCIE通信测试, 6657作为RC端口, pcie外接设备

在代码中有如下部分:

CSL_Pciess_appRegs *gpPCIE_app_regs = (CSL_Pciess_appRegs*)CSL_PCIE_CONFIG_REGS;
CSL_Pcie_cfg_space_rootcomplexRegs *gpPCIE_RC_regs = (CSL_Pcie_cfg_space_rootcomplexRegs*)(CSL_PCIE_CONFIG_REGS + 0x1000);
CSL_Pcie_cfg_space_endpointRegs *gpPCIE_EP_regs = (CSL_Pcie_cfg_space_endpointRegs*)(CSL_PCIE_CONFIG_REGS + 0x1000);

//remote PCIE EP registers
CSL_Pcie_cfg_space_endpointRegs *gpPCIE_remote_EP_regs = (CSL_Pcie_cfg_space_endpointRegs*)(CSL_PCIE_CONFIG_REGS+0x3000);

这里的 gpPCIE_remote_EP_regs 我理解是在  train link 完成后, 在本地PCIE config空间映射的 EP端的config空间,

后续初始化EP端Bar base地址的时候,就是操作 gpPCIE_remote_EP_regs 里面的bar内存。

现在有个疑问:

问题1 :

在 PCI Express (PCIe) for KeyStone Devices User's Guide.pdf 文档中有这么一副图

在图中看

偏移 0x0 是application 部分 

偏移0x1000 是local config 本地pcie配置空间

偏移0x2000 是remote config EP 端的pcie配置空间映射

偏移0x3000 是remote io 操作的映射

那我按照上图的理解, 配置EP端的pcie config 空间,应该操作的是0x2000偏移的这段内存, 但是测试用例中为什么使用 0x3000的偏移地址呢

通过在ccs中查看memory 发现 0x2180_2000 地址是 EP端的配置空间内容, 而 0x2180_3000 地址的内容是全0 (0x2180_0000 是memory 中pcie config 的起始地址)

请教下, 这样看是不是例程中的 gpPCIE_remote_EP_regs 地址赋值有误?


问题2 :

6657做pcie主设备的时候, 下挂的pcie 不是一个EP设备, 而是一个 pcie-bridge, 在 bridge 下面有一个pci设备, 所以现在需要在代码中枚举pcie设备,请教下有没有 DSP做RC端时, 枚举PCIE设备的参考用例

非常感谢您的回复

  • 帖子里面可以@管理员吗

  • 1 你说的是哪行代码用的是0x3000

     我看到的定义的是 0x2000。

    CSL_Pcie_cfg_space_endpointRegs *gpPCIE_remote_EP_regs[] =
    {
    (CSL_Pcie_cfg_space_endpointRegs*)(CSL_PCIE_0_SLV_CFG_REGS + 0x2000),
    (CSL_Pcie_cfg_space_endpointRegs*)(CSL_PCIE_1_SLV_CFG_REGS + 0x2000)
    };

    2  主机侧没有完整的RC 枚举参考代码,但提供了相应寄存器,可以参看STK中DSP作为RC的例子

  • 非常感谢管理的回复, 

    我使用的STK包是从置顶帖子里面 keystone1 stk里下载的EVM6657的stk用例, 代码如压缩包中的 STK_C6657.7z

    在pcie的例子中, Keystone_PCIE_Init_drv.c  20行-29行

    其中定的的 gpPCIE_remote_EP_regs 偏移量为0x3000 (是不是我使用的这个STK版本不对, 管理可否把最新的6657 STK下载地址告诉下)

    /************************Global Variable define******************************/
    CSL_Pciess_appRegs *gpPCIE_app_regs = (CSL_Pciess_appRegs*)CSL_PCIE_CONFIG_REGS;
    CSL_Pcie_cfg_space_rootcomplexRegs *gpPCIE_RC_regs = (CSL_Pcie_cfg_space_rootcomplexRegs*)(CSL_PCIE_CONFIG_REGS + 0x1000);
    CSL_Pcie_cfg_space_endpointRegs *gpPCIE_EP_regs = (CSL_Pcie_cfg_space_endpointRegs*)(CSL_PCIE_CONFIG_REGS + 0x1000);

    //PCIE capability and implementation specific registers
    PCIE_CAP_Implement_Regs *gpPCIE_CAP_implement_regs = (PCIE_CAP_Implement_Regs *)(CSL_PCIE_CONFIG_REGS + 0x1040);

    //remote PCIE EP registers 
    CSL_Pcie_cfg_space_endpointRegs *gpPCIE_remote_EP_regs = (CSL_Pcie_cfg_space_endpointRegs*)(CSL_PCIE_CONFIG_REGS+0x3000);

    我按照上面的指导,把 gpPCIE_remote_EP_regs  的偏移修改为0x2000, 在0x2180_2000处可以读到了下级pcie设备的配置空间, 因为我连接的pcie设备是一个pcie bridge我需要枚举其下面的其他PCIE设备。

    我的做法如下:

    1, 配置PCIE_bridge 其中的上级bus号为0 , 下级bus号为1, 配置bridge的 memory base 和 limited , pre-fetch memory base 和limited

    2,   配置bus =1 dev =0 fun=0 到 application中的cfg寄存器, (设置bridge下面的pcie设备地址, 尝试枚举)

    3, 重新读取 x02180_2000 地址处的 remote config 配置, (我理解这里应该可以读出  bus1 dev0, fun0 对应pcie设备的配置空间, 如果没读到 vendor id之类为空, 但是现在读出来的还依然是pcie-bridge上面的配置空间)

    请教下这个中间是否有少什么步骤, 在配置了 application 的cfg寄存器后, 是否直接可以从 0x2180_2000 读出对应设备的配置空间, 还是中间需要添加什么其他步骤, 感谢您的回复

    STK_C6657.7z