15 #define HAL_DSI_PHY_PLL_READY_TIMEOUT_MS 150
16 #define HAL_DSI_PHY_REFGEN_TIMEOUT_MS 150
18 #define DSI_MAX_REFRESH_RATE 95
19 #define DSI_MIN_REFRESH_RATE 15
21 #define HAL_DSI_PLL_VCO_MIN_MHZ_2_2_0 1000
23 #define S_DIV_ROUND_UP(n, d) \
24 (((n) >= 0) ? (((n) + (d) - 1) / (d)) : (((n) - (d) + 1) / (d)))
26 #define mult_frac(x, numer, denom)( \
28 typeof(x) quot = (x) / (denom); \
29 typeof(x) rem = (x) % (denom); \
30 (quot * (numer)) + ((rem * (numer)) / (denom)); \
86 s32 min_result,
bool even)
90 v = (tmax - tmin) * percent;
92 if (even && (v & 0x1))
93 return MAX(min_result, v - 1);
95 return MAX(min_result, v);
141 reg_val = ((data_strength_lp_n << 0x4) & 0xf0) |
142 (data_strength_lp_p & 0x0f);
167 reg_val = (strength_override << 0x5) & 0x20;
171 reg_val = ((pemph_bottom << 0x04) & 0xf0) |
182 reg_val = (clk_lane << 0x07) & 0x80;
195 const unsigned long bit_rate =
phy_cfg->desired_bitclk_freq;
205 s32 hb_en, hb_en_ckln;
215 ui =
mult_frac(1000000, coeff, bit_rate / 1000);
220 temp = (95 * coeff) / ui_x8;
224 temp = 300 * coeff - (timing->
clk_prepare << 3) * ui;
226 tmax = (tmin > 255) ? 511 : 255;
230 temp = 105 * coeff + 12 * ui - 20 * coeff;
231 tmax = (temp + 3 * ui) / ui_x8;
236 temp = (85 * coeff + 6 * ui) / ui_x8;
240 temp = 145 * coeff + 10 * ui - (timing->
hs_prepare << 3) * ui;
246 temp = 105 * coeff + 12 * ui - 20 * coeff;
247 tmax = (temp / ui_x8) - 1;
250 temp = 50 * coeff + ((hb_en << 2) - 8) * ui;
257 temp = 50 * coeff + ((hb_en_ckln << 2) - 8) * ui;
260 temp = 60 * coeff + 52 * ui - 43 * ui;
266 temp += (((timing->
clk_zero + 3) << 3) + 11) * ui;
267 temp += hb_en_ckln ? (((timing->
hs_rqst << 3) + 4) * ui) :
268 (((timing->
hs_rqst << 3) + 8) * ui);
284 printk(
BIOS_INFO,
"PHY timings: %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d\n",
300 reg_val = (0x02 << 3) & 0x18;
427 clk_cfg |= ((clk_enable << 0x5) & 0x20);
470 clk_cfg |= ((dsi_clksel) & 0x3);
482 reg_val = (0x01 << 6) | (0x01 << 7);
494 if (
phy_cfg->bits_per_pixel == 18) {
495 switch (
phy_cfg->num_data_lanes) {
508 }
else if ((
phy_cfg->bits_per_pixel == 16) &&
509 (
phy_cfg->num_data_lanes == 3)) {
512 }
else if ((
phy_cfg->bits_per_pixel == 30) &&
513 (
phy_cfg->num_data_lanes == 4)) {
519 phy_cfg->pclk_divnumerator = m_val;
520 phy_cfg->pclk_divdenominator = n_val;
529 div_ctrl = (m_val *
phy_cfg->bits_per_pixel) /
530 (n_val *
phy_cfg->num_data_lanes * 2);
538 bool div_found =
false;
559 m_val =
phy_cfg->pclk_divnumerator;
560 n_val =
phy_cfg->pclk_divdenominator;
568 lut += (lut_max - 1);
573 for (i = lut_max - 1; i >= 0; i--, lut--) {
577 if ((desired_bitclk_hz * fval) > min_vco_freq_hz) {
597 reg_val = (div_ctrl << 0x04) & 0xf0;
609 return (
unsigned long)vco_freq_hz;
625 unsigned long vco_freq_hz;
631 }
else if ((
phy_cfg->bits_per_pixel != 16) &&
632 (
phy_cfg->bits_per_pixel != 18) &&
633 (
phy_cfg->bits_per_pixel != 24)) {
636 }
else if ((
phy_cfg->num_data_lanes == 0) ||
637 (
phy_cfg->num_data_lanes > 4)) {
682 desired_bclk = pixel_clock_in_hz * (
uint64_t)bpp;
683 desired_bclk = desired_bclk/(
uint64_t)(num_lines);
702 phy_cfg.num_data_lanes = num_of_lanes;
725 .clk_div = 1, .source_div = 2},
738 "mdss_clock_configure failed for %u\n",
746 "mdss_clock_enable failed for %u\n",
static void write32(void *addr, uint32_t val)
static uint32_t read32(const void *addr)
void * memset(void *dstpp, int c, size_t len)
#define DIV_ROUND_UP(x, y)
cb_err
coreboot error codes
@ CB_ERR
Generic error code.
@ CB_SUCCESS
Call completed successfully.
#define printk(level,...)
static struct dsi_regs *const dsi0
static enum cb_err dsi_phy_waitforrefgen(void)
static void mdss_dsi_phy_setup(void)
#define HAL_DSI_PHY_REFGEN_TIMEOUT_MS
static void dsi_phy_pll_outputdiv_rate(struct dsi_phy_configtype *pll_cfg)
#define S_DIV_ROUND_UP(n, d)
static struct dsi_phy_divider_lut_entry_type pll_dividerlut_dphy[]
static void dsi_phy_resync_fifo(void)
static void mdss_dsi_calculate_phy_timings(struct msm_dsi_phy_ctrl *timing, struct dsi_phy_configtype *phy_cfg)
static void dsi_phy_mnd_divider(struct dsi_phy_configtype *phy_cfg)
enum cb_err mdss_dsi_phy_10nm_init(struct edid *edid, uint32_t num_of_lanes, uint32_t bpp)
static s32 linear_inter(s32 tmax, s32 tmin, s32 percent, s32 min_result, bool even)
static void dsi_phy_pll_bias_enable(bool enable)
static enum cb_err enable_dsi_clk(void)
static void dsi_phy_toggle_dln3_tx_dctrl(void)
static void mdss_dsi_phy_setup_lanephy(enum dsi_laneid_type lane)
static enum cb_err dsi_phy_pll_lock_detect(void)
static enum cb_err dsi_phy_pll_calcandcommit(struct dsi_phy_configtype *phy_cfg)
static enum cb_err mdss_dsi_phy_commit(void)
static uint32_t dsi_phy_dsiclk_divider(struct dsi_phy_configtype *phy_cfg)
static unsigned long dsi_phy_calc_clk_divider(struct dsi_phy_configtype *phy_cfg)
static uint32_t dsi_calc_desired_bitclk(struct edid *edid, uint32_t num_lines, uint32_t bpp)
#define mult_frac(x, numer, denom)
static enum cb_err mdss_dsi_phy_pll_setup(struct edid *edid, uint32_t num_of_lanes, uint32_t bpp)
static void mdss_dsi_phy_reset(void)
#define HAL_DSI_PLL_VCO_MIN_MHZ_2_2_0
static enum cb_err mdss_dsi_phy_timings(struct msm_dsi_phy_ctrl *phy_timings)
static void dsi_phy_pll_set_source(void)
static void dsi_phy_pll_global_clk_enable(bool enable)
static void mdss_dsi_power_down(void)
void dsi_phy_pll_vco_10nm_set_rate(unsigned long rate)
#define wait_us(timeout_us, condition)
#define BIOS_INFO
BIOS_INFO - Expected events.
#define BIOS_ERR
BIOS_ERR - System in incomplete state.
static struct dsi_phy_pll_qlink_regs *const phy_pll_qlink
static struct dsi_phy_regs *const dsi0_phy
static void phy_cfg(u32 channel, const struct rk3288_sdram_params *sdram_params)
int mdss_clock_enable(enum mdss_clock clk_type)
enum cb_err mdss_clock_configure(enum mdss_clock clk_type, uint32_t source, uint32_t divider, uint32_t m, uint32_t n, uint32_t d_2)
unsigned long long uint64_t
uint32_t desired_bitclk_freq
uint32_t pclk_divnumerator
uint32_t pclk_divdenominator
uint32_t pll_common_status_one
uint32_t pll_system_muxes
struct dsi_phy_regs::@1421 phy_ln_regs[5]
uint32_t phy_cmn_phy_status
uint32_t phy_cmn_timing_ctrl[12]
uint32_t dln0_offset_bot_ctrl
uint32_t phy_cmn_pll_ctrl
uint32_t phy_cmn_clk_cfg0
uint32_t phy_cmn_rbuf_ctrl
uint32_t dln0_hstx_str_ctrl
uint32_t phy_cmn_clk_cfg1
uint32_t phy_cmn_glbl_ctrl
uint32_t dln0_lptx_str_ctrl
uint32_t phy_cmn_vreg_ctrl
uint32_t dln0_offset_top_ctrl
uint32_t phy_cmn_dsi_lane_ctrl0
uint32_t clkout_timing_ctrl
uint32_t half_byte_clk_en