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.

PCIe configuration in C6678 (memset)

Hi, 

I'm tested the PCIe sample code provided by TI with two keystone C66 devices and it works perfectly.

But i found in the code, exactly in configuration part, that every time memset is used with the value 0 whitch overwrites the old value in the registers.

For example : 

/* Configure the size of the translation regions */
memset (&setRegs, 0, sizeof(setRegs));
memset (&getRegs, 0, sizeof(getRegs));

obSize.size = pcie_OB_SIZE_8MB;
setRegs.obSize = &obSize;

if ((retVal = Pcie_writeRegs (handle, pcie_LOCATION_LOCAL, &setRegs)) != pcie_RET_OK)
{
System_printf ("SET OB_SIZE register failed!\n");
return retVal;
}

/* Setting PL_GEN2 */
memset (&setRegs, 0, sizeof(setRegs));
gen2.numFts = 0xF;
gen2.dirSpd = 0x0;
gen2.lnEn = 1;
setRegs.gen2 = &gen2;

if ((retVal = Pcie_writeRegs (handle, pcie_LOCATION_LOCAL, &setRegs)) != pcie_RET_OK)
{
System_printf ("SET GEN2 register failed!\n");
return retVal;
}

So in this case the value in OB_SIZE register will not be overwrited.

Sincerly

Youssef

  • Youssef,

    Please take a look at the details of "Pcie_writeRegs()" API in PCIe LLD source code "C:\ti\pdk_C6657_1_1_2_5\packages\ti\drv\pcie\src\pcie.c".

    if (writeRegs->cmdStatus) {
    pcie_check_result(retVal, pcie_write_cmdStatus_reg (baseAppRegs, writeRegs->cmdStatus));
    }
    if (writeRegs->cfgTrans) {
    pcie_check_result(retVal, pcie_write_cfgTrans_reg (baseAppRegs, writeRegs->cfgTrans));
    }
    if (writeRegs->ioBase) {
    pcie_check_result(retVal, pcie_write_ioBase_reg (baseAppRegs, writeRegs->ioBase));
    }

    ......

    "setRegs" and "getRegs" are just data structures of PCIe register pointers.  The API will check if any new register pointers are assigned to "writeRegs"(setRegs) and only the new modifications will be updated when calling this API. So the previous updates will remain the same.