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.

SPI and PWRM on C6748

Other Parts Discussed in Thread: OMAP-L138, OMAPL138

I have run into a frustrating problem with SPI while attempting to port an existing (functional) application from a C6747 platform to a C6748 (actually the DSP portion of an OMAP-L138). The application is built on DSP/BIOS 5.41.02.14, PSP 1.30.01, and EDMA3 1.10.0.01.   

When the SPI device is created using a call to DEV_createDevice() I get back error code 7 on the C6748 eval platform.  I dug into the spi.c source code and did some single-stepping.  I found that with the SPI driver parameter for PWRM set to FALSE (the DSP acts as a slave, so PWRM can't be enabled) and with BIOS_PWRM_ENABLE defined the code is attempting to use PWRM anyway (error code 7 is PWRM_ENOTSUPPORTED, returned from PWRM_setDependency).  A code snippet is below (starting at line 469 from spi.c in the PSP):

 if ((IOM_COMPLETED == status) && (FALSE == instHandle->pscPwrmEnable))
{
#ifdef BIOS_PWRM_ENABLE
            /* power on using bios PWRM API                                   */
            status = (Int32)PWRM_setDependency(
                        (PWRM_Resource)instHandle->deviceInfo.pwrmLpscId);

#else
            /* power on using PSC API                                         */
            status = Psc_ModuleClkCtrl(
                         (Psc_DevId)instHandle->deviceInfo.pscInstance,
                         (Uint32)instHandle->deviceInfo.pwrmLpscId,
                         TRUE);
#endif
}

I think the logic of this code block is incorrect.  What you want is if pscPwrmEnable is TRUE and BIOS_PWRM_ENABLE is defined then use PWRM, otherwise you want to use the PSC (to power-on the SPI module).  It looks like the author was attempting to combine preprocessor #ifdef logic with runtime logic and ending up creating a bug. I think the following is the intent: 

if (IOM_COMPLETED == status )
{
#ifdef BIOS_PWRM_ENABLE
    if( TRUE == instHandle->pscPwrmEnable )
        /* PWRM disabled - always use PSC API                              */
        status = Psc_ModuleClkCtrl(
                    (Psc_DevId)instHandle->deviceInfo.pscInstance,
                    (Uint32)instHandle->deviceInfo.pwrmLpscId,
                     TRUE);
    else
#endif
            /* power on using PSC API (no PWRM  support or PWRM not enabled)           */
            status = Psc_ModuleClkCtrl(
                         (Psc_DevId)instHandle->deviceInfo.pscInstance,
                         (Uint32)instHandle->deviceInfo.pwrmLpscId,
                         TRUE);
}
 

You don't want to call PWRM unless it is enabled for use in the driver AND support for it is enabled in the PSP.  Obviously I can fix this problem and rebuild the SPI driver, but I found the same issue in at least one other driver (I2C) so I am little worried about using PSP 1.30.01 on the C6748 platform. I looked for an updated PSP but didn't see one.  I  also did a search throughthe forums and on the Internet but didn't find anyone else commenting on this particular problem. 

I just wanted to make sure I wasn't doing something wrong but the code for the SPI drive sure seems wrong to me.

Thanks

  • Hi Ron,

    If you refer the C6748_BIOSPSP_Userguide (placed in - pspdrivers_01_30_01\docs) section 1.6 clearly mentions about the usage of Power Management.. Please refer it.

    1. The user can configure the driver to use either DSP/BIOS PWRM module API's or BIOSPSP PSC driver API's by enabling or disabling the BIOS_PWRM_ENABLE compiler switch respectively.

    2. If the user wishes not to use the power management functionalities of pwrm like, dynamic voltage frequency scaling(DVFS), etc,.. Then he can simple set the “pscPwrmEnable” to false. By doing so, the driver only enables/turns on the module (using BIOS PWRM - why? refer next point) once during driver instantiation(mdBindDev()) and then disables only during driver instance deletion(mdUnbindDev())

    3. Please note that DSP/BIOS based power management support is currently for C6748 and OMAPL138 based platform only and only BIOS power management must be used for these platforms. 

     

    Can you please refer the Userguide section 1.2.1, and install all the appropriate tools(seems like you are using the older version of BIOS) as mentioned and check again.

    Hope this is clear now.. 

     

    Thanks & regards,

    Raghavendra

  • Hi

    I am trying to disable the BIOS_PWRM_ENABLE compile switch as described above (on OMAPL138).

    However both SpiLocal.h and mcbspLocal.h contain the following snippet of code:

    #if ((defined(CHIP_C6748) || defined(CHIP_OMAPL138)) && (!defined(BIOS_PWRM_ENABLE)))
    #error "Use Bios PWRM module only for the SoC"
    #elif defined(BIOS_PWRM_ENABLE)
        #include <pwrm.h>
    #endif

    Is it possible to use SPI or McBSP without the BIOS_PWRM_ENABLE defined?

    Thanks

  • Hi Dhar Kurban,

    Dhar Kurban said:
    Is it possible to use SPI or McBSP without the BIOS_PWRM_ENABLE defined?

    Yes, It is possible.. But,

    As I have already mentioned above, the Userguide says that “DSP/BIOS based power management support is currently for C6748 and OMAPL138 based platform only and only BIOS power management must be used for these platforms”. In fact, just using PSC without PWRM would also work! with little modifications in the driver. But, it’s not tested/validated. To use SPI or McBSP without the "BIOS_PWRM_ENABLE" few steps have to be taken care. Like –

    In the driver (SPI or McBSP) folder,

    1. Remove the BIOS_PWRM_ENABLE entry from the pjt file.
    2. Comment the message “#error "Use Bios PWRM module only for the SoC" in the SpiLocal.h  and McbspLocal.h files.
    3. Re-Build the driver.

     Then, build the application. Hope this helps..

     

    Best Regards,

    Raghavendra