coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
pmic_wrap_common.h File Reference
#include <console/console.h>
Include dependency graph for pmic_wrap_common.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define PWRAPTAG   "[PWRAP] "
 
#define pwrap_err(fmt, arg ...)
 

Typedefs

typedef u32(* loop_condition_fp) (u32)
 

Enumerations

enum  { DEFAULT_VALUE_READ_TEST = 0x5aa5 , WRITE_TEST_VALUE = 0xa55a }
 
enum  { TIMEOUT_READ_US = 255 , TIMEOUT_WAIT_IDLE_US = 255 }
 
enum  { OP_WR = 0x1 , OP_CSH = 0x0 , OP_CSL = 0x1 , OP_OUTS = 0x8 }
 
enum  {
  RDATA_WACS_RDATA_SHIFT = 0 , RDATA_WACS_FSM_SHIFT = 16 , RDATA_WACS_REQ_SHIFT = 19 , RDATA_SYNC_IDLE_SHIFT ,
  RDATA_INIT_DONE_V1_SHIFT , RDATA_SYS_IDLE_V1_SHIFT
}
 
enum  { RDATA_INIT_DONE_V2_SHIFT = 22 , RDATA_SYS_IDLE_V2_SHIFT = 23 }
 
enum  {
  RDATA_WACS_RDATA_MASK = 0xffff , RDATA_WACS_FSM_MASK = 0x7 , RDATA_WACS_REQ_MASK = 0x1 , RDATA_SYNC_IDLE_MASK = 0x1 ,
  RDATA_INIT_DONE_MASK = 0x1 , RDATA_SYS_IDLE_MASK = 0x1
}
 
enum  {
  WACS_FSM_IDLE = 0x00 , WACS_FSM_REQ = 0x02 , WACS_FSM_WFDLE = 0x04 , WACS_FSM_WFVLDCLR = 0x06 ,
  WACS_INIT_DONE = 0x01 , WACS_SYNC_IDLE = 0x01 , WACS_SYNC_BUSY = 0x00
}
 
enum  {
  E_PWR_INVALID_ARG = 1 , E_PWR_INVALID_RW = 2 , E_PWR_INVALID_ADDR = 3 , E_PWR_INVALID_WDAT = 4 ,
  E_PWR_INVALID_OP_MANUAL = 5 , E_PWR_NOT_IDLE_STATE = 6 , E_PWR_NOT_INIT_DONE = 7 , E_PWR_NOT_INIT_DONE_READ = 8 ,
  E_PWR_WAIT_IDLE_TIMEOUT = 9 , E_PWR_WAIT_IDLE_TIMEOUT_READ = 10 , E_PWR_INIT_SIDLY_FAIL = 11 , E_PWR_RESET_TIMEOUT = 12 ,
  E_PWR_TIMEOUT = 13 , E_PWR_INIT_RESET_SPI = 20 , E_PWR_INIT_SIDLY = 21 , E_PWR_INIT_REG_CLOCK = 22 ,
  E_PWR_INIT_ENABLE_PMIC = 23 , E_PWR_INIT_DIO = 24 , E_PWR_INIT_CIPHER = 25 , E_PWR_INIT_WRITE_TEST = 26 ,
  E_PWR_INIT_ENABLE_CRC = 27 , E_PWR_INIT_ENABLE_DEWRAP = 28 , E_PWR_INIT_ENABLE_EVENT = 29 , E_PWR_READ_TEST_FAIL = 30 ,
  E_PWR_WRITE_TEST_FAIL = 31 , E_PWR_SWITCH_DIO = 32
}
 

Functions

s32 pwrap_wacs2 (u32 write, u16 adr, u16 wdata, u16 *rdata, u32 init_check)
 
s32 pwrap_init (void)
 
static s32 pwrap_read (u16 addr, u16 *rdata)
 
static s32 pwrap_write (u16 addr, u16 wdata)
 
static u16 pwrap_read_field (u16 reg, u16 mask, u16 shift)
 
static void pwrap_write_field (u16 reg, u16 val, u16 mask, u16 shift)
 
s32 pwrap_reset_spislv (void)
 
static s32 pwrap_read_nochk (u16 addr, u16 *rdata)
 
static s32 pwrap_write_nochk (u16 addr, u16 wdata)
 
static u32 wait_for_fsm_vldclr (u32 x)
 
static u32 wait_for_sync (u32 x)
 
static u32 wait_for_idle_and_sync (u32 x)
 
static u32 wait_for_cipher_ready (u32 x)
 
u32 wait_for_state_idle (u32 timeout_us, void *wacs_register, void *wacs_vldclr_register, u32 *read_reg)
 
u32 wait_for_state_ready (loop_condition_fp fp, u32 timeout_us, void *wacs_register, u32 *read_reg)
 

Macro Definition Documentation

◆ pwrap_err

#define pwrap_err (   fmt,
  arg ... 
)
Value:
printk(BIOS_ERR, PWRAPTAG "ERROR,line=%d" fmt, \
__LINE__, ## arg)
#define printk(level,...)
Definition: stdlib.h:16
struct bootblock_arg arg
Definition: decompressor.c:22
#define BIOS_ERR
BIOS_ERR - System in incomplete state.
Definition: loglevel.h:72
#define PWRAPTAG

Definition at line 9 of file pmic_wrap_common.h.

◆ PWRAPTAG

#define PWRAPTAG   "[PWRAP] "

Definition at line 8 of file pmic_wrap_common.h.

Typedef Documentation

◆ loop_condition_fp

typedef u32(* loop_condition_fp) (u32)

Definition at line 144 of file pmic_wrap_common.h.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
DEFAULT_VALUE_READ_TEST 
WRITE_TEST_VALUE 

Definition at line 60 of file pmic_wrap_common.h.

◆ anonymous enum

anonymous enum
Enumerator
TIMEOUT_READ_US 
TIMEOUT_WAIT_IDLE_US 

Definition at line 66 of file pmic_wrap_common.h.

◆ anonymous enum

anonymous enum
Enumerator
OP_WR 
OP_CSH 
OP_CSL 
OP_OUTS 

Definition at line 72 of file pmic_wrap_common.h.

◆ anonymous enum

anonymous enum
Enumerator
RDATA_WACS_RDATA_SHIFT 
RDATA_WACS_FSM_SHIFT 
RDATA_WACS_REQ_SHIFT 
RDATA_SYNC_IDLE_SHIFT 
RDATA_INIT_DONE_V1_SHIFT 
RDATA_SYS_IDLE_V1_SHIFT 

Definition at line 79 of file pmic_wrap_common.h.

◆ anonymous enum

anonymous enum
Enumerator
RDATA_INIT_DONE_V2_SHIFT 
RDATA_SYS_IDLE_V2_SHIFT 

Definition at line 88 of file pmic_wrap_common.h.

◆ anonymous enum

anonymous enum
Enumerator
RDATA_WACS_RDATA_MASK 
RDATA_WACS_FSM_MASK 
RDATA_WACS_REQ_MASK 
RDATA_SYNC_IDLE_MASK 
RDATA_INIT_DONE_MASK 
RDATA_SYS_IDLE_MASK 

Definition at line 93 of file pmic_wrap_common.h.

◆ anonymous enum

anonymous enum
Enumerator
WACS_FSM_IDLE 
WACS_FSM_REQ 
WACS_FSM_WFDLE 
WACS_FSM_WFVLDCLR 
WACS_INIT_DONE 
WACS_SYNC_IDLE 
WACS_SYNC_BUSY 

Definition at line 103 of file pmic_wrap_common.h.

◆ anonymous enum

anonymous enum
Enumerator
E_PWR_INVALID_ARG 
E_PWR_INVALID_RW 
E_PWR_INVALID_ADDR 
E_PWR_INVALID_WDAT 
E_PWR_INVALID_OP_MANUAL 
E_PWR_NOT_IDLE_STATE 
E_PWR_NOT_INIT_DONE 
E_PWR_NOT_INIT_DONE_READ 
E_PWR_WAIT_IDLE_TIMEOUT 
E_PWR_WAIT_IDLE_TIMEOUT_READ 
E_PWR_INIT_SIDLY_FAIL 
E_PWR_RESET_TIMEOUT 
E_PWR_TIMEOUT 
E_PWR_INIT_RESET_SPI 
E_PWR_INIT_SIDLY 
E_PWR_INIT_REG_CLOCK 
E_PWR_INIT_ENABLE_PMIC 
E_PWR_INIT_DIO 
E_PWR_INIT_CIPHER 
E_PWR_INIT_WRITE_TEST 
E_PWR_INIT_ENABLE_CRC 
E_PWR_INIT_ENABLE_DEWRAP 
E_PWR_INIT_ENABLE_EVENT 
E_PWR_READ_TEST_FAIL 
E_PWR_WRITE_TEST_FAIL 
E_PWR_SWITCH_DIO 

Definition at line 115 of file pmic_wrap_common.h.

Function Documentation

◆ pwrap_init()

◆ pwrap_read()

static s32 pwrap_read ( u16  addr,
u16 rdata 
)
inlinestatic

Definition at line 15 of file pmic_wrap_common.h.

References addr, and pwrap_wacs2().

Referenced by mt6391_gpio_get(), pwrap_read_field(), pwrap_write_field(), and rtc_read().

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

◆ pwrap_read_field()

static u16 pwrap_read_field ( u16  reg,
u16  mask,
u16  shift 
)
inlinestatic

◆ pwrap_read_nochk()

static s32 pwrap_read_nochk ( u16  addr,
u16 rdata 
)
inlinestatic

Definition at line 49 of file pmic_wrap_common.h.

References addr, and pwrap_wacs2().

Referenced by pwrap_init(), pwrap_init_dio(), pwrap_init_reg_clock(), and pwrap_init_sistrobe().

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

◆ pwrap_reset_spislv()

◆ pwrap_wacs2()

◆ pwrap_write()

static s32 pwrap_write ( u16  addr,
u16  wdata 
)
inlinestatic

Definition at line 20 of file pmic_wrap_common.h.

References addr, and pwrap_wacs2().

Referenced by mt6391_gpio_set(), mt6391_gpio_set_dir(), mt6391_gpio_set_pull(), pwrap_write_field(), rtc_write(), and wfc_id().

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

◆ pwrap_write_field()

◆ pwrap_write_nochk()

static s32 pwrap_write_nochk ( u16  addr,
u16  wdata 
)
inlinestatic

Definition at line 54 of file pmic_wrap_common.h.

References addr, and pwrap_wacs2().

Referenced by pwrap_init(), pwrap_init_dio(), pwrap_init_reg_clock(), pwrap_init_sistrobe(), pwrap_init_spislv(), pwrap_initstaupd(), and pwrap_lock_spislvreg().

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

◆ wait_for_cipher_ready()

static u32 wait_for_cipher_ready ( u32  x)
inlinestatic

Definition at line 165 of file pmic_wrap_common.h.

References x.

◆ wait_for_fsm_vldclr()

static u32 wait_for_fsm_vldclr ( u32  x)
inlinestatic

Definition at line 146 of file pmic_wrap_common.h.

References RDATA_WACS_FSM_MASK, RDATA_WACS_FSM_SHIFT, WACS_FSM_WFVLDCLR, and x.

Referenced by pwrap_wacs2().

Here is the caller graph for this function:

◆ wait_for_idle_and_sync()

static u32 wait_for_idle_and_sync ( u32  x)
inlinestatic

Definition at line 158 of file pmic_wrap_common.h.

References RDATA_SYNC_IDLE_MASK, RDATA_SYNC_IDLE_SHIFT, RDATA_WACS_FSM_MASK, RDATA_WACS_FSM_SHIFT, WACS_FSM_IDLE, WACS_SYNC_IDLE, and x.

Referenced by pwrap_init_dio().

Here is the caller graph for this function:

◆ wait_for_state_idle()

u32 wait_for_state_idle ( u32  timeout_us,
void wacs_register,
void wacs_vldclr_register,
u32 read_reg 
)

Definition at line 7 of file pmic_wrap.c.

References E_PWR_WAIT_IDLE_TIMEOUT, pwrap_err, RDATA_WACS_FSM_MASK, RDATA_WACS_FSM_SHIFT, read32(), read_reg(), stopwatch_expired(), stopwatch_init_usecs_expire(), WACS_FSM_IDLE, WACS_FSM_REQ, WACS_FSM_WFDLE, WACS_FSM_WFVLDCLR, and write32().

Referenced by pwrap_wacs2().

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

◆ wait_for_state_ready()

u32 wait_for_state_ready ( loop_condition_fp  fp,
u32  timeout_us,
void wacs_register,
u32 read_reg 
)

Definition at line 46 of file pmic_wrap.c.

References E_PWR_WAIT_IDLE_TIMEOUT, pwrap_err, read32(), read_reg(), stopwatch_expired(), and stopwatch_init_usecs_expire().

Referenced by pwrap_init_dio(), pwrap_reset_spislv(), and pwrap_wacs2().

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

◆ wait_for_sync()

static u32 wait_for_sync ( u32  x)
inlinestatic

Definition at line 152 of file pmic_wrap_common.h.

References RDATA_SYNC_IDLE_MASK, RDATA_SYNC_IDLE_SHIFT, WACS_SYNC_IDLE, and x.

Referenced by pwrap_reset_spislv().

Here is the caller graph for this function: