coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
srclken_rc.c File Reference
#include <console/console.h>
#include <delay.h>
#include <soc/addressmap.h>
#include <soc/pmif.h>
#include <soc/srclken_rc.h>
Include dependency graph for srclken_rc.c:

Go to the source code of this file.

Macros

#define RCTAG   "[SRCLKEN_RC]"
 
#define rc_info(fmt, arg ...)
 
#define SRCLKEN_DBG   1
 
#define SUB_CTRL_CON(_dcxo_prd, _xo_prd, _bypass_cmd, _dcxo_settle_blk_en)
 

Enumerations

enum  {
  FULL_SET_HW_MODE = 0 , VCORE_SETTLE_TIME = 1 , ULPOSC_SETTLE_TIME = 4 , XO_SETTLE_TIME = 0x1 ,
  DCXO_SETTLE_TIME = 0x1 , CENTROL_CNT_STEP = 0x3 , DCXO_STABLE_TIME = 0x70 , XO_STABLE_TIME = 0x70 ,
  KEEP_RC_SPI_ACTIVE_VAL = 1 , SRCLKEN_RC_EN_SEL_VAL = 0
}
 
enum  { INIT_SUBSYS_FPM_TO_LPM , INIT_SUBSYS_FPM_TO_BBLPM = 1 << CHN_DEEPIDLE , INIT_SUBSYS_TO_HW = 1 << CHN_SUSPEND | 1 << CHN_DEEPIDLE | 1 << CHN_MCU }
 
enum  {
  RC_CENTRAL_ENABLE = 1 , RC_CENTRAL_DISABLE = 0 , SPI_TRIG_MODE = SRCLKENAO_MODE , IS_SPI_DONE_RELEASE = 0 ,
  IS_SPI2PMIC_SET_CLR = 0 , SRCLKENO_0_CTRL_M = MERGE_OR_MODE , VREQ_CTRL_M = BYPASS_MODE , ULPOSC_CTRL_M_VAL = BYPASS_MODE ,
  PWRAP_CTRL_M = MERGE_OR_MODE , SPI_CLK_SRC = RC_32K
}
 
enum  { DCXO_FPM_CTRL_MODE = MERGE_OR_MODE | ASYNC_MODE , PWRAP_TMOUT_VAL = 0xA , FPM_MSK_B = FULL_SET_HW_MODE , MD0_SRCLKENO_0_MASK_B = 0 }
 
enum  { SUB_BBLPM_SET = 1 << CHN_COANT | 1 << CHN_DEEPIDLE , SUB_FPM_SET }
 
enum  { SW_FPM_LOW = 0 , SW_FPM_HIGH = 1 }
 
enum  { SW_BBLPM_LOW = 0 , SW_BBLPM_HIGH = 1 }
 
enum  { DXCO_SETTLE_BLK_DIS = 0 , DXCO_SETTLE_BLK_EN = 1 }
 

Functions

static void pmic_read (u32 addr, u32 *rdata)
 
static void rc_dump_reg_info (void)
 
static void __rc_ctrl_mode_switch (enum chn_id id, enum rc_ctrl_m mode)
 
static void __rc_ctrl_fpm_switch (enum chn_id id, unsigned int mode)
 
static void __rc_ctrl_bblpm_switch (enum chn_id id, unsigned int mode)
 
static void rc_init_subsys_hw_mode (void)
 
static void rc_init_subsys_lpm (void)
 
static void rc_ctrl_mode_switch_init (enum chn_id id)
 
static enum rc_support srclken_rc_chk_init_cfg (void)
 
int srclken_rc_init (void)
 

Variables

static struct mtk_rc_regsrc_regs = (struct mtk_rc_regs *)RC_BASE
 
static struct mtk_rc_status_regsrc_sta_regs = (struct mtk_rc_status_regs *)RC_STATUS_BASE
 
static struct subsys_rc_con rc_ctrl [MAX_CHN_NUM]
 

Macro Definition Documentation

◆ rc_info

#define rc_info (   fmt,
  arg ... 
)
Value:
printk(BIOS_INFO, RCTAG "%s,%d: " fmt, \
__func__, __LINE__, ## arg)
#define printk(level,...)
Definition: stdlib.h:16
struct bootblock_arg arg
Definition: decompressor.c:22
#define BIOS_INFO
BIOS_INFO - Expected events.
Definition: loglevel.h:113
#define RCTAG
Definition: srclken_rc.c:9

Definition at line 10 of file srclken_rc.c.

◆ RCTAG

#define RCTAG   "[SRCLKEN_RC]"

Definition at line 9 of file srclken_rc.c.

◆ SRCLKEN_DBG

#define SRCLKEN_DBG   1

Definition at line 13 of file srclken_rc.c.

◆ SUB_CTRL_CON

#define SUB_CTRL_CON (   _dcxo_prd,
  _xo_prd,
  _bypass_cmd,
  _dcxo_settle_blk_en 
)
Value:
{ \
.dcxo_prd = _dcxo_prd, \
.xo_prd = _xo_prd, \
.cnt_step = CENTROL_CNT_STEP, \
.track_en = 0x0, \
.req_ack_imd_en = 0x1, \
.xo_soc_link_en = 0x0, \
.sw_bblpm = SW_BBLPM_LOW, \
.sw_fpm = SW_FPM_HIGH, \
.sw_rc = SW_MODE, \
.bypass_cmd = _bypass_cmd, \
.dcxo_settle_blk_en = _dcxo_settle_blk_en, \
}
@ SW_FPM_HIGH
Definition: srclken_rc.c:70
@ CENTROL_CNT_STEP
Definition: srclken_rc.c:22
@ SW_BBLPM_LOW
Definition: srclken_rc.c:74
@ SW_MODE
Definition: srclken_rc.h:166

Definition at line 83 of file srclken_rc.c.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
FULL_SET_HW_MODE 
VCORE_SETTLE_TIME 
ULPOSC_SETTLE_TIME 
XO_SETTLE_TIME 
DCXO_SETTLE_TIME 
CENTROL_CNT_STEP 
DCXO_STABLE_TIME 
XO_STABLE_TIME 
KEEP_RC_SPI_ACTIVE_VAL 
SRCLKEN_RC_EN_SEL_VAL 

Definition at line 16 of file srclken_rc.c.

◆ anonymous enum

anonymous enum
Enumerator
INIT_SUBSYS_FPM_TO_LPM 
INIT_SUBSYS_FPM_TO_BBLPM 
INIT_SUBSYS_TO_HW 

Definition at line 29 of file srclken_rc.c.

◆ anonymous enum

anonymous enum
Enumerator
RC_CENTRAL_ENABLE 
RC_CENTRAL_DISABLE 
SPI_TRIG_MODE 
IS_SPI_DONE_RELEASE 
IS_SPI2PMIC_SET_CLR 
SRCLKENO_0_CTRL_M 
VREQ_CTRL_M 
ULPOSC_CTRL_M_VAL 
PWRAP_CTRL_M 
SPI_CLK_SRC 

Definition at line 39 of file srclken_rc.c.

◆ anonymous enum

anonymous enum
Enumerator
DCXO_FPM_CTRL_MODE 
PWRAP_TMOUT_VAL 
FPM_MSK_B 
MD0_SRCLKENO_0_MASK_B 

Definition at line 53 of file srclken_rc.c.

◆ anonymous enum

anonymous enum
Enumerator
SUB_BBLPM_SET 
SUB_FPM_SET 

Definition at line 60 of file srclken_rc.c.

◆ anonymous enum

anonymous enum
Enumerator
SW_FPM_LOW 
SW_FPM_HIGH 

Definition at line 68 of file srclken_rc.c.

◆ anonymous enum

anonymous enum
Enumerator
SW_BBLPM_LOW 
SW_BBLPM_HIGH 

Definition at line 73 of file srclken_rc.c.

◆ anonymous enum

anonymous enum
Enumerator
DXCO_SETTLE_BLK_DIS 
DXCO_SETTLE_BLK_EN 

Definition at line 78 of file srclken_rc.c.

Function Documentation

◆ __rc_ctrl_bblpm_switch()

static void __rc_ctrl_bblpm_switch ( enum chn_id  id,
unsigned int  mode 
)
static

Definition at line 189 of file srclken_rc.c.

References rc_ctrl, rc_info, mtk_rc_regs::rc_mxx_srclken_cfg, rc_regs, read32(), SET32_BITFIELDS, and subsys_rc_con::sw_bblpm.

Referenced by rc_init_subsys_lpm().

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

◆ __rc_ctrl_fpm_switch()

static void __rc_ctrl_fpm_switch ( enum chn_id  id,
unsigned int  mode 
)
static

Definition at line 182 of file srclken_rc.c.

References rc_ctrl, rc_info, mtk_rc_regs::rc_mxx_srclken_cfg, rc_regs, read32(), SET32_BITFIELDS, and subsys_rc_con::sw_fpm.

Referenced by rc_init_subsys_lpm().

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

◆ __rc_ctrl_mode_switch()

◆ pmic_read()

static void pmic_read ( u32  addr,
u32 rdata 
)
static

Definition at line 117 of file srclken_rc.c.

References addr, get_pmif_controller(), NULL, pmif_arb, PMIF_SPI, and pmif::read.

Referenced by srclken_rc_init().

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

◆ rc_ctrl_mode_switch_init()

static void rc_ctrl_mode_switch_init ( enum chn_id  id)
static

Definition at line 220 of file srclken_rc.c.

References __rc_ctrl_mode_switch(), and INIT_MODE.

Referenced by srclken_rc_init().

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

◆ rc_dump_reg_info()

◆ rc_init_subsys_hw_mode()

static void rc_init_subsys_hw_mode ( void  )
static

Definition at line 196 of file srclken_rc.c.

References __rc_ctrl_mode_switch(), HW_MODE, INIT_SUBSYS_TO_HW, and MAX_CHN_NUM.

Referenced by srclken_rc_init().

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

◆ rc_init_subsys_lpm()

static void rc_init_subsys_lpm ( void  )
static

Definition at line 206 of file srclken_rc.c.

References __rc_ctrl_bblpm_switch(), __rc_ctrl_fpm_switch(), INIT_SUBSYS_FPM_TO_BBLPM, INIT_SUBSYS_FPM_TO_LPM, MAX_CHN_NUM, SW_BBLPM_HIGH, and SW_FPM_LOW.

Referenced by srclken_rc_init().

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

◆ srclken_rc_chk_init_cfg()

static enum rc_support srclken_rc_chk_init_cfg ( void  )
static

Definition at line 220 of file srclken_rc.c.

Referenced by srclken_rc_init().

Here is the caller graph for this function:

◆ srclken_rc_init()

Variable Documentation

◆ rc_ctrl

struct subsys_rc_con rc_ctrl[MAX_CHN_NUM]
static
Initial value:
= {
}
@ DXCO_SETTLE_BLK_EN
Definition: srclken_rc.c:80
@ DXCO_SETTLE_BLK_DIS
Definition: srclken_rc.c:79
#define SUB_CTRL_CON(_dcxo_prd, _xo_prd, _bypass_cmd, _dcxo_settle_blk_en)
Definition: srclken_rc.c:83
@ XO_STABLE_TIME
Definition: srclken_rc.c:24
@ DCXO_STABLE_TIME
Definition: srclken_rc.c:23
@ CHN_UFS
Definition: srclken_rc.h:139
@ CHN_MCU
Definition: srclken_rc.h:136
@ CHN_WIFI
Definition: srclken_rc.h:135
@ CHN_RESERVE
Definition: srclken_rc.h:141
@ CHN_NFC
Definition: srclken_rc.h:138
@ CHN_RF
Definition: srclken_rc.h:130
@ CHN_MD
Definition: srclken_rc.h:132
@ CHN_GPS
Definition: srclken_rc.h:133
@ CHN_BT
Definition: srclken_rc.h:134
@ CHN_SUSPEND
Definition: srclken_rc.h:129
@ CHN_COANT
Definition: srclken_rc.h:137
@ CHN_SCP
Definition: srclken_rc.h:140
@ CHN_DEEPIDLE
Definition: srclken_rc.h:131

Definition at line 98 of file srclken_rc.c.

Referenced by __rc_ctrl_bblpm_switch(), __rc_ctrl_fpm_switch(), __rc_ctrl_mode_switch(), and srclken_rc_init().

◆ rc_regs

◆ rc_sta_regs

struct mtk_rc_status_regs* rc_sta_regs = (struct mtk_rc_status_regs *)RC_STATUS_BASE
static

Definition at line 98 of file srclken_rc.c.

Referenced by rc_dump_reg_info(), and srclken_rc_init().