Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/msm/dp: Use qmp phy for DP PLL and PHY

Make the necessary changes to the DP driver to use the qmp phy from the
common phy framework instead of rolling our own in the drm subsystem.
This also removes the PLL code and adds proper includes so things build.

Cc: Jeykumar Sankaran <jsanka@codeaurora.org>
Cc: Chandan Uddaraju <chandanu@codeaurora.org>
Cc: Vara Reddy <varar@codeaurora.org>
Cc: Tanmay Shah <tanmay@codeaurora.org>
Cc: Bjorn Andersson <bjorn.andersson@linaro.org>
Cc: Manu Gautam <mgautam@codeaurora.org>
Cc: Sandeep Maheswaram <sanm@codeaurora.org>
Cc: Douglas Anderson <dianders@chromium.org>
Cc: Sean Paul <seanpaul@chromium.org>
Cc: Jonathan Marek <jonathan@marek.ca>
Cc: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Cc: Rob Clark <robdclark@chromium.org>
Signed-off-by: Stephen Boyd <swboyd@chromium.org>
Signed-off-by: Rob Clark <robdclark@chromium.org>

authored by

Stephen Boyd and committed by
Rob Clark
937f941c ab205927

+78 -1762
-2
drivers/gpu/drm/msm/Makefile
··· 111 111 dp/dp_panel.o \ 112 112 dp/dp_parser.o \ 113 113 dp/dp_power.o \ 114 - dp/dp_pll.o \ 115 - dp/dp_pll_10nm.o \ 116 114 dp/dp_audio.o 117 115 118 116 msm-$(CONFIG_DRM_FBDEV_EMULATION) += msm_fbdev.o
+3 -4
drivers/gpu/drm/msm/dp/dp_aux.c
··· 4 4 */ 5 5 6 6 #include <linux/delay.h> 7 + #include <drm/drm_print.h> 7 8 8 9 #include "dp_reg.h" 9 10 #include "dp_aux.h" ··· 381 380 if (aux->native) { 382 381 aux->retry_cnt++; 383 382 if (!(aux->retry_cnt % retry_count)) 384 - dp_catalog_aux_update_cfg(aux->catalog, 385 - PHY_AUX_CFG1); 383 + dp_catalog_aux_update_cfg(aux->catalog); 386 384 dp_catalog_aux_reset(aux->catalog); 387 385 } 388 386 usleep_range(400, 500); /* at least 400us to next try */ ··· 438 438 439 439 aux = container_of(dp_aux, struct dp_aux_private, dp_aux); 440 440 441 - dp_catalog_aux_update_cfg(aux->catalog, PHY_AUX_CFG1); 441 + dp_catalog_aux_update_cfg(aux->catalog); 442 442 dp_catalog_aux_reset(aux->catalog); 443 443 } 444 444 ··· 453 453 454 454 aux = container_of(dp_aux, struct dp_aux_private, dp_aux); 455 455 456 - dp_catalog_aux_setup(aux->catalog); 457 456 dp_catalog_aux_enable(aux->catalog, true); 458 457 aux->retry_cnt = 0; 459 458 }
+21 -266
drivers/gpu/drm/msm/dp/dp_catalog.c
··· 8 8 #include <linux/rational.h> 9 9 #include <linux/delay.h> 10 10 #include <linux/iopoll.h> 11 + #include <linux/phy/phy.h> 12 + #include <linux/phy/phy-dp.h> 11 13 #include <linux/rational.h> 12 14 #include <drm/drm_dp_helper.h> 15 + #include <drm/drm_print.h> 13 16 14 17 #include "dp_catalog.h" 15 18 #include "dp_reg.h" ··· 55 52 #define DP_INTERRUPT_STATUS2_MASK \ 56 53 (DP_INTERRUPT_STATUS2 << DP_INTERRUPT_STATUS_MASK_SHIFT) 57 54 58 - static u8 const vm_pre_emphasis_hbr_rbr[4][4] = { 59 - {0x00, 0x0C, 0x14, 0x19}, 60 - {0x00, 0x0B, 0x12, 0xFF}, 61 - {0x00, 0x0B, 0xFF, 0xFF}, 62 - {0x04, 0xFF, 0xFF, 0xFF} 63 - }; 64 - 65 - static u8 const vm_voltage_swing_hbr_rbr[4][4] = { 66 - {0x08, 0x0F, 0x16, 0x1F}, 67 - {0x11, 0x1E, 0x1F, 0xFF}, 68 - {0x19, 0x1F, 0xFF, 0xFF}, 69 - {0x1F, 0xFF, 0xFF, 0xFF} 70 - }; 71 - 72 - /* AUX look-up-table configurations 73 - * Pair of offset and config values for each LUT 74 - */ 75 - static u8 const aux_lut_offset[] = { 76 - 0x20, 0x24, 0x28, 0x2C, 0x30, 0x34, 0x38, 0x3C, 0x40, 0x44 77 - }; 78 - 79 - static u8 const 80 - aux_lut_value[PHY_AUX_CFG_MAX][DP_AUX_CFG_MAX_VALUE_CNT] = { 81 - { 0x00, 0x00, 0x00, }, 82 - { 0x13, 0x23, 0x1d, }, 83 - { 0x24, 0x00, 0x00, }, 84 - { 0x00, 0x00, 0x00, }, 85 - { 0x0A, 0x00, 0x00, }, 86 - { 0x26, 0x00, 0x00, }, 87 - { 0x0A, 0x00, 0x00, }, 88 - { 0x03, 0x00, 0x00, }, 89 - { 0xBB, 0x00, 0x00, }, 90 - { 0x03, 0x00, 0x00, } 91 - }; 92 - 93 55 struct dp_catalog_private { 94 56 struct device *dev; 95 57 struct dp_io *io; ··· 95 127 * this function uses writel() instread of writel_relaxed() 96 128 */ 97 129 writel(data, catalog->io->dp_controller.base + offset); 98 - } 99 - 100 - static inline void dp_write_phy(struct dp_catalog_private *catalog, 101 - u32 offset, u32 data) 102 - { 103 - offset += DP_PHY_REG_OFFSET; 104 - /* 105 - * To make sure phy reg writes happens before any other operation, 106 - * this function uses writel() instread of writel_relaxed() 107 - */ 108 - writel(data, catalog->io->phy_reg.base + offset); 109 - } 110 - 111 - static inline u32 dp_read_phy(struct dp_catalog_private *catalog, 112 - u32 offset) 113 - { 114 - offset += DP_PHY_REG_OFFSET; 115 - /* 116 - * To make sure phy reg writes happens before any other operation, 117 - * this function uses writel() instread of writel_relaxed() 118 - */ 119 - return readl_relaxed(catalog->io->phy_reg.base + offset); 120 - } 121 - 122 - static inline void dp_write_pll(struct dp_catalog_private *catalog, 123 - u32 offset, u32 data) 124 - { 125 - offset += DP_PHY_PLL_OFFSET; 126 - writel_relaxed(data, catalog->io->phy_reg.base + offset); 127 - } 128 - 129 - static inline void dp_write_ln_tx0(struct dp_catalog_private *catalog, 130 - u32 offset, u32 data) 131 - { 132 - offset += DP_PHY_LN_TX0_OFFSET; 133 - writel_relaxed(data, catalog->io->phy_reg.base + offset); 134 - } 135 - 136 - static inline void dp_write_ln_tx1(struct dp_catalog_private *catalog, 137 - u32 offset, u32 data) 138 - { 139 - offset += DP_PHY_LN_TX1_OFFSET; 140 - writel_relaxed(data, catalog->io->phy_reg.base + offset); 141 - } 142 - 143 - static inline u32 dp_read_ln_tx0(struct dp_catalog_private *catalog, 144 - u32 offset) 145 - { 146 - offset += DP_PHY_LN_TX0_OFFSET; 147 - return readl_relaxed(catalog->io->phy_reg.base + offset); 148 - } 149 - 150 - static inline u32 dp_read_ln_tx1(struct dp_catalog_private *catalog, 151 - u32 offset) 152 - { 153 - offset += DP_PHY_LN_TX1_OFFSET; 154 - return readl_relaxed(catalog->io->phy_reg.base + offset); 155 - } 156 - 157 - static inline void dp_write_usb_cm(struct dp_catalog_private *catalog, 158 - u32 offset, u32 data) 159 - { 160 - /* 161 - * To make sure usb reg writes happens before any other operation, 162 - * this function uses writel() instread of writel_relaxed() 163 - */ 164 - writel(data, catalog->io->usb3_dp_com.base + offset); 165 - } 166 - 167 - static inline u32 dp_read_usb_cm(struct dp_catalog_private *catalog, 168 - u32 offset) 169 - { 170 - /* 171 - * To make sure usb reg writes happens before any other operation, 172 - * this function uses writel() instread of writel_relaxed() 173 - */ 174 - return readl_relaxed(catalog->io->usb3_dp_com.base + offset); 175 130 } 176 131 177 132 static inline void dp_write_p0(struct dp_catalog_private *catalog, ··· 226 335 dp_write_aux(catalog, REG_DP_AUX_CTRL, aux_ctrl); 227 336 } 228 337 229 - void dp_catalog_aux_update_cfg(struct dp_catalog *dp_catalog, 230 - enum dp_phy_aux_config_type type) 338 + void dp_catalog_aux_update_cfg(struct dp_catalog *dp_catalog) 231 339 { 232 340 struct dp_catalog_private *catalog = container_of(dp_catalog, 233 341 struct dp_catalog_private, dp_catalog); 234 - u32 new_index = 0, current_index = 0; 342 + struct dp_io *dp_io = catalog->io; 343 + struct phy *phy = dp_io->phy; 235 344 236 - if (type >= PHY_AUX_CFG_MAX) { 237 - DRM_ERROR("invalid input\n"); 238 - return; 239 - } 240 - 241 - current_index = catalog->aux_lut_cfg_index[type]; 242 - new_index = (current_index + 1) % DP_AUX_CFG_MAX_VALUE_CNT; 243 - DRM_DEBUG_DP("Updating PHY_AUX_CFG%d from 0x%08x to 0x%08x\n", 244 - type, aux_lut_value[type][current_index], 245 - aux_lut_value[type][new_index]); 246 - 247 - dp_write_phy(catalog, aux_lut_offset[type], 248 - aux_lut_value[type][new_index]); 249 - catalog->aux_lut_cfg_index[type] = new_index; 345 + phy_calibrate(phy); 250 346 } 251 347 252 348 static void dump_regs(void __iomem *base, int len) ··· 279 401 offset = MSM_DP_CONTROLLER_P0_OFFSET; 280 402 len = MSM_DP_CONTROLLER_P0_SIZE; 281 403 dump_regs(catalog->io->dp_controller.base + offset, len); 282 - 283 - pr_info("USB3 DP COM regs\n"); 284 - dump_regs(catalog->io->usb3_dp_com.base, catalog->io->usb3_dp_com.len); 285 - 286 - pr_info("LN TX0 regs\n"); 287 - dump_regs(catalog->io->phy_reg.base + DP_PHY_LN_TX0_OFFSET, 288 - DP_PHY_LN_TX0_SIZE); 289 - 290 - pr_info("LN TX1 regs\n"); 291 - dump_regs(catalog->io->phy_reg.base + DP_PHY_LN_TX1_OFFSET, 292 - DP_PHY_LN_TX1_SIZE); 293 - 294 - pr_info("DP PHY regs\n"); 295 - dump_regs(catalog->io->phy_reg.base + DP_PHY_REG_OFFSET, 296 - DP_PHY_REG_SIZE); 297 - } 298 - 299 - void dp_catalog_aux_setup(struct dp_catalog *dp_catalog) 300 - { 301 - struct dp_catalog_private *catalog = container_of(dp_catalog, 302 - struct dp_catalog_private, dp_catalog); 303 - int i = 0; 304 - 305 - dp_write_phy(catalog, REG_DP_PHY_PD_CTL, DP_PHY_PD_CTL_PWRDN | 306 - DP_PHY_PD_CTL_AUX_PWRDN | DP_PHY_PD_CTL_PLL_PWRDN | 307 - DP_PHY_PD_CTL_DP_CLAMP_EN); 308 - 309 - /* Turn on BIAS current for PHY/PLL */ 310 - dp_write_pll(catalog, 311 - QSERDES_COM_BIAS_EN_CLKBUFLR_EN, QSERDES_COM_BIAS_EN | 312 - QSERDES_COM_BIAS_EN_MUX | QSERDES_COM_CLKBUF_L_EN | 313 - QSERDES_COM_EN_SYSCLK_TX_SEL); 314 - 315 - dp_write_phy(catalog, REG_DP_PHY_PD_CTL, DP_PHY_PD_CTL_PSR_PWRDN); 316 - 317 - dp_write_phy(catalog, REG_DP_PHY_PD_CTL, DP_PHY_PD_CTL_PWRDN | 318 - DP_PHY_PD_CTL_AUX_PWRDN | DP_PHY_PD_CTL_LANE_0_1_PWRDN 319 - | DP_PHY_PD_CTL_LANE_2_3_PWRDN | DP_PHY_PD_CTL_PLL_PWRDN 320 - | DP_PHY_PD_CTL_DP_CLAMP_EN); 321 - 322 - dp_write_pll(catalog, 323 - QSERDES_COM_BIAS_EN_CLKBUFLR_EN, QSERDES_COM_BIAS_EN | 324 - QSERDES_COM_BIAS_EN_MUX | QSERDES_COM_CLKBUF_R_EN | 325 - QSERDES_COM_CLKBUF_L_EN | QSERDES_COM_EN_SYSCLK_TX_SEL | 326 - QSERDES_COM_CLKBUF_RX_DRIVE_L); 327 - 328 - /* DP AUX CFG register programming */ 329 - for (i = 0; i < PHY_AUX_CFG_MAX; i++) { 330 - DRM_DEBUG_DP("PHY_AUX_CFG%ds: offset=0x%08x, value=0x%08x\n", 331 - i, aux_lut_offset[i], aux_lut_value[i][0]); 332 - dp_write_phy(catalog, aux_lut_offset[i], 333 - aux_lut_value[i][0]); 334 - } 335 - 336 - dp_write_phy(catalog, REG_DP_PHY_AUX_INTERRUPT_MASK, 337 - PHY_AUX_STOP_ERR_MASK | PHY_AUX_DEC_ERR_MASK | 338 - PHY_AUX_SYNC_ERR_MASK | PHY_AUX_ALIGN_ERR_MASK | 339 - PHY_AUX_REQ_ERR_MASK); 340 404 } 341 405 342 406 int dp_catalog_aux_get_irq(struct dp_catalog *dp_catalog) ··· 405 585 bool fixed_nvid) 406 586 { 407 587 u32 pixel_m, pixel_n; 408 - u32 mvid, nvid, div, pixel_div = 0, dispcc_input_rate; 588 + u32 mvid, nvid, pixel_div = 0, dispcc_input_rate; 409 589 u32 const nvid_fixed = DP_LINK_CONSTANT_N_VALUE; 410 590 u32 const link_rate_hbr2 = 540000; 411 591 u32 const link_rate_hbr3 = 810000; ··· 414 594 struct dp_catalog_private *catalog = container_of(dp_catalog, 415 595 struct dp_catalog_private, dp_catalog); 416 596 417 - div = dp_read_phy(catalog, REG_DP_PHY_VCO_DIV); 418 - div &= 0x03; 419 - 420 - if (div == 0) 597 + if (rate == link_rate_hbr3) 421 598 pixel_div = 6; 422 - else if (div == 1) 599 + else if (rate == 1620000 || rate == 270000) 423 600 pixel_div = 2; 424 - else if (div == 2) 601 + else if (rate == link_rate_hbr2) 425 602 pixel_div = 4; 426 603 else 427 604 DRM_ERROR("Invalid pixel mux divider\n"); ··· 482 665 return ret; 483 666 } 484 667 return 0; 485 - } 486 - 487 - void dp_catalog_ctrl_usb_reset(struct dp_catalog *dp_catalog, bool flip) 488 - { 489 - struct dp_catalog_private *catalog = container_of(dp_catalog, 490 - struct dp_catalog_private, dp_catalog); 491 - u32 typec_ctrl; 492 - 493 - dp_write_usb_cm(catalog, REG_USB3_DP_COM_RESET_OVRD_CTRL, 494 - USB3_DP_COM_OVRD_CTRL_SW_DPPHY_RESET_MUX | 495 - USB3_DP_COM_OVRD_CTRL_SW_USB3PHY_RESET_MUX); 496 - dp_write_usb_cm(catalog, REG_USB3_DP_COM_PHY_MODE_CTRL, 497 - USB3_DP_COM_PHY_MODE_DP); 498 - dp_write_usb_cm(catalog, REG_USB3_DP_COM_SW_RESET, 499 - USB3_DP_COM_SW_RESET_SET); 500 - 501 - /* Default configuration i.e CC1 */ 502 - typec_ctrl = USB3_DP_COM_TYPEC_CTRL_PORTSEL_MUX; 503 - if (flip) 504 - typec_ctrl |= USB3_DP_COM_TYPEC_CTRL_PORTSEL; 505 - 506 - dp_write_usb_cm(catalog, REG_USB3_DP_COM_TYPEC_CTRL, typec_ctrl); 507 - 508 - dp_write_usb_cm(catalog, REG_USB3_DP_COM_SWI_CTRL, 0x00); 509 - dp_write_usb_cm(catalog, REG_USB3_DP_COM_SW_RESET, 0x00); 510 - 511 - dp_write_usb_cm(catalog, REG_USB3_DP_COM_POWER_DOWN_CTRL, 512 - USB3_DP_COM_POWER_DOWN_CTRL_SW_PWRDN); 513 - dp_write_usb_cm(catalog, REG_USB3_DP_COM_RESET_OVRD_CTRL, 0x00); 514 - 515 668 } 516 669 517 670 void dp_catalog_ctrl_reset(struct dp_catalog *dp_catalog) ··· 607 820 struct dp_catalog_private, dp_catalog); 608 821 609 822 dp_write_ahb(catalog, REG_DP_PHY_CTRL, 610 - DP_PHY_CTRL_SW_RESET_PLL | DP_PHY_CTRL_SW_RESET); 823 + DP_PHY_CTRL_SW_RESET | DP_PHY_CTRL_SW_RESET_PLL); 611 824 usleep_range(1000, 1100); /* h/w recommended delay */ 612 825 dp_write_ahb(catalog, REG_DP_PHY_CTRL, 0x0); 613 - } 614 - 615 - void dp_catalog_ctrl_phy_lane_cfg(struct dp_catalog *dp_catalog, 616 - bool flipped, u8 ln_cnt) 617 - { 618 - u32 info; 619 - struct dp_catalog_private *catalog = container_of(dp_catalog, 620 - struct dp_catalog_private, dp_catalog); 621 - u8 orientation = BIT(!!flipped); 622 - 623 - info = ln_cnt & DP_PHY_SPARE0_MASK; 624 - info |= (orientation & DP_PHY_SPARE0_MASK) 625 - << DP_PHY_SPARE0_ORIENTATION_INFO_SHIFT; 626 - DRM_DEBUG_DP("Shared Info = 0x%x\n", info); 627 - 628 - dp_write_phy(catalog, REG_DP_PHY_SPARE0, info); 629 826 } 630 827 631 828 int dp_catalog_ctrl_update_vx_px(struct dp_catalog *dp_catalog, ··· 617 846 { 618 847 struct dp_catalog_private *catalog = container_of(dp_catalog, 619 848 struct dp_catalog_private, dp_catalog); 620 - u8 voltage_swing_cfg, pre_emphasis_cfg; 849 + struct dp_io *dp_io = catalog->io; 850 + struct phy *phy = dp_io->phy; 851 + struct phy_configure_opts_dp *opts_dp = &dp_io->phy_opts.dp; 621 852 622 - DRM_DEBUG_DP("hw: v=%d p=%d\n", v_level, p_level); 623 - 624 - voltage_swing_cfg = vm_voltage_swing_hbr_rbr[v_level][p_level]; 625 - pre_emphasis_cfg = vm_pre_emphasis_hbr_rbr[v_level][p_level]; 626 - 627 - if (voltage_swing_cfg == 0xFF && pre_emphasis_cfg == 0xFF) { 628 - DRM_ERROR("invalid vx (0x%x=0x%x), px (0x%x=0x%x\n", 629 - v_level, voltage_swing_cfg, p_level, pre_emphasis_cfg); 630 - return -EINVAL; 631 - } 632 - 633 - /* Enable MUX to use Cursor values from these registers */ 634 - voltage_swing_cfg |= DP_PHY_TXn_TX_DRV_LVL_MUX_EN; 635 - pre_emphasis_cfg |= DP_PHY_TXn_TX_EMP_POST1_LVL_MUX_EN; 636 - 637 - /* Configure host and panel only if both values are allowed */ 638 - dp_write_ln_tx0(catalog, REG_DP_PHY_TXn_TX_DRV_LVL, voltage_swing_cfg); 639 - dp_write_ln_tx1(catalog, REG_DP_PHY_TXn_TX_DRV_LVL, voltage_swing_cfg); 640 - dp_write_ln_tx0(catalog, REG_DP_PHY_TXn_TX_EMP_POST1_LVL, 641 - pre_emphasis_cfg); 642 - dp_write_ln_tx1(catalog, REG_DP_PHY_TXn_TX_EMP_POST1_LVL, 643 - pre_emphasis_cfg); 644 - DRM_DEBUG_DP("hw: vx_value=0x%x px_value=0x%x\n", 645 - voltage_swing_cfg, pre_emphasis_cfg); 853 + /* TODO: Update for all lanes instead of just first one */ 854 + opts_dp->voltage[0] = v_level; 855 + opts_dp->pre[0] = p_level; 856 + opts_dp->set_voltages = 1; 857 + phy_configure(phy, &dp_io->phy_opts); 858 + opts_dp->set_voltages = 0; 646 859 647 860 return 0; 648 861 }
+3 -6
drivers/gpu/drm/msm/dp/dp_catalog.h
··· 6 6 #ifndef _DP_CATALOG_H_ 7 7 #define _DP_CATALOG_H_ 8 8 9 + #include <drm/drm_modes.h> 10 + 9 11 #include "dp_parser.h" 10 12 11 13 /* interrupts */ ··· 79 77 int dp_catalog_aux_clear_hw_interrupts(struct dp_catalog *dp_catalog); 80 78 void dp_catalog_aux_reset(struct dp_catalog *dp_catalog); 81 79 void dp_catalog_aux_enable(struct dp_catalog *dp_catalog, bool enable); 82 - void dp_catalog_aux_update_cfg(struct dp_catalog *dp_catalog, 83 - enum dp_phy_aux_config_type type); 84 - void dp_catalog_aux_setup(struct dp_catalog *dp_catalog); 80 + void dp_catalog_aux_update_cfg(struct dp_catalog *dp_catalog); 85 81 int dp_catalog_aux_get_irq(struct dp_catalog *dp_catalog); 86 82 87 83 /* DP Controller APIs */ ··· 92 92 u32 stream_rate_khz, bool fixed_nvid); 93 93 int dp_catalog_ctrl_set_pattern(struct dp_catalog *dp_catalog, u32 pattern); 94 94 void dp_catalog_ctrl_reset(struct dp_catalog *dp_catalog); 95 - void dp_catalog_ctrl_usb_reset(struct dp_catalog *dp_catalog, bool flip); 96 95 bool dp_catalog_ctrl_mainlink_ready(struct dp_catalog *dp_catalog); 97 96 void dp_catalog_ctrl_enable_irq(struct dp_catalog *dp_catalog, bool enable); 98 97 void dp_catalog_hpd_config_intr(struct dp_catalog *dp_catalog, ··· 99 100 void dp_catalog_ctrl_hpd_config(struct dp_catalog *dp_catalog); 100 101 u32 dp_catalog_hpd_get_intr_status(struct dp_catalog *dp_catalog); 101 102 void dp_catalog_ctrl_phy_reset(struct dp_catalog *dp_catalog); 102 - void dp_catalog_ctrl_phy_lane_cfg(struct dp_catalog *dp_catalog, bool flipped, 103 - u8 lane_cnt); 104 103 int dp_catalog_ctrl_update_vx_px(struct dp_catalog *dp_catalog, u8 v_level, 105 104 u8 p_level); 106 105 int dp_catalog_ctrl_get_interrupt(struct dp_catalog *dp_catalog);
+34 -14
drivers/gpu/drm/msm/dp/dp_ctrl.c
··· 8 8 #include <linux/types.h> 9 9 #include <linux/completion.h> 10 10 #include <linux/delay.h> 11 + #include <linux/phy/phy.h> 12 + #include <linux/phy/phy-dp.h> 11 13 #include <drm/drm_fixed.h> 12 14 #include <drm/drm_dp_helper.h> 15 + #include <drm/drm_print.h> 13 16 14 17 #include "dp_reg.h" 15 18 #include "dp_ctrl.h" ··· 1305 1302 } 1306 1303 1307 1304 static void dp_ctrl_set_clock_rate(struct dp_ctrl_private *ctrl, 1308 - enum dp_pm_type module, char *name, u32 rate) 1305 + enum dp_pm_type module, char *name, unsigned long rate) 1309 1306 { 1310 1307 u32 num = ctrl->parser->mp[module].num_clk; 1311 1308 struct dss_clk *cfg = ctrl->parser->mp[module].clk_config; ··· 1315 1312 cfg++; 1316 1313 } 1317 1314 1318 - DRM_DEBUG_DP("setting rate=%d on clk=%s\n", rate, name); 1315 + DRM_DEBUG_DP("setting rate=%lu on clk=%s\n", rate, name); 1319 1316 1320 1317 if (num) 1321 1318 cfg->rate = rate; 1322 1319 else 1323 - DRM_ERROR("%s clock doesn't exit to set rate %d\n", 1320 + DRM_ERROR("%s clock doesn't exit to set rate %lu\n", 1324 1321 name, rate); 1325 1322 } 1326 1323 1327 1324 static int dp_ctrl_enable_mainlink_clocks(struct dp_ctrl_private *ctrl) 1328 1325 { 1329 1326 int ret = 0; 1327 + struct dp_io *dp_io = &ctrl->parser->io; 1328 + struct phy *phy = dp_io->phy; 1329 + struct phy_configure_opts_dp *opts_dp = &dp_io->phy_opts.dp; 1330 1330 1331 - dp_power_set_link_clk_parent(ctrl->power); 1332 - 1331 + opts_dp->lanes = ctrl->link->link_params.num_lanes; 1332 + opts_dp->link_rate = ctrl->link->link_params.rate / 100; 1333 1333 dp_ctrl_set_clock_rate(ctrl, DP_CTRL_PM, "ctrl_link", 1334 - ctrl->link->link_params.rate); 1334 + ctrl->link->link_params.rate * 1000); 1335 + 1336 + phy_configure(phy, &dp_io->phy_opts); 1337 + phy_power_on(phy); 1335 1338 1336 1339 ret = dp_power_clk_enable(ctrl->power, DP_CTRL_PM, true); 1337 1340 if (ret) ··· 1354 1345 int ret = 0; 1355 1346 1356 1347 dp_ctrl_set_clock_rate(ctrl, DP_STREAM_PM, "stream_pixel", 1357 - ctrl->dp_ctrl.pixel_rate); 1348 + ctrl->dp_ctrl.pixel_rate * 1000); 1358 1349 1359 1350 ret = dp_power_clk_enable(ctrl->power, DP_STREAM_PM, true); 1360 1351 if (ret) ··· 1369 1360 int dp_ctrl_host_init(struct dp_ctrl *dp_ctrl, bool flip) 1370 1361 { 1371 1362 struct dp_ctrl_private *ctrl; 1363 + struct dp_io *dp_io; 1364 + struct phy *phy; 1372 1365 1373 1366 if (!dp_ctrl) { 1374 1367 DRM_ERROR("Invalid input data\n"); ··· 1378 1367 } 1379 1368 1380 1369 ctrl = container_of(dp_ctrl, struct dp_ctrl_private, dp_ctrl); 1370 + dp_io = &ctrl->parser->io; 1371 + phy = dp_io->phy; 1381 1372 1382 1373 ctrl->dp_ctrl.orientation = flip; 1383 1374 1384 - dp_catalog_ctrl_usb_reset(ctrl->catalog, flip); 1385 1375 dp_catalog_ctrl_phy_reset(ctrl->catalog); 1376 + phy_init(phy); 1386 1377 dp_catalog_ctrl_enable_irq(ctrl->catalog, true); 1387 1378 1388 1379 return 0; ··· 1433 1420 static int dp_ctrl_reinitialize_mainlink(struct dp_ctrl_private *ctrl) 1434 1421 { 1435 1422 int ret = 0; 1423 + struct dp_io *dp_io = &ctrl->parser->io; 1424 + struct phy *phy = dp_io->phy; 1425 + struct phy_configure_opts_dp *opts_dp = &dp_io->phy_opts.dp; 1436 1426 1437 1427 dp_catalog_ctrl_mainlink_ctrl(ctrl->catalog, false); 1438 - dp_catalog_ctrl_phy_lane_cfg(ctrl->catalog, 1439 - ctrl->dp_ctrl.orientation, ctrl->link->link_params.num_lanes); 1428 + opts_dp->lanes = ctrl->link->link_params.num_lanes; 1429 + phy_configure(phy, &dp_io->phy_opts); 1440 1430 /* 1441 1431 * Disable and re-enable the mainlink clock since the 1442 1432 * link clock might have been adjusted as part of the ··· 1450 1434 DRM_ERROR("Failed to disable clocks. ret=%d\n", ret); 1451 1435 return ret; 1452 1436 } 1437 + phy_power_off(phy); 1453 1438 /* hw recommended delay before re-enabling clocks */ 1454 1439 msleep(20); 1455 1440 ··· 1639 1622 ctrl->link->link_params.rate, 1640 1623 ctrl->link->link_params.num_lanes, ctrl->dp_ctrl.pixel_rate); 1641 1624 1642 - dp_catalog_ctrl_phy_lane_cfg(ctrl->catalog, 1643 - ctrl->dp_ctrl.orientation, 1644 - ctrl->link->link_params.num_lanes); 1645 - 1646 1625 rc = dp_ctrl_enable_mainlink_clocks(ctrl); 1647 1626 if (rc) 1648 1627 return rc; ··· 1776 1763 int dp_ctrl_off(struct dp_ctrl *dp_ctrl) 1777 1764 { 1778 1765 struct dp_ctrl_private *ctrl; 1766 + struct dp_io *dp_io; 1767 + struct phy *phy; 1779 1768 int ret = 0; 1780 1769 1781 1770 if (!dp_ctrl) 1782 1771 return -EINVAL; 1783 1772 1784 1773 ctrl = container_of(dp_ctrl, struct dp_ctrl_private, dp_ctrl); 1774 + dp_io = &ctrl->parser->io; 1775 + phy = dp_io->phy; 1785 1776 1786 1777 dp_catalog_ctrl_mainlink_ctrl(ctrl->catalog, false); 1787 1778 ··· 1799 1782 if (ret) { 1800 1783 DRM_ERROR("Failed to disable link clocks. ret=%d\n", ret); 1801 1784 } 1785 + 1786 + phy_power_off(phy); 1787 + phy_exit(phy); 1802 1788 1803 1789 DRM_DEBUG_DP("DP off done\n"); 1804 1790 return ret;
-17
drivers/gpu/drm/msm/dp/dp_display.c
··· 24 24 #include "dp_ctrl.h" 25 25 #include "dp_display.h" 26 26 #include "dp_drm.h" 27 - #include "dp_pll.h" 28 27 #include "dp_audio.h" 29 28 #include "dp_debug.h" 30 29 ··· 90 91 91 92 struct dp_usbpd *usbpd; 92 93 struct dp_parser *parser; 93 - struct msm_dp_pll *pll; 94 94 struct dp_power *power; 95 95 struct dp_catalog *catalog; 96 96 struct drm_dp_aux *aux; ··· 657 659 dp_ctrl_put(dp->ctrl); 658 660 dp_panel_put(dp->panel); 659 661 dp_aux_put(dp->aux); 660 - dp_pll_put(dp->pll); 661 662 dp_audio_put(dp->audio); 662 663 } 663 664 ··· 667 670 struct dp_usbpd_cb *cb = &dp->usbpd_cb; 668 671 struct dp_panel_in panel_in = { 669 672 .dev = dev, 670 - }; 671 - struct dp_pll_in pll_in = { 672 - .pdev = dp->pdev, 673 673 }; 674 674 675 675 /* Callback APIs used for cable status change event */ ··· 697 703 dp->catalog = NULL; 698 704 goto error; 699 705 } 700 - 701 - pll_in.parser = dp->parser; 702 - dp->pll = dp_pll_get(&pll_in); 703 - if (IS_ERR_OR_NULL(dp->pll)) { 704 - rc = -EINVAL; 705 - DRM_ERROR("failed to initialize pll, rc = %d\n", rc); 706 - dp->pll = NULL; 707 - goto error; 708 - } 709 - 710 - dp->parser->pll = dp->pll; 711 706 712 707 dp->power = dp_power_get(dp->parser); 713 708 if (IS_ERR(dp->power)) {
-3
drivers/gpu/drm/msm/dp/dp_display.h
··· 36 36 int dp_display_get_test_bpp(struct msm_dp *dp_display); 37 37 void dp_display_signal_audio_complete(struct msm_dp *dp_display); 38 38 39 - void __init msm_dp_pll_driver_register(void); 40 - void __exit msm_dp_pll_driver_unregister(void); 41 - 42 39 #endif /* _DP_DISPLAY_H_ */
+2
drivers/gpu/drm/msm/dp/dp_link.c
··· 5 5 6 6 #define pr_fmt(fmt) "[drm-dp] %s: " fmt, __func__ 7 7 8 + #include <drm/drm_print.h> 9 + 8 10 #include "dp_link.h" 9 11 #include "dp_panel.h" 10 12
+1
drivers/gpu/drm/msm/dp/dp_panel.c
··· 7 7 8 8 #include <drm/drm_connector.h> 9 9 #include <drm/drm_edid.h> 10 + #include <drm/drm_print.h> 10 11 11 12 struct dp_panel_private { 12 13 struct device *dev;
+9 -3
drivers/gpu/drm/msm/dp/dp_parser.c
··· 4 4 */ 5 5 6 6 #include <linux/of_gpio.h> 7 + #include <linux/phy/phy.h> 8 + 9 + #include <drm/drm_print.h> 7 10 8 11 #include "dp_parser.h" 9 12 #include "dp_reg.h" ··· 56 53 struct dp_io *io = &parser->io; 57 54 58 55 msm_dss_iounmap(&io->dp_controller); 59 - msm_dss_iounmap(&io->phy_reg); 60 - msm_dss_iounmap(&io->usb3_dp_com); 61 56 } 62 57 63 58 static int dp_parser_ctrl_res(struct dp_parser *parser) ··· 67 66 rc = msm_dss_ioremap(pdev, &io->dp_controller); 68 67 if (rc) { 69 68 DRM_ERROR("unable to remap dp io resources, rc=%d\n", rc); 69 + goto err; 70 + } 71 + 72 + io->phy = devm_phy_get(&pdev->dev, "dp"); 73 + if (IS_ERR(io->phy)) { 74 + rc = PTR_ERR(io->phy); 70 75 goto err; 71 76 } 72 77 ··· 97 90 } 98 91 99 92 parser->max_dp_lanes = len; 100 - 101 93 return 0; 102 94 } 103 95
+4 -8
drivers/gpu/drm/msm/dp/dp_parser.h
··· 7 7 #define _DP_PARSER_H_ 8 8 9 9 #include <linux/platform_device.h> 10 + #include <linux/phy/phy.h> 11 + #include <linux/phy/phy-dp.h> 10 12 11 13 #include "dpu_io_util.h" 12 14 #include "msm_drv.h" 13 - #include "dp_pll.h" 14 15 15 16 #define DP_LABEL "MDSS DP DISPLAY" 16 17 #define DP_MAX_PIXEL_CLK_KHZ 675000 ··· 63 62 * 64 63 * @dp_controller: Display Port controller mapped memory address 65 64 * @phy_io: phy's mapped memory address 66 - * @ln_tx0_io: USB-DP lane TX0's mapped memory address 67 - * @ln_tx1_io: USB-DP lane TX1's mapped memory address 68 - * @dp_pll_io: DP PLL mapped memory address 69 - * @usb3_dp_com: USB3 DP PHY combo mapped memory address 70 65 */ 71 66 struct dp_io { 72 67 struct dss_io_data dp_controller; 73 - struct dss_io_data phy_reg; 74 - struct dss_io_data usb3_dp_com; 68 + struct phy *phy; 69 + union phy_configure_opts phy_opts; 75 70 }; 76 71 77 72 /** ··· 114 117 struct dp_pinctrl pinctrl; 115 118 struct dp_io io; 116 119 struct dp_display_data disp_data; 117 - struct msm_dp_pll *pll; 118 120 const struct dp_regulator_cfg *regulator_cfg; 119 121 u32 max_dp_lanes; 120 122
-99
drivers/gpu/drm/msm/dp/dp_pll.c
··· 1 - // SPDX-License-Identifier: GPL-2.0-only 2 - /* 3 - * Copyright (c) 2016-2020, The Linux Foundation. All rights reserved. 4 - */ 5 - 6 - #include <linux/device.h> 7 - 8 - #include "dp_parser.h" 9 - #include "dp_pll.h" 10 - #include "dp_pll_private.h" 11 - 12 - static int dp_pll_get_phy_io(struct dp_parser *parser) 13 - { 14 - struct dp_io *io = &parser->io; 15 - 16 - io->usb3_dp_com.base = ioremap(REG_USB3_DP_COM_REGION_BASE, 17 - REG_USB3_DP_COM_REGION_SIZE); 18 - if (!io->usb3_dp_com.base) { 19 - DRM_ERROR("unable to map USB3 DP COM IO\n"); 20 - return -EIO; 21 - } 22 - 23 - /* ToDo(user): DP PLL and DP PHY will not be part of 24 - * DP driver eventually so for now Hardcode Base and offsets 25 - * of PHY registers so we can remove them from dts and bindings 26 - */ 27 - io->phy_reg.base = ioremap(REG_DP_PHY_REGION_BASE, 28 - REG_DP_PHY_REGION_SIZE); 29 - if (!io->phy_reg.base) { 30 - DRM_ERROR("DP PHY io region mapping failed\n"); 31 - return -EIO; 32 - } 33 - io->phy_reg.len = REG_DP_PHY_REGION_SIZE; 34 - 35 - return 0; 36 - } 37 - 38 - static int msm_dp_pll_init(struct msm_dp_pll *pll, 39 - enum msm_dp_pll_type type, int id) 40 - { 41 - struct device *dev = &pll->pdev->dev; 42 - int ret = 0; 43 - 44 - switch (type) { 45 - case MSM_DP_PLL_10NM: 46 - ret = msm_dp_pll_10nm_init(pll, id); 47 - break; 48 - default: 49 - DRM_DEV_ERROR(dev, "%s: Wrong PLL type %d\n", __func__, type); 50 - return -ENXIO; 51 - } 52 - 53 - if (ret) { 54 - DRM_DEV_ERROR(dev, "%s: failed to init DP PLL\n", __func__); 55 - return ret; 56 - } 57 - 58 - pll->type = type; 59 - 60 - DRM_DEBUG_DP("DP:%d PLL registered", id); 61 - 62 - return ret; 63 - } 64 - 65 - struct msm_dp_pll *dp_pll_get(struct dp_pll_in *pll_in) 66 - { 67 - struct msm_dp_pll *dp_pll; 68 - struct dp_parser *parser = pll_in->parser; 69 - struct dp_io_pll *pll_io; 70 - int ret; 71 - 72 - dp_pll = devm_kzalloc(&pll_in->pdev->dev, sizeof(*dp_pll), GFP_KERNEL); 73 - if (!dp_pll) 74 - return ERR_PTR(-ENOMEM); 75 - 76 - pll_io = &dp_pll->pll_io; 77 - dp_pll->pdev = pll_in->pdev; 78 - 79 - dp_pll_get_phy_io(parser); 80 - 81 - pll_io->pll_base = parser->io.phy_reg.base + DP_PHY_PLL_OFFSET; 82 - pll_io->phy_base = parser->io.phy_reg.base + DP_PHY_REG_OFFSET; 83 - pll_io->ln_tx0_base = parser->io.phy_reg.base + DP_PHY_LN_TX0_OFFSET; 84 - pll_io->ln_tx1_base = parser->io.phy_reg.base + DP_PHY_LN_TX1_OFFSET; 85 - 86 - ret = msm_dp_pll_init(dp_pll, MSM_DP_PLL_10NM, 0); 87 - if (ret) { 88 - kfree(dp_pll); 89 - return ERR_PTR(ret); 90 - } 91 - 92 - return dp_pll; 93 - } 94 - 95 - void dp_pll_put(struct msm_dp_pll *dp_pll) 96 - { 97 - if (dp_pll->type == MSM_DP_PLL_10NM) 98 - msm_dp_pll_10nm_deinit(dp_pll); 99 - }
-61
drivers/gpu/drm/msm/dp/dp_pll.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0-only */ 2 - /* 3 - * Copyright (c) 2016-2020, The Linux Foundation. All rights reserved. 4 - */ 5 - 6 - #ifndef __DP_PLL_H 7 - #define __DP_PLL_H 8 - 9 - #include <linux/clk.h> 10 - #include <linux/clk-provider.h> 11 - #include <linux/platform_device.h> 12 - 13 - #include "dpu_io_util.h" 14 - #include "msm_drv.h" 15 - #include "dp_parser.h" 16 - 17 - #define PLL_REG_W(base, offset, data) \ 18 - writel((data), (base) + (offset)) 19 - #define PLL_REG_R(base, offset) readl((base) + (offset)) 20 - 21 - enum msm_dp_pll_type { 22 - MSM_DP_PLL_10NM, 23 - MSM_DP_PLL_MAX 24 - }; 25 - 26 - struct dp_pll_in { 27 - struct platform_device *pdev; 28 - struct dp_parser *parser; 29 - }; 30 - 31 - struct dp_io_pll { 32 - void __iomem *pll_base; 33 - void __iomem *phy_base; 34 - void __iomem *ln_tx0_base; 35 - void __iomem *ln_tx1_base; 36 - }; 37 - 38 - struct msm_dp_pll { 39 - enum msm_dp_pll_type type; 40 - bool pll_on; 41 - 42 - struct dp_io_pll pll_io; 43 - 44 - /* clock-provider: */ 45 - struct clk_hw_onecell_data *hw_data; 46 - 47 - struct platform_device *pdev; 48 - void *priv; 49 - 50 - /* Pll specific resources like GPIO, power supply, clocks, etc*/ 51 - struct dss_module_power mp; 52 - int (*get_provider)(struct msm_dp_pll *pll, 53 - struct clk **link_clk_provider, 54 - struct clk **pixel_clk_provider); 55 - }; 56 - 57 - struct msm_dp_pll *dp_pll_get(struct dp_pll_in *pll_in); 58 - 59 - void dp_pll_put(struct msm_dp_pll *dp_pll); 60 - 61 - #endif /* __DP_PLL_H */
-930
drivers/gpu/drm/msm/dp/dp_pll_10nm.c
··· 1 - // SPDX-License-Identifier: GPL-2.0-only 2 - /* 3 - * Copyright (c) 2016-2020, The Linux Foundation. All rights reserved. 4 - */ 5 - 6 - /* 7 - * Display Port PLL driver block diagram for branch clocks 8 - * 9 - * +------------------------------+ 10 - * | DP_VCO_CLK | 11 - * | | 12 - * | +-------------------+ | 13 - * | | (DP PLL/VCO) | | 14 - * | +---------+---------+ | 15 - * | v | 16 - * | +----------+-----------+ | 17 - * | | hsclk_divsel_clk_src | | 18 - * | +----------+-----------+ | 19 - * +------------------------------+ 20 - * | 21 - * +---------<---------v------------>----------+ 22 - * | | 23 - * +--------v---------+ | 24 - * | dp_phy_pll | | 25 - * | link_clk | | 26 - * +--------+---------+ | 27 - * | | 28 - * | | 29 - * v v 30 - * Input to DISPCC block | 31 - * for link clk, crypto clk | 32 - * and interface clock | 33 - * | 34 - * | 35 - * +--------<------------+-----------------+---<---+ 36 - * | | | 37 - * +----v---------+ +--------v-----+ +--------v------+ 38 - * | vco_divided | | vco_divided | | vco_divided | 39 - * | _clk_src | | _clk_src | | _clk_src | 40 - * | | | | | | 41 - * |divsel_six | | divsel_two | | divsel_four | 42 - * +-------+------+ +-----+--------+ +--------+------+ 43 - * | | | 44 - * v---->----------v-------------<------v 45 - * | 46 - * +----------+---------+ 47 - * | dp_phy_pll_vco | 48 - * | div_clk | 49 - * +---------+----------+ 50 - * | 51 - * v 52 - * Input to DISPCC block 53 - * for DP pixel clock 54 - * 55 - */ 56 - 57 - #include <linux/clk.h> 58 - #include <linux/delay.h> 59 - #include <linux/err.h> 60 - #include <linux/kernel.h> 61 - #include <linux/regmap.h> 62 - #include <linux/iopoll.h> 63 - 64 - #include "dp_hpd.h" 65 - #include "dp_pll.h" 66 - #include "dp_pll_private.h" 67 - 68 - #define NUM_PROVIDED_CLKS 2 69 - 70 - #define DP_LINK_CLK_SRC 0 71 - #define DP_PIXEL_CLK_SRC 1 72 - 73 - 74 - static int dp_vco_set_rate_10nm(struct clk_hw *hw, unsigned long rate, 75 - unsigned long parent_rate); 76 - 77 - static unsigned long dp_vco_recalc_rate_10nm(struct clk_hw *hw, 78 - unsigned long parent_rate); 79 - 80 - static long dp_vco_round_rate_10nm(struct clk_hw *hw, 81 - unsigned long rate, unsigned long *parent_rate); 82 - 83 - static int dp_vco_prepare_10nm(struct clk_hw *hw); 84 - static void dp_vco_unprepare_10nm(struct clk_hw *hw); 85 - 86 - static struct dp_pll_db *dp_pdb; 87 - 88 - static const struct clk_ops dp_10nm_vco_clk_ops = { 89 - .recalc_rate = dp_vco_recalc_rate_10nm, 90 - .set_rate = dp_vco_set_rate_10nm, 91 - .round_rate = dp_vco_round_rate_10nm, 92 - .prepare = dp_vco_prepare_10nm, 93 - .unprepare = dp_vco_unprepare_10nm, 94 - }; 95 - 96 - struct dp_pll_10nm_pclksel { 97 - struct clk_hw hw; 98 - 99 - /* divider params */ 100 - u8 shift; 101 - u8 width; 102 - u8 flags; /* same flags as used by clk_divider struct */ 103 - 104 - struct dp_pll_db *pll; 105 - }; 106 - 107 - #define to_pll_10nm_pclksel(_hw) \ 108 - container_of(_hw, struct dp_pll_10nm_pclksel, hw) 109 - 110 - static const struct clk_parent_data disp_cc_parent_data_0[] = { 111 - { .fw_name = "bi_tcxo" }, 112 - { .fw_name = "dp_phy_pll_link_clk", .name = "dp_phy_pll_link_clk" }, 113 - { .fw_name = "core_bi_pll_test_se", .name = "core_bi_pll_test_se" }, 114 - }; 115 - 116 - static struct dp_pll_vco_clk dp_vco_clk = { 117 - .min_rate = DP_VCO_HSCLK_RATE_1620MHZDIV1000, 118 - .max_rate = DP_VCO_HSCLK_RATE_8100MHZDIV1000, 119 - }; 120 - 121 - static int dp_pll_mux_set_parent_10nm(struct clk_hw *hw, u8 val) 122 - { 123 - struct dp_pll_10nm_pclksel *pclksel = to_pll_10nm_pclksel(hw); 124 - struct dp_pll_db *dp_res = pclksel->pll; 125 - struct dp_io_pll *pll_io = &dp_res->base->pll_io; 126 - u32 auxclk_div; 127 - 128 - auxclk_div = PLL_REG_R(pll_io->phy_base, REG_DP_PHY_VCO_DIV); 129 - auxclk_div &= ~0x03; 130 - 131 - if (val == 0) 132 - auxclk_div |= 1; 133 - else if (val == 1) 134 - auxclk_div |= 2; 135 - else if (val == 2) 136 - auxclk_div |= 0; 137 - 138 - PLL_REG_W(pll_io->phy_base, 139 - REG_DP_PHY_VCO_DIV, auxclk_div); 140 - DRM_DEBUG_DP("%s: mux=%d auxclk_div=%x\n", __func__, val, auxclk_div); 141 - 142 - return 0; 143 - } 144 - 145 - static u8 dp_pll_mux_get_parent_10nm(struct clk_hw *hw) 146 - { 147 - u32 auxclk_div = 0; 148 - struct dp_pll_10nm_pclksel *pclksel = to_pll_10nm_pclksel(hw); 149 - struct dp_pll_db *dp_res = pclksel->pll; 150 - struct dp_io_pll *pll_io = &dp_res->base->pll_io; 151 - u8 val = 0; 152 - 153 - auxclk_div = PLL_REG_R(pll_io->phy_base, REG_DP_PHY_VCO_DIV); 154 - auxclk_div &= 0x03; 155 - 156 - if (auxclk_div == 1) /* Default divider */ 157 - val = 0; 158 - else if (auxclk_div == 2) 159 - val = 1; 160 - else if (auxclk_div == 0) 161 - val = 2; 162 - 163 - DRM_DEBUG_DP("%s: auxclk_div=%d, val=%d\n", __func__, auxclk_div, val); 164 - 165 - return val; 166 - } 167 - 168 - static int dp_pll_clk_mux_determine_rate(struct clk_hw *hw, 169 - struct clk_rate_request *req) 170 - { 171 - unsigned long rate = 0; 172 - 173 - rate = clk_get_rate(hw->clk); 174 - 175 - if (rate <= 0) { 176 - DRM_ERROR("Rate is not set properly\n"); 177 - return -EINVAL; 178 - } 179 - 180 - req->rate = rate; 181 - 182 - DRM_DEBUG_DP("%s: rate=%ld\n", __func__, req->rate); 183 - return 0; 184 - } 185 - 186 - static unsigned long dp_pll_mux_recalc_rate(struct clk_hw *hw, 187 - unsigned long parent_rate) 188 - { 189 - struct clk_hw *div_clk_hw = NULL, *vco_clk_hw = NULL; 190 - struct dp_pll_vco_clk *vco; 191 - 192 - div_clk_hw = clk_hw_get_parent(hw); 193 - if (!div_clk_hw) 194 - return 0; 195 - 196 - vco_clk_hw = clk_hw_get_parent(div_clk_hw); 197 - if (!vco_clk_hw) 198 - return 0; 199 - 200 - vco = to_dp_vco_hw(vco_clk_hw); 201 - if (!vco) 202 - return 0; 203 - 204 - if (vco->rate == DP_VCO_HSCLK_RATE_8100MHZDIV1000) 205 - return (vco->rate / 6); 206 - else if (vco->rate == DP_VCO_HSCLK_RATE_5400MHZDIV1000) 207 - return (vco->rate / 4); 208 - else 209 - return (vco->rate / 2); 210 - } 211 - 212 - static int dp_pll_10nm_get_provider(struct msm_dp_pll *pll, 213 - struct clk **link_clk_provider, 214 - struct clk **pixel_clk_provider) 215 - { 216 - struct clk_hw_onecell_data *hw_data = pll->hw_data; 217 - 218 - if (link_clk_provider) 219 - *link_clk_provider = hw_data->hws[DP_LINK_CLK_SRC]->clk; 220 - if (pixel_clk_provider) 221 - *pixel_clk_provider = hw_data->hws[DP_PIXEL_CLK_SRC]->clk; 222 - 223 - return 0; 224 - } 225 - 226 - static const struct clk_ops dp_10nm_pclksel_clk_ops = { 227 - .get_parent = dp_pll_mux_get_parent_10nm, 228 - .set_parent = dp_pll_mux_set_parent_10nm, 229 - .recalc_rate = dp_pll_mux_recalc_rate, 230 - .determine_rate = dp_pll_clk_mux_determine_rate, 231 - }; 232 - 233 - static struct clk_hw *dp_pll_10nm_pixel_clk_sel(struct dp_pll_db *pll_10nm) 234 - { 235 - struct device *dev = &pll_10nm->pdev->dev; 236 - struct dp_pll_10nm_pclksel *pll_pclksel; 237 - struct clk_init_data pclksel_init = { 238 - .parent_data = disp_cc_parent_data_0, 239 - .num_parents = 3, 240 - .name = "dp_phy_pll_vco_div_clk", 241 - .ops = &dp_10nm_pclksel_clk_ops, 242 - }; 243 - int ret; 244 - 245 - pll_pclksel = devm_kzalloc(dev, sizeof(*pll_pclksel), GFP_KERNEL); 246 - if (!pll_pclksel) 247 - return ERR_PTR(-ENOMEM); 248 - 249 - pll_pclksel->pll = pll_10nm; 250 - pll_pclksel->shift = 0; 251 - pll_pclksel->width = 4; 252 - pll_pclksel->hw.init = &pclksel_init; 253 - 254 - ret = clk_hw_register(dev, &pll_pclksel->hw); 255 - if (ret) 256 - return ERR_PTR(ret); 257 - 258 - return &pll_pclksel->hw; 259 - } 260 - 261 - static void dp_pll_10nm_unregister(struct dp_pll_db *pll_10nm) 262 - { 263 - int i = 0; 264 - struct clk_hw **hws; 265 - 266 - hws = pll_10nm->hws; 267 - 268 - for (i = 0; i < pll_10nm->num_hws; i++) { 269 - if (pll_10nm->fixed_factor_clk[i] == true) 270 - clk_hw_unregister_fixed_factor(hws[i]); 271 - else 272 - clk_hw_unregister(hws[i]); 273 - } 274 - } 275 - 276 - static int dp_pll_10nm_register(struct dp_pll_db *pll_10nm) 277 - { 278 - struct clk_hw_onecell_data *hw_data; 279 - int ret = 0; 280 - struct clk_hw *hw; 281 - 282 - struct msm_dp_pll *pll = pll_10nm->base; 283 - struct device *dev = &pll_10nm->pdev->dev; 284 - struct clk_hw **hws = pll_10nm->hws; 285 - int num = 0; 286 - 287 - struct clk_init_data vco_init = { 288 - .parent_data = &(const struct clk_parent_data){ 289 - .fw_name = "bi_tcxo", 290 - }, 291 - .num_parents = 1, 292 - .name = "dp_vco_clk", 293 - .ops = &dp_10nm_vco_clk_ops, 294 - }; 295 - 296 - if (!dev) { 297 - DRM_ERROR("DP dev node not available\n"); 298 - return 0; 299 - } 300 - 301 - DRM_DEBUG_DP("DP->id = %d", pll_10nm->id); 302 - 303 - hw_data = devm_kzalloc(dev, sizeof(*hw_data) + 304 - NUM_PROVIDED_CLKS * sizeof(struct clk_hw *), 305 - GFP_KERNEL); 306 - if (!hw_data) 307 - return -ENOMEM; 308 - 309 - dp_vco_clk.hw.init = &vco_init; 310 - ret = clk_hw_register(dev, &dp_vco_clk.hw); 311 - if (ret) 312 - return ret; 313 - hws[num++] = &dp_vco_clk.hw; 314 - 315 - hw = clk_hw_register_fixed_factor(dev, "dp_phy_pll_link_clk", 316 - "dp_vco_clk", CLK_SET_RATE_PARENT, 1, 10); 317 - if (IS_ERR(hw)) 318 - return PTR_ERR(hw); 319 - 320 - pll_10nm->fixed_factor_clk[num] = true; 321 - hws[num++] = hw; 322 - hw_data->hws[DP_LINK_CLK_SRC] = hw; 323 - 324 - hw = clk_hw_register_fixed_factor(dev, "dp_vco_divsel_two_clk_src", 325 - "dp_vco_clk", 0, 1, 2); 326 - if (IS_ERR(hw)) 327 - return PTR_ERR(hw); 328 - 329 - pll_10nm->fixed_factor_clk[num] = true; 330 - hws[num++] = hw; 331 - 332 - hw = clk_hw_register_fixed_factor(dev, "dp_vco_divsel_four_clk_src", 333 - "dp_vco_clk", 0, 1, 4); 334 - if (IS_ERR(hw)) 335 - return PTR_ERR(hw); 336 - 337 - pll_10nm->fixed_factor_clk[num] = true; 338 - hws[num++] = hw; 339 - 340 - hw = clk_hw_register_fixed_factor(dev, "dp_vco_divsel_six_clk_src", 341 - "dp_vco_clk", 0, 1, 6); 342 - if (IS_ERR(hw)) 343 - return PTR_ERR(hw); 344 - 345 - pll_10nm->fixed_factor_clk[num] = true; 346 - hws[num++] = hw; 347 - 348 - hw = dp_pll_10nm_pixel_clk_sel(pll_10nm); 349 - if (IS_ERR(hw)) 350 - return PTR_ERR(hw); 351 - 352 - hws[num++] = hw; 353 - hw_data->hws[DP_PIXEL_CLK_SRC] = hw; 354 - 355 - pll_10nm->num_hws = num; 356 - 357 - hw_data->num = NUM_PROVIDED_CLKS; 358 - pll->hw_data = hw_data; 359 - 360 - ret = devm_of_clk_add_hw_provider(dev, of_clk_hw_onecell_get, 361 - pll->hw_data); 362 - if (ret) { 363 - DRM_DEV_ERROR(dev, "failed to register clk provider: %d\n", 364 - ret); 365 - return ret; 366 - } 367 - 368 - return ret; 369 - } 370 - 371 - void msm_dp_pll_10nm_deinit(struct msm_dp_pll *pll) 372 - { 373 - dp_pll_10nm_unregister(pll->priv); 374 - } 375 - 376 - int msm_dp_pll_10nm_init(struct msm_dp_pll *pll, int id) 377 - { 378 - struct dp_pll_db *dp_10nm_pll; 379 - struct platform_device *pdev = pll->pdev; 380 - int ret; 381 - 382 - dp_10nm_pll = devm_kzalloc(&pdev->dev, 383 - sizeof(*dp_10nm_pll), GFP_KERNEL); 384 - if (!dp_10nm_pll) 385 - return -ENOMEM; 386 - 387 - DRM_DEBUG_DP("DP PLL%d", id); 388 - 389 - dp_10nm_pll->base = pll; 390 - dp_10nm_pll->pdev = pll->pdev; 391 - dp_10nm_pll->id = id; 392 - dp_pdb = dp_10nm_pll; 393 - pll->priv = (void *)dp_10nm_pll; 394 - dp_vco_clk.priv = pll; 395 - dp_10nm_pll->index = 0; 396 - 397 - ret = dp_pll_10nm_register(dp_10nm_pll); 398 - if (ret) { 399 - DRM_DEV_ERROR(&pdev->dev, "failed to register PLL: %d\n", ret); 400 - return ret; 401 - } 402 - 403 - pll->get_provider = dp_pll_10nm_get_provider; 404 - 405 - return ret; 406 - } 407 - 408 - static int dp_vco_pll_init_db_10nm(struct msm_dp_pll *pll, 409 - unsigned long rate) 410 - { 411 - u32 spare_value = 0; 412 - struct dp_io_pll *pll_io; 413 - struct dp_pll_db *dp_res = to_dp_pll_db(pll); 414 - 415 - pll_io = &pll->pll_io; 416 - spare_value = PLL_REG_R(pll_io->phy_base, REG_DP_PHY_SPARE0); 417 - dp_res->lane_cnt = spare_value & 0x0F; 418 - dp_res->orientation = (spare_value & 0xF0) >> 4; 419 - 420 - DRM_DEBUG_DP("%s: spare_value=0x%x, ln_cnt=0x%x, orientation=0x%x\n", 421 - __func__, spare_value, dp_res->lane_cnt, 422 - dp_res->orientation); 423 - 424 - switch (rate) { 425 - case DP_VCO_HSCLK_RATE_1620MHZDIV1000: 426 - DRM_DEBUG_DP("%s: VCO rate: %ld\n", __func__, 427 - DP_VCO_RATE_9720MHZDIV1000); 428 - dp_res->hsclk_sel = 0x0c; 429 - dp_res->dec_start_mode0 = 0x69; 430 - dp_res->div_frac_start1_mode0 = 0x00; 431 - dp_res->div_frac_start2_mode0 = 0x80; 432 - dp_res->div_frac_start3_mode0 = 0x07; 433 - dp_res->integloop_gain0_mode0 = 0x3f; 434 - dp_res->integloop_gain1_mode0 = 0x00; 435 - dp_res->vco_tune_map = 0x00; 436 - dp_res->lock_cmp1_mode0 = 0x6f; 437 - dp_res->lock_cmp2_mode0 = 0x08; 438 - dp_res->lock_cmp3_mode0 = 0x00; 439 - dp_res->phy_vco_div = 0x1; 440 - dp_res->lock_cmp_en = 0x00; 441 - break; 442 - case DP_VCO_HSCLK_RATE_2700MHZDIV1000: 443 - DRM_DEBUG_DP("%s: VCO rate: %ld\n", __func__, 444 - DP_VCO_RATE_10800MHZDIV1000); 445 - dp_res->hsclk_sel = 0x04; 446 - dp_res->dec_start_mode0 = 0x69; 447 - dp_res->div_frac_start1_mode0 = 0x00; 448 - dp_res->div_frac_start2_mode0 = 0x80; 449 - dp_res->div_frac_start3_mode0 = 0x07; 450 - dp_res->integloop_gain0_mode0 = 0x3f; 451 - dp_res->integloop_gain1_mode0 = 0x00; 452 - dp_res->vco_tune_map = 0x00; 453 - dp_res->lock_cmp1_mode0 = 0x0f; 454 - dp_res->lock_cmp2_mode0 = 0x0e; 455 - dp_res->lock_cmp3_mode0 = 0x00; 456 - dp_res->phy_vco_div = 0x1; 457 - dp_res->lock_cmp_en = 0x00; 458 - break; 459 - case DP_VCO_HSCLK_RATE_5400MHZDIV1000: 460 - DRM_DEBUG_DP("%s: VCO rate: %ld\n", __func__, 461 - DP_VCO_RATE_10800MHZDIV1000); 462 - dp_res->hsclk_sel = 0x00; 463 - dp_res->dec_start_mode0 = 0x8c; 464 - dp_res->div_frac_start1_mode0 = 0x00; 465 - dp_res->div_frac_start2_mode0 = 0x00; 466 - dp_res->div_frac_start3_mode0 = 0x0a; 467 - dp_res->integloop_gain0_mode0 = 0x3f; 468 - dp_res->integloop_gain1_mode0 = 0x00; 469 - dp_res->vco_tune_map = 0x00; 470 - dp_res->lock_cmp1_mode0 = 0x1f; 471 - dp_res->lock_cmp2_mode0 = 0x1c; 472 - dp_res->lock_cmp3_mode0 = 0x00; 473 - dp_res->phy_vco_div = 0x2; 474 - dp_res->lock_cmp_en = 0x00; 475 - break; 476 - case DP_VCO_HSCLK_RATE_8100MHZDIV1000: 477 - DRM_DEBUG_DP("%s: VCO rate: %ld\n", __func__, 478 - DP_VCO_RATE_8100MHZDIV1000); 479 - dp_res->hsclk_sel = 0x03; 480 - dp_res->dec_start_mode0 = 0x69; 481 - dp_res->div_frac_start1_mode0 = 0x00; 482 - dp_res->div_frac_start2_mode0 = 0x80; 483 - dp_res->div_frac_start3_mode0 = 0x07; 484 - dp_res->integloop_gain0_mode0 = 0x3f; 485 - dp_res->integloop_gain1_mode0 = 0x00; 486 - dp_res->vco_tune_map = 0x00; 487 - dp_res->lock_cmp1_mode0 = 0x2f; 488 - dp_res->lock_cmp2_mode0 = 0x2a; 489 - dp_res->lock_cmp3_mode0 = 0x00; 490 - dp_res->phy_vco_div = 0x0; 491 - dp_res->lock_cmp_en = 0x08; 492 - break; 493 - default: 494 - return -EINVAL; 495 - } 496 - return 0; 497 - } 498 - 499 - static int dp_config_vco_rate_10nm(struct dp_pll_vco_clk *vco, 500 - unsigned long rate) 501 - { 502 - u32 res = 0; 503 - struct msm_dp_pll *pll = vco->priv; 504 - struct dp_io_pll *pll_io = &pll->pll_io; 505 - struct dp_pll_db *dp_res = to_dp_pll_db(pll); 506 - 507 - res = dp_vco_pll_init_db_10nm(pll, rate); 508 - if (res) { 509 - DRM_ERROR("VCO Init DB failed\n"); 510 - return res; 511 - } 512 - 513 - if (dp_res->lane_cnt != 4) { 514 - if (dp_res->orientation == ORIENTATION_CC2) 515 - PLL_REG_W(pll_io->phy_base, REG_DP_PHY_PD_CTL, 0x6d); 516 - else 517 - PLL_REG_W(pll_io->phy_base, REG_DP_PHY_PD_CTL, 0x75); 518 - } else { 519 - PLL_REG_W(pll_io->phy_base, REG_DP_PHY_PD_CTL, 0x7d); 520 - } 521 - 522 - PLL_REG_W(pll_io->pll_base, QSERDES_COM_SVS_MODE_CLK_SEL, 0x01); 523 - PLL_REG_W(pll_io->pll_base, QSERDES_COM_SYSCLK_EN_SEL, 0x37); 524 - PLL_REG_W(pll_io->pll_base, QSERDES_COM_SYS_CLK_CTRL, 0x02); 525 - PLL_REG_W(pll_io->pll_base, QSERDES_COM_CLK_ENABLE1, 0x0e); 526 - PLL_REG_W(pll_io->pll_base, QSERDES_COM_SYSCLK_BUF_ENABLE, 0x06); 527 - PLL_REG_W(pll_io->pll_base, QSERDES_COM_CLK_SEL, 0x30); 528 - PLL_REG_W(pll_io->pll_base, QSERDES_COM_CMN_CONFIG, 0x02); 529 - 530 - /* Different for each clock rates */ 531 - PLL_REG_W(pll_io->pll_base, 532 - QSERDES_COM_HSCLK_SEL, dp_res->hsclk_sel); 533 - PLL_REG_W(pll_io->pll_base, 534 - QSERDES_COM_DEC_START_MODE0, dp_res->dec_start_mode0); 535 - PLL_REG_W(pll_io->pll_base, 536 - QSERDES_COM_DIV_FRAC_START1_MODE0, 537 - dp_res->div_frac_start1_mode0); 538 - PLL_REG_W(pll_io->pll_base, 539 - QSERDES_COM_DIV_FRAC_START2_MODE0, 540 - dp_res->div_frac_start2_mode0); 541 - PLL_REG_W(pll_io->pll_base, 542 - QSERDES_COM_DIV_FRAC_START3_MODE0, 543 - dp_res->div_frac_start3_mode0); 544 - PLL_REG_W(pll_io->pll_base, 545 - QSERDES_COM_INTEGLOOP_GAIN0_MODE0, 546 - dp_res->integloop_gain0_mode0); 547 - PLL_REG_W(pll_io->pll_base, 548 - QSERDES_COM_INTEGLOOP_GAIN1_MODE0, 549 - dp_res->integloop_gain1_mode0); 550 - PLL_REG_W(pll_io->pll_base, 551 - QSERDES_COM_VCO_TUNE_MAP, dp_res->vco_tune_map); 552 - PLL_REG_W(pll_io->pll_base, 553 - QSERDES_COM_LOCK_CMP1_MODE0, dp_res->lock_cmp1_mode0); 554 - PLL_REG_W(pll_io->pll_base, 555 - QSERDES_COM_LOCK_CMP2_MODE0, dp_res->lock_cmp2_mode0); 556 - PLL_REG_W(pll_io->pll_base, 557 - QSERDES_COM_LOCK_CMP3_MODE0, dp_res->lock_cmp3_mode0); 558 - 559 - PLL_REG_W(pll_io->pll_base, QSERDES_COM_BG_TIMER, 0x0a); 560 - PLL_REG_W(pll_io->pll_base, QSERDES_COM_CORECLK_DIV_MODE0, 0x0a); 561 - PLL_REG_W(pll_io->pll_base, QSERDES_COM_VCO_TUNE_CTRL, 0x00); 562 - PLL_REG_W(pll_io->pll_base, QSERDES_COM_BIAS_EN_CLKBUFLR_EN, 0x3f); 563 - PLL_REG_W(pll_io->pll_base, QSERDES_COM_CORE_CLK_EN, 0x1f); 564 - PLL_REG_W(pll_io->pll_base, QSERDES_COM_PLL_IVCO, 0x07); 565 - PLL_REG_W(pll_io->pll_base, 566 - QSERDES_COM_LOCK_CMP_EN, dp_res->lock_cmp_en); 567 - PLL_REG_W(pll_io->pll_base, QSERDES_COM_PLL_CCTRL_MODE0, 0x36); 568 - PLL_REG_W(pll_io->pll_base, QSERDES_COM_PLL_RCTRL_MODE0, 0x16); 569 - PLL_REG_W(pll_io->pll_base, QSERDES_COM_CP_CTRL_MODE0, 0x06); 570 - 571 - if (dp_res->orientation == ORIENTATION_CC2) 572 - PLL_REG_W(pll_io->phy_base, REG_DP_PHY_MODE, 0x4c); 573 - else 574 - PLL_REG_W(pll_io->phy_base, REG_DP_PHY_MODE, 0x5c); 575 - 576 - /* TX Lane configuration */ 577 - PLL_REG_W(pll_io->phy_base, 578 - REG_DP_PHY_TX0_TX1_LANE_CTL, 0x05); 579 - PLL_REG_W(pll_io->phy_base, 580 - REG_DP_PHY_TX2_TX3_LANE_CTL, 0x05); 581 - 582 - /* TX-0 register configuration */ 583 - PLL_REG_W(pll_io->ln_tx0_base, 584 - REG_DP_PHY_TXn_TRANSCEIVER_BIAS_EN, 0x1a); 585 - PLL_REG_W(pll_io->ln_tx0_base, 586 - REG_DP_PHY_TXn_VMODE_CTRL1, 0x40); 587 - PLL_REG_W(pll_io->ln_tx0_base, 588 - REG_DP_PHY_TXn_PRE_STALL_LDO_BOOST_EN, 0x30); 589 - PLL_REG_W(pll_io->ln_tx0_base, 590 - REG_DP_PHY_TXn_INTERFACE_SELECT, 0x3d); 591 - PLL_REG_W(pll_io->ln_tx0_base, 592 - REG_DP_PHY_TXn_CLKBUF_ENABLE, 0x0f); 593 - PLL_REG_W(pll_io->ln_tx0_base, 594 - REG_DP_PHY_TXn_RESET_TSYNC_EN, 0x03); 595 - PLL_REG_W(pll_io->ln_tx0_base, 596 - REG_DP_PHY_TXn_TRAN_DRVR_EMP_EN, 0x03); 597 - PLL_REG_W(pll_io->ln_tx0_base, 598 - REG_DP_PHY_TXn_PARRATE_REC_DETECT_IDLE_EN, 0x00); 599 - PLL_REG_W(pll_io->ln_tx0_base, 600 - REG_DP_PHY_TXn_TX_INTERFACE_MODE, 0x00); 601 - PLL_REG_W(pll_io->ln_tx0_base, REG_DP_PHY_TXn_TX_BAND, 0x4); 602 - 603 - /* TX-1 register configuration */ 604 - PLL_REG_W(pll_io->ln_tx1_base, 605 - REG_DP_PHY_TXn_TRANSCEIVER_BIAS_EN, 0x1a); 606 - PLL_REG_W(pll_io->ln_tx1_base, 607 - REG_DP_PHY_TXn_VMODE_CTRL1, 0x40); 608 - PLL_REG_W(pll_io->ln_tx1_base, 609 - REG_DP_PHY_TXn_PRE_STALL_LDO_BOOST_EN, 0x30); 610 - PLL_REG_W(pll_io->ln_tx1_base, 611 - REG_DP_PHY_TXn_INTERFACE_SELECT, 0x3d); 612 - PLL_REG_W(pll_io->ln_tx1_base, 613 - REG_DP_PHY_TXn_CLKBUF_ENABLE, 0x0f); 614 - PLL_REG_W(pll_io->ln_tx1_base, 615 - REG_DP_PHY_TXn_RESET_TSYNC_EN, 0x03); 616 - PLL_REG_W(pll_io->ln_tx1_base, 617 - REG_DP_PHY_TXn_TRAN_DRVR_EMP_EN, 0x03); 618 - PLL_REG_W(pll_io->ln_tx1_base, 619 - REG_DP_PHY_TXn_PARRATE_REC_DETECT_IDLE_EN, 0x00); 620 - PLL_REG_W(pll_io->ln_tx1_base, 621 - REG_DP_PHY_TXn_TX_INTERFACE_MODE, 0x00); 622 - PLL_REG_W(pll_io->ln_tx1_base, 623 - REG_DP_PHY_TXn_TX_BAND, 0x4); 624 - 625 - /* dependent on the vco frequency */ 626 - PLL_REG_W(pll_io->phy_base, 627 - REG_DP_PHY_VCO_DIV, dp_res->phy_vco_div); 628 - 629 - return res; 630 - } 631 - 632 - static bool dp_10nm_pll_lock_status(struct dp_pll_db *dp_res) 633 - { 634 - u32 status; 635 - bool pll_locked; 636 - struct dp_io_pll *pll_io = &dp_res->base->pll_io; 637 - 638 - /* poll for PLL lock status */ 639 - if (readl_poll_timeout_atomic((pll_io->pll_base + 640 - QSERDES_COM_C_READY_STATUS), 641 - status, 642 - ((status & BIT(0)) > 0), 643 - DP_PHY_PLL_POLL_SLEEP_US, 644 - DP_PHY_PLL_POLL_TIMEOUT_US)) { 645 - DRM_ERROR("%s: C_READY status is not high. Status=%x\n", 646 - __func__, status); 647 - pll_locked = false; 648 - } else { 649 - pll_locked = true; 650 - } 651 - 652 - return pll_locked; 653 - } 654 - 655 - static bool dp_10nm_phy_rdy_status(struct dp_pll_db *dp_res) 656 - { 657 - u32 status; 658 - bool phy_ready = true; 659 - struct dp_io_pll *pll_io = &dp_res->base->pll_io; 660 - 661 - /* poll for PHY ready status */ 662 - if (readl_poll_timeout_atomic((pll_io->phy_base + 663 - REG_DP_PHY_STATUS), 664 - status, 665 - ((status & (BIT(1))) > 0), 666 - DP_PHY_PLL_POLL_SLEEP_US, 667 - DP_PHY_PLL_POLL_TIMEOUT_US)) { 668 - DRM_ERROR("%s: Phy_ready is not high. Status=%x\n", 669 - __func__, status); 670 - phy_ready = false; 671 - } 672 - 673 - return phy_ready; 674 - } 675 - 676 - static int dp_pll_enable_10nm(struct clk_hw *hw) 677 - { 678 - int rc = 0; 679 - u32 bias_en, drvr_en; 680 - struct dp_io_pll *pll_io; 681 - struct dp_pll_vco_clk *vco = to_dp_vco_hw(hw); 682 - struct msm_dp_pll *pll = to_msm_dp_pll(vco); 683 - struct dp_pll_db *dp_res = to_dp_pll_db(pll); 684 - 685 - pll_io = &pll->pll_io; 686 - 687 - PLL_REG_W(pll_io->phy_base, REG_DP_PHY_AUX_CFG2, 0x04); 688 - PLL_REG_W(pll_io->phy_base, REG_DP_PHY_CFG, 0x01); 689 - PLL_REG_W(pll_io->phy_base, REG_DP_PHY_CFG, 0x05); 690 - PLL_REG_W(pll_io->phy_base, REG_DP_PHY_CFG, 0x01); 691 - PLL_REG_W(pll_io->phy_base, REG_DP_PHY_CFG, 0x09); 692 - 693 - PLL_REG_W(pll_io->pll_base, QSERDES_COM_RESETSM_CNTRL, 0x20); 694 - 695 - if (!dp_10nm_pll_lock_status(dp_res)) { 696 - rc = -EINVAL; 697 - goto lock_err; 698 - } 699 - 700 - PLL_REG_W(pll_io->phy_base, REG_DP_PHY_CFG, 0x19); 701 - /* poll for PHY ready status */ 702 - if (!dp_10nm_phy_rdy_status(dp_res)) { 703 - rc = -EINVAL; 704 - goto lock_err; 705 - } 706 - 707 - DRM_DEBUG_DP("%s: PLL is locked\n", __func__); 708 - 709 - if (dp_res->lane_cnt == 1) { 710 - bias_en = 0x3e; 711 - drvr_en = 0x13; 712 - } else { 713 - bias_en = 0x3f; 714 - drvr_en = 0x10; 715 - } 716 - 717 - if (dp_res->lane_cnt != 4) { 718 - if (dp_res->orientation == ORIENTATION_CC1) { 719 - PLL_REG_W(pll_io->ln_tx1_base, 720 - REG_DP_PHY_TXn_HIGHZ_DRVR_EN, drvr_en); 721 - PLL_REG_W(pll_io->ln_tx1_base, 722 - REG_DP_PHY_TXn_TRANSCEIVER_BIAS_EN, bias_en); 723 - } else { 724 - PLL_REG_W(pll_io->ln_tx0_base, 725 - REG_DP_PHY_TXn_HIGHZ_DRVR_EN, drvr_en); 726 - PLL_REG_W(pll_io->ln_tx0_base, 727 - REG_DP_PHY_TXn_TRANSCEIVER_BIAS_EN, bias_en); 728 - } 729 - } else { 730 - PLL_REG_W(pll_io->ln_tx0_base, 731 - REG_DP_PHY_TXn_HIGHZ_DRVR_EN, drvr_en); 732 - PLL_REG_W(pll_io->ln_tx0_base, 733 - REG_DP_PHY_TXn_TRANSCEIVER_BIAS_EN, bias_en); 734 - PLL_REG_W(pll_io->ln_tx1_base, 735 - REG_DP_PHY_TXn_HIGHZ_DRVR_EN, drvr_en); 736 - PLL_REG_W(pll_io->ln_tx1_base, 737 - REG_DP_PHY_TXn_TRANSCEIVER_BIAS_EN, bias_en); 738 - } 739 - 740 - PLL_REG_W(pll_io->ln_tx0_base, REG_DP_PHY_TXn_TX_POL_INV, 0x0a); 741 - PLL_REG_W(pll_io->ln_tx1_base, REG_DP_PHY_TXn_TX_POL_INV, 0x0a); 742 - PLL_REG_W(pll_io->phy_base, REG_DP_PHY_CFG, 0x18); 743 - udelay(2000); 744 - 745 - PLL_REG_W(pll_io->phy_base, REG_DP_PHY_CFG, 0x19); 746 - 747 - /* poll for PHY ready status */ 748 - if (!dp_10nm_phy_rdy_status(dp_res)) { 749 - rc = -EINVAL; 750 - goto lock_err; 751 - } 752 - 753 - PLL_REG_W(pll_io->ln_tx0_base, REG_DP_PHY_TXn_TX_DRV_LVL, 0x38); 754 - PLL_REG_W(pll_io->ln_tx1_base, REG_DP_PHY_TXn_TX_DRV_LVL, 0x38); 755 - PLL_REG_W(pll_io->ln_tx0_base, REG_DP_PHY_TXn_TX_EMP_POST1_LVL, 0x20); 756 - PLL_REG_W(pll_io->ln_tx1_base, REG_DP_PHY_TXn_TX_EMP_POST1_LVL, 0x20); 757 - PLL_REG_W(pll_io->ln_tx0_base, 758 - REG_DP_PHY_TXn_RES_CODE_LANE_OFFSET_TX, 0x06); 759 - PLL_REG_W(pll_io->ln_tx1_base, 760 - REG_DP_PHY_TXn_RES_CODE_LANE_OFFSET_TX, 0x06); 761 - PLL_REG_W(pll_io->ln_tx0_base, 762 - REG_DP_PHY_TXn_RES_CODE_LANE_OFFSET_RX, 0x07); 763 - PLL_REG_W(pll_io->ln_tx1_base, 764 - REG_DP_PHY_TXn_RES_CODE_LANE_OFFSET_RX, 0x07); 765 - 766 - lock_err: 767 - return rc; 768 - } 769 - 770 - static int dp_pll_disable_10nm(struct clk_hw *hw) 771 - { 772 - int rc = 0; 773 - struct dp_pll_vco_clk *vco = to_dp_vco_hw(hw); 774 - struct msm_dp_pll *pll = to_msm_dp_pll(vco); 775 - 776 - /* Assert DP PHY power down */ 777 - PLL_REG_W(pll->pll_io.phy_base, REG_DP_PHY_PD_CTL, 0x2); 778 - 779 - return rc; 780 - } 781 - 782 - 783 - static int dp_vco_prepare_10nm(struct clk_hw *hw) 784 - { 785 - int rc = 0; 786 - struct dp_pll_vco_clk *vco = to_dp_vco_hw(hw); 787 - struct msm_dp_pll *pll = (struct msm_dp_pll *)vco->priv; 788 - struct dp_pll_db *dp_res = to_dp_pll_db(pll); 789 - 790 - DRM_DEBUG_DP("%s: rate = %ld\n", __func__, vco->rate); 791 - if ((dp_res->vco_cached_rate != 0) 792 - && (dp_res->vco_cached_rate == vco->rate)) { 793 - rc = dp_vco_set_rate_10nm(hw, 794 - dp_res->vco_cached_rate, dp_res->vco_cached_rate); 795 - if (rc) { 796 - DRM_ERROR("index=%d vco_set_rate failed. rc=%d\n", 797 - rc, dp_res->index); 798 - goto error; 799 - } 800 - } 801 - 802 - rc = dp_pll_enable_10nm(hw); 803 - if (rc) { 804 - DRM_ERROR("ndx=%d failed to enable dp pll\n", 805 - dp_res->index); 806 - goto error; 807 - } 808 - 809 - pll->pll_on = true; 810 - error: 811 - return rc; 812 - } 813 - 814 - static void dp_vco_unprepare_10nm(struct clk_hw *hw) 815 - { 816 - struct dp_pll_vco_clk *vco = to_dp_vco_hw(hw); 817 - struct msm_dp_pll *pll = to_msm_dp_pll(vco); 818 - struct dp_pll_db *dp_res = to_dp_pll_db(pll); 819 - 820 - if (!dp_res) { 821 - DRM_ERROR("Invalid input parameter\n"); 822 - return; 823 - } 824 - 825 - if (!pll->pll_on) { 826 - DRM_ERROR("pll resource can't be enabled\n"); 827 - return; 828 - } 829 - dp_res->vco_cached_rate = vco->rate; 830 - dp_pll_disable_10nm(hw); 831 - 832 - pll->pll_on = false; 833 - } 834 - 835 - static int dp_vco_set_rate_10nm(struct clk_hw *hw, unsigned long rate, 836 - unsigned long parent_rate) 837 - { 838 - struct dp_pll_vco_clk *vco = to_dp_vco_hw(hw); 839 - int rc; 840 - 841 - DRM_DEBUG_DP("DP lane CLK rate=%ld\n", rate); 842 - 843 - rc = dp_config_vco_rate_10nm(vco, rate); 844 - if (rc) 845 - DRM_ERROR("%s: Failed to set clk rate\n", __func__); 846 - 847 - vco->rate = rate; 848 - 849 - return 0; 850 - } 851 - 852 - static unsigned long dp_vco_recalc_rate_10nm(struct clk_hw *hw, 853 - unsigned long parent_rate) 854 - { 855 - u32 div, hsclk_div, link_clk_div = 0; 856 - u64 vco_rate; 857 - struct dp_io_pll *pll_io; 858 - struct dp_pll_vco_clk *vco = to_dp_vco_hw(hw); 859 - struct msm_dp_pll *pll = to_msm_dp_pll(vco); 860 - struct dp_pll_db *dp_res = to_dp_pll_db(pll); 861 - 862 - pll_io = &pll->pll_io; 863 - 864 - div = PLL_REG_R(pll_io->pll_base, QSERDES_COM_HSCLK_SEL); 865 - div &= 0x0f; 866 - 867 - if (div == 12) 868 - hsclk_div = 6; /* Default */ 869 - else if (div == 4) 870 - hsclk_div = 4; 871 - else if (div == 0) 872 - hsclk_div = 2; 873 - else if (div == 3) 874 - hsclk_div = 1; 875 - else { 876 - DRM_DEBUG_DP("unknown divider. forcing to default\n"); 877 - hsclk_div = 5; 878 - } 879 - 880 - div = PLL_REG_R(pll_io->phy_base, REG_DP_PHY_AUX_CFG2); 881 - div >>= 2; 882 - 883 - if ((div & 0x3) == 0) 884 - link_clk_div = 5; 885 - else if ((div & 0x3) == 1) 886 - link_clk_div = 10; 887 - else if ((div & 0x3) == 2) 888 - link_clk_div = 20; 889 - else 890 - DRM_ERROR("%s: unsupported div. Phy_mode: %d\n", __func__, div); 891 - 892 - if (link_clk_div == 20) { 893 - vco_rate = DP_VCO_HSCLK_RATE_2700MHZDIV1000; 894 - } else { 895 - if (hsclk_div == 6) 896 - vco_rate = DP_VCO_HSCLK_RATE_1620MHZDIV1000; 897 - else if (hsclk_div == 4) 898 - vco_rate = DP_VCO_HSCLK_RATE_2700MHZDIV1000; 899 - else if (hsclk_div == 2) 900 - vco_rate = DP_VCO_HSCLK_RATE_5400MHZDIV1000; 901 - else 902 - vco_rate = DP_VCO_HSCLK_RATE_8100MHZDIV1000; 903 - } 904 - 905 - DRM_DEBUG_DP("returning vco rate = %lu\n", (unsigned long)vco_rate); 906 - 907 - dp_res->vco_cached_rate = vco->rate = vco_rate; 908 - return (unsigned long)vco_rate; 909 - } 910 - 911 - long dp_vco_round_rate_10nm(struct clk_hw *hw, unsigned long rate, 912 - unsigned long *parent_rate) 913 - { 914 - unsigned long rrate = rate; 915 - struct dp_pll_vco_clk *vco = to_dp_vco_hw(hw); 916 - 917 - if (rate <= vco->min_rate) 918 - rrate = vco->min_rate; 919 - else if (rate <= DP_VCO_HSCLK_RATE_2700MHZDIV1000) 920 - rrate = DP_VCO_HSCLK_RATE_2700MHZDIV1000; 921 - else if (rate <= DP_VCO_HSCLK_RATE_5400MHZDIV1000) 922 - rrate = DP_VCO_HSCLK_RATE_5400MHZDIV1000; 923 - else 924 - rrate = vco->max_rate; 925 - 926 - DRM_DEBUG_DP("%s: rrate=%ld\n", __func__, rrate); 927 - 928 - *parent_rate = rrate; 929 - return rrate; 930 - }
-89
drivers/gpu/drm/msm/dp/dp_pll_private.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0-only */ 2 - /* 3 - * Copyright (c) 2016-2020, The Linux Foundation. All rights reserved. 4 - */ 5 - 6 - #ifndef __DP_PLL_10NM_H 7 - #define __DP_PLL_10NM_H 8 - 9 - #include "dp_pll.h" 10 - #include "dp_reg.h" 11 - 12 - #define DP_VCO_HSCLK_RATE_1620MHZDIV1000 1620000UL 13 - #define DP_VCO_HSCLK_RATE_2700MHZDIV1000 2700000UL 14 - #define DP_VCO_HSCLK_RATE_5400MHZDIV1000 5400000UL 15 - #define DP_VCO_HSCLK_RATE_8100MHZDIV1000 8100000UL 16 - 17 - #define NUM_DP_CLOCKS_MAX 6 18 - 19 - #define DP_PHY_PLL_POLL_SLEEP_US 500 20 - #define DP_PHY_PLL_POLL_TIMEOUT_US 10000 21 - 22 - #define DP_VCO_RATE_8100MHZDIV1000 8100000UL 23 - #define DP_VCO_RATE_9720MHZDIV1000 9720000UL 24 - #define DP_VCO_RATE_10800MHZDIV1000 10800000UL 25 - 26 - struct dp_pll_vco_clk { 27 - struct clk_hw hw; 28 - unsigned long rate; /* current vco rate */ 29 - u64 min_rate; /* min vco rate */ 30 - u64 max_rate; /* max vco rate */ 31 - void *priv; 32 - }; 33 - 34 - struct dp_pll_db { 35 - struct msm_dp_pll *base; 36 - 37 - int id; 38 - struct platform_device *pdev; 39 - 40 - /* private clocks: */ 41 - bool fixed_factor_clk[NUM_DP_CLOCKS_MAX]; 42 - struct clk_hw *hws[NUM_DP_CLOCKS_MAX]; 43 - u32 num_hws; 44 - 45 - /* lane and orientation settings */ 46 - u8 lane_cnt; 47 - u8 orientation; 48 - 49 - /* COM PHY settings */ 50 - u32 hsclk_sel; 51 - u32 dec_start_mode0; 52 - u32 div_frac_start1_mode0; 53 - u32 div_frac_start2_mode0; 54 - u32 div_frac_start3_mode0; 55 - u32 integloop_gain0_mode0; 56 - u32 integloop_gain1_mode0; 57 - u32 vco_tune_map; 58 - u32 lock_cmp1_mode0; 59 - u32 lock_cmp2_mode0; 60 - u32 lock_cmp3_mode0; 61 - u32 lock_cmp_en; 62 - 63 - /* PHY vco divider */ 64 - u32 phy_vco_div; 65 - /* 66 - * Certain pll's needs to update the same vco rate after resume in 67 - * suspend/resume scenario. Cached the vco rate for such plls. 68 - */ 69 - unsigned long vco_cached_rate; 70 - u32 cached_cfg0; 71 - u32 cached_cfg1; 72 - u32 cached_outdiv; 73 - 74 - uint32_t index; 75 - }; 76 - 77 - static inline struct dp_pll_vco_clk *to_dp_vco_hw(struct clk_hw *hw) 78 - { 79 - return container_of(hw, struct dp_pll_vco_clk, hw); 80 - } 81 - 82 - #define to_msm_dp_pll(vco) ((struct msm_dp_pll *)vco->priv) 83 - 84 - #define to_dp_pll_db(x) ((struct dp_pll_db *)x->priv) 85 - 86 - int msm_dp_pll_10nm_init(struct msm_dp_pll *dp_pll, int id); 87 - void msm_dp_pll_10nm_deinit(struct msm_dp_pll *dp_pll); 88 - 89 - #endif /* __DP_PLL_10NM_H */
+1 -38
drivers/gpu/drm/msm/dp/dp_power.c
··· 9 9 #include <linux/clk-provider.h> 10 10 #include <linux/regulator/consumer.h> 11 11 #include "dp_power.h" 12 + #include "msm_drv.h" 12 13 13 14 struct dp_power_private { 14 15 struct dp_parser *parser; ··· 102 101 core = &power->parser->mp[DP_CORE_PM]; 103 102 ctrl = &power->parser->mp[DP_CTRL_PM]; 104 103 stream = &power->parser->mp[DP_STREAM_PM]; 105 - 106 - if (power->parser->pll && power->parser->pll->get_provider) { 107 - rc = power->parser->pll->get_provider(power->parser->pll, 108 - &power->link_provider, &power->pixel_provider); 109 - if (rc) { 110 - DRM_ERROR("%s:provider failed,don't set parent\n", 111 - __func__); 112 - return 0; 113 - } 114 - } 115 104 116 105 rc = msm_dss_get_clk(dev, core->clk_config, core->num_clk); 117 106 if (rc) { ··· 301 310 dp_power_clk_deinit(power); 302 311 pm_runtime_disable(&power->pdev->dev); 303 312 304 - } 305 - 306 - int dp_power_set_link_clk_parent(struct dp_power *dp_power) 307 - { 308 - int rc = 0; 309 - struct dp_power_private *power; 310 - u32 num; 311 - struct dss_clk *cfg; 312 - char *name = "ctrl_link"; 313 - 314 - if (!dp_power) { 315 - DRM_ERROR("invalid power data\n"); 316 - rc = -EINVAL; 317 - goto exit; 318 - } 319 - 320 - power = container_of(dp_power, struct dp_power_private, dp_power); 321 - 322 - num = power->parser->mp[DP_CTRL_PM].num_clk; 323 - cfg = power->parser->mp[DP_CTRL_PM].clk_config; 324 - 325 - while (num && strcmp(cfg->clk_name, name)) { 326 - num--; 327 - cfg++; 328 - } 329 - 330 - exit: 331 - return rc; 332 313 } 333 314 334 315 int dp_power_init(struct dp_power *dp_power, bool flip)
-9
drivers/gpu/drm/msm/dp/dp_power.h
··· 69 69 70 70 int dp_power_clk_enable(struct dp_power *power, enum dp_pm_type pm_type, 71 71 bool enable); 72 - /** 73 - * dp_power_set_link_clk_parent() - configures parent of link clocks 74 - * 75 - * @power: instance of power module 76 - * return: 0 for success, error for failures 77 - * 78 - * This API will set the link clock parent source 79 - */ 80 - int dp_power_set_link_clk_parent(struct dp_power *power); 81 72 82 73 /** 83 74 * dp_power_client_init() - initialize clock and regulator modules
-213
drivers/gpu/drm/msm/dp/dp_reg.h
··· 6 6 #ifndef _DP_REG_H_ 7 7 #define _DP_REG_H_ 8 8 9 - /* DP PHY Register Regions */ 10 - #define REG_DP_PHY_REGION_BASE (0x088ea000) 11 - #define REG_DP_PHY_REGION_SIZE (0x00000C00) 12 - 13 - #define REG_USB3_DP_COM_REGION_BASE (0x088e8000) 14 - #define REG_USB3_DP_COM_REGION_SIZE (0x00000020) 15 - 16 - #define DP_PHY_PLL_OFFSET (0x00000000) 17 - #define DP_PHY_PLL_SIZE (0x00000200) 18 - #define DP_PHY_REG_OFFSET (0x00000A00) 19 - #define DP_PHY_REG_SIZE (0x00000200) 20 - #define DP_PHY_LN_TX0_OFFSET (0x00000200) 21 - #define DP_PHY_LN_TX0_SIZE (0x00000200) 22 - #define DP_PHY_LN_TX1_OFFSET (0x00000600) 23 - #define DP_PHY_LN_TX1_SIZE (0x00000200) 24 - 25 9 /* DP_TX Registers */ 26 10 #define REG_DP_HW_VERSION (0x00000000) 27 11 ··· 274 290 275 291 #define MMSS_DP_ASYNC_FIFO_CONFIG (0x00000088) 276 292 277 - /*DP PHY Register offsets */ 278 - #define REG_DP_PHY_REVISION_ID0 (0x00000000) 279 - #define REG_DP_PHY_REVISION_ID1 (0x00000004) 280 - #define REG_DP_PHY_REVISION_ID2 (0x00000008) 281 - #define REG_DP_PHY_REVISION_ID3 (0x0000000C) 282 - 283 - #define REG_DP_PHY_CFG (0x00000010) 284 - 285 - #define REG_DP_PHY_PD_CTL (0x00000018) 286 - #define DP_PHY_PD_CTL_PWRDN (0x00000001) 287 - #define DP_PHY_PD_CTL_PSR_PWRDN (0x00000002) 288 - #define DP_PHY_PD_CTL_AUX_PWRDN (0x00000004) 289 - #define DP_PHY_PD_CTL_LANE_0_1_PWRDN (0x00000008) 290 - #define DP_PHY_PD_CTL_LANE_2_3_PWRDN (0x00000010) 291 - #define DP_PHY_PD_CTL_PLL_PWRDN (0x00000020) 292 - #define DP_PHY_PD_CTL_DP_CLAMP_EN (0x00000040) 293 - 294 - #define REG_DP_PHY_MODE (0x0000001C) 295 - 296 - #define REG_DP_PHY_AUX_CFG0 (0x00000020) 297 - #define REG_DP_PHY_AUX_CFG1 (0x00000024) 298 - #define REG_DP_PHY_AUX_CFG2 (0x00000028) 299 - #define REG_DP_PHY_AUX_CFG3 (0x0000002C) 300 - #define REG_DP_PHY_AUX_CFG4 (0x00000030) 301 - #define REG_DP_PHY_AUX_CFG5 (0x00000034) 302 - #define REG_DP_PHY_AUX_CFG6 (0x00000038) 303 - #define REG_DP_PHY_AUX_CFG7 (0x0000003C) 304 - #define REG_DP_PHY_AUX_CFG8 (0x00000040) 305 - #define REG_DP_PHY_AUX_CFG9 (0x00000044) 306 - 307 - #define REG_DP_PHY_AUX_INTERRUPT_MASK (0x00000048) 308 - #define PHY_AUX_STOP_ERR_MASK (0x00000001) 309 - #define PHY_AUX_DEC_ERR_MASK (0x00000002) 310 - #define PHY_AUX_SYNC_ERR_MASK (0x00000004) 311 - #define PHY_AUX_ALIGN_ERR_MASK (0x00000008) 312 - #define PHY_AUX_REQ_ERR_MASK (0x00000010) 313 - 314 - 315 293 #define REG_DP_PHY_AUX_INTERRUPT_CLEAR (0x0000004C) 316 294 #define REG_DP_PHY_AUX_BIST_CFG (0x00000050) 317 295 #define REG_DP_PHY_AUX_INTERRUPT_STATUS (0x000000BC) 318 - 319 - #define REG_DP_PHY_VCO_DIV 0x0064 320 - #define REG_DP_PHY_TX0_TX1_LANE_CTL 0x006C 321 - #define REG_DP_PHY_TX2_TX3_LANE_CTL 0x0088 322 - 323 - #define REG_DP_PHY_SPARE0 (0x00AC) 324 - #define DP_PHY_SPARE0_MASK (0x000F) 325 - #define DP_PHY_SPARE0_ORIENTATION_INFO_SHIFT (0x0004) 326 - 327 - #define REG_DP_PHY_STATUS (0x00C0) 328 - 329 - /* Tx registers */ 330 - #define REG_DP_PHY_TXn_BIST_MODE_LANENO 0x0000 331 - #define REG_DP_PHY_TXn_CLKBUF_ENABLE 0x0008 332 - 333 - #define REG_DP_PHY_TXn_TX_EMP_POST1_LVL 0x000C 334 - #define DP_PHY_TXn_TX_EMP_POST1_LVL_MASK 0x001F 335 - #define DP_PHY_TXn_TX_EMP_POST1_LVL_MUX_EN 0x0020 336 - 337 - #define REG_DP_PHY_TXn_TX_DRV_LVL 0x001C 338 - #define DP_PHY_TXn_TX_DRV_LVL_MASK 0x001F 339 - #define DP_PHY_TXn_TX_DRV_LVL_MUX_EN 0x0020 340 - 341 - #define REG_DP_PHY_TXn_RESET_TSYNC_EN 0x0024 342 - #define REG_DP_PHY_TXn_PRE_STALL_LDO_BOOST_EN 0x0028 343 - #define REG_DP_PHY_TXn_TX_BAND 0x002C 344 - #define REG_DP_PHY_TXn_SLEW_CNTL 0x0030 345 - #define REG_DP_PHY_TXn_INTERFACE_SELECT 0x0034 346 - 347 - #define REG_DP_PHY_TXn_RES_CODE_LANE_TX 0x003C 348 - #define REG_DP_PHY_TXn_RES_CODE_LANE_RX 0x0040 349 - #define REG_DP_PHY_TXn_RES_CODE_LANE_OFFSET_TX 0x0044 350 - #define REG_DP_PHY_TXn_RES_CODE_LANE_OFFSET_RX 0x0048 351 - 352 - #define REG_DP_PHY_TXn_DEBUG_BUS_SEL 0x0058 353 - #define REG_DP_PHY_TXn_TRANSCEIVER_BIAS_EN 0x005C 354 - #define REG_DP_PHY_TXn_HIGHZ_DRVR_EN 0x0060 355 - #define REG_DP_PHY_TXn_TX_POL_INV 0x0064 356 - #define REG_DP_PHY_TXn_PARRATE_REC_DETECT_IDLE_EN 0x0068 357 - 358 - #define REG_DP_PHY_TXn_LANE_MODE_1 0x008C 359 - 360 - #define REG_DP_PHY_TXn_TRAN_DRVR_EMP_EN 0x00C0 361 - #define REG_DP_PHY_TXn_TX_INTERFACE_MODE 0x00C4 362 - 363 - #define REG_DP_PHY_TXn_VMODE_CTRL1 0x00F0 364 - 365 - /* PLL register offset */ 366 - #define QSERDES_COM_ATB_SEL1 0x0000 367 - #define QSERDES_COM_ATB_SEL2 0x0004 368 - #define QSERDES_COM_FREQ_UPDATE 0x0008 369 - #define QSERDES_COM_BG_TIMER 0x000C 370 - #define QSERDES_COM_SSC_EN_CENTER 0x0010 371 - #define QSERDES_COM_SSC_ADJ_PER1 0x0014 372 - #define QSERDES_COM_SSC_ADJ_PER2 0x0018 373 - #define QSERDES_COM_SSC_PER1 0x001C 374 - #define QSERDES_COM_SSC_PER2 0x0020 375 - #define QSERDES_COM_SSC_STEP_SIZE1 0x0024 376 - #define QSERDES_COM_SSC_STEP_SIZE2 0x0028 377 - #define QSERDES_COM_POST_DIV 0x002C 378 - #define QSERDES_COM_POST_DIV_MUX 0x0030 379 - 380 - #define QSERDES_COM_BIAS_EN_CLKBUFLR_EN 0x0034 381 - #define QSERDES_COM_BIAS_EN 0x0001 382 - #define QSERDES_COM_BIAS_EN_MUX 0x0002 383 - #define QSERDES_COM_CLKBUF_R_EN 0x0004 384 - #define QSERDES_COM_CLKBUF_L_EN 0x0008 385 - #define QSERDES_COM_EN_SYSCLK_TX_SEL 0x0010 386 - #define QSERDES_COM_CLKBUF_RX_DRIVE_L 0x0020 387 - #define QSERDES_COM_CLKBUF_RX_DRIVE_R 0x0040 388 - 389 - #define QSERDES_COM_CLK_ENABLE1 0x0038 390 - #define QSERDES_COM_SYS_CLK_CTRL 0x003C 391 - #define QSERDES_COM_SYSCLK_BUF_ENABLE 0x0040 392 - #define QSERDES_COM_PLL_EN 0x0044 393 - #define QSERDES_COM_PLL_IVCO 0x0048 394 - #define QSERDES_COM_CMN_IETRIM 0x004C 395 - #define QSERDES_COM_CMN_IPTRIM 0x0050 396 - 397 - #define QSERDES_COM_CP_CTRL_MODE0 0x0060 398 - #define QSERDES_COM_CP_CTRL_MODE1 0x0064 399 - #define QSERDES_COM_PLL_RCTRL_MODE0 0x0068 400 - #define QSERDES_COM_PLL_RCTRL_MODE1 0x006C 401 - #define QSERDES_COM_PLL_CCTRL_MODE0 0x0070 402 - #define QSERDES_COM_PLL_CCTRL_MODE1 0x0074 403 - #define QSERDES_COM_PLL_CNTRL 0x0078 404 - #define QSERDES_COM_BIAS_EN_CTRL_BY_PSM 0x007C 405 - #define QSERDES_COM_SYSCLK_EN_SEL 0x0080 406 - #define QSERDES_COM_CML_SYSCLK_SEL 0x0084 407 - #define QSERDES_COM_RESETSM_CNTRL 0x0088 408 - #define QSERDES_COM_RESETSM_CNTRL2 0x008C 409 - #define QSERDES_COM_LOCK_CMP_EN 0x0090 410 - #define QSERDES_COM_LOCK_CMP_CFG 0x0094 411 - #define QSERDES_COM_LOCK_CMP1_MODE0 0x0098 412 - #define QSERDES_COM_LOCK_CMP2_MODE0 0x009C 413 - #define QSERDES_COM_LOCK_CMP3_MODE0 0x00A0 414 - 415 - #define QSERDES_COM_DEC_START_MODE0 0x00B0 416 - #define QSERDES_COM_DEC_START_MODE1 0x00B4 417 - #define QSERDES_COM_DIV_FRAC_START1_MODE0 0x00B8 418 - #define QSERDES_COM_DIV_FRAC_START2_MODE0 0x00BC 419 - #define QSERDES_COM_DIV_FRAC_START3_MODE0 0x00C0 420 - #define QSERDES_COM_DIV_FRAC_START1_MODE1 0x00C4 421 - #define QSERDES_COM_DIV_FRAC_START2_MODE1 0x00C8 422 - #define QSERDES_COM_DIV_FRAC_START3_MODE1 0x00CC 423 - #define QSERDES_COM_INTEGLOOP_INITVAL 0x00D0 424 - #define QSERDES_COM_INTEGLOOP_EN 0x00D4 425 - #define QSERDES_COM_INTEGLOOP_GAIN0_MODE0 0x00D8 426 - #define QSERDES_COM_INTEGLOOP_GAIN1_MODE0 0x00DC 427 - #define QSERDES_COM_INTEGLOOP_GAIN0_MODE1 0x00E0 428 - #define QSERDES_COM_INTEGLOOP_GAIN1_MODE1 0x00E4 429 - #define QSERDES_COM_VCOCAL_DEADMAN_CTRL 0x00E8 430 - #define QSERDES_COM_VCO_TUNE_CTRL 0x00EC 431 - #define QSERDES_COM_VCO_TUNE_MAP 0x00F0 432 - 433 - #define QSERDES_COM_CMN_STATUS 0x0124 434 - #define QSERDES_COM_RESET_SM_STATUS 0x0128 435 - 436 - #define QSERDES_COM_CLK_SEL 0x0138 437 - #define QSERDES_COM_HSCLK_SEL 0x013C 438 - 439 - #define QSERDES_COM_CORECLK_DIV_MODE0 0x0148 440 - 441 - #define QSERDES_COM_SW_RESET 0x0150 442 - #define QSERDES_COM_CORE_CLK_EN 0x0154 443 - #define QSERDES_COM_C_READY_STATUS 0x0158 444 - #define QSERDES_COM_CMN_CONFIG 0x015C 445 - 446 - #define QSERDES_COM_SVS_MODE_CLK_SEL 0x0164 447 - 448 - /* DP MMSS_CC registers */ 449 - #define MMSS_DP_LINK_CMD_RCGR (0x0138) 450 - #define MMSS_DP_LINK_CFG_RCGR (0x013C) 451 - #define MMSS_DP_PIXEL_M (0x01B4) 452 - #define MMSS_DP_PIXEL_N (0x01B8) 453 296 454 297 /* DP HDCP 1.3 registers */ 455 298 #define DP_HDCP_CTRL (0x0A0) ··· 302 491 #define HDCP_SEC_DP_TZ_HV_HLOS_HDCP_RCVPORT_DATA10 (0x018) 303 492 #define HDCP_SEC_DP_TZ_HV_HLOS_HDCP_RCVPORT_DATA11 (0x01C) 304 493 #define HDCP_SEC_DP_TZ_HV_HLOS_HDCP_RCVPORT_DATA12 (0x020) 305 - 306 - /* USB3 DP COM registers */ 307 - #define REG_USB3_DP_COM_RESET_OVRD_CTRL (0x1C) 308 - #define USB3_DP_COM_OVRD_CTRL_SW_DPPHY_RESET (0x01) 309 - #define USB3_DP_COM_OVRD_CTRL_SW_DPPHY_RESET_MUX (0x02) 310 - #define USB3_DP_COM_OVRD_CTRL_SW_USB3PHY_RESET (0x04) 311 - #define USB3_DP_COM_OVRD_CTRL_SW_USB3PHY_RESET_MUX (0x08) 312 - 313 - #define REG_USB3_DP_COM_PHY_MODE_CTRL (0x00) 314 - #define USB3_DP_COM_PHY_MODE_DP (0x03) 315 - 316 - #define REG_USB3_DP_COM_SW_RESET (0x04) 317 - #define USB3_DP_COM_SW_RESET_SET (0x01) 318 - 319 - #define REG_USB3_DP_COM_TYPEC_CTRL (0x10) 320 - #define USB3_DP_COM_TYPEC_CTRL_PORTSEL (0x01) 321 - #define USB3_DP_COM_TYPEC_CTRL_PORTSEL_MUX (0x02) 322 - 323 - #define REG_USB3_DP_COM_SWI_CTRL (0x0c) 324 - 325 - #define REG_USB3_DP_COM_POWER_DOWN_CTRL (0x08) 326 - #define USB3_DP_COM_POWER_DOWN_CTRL_SW_PWRDN (0x01) 327 - 328 - 329 494 330 495 #endif /* _DP_REG_H_ */