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.

PROCESSOR-SDK-AM65X: CPSW PLL HSDIV2 frequency with processor SDK RTOS 07.01

Part Number: PROCESSOR-SDK-AM65X

Dear TI team,

while moving from SDK 07.00 to SDK 07.01 we noticed that our SYS/BIOS sleep calls (via Task_sleep) on an A53 core slept longer than before.

With SDK 07.00 sleeping for 10,000 ticks would sleep for 10 seconds, now it is sleeping for 12.5 seconds.

The GTC which serves as the time base for the A53 timer is clocked from CPSWHSDIV_CLKOUT2. Looking at MCU_PLL0_HSDIV_CLKDIV  I noticed that the HSDIV2 output is now configured to divide /10 (0x9), whereas with SDK 07.00 that output was configured to divide /8 (0x7). This is was explicitly changed some time ago (https://git.ti.com/cgit/keystone-rtos/board/commit/src/am65xx_idk/am65xx_idk_pll.c?id=52f145f3ada21e9332e36937b5278671587426ec). Now the divider seems to be back at /10.

By default the SYS/BIOS code seems to assume 200 MHz for the A53 timer. At some point we changed that to 250 MHz by setting v8aTimer.intFreq.lo = 250000000 in the xdc config file, so basically our previous workaround causes the timing to be off now.

The change was probably introduced by commit 01a010b197879a071bd484947dcae8e9afe97ed5 (PRSDK-8607: Board: Removed CSL based PLL config functions in AM65x Board library) that changed the code in packages/ti/board/src/evmKeystone3/board_pll.c to use the Sciclient to configure the clocks, instead of directly writing to the PLL registers. I checked the new code, and there is one CPSW clock that is getting configured for 250 MHz, but I suspect that this is a different PLL output.

Is it intentional that the CPSW HSDIV2 output got switched back to 200 MHz?

What was the reason for having the 250 MHz starting with commit 52f145...?

Should we explicitly configure the GTC to 200 (or 250?) MHz or are there some guarantees that it will always come up with a known frequency? Should we configure CPSW_HSDIV2 explicitly as the clock parent, and then configure the frequency?


Regards,

Dominic

  • Hi Dominic,

    Sorry for the delay, I will check with the Ethernet experts and get back to you.

    Regards

    Vineet

  • Hi Dominic,

    I still see the value of 8 (0x7) in PLL settings in 7.1 SDK. Where do you see 10 (0x9) ?

    I am looking at pdk/packages/ti/board/src/am65xx_idk/am65xx_idk_pll.c

    I am checking with the SW module owners on the possibility that Sciclient changes can override this setting but a clock frequency of 250Mhz is required so that CPTS time synchronization can work. You should always configure it as 250Mhz.

    You may configure CPSW_HSDIV2 explicitly as the clock parent so this setting is always tracked.

    Regards

    Vineet

  • Hello Vineet,

    the code in am65xx_idk_pll.c isn't used anymore since commit 01a010b197879a071bd484947dcae8e9afe97ed5. See also this thread: https://e2e.ti.com/support/processors/f/791/p/900527/3586822

    We've checked the actual PLL configuration registers AND the effect of the clock, i.e. we really saw 12.5 instead of 10 seconds with a stop watch.

    To answer my questions:

    • Right now I'm guessing that it was not intentional that the CPSW PLL HSDIV2 output is now running at 200 MHz.
    • I have no idea what code (example, test, ..) relies on the 250 MHz for the CPTS, but at least the 52f145... commit says it is due to CPTS.
    • I'm not sure where and how the GTC should be configured. As far as I understand SYS/BIOS relies on the GTC running at 200 MHz, but the configuration works rather out of coincidence right now, and should have been wrong before when the GTC was running at 250 MHz.

    Regards,

    Dominic

  • Hi Dominic,

    I checked internally and here are a few points

    1. pdk/packages/ti/board/src/am65xx_idk/am65xx_idk_pll.c is not used any more. All clocks are set by: pdk\packages\ti\board\src\evmKeystone3\board_pll.c

    2. The GTC can take the clock from multiple sources. See below

    The image is taken from here

    3. Option 0 – Gives 200 MHz which is default. Option 1 – Gives 250 MHz which is what you need for CPTS and to have backward compatibility with previous changes.

    4. To configure the GTC, use this API call

    status = Sciclient_pmSetModuleClkParent(

                   TISCI_DEV_GTC0,

                   TISCI_DEV_GTC0_BUS_VBUSP_CLK,

                   TISCI_DEV_GTC0_BUS_VBUSP_CLK_PARENT_ADPLLLJM_HSDIV_WRAP_MAIN_0_BUS_HSDIV_CLKOUT3_CLK,

                  SCICLIENT_SERVICE_WAIT_FOREVER);

    5. See the attached general FAQ on this. (It will be part of ti.com documentation from next release cycle)

    FAQ - How to set the clock for a given module and clock
    =======================================================
    
    Introduction
    ------------
    
    Setting the clock frequency for a module can be a confusing activity especially
    if you do not know where to get started. This FAQ is written to address concerns
    you may have to know which clock for which module is running at what frequency
    and how to go about setting the clock frequency to the one you desire.
    
    Before we dive right in make sure you keep the following documents handy for
    you to navigate through the clocking infrastructure of the device you are
    working with.
    
    - **System Firmware Documentation**: This is definitely something you should
      bookmark and keep in your browser if not already done.
      https://software-dl.ti.com/tisci/esd/latest/index.html
      Messages which are used to set the clock frequency for various modules:
    
    +-------------------------------------+---------------------------------+-------------------------------------------------------------------------------------------------------------+
    | Sciclient API to use                | TISCI Message                   | TISCI Message Documentation Link                                                                            |
    +=====================================+=================================+=============================================================================================================+
    | Sciclient_pmSetModuleClkParent      | TISCI_MSG_SET_CLOCK_PARENT      | https://software-dl.ti.com/tisci/esd/latest/2_tisci_msgs/pm/clocks.html#pm-clocks-msg-set-clock-parent      |
    +-------------------------------------+---------------------------------+-------------------------------------------------------------------------------------------------------------+
    | Sciclient_pmGetModuleClkParent      | TISCI_MSG_GET_CLOCK_PARENT      | https://software-dl.ti.com/tisci/esd/latest/2_tisci_msgs/pm/clocks.html#pm-clocks-msg-get-clock-parent      |
    +-------------------------------------+---------------------------------+-------------------------------------------------------------------------------------------------------------+
    | Sciclient_pmGetModuleClkNumParent   | TISCI_MSG_GET_NUM_CLOCK_PARENTS | https://software-dl.ti.com/tisci/esd/latest/2_tisci_msgs/pm/clocks.html#pm-clocks-msg-get-num-clock-parents |
    +-------------------------------------+---------------------------------+-------------------------------------------------------------------------------------------------------------+
    | Sciclient_pmSetModuleClkFreq        | TISCI_MSG_SET_FREQ              | https://software-dl.ti.com/tisci/esd/latest/2_tisci_msgs/pm/clocks.html#pm-clocks-msg-set-freq              |
    +-------------------------------------+---------------------------------+-------------------------------------------------------------------------------------------------------------+
    | Sciclient_pmSetModuleClkFreqRange   | TISCI_MSG_SET_FREQ              | https://software-dl.ti.com/tisci/esd/latest/2_tisci_msgs/pm/clocks.html#pm-clocks-msg-set-freq              |
    +-------------------------------------+---------------------------------+-------------------------------------------------------------------------------------------------------------+
    | Sciclient_pmQueryModuleClkFreq      | TISCI_MSG_QUERY_FREQ            | https://software-dl.ti.com/tisci/esd/latest/2_tisci_msgs/pm/clocks.html#pm-clocks-msg-query-freq            |
    +-------------------------------------+---------------------------------+-------------------------------------------------------------------------------------------------------------+
    | Sciclient_pmQueryModuleClkFreqRange | TISCI_MSG_QUERY_FREQ            | https://software-dl.ti.com/tisci/esd/latest/2_tisci_msgs/pm/clocks.html#pm-clocks-msg-query-freq            |
    +-------------------------------------+---------------------------------+-------------------------------------------------------------------------------------------------------------+
    | Sciclient_pmGetModuleClkFreq        | TISCI_MSG_GET_FREQ              | https://software-dl.ti.com/tisci/esd/latest/2_tisci_msgs/pm/clocks.html#pm-clocks-msg-get-freq              |
    +-------------------------------------+---------------------------------+-------------------------------------------------------------------------------------------------------------+
    
    - **Device Clocking tool**: This is a tool which helps understand the clocking
      of the different modules and their sources: https://www.ti.com/tool/CLOCKTREETOOL
    
    - **Device TRM**: This document should be referred to for the different clock 
      options for the different modules. Keep in mind the following chapters when
      trying to understand the clocking of the device:
    
    +-------------+----------------------------------------------------------+
    | TRM Chapter | What should you refer in this                            |
    +=============+==========================================================+
    | Clocking    | The "Clocking" Chapter under                             |
    |             | "Device Configuration" is your guide                     |
    |             | to the different clock sources available in the          |
    |             | system. It gives details of the high level device        |
    |             | clocking and the PLLs in the device.                     |
    +-------------+----------------------------------------------------------+
    | Integration | In every module chapter you would find a section         |
    |             | called "Integration". Use this section of the TRM        |
    |             | to see which clocks go to a particular module.           |
    |             | For every module in the SoC, there could be one or more  |
    |             | clocks supplies. There could be different options for    |
    |             | the clocking as well. When multiple options are present  |
    |             | there would be multiplexer or mux which sits in front of |
    |             | this clock. The mux options are highlighted in this      |
    |             | chapter as well.                                         |
    +-------------+----------------------------------------------------------+
    
    Default clock state of the system
    ---------------------------------
    
    There are some default clocks which are set during the device boot by the
    bootloader. This includes the clocks set by the Device Manager part of the
    System firmware and the Board library. Typically the sequence is:
    
    -   Device manager will set the PLLs to a default value. Note the device manager
        does not set any multiplexers during initialization. Hence all clock options
        will be set to their hardware default.
        In order to know what is the device PLL defaults the Device manager is
        setting please refer to:
    
        *  **AM65x SR1.0**: https://software-dl.ti.com/tisci/esd/latest/5_soc_doc/am6x/pll_data.html
    
        *  **AM65x SR2.0**: https://software-dl.ti.com/tisci/esd/latest/5_soc_doc/am65x_sr2/pll_data.html
    
        *  **J721e** (Both SR1.0 and SR1.1): https://software-dl.ti.com/tisci/esd/latest/5_soc_doc/j721e/pll_data.html
    
        *  **J7200** : https://software-dl.ti.com/tisci/esd/latest/5_soc_doc/j7200/pll_data.html
    
        *  **For any future devices**: Just go to https://software-dl.ti.com/tisci/esd/latest/5_soc_doc/index.html and search for PLL defaults.
        
        The device manager looks the value of the CTRLMMR_WKUP_DEVSTAT to determine
        the oscillator connected to the device and then it will set up the PLLs based
        on the different tables given in the pages above.
        The device manager will set up the PLLs when the TISCI_MSG_BOARD_CONFIG_PM 
        message as part of the Boot loader is sent. For more details on what happens
        when TISCI_MSG_BOARD_CONFIG_PM is sent refer:  https://software-dl.ti.com/tisci/esd/latest/3_boardcfg/BOARDCFG_PM.html#power-management-initialization-after-receiving-board-configuration
    
     
    -   Board Library: will then use the Device Manager configuration and then also
        program the clocks for modules which require some multiplexer configurations
        or clocking which is different than the default.
    
        Refer the following files to see what does the board library set:
    
        * **AM65x**: pdk/packages/ti/board/src/evmKeystone3/board_pll.c
    
        * **J721e**: pdk/packages/ti/board/src/j721e_evm/board_pll.c
    
        * **J7200**: pdk/packages/ti/board/src/j7200_evm/board_pll.c
    
        In particular look at the function: Board_PLLInitAll or Board_PLLInitMcu or 
        Board_PLLInitMain to see what clocks and what modules are set.
    
    Setting the clock for a device
    ------------------------------
    
    In order to set the clock for a device the first step is to identify the device
    ID which you want to set the clock for. There are 2 ways you can do this:
    
    -   **OPTION 1**: Look at the source code:
        Here you can refer to the following files to see what is the device ID to use:
    
        * **AM65x SR1.0**: pdk/packages/ti/drv/sciclient/soc/sysfw/include/am65x/tisci_devices.h
    
        * **AM65x SR2.0**: pdk/packages/ti/drv/sciclient/soc/sysfw/include/am65x_sr2/tisci_devices.h
    
        * **J721e**: pdk/packages/ti/drv/sciclient/soc/sysfw/include/j721e/tisci_devices.h
    
        * **J7200**: pdk/packages/ti/drv/sciclient/soc/sysfw/include/j7200/tisci_devices.h
    
        In these files search for the device you would like to set the clock for.
        The advantage with this method is you would find the exact macro to be used
        with Sciclient APIs.
    
    -   **OPTION 2**: Look at the TISCI documentation.
        Here you can refer to the following files to see what is the device ID to use:
    
        * **AM65x SR1.0**: https://software-dl.ti.com/tisci/esd/latest/5_soc_doc/am6x/devices.html
    
        * **AM65x SR2.0**: https://software-dl.ti.com/tisci/esd/latest/5_soc_doc/am65x_sr2/devices.html
    
        * **J721e**: https://software-dl.ti.com/tisci/esd/latest/5_soc_doc/j721e/devices.html
    
        * **J7200**: https://software-dl.ti.com/tisci/esd/latest/5_soc_doc/j7200/devices.html
    
        In these files search for the device you would like to set the clock for.
        Once you find the device, in order to use this with the Sciclient APIs you
        would need to either use the exact number for the module ID or convert the name
        to a macro by doing the following substituion:
    
        * **AM65x SR1.0**: Replace AM6 with TISCI
    
        * **AM65x SR2.0**: Replace AM6 with TISCI
    
        * **J721e**: Replace J721E with TISCI
    
        * **J7200**: Replace J7200 with TISCI
    
    Once you identify the device the next step is to identify the clock for that
    particular device you would like to set the frequency for. There are again 2
    ways you can do this:
    
    
    - **OPTION 1**: Look at the source code:
      Here you can refer to the following files to see what is the device ID to use:
    
      * **AM65x SR1.0**: pdk/packages/ti/drv/sciclient/soc/sysfw/include/am65x/tisci_clocks.h
    
      * **AM65x SR2.0**: pdk/packages/ti/drv/sciclient/soc/sysfw/include/am65x_sr2/tisci_clocks.h
    
      * **J721e**: pdk/packages/ti/drv/sciclient/soc/sysfw/include/j721e/tisci_clocks.h
    
      * **J7200**: pdk/packages/ti/drv/sciclient/soc/sysfw/include/j7200/tisci_clocks.h
    
      In these files search for the device you would like to set the clock for.
      The advantage with this method is you would find the exact macro to be used
      with Sciclient APIs.
    
    - **OPTION 2**: Look at the TISCI documentation.
      Here you can refer to the following files to see what is the device ID to use:
    
      * **AM65x SR1.0**: https://software-dl.ti.com/tisci/esd/latest/5_soc_doc/am6x/clocks.html
    
      * **AM65x SR2.0**: https://software-dl.ti.com/tisci/esd/latest/5_soc_doc/am65x_sr2/clocks.html
    
      * **J721e**: https://software-dl.ti.com/tisci/esd/latest/5_soc_doc/j721e/clocks.html
    
      * **J7200**: https://software-dl.ti.com/tisci/esd/latest/5_soc_doc/j7200/clocks.html
    
      In these files search for the device you would like to set the clock for.
      Once you find the device, in order to use this with the Sciclient APIs you
      would need to either use the exact number for the module ID or convert the name
      to a macro by doing the following substitution:
    
      * **AM65x SR1.0**: Replace AM6 with TISCI
    
      * **AM65x SR2.0**: Replace AM6 with TISCI
    
      * **J721e**: Replace J721E with TISCI
    
      * **J7200**: Replace J7200 with TISCI
    
    .. Note::
    
        Clocks with the name _PARENT_ are special. They are clocks which are not
        directly fed to the module but feed into a multiplexer and then based
        on the value of the multiplexer will reach the module. When using the
        Sciclient_pmSetModuleClkFreq or Sciclient_pmQueryModuleClkFreq or
        Sciclient_pmGetModuleClkFreq do not use these clock IDs. Only use this
        for Sciclient_pmSetModuleClkParent or Sciclient_pmGetModuleClkParent APIs.
    
    Now that you know the module ID and clock ID, the next step is to look at the
    TRM or the Clock tree tool to see if this clock has a multiplexer sitting before
    this. If yes, you need to make a choice of where this clock is going to be sourced from.
    
    For example,
    The GTC module in AM65xx can take the clock from multiple sources:
    Option 0 – Gives 200 MHz which is default.
    Option 1 – Gives 250 MHz. 
    To set the clock to 250 MHz use the below API:
    
    .. code::
    
        status = Sciclient_pmSetModuleClkParent(
                                        TISCI_DEV_GTC0,
                                        TISCI_DEV_GTC0_BUS_VBUSP_CLK,
                                        TISCI_DEV_GTC0_BUS_VBUSP_CLK_PARENT_ADPLLLJM_HSDIV_WRAP_MAIN_0_BUS_HSDIV_CLKOUT3_CLK,
                                        SCICLIENT_SERVICE_WAIT_FOREVER);
    
    Let's say now you have selected the parent for the clock input to the module
    the next step is to then see if the default PLL configuration given by Device
    Manager or Board Initilization is sufficient. If yes, you are done and can skip
    the rest of this FAQ. 
    
    You can double confirm if the clock is set correctly by using:
    
    .. code::
    
        status = Sciclient_pmGetModuleClkFreq(
                                        TISCI_DEV_GTC0,
                                        TISCI_DEV_GTC0_BUS_VBUSP_CLK,
                                        &currentFreq,
                                        SCICLIENT_SERVICE_WAIT_FOREVER);
    
    The API will return the current frequency in Hertz in the variable currentFreq.
    
    If the clock is not the frequency you would like to set even after setting the
    multiplexer or the clock does not have a multiplexer and the default is not what
    suits your usecase, then follow the next steps to set the clock.
    
    **STEP 1**: Check if the clock frequency you are trying to set is possible or not.
    In this step we simply check if the PLLs and other modules which source their
    clocks from the same HSDIV or PLL allow you to set the frequency for this
    particular module clock to the desired clock. If possible, the API returns
    with CSL_PASS. If not the API will return with a CSL_EFAIL. The advantage of 
    doing this is to make sure the registers are not programmed if the clock setup
    is not possible.
    
    Example:
    Let's say you are trying to set the exact frequency of 250 MHz to GTC device,
    you would use the Query api as below to check if this is possible or not. 
    
    .. code::
    
        status = Sciclient_pmQueryModuleClkFreq (
                                        TISCI_DEV_GTC0,
                                        TISCI_DEV_GTC0_BUS_VBUSP_CLK,
                                        250000000,
                                        &respFreq,
                                        SCICLIENT_SERVICE_WAIT_FOREVER);
    
    .. Note::
    
        If you can tolerate a variance to the frequency then you can use the api
        Sciclient_pmQueryModuleClkFreqRange to set the min and max values of frequency
        you can tolerate and then the respFreqHz returned will contain the value
        of the frequency that the Sciclient_pmSetModuleClkFreq can set within this
        range. If the API returns fail then respFreqHz will be 0 Hz.
    
    **STEP 2**: If you find that setting the frequency is possible, go ahead and use
    Sciclient_pmSetModuleClkFreq to set the frequency of the clock.
    
    Example: If the query frequency has passed then set the clock as below for the 
    GTC clock.
    
    .. code::
    
        status = Sciclient_pmSetModuleClkFreq (
                                        TISCI_DEV_GTC0,
                                        TISCI_DEV_GTC0_BUS_VBUSP_CLK,
                                        250000000,
                                        TISCI_MSG_FLAG_CLOCK_ALLOW_FREQ_CHANGE,
                                        SCICLIENT_SERVICE_WAIT_FOREVER);
    
    You can double confirm if the clock is set correctly by using:
    
    .. code::
    
        status = Sciclient_pmGetModuleClkFreq(
                                        TISCI_DEV_GTC0,
                                        TISCI_DEV_GTC0_BUS_VBUSP_CLK,
                                        &currentFreq,
                                        SCICLIENT_SERVICE_WAIT_FOREVER);
    
    The API will return the current frequency in Hertz in the variable currentFreq.
    

    Regards

    Vineet