coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
clock.c File Reference
#include <console/console.h>
#include <device/mmio.h>
#include <types.h>
#include <commonlib/helpers.h>
#include <soc/clock.h>
Include dependency graph for clock.c:

Go to the source code of this file.

Macros

#define DIV(div)   (div ? (2*div - 1) : 0)
 
#define HALF_DIVIDER(div2x)   (div2x ? (div2x - 1) : 0)
 

Functions

static int clock_configure_gpll0 (void)
 
static int clock_configure_mnd (struct qcs405_clock *clk, uint32_t m, uint32_t n, uint32_t d_2)
 
static int clock_configure (struct qcs405_clock *clk, struct clock_config *clk_cfg, uint32_t hz, uint32_t num_perfs)
 
static bool clock_is_off (void *cbcr_addr)
 
static int clock_enable_vote (void *cbcr_addr, void *vote_addr, uint32_t vote_bit)
 
static int clock_enable (void *cbcr_addr)
 
static int clock_disable (void *cbcr_addr)
 
int clock_reset_bcr (void *bcr_addr, bool reset)
 
void clock_configure_uart (uint32_t hz)
 
void clock_configure_spi (int blsp, int qup, uint32_t hz)
 
void clock_configure_i2c (uint32_t hz)
 
void clock_enable_uart (void)
 
void clock_disable_uart (void)
 
void clock_enable_spi (int blsp, int qup)
 
void clock_disable_spi (int blsp, int qup)
 
void clock_enable_i2c (void)
 
void clock_disable_i2c (void)
 
void clock_init (void)
 

Variables

struct clock_config uart_cfg []
 
struct clock_config i2c_cfg []
 
struct clock_config spi_cfg []
 

Macro Definition Documentation

◆ DIV

#define DIV (   div)    (div ? (2*div - 1) : 0)

Definition at line 9 of file clock.c.

◆ HALF_DIVIDER

#define HALF_DIVIDER (   div2x)    (div2x ? (div2x - 1) : 0)

Definition at line 10 of file clock.c.

Function Documentation

◆ clock_configure()

static int clock_configure ( struct qcs405_clock clk,
struct clock_config clk_cfg,
uint32_t  hz,
uint32_t  num_perfs 
)
static

◆ clock_configure_gpll0()

static int clock_configure_gpll0 ( void  )
static

◆ clock_configure_i2c()

void clock_configure_i2c ( uint32_t  hz)

Definition at line 238 of file clock.c.

References ARRAY_SIZE, qcs405_gcc::blsp1_qup1_i2c_clk, clock_configure(), gcc, and i2c_cfg.

Referenced by blsp_i2c_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ clock_configure_mnd()

static int clock_configure_mnd ( struct qcs405_clock clk,
uint32_t  m,
uint32_t  n,
uint32_t  d_2 
)
static

Definition at line 94 of file clock.c.

References qcs405_rcg::cfg, CLK_CTL_CFG_MODE_SHFT, CLK_CTL_RCG_MND_BMSK, qcs405_clock::d_2, clock_config::d_2, m, qcs405_clock::m, qcs405_clock::n, clock_config::n, qcs405_clock::rcg, read32(), and write32().

Referenced by clock_configure().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ clock_configure_spi()

void clock_configure_spi ( int  blsp,
int  qup,
uint32_t  hz 
)

Definition at line 198 of file clock.c.

References ARRAY_SIZE, BIOS_ERR, qcs405_gcc::blsp1_qup0_spi_clk, qcs405_gcc::blsp1_qup1_spi_clk, qcs405_gcc::blsp1_qup2_spi_clk, qcs405_gcc::blsp1_qup3_spi_clk, qcs405_gcc::blsp1_qup4_spi_clk, qcs405_gcc::blsp2_qup0_spi_clk, clock_configure(), gcc, and printk.

Referenced by spi_ctrlr_setup().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ clock_configure_uart()

void clock_configure_uart ( uint32_t  hz)

Definition at line 190 of file clock.c.

References ARRAY_SIZE, qcs405_gcc::blsp1_uart2_apps_clk, clock_configure(), gcc, and uart_cfg.

Referenced by uart_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ clock_disable()

static int clock_disable ( void cbcr_addr)
static

Definition at line 170 of file clock.c.

References BIT, CLK_CTL_CBC_CLK_EN_SHFT, and clrbits32.

Referenced by clock_disable_i2c(), and clock_disable_uart().

Here is the caller graph for this function:

◆ clock_disable_i2c()

void clock_disable_i2c ( void  )

Definition at line 314 of file clock.c.

References qcs405_gcc::blsp1_qup1_i2c_apps_cbcr, clock_disable(), and gcc.

Here is the call graph for this function:

◆ clock_disable_spi()

◆ clock_disable_uart()

void clock_disable_uart ( void  )

Definition at line 251 of file clock.c.

References qcs405_gcc::blsp1_uart2_apps_cbcr, clock_disable(), and gcc.

Here is the call graph for this function:

◆ clock_enable()

static int clock_enable ( void cbcr_addr)
static

Definition at line 157 of file clock.c.

References BIT, CLK_CTL_CBC_CLK_EN_SHFT, clock_is_off(), and setbits32.

Here is the call graph for this function:

◆ clock_enable_i2c()

void clock_enable_i2c ( void  )

Definition at line 309 of file clock.c.

References qcs405_gcc::blsp1_qup1_i2c_apps_cbcr, clock_enable(), and gcc.

Referenced by blsp_i2c_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ clock_enable_spi()

void clock_enable_spi ( int  blsp,
int  qup 
)

◆ clock_enable_uart()

void clock_enable_uart ( void  )

Definition at line 246 of file clock.c.

References qcs405_gcc::blsp1_uart2_apps_cbcr, clock_enable(), and gcc.

Referenced by uart_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ clock_enable_vote()

static int clock_enable_vote ( void cbcr_addr,
void vote_addr,
uint32_t  vote_bit 
)
static

Definition at line 144 of file clock.c.

References BIT, clock_is_off(), and setbits32.

Here is the call graph for this function:

◆ clock_init()

◆ clock_is_off()

static bool clock_is_off ( void cbcr_addr)
static

Definition at line 139 of file clock.c.

References CLK_CTL_CBC_CLK_OFF_BMSK, and read32().

Referenced by clock_enable(), and clock_enable_vote().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ clock_reset_bcr()

int clock_reset_bcr ( void bcr_addr,
bool  reset 
)

Definition at line 178 of file clock.c.

References qcs405_bcr::bcr, BIT, CLK_CTL_BCR_BLK_ARES_SHFT, clrbits32, reset(), and setbits32.

Here is the call graph for this function:

Variable Documentation

◆ i2c_cfg

struct clock_config i2c_cfg[]
Initial value:
= {
{
.hz = 19200000,
.hw_ctl = 0x0,
.div = DIV(0),
},
{
.hz = 50000000,
.hw_ctl = 0x0,
.div = DIV(32),
}
}
#define DIV(div)
Definition: clock.c:9
#define SRC_XO_19_2MHZ
Definition: clock.h:10
#define SRC_GPLL0_MAIN_800MHZ
Definition: clock.h:11

Definition at line 1 of file clock.c.

Referenced by clock_configure_i2c().

◆ spi_cfg

Definition at line 1 of file clock.c.

◆ uart_cfg

struct clock_config uart_cfg[]
Initial value:
= {
{
.hz = 1843200,
.hw_ctl = 0x0,
.div = DIV(0),
.m = 36,
.n = 15625,
.d_2 = 15625,
},
{
.hz = 3686400,
.hw_ctl = 0x0,
.div = DIV(0),
.m = 72,
.n = 15625,
.d_2 = 15625,
}
}

Definition at line 1 of file clock.c.

Referenced by clock_configure_uart().