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