SyterKit 0.4.0.x
SyterKit is a bare-metal framework
Loading...
Searching...
No Matches
Classes | Macros | Functions | Variables
sys-clk.c File Reference
#include <io.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <types.h>
#include <timer.h>
#include <log.h>
#include <sys-clk.h>
Include dependency graph for sys-clk.c:

Classes

struct  pll_reg_config
 

Macros

#define PLL_REG_CONF(x)    { x, (1 << x##_PLL_FREF_SEL_OFFSET) }
 
#define CPU_PLL_FACTOR_N_24M(x)   (((x) + (24) - 1) / (24))
 
#define CPU_PLL_FACTOR_N_26M(x)   (((x) + (26) - 1) / (26))
 

Functions

static void set_pll_parent (void)
 
static void enable_pll (uint32_t addr, uint32_t m0, uint32_t n, uint32_t m1, uint32_t p)
 
static void set_pll (uint32_t addr, uint32_t m0, uint32_t n, uint32_t m1, uint32_t p)
 
static void set_pll_cpux_axi (void)
 
static void set_apb1 (void)
 
static void set_pll_nsi (void)
 
void sunxi_clk_init (void)
 Initialize the global clocks.
 
uint32_t sunxi_clk_get_hosc_type ()
 Get the type of High-Speed Oscillator (HOSC).
 
void sunxi_clk_reset (void)
 Reset the global clocks.
 
uint32_t sunxi_clk_get_peri1x_rate ()
 Get the clock rate of the PERI1X bus.
 
static void sunxi_cpu_clk_dump (uint32_t pll_addr, uint32_t ctl_addr, char *name, uint32_t clk_hosc)
 
static void sunxi_peri_clk_dump (uint32_t addr, char *name, uint8_t pll_div)
 
void sunxi_clk_dump (void)
 Dump all clock-related register values.
 

Variables

const struct pll_reg_config pll_ctrl_regs []
 

Macro Definition Documentation

◆ CPU_PLL_FACTOR_N_24M

#define CPU_PLL_FACTOR_N_24M (   x)    (((x) + (24) - 1) / (24))

◆ CPU_PLL_FACTOR_N_26M

#define CPU_PLL_FACTOR_N_26M (   x)    (((x) + (26) - 1) / (26))

◆ PLL_REG_CONF

#define PLL_REG_CONF (   x)     { x, (1 << x##_PLL_FREF_SEL_OFFSET) }

Function Documentation

◆ enable_pll()

static void enable_pll ( uint32_t  addr,
uint32_t  m0,
uint32_t  n,
uint32_t  m1,
uint32_t  p 
)
inlinestatic

◆ set_apb1()

static void set_apb1 ( void  )
inlinestatic

◆ set_pll()

static void set_pll ( uint32_t  addr,
uint32_t  m0,
uint32_t  n,
uint32_t  m1,
uint32_t  p 
)
inlinestatic

◆ set_pll_cpux_axi()

static void set_pll_cpux_axi ( void  )
inlinestatic

◆ set_pll_nsi()

static void set_pll_nsi ( void  )
inlinestatic

◆ set_pll_parent()

static void set_pll_parent ( void  )
inlinestatic

◆ sunxi_clk_dump()

void sunxi_clk_dump ( void  )

Dump all clock-related register values.

This function prints out all clock-related register values for debugging and observation.

◆ sunxi_clk_get_hosc_type()

uint32_t sunxi_clk_get_hosc_type ( void  )

Get the type of High-Speed Oscillator (HOSC).

This function retrieves the type of the High-Speed Oscillator currently being used. The returned value can indicate different HOSC configurations or features supported by the system.

Returns
uint32_t Type of the HOSC.

◆ sunxi_clk_get_peri1x_rate()

uint32_t sunxi_clk_get_peri1x_rate ( )

Get the clock rate of the PERI1X bus.

Returns
The clock rate of the PERI1X bus in Hz.

◆ sunxi_clk_init()

void sunxi_clk_init ( void  )

Initialize the global clocks.

This function initializes the global clocks, including PLLs and clock dividers.

Initialize the global clocks.

This function configures various clock sources for the CPU, AXI, APB, NSI, and MBUS based on the Sunxi platform's requirements. The function also prints debug messages to track the initialization process.

It performs the following tasks:

Note
This function should be called during the system initialization process to ensure the correct operation of the platform's clock system.
Warning
Ensure that all the clock configuration functions are correctly implemented and tested to avoid system instability.

◆ sunxi_clk_reset()

void sunxi_clk_reset ( void  )

Reset the global clocks.

This function resets all global clocks to their default values.

◆ sunxi_cpu_clk_dump()

static void sunxi_cpu_clk_dump ( uint32_t  pll_addr,
uint32_t  ctl_addr,
char *  name,
uint32_t  clk_hosc 
)
inlinestatic

◆ sunxi_peri_clk_dump()

static void sunxi_peri_clk_dump ( uint32_t  addr,
char *  name,
uint8_t  pll_div 
)
inlinestatic

Variable Documentation

◆ pll_ctrl_regs

const struct pll_reg_config pll_ctrl_regs[]
Initial value:
= {
}
#define PLL_NPU_CTRL_REG
Definition reg-ccu.h:272
#define PLL_DDR_CTRL_REG
Definition reg-ccu.h:59
#define PLL_PERI1_CTRL_REG
Definition reg-ccu.h:247
#define PLL_VIDEO1_CTRL_REG
Definition reg-ccu.h:374
#define PLL_PERI0_CTRL_REG
Definition reg-ccu.h:202
#define PLL_VIDEO2_CTRL_REG
Definition reg-ccu.h:415
#define PLL_VIDEO0_CTRL_REG
Definition reg-ccu.h:333
#define PLL_AUDIO0_CTRL_REG
Definition reg-ccu.h:492
#define PLL_AUDIO1_CTRL_REG
Definition reg-ccu.h:571
#define PLL_VE1_CTRL_REG
Definition reg-ccu.h:1015
#define PLL_VE0_CTRL_REG
Definition reg-ccu.h:902
#define PLL_GPU0_CTRL_REG
Definition reg-ccu.h:432
#define PLL_DE_CTRL_REG
Definition reg-ccu.h:1469
#define PLL_REG_CONF(x)
Definition sys-clk.c:16