RTEMS  5.1
Data Structures | Macros | Typedefs | Enumerations | Functions
alt_clock_manager.c File Reference
#include <stdint.h>
#include <stdlib.h>
#include <stdbool.h>
#include <stdio.h>
#include <bsp/socal/hps.h>
#include <bsp/socal/socal.h>
#include <bsp/socal/alt_sysmgr.h>
#include <bsp/hwlib.h>
#include <bsp/alt_clock_manager.h>
#include <bsp/alt_mpu_registers.h>

Data Structures

struct  ALT_CLK_PARAMS_s
 
struct  ALT_EXT_CLK_PARAMBLOK_s
 
struct  ALT_PLL_CLK_PARAMBLOK_s
 
struct  ALT_PLL_CNTR_FREQMAX_s
 

Macros

#define UINT12_MAX   (4096)
 
#define ALT_ORIGINAL_GUARDBAND_VAL   20
 
#define ALT_GUARDBAND_LIMIT   20
 
#define ALT_CLK_PLL_MULT_MAX   4095
 
#define ALT_CLK_PLL_DIV_MAX   63
 
#define ALT_CLK_PLL_CNTR_MAX   511
 
#define ALT_CLK_PLL_RST_BIT_C0   0x00000001
 
#define ALT_CLK_PLL_RST_BIT_C1   0x00000002
 
#define ALT_CLK_PLL_RST_BIT_C2   0x00000004
 
#define ALT_CLK_PLL_RST_BIT_C3   0x00000008
 
#define ALT_CLK_PLL_RST_BIT_C4   0x00000010
 
#define ALT_CLK_PLL_RST_BIT_C5   0x00000020
 
#define ALT_CLK_MGR_PLL_LOCK_BITS
 
#define ALT_CLKMGR_ALTERA_OFST   0xe0
 
#define ALT_CLKMGR_ALTERA_MPUCLK_OFST   0x0
 
#define ALT_CLKMGR_ALTERA_MAINCLK_OFST   0x4
 
#define ALT_CLKMGR_ALTERA_DBGATCLK_OFST   0x8
 
#define ALT_CLKMGR_ALTERA_ADDR   ALT_CAST(void *, (ALT_CAST(char *, ALT_CLKMGR_ADDR) + ALT_CLKMGR_ALTERA_OFST))
 
#define ALT_CLKMGR_ALTERA_MPUCLK_ADDR   ALT_CAST(void *, (ALT_CAST(char *, ALT_CLKMGR_ALTERA_ADDR) + ALT_CLKMGR_ALTERA_MPUCLK_OFST))
 
#define ALT_CLKMGR_ALTERA_MAINCLK_ADDR   ALT_CAST(void *, (ALT_CAST(char *, ALT_CLKMGR_ALTERA_ADDR) + ALT_CLKMGR_ALTERA_MAINCLK_OFST))
 
#define ALT_CLKMGR_ALTERA_DBGATCLK_ADDR   ALT_CAST(void *, (ALT_CAST(char *, ALT_CLKMGR_ALTERA_ADDR) + ALT_CLKMGR_ALTERA_DBGATCLK_OFST))
 
#define ALT_CLKMGR_ALTERA_MPUCLK_CNT_GET(value)   (((value) & 0x000001ff) >> 0)
 
#define ALT_CLKMGR_ALTERA_MAINCLK_CNT_GET(value)   (((value) & 0x000001ff) >> 0)
 
#define ALT_CLKMGR_ALTERA_DBGATCLK_CNT_GET(value)   (((value) & 0x000001ff) >> 0)
 
#define ALT_SW_MANAGED_CLK_WAIT_CTRDIV   30 /* 30 or more MPU clock cycles */
 
#define ALT_SW_MANAGED_CLK_WAIT_HWCTRDIV   40
 
#define ALT_SW_MANAGED_CLK_WAIT_BYPASS   30
 
#define ALT_SW_MANAGED_CLK_WAIT_SAFEREQ   30
 
#define ALT_SW_MANAGED_CLK_WAIT_SAFEEXIT   30
 
#define ALT_SW_MANAGED_CLK_WAIT_NANDCLK   8 /* 8 or more MPU clock cycles */
 
#define ALT_BYPASS_TIMEOUT_CNT   50
 
#define ALT_TIMEOUT_PHASE_SYNC   300
 
#define alt_within_delta(ref, neu, prcnt)
 
#define ALT_PREVENT_GLITCH_BYP   true
 
#define ALT_PREVENT_GLITCH_EXSAFE   true
 
#define ALT_PREVENT_GLITCH_CNTRRST   true
 
#define ALT_PREVENT_GLITCH_CHGC1   true
 
#define ALT_CLK_PLL_VCO_CHG_METHOD_TEST_MODE   false
 
#define ALT_CLK_WITHIN_FREQ_LIMITS_TEST_MODE   false
 

Typedefs

typedef struct ALT_CLK_PARAMS_s ALT_CLK_PARAMS_t
 
typedef struct ALT_EXT_CLK_PARAMBLOK_s ALT_EXT_CLK_PARAMBLOK_t
 
typedef struct ALT_PLL_CLK_PARAMBLOK_s ALT_PLL_CLK_PARAMBLOK_t
 
typedef struct ALT_PLL_CNTR_FREQMAX_s ALT_PLL_CNTR_FREQMAX_t
 
typedef enum ALT_CLK_PLL_VCO_CHG_METHOD_e ALT_CLK_PLL_VCO_CHG_METHOD_t
 

Enumerations

enum  ALT_CLK_PLL_VCO_CHG_METHOD_e {
  ALT_VCO_CHG_NONE_VALID = 0, ALT_VCO_CHG_NOCHANGE = 0x00000001, ALT_VCO_CHG_NUM = 0x00000002, ALT_VCO_CHG_NUM_BYP = 0x00000004,
  ALT_VCO_CHG_DENOM = 0x00000008, ALT_VCO_CHG_DENOM_BYP = 0x00000010, ALT_VCO_CHG_NUM_DENOM = 0x00000020, ALT_VCO_CHG_NUM_DENOM_BYP = 0x00000040,
  ALT_VCO_CHG_DENOM_NUM = 0x00000080, ALT_VCO_CHG_DENOM_NUM_BYP = 0x00000100
}
 

Functions

ALT_STATUS_CODE alt_clk_plls_settle_wait (void)
 
ALT_STATUS_CODE alt_clk_lock_status_clear (ALT_CLK_PLL_LOCK_STATUS_t lock_stat_mask)
 
uint32_t alt_clk_lock_status_get (void)
 
ALT_STATUS_CODE alt_clk_pll_is_locked (ALT_CLK_t pll)
 
ALT_STATUS_CODE alt_clk_safe_mode_clear (void)
 
bool alt_clk_is_in_safe_mode (ALT_CLK_SAFE_DOMAIN_t clk_domain)
 
ALT_STATUS_CODE alt_clk_pll_bypass_disable (ALT_CLK_t pll)
 
ALT_STATUS_CODE alt_clk_pll_bypass_enable (ALT_CLK_t pll, bool use_input_mux)
 
ALT_STATUS_CODE alt_clk_pll_is_bypassed (ALT_CLK_t pll)
 
ALT_CLK_t alt_clk_pll_source_get (ALT_CLK_t pll)
 
ALT_STATUS_CODE alt_clk_clock_disable (ALT_CLK_t clk)
 
ALT_STATUS_CODE alt_clk_clock_enable (ALT_CLK_t clk)
 
ALT_STATUS_CODE alt_clk_is_enabled (ALT_CLK_t clk)
 
ALT_CLK_t alt_clk_source_get (ALT_CLK_t clk)
 
ALT_STATUS_CODE alt_clk_source_set (ALT_CLK_t clk, ALT_CLK_t ref_clk)
 
ALT_STATUS_CODE alt_clk_ext_clk_freq_set (ALT_CLK_t clk, alt_freq_t freq)
 
alt_freq_t alt_clk_ext_clk_freq_get (ALT_CLK_t clk)
 
ALT_STATUS_CODE alt_clk_pll_cfg_get (ALT_CLK_t pll, ALT_CLK_PLL_CFG_t *pll_cfg)
 
ALT_STATUS_CODE alt_clk_pll_cfg_set (ALT_CLK_t pll, const ALT_CLK_PLL_CFG_t *pll_cfg)
 
ALT_STATUS_CODE alt_clk_pll_vco_cfg_get (ALT_CLK_t pll, uint32_t *mult, uint32_t *div)
 
ALT_STATUS_CODE alt_clk_pll_vco_cfg_set (ALT_CLK_t pll, uint32_t mult, uint32_t div)
 
ALT_STATUS_CODE alt_clk_pll_vco_freq_get (ALT_CLK_t pll, alt_freq_t *freq)
 
uint32_t alt_clk_pll_guard_band_get (ALT_CLK_t pll)
 
ALT_STATUS_CODE alt_clk_pll_guard_band_set (ALT_CLK_t pll, uint32_t guard_band)
 
ALT_STATUS_CODE alt_clk_divider_get (ALT_CLK_t clk, uint32_t *div)
 
ALT_STATUS_CODE alt_clk_divider_set (ALT_CLK_t clk, uint32_t div)
 
ALT_STATUS_CODE alt_clk_freq_get (ALT_CLK_t clk, alt_freq_t *freq)
 
ALT_STATUS_CODE alt_clk_irq_disable (ALT_CLK_PLL_LOCK_STATUS_t lock_stat_mask)
 
ALT_STATUS_CODE alt_clk_irq_enable (ALT_CLK_PLL_LOCK_STATUS_t lock_stat_mask)
 
ALT_STATUS_CODE alt_clk_group_cfg_raw_get (ALT_CLK_GRP_t clk_group, ALT_CLK_GROUP_RAW_CFG_t *clk_group_raw_cfg)
 
ALT_STATUS_CODE alt_clk_group_cfg_raw_set (const ALT_CLK_GROUP_RAW_CFG_t *clk_group_raw_cfg)
 
ALT_STATUS_CODE alt_clk_id_to_string (ALT_CLK_t clk_id, char *output, size_t size)
 
ALT_STATUS_CODE alt_clk_pll_cntr_maxfreq_recalc (ALT_CLK_t clk, ALT_PLL_CNTR_FREQMAX_t *maxfreq)
 
ALT_STATUS_CODE alt_clk_clkmgr_init (void)
 

Macro Definition Documentation

◆ ALT_CLK_MGR_PLL_LOCK_BITS

#define ALT_CLK_MGR_PLL_LOCK_BITS
Value:
(ALT_CLKMGR_INTREN_MAINPLLACHIEVED_CLR_MSK \
& ALT_CLKMGR_INTREN_PERPLLACHIEVED_CLR_MSK \
& ALT_CLKMGR_INTREN_SDRPLLACHIEVED_CLR_MSK \
& ALT_CLKMGR_INTREN_MAINPLLLOST_CLR_MSK \
& ALT_CLKMGR_INTREN_PERPLLLOST_CLR_MSK \
& ALT_CLKMGR_INTREN_SDRPLLLOST_CLR_MSK)

◆ alt_within_delta

#define alt_within_delta (   ref,
  neu,
  prcnt 
)
Value:
(((((neu) * 100)/(ref)) < (100 + (prcnt))) \
&& ((((neu) * 100)/(ref)) > (100 - (prcnt))))