Other Parts Discussed in Thread: SYSCONFIG
Tool/software:
Trying to setup GPMC for 3 different areas, 32bit 32Meg on CS0, 16bit 32Meg on CS1 and 32bit 64Meg on CS2. I could only get the last one configured to work.
As sysconfig does not allow the configuration as required, I created an example, then used that to create an routine to support the 3 sections:
/********************************************************/
void Drivers_gpmcOpen(void) {
uint32_t instCnt;
int32_t status = SystemP_SUCCESS;
GPMC_init();
GPMC_clockEnable();
GPMC_clockSetFrequency();
for (instCnt = 0U; instCnt < CONFIG_GPMC_NUM_INSTANCES; instCnt++) {
gGpmcHandle[instCnt] = NULL; /* Init to NULL so that we can exit gracefully */
}
/* Open all instances */
for (instCnt = 0U; instCnt < gGpmcConfigNum; instCnt++) {
gGpmcHandle[instCnt] = GPMC_open(instCnt, &gGpmcParams[instCnt]);
if (NULL == gGpmcHandle[instCnt]) {
status = SystemP_FAILURE;
break;
}
if (GPMC_setDeviceType(gGpmcHandle[instCnt]) != SystemP_SUCCESS) {
status = SystemP_FAILURE;
break;
}
if (GPMC_setDeviceSize(gGpmcHandle[instCnt]) != SystemP_SUCCESS) {
status = SystemP_FAILURE;
break;
}
if (GPMC_configureTimingParameters(gGpmcHandle[instCnt]) != SystemP_SUCCESS) {
status = SystemP_FAILURE;
break;
}
}
if (SystemP_FAILURE == status) {
Drivers_gpmcClose(); /* Exit gracefully */
}
return;
}
/***********************************************************/
The issue was that I could only get the last item to work, if I did them one at a time, the sections worked, but doing more that one, only the last worked. (no matter which order).
Digging into it, I found that GPMC_open, called a routine
static int32_t GPMC_programInstance(GPMC_Handle config)
And Right at the top of the routing is a reset device:
/* Reset GPMC */
CSL_REG32_FINS(hwAttrs->gpmcBaseAddr + CSL_GPMC_SYSCONFIG, GPMC_SYSCONFIG_SOFTRESET,CSL_GPMC_SYSCONFIG_SOFTRESET_RESET);
status += GPMC_moduleResetStatusWaitTimeout(config,GPMC_MODULE_RESET_WAIT_TIME_MAX);
So every time a GPMC_Open is called, (Which I needed to do for the 3 instances), the device was reset.
To correct the issue, I added a static flag to only allow the device to be reset on the first call.
+ static int reset_done = 0;
then around the 2 lines of code that does a RESET, replace with the following:
+ if (reset_done == 0) // only reset on first instance
+ {
/* Reset GPMC */
CSL_REG32_FINS(hwAttrs->gpmcBaseAddr + CSL_GPMC_SYSCONFIG, GPMC_SYSCONFIG_SOFTRESET,CSL_GPMC_SYSCONFIG_SOFTRESET_RESET);
status += GPMC_moduleResetStatusWaitTimeout(config,GPMC_MODULE_RESET_WAIT_TIME_MAX);
+ reset_done = 1;
+ }
That corrected the issue and all the areas work correctly.
Just a little FYI of what I found.