coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
rk808.c File Reference
#include <assert.h>
#include <commonlib/bsd/bcd.h>
#include <console/console.h>
#include <delay.h>
#include <device/i2c_simple.h>
#include <rtc.h>
#include <soc/rk808.h>
#include <stdint.h>
Include dependency graph for rk808.c:

Go to the source code of this file.

Macros

#define RK808_ADDR   0x1b
 
#define DCDC_EN   0x23
 
#define LDO_EN   0x24
 
#define BUCK1SEL   0x2f
 
#define BUCK4SEL   0x38
 
#define LDO_ONSEL(i)   (0x39 + 2 * i)
 
#define LDO_SLPSEL(i)   (0x3a + 2 * i)
 
#define RTC_SECOND   0x00
 
#define RTC_MINUTE   0x01
 
#define RTC_HOUR   0x02
 
#define RTC_DAY   0x03
 
#define RTC_MONTH   0x04
 
#define RTC_YEAR   0x05
 
#define RTC_WEEKS   0x06
 
#define RTC_CTRL   0x10
 
#define RTC_STATUS   0x11
 
#define RTC_CTRL_STOP_RTC   (1 << 0)
 
#define RTC_CTRL_GET_TIME   (1 << 6)
 
#define RTC_CTRL_RTC_READSEL   (1 << 7)
 
#define DCDC_UV_ACT   0x28
 
#define DCDC_ILMAX   0x90
 

Functions

static int rk808_read (uint8_t reg, uint8_t *value)
 
static int rk808_write (uint8_t reg, uint8_t value)
 
static void rk808_clrsetbits (uint8_t reg, uint8_t clr, uint8_t set)
 
void rk808_configure_switch (int sw, int enabled)
 
void rk808_configure_ldo (int ldo, int millivolts)
 
void rk808_configure_buck (int buck, int millivolts)
 
static void rk808rtc_stop (void)
 
static void rk808rtc_start (void)
 
int rtc_set (const struct rtc_time *time)
 
int rtc_get (struct rtc_time *time)
 

Macro Definition Documentation

◆ BUCK1SEL

#define BUCK1SEL   0x2f

Definition at line 20 of file rk808.c.

◆ BUCK4SEL

#define BUCK4SEL   0x38

Definition at line 21 of file rk808.c.

◆ DCDC_EN

#define DCDC_EN   0x23

Definition at line 18 of file rk808.c.

◆ DCDC_ILMAX

#define DCDC_ILMAX   0x90

Definition at line 40 of file rk808.c.

◆ DCDC_UV_ACT

#define DCDC_UV_ACT   0x28

Definition at line 39 of file rk808.c.

◆ LDO_EN

#define LDO_EN   0x24

Definition at line 19 of file rk808.c.

◆ LDO_ONSEL

#define LDO_ONSEL (   i)    (0x39 + 2 * i)

Definition at line 22 of file rk808.c.

◆ LDO_SLPSEL

#define LDO_SLPSEL (   i)    (0x3a + 2 * i)

Definition at line 23 of file rk808.c.

◆ RK808_ADDR

#define RK808_ADDR   0x1b

Definition at line 16 of file rk808.c.

◆ RTC_CTRL

#define RTC_CTRL   0x10

Definition at line 32 of file rk808.c.

◆ RTC_CTRL_GET_TIME

#define RTC_CTRL_GET_TIME   (1 << 6)

Definition at line 36 of file rk808.c.

◆ RTC_CTRL_RTC_READSEL

#define RTC_CTRL_RTC_READSEL   (1 << 7)

Definition at line 37 of file rk808.c.

◆ RTC_CTRL_STOP_RTC

#define RTC_CTRL_STOP_RTC   (1 << 0)

Definition at line 35 of file rk808.c.

◆ RTC_DAY

#define RTC_DAY   0x03

Definition at line 28 of file rk808.c.

◆ RTC_HOUR

#define RTC_HOUR   0x02

Definition at line 27 of file rk808.c.

◆ RTC_MINUTE

#define RTC_MINUTE   0x01

Definition at line 26 of file rk808.c.

◆ RTC_MONTH

#define RTC_MONTH   0x04

Definition at line 29 of file rk808.c.

◆ RTC_SECOND

#define RTC_SECOND   0x00

Definition at line 25 of file rk808.c.

◆ RTC_STATUS

#define RTC_STATUS   0x11

Definition at line 33 of file rk808.c.

◆ RTC_WEEKS

#define RTC_WEEKS   0x06

Definition at line 31 of file rk808.c.

◆ RTC_YEAR

#define RTC_YEAR   0x05

Definition at line 30 of file rk808.c.

Function Documentation

◆ rk808_clrsetbits()

static void rk808_clrsetbits ( uint8_t  reg,
uint8_t  clr,
uint8_t  set 
)
static

Definition at line 52 of file rk808.c.

References BIOS_ERR, printk, rk808_read(), rk808_write(), and value.

Referenced by rk808_configure_buck(), rk808_configure_ldo(), rk808_configure_switch(), rk808rtc_start(), rk808rtc_stop(), and rtc_get().

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

◆ rk808_configure_buck()

void rk808_configure_buck ( int  buck,
int  millivolts 
)

Definition at line 98 of file rk808.c.

References assert, BUCK1SEL, BUCK4SEL, DCDC_EN, DCDC_ILMAX, DCDC_UV_ACT, die(), DIV_ROUND_UP, and rk808_clrsetbits().

Referenced by bootblock_mainboard_init(), and mainboard_init().

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

◆ rk808_configure_ldo()

void rk808_configure_ldo ( int  ldo,
int  millivolts 
)

Definition at line 66 of file rk808.c.

References assert, die(), DIV_ROUND_UP, LDO_EN, LDO_ONSEL, and rk808_clrsetbits().

Referenced by configure_codec(), configure_sdmmc(), configure_vop(), and sdmmc_power_off().

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

◆ rk808_configure_switch()

void rk808_configure_switch ( int  sw,
int  enabled 
)

Definition at line 60 of file rk808.c.

References assert, DCDC_EN, and rk808_clrsetbits().

Referenced by configure_vop().

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

◆ rk808_read()

static int rk808_read ( uint8_t  reg,
uint8_t value 
)
static

Definition at line 42 of file rk808.c.

References i2c_readb(), RK808_ADDR, and value.

Referenced by rk808_clrsetbits(), and rtc_get().

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

◆ rk808_write()

static int rk808_write ( uint8_t  reg,
uint8_t  value 
)
static

Definition at line 47 of file rk808.c.

References i2c_writeb(), RK808_ADDR, and value.

Referenced by rk808_clrsetbits(), and rtc_set().

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

◆ rk808rtc_start()

static void rk808rtc_start ( void  )
static

Definition at line 133 of file rk808.c.

References rk808_clrsetbits(), RTC_CTRL, and RTC_CTRL_STOP_RTC.

Referenced by rtc_set().

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

◆ rk808rtc_stop()

static void rk808rtc_stop ( void  )
static

Definition at line 128 of file rk808.c.

References rk808_clrsetbits(), RTC_CTRL, and RTC_CTRL_STOP_RTC.

Referenced by rtc_set().

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

◆ rtc_get()

◆ rtc_set()

int rtc_set ( const struct rtc_time time)