/* * Copyright © 2014-2016 Intel Corporation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice (including the next * paragraph) shall be included in all copies or substantial portions of the * Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ #include "bxt_dpio_phy_regs.h" #include "i915_reg.h" #include "intel_ddi.h" #include "intel_ddi_buf_trans.h" #include "intel_de.h" #include "intel_display_power_well.h" #include "intel_display_types.h" #include "intel_dp.h" #include "intel_dpio_phy.h" #include "vlv_dpio_phy_regs.h" #include "vlv_sideband.h" /** * DOC: DPIO * * VLV, CHV and BXT have slightly peculiar display PHYs for driving DP/HDMI * ports. DPIO is the name given to such a display PHY. These PHYs * don't follow the standard programming model using direct MMIO * registers, and instead their registers must be accessed trough IOSF * sideband. VLV has one such PHY for driving ports B and C, and CHV * adds another PHY for driving port D. Each PHY responds to specific * IOSF-SB port. * * Each display PHY is made up of one or two channels. Each channel * houses a common lane part which contains the PLL and other common * logic. CH0 common lane also contains the IOSF-SB logic for the * Common Register Interface (CRI) ie. the DPIO registers. CRI clock * must be running when any DPIO registers are accessed. * * In addition to having their own registers, the PHYs are also * controlled through some dedicated signals from the display * controller. These include PLL reference clock enable, PLL enable, * and CRI clock selection, for example. * * Eeach channel also has two splines (also called data lanes), and * each spline is made up of one Physical Access Coding Sub-Layer * (PCS) block and two TX lanes. So each channel has two PCS blocks * and four TX lanes. The TX lanes are used as DP lanes or TMDS * data/clock pairs depending on the output type. * * Additionally the PHY also contains an AUX lane with AUX blocks * for each channel. This is used for DP AUX communication, but * this fact isn't really relevant for the driver since AUX is * controlled from the display controller side. No DPIO registers * need to be accessed during AUX communication, * * Generally on VLV/CHV the common lane corresponds to the pipe and * the spline (PCS/TX) corresponds to the port. * * For dual channel PHY (VLV/CHV): * * pipe A == CMN/PLL/REF CH0 * * pipe B == CMN/PLL/REF CH1 * * port B == PCS/TX CH0 * * port C == PCS/TX CH1 * * This is especially important when we cross the streams * ie. drive port B with pipe B, or port C with pipe A. * * For single channel PHY (CHV): * * pipe C == CMN/PLL/REF CH0 * * port D == PCS/TX CH0 * * On BXT the entire PHY channel corresponds to the port. That means * the PLL is also now associated with the port rather than the pipe, * and so the clock needs to be routed to the appropriate transcoder. * Port A PLL is directly connected to transcoder EDP and port B/C * PLLs can be routed to any transcoder A/B/C. * * Note: DDI0 is digital port B, DD1 is digital port C, and DDI2 is * digital port D (CHV) or port A (BXT). :: * * * Dual channel PHY (VLV/CHV/BXT) * --------------------------------- * | CH0 | CH1 | * | CMN/PLL/REF | CMN/PLL/REF | * |---------------|---------------| Display PHY * | PCS01 | PCS23 | PCS01 | PCS23 | * |-------|-------|-------|-------| * |TX0|TX1|TX2|TX3|TX0|TX1|TX2|TX3| * --------------------------------- * | DDI0 | DDI1 | DP/HDMI ports * --------------------------------- * * Single channel PHY (CHV/BXT) * ----------------- * | CH0 | * | CMN/PLL/REF | * |---------------| Display PHY * | PCS01 | PCS23 | * |-------|-------| * |TX0|TX1|TX2|TX3| * ----------------- * | DDI2 | DP/HDMI port * ----------------- */ /** * struct bxt_dpio_phy_info - Hold info for a broxton DDI phy */ struct bxt_dpio_phy_info { … }; static const struct bxt_dpio_phy_info bxt_dpio_phy_info[] = …; static const struct bxt_dpio_phy_info glk_dpio_phy_info[] = …; static const struct bxt_dpio_phy_info * bxt_get_phy_list(struct drm_i915_private *dev_priv, int *count) { … } static const struct bxt_dpio_phy_info * bxt_get_phy_info(struct drm_i915_private *dev_priv, enum dpio_phy phy) { … } void bxt_port_to_phy_channel(struct drm_i915_private *dev_priv, enum port port, enum dpio_phy *phy, enum dpio_channel *ch) { … } /* * Like intel_de_rmw() but reads from a single per-lane register and * writes to the group register to write the same value to all the lanes. */ static u32 bxt_dpio_phy_rmw_grp(struct drm_i915_private *i915, i915_reg_t reg_single, i915_reg_t reg_group, u32 clear, u32 set) { … } void bxt_dpio_phy_set_signal_levels(struct intel_encoder *encoder, const struct intel_crtc_state *crtc_state) { … } bool bxt_dpio_phy_is_enabled(struct drm_i915_private *dev_priv, enum dpio_phy phy) { … } static u32 bxt_get_grc(struct drm_i915_private *dev_priv, enum dpio_phy phy) { … } static void bxt_phy_wait_grc_done(struct drm_i915_private *dev_priv, enum dpio_phy phy) { … } static void _bxt_dpio_phy_init(struct drm_i915_private *dev_priv, enum dpio_phy phy) { … } void bxt_dpio_phy_uninit(struct drm_i915_private *dev_priv, enum dpio_phy phy) { … } void bxt_dpio_phy_init(struct drm_i915_private *dev_priv, enum dpio_phy phy) { … } static bool __printf(6, 7) __phy_reg_verify_state(struct drm_i915_private *dev_priv, enum dpio_phy phy, i915_reg_t reg, u32 mask, u32 expected, const char *reg_fmt, ...) { … } bool bxt_dpio_phy_verify_state(struct drm_i915_private *dev_priv, enum dpio_phy phy) { … } u8 bxt_dpio_phy_calc_lane_lat_optim_mask(u8 lane_count) { … } void bxt_dpio_phy_set_lane_optim_mask(struct intel_encoder *encoder, u8 lane_lat_optim_mask) { … } u8 bxt_dpio_phy_get_lane_lat_optim_mask(struct intel_encoder *encoder) { … } enum dpio_channel vlv_dig_port_to_channel(struct intel_digital_port *dig_port) { … } enum dpio_phy vlv_dig_port_to_phy(struct intel_digital_port *dig_port) { … } enum dpio_phy vlv_pipe_to_phy(enum pipe pipe) { … } enum dpio_channel vlv_pipe_to_channel(enum pipe pipe) { … } void chv_set_phy_signal_level(struct intel_encoder *encoder, const struct intel_crtc_state *crtc_state, u32 deemph_reg_value, u32 margin_reg_value, bool uniq_trans_scale) { … } void chv_data_lane_soft_reset(struct intel_encoder *encoder, const struct intel_crtc_state *crtc_state, bool reset) { … } void chv_phy_pre_pll_enable(struct intel_encoder *encoder, const struct intel_crtc_state *crtc_state) { … } void chv_phy_pre_encoder_enable(struct intel_encoder *encoder, const struct intel_crtc_state *crtc_state) { … } void chv_phy_release_cl2_override(struct intel_encoder *encoder) { … } void chv_phy_post_pll_disable(struct intel_encoder *encoder, const struct intel_crtc_state *old_crtc_state) { … } void vlv_set_phy_signal_level(struct intel_encoder *encoder, const struct intel_crtc_state *crtc_state, u32 demph_reg_value, u32 preemph_reg_value, u32 uniqtranscale_reg_value, u32 tx3_demph) { … } void vlv_phy_pre_pll_enable(struct intel_encoder *encoder, const struct intel_crtc_state *crtc_state) { … } void vlv_phy_pre_encoder_enable(struct intel_encoder *encoder, const struct intel_crtc_state *crtc_state) { … } void vlv_phy_reset_lanes(struct intel_encoder *encoder, const struct intel_crtc_state *old_crtc_state) { … }