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

Go to the source code of this file.

Functions

static void rk_mipi_dsi_wait_for_two_frames (struct rk_mipi_dsi *dsi, const struct edid *edid)
 
static int max_mbps_to_parameter (unsigned int max_mbps)
 
static void rk_mipi_dsi_phy_write (struct rk_mipi_dsi *dsi, u8 test_code, u8 test_data)
 
static unsigned int bytes_per_ns (struct rk_mipi_dsi *dsi, int ns)
 
static unsigned int bits_per_ns (struct rk_mipi_dsi *dsi, int ns)
 
static int rk_mipi_dsi_wait_phy_lock (struct rk_mipi_dsi *dsi)
 
static int rk_mipi_dsi_phy_init (struct rk_mipi_dsi *dsi)
 
static int mipi_dsi_pixel_format_to_bpp (enum mipi_dsi_pixel_format fmt)
 
static int rk_mipi_dsi_get_lane_bps (struct rk_mipi_dsi *dsi, const struct edid *edid, const struct mipi_panel_data *panel_data)
 
static void rk_mipi_dsi_dpi_config (struct rk_mipi_dsi *dsi)
 
static void rk_mipi_dsi_packet_handler_config (struct rk_mipi_dsi *dsi)
 
static void rk_mipi_dsi_video_mode_config (struct rk_mipi_dsi *dsi)
 
static void rk_mipi_dsi_video_packet_config (struct rk_mipi_dsi *dsi, const struct edid *edid, const struct mipi_panel_data *panel_data)
 
static void rk_mipi_dsi_command_mode_config (struct rk_mipi_dsi *dsi)
 
static u32 rk_mipi_dsi_get_hcomponent_lbcc (struct rk_mipi_dsi *dsi, u32 hcomponent, const struct edid *edid)
 
static void rk_mipi_dsi_line_timer_config (struct rk_mipi_dsi *dsi, const struct edid *edid)
 
static void rk_mipi_dsi_vertical_timing_config (struct rk_mipi_dsi *dsi, const struct edid *edid)
 
static void rk_mipi_dsi_dphy_timing_config (struct rk_mipi_dsi *dsi)
 
static void rk_mipi_dsi_clear_err (struct rk_mipi_dsi *dsi)
 
static void rk_mipi_dsi_dphy_interface_config (struct rk_mipi_dsi *dsi)
 
static void rk_mipi_dsi_set_mode (struct rk_mipi_dsi *dsi, enum rk_mipi_dsi_mode mode)
 
static void rk_mipi_dsi_init (struct rk_mipi_dsi *dsi)
 
static void rk_mipi_message_config (struct rk_mipi_dsi *dsi)
 
static int rk_mipi_dsi_check_fifo (struct rk_mipi_dsi *dsi, u32 flag)
 
static int rk_mipi_dsi_gen_pkt_hdr_write (struct rk_mipi_dsi *dsi, u32 hdr_val)
 
static int rk_mipi_dsi_dcs_cmd (struct rk_mipi_dsi *dsi, u8 cmd)
 
static int rk_mipi_dsi_dci_long_write (struct rk_mipi_dsi *dsi, char *data, u32 len)
 
static int rk_mipi_dsi_write (struct rk_mipi_dsi *dsi, char *data, int len)
 
static void rk_mipi_enable (struct rk_mipi_dsi *dsi, const struct edid *edid, const struct mipi_panel_data *panel_data)
 
void rk_mipi_prepare (const struct edid *edid, const struct mipi_panel_data *panel_data)
 

Variables

static struct rk_mipi_dsi rk_mipi [2]
 
static const struct dphy_pll_parameter_map dppa_map []
 

Function Documentation

◆ bits_per_ns()

static unsigned int bits_per_ns ( struct rk_mipi_dsi dsi,
int  ns 
)
inlinestatic

Definition at line 123 of file mipi.c.

References DIV_ROUND_UP, rk_mipi_dsi::lane_bps, and NSECS_PER_SEC.

Referenced by rk_mipi_dsi_phy_init().

Here is the caller graph for this function:

◆ bytes_per_ns()

static unsigned int bytes_per_ns ( struct rk_mipi_dsi dsi,
int  ns 
)
inlinestatic

Definition at line 117 of file mipi.c.

References DIV_ROUND_UP, rk_mipi_dsi::lane_bps, and NSECS_PER_SEC.

Referenced by rk_mipi_dsi_phy_init().

Here is the caller graph for this function:

◆ max_mbps_to_parameter()

static int max_mbps_to_parameter ( unsigned int  max_mbps)
static

Definition at line 79 of file mipi.c.

References ARRAY_SIZE, dppa_map, and dphy_pll_parameter_map::max_mbps.

Referenced by rk_mipi_dsi_phy_init().

Here is the caller graph for this function:

◆ mipi_dsi_pixel_format_to_bpp()

static int mipi_dsi_pixel_format_to_bpp ( enum mipi_dsi_pixel_format  fmt)
inlinestatic

Definition at line 257 of file mipi.c.

References MIPI_DSI_FMT_RGB565, MIPI_DSI_FMT_RGB666, MIPI_DSI_FMT_RGB666_PACKED, and MIPI_DSI_FMT_RGB888.

Referenced by rk_mipi_dsi_get_lane_bps().

Here is the caller graph for this function:

◆ rk_mipi_dsi_check_fifo()

static int rk_mipi_dsi_check_fifo ( struct rk_mipi_dsi dsi,
u32  flag 
)
static

Definition at line 537 of file mipi.c.

References rk_mipi_regs::dsi_cmd_pkt_status, rk_mipi_dsi::mipi_regs, read32(), stopwatch_expired(), stopwatch_init_msecs_expire(), and val.

Referenced by rk_mipi_dsi_dci_long_write(), and rk_mipi_dsi_gen_pkt_hdr_write().

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

◆ rk_mipi_dsi_clear_err()

static void rk_mipi_dsi_clear_err ( struct rk_mipi_dsi dsi)
static

Definition at line 482 of file mipi.c.

References rk_mipi_regs::dsi_int_msk0, rk_mipi_regs::dsi_int_msk1, rk_mipi_regs::dsi_int_st0, rk_mipi_regs::dsi_int_st1, rk_mipi_dsi::mipi_regs, read32(), and write32().

Referenced by rk_mipi_enable().

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

◆ rk_mipi_dsi_command_mode_config()

static void rk_mipi_dsi_command_mode_config ( struct rk_mipi_dsi dsi)
static

Definition at line 411 of file mipi.c.

References CMD_MODE_ALL_LP, rk_mipi_regs::dsi_bta_to_cnt, rk_mipi_regs::dsi_cmd_mode_cfg, rk_mipi_regs::dsi_mode_cfg, rk_mipi_regs::dsi_to_cnt_cfg, ENABLE_CMD_MODE, HSTX_TO_CNT, LPRX_TO_CNT, rk_mipi_dsi::mipi_regs, and write32().

Referenced by rk_mipi_enable().

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

◆ rk_mipi_dsi_dci_long_write()

static int rk_mipi_dsi_dci_long_write ( struct rk_mipi_dsi dsi,
char *  data,
u32  len 
)
static

Definition at line 588 of file mipi.c.

References BIOS_ERR, rk_mipi_regs::dsi_gen_pld_data, GEN_PLD_W_FULL, memcpy(), rk_mipi_dsi::mipi_regs, printk, rk_mipi_dsi_check_fifo(), and write32().

Referenced by rk_mipi_dsi_write().

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

◆ rk_mipi_dsi_dcs_cmd()

static int rk_mipi_dsi_dcs_cmd ( struct rk_mipi_dsi dsi,
u8  cmd 
)
static

Definition at line 577 of file mipi.c.

References GEN_HDATA, GEN_HTYPE, MIPI_DSI_DCS_SHORT_WRITE, rk_mipi_dsi_gen_pkt_hdr_write(), rk_mipi_message_config(), and val.

Referenced by rk_mipi_prepare().

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

◆ rk_mipi_dsi_dphy_interface_config()

static void rk_mipi_dsi_dphy_interface_config ( struct rk_mipi_dsi dsi)
static

Definition at line 490 of file mipi.c.

References rk_mipi_regs::dsi_phy_if_cfg, rk_mipi_dsi::lanes, rk_mipi_dsi::mipi_regs, N_LANES, PHY_STOP_WAIT_TIME, and write32().

Referenced by rk_mipi_enable().

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

◆ rk_mipi_dsi_dphy_timing_config()

static void rk_mipi_dsi_dphy_timing_config ( struct rk_mipi_dsi dsi)
static

Definition at line 468 of file mipi.c.

References rk_mipi_regs::dsi_phy_tmr_cfg, rk_mipi_regs::dsi_phy_tmr_lpclk_cfg, MAX_RD_TIME, rk_mipi_dsi::mipi_regs, PHY_CLKHS2LP_TIME, PHY_CLKLP2HS_TIME, PHY_HS2LP_TIME, PHY_LP2HS_TIME, and write32().

Referenced by rk_mipi_enable().

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

◆ rk_mipi_dsi_dpi_config()

◆ rk_mipi_dsi_gen_pkt_hdr_write()

static int rk_mipi_dsi_gen_pkt_hdr_write ( struct rk_mipi_dsi dsi,
u32  hdr_val 
)
static

◆ rk_mipi_dsi_get_hcomponent_lbcc()

static u32 rk_mipi_dsi_get_hcomponent_lbcc ( struct rk_mipi_dsi dsi,
u32  hcomponent,
const struct edid edid 
)
static

Definition at line 421 of file mipi.c.

References DIV_ROUND_UP, rk_mipi_dsi::lane_bps, edid::mode, MSECS_PER_SEC, and edid_mode::pixel_clock.

Referenced by rk_mipi_dsi_line_timer_config().

Here is the caller graph for this function:

◆ rk_mipi_dsi_get_lane_bps()

static int rk_mipi_dsi_get_lane_bps ( struct rk_mipi_dsi dsi,
const struct edid edid,
const struct mipi_panel_data panel_data 
)
static

◆ rk_mipi_dsi_init()

static void rk_mipi_dsi_init ( struct rk_mipi_dsi dsi)
static

◆ rk_mipi_dsi_line_timer_config()

static void rk_mipi_dsi_line_timer_config ( struct rk_mipi_dsi dsi,
const struct edid edid 
)
static

Definition at line 434 of file mipi.c.

References rk_mipi_regs::dsi_vid_hbp_time, rk_mipi_regs::dsi_vid_hline_time, rk_mipi_regs::dsi_vid_hsa_time, edid_mode::ha, edid_mode::hbl, edid_mode::hso, edid_mode::hspw, htotal, rk_mipi_dsi::mipi_regs, edid::mode, rk_mipi_dsi_get_hcomponent_lbcc(), and write32().

Referenced by rk_mipi_enable().

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

◆ rk_mipi_dsi_packet_handler_config()

static void rk_mipi_dsi_packet_handler_config ( struct rk_mipi_dsi dsi)
static

Definition at line 385 of file mipi.c.

References rk_mipi_regs::dsi_pckhdl_cfg, EN_BTA, EN_CRC_RX, EN_ECC_RX, rk_mipi_dsi::mipi_regs, and write32().

Referenced by rk_mipi_enable().

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

◆ rk_mipi_dsi_phy_init()

static int rk_mipi_dsi_phy_init ( struct rk_mipi_dsi dsi)
static

Definition at line 143 of file mipi.c.

References AFE_BIAS_BANDGAP_ANALOG_PROGRAMMABILITY, BANDGAP_96_10, BANDGAP_AND_BIAS_CONTROL, BANDGAP_ON, BANDGAP_SEL, BIAS_BLOCK_ON, BIASEXTR_127_7, BIASEXTR_SEL, BIOS_DEBUG, BIOS_ERR, BIT, bits_per_ns(), BYPASS_VCO_RANGE, bytes_per_ns(), CP_CURRENT_SEL, CP_PROGRAM_EN, DIV_ROUND_UP, dppa_map, rk_mipi_regs::dsi_phy_rstz, rk_mipi_regs::dsi_phy_status, rk_mipi_regs::dsi_phy_tst_ctrl0, rk_mipi_dsi::feedback_div, HIGH_PROGRAM_EN, HS_RX_CONTROL_OF_LANE_0, HS_TX_CLOCK_LANE_EXIT_STATE_TIME_CONTROL, HS_TX_CLOCK_LANE_HS_ZERO_STATE_TIME_CONTROL, HS_TX_CLOCK_LANE_POST_TIME_CONTROL, HS_TX_CLOCK_LANE_PREPARE_STATE_TIME_CONTROL, HS_TX_CLOCK_LANE_REQUEST_STATE_TIME_CONTROL, HS_TX_CLOCK_LANE_TRAIL_STATE_TIME_CONTROL, HS_TX_DATA_LANE_EXIT_STATE_TIME_CONTROL, HS_TX_DATA_LANE_HS_ZERO_STATE_TIME_CONTROL, HS_TX_DATA_LANE_PREPARE_STATE_TIME_CONTROL, HS_TX_DATA_LANE_REQUEST_STATE_TIME_CONTROL, HS_TX_DATA_LANE_TRAIL_STATE_TIME_CONTROL, HSFREQRANGE_SEL, rk_mipi_dsi::input_div, INPUT_DIVIDER, INTERNAL_REG_CURRENT, rk_mipi_dsi::lane_bps, LEVEL_SHIFTERS_ON, LOOP_DIV_HIGH_SEL, LOOP_DIV_LOW_SEL, LOW_PROGRAM_EN, LPF_PROGRAM_EN, LPF_RESISTORS_SEL, max_mbps_to_parameter(), rk_mipi_dsi::mipi_regs, PHY_ENABLECLK, PHY_ENFORCEPLL, PHY_TESTCLR, PHY_UNRSTZ, PHY_UNSHUTDOWNZ, PHY_UNTESTCLR, PLL_BIAS_CUR_SEL_CAP_VCO_CONTROL, PLL_CP_CONTROL_PLL_LOCK_BYPASS, PLL_INPUT_AND_LOOP_DIVIDER_RATIOS_CONTROL, PLL_INPUT_DIV_EN, PLL_INPUT_DIVIDER_RATIO, PLL_LOOP_DIV_EN, PLL_LOOP_DIVIDER_RATIO, PLL_LPF_AND_CP_CONTROL, POWER_CONTROL, POWER_MANAGE, printk, read32(), REF_BIAS_CUR_SEL, rk_mipi_dsi_phy_write(), rk_mipi_dsi_wait_phy_lock(), SETRD_MAX, STOP_STATE_CLK_LANE, stopwatch_expired(), stopwatch_init_msecs_expire(), TER_CAL_DONE, TER_RESISTOR_HIGH, TER_RESISTOR_LOW, TER_RESISTORS_ON, TERMINATION_RESISTER_CONTROL, THS_PRE_PROGRAM_EN, THS_ZERO_PROGRAM_EN, TLP_PROGRAM_EN, USECS_PER_SEC, val, VCO_IN_CAP_CON_LOW, VCO_RANGE_CON_SEL, and write32().

Referenced by rk_mipi_enable().

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

◆ rk_mipi_dsi_phy_write()

static void rk_mipi_dsi_phy_write ( struct rk_mipi_dsi dsi,
u8  test_code,
u8  test_data 
)
static

Definition at line 91 of file mipi.c.

References rk_mipi_regs::dsi_phy_tst_ctrl0, rk_mipi_regs::dsi_phy_tst_ctrl1, rk_mipi_dsi::mipi_regs, PHY_TESTCLK, PHY_TESTDIN, PHY_TESTDOUT, PHY_TESTEN, PHY_UNTESTCLK, PHY_UNTESTCLR, PHY_UNTESTEN, and write32().

Referenced by rk_mipi_dsi_phy_init().

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

◆ rk_mipi_dsi_set_mode()

static void rk_mipi_dsi_set_mode ( struct rk_mipi_dsi dsi,
enum rk_mipi_dsi_mode  mode 
)
static

Definition at line 496 of file mipi.c.

References rk_mipi_regs::dsi_lpclk_ctrl, rk_mipi_regs::dsi_mode_cfg, rk_mipi_regs::dsi_pwr_up, ENABLE_CMD_MODE, ENABLE_VIDEO_MODE, MIPI_DSI_CMD_MODE, rk_mipi_dsi::mipi_regs, PHY_TXREQUESTCLKHS, POWERUP, RESET, rk_mipi_dsi_video_mode_config(), and write32().

Referenced by rk_mipi_enable(), and rk_mipi_prepare().

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

◆ rk_mipi_dsi_vertical_timing_config()

static void rk_mipi_dsi_vertical_timing_config ( struct rk_mipi_dsi dsi,
const struct edid edid 
)
static

Definition at line 452 of file mipi.c.

References rk_mipi_regs::dsi_vid_vactive_lines, rk_mipi_regs::dsi_vid_vbp_lines, rk_mipi_regs::dsi_vid_vfp_lines, rk_mipi_regs::dsi_vid_vsa_lines, rk_mipi_dsi::mipi_regs, edid::mode, edid_mode::va, edid_mode::vbl, edid_mode::vso, edid_mode::vspw, and write32().

Referenced by rk_mipi_enable().

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

◆ rk_mipi_dsi_video_mode_config()

static void rk_mipi_dsi_video_mode_config ( struct rk_mipi_dsi dsi)
static

Definition at line 391 of file mipi.c.

References rk_mipi_regs::dsi_vid_mode_cfg, ENABLE_LOW_POWER, rk_mipi_dsi::mipi_regs, VID_MODE_TYPE_BURST_SYNC_PULSES, and write32().

Referenced by rk_mipi_dsi_set_mode(), and rk_mipi_enable().

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

◆ rk_mipi_dsi_video_packet_config()

static void rk_mipi_dsi_video_packet_config ( struct rk_mipi_dsi dsi,
const struct edid edid,
const struct mipi_panel_data panel_data 
)
static

Definition at line 397 of file mipi.c.

References rk_mipi_regs::dsi_vid_pkt_size, edid_mode::ha, mipi_panel_data::mipi_num, rk_mipi_dsi::mipi_regs, edid::mode, VID_PKT_SIZE, and write32().

Referenced by rk_mipi_enable().

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

◆ rk_mipi_dsi_wait_for_two_frames()

static void rk_mipi_dsi_wait_for_two_frames ( struct rk_mipi_dsi dsi,
const struct edid edid 
)
static

Definition at line 27 of file mipi.c.

Referenced by rk_mipi_enable().

Here is the caller graph for this function:

◆ rk_mipi_dsi_wait_phy_lock()

static int rk_mipi_dsi_wait_phy_lock ( struct rk_mipi_dsi dsi)
static

Definition at line 128 of file mipi.c.

References rk_mipi_regs::dsi_phy_status, LOCK, rk_mipi_dsi::mipi_regs, read32(), stopwatch_expired(), stopwatch_init_msecs_expire(), and val.

Referenced by rk_mipi_dsi_phy_init().

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

◆ rk_mipi_dsi_write()

static int rk_mipi_dsi_write ( struct rk_mipi_dsi dsi,
char *  data,
int  len 
)
static

Definition at line 617 of file mipi.c.

References BIOS_ERR, buf, die(), GEN_HDATA, GEN_HTYPE, MIPI_DSI_DCS_LONG_WRITE, MIPI_DSI_DCS_SHORT_WRITE, MIPI_DSI_DCS_SHORT_WRITE_PARAM, printk, rk_mipi_dsi_dci_long_write(), rk_mipi_dsi_gen_pkt_hdr_write(), rk_mipi_message_config(), and val.

Referenced by rk_mipi_prepare().

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

◆ rk_mipi_enable()

◆ rk_mipi_message_config()

static void rk_mipi_message_config ( struct rk_mipi_dsi dsi)
static

Definition at line 531 of file mipi.c.

References CMD_MODE_ALL_LP, rk_mipi_regs::dsi_cmd_mode_cfg, rk_mipi_regs::dsi_lpclk_ctrl, rk_mipi_dsi::mipi_regs, and write32().

Referenced by rk_mipi_dsi_dcs_cmd(), and rk_mipi_dsi_write().

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

◆ rk_mipi_prepare()

Variable Documentation

◆ dppa_map

const struct dphy_pll_parameter_map dppa_map[]
static

Definition at line 27 of file mipi.c.

Referenced by max_mbps_to_parameter(), rk_mipi_dsi_get_lane_bps(), and rk_mipi_dsi_phy_init().

◆ rk_mipi

struct rk_mipi_dsi rk_mipi[2]
static
Initial value:
= {
{ .mipi_regs = (void *)MIPI0_BASE},
{ .mipi_regs = (void *)MIPI1_BASE}
}
#define MIPI0_BASE
Definition: addressmap.h:49
#define MIPI1_BASE
Definition: addressmap.h:50

Definition at line 1 of file mipi.c.

Referenced by rk_mipi_prepare().