AM6442: Issue using multiple GPMC areas, (FYI and Fix)

Part Number: AM6442
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.

           

  • This is in the latest version mcu_plus_sdk_am64x_11_01_00_17, plus the previous 2 versions.

  • Hello Robert Morse ,

    In the MCU+ SDK, we currently don’t support configuring multiple chip-select (CS) lines simultaneously.
    If multiple CS lines are needed, each GPMC instance must be initialized separately with its respective CS configuration.

    Also, the GPMC reset needs to be performed only once — during the initial setup.

    After that, you can reconfigure the CS lines as required without repeating the reset.

    The above fix seems to be correct .

    Regards,

    Anil.

  • Yes, I understand that sysconfig does not support it.  And understand that the end user needs to initialize the segments.  I only brought it up because if someone wanted to do more than one region, it requires them to edit the actual gmpc0 device driver.  While if TI fixes it, (i.e only reset the device the first time), it works for everyone.  

    This was just more of FYI, and possible enhancement to the GPMC Driver.

    Robert