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.

RTOS/AM5728: How to change QSPI-Flash CLK with PROCESSOR-SDK-RTOS-AM57X

Guru 10235 points
Part Number: AM5728

Tool/software: TI-RTOS

Hello, TI Experts,

 

Our customer sent us questions about QSPI-Flash CLK with TMDXIDK5728.

They want to know how to change the QSPI-Flash CLK(SPIMEM_CLK in TMDXIDK5728 schematics).

We found related link like below;

http://processors.wiki.ti.com/index.php/Processor_SDK_RTOS_BOOT_AM57x#SBL_Customization

 

1: We tried to modify "spiParams.bitRate".

   But QSPI-Flash CLK on the TMDXIDK5728 seems not to be changed.

2: We found QSPI_HwAttrs parameter in C:\ti\pdk_am57xx_1_0_13\packages\ti\drv\spi\soc\QSPI_v1.h.

   But we cannot find how to modify ”funcClk” in QSPI_v1.h.

 

Question:

Could you tell us recommended way of changing QSPI-Flash CLK with PROCESSOR-SDK-RTOS-AM57X?

   - Which file should be modified?

   - Which line of the file should be modified?

 

Best regards,

  • Hello,
    you can try to modify SPI_MODULE_CLOCK_DIVIDER and check if change in SPI clock frequency will occur.
    It is defined in file .../packages/ti/drv/spi/soc/SPI_soc.h

    BR
    Michail
  • Hi,

    Thank you very much for your kindness.
    I really appreciate your help.

    We checked "SPI_MODULE_CLOCK_DIVIDER" usage in pdk.
    But we cannot find the usage of "SPI_MODULE_CLOCK_DIVIDER" for QSPI function setting in pdk.

    And our customer sent us the feedback like below;
    They found the QSPI Clock related register(QSPI_SPI_CLOCK_CNTRL_REG) setting in ti\drv\spi\src\v1\QPI_v1.c .
    - QSPISetPreScaler(hwAttrs->baseAddr, 0x0U);

    Then we modified the code like below & rebuild sbl.
    - QSPISetPreScaler(hwAttrs->baseAddr, 0x1U);

    The QSPI-Flash CLK(SPIMEM_CLK) seems to be changed from 48MHz to 24MHz.

    So we understand like below;
    - "SPI_MODULE_CLOCK_DIVIDER" is defined.
    - But for QSPI, QSPI_SPI_CLOCK_CNTRL_REG is configured by "real value:0x0" in pdk.

      ("SPI_MODULE_CLOCK_DIVIDER" definition seems not to be used for the register setting.)

    If there are missing or notice, please tell us.

    Best regards,

  • Matusan,

    What is your customer trying to do with the QSPI clock ? 48 Mhz is the maximum QSPI clock setup supported on this device and as you determined changing the prescalar allows you to scale the clock down.

    Let me try and explain the clock setup for QSPI on this device. The QSPI module is clocked using PER DPLL  as per the clock spec here

    The QSPI GFCLK to the QSPI module is set to 48 MHz. This configuration is done using CM_L4PER2_QSPI_CLKCTRL_REG register. Since all of the SOC level clock configuration is done in the board library, please refer to the file idkAM574x_clock.c and check the following lines of code:

        CSL_FINST(l4PerCmReg->CM_L4PER2_QSPI_CLKCTRL_REG,
            L4PER_CM_CORE_COMPONENT_CM_L4PER2_QSPI_CLKCTRL_REG_MODULEMODE, ENABLED);
    
        while(CSL_L4PER_CM_CORE_COMPONENT_CM_L4PER2_QSPI_CLKCTRL_REG_IDLEST_FUNC !=
           CSL_FEXT(l4PerCmReg->CM_L4PER2_QSPI_CLKCTRL_REG,
            L4PER_CM_CORE_COMPONENT_CM_L4PER2_QSPI_CLKCTRL_REG_IDLEST));
    
        CSL_FINST(l4PerCmReg->CM_L4PER2_QSPI_CLKCTRL_REG,
            L4PER_CM_CORE_COMPONENT_CM_L4PER2_QSPI_CLKCTRL_REG_CLKSEL_DIV, DIV4);
    
        CSL_FINST(l4PerCmReg->CM_L4PER2_QSPI_CLKCTRL_REG,
            L4PER_CM_CORE_COMPONENT_CM_L4PER2_QSPI_CLKCTRL_REG_CLKSEL_SOURCE, SEL_PER_QSPI_CLK);

    The following setting uses the 192 Mhz clock derived from PER DPLL and divides it by 4 to feed 48 Mhz clock to QSPI module. This is the default setup in both the GEL and the board library clock settings. This clocking configuration is then informed to the driver using the QSPI_HWAttr in SPI_soc.c file  found under 

    pdk_am57xx_1_0_13\packages\ti\drv\spi\soc\am574x

    The Prescalar that you see in the QSPI driver is in the module internal divider that allows you to derive clocks base on the input clock connect to the module. That is why when you set the prescalar to 1 (divide by (prescalar+1)) , you saw QSPI clock of 24Mhz.

    In Summary the follow settings are used to setup the QSPI clock

    1. Set PER DPLL and QSPI GFCLK in board library

    2. Set the value in QSPI_HWAttr for driver to use

    3. Modify Prescalar in driver if required.

     

    Hope this helps.

    Regards,

    Rahul

    PS: A good way to understand clocks on this device is the CLock tree tool that we provide on ti.com 

    http://www.ti.com/tool/CLOCKTREETOOL 

  • Hi,

     

    Thank you very much for your detail explanation.

    I really appreciate your help.

     

    We understand like below;

    - For TMDXIDK5728, QSPI_GFCLK is configured to 48MHz by idkAM572x_clock.c and SPI_soc.c.

    - We can configure QSPI-Flash CLK(SPIMEM_CLK in TMDXIDK5728 schematics) to 24MHz by modifying the related code in ti\drv\spi\src\v1\QPI_v1.c.

           QSPISetPreScaler(hwAttrs->baseAddr, 0x1U);

     

    Best regards,

  • Matusan,

    Your understanding is correct. Ideally the driver Params should be used to setup the prescaler value but the driver seems to be written with the intent of configuring the QSPI at the highest output clock of 48 MHz.

    Can you please indicate why you need to run the clock at speed different than 48 MHz. Are you working with a NOR flash that doesn`t support these speeds?

    Regards,
    Rahul

    PS: note that the max value of QSPI GFCLK is 192 MHz, which you can change in GEL file or idkAM572x_clock.c and change the value in SPI_soc.c if you need higher GFCLK
  • Hi,

    Thank you very much for your kindness.
    I really appreciate your help.

    They sent us the feedback about your question like below;
    - They tried to design custom board based on TMDXIDK5728.
    - But they found not to run their program with QSPI-boot on their custom board.
    - So they tried to set lower frequency to QSPI clock as a trail by modifying below part in QPI_v1.c.
    QSPISetPreScaler(hwAttrs->baseAddr, 0x0U);

    Best regards,