|
SemiDrive SSDK Appication Program Interface PTG3.0
|
#include <sdrv_common.h>#include <lib/list.h>#include <types.h>#include <part.h>#include <sdrv_rtc.h>Go to the source code of this file.
Data Structures | |
| struct | sdrv_ckgen_node |
| struct | sdrv_ckgen_slice_node |
| struct | sdrv_ckgen_cg_node |
| struct | sdrv_pll_node |
| struct | sdrv_ckgen_rate_config_node |
| struct | sdrv_ckgen_rate_config |
| struct | sdrv_ckgen_bus_config_node |
| struct | sdrv_ckgen_bus_config |
| struct | sdrv_ckgen_gating_config_node |
| struct | sdrv_ckgen_gating_config |
| struct | sdrv_ckgen_ip_clock_config_node |
| struct | sdrv_ckgen_ip_clock_config |
| struct | sdrv_ckgen_config |
| struct | sdrv_clk |
| struct | sdrv_clk_config |
| struct | sdrv_ckgen_xcg_set |
| #define CLK_MHZ | ( | x | ) | ((x) * 1000 * 1000) |
| #define CLK_NODE | ( | node | ) | (sdrv_ckgen_node_t *)&(node.clk_node) |
| #define CONFIG_CKGEN_PARENTS_NUM 5 |
| #define RTC_SS_ACCESS_END | ( | ) |
| #define RTC_SS_ACCESS_START | ( | ) |
| typedef struct sdrv_ckgen_bus_config_node sdrv_ckgen_bus_config_node_t |
Clock rate config for Bus node.
| typedef struct sdrv_ckgen_bus_config sdrv_ckgen_bus_config_t |
Clock rate config lists for Bus node.
| typedef enum sdrv_ckgen_bus_out_type sdrv_ckgen_bus_out_type_e |
Config bus slice node output type. For SF/SP BUS, clk_out_m for core, clk_out_n for AXI, clk_out_p for APB For AP domain bus, clk_out_m not used, clk_out_n for AXI, clk_out_p for APB.
| typedef enum sdrv_ckgen_bus_post_div sdrv_ckgen_bus_post_div_e |
Bus slice post divide ratio.
| typedef struct sdrv_ckgen_cg_node sdrv_ckgen_cg_node_t |
Abstract xcg node for driver operate.
| typedef struct sdrv_ckgen_config sdrv_ckgen_config_t |
Initialize clock config for system setup.
| typedef struct sdrv_ckgen_gating_config_node sdrv_ckgen_gating_config_node_t |
Gate config for xcg node.
| typedef struct sdrv_ckgen_gating_config sdrv_ckgen_gating_config_t |
Gate config list for XCG node.
| typedef struct sdrv_ckgen_ip_clock_config_node sdrv_ckgen_ip_clock_config_node_t |
IP clock enable/disable config node.
| typedef struct sdrv_ckgen_ip_clock_config sdrv_ckgen_ip_clock_config_t |
IP clock enable or disable config.
| typedef enum sdrv_ckgen_lp_mode sdrv_ckgen_lp_mode_e |
Low power mode for clock config.
| typedef struct sdrv_ckgen_node sdrv_ckgen_node_t |
Abstract clock common node for driver operate.
| typedef struct sdrv_ckgen_rate_config_node sdrv_ckgen_rate_config_node_t |
Clock rate config for IP/Core/PLL node.
| typedef struct sdrv_ckgen_rate_config sdrv_ckgen_rate_config_t |
Clock rate config lists for IP/Core/PLL node.
| typedef struct sdrv_ckgen_slice_node sdrv_ckgen_slice_node_t |
Abstract clock slice node for driver operate.
| typedef enum sdrv_ckgen_ssc_amplitude sdrv_ckgen_ssc_amplitude_e |
PLL Spread amplitude.
| typedef enum sdrv_ckgen_ssc_freq sdrv_ckgen_ssc_freq_e |
PLL Spread Modulation frequency.
| typedef enum sdrv_ckgen_ssc_mode sdrv_ckgen_ssc_mode_e |
PLL Spread mode.
| typedef enum sdrv_ckgen_type sdrv_ckgen_type_e |
Clock node type.
| typedef struct sdrv_ckgen_xcg_set sdrv_ckgen_xcg_set_t |
CKGEN XCG List.
| typedef struct sdrv_clk_config sdrv_clk_config_t |
System default total clock node list.
| typedef struct sdrv_clk sdrv_clk_t |
Definition for clock tree node.
| typedef enum sdrv_fs_src_type sdrv_fs_src_type_e |
Function Safe clock source.
| typedef struct sdrv_pll_node sdrv_pll_node_t |
Abstract pll node for driver operate.
Config bus slice node output type. For SF/SP BUS, clk_out_m for core, clk_out_n for AXI, clk_out_p for APB For AP domain bus, clk_out_m not used, clk_out_n for AXI, clk_out_p for APB.
| enum sdrv_ckgen_error |
CKGEN status error code.
| enum sdrv_ckgen_lp_mode |
PLL Spread amplitude.
| enum sdrv_ckgen_ssc_freq |
| enum sdrv_ckgen_ssc_mode |
| enum sdrv_ckgen_type |
Clock node type.
| enum sdrv_fs_src_type |
| uint32_t sdrv_ckgen_bus_get_rate | ( | sdrv_ckgen_node_t * | ckgen, |
| sdrv_ckgen_bus_out_type_e | clk_out | ||
| ) |
Get clock rate for Bus slice node.
This function can get Bus slice clock rate, it can get clk_in4 clock directly without divide, or Clk_out_m/Clk_out_n/Clk_out_p/Clk_out_q divided by m/n/p/q.
| [in] | ckgen | ckgen node type can be CKGEN_SF_BUS_SLICE_TYPE or CKGEN_BUS_SLICE_TYPE. |
| [in] | clk_out | Clk_out/Clk_out_m/Clk_out_n/Clk_out_p/Clk_out_q. |
| status_t sdrv_ckgen_bus_set_rate | ( | sdrv_ckgen_node_t * | ckgen, |
| uint32_t | rate, | ||
| sdrv_ckgen_bus_post_div_e | div | ||
| ) |
Config clock rate for Bus slice node.
This function configure expected clock rate for specific ckgen BUS slice node, since bus slice can output clock direct, or clock divide by m/n/p/q, and their ratio only has two option, one is 4:2:1, other is 2:2:1. Clk_out_m is for core clock rate, Clk_out_n is for AXI bus clock rate, Clk_out_p is for APB bus clock rate.
| [in] | ckgen | ckgen node type can be CKGEN_SF_BUS_SLICE_TYPE or CKGEN_BUS_SLICE_TYPE. |
| [in] | rate | clock rate to be set for Clk_out_m. |
| [in] | div | m/n/p,q ratio select. |
| status_t sdrv_ckgen_cg_mask | ( | sdrv_ckgen_node_t * | ckgen, |
| bool | mask | ||
| ) |
Set CG NODE whether participate in low power handshake.
This function config CG Node lowpower mask bit. If set to mask, cg status is ignored under low power handshake. Otherwize, cg status is considerd into low power handshake.
| [in] | ckgen | ckgen node type can be CG NODE. |
| [in] | mask | true or false. |
| status_t sdrv_ckgen_clock_config | ( | sdrv_ckgen_node_t * | ckgen, |
| bool | enable | ||
| ) |
Config clock enable or disable in run mode.
This function configure clock gating status in run mode.
| [in] | ckgen | ckgen node type can be CG NODE. |
| [in] | enable | clock enable or disable. |
| uint32_t sdrv_ckgen_get_fs32k_real_frequency | ( | sdrv_ckgen_node_t * | ckgen | ) |
Get FS32K real output clock frequency.
This function use FS24M to check FS32K clock frequency. So you must make sure FS24M is accurate. If you want check RC32K frequency, first change FS32K source to RC, then call this function. If you want check XTAL32K frequency, first change FS32K source to XTAL, then call this function.
| [in] | ckgen | ckgen node type must be CKGEN_FS24M_TYPE. |
| uint32_t sdrv_ckgen_get_rate | ( | sdrv_ckgen_node_t * | ckgen | ) |
Get clock rate for Core/IP slice node.
This function get clock rate for CORE or IP slice node.
| [in] | ckgen | ckgen node type can be CKGEN_IP_SLICE_TYPE or CKGEN_CORE_SLICE_TYPE. |
| status_t sdrv_ckgen_init | ( | sdrv_ckgen_config_t * | config | ) |
System clock initialize.
This function initialize all system clock as pre-defined. It will change core clock to 24M, then config PLL, after PLL is locked, config BUS and CORE to expect rate. After that config IP clock if defined, and enable or disable clock gate.
| [in] | config | pre-defined clock config list. |
| status_t sdrv_ckgen_ip_clock_enable | ( | const sdrv_ckgen_node_t * | ckgen_ip[], |
| sdrv_ckgen_lp_mode_e | mode, | ||
| bool | enable | ||
| ) |
Config IP clock enable/disable in run/sleep/hibernate mode.
This function config all xcg belongs to this IP in run/sleep/hibernate mode.
| [in] | ckgen_ip | CG Node list belongs to this IP. |
| [in] | mode | Run/Sleep/Hibernate. |
| [in] | enable | clock enable or disable. |
| status_t sdrv_ckgen_is_gated | ( | sdrv_ckgen_node_t * | ckgen | ) |
Get ckgen xcg node gating status.
This function check whether xcg node is gated.
| [in] | ckgen | ckgen node type can be CG NODE. |
| status_t sdrv_ckgen_set_gate | ( | sdrv_ckgen_node_t * | ckgen, |
| sdrv_ckgen_lp_mode_e | lp_mode, | ||
| bool | gating | ||
| ) |
Config xcg status under run/sleep/hibernate mode.
This function configure clock gating status in run/sleep/hibernate mode, when system enter run/sleep/hibernate mode, hardware auto enable or disable clock as configured.
| [in] | ckgen | ckgen node type can be CG NODE. |
| [in] | lp_mode | Run/Sleep/Hibernate. |
| [in] | gating | gating enable or disable. |
| status_t sdrv_ckgen_set_pll_power | ( | sdrv_ckgen_node_t * | ckgen, |
| sdrv_ckgen_lp_mode_e | lp_mode, | ||
| bool | power_down | ||
| ) |
Config PLL power down under run/sleep/hibernate mode.
This function config enable or disable PLL power under run/sleep/hibernate mode.
| [in] | ckgen | ckgen node type can be CKGEN_PLL_CG_TYPE. |
| [in] | lp_mode | Run/Sleep/Hibernate. |
| [in] | power_down | power down enable or disable. |
| status_t sdrv_ckgen_set_rate | ( | sdrv_ckgen_node_t * | ckgen, |
| uint32_t | rate | ||
| ) |
Config clock rate for Core/IP slice node.
This function configures expected clock rate for specific ckgen node, it will search all his parent nodes, and select a closest clock rate at last.
| [in] | ckgen | ckgen node type can be CKGEN_IP_SLICE_TYPE or CKGEN_CORE_SLICE_TYPE. |
| [in] | rate | expected clock rate. |
| status_t sdrv_ckgen_slice_gated | ( | sdrv_ckgen_node_t * | ckgen | ) |
Get slice node gating status.
This function check whether slice node is gated.
| [in] | ckgen | ckgen node type can be IP/Core/Bus slice. |
| status_t sdrv_ckgen_xcg_type_set | ( | sdrv_ckgen_xcg_set_t * | xcg, |
| sdrv_ckgen_lp_mode_e | mode, | ||
| bool | gate | ||
| ) |
Config All xcg gate or active.
This function config PCG/BCG/CCG all gate or active.
| [in] | xcg | xcg info. |
| [in] | mode | run mode. |
| [in] | gate | true or false. |
| status_t sdrv_clktree_dump | ( | sdrv_clk_config_t * | clk_config, |
| sdrv_clk_t * | clk_node | ||
| ) |
Dump system clock tree.
| [in] | clk_config | system total clock node list. |
| [in] | clk_node | the root clock node begin to dump, if set NULL means dump all clock. |
| int sdrv_fs24m_change_src | ( | sdrv_ckgen_node_t * | ckgen, |
| sdrv_fs_src_type_e | src | ||
| ) |
Config FS24M clock source.
This function select FS24M clock source, RC oscillator or XTAL oscillator.
| [in] | ckgen | ckgen node type must be CKGEN_FS24M_TYPE. |
| [in] | src | RC oscillator or XTAL oscillator |
| int sdrv_fs32k_change_src | ( | sdrv_ckgen_node_t * | ckgen, |
| sdrv_fs_src_type_e | src | ||
| ) |
Config FS32K clock source.
This function select FS32K clock source, RC oscillator or XTAL oscillator.
| [in] | ckgen | ckgen node type must be CKGEN_FS32K_TYPE. |
| [in] | src | RC oscillator or XTAL oscillator |
| int sdrv_fs32k_change_src_nowait | ( | sdrv_ckgen_node_t * | ckgen, |
| sdrv_fs_src_type_e | src | ||
| ) |
Config FS32K clock source without wait active status.
This function select FS32K clock source, RC oscillator or XTAL oscillator.
| [in] | ckgen | ckgen node type must be CKGEN_FS32K_TYPE. |
| [in] | src | RC oscillator or XTAL oscillator |
| bool sdrv_fs32k_get_src_active_status | ( | sdrv_ckgen_node_t * | ckgen, |
| sdrv_fs_src_type_e | src | ||
| ) |
Get FS32K clock source active status.
This function get FS32K clock source, RC oscillator or XTAL oscillator, active status.
| [in] | ckgen | ckgen node type must be CKGEN_FS32K_TYPE. |
| [in] | src | RC oscillator or XTAL oscillator |
| int sdrv_fs32k_lpvd_power_ctrl | ( | sdrv_ckgen_node_t * | ckgen, |
| bool | power_on | ||
| ) |
Control low power voltage detector power on or down.
| [in] | ckgen | ckgen node type must be CKGEN_FS32K_TYPE. |
| [in] | power_on | True or False. |
| uint32_t sdrv_pll_get_rate | ( | sdrv_ckgen_node_t * | ckgen | ) |
Get PLL rate.
This function get clock rate for specific PLL.
| [in] | ckgen | ckgen node type can be CKGEN_PLL_CTRL_TYPE or CKGEN_PLL_LVDS_TYPE. |
| status_t sdrv_pll_is_locked | ( | sdrv_ckgen_node_t * | ckgen | ) |
Get PLL lock detector status.
This function check whether pll is locked.
| [in] | ckgen | ckgen node type can be CKGEN_PLL_CTRL_TYPE. |
| status_t sdrv_pll_set_rate | ( | sdrv_ckgen_node_t * | ckgen, |
| uint32_t | rate | ||
| ) |
Config PLL rate.
This function config clock rate for specific PLL.
| [in] | ckgen | ckgen node type can be CKGEN_PLL_CTRL_TYPE or CKGEN_PLL_LVDS_TYPE. |
| [in] | rate | clock rate to be set. |
| status_t sdrv_pll_set_rate_with_dsm | ( | sdrv_ckgen_node_t * | ckgen, |
| uint32_t | rate, | ||
| bool | dsm_en | ||
| ) |
Config PLL rate with delta-sigma modulator enable config.
This function config clock rate for specific PLL, and when rate configed work as integer pll, it's up to user whether enable fractional.
| [in] | ckgen | ckgen node type can be CKGEN_PLL_CTRL_TYPE or CKGEN_PLL_LVDS_TYPE. |
| [in] | rate | clock rate to be set. |
| [in] | dsm_en | dsm enable or not. |
| status_t sdrv_pll_set_ssc_amplitude | ( | sdrv_ckgen_node_t * | ckgen, |
| sdrv_ckgen_ssc_amplitude_e | amplitude | ||
| ) |
Set PLL spread amplitude.
This function set SSC amplitude for specific pll.
| [in] | ckgen | ckgen node only can be CKGEN_PLL_CTRL_TYPE. |
| [in] | amplitude | SSC amplitude 0-31 represents 0.0% - 3.1%. |
| status_t sdrv_pll_set_ssc_frequency | ( | sdrv_ckgen_node_t * | ckgen, |
| sdrv_ckgen_ssc_freq_e | ssc_freq | ||
| ) |
Set PLL spread frequency.
This function set SSC frequency for specific pll.
| [in] | ckgen | ckgen node only can be CKGEN_PLL_CTRL_TYPE. |
| [in] | ssc_freq | SSC modulation frequency. |
| status_t sdrv_pll_set_ssc_mode | ( | sdrv_ckgen_node_t * | ckgen, |
| sdrv_ckgen_ssc_mode_e | ssc_mode | ||
| ) |
Set PLL spread mode.
This function set SSC mode for specific pll. This function will check PLL work mode first, if pll config DSM_DISABLE, set spread mode will failed.
| [in] | ckgen | ckgen node only can be CKGEN_PLL_CTRL_TYPE. |
| [in] | ssc_mode | SSC mode. |
| int sdrv_xtal24m_enable | ( | sdrv_ckgen_node_t * | ckgen, |
| bool | enable | ||
| ) |
Config XTAL24M oscillator.
This function enable or disable xtal24m oscillator.
| [in] | ckgen | ckgen node type must be CKGEN_FS24M_TYPE. |
| [in] | enable | true represents enable oscillator, false represents disable oscillator. |
| int sdrv_xtal24m_from_active_crystal | ( | sdrv_ckgen_node_t * | ckgen | ) |
Config XTAL24M oscillator.
This function config 24M clock from external active crystal.
| [in] | ckgen | ckgen node type must be CKGEN_FS24M_TYPE. |
| int sdrv_xtal32k_enable | ( | sdrv_ckgen_node_t * | ckgen, |
| bool | enable | ||
| ) |
Config XTAL32K oscillator.
This function enable or disable xtal32k oscillator.
| [in] | ckgen | ckgen node type must be CKGEN_FS32K_TYPE. |
| [in] | enable | true represents enable oscillator, false represents disable oscillator. |
| int sdrv_xtal32k_enable_nowait | ( | sdrv_ckgen_node_t * | ckgen, |
| bool | enable | ||
| ) |
Config XTAL32K oscillator.
This function enable or disable xtal32k oscillator without wait ready status.
| [in] | ckgen | ckgen node type must be CKGEN_FS32K_TYPE. |
| [in] | enable | true represents enable oscillator, false represents disable oscillator. |
| int sdrv_xtal32k_from_active_crystal | ( | sdrv_ckgen_node_t * | ckgen | ) |
Config XTAL32K oscillator.
This function config 32k clock from external active crystal.
| [in] | ckgen | ckgen node type must be CKGEN_FS32K_TYPE. |
| bool sdrv_xtal32k_get_ready_status | ( | sdrv_ckgen_node_t * | ckgen | ) |
Get xtal32k ready status.
This function get xtal32k ready status.
| [in] | ckgen | ckgen node type must be CKGEN_FS32K_TYPE. |