On Mon, Oct 16, 2017 at 02:29:37PM -0700, Rodrigo Vivi wrote: > On CNP boards that are using DDI F, > bit 25 (SDE_PORTE_HOTPLUG_SPT) is representing > the Digital Port F hotplug line when the Digital > Port F hotplug detect input is enabled. > > v2: Reuse all existent structure instead of adding a > new HPD_PORT_F pointing to pin of port E. > v3: Use IS_CNL_WITH_PORT_F so we can start upstreaming > this right now. If that SKU ever get a proper name > we come back and update it. > > Cc: Manasi Navare <manasi.d.navare@xxxxxxxxx> > Cc: Dhinakaran Pandiyan <dhinakaran.pandiyan@xxxxxxxxx> > Cc: Ville Syrjälä <ville.syrjala@xxxxxxxxxxxxxxx> > Signed-off-by: Rodrigo Vivi <rodrigo.vivi@xxxxxxxxx> > --- > drivers/gpu/drm/i915/i915_drv.h | 7 +++++-- > drivers/gpu/drm/i915/i915_irq.c | 35 +++++++++++++++++++---------------- > drivers/gpu/drm/i915/intel_dp.c | 7 +++++-- > drivers/gpu/drm/i915/intel_hdmi.c | 2 +- > drivers/gpu/drm/i915/intel_hotplug.c | 14 +++++++++++--- > 5 files changed, 41 insertions(+), 24 deletions(-) > > diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h > index 74732af5af3c..4e1ce795dd2b 100644 > --- a/drivers/gpu/drm/i915/i915_drv.h > +++ b/drivers/gpu/drm/i915/i915_drv.h > @@ -3007,6 +3007,8 @@ intel_info(const struct drm_i915_private *dev_priv) > (INTEL_DEVID(dev_priv) & 0x00F0) == 0x00A0) > #define IS_CFL_GT2(dev_priv) (IS_COFFEELAKE(dev_priv) && \ > (dev_priv)->info.gt == 2) > +#define IS_CNL_WITH_PORT_F(dev_priv) (IS_CANNONLAKE(dev_priv) && \ > + (INTEL_DEVID(dev_priv) & 0x0004) == 0x0004) > > #define IS_ALPHA_SUPPORT(intel_info) ((intel_info)->is_alpha_support) > > @@ -3290,8 +3292,9 @@ void intel_hpd_irq_handler(struct drm_i915_private *dev_priv, > void intel_hpd_init(struct drm_i915_private *dev_priv); > void intel_hpd_init_work(struct drm_i915_private *dev_priv); > void intel_hpd_cancel_work(struct drm_i915_private *dev_priv); > -enum port intel_hpd_pin_to_port(enum hpd_pin pin); > -enum hpd_pin intel_hpd_pin(enum port port); > +enum port intel_hpd_pin_to_port(struct drm_i915_private *dev_priv, > + enum hpd_pin pin); > +enum hpd_pin intel_hpd_pin(struct drm_i915_private *dev_priv, enum port port); > bool intel_hpd_disable(struct drm_i915_private *dev_priv, enum hpd_pin pin); > void intel_hpd_enable(struct drm_i915_private *dev_priv, enum hpd_pin pin); > > diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c > index 29ad6649ac87..6c90c3ffe30a 100644 > --- a/drivers/gpu/drm/i915/i915_irq.c > +++ b/drivers/gpu/drm/i915/i915_irq.c > @@ -1556,10 +1556,11 @@ static bool i9xx_port_hotplug_long_detect(enum port port, u32 val) > * > * Note that the caller is expected to zero out the masks initially. > */ > -static void intel_get_hpd_pins(u32 *pin_mask, u32 *long_mask, > - u32 hotplug_trigger, u32 dig_hotplug_reg, > - const u32 hpd[HPD_NUM_PINS], > - bool long_pulse_detect(enum port port, u32 val)) > +static void intel_get_hpd_pins(struct drm_i915_private *dev_priv, > + u32 *pin_mask, u32 *long_mask, > + u32 hotplug_trigger, u32 dig_hotplug_reg, > + const u32 hpd[HPD_NUM_PINS], > + bool long_pulse_detect(enum port port, u32 val)) > { > enum port port; > int i; > @@ -1570,7 +1571,7 @@ static void intel_get_hpd_pins(u32 *pin_mask, u32 *long_mask, > > *pin_mask |= BIT(i); > > - port = intel_hpd_pin_to_port(i); > + port = intel_hpd_pin_to_port(dev_priv, i); > if (port == PORT_NONE) > continue; > > @@ -1956,8 +1957,9 @@ static void i9xx_hpd_irq_handler(struct drm_i915_private *dev_priv, > u32 hotplug_trigger = hotplug_status & HOTPLUG_INT_STATUS_G4X; > > if (hotplug_trigger) { > - intel_get_hpd_pins(&pin_mask, &long_mask, hotplug_trigger, > - hotplug_trigger, hpd_status_g4x, > + intel_get_hpd_pins(dev_priv, &pin_mask, &long_mask, > + hotplug_trigger, hotplug_trigger, > + hpd_status_g4x, > i9xx_port_hotplug_long_detect); > > intel_hpd_irq_handler(dev_priv, pin_mask, long_mask); > @@ -1969,8 +1971,9 @@ static void i9xx_hpd_irq_handler(struct drm_i915_private *dev_priv, > u32 hotplug_trigger = hotplug_status & HOTPLUG_INT_STATUS_I915; > > if (hotplug_trigger) { > - intel_get_hpd_pins(&pin_mask, &long_mask, hotplug_trigger, > - hotplug_trigger, hpd_status_i915, > + intel_get_hpd_pins(dev_priv, &pin_mask, &long_mask, > + hotplug_trigger, hotplug_trigger, > + hpd_status_i915, > i9xx_port_hotplug_long_detect); > intel_hpd_irq_handler(dev_priv, pin_mask, long_mask); > } > @@ -2171,7 +2174,7 @@ static void ibx_hpd_irq_handler(struct drm_i915_private *dev_priv, > if (!hotplug_trigger) > return; > > - intel_get_hpd_pins(&pin_mask, &long_mask, hotplug_trigger, > + intel_get_hpd_pins(dev_priv, &pin_mask, &long_mask, hotplug_trigger, > dig_hotplug_reg, hpd, > pch_port_hotplug_long_detect); > > @@ -2317,8 +2320,8 @@ static void spt_irq_handler(struct drm_i915_private *dev_priv, u32 pch_iir) > dig_hotplug_reg = I915_READ(PCH_PORT_HOTPLUG); > I915_WRITE(PCH_PORT_HOTPLUG, dig_hotplug_reg); > > - intel_get_hpd_pins(&pin_mask, &long_mask, hotplug_trigger, > - dig_hotplug_reg, hpd_spt, > + intel_get_hpd_pins(dev_priv, &pin_mask, &long_mask, > + hotplug_trigger, dig_hotplug_reg, hpd_spt, > spt_port_hotplug_long_detect); > } > > @@ -2328,8 +2331,8 @@ static void spt_irq_handler(struct drm_i915_private *dev_priv, u32 pch_iir) > dig_hotplug_reg = I915_READ(PCH_PORT_HOTPLUG2); > I915_WRITE(PCH_PORT_HOTPLUG2, dig_hotplug_reg); > > - intel_get_hpd_pins(&pin_mask, &long_mask, hotplug2_trigger, > - dig_hotplug_reg, hpd_spt, > + intel_get_hpd_pins(dev_priv, &pin_mask, &long_mask, > + hotplug2_trigger, dig_hotplug_reg, hpd_spt, > spt_port_hotplug2_long_detect); > } > > @@ -2349,7 +2352,7 @@ static void ilk_hpd_irq_handler(struct drm_i915_private *dev_priv, > dig_hotplug_reg = I915_READ(DIGITAL_PORT_HOTPLUG_CNTRL); > I915_WRITE(DIGITAL_PORT_HOTPLUG_CNTRL, dig_hotplug_reg); > > - intel_get_hpd_pins(&pin_mask, &long_mask, hotplug_trigger, > + intel_get_hpd_pins(dev_priv, &pin_mask, &long_mask, hotplug_trigger, > dig_hotplug_reg, hpd, > ilk_port_hotplug_long_detect); > > @@ -2526,7 +2529,7 @@ static void bxt_hpd_irq_handler(struct drm_i915_private *dev_priv, > dig_hotplug_reg = I915_READ(PCH_PORT_HOTPLUG); > I915_WRITE(PCH_PORT_HOTPLUG, dig_hotplug_reg); > > - intel_get_hpd_pins(&pin_mask, &long_mask, hotplug_trigger, > + intel_get_hpd_pins(dev_priv, &pin_mask, &long_mask, hotplug_trigger, > dig_hotplug_reg, hpd, > bxt_port_hotplug_long_detect); > > diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c > index de6ebeaf1c1b..4d520c6b766a 100644 > --- a/drivers/gpu/drm/i915/intel_dp.c > +++ b/drivers/gpu/drm/i915/intel_dp.c > @@ -4528,6 +4528,8 @@ static bool spt_digital_port_connected(struct drm_i915_private *dev_priv, > case PORT_A: > bit = SDE_PORTA_HOTPLUG_SPT; > break; > + case PORT_F: > + WARN_ON(!IS_CNL_WITH_PORT_F(dev_priv)); I'd like to see these functions to be changed to just look at encoder->hpd_pin instead of ->port. And while at it you could just as well change them to take 'struct intel_encoder *encoder' directly instead of passing in dev_priv+dig_port. > case PORT_E: > bit = SDE_PORTE_HOTPLUG_SPT; > break; > @@ -4627,7 +4629,7 @@ static bool bxt_digital_port_connected(struct drm_i915_private *dev_priv, > enum port port; > u32 bit; > > - port = intel_hpd_pin_to_port(intel_encoder->hpd_pin); > + port = intel_hpd_pin_to_port(dev_priv, intel_encoder->hpd_pin); > switch (port) { > case PORT_A: > bit = BXT_DE_PORT_HP_DDIA; > @@ -5965,8 +5967,9 @@ intel_dp_init_connector_port_info(struct intel_digital_port *intel_dig_port) > { > struct intel_encoder *encoder = &intel_dig_port->base; > struct intel_dp *intel_dp = &intel_dig_port->dp; > + struct drm_i915_private *dev_priv = to_i915(encoder->base.dev); > > - encoder->hpd_pin = intel_hpd_pin(intel_dig_port->port); > + encoder->hpd_pin = intel_hpd_pin(dev_priv, intel_dig_port->port); > > switch (intel_dig_port->port) { > case PORT_A: > diff --git a/drivers/gpu/drm/i915/intel_hdmi.c b/drivers/gpu/drm/i915/intel_hdmi.c > index e6f8f30ce7bd..9aa63cfb7fe0 100644 > --- a/drivers/gpu/drm/i915/intel_hdmi.c > +++ b/drivers/gpu/drm/i915/intel_hdmi.c > @@ -2022,7 +2022,7 @@ void intel_hdmi_init_connector(struct intel_digital_port *intel_dig_port, > > if (WARN_ON(port == PORT_A)) > return; > - intel_encoder->hpd_pin = intel_hpd_pin(port); > + intel_encoder->hpd_pin = intel_hpd_pin(dev_priv, port); > > if (HAS_DDI(dev_priv)) > intel_connector->get_hw_state = intel_ddi_connector_get_hw_state; > diff --git a/drivers/gpu/drm/i915/intel_hotplug.c b/drivers/gpu/drm/i915/intel_hotplug.c > index 875d5d218d5c..dfc64e135069 100644 > --- a/drivers/gpu/drm/i915/intel_hotplug.c > +++ b/drivers/gpu/drm/i915/intel_hotplug.c > @@ -78,12 +78,14 @@ > > /** > * intel_hpd_port - return port hard associated with certain pin. > + * @dev_priv: private driver data pointer > * @pin: the hpd pin to get associated port > * > * Return port that is associatade with @pin and PORT_NONE if no port is > * hard associated with that @pin. > */ > -enum port intel_hpd_pin_to_port(enum hpd_pin pin) > +enum port intel_hpd_pin_to_port(struct drm_i915_private *dev_priv, > + enum hpd_pin pin) > { > switch (pin) { > case HPD_PORT_A: > @@ -95,6 +97,8 @@ enum port intel_hpd_pin_to_port(enum hpd_pin pin) > case HPD_PORT_D: > return PORT_D; > case HPD_PORT_E: > + if (IS_CNL_WITH_PORT_F(dev_priv)) > + return PORT_F; I think we'll just want to replace this whole switch with something like for_each_intel_encoder() { if (encoder->hdp_pin == pin) return encoder->port; } That will make it work with any port<->hpd_pin mapping in the future. > return PORT_E; > default: > return PORT_NONE; /* no port for this pin */ > @@ -103,12 +107,13 @@ enum port intel_hpd_pin_to_port(enum hpd_pin pin) > > /** > * intel_hpd_pin - return pin hard associated with certain port. > + * @dev_priv: private driver data pointer > * @port: the hpd port to get associated pin > * > * Return pin that is associatade with @port and HDP_NONE if no pin is > * hard associated with that @port. > */ > -enum hpd_pin intel_hpd_pin(enum port port) > +enum hpd_pin intel_hpd_pin(struct drm_i915_private *dev_priv, enum port port) We should probably rename this function to be something intel_default_hpd_pin() to reflect the fact this is just our default port->hpd_pin mapping. Maybe we should also put dig_port or something to the name since this doesn't apply to other encoder types. Hmm. I thought VBT would provide us with the hpd pin as well, but now I don't see anything like that. Maybe I was mistaken? I guess that might happen at some point anyway, so I think the renaming would still make things a bit less confusing. > { > switch (port) { > case PORT_A: > @@ -121,6 +126,9 @@ enum hpd_pin intel_hpd_pin(enum port port) > return HPD_PORT_D; > case PORT_E: > return HPD_PORT_E; > + case PORT_F: > + if (IS_CNL_WITH_PORT_F(dev_priv)) > + return HPD_PORT_E; > default: > MISSING_CASE(port); > return HPD_NONE; > @@ -417,7 +425,7 @@ void intel_hpd_irq_handler(struct drm_i915_private *dev_priv, > if (!(BIT(i) & pin_mask)) > continue; > > - port = intel_hpd_pin_to_port(i); > + port = intel_hpd_pin_to_port(dev_priv, i); > is_dig_port = port != PORT_NONE && > dev_priv->hotplug.irq_port[port]; > > -- > 2.13.5 -- Ville Syrjälä Intel OTC _______________________________________________ Intel-gfx mailing list Intel-gfx@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/intel-gfx