Skip to content

Commit

Permalink
drm/i915: add vlv_pipe_to_phy() helper to replace DPIO_PHY()
Browse files Browse the repository at this point in the history
Add a helper with better typing and handing for bogus input, and better
in line with vlv_dig_port_to_channel(), vlv_dig_port_to_phy(), and
vlv_pipe_to_channel().

Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20231114104534.4180144-2-jani.nikula@intel.com
  • Loading branch information
Jani Nikula committed Nov 17, 2023
1 parent 9d69533 commit 9fda18c
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 5 deletions.
14 changes: 14 additions & 0 deletions drivers/gpu/drm/i915/display/intel_dpio_phy.c
Original file line number Diff line number Diff line change
Expand Up @@ -666,6 +666,20 @@ enum dpio_phy vlv_dig_port_to_phy(struct intel_digital_port *dig_port)
}
}

enum dpio_phy vlv_pipe_to_phy(enum pipe pipe)
{
switch (pipe) {
default:
MISSING_CASE(pipe);
fallthrough;
case PIPE_A:
case PIPE_B:
return DPIO_PHY0;
case PIPE_C:
return DPIO_PHY1;
}
}

enum dpio_channel vlv_pipe_to_channel(enum pipe pipe)
{
switch (pipe) {
Expand Down
5 changes: 5 additions & 0 deletions drivers/gpu/drm/i915/display/intel_dpio_phy.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ u8 bxt_ddi_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,
Expand Down Expand Up @@ -116,6 +117,10 @@ static inline enum dpio_phy vlv_dig_port_to_phy(struct intel_digital_port *dig_p
{
return DPIO_PHY0;
}
static inline enum dpio_phy vlv_pipe_to_phy(enum pipe pipe)
{
return DPIO_PHY0;
}
static inline enum dpio_channel vlv_pipe_to_channel(enum pipe pipe)
{
return DPIO_CH0;
Expand Down
2 changes: 1 addition & 1 deletion drivers/gpu/drm/i915/display/intel_pps.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ vlv_power_sequencer_kick(struct intel_dp *intel_dp)
struct intel_digital_port *dig_port = dp_to_dig_port(intel_dp);
enum pipe pipe = intel_dp->pps.pps_pipe;
bool pll_enabled, release_cl_override = false;
enum dpio_phy phy = DPIO_PHY(pipe);
enum dpio_phy phy = vlv_pipe_to_phy(pipe);
enum dpio_channel ch = vlv_pipe_to_channel(pipe);
u32 DP;

Expand Down
2 changes: 0 additions & 2 deletions drivers/gpu/drm/i915/i915_reg.h
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,6 @@
#define DPIO_SFR_BYPASS (1 << 1)
#define DPIO_CMNRST (1 << 0)

#define DPIO_PHY(pipe) ((pipe) >> 1)

/*
* Per pipe/PLL DPIO regs
*/
Expand Down
6 changes: 4 additions & 2 deletions drivers/gpu/drm/i915/vlv_sideband.c
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,8 @@ static u32 vlv_dpio_phy_iosf_port(struct drm_i915_private *i915, enum dpio_phy p

u32 vlv_dpio_read(struct drm_i915_private *i915, enum pipe pipe, int reg)
{
u32 port = vlv_dpio_phy_iosf_port(i915, DPIO_PHY(pipe));
enum dpio_phy phy = vlv_pipe_to_phy(pipe);
u32 port = vlv_dpio_phy_iosf_port(i915, phy);
u32 val = 0;

vlv_sideband_rw(i915, DPIO_DEVFN, port, SB_MRD_NP, reg, &val);
Expand All @@ -248,7 +249,8 @@ u32 vlv_dpio_read(struct drm_i915_private *i915, enum pipe pipe, int reg)
void vlv_dpio_write(struct drm_i915_private *i915,
enum pipe pipe, int reg, u32 val)
{
u32 port = vlv_dpio_phy_iosf_port(i915, DPIO_PHY(pipe));
enum dpio_phy phy = vlv_pipe_to_phy(pipe);
u32 port = vlv_dpio_phy_iosf_port(i915, phy);

vlv_sideband_rw(i915, DPIO_DEVFN, port, SB_MWR_NP, reg, &val);
}
Expand Down

0 comments on commit 9fda18c

Please sign in to comment.