diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2010-09-11 08:48:45 -0400 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2010-09-11 14:27:12 -0400 |
commit | 5eddb70ba2b8cdbbdd563f5cb04e26fdc9b017f7 (patch) | |
tree | 49a0f42a99b4b72794bd2cbab78816595c88da25 /drivers/gpu/drm/i915/intel_display.c | |
parent | 4ed765f966c8279acc6f6bc1a5dcb0424d074b40 (diff) |
drm/i915: Use macros to switch between equivalent pipe registers
The purpose is to make the code much easier to read and therefore reduce
the possibility for bugs.
A side effect is that it also makes it much easier for the compiler,
reducing the object size by 4k -- from just a few functions!
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'drivers/gpu/drm/i915/intel_display.c')
-rw-r--r-- | drivers/gpu/drm/i915/intel_display.c | 912 |
1 files changed, 421 insertions, 491 deletions
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c index 3ef6d7ea1e0e..1e88ebbc1a1e 100644 --- a/drivers/gpu/drm/i915/intel_display.c +++ b/drivers/gpu/drm/i915/intel_display.c | |||
@@ -959,26 +959,26 @@ static bool | |||
959 | intel_find_pll_g4x_dp(const intel_limit_t *limit, struct drm_crtc *crtc, | 959 | intel_find_pll_g4x_dp(const intel_limit_t *limit, struct drm_crtc *crtc, |
960 | int target, int refclk, intel_clock_t *best_clock) | 960 | int target, int refclk, intel_clock_t *best_clock) |
961 | { | 961 | { |
962 | intel_clock_t clock; | 962 | intel_clock_t clock; |
963 | if (target < 200000) { | 963 | if (target < 200000) { |
964 | clock.p1 = 2; | 964 | clock.p1 = 2; |
965 | clock.p2 = 10; | 965 | clock.p2 = 10; |
966 | clock.n = 2; | 966 | clock.n = 2; |
967 | clock.m1 = 23; | 967 | clock.m1 = 23; |
968 | clock.m2 = 8; | 968 | clock.m2 = 8; |
969 | } else { | 969 | } else { |
970 | clock.p1 = 1; | 970 | clock.p1 = 1; |
971 | clock.p2 = 10; | 971 | clock.p2 = 10; |
972 | clock.n = 1; | 972 | clock.n = 1; |
973 | clock.m1 = 14; | 973 | clock.m1 = 14; |
974 | clock.m2 = 2; | 974 | clock.m2 = 2; |
975 | } | 975 | } |
976 | clock.m = 5 * (clock.m1 + 2) + (clock.m2 + 2); | 976 | clock.m = 5 * (clock.m1 + 2) + (clock.m2 + 2); |
977 | clock.p = (clock.p1 * clock.p2); | 977 | clock.p = (clock.p1 * clock.p2); |
978 | clock.dot = 96000 * clock.m / (clock.n + 2) / clock.p; | 978 | clock.dot = 96000 * clock.m / (clock.n + 2) / clock.p; |
979 | clock.vco = 0; | 979 | clock.vco = 0; |
980 | memcpy(best_clock, &clock, sizeof(intel_clock_t)); | 980 | memcpy(best_clock, &clock, sizeof(intel_clock_t)); |
981 | return true; | 981 | return true; |
982 | } | 982 | } |
983 | 983 | ||
984 | /** | 984 | /** |
@@ -1099,7 +1099,7 @@ static void i8xx_enable_fbc(struct drm_crtc *crtc, unsigned long interval) | |||
1099 | I915_WRITE(FBC_CONTROL, fbc_ctl); | 1099 | I915_WRITE(FBC_CONTROL, fbc_ctl); |
1100 | 1100 | ||
1101 | DRM_DEBUG_KMS("enabled FBC, pitch %ld, yoff %d, plane %d, ", | 1101 | DRM_DEBUG_KMS("enabled FBC, pitch %ld, yoff %d, plane %d, ", |
1102 | dev_priv->cfb_pitch, crtc->y, dev_priv->cfb_plane); | 1102 | dev_priv->cfb_pitch, crtc->y, dev_priv->cfb_plane); |
1103 | } | 1103 | } |
1104 | 1104 | ||
1105 | void i8xx_disable_fbc(struct drm_device *dev) | 1105 | void i8xx_disable_fbc(struct drm_device *dev) |
@@ -1136,8 +1136,7 @@ static void g4x_enable_fbc(struct drm_crtc *crtc, unsigned long interval) | |||
1136 | struct intel_framebuffer *intel_fb = to_intel_framebuffer(fb); | 1136 | struct intel_framebuffer *intel_fb = to_intel_framebuffer(fb); |
1137 | struct drm_i915_gem_object *obj_priv = to_intel_bo(intel_fb->obj); | 1137 | struct drm_i915_gem_object *obj_priv = to_intel_bo(intel_fb->obj); |
1138 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); | 1138 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); |
1139 | int plane = (intel_crtc->plane == 0 ? DPFC_CTL_PLANEA : | 1139 | int plane = intel_crtc->plane == 0 ? DPFC_CTL_PLANEA : DPFC_CTL_PLANEB; |
1140 | DPFC_CTL_PLANEB); | ||
1141 | unsigned long stall_watermark = 200; | 1140 | unsigned long stall_watermark = 200; |
1142 | u32 dpfc_ctl; | 1141 | u32 dpfc_ctl; |
1143 | 1142 | ||
@@ -1208,8 +1207,7 @@ static void ironlake_enable_fbc(struct drm_crtc *crtc, unsigned long interval) | |||
1208 | struct intel_framebuffer *intel_fb = to_intel_framebuffer(fb); | 1207 | struct intel_framebuffer *intel_fb = to_intel_framebuffer(fb); |
1209 | struct drm_i915_gem_object *obj_priv = to_intel_bo(intel_fb->obj); | 1208 | struct drm_i915_gem_object *obj_priv = to_intel_bo(intel_fb->obj); |
1210 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); | 1209 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); |
1211 | int plane = (intel_crtc->plane == 0) ? DPFC_CTL_PLANEA : | 1210 | int plane = intel_crtc->plane == 0 ? DPFC_CTL_PLANEA : DPFC_CTL_PLANEB; |
1212 | DPFC_CTL_PLANEB; | ||
1213 | unsigned long stall_watermark = 200; | 1211 | unsigned long stall_watermark = 200; |
1214 | u32 dpfc_ctl; | 1212 | u32 dpfc_ctl; |
1215 | 1213 | ||
@@ -1374,14 +1372,14 @@ static void intel_update_fbc(struct drm_device *dev) | |||
1374 | 1372 | ||
1375 | if (intel_fb->obj->size > dev_priv->cfb_size) { | 1373 | if (intel_fb->obj->size > dev_priv->cfb_size) { |
1376 | DRM_DEBUG_KMS("framebuffer too large, disabling " | 1374 | DRM_DEBUG_KMS("framebuffer too large, disabling " |
1377 | "compression\n"); | 1375 | "compression\n"); |
1378 | dev_priv->no_fbc_reason = FBC_STOLEN_TOO_SMALL; | 1376 | dev_priv->no_fbc_reason = FBC_STOLEN_TOO_SMALL; |
1379 | goto out_disable; | 1377 | goto out_disable; |
1380 | } | 1378 | } |
1381 | if ((crtc->mode.flags & DRM_MODE_FLAG_INTERLACE) || | 1379 | if ((crtc->mode.flags & DRM_MODE_FLAG_INTERLACE) || |
1382 | (crtc->mode.flags & DRM_MODE_FLAG_DBLSCAN)) { | 1380 | (crtc->mode.flags & DRM_MODE_FLAG_DBLSCAN)) { |
1383 | DRM_DEBUG_KMS("mode incompatible with compression, " | 1381 | DRM_DEBUG_KMS("mode incompatible with compression, " |
1384 | "disabling\n"); | 1382 | "disabling\n"); |
1385 | dev_priv->no_fbc_reason = FBC_UNSUPPORTED_MODE; | 1383 | dev_priv->no_fbc_reason = FBC_UNSUPPORTED_MODE; |
1386 | goto out_disable; | 1384 | goto out_disable; |
1387 | } | 1385 | } |
@@ -1479,12 +1477,8 @@ intel_pipe_set_base_atomic(struct drm_crtc *crtc, struct drm_framebuffer *fb, | |||
1479 | struct drm_gem_object *obj; | 1477 | struct drm_gem_object *obj; |
1480 | int plane = intel_crtc->plane; | 1478 | int plane = intel_crtc->plane; |
1481 | unsigned long Start, Offset; | 1479 | unsigned long Start, Offset; |
1482 | int dspbase = (plane == 0 ? DSPAADDR : DSPBADDR); | ||
1483 | int dspsurf = (plane == 0 ? DSPASURF : DSPBSURF); | ||
1484 | int dspstride = (plane == 0) ? DSPASTRIDE : DSPBSTRIDE; | ||
1485 | int dsptileoff = (plane == 0 ? DSPATILEOFF : DSPBTILEOFF); | ||
1486 | int dspcntr_reg = (plane == 0) ? DSPACNTR : DSPBCNTR; | ||
1487 | u32 dspcntr; | 1480 | u32 dspcntr; |
1481 | u32 reg; | ||
1488 | 1482 | ||
1489 | switch (plane) { | 1483 | switch (plane) { |
1490 | case 0: | 1484 | case 0: |
@@ -1499,7 +1493,8 @@ intel_pipe_set_base_atomic(struct drm_crtc *crtc, struct drm_framebuffer *fb, | |||
1499 | obj = intel_fb->obj; | 1493 | obj = intel_fb->obj; |
1500 | obj_priv = to_intel_bo(obj); | 1494 | obj_priv = to_intel_bo(obj); |
1501 | 1495 | ||
1502 | dspcntr = I915_READ(dspcntr_reg); | 1496 | reg = DSPCNTR(plane); |
1497 | dspcntr = I915_READ(reg); | ||
1503 | /* Mask out pixel format bits in case we change it */ | 1498 | /* Mask out pixel format bits in case we change it */ |
1504 | dspcntr &= ~DISPPLANE_PIXFORMAT_MASK; | 1499 | dspcntr &= ~DISPPLANE_PIXFORMAT_MASK; |
1505 | switch (fb->bits_per_pixel) { | 1500 | switch (fb->bits_per_pixel) { |
@@ -1531,22 +1526,21 @@ intel_pipe_set_base_atomic(struct drm_crtc *crtc, struct drm_framebuffer *fb, | |||
1531 | /* must disable */ | 1526 | /* must disable */ |
1532 | dspcntr |= DISPPLANE_TRICKLE_FEED_DISABLE; | 1527 | dspcntr |= DISPPLANE_TRICKLE_FEED_DISABLE; |
1533 | 1528 | ||
1534 | I915_WRITE(dspcntr_reg, dspcntr); | 1529 | I915_WRITE(reg, dspcntr); |
1535 | 1530 | ||
1536 | Start = obj_priv->gtt_offset; | 1531 | Start = obj_priv->gtt_offset; |
1537 | Offset = y * fb->pitch + x * (fb->bits_per_pixel / 8); | 1532 | Offset = y * fb->pitch + x * (fb->bits_per_pixel / 8); |
1538 | 1533 | ||
1539 | DRM_DEBUG_KMS("Writing base %08lX %08lX %d %d %d\n", | 1534 | DRM_DEBUG_KMS("Writing base %08lX %08lX %d %d %d\n", |
1540 | Start, Offset, x, y, fb->pitch); | 1535 | Start, Offset, x, y, fb->pitch); |
1541 | I915_WRITE(dspstride, fb->pitch); | 1536 | I915_WRITE(DSPSTRIDE(plane), fb->pitch); |
1542 | if (IS_I965G(dev)) { | 1537 | if (IS_I965G(dev)) { |
1543 | I915_WRITE(dspsurf, Start); | 1538 | I915_WRITE(DSPSURF(plane), Start); |
1544 | I915_WRITE(dsptileoff, (y << 16) | x); | 1539 | I915_WRITE(DSPTILEOFF(plane), (y << 16) | x); |
1545 | I915_WRITE(dspbase, Offset); | 1540 | I915_WRITE(DSPADDR(plane), Offset); |
1546 | } else { | 1541 | } else |
1547 | I915_WRITE(dspbase, Start + Offset); | 1542 | I915_WRITE(DSPADDR(plane), Start + Offset); |
1548 | } | 1543 | POSTING_READ(reg); |
1549 | POSTING_READ(dspbase); | ||
1550 | 1544 | ||
1551 | intel_update_fbc(dev); | 1545 | intel_update_fbc(dev); |
1552 | intel_increase_pllclock(crtc); | 1546 | intel_increase_pllclock(crtc); |
@@ -1634,7 +1628,7 @@ intel_pipe_set_base(struct drm_crtc *crtc, int x, int y, | |||
1634 | return 0; | 1628 | return 0; |
1635 | } | 1629 | } |
1636 | 1630 | ||
1637 | static void ironlake_set_pll_edp (struct drm_crtc *crtc, int clock) | 1631 | static void ironlake_set_pll_edp(struct drm_crtc *crtc, int clock) |
1638 | { | 1632 | { |
1639 | struct drm_device *dev = crtc->dev; | 1633 | struct drm_device *dev = crtc->dev; |
1640 | struct drm_i915_private *dev_priv = dev->dev_private; | 1634 | struct drm_i915_private *dev_priv = dev->dev_private; |
@@ -1666,8 +1660,8 @@ static void ironlake_set_pll_edp (struct drm_crtc *crtc, int clock) | |||
1666 | dpa_ctl |= DP_PLL_FREQ_270MHZ; | 1660 | dpa_ctl |= DP_PLL_FREQ_270MHZ; |
1667 | } | 1661 | } |
1668 | I915_WRITE(DP_A, dpa_ctl); | 1662 | I915_WRITE(DP_A, dpa_ctl); |
1669 | POSTING_READ(DP_A); | ||
1670 | 1663 | ||
1664 | POSTING_READ(DP_A); | ||
1671 | udelay(500); | 1665 | udelay(500); |
1672 | } | 1666 | } |
1673 | 1667 | ||
@@ -1678,85 +1672,84 @@ static void ironlake_fdi_link_train(struct drm_crtc *crtc) | |||
1678 | struct drm_i915_private *dev_priv = dev->dev_private; | 1672 | struct drm_i915_private *dev_priv = dev->dev_private; |
1679 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); | 1673 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); |
1680 | int pipe = intel_crtc->pipe; | 1674 | int pipe = intel_crtc->pipe; |
1681 | int fdi_tx_reg = (pipe == 0) ? FDI_TXA_CTL : FDI_TXB_CTL; | 1675 | u32 reg, temp, tries; |
1682 | int fdi_rx_reg = (pipe == 0) ? FDI_RXA_CTL : FDI_RXB_CTL; | ||
1683 | int fdi_rx_iir_reg = (pipe == 0) ? FDI_RXA_IIR : FDI_RXB_IIR; | ||
1684 | int fdi_rx_imr_reg = (pipe == 0) ? FDI_RXA_IMR : FDI_RXB_IMR; | ||
1685 | u32 temp, tries = 0; | ||
1686 | 1676 | ||
1687 | /* Train 1: umask FDI RX Interrupt symbol_lock and bit_lock bit | 1677 | /* Train 1: umask FDI RX Interrupt symbol_lock and bit_lock bit |
1688 | for train result */ | 1678 | for train result */ |
1689 | temp = I915_READ(fdi_rx_imr_reg); | 1679 | reg = FDI_RX_IMR(pipe); |
1680 | temp = I915_READ(reg); | ||
1690 | temp &= ~FDI_RX_SYMBOL_LOCK; | 1681 | temp &= ~FDI_RX_SYMBOL_LOCK; |
1691 | temp &= ~FDI_RX_BIT_LOCK; | 1682 | temp &= ~FDI_RX_BIT_LOCK; |
1692 | I915_WRITE(fdi_rx_imr_reg, temp); | 1683 | I915_WRITE(reg, temp); |
1693 | I915_READ(fdi_rx_imr_reg); | 1684 | I915_READ(reg); |
1694 | udelay(150); | 1685 | udelay(150); |
1695 | 1686 | ||
1696 | /* enable CPU FDI TX and PCH FDI RX */ | 1687 | /* enable CPU FDI TX and PCH FDI RX */ |
1697 | temp = I915_READ(fdi_tx_reg); | 1688 | reg = FDI_TX_CTL(pipe); |
1698 | temp |= FDI_TX_ENABLE; | 1689 | temp = I915_READ(reg); |
1699 | temp &= ~(7 << 19); | 1690 | temp &= ~(7 << 19); |
1700 | temp |= (intel_crtc->fdi_lanes - 1) << 19; | 1691 | temp |= (intel_crtc->fdi_lanes - 1) << 19; |
1701 | temp &= ~FDI_LINK_TRAIN_NONE; | 1692 | temp &= ~FDI_LINK_TRAIN_NONE; |
1702 | temp |= FDI_LINK_TRAIN_PATTERN_1; | 1693 | temp |= FDI_LINK_TRAIN_PATTERN_1; |
1703 | I915_WRITE(fdi_tx_reg, temp); | 1694 | I915_WRITE(reg, temp | FDI_TX_ENABLE); |
1704 | I915_READ(fdi_tx_reg); | ||
1705 | 1695 | ||
1706 | temp = I915_READ(fdi_rx_reg); | 1696 | reg = FDI_RX_CTL(pipe); |
1697 | temp = I915_READ(reg); | ||
1707 | temp &= ~FDI_LINK_TRAIN_NONE; | 1698 | temp &= ~FDI_LINK_TRAIN_NONE; |
1708 | temp |= FDI_LINK_TRAIN_PATTERN_1; | 1699 | temp |= FDI_LINK_TRAIN_PATTERN_1; |
1709 | I915_WRITE(fdi_rx_reg, temp | FDI_RX_ENABLE); | 1700 | I915_WRITE(reg, temp | FDI_RX_ENABLE); |
1710 | I915_READ(fdi_rx_reg); | 1701 | |
1702 | POSTING_READ(reg); | ||
1711 | udelay(150); | 1703 | udelay(150); |
1712 | 1704 | ||
1705 | reg = FDI_RX_IIR(pipe); | ||
1713 | for (tries = 0; tries < 5; tries++) { | 1706 | for (tries = 0; tries < 5; tries++) { |
1714 | temp = I915_READ(fdi_rx_iir_reg); | 1707 | temp = I915_READ(reg); |
1715 | DRM_DEBUG_KMS("FDI_RX_IIR 0x%x\n", temp); | 1708 | DRM_DEBUG_KMS("FDI_RX_IIR 0x%x\n", temp); |
1716 | 1709 | ||
1717 | if ((temp & FDI_RX_BIT_LOCK)) { | 1710 | if ((temp & FDI_RX_BIT_LOCK)) { |
1718 | DRM_DEBUG_KMS("FDI train 1 done.\n"); | 1711 | DRM_DEBUG_KMS("FDI train 1 done.\n"); |
1719 | I915_WRITE(fdi_rx_iir_reg, | 1712 | I915_WRITE(reg, temp | FDI_RX_BIT_LOCK); |
1720 | temp | FDI_RX_BIT_LOCK); | ||
1721 | break; | 1713 | break; |
1722 | } | 1714 | } |
1723 | } | 1715 | } |
1724 | if (tries == 5) | 1716 | if (tries == 5) |
1725 | DRM_DEBUG_KMS("FDI train 1 fail!\n"); | 1717 | DRM_ERROR("FDI train 1 fail!\n"); |
1726 | 1718 | ||
1727 | /* Train 2 */ | 1719 | /* Train 2 */ |
1728 | temp = I915_READ(fdi_tx_reg); | 1720 | reg = FDI_TX_CTL(pipe); |
1721 | temp = I915_READ(reg); | ||
1729 | temp &= ~FDI_LINK_TRAIN_NONE; | 1722 | temp &= ~FDI_LINK_TRAIN_NONE; |
1730 | temp |= FDI_LINK_TRAIN_PATTERN_2; | 1723 | temp |= FDI_LINK_TRAIN_PATTERN_2; |
1731 | I915_WRITE(fdi_tx_reg, temp); | 1724 | I915_WRITE(reg, temp); |
1732 | 1725 | ||
1733 | temp = I915_READ(fdi_rx_reg); | 1726 | reg = FDI_RX_CTL(pipe); |
1727 | temp = I915_READ(reg); | ||
1734 | temp &= ~FDI_LINK_TRAIN_NONE; | 1728 | temp &= ~FDI_LINK_TRAIN_NONE; |
1735 | temp |= FDI_LINK_TRAIN_PATTERN_2; | 1729 | temp |= FDI_LINK_TRAIN_PATTERN_2; |
1736 | I915_WRITE(fdi_rx_reg, temp); | 1730 | I915_WRITE(reg, temp); |
1737 | POSTING_READ(fdi_rx_reg); | ||
1738 | udelay(150); | ||
1739 | 1731 | ||
1740 | tries = 0; | 1732 | POSTING_READ(reg); |
1733 | udelay(150); | ||
1741 | 1734 | ||
1735 | reg = FDI_RX_IIR(pipe); | ||
1742 | for (tries = 0; tries < 5; tries++) { | 1736 | for (tries = 0; tries < 5; tries++) { |
1743 | temp = I915_READ(fdi_rx_iir_reg); | 1737 | temp = I915_READ(reg); |
1744 | DRM_DEBUG_KMS("FDI_RX_IIR 0x%x\n", temp); | 1738 | DRM_DEBUG_KMS("FDI_RX_IIR 0x%x\n", temp); |
1745 | 1739 | ||
1746 | if (temp & FDI_RX_SYMBOL_LOCK) { | 1740 | if (temp & FDI_RX_SYMBOL_LOCK) { |
1747 | I915_WRITE(fdi_rx_iir_reg, | 1741 | I915_WRITE(reg, temp | FDI_RX_SYMBOL_LOCK); |
1748 | temp | FDI_RX_SYMBOL_LOCK); | ||
1749 | DRM_DEBUG_KMS("FDI train 2 done.\n"); | 1742 | DRM_DEBUG_KMS("FDI train 2 done.\n"); |
1750 | break; | 1743 | break; |
1751 | } | 1744 | } |
1752 | } | 1745 | } |
1753 | if (tries == 5) | 1746 | if (tries == 5) |
1754 | DRM_DEBUG_KMS("FDI train 2 fail!\n"); | 1747 | DRM_ERROR("FDI train 2 fail!\n"); |
1755 | 1748 | ||
1756 | DRM_DEBUG_KMS("FDI train done\n"); | 1749 | DRM_DEBUG_KMS("FDI train done\n"); |
1757 | } | 1750 | } |
1758 | 1751 | ||
1759 | static int snb_b_fdi_train_param [] = { | 1752 | static const int const snb_b_fdi_train_param [] = { |
1760 | FDI_LINK_TRAIN_400MV_0DB_SNB_B, | 1753 | FDI_LINK_TRAIN_400MV_0DB_SNB_B, |
1761 | FDI_LINK_TRAIN_400MV_6DB_SNB_B, | 1754 | FDI_LINK_TRAIN_400MV_6DB_SNB_B, |
1762 | FDI_LINK_TRAIN_600MV_3_5DB_SNB_B, | 1755 | FDI_LINK_TRAIN_600MV_3_5DB_SNB_B, |
@@ -1770,24 +1763,22 @@ static void gen6_fdi_link_train(struct drm_crtc *crtc) | |||
1770 | struct drm_i915_private *dev_priv = dev->dev_private; | 1763 | struct drm_i915_private *dev_priv = dev->dev_private; |
1771 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); | 1764 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); |
1772 | int pipe = intel_crtc->pipe; | 1765 | int pipe = intel_crtc->pipe; |
1773 | int fdi_tx_reg = (pipe == 0) ? FDI_TXA_CTL : FDI_TXB_CTL; | 1766 | u32 reg, temp, i; |
1774 | int fdi_rx_reg = (pipe == 0) ? FDI_RXA_CTL : FDI_RXB_CTL; | ||
1775 | int fdi_rx_iir_reg = (pipe == 0) ? FDI_RXA_IIR : FDI_RXB_IIR; | ||
1776 | int fdi_rx_imr_reg = (pipe == 0) ? FDI_RXA_IMR : FDI_RXB_IMR; | ||
1777 | u32 temp, i; | ||
1778 | 1767 | ||
1779 | /* Train 1: umask FDI RX Interrupt symbol_lock and bit_lock bit | 1768 | /* Train 1: umask FDI RX Interrupt symbol_lock and bit_lock bit |
1780 | for train result */ | 1769 | for train result */ |
1781 | temp = I915_READ(fdi_rx_imr_reg); | 1770 | reg = FDI_RX_IMR(pipe); |
1771 | temp = I915_READ(reg); | ||
1782 | temp &= ~FDI_RX_SYMBOL_LOCK; | 1772 | temp &= ~FDI_RX_SYMBOL_LOCK; |
1783 | temp &= ~FDI_RX_BIT_LOCK; | 1773 | temp &= ~FDI_RX_BIT_LOCK; |
1784 | I915_WRITE(fdi_rx_imr_reg, temp); | 1774 | I915_WRITE(reg, temp); |
1785 | I915_READ(fdi_rx_imr_reg); | 1775 | |
1776 | POSTING_READ(reg); | ||
1786 | udelay(150); | 1777 | udelay(150); |
1787 | 1778 | ||
1788 | /* enable CPU FDI TX and PCH FDI RX */ | 1779 | /* enable CPU FDI TX and PCH FDI RX */ |
1789 | temp = I915_READ(fdi_tx_reg); | 1780 | reg = FDI_TX_CTL(pipe); |
1790 | temp |= FDI_TX_ENABLE; | 1781 | temp = I915_READ(reg); |
1791 | temp &= ~(7 << 19); | 1782 | temp &= ~(7 << 19); |
1792 | temp |= (intel_crtc->fdi_lanes - 1) << 19; | 1783 | temp |= (intel_crtc->fdi_lanes - 1) << 19; |
1793 | temp &= ~FDI_LINK_TRAIN_NONE; | 1784 | temp &= ~FDI_LINK_TRAIN_NONE; |
@@ -1795,10 +1786,10 @@ static void gen6_fdi_link_train(struct drm_crtc *crtc) | |||
1795 | temp &= ~FDI_LINK_TRAIN_VOL_EMP_MASK; | 1786 | temp &= ~FDI_LINK_TRAIN_VOL_EMP_MASK; |
1796 | /* SNB-B */ | 1787 | /* SNB-B */ |
1797 | temp |= FDI_LINK_TRAIN_400MV_0DB_SNB_B; | 1788 | temp |= FDI_LINK_TRAIN_400MV_0DB_SNB_B; |
1798 | I915_WRITE(fdi_tx_reg, temp); | 1789 | I915_WRITE(reg, temp | FDI_TX_ENABLE); |
1799 | I915_READ(fdi_tx_reg); | ||
1800 | 1790 | ||
1801 | temp = I915_READ(fdi_rx_reg); | 1791 | reg = FDI_RX_CTL(pipe); |
1792 | temp = I915_READ(reg); | ||
1802 | if (HAS_PCH_CPT(dev)) { | 1793 | if (HAS_PCH_CPT(dev)) { |
1803 | temp &= ~FDI_LINK_TRAIN_PATTERN_MASK_CPT; | 1794 | temp &= ~FDI_LINK_TRAIN_PATTERN_MASK_CPT; |
1804 | temp |= FDI_LINK_TRAIN_PATTERN_1_CPT; | 1795 | temp |= FDI_LINK_TRAIN_PATTERN_1_CPT; |
@@ -1806,33 +1797,37 @@ static void gen6_fdi_link_train(struct drm_crtc *crtc) | |||
1806 | temp &= ~FDI_LINK_TRAIN_NONE; | 1797 | temp &= ~FDI_LINK_TRAIN_NONE; |
1807 | temp |= FDI_LINK_TRAIN_PATTERN_1; | 1798 | temp |= FDI_LINK_TRAIN_PATTERN_1; |
1808 | } | 1799 | } |
1809 | I915_WRITE(fdi_rx_reg, temp | FDI_RX_ENABLE); | 1800 | I915_WRITE(reg, temp | FDI_RX_ENABLE); |
1810 | I915_READ(fdi_rx_reg); | 1801 | |
1802 | POSTING_READ(reg); | ||
1811 | udelay(150); | 1803 | udelay(150); |
1812 | 1804 | ||
1813 | for (i = 0; i < 4; i++ ) { | 1805 | for (i = 0; i < 4; i++ ) { |
1814 | temp = I915_READ(fdi_tx_reg); | 1806 | reg = FDI_TX_CTL(pipe); |
1807 | temp = I915_READ(reg); | ||
1815 | temp &= ~FDI_LINK_TRAIN_VOL_EMP_MASK; | 1808 | temp &= ~FDI_LINK_TRAIN_VOL_EMP_MASK; |
1816 | temp |= snb_b_fdi_train_param[i]; | 1809 | temp |= snb_b_fdi_train_param[i]; |
1817 | I915_WRITE(fdi_tx_reg, temp); | 1810 | I915_WRITE(reg, temp); |
1818 | POSTING_READ(fdi_tx_reg); | 1811 | |
1812 | POSTING_READ(reg); | ||
1819 | udelay(500); | 1813 | udelay(500); |
1820 | 1814 | ||
1821 | temp = I915_READ(fdi_rx_iir_reg); | 1815 | reg = FDI_RX_IIR(pipe); |
1816 | temp = I915_READ(reg); | ||
1822 | DRM_DEBUG_KMS("FDI_RX_IIR 0x%x\n", temp); | 1817 | DRM_DEBUG_KMS("FDI_RX_IIR 0x%x\n", temp); |
1823 | 1818 | ||
1824 | if (temp & FDI_RX_BIT_LOCK) { | 1819 | if (temp & FDI_RX_BIT_LOCK) { |
1825 | I915_WRITE(fdi_rx_iir_reg, | 1820 | I915_WRITE(reg, temp | FDI_RX_BIT_LOCK); |
1826 | temp | FDI_RX_BIT_LOCK); | ||
1827 | DRM_DEBUG_KMS("FDI train 1 done.\n"); | 1821 | DRM_DEBUG_KMS("FDI train 1 done.\n"); |
1828 | break; | 1822 | break; |
1829 | } | 1823 | } |
1830 | } | 1824 | } |
1831 | if (i == 4) | 1825 | if (i == 4) |
1832 | DRM_DEBUG_KMS("FDI train 1 fail!\n"); | 1826 | DRM_ERROR("FDI train 1 fail!\n"); |
1833 | 1827 | ||
1834 | /* Train 2 */ | 1828 | /* Train 2 */ |
1835 | temp = I915_READ(fdi_tx_reg); | 1829 | reg = FDI_TX_CTL(pipe); |
1830 | temp = I915_READ(reg); | ||
1836 | temp &= ~FDI_LINK_TRAIN_NONE; | 1831 | temp &= ~FDI_LINK_TRAIN_NONE; |
1837 | temp |= FDI_LINK_TRAIN_PATTERN_2; | 1832 | temp |= FDI_LINK_TRAIN_PATTERN_2; |
1838 | if (IS_GEN6(dev)) { | 1833 | if (IS_GEN6(dev)) { |
@@ -1840,9 +1835,10 @@ static void gen6_fdi_link_train(struct drm_crtc *crtc) | |||
1840 | /* SNB-B */ | 1835 | /* SNB-B */ |
1841 | temp |= FDI_LINK_TRAIN_400MV_0DB_SNB_B; | 1836 | temp |= FDI_LINK_TRAIN_400MV_0DB_SNB_B; |
1842 | } | 1837 | } |
1843 | I915_WRITE(fdi_tx_reg, temp); | 1838 | I915_WRITE(reg, temp); |
1844 | 1839 | ||
1845 | temp = I915_READ(fdi_rx_reg); | 1840 | reg = FDI_RX_CTL(pipe); |
1841 | temp = I915_READ(reg); | ||
1846 | if (HAS_PCH_CPT(dev)) { | 1842 | if (HAS_PCH_CPT(dev)) { |
1847 | temp &= ~FDI_LINK_TRAIN_PATTERN_MASK_CPT; | 1843 | temp &= ~FDI_LINK_TRAIN_PATTERN_MASK_CPT; |
1848 | temp |= FDI_LINK_TRAIN_PATTERN_2_CPT; | 1844 | temp |= FDI_LINK_TRAIN_PATTERN_2_CPT; |
@@ -1850,30 +1846,33 @@ static void gen6_fdi_link_train(struct drm_crtc *crtc) | |||
1850 | temp &= ~FDI_LINK_TRAIN_NONE; | 1846 | temp &= ~FDI_LINK_TRAIN_NONE; |
1851 | temp |= FDI_LINK_TRAIN_PATTERN_2; | 1847 | temp |= FDI_LINK_TRAIN_PATTERN_2; |
1852 | } | 1848 | } |
1853 | I915_WRITE(fdi_rx_reg, temp); | 1849 | I915_WRITE(reg, temp); |
1854 | POSTING_READ(fdi_rx_reg); | 1850 | |
1851 | POSTING_READ(reg); | ||
1855 | udelay(150); | 1852 | udelay(150); |
1856 | 1853 | ||
1857 | for (i = 0; i < 4; i++ ) { | 1854 | for (i = 0; i < 4; i++ ) { |
1858 | temp = I915_READ(fdi_tx_reg); | 1855 | reg = FDI_TX_CTL(pipe); |
1856 | temp = I915_READ(reg); | ||
1859 | temp &= ~FDI_LINK_TRAIN_VOL_EMP_MASK; | 1857 | temp &= ~FDI_LINK_TRAIN_VOL_EMP_MASK; |
1860 | temp |= snb_b_fdi_train_param[i]; | 1858 | temp |= snb_b_fdi_train_param[i]; |
1861 | I915_WRITE(fdi_tx_reg, temp); | 1859 | I915_WRITE(reg, temp); |
1862 | POSTING_READ(fdi_tx_reg); | 1860 | |
1861 | POSTING_READ(reg); | ||
1863 | udelay(500); | 1862 | udelay(500); |
1864 | 1863 | ||
1865 | temp = I915_READ(fdi_rx_iir_reg); | 1864 | reg = FDI_RX_IIR(pipe); |
1865 | temp = I915_READ(reg); | ||
1866 | DRM_DEBUG_KMS("FDI_RX_IIR 0x%x\n", temp); | 1866 | DRM_DEBUG_KMS("FDI_RX_IIR 0x%x\n", temp); |
1867 | 1867 | ||
1868 | if (temp & FDI_RX_SYMBOL_LOCK) { | 1868 | if (temp & FDI_RX_SYMBOL_LOCK) { |
1869 | I915_WRITE(fdi_rx_iir_reg, | 1869 | I915_WRITE(reg, temp | FDI_RX_SYMBOL_LOCK); |
1870 | temp | FDI_RX_SYMBOL_LOCK); | ||
1871 | DRM_DEBUG_KMS("FDI train 2 done.\n"); | 1870 | DRM_DEBUG_KMS("FDI train 2 done.\n"); |
1872 | break; | 1871 | break; |
1873 | } | 1872 | } |
1874 | } | 1873 | } |
1875 | if (i == 4) | 1874 | if (i == 4) |
1876 | DRM_DEBUG_KMS("FDI train 2 fail!\n"); | 1875 | DRM_ERROR("FDI train 2 fail!\n"); |
1877 | 1876 | ||
1878 | DRM_DEBUG_KMS("FDI train done.\n"); | 1877 | DRM_DEBUG_KMS("FDI train done.\n"); |
1879 | } | 1878 | } |
@@ -1884,50 +1883,49 @@ static void ironlake_fdi_enable(struct drm_crtc *crtc) | |||
1884 | struct drm_i915_private *dev_priv = dev->dev_private; | 1883 | struct drm_i915_private *dev_priv = dev->dev_private; |
1885 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); | 1884 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); |
1886 | int pipe = intel_crtc->pipe; | 1885 | int pipe = intel_crtc->pipe; |
1887 | int pipeconf_reg = (pipe == 0) ? PIPEACONF : PIPEBCONF; | 1886 | u32 reg, temp; |
1888 | int fdi_tx_reg = (pipe == 0) ? FDI_TXA_CTL : FDI_TXB_CTL; | ||
1889 | int fdi_rx_reg = (pipe == 0) ? FDI_RXA_CTL : FDI_RXB_CTL; | ||
1890 | int data_m1_reg = (pipe == 0) ? PIPEA_DATA_M1 : PIPEB_DATA_M1; | ||
1891 | u32 temp; | ||
1892 | u32 pipe_bpc; | ||
1893 | u32 tx_size; | ||
1894 | |||
1895 | temp = I915_READ(pipeconf_reg); | ||
1896 | pipe_bpc = temp & PIPE_BPC_MASK; | ||
1897 | 1887 | ||
1898 | /* Write the TU size bits so error detection works */ | 1888 | /* Write the TU size bits so error detection works */ |
1899 | tx_size = I915_READ(data_m1_reg) & TU_SIZE_MASK; | 1889 | I915_WRITE(FDI_RX_TUSIZE1(pipe), |
1900 | I915_WRITE(FDI_RXA_TUSIZE1, tx_size); | 1890 | I915_READ(PIPE_DATA_M1(pipe)) & TU_SIZE_MASK); |
1901 | 1891 | ||
1902 | /* enable PCH FDI RX PLL, wait warmup plus DMI latency */ | 1892 | /* enable PCH FDI RX PLL, wait warmup plus DMI latency */ |
1903 | temp = I915_READ(fdi_rx_reg); | 1893 | reg = FDI_RX_CTL(pipe); |
1904 | /* | 1894 | temp = I915_READ(reg); |
1905 | * make the BPC in FDI Rx be consistent with that in | 1895 | temp &= ~((0x7 << 19) | (0x7 << 16)); |
1906 | * pipeconf reg. | ||
1907 | */ | ||
1908 | temp &= ~(0x7 << 16); | ||
1909 | temp |= (pipe_bpc << 11); | ||
1910 | temp &= ~(7 << 19); | ||
1911 | temp |= (intel_crtc->fdi_lanes - 1) << 19; | 1896 | temp |= (intel_crtc->fdi_lanes - 1) << 19; |
1912 | I915_WRITE(fdi_rx_reg, temp | FDI_RX_PLL_ENABLE); | 1897 | temp |= (I915_READ(PIPECONF(pipe)) & PIPE_BPC_MASK) << 11; |
1913 | I915_READ(fdi_rx_reg); | 1898 | I915_WRITE(reg, temp | FDI_RX_PLL_ENABLE); |
1899 | |||
1900 | POSTING_READ(reg); | ||
1914 | udelay(200); | 1901 | udelay(200); |
1915 | 1902 | ||
1916 | /* Switch from Rawclk to PCDclk */ | 1903 | /* Switch from Rawclk to PCDclk */ |
1917 | temp = I915_READ(fdi_rx_reg); | 1904 | temp = I915_READ(reg); |
1918 | I915_WRITE(fdi_rx_reg, temp | FDI_SEL_PCDCLK); | 1905 | I915_WRITE(reg, temp | FDI_PCDCLK); |
1919 | I915_READ(fdi_rx_reg); | 1906 | |
1907 | POSTING_READ(reg); | ||
1920 | udelay(200); | 1908 | udelay(200); |
1921 | 1909 | ||
1922 | /* Enable CPU FDI TX PLL, always on for Ironlake */ | 1910 | /* Enable CPU FDI TX PLL, always on for Ironlake */ |
1923 | temp = I915_READ(fdi_tx_reg); | 1911 | reg = FDI_TX_CTL(pipe); |
1912 | temp = I915_READ(reg); | ||
1924 | if ((temp & FDI_TX_PLL_ENABLE) == 0) { | 1913 | if ((temp & FDI_TX_PLL_ENABLE) == 0) { |
1925 | I915_WRITE(fdi_tx_reg, temp | FDI_TX_PLL_ENABLE); | 1914 | I915_WRITE(reg, temp | FDI_TX_PLL_ENABLE); |
1926 | I915_READ(fdi_tx_reg); | 1915 | |
1916 | POSTING_READ(reg); | ||
1927 | udelay(100); | 1917 | udelay(100); |
1928 | } | 1918 | } |
1929 | } | 1919 | } |
1930 | 1920 | ||
1921 | static void intel_flush_display_plane(struct drm_device *dev, | ||
1922 | int plane) | ||
1923 | { | ||
1924 | struct drm_i915_private *dev_priv = dev->dev_private; | ||
1925 | u32 reg = DSPADDR(plane); | ||
1926 | I915_WRITE(reg, I915_READ(reg)); | ||
1927 | } | ||
1928 | |||
1931 | static void ironlake_crtc_enable(struct drm_crtc *crtc) | 1929 | static void ironlake_crtc_enable(struct drm_crtc *crtc) |
1932 | { | 1930 | { |
1933 | struct drm_device *dev = crtc->dev; | 1931 | struct drm_device *dev = crtc->dev; |
@@ -1935,38 +1933,12 @@ static void ironlake_crtc_enable(struct drm_crtc *crtc) | |||
1935 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); | 1933 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); |
1936 | int pipe = intel_crtc->pipe; | 1934 | int pipe = intel_crtc->pipe; |
1937 | int plane = intel_crtc->plane; | 1935 | int plane = intel_crtc->plane; |
1938 | int pch_dpll_reg = (pipe == 0) ? PCH_DPLL_A : PCH_DPLL_B; | 1936 | u32 reg, temp; |
1939 | int pipeconf_reg = (pipe == 0) ? PIPEACONF : PIPEBCONF; | ||
1940 | int dspcntr_reg = (plane == 0) ? DSPACNTR : DSPBCNTR; | ||
1941 | int dspbase_reg = (plane == 0) ? DSPAADDR : DSPBADDR; | ||
1942 | int fdi_tx_reg = (pipe == 0) ? FDI_TXA_CTL : FDI_TXB_CTL; | ||
1943 | int fdi_rx_reg = (pipe == 0) ? FDI_RXA_CTL : FDI_RXB_CTL; | ||
1944 | int transconf_reg = (pipe == 0) ? TRANSACONF : TRANSBCONF; | ||
1945 | int cpu_htot_reg = (pipe == 0) ? HTOTAL_A : HTOTAL_B; | ||
1946 | int cpu_hblank_reg = (pipe == 0) ? HBLANK_A : HBLANK_B; | ||
1947 | int cpu_hsync_reg = (pipe == 0) ? HSYNC_A : HSYNC_B; | ||
1948 | int cpu_vtot_reg = (pipe == 0) ? VTOTAL_A : VTOTAL_B; | ||
1949 | int cpu_vblank_reg = (pipe == 0) ? VBLANK_A : VBLANK_B; | ||
1950 | int cpu_vsync_reg = (pipe == 0) ? VSYNC_A : VSYNC_B; | ||
1951 | int trans_htot_reg = (pipe == 0) ? TRANS_HTOTAL_A : TRANS_HTOTAL_B; | ||
1952 | int trans_hblank_reg = (pipe == 0) ? TRANS_HBLANK_A : TRANS_HBLANK_B; | ||
1953 | int trans_hsync_reg = (pipe == 0) ? TRANS_HSYNC_A : TRANS_HSYNC_B; | ||
1954 | int trans_vtot_reg = (pipe == 0) ? TRANS_VTOTAL_A : TRANS_VTOTAL_B; | ||
1955 | int trans_vblank_reg = (pipe == 0) ? TRANS_VBLANK_A : TRANS_VBLANK_B; | ||
1956 | int trans_vsync_reg = (pipe == 0) ? TRANS_VSYNC_A : TRANS_VSYNC_B; | ||
1957 | int trans_dpll_sel = (pipe == 0) ? 0 : 1; | ||
1958 | u32 temp; | ||
1959 | u32 pipe_bpc; | ||
1960 | |||
1961 | temp = I915_READ(pipeconf_reg); | ||
1962 | pipe_bpc = temp & PIPE_BPC_MASK; | ||
1963 | 1937 | ||
1964 | if (intel_pipe_has_type(crtc, INTEL_OUTPUT_LVDS)) { | 1938 | if (intel_pipe_has_type(crtc, INTEL_OUTPUT_LVDS)) { |
1965 | temp = I915_READ(PCH_LVDS); | 1939 | temp = I915_READ(PCH_LVDS); |
1966 | if ((temp & LVDS_PORT_EN) == 0) { | 1940 | if ((temp & LVDS_PORT_EN) == 0) |
1967 | I915_WRITE(PCH_LVDS, temp | LVDS_PORT_EN); | 1941 | I915_WRITE(PCH_LVDS, temp | LVDS_PORT_EN); |
1968 | POSTING_READ(PCH_LVDS); | ||
1969 | } | ||
1970 | } | 1942 | } |
1971 | 1943 | ||
1972 | ironlake_fdi_enable(crtc); | 1944 | ironlake_fdi_enable(crtc); |
@@ -1988,19 +1960,20 @@ static void ironlake_crtc_enable(struct drm_crtc *crtc) | |||
1988 | } | 1960 | } |
1989 | 1961 | ||
1990 | /* Enable CPU pipe */ | 1962 | /* Enable CPU pipe */ |
1991 | temp = I915_READ(pipeconf_reg); | 1963 | reg = PIPECONF(pipe); |
1992 | if ((temp & PIPEACONF_ENABLE) == 0) { | 1964 | temp = I915_READ(reg); |
1993 | I915_WRITE(pipeconf_reg, temp | PIPEACONF_ENABLE); | 1965 | if ((temp & PIPECONF_ENABLE) == 0) { |
1994 | I915_READ(pipeconf_reg); | 1966 | I915_WRITE(reg, temp | PIPECONF_ENABLE); |
1967 | POSTING_READ(reg); | ||
1995 | udelay(100); | 1968 | udelay(100); |
1996 | } | 1969 | } |
1997 | 1970 | ||
1998 | /* configure and enable CPU plane */ | 1971 | /* configure and enable CPU plane */ |
1999 | temp = I915_READ(dspcntr_reg); | 1972 | reg = DSPCNTR(plane); |
1973 | temp = I915_READ(reg); | ||
2000 | if ((temp & DISPLAY_PLANE_ENABLE) == 0) { | 1974 | if ((temp & DISPLAY_PLANE_ENABLE) == 0) { |
2001 | I915_WRITE(dspcntr_reg, temp | DISPLAY_PLANE_ENABLE); | 1975 | I915_WRITE(reg, temp | DISPLAY_PLANE_ENABLE); |
2002 | /* Flush the plane changes */ | 1976 | intel_flush_display_plane(dev, plane); |
2003 | I915_WRITE(dspbase_reg, I915_READ(dspbase_reg)); | ||
2004 | } | 1977 | } |
2005 | 1978 | ||
2006 | /* For PCH output, training FDI link */ | 1979 | /* For PCH output, training FDI link */ |
@@ -2010,42 +1983,42 @@ static void ironlake_crtc_enable(struct drm_crtc *crtc) | |||
2010 | ironlake_fdi_link_train(crtc); | 1983 | ironlake_fdi_link_train(crtc); |
2011 | 1984 | ||
2012 | /* enable PCH DPLL */ | 1985 | /* enable PCH DPLL */ |
2013 | temp = I915_READ(pch_dpll_reg); | 1986 | reg = PCH_DPLL(pipe); |
1987 | temp = I915_READ(reg); | ||
2014 | if ((temp & DPLL_VCO_ENABLE) == 0) { | 1988 | if ((temp & DPLL_VCO_ENABLE) == 0) { |
2015 | I915_WRITE(pch_dpll_reg, temp | DPLL_VCO_ENABLE); | 1989 | I915_WRITE(reg, temp | DPLL_VCO_ENABLE); |
2016 | I915_READ(pch_dpll_reg); | 1990 | POSTING_READ(reg); |
2017 | udelay(200); | 1991 | udelay(200); |
2018 | } | 1992 | } |
2019 | 1993 | ||
2020 | if (HAS_PCH_CPT(dev)) { | 1994 | if (HAS_PCH_CPT(dev)) { |
2021 | /* Be sure PCH DPLL SEL is set */ | 1995 | /* Be sure PCH DPLL SEL is set */ |
2022 | temp = I915_READ(PCH_DPLL_SEL); | 1996 | temp = I915_READ(PCH_DPLL_SEL); |
2023 | if (trans_dpll_sel == 0 && | 1997 | if (pipe == 0 && (temp & TRANSA_DPLL_ENABLE) == 0) |
2024 | (temp & TRANSA_DPLL_ENABLE) == 0) | ||
2025 | temp |= (TRANSA_DPLL_ENABLE | TRANSA_DPLLA_SEL); | 1998 | temp |= (TRANSA_DPLL_ENABLE | TRANSA_DPLLA_SEL); |
2026 | else if (trans_dpll_sel == 1 && | 1999 | else if (pipe == 1 && (temp & TRANSB_DPLL_ENABLE) == 0) |
2027 | (temp & TRANSB_DPLL_ENABLE) == 0) | ||
2028 | temp |= (TRANSB_DPLL_ENABLE | TRANSB_DPLLB_SEL); | 2000 | temp |= (TRANSB_DPLL_ENABLE | TRANSB_DPLLB_SEL); |
2029 | I915_WRITE(PCH_DPLL_SEL, temp); | 2001 | I915_WRITE(PCH_DPLL_SEL, temp); |
2030 | I915_READ(PCH_DPLL_SEL); | ||
2031 | } | 2002 | } |
2003 | |||
2032 | /* set transcoder timing */ | 2004 | /* set transcoder timing */ |
2033 | I915_WRITE(trans_htot_reg, I915_READ(cpu_htot_reg)); | 2005 | I915_WRITE(TRANS_HTOTAL(pipe), I915_READ(HTOTAL(pipe))); |
2034 | I915_WRITE(trans_hblank_reg, I915_READ(cpu_hblank_reg)); | 2006 | I915_WRITE(TRANS_HBLANK(pipe), I915_READ(HBLANK(pipe))); |
2035 | I915_WRITE(trans_hsync_reg, I915_READ(cpu_hsync_reg)); | 2007 | I915_WRITE(TRANS_HSYNC(pipe), I915_READ(HSYNC(pipe))); |
2036 | 2008 | ||
2037 | I915_WRITE(trans_vtot_reg, I915_READ(cpu_vtot_reg)); | 2009 | I915_WRITE(TRANS_VTOTAL(pipe), I915_READ(VTOTAL(pipe))); |
2038 | I915_WRITE(trans_vblank_reg, I915_READ(cpu_vblank_reg)); | 2010 | I915_WRITE(TRANS_VBLANK(pipe), I915_READ(VBLANK(pipe))); |
2039 | I915_WRITE(trans_vsync_reg, I915_READ(cpu_vsync_reg)); | 2011 | I915_WRITE(TRANS_VSYNC(pipe), I915_READ(VSYNC(pipe))); |
2040 | 2012 | ||
2041 | /* enable normal train */ | 2013 | /* enable normal train */ |
2042 | temp = I915_READ(fdi_tx_reg); | 2014 | reg = FDI_TX_CTL(pipe); |
2015 | temp = I915_READ(reg); | ||
2043 | temp &= ~FDI_LINK_TRAIN_NONE; | 2016 | temp &= ~FDI_LINK_TRAIN_NONE; |
2044 | I915_WRITE(fdi_tx_reg, temp | FDI_LINK_TRAIN_NONE | | 2017 | temp |= FDI_LINK_TRAIN_NONE | FDI_TX_ENHANCE_FRAME_ENABLE; |
2045 | FDI_TX_ENHANCE_FRAME_ENABLE); | 2018 | I915_WRITE(reg, temp); |
2046 | I915_READ(fdi_tx_reg); | ||
2047 | 2019 | ||
2048 | temp = I915_READ(fdi_rx_reg); | 2020 | reg = FDI_RX_CTL(pipe); |
2021 | temp = I915_READ(reg); | ||
2049 | if (HAS_PCH_CPT(dev)) { | 2022 | if (HAS_PCH_CPT(dev)) { |
2050 | temp &= ~FDI_LINK_TRAIN_PATTERN_MASK_CPT; | 2023 | temp &= ~FDI_LINK_TRAIN_PATTERN_MASK_CPT; |
2051 | temp |= FDI_LINK_TRAIN_NORMAL_CPT; | 2024 | temp |= FDI_LINK_TRAIN_NORMAL_CPT; |
@@ -2053,61 +2026,57 @@ static void ironlake_crtc_enable(struct drm_crtc *crtc) | |||
2053 | temp &= ~FDI_LINK_TRAIN_NONE; | 2026 | temp &= ~FDI_LINK_TRAIN_NONE; |
2054 | temp |= FDI_LINK_TRAIN_NONE; | 2027 | temp |= FDI_LINK_TRAIN_NONE; |
2055 | } | 2028 | } |
2056 | I915_WRITE(fdi_rx_reg, temp | FDI_RX_ENHANCE_FRAME_ENABLE); | 2029 | I915_WRITE(reg, temp | FDI_RX_ENHANCE_FRAME_ENABLE); |
2057 | I915_READ(fdi_rx_reg); | ||
2058 | 2030 | ||
2059 | /* wait one idle pattern time */ | 2031 | /* wait one idle pattern time */ |
2032 | POSTING_READ(reg); | ||
2060 | udelay(100); | 2033 | udelay(100); |
2061 | 2034 | ||
2062 | /* For PCH DP, enable TRANS_DP_CTL */ | 2035 | /* For PCH DP, enable TRANS_DP_CTL */ |
2063 | if (HAS_PCH_CPT(dev) && | 2036 | if (HAS_PCH_CPT(dev) && |
2064 | intel_pipe_has_type(crtc, INTEL_OUTPUT_DISPLAYPORT)) { | 2037 | intel_pipe_has_type(crtc, INTEL_OUTPUT_DISPLAYPORT)) { |
2065 | int trans_dp_ctl = (pipe == 0) ? TRANS_DP_CTL_A : TRANS_DP_CTL_B; | 2038 | reg = TRANS_DP_CTL(pipe); |
2066 | int reg; | 2039 | temp = I915_READ(reg); |
2067 | 2040 | temp &= ~(TRANS_DP_PORT_SEL_MASK | | |
2068 | reg = I915_READ(trans_dp_ctl); | 2041 | TRANS_DP_SYNC_MASK); |
2069 | reg &= ~(TRANS_DP_PORT_SEL_MASK | | 2042 | temp |= (TRANS_DP_OUTPUT_ENABLE | |
2070 | TRANS_DP_SYNC_MASK); | 2043 | TRANS_DP_ENH_FRAMING); |
2071 | reg |= (TRANS_DP_OUTPUT_ENABLE | | ||
2072 | TRANS_DP_ENH_FRAMING); | ||
2073 | 2044 | ||
2074 | if (crtc->mode.flags & DRM_MODE_FLAG_PHSYNC) | 2045 | if (crtc->mode.flags & DRM_MODE_FLAG_PHSYNC) |
2075 | reg |= TRANS_DP_HSYNC_ACTIVE_HIGH; | 2046 | temp |= TRANS_DP_HSYNC_ACTIVE_HIGH; |
2076 | if (crtc->mode.flags & DRM_MODE_FLAG_PVSYNC) | 2047 | if (crtc->mode.flags & DRM_MODE_FLAG_PVSYNC) |
2077 | reg |= TRANS_DP_VSYNC_ACTIVE_HIGH; | 2048 | temp |= TRANS_DP_VSYNC_ACTIVE_HIGH; |
2078 | 2049 | ||
2079 | switch (intel_trans_dp_port_sel(crtc)) { | 2050 | switch (intel_trans_dp_port_sel(crtc)) { |
2080 | case PCH_DP_B: | 2051 | case PCH_DP_B: |
2081 | reg |= TRANS_DP_PORT_SEL_B; | 2052 | temp |= TRANS_DP_PORT_SEL_B; |
2082 | break; | 2053 | break; |
2083 | case PCH_DP_C: | 2054 | case PCH_DP_C: |
2084 | reg |= TRANS_DP_PORT_SEL_C; | 2055 | temp |= TRANS_DP_PORT_SEL_C; |
2085 | break; | 2056 | break; |
2086 | case PCH_DP_D: | 2057 | case PCH_DP_D: |
2087 | reg |= TRANS_DP_PORT_SEL_D; | 2058 | temp |= TRANS_DP_PORT_SEL_D; |
2088 | break; | 2059 | break; |
2089 | default: | 2060 | default: |
2090 | DRM_DEBUG_KMS("Wrong PCH DP port return. Guess port B\n"); | 2061 | DRM_DEBUG_KMS("Wrong PCH DP port return. Guess port B\n"); |
2091 | reg |= TRANS_DP_PORT_SEL_B; | 2062 | temp |= TRANS_DP_PORT_SEL_B; |
2092 | break; | 2063 | break; |
2093 | } | 2064 | } |
2094 | 2065 | ||
2095 | I915_WRITE(trans_dp_ctl, reg); | 2066 | I915_WRITE(reg, temp); |
2096 | POSTING_READ(trans_dp_ctl); | ||
2097 | } | 2067 | } |
2098 | 2068 | ||
2099 | /* enable PCH transcoder */ | 2069 | /* enable PCH transcoder */ |
2100 | temp = I915_READ(transconf_reg); | 2070 | reg = TRANSCONF(pipe); |
2071 | temp = I915_READ(reg); | ||
2101 | /* | 2072 | /* |
2102 | * make the BPC in transcoder be consistent with | 2073 | * make the BPC in transcoder be consistent with |
2103 | * that in pipeconf reg. | 2074 | * that in pipeconf reg. |
2104 | */ | 2075 | */ |
2105 | temp &= ~PIPE_BPC_MASK; | 2076 | temp &= ~PIPE_BPC_MASK; |
2106 | temp |= pipe_bpc; | 2077 | temp |= I915_READ(PIPECONF(pipe)) & PIPE_BPC_MASK; |
2107 | I915_WRITE(transconf_reg, temp | TRANS_ENABLE); | 2078 | I915_WRITE(reg, temp | TRANS_ENABLE); |
2108 | I915_READ(transconf_reg); | 2079 | if (wait_for(I915_READ(reg) & TRANS_STATE_ENABLE, 100)) |
2109 | |||
2110 | if (wait_for(I915_READ(transconf_reg) & TRANS_STATE_ENABLE, 100)) | ||
2111 | DRM_ERROR("failed to enable transcoder\n"); | 2080 | DRM_ERROR("failed to enable transcoder\n"); |
2112 | 2081 | ||
2113 | intel_crtc_load_lut(crtc); | 2082 | intel_crtc_load_lut(crtc); |
@@ -2121,28 +2090,16 @@ static void ironlake_crtc_disable(struct drm_crtc *crtc) | |||
2121 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); | 2090 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); |
2122 | int pipe = intel_crtc->pipe; | 2091 | int pipe = intel_crtc->pipe; |
2123 | int plane = intel_crtc->plane; | 2092 | int plane = intel_crtc->plane; |
2124 | int pch_dpll_reg = (pipe == 0) ? PCH_DPLL_A : PCH_DPLL_B; | 2093 | u32 reg, temp; |
2125 | int pipeconf_reg = (pipe == 0) ? PIPEACONF : PIPEBCONF; | ||
2126 | int dspcntr_reg = (plane == 0) ? DSPACNTR : DSPBCNTR; | ||
2127 | int dspbase_reg = (plane == 0) ? DSPAADDR : DSPBADDR; | ||
2128 | int fdi_tx_reg = (pipe == 0) ? FDI_TXA_CTL : FDI_TXB_CTL; | ||
2129 | int fdi_rx_reg = (pipe == 0) ? FDI_RXA_CTL : FDI_RXB_CTL; | ||
2130 | int transconf_reg = (pipe == 0) ? TRANSACONF : TRANSBCONF; | ||
2131 | int trans_dpll_sel = (pipe == 0) ? 0 : 1; | ||
2132 | u32 temp; | ||
2133 | u32 pipe_bpc; | ||
2134 | |||
2135 | temp = I915_READ(pipeconf_reg); | ||
2136 | pipe_bpc = temp & PIPE_BPC_MASK; | ||
2137 | 2094 | ||
2138 | drm_vblank_off(dev, pipe); | 2095 | drm_vblank_off(dev, pipe); |
2096 | |||
2139 | /* Disable display plane */ | 2097 | /* Disable display plane */ |
2140 | temp = I915_READ(dspcntr_reg); | 2098 | reg = DSPCNTR(plane); |
2141 | if ((temp & DISPLAY_PLANE_ENABLE) != 0) { | 2099 | temp = I915_READ(reg); |
2142 | I915_WRITE(dspcntr_reg, temp & ~DISPLAY_PLANE_ENABLE); | 2100 | if (temp & DISPLAY_PLANE_ENABLE) { |
2143 | /* Flush the plane changes */ | 2101 | I915_WRITE(reg, temp & ~DISPLAY_PLANE_ENABLE); |
2144 | I915_WRITE(dspbase_reg, I915_READ(dspbase_reg)); | 2102 | intel_flush_display_plane(dev, plane); |
2145 | I915_READ(dspbase_reg); | ||
2146 | } | 2103 | } |
2147 | 2104 | ||
2148 | if (dev_priv->cfb_plane == plane && | 2105 | if (dev_priv->cfb_plane == plane && |
@@ -2150,42 +2107,43 @@ static void ironlake_crtc_disable(struct drm_crtc *crtc) | |||
2150 | dev_priv->display.disable_fbc(dev); | 2107 | dev_priv->display.disable_fbc(dev); |
2151 | 2108 | ||
2152 | /* disable cpu pipe, disable after all planes disabled */ | 2109 | /* disable cpu pipe, disable after all planes disabled */ |
2153 | temp = I915_READ(pipeconf_reg); | 2110 | reg = PIPECONF(pipe); |
2154 | if ((temp & PIPEACONF_ENABLE) != 0) { | 2111 | temp = I915_READ(reg); |
2155 | I915_WRITE(pipeconf_reg, temp & ~PIPEACONF_ENABLE); | 2112 | if (temp & PIPECONF_ENABLE) { |
2156 | 2113 | I915_WRITE(reg, temp & ~PIPECONF_ENABLE); | |
2157 | /* wait for cpu pipe off, pipe state */ | 2114 | /* wait for cpu pipe off, pipe state */ |
2158 | if (wait_for((I915_READ(pipeconf_reg) & I965_PIPECONF_ACTIVE) == 0, 50)) | 2115 | if (wait_for((I915_READ(reg) & I965_PIPECONF_ACTIVE) == 0, 50)) |
2159 | DRM_ERROR("failed to turn off cpu pipe\n"); | 2116 | DRM_ERROR("failed to turn off cpu pipe\n"); |
2160 | } else | 2117 | } |
2161 | DRM_DEBUG_KMS("crtc %d is disabled\n", pipe); | ||
2162 | 2118 | ||
2163 | /* Disable PF */ | 2119 | /* Disable PF */ |
2164 | I915_WRITE(pipe ? PFB_CTL_1 : PFA_CTL_1, 0); | 2120 | I915_WRITE(pipe ? PFB_CTL_1 : PFA_CTL_1, 0); |
2165 | I915_WRITE(pipe ? PFB_WIN_SZ : PFA_WIN_SZ, 0); | 2121 | I915_WRITE(pipe ? PFB_WIN_SZ : PFA_WIN_SZ, 0); |
2166 | 2122 | ||
2167 | /* disable CPU FDI tx and PCH FDI rx */ | 2123 | /* disable CPU FDI tx and PCH FDI rx */ |
2168 | temp = I915_READ(fdi_tx_reg); | 2124 | reg = FDI_TX_CTL(pipe); |
2169 | I915_WRITE(fdi_tx_reg, temp & ~FDI_TX_ENABLE); | 2125 | temp = I915_READ(reg); |
2170 | I915_READ(fdi_tx_reg); | 2126 | I915_WRITE(reg, temp & ~FDI_TX_ENABLE); |
2127 | POSTING_READ(reg); | ||
2171 | 2128 | ||
2172 | temp = I915_READ(fdi_rx_reg); | 2129 | reg = FDI_RX_CTL(pipe); |
2173 | /* BPC in FDI rx is consistent with that in pipeconf */ | 2130 | temp = I915_READ(reg); |
2174 | temp &= ~(0x07 << 16); | 2131 | temp &= ~(0x7 << 16); |
2175 | temp |= (pipe_bpc << 11); | 2132 | temp |= (I915_READ(PIPECONF(pipe)) & PIPE_BPC_MASK) << 11; |
2176 | I915_WRITE(fdi_rx_reg, temp & ~FDI_RX_ENABLE); | 2133 | I915_WRITE(reg, temp & ~FDI_RX_ENABLE); |
2177 | I915_READ(fdi_rx_reg); | ||
2178 | 2134 | ||
2135 | POSTING_READ(reg); | ||
2179 | udelay(100); | 2136 | udelay(100); |
2180 | 2137 | ||
2181 | /* still set train pattern 1 */ | 2138 | /* still set train pattern 1 */ |
2182 | temp = I915_READ(fdi_tx_reg); | 2139 | reg = FDI_TX_CTL(pipe); |
2140 | temp = I915_READ(reg); | ||
2183 | temp &= ~FDI_LINK_TRAIN_NONE; | 2141 | temp &= ~FDI_LINK_TRAIN_NONE; |
2184 | temp |= FDI_LINK_TRAIN_PATTERN_1; | 2142 | temp |= FDI_LINK_TRAIN_PATTERN_1; |
2185 | I915_WRITE(fdi_tx_reg, temp); | 2143 | I915_WRITE(reg, temp); |
2186 | POSTING_READ(fdi_tx_reg); | ||
2187 | 2144 | ||
2188 | temp = I915_READ(fdi_rx_reg); | 2145 | reg = FDI_RX_CTL(pipe); |
2146 | temp = I915_READ(reg); | ||
2189 | if (HAS_PCH_CPT(dev)) { | 2147 | if (HAS_PCH_CPT(dev)) { |
2190 | temp &= ~FDI_LINK_TRAIN_PATTERN_MASK_CPT; | 2148 | temp &= ~FDI_LINK_TRAIN_PATTERN_MASK_CPT; |
2191 | temp |= FDI_LINK_TRAIN_PATTERN_1_CPT; | 2149 | temp |= FDI_LINK_TRAIN_PATTERN_1_CPT; |
@@ -2193,80 +2151,73 @@ static void ironlake_crtc_disable(struct drm_crtc *crtc) | |||
2193 | temp &= ~FDI_LINK_TRAIN_NONE; | 2151 | temp &= ~FDI_LINK_TRAIN_NONE; |
2194 | temp |= FDI_LINK_TRAIN_PATTERN_1; | 2152 | temp |= FDI_LINK_TRAIN_PATTERN_1; |
2195 | } | 2153 | } |
2196 | I915_WRITE(fdi_rx_reg, temp); | 2154 | /* BPC in FDI rx is consistent with that in PIPECONF */ |
2197 | POSTING_READ(fdi_rx_reg); | 2155 | temp &= ~(0x07 << 16); |
2156 | temp |= (I915_READ(PIPECONF(pipe)) & PIPE_BPC_MASK) << 11; | ||
2157 | I915_WRITE(reg, temp); | ||
2198 | 2158 | ||
2159 | POSTING_READ(reg); | ||
2199 | udelay(100); | 2160 | udelay(100); |
2200 | 2161 | ||
2201 | if (intel_pipe_has_type(crtc, INTEL_OUTPUT_LVDS)) { | 2162 | if (intel_pipe_has_type(crtc, INTEL_OUTPUT_LVDS)) { |
2202 | temp = I915_READ(PCH_LVDS); | 2163 | temp = I915_READ(PCH_LVDS); |
2203 | I915_WRITE(PCH_LVDS, temp & ~LVDS_PORT_EN); | 2164 | if (temp & LVDS_PORT_EN) { |
2204 | I915_READ(PCH_LVDS); | 2165 | I915_WRITE(PCH_LVDS, temp & ~LVDS_PORT_EN); |
2205 | udelay(100); | 2166 | POSTING_READ(PCH_LVDS); |
2167 | udelay(100); | ||
2168 | } | ||
2206 | } | 2169 | } |
2207 | 2170 | ||
2208 | /* disable PCH transcoder */ | 2171 | /* disable PCH transcoder */ |
2209 | temp = I915_READ(transconf_reg); | 2172 | reg = TRANSCONF(plane); |
2210 | if ((temp & TRANS_ENABLE) != 0) { | 2173 | temp = I915_READ(reg); |
2211 | I915_WRITE(transconf_reg, temp & ~TRANS_ENABLE); | 2174 | if (temp & TRANS_ENABLE) { |
2212 | 2175 | I915_WRITE(reg, temp & ~TRANS_ENABLE); | |
2213 | /* wait for PCH transcoder off, transcoder state */ | 2176 | /* wait for PCH transcoder off, transcoder state */ |
2214 | if (wait_for((I915_READ(transconf_reg) & TRANS_STATE_ENABLE) == 0, 50)) | 2177 | if (wait_for((I915_READ(reg) & TRANS_STATE_ENABLE) == 0, 50)) |
2215 | DRM_ERROR("failed to disable transcoder\n"); | 2178 | DRM_ERROR("failed to disable transcoder\n"); |
2216 | } | 2179 | } |
2217 | 2180 | ||
2218 | temp = I915_READ(transconf_reg); | ||
2219 | /* BPC in transcoder is consistent with that in pipeconf */ | ||
2220 | temp &= ~PIPE_BPC_MASK; | ||
2221 | temp |= pipe_bpc; | ||
2222 | I915_WRITE(transconf_reg, temp); | ||
2223 | I915_READ(transconf_reg); | ||
2224 | udelay(100); | ||
2225 | |||
2226 | if (HAS_PCH_CPT(dev)) { | 2181 | if (HAS_PCH_CPT(dev)) { |
2227 | /* disable TRANS_DP_CTL */ | 2182 | /* disable TRANS_DP_CTL */ |
2228 | int trans_dp_ctl = (pipe == 0) ? TRANS_DP_CTL_A : TRANS_DP_CTL_B; | 2183 | reg = TRANS_DP_CTL(pipe); |
2229 | int reg; | 2184 | temp = I915_READ(reg); |
2230 | 2185 | temp &= ~(TRANS_DP_OUTPUT_ENABLE | TRANS_DP_PORT_SEL_MASK); | |
2231 | reg = I915_READ(trans_dp_ctl); | 2186 | I915_WRITE(reg, temp); |
2232 | reg &= ~(TRANS_DP_OUTPUT_ENABLE | TRANS_DP_PORT_SEL_MASK); | ||
2233 | I915_WRITE(trans_dp_ctl, reg); | ||
2234 | POSTING_READ(trans_dp_ctl); | ||
2235 | 2187 | ||
2236 | /* disable DPLL_SEL */ | 2188 | /* disable DPLL_SEL */ |
2237 | temp = I915_READ(PCH_DPLL_SEL); | 2189 | temp = I915_READ(PCH_DPLL_SEL); |
2238 | if (trans_dpll_sel == 0) | 2190 | if (pipe == 0) |
2239 | temp &= ~(TRANSA_DPLL_ENABLE | TRANSA_DPLLB_SEL); | 2191 | temp &= ~(TRANSA_DPLL_ENABLE | TRANSA_DPLLB_SEL); |
2240 | else | 2192 | else |
2241 | temp &= ~(TRANSB_DPLL_ENABLE | TRANSB_DPLLB_SEL); | 2193 | temp &= ~(TRANSB_DPLL_ENABLE | TRANSB_DPLLB_SEL); |
2242 | I915_WRITE(PCH_DPLL_SEL, temp); | 2194 | I915_WRITE(PCH_DPLL_SEL, temp); |
2243 | I915_READ(PCH_DPLL_SEL); | ||
2244 | |||
2245 | } | 2195 | } |
2246 | 2196 | ||
2247 | /* disable PCH DPLL */ | 2197 | /* disable PCH DPLL */ |
2248 | temp = I915_READ(pch_dpll_reg); | 2198 | reg = PCH_DPLL(pipe); |
2249 | I915_WRITE(pch_dpll_reg, temp & ~DPLL_VCO_ENABLE); | 2199 | temp = I915_READ(reg); |
2250 | I915_READ(pch_dpll_reg); | 2200 | I915_WRITE(reg, temp & ~DPLL_VCO_ENABLE); |
2251 | 2201 | ||
2252 | /* Switch from PCDclk to Rawclk */ | 2202 | /* Switch from PCDclk to Rawclk */ |
2253 | temp = I915_READ(fdi_rx_reg); | 2203 | reg = FDI_RX_CTL(pipe); |
2254 | temp &= ~FDI_SEL_PCDCLK; | 2204 | temp = I915_READ(reg); |
2255 | I915_WRITE(fdi_rx_reg, temp); | 2205 | I915_WRITE(reg, temp & ~FDI_PCDCLK); |
2256 | I915_READ(fdi_rx_reg); | ||
2257 | 2206 | ||
2258 | /* Disable CPU FDI TX PLL */ | 2207 | /* Disable CPU FDI TX PLL */ |
2259 | temp = I915_READ(fdi_tx_reg); | 2208 | reg = FDI_TX_CTL(pipe); |
2260 | I915_WRITE(fdi_tx_reg, temp & ~FDI_TX_PLL_ENABLE); | 2209 | temp = I915_READ(reg); |
2261 | I915_READ(fdi_tx_reg); | 2210 | I915_WRITE(reg, temp & ~FDI_TX_PLL_ENABLE); |
2211 | |||
2212 | POSTING_READ(reg); | ||
2262 | udelay(100); | 2213 | udelay(100); |
2263 | 2214 | ||
2264 | temp = I915_READ(fdi_rx_reg); | 2215 | reg = FDI_RX_CTL(pipe); |
2265 | temp &= ~FDI_RX_PLL_ENABLE; | 2216 | temp = I915_READ(reg); |
2266 | I915_WRITE(fdi_rx_reg, temp); | 2217 | I915_WRITE(reg, temp & ~FDI_RX_PLL_ENABLE); |
2267 | I915_READ(fdi_rx_reg); | ||
2268 | 2218 | ||
2269 | /* Wait for the clocks to turn off. */ | 2219 | /* Wait for the clocks to turn off. */ |
2220 | POSTING_READ(reg); | ||
2270 | udelay(100); | 2221 | udelay(100); |
2271 | } | 2222 | } |
2272 | 2223 | ||
@@ -2316,40 +2267,43 @@ static void i9xx_crtc_enable(struct drm_crtc *crtc) | |||
2316 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); | 2267 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); |
2317 | int pipe = intel_crtc->pipe; | 2268 | int pipe = intel_crtc->pipe; |
2318 | int plane = intel_crtc->plane; | 2269 | int plane = intel_crtc->plane; |
2319 | int dpll_reg = (pipe == 0) ? DPLL_A : DPLL_B; | 2270 | u32 reg, temp; |
2320 | int dspcntr_reg = (plane == 0) ? DSPACNTR : DSPBCNTR; | ||
2321 | int dspbase_reg = (plane == 0) ? DSPAADDR : DSPBADDR; | ||
2322 | int pipeconf_reg = (pipe == 0) ? PIPEACONF : PIPEBCONF; | ||
2323 | u32 temp; | ||
2324 | 2271 | ||
2325 | /* Enable the DPLL */ | 2272 | /* Enable the DPLL */ |
2326 | temp = I915_READ(dpll_reg); | 2273 | reg = DPLL(pipe); |
2274 | temp = I915_READ(reg); | ||
2327 | if ((temp & DPLL_VCO_ENABLE) == 0) { | 2275 | if ((temp & DPLL_VCO_ENABLE) == 0) { |
2328 | I915_WRITE(dpll_reg, temp); | 2276 | I915_WRITE(reg, temp); |
2329 | I915_READ(dpll_reg); | 2277 | |
2330 | /* Wait for the clocks to stabilize. */ | 2278 | /* Wait for the clocks to stabilize. */ |
2279 | POSTING_READ(reg); | ||
2331 | udelay(150); | 2280 | udelay(150); |
2332 | I915_WRITE(dpll_reg, temp | DPLL_VCO_ENABLE); | 2281 | |
2333 | I915_READ(dpll_reg); | 2282 | I915_WRITE(reg, temp | DPLL_VCO_ENABLE); |
2283 | |||
2334 | /* Wait for the clocks to stabilize. */ | 2284 | /* Wait for the clocks to stabilize. */ |
2285 | POSTING_READ(reg); | ||
2335 | udelay(150); | 2286 | udelay(150); |
2336 | I915_WRITE(dpll_reg, temp | DPLL_VCO_ENABLE); | 2287 | |
2337 | I915_READ(dpll_reg); | 2288 | I915_WRITE(reg, temp | DPLL_VCO_ENABLE); |
2289 | |||
2338 | /* Wait for the clocks to stabilize. */ | 2290 | /* Wait for the clocks to stabilize. */ |
2291 | POSTING_READ(reg); | ||
2339 | udelay(150); | 2292 | udelay(150); |
2340 | } | 2293 | } |
2341 | 2294 | ||
2342 | /* Enable the pipe */ | 2295 | /* Enable the pipe */ |
2343 | temp = I915_READ(pipeconf_reg); | 2296 | reg = PIPECONF(pipe); |
2344 | if ((temp & PIPEACONF_ENABLE) == 0) | 2297 | temp = I915_READ(reg); |
2345 | I915_WRITE(pipeconf_reg, temp | PIPEACONF_ENABLE); | 2298 | if ((temp & PIPECONF_ENABLE) == 0) |
2299 | I915_WRITE(reg, temp | PIPECONF_ENABLE); | ||
2346 | 2300 | ||
2347 | /* Enable the plane */ | 2301 | /* Enable the plane */ |
2348 | temp = I915_READ(dspcntr_reg); | 2302 | reg = DSPCNTR(plane); |
2303 | temp = I915_READ(reg); | ||
2349 | if ((temp & DISPLAY_PLANE_ENABLE) == 0) { | 2304 | if ((temp & DISPLAY_PLANE_ENABLE) == 0) { |
2350 | I915_WRITE(dspcntr_reg, temp | DISPLAY_PLANE_ENABLE); | 2305 | I915_WRITE(reg, temp | DISPLAY_PLANE_ENABLE); |
2351 | /* Flush the plane changes */ | 2306 | intel_flush_display_plane(dev, plane); |
2352 | I915_WRITE(dspbase_reg, I915_READ(dspbase_reg)); | ||
2353 | } | 2307 | } |
2354 | 2308 | ||
2355 | intel_crtc_load_lut(crtc); | 2309 | intel_crtc_load_lut(crtc); |
@@ -2366,11 +2320,7 @@ static void i9xx_crtc_disable(struct drm_crtc *crtc) | |||
2366 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); | 2320 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); |
2367 | int pipe = intel_crtc->pipe; | 2321 | int pipe = intel_crtc->pipe; |
2368 | int plane = intel_crtc->plane; | 2322 | int plane = intel_crtc->plane; |
2369 | int dpll_reg = (pipe == 0) ? DPLL_A : DPLL_B; | 2323 | u32 reg, temp; |
2370 | int dspcntr_reg = (plane == 0) ? DSPACNTR : DSPBCNTR; | ||
2371 | int dspbase_reg = (plane == 0) ? DSPAADDR : DSPBADDR; | ||
2372 | int pipeconf_reg = (pipe == 0) ? PIPEACONF : PIPEBCONF; | ||
2373 | u32 temp; | ||
2374 | 2324 | ||
2375 | /* Give the overlay scaler a chance to disable if it's on this pipe */ | 2325 | /* Give the overlay scaler a chance to disable if it's on this pipe */ |
2376 | intel_crtc_dpms_overlay(intel_crtc, false); | 2326 | intel_crtc_dpms_overlay(intel_crtc, false); |
@@ -2381,42 +2331,42 @@ static void i9xx_crtc_disable(struct drm_crtc *crtc) | |||
2381 | dev_priv->display.disable_fbc(dev); | 2331 | dev_priv->display.disable_fbc(dev); |
2382 | 2332 | ||
2383 | /* Disable display plane */ | 2333 | /* Disable display plane */ |
2384 | temp = I915_READ(dspcntr_reg); | 2334 | reg = DSPCNTR(plane); |
2385 | if ((temp & DISPLAY_PLANE_ENABLE) != 0) { | 2335 | temp = I915_READ(reg); |
2386 | I915_WRITE(dspcntr_reg, temp & ~DISPLAY_PLANE_ENABLE); | 2336 | if (temp & DISPLAY_PLANE_ENABLE) { |
2337 | I915_WRITE(reg, temp & ~DISPLAY_PLANE_ENABLE); | ||
2387 | /* Flush the plane changes */ | 2338 | /* Flush the plane changes */ |
2388 | I915_WRITE(dspbase_reg, I915_READ(dspbase_reg)); | 2339 | intel_flush_display_plane(dev, plane); |
2389 | I915_READ(dspbase_reg); | ||
2390 | } | ||
2391 | 2340 | ||
2392 | if (!IS_I9XX(dev)) { | ||
2393 | /* Wait for vblank for the disable to take effect */ | 2341 | /* Wait for vblank for the disable to take effect */ |
2394 | intel_wait_for_vblank_off(dev, pipe); | 2342 | if (!IS_I9XX(dev)) |
2343 | intel_wait_for_vblank_off(dev, pipe); | ||
2395 | } | 2344 | } |
2396 | 2345 | ||
2397 | /* Don't disable pipe A or pipe A PLLs if needed */ | 2346 | /* Don't disable pipe A or pipe A PLLs if needed */ |
2398 | if (pipeconf_reg == PIPEACONF && | 2347 | if (pipe == 0 && (dev_priv->quirks & QUIRK_PIPEA_FORCE)) |
2399 | (dev_priv->quirks & QUIRK_PIPEA_FORCE)) | 2348 | return; |
2400 | goto skip_pipe_off; | ||
2401 | 2349 | ||
2402 | /* Next, disable display pipes */ | 2350 | /* Next, disable display pipes */ |
2403 | temp = I915_READ(pipeconf_reg); | 2351 | reg = PIPECONF(pipe); |
2404 | if ((temp & PIPEACONF_ENABLE) != 0) { | 2352 | temp = I915_READ(reg); |
2405 | I915_WRITE(pipeconf_reg, temp & ~PIPEACONF_ENABLE); | 2353 | if (temp & PIPECONF_ENABLE) { |
2406 | I915_READ(pipeconf_reg); | 2354 | I915_WRITE(reg, temp & ~PIPECONF_ENABLE); |
2355 | |||
2356 | /* Wait for vblank for the disable to take effect. */ | ||
2357 | POSTING_READ(reg); | ||
2358 | intel_wait_for_vblank_off(dev, pipe); | ||
2407 | } | 2359 | } |
2408 | 2360 | ||
2409 | /* Wait for vblank for the disable to take effect. */ | 2361 | reg = DPLL(pipe); |
2410 | intel_wait_for_vblank_off(dev, pipe); | 2362 | temp = I915_READ(reg); |
2363 | if (temp & DPLL_VCO_ENABLE) { | ||
2364 | I915_WRITE(reg, temp & ~DPLL_VCO_ENABLE); | ||
2411 | 2365 | ||
2412 | temp = I915_READ(dpll_reg); | 2366 | /* Wait for the clocks to turn off. */ |
2413 | if ((temp & DPLL_VCO_ENABLE) != 0) { | 2367 | POSTING_READ(reg); |
2414 | I915_WRITE(dpll_reg, temp & ~DPLL_VCO_ENABLE); | 2368 | udelay(150); |
2415 | I915_READ(dpll_reg); | ||
2416 | } | 2369 | } |
2417 | skip_pipe_off: | ||
2418 | /* Wait for the clocks to turn off. */ | ||
2419 | udelay(150); | ||
2420 | } | 2370 | } |
2421 | 2371 | ||
2422 | static void i9xx_crtc_dpms(struct drm_crtc *crtc, int mode) | 2372 | static void i9xx_crtc_dpms(struct drm_crtc *crtc, int mode) |
@@ -3030,7 +2980,7 @@ static int i9xx_get_fifo_size(struct drm_device *dev, int plane) | |||
3030 | size = ((dsparb >> DSPARB_CSTART_SHIFT) & 0x7f) - size; | 2980 | size = ((dsparb >> DSPARB_CSTART_SHIFT) & 0x7f) - size; |
3031 | 2981 | ||
3032 | DRM_DEBUG_KMS("FIFO size - (0x%08x) %s: %d\n", dsparb, | 2982 | DRM_DEBUG_KMS("FIFO size - (0x%08x) %s: %d\n", dsparb, |
3033 | plane ? "B" : "A", size); | 2983 | plane ? "B" : "A", size); |
3034 | 2984 | ||
3035 | return size; | 2985 | return size; |
3036 | } | 2986 | } |
@@ -3047,7 +2997,7 @@ static int i85x_get_fifo_size(struct drm_device *dev, int plane) | |||
3047 | size >>= 1; /* Convert to cachelines */ | 2997 | size >>= 1; /* Convert to cachelines */ |
3048 | 2998 | ||
3049 | DRM_DEBUG_KMS("FIFO size - (0x%08x) %s: %d\n", dsparb, | 2999 | DRM_DEBUG_KMS("FIFO size - (0x%08x) %s: %d\n", dsparb, |
3050 | plane ? "B" : "A", size); | 3000 | plane ? "B" : "A", size); |
3051 | 3001 | ||
3052 | return size; | 3002 | return size; |
3053 | } | 3003 | } |
@@ -3062,8 +3012,8 @@ static int i845_get_fifo_size(struct drm_device *dev, int plane) | |||
3062 | size >>= 2; /* Convert to cachelines */ | 3012 | size >>= 2; /* Convert to cachelines */ |
3063 | 3013 | ||
3064 | DRM_DEBUG_KMS("FIFO size - (0x%08x) %s: %d\n", dsparb, | 3014 | DRM_DEBUG_KMS("FIFO size - (0x%08x) %s: %d\n", dsparb, |
3065 | plane ? "B" : "A", | 3015 | plane ? "B" : "A", |
3066 | size); | 3016 | size); |
3067 | 3017 | ||
3068 | return size; | 3018 | return size; |
3069 | } | 3019 | } |
@@ -3078,14 +3028,14 @@ static int i830_get_fifo_size(struct drm_device *dev, int plane) | |||
3078 | size >>= 1; /* Convert to cachelines */ | 3028 | size >>= 1; /* Convert to cachelines */ |
3079 | 3029 | ||
3080 | DRM_DEBUG_KMS("FIFO size - (0x%08x) %s: %d\n", dsparb, | 3030 | DRM_DEBUG_KMS("FIFO size - (0x%08x) %s: %d\n", dsparb, |
3081 | plane ? "B" : "A", size); | 3031 | plane ? "B" : "A", size); |
3082 | 3032 | ||
3083 | return size; | 3033 | return size; |
3084 | } | 3034 | } |
3085 | 3035 | ||
3086 | static void pineview_update_wm(struct drm_device *dev, int planea_clock, | 3036 | static void pineview_update_wm(struct drm_device *dev, int planea_clock, |
3087 | int planeb_clock, int sr_hdisplay, int unused, | 3037 | int planeb_clock, int sr_hdisplay, int unused, |
3088 | int pixel_size) | 3038 | int pixel_size) |
3089 | { | 3039 | { |
3090 | struct drm_i915_private *dev_priv = dev->dev_private; | 3040 | struct drm_i915_private *dev_priv = dev->dev_private; |
3091 | const struct cxsr_latency *latency; | 3041 | const struct cxsr_latency *latency; |
@@ -3197,13 +3147,13 @@ static void g4x_update_wm(struct drm_device *dev, int planea_clock, | |||
3197 | 3147 | ||
3198 | /* Use ns/us then divide to preserve precision */ | 3148 | /* Use ns/us then divide to preserve precision */ |
3199 | sr_entries = (((sr_latency_ns / line_time_us) + 1000) / 1000) * | 3149 | sr_entries = (((sr_latency_ns / line_time_us) + 1000) / 1000) * |
3200 | pixel_size * sr_hdisplay; | 3150 | pixel_size * sr_hdisplay; |
3201 | sr_entries = DIV_ROUND_UP(sr_entries, cacheline_size); | 3151 | sr_entries = DIV_ROUND_UP(sr_entries, cacheline_size); |
3202 | 3152 | ||
3203 | entries_required = (((sr_latency_ns / line_time_us) + | 3153 | entries_required = (((sr_latency_ns / line_time_us) + |
3204 | 1000) / 1000) * pixel_size * 64; | 3154 | 1000) / 1000) * pixel_size * 64; |
3205 | entries_required = DIV_ROUND_UP(entries_required, | 3155 | entries_required = DIV_ROUND_UP(entries_required, |
3206 | g4x_cursor_wm_info.cacheline_size); | 3156 | g4x_cursor_wm_info.cacheline_size); |
3207 | cursor_sr = entries_required + g4x_cursor_wm_info.guard_size; | 3157 | cursor_sr = entries_required + g4x_cursor_wm_info.guard_size; |
3208 | 3158 | ||
3209 | if (cursor_sr > g4x_cursor_wm_info.max_wm) | 3159 | if (cursor_sr > g4x_cursor_wm_info.max_wm) |
@@ -3215,7 +3165,7 @@ static void g4x_update_wm(struct drm_device *dev, int planea_clock, | |||
3215 | } else { | 3165 | } else { |
3216 | /* Turn off self refresh if both pipes are enabled */ | 3166 | /* Turn off self refresh if both pipes are enabled */ |
3217 | I915_WRITE(FW_BLC_SELF, I915_READ(FW_BLC_SELF) | 3167 | I915_WRITE(FW_BLC_SELF, I915_READ(FW_BLC_SELF) |
3218 | & ~FW_BLC_SELF_EN); | 3168 | & ~FW_BLC_SELF_EN); |
3219 | } | 3169 | } |
3220 | 3170 | ||
3221 | DRM_DEBUG("Setting FIFO watermarks - A: %d, B: %d, SR %d\n", | 3171 | DRM_DEBUG("Setting FIFO watermarks - A: %d, B: %d, SR %d\n", |
@@ -3253,7 +3203,7 @@ static void i965_update_wm(struct drm_device *dev, int planea_clock, | |||
3253 | 3203 | ||
3254 | /* Use ns/us then divide to preserve precision */ | 3204 | /* Use ns/us then divide to preserve precision */ |
3255 | sr_entries = (((sr_latency_ns / line_time_us) + 1000) / 1000) * | 3205 | sr_entries = (((sr_latency_ns / line_time_us) + 1000) / 1000) * |
3256 | pixel_size * sr_hdisplay; | 3206 | pixel_size * sr_hdisplay; |
3257 | sr_entries = DIV_ROUND_UP(sr_entries, I915_FIFO_LINE_SIZE); | 3207 | sr_entries = DIV_ROUND_UP(sr_entries, I915_FIFO_LINE_SIZE); |
3258 | DRM_DEBUG("self-refresh entries: %d\n", sr_entries); | 3208 | DRM_DEBUG("self-refresh entries: %d\n", sr_entries); |
3259 | srwm = I965_FIFO_SIZE - sr_entries; | 3209 | srwm = I965_FIFO_SIZE - sr_entries; |
@@ -3262,11 +3212,11 @@ static void i965_update_wm(struct drm_device *dev, int planea_clock, | |||
3262 | srwm &= 0x1ff; | 3212 | srwm &= 0x1ff; |
3263 | 3213 | ||
3264 | sr_entries = (((sr_latency_ns / line_time_us) + 1000) / 1000) * | 3214 | sr_entries = (((sr_latency_ns / line_time_us) + 1000) / 1000) * |
3265 | pixel_size * 64; | 3215 | pixel_size * 64; |
3266 | sr_entries = DIV_ROUND_UP(sr_entries, | 3216 | sr_entries = DIV_ROUND_UP(sr_entries, |
3267 | i965_cursor_wm_info.cacheline_size); | 3217 | i965_cursor_wm_info.cacheline_size); |
3268 | cursor_sr = i965_cursor_wm_info.fifo_size - | 3218 | cursor_sr = i965_cursor_wm_info.fifo_size - |
3269 | (sr_entries + i965_cursor_wm_info.guard_size); | 3219 | (sr_entries + i965_cursor_wm_info.guard_size); |
3270 | 3220 | ||
3271 | if (cursor_sr > i965_cursor_wm_info.max_wm) | 3221 | if (cursor_sr > i965_cursor_wm_info.max_wm) |
3272 | cursor_sr = i965_cursor_wm_info.max_wm; | 3222 | cursor_sr = i965_cursor_wm_info.max_wm; |
@@ -3345,7 +3295,7 @@ static void i9xx_update_wm(struct drm_device *dev, int planea_clock, | |||
3345 | 3295 | ||
3346 | /* Use ns/us then divide to preserve precision */ | 3296 | /* Use ns/us then divide to preserve precision */ |
3347 | sr_entries = (((sr_latency_ns / line_time_us) + 1000) / 1000) * | 3297 | sr_entries = (((sr_latency_ns / line_time_us) + 1000) / 1000) * |
3348 | pixel_size * sr_hdisplay; | 3298 | pixel_size * sr_hdisplay; |
3349 | sr_entries = DIV_ROUND_UP(sr_entries, cacheline_size); | 3299 | sr_entries = DIV_ROUND_UP(sr_entries, cacheline_size); |
3350 | DRM_DEBUG_KMS("self-refresh entries: %d\n", sr_entries); | 3300 | DRM_DEBUG_KMS("self-refresh entries: %d\n", sr_entries); |
3351 | srwm = total_size - sr_entries; | 3301 | srwm = total_size - sr_entries; |
@@ -3370,7 +3320,7 @@ static void i9xx_update_wm(struct drm_device *dev, int planea_clock, | |||
3370 | } | 3320 | } |
3371 | 3321 | ||
3372 | DRM_DEBUG_KMS("Setting FIFO watermarks - A: %d, B: %d, C: %d, SR %d\n", | 3322 | DRM_DEBUG_KMS("Setting FIFO watermarks - A: %d, B: %d, C: %d, SR %d\n", |
3373 | planea_wm, planeb_wm, cwm, srwm); | 3323 | planea_wm, planeb_wm, cwm, srwm); |
3374 | 3324 | ||
3375 | fwater_lo = ((planeb_wm & 0x3f) << 16) | (planea_wm & 0x3f); | 3325 | fwater_lo = ((planeb_wm & 0x3f) << 16) | (planea_wm & 0x3f); |
3376 | fwater_hi = (cwm & 0x1f); | 3326 | fwater_hi = (cwm & 0x1f); |
@@ -3489,7 +3439,7 @@ static void ironlake_update_wm(struct drm_device *dev, | |||
3489 | 3439 | ||
3490 | /* Use ns/us then divide to preserve precision */ | 3440 | /* Use ns/us then divide to preserve precision */ |
3491 | line_count = ((ilk_sr_latency * 500) / line_time_us + 1000) | 3441 | line_count = ((ilk_sr_latency * 500) / line_time_us + 1000) |
3492 | / 1000; | 3442 | / 1000; |
3493 | line_size = sr_hdisplay * pixel_size; | 3443 | line_size = sr_hdisplay * pixel_size; |
3494 | 3444 | ||
3495 | /* Use the minimum of the small and large buffer method for primary */ | 3445 | /* Use the minimum of the small and large buffer method for primary */ |
@@ -3559,7 +3509,7 @@ static void ironlake_update_wm(struct drm_device *dev, | |||
3559 | * | 3509 | * |
3560 | * We don't use the sprite, so we can ignore that. And on Crestline we have | 3510 | * We don't use the sprite, so we can ignore that. And on Crestline we have |
3561 | * to set the non-SR watermarks to 8. | 3511 | * to set the non-SR watermarks to 8. |
3562 | */ | 3512 | */ |
3563 | static void intel_update_watermarks(struct drm_device *dev) | 3513 | static void intel_update_watermarks(struct drm_device *dev) |
3564 | { | 3514 | { |
3565 | struct drm_i915_private *dev_priv = dev->dev_private; | 3515 | struct drm_i915_private *dev_priv = dev->dev_private; |
@@ -3579,11 +3529,11 @@ static void intel_update_watermarks(struct drm_device *dev) | |||
3579 | enabled++; | 3529 | enabled++; |
3580 | if (intel_crtc->plane == 0) { | 3530 | if (intel_crtc->plane == 0) { |
3581 | DRM_DEBUG_KMS("plane A (pipe %d) clock: %d\n", | 3531 | DRM_DEBUG_KMS("plane A (pipe %d) clock: %d\n", |
3582 | intel_crtc->pipe, crtc->mode.clock); | 3532 | intel_crtc->pipe, crtc->mode.clock); |
3583 | planea_clock = crtc->mode.clock; | 3533 | planea_clock = crtc->mode.clock; |
3584 | } else { | 3534 | } else { |
3585 | DRM_DEBUG_KMS("plane B (pipe %d) clock: %d\n", | 3535 | DRM_DEBUG_KMS("plane B (pipe %d) clock: %d\n", |
3586 | intel_crtc->pipe, crtc->mode.clock); | 3536 | intel_crtc->pipe, crtc->mode.clock); |
3587 | planeb_clock = crtc->mode.clock; | 3537 | planeb_clock = crtc->mode.clock; |
3588 | } | 3538 | } |
3589 | sr_hdisplay = crtc->mode.hdisplay; | 3539 | sr_hdisplay = crtc->mode.hdisplay; |
@@ -3614,61 +3564,35 @@ static int intel_crtc_mode_set(struct drm_crtc *crtc, | |||
3614 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); | 3564 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); |
3615 | int pipe = intel_crtc->pipe; | 3565 | int pipe = intel_crtc->pipe; |
3616 | int plane = intel_crtc->plane; | 3566 | int plane = intel_crtc->plane; |
3617 | int fp_reg = (pipe == 0) ? FPA0 : FPB0; | 3567 | u32 fp_reg, dpll_reg; |
3618 | int dpll_reg = (pipe == 0) ? DPLL_A : DPLL_B; | ||
3619 | int dpll_md_reg = (intel_crtc->pipe == 0) ? DPLL_A_MD : DPLL_B_MD; | ||
3620 | int dspcntr_reg = (plane == 0) ? DSPACNTR : DSPBCNTR; | ||
3621 | int pipeconf_reg = (pipe == 0) ? PIPEACONF : PIPEBCONF; | ||
3622 | int htot_reg = (pipe == 0) ? HTOTAL_A : HTOTAL_B; | ||
3623 | int hblank_reg = (pipe == 0) ? HBLANK_A : HBLANK_B; | ||
3624 | int hsync_reg = (pipe == 0) ? HSYNC_A : HSYNC_B; | ||
3625 | int vtot_reg = (pipe == 0) ? VTOTAL_A : VTOTAL_B; | ||
3626 | int vblank_reg = (pipe == 0) ? VBLANK_A : VBLANK_B; | ||
3627 | int vsync_reg = (pipe == 0) ? VSYNC_A : VSYNC_B; | ||
3628 | int dspsize_reg = (plane == 0) ? DSPASIZE : DSPBSIZE; | ||
3629 | int dsppos_reg = (plane == 0) ? DSPAPOS : DSPBPOS; | ||
3630 | int pipesrc_reg = (pipe == 0) ? PIPEASRC : PIPEBSRC; | ||
3631 | int refclk, num_connectors = 0; | 3568 | int refclk, num_connectors = 0; |
3632 | intel_clock_t clock, reduced_clock; | 3569 | intel_clock_t clock, reduced_clock; |
3633 | u32 dpll = 0, fp = 0, fp2 = 0, dspcntr, pipeconf; | 3570 | u32 dpll, fp = 0, fp2 = 0, dspcntr, pipeconf; |
3634 | bool ok, has_reduced_clock = false, is_sdvo = false, is_dvo = false; | 3571 | bool ok, has_reduced_clock = false, is_sdvo = false, is_dvo = false; |
3635 | bool is_crt = false, is_lvds = false, is_tv = false, is_dp = false; | 3572 | bool is_crt = false, is_lvds = false, is_tv = false, is_dp = false; |
3636 | struct intel_encoder *has_edp_encoder = NULL; | 3573 | struct intel_encoder *has_edp_encoder = NULL; |
3637 | struct drm_mode_config *mode_config = &dev->mode_config; | 3574 | struct drm_mode_config *mode_config = &dev->mode_config; |
3638 | struct drm_encoder *encoder; | 3575 | struct intel_encoder *encoder; |
3639 | const intel_limit_t *limit; | 3576 | const intel_limit_t *limit; |
3640 | int ret; | 3577 | int ret; |
3641 | struct fdi_m_n m_n = {0}; | 3578 | struct fdi_m_n m_n = {0}; |
3642 | int data_m1_reg = (pipe == 0) ? PIPEA_DATA_M1 : PIPEB_DATA_M1; | 3579 | u32 reg, temp; |
3643 | int data_n1_reg = (pipe == 0) ? PIPEA_DATA_N1 : PIPEB_DATA_N1; | ||
3644 | int link_m1_reg = (pipe == 0) ? PIPEA_LINK_M1 : PIPEB_LINK_M1; | ||
3645 | int link_n1_reg = (pipe == 0) ? PIPEA_LINK_N1 : PIPEB_LINK_N1; | ||
3646 | int pch_fp_reg = (pipe == 0) ? PCH_FPA0 : PCH_FPB0; | ||
3647 | int pch_dpll_reg = (pipe == 0) ? PCH_DPLL_A : PCH_DPLL_B; | ||
3648 | int fdi_rx_reg = (pipe == 0) ? FDI_RXA_CTL : FDI_RXB_CTL; | ||
3649 | int fdi_tx_reg = (pipe == 0) ? FDI_TXA_CTL : FDI_TXB_CTL; | ||
3650 | int trans_dpll_sel = (pipe == 0) ? 0 : 1; | ||
3651 | int lvds_reg = LVDS; | ||
3652 | u32 temp; | ||
3653 | int target_clock; | 3580 | int target_clock; |
3654 | 3581 | ||
3655 | drm_vblank_pre_modeset(dev, pipe); | 3582 | drm_vblank_pre_modeset(dev, pipe); |
3656 | 3583 | ||
3657 | list_for_each_entry(encoder, &mode_config->encoder_list, head) { | 3584 | list_for_each_entry(encoder, &mode_config->encoder_list, base.head) { |
3658 | struct intel_encoder *intel_encoder; | 3585 | if (encoder->base.crtc != crtc) |
3659 | |||
3660 | if (encoder->crtc != crtc) | ||
3661 | continue; | 3586 | continue; |
3662 | 3587 | ||
3663 | intel_encoder = to_intel_encoder(encoder); | 3588 | switch (encoder->type) { |
3664 | switch (intel_encoder->type) { | ||
3665 | case INTEL_OUTPUT_LVDS: | 3589 | case INTEL_OUTPUT_LVDS: |
3666 | is_lvds = true; | 3590 | is_lvds = true; |
3667 | break; | 3591 | break; |
3668 | case INTEL_OUTPUT_SDVO: | 3592 | case INTEL_OUTPUT_SDVO: |
3669 | case INTEL_OUTPUT_HDMI: | 3593 | case INTEL_OUTPUT_HDMI: |
3670 | is_sdvo = true; | 3594 | is_sdvo = true; |
3671 | if (intel_encoder->needs_tv_clock) | 3595 | if (encoder->needs_tv_clock) |
3672 | is_tv = true; | 3596 | is_tv = true; |
3673 | break; | 3597 | break; |
3674 | case INTEL_OUTPUT_DVO: | 3598 | case INTEL_OUTPUT_DVO: |
@@ -3684,7 +3608,7 @@ static int intel_crtc_mode_set(struct drm_crtc *crtc, | |||
3684 | is_dp = true; | 3608 | is_dp = true; |
3685 | break; | 3609 | break; |
3686 | case INTEL_OUTPUT_EDP: | 3610 | case INTEL_OUTPUT_EDP: |
3687 | has_edp_encoder = intel_encoder; | 3611 | has_edp_encoder = encoder; |
3688 | break; | 3612 | break; |
3689 | } | 3613 | } |
3690 | 3614 | ||
@@ -3694,7 +3618,7 @@ static int intel_crtc_mode_set(struct drm_crtc *crtc, | |||
3694 | if (is_lvds && dev_priv->lvds_use_ssc && num_connectors < 2) { | 3618 | if (is_lvds && dev_priv->lvds_use_ssc && num_connectors < 2) { |
3695 | refclk = dev_priv->lvds_ssc_freq * 1000; | 3619 | refclk = dev_priv->lvds_ssc_freq * 1000; |
3696 | DRM_DEBUG_KMS("using SSC reference clock of %d MHz\n", | 3620 | DRM_DEBUG_KMS("using SSC reference clock of %d MHz\n", |
3697 | refclk / 1000); | 3621 | refclk / 1000); |
3698 | } else if (IS_I9XX(dev)) { | 3622 | } else if (IS_I9XX(dev)) { |
3699 | refclk = 96000; | 3623 | refclk = 96000; |
3700 | if (HAS_PCH_SPLIT(dev)) | 3624 | if (HAS_PCH_SPLIT(dev)) |
@@ -3702,7 +3626,6 @@ static int intel_crtc_mode_set(struct drm_crtc *crtc, | |||
3702 | } else { | 3626 | } else { |
3703 | refclk = 48000; | 3627 | refclk = 48000; |
3704 | } | 3628 | } |
3705 | |||
3706 | 3629 | ||
3707 | /* | 3630 | /* |
3708 | * Returns a set of divisors for the desired target clock with the given | 3631 | * Returns a set of divisors for the desired target clock with the given |
@@ -3722,9 +3645,9 @@ static int intel_crtc_mode_set(struct drm_crtc *crtc, | |||
3722 | 3645 | ||
3723 | if (is_lvds && dev_priv->lvds_downclock_avail) { | 3646 | if (is_lvds && dev_priv->lvds_downclock_avail) { |
3724 | has_reduced_clock = limit->find_pll(limit, crtc, | 3647 | has_reduced_clock = limit->find_pll(limit, crtc, |
3725 | dev_priv->lvds_downclock, | 3648 | dev_priv->lvds_downclock, |
3726 | refclk, | 3649 | refclk, |
3727 | &reduced_clock); | 3650 | &reduced_clock); |
3728 | if (has_reduced_clock && (clock.p != reduced_clock.p)) { | 3651 | if (has_reduced_clock && (clock.p != reduced_clock.p)) { |
3729 | /* | 3652 | /* |
3730 | * If the different P is found, it means that we can't | 3653 | * If the different P is found, it means that we can't |
@@ -3733,7 +3656,7 @@ static int intel_crtc_mode_set(struct drm_crtc *crtc, | |||
3733 | * feature. | 3656 | * feature. |
3734 | */ | 3657 | */ |
3735 | DRM_DEBUG_KMS("Different P is found for " | 3658 | DRM_DEBUG_KMS("Different P is found for " |
3736 | "LVDS clock/downclock\n"); | 3659 | "LVDS clock/downclock\n"); |
3737 | has_reduced_clock = 0; | 3660 | has_reduced_clock = 0; |
3738 | } | 3661 | } |
3739 | } | 3662 | } |
@@ -3741,14 +3664,14 @@ static int intel_crtc_mode_set(struct drm_crtc *crtc, | |||
3741 | this mirrors vbios setting. */ | 3664 | this mirrors vbios setting. */ |
3742 | if (is_sdvo && is_tv) { | 3665 | if (is_sdvo && is_tv) { |
3743 | if (adjusted_mode->clock >= 100000 | 3666 | if (adjusted_mode->clock >= 100000 |
3744 | && adjusted_mode->clock < 140500) { | 3667 | && adjusted_mode->clock < 140500) { |
3745 | clock.p1 = 2; | 3668 | clock.p1 = 2; |
3746 | clock.p2 = 10; | 3669 | clock.p2 = 10; |
3747 | clock.n = 3; | 3670 | clock.n = 3; |
3748 | clock.m1 = 16; | 3671 | clock.m1 = 16; |
3749 | clock.m2 = 8; | 3672 | clock.m2 = 8; |
3750 | } else if (adjusted_mode->clock >= 140500 | 3673 | } else if (adjusted_mode->clock >= 140500 |
3751 | && adjusted_mode->clock <= 200000) { | 3674 | && adjusted_mode->clock <= 200000) { |
3752 | clock.p1 = 1; | 3675 | clock.p1 = 1; |
3753 | clock.p2 = 10; | 3676 | clock.p2 = 10; |
3754 | clock.n = 6; | 3677 | clock.n = 6; |
@@ -3785,12 +3708,11 @@ static int intel_crtc_mode_set(struct drm_crtc *crtc, | |||
3785 | } | 3708 | } |
3786 | 3709 | ||
3787 | /* determine panel color depth */ | 3710 | /* determine panel color depth */ |
3788 | temp = I915_READ(pipeconf_reg); | 3711 | temp = I915_READ(PIPECONF(pipe)); |
3789 | temp &= ~PIPE_BPC_MASK; | 3712 | temp &= ~PIPE_BPC_MASK; |
3790 | if (is_lvds) { | 3713 | if (is_lvds) { |
3791 | int lvds_reg = I915_READ(PCH_LVDS); | ||
3792 | /* the BPC will be 6 if it is 18-bit LVDS panel */ | 3714 | /* the BPC will be 6 if it is 18-bit LVDS panel */ |
3793 | if ((lvds_reg & LVDS_A3_POWER_MASK) == LVDS_A3_POWER_UP) | 3715 | if ((I915_READ(PCH_LVDS) & LVDS_A3_POWER_MASK) == LVDS_A3_POWER_UP) |
3794 | temp |= PIPE_8BPC; | 3716 | temp |= PIPE_8BPC; |
3795 | else | 3717 | else |
3796 | temp |= PIPE_6BPC; | 3718 | temp |= PIPE_6BPC; |
@@ -3811,8 +3733,7 @@ static int intel_crtc_mode_set(struct drm_crtc *crtc, | |||
3811 | } | 3733 | } |
3812 | } else | 3734 | } else |
3813 | temp |= PIPE_8BPC; | 3735 | temp |= PIPE_8BPC; |
3814 | I915_WRITE(pipeconf_reg, temp); | 3736 | I915_WRITE(PIPECONF(pipe), temp); |
3815 | I915_READ(pipeconf_reg); | ||
3816 | 3737 | ||
3817 | switch (temp & PIPE_BPC_MASK) { | 3738 | switch (temp & PIPE_BPC_MASK) { |
3818 | case PIPE_8BPC: | 3739 | case PIPE_8BPC: |
@@ -3857,33 +3778,27 @@ static int intel_crtc_mode_set(struct drm_crtc *crtc, | |||
3857 | /* Always enable nonspread source */ | 3778 | /* Always enable nonspread source */ |
3858 | temp &= ~DREF_NONSPREAD_SOURCE_MASK; | 3779 | temp &= ~DREF_NONSPREAD_SOURCE_MASK; |
3859 | temp |= DREF_NONSPREAD_SOURCE_ENABLE; | 3780 | temp |= DREF_NONSPREAD_SOURCE_ENABLE; |
3860 | I915_WRITE(PCH_DREF_CONTROL, temp); | ||
3861 | POSTING_READ(PCH_DREF_CONTROL); | ||
3862 | |||
3863 | temp &= ~DREF_SSC_SOURCE_MASK; | 3781 | temp &= ~DREF_SSC_SOURCE_MASK; |
3864 | temp |= DREF_SSC_SOURCE_ENABLE; | 3782 | temp |= DREF_SSC_SOURCE_ENABLE; |
3865 | I915_WRITE(PCH_DREF_CONTROL, temp); | 3783 | I915_WRITE(PCH_DREF_CONTROL, temp); |
3866 | POSTING_READ(PCH_DREF_CONTROL); | ||
3867 | 3784 | ||
3785 | POSTING_READ(PCH_DREF_CONTROL); | ||
3868 | udelay(200); | 3786 | udelay(200); |
3869 | 3787 | ||
3870 | if (has_edp_encoder) { | 3788 | if (has_edp_encoder) { |
3871 | if (dev_priv->lvds_use_ssc) { | 3789 | if (dev_priv->lvds_use_ssc) { |
3872 | temp |= DREF_SSC1_ENABLE; | 3790 | temp |= DREF_SSC1_ENABLE; |
3873 | I915_WRITE(PCH_DREF_CONTROL, temp); | 3791 | I915_WRITE(PCH_DREF_CONTROL, temp); |
3874 | POSTING_READ(PCH_DREF_CONTROL); | ||
3875 | 3792 | ||
3793 | POSTING_READ(PCH_DREF_CONTROL); | ||
3876 | udelay(200); | 3794 | udelay(200); |
3877 | 3795 | ||
3878 | temp &= ~DREF_CPU_SOURCE_OUTPUT_MASK; | 3796 | temp &= ~DREF_CPU_SOURCE_OUTPUT_MASK; |
3879 | temp |= DREF_CPU_SOURCE_OUTPUT_DOWNSPREAD; | 3797 | temp |= DREF_CPU_SOURCE_OUTPUT_DOWNSPREAD; |
3880 | I915_WRITE(PCH_DREF_CONTROL, temp); | ||
3881 | POSTING_READ(PCH_DREF_CONTROL); | ||
3882 | } else { | 3798 | } else { |
3883 | temp |= DREF_CPU_SOURCE_OUTPUT_NONSPREAD; | 3799 | temp |= DREF_CPU_SOURCE_OUTPUT_NONSPREAD; |
3884 | I915_WRITE(PCH_DREF_CONTROL, temp); | ||
3885 | POSTING_READ(PCH_DREF_CONTROL); | ||
3886 | } | 3800 | } |
3801 | I915_WRITE(PCH_DREF_CONTROL, temp); | ||
3887 | } | 3802 | } |
3888 | } | 3803 | } |
3889 | 3804 | ||
@@ -3899,6 +3814,7 @@ static int intel_crtc_mode_set(struct drm_crtc *crtc, | |||
3899 | reduced_clock.m2; | 3814 | reduced_clock.m2; |
3900 | } | 3815 | } |
3901 | 3816 | ||
3817 | dpll = 0; | ||
3902 | if (!HAS_PCH_SPLIT(dev)) | 3818 | if (!HAS_PCH_SPLIT(dev)) |
3903 | dpll = DPLL_VGA_MODE_DIS; | 3819 | dpll = DPLL_VGA_MODE_DIS; |
3904 | 3820 | ||
@@ -3972,7 +3888,7 @@ static int intel_crtc_mode_set(struct drm_crtc *crtc, | |||
3972 | dpll |= PLL_REF_INPUT_DREFCLK; | 3888 | dpll |= PLL_REF_INPUT_DREFCLK; |
3973 | 3889 | ||
3974 | /* setup pipeconf */ | 3890 | /* setup pipeconf */ |
3975 | pipeconf = I915_READ(pipeconf_reg); | 3891 | pipeconf = I915_READ(PIPECONF(pipe)); |
3976 | 3892 | ||
3977 | /* Set up the display plane register */ | 3893 | /* Set up the display plane register */ |
3978 | dspcntr = DISPPLANE_GAMMA_ENABLE; | 3894 | dspcntr = DISPPLANE_GAMMA_ENABLE; |
@@ -3995,16 +3911,15 @@ static int intel_crtc_mode_set(struct drm_crtc *crtc, | |||
3995 | */ | 3911 | */ |
3996 | if (mode->clock > | 3912 | if (mode->clock > |
3997 | dev_priv->display.get_display_clock_speed(dev) * 9 / 10) | 3913 | dev_priv->display.get_display_clock_speed(dev) * 9 / 10) |
3998 | pipeconf |= PIPEACONF_DOUBLE_WIDE; | 3914 | pipeconf |= PIPECONF_DOUBLE_WIDE; |
3999 | else | 3915 | else |
4000 | pipeconf &= ~PIPEACONF_DOUBLE_WIDE; | 3916 | pipeconf &= ~PIPECONF_DOUBLE_WIDE; |
4001 | } | 3917 | } |
4002 | 3918 | ||
4003 | dspcntr |= DISPLAY_PLANE_ENABLE; | 3919 | dspcntr |= DISPLAY_PLANE_ENABLE; |
4004 | pipeconf |= PIPEACONF_ENABLE; | 3920 | pipeconf |= PIPECONF_ENABLE; |
4005 | dpll |= DPLL_VCO_ENABLE; | 3921 | dpll |= DPLL_VCO_ENABLE; |
4006 | 3922 | ||
4007 | |||
4008 | /* Disable the panel fitter if it was on our pipe */ | 3923 | /* Disable the panel fitter if it was on our pipe */ |
4009 | if (!HAS_PCH_SPLIT(dev) && intel_panel_fitter_pipe(dev) == pipe) | 3924 | if (!HAS_PCH_SPLIT(dev) && intel_panel_fitter_pipe(dev) == pipe) |
4010 | I915_WRITE(PFIT_CONTROL, 0); | 3925 | I915_WRITE(PFIT_CONTROL, 0); |
@@ -4014,26 +3929,31 @@ static int intel_crtc_mode_set(struct drm_crtc *crtc, | |||
4014 | 3929 | ||
4015 | /* assign to Ironlake registers */ | 3930 | /* assign to Ironlake registers */ |
4016 | if (HAS_PCH_SPLIT(dev)) { | 3931 | if (HAS_PCH_SPLIT(dev)) { |
4017 | fp_reg = pch_fp_reg; | 3932 | fp_reg = PCH_FP0(pipe); |
4018 | dpll_reg = pch_dpll_reg; | 3933 | dpll_reg = PCH_DPLL(pipe); |
3934 | } else { | ||
3935 | fp_reg = FP0(pipe); | ||
3936 | dpll_reg = DPLL(pipe); | ||
4019 | } | 3937 | } |
4020 | 3938 | ||
4021 | if (!has_edp_encoder) { | 3939 | if (!has_edp_encoder) { |
4022 | I915_WRITE(fp_reg, fp); | 3940 | I915_WRITE(fp_reg, fp); |
4023 | I915_WRITE(dpll_reg, dpll & ~DPLL_VCO_ENABLE); | 3941 | I915_WRITE(dpll_reg, dpll & ~DPLL_VCO_ENABLE); |
4024 | I915_READ(dpll_reg); | 3942 | |
3943 | POSTING_READ(dpll_reg); | ||
4025 | udelay(150); | 3944 | udelay(150); |
4026 | } | 3945 | } |
4027 | 3946 | ||
4028 | /* enable transcoder DPLL */ | 3947 | /* enable transcoder DPLL */ |
4029 | if (HAS_PCH_CPT(dev)) { | 3948 | if (HAS_PCH_CPT(dev)) { |
4030 | temp = I915_READ(PCH_DPLL_SEL); | 3949 | temp = I915_READ(PCH_DPLL_SEL); |
4031 | if (trans_dpll_sel == 0) | 3950 | if (pipe == 0) |
4032 | temp |= (TRANSA_DPLL_ENABLE | TRANSA_DPLLA_SEL); | 3951 | temp |= TRANSA_DPLL_ENABLE | TRANSA_DPLLA_SEL; |
4033 | else | 3952 | else |
4034 | temp |= (TRANSB_DPLL_ENABLE | TRANSB_DPLLB_SEL); | 3953 | temp |= TRANSB_DPLL_ENABLE | TRANSB_DPLLB_SEL; |
4035 | I915_WRITE(PCH_DPLL_SEL, temp); | 3954 | I915_WRITE(PCH_DPLL_SEL, temp); |
4036 | I915_READ(PCH_DPLL_SEL); | 3955 | |
3956 | POSTING_READ(PCH_DPLL_SEL); | ||
4037 | udelay(150); | 3957 | udelay(150); |
4038 | } | 3958 | } |
4039 | 3959 | ||
@@ -4042,33 +3962,32 @@ static int intel_crtc_mode_set(struct drm_crtc *crtc, | |||
4042 | * things on. | 3962 | * things on. |
4043 | */ | 3963 | */ |
4044 | if (is_lvds) { | 3964 | if (is_lvds) { |
4045 | u32 lvds; | 3965 | reg = LVDS; |
4046 | |||
4047 | if (HAS_PCH_SPLIT(dev)) | 3966 | if (HAS_PCH_SPLIT(dev)) |
4048 | lvds_reg = PCH_LVDS; | 3967 | reg = PCH_LVDS; |
4049 | 3968 | ||
4050 | lvds = I915_READ(lvds_reg); | 3969 | temp = I915_READ(reg); |
4051 | lvds |= LVDS_PORT_EN | LVDS_A0A2_CLKA_POWER_UP; | 3970 | temp |= LVDS_PORT_EN | LVDS_A0A2_CLKA_POWER_UP; |
4052 | if (pipe == 1) { | 3971 | if (pipe == 1) { |
4053 | if (HAS_PCH_CPT(dev)) | 3972 | if (HAS_PCH_CPT(dev)) |
4054 | lvds |= PORT_TRANS_B_SEL_CPT; | 3973 | temp |= PORT_TRANS_B_SEL_CPT; |
4055 | else | 3974 | else |
4056 | lvds |= LVDS_PIPEB_SELECT; | 3975 | temp |= LVDS_PIPEB_SELECT; |
4057 | } else { | 3976 | } else { |
4058 | if (HAS_PCH_CPT(dev)) | 3977 | if (HAS_PCH_CPT(dev)) |
4059 | lvds &= ~PORT_TRANS_SEL_MASK; | 3978 | temp &= ~PORT_TRANS_SEL_MASK; |
4060 | else | 3979 | else |
4061 | lvds &= ~LVDS_PIPEB_SELECT; | 3980 | temp &= ~LVDS_PIPEB_SELECT; |
4062 | } | 3981 | } |
4063 | /* set the corresponsding LVDS_BORDER bit */ | 3982 | /* set the corresponsding LVDS_BORDER bit */ |
4064 | lvds |= dev_priv->lvds_border_bits; | 3983 | temp |= dev_priv->lvds_border_bits; |
4065 | /* Set the B0-B3 data pairs corresponding to whether we're going to | 3984 | /* Set the B0-B3 data pairs corresponding to whether we're going to |
4066 | * set the DPLLs for dual-channel mode or not. | 3985 | * set the DPLLs for dual-channel mode or not. |
4067 | */ | 3986 | */ |
4068 | if (clock.p2 == 7) | 3987 | if (clock.p2 == 7) |
4069 | lvds |= LVDS_B0B3_POWER_UP | LVDS_CLKB_POWER_UP; | 3988 | temp |= LVDS_B0B3_POWER_UP | LVDS_CLKB_POWER_UP; |
4070 | else | 3989 | else |
4071 | lvds &= ~(LVDS_B0B3_POWER_UP | LVDS_CLKB_POWER_UP); | 3990 | temp &= ~(LVDS_B0B3_POWER_UP | LVDS_CLKB_POWER_UP); |
4072 | 3991 | ||
4073 | /* It would be nice to set 24 vs 18-bit mode (LVDS_A3_POWER_UP) | 3992 | /* It would be nice to set 24 vs 18-bit mode (LVDS_A3_POWER_UP) |
4074 | * appropriately here, but we need to look more thoroughly into how | 3993 | * appropriately here, but we need to look more thoroughly into how |
@@ -4077,12 +3996,11 @@ static int intel_crtc_mode_set(struct drm_crtc *crtc, | |||
4077 | /* set the dithering flag on non-PCH LVDS as needed */ | 3996 | /* set the dithering flag on non-PCH LVDS as needed */ |
4078 | if (IS_I965G(dev) && !HAS_PCH_SPLIT(dev)) { | 3997 | if (IS_I965G(dev) && !HAS_PCH_SPLIT(dev)) { |
4079 | if (dev_priv->lvds_dither) | 3998 | if (dev_priv->lvds_dither) |
4080 | lvds |= LVDS_ENABLE_DITHER; | 3999 | temp |= LVDS_ENABLE_DITHER; |
4081 | else | 4000 | else |
4082 | lvds &= ~LVDS_ENABLE_DITHER; | 4001 | temp &= ~LVDS_ENABLE_DITHER; |
4083 | } | 4002 | } |
4084 | I915_WRITE(lvds_reg, lvds); | 4003 | I915_WRITE(reg, temp); |
4085 | I915_READ(lvds_reg); | ||
4086 | } | 4004 | } |
4087 | 4005 | ||
4088 | /* set the dithering flag and clear for anything other than a panel. */ | 4006 | /* set the dithering flag and clear for anything other than a panel. */ |
@@ -4115,32 +4033,32 @@ static int intel_crtc_mode_set(struct drm_crtc *crtc, | |||
4115 | if (!has_edp_encoder) { | 4033 | if (!has_edp_encoder) { |
4116 | I915_WRITE(fp_reg, fp); | 4034 | I915_WRITE(fp_reg, fp); |
4117 | I915_WRITE(dpll_reg, dpll); | 4035 | I915_WRITE(dpll_reg, dpll); |
4118 | I915_READ(dpll_reg); | 4036 | |
4119 | /* Wait for the clocks to stabilize. */ | 4037 | /* Wait for the clocks to stabilize. */ |
4038 | POSTING_READ(dpll_reg); | ||
4120 | udelay(150); | 4039 | udelay(150); |
4121 | 4040 | ||
4122 | if (IS_I965G(dev) && !HAS_PCH_SPLIT(dev)) { | 4041 | if (IS_I965G(dev) && !HAS_PCH_SPLIT(dev)) { |
4042 | temp = 0; | ||
4123 | if (is_sdvo) { | 4043 | if (is_sdvo) { |
4124 | int pixel_multiplier = intel_mode_get_pixel_multiplier(adjusted_mode); | 4044 | temp = intel_mode_get_pixel_multiplier(adjusted_mode); |
4125 | if (pixel_multiplier > 1) | 4045 | if (temp > 1) |
4126 | pixel_multiplier = (pixel_multiplier - 1) << DPLL_MD_UDI_MULTIPLIER_SHIFT; | 4046 | temp = (temp - 1) << DPLL_MD_UDI_MULTIPLIER_SHIFT; |
4127 | else | 4047 | else |
4128 | pixel_multiplier = 0; | 4048 | temp = 0; |
4129 | 4049 | } | |
4130 | I915_WRITE(dpll_md_reg, | 4050 | I915_WRITE(DPLL_MD(pipe), temp); |
4131 | (0 << DPLL_MD_UDI_DIVIDER_SHIFT) | | ||
4132 | pixel_multiplier); | ||
4133 | } else | ||
4134 | I915_WRITE(dpll_md_reg, 0); | ||
4135 | } else { | 4051 | } else { |
4136 | /* write it again -- the BIOS does, after all */ | 4052 | /* write it again -- the BIOS does, after all */ |
4137 | I915_WRITE(dpll_reg, dpll); | 4053 | I915_WRITE(dpll_reg, dpll); |
4138 | } | 4054 | } |
4139 | I915_READ(dpll_reg); | 4055 | |
4140 | /* Wait for the clocks to stabilize. */ | 4056 | /* Wait for the clocks to stabilize. */ |
4057 | POSTING_READ(dpll_reg); | ||
4141 | udelay(150); | 4058 | udelay(150); |
4142 | } | 4059 | } |
4143 | 4060 | ||
4061 | intel_crtc->lowfreq_avail = false; | ||
4144 | if (is_lvds && has_reduced_clock && i915_powersave) { | 4062 | if (is_lvds && has_reduced_clock && i915_powersave) { |
4145 | I915_WRITE(fp_reg + 4, fp2); | 4063 | I915_WRITE(fp_reg + 4, fp2); |
4146 | intel_crtc->lowfreq_avail = true; | 4064 | intel_crtc->lowfreq_avail = true; |
@@ -4150,7 +4068,6 @@ static int intel_crtc_mode_set(struct drm_crtc *crtc, | |||
4150 | } | 4068 | } |
4151 | } else { | 4069 | } else { |
4152 | I915_WRITE(fp_reg + 4, fp); | 4070 | I915_WRITE(fp_reg + 4, fp); |
4153 | intel_crtc->lowfreq_avail = false; | ||
4154 | if (HAS_PIPE_CXSR(dev)) { | 4071 | if (HAS_PIPE_CXSR(dev)) { |
4155 | DRM_DEBUG_KMS("disabling CxSR downclocking\n"); | 4072 | DRM_DEBUG_KMS("disabling CxSR downclocking\n"); |
4156 | pipeconf &= ~PIPECONF_CXSR_DOWNCLOCK; | 4073 | pipeconf &= ~PIPECONF_CXSR_DOWNCLOCK; |
@@ -4169,58 +4086,72 @@ static int intel_crtc_mode_set(struct drm_crtc *crtc, | |||
4169 | } else | 4086 | } else |
4170 | pipeconf &= ~PIPECONF_INTERLACE_W_FIELD_INDICATION; /* progressive */ | 4087 | pipeconf &= ~PIPECONF_INTERLACE_W_FIELD_INDICATION; /* progressive */ |
4171 | 4088 | ||
4172 | I915_WRITE(htot_reg, (adjusted_mode->crtc_hdisplay - 1) | | 4089 | I915_WRITE(HTOTAL(pipe), |
4090 | (adjusted_mode->crtc_hdisplay - 1) | | ||
4173 | ((adjusted_mode->crtc_htotal - 1) << 16)); | 4091 | ((adjusted_mode->crtc_htotal - 1) << 16)); |
4174 | I915_WRITE(hblank_reg, (adjusted_mode->crtc_hblank_start - 1) | | 4092 | I915_WRITE(HBLANK(pipe), |
4093 | (adjusted_mode->crtc_hblank_start - 1) | | ||
4175 | ((adjusted_mode->crtc_hblank_end - 1) << 16)); | 4094 | ((adjusted_mode->crtc_hblank_end - 1) << 16)); |
4176 | I915_WRITE(hsync_reg, (adjusted_mode->crtc_hsync_start - 1) | | 4095 | I915_WRITE(HSYNC(pipe), |
4096 | (adjusted_mode->crtc_hsync_start - 1) | | ||
4177 | ((adjusted_mode->crtc_hsync_end - 1) << 16)); | 4097 | ((adjusted_mode->crtc_hsync_end - 1) << 16)); |
4178 | I915_WRITE(vtot_reg, (adjusted_mode->crtc_vdisplay - 1) | | 4098 | |
4099 | I915_WRITE(VTOTAL(pipe), | ||
4100 | (adjusted_mode->crtc_vdisplay - 1) | | ||
4179 | ((adjusted_mode->crtc_vtotal - 1) << 16)); | 4101 | ((adjusted_mode->crtc_vtotal - 1) << 16)); |
4180 | I915_WRITE(vblank_reg, (adjusted_mode->crtc_vblank_start - 1) | | 4102 | I915_WRITE(VBLANK(pipe), |
4103 | (adjusted_mode->crtc_vblank_start - 1) | | ||
4181 | ((adjusted_mode->crtc_vblank_end - 1) << 16)); | 4104 | ((adjusted_mode->crtc_vblank_end - 1) << 16)); |
4182 | I915_WRITE(vsync_reg, (adjusted_mode->crtc_vsync_start - 1) | | 4105 | I915_WRITE(VSYNC(pipe), |
4106 | (adjusted_mode->crtc_vsync_start - 1) | | ||
4183 | ((adjusted_mode->crtc_vsync_end - 1) << 16)); | 4107 | ((adjusted_mode->crtc_vsync_end - 1) << 16)); |
4184 | /* pipesrc and dspsize control the size that is scaled from, which should | 4108 | |
4185 | * always be the user's requested size. | 4109 | /* pipesrc and dspsize control the size that is scaled from, |
4110 | * which should always be the user's requested size. | ||
4186 | */ | 4111 | */ |
4187 | if (!HAS_PCH_SPLIT(dev)) { | 4112 | if (!HAS_PCH_SPLIT(dev)) { |
4188 | I915_WRITE(dspsize_reg, ((mode->vdisplay - 1) << 16) | | 4113 | I915_WRITE(DSPSIZE(plane), |
4189 | (mode->hdisplay - 1)); | 4114 | ((mode->vdisplay - 1) << 16) | |
4190 | I915_WRITE(dsppos_reg, 0); | 4115 | (mode->hdisplay - 1)); |
4116 | I915_WRITE(DSPPOS(plane), 0); | ||
4191 | } | 4117 | } |
4192 | I915_WRITE(pipesrc_reg, ((mode->hdisplay - 1) << 16) | (mode->vdisplay - 1)); | 4118 | I915_WRITE(PIPESRC(pipe), |
4119 | ((mode->hdisplay - 1) << 16) | (mode->vdisplay - 1)); | ||
4193 | 4120 | ||
4194 | if (HAS_PCH_SPLIT(dev)) { | 4121 | if (HAS_PCH_SPLIT(dev)) { |
4195 | I915_WRITE(data_m1_reg, TU_SIZE(m_n.tu) | m_n.gmch_m); | 4122 | I915_WRITE(PIPE_DATA_M1(pipe), TU_SIZE(m_n.tu) | m_n.gmch_m); |
4196 | I915_WRITE(data_n1_reg, m_n.gmch_n); | 4123 | I915_WRITE(PIPE_DATA_N1(pipe), m_n.gmch_n); |
4197 | I915_WRITE(link_m1_reg, m_n.link_m); | 4124 | I915_WRITE(PIPE_LINK_M1(pipe), m_n.link_m); |
4198 | I915_WRITE(link_n1_reg, m_n.link_n); | 4125 | I915_WRITE(PIPE_LINK_N1(pipe), m_n.link_n); |
4199 | 4126 | ||
4200 | if (has_edp_encoder) { | 4127 | if (has_edp_encoder) { |
4201 | ironlake_set_pll_edp(crtc, adjusted_mode->clock); | 4128 | ironlake_set_pll_edp(crtc, adjusted_mode->clock); |
4202 | } else { | 4129 | } else { |
4203 | /* enable FDI RX PLL too */ | 4130 | /* enable FDI RX PLL too */ |
4204 | temp = I915_READ(fdi_rx_reg); | 4131 | reg = FDI_RX_CTL(pipe); |
4205 | I915_WRITE(fdi_rx_reg, temp | FDI_RX_PLL_ENABLE); | 4132 | temp = I915_READ(reg); |
4206 | I915_READ(fdi_rx_reg); | 4133 | I915_WRITE(reg, temp | FDI_RX_PLL_ENABLE); |
4134 | |||
4135 | POSTING_READ(reg); | ||
4207 | udelay(200); | 4136 | udelay(200); |
4208 | 4137 | ||
4209 | /* enable FDI TX PLL too */ | 4138 | /* enable FDI TX PLL too */ |
4210 | temp = I915_READ(fdi_tx_reg); | 4139 | reg = FDI_TX_CTL(pipe); |
4211 | I915_WRITE(fdi_tx_reg, temp | FDI_TX_PLL_ENABLE); | 4140 | temp = I915_READ(reg); |
4212 | I915_READ(fdi_tx_reg); | 4141 | I915_WRITE(reg, temp | FDI_TX_PLL_ENABLE); |
4213 | 4142 | ||
4214 | /* enable FDI RX PCDCLK */ | 4143 | /* enable FDI RX PCDCLK */ |
4215 | temp = I915_READ(fdi_rx_reg); | 4144 | reg = FDI_RX_CTL(pipe); |
4216 | I915_WRITE(fdi_rx_reg, temp | FDI_SEL_PCDCLK); | 4145 | temp = I915_READ(reg); |
4217 | I915_READ(fdi_rx_reg); | 4146 | I915_WRITE(reg, temp | FDI_PCDCLK); |
4147 | |||
4148 | POSTING_READ(reg); | ||
4218 | udelay(200); | 4149 | udelay(200); |
4219 | } | 4150 | } |
4220 | } | 4151 | } |
4221 | 4152 | ||
4222 | I915_WRITE(pipeconf_reg, pipeconf); | 4153 | I915_WRITE(PIPECONF(pipe), pipeconf); |
4223 | I915_READ(pipeconf_reg); | 4154 | POSTING_READ(PIPECONF(pipe)); |
4224 | 4155 | ||
4225 | intel_wait_for_vblank(dev, pipe); | 4156 | intel_wait_for_vblank(dev, pipe); |
4226 | 4157 | ||
@@ -4230,9 +4161,8 @@ static int intel_crtc_mode_set(struct drm_crtc *crtc, | |||
4230 | I915_WRITE(DISP_ARB_CTL, temp | DISP_TILE_SURFACE_SWIZZLING); | 4161 | I915_WRITE(DISP_ARB_CTL, temp | DISP_TILE_SURFACE_SWIZZLING); |
4231 | } | 4162 | } |
4232 | 4163 | ||
4233 | I915_WRITE(dspcntr_reg, dspcntr); | 4164 | I915_WRITE(DSPCNTR(plane), dspcntr); |
4234 | 4165 | ||
4235 | /* Flush the plane changes */ | ||
4236 | ret = intel_pipe_set_base(crtc, x, y, old_fb); | 4166 | ret = intel_pipe_set_base(crtc, x, y, old_fb); |
4237 | 4167 | ||
4238 | intel_update_watermarks(dev); | 4168 | intel_update_watermarks(dev); |