Functions for Clock Driver.
More...
Functions for Clock Driver.
◆ clk_init_tree()
Initializes the clock tree with the specified PLL configuration.
- Parameters
-
| pll_config | PLL configuration to apply. Valid values:
|
- Returns
- CLK_OK if successful, otherwise CLK_ERROR_PARAMETER.
◆ clk_enable()
Enables the specified clock.
- Parameters
-
| clk_id | Clock ID to enable. |
- Returns
- CLK_OK if the clock was enabled successfully, otherwise error code.
◆ clk_disable()
Disables the specified clock.
- Note
- If any downstream clocks are enabled, this function will not disable the clock. Disable downstream clocks first or use clk_force_disable().
- Parameters
-
| clk_id | Clock ID to disable. |
- Returns
- CLK_OK if the clock was disabled successfully, otherwise error code.
◆ clk_force_disable()
Forcibly disables the specified clock regardless of downstream dependencies.
- Parameters
-
| clk_id | Clock ID to forcibly disable. |
- Returns
- CLK_OK if the clock was forcibly disabled, otherwise error code.
◆ clk_is_enabled()
Checks whether the specified clock is currently enabled.
- Parameters
-
| clk_id | Clock ID to check. |
| out_status | Pointer to store the clock enable status. Returns:
|
- Returns
- CLK_OK if the status was retrieved successfully, otherwise error code.
◆ clk_get_rate()
Retrieves the current operating frequency of the specified clock.
- Parameters
-
| clk_id | Clock ID. |
| rate | Pointer to store the current rate in Hz. |
- Returns
- CLK_OK if the rate was retrieved successfully, otherwise error code.
◆ clk_set_rate()
Sets the frequency of the specified clock. The behavior depends on the clock type:
- If clk_id is CPU_CLK, valid rates are:
- If clk_id is SYSPLL0_CLKOUT or SYSPLL1_CLKOUT, valid configurations are:
- For other clocks, the closest supported frequency not exceeding the requested rate will be set based on divider configuration computed internally.
- Parameters
-
| clk_id | Clock ID to configure. |
| requested_rate | Desired frequency in Hz. |
| actual_rate | Pointer to store the actual configured rate in Hz. |
- Returns
- CLK_OK if the rate was set successfully, otherwise error code.
◆ clk_get_divider()
Retrieves the current divider value for the specified clock.
- Parameters
-
| clk_id | Clock ID. |
| divider | Pointer to store the current divider value. |
- Returns
- CLK_OK if the divider was retrieved successfully, otherwise error code.
◆ clk_set_pll_config()
Configures the specified PLL with a predefined frequency setup. This involves writing appropriate values to the PLL's reference divider, feedback divider, fractional divider, and post-dividers to achieve the target frequency. Special configurations like bypass and power-down modes are also supported.
- Parameters
-
| pll | Clock PLL to configure. Valid values:
|
| pll_config | PLL configuration to apply. Valid values:
|
- Returns
- CLK_OK if the configuration was applied successfully, otherwise error code.
◆ clk_get_pll_config()
Retrieves the current configuration of the specified PLL. This is done by reading the PLL's hardware divider settings - reference divider, feedback divider, fractional divider, and post-dividers and matching them against known PLL configuration presets. The function also detects if the PLL is operating in bypass mode or is powered down.
- Parameters
-
| pll | Clock PLL to query. |
| pll_config | Pointer to store the current PLL configuration. |
- Returns
- CLK_OK if the configuration was retrieved successfully, otherwise error code.
◆ clk_set_mux()
Sets the mux output configuration for the specified clock. This function configures the clock source selection (mux) for a given clock ID. It applies to clocks that support mux switching, such as PLL muxes or CGL clock muxes.
- Parameters
-
| clk_id | Clock ID for which the mux configuration is to be set. |
| mux_out | Desired mux output configuration. Valid values:
|
- Returns
- CLK_OK if the mux was set successfully, CLK_ERROR_PARAMETER if invalid parameters are passed, CLK_ERROR_INVALID_MUX if the clock does not support mux selection.