coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
edp.c File Reference
#include <device/mmio.h>
#include <console/console.h>
#include <delay.h>
#include <device/device.h>
#include <edid.h>
#include <string.h>
#include <soc/addressmap.h>
#include <soc/display.h>
#include <soc/edp.h>
#include <timer.h>
#include <types.h>
Include dependency graph for edp.c:

Go to the source code of this file.

Macros

#define edp_debug(x...)   do {if (0) printk(BIOS_DEBUG, x); } while (0)
 
#define MAX_CR_LOOP   5
 
#define MAX_EQ_LOOP   5
 
#define DP_LINK_STATUS_SIZE   6
 
#define DP_VOLTAGE_MAX   DP_TRAIN_VOLTAGE_SWING_1200
 
#define DP_PRE_EMPHASIS_MAX   DP_TRAIN_PRE_EMPHASIS_9_5
 

Functions

static void rk_edp_init_refclk (struct rk_edp *edp)
 
static void rk_edp_init_interrupt (struct rk_edp *edp)
 
static void rk_edp_enable_sw_function (struct rk_edp *edp)
 
static int rk_edp_get_pll_lock_status (struct rk_edp *edp)
 
static void rk_edp_init_analog_func (struct rk_edp *edp)
 
static void rk_edp_init_aux (struct rk_edp *edp)
 
static int rk_edp_aux_enable (struct rk_edp *edp)
 
static int rk_edp_is_aux_reply (struct rk_edp *edp)
 
static int rk_edp_start_aux_transaction (struct rk_edp *edp)
 
static int rk_edp_dpcd_transfer (struct rk_edp *edp, unsigned int val_addr, u8 *data, unsigned int length, enum dpcd_request request)
 
static int rk_edp_dpcd_read (struct rk_edp *edp, u32 addr, u8 *values, size_t size)
 
static int rk_edp_dpcd_write (struct rk_edp *edp, u32 addr, u8 *values, size_t size)
 
static int rk_edp_link_power_up (struct rk_edp *edp)
 
static int rk_edp_link_configure (struct rk_edp *edp)
 
static void rk_edp_set_link_training (struct rk_edp *edp, const u8 *training_values)
 
static u8 edp_link_status (const u8 *link_status, int r)
 
static int rk_edp_dpcd_read_link_status (struct rk_edp *edp, u8 *link_status)
 
static u8 edp_get_lane_status (const u8 *link_status, int lane)
 
static int rk_edp_clock_recovery_ok (const u8 *link_status, int lane_count)
 
static int rk_edp_channel_eq_ok (const u8 *link_status, int lane_count)
 
static u8 rk_edp_get_adjust_request_voltage (const u8 *link_status, int lane)
 
static u8 rk_edp_get_adjust_request_pre_emphasis (const u8 *link_status, int lane)
 
static void edp_get_adjust_train (const u8 *link_status, int lane_count, u8 train_set[])
 
static int rk_edp_link_train_cr (struct rk_edp *edp)
 
static int rk_edp_link_train_ce (struct rk_edp *edp)
 
static int rk_edp_init_training (struct rk_edp *edp)
 
static int rk_edp_hw_link_training (struct rk_edp *edp)
 
static int rk_edp_select_i2c_device (struct rk_edp *edp, unsigned int device_addr, unsigned int val_addr)
 
static int rk_edp_read_bytes_from_i2c (struct rk_edp *edp, unsigned int device_addr, unsigned int val_addr, unsigned int count, u8 edid[])
 
static int rk_edp_read_edid (struct rk_edp *edp, struct edid *edid)
 
static int rk_edp_set_link_train (struct rk_edp *edp)
 
static void rk_edp_init_video (struct rk_edp *edp)
 
static void rk_edp_config_video_slave_mode (struct rk_edp *edp)
 
static void rk_edp_set_video_cr_mn (struct rk_edp *edp, enum clock_recovery_m_value_type type, u32 m_value, u32 n_value)
 
static int rk_edp_is_video_stream_clock_on (struct rk_edp *edp)
 
static int rk_edp_is_video_stream_on (struct rk_edp *edp)
 
static int rk_edp_config_video (struct rk_edp *edp)
 
static void rockchip_edp_force_hpd (struct rk_edp *edp)
 
static int rockchip_edp_get_plug_in_status (struct rk_edp *edp)
 
static void rk_edp_wait_hpd (struct rk_edp *edp)
 
int rk_edp_get_edid (struct edid *edid)
 
int rk_edp_prepare (void)
 
int rk_edp_enable (void)
 
void rk_edp_init (void)
 

Variables

static struct rk_edp rk_edp
 
static const char * voltage_names []
 
static const char * pre_emph_names []
 

Macro Definition Documentation

◆ DP_LINK_STATUS_SIZE

#define DP_LINK_STATUS_SIZE   6

Definition at line 21 of file edp.c.

◆ DP_PRE_EMPHASIS_MAX

#define DP_PRE_EMPHASIS_MAX   DP_TRAIN_PRE_EMPHASIS_9_5

Definition at line 31 of file edp.c.

◆ DP_VOLTAGE_MAX

#define DP_VOLTAGE_MAX   DP_TRAIN_VOLTAGE_SWING_1200

Definition at line 30 of file edp.c.

◆ edp_debug

#define edp_debug (   x...)    do {if (0) printk(BIOS_DEBUG, x); } while (0)

Definition at line 15 of file edp.c.

◆ MAX_CR_LOOP

#define MAX_CR_LOOP   5

Definition at line 19 of file edp.c.

◆ MAX_EQ_LOOP

#define MAX_EQ_LOOP   5

Definition at line 20 of file edp.c.

Function Documentation

◆ edp_get_adjust_train()

static void edp_get_adjust_train ( const u8 link_status,
int  lane_count,
u8  train_set[] 
)
static

◆ edp_get_lane_status()

static u8 edp_get_lane_status ( const u8 link_status,
int  lane 
)
static

Definition at line 343 of file edp.c.

References DPCD_LANE0_1_STATUS, edp_link_status(), and s.

Referenced by rk_edp_channel_eq_ok(), and rk_edp_clock_recovery_ok().

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

◆ edp_link_status()

static u8 edp_link_status ( const u8 link_status,
int  r 
)
static

Definition at line 332 of file edp.c.

References DPCD_LANE0_1_STATUS.

Referenced by edp_get_lane_status(), rk_edp_channel_eq_ok(), rk_edp_get_adjust_request_pre_emphasis(), and rk_edp_get_adjust_request_voltage().

Here is the caller graph for this function:

◆ rk_edp_aux_enable()

static int rk_edp_aux_enable ( struct rk_edp edp)
static

Definition at line 138 of file edp.c.

References rk_edp_regs::aux_ch_ctl_2, AUX_EN, read32(), rk_edp::regs, setbits32, stopwatch_expired(), and stopwatch_init_msecs_expire().

Referenced by rk_edp_start_aux_transaction().

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

◆ rk_edp_channel_eq_ok()

static int rk_edp_channel_eq_ok ( const u8 link_status,
int  lane_count 
)
static

Definition at line 365 of file edp.c.

References DP_CHANNEL_EQ_BITS, DP_INTERLANE_ALIGN_DONE, DPCD_LANE_ALIGN_STATUS_UPDATED, edp_get_lane_status(), and edp_link_status().

Referenced by rk_edp_link_train_ce().

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

◆ rk_edp_clock_recovery_ok()

static int rk_edp_clock_recovery_ok ( const u8 link_status,
int  lane_count 
)
static

Definition at line 352 of file edp.c.

References DP_LANE_CR_DONE, and edp_get_lane_status().

Referenced by rk_edp_link_train_cr().

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

◆ rk_edp_config_video()

static int rk_edp_config_video ( struct rk_edp edp)
static

◆ rk_edp_config_video_slave_mode()

static void rk_edp_config_video_slave_mode ( struct rk_edp edp)
static

Definition at line 803 of file edp.c.

References clrbits32, rk_edp_regs::func_en_1, rk_edp::regs, VID_CAP_FUNC_EN_N, and VID_FIFO_FUNC_EN_N.

Referenced by rk_edp_config_video().

Here is the caller graph for this function:

◆ rk_edp_dpcd_read()

static int rk_edp_dpcd_read ( struct rk_edp edp,
u32  addr,
u8 values,
size_t  size 
)
static

Definition at line 271 of file edp.c.

References addr, DPCD_READ, and rk_edp_dpcd_transfer().

Referenced by rk_edp_dpcd_read_link_status(), rk_edp_init_training(), and rk_edp_link_power_up().

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

◆ rk_edp_dpcd_read_link_status()

static int rk_edp_dpcd_read_link_status ( struct rk_edp edp,
u8 link_status 
)
static

Definition at line 337 of file edp.c.

References DP_LINK_STATUS_SIZE, DPCD_LANE0_1_STATUS, and rk_edp_dpcd_read().

Referenced by rk_edp_link_train_ce(), and rk_edp_link_train_cr().

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

◆ rk_edp_dpcd_transfer()

static int rk_edp_dpcd_transfer ( struct rk_edp edp,
unsigned int  val_addr,
u8 data,
unsigned int  length,
enum dpcd_request  request 
)
static

◆ rk_edp_dpcd_write()

static int rk_edp_dpcd_write ( struct rk_edp edp,
u32  addr,
u8 values,
size_t  size 
)
static

Definition at line 277 of file edp.c.

References addr, DPCD_WRITE, and rk_edp_dpcd_transfer().

Referenced by rk_edp_link_configure(), rk_edp_link_power_up(), rk_edp_link_train_ce(), and rk_edp_link_train_cr().

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

◆ rk_edp_enable()

int rk_edp_enable ( void  )

Definition at line 986 of file edp.c.

References rk_edp::regs, rk_edp_is_video_stream_on(), setbits32, rk_edp_regs::video_ctl_1, and VIDEO_EN.

Referenced by rk_display_init().

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

◆ rk_edp_enable_sw_function()

static void rk_edp_enable_sw_function ( struct rk_edp edp)
static

Definition at line 85 of file edp.c.

References clrbits32, rk_edp_regs::func_en_1, rk_edp::regs, and SW_FUNC_EN_N.

Referenced by rk_edp_init().

Here is the caller graph for this function:

◆ rk_edp_get_adjust_request_pre_emphasis()

static u8 rk_edp_get_adjust_request_pre_emphasis ( const u8 link_status,
int  lane 
)
static

Definition at line 395 of file edp.c.

References DP_ADJUST_PRE_EMPHASIS_LANE0_SHIFT, DP_ADJUST_PRE_EMPHASIS_LANE1_SHIFT, DP_TRAIN_PRE_EMPHASIS_SHIFT, DPCD_ADJUST_REQUEST_LANE0_1, edp_link_status(), and s.

Referenced by edp_get_adjust_train().

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

◆ rk_edp_get_adjust_request_voltage()

static u8 rk_edp_get_adjust_request_voltage ( const u8 link_status,
int  lane 
)
static

Definition at line 384 of file edp.c.

References DP_ADJUST_VOLTAGE_SWING_LANE0_SHIFT, DP_ADJUST_VOLTAGE_SWING_LANE1_SHIFT, DP_TRAIN_VOLTAGE_SWING_SHIFT, DPCD_ADJUST_REQUEST_LANE0_1, edp_link_status(), and s.

Referenced by edp_get_adjust_train().

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

◆ rk_edp_get_edid()

int rk_edp_get_edid ( struct edid edid)

Definition at line 954 of file edp.c.

References rk_edp_read_edid().

Referenced by rk_display_init().

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

◆ rk_edp_get_pll_lock_status()

static int rk_edp_get_pll_lock_status ( struct rk_edp edp)
static

Definition at line 90 of file edp.c.

References rk_edp_regs::dp_debug_ctl, DP_PLL_LOCKED, DP_PLL_UNLOCKED, PLL_LOCK, read32(), rk_edp::regs, and val.

Referenced by rk_edp_config_video(), and rk_edp_init_analog_func().

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

◆ rk_edp_hw_link_training()

static int rk_edp_hw_link_training ( struct rk_edp edp)
static

◆ rk_edp_init()

void rk_edp_init ( void  )

Definition at line 994 of file edp.c.

References EDP_BASE, rk_edp::regs, rk_edp_enable_sw_function(), rk_edp_init_analog_func(), rk_edp_init_aux(), rk_edp_init_interrupt(), rk_edp_init_refclk(), and rk_edp_wait_hpd().

Referenced by rk_display_init().

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

◆ rk_edp_init_analog_func()

◆ rk_edp_init_aux()

static void rk_edp_init_aux ( struct rk_edp edp)
static

Definition at line 123 of file edp.c.

References rk_edp_regs::aux_ch_defer_dtl, AUX_FUNC_EN_N, clrbits32, DEFER_COUNT, DEFER_CTRL_EN, rk_edp_regs::dp_int_sta, rk_edp_regs::func_en_2, rk_edp::regs, setbits32, and write32().

Referenced by rk_edp_init().

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

◆ rk_edp_init_interrupt()

◆ rk_edp_init_refclk()

◆ rk_edp_init_training()

static int rk_edp_init_training ( struct rk_edp edp)
static

Definition at line 569 of file edp.c.

References DP_MAX_LANE_COUNT_MASK, DPCD_DPCD_REV, edp_debug, link_train::lane_count, link_train::link_rate, LINK_RATE_1_62GBPS, LINK_RATE_2_70GBPS, rk_edp::link_train, link_train::revision, rk_edp_dpcd_read(), rk_edp_link_configure(), and rk_edp_link_power_up().

Referenced by rk_edp_set_link_train().

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

◆ rk_edp_init_video()

static void rk_edp_init_video ( struct rk_edp edp)
static

Definition at line 789 of file edp.c.

References CHA_CRI, CHA_CTRL, rk_edp_regs::common_int_sta_1, rk_edp::regs, rk_edp_regs::sys_ctl_2, val, VID_CLK_CHG, VID_FORMAT_CHG, VID_HRES_TH, VID_VRES_TH, rk_edp_regs::video_ctl_8, VSYNC_DET, and write32().

Referenced by rk_edp_prepare().

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

◆ rk_edp_is_aux_reply()

static int rk_edp_is_aux_reply ( struct rk_edp edp)
static

Definition at line 153 of file edp.c.

References rk_edp_regs::dp_int_sta, read32(), rk_edp::regs, RPLY_RECEIV, stopwatch_expired(), stopwatch_init_msecs_expire(), and write32().

Referenced by rk_edp_start_aux_transaction().

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

◆ rk_edp_is_video_stream_clock_on()

static int rk_edp_is_video_stream_clock_on ( struct rk_edp edp)
static

Definition at line 840 of file edp.c.

References CHA_STA, DET_STA, read32(), rk_edp::regs, stopwatch_expired(), stopwatch_init_msecs_expire(), rk_edp_regs::sys_ctl_1, rk_edp_regs::sys_ctl_2, val, and write32().

Referenced by rk_edp_config_video().

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

◆ rk_edp_is_video_stream_on()

static int rk_edp_is_video_stream_on ( struct rk_edp edp)
static

Definition at line 867 of file edp.c.

References read32(), rk_edp::regs, stopwatch_expired(), stopwatch_init_msecs_expire(), STRM_VALID, rk_edp_regs::sys_ctl_3, val, and write32().

Referenced by rk_edp_enable().

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

◆ rk_edp_link_configure()

static int rk_edp_link_configure ( struct rk_edp edp)
static

Definition at line 313 of file edp.c.

References DPCD_LINK_BW_SET, link_train::lane_count, link_train::link_rate, rk_edp::link_train, and rk_edp_dpcd_write().

Referenced by rk_edp_init_training().

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

◆ rk_edp_link_power_up()

static int rk_edp_link_power_up ( struct rk_edp edp)
static

Definition at line 283 of file edp.c.

References DP_SET_POWER_D0, DP_SET_POWER_MASK, DPCD_LINK_POWER_STATE, rk_edp::link_train, mdelay(), link_train::revision, rk_edp_dpcd_read(), rk_edp_dpcd_write(), and value.

Referenced by rk_edp_init_training().

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

◆ rk_edp_link_train_ce()

◆ rk_edp_link_train_cr()

◆ rk_edp_prepare()

int rk_edp_prepare ( void  )

Definition at line 969 of file edp.c.

References BIOS_ERR, printk, rk_edp_config_video(), rk_edp_init_video(), and rk_edp_set_link_train().

Referenced by rk_display_init().

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

◆ rk_edp_read_bytes_from_i2c()

static int rk_edp_read_bytes_from_i2c ( struct rk_edp edp,
unsigned int  device_addr,
unsigned int  val_addr,
unsigned int  count,
u8  edid[] 
)
static

◆ rk_edp_read_edid()

static int rk_edp_read_edid ( struct rk_edp edp,
struct edid edid 
)
static

Definition at line 738 of file edp.c.

References BIOS_ERR, buf, decode_edid(), EDID_ADDR, EDID_CONFORMANT, EDID_EXTENSION_FLAG, EDID_HEADER, EDID_LENGTH, edp_debug, printk, and rk_edp_read_bytes_from_i2c().

Referenced by rk_edp_get_edid().

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

◆ rk_edp_select_i2c_device()

static int rk_edp_select_i2c_device ( struct rk_edp edp,
unsigned int  device_addr,
unsigned int  val_addr 
)
static

◆ rk_edp_set_link_train()

static int rk_edp_set_link_train ( struct rk_edp edp)
static

Definition at line 775 of file edp.c.

References BIOS_ERR, printk, rk_edp_hw_link_training(), and rk_edp_init_training().

Referenced by rk_edp_prepare().

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

◆ rk_edp_set_link_training()

static void rk_edp_set_link_training ( struct rk_edp edp,
const u8 training_values 
)
static

Definition at line 323 of file edp.c.

References link_train::lane_count, rk_edp::link_train, rk_edp_regs::ln_link_trn_ctl, rk_edp::regs, and write32().

Referenced by rk_edp_link_train_ce(), and rk_edp_link_train_cr().

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

◆ rk_edp_set_video_cr_mn()

static void rk_edp_set_video_cr_mn ( struct rk_edp edp,
enum clock_recovery_m_value_type  type,
u32  m_value,
u32  n_value 
)
static

Definition at line 809 of file edp.c.

References clrbits32, FIX_M_VID, rk_edp_regs::m_vid_0, rk_edp_regs::m_vid_1, rk_edp_regs::m_vid_2, rk_edp_regs::n_vid_0, rk_edp_regs::n_vid_1, rk_edp_regs::n_vid_2, REGISTER_M, rk_edp::regs, setbits32, rk_edp_regs::sys_ctl_4, type, val, and write32().

Referenced by rk_edp_config_video().

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

◆ rk_edp_start_aux_transaction()

static int rk_edp_start_aux_transaction ( struct rk_edp edp)
static

Definition at line 169 of file edp.c.

References AUX_ERR, AUX_STATUS_MASK, rk_edp_regs::dp_int_sta, edp_debug, read32(), rk_edp::regs, rk_edp_aux_enable(), rk_edp_is_aux_reply(), val, and write32().

Referenced by rk_edp_dpcd_transfer(), rk_edp_read_bytes_from_i2c(), and rk_edp_select_i2c_device().

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

◆ rk_edp_wait_hpd()

static void rk_edp_wait_hpd ( struct rk_edp edp)
static

Definition at line 939 of file edp.c.

References BIOS_DEBUG, printk, rockchip_edp_force_hpd(), rockchip_edp_get_plug_in_status(), stopwatch_expired(), stopwatch_init_msecs_expire(), and udelay().

Referenced by rk_edp_init().

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

◆ rockchip_edp_force_hpd()

static void rockchip_edp_force_hpd ( struct rk_edp edp)
static

Definition at line 911 of file edp.c.

References F_HPD, HPD_CTRL, read32(), rk_edp::regs, rk_edp_regs::sys_ctl_3, val, and write32().

Referenced by rk_edp_wait_hpd().

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

◆ rockchip_edp_get_plug_in_status()

static int rockchip_edp_get_plug_in_status ( struct rk_edp edp)
static

Definition at line 920 of file edp.c.

References HPD_STATUS, read32(), rk_edp::regs, rk_edp_regs::sys_ctl_3, and val.

Referenced by rk_edp_wait_hpd().

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

Variable Documentation

◆ pre_emph_names

const char* pre_emph_names[]
static
Initial value:
= {
"0dB", "3.5dB", "6dB", "9.5dB"
}

Definition at line 26 of file edp.c.

Referenced by edp_get_adjust_train().

◆ rk_edp

struct rk_edp rk_edp
static

Definition at line 1 of file edp.c.

◆ voltage_names

const char* voltage_names[]
static
Initial value:
= {
"0.4V", "0.6V", "0.8V", "1.2V"
}

Definition at line 23 of file edp.c.

Referenced by edp_get_adjust_train().