Merge branch 'for-upstream/mali-dp' of git://linux-arm.org/linux-ld into drm-next
[sfrench/cifs-2.6.git] / drivers / gpu / drm / i915 / gvt / edid.c
index 5d4bb35bb889e932c6b2905ac06e4495d57b0cb4..1fe6124918f1bcc2a97b39e7a811548a7a611e6d 100644 (file)
@@ -77,16 +77,32 @@ static unsigned char edid_get_byte(struct intel_vgpu *vgpu)
        return chr;
 }
 
+static inline int cnp_get_port_from_gmbus0(u32 gmbus0)
+{
+       int port_select = gmbus0 & _GMBUS_PIN_SEL_MASK;
+       int port = -EINVAL;
+
+       if (port_select == GMBUS_PIN_1_BXT)
+               port = PORT_B;
+       else if (port_select == GMBUS_PIN_2_BXT)
+               port = PORT_C;
+       else if (port_select == GMBUS_PIN_3_BXT)
+               port = PORT_D;
+       else if (port_select == GMBUS_PIN_4_CNP)
+               port = PORT_E;
+       return port;
+}
+
 static inline int bxt_get_port_from_gmbus0(u32 gmbus0)
 {
        int port_select = gmbus0 & _GMBUS_PIN_SEL_MASK;
        int port = -EINVAL;
 
-       if (port_select == 1)
+       if (port_select == GMBUS_PIN_1_BXT)
                port = PORT_B;
-       else if (port_select == 2)
+       else if (port_select == GMBUS_PIN_2_BXT)
                port = PORT_C;
-       else if (port_select == 3)
+       else if (port_select == GMBUS_PIN_3_BXT)
                port = PORT_D;
        return port;
 }
@@ -96,13 +112,13 @@ static inline int get_port_from_gmbus0(u32 gmbus0)
        int port_select = gmbus0 & _GMBUS_PIN_SEL_MASK;
        int port = -EINVAL;
 
-       if (port_select == 2)
+       if (port_select == GMBUS_PIN_VGADDC)
                port = PORT_E;
-       else if (port_select == 4)
+       else if (port_select == GMBUS_PIN_DPC)
                port = PORT_C;
-       else if (port_select == 5)
+       else if (port_select == GMBUS_PIN_DPB)
                port = PORT_B;
-       else if (port_select == 6)
+       else if (port_select == GMBUS_PIN_DPD)
                port = PORT_D;
        return port;
 }
@@ -133,6 +149,8 @@ static int gmbus0_mmio_write(struct intel_vgpu *vgpu,
 
        if (IS_BROXTON(dev_priv))
                port = bxt_get_port_from_gmbus0(pin_select);
+       else if (IS_COFFEELAKE(dev_priv))
+               port = cnp_get_port_from_gmbus0(pin_select);
        else
                port = get_port_from_gmbus0(pin_select);
        if (WARN_ON(port < 0))