diff options
author | Alan Cox <alan@linux.intel.com> | 2012-05-11 06:31:22 -0400 |
---|---|---|
committer | Dave Airlie <airlied@redhat.com> | 2012-05-11 12:35:51 -0400 |
commit | 213a84346fa963a6c0136be6844c5e4d806308a0 (patch) | |
tree | e3b80be8d4637746bb31544710ce52ea41387661 | |
parent | 8512e0748729a49d9af6693f920c1b432796fa8d (diff) |
gma500: use the register map to clean up
Signed-off-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
-rw-r--r-- | drivers/gpu/drm/gma500/cdv_device.c | 2 | ||||
-rw-r--r-- | drivers/gpu/drm/gma500/cdv_intel_display.c | 290 | ||||
-rw-r--r-- | drivers/gpu/drm/gma500/mdfld_device.c | 223 | ||||
-rw-r--r-- | drivers/gpu/drm/gma500/mdfld_dsi_pkg_sender.c | 24 | ||||
-rw-r--r-- | drivers/gpu/drm/gma500/mdfld_intel_display.c | 330 | ||||
-rw-r--r-- | drivers/gpu/drm/gma500/oaktrail_crtc.c | 134 | ||||
-rw-r--r-- | drivers/gpu/drm/gma500/oaktrail_device.c | 2 | ||||
-rw-r--r-- | drivers/gpu/drm/gma500/psb_intel_display.c | 251 |
8 files changed, 473 insertions, 783 deletions
diff --git a/drivers/gpu/drm/gma500/cdv_device.c b/drivers/gpu/drm/gma500/cdv_device.c index ec062e4c3029..148e3e7524d9 100644 --- a/drivers/gpu/drm/gma500/cdv_device.c +++ b/drivers/gpu/drm/gma500/cdv_device.c | |||
@@ -494,6 +494,7 @@ static const struct psb_offset cdv_regmap[2] = { | |||
494 | .conf = PIPEACONF, | 494 | .conf = PIPEACONF, |
495 | .src = PIPEASRC, | 495 | .src = PIPEASRC, |
496 | .dpll = DPLL_A, | 496 | .dpll = DPLL_A, |
497 | .dpll_md = DPLL_A_MD, | ||
497 | .htotal = HTOTAL_A, | 498 | .htotal = HTOTAL_A, |
498 | .hblank = HBLANK_A, | 499 | .hblank = HBLANK_A, |
499 | .hsync = HSYNC_A, | 500 | .hsync = HSYNC_A, |
@@ -518,6 +519,7 @@ static const struct psb_offset cdv_regmap[2] = { | |||
518 | .conf = PIPEBCONF, | 519 | .conf = PIPEBCONF, |
519 | .src = PIPEBSRC, | 520 | .src = PIPEBSRC, |
520 | .dpll = DPLL_B, | 521 | .dpll = DPLL_B, |
522 | .dpll_md = DPLL_B_MD, | ||
521 | .htotal = HTOTAL_B, | 523 | .htotal = HTOTAL_B, |
522 | .hblank = HBLANK_B, | 524 | .hblank = HBLANK_B, |
523 | .hsync = HSYNC_B, | 525 | .hsync = HSYNC_B, |
diff --git a/drivers/gpu/drm/gma500/cdv_intel_display.c b/drivers/gpu/drm/gma500/cdv_intel_display.c index 123ed5aa80c1..c3e9a0f701df 100644 --- a/drivers/gpu/drm/gma500/cdv_intel_display.c +++ b/drivers/gpu/drm/gma500/cdv_intel_display.c | |||
@@ -218,8 +218,7 @@ static int | |||
218 | cdv_dpll_set_clock_cdv(struct drm_device *dev, struct drm_crtc *crtc, | 218 | cdv_dpll_set_clock_cdv(struct drm_device *dev, struct drm_crtc *crtc, |
219 | struct cdv_intel_clock_t *clock, bool is_lvds) | 219 | struct cdv_intel_clock_t *clock, bool is_lvds) |
220 | { | 220 | { |
221 | struct psb_intel_crtc *psb_crtc = | 221 | struct psb_intel_crtc *psb_crtc = to_psb_intel_crtc(crtc); |
222 | to_psb_intel_crtc(crtc); | ||
223 | int pipe = psb_crtc->pipe; | 222 | int pipe = psb_crtc->pipe; |
224 | u32 m, n_vco, p; | 223 | u32 m, n_vco, p; |
225 | int ret = 0; | 224 | int ret = 0; |
@@ -503,14 +502,12 @@ static int cdv_intel_pipe_set_base(struct drm_crtc *crtc, | |||
503 | int x, int y, struct drm_framebuffer *old_fb) | 502 | int x, int y, struct drm_framebuffer *old_fb) |
504 | { | 503 | { |
505 | struct drm_device *dev = crtc->dev; | 504 | struct drm_device *dev = crtc->dev; |
505 | struct drm_psb_private *dev_priv = dev->dev_private; | ||
506 | struct psb_intel_crtc *psb_intel_crtc = to_psb_intel_crtc(crtc); | 506 | struct psb_intel_crtc *psb_intel_crtc = to_psb_intel_crtc(crtc); |
507 | struct psb_framebuffer *psbfb = to_psb_fb(crtc->fb); | 507 | struct psb_framebuffer *psbfb = to_psb_fb(crtc->fb); |
508 | int pipe = psb_intel_crtc->pipe; | 508 | int pipe = psb_intel_crtc->pipe; |
509 | const struct psb_offset *map = &dev_priv->regmap[pipe]; | ||
509 | unsigned long start, offset; | 510 | unsigned long start, offset; |
510 | int dspbase = (pipe == 0 ? DSPABASE : DSPBBASE); | ||
511 | int dspsurf = (pipe == 0 ? DSPASURF : DSPBSURF); | ||
512 | int dspstride = (pipe == 0) ? DSPASTRIDE : DSPBSTRIDE; | ||
513 | int dspcntr_reg = (pipe == 0) ? DSPACNTR : DSPBCNTR; | ||
514 | u32 dspcntr; | 511 | u32 dspcntr; |
515 | int ret = 0; | 512 | int ret = 0; |
516 | 513 | ||
@@ -532,9 +529,9 @@ static int cdv_intel_pipe_set_base(struct drm_crtc *crtc, | |||
532 | start = psbfb->gtt->offset; | 529 | start = psbfb->gtt->offset; |
533 | offset = y * crtc->fb->pitches[0] + x * (crtc->fb->bits_per_pixel / 8); | 530 | offset = y * crtc->fb->pitches[0] + x * (crtc->fb->bits_per_pixel / 8); |
534 | 531 | ||
535 | REG_WRITE(dspstride, crtc->fb->pitches[0]); | 532 | REG_WRITE(map->stride, crtc->fb->pitches[0]); |
536 | 533 | ||
537 | dspcntr = REG_READ(dspcntr_reg); | 534 | dspcntr = REG_READ(map->cntr); |
538 | dspcntr &= ~DISPPLANE_PIXFORMAT_MASK; | 535 | dspcntr &= ~DISPPLANE_PIXFORMAT_MASK; |
539 | 536 | ||
540 | switch (crtc->fb->bits_per_pixel) { | 537 | switch (crtc->fb->bits_per_pixel) { |
@@ -556,15 +553,15 @@ static int cdv_intel_pipe_set_base(struct drm_crtc *crtc, | |||
556 | ret = -EINVAL; | 553 | ret = -EINVAL; |
557 | goto psb_intel_pipe_set_base_exit; | 554 | goto psb_intel_pipe_set_base_exit; |
558 | } | 555 | } |
559 | REG_WRITE(dspcntr_reg, dspcntr); | 556 | REG_WRITE(map->cntr, dspcntr); |
560 | 557 | ||
561 | dev_dbg(dev->dev, | 558 | dev_dbg(dev->dev, |
562 | "Writing base %08lX %08lX %d %d\n", start, offset, x, y); | 559 | "Writing base %08lX %08lX %d %d\n", start, offset, x, y); |
563 | 560 | ||
564 | REG_WRITE(dspbase, offset); | 561 | REG_WRITE(map->base, offset); |
565 | REG_READ(dspbase); | 562 | REG_READ(map->base); |
566 | REG_WRITE(dspsurf, start); | 563 | REG_WRITE(map->surf, start); |
567 | REG_READ(dspsurf); | 564 | REG_READ(map->surf); |
568 | 565 | ||
569 | psb_intel_pipe_cleaner: | 566 | psb_intel_pipe_cleaner: |
570 | /* If there was a previous display we can now unpin it */ | 567 | /* If there was a previous display we can now unpin it */ |
@@ -721,8 +718,7 @@ static void cdv_intel_update_watermark (struct drm_device *dev, struct drm_crtc | |||
721 | static void cdv_intel_crtc_load_lut(struct drm_crtc *crtc) | 718 | static void cdv_intel_crtc_load_lut(struct drm_crtc *crtc) |
722 | { | 719 | { |
723 | struct drm_device *dev = crtc->dev; | 720 | struct drm_device *dev = crtc->dev; |
724 | struct drm_psb_private *dev_priv = | 721 | struct drm_psb_private *dev_priv = dev->dev_private; |
725 | (struct drm_psb_private *)dev->dev_private; | ||
726 | struct psb_intel_crtc *psb_intel_crtc = to_psb_intel_crtc(crtc); | 722 | struct psb_intel_crtc *psb_intel_crtc = to_psb_intel_crtc(crtc); |
727 | int palreg = PALETTE_A; | 723 | int palreg = PALETTE_A; |
728 | int i; | 724 | int i; |
@@ -779,13 +775,10 @@ static void cdv_intel_crtc_load_lut(struct drm_crtc *crtc) | |||
779 | static void cdv_intel_crtc_dpms(struct drm_crtc *crtc, int mode) | 775 | static void cdv_intel_crtc_dpms(struct drm_crtc *crtc, int mode) |
780 | { | 776 | { |
781 | struct drm_device *dev = crtc->dev; | 777 | struct drm_device *dev = crtc->dev; |
778 | struct drm_psb_private *dev_priv = dev->dev_private; | ||
782 | struct psb_intel_crtc *psb_intel_crtc = to_psb_intel_crtc(crtc); | 779 | struct psb_intel_crtc *psb_intel_crtc = to_psb_intel_crtc(crtc); |
783 | int pipe = psb_intel_crtc->pipe; | 780 | int pipe = psb_intel_crtc->pipe; |
784 | int dpll_reg = (pipe == 0) ? DPLL_A : DPLL_B; | 781 | const struct psb_offset *map = &dev_priv->regmap[pipe]; |
785 | int dspcntr_reg = (pipe == 0) ? DSPACNTR : DSPBCNTR; | ||
786 | int dspbase_reg = (pipe == 0) ? DSPABASE : DSPBBASE; | ||
787 | int pipeconf_reg = (pipe == 0) ? PIPEACONF : PIPEBCONF; | ||
788 | int pipestat_reg = (pipe == 0) ? PIPEASTAT : PIPEBSTAT; | ||
789 | u32 temp; | 782 | u32 temp; |
790 | 783 | ||
791 | /* XXX: When our outputs are all unaware of DPMS modes other than off | 784 | /* XXX: When our outputs are all unaware of DPMS modes other than off |
@@ -803,44 +796,44 @@ static void cdv_intel_crtc_dpms(struct drm_crtc *crtc, int mode) | |||
803 | psb_intel_crtc->active = true; | 796 | psb_intel_crtc->active = true; |
804 | 797 | ||
805 | /* Enable the DPLL */ | 798 | /* Enable the DPLL */ |
806 | temp = REG_READ(dpll_reg); | 799 | temp = REG_READ(map->dpll); |
807 | if ((temp & DPLL_VCO_ENABLE) == 0) { | 800 | if ((temp & DPLL_VCO_ENABLE) == 0) { |
808 | REG_WRITE(dpll_reg, temp); | 801 | REG_WRITE(map->dpll, temp); |
809 | REG_READ(dpll_reg); | 802 | REG_READ(map->dpll); |
810 | /* Wait for the clocks to stabilize. */ | 803 | /* Wait for the clocks to stabilize. */ |
811 | udelay(150); | 804 | udelay(150); |
812 | REG_WRITE(dpll_reg, temp | DPLL_VCO_ENABLE); | 805 | REG_WRITE(map->dpll, temp | DPLL_VCO_ENABLE); |
813 | REG_READ(dpll_reg); | 806 | REG_READ(map->dpll); |
814 | /* Wait for the clocks to stabilize. */ | 807 | /* Wait for the clocks to stabilize. */ |
815 | udelay(150); | 808 | udelay(150); |
816 | REG_WRITE(dpll_reg, temp | DPLL_VCO_ENABLE); | 809 | REG_WRITE(map->dpll, temp | DPLL_VCO_ENABLE); |
817 | REG_READ(dpll_reg); | 810 | REG_READ(map->dpll); |
818 | /* Wait for the clocks to stabilize. */ | 811 | /* Wait for the clocks to stabilize. */ |
819 | udelay(150); | 812 | udelay(150); |
820 | } | 813 | } |
821 | 814 | ||
822 | /* Jim Bish - switch plan and pipe per scott */ | 815 | /* Jim Bish - switch plan and pipe per scott */ |
823 | /* Enable the plane */ | 816 | /* Enable the plane */ |
824 | temp = REG_READ(dspcntr_reg); | 817 | temp = REG_READ(map->cntr); |
825 | if ((temp & DISPLAY_PLANE_ENABLE) == 0) { | 818 | if ((temp & DISPLAY_PLANE_ENABLE) == 0) { |
826 | REG_WRITE(dspcntr_reg, | 819 | REG_WRITE(map->cntr, |
827 | temp | DISPLAY_PLANE_ENABLE); | 820 | temp | DISPLAY_PLANE_ENABLE); |
828 | /* Flush the plane changes */ | 821 | /* Flush the plane changes */ |
829 | REG_WRITE(dspbase_reg, REG_READ(dspbase_reg)); | 822 | REG_WRITE(map->base, REG_READ(map->base)); |
830 | } | 823 | } |
831 | 824 | ||
832 | udelay(150); | 825 | udelay(150); |
833 | 826 | ||
834 | /* Enable the pipe */ | 827 | /* Enable the pipe */ |
835 | temp = REG_READ(pipeconf_reg); | 828 | temp = REG_READ(map->conf); |
836 | if ((temp & PIPEACONF_ENABLE) == 0) | 829 | if ((temp & PIPEACONF_ENABLE) == 0) |
837 | REG_WRITE(pipeconf_reg, temp | PIPEACONF_ENABLE); | 830 | REG_WRITE(map->conf, temp | PIPEACONF_ENABLE); |
838 | 831 | ||
839 | temp = REG_READ(pipestat_reg); | 832 | temp = REG_READ(map->status); |
840 | temp &= ~(0xFFFF); | 833 | temp &= ~(0xFFFF); |
841 | temp |= PIPE_FIFO_UNDERRUN; | 834 | temp |= PIPE_FIFO_UNDERRUN; |
842 | REG_WRITE(pipestat_reg, temp); | 835 | REG_WRITE(map->status, temp); |
843 | REG_READ(pipestat_reg); | 836 | REG_READ(map->status); |
844 | 837 | ||
845 | cdv_intel_update_watermark(dev, crtc); | 838 | cdv_intel_update_watermark(dev, crtc); |
846 | cdv_intel_crtc_load_lut(crtc); | 839 | cdv_intel_crtc_load_lut(crtc); |
@@ -870,10 +863,10 @@ static void cdv_intel_crtc_dpms(struct drm_crtc *crtc, int mode) | |||
870 | cdv_intel_wait_for_vblank(dev); | 863 | cdv_intel_wait_for_vblank(dev); |
871 | 864 | ||
872 | /* Next, disable display pipes */ | 865 | /* Next, disable display pipes */ |
873 | temp = REG_READ(pipeconf_reg); | 866 | temp = REG_READ(map->conf); |
874 | if ((temp & PIPEACONF_ENABLE) != 0) { | 867 | if ((temp & PIPEACONF_ENABLE) != 0) { |
875 | REG_WRITE(pipeconf_reg, temp & ~PIPEACONF_ENABLE); | 868 | REG_WRITE(map->conf, temp & ~PIPEACONF_ENABLE); |
876 | REG_READ(pipeconf_reg); | 869 | REG_READ(map->conf); |
877 | } | 870 | } |
878 | 871 | ||
879 | /* Wait for vblank for the disable to take effect. */ | 872 | /* Wait for vblank for the disable to take effect. */ |
@@ -882,19 +875,19 @@ static void cdv_intel_crtc_dpms(struct drm_crtc *crtc, int mode) | |||
882 | udelay(150); | 875 | udelay(150); |
883 | 876 | ||
884 | /* Disable display plane */ | 877 | /* Disable display plane */ |
885 | temp = REG_READ(dspcntr_reg); | 878 | temp = REG_READ(map->cntr); |
886 | if ((temp & DISPLAY_PLANE_ENABLE) != 0) { | 879 | if ((temp & DISPLAY_PLANE_ENABLE) != 0) { |
887 | REG_WRITE(dspcntr_reg, | 880 | REG_WRITE(map->cntr, |
888 | temp & ~DISPLAY_PLANE_ENABLE); | 881 | temp & ~DISPLAY_PLANE_ENABLE); |
889 | /* Flush the plane changes */ | 882 | /* Flush the plane changes */ |
890 | REG_WRITE(dspbase_reg, REG_READ(dspbase_reg)); | 883 | REG_WRITE(map->base, REG_READ(map->base)); |
891 | REG_READ(dspbase_reg); | 884 | REG_READ(map->base); |
892 | } | 885 | } |
893 | 886 | ||
894 | temp = REG_READ(dpll_reg); | 887 | temp = REG_READ(map->dpll); |
895 | if ((temp & DPLL_VCO_ENABLE) != 0) { | 888 | if ((temp & DPLL_VCO_ENABLE) != 0) { |
896 | REG_WRITE(dpll_reg, temp & ~DPLL_VCO_ENABLE); | 889 | REG_WRITE(map->dpll, temp & ~DPLL_VCO_ENABLE); |
897 | REG_READ(dpll_reg); | 890 | REG_READ(map->dpll); |
898 | } | 891 | } |
899 | 892 | ||
900 | /* Wait for the clocks to turn off. */ | 893 | /* Wait for the clocks to turn off. */ |
@@ -953,19 +946,7 @@ static int cdv_intel_crtc_mode_set(struct drm_crtc *crtc, | |||
953 | struct drm_psb_private *dev_priv = dev->dev_private; | 946 | struct drm_psb_private *dev_priv = dev->dev_private; |
954 | struct psb_intel_crtc *psb_intel_crtc = to_psb_intel_crtc(crtc); | 947 | struct psb_intel_crtc *psb_intel_crtc = to_psb_intel_crtc(crtc); |
955 | int pipe = psb_intel_crtc->pipe; | 948 | int pipe = psb_intel_crtc->pipe; |
956 | int dpll_reg = (pipe == 0) ? DPLL_A : DPLL_B; | 949 | const struct psb_offset *map = &dev_priv->regmap[pipe]; |
957 | int dpll_md_reg = (psb_intel_crtc->pipe == 0) ? DPLL_A_MD : DPLL_B_MD; | ||
958 | int dspcntr_reg = (pipe == 0) ? DSPACNTR : DSPBCNTR; | ||
959 | int pipeconf_reg = (pipe == 0) ? PIPEACONF : PIPEBCONF; | ||
960 | int htot_reg = (pipe == 0) ? HTOTAL_A : HTOTAL_B; | ||
961 | int hblank_reg = (pipe == 0) ? HBLANK_A : HBLANK_B; | ||
962 | int hsync_reg = (pipe == 0) ? HSYNC_A : HSYNC_B; | ||
963 | int vtot_reg = (pipe == 0) ? VTOTAL_A : VTOTAL_B; | ||
964 | int vblank_reg = (pipe == 0) ? VBLANK_A : VBLANK_B; | ||
965 | int vsync_reg = (pipe == 0) ? VSYNC_A : VSYNC_B; | ||
966 | int dspsize_reg = (pipe == 0) ? DSPASIZE : DSPBSIZE; | ||
967 | int dsppos_reg = (pipe == 0) ? DSPAPOS : DSPBPOS; | ||
968 | int pipesrc_reg = (pipe == 0) ? PIPEASRC : PIPEBSRC; | ||
969 | int refclk; | 950 | int refclk; |
970 | struct cdv_intel_clock_t clock; | 951 | struct cdv_intel_clock_t clock; |
971 | u32 dpll = 0, dspcntr, pipeconf; | 952 | u32 dpll = 0, dspcntr, pipeconf; |
@@ -1036,7 +1017,7 @@ static int cdv_intel_crtc_mode_set(struct drm_crtc *crtc, | |||
1036 | /* dpll |= (2 << 11); */ | 1017 | /* dpll |= (2 << 11); */ |
1037 | 1018 | ||
1038 | /* setup pipeconf */ | 1019 | /* setup pipeconf */ |
1039 | pipeconf = REG_READ(pipeconf_reg); | 1020 | pipeconf = REG_READ(map->conf); |
1040 | 1021 | ||
1041 | /* Set up the display plane register */ | 1022 | /* Set up the display plane register */ |
1042 | dspcntr = DISPPLANE_GAMMA_ENABLE; | 1023 | dspcntr = DISPPLANE_GAMMA_ENABLE; |
@@ -1049,8 +1030,8 @@ static int cdv_intel_crtc_mode_set(struct drm_crtc *crtc, | |||
1049 | dspcntr |= DISPLAY_PLANE_ENABLE; | 1030 | dspcntr |= DISPLAY_PLANE_ENABLE; |
1050 | pipeconf |= PIPEACONF_ENABLE; | 1031 | pipeconf |= PIPEACONF_ENABLE; |
1051 | 1032 | ||
1052 | REG_WRITE(dpll_reg, dpll | DPLL_VGA_MODE_DIS | DPLL_SYNCLOCK_ENABLE); | 1033 | REG_WRITE(map->dpll, dpll | DPLL_VGA_MODE_DIS | DPLL_SYNCLOCK_ENABLE); |
1053 | REG_READ(dpll_reg); | 1034 | REG_READ(map->dpll); |
1054 | 1035 | ||
1055 | cdv_dpll_set_clock_cdv(dev, crtc, &clock, is_lvds); | 1036 | cdv_dpll_set_clock_cdv(dev, crtc, &clock, is_lvds); |
1056 | 1037 | ||
@@ -1094,48 +1075,48 @@ static int cdv_intel_crtc_mode_set(struct drm_crtc *crtc, | |||
1094 | DRM_DEBUG_KMS("Mode for pipe %c:\n", pipe == 0 ? 'A' : 'B'); | 1075 | DRM_DEBUG_KMS("Mode for pipe %c:\n", pipe == 0 ? 'A' : 'B'); |
1095 | drm_mode_debug_printmodeline(mode); | 1076 | drm_mode_debug_printmodeline(mode); |
1096 | 1077 | ||
1097 | REG_WRITE(dpll_reg, | 1078 | REG_WRITE(map->dpll, |
1098 | (REG_READ(dpll_reg) & ~DPLL_LOCK) | DPLL_VCO_ENABLE); | 1079 | (REG_READ(map->dpll) & ~DPLL_LOCK) | DPLL_VCO_ENABLE); |
1099 | REG_READ(dpll_reg); | 1080 | REG_READ(map->dpll); |
1100 | /* Wait for the clocks to stabilize. */ | 1081 | /* Wait for the clocks to stabilize. */ |
1101 | udelay(150); /* 42 usec w/o calibration, 110 with. rounded up. */ | 1082 | udelay(150); /* 42 usec w/o calibration, 110 with. rounded up. */ |
1102 | 1083 | ||
1103 | if (!(REG_READ(dpll_reg) & DPLL_LOCK)) { | 1084 | if (!(REG_READ(map->dpll) & DPLL_LOCK)) { |
1104 | dev_err(dev->dev, "Failed to get DPLL lock\n"); | 1085 | dev_err(dev->dev, "Failed to get DPLL lock\n"); |
1105 | return -EBUSY; | 1086 | return -EBUSY; |
1106 | } | 1087 | } |
1107 | 1088 | ||
1108 | { | 1089 | { |
1109 | int sdvo_pixel_multiply = adjusted_mode->clock / mode->clock; | 1090 | int sdvo_pixel_multiply = adjusted_mode->clock / mode->clock; |
1110 | REG_WRITE(dpll_md_reg, (0 << DPLL_MD_UDI_DIVIDER_SHIFT) | ((sdvo_pixel_multiply - 1) << DPLL_MD_UDI_MULTIPLIER_SHIFT)); | 1091 | REG_WRITE(map->dpll_md, (0 << DPLL_MD_UDI_DIVIDER_SHIFT) | ((sdvo_pixel_multiply - 1) << DPLL_MD_UDI_MULTIPLIER_SHIFT)); |
1111 | } | 1092 | } |
1112 | 1093 | ||
1113 | REG_WRITE(htot_reg, (adjusted_mode->crtc_hdisplay - 1) | | 1094 | REG_WRITE(map->htotal, (adjusted_mode->crtc_hdisplay - 1) | |
1114 | ((adjusted_mode->crtc_htotal - 1) << 16)); | 1095 | ((adjusted_mode->crtc_htotal - 1) << 16)); |
1115 | REG_WRITE(hblank_reg, (adjusted_mode->crtc_hblank_start - 1) | | 1096 | REG_WRITE(map->hblank, (adjusted_mode->crtc_hblank_start - 1) | |
1116 | ((adjusted_mode->crtc_hblank_end - 1) << 16)); | 1097 | ((adjusted_mode->crtc_hblank_end - 1) << 16)); |
1117 | REG_WRITE(hsync_reg, (adjusted_mode->crtc_hsync_start - 1) | | 1098 | REG_WRITE(map->hsync, (adjusted_mode->crtc_hsync_start - 1) | |
1118 | ((adjusted_mode->crtc_hsync_end - 1) << 16)); | 1099 | ((adjusted_mode->crtc_hsync_end - 1) << 16)); |
1119 | REG_WRITE(vtot_reg, (adjusted_mode->crtc_vdisplay - 1) | | 1100 | REG_WRITE(map->vtotal, (adjusted_mode->crtc_vdisplay - 1) | |
1120 | ((adjusted_mode->crtc_vtotal - 1) << 16)); | 1101 | ((adjusted_mode->crtc_vtotal - 1) << 16)); |
1121 | REG_WRITE(vblank_reg, (adjusted_mode->crtc_vblank_start - 1) | | 1102 | REG_WRITE(map->vblank, (adjusted_mode->crtc_vblank_start - 1) | |
1122 | ((adjusted_mode->crtc_vblank_end - 1) << 16)); | 1103 | ((adjusted_mode->crtc_vblank_end - 1) << 16)); |
1123 | REG_WRITE(vsync_reg, (adjusted_mode->crtc_vsync_start - 1) | | 1104 | REG_WRITE(map->vsync, (adjusted_mode->crtc_vsync_start - 1) | |
1124 | ((adjusted_mode->crtc_vsync_end - 1) << 16)); | 1105 | ((adjusted_mode->crtc_vsync_end - 1) << 16)); |
1125 | /* pipesrc and dspsize control the size that is scaled from, | 1106 | /* pipesrc and dspsize control the size that is scaled from, |
1126 | * which should always be the user's requested size. | 1107 | * which should always be the user's requested size. |
1127 | */ | 1108 | */ |
1128 | REG_WRITE(dspsize_reg, | 1109 | REG_WRITE(map->size, |
1129 | ((mode->vdisplay - 1) << 16) | (mode->hdisplay - 1)); | 1110 | ((mode->vdisplay - 1) << 16) | (mode->hdisplay - 1)); |
1130 | REG_WRITE(dsppos_reg, 0); | 1111 | REG_WRITE(map->pos, 0); |
1131 | REG_WRITE(pipesrc_reg, | 1112 | REG_WRITE(map->src, |
1132 | ((mode->hdisplay - 1) << 16) | (mode->vdisplay - 1)); | 1113 | ((mode->hdisplay - 1) << 16) | (mode->vdisplay - 1)); |
1133 | REG_WRITE(pipeconf_reg, pipeconf); | 1114 | REG_WRITE(map->conf, pipeconf); |
1134 | REG_READ(pipeconf_reg); | 1115 | REG_READ(map->conf); |
1135 | 1116 | ||
1136 | cdv_intel_wait_for_vblank(dev); | 1117 | cdv_intel_wait_for_vblank(dev); |
1137 | 1118 | ||
1138 | REG_WRITE(dspcntr_reg, dspcntr); | 1119 | REG_WRITE(map->cntr, dspcntr); |
1139 | 1120 | ||
1140 | /* Flush the plane changes */ | 1121 | /* Flush the plane changes */ |
1141 | { | 1122 | { |
@@ -1156,11 +1137,10 @@ static int cdv_intel_crtc_mode_set(struct drm_crtc *crtc, | |||
1156 | static void cdv_intel_crtc_save(struct drm_crtc *crtc) | 1137 | static void cdv_intel_crtc_save(struct drm_crtc *crtc) |
1157 | { | 1138 | { |
1158 | struct drm_device *dev = crtc->dev; | 1139 | struct drm_device *dev = crtc->dev; |
1159 | /* struct drm_psb_private *dev_priv = | 1140 | struct drm_psb_private *dev_priv = dev->dev_private; |
1160 | (struct drm_psb_private *)dev->dev_private; */ | ||
1161 | struct psb_intel_crtc *psb_intel_crtc = to_psb_intel_crtc(crtc); | 1141 | struct psb_intel_crtc *psb_intel_crtc = to_psb_intel_crtc(crtc); |
1162 | struct psb_intel_crtc_state *crtc_state = psb_intel_crtc->crtc_state; | 1142 | struct psb_intel_crtc_state *crtc_state = psb_intel_crtc->crtc_state; |
1163 | int pipeA = (psb_intel_crtc->pipe == 0); | 1143 | const struct psb_offset *map = &dev_priv->regmap[psb_intel_crtc->pipe]; |
1164 | uint32_t paletteReg; | 1144 | uint32_t paletteReg; |
1165 | int i; | 1145 | int i; |
1166 | 1146 | ||
@@ -1169,25 +1149,25 @@ static void cdv_intel_crtc_save(struct drm_crtc *crtc) | |||
1169 | return; | 1149 | return; |
1170 | } | 1150 | } |
1171 | 1151 | ||
1172 | crtc_state->saveDSPCNTR = REG_READ(pipeA ? DSPACNTR : DSPBCNTR); | 1152 | crtc_state->saveDSPCNTR = REG_READ(map->cntr); |
1173 | crtc_state->savePIPECONF = REG_READ(pipeA ? PIPEACONF : PIPEBCONF); | 1153 | crtc_state->savePIPECONF = REG_READ(map->conf); |
1174 | crtc_state->savePIPESRC = REG_READ(pipeA ? PIPEASRC : PIPEBSRC); | 1154 | crtc_state->savePIPESRC = REG_READ(map->src); |
1175 | crtc_state->saveFP0 = REG_READ(pipeA ? FPA0 : FPB0); | 1155 | crtc_state->saveFP0 = REG_READ(map->fp0); |
1176 | crtc_state->saveFP1 = REG_READ(pipeA ? FPA1 : FPB1); | 1156 | crtc_state->saveFP1 = REG_READ(map->fp1); |
1177 | crtc_state->saveDPLL = REG_READ(pipeA ? DPLL_A : DPLL_B); | 1157 | crtc_state->saveDPLL = REG_READ(map->dpll); |
1178 | crtc_state->saveHTOTAL = REG_READ(pipeA ? HTOTAL_A : HTOTAL_B); | 1158 | crtc_state->saveHTOTAL = REG_READ(map->htotal); |
1179 | crtc_state->saveHBLANK = REG_READ(pipeA ? HBLANK_A : HBLANK_B); | 1159 | crtc_state->saveHBLANK = REG_READ(map->hblank); |
1180 | crtc_state->saveHSYNC = REG_READ(pipeA ? HSYNC_A : HSYNC_B); | 1160 | crtc_state->saveHSYNC = REG_READ(map->hsync); |
1181 | crtc_state->saveVTOTAL = REG_READ(pipeA ? VTOTAL_A : VTOTAL_B); | 1161 | crtc_state->saveVTOTAL = REG_READ(map->vtotal); |
1182 | crtc_state->saveVBLANK = REG_READ(pipeA ? VBLANK_A : VBLANK_B); | 1162 | crtc_state->saveVBLANK = REG_READ(map->vblank); |
1183 | crtc_state->saveVSYNC = REG_READ(pipeA ? VSYNC_A : VSYNC_B); | 1163 | crtc_state->saveVSYNC = REG_READ(map->vsync); |
1184 | crtc_state->saveDSPSTRIDE = REG_READ(pipeA ? DSPASTRIDE : DSPBSTRIDE); | 1164 | crtc_state->saveDSPSTRIDE = REG_READ(map->stride); |
1185 | 1165 | ||
1186 | /*NOTE: DSPSIZE DSPPOS only for psb*/ | 1166 | /*NOTE: DSPSIZE DSPPOS only for psb*/ |
1187 | crtc_state->saveDSPSIZE = REG_READ(pipeA ? DSPASIZE : DSPBSIZE); | 1167 | crtc_state->saveDSPSIZE = REG_READ(map->size); |
1188 | crtc_state->saveDSPPOS = REG_READ(pipeA ? DSPAPOS : DSPBPOS); | 1168 | crtc_state->saveDSPPOS = REG_READ(map->pos); |
1189 | 1169 | ||
1190 | crtc_state->saveDSPBASE = REG_READ(pipeA ? DSPABASE : DSPBBASE); | 1170 | crtc_state->saveDSPBASE = REG_READ(map->base); |
1191 | 1171 | ||
1192 | DRM_DEBUG("(%x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x)\n", | 1172 | DRM_DEBUG("(%x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x)\n", |
1193 | crtc_state->saveDSPCNTR, | 1173 | crtc_state->saveDSPCNTR, |
@@ -1208,7 +1188,7 @@ static void cdv_intel_crtc_save(struct drm_crtc *crtc) | |||
1208 | crtc_state->saveDSPBASE | 1188 | crtc_state->saveDSPBASE |
1209 | ); | 1189 | ); |
1210 | 1190 | ||
1211 | paletteReg = pipeA ? PALETTE_A : PALETTE_B; | 1191 | paletteReg = map->palette; |
1212 | for (i = 0; i < 256; ++i) | 1192 | for (i = 0; i < 256; ++i) |
1213 | crtc_state->savePalette[i] = REG_READ(paletteReg + (i << 2)); | 1193 | crtc_state->savePalette[i] = REG_READ(paletteReg + (i << 2)); |
1214 | } | 1194 | } |
@@ -1219,12 +1199,10 @@ static void cdv_intel_crtc_save(struct drm_crtc *crtc) | |||
1219 | static void cdv_intel_crtc_restore(struct drm_crtc *crtc) | 1199 | static void cdv_intel_crtc_restore(struct drm_crtc *crtc) |
1220 | { | 1200 | { |
1221 | struct drm_device *dev = crtc->dev; | 1201 | struct drm_device *dev = crtc->dev; |
1222 | /* struct drm_psb_private * dev_priv = | 1202 | struct drm_psb_private *dev_priv = dev->dev_private; |
1223 | (struct drm_psb_private *)dev->dev_private; */ | ||
1224 | struct psb_intel_crtc *psb_intel_crtc = to_psb_intel_crtc(crtc); | 1203 | struct psb_intel_crtc *psb_intel_crtc = to_psb_intel_crtc(crtc); |
1225 | struct psb_intel_crtc_state *crtc_state = psb_intel_crtc->crtc_state; | 1204 | struct psb_intel_crtc_state *crtc_state = psb_intel_crtc->crtc_state; |
1226 | /* struct drm_crtc_helper_funcs * crtc_funcs = crtc->helper_private; */ | 1205 | const struct psb_offset *map = &dev_priv->regmap[psb_intel_crtc->pipe]; |
1227 | int pipeA = (psb_intel_crtc->pipe == 0); | ||
1228 | uint32_t paletteReg; | 1206 | uint32_t paletteReg; |
1229 | int i; | 1207 | int i; |
1230 | 1208 | ||
@@ -1235,23 +1213,23 @@ static void cdv_intel_crtc_restore(struct drm_crtc *crtc) | |||
1235 | 1213 | ||
1236 | DRM_DEBUG( | 1214 | DRM_DEBUG( |
1237 | "current:(%x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x)\n", | 1215 | "current:(%x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x)\n", |
1238 | REG_READ(pipeA ? DSPACNTR : DSPBCNTR), | 1216 | REG_READ(map->cntr), |
1239 | REG_READ(pipeA ? PIPEACONF : PIPEBCONF), | 1217 | REG_READ(map->conf), |
1240 | REG_READ(pipeA ? PIPEASRC : PIPEBSRC), | 1218 | REG_READ(map->src), |
1241 | REG_READ(pipeA ? FPA0 : FPB0), | 1219 | REG_READ(map->fp0), |
1242 | REG_READ(pipeA ? FPA1 : FPB1), | 1220 | REG_READ(map->fp1), |
1243 | REG_READ(pipeA ? DPLL_A : DPLL_B), | 1221 | REG_READ(map->dpll), |
1244 | REG_READ(pipeA ? HTOTAL_A : HTOTAL_B), | 1222 | REG_READ(map->htotal), |
1245 | REG_READ(pipeA ? HBLANK_A : HBLANK_B), | 1223 | REG_READ(map->hblank), |
1246 | REG_READ(pipeA ? HSYNC_A : HSYNC_B), | 1224 | REG_READ(map->hsync), |
1247 | REG_READ(pipeA ? VTOTAL_A : VTOTAL_B), | 1225 | REG_READ(map->vtotal), |
1248 | REG_READ(pipeA ? VBLANK_A : VBLANK_B), | 1226 | REG_READ(map->vblank), |
1249 | REG_READ(pipeA ? VSYNC_A : VSYNC_B), | 1227 | REG_READ(map->vsync), |
1250 | REG_READ(pipeA ? DSPASTRIDE : DSPBSTRIDE), | 1228 | REG_READ(map->stride), |
1251 | REG_READ(pipeA ? DSPASIZE : DSPBSIZE), | 1229 | REG_READ(map->size), |
1252 | REG_READ(pipeA ? DSPAPOS : DSPBPOS), | 1230 | REG_READ(map->pos), |
1253 | REG_READ(pipeA ? DSPABASE : DSPBBASE) | 1231 | REG_READ(map->base) |
1254 | ); | 1232 | ); |
1255 | 1233 | ||
1256 | DRM_DEBUG( | 1234 | DRM_DEBUG( |
1257 | "saved: (%x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x)\n", | 1235 | "saved: (%x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x)\n", |
@@ -1271,51 +1249,51 @@ static void cdv_intel_crtc_restore(struct drm_crtc *crtc) | |||
1271 | crtc_state->saveDSPSIZE, | 1249 | crtc_state->saveDSPSIZE, |
1272 | crtc_state->saveDSPPOS, | 1250 | crtc_state->saveDSPPOS, |
1273 | crtc_state->saveDSPBASE | 1251 | crtc_state->saveDSPBASE |
1274 | ); | 1252 | ); |
1275 | 1253 | ||
1276 | 1254 | ||
1277 | if (crtc_state->saveDPLL & DPLL_VCO_ENABLE) { | 1255 | if (crtc_state->saveDPLL & DPLL_VCO_ENABLE) { |
1278 | REG_WRITE(pipeA ? DPLL_A : DPLL_B, | 1256 | REG_WRITE(map->dpll, |
1279 | crtc_state->saveDPLL & ~DPLL_VCO_ENABLE); | 1257 | crtc_state->saveDPLL & ~DPLL_VCO_ENABLE); |
1280 | REG_READ(pipeA ? DPLL_A : DPLL_B); | 1258 | REG_READ(map->dpll); |
1281 | DRM_DEBUG("write dpll: %x\n", | 1259 | DRM_DEBUG("write dpll: %x\n", |
1282 | REG_READ(pipeA ? DPLL_A : DPLL_B)); | 1260 | REG_READ(map->dpll)); |
1283 | udelay(150); | 1261 | udelay(150); |
1284 | } | 1262 | } |
1285 | 1263 | ||
1286 | REG_WRITE(pipeA ? FPA0 : FPB0, crtc_state->saveFP0); | 1264 | REG_WRITE(map->fp0, crtc_state->saveFP0); |
1287 | REG_READ(pipeA ? FPA0 : FPB0); | 1265 | REG_READ(map->fp0); |
1288 | 1266 | ||
1289 | REG_WRITE(pipeA ? FPA1 : FPB1, crtc_state->saveFP1); | 1267 | REG_WRITE(map->fp1, crtc_state->saveFP1); |
1290 | REG_READ(pipeA ? FPA1 : FPB1); | 1268 | REG_READ(map->fp1); |
1291 | 1269 | ||
1292 | REG_WRITE(pipeA ? DPLL_A : DPLL_B, crtc_state->saveDPLL); | 1270 | REG_WRITE(map->dpll, crtc_state->saveDPLL); |
1293 | REG_READ(pipeA ? DPLL_A : DPLL_B); | 1271 | REG_READ(map->dpll); |
1294 | udelay(150); | 1272 | udelay(150); |
1295 | 1273 | ||
1296 | REG_WRITE(pipeA ? HTOTAL_A : HTOTAL_B, crtc_state->saveHTOTAL); | 1274 | REG_WRITE(map->htotal, crtc_state->saveHTOTAL); |
1297 | REG_WRITE(pipeA ? HBLANK_A : HBLANK_B, crtc_state->saveHBLANK); | 1275 | REG_WRITE(map->hblank, crtc_state->saveHBLANK); |
1298 | REG_WRITE(pipeA ? HSYNC_A : HSYNC_B, crtc_state->saveHSYNC); | 1276 | REG_WRITE(map->hsync, crtc_state->saveHSYNC); |
1299 | REG_WRITE(pipeA ? VTOTAL_A : VTOTAL_B, crtc_state->saveVTOTAL); | 1277 | REG_WRITE(map->vtotal, crtc_state->saveVTOTAL); |
1300 | REG_WRITE(pipeA ? VBLANK_A : VBLANK_B, crtc_state->saveVBLANK); | 1278 | REG_WRITE(map->vblank, crtc_state->saveVBLANK); |
1301 | REG_WRITE(pipeA ? VSYNC_A : VSYNC_B, crtc_state->saveVSYNC); | 1279 | REG_WRITE(map->vsync, crtc_state->saveVSYNC); |
1302 | REG_WRITE(pipeA ? DSPASTRIDE : DSPBSTRIDE, crtc_state->saveDSPSTRIDE); | 1280 | REG_WRITE(map->stride, crtc_state->saveDSPSTRIDE); |
1303 | 1281 | ||
1304 | REG_WRITE(pipeA ? DSPASIZE : DSPBSIZE, crtc_state->saveDSPSIZE); | 1282 | REG_WRITE(map->size, crtc_state->saveDSPSIZE); |
1305 | REG_WRITE(pipeA ? DSPAPOS : DSPBPOS, crtc_state->saveDSPPOS); | 1283 | REG_WRITE(map->pos, crtc_state->saveDSPPOS); |
1306 | 1284 | ||
1307 | REG_WRITE(pipeA ? PIPEASRC : PIPEBSRC, crtc_state->savePIPESRC); | 1285 | REG_WRITE(map->src, crtc_state->savePIPESRC); |
1308 | REG_WRITE(pipeA ? DSPABASE : DSPBBASE, crtc_state->saveDSPBASE); | 1286 | REG_WRITE(map->base, crtc_state->saveDSPBASE); |
1309 | REG_WRITE(pipeA ? PIPEACONF : PIPEBCONF, crtc_state->savePIPECONF); | 1287 | REG_WRITE(map->conf, crtc_state->savePIPECONF); |
1310 | 1288 | ||
1311 | cdv_intel_wait_for_vblank(dev); | 1289 | cdv_intel_wait_for_vblank(dev); |
1312 | 1290 | ||
1313 | REG_WRITE(pipeA ? DSPACNTR : DSPBCNTR, crtc_state->saveDSPCNTR); | 1291 | REG_WRITE(map->cntr, crtc_state->saveDSPCNTR); |
1314 | REG_WRITE(pipeA ? DSPABASE : DSPBBASE, crtc_state->saveDSPBASE); | 1292 | REG_WRITE(map->base, crtc_state->saveDSPBASE); |
1315 | 1293 | ||
1316 | cdv_intel_wait_for_vblank(dev); | 1294 | cdv_intel_wait_for_vblank(dev); |
1317 | 1295 | ||
1318 | paletteReg = pipeA ? PALETTE_A : PALETTE_B; | 1296 | paletteReg = map->palette; |
1319 | for (i = 0; i < 256; ++i) | 1297 | for (i = 0; i < 256; ++i) |
1320 | REG_WRITE(paletteReg + (i << 2), crtc_state->savePalette[i]); | 1298 | REG_WRITE(paletteReg + (i << 2), crtc_state->savePalette[i]); |
1321 | } | 1299 | } |
@@ -1490,21 +1468,22 @@ static void i8xx_clock(int refclk, struct cdv_intel_clock_t *clock) | |||
1490 | static int cdv_intel_crtc_clock_get(struct drm_device *dev, | 1468 | static int cdv_intel_crtc_clock_get(struct drm_device *dev, |
1491 | struct drm_crtc *crtc) | 1469 | struct drm_crtc *crtc) |
1492 | { | 1470 | { |
1471 | struct drm_psb_private *dev_priv = dev->dev_private; | ||
1493 | struct psb_intel_crtc *psb_intel_crtc = to_psb_intel_crtc(crtc); | 1472 | struct psb_intel_crtc *psb_intel_crtc = to_psb_intel_crtc(crtc); |
1494 | int pipe = psb_intel_crtc->pipe; | 1473 | int pipe = psb_intel_crtc->pipe; |
1474 | const struct psb_offset *map = &dev_priv->regmap[pipe]; | ||
1495 | u32 dpll; | 1475 | u32 dpll; |
1496 | u32 fp; | 1476 | u32 fp; |
1497 | struct cdv_intel_clock_t clock; | 1477 | struct cdv_intel_clock_t clock; |
1498 | bool is_lvds; | 1478 | bool is_lvds; |
1499 | struct drm_psb_private *dev_priv = dev->dev_private; | ||
1500 | struct psb_pipe *p = &dev_priv->regs.pipe[pipe]; | 1479 | struct psb_pipe *p = &dev_priv->regs.pipe[pipe]; |
1501 | 1480 | ||
1502 | if (gma_power_begin(dev, false)) { | 1481 | if (gma_power_begin(dev, false)) { |
1503 | dpll = REG_READ((pipe == 0) ? DPLL_A : DPLL_B); | 1482 | dpll = REG_READ(map->dpll); |
1504 | if ((dpll & DISPLAY_RATE_SELECT_FPA1) == 0) | 1483 | if ((dpll & DISPLAY_RATE_SELECT_FPA1) == 0) |
1505 | fp = REG_READ((pipe == 0) ? FPA0 : FPB0); | 1484 | fp = REG_READ(map->fp0); |
1506 | else | 1485 | else |
1507 | fp = REG_READ((pipe == 0) ? FPA1 : FPB1); | 1486 | fp = REG_READ(map->fp1); |
1508 | is_lvds = (pipe == 1) && (REG_READ(LVDS) & LVDS_PORT_EN); | 1487 | is_lvds = (pipe == 1) && (REG_READ(LVDS) & LVDS_PORT_EN); |
1509 | gma_power_end(dev); | 1488 | gma_power_end(dev); |
1510 | } else { | 1489 | } else { |
@@ -1570,19 +1549,20 @@ struct drm_display_mode *cdv_intel_crtc_mode_get(struct drm_device *dev, | |||
1570 | { | 1549 | { |
1571 | struct psb_intel_crtc *psb_intel_crtc = to_psb_intel_crtc(crtc); | 1550 | struct psb_intel_crtc *psb_intel_crtc = to_psb_intel_crtc(crtc); |
1572 | int pipe = psb_intel_crtc->pipe; | 1551 | int pipe = psb_intel_crtc->pipe; |
1552 | struct drm_psb_private *dev_priv = dev->dev_private; | ||
1553 | struct psb_pipe *p = &dev_priv->regs.pipe[pipe]; | ||
1554 | const struct psb_offset *map = &dev_priv->regmap[pipe]; | ||
1573 | struct drm_display_mode *mode; | 1555 | struct drm_display_mode *mode; |
1574 | int htot; | 1556 | int htot; |
1575 | int hsync; | 1557 | int hsync; |
1576 | int vtot; | 1558 | int vtot; |
1577 | int vsync; | 1559 | int vsync; |
1578 | struct drm_psb_private *dev_priv = dev->dev_private; | ||
1579 | struct psb_pipe *p = &dev_priv->regs.pipe[pipe]; | ||
1580 | 1560 | ||
1581 | if (gma_power_begin(dev, false)) { | 1561 | if (gma_power_begin(dev, false)) { |
1582 | htot = REG_READ((pipe == 0) ? HTOTAL_A : HTOTAL_B); | 1562 | htot = REG_READ(map->htotal); |
1583 | hsync = REG_READ((pipe == 0) ? HSYNC_A : HSYNC_B); | 1563 | hsync = REG_READ(map->hsync); |
1584 | vtot = REG_READ((pipe == 0) ? VTOTAL_A : VTOTAL_B); | 1564 | vtot = REG_READ(map->vtotal); |
1585 | vsync = REG_READ((pipe == 0) ? VSYNC_A : VSYNC_B); | 1565 | vsync = REG_READ(map->vsync); |
1586 | gma_power_end(dev); | 1566 | gma_power_end(dev); |
1587 | } else { | 1567 | } else { |
1588 | htot = p->htotal; | 1568 | htot = p->htotal; |
diff --git a/drivers/gpu/drm/gma500/mdfld_device.c b/drivers/gpu/drm/gma500/mdfld_device.c index 000d316c6afd..393a0e15d5de 100644 --- a/drivers/gpu/drm/gma500/mdfld_device.c +++ b/drivers/gpu/drm/gma500/mdfld_device.c | |||
@@ -168,30 +168,12 @@ static int mdfld_save_display_registers(struct drm_device *dev, int pipenum) | |||
168 | struct drm_psb_private *dev_priv = dev->dev_private; | 168 | struct drm_psb_private *dev_priv = dev->dev_private; |
169 | struct medfield_state *regs = &dev_priv->regs.mdfld; | 169 | struct medfield_state *regs = &dev_priv->regs.mdfld; |
170 | struct psb_pipe *pipe = &dev_priv->regs.pipe[pipenum]; | 170 | struct psb_pipe *pipe = &dev_priv->regs.pipe[pipenum]; |
171 | const struct psb_offset *map = &dev_priv->regmap[pipenum]; | ||
171 | int i; | 172 | int i; |
172 | u32 *mipi_val; | 173 | u32 *mipi_val; |
173 | 174 | ||
174 | /* register */ | 175 | /* register */ |
175 | u32 dpll_reg = MRST_DPLL_A; | ||
176 | u32 fp_reg = MRST_FPA0; | ||
177 | u32 pipeconf_reg = PIPEACONF; | ||
178 | u32 htot_reg = HTOTAL_A; | ||
179 | u32 hblank_reg = HBLANK_A; | ||
180 | u32 hsync_reg = HSYNC_A; | ||
181 | u32 vtot_reg = VTOTAL_A; | ||
182 | u32 vblank_reg = VBLANK_A; | ||
183 | u32 vsync_reg = VSYNC_A; | ||
184 | u32 pipesrc_reg = PIPEASRC; | ||
185 | u32 dspstride_reg = DSPASTRIDE; | ||
186 | u32 dsplinoff_reg = DSPALINOFF; | ||
187 | u32 dsptileoff_reg = DSPATILEOFF; | ||
188 | u32 dspsize_reg = DSPASIZE; | ||
189 | u32 dsppos_reg = DSPAPOS; | ||
190 | u32 dspsurf_reg = DSPASURF; | ||
191 | u32 mipi_reg = MIPI; | 176 | u32 mipi_reg = MIPI; |
192 | u32 dspcntr_reg = DSPACNTR; | ||
193 | u32 dspstatus_reg = PIPEASTAT; | ||
194 | u32 palette_reg = PALETTE_A; | ||
195 | 177 | ||
196 | switch (pipenum) { | 178 | switch (pipenum) { |
197 | case 0: | 179 | case 0: |
@@ -199,48 +181,10 @@ static int mdfld_save_display_registers(struct drm_device *dev, int pipenum) | |||
199 | break; | 181 | break; |
200 | case 1: | 182 | case 1: |
201 | mipi_val = ®s->saveMIPI; | 183 | mipi_val = ®s->saveMIPI; |
202 | /* register */ | ||
203 | dpll_reg = MDFLD_DPLL_B; | ||
204 | fp_reg = MDFLD_DPLL_DIV0; | ||
205 | pipeconf_reg = PIPEBCONF; | ||
206 | htot_reg = HTOTAL_B; | ||
207 | hblank_reg = HBLANK_B; | ||
208 | hsync_reg = HSYNC_B; | ||
209 | vtot_reg = VTOTAL_B; | ||
210 | vblank_reg = VBLANK_B; | ||
211 | vsync_reg = VSYNC_B; | ||
212 | pipesrc_reg = PIPEBSRC; | ||
213 | dspstride_reg = DSPBSTRIDE; | ||
214 | dsplinoff_reg = DSPBLINOFF; | ||
215 | dsptileoff_reg = DSPBTILEOFF; | ||
216 | dspsize_reg = DSPBSIZE; | ||
217 | dsppos_reg = DSPBPOS; | ||
218 | dspsurf_reg = DSPBSURF; | ||
219 | dspcntr_reg = DSPBCNTR; | ||
220 | dspstatus_reg = PIPEBSTAT; | ||
221 | palette_reg = PALETTE_B; | ||
222 | break; | 184 | break; |
223 | case 2: | 185 | case 2: |
224 | /* register */ | 186 | /* register */ |
225 | pipeconf_reg = PIPECCONF; | ||
226 | htot_reg = HTOTAL_C; | ||
227 | hblank_reg = HBLANK_C; | ||
228 | hsync_reg = HSYNC_C; | ||
229 | vtot_reg = VTOTAL_C; | ||
230 | vblank_reg = VBLANK_C; | ||
231 | vsync_reg = VSYNC_C; | ||
232 | pipesrc_reg = PIPECSRC; | ||
233 | dspstride_reg = DSPCSTRIDE; | ||
234 | dsplinoff_reg = DSPCLINOFF; | ||
235 | dsptileoff_reg = DSPCTILEOFF; | ||
236 | dspsize_reg = DSPCSIZE; | ||
237 | dsppos_reg = DSPCPOS; | ||
238 | dspsurf_reg = DSPCSURF; | ||
239 | mipi_reg = MIPI_C; | 187 | mipi_reg = MIPI_C; |
240 | dspcntr_reg = DSPCCNTR; | ||
241 | dspstatus_reg = PIPECSTAT; | ||
242 | palette_reg = PALETTE_C; | ||
243 | |||
244 | /* pointer to values */ | 188 | /* pointer to values */ |
245 | mipi_val = ®s->saveMIPI_C; | 189 | mipi_val = ®s->saveMIPI_C; |
246 | break; | 190 | break; |
@@ -250,28 +194,28 @@ static int mdfld_save_display_registers(struct drm_device *dev, int pipenum) | |||
250 | } | 194 | } |
251 | 195 | ||
252 | /* Pipe & plane A info */ | 196 | /* Pipe & plane A info */ |
253 | pipe->dpll = PSB_RVDC32(dpll_reg); | 197 | pipe->dpll = PSB_RVDC32(map->dpll); |
254 | pipe->fp0 = PSB_RVDC32(fp_reg); | 198 | pipe->fp0 = PSB_RVDC32(map->fp0); |
255 | pipe->conf = PSB_RVDC32(pipeconf_reg); | 199 | pipe->conf = PSB_RVDC32(map->conf); |
256 | pipe->htotal = PSB_RVDC32(htot_reg); | 200 | pipe->htotal = PSB_RVDC32(map->htotal); |
257 | pipe->hblank = PSB_RVDC32(hblank_reg); | 201 | pipe->hblank = PSB_RVDC32(map->hblank); |
258 | pipe->hsync = PSB_RVDC32(hsync_reg); | 202 | pipe->hsync = PSB_RVDC32(map->hsync); |
259 | pipe->vtotal = PSB_RVDC32(vtot_reg); | 203 | pipe->vtotal = PSB_RVDC32(map->vtotal); |
260 | pipe->vblank = PSB_RVDC32(vblank_reg); | 204 | pipe->vblank = PSB_RVDC32(map->vblank); |
261 | pipe->vsync = PSB_RVDC32(vsync_reg); | 205 | pipe->vsync = PSB_RVDC32(map->vsync); |
262 | pipe->src = PSB_RVDC32(pipesrc_reg); | 206 | pipe->src = PSB_RVDC32(map->src); |
263 | pipe->stride = PSB_RVDC32(dspstride_reg); | 207 | pipe->stride = PSB_RVDC32(map->stride); |
264 | pipe->linoff = PSB_RVDC32(dsplinoff_reg); | 208 | pipe->linoff = PSB_RVDC32(map->linoff); |
265 | pipe->tileoff = PSB_RVDC32(dsptileoff_reg); | 209 | pipe->tileoff = PSB_RVDC32(map->tileoff); |
266 | pipe->size = PSB_RVDC32(dspsize_reg); | 210 | pipe->size = PSB_RVDC32(map->size); |
267 | pipe->pos = PSB_RVDC32(dsppos_reg); | 211 | pipe->pos = PSB_RVDC32(map->pos); |
268 | pipe->surf = PSB_RVDC32(dspsurf_reg); | 212 | pipe->surf = PSB_RVDC32(map->surf); |
269 | pipe->cntr = PSB_RVDC32(dspcntr_reg); | 213 | pipe->cntr = PSB_RVDC32(map->cntr); |
270 | pipe->status = PSB_RVDC32(dspstatus_reg); | 214 | pipe->status = PSB_RVDC32(map->status); |
271 | 215 | ||
272 | /*save palette (gamma) */ | 216 | /*save palette (gamma) */ |
273 | for (i = 0; i < 256; i++) | 217 | for (i = 0; i < 256; i++) |
274 | pipe->palette[i] = PSB_RVDC32(palette_reg + (i << 2)); | 218 | pipe->palette[i] = PSB_RVDC32(map->palette + (i << 2)); |
275 | 219 | ||
276 | if (pipenum == 1) { | 220 | if (pipenum == 1) { |
277 | regs->savePFIT_CONTROL = PSB_RVDC32(PFIT_CONTROL); | 221 | regs->savePFIT_CONTROL = PSB_RVDC32(PFIT_CONTROL); |
@@ -302,31 +246,13 @@ static int mdfld_restore_display_registers(struct drm_device *dev, int pipenum) | |||
302 | struct mdfld_dsi_config *dsi_config = NULL; | 246 | struct mdfld_dsi_config *dsi_config = NULL; |
303 | struct medfield_state *regs = &dev_priv->regs.mdfld; | 247 | struct medfield_state *regs = &dev_priv->regs.mdfld; |
304 | struct psb_pipe *pipe = &dev_priv->regs.pipe[pipenum]; | 248 | struct psb_pipe *pipe = &dev_priv->regs.pipe[pipenum]; |
249 | const struct psb_offset *map = &dev_priv->regmap[pipenum]; | ||
305 | u32 i; | 250 | u32 i; |
306 | u32 dpll; | 251 | u32 dpll; |
307 | u32 timeout = 0; | 252 | u32 timeout = 0; |
308 | 253 | ||
309 | /* register */ | 254 | /* register */ |
310 | u32 dpll_reg = MRST_DPLL_A; | ||
311 | u32 fp_reg = MRST_FPA0; | ||
312 | u32 pipeconf_reg = PIPEACONF; | ||
313 | u32 htot_reg = HTOTAL_A; | ||
314 | u32 hblank_reg = HBLANK_A; | ||
315 | u32 hsync_reg = HSYNC_A; | ||
316 | u32 vtot_reg = VTOTAL_A; | ||
317 | u32 vblank_reg = VBLANK_A; | ||
318 | u32 vsync_reg = VSYNC_A; | ||
319 | u32 pipesrc_reg = PIPEASRC; | ||
320 | u32 dspstride_reg = DSPASTRIDE; | ||
321 | u32 dsplinoff_reg = DSPALINOFF; | ||
322 | u32 dsptileoff_reg = DSPATILEOFF; | ||
323 | u32 dspsize_reg = DSPASIZE; | ||
324 | u32 dsppos_reg = DSPAPOS; | ||
325 | u32 dspsurf_reg = DSPASURF; | ||
326 | u32 dspstatus_reg = PIPEASTAT; | ||
327 | u32 mipi_reg = MIPI; | 255 | u32 mipi_reg = MIPI; |
328 | u32 dspcntr_reg = DSPACNTR; | ||
329 | u32 palette_reg = PALETTE_A; | ||
330 | 256 | ||
331 | /* values */ | 257 | /* values */ |
332 | u32 dpll_val = pipe->dpll; | 258 | u32 dpll_val = pipe->dpll; |
@@ -338,52 +264,10 @@ static int mdfld_restore_display_registers(struct drm_device *dev, int pipenum) | |||
338 | dsi_config = dev_priv->dsi_configs[0]; | 264 | dsi_config = dev_priv->dsi_configs[0]; |
339 | break; | 265 | break; |
340 | case 1: | 266 | case 1: |
341 | /* register */ | ||
342 | dpll_reg = MDFLD_DPLL_B; | ||
343 | fp_reg = MDFLD_DPLL_DIV0; | ||
344 | pipeconf_reg = PIPEBCONF; | ||
345 | htot_reg = HTOTAL_B; | ||
346 | hblank_reg = HBLANK_B; | ||
347 | hsync_reg = HSYNC_B; | ||
348 | vtot_reg = VTOTAL_B; | ||
349 | vblank_reg = VBLANK_B; | ||
350 | vsync_reg = VSYNC_B; | ||
351 | pipesrc_reg = PIPEBSRC; | ||
352 | dspstride_reg = DSPBSTRIDE; | ||
353 | dsplinoff_reg = DSPBLINOFF; | ||
354 | dsptileoff_reg = DSPBTILEOFF; | ||
355 | dspsize_reg = DSPBSIZE; | ||
356 | dsppos_reg = DSPBPOS; | ||
357 | dspsurf_reg = DSPBSURF; | ||
358 | dspcntr_reg = DSPBCNTR; | ||
359 | dspstatus_reg = PIPEBSTAT; | ||
360 | palette_reg = PALETTE_B; | ||
361 | |||
362 | /* values */ | ||
363 | dpll_val &= ~DPLL_VCO_ENABLE; | 267 | dpll_val &= ~DPLL_VCO_ENABLE; |
364 | break; | 268 | break; |
365 | case 2: | 269 | case 2: |
366 | /* register */ | ||
367 | pipeconf_reg = PIPECCONF; | ||
368 | htot_reg = HTOTAL_C; | ||
369 | hblank_reg = HBLANK_C; | ||
370 | hsync_reg = HSYNC_C; | ||
371 | vtot_reg = VTOTAL_C; | ||
372 | vblank_reg = VBLANK_C; | ||
373 | vsync_reg = VSYNC_C; | ||
374 | pipesrc_reg = PIPECSRC; | ||
375 | dspstride_reg = DSPCSTRIDE; | ||
376 | dsplinoff_reg = DSPCLINOFF; | ||
377 | dsptileoff_reg = DSPCTILEOFF; | ||
378 | dspsize_reg = DSPCSIZE; | ||
379 | dsppos_reg = DSPCPOS; | ||
380 | dspsurf_reg = DSPCSURF; | ||
381 | mipi_reg = MIPI_C; | 270 | mipi_reg = MIPI_C; |
382 | dspcntr_reg = DSPCCNTR; | ||
383 | dspstatus_reg = PIPECSTAT; | ||
384 | palette_reg = PALETTE_C; | ||
385 | |||
386 | /* values */ | ||
387 | mipi_val = regs->saveMIPI_C; | 271 | mipi_val = regs->saveMIPI_C; |
388 | dsi_config = dev_priv->dsi_configs[1]; | 272 | dsi_config = dev_priv->dsi_configs[1]; |
389 | break; | 273 | break; |
@@ -396,13 +280,13 @@ static int mdfld_restore_display_registers(struct drm_device *dev, int pipenum) | |||
396 | PSB_WVDC32(0x80000000, VGACNTRL); | 280 | PSB_WVDC32(0x80000000, VGACNTRL); |
397 | 281 | ||
398 | if (pipenum == 1) { | 282 | if (pipenum == 1) { |
399 | PSB_WVDC32(dpll_val & ~DPLL_VCO_ENABLE, dpll_reg); | 283 | PSB_WVDC32(dpll_val & ~DPLL_VCO_ENABLE, map->dpll); |
400 | PSB_RVDC32(dpll_reg); | 284 | PSB_RVDC32(map->dpll); |
401 | 285 | ||
402 | PSB_WVDC32(pipe->fp0, fp_reg); | 286 | PSB_WVDC32(pipe->fp0, map->fp0); |
403 | } else { | 287 | } else { |
404 | 288 | ||
405 | dpll = PSB_RVDC32(dpll_reg); | 289 | dpll = PSB_RVDC32(map->dpll); |
406 | 290 | ||
407 | if (!(dpll & DPLL_VCO_ENABLE)) { | 291 | if (!(dpll & DPLL_VCO_ENABLE)) { |
408 | 292 | ||
@@ -410,23 +294,23 @@ static int mdfld_restore_display_registers(struct drm_device *dev, int pipenum) | |||
410 | before enable the VCO */ | 294 | before enable the VCO */ |
411 | if (dpll & MDFLD_PWR_GATE_EN) { | 295 | if (dpll & MDFLD_PWR_GATE_EN) { |
412 | dpll &= ~MDFLD_PWR_GATE_EN; | 296 | dpll &= ~MDFLD_PWR_GATE_EN; |
413 | PSB_WVDC32(dpll, dpll_reg); | 297 | PSB_WVDC32(dpll, map->dpll); |
414 | /* FIXME_MDFLD PO - change 500 to 1 after PO */ | 298 | /* FIXME_MDFLD PO - change 500 to 1 after PO */ |
415 | udelay(500); | 299 | udelay(500); |
416 | } | 300 | } |
417 | 301 | ||
418 | PSB_WVDC32(pipe->fp0, fp_reg); | 302 | PSB_WVDC32(pipe->fp0, map->fp0); |
419 | PSB_WVDC32(dpll_val, dpll_reg); | 303 | PSB_WVDC32(dpll_val, map->dpll); |
420 | /* FIXME_MDFLD PO - change 500 to 1 after PO */ | 304 | /* FIXME_MDFLD PO - change 500 to 1 after PO */ |
421 | udelay(500); | 305 | udelay(500); |
422 | 306 | ||
423 | dpll_val |= DPLL_VCO_ENABLE; | 307 | dpll_val |= DPLL_VCO_ENABLE; |
424 | PSB_WVDC32(dpll_val, dpll_reg); | 308 | PSB_WVDC32(dpll_val, map->dpll); |
425 | PSB_RVDC32(dpll_reg); | 309 | PSB_RVDC32(map->dpll); |
426 | 310 | ||
427 | /* wait for DSI PLL to lock */ | 311 | /* wait for DSI PLL to lock */ |
428 | while (timeout < 20000 && | 312 | while (timeout < 20000 && |
429 | !(PSB_RVDC32(pipeconf_reg) & PIPECONF_DSIPLL_LOCK)) { | 313 | !(PSB_RVDC32(map->conf) & PIPECONF_DSIPLL_LOCK)) { |
430 | udelay(150); | 314 | udelay(150); |
431 | timeout++; | 315 | timeout++; |
432 | } | 316 | } |
@@ -439,28 +323,28 @@ static int mdfld_restore_display_registers(struct drm_device *dev, int pipenum) | |||
439 | } | 323 | } |
440 | } | 324 | } |
441 | /* Restore mode */ | 325 | /* Restore mode */ |
442 | PSB_WVDC32(pipe->htotal, htot_reg); | 326 | PSB_WVDC32(pipe->htotal, map->htotal); |
443 | PSB_WVDC32(pipe->hblank, hblank_reg); | 327 | PSB_WVDC32(pipe->hblank, map->hblank); |
444 | PSB_WVDC32(pipe->hsync, hsync_reg); | 328 | PSB_WVDC32(pipe->hsync, map->hsync); |
445 | PSB_WVDC32(pipe->vtotal, vtot_reg); | 329 | PSB_WVDC32(pipe->vtotal, map->vtotal); |
446 | PSB_WVDC32(pipe->vblank, vblank_reg); | 330 | PSB_WVDC32(pipe->vblank, map->vblank); |
447 | PSB_WVDC32(pipe->vsync, vsync_reg); | 331 | PSB_WVDC32(pipe->vsync, map->vsync); |
448 | PSB_WVDC32(pipe->src, pipesrc_reg); | 332 | PSB_WVDC32(pipe->src, map->src); |
449 | PSB_WVDC32(pipe->status, dspstatus_reg); | 333 | PSB_WVDC32(pipe->status, map->status); |
450 | 334 | ||
451 | /*set up the plane*/ | 335 | /*set up the plane*/ |
452 | PSB_WVDC32(pipe->stride, dspstride_reg); | 336 | PSB_WVDC32(pipe->stride, map->stride); |
453 | PSB_WVDC32(pipe->linoff, dsplinoff_reg); | 337 | PSB_WVDC32(pipe->linoff, map->linoff); |
454 | PSB_WVDC32(pipe->tileoff, dsptileoff_reg); | 338 | PSB_WVDC32(pipe->tileoff, map->tileoff); |
455 | PSB_WVDC32(pipe->size, dspsize_reg); | 339 | PSB_WVDC32(pipe->size, map->size); |
456 | PSB_WVDC32(pipe->pos, dsppos_reg); | 340 | PSB_WVDC32(pipe->pos, map->pos); |
457 | PSB_WVDC32(pipe->surf, dspsurf_reg); | 341 | PSB_WVDC32(pipe->surf, map->surf); |
458 | 342 | ||
459 | if (pipenum == 1) { | 343 | if (pipenum == 1) { |
460 | /* restore palette (gamma) */ | 344 | /* restore palette (gamma) */ |
461 | /*DRM_UDELAY(50000); */ | 345 | /*DRM_UDELAY(50000); */ |
462 | for (i = 0; i < 256; i++) | 346 | for (i = 0; i < 256; i++) |
463 | PSB_WVDC32(pipe->palette[i], palette_reg + (i << 2)); | 347 | PSB_WVDC32(pipe->palette[i], map->palette + (i << 2)); |
464 | 348 | ||
465 | PSB_WVDC32(regs->savePFIT_CONTROL, PFIT_CONTROL); | 349 | PSB_WVDC32(regs->savePFIT_CONTROL, PFIT_CONTROL); |
466 | PSB_WVDC32(regs->savePFIT_PGM_RATIOS, PFIT_PGM_RATIOS); | 350 | PSB_WVDC32(regs->savePFIT_PGM_RATIOS, PFIT_PGM_RATIOS); |
@@ -470,7 +354,7 @@ static int mdfld_restore_display_registers(struct drm_device *dev, int pipenum) | |||
470 | /*TODO: resume pipe*/ | 354 | /*TODO: resume pipe*/ |
471 | 355 | ||
472 | /*enable the plane*/ | 356 | /*enable the plane*/ |
473 | PSB_WVDC32(pipe->cntr & ~DISPLAY_PLANE_ENABLE, dspcntr_reg); | 357 | PSB_WVDC32(pipe->cntr & ~DISPLAY_PLANE_ENABLE, map->cntr); |
474 | 358 | ||
475 | return 0; | 359 | return 0; |
476 | } | 360 | } |
@@ -488,7 +372,7 @@ static int mdfld_restore_display_registers(struct drm_device *dev, int pipenum) | |||
488 | msleep(20); | 372 | msleep(20); |
489 | 373 | ||
490 | /*enable the plane*/ | 374 | /*enable the plane*/ |
491 | PSB_WVDC32(pipe->cntr, dspcntr_reg); | 375 | PSB_WVDC32(pipe->cntr, map->cntr); |
492 | 376 | ||
493 | if (in_atomic() || in_interrupt()) | 377 | if (in_atomic() || in_interrupt()) |
494 | mdelay(20); | 378 | mdelay(20); |
@@ -517,12 +401,12 @@ static int mdfld_restore_display_registers(struct drm_device *dev, int pipenum) | |||
517 | mdelay(1); | 401 | mdelay(1); |
518 | 402 | ||
519 | /*enable the pipe*/ | 403 | /*enable the pipe*/ |
520 | PSB_WVDC32(pipe->conf, pipeconf_reg); | 404 | PSB_WVDC32(pipe->conf, map->conf); |
521 | 405 | ||
522 | /* restore palette (gamma) */ | 406 | /* restore palette (gamma) */ |
523 | /*DRM_UDELAY(50000); */ | 407 | /*DRM_UDELAY(50000); */ |
524 | for (i = 0; i < 256; i++) | 408 | for (i = 0; i < 256; i++) |
525 | PSB_WVDC32(pipe->palette[i], palette_reg + (i << 2)); | 409 | PSB_WVDC32(pipe->palette[i], map->palette + (i << 2)); |
526 | 410 | ||
527 | return 0; | 411 | return 0; |
528 | } | 412 | } |
@@ -578,7 +462,7 @@ static const struct psb_offset mdfld_regmap[3] = { | |||
578 | .size = DSPASIZE, | 462 | .size = DSPASIZE, |
579 | .pos = DSPAPOS, | 463 | .pos = DSPAPOS, |
580 | .surf = DSPASURF, | 464 | .surf = DSPASURF, |
581 | .addr = DSPABASE, | 465 | .addr = MRST_DSPABASE, |
582 | .status = PIPEASTAT, | 466 | .status = PIPEASTAT, |
583 | .linoff = DSPALINOFF, | 467 | .linoff = DSPALINOFF, |
584 | .tileoff = DSPATILEOFF, | 468 | .tileoff = DSPATILEOFF, |
@@ -600,13 +484,14 @@ static const struct psb_offset mdfld_regmap[3] = { | |||
600 | .size = DSPBSIZE, | 484 | .size = DSPBSIZE, |
601 | .pos = DSPBPOS, | 485 | .pos = DSPBPOS, |
602 | .surf = DSPBSURF, | 486 | .surf = DSPBSURF, |
603 | .addr = DSPBBASE, | 487 | .addr = MRST_DSPBBASE, |
604 | .status = PIPEBSTAT, | 488 | .status = PIPEBSTAT, |
605 | .linoff = DSPBLINOFF, | 489 | .linoff = DSPBLINOFF, |
606 | .tileoff = DSPBTILEOFF, | 490 | .tileoff = DSPBTILEOFF, |
607 | .palette = PALETTE_B, | 491 | .palette = PALETTE_B, |
608 | }, | 492 | }, |
609 | { | 493 | { |
494 | .fp0 = MRST_FPA0, /* This is what the old code did ?? */ | ||
610 | .cntr = DSPCCNTR, | 495 | .cntr = DSPCCNTR, |
611 | .conf = PIPECCONF, | 496 | .conf = PIPECCONF, |
612 | .src = PIPECSRC, | 497 | .src = PIPECSRC, |
@@ -622,7 +507,7 @@ static const struct psb_offset mdfld_regmap[3] = { | |||
622 | .size = DSPBSIZE, | 507 | .size = DSPBSIZE, |
623 | .pos = DSPCPOS, | 508 | .pos = DSPCPOS, |
624 | .surf = DSPCSURF, | 509 | .surf = DSPCSURF, |
625 | .addr = DSPCBASE, | 510 | .addr = MDFLD_DSPCBASE, |
626 | .status = PIPECSTAT, | 511 | .status = PIPECSTAT, |
627 | .linoff = DSPCLINOFF, | 512 | .linoff = DSPCLINOFF, |
628 | .tileoff = DSPCTILEOFF, | 513 | .tileoff = DSPCTILEOFF, |
diff --git a/drivers/gpu/drm/gma500/mdfld_dsi_pkg_sender.c b/drivers/gpu/drm/gma500/mdfld_dsi_pkg_sender.c index baa0e14165e0..489ffd2c66e5 100644 --- a/drivers/gpu/drm/gma500/mdfld_dsi_pkg_sender.c +++ b/drivers/gpu/drm/gma500/mdfld_dsi_pkg_sender.c | |||
@@ -605,6 +605,8 @@ int mdfld_dsi_pkg_sender_init(struct mdfld_dsi_connector *dsi_connector, | |||
605 | struct mdfld_dsi_config *dsi_config = | 605 | struct mdfld_dsi_config *dsi_config = |
606 | mdfld_dsi_get_config(dsi_connector); | 606 | mdfld_dsi_get_config(dsi_connector); |
607 | struct drm_device *dev = dsi_config->dev; | 607 | struct drm_device *dev = dsi_config->dev; |
608 | struct drm_psb_private *dev_priv = dev->dev_private; | ||
609 | const struct psb_offset *map = &dev_priv->regmap[pipe]; | ||
608 | u32 mipi_val = 0; | 610 | u32 mipi_val = 0; |
609 | 611 | ||
610 | if (!dsi_connector) { | 612 | if (!dsi_connector) { |
@@ -632,21 +634,13 @@ int mdfld_dsi_pkg_sender_init(struct mdfld_dsi_connector *dsi_connector, | |||
632 | pkg_sender->status = MDFLD_DSI_PKG_SENDER_FREE; | 634 | pkg_sender->status = MDFLD_DSI_PKG_SENDER_FREE; |
633 | 635 | ||
634 | /*init regs*/ | 636 | /*init regs*/ |
635 | if (pipe == 0) { | 637 | /* FIXME: should just copy the regmap ptr ? */ |
636 | pkg_sender->dpll_reg = MRST_DPLL_A; | 638 | pkg_sender->dpll_reg = map->dpll; |
637 | pkg_sender->dspcntr_reg = DSPACNTR; | 639 | pkg_sender->dspcntr_reg = map->cntr; |
638 | pkg_sender->pipeconf_reg = PIPEACONF; | 640 | pkg_sender->pipeconf_reg = map->conf; |
639 | pkg_sender->dsplinoff_reg = DSPALINOFF; | 641 | pkg_sender->dsplinoff_reg = map->linoff; |
640 | pkg_sender->dspsurf_reg = DSPASURF; | 642 | pkg_sender->dspsurf_reg = map->surf; |
641 | pkg_sender->pipestat_reg = PIPEASTAT; | 643 | pkg_sender->pipestat_reg = map->status; |
642 | } else if (pipe == 2) { | ||
643 | pkg_sender->dpll_reg = MRST_DPLL_A; | ||
644 | pkg_sender->dspcntr_reg = DSPCCNTR; | ||
645 | pkg_sender->pipeconf_reg = PIPECCONF; | ||
646 | pkg_sender->dsplinoff_reg = DSPCLINOFF; | ||
647 | pkg_sender->dspsurf_reg = DSPCSURF; | ||
648 | pkg_sender->pipestat_reg = PIPECSTAT; | ||
649 | } | ||
650 | 644 | ||
651 | pkg_sender->mipi_intr_stat_reg = MIPI_INTR_STAT_REG(pipe); | 645 | pkg_sender->mipi_intr_stat_reg = MIPI_INTR_STAT_REG(pipe); |
652 | pkg_sender->mipi_lp_gen_data_reg = MIPI_LP_GEN_DATA_REG(pipe); | 646 | pkg_sender->mipi_lp_gen_data_reg = MIPI_LP_GEN_DATA_REG(pipe); |
diff --git a/drivers/gpu/drm/gma500/mdfld_intel_display.c b/drivers/gpu/drm/gma500/mdfld_intel_display.c index a35a2921bdf7..3f3cd619c79f 100644 --- a/drivers/gpu/drm/gma500/mdfld_intel_display.c +++ b/drivers/gpu/drm/gma500/mdfld_intel_display.c | |||
@@ -50,17 +50,14 @@ struct mrst_clock_t { | |||
50 | 50 | ||
51 | void mdfldWaitForPipeDisable(struct drm_device *dev, int pipe) | 51 | void mdfldWaitForPipeDisable(struct drm_device *dev, int pipe) |
52 | { | 52 | { |
53 | struct drm_psb_private *dev_priv = dev->dev_private; | ||
54 | const struct psb_offset *map = &dev_priv->regmap[pipe]; | ||
53 | int count, temp; | 55 | int count, temp; |
54 | u32 pipeconf_reg = PIPEACONF; | ||
55 | 56 | ||
56 | switch (pipe) { | 57 | switch (pipe) { |
57 | case 0: | 58 | case 0: |
58 | break; | ||
59 | case 1: | 59 | case 1: |
60 | pipeconf_reg = PIPEBCONF; | ||
61 | break; | ||
62 | case 2: | 60 | case 2: |
63 | pipeconf_reg = PIPECCONF; | ||
64 | break; | 61 | break; |
65 | default: | 62 | default: |
66 | DRM_ERROR("Illegal Pipe Number.\n"); | 63 | DRM_ERROR("Illegal Pipe Number.\n"); |
@@ -73,7 +70,7 @@ void mdfldWaitForPipeDisable(struct drm_device *dev, int pipe) | |||
73 | 70 | ||
74 | /* Wait for for the pipe disable to take effect. */ | 71 | /* Wait for for the pipe disable to take effect. */ |
75 | for (count = 0; count < COUNT_MAX; count++) { | 72 | for (count = 0; count < COUNT_MAX; count++) { |
76 | temp = REG_READ(pipeconf_reg); | 73 | temp = REG_READ(map->conf); |
77 | if ((temp & PIPEACONF_PIPE_STATE) == 0) | 74 | if ((temp & PIPEACONF_PIPE_STATE) == 0) |
78 | break; | 75 | break; |
79 | } | 76 | } |
@@ -81,17 +78,14 @@ void mdfldWaitForPipeDisable(struct drm_device *dev, int pipe) | |||
81 | 78 | ||
82 | void mdfldWaitForPipeEnable(struct drm_device *dev, int pipe) | 79 | void mdfldWaitForPipeEnable(struct drm_device *dev, int pipe) |
83 | { | 80 | { |
81 | struct drm_psb_private *dev_priv = dev->dev_private; | ||
82 | const struct psb_offset *map = &dev_priv->regmap[pipe]; | ||
84 | int count, temp; | 83 | int count, temp; |
85 | u32 pipeconf_reg = PIPEACONF; | ||
86 | 84 | ||
87 | switch (pipe) { | 85 | switch (pipe) { |
88 | case 0: | 86 | case 0: |
89 | break; | ||
90 | case 1: | 87 | case 1: |
91 | pipeconf_reg = PIPEBCONF; | ||
92 | break; | ||
93 | case 2: | 88 | case 2: |
94 | pipeconf_reg = PIPECCONF; | ||
95 | break; | 89 | break; |
96 | default: | 90 | default: |
97 | DRM_ERROR("Illegal Pipe Number.\n"); | 91 | DRM_ERROR("Illegal Pipe Number.\n"); |
@@ -104,7 +98,7 @@ void mdfldWaitForPipeEnable(struct drm_device *dev, int pipe) | |||
104 | 98 | ||
105 | /* Wait for for the pipe enable to take effect. */ | 99 | /* Wait for for the pipe enable to take effect. */ |
106 | for (count = 0; count < COUNT_MAX; count++) { | 100 | for (count = 0; count < COUNT_MAX; count++) { |
107 | temp = REG_READ(pipeconf_reg); | 101 | temp = REG_READ(map->conf); |
108 | if ((temp & PIPEACONF_PIPE_STATE) == 1) | 102 | if ((temp & PIPEACONF_PIPE_STATE) == 1) |
109 | break; | 103 | break; |
110 | } | 104 | } |
@@ -189,15 +183,12 @@ static int mdfld__intel_pipe_set_base(struct drm_crtc *crtc, int x, int y, | |||
189 | struct drm_framebuffer *old_fb) | 183 | struct drm_framebuffer *old_fb) |
190 | { | 184 | { |
191 | struct drm_device *dev = crtc->dev; | 185 | struct drm_device *dev = crtc->dev; |
192 | /* struct drm_i915_master_private *master_priv; */ | 186 | struct drm_psb_private *dev_priv = dev->dev_private; |
193 | struct psb_intel_crtc *psb_intel_crtc = to_psb_intel_crtc(crtc); | 187 | struct psb_intel_crtc *psb_intel_crtc = to_psb_intel_crtc(crtc); |
194 | struct psb_framebuffer *psbfb = to_psb_fb(crtc->fb); | 188 | struct psb_framebuffer *psbfb = to_psb_fb(crtc->fb); |
195 | int pipe = psb_intel_crtc->pipe; | 189 | int pipe = psb_intel_crtc->pipe; |
190 | const struct psb_offset *map = &dev_priv->regmap[pipe]; | ||
196 | unsigned long start, offset; | 191 | unsigned long start, offset; |
197 | int dsplinoff = DSPALINOFF; | ||
198 | int dspsurf = DSPASURF; | ||
199 | int dspstride = DSPASTRIDE; | ||
200 | int dspcntr_reg = DSPACNTR; | ||
201 | u32 dspcntr; | 192 | u32 dspcntr; |
202 | int ret; | 193 | int ret; |
203 | 194 | ||
@@ -215,23 +206,7 @@ static int mdfld__intel_pipe_set_base(struct drm_crtc *crtc, int x, int y, | |||
215 | if (ret) | 206 | if (ret) |
216 | return ret; | 207 | return ret; |
217 | 208 | ||
218 | switch (pipe) { | 209 | if (pipe > 2) { |
219 | case 0: | ||
220 | dsplinoff = DSPALINOFF; | ||
221 | break; | ||
222 | case 1: | ||
223 | dsplinoff = DSPBLINOFF; | ||
224 | dspsurf = DSPBSURF; | ||
225 | dspstride = DSPBSTRIDE; | ||
226 | dspcntr_reg = DSPBCNTR; | ||
227 | break; | ||
228 | case 2: | ||
229 | dsplinoff = DSPCLINOFF; | ||
230 | dspsurf = DSPCSURF; | ||
231 | dspstride = DSPCSTRIDE; | ||
232 | dspcntr_reg = DSPCCNTR; | ||
233 | break; | ||
234 | default: | ||
235 | DRM_ERROR("Illegal Pipe Number.\n"); | 210 | DRM_ERROR("Illegal Pipe Number.\n"); |
236 | return -EINVAL; | 211 | return -EINVAL; |
237 | } | 212 | } |
@@ -242,8 +217,8 @@ static int mdfld__intel_pipe_set_base(struct drm_crtc *crtc, int x, int y, | |||
242 | start = psbfb->gtt->offset; | 217 | start = psbfb->gtt->offset; |
243 | offset = y * crtc->fb->pitches[0] + x * (crtc->fb->bits_per_pixel / 8); | 218 | offset = y * crtc->fb->pitches[0] + x * (crtc->fb->bits_per_pixel / 8); |
244 | 219 | ||
245 | REG_WRITE(dspstride, crtc->fb->pitches[0]); | 220 | REG_WRITE(map->stride, crtc->fb->pitches[0]); |
246 | dspcntr = REG_READ(dspcntr_reg); | 221 | dspcntr = REG_READ(map->cntr); |
247 | dspcntr &= ~DISPPLANE_PIXFORMAT_MASK; | 222 | dspcntr &= ~DISPPLANE_PIXFORMAT_MASK; |
248 | 223 | ||
249 | switch (crtc->fb->bits_per_pixel) { | 224 | switch (crtc->fb->bits_per_pixel) { |
@@ -261,14 +236,14 @@ static int mdfld__intel_pipe_set_base(struct drm_crtc *crtc, int x, int y, | |||
261 | dspcntr |= DISPPLANE_32BPP_NO_ALPHA; | 236 | dspcntr |= DISPPLANE_32BPP_NO_ALPHA; |
262 | break; | 237 | break; |
263 | } | 238 | } |
264 | REG_WRITE(dspcntr_reg, dspcntr); | 239 | REG_WRITE(map->cntr, dspcntr); |
265 | 240 | ||
266 | dev_dbg(dev->dev, "Writing base %08lX %08lX %d %d\n", | 241 | dev_dbg(dev->dev, "Writing base %08lX %08lX %d %d\n", |
267 | start, offset, x, y); | 242 | start, offset, x, y); |
268 | REG_WRITE(dsplinoff, offset); | 243 | REG_WRITE(map->linoff, offset); |
269 | REG_READ(dsplinoff); | 244 | REG_READ(map->linoff); |
270 | REG_WRITE(dspsurf, start); | 245 | REG_WRITE(map->surf, start); |
271 | REG_READ(dspsurf); | 246 | REG_READ(map->surf); |
272 | 247 | ||
273 | gma_power_end(dev); | 248 | gma_power_end(dev); |
274 | 249 | ||
@@ -281,78 +256,56 @@ static int mdfld__intel_pipe_set_base(struct drm_crtc *crtc, int x, int y, | |||
281 | */ | 256 | */ |
282 | void mdfld_disable_crtc(struct drm_device *dev, int pipe) | 257 | void mdfld_disable_crtc(struct drm_device *dev, int pipe) |
283 | { | 258 | { |
284 | int dpll_reg = MRST_DPLL_A; | 259 | struct drm_psb_private *dev_priv = dev->dev_private; |
285 | int dspcntr_reg = DSPACNTR; | 260 | const struct psb_offset *map = &dev_priv->regmap[pipe]; |
286 | int dspbase_reg = MRST_DSPABASE; | ||
287 | int pipeconf_reg = PIPEACONF; | ||
288 | u32 temp; | 261 | u32 temp; |
289 | 262 | ||
290 | dev_dbg(dev->dev, "pipe = %d\n", pipe); | 263 | dev_dbg(dev->dev, "pipe = %d\n", pipe); |
291 | 264 | ||
292 | 265 | ||
293 | switch (pipe) { | ||
294 | case 0: | ||
295 | break; | ||
296 | case 1: | ||
297 | dpll_reg = MDFLD_DPLL_B; | ||
298 | dspcntr_reg = DSPBCNTR; | ||
299 | dspbase_reg = DSPBSURF; | ||
300 | pipeconf_reg = PIPEBCONF; | ||
301 | break; | ||
302 | case 2: | ||
303 | dpll_reg = MRST_DPLL_A; | ||
304 | dspcntr_reg = DSPCCNTR; | ||
305 | dspbase_reg = MDFLD_DSPCBASE; | ||
306 | pipeconf_reg = PIPECCONF; | ||
307 | break; | ||
308 | default: | ||
309 | DRM_ERROR("Illegal Pipe Number.\n"); | ||
310 | return; | ||
311 | } | ||
312 | |||
313 | if (pipe != 1) | 266 | if (pipe != 1) |
314 | mdfld_dsi_gen_fifo_ready(dev, MIPI_GEN_FIFO_STAT_REG(pipe), | 267 | mdfld_dsi_gen_fifo_ready(dev, MIPI_GEN_FIFO_STAT_REG(pipe), |
315 | HS_CTRL_FIFO_EMPTY | HS_DATA_FIFO_EMPTY); | 268 | HS_CTRL_FIFO_EMPTY | HS_DATA_FIFO_EMPTY); |
316 | 269 | ||
317 | /* Disable display plane */ | 270 | /* Disable display plane */ |
318 | temp = REG_READ(dspcntr_reg); | 271 | temp = REG_READ(map->cntr); |
319 | if ((temp & DISPLAY_PLANE_ENABLE) != 0) { | 272 | if ((temp & DISPLAY_PLANE_ENABLE) != 0) { |
320 | REG_WRITE(dspcntr_reg, | 273 | REG_WRITE(map->cntr, |
321 | temp & ~DISPLAY_PLANE_ENABLE); | 274 | temp & ~DISPLAY_PLANE_ENABLE); |
322 | /* Flush the plane changes */ | 275 | /* Flush the plane changes */ |
323 | REG_WRITE(dspbase_reg, REG_READ(dspbase_reg)); | 276 | REG_WRITE(map->base, REG_READ(map->base)); |
324 | REG_READ(dspbase_reg); | 277 | REG_READ(map->base); |
325 | } | 278 | } |
326 | 279 | ||
327 | /* FIXME_JLIU7 MDFLD_PO revisit */ | 280 | /* FIXME_JLIU7 MDFLD_PO revisit */ |
328 | 281 | ||
329 | /* Next, disable display pipes */ | 282 | /* Next, disable display pipes */ |
330 | temp = REG_READ(pipeconf_reg); | 283 | temp = REG_READ(map->conf); |
331 | if ((temp & PIPEACONF_ENABLE) != 0) { | 284 | if ((temp & PIPEACONF_ENABLE) != 0) { |
332 | temp &= ~PIPEACONF_ENABLE; | 285 | temp &= ~PIPEACONF_ENABLE; |
333 | temp |= PIPECONF_PLANE_OFF | PIPECONF_CURSOR_OFF; | 286 | temp |= PIPECONF_PLANE_OFF | PIPECONF_CURSOR_OFF; |
334 | REG_WRITE(pipeconf_reg, temp); | 287 | REG_WRITE(map->conf, temp); |
335 | REG_READ(pipeconf_reg); | 288 | REG_READ(map->conf); |
336 | 289 | ||
337 | /* Wait for for the pipe disable to take effect. */ | 290 | /* Wait for for the pipe disable to take effect. */ |
338 | mdfldWaitForPipeDisable(dev, pipe); | 291 | mdfldWaitForPipeDisable(dev, pipe); |
339 | } | 292 | } |
340 | 293 | ||
341 | temp = REG_READ(dpll_reg); | 294 | temp = REG_READ(map->dpll); |
342 | if (temp & DPLL_VCO_ENABLE) { | 295 | if (temp & DPLL_VCO_ENABLE) { |
343 | if ((pipe != 1 && | 296 | if ((pipe != 1 && |
344 | !((REG_READ(PIPEACONF) | REG_READ(PIPECCONF)) | 297 | !((REG_READ(PIPEACONF) | REG_READ(PIPECCONF)) |
345 | & PIPEACONF_ENABLE)) || pipe == 1) { | 298 | & PIPEACONF_ENABLE)) || pipe == 1) { |
346 | temp &= ~(DPLL_VCO_ENABLE); | 299 | temp &= ~(DPLL_VCO_ENABLE); |
347 | REG_WRITE(dpll_reg, temp); | 300 | REG_WRITE(map->dpll, temp); |
348 | REG_READ(dpll_reg); | 301 | REG_READ(map->dpll); |
349 | /* Wait for the clocks to turn off. */ | 302 | /* Wait for the clocks to turn off. */ |
350 | /* FIXME_MDFLD PO may need more delay */ | 303 | /* FIXME_MDFLD PO may need more delay */ |
351 | udelay(500); | 304 | udelay(500); |
352 | 305 | ||
353 | if (!(temp & MDFLD_PWR_GATE_EN)) { | 306 | if (!(temp & MDFLD_PWR_GATE_EN)) { |
354 | /* gating power of DPLL */ | 307 | /* gating power of DPLL */ |
355 | REG_WRITE(dpll_reg, temp | MDFLD_PWR_GATE_EN); | 308 | REG_WRITE(map->dpll, temp | MDFLD_PWR_GATE_EN); |
356 | /* FIXME_MDFLD PO - change 500 to 1 after PO */ | 309 | /* FIXME_MDFLD PO - change 500 to 1 after PO */ |
357 | udelay(5000); | 310 | udelay(5000); |
358 | } | 311 | } |
@@ -373,41 +326,15 @@ static void mdfld_crtc_dpms(struct drm_crtc *crtc, int mode) | |||
373 | struct drm_psb_private *dev_priv = dev->dev_private; | 326 | struct drm_psb_private *dev_priv = dev->dev_private; |
374 | struct psb_intel_crtc *psb_intel_crtc = to_psb_intel_crtc(crtc); | 327 | struct psb_intel_crtc *psb_intel_crtc = to_psb_intel_crtc(crtc); |
375 | int pipe = psb_intel_crtc->pipe; | 328 | int pipe = psb_intel_crtc->pipe; |
376 | int dpll_reg = MRST_DPLL_A; | 329 | const struct psb_offset *map = &dev_priv->regmap[pipe]; |
377 | int dspcntr_reg = DSPACNTR; | ||
378 | int dspbase_reg = MRST_DSPABASE; | ||
379 | int pipeconf_reg = PIPEACONF; | ||
380 | u32 pipestat_reg = PIPEASTAT; | ||
381 | u32 pipeconf = dev_priv->pipeconf[pipe]; | 330 | u32 pipeconf = dev_priv->pipeconf[pipe]; |
382 | u32 temp; | 331 | u32 temp; |
383 | int timeout = 0; | 332 | int timeout = 0; |
384 | 333 | ||
385 | dev_dbg(dev->dev, "mode = %d, pipe = %d\n", mode, pipe); | 334 | dev_dbg(dev->dev, "mode = %d, pipe = %d\n", mode, pipe); |
386 | 335 | ||
387 | /* FIXME_JLIU7 MDFLD_PO replaced w/ the following function */ | 336 | /* Note: Old code uses pipe a stat for pipe b but that appears |
388 | /* mdfld_dbi_dpms (struct drm_device *dev, int pipe, bool enabled) */ | 337 | to be a bug */ |
389 | |||
390 | switch (pipe) { | ||
391 | case 0: | ||
392 | break; | ||
393 | case 1: | ||
394 | dpll_reg = DPLL_B; | ||
395 | dspcntr_reg = DSPBCNTR; | ||
396 | dspbase_reg = MRST_DSPBBASE; | ||
397 | pipeconf_reg = PIPEBCONF; | ||
398 | dpll_reg = MDFLD_DPLL_B; | ||
399 | break; | ||
400 | case 2: | ||
401 | dpll_reg = MRST_DPLL_A; | ||
402 | dspcntr_reg = DSPCCNTR; | ||
403 | dspbase_reg = MDFLD_DSPCBASE; | ||
404 | pipeconf_reg = PIPECCONF; | ||
405 | pipestat_reg = PIPECSTAT; | ||
406 | break; | ||
407 | default: | ||
408 | DRM_ERROR("Illegal Pipe Number.\n"); | ||
409 | return; | ||
410 | } | ||
411 | 338 | ||
412 | if (!gma_power_begin(dev, true)) | 339 | if (!gma_power_begin(dev, true)) |
413 | return; | 340 | return; |
@@ -420,25 +347,25 @@ static void mdfld_crtc_dpms(struct drm_crtc *crtc, int mode) | |||
420 | case DRM_MODE_DPMS_STANDBY: | 347 | case DRM_MODE_DPMS_STANDBY: |
421 | case DRM_MODE_DPMS_SUSPEND: | 348 | case DRM_MODE_DPMS_SUSPEND: |
422 | /* Enable the DPLL */ | 349 | /* Enable the DPLL */ |
423 | temp = REG_READ(dpll_reg); | 350 | temp = REG_READ(map->dpll); |
424 | 351 | ||
425 | if ((temp & DPLL_VCO_ENABLE) == 0) { | 352 | if ((temp & DPLL_VCO_ENABLE) == 0) { |
426 | /* When ungating power of DPLL, needs to wait 0.5us | 353 | /* When ungating power of DPLL, needs to wait 0.5us |
427 | before enable the VCO */ | 354 | before enable the VCO */ |
428 | if (temp & MDFLD_PWR_GATE_EN) { | 355 | if (temp & MDFLD_PWR_GATE_EN) { |
429 | temp &= ~MDFLD_PWR_GATE_EN; | 356 | temp &= ~MDFLD_PWR_GATE_EN; |
430 | REG_WRITE(dpll_reg, temp); | 357 | REG_WRITE(map->dpll, temp); |
431 | /* FIXME_MDFLD PO - change 500 to 1 after PO */ | 358 | /* FIXME_MDFLD PO - change 500 to 1 after PO */ |
432 | udelay(500); | 359 | udelay(500); |
433 | } | 360 | } |
434 | 361 | ||
435 | REG_WRITE(dpll_reg, temp); | 362 | REG_WRITE(map->dpll, temp); |
436 | REG_READ(dpll_reg); | 363 | REG_READ(map->dpll); |
437 | /* FIXME_MDFLD PO - change 500 to 1 after PO */ | 364 | /* FIXME_MDFLD PO - change 500 to 1 after PO */ |
438 | udelay(500); | 365 | udelay(500); |
439 | 366 | ||
440 | REG_WRITE(dpll_reg, temp | DPLL_VCO_ENABLE); | 367 | REG_WRITE(map->dpll, temp | DPLL_VCO_ENABLE); |
441 | REG_READ(dpll_reg); | 368 | REG_READ(map->dpll); |
442 | 369 | ||
443 | /** | 370 | /** |
444 | * wait for DSI PLL to lock | 371 | * wait for DSI PLL to lock |
@@ -446,25 +373,25 @@ static void mdfld_crtc_dpms(struct drm_crtc *crtc, int mode) | |||
446 | * since both MIPI pipes share the same PLL. | 373 | * since both MIPI pipes share the same PLL. |
447 | */ | 374 | */ |
448 | while ((pipe != 2) && (timeout < 20000) && | 375 | while ((pipe != 2) && (timeout < 20000) && |
449 | !(REG_READ(pipeconf_reg) & PIPECONF_DSIPLL_LOCK)) { | 376 | !(REG_READ(map->conf) & PIPECONF_DSIPLL_LOCK)) { |
450 | udelay(150); | 377 | udelay(150); |
451 | timeout++; | 378 | timeout++; |
452 | } | 379 | } |
453 | } | 380 | } |
454 | 381 | ||
455 | /* Enable the plane */ | 382 | /* Enable the plane */ |
456 | temp = REG_READ(dspcntr_reg); | 383 | temp = REG_READ(map->cntr); |
457 | if ((temp & DISPLAY_PLANE_ENABLE) == 0) { | 384 | if ((temp & DISPLAY_PLANE_ENABLE) == 0) { |
458 | REG_WRITE(dspcntr_reg, | 385 | REG_WRITE(map->cntr, |
459 | temp | DISPLAY_PLANE_ENABLE); | 386 | temp | DISPLAY_PLANE_ENABLE); |
460 | /* Flush the plane changes */ | 387 | /* Flush the plane changes */ |
461 | REG_WRITE(dspbase_reg, REG_READ(dspbase_reg)); | 388 | REG_WRITE(map->base, REG_READ(map->base)); |
462 | } | 389 | } |
463 | 390 | ||
464 | /* Enable the pipe */ | 391 | /* Enable the pipe */ |
465 | temp = REG_READ(pipeconf_reg); | 392 | temp = REG_READ(map->conf); |
466 | if ((temp & PIPEACONF_ENABLE) == 0) { | 393 | if ((temp & PIPEACONF_ENABLE) == 0) { |
467 | REG_WRITE(pipeconf_reg, pipeconf); | 394 | REG_WRITE(map->conf, pipeconf); |
468 | 395 | ||
469 | /* Wait for for the pipe enable to take effect. */ | 396 | /* Wait for for the pipe enable to take effect. */ |
470 | mdfldWaitForPipeEnable(dev, pipe); | 397 | mdfldWaitForPipeEnable(dev, pipe); |
@@ -473,39 +400,39 @@ static void mdfld_crtc_dpms(struct drm_crtc *crtc, int mode) | |||
473 | /*workaround for sighting 3741701 Random X blank display*/ | 400 | /*workaround for sighting 3741701 Random X blank display*/ |
474 | /*perform w/a in video mode only on pipe A or C*/ | 401 | /*perform w/a in video mode only on pipe A or C*/ |
475 | if (pipe == 0 || pipe == 2) { | 402 | if (pipe == 0 || pipe == 2) { |
476 | REG_WRITE(pipestat_reg, REG_READ(pipestat_reg)); | 403 | REG_WRITE(map->status, REG_READ(map->status)); |
477 | msleep(100); | 404 | msleep(100); |
478 | if (PIPE_VBLANK_STATUS & REG_READ(pipestat_reg)) | 405 | if (PIPE_VBLANK_STATUS & REG_READ(map->status)) |
479 | dev_dbg(dev->dev, "OK"); | 406 | dev_dbg(dev->dev, "OK"); |
480 | else { | 407 | else { |
481 | dev_dbg(dev->dev, "STUCK!!!!"); | 408 | dev_dbg(dev->dev, "STUCK!!!!"); |
482 | /*shutdown controller*/ | 409 | /*shutdown controller*/ |
483 | temp = REG_READ(dspcntr_reg); | 410 | temp = REG_READ(map->cntr); |
484 | REG_WRITE(dspcntr_reg, | 411 | REG_WRITE(map->cntr, |
485 | temp & ~DISPLAY_PLANE_ENABLE); | 412 | temp & ~DISPLAY_PLANE_ENABLE); |
486 | REG_WRITE(dspbase_reg, REG_READ(dspbase_reg)); | 413 | REG_WRITE(map->base, REG_READ(map->base)); |
487 | /*mdfld_dsi_dpi_shut_down(dev, pipe);*/ | 414 | /*mdfld_dsi_dpi_shut_down(dev, pipe);*/ |
488 | REG_WRITE(0xb048, 1); | 415 | REG_WRITE(0xb048, 1); |
489 | msleep(100); | 416 | msleep(100); |
490 | temp = REG_READ(pipeconf_reg); | 417 | temp = REG_READ(map->conf); |
491 | temp &= ~PIPEACONF_ENABLE; | 418 | temp &= ~PIPEACONF_ENABLE; |
492 | REG_WRITE(pipeconf_reg, temp); | 419 | REG_WRITE(map->conf, temp); |
493 | msleep(100); /*wait for pipe disable*/ | 420 | msleep(100); /*wait for pipe disable*/ |
494 | REG_WRITE(MIPI_DEVICE_READY_REG(pipe), 0); | 421 | REG_WRITE(MIPI_DEVICE_READY_REG(pipe), 0); |
495 | msleep(100); | 422 | msleep(100); |
496 | REG_WRITE(0xb004, REG_READ(0xb004)); | 423 | REG_WRITE(0xb004, REG_READ(0xb004)); |
497 | /* try to bring the controller back up again*/ | 424 | /* try to bring the controller back up again*/ |
498 | REG_WRITE(MIPI_DEVICE_READY_REG(pipe), 1); | 425 | REG_WRITE(MIPI_DEVICE_READY_REG(pipe), 1); |
499 | temp = REG_READ(dspcntr_reg); | 426 | temp = REG_READ(map->cntr); |
500 | REG_WRITE(dspcntr_reg, | 427 | REG_WRITE(map->cntr, |
501 | temp | DISPLAY_PLANE_ENABLE); | 428 | temp | DISPLAY_PLANE_ENABLE); |
502 | REG_WRITE(dspbase_reg, REG_READ(dspbase_reg)); | 429 | REG_WRITE(map->base, REG_READ(map->base)); |
503 | /*mdfld_dsi_dpi_turn_on(dev, pipe);*/ | 430 | /*mdfld_dsi_dpi_turn_on(dev, pipe);*/ |
504 | REG_WRITE(0xb048, 2); | 431 | REG_WRITE(0xb048, 2); |
505 | msleep(100); | 432 | msleep(100); |
506 | temp = REG_READ(pipeconf_reg); | 433 | temp = REG_READ(map->conf); |
507 | temp |= PIPEACONF_ENABLE; | 434 | temp |= PIPEACONF_ENABLE; |
508 | REG_WRITE(pipeconf_reg, temp); | 435 | REG_WRITE(map->conf, temp); |
509 | } | 436 | } |
510 | } | 437 | } |
511 | 438 | ||
@@ -529,35 +456,35 @@ static void mdfld_crtc_dpms(struct drm_crtc *crtc, int mode) | |||
529 | REG_WRITE(VGACNTRL, VGA_DISP_DISABLE); | 456 | REG_WRITE(VGACNTRL, VGA_DISP_DISABLE); |
530 | 457 | ||
531 | /* Disable display plane */ | 458 | /* Disable display plane */ |
532 | temp = REG_READ(dspcntr_reg); | 459 | temp = REG_READ(map->cntr); |
533 | if ((temp & DISPLAY_PLANE_ENABLE) != 0) { | 460 | if ((temp & DISPLAY_PLANE_ENABLE) != 0) { |
534 | REG_WRITE(dspcntr_reg, | 461 | REG_WRITE(map->cntr, |
535 | temp & ~DISPLAY_PLANE_ENABLE); | 462 | temp & ~DISPLAY_PLANE_ENABLE); |
536 | /* Flush the plane changes */ | 463 | /* Flush the plane changes */ |
537 | REG_WRITE(dspbase_reg, REG_READ(dspbase_reg)); | 464 | REG_WRITE(map->base, REG_READ(map->base)); |
538 | REG_READ(dspbase_reg); | 465 | REG_READ(map->base); |
539 | } | 466 | } |
540 | 467 | ||
541 | /* Next, disable display pipes */ | 468 | /* Next, disable display pipes */ |
542 | temp = REG_READ(pipeconf_reg); | 469 | temp = REG_READ(map->conf); |
543 | if ((temp & PIPEACONF_ENABLE) != 0) { | 470 | if ((temp & PIPEACONF_ENABLE) != 0) { |
544 | temp &= ~PIPEACONF_ENABLE; | 471 | temp &= ~PIPEACONF_ENABLE; |
545 | temp |= PIPECONF_PLANE_OFF | PIPECONF_CURSOR_OFF; | 472 | temp |= PIPECONF_PLANE_OFF | PIPECONF_CURSOR_OFF; |
546 | REG_WRITE(pipeconf_reg, temp); | 473 | REG_WRITE(map->conf, temp); |
547 | REG_READ(pipeconf_reg); | 474 | REG_READ(map->conf); |
548 | 475 | ||
549 | /* Wait for for the pipe disable to take effect. */ | 476 | /* Wait for for the pipe disable to take effect. */ |
550 | mdfldWaitForPipeDisable(dev, pipe); | 477 | mdfldWaitForPipeDisable(dev, pipe); |
551 | } | 478 | } |
552 | 479 | ||
553 | temp = REG_READ(dpll_reg); | 480 | temp = REG_READ(map->dpll); |
554 | if (temp & DPLL_VCO_ENABLE) { | 481 | if (temp & DPLL_VCO_ENABLE) { |
555 | if ((pipe != 1 && !((REG_READ(PIPEACONF) | 482 | if ((pipe != 1 && !((REG_READ(PIPEACONF) |
556 | | REG_READ(PIPECCONF)) & PIPEACONF_ENABLE)) | 483 | | REG_READ(PIPECCONF)) & PIPEACONF_ENABLE)) |
557 | || pipe == 1) { | 484 | || pipe == 1) { |
558 | temp &= ~(DPLL_VCO_ENABLE); | 485 | temp &= ~(DPLL_VCO_ENABLE); |
559 | REG_WRITE(dpll_reg, temp); | 486 | REG_WRITE(map->dpll, temp); |
560 | REG_READ(dpll_reg); | 487 | REG_READ(map->dpll); |
561 | /* Wait for the clocks to turn off. */ | 488 | /* Wait for the clocks to turn off. */ |
562 | /* FIXME_MDFLD PO may need more delay */ | 489 | /* FIXME_MDFLD PO may need more delay */ |
563 | udelay(500); | 490 | udelay(500); |
@@ -764,21 +691,7 @@ static int mdfld_crtc_mode_set(struct drm_crtc *crtc, | |||
764 | struct psb_intel_crtc *psb_intel_crtc = to_psb_intel_crtc(crtc); | 691 | struct psb_intel_crtc *psb_intel_crtc = to_psb_intel_crtc(crtc); |
765 | struct drm_psb_private *dev_priv = dev->dev_private; | 692 | struct drm_psb_private *dev_priv = dev->dev_private; |
766 | int pipe = psb_intel_crtc->pipe; | 693 | int pipe = psb_intel_crtc->pipe; |
767 | int fp_reg = MRST_FPA0; | 694 | const struct psb_offset *map = &dev_priv->regmap[pipe]; |
768 | int dpll_reg = MRST_DPLL_A; | ||
769 | int dspcntr_reg = DSPACNTR; | ||
770 | int pipeconf_reg = PIPEACONF; | ||
771 | int htot_reg = HTOTAL_A; | ||
772 | int hblank_reg = HBLANK_A; | ||
773 | int hsync_reg = HSYNC_A; | ||
774 | int vtot_reg = VTOTAL_A; | ||
775 | int vblank_reg = VBLANK_A; | ||
776 | int vsync_reg = VSYNC_A; | ||
777 | int dspsize_reg = DSPASIZE; | ||
778 | int dsppos_reg = DSPAPOS; | ||
779 | int pipesrc_reg = PIPEASRC; | ||
780 | u32 *pipeconf = &dev_priv->pipeconf[pipe]; | ||
781 | u32 *dspcntr = &dev_priv->dspcntr[pipe]; | ||
782 | int refclk = 0; | 695 | int refclk = 0; |
783 | int clk_n = 0, clk_p2 = 0, clk_byte = 1, clk = 0, m_conv = 0, | 696 | int clk_n = 0, clk_p2 = 0, clk_byte = 1, clk = 0, m_conv = 0, |
784 | clk_tmp = 0; | 697 | clk_tmp = 0; |
@@ -806,45 +719,6 @@ static int mdfld_crtc_mode_set(struct drm_crtc *crtc, | |||
806 | } | 719 | } |
807 | #endif | 720 | #endif |
808 | 721 | ||
809 | switch (pipe) { | ||
810 | case 0: | ||
811 | break; | ||
812 | case 1: | ||
813 | fp_reg = FPB0; | ||
814 | dpll_reg = DPLL_B; | ||
815 | dspcntr_reg = DSPBCNTR; | ||
816 | pipeconf_reg = PIPEBCONF; | ||
817 | htot_reg = HTOTAL_B; | ||
818 | hblank_reg = HBLANK_B; | ||
819 | hsync_reg = HSYNC_B; | ||
820 | vtot_reg = VTOTAL_B; | ||
821 | vblank_reg = VBLANK_B; | ||
822 | vsync_reg = VSYNC_B; | ||
823 | dspsize_reg = DSPBSIZE; | ||
824 | dsppos_reg = DSPBPOS; | ||
825 | pipesrc_reg = PIPEBSRC; | ||
826 | fp_reg = MDFLD_DPLL_DIV0; | ||
827 | dpll_reg = MDFLD_DPLL_B; | ||
828 | break; | ||
829 | case 2: | ||
830 | dpll_reg = MRST_DPLL_A; | ||
831 | dspcntr_reg = DSPCCNTR; | ||
832 | pipeconf_reg = PIPECCONF; | ||
833 | htot_reg = HTOTAL_C; | ||
834 | hblank_reg = HBLANK_C; | ||
835 | hsync_reg = HSYNC_C; | ||
836 | vtot_reg = VTOTAL_C; | ||
837 | vblank_reg = VBLANK_C; | ||
838 | vsync_reg = VSYNC_C; | ||
839 | dspsize_reg = DSPCSIZE; | ||
840 | dsppos_reg = DSPCPOS; | ||
841 | pipesrc_reg = PIPECSRC; | ||
842 | break; | ||
843 | default: | ||
844 | DRM_ERROR("Illegal Pipe Number.\n"); | ||
845 | return 0; | ||
846 | } | ||
847 | |||
848 | ret = check_fb(crtc->fb); | 722 | ret = check_fb(crtc->fb); |
849 | if (ret) | 723 | if (ret) |
850 | return ret; | 724 | return ret; |
@@ -929,21 +803,21 @@ static int mdfld_crtc_mode_set(struct drm_crtc *crtc, | |||
929 | * contained within the displayable area of the screen image | 803 | * contained within the displayable area of the screen image |
930 | * (frame buffer). | 804 | * (frame buffer). |
931 | */ | 805 | */ |
932 | REG_WRITE(dspsize_reg, ((min(mode->crtc_vdisplay, adjusted_mode->crtc_vdisplay) - 1) << 16) | 806 | REG_WRITE(map->size, ((min(mode->crtc_vdisplay, adjusted_mode->crtc_vdisplay) - 1) << 16) |
933 | | (min(mode->crtc_hdisplay, adjusted_mode->crtc_hdisplay) - 1)); | 807 | | (min(mode->crtc_hdisplay, adjusted_mode->crtc_hdisplay) - 1)); |
934 | /* Set the CRTC with encoder mode. */ | 808 | /* Set the CRTC with encoder mode. */ |
935 | REG_WRITE(pipesrc_reg, ((mode->crtc_hdisplay - 1) << 16) | 809 | REG_WRITE(map->src, ((mode->crtc_hdisplay - 1) << 16) |
936 | | (mode->crtc_vdisplay - 1)); | 810 | | (mode->crtc_vdisplay - 1)); |
937 | } else { | 811 | } else { |
938 | REG_WRITE(dspsize_reg, | 812 | REG_WRITE(map->size, |
939 | ((mode->crtc_vdisplay - 1) << 16) | | 813 | ((mode->crtc_vdisplay - 1) << 16) | |
940 | (mode->crtc_hdisplay - 1)); | 814 | (mode->crtc_hdisplay - 1)); |
941 | REG_WRITE(pipesrc_reg, | 815 | REG_WRITE(map->src, |
942 | ((mode->crtc_hdisplay - 1) << 16) | | 816 | ((mode->crtc_hdisplay - 1) << 16) | |
943 | (mode->crtc_vdisplay - 1)); | 817 | (mode->crtc_vdisplay - 1)); |
944 | } | 818 | } |
945 | 819 | ||
946 | REG_WRITE(dsppos_reg, 0); | 820 | REG_WRITE(map->pos, 0); |
947 | 821 | ||
948 | if (psb_intel_encoder) | 822 | if (psb_intel_encoder) |
949 | drm_connector_property_get_value(connector, | 823 | drm_connector_property_get_value(connector, |
@@ -961,34 +835,34 @@ static int mdfld_crtc_mode_set(struct drm_crtc *crtc, | |||
961 | offsetY = (adjusted_mode->crtc_vdisplay - | 835 | offsetY = (adjusted_mode->crtc_vdisplay - |
962 | mode->crtc_vdisplay) / 2; | 836 | mode->crtc_vdisplay) / 2; |
963 | 837 | ||
964 | REG_WRITE(htot_reg, (mode->crtc_hdisplay - 1) | | 838 | REG_WRITE(map->htotal, (mode->crtc_hdisplay - 1) | |
965 | ((adjusted_mode->crtc_htotal - 1) << 16)); | 839 | ((adjusted_mode->crtc_htotal - 1) << 16)); |
966 | REG_WRITE(vtot_reg, (mode->crtc_vdisplay - 1) | | 840 | REG_WRITE(map->vtotal, (mode->crtc_vdisplay - 1) | |
967 | ((adjusted_mode->crtc_vtotal - 1) << 16)); | 841 | ((adjusted_mode->crtc_vtotal - 1) << 16)); |
968 | REG_WRITE(hblank_reg, (adjusted_mode->crtc_hblank_start - | 842 | REG_WRITE(map->hblank, (adjusted_mode->crtc_hblank_start - |
969 | offsetX - 1) | | 843 | offsetX - 1) | |
970 | ((adjusted_mode->crtc_hblank_end - offsetX - 1) << 16)); | 844 | ((adjusted_mode->crtc_hblank_end - offsetX - 1) << 16)); |
971 | REG_WRITE(hsync_reg, (adjusted_mode->crtc_hsync_start - | 845 | REG_WRITE(map->hsync, (adjusted_mode->crtc_hsync_start - |
972 | offsetX - 1) | | 846 | offsetX - 1) | |
973 | ((adjusted_mode->crtc_hsync_end - offsetX - 1) << 16)); | 847 | ((adjusted_mode->crtc_hsync_end - offsetX - 1) << 16)); |
974 | REG_WRITE(vblank_reg, (adjusted_mode->crtc_vblank_start - | 848 | REG_WRITE(map->vblank, (adjusted_mode->crtc_vblank_start - |
975 | offsetY - 1) | | 849 | offsetY - 1) | |
976 | ((adjusted_mode->crtc_vblank_end - offsetY - 1) << 16)); | 850 | ((adjusted_mode->crtc_vblank_end - offsetY - 1) << 16)); |
977 | REG_WRITE(vsync_reg, (adjusted_mode->crtc_vsync_start - | 851 | REG_WRITE(map->vsync, (adjusted_mode->crtc_vsync_start - |
978 | offsetY - 1) | | 852 | offsetY - 1) | |
979 | ((adjusted_mode->crtc_vsync_end - offsetY - 1) << 16)); | 853 | ((adjusted_mode->crtc_vsync_end - offsetY - 1) << 16)); |
980 | } else { | 854 | } else { |
981 | REG_WRITE(htot_reg, (adjusted_mode->crtc_hdisplay - 1) | | 855 | REG_WRITE(map->htotal, (adjusted_mode->crtc_hdisplay - 1) | |
982 | ((adjusted_mode->crtc_htotal - 1) << 16)); | 856 | ((adjusted_mode->crtc_htotal - 1) << 16)); |
983 | REG_WRITE(vtot_reg, (adjusted_mode->crtc_vdisplay - 1) | | 857 | REG_WRITE(map->vtotal, (adjusted_mode->crtc_vdisplay - 1) | |
984 | ((adjusted_mode->crtc_vtotal - 1) << 16)); | 858 | ((adjusted_mode->crtc_vtotal - 1) << 16)); |
985 | REG_WRITE(hblank_reg, (adjusted_mode->crtc_hblank_start - 1) | | 859 | REG_WRITE(map->hblank, (adjusted_mode->crtc_hblank_start - 1) | |
986 | ((adjusted_mode->crtc_hblank_end - 1) << 16)); | 860 | ((adjusted_mode->crtc_hblank_end - 1) << 16)); |
987 | REG_WRITE(hsync_reg, (adjusted_mode->crtc_hsync_start - 1) | | 861 | REG_WRITE(map->hsync, (adjusted_mode->crtc_hsync_start - 1) | |
988 | ((adjusted_mode->crtc_hsync_end - 1) << 16)); | 862 | ((adjusted_mode->crtc_hsync_end - 1) << 16)); |
989 | REG_WRITE(vblank_reg, (adjusted_mode->crtc_vblank_start - 1) | | 863 | REG_WRITE(map->vblank, (adjusted_mode->crtc_vblank_start - 1) | |
990 | ((adjusted_mode->crtc_vblank_end - 1) << 16)); | 864 | ((adjusted_mode->crtc_vblank_end - 1) << 16)); |
991 | REG_WRITE(vsync_reg, (adjusted_mode->crtc_vsync_start - 1) | | 865 | REG_WRITE(map->vsync, (adjusted_mode->crtc_vsync_start - 1) | |
992 | ((adjusted_mode->crtc_vsync_end - 1) << 16)); | 866 | ((adjusted_mode->crtc_vsync_end - 1) << 16)); |
993 | } | 867 | } |
994 | 868 | ||
@@ -1000,12 +874,12 @@ static int mdfld_crtc_mode_set(struct drm_crtc *crtc, | |||
1000 | } | 874 | } |
1001 | 875 | ||
1002 | /* setup pipeconf */ | 876 | /* setup pipeconf */ |
1003 | *pipeconf = PIPEACONF_ENABLE; /* FIXME_JLIU7 REG_READ(pipeconf_reg); */ | 877 | dev_priv->pipeconf[pipe] = PIPEACONF_ENABLE; /* FIXME_JLIU7 REG_READ(pipeconf_reg); */ |
1004 | 878 | ||
1005 | /* Set up the display plane register */ | 879 | /* Set up the display plane register */ |
1006 | *dspcntr = REG_READ(dspcntr_reg); | 880 | dev_priv->dspcntr[pipe] = REG_READ(map->cntr); |
1007 | *dspcntr |= pipe << DISPPLANE_SEL_PIPE_POS; | 881 | dev_priv->dspcntr[pipe] |= pipe << DISPPLANE_SEL_PIPE_POS; |
1008 | *dspcntr |= DISPLAY_PLANE_ENABLE; | 882 | dev_priv->dspcntr[pipe] |= DISPLAY_PLANE_ENABLE; |
1009 | 883 | ||
1010 | if (is_mipi2) | 884 | if (is_mipi2) |
1011 | goto mrst_crtc_mode_set_exit; | 885 | goto mrst_crtc_mode_set_exit; |
@@ -1070,21 +944,21 @@ static int mdfld_crtc_mode_set(struct drm_crtc *crtc, | |||
1070 | clock.p1, m_conv); | 944 | clock.p1, m_conv); |
1071 | } | 945 | } |
1072 | 946 | ||
1073 | dpll = REG_READ(dpll_reg); | 947 | dpll = REG_READ(map->dpll); |
1074 | 948 | ||
1075 | if (dpll & DPLL_VCO_ENABLE) { | 949 | if (dpll & DPLL_VCO_ENABLE) { |
1076 | dpll &= ~DPLL_VCO_ENABLE; | 950 | dpll &= ~DPLL_VCO_ENABLE; |
1077 | REG_WRITE(dpll_reg, dpll); | 951 | REG_WRITE(map->dpll, dpll); |
1078 | REG_READ(dpll_reg); | 952 | REG_READ(map->dpll); |
1079 | 953 | ||
1080 | /* FIXME jliu7 check the DPLL lock bit PIPEACONF[29] */ | 954 | /* FIXME jliu7 check the DPLL lock bit PIPEACONF[29] */ |
1081 | /* FIXME_MDFLD PO - change 500 to 1 after PO */ | 955 | /* FIXME_MDFLD PO - change 500 to 1 after PO */ |
1082 | udelay(500); | 956 | udelay(500); |
1083 | 957 | ||
1084 | /* reset M1, N1 & P1 */ | 958 | /* reset M1, N1 & P1 */ |
1085 | REG_WRITE(fp_reg, 0); | 959 | REG_WRITE(map->fp0, 0); |
1086 | dpll &= ~MDFLD_P1_MASK; | 960 | dpll &= ~MDFLD_P1_MASK; |
1087 | REG_WRITE(dpll_reg, dpll); | 961 | REG_WRITE(map->dpll, dpll); |
1088 | /* FIXME_MDFLD PO - change 500 to 1 after PO */ | 962 | /* FIXME_MDFLD PO - change 500 to 1 after PO */ |
1089 | udelay(500); | 963 | udelay(500); |
1090 | } | 964 | } |
@@ -1093,7 +967,7 @@ static int mdfld_crtc_mode_set(struct drm_crtc *crtc, | |||
1093 | * enable the VCO */ | 967 | * enable the VCO */ |
1094 | if (dpll & MDFLD_PWR_GATE_EN) { | 968 | if (dpll & MDFLD_PWR_GATE_EN) { |
1095 | dpll &= ~MDFLD_PWR_GATE_EN; | 969 | dpll &= ~MDFLD_PWR_GATE_EN; |
1096 | REG_WRITE(dpll_reg, dpll); | 970 | REG_WRITE(map->dpll, dpll); |
1097 | /* FIXME_MDFLD PO - change 500 to 1 after PO */ | 971 | /* FIXME_MDFLD PO - change 500 to 1 after PO */ |
1098 | udelay(500); | 972 | udelay(500); |
1099 | } | 973 | } |
@@ -1134,18 +1008,18 @@ static int mdfld_crtc_mode_set(struct drm_crtc *crtc, | |||
1134 | fp = 0x000000c1; | 1008 | fp = 0x000000c1; |
1135 | } | 1009 | } |
1136 | 1010 | ||
1137 | REG_WRITE(fp_reg, fp); | 1011 | REG_WRITE(map->fp0, fp); |
1138 | REG_WRITE(dpll_reg, dpll); | 1012 | REG_WRITE(map->dpll, dpll); |
1139 | /* FIXME_MDFLD PO - change 500 to 1 after PO */ | 1013 | /* FIXME_MDFLD PO - change 500 to 1 after PO */ |
1140 | udelay(500); | 1014 | udelay(500); |
1141 | 1015 | ||
1142 | dpll |= DPLL_VCO_ENABLE; | 1016 | dpll |= DPLL_VCO_ENABLE; |
1143 | REG_WRITE(dpll_reg, dpll); | 1017 | REG_WRITE(map->dpll, dpll); |
1144 | REG_READ(dpll_reg); | 1018 | REG_READ(map->dpll); |
1145 | 1019 | ||
1146 | /* wait for DSI PLL to lock */ | 1020 | /* wait for DSI PLL to lock */ |
1147 | while (timeout < 20000 && | 1021 | while (timeout < 20000 && |
1148 | !(REG_READ(pipeconf_reg) & PIPECONF_DSIPLL_LOCK)) { | 1022 | !(REG_READ(map->conf) & PIPECONF_DSIPLL_LOCK)) { |
1149 | udelay(150); | 1023 | udelay(150); |
1150 | timeout++; | 1024 | timeout++; |
1151 | } | 1025 | } |
@@ -1155,11 +1029,11 @@ static int mdfld_crtc_mode_set(struct drm_crtc *crtc, | |||
1155 | 1029 | ||
1156 | dev_dbg(dev->dev, "is_mipi = 0x%x\n", is_mipi); | 1030 | dev_dbg(dev->dev, "is_mipi = 0x%x\n", is_mipi); |
1157 | 1031 | ||
1158 | REG_WRITE(pipeconf_reg, *pipeconf); | 1032 | REG_WRITE(map->conf, dev_priv->pipeconf[pipe]); |
1159 | REG_READ(pipeconf_reg); | 1033 | REG_READ(map->conf); |
1160 | 1034 | ||
1161 | /* Wait for for the pipe enable to take effect. */ | 1035 | /* Wait for for the pipe enable to take effect. */ |
1162 | REG_WRITE(dspcntr_reg, *dspcntr); | 1036 | REG_WRITE(map->cntr, dev_priv->dspcntr[pipe]); |
1163 | psb_intel_wait_for_vblank(dev); | 1037 | psb_intel_wait_for_vblank(dev); |
1164 | 1038 | ||
1165 | mrst_crtc_mode_set_exit: | 1039 | mrst_crtc_mode_set_exit: |
diff --git a/drivers/gpu/drm/gma500/oaktrail_crtc.c b/drivers/gpu/drm/gma500/oaktrail_crtc.c index a39b0d0d680f..f821c835ca90 100644 --- a/drivers/gpu/drm/gma500/oaktrail_crtc.c +++ b/drivers/gpu/drm/gma500/oaktrail_crtc.c | |||
@@ -162,12 +162,10 @@ mrstFindBestPLL(struct drm_crtc *crtc, int target, int refclk, | |||
162 | static void oaktrail_crtc_dpms(struct drm_crtc *crtc, int mode) | 162 | static void oaktrail_crtc_dpms(struct drm_crtc *crtc, int mode) |
163 | { | 163 | { |
164 | struct drm_device *dev = crtc->dev; | 164 | struct drm_device *dev = crtc->dev; |
165 | struct drm_psb_private *dev_priv = dev->dev_private; | ||
165 | struct psb_intel_crtc *psb_intel_crtc = to_psb_intel_crtc(crtc); | 166 | struct psb_intel_crtc *psb_intel_crtc = to_psb_intel_crtc(crtc); |
166 | int pipe = psb_intel_crtc->pipe; | 167 | int pipe = psb_intel_crtc->pipe; |
167 | int dpll_reg = (pipe == 0) ? MRST_DPLL_A : DPLL_B; | 168 | const struct psb_offset *map = &dev_priv->regmap[pipe]; |
168 | int dspcntr_reg = (pipe == 0) ? DSPACNTR : DSPBCNTR; | ||
169 | int dspbase_reg = (pipe == 0) ? MRST_DSPABASE : DSPBBASE; | ||
170 | int pipeconf_reg = (pipe == 0) ? PIPEACONF : PIPEBCONF; | ||
171 | u32 temp; | 169 | u32 temp; |
172 | 170 | ||
173 | if (!gma_power_begin(dev, true)) | 171 | if (!gma_power_begin(dev, true)) |
@@ -181,32 +179,32 @@ static void oaktrail_crtc_dpms(struct drm_crtc *crtc, int mode) | |||
181 | case DRM_MODE_DPMS_STANDBY: | 179 | case DRM_MODE_DPMS_STANDBY: |
182 | case DRM_MODE_DPMS_SUSPEND: | 180 | case DRM_MODE_DPMS_SUSPEND: |
183 | /* Enable the DPLL */ | 181 | /* Enable the DPLL */ |
184 | temp = REG_READ(dpll_reg); | 182 | temp = REG_READ(map->dpll); |
185 | if ((temp & DPLL_VCO_ENABLE) == 0) { | 183 | if ((temp & DPLL_VCO_ENABLE) == 0) { |
186 | REG_WRITE(dpll_reg, temp); | 184 | REG_WRITE(map->dpll, temp); |
187 | REG_READ(dpll_reg); | 185 | REG_READ(map->dpll); |
188 | /* Wait for the clocks to stabilize. */ | 186 | /* Wait for the clocks to stabilize. */ |
189 | udelay(150); | 187 | udelay(150); |
190 | REG_WRITE(dpll_reg, temp | DPLL_VCO_ENABLE); | 188 | REG_WRITE(map->dpll, temp | DPLL_VCO_ENABLE); |
191 | REG_READ(dpll_reg); | 189 | REG_READ(map->dpll); |
192 | /* Wait for the clocks to stabilize. */ | 190 | /* Wait for the clocks to stabilize. */ |
193 | udelay(150); | 191 | udelay(150); |
194 | REG_WRITE(dpll_reg, temp | DPLL_VCO_ENABLE); | 192 | REG_WRITE(map->dpll, temp | DPLL_VCO_ENABLE); |
195 | REG_READ(dpll_reg); | 193 | REG_READ(map->dpll); |
196 | /* Wait for the clocks to stabilize. */ | 194 | /* Wait for the clocks to stabilize. */ |
197 | udelay(150); | 195 | udelay(150); |
198 | } | 196 | } |
199 | /* Enable the pipe */ | 197 | /* Enable the pipe */ |
200 | temp = REG_READ(pipeconf_reg); | 198 | temp = REG_READ(map->conf); |
201 | if ((temp & PIPEACONF_ENABLE) == 0) | 199 | if ((temp & PIPEACONF_ENABLE) == 0) |
202 | REG_WRITE(pipeconf_reg, temp | PIPEACONF_ENABLE); | 200 | REG_WRITE(map->conf, temp | PIPEACONF_ENABLE); |
203 | /* Enable the plane */ | 201 | /* Enable the plane */ |
204 | temp = REG_READ(dspcntr_reg); | 202 | temp = REG_READ(map->cntr); |
205 | if ((temp & DISPLAY_PLANE_ENABLE) == 0) { | 203 | if ((temp & DISPLAY_PLANE_ENABLE) == 0) { |
206 | REG_WRITE(dspcntr_reg, | 204 | REG_WRITE(map->cntr, |
207 | temp | DISPLAY_PLANE_ENABLE); | 205 | temp | DISPLAY_PLANE_ENABLE); |
208 | /* Flush the plane changes */ | 206 | /* Flush the plane changes */ |
209 | REG_WRITE(dspbase_reg, REG_READ(dspbase_reg)); | 207 | REG_WRITE(map->base, REG_READ(map->base)); |
210 | } | 208 | } |
211 | 209 | ||
212 | psb_intel_crtc_load_lut(crtc); | 210 | psb_intel_crtc_load_lut(crtc); |
@@ -223,28 +221,28 @@ static void oaktrail_crtc_dpms(struct drm_crtc *crtc, int mode) | |||
223 | /* Disable the VGA plane that we never use */ | 221 | /* Disable the VGA plane that we never use */ |
224 | REG_WRITE(VGACNTRL, VGA_DISP_DISABLE); | 222 | REG_WRITE(VGACNTRL, VGA_DISP_DISABLE); |
225 | /* Disable display plane */ | 223 | /* Disable display plane */ |
226 | temp = REG_READ(dspcntr_reg); | 224 | temp = REG_READ(map->cntr); |
227 | if ((temp & DISPLAY_PLANE_ENABLE) != 0) { | 225 | if ((temp & DISPLAY_PLANE_ENABLE) != 0) { |
228 | REG_WRITE(dspcntr_reg, | 226 | REG_WRITE(map->cntr, |
229 | temp & ~DISPLAY_PLANE_ENABLE); | 227 | temp & ~DISPLAY_PLANE_ENABLE); |
230 | /* Flush the plane changes */ | 228 | /* Flush the plane changes */ |
231 | REG_WRITE(dspbase_reg, REG_READ(dspbase_reg)); | 229 | REG_WRITE(map->base, REG_READ(map->base)); |
232 | REG_READ(dspbase_reg); | 230 | REG_READ(map->base); |
233 | } | 231 | } |
234 | 232 | ||
235 | /* Next, disable display pipes */ | 233 | /* Next, disable display pipes */ |
236 | temp = REG_READ(pipeconf_reg); | 234 | temp = REG_READ(map->conf); |
237 | if ((temp & PIPEACONF_ENABLE) != 0) { | 235 | if ((temp & PIPEACONF_ENABLE) != 0) { |
238 | REG_WRITE(pipeconf_reg, temp & ~PIPEACONF_ENABLE); | 236 | REG_WRITE(map->conf, temp & ~PIPEACONF_ENABLE); |
239 | REG_READ(pipeconf_reg); | 237 | REG_READ(map->conf); |
240 | } | 238 | } |
241 | /* Wait for for the pipe disable to take effect. */ | 239 | /* Wait for for the pipe disable to take effect. */ |
242 | psb_intel_wait_for_vblank(dev); | 240 | psb_intel_wait_for_vblank(dev); |
243 | 241 | ||
244 | temp = REG_READ(dpll_reg); | 242 | temp = REG_READ(map->dpll); |
245 | if ((temp & DPLL_VCO_ENABLE) != 0) { | 243 | if ((temp & DPLL_VCO_ENABLE) != 0) { |
246 | REG_WRITE(dpll_reg, temp & ~DPLL_VCO_ENABLE); | 244 | REG_WRITE(map->dpll, temp & ~DPLL_VCO_ENABLE); |
247 | REG_READ(dpll_reg); | 245 | REG_READ(map->dpll); |
248 | } | 246 | } |
249 | 247 | ||
250 | /* Wait for the clocks to turn off. */ | 248 | /* Wait for the clocks to turn off. */ |
@@ -292,17 +290,7 @@ static int oaktrail_crtc_mode_set(struct drm_crtc *crtc, | |||
292 | struct psb_intel_crtc *psb_intel_crtc = to_psb_intel_crtc(crtc); | 290 | struct psb_intel_crtc *psb_intel_crtc = to_psb_intel_crtc(crtc); |
293 | struct drm_psb_private *dev_priv = dev->dev_private; | 291 | struct drm_psb_private *dev_priv = dev->dev_private; |
294 | int pipe = psb_intel_crtc->pipe; | 292 | int pipe = psb_intel_crtc->pipe; |
295 | int fp_reg = (pipe == 0) ? MRST_FPA0 : FPB0; | 293 | const struct psb_offset *map = &dev_priv->regmap[pipe]; |
296 | int dpll_reg = (pipe == 0) ? MRST_DPLL_A : DPLL_B; | ||
297 | int dspcntr_reg = (pipe == 0) ? DSPACNTR : DSPBCNTR; | ||
298 | int pipeconf_reg = (pipe == 0) ? PIPEACONF : PIPEBCONF; | ||
299 | int htot_reg = (pipe == 0) ? HTOTAL_A : HTOTAL_B; | ||
300 | int hblank_reg = (pipe == 0) ? HBLANK_A : HBLANK_B; | ||
301 | int hsync_reg = (pipe == 0) ? HSYNC_A : HSYNC_B; | ||
302 | int vtot_reg = (pipe == 0) ? VTOTAL_A : VTOTAL_B; | ||
303 | int vblank_reg = (pipe == 0) ? VBLANK_A : VBLANK_B; | ||
304 | int vsync_reg = (pipe == 0) ? VSYNC_A : VSYNC_B; | ||
305 | int pipesrc_reg = (pipe == 0) ? PIPEASRC : PIPEBSRC; | ||
306 | int refclk = 0; | 294 | int refclk = 0; |
307 | struct oaktrail_clock_t clock; | 295 | struct oaktrail_clock_t clock; |
308 | u32 dpll = 0, fp = 0, dspcntr, pipeconf; | 296 | u32 dpll = 0, fp = 0, dspcntr, pipeconf; |
@@ -350,7 +338,7 @@ static int oaktrail_crtc_mode_set(struct drm_crtc *crtc, | |||
350 | if (oaktrail_panel_fitter_pipe(dev) == pipe) | 338 | if (oaktrail_panel_fitter_pipe(dev) == pipe) |
351 | REG_WRITE(PFIT_CONTROL, 0); | 339 | REG_WRITE(PFIT_CONTROL, 0); |
352 | 340 | ||
353 | REG_WRITE(pipesrc_reg, | 341 | REG_WRITE(map->src, |
354 | ((mode->crtc_hdisplay - 1) << 16) | | 342 | ((mode->crtc_hdisplay - 1) << 16) | |
355 | (mode->crtc_vdisplay - 1)); | 343 | (mode->crtc_vdisplay - 1)); |
356 | 344 | ||
@@ -369,34 +357,34 @@ static int oaktrail_crtc_mode_set(struct drm_crtc *crtc, | |||
369 | offsetY = (adjusted_mode->crtc_vdisplay - | 357 | offsetY = (adjusted_mode->crtc_vdisplay - |
370 | mode->crtc_vdisplay) / 2; | 358 | mode->crtc_vdisplay) / 2; |
371 | 359 | ||
372 | REG_WRITE(htot_reg, (mode->crtc_hdisplay - 1) | | 360 | REG_WRITE(map->htotal, (mode->crtc_hdisplay - 1) | |
373 | ((adjusted_mode->crtc_htotal - 1) << 16)); | 361 | ((adjusted_mode->crtc_htotal - 1) << 16)); |
374 | REG_WRITE(vtot_reg, (mode->crtc_vdisplay - 1) | | 362 | REG_WRITE(map->vtotal, (mode->crtc_vdisplay - 1) | |
375 | ((adjusted_mode->crtc_vtotal - 1) << 16)); | 363 | ((adjusted_mode->crtc_vtotal - 1) << 16)); |
376 | REG_WRITE(hblank_reg, | 364 | REG_WRITE(map->hblank, |
377 | (adjusted_mode->crtc_hblank_start - offsetX - 1) | | 365 | (adjusted_mode->crtc_hblank_start - offsetX - 1) | |
378 | ((adjusted_mode->crtc_hblank_end - offsetX - 1) << 16)); | 366 | ((adjusted_mode->crtc_hblank_end - offsetX - 1) << 16)); |
379 | REG_WRITE(hsync_reg, | 367 | REG_WRITE(map->hsync, |
380 | (adjusted_mode->crtc_hsync_start - offsetX - 1) | | 368 | (adjusted_mode->crtc_hsync_start - offsetX - 1) | |
381 | ((adjusted_mode->crtc_hsync_end - offsetX - 1) << 16)); | 369 | ((adjusted_mode->crtc_hsync_end - offsetX - 1) << 16)); |
382 | REG_WRITE(vblank_reg, | 370 | REG_WRITE(map->vblank, |
383 | (adjusted_mode->crtc_vblank_start - offsetY - 1) | | 371 | (adjusted_mode->crtc_vblank_start - offsetY - 1) | |
384 | ((adjusted_mode->crtc_vblank_end - offsetY - 1) << 16)); | 372 | ((adjusted_mode->crtc_vblank_end - offsetY - 1) << 16)); |
385 | REG_WRITE(vsync_reg, | 373 | REG_WRITE(map->vsync, |
386 | (adjusted_mode->crtc_vsync_start - offsetY - 1) | | 374 | (adjusted_mode->crtc_vsync_start - offsetY - 1) | |
387 | ((adjusted_mode->crtc_vsync_end - offsetY - 1) << 16)); | 375 | ((adjusted_mode->crtc_vsync_end - offsetY - 1) << 16)); |
388 | } else { | 376 | } else { |
389 | REG_WRITE(htot_reg, (adjusted_mode->crtc_hdisplay - 1) | | 377 | REG_WRITE(map->htotal, (adjusted_mode->crtc_hdisplay - 1) | |
390 | ((adjusted_mode->crtc_htotal - 1) << 16)); | 378 | ((adjusted_mode->crtc_htotal - 1) << 16)); |
391 | REG_WRITE(vtot_reg, (adjusted_mode->crtc_vdisplay - 1) | | 379 | REG_WRITE(map->vtotal, (adjusted_mode->crtc_vdisplay - 1) | |
392 | ((adjusted_mode->crtc_vtotal - 1) << 16)); | 380 | ((adjusted_mode->crtc_vtotal - 1) << 16)); |
393 | REG_WRITE(hblank_reg, (adjusted_mode->crtc_hblank_start - 1) | | 381 | REG_WRITE(map->hblank, (adjusted_mode->crtc_hblank_start - 1) | |
394 | ((adjusted_mode->crtc_hblank_end - 1) << 16)); | 382 | ((adjusted_mode->crtc_hblank_end - 1) << 16)); |
395 | REG_WRITE(hsync_reg, (adjusted_mode->crtc_hsync_start - 1) | | 383 | REG_WRITE(map->hsync, (adjusted_mode->crtc_hsync_start - 1) | |
396 | ((adjusted_mode->crtc_hsync_end - 1) << 16)); | 384 | ((adjusted_mode->crtc_hsync_end - 1) << 16)); |
397 | REG_WRITE(vblank_reg, (adjusted_mode->crtc_vblank_start - 1) | | 385 | REG_WRITE(map->vblank, (adjusted_mode->crtc_vblank_start - 1) | |
398 | ((adjusted_mode->crtc_vblank_end - 1) << 16)); | 386 | ((adjusted_mode->crtc_vblank_end - 1) << 16)); |
399 | REG_WRITE(vsync_reg, (adjusted_mode->crtc_vsync_start - 1) | | 387 | REG_WRITE(map->vsync, (adjusted_mode->crtc_vsync_start - 1) | |
400 | ((adjusted_mode->crtc_vsync_end - 1) << 16)); | 388 | ((adjusted_mode->crtc_vsync_end - 1) << 16)); |
401 | } | 389 | } |
402 | 390 | ||
@@ -408,10 +396,10 @@ static int oaktrail_crtc_mode_set(struct drm_crtc *crtc, | |||
408 | } | 396 | } |
409 | 397 | ||
410 | /* setup pipeconf */ | 398 | /* setup pipeconf */ |
411 | pipeconf = REG_READ(pipeconf_reg); | 399 | pipeconf = REG_READ(map->conf); |
412 | 400 | ||
413 | /* Set up the display plane register */ | 401 | /* Set up the display plane register */ |
414 | dspcntr = REG_READ(dspcntr_reg); | 402 | dspcntr = REG_READ(map->cntr); |
415 | dspcntr |= DISPPLANE_GAMMA_ENABLE; | 403 | dspcntr |= DISPPLANE_GAMMA_ENABLE; |
416 | 404 | ||
417 | if (pipe == 0) | 405 | if (pipe == 0) |
@@ -467,30 +455,30 @@ static int oaktrail_crtc_mode_set(struct drm_crtc *crtc, | |||
467 | mrstPrintPll("chosen", &clock); | 455 | mrstPrintPll("chosen", &clock); |
468 | 456 | ||
469 | if (dpll & DPLL_VCO_ENABLE) { | 457 | if (dpll & DPLL_VCO_ENABLE) { |
470 | REG_WRITE(fp_reg, fp); | 458 | REG_WRITE(map->fp0, fp); |
471 | REG_WRITE(dpll_reg, dpll & ~DPLL_VCO_ENABLE); | 459 | REG_WRITE(map->dpll, dpll & ~DPLL_VCO_ENABLE); |
472 | REG_READ(dpll_reg); | 460 | REG_READ(map->dpll); |
473 | /* Check the DPLLA lock bit PIPEACONF[29] */ | 461 | /* Check the DPLLA lock bit PIPEACONF[29] */ |
474 | udelay(150); | 462 | udelay(150); |
475 | } | 463 | } |
476 | 464 | ||
477 | REG_WRITE(fp_reg, fp); | 465 | REG_WRITE(map->fp0, fp); |
478 | REG_WRITE(dpll_reg, dpll); | 466 | REG_WRITE(map->dpll, dpll); |
479 | REG_READ(dpll_reg); | 467 | REG_READ(map->dpll); |
480 | /* Wait for the clocks to stabilize. */ | 468 | /* Wait for the clocks to stabilize. */ |
481 | udelay(150); | 469 | udelay(150); |
482 | 470 | ||
483 | /* write it again -- the BIOS does, after all */ | 471 | /* write it again -- the BIOS does, after all */ |
484 | REG_WRITE(dpll_reg, dpll); | 472 | REG_WRITE(map->dpll, dpll); |
485 | REG_READ(dpll_reg); | 473 | REG_READ(map->dpll); |
486 | /* Wait for the clocks to stabilize. */ | 474 | /* Wait for the clocks to stabilize. */ |
487 | udelay(150); | 475 | udelay(150); |
488 | 476 | ||
489 | REG_WRITE(pipeconf_reg, pipeconf); | 477 | REG_WRITE(map->conf, pipeconf); |
490 | REG_READ(pipeconf_reg); | 478 | REG_READ(map->conf); |
491 | psb_intel_wait_for_vblank(dev); | 479 | psb_intel_wait_for_vblank(dev); |
492 | 480 | ||
493 | REG_WRITE(dspcntr_reg, dspcntr); | 481 | REG_WRITE(map->cntr, dspcntr); |
494 | psb_intel_wait_for_vblank(dev); | 482 | psb_intel_wait_for_vblank(dev); |
495 | 483 | ||
496 | oaktrail_crtc_mode_set_exit: | 484 | oaktrail_crtc_mode_set_exit: |
@@ -509,15 +497,13 @@ static int oaktrail_pipe_set_base(struct drm_crtc *crtc, | |||
509 | int x, int y, struct drm_framebuffer *old_fb) | 497 | int x, int y, struct drm_framebuffer *old_fb) |
510 | { | 498 | { |
511 | struct drm_device *dev = crtc->dev; | 499 | struct drm_device *dev = crtc->dev; |
500 | struct drm_psb_private *dev_priv = dev->dev_private; | ||
512 | struct psb_intel_crtc *psb_intel_crtc = to_psb_intel_crtc(crtc); | 501 | struct psb_intel_crtc *psb_intel_crtc = to_psb_intel_crtc(crtc); |
513 | struct psb_framebuffer *psbfb = to_psb_fb(crtc->fb); | 502 | struct psb_framebuffer *psbfb = to_psb_fb(crtc->fb); |
514 | int pipe = psb_intel_crtc->pipe; | 503 | int pipe = psb_intel_crtc->pipe; |
504 | const struct psb_offset *map = &dev_priv->regmap[pipe]; | ||
515 | unsigned long start, offset; | 505 | unsigned long start, offset; |
516 | 506 | ||
517 | int dspbase = (pipe == 0 ? DSPALINOFF : DSPBBASE); | ||
518 | int dspsurf = (pipe == 0 ? DSPASURF : DSPBSURF); | ||
519 | int dspstride = (pipe == 0) ? DSPASTRIDE : DSPBSTRIDE; | ||
520 | int dspcntr_reg = (pipe == 0) ? DSPACNTR : DSPBCNTR; | ||
521 | u32 dspcntr; | 507 | u32 dspcntr; |
522 | int ret = 0; | 508 | int ret = 0; |
523 | 509 | ||
@@ -533,9 +519,9 @@ static int oaktrail_pipe_set_base(struct drm_crtc *crtc, | |||
533 | start = psbfb->gtt->offset; | 519 | start = psbfb->gtt->offset; |
534 | offset = y * crtc->fb->pitches[0] + x * (crtc->fb->bits_per_pixel / 8); | 520 | offset = y * crtc->fb->pitches[0] + x * (crtc->fb->bits_per_pixel / 8); |
535 | 521 | ||
536 | REG_WRITE(dspstride, crtc->fb->pitches[0]); | 522 | REG_WRITE(map->stride, crtc->fb->pitches[0]); |
537 | 523 | ||
538 | dspcntr = REG_READ(dspcntr_reg); | 524 | dspcntr = REG_READ(map->cntr); |
539 | dspcntr &= ~DISPPLANE_PIXFORMAT_MASK; | 525 | dspcntr &= ~DISPPLANE_PIXFORMAT_MASK; |
540 | 526 | ||
541 | switch (crtc->fb->bits_per_pixel) { | 527 | switch (crtc->fb->bits_per_pixel) { |
@@ -557,12 +543,12 @@ static int oaktrail_pipe_set_base(struct drm_crtc *crtc, | |||
557 | ret = -EINVAL; | 543 | ret = -EINVAL; |
558 | goto pipe_set_base_exit; | 544 | goto pipe_set_base_exit; |
559 | } | 545 | } |
560 | REG_WRITE(dspcntr_reg, dspcntr); | 546 | REG_WRITE(map->cntr, dspcntr); |
561 | 547 | ||
562 | REG_WRITE(dspbase, offset); | 548 | REG_WRITE(map->base, offset); |
563 | REG_READ(dspbase); | 549 | REG_READ(map->base); |
564 | REG_WRITE(dspsurf, start); | 550 | REG_WRITE(map->surf, start); |
565 | REG_READ(dspsurf); | 551 | REG_READ(map->surf); |
566 | 552 | ||
567 | pipe_set_base_exit: | 553 | pipe_set_base_exit: |
568 | gma_power_end(dev); | 554 | gma_power_end(dev); |
diff --git a/drivers/gpu/drm/gma500/oaktrail_device.c b/drivers/gpu/drm/gma500/oaktrail_device.c index 3c3c862ef61e..a8eb8014871f 100644 --- a/drivers/gpu/drm/gma500/oaktrail_device.c +++ b/drivers/gpu/drm/gma500/oaktrail_device.c | |||
@@ -475,7 +475,7 @@ static const struct psb_offset oaktrail_regmap[2] = { | |||
475 | .size = DSPASIZE, | 475 | .size = DSPASIZE, |
476 | .pos = DSPAPOS, | 476 | .pos = DSPAPOS, |
477 | .surf = DSPASURF, | 477 | .surf = DSPASURF, |
478 | .addr = DSPABASE, | 478 | .addr = MRST_DSPABASE, |
479 | .status = PIPEASTAT, | 479 | .status = PIPEASTAT, |
480 | .linoff = DSPALINOFF, | 480 | .linoff = DSPALINOFF, |
481 | .tileoff = DSPATILEOFF, | 481 | .tileoff = DSPATILEOFF, |
diff --git a/drivers/gpu/drm/gma500/psb_intel_display.c b/drivers/gpu/drm/gma500/psb_intel_display.c index 2cda49dc3307..f3a3160aafdc 100644 --- a/drivers/gpu/drm/gma500/psb_intel_display.c +++ b/drivers/gpu/drm/gma500/psb_intel_display.c | |||
@@ -337,15 +337,12 @@ static int psb_intel_pipe_set_base(struct drm_crtc *crtc, | |||
337 | int x, int y, struct drm_framebuffer *old_fb) | 337 | int x, int y, struct drm_framebuffer *old_fb) |
338 | { | 338 | { |
339 | struct drm_device *dev = crtc->dev; | 339 | struct drm_device *dev = crtc->dev; |
340 | /* struct drm_i915_master_private *master_priv; */ | 340 | struct drm_psb_private *dev_priv = dev->dev_private; |
341 | struct psb_intel_crtc *psb_intel_crtc = to_psb_intel_crtc(crtc); | 341 | struct psb_intel_crtc *psb_intel_crtc = to_psb_intel_crtc(crtc); |
342 | struct psb_framebuffer *psbfb = to_psb_fb(crtc->fb); | 342 | struct psb_framebuffer *psbfb = to_psb_fb(crtc->fb); |
343 | int pipe = psb_intel_crtc->pipe; | 343 | int pipe = psb_intel_crtc->pipe; |
344 | const struct psb_offset *map = &dev_priv->regmap[pipe]; | ||
344 | unsigned long start, offset; | 345 | unsigned long start, offset; |
345 | int dspbase = (pipe == 0 ? DSPABASE : DSPBBASE); | ||
346 | int dspsurf = (pipe == 0 ? DSPASURF : DSPBSURF); | ||
347 | int dspstride = (pipe == 0) ? DSPASTRIDE : DSPBSTRIDE; | ||
348 | int dspcntr_reg = (pipe == 0) ? DSPACNTR : DSPBCNTR; | ||
349 | u32 dspcntr; | 346 | u32 dspcntr; |
350 | int ret = 0; | 347 | int ret = 0; |
351 | 348 | ||
@@ -367,9 +364,9 @@ static int psb_intel_pipe_set_base(struct drm_crtc *crtc, | |||
367 | 364 | ||
368 | offset = y * crtc->fb->pitches[0] + x * (crtc->fb->bits_per_pixel / 8); | 365 | offset = y * crtc->fb->pitches[0] + x * (crtc->fb->bits_per_pixel / 8); |
369 | 366 | ||
370 | REG_WRITE(dspstride, crtc->fb->pitches[0]); | 367 | REG_WRITE(map->stride, crtc->fb->pitches[0]); |
371 | 368 | ||
372 | dspcntr = REG_READ(dspcntr_reg); | 369 | dspcntr = REG_READ(map->cntr); |
373 | dspcntr &= ~DISPPLANE_PIXFORMAT_MASK; | 370 | dspcntr &= ~DISPPLANE_PIXFORMAT_MASK; |
374 | 371 | ||
375 | switch (crtc->fb->bits_per_pixel) { | 372 | switch (crtc->fb->bits_per_pixel) { |
@@ -392,18 +389,10 @@ static int psb_intel_pipe_set_base(struct drm_crtc *crtc, | |||
392 | psb_gtt_unpin(psbfb->gtt); | 389 | psb_gtt_unpin(psbfb->gtt); |
393 | goto psb_intel_pipe_set_base_exit; | 390 | goto psb_intel_pipe_set_base_exit; |
394 | } | 391 | } |
395 | REG_WRITE(dspcntr_reg, dspcntr); | 392 | REG_WRITE(map->cntr, dspcntr); |
396 | |||
397 | 393 | ||
398 | if (0 /* FIXMEAC - check what PSB needs */) { | 394 | REG_WRITE(map->base, start + offset); |
399 | REG_WRITE(dspbase, offset); | 395 | REG_READ(map->base); |
400 | REG_READ(dspbase); | ||
401 | REG_WRITE(dspsurf, start); | ||
402 | REG_READ(dspsurf); | ||
403 | } else { | ||
404 | REG_WRITE(dspbase, start + offset); | ||
405 | REG_READ(dspbase); | ||
406 | } | ||
407 | 396 | ||
408 | psb_intel_pipe_cleaner: | 397 | psb_intel_pipe_cleaner: |
409 | /* If there was a previous display we can now unpin it */ | 398 | /* If there was a previous display we can now unpin it */ |
@@ -424,14 +413,10 @@ psb_intel_pipe_set_base_exit: | |||
424 | static void psb_intel_crtc_dpms(struct drm_crtc *crtc, int mode) | 413 | static void psb_intel_crtc_dpms(struct drm_crtc *crtc, int mode) |
425 | { | 414 | { |
426 | struct drm_device *dev = crtc->dev; | 415 | struct drm_device *dev = crtc->dev; |
427 | /* struct drm_i915_master_private *master_priv; */ | 416 | struct drm_psb_private *dev_priv = dev->dev_private; |
428 | /* struct drm_i915_private *dev_priv = dev->dev_private; */ | ||
429 | struct psb_intel_crtc *psb_intel_crtc = to_psb_intel_crtc(crtc); | 417 | struct psb_intel_crtc *psb_intel_crtc = to_psb_intel_crtc(crtc); |
430 | int pipe = psb_intel_crtc->pipe; | 418 | int pipe = psb_intel_crtc->pipe; |
431 | int dpll_reg = (pipe == 0) ? DPLL_A : DPLL_B; | 419 | const struct psb_offset *map = &dev_priv->regmap[pipe]; |
432 | int dspcntr_reg = (pipe == 0) ? DSPACNTR : DSPBCNTR; | ||
433 | int dspbase_reg = (pipe == 0) ? DSPABASE : DSPBBASE; | ||
434 | int pipeconf_reg = (pipe == 0) ? PIPEACONF : PIPEBCONF; | ||
435 | u32 temp; | 420 | u32 temp; |
436 | 421 | ||
437 | /* XXX: When our outputs are all unaware of DPMS modes other than off | 422 | /* XXX: When our outputs are all unaware of DPMS modes other than off |
@@ -442,34 +427,34 @@ static void psb_intel_crtc_dpms(struct drm_crtc *crtc, int mode) | |||
442 | case DRM_MODE_DPMS_STANDBY: | 427 | case DRM_MODE_DPMS_STANDBY: |
443 | case DRM_MODE_DPMS_SUSPEND: | 428 | case DRM_MODE_DPMS_SUSPEND: |
444 | /* Enable the DPLL */ | 429 | /* Enable the DPLL */ |
445 | temp = REG_READ(dpll_reg); | 430 | temp = REG_READ(map->dpll); |
446 | if ((temp & DPLL_VCO_ENABLE) == 0) { | 431 | if ((temp & DPLL_VCO_ENABLE) == 0) { |
447 | REG_WRITE(dpll_reg, temp); | 432 | REG_WRITE(map->dpll, temp); |
448 | REG_READ(dpll_reg); | 433 | REG_READ(map->dpll); |
449 | /* Wait for the clocks to stabilize. */ | 434 | /* Wait for the clocks to stabilize. */ |
450 | udelay(150); | 435 | udelay(150); |
451 | REG_WRITE(dpll_reg, temp | DPLL_VCO_ENABLE); | 436 | REG_WRITE(map->dpll, temp | DPLL_VCO_ENABLE); |
452 | REG_READ(dpll_reg); | 437 | REG_READ(map->dpll); |
453 | /* Wait for the clocks to stabilize. */ | 438 | /* Wait for the clocks to stabilize. */ |
454 | udelay(150); | 439 | udelay(150); |
455 | REG_WRITE(dpll_reg, temp | DPLL_VCO_ENABLE); | 440 | REG_WRITE(map->dpll, temp | DPLL_VCO_ENABLE); |
456 | REG_READ(dpll_reg); | 441 | REG_READ(map->dpll); |
457 | /* Wait for the clocks to stabilize. */ | 442 | /* Wait for the clocks to stabilize. */ |
458 | udelay(150); | 443 | udelay(150); |
459 | } | 444 | } |
460 | 445 | ||
461 | /* Enable the pipe */ | 446 | /* Enable the pipe */ |
462 | temp = REG_READ(pipeconf_reg); | 447 | temp = REG_READ(map->conf); |
463 | if ((temp & PIPEACONF_ENABLE) == 0) | 448 | if ((temp & PIPEACONF_ENABLE) == 0) |
464 | REG_WRITE(pipeconf_reg, temp | PIPEACONF_ENABLE); | 449 | REG_WRITE(map->conf, temp | PIPEACONF_ENABLE); |
465 | 450 | ||
466 | /* Enable the plane */ | 451 | /* Enable the plane */ |
467 | temp = REG_READ(dspcntr_reg); | 452 | temp = REG_READ(map->cntr); |
468 | if ((temp & DISPLAY_PLANE_ENABLE) == 0) { | 453 | if ((temp & DISPLAY_PLANE_ENABLE) == 0) { |
469 | REG_WRITE(dspcntr_reg, | 454 | REG_WRITE(map->cntr, |
470 | temp | DISPLAY_PLANE_ENABLE); | 455 | temp | DISPLAY_PLANE_ENABLE); |
471 | /* Flush the plane changes */ | 456 | /* Flush the plane changes */ |
472 | REG_WRITE(dspbase_reg, REG_READ(dspbase_reg)); | 457 | REG_WRITE(map->base, REG_READ(map->base)); |
473 | } | 458 | } |
474 | 459 | ||
475 | psb_intel_crtc_load_lut(crtc); | 460 | psb_intel_crtc_load_lut(crtc); |
@@ -487,29 +472,29 @@ static void psb_intel_crtc_dpms(struct drm_crtc *crtc, int mode) | |||
487 | REG_WRITE(VGACNTRL, VGA_DISP_DISABLE); | 472 | REG_WRITE(VGACNTRL, VGA_DISP_DISABLE); |
488 | 473 | ||
489 | /* Disable display plane */ | 474 | /* Disable display plane */ |
490 | temp = REG_READ(dspcntr_reg); | 475 | temp = REG_READ(map->cntr); |
491 | if ((temp & DISPLAY_PLANE_ENABLE) != 0) { | 476 | if ((temp & DISPLAY_PLANE_ENABLE) != 0) { |
492 | REG_WRITE(dspcntr_reg, | 477 | REG_WRITE(map->cntr, |
493 | temp & ~DISPLAY_PLANE_ENABLE); | 478 | temp & ~DISPLAY_PLANE_ENABLE); |
494 | /* Flush the plane changes */ | 479 | /* Flush the plane changes */ |
495 | REG_WRITE(dspbase_reg, REG_READ(dspbase_reg)); | 480 | REG_WRITE(map->base, REG_READ(map->base)); |
496 | REG_READ(dspbase_reg); | 481 | REG_READ(map->base); |
497 | } | 482 | } |
498 | 483 | ||
499 | /* Next, disable display pipes */ | 484 | /* Next, disable display pipes */ |
500 | temp = REG_READ(pipeconf_reg); | 485 | temp = REG_READ(map->conf); |
501 | if ((temp & PIPEACONF_ENABLE) != 0) { | 486 | if ((temp & PIPEACONF_ENABLE) != 0) { |
502 | REG_WRITE(pipeconf_reg, temp & ~PIPEACONF_ENABLE); | 487 | REG_WRITE(map->conf, temp & ~PIPEACONF_ENABLE); |
503 | REG_READ(pipeconf_reg); | 488 | REG_READ(map->conf); |
504 | } | 489 | } |
505 | 490 | ||
506 | /* Wait for vblank for the disable to take effect. */ | 491 | /* Wait for vblank for the disable to take effect. */ |
507 | psb_intel_wait_for_vblank(dev); | 492 | psb_intel_wait_for_vblank(dev); |
508 | 493 | ||
509 | temp = REG_READ(dpll_reg); | 494 | temp = REG_READ(map->dpll); |
510 | if ((temp & DPLL_VCO_ENABLE) != 0) { | 495 | if ((temp & DPLL_VCO_ENABLE) != 0) { |
511 | REG_WRITE(dpll_reg, temp & ~DPLL_VCO_ENABLE); | 496 | REG_WRITE(map->dpll, temp & ~DPLL_VCO_ENABLE); |
512 | REG_READ(dpll_reg); | 497 | REG_READ(map->dpll); |
513 | } | 498 | } |
514 | 499 | ||
515 | /* Wait for the clocks to turn off. */ | 500 | /* Wait for the clocks to turn off. */ |
@@ -589,22 +574,11 @@ static int psb_intel_crtc_mode_set(struct drm_crtc *crtc, | |||
589 | struct drm_framebuffer *old_fb) | 574 | struct drm_framebuffer *old_fb) |
590 | { | 575 | { |
591 | struct drm_device *dev = crtc->dev; | 576 | struct drm_device *dev = crtc->dev; |
577 | struct drm_psb_private *dev_priv = dev->dev_private; | ||
592 | struct psb_intel_crtc *psb_intel_crtc = to_psb_intel_crtc(crtc); | 578 | struct psb_intel_crtc *psb_intel_crtc = to_psb_intel_crtc(crtc); |
593 | struct drm_crtc_helper_funcs *crtc_funcs = crtc->helper_private; | 579 | struct drm_crtc_helper_funcs *crtc_funcs = crtc->helper_private; |
594 | int pipe = psb_intel_crtc->pipe; | 580 | int pipe = psb_intel_crtc->pipe; |
595 | int fp_reg = (pipe == 0) ? FPA0 : FPB0; | 581 | const struct psb_offset *map = &dev_priv->regmap[pipe]; |
596 | int dpll_reg = (pipe == 0) ? DPLL_A : DPLL_B; | ||
597 | int dspcntr_reg = (pipe == 0) ? DSPACNTR : DSPBCNTR; | ||
598 | int pipeconf_reg = (pipe == 0) ? PIPEACONF : PIPEBCONF; | ||
599 | int htot_reg = (pipe == 0) ? HTOTAL_A : HTOTAL_B; | ||
600 | int hblank_reg = (pipe == 0) ? HBLANK_A : HBLANK_B; | ||
601 | int hsync_reg = (pipe == 0) ? HSYNC_A : HSYNC_B; | ||
602 | int vtot_reg = (pipe == 0) ? VTOTAL_A : VTOTAL_B; | ||
603 | int vblank_reg = (pipe == 0) ? VBLANK_A : VBLANK_B; | ||
604 | int vsync_reg = (pipe == 0) ? VSYNC_A : VSYNC_B; | ||
605 | int dspsize_reg = (pipe == 0) ? DSPASIZE : DSPBSIZE; | ||
606 | int dsppos_reg = (pipe == 0) ? DSPAPOS : DSPBPOS; | ||
607 | int pipesrc_reg = (pipe == 0) ? PIPEASRC : PIPEBSRC; | ||
608 | int refclk; | 582 | int refclk; |
609 | struct psb_intel_clock_t clock; | 583 | struct psb_intel_clock_t clock; |
610 | u32 dpll = 0, fp = 0, dspcntr, pipeconf; | 584 | u32 dpll = 0, fp = 0, dspcntr, pipeconf; |
@@ -690,7 +664,7 @@ static int psb_intel_crtc_mode_set(struct drm_crtc *crtc, | |||
690 | dpll |= PLL_REF_INPUT_DREFCLK; | 664 | dpll |= PLL_REF_INPUT_DREFCLK; |
691 | 665 | ||
692 | /* setup pipeconf */ | 666 | /* setup pipeconf */ |
693 | pipeconf = REG_READ(pipeconf_reg); | 667 | pipeconf = REG_READ(map->conf); |
694 | 668 | ||
695 | /* Set up the display plane register */ | 669 | /* Set up the display plane register */ |
696 | dspcntr = DISPPLANE_GAMMA_ENABLE; | 670 | dspcntr = DISPPLANE_GAMMA_ENABLE; |
@@ -712,9 +686,9 @@ static int psb_intel_crtc_mode_set(struct drm_crtc *crtc, | |||
712 | drm_mode_debug_printmodeline(mode); | 686 | drm_mode_debug_printmodeline(mode); |
713 | 687 | ||
714 | if (dpll & DPLL_VCO_ENABLE) { | 688 | if (dpll & DPLL_VCO_ENABLE) { |
715 | REG_WRITE(fp_reg, fp); | 689 | REG_WRITE(map->fp0, fp); |
716 | REG_WRITE(dpll_reg, dpll & ~DPLL_VCO_ENABLE); | 690 | REG_WRITE(map->dpll, dpll & ~DPLL_VCO_ENABLE); |
717 | REG_READ(dpll_reg); | 691 | REG_READ(map->dpll); |
718 | udelay(150); | 692 | udelay(150); |
719 | } | 693 | } |
720 | 694 | ||
@@ -747,45 +721,45 @@ static int psb_intel_crtc_mode_set(struct drm_crtc *crtc, | |||
747 | REG_READ(LVDS); | 721 | REG_READ(LVDS); |
748 | } | 722 | } |
749 | 723 | ||
750 | REG_WRITE(fp_reg, fp); | 724 | REG_WRITE(map->fp0, fp); |
751 | REG_WRITE(dpll_reg, dpll); | 725 | REG_WRITE(map->dpll, dpll); |
752 | REG_READ(dpll_reg); | 726 | REG_READ(map->dpll); |
753 | /* Wait for the clocks to stabilize. */ | 727 | /* Wait for the clocks to stabilize. */ |
754 | udelay(150); | 728 | udelay(150); |
755 | 729 | ||
756 | /* write it again -- the BIOS does, after all */ | 730 | /* write it again -- the BIOS does, after all */ |
757 | REG_WRITE(dpll_reg, dpll); | 731 | REG_WRITE(map->dpll, dpll); |
758 | 732 | ||
759 | REG_READ(dpll_reg); | 733 | REG_READ(map->dpll); |
760 | /* Wait for the clocks to stabilize. */ | 734 | /* Wait for the clocks to stabilize. */ |
761 | udelay(150); | 735 | udelay(150); |
762 | 736 | ||
763 | REG_WRITE(htot_reg, (adjusted_mode->crtc_hdisplay - 1) | | 737 | REG_WRITE(map->htotal, (adjusted_mode->crtc_hdisplay - 1) | |
764 | ((adjusted_mode->crtc_htotal - 1) << 16)); | 738 | ((adjusted_mode->crtc_htotal - 1) << 16)); |
765 | REG_WRITE(hblank_reg, (adjusted_mode->crtc_hblank_start - 1) | | 739 | REG_WRITE(map->hblank, (adjusted_mode->crtc_hblank_start - 1) | |
766 | ((adjusted_mode->crtc_hblank_end - 1) << 16)); | 740 | ((adjusted_mode->crtc_hblank_end - 1) << 16)); |
767 | REG_WRITE(hsync_reg, (adjusted_mode->crtc_hsync_start - 1) | | 741 | REG_WRITE(map->hsync, (adjusted_mode->crtc_hsync_start - 1) | |
768 | ((adjusted_mode->crtc_hsync_end - 1) << 16)); | 742 | ((adjusted_mode->crtc_hsync_end - 1) << 16)); |
769 | REG_WRITE(vtot_reg, (adjusted_mode->crtc_vdisplay - 1) | | 743 | REG_WRITE(map->vtotal, (adjusted_mode->crtc_vdisplay - 1) | |
770 | ((adjusted_mode->crtc_vtotal - 1) << 16)); | 744 | ((adjusted_mode->crtc_vtotal - 1) << 16)); |
771 | REG_WRITE(vblank_reg, (adjusted_mode->crtc_vblank_start - 1) | | 745 | REG_WRITE(map->vblank, (adjusted_mode->crtc_vblank_start - 1) | |
772 | ((adjusted_mode->crtc_vblank_end - 1) << 16)); | 746 | ((adjusted_mode->crtc_vblank_end - 1) << 16)); |
773 | REG_WRITE(vsync_reg, (adjusted_mode->crtc_vsync_start - 1) | | 747 | REG_WRITE(map->vsync, (adjusted_mode->crtc_vsync_start - 1) | |
774 | ((adjusted_mode->crtc_vsync_end - 1) << 16)); | 748 | ((adjusted_mode->crtc_vsync_end - 1) << 16)); |
775 | /* pipesrc and dspsize control the size that is scaled from, | 749 | /* pipesrc and dspsize control the size that is scaled from, |
776 | * which should always be the user's requested size. | 750 | * which should always be the user's requested size. |
777 | */ | 751 | */ |
778 | REG_WRITE(dspsize_reg, | 752 | REG_WRITE(map->size, |
779 | ((mode->vdisplay - 1) << 16) | (mode->hdisplay - 1)); | 753 | ((mode->vdisplay - 1) << 16) | (mode->hdisplay - 1)); |
780 | REG_WRITE(dsppos_reg, 0); | 754 | REG_WRITE(map->pos, 0); |
781 | REG_WRITE(pipesrc_reg, | 755 | REG_WRITE(map->src, |
782 | ((mode->hdisplay - 1) << 16) | (mode->vdisplay - 1)); | 756 | ((mode->hdisplay - 1) << 16) | (mode->vdisplay - 1)); |
783 | REG_WRITE(pipeconf_reg, pipeconf); | 757 | REG_WRITE(map->conf, pipeconf); |
784 | REG_READ(pipeconf_reg); | 758 | REG_READ(map->conf); |
785 | 759 | ||
786 | psb_intel_wait_for_vblank(dev); | 760 | psb_intel_wait_for_vblank(dev); |
787 | 761 | ||
788 | REG_WRITE(dspcntr_reg, dspcntr); | 762 | REG_WRITE(map->cntr, dspcntr); |
789 | 763 | ||
790 | /* Flush the plane changes */ | 764 | /* Flush the plane changes */ |
791 | crtc_funcs->mode_set_base(crtc, x, y, old_fb); | 765 | crtc_funcs->mode_set_base(crtc, x, y, old_fb); |
@@ -801,7 +775,8 @@ void psb_intel_crtc_load_lut(struct drm_crtc *crtc) | |||
801 | struct drm_device *dev = crtc->dev; | 775 | struct drm_device *dev = crtc->dev; |
802 | struct drm_psb_private *dev_priv = dev->dev_private; | 776 | struct drm_psb_private *dev_priv = dev->dev_private; |
803 | struct psb_intel_crtc *psb_intel_crtc = to_psb_intel_crtc(crtc); | 777 | struct psb_intel_crtc *psb_intel_crtc = to_psb_intel_crtc(crtc); |
804 | int palreg = PALETTE_A; | 778 | const struct psb_offset *map = &dev_priv->regmap[psb_intel_crtc->pipe]; |
779 | int palreg = map->palette; | ||
805 | int i; | 780 | int i; |
806 | 781 | ||
807 | /* The clocks have to be on to load the palette. */ | 782 | /* The clocks have to be on to load the palette. */ |
@@ -810,12 +785,7 @@ void psb_intel_crtc_load_lut(struct drm_crtc *crtc) | |||
810 | 785 | ||
811 | switch (psb_intel_crtc->pipe) { | 786 | switch (psb_intel_crtc->pipe) { |
812 | case 0: | 787 | case 0: |
813 | break; | ||
814 | case 1: | 788 | case 1: |
815 | palreg = PALETTE_B; | ||
816 | break; | ||
817 | case 2: | ||
818 | palreg = PALETTE_C; | ||
819 | break; | 789 | break; |
820 | default: | 790 | default: |
821 | dev_err(dev->dev, "Illegal Pipe Number.\n"); | 791 | dev_err(dev->dev, "Illegal Pipe Number.\n"); |
@@ -853,11 +823,10 @@ void psb_intel_crtc_load_lut(struct drm_crtc *crtc) | |||
853 | static void psb_intel_crtc_save(struct drm_crtc *crtc) | 823 | static void psb_intel_crtc_save(struct drm_crtc *crtc) |
854 | { | 824 | { |
855 | struct drm_device *dev = crtc->dev; | 825 | struct drm_device *dev = crtc->dev; |
856 | /* struct drm_psb_private *dev_priv = | 826 | struct drm_psb_private *dev_priv = dev->dev_private; |
857 | (struct drm_psb_private *)dev->dev_private; */ | ||
858 | struct psb_intel_crtc *psb_intel_crtc = to_psb_intel_crtc(crtc); | 827 | struct psb_intel_crtc *psb_intel_crtc = to_psb_intel_crtc(crtc); |
859 | struct psb_intel_crtc_state *crtc_state = psb_intel_crtc->crtc_state; | 828 | struct psb_intel_crtc_state *crtc_state = psb_intel_crtc->crtc_state; |
860 | int pipeA = (psb_intel_crtc->pipe == 0); | 829 | const struct psb_offset *map = &dev_priv->regmap[psb_intel_crtc->pipe]; |
861 | uint32_t paletteReg; | 830 | uint32_t paletteReg; |
862 | int i; | 831 | int i; |
863 | 832 | ||
@@ -866,27 +835,27 @@ static void psb_intel_crtc_save(struct drm_crtc *crtc) | |||
866 | return; | 835 | return; |
867 | } | 836 | } |
868 | 837 | ||
869 | crtc_state->saveDSPCNTR = REG_READ(pipeA ? DSPACNTR : DSPBCNTR); | 838 | crtc_state->saveDSPCNTR = REG_READ(map->cntr); |
870 | crtc_state->savePIPECONF = REG_READ(pipeA ? PIPEACONF : PIPEBCONF); | 839 | crtc_state->savePIPECONF = REG_READ(map->conf); |
871 | crtc_state->savePIPESRC = REG_READ(pipeA ? PIPEASRC : PIPEBSRC); | 840 | crtc_state->savePIPESRC = REG_READ(map->src); |
872 | crtc_state->saveFP0 = REG_READ(pipeA ? FPA0 : FPB0); | 841 | crtc_state->saveFP0 = REG_READ(map->fp0); |
873 | crtc_state->saveFP1 = REG_READ(pipeA ? FPA1 : FPB1); | 842 | crtc_state->saveFP1 = REG_READ(map->fp1); |
874 | crtc_state->saveDPLL = REG_READ(pipeA ? DPLL_A : DPLL_B); | 843 | crtc_state->saveDPLL = REG_READ(map->dpll); |
875 | crtc_state->saveHTOTAL = REG_READ(pipeA ? HTOTAL_A : HTOTAL_B); | 844 | crtc_state->saveHTOTAL = REG_READ(map->htotal); |
876 | crtc_state->saveHBLANK = REG_READ(pipeA ? HBLANK_A : HBLANK_B); | 845 | crtc_state->saveHBLANK = REG_READ(map->hblank); |
877 | crtc_state->saveHSYNC = REG_READ(pipeA ? HSYNC_A : HSYNC_B); | 846 | crtc_state->saveHSYNC = REG_READ(map->hsync); |
878 | crtc_state->saveVTOTAL = REG_READ(pipeA ? VTOTAL_A : VTOTAL_B); | 847 | crtc_state->saveVTOTAL = REG_READ(map->vtotal); |
879 | crtc_state->saveVBLANK = REG_READ(pipeA ? VBLANK_A : VBLANK_B); | 848 | crtc_state->saveVBLANK = REG_READ(map->vblank); |
880 | crtc_state->saveVSYNC = REG_READ(pipeA ? VSYNC_A : VSYNC_B); | 849 | crtc_state->saveVSYNC = REG_READ(map->vsync); |
881 | crtc_state->saveDSPSTRIDE = REG_READ(pipeA ? DSPASTRIDE : DSPBSTRIDE); | 850 | crtc_state->saveDSPSTRIDE = REG_READ(map->stride); |
882 | 851 | ||
883 | /*NOTE: DSPSIZE DSPPOS only for psb*/ | 852 | /*NOTE: DSPSIZE DSPPOS only for psb*/ |
884 | crtc_state->saveDSPSIZE = REG_READ(pipeA ? DSPASIZE : DSPBSIZE); | 853 | crtc_state->saveDSPSIZE = REG_READ(map->size); |
885 | crtc_state->saveDSPPOS = REG_READ(pipeA ? DSPAPOS : DSPBPOS); | 854 | crtc_state->saveDSPPOS = REG_READ(map->pos); |
886 | 855 | ||
887 | crtc_state->saveDSPBASE = REG_READ(pipeA ? DSPABASE : DSPBBASE); | 856 | crtc_state->saveDSPBASE = REG_READ(map->base); |
888 | 857 | ||
889 | paletteReg = pipeA ? PALETTE_A : PALETTE_B; | 858 | paletteReg = map->palette; |
890 | for (i = 0; i < 256; ++i) | 859 | for (i = 0; i < 256; ++i) |
891 | crtc_state->savePalette[i] = REG_READ(paletteReg + (i << 2)); | 860 | crtc_state->savePalette[i] = REG_READ(paletteReg + (i << 2)); |
892 | } | 861 | } |
@@ -897,12 +866,10 @@ static void psb_intel_crtc_save(struct drm_crtc *crtc) | |||
897 | static void psb_intel_crtc_restore(struct drm_crtc *crtc) | 866 | static void psb_intel_crtc_restore(struct drm_crtc *crtc) |
898 | { | 867 | { |
899 | struct drm_device *dev = crtc->dev; | 868 | struct drm_device *dev = crtc->dev; |
900 | /* struct drm_psb_private * dev_priv = | 869 | struct drm_psb_private *dev_priv = dev->dev_private; |
901 | (struct drm_psb_private *)dev->dev_private; */ | ||
902 | struct psb_intel_crtc *psb_intel_crtc = to_psb_intel_crtc(crtc); | 870 | struct psb_intel_crtc *psb_intel_crtc = to_psb_intel_crtc(crtc); |
903 | struct psb_intel_crtc_state *crtc_state = psb_intel_crtc->crtc_state; | 871 | struct psb_intel_crtc_state *crtc_state = psb_intel_crtc->crtc_state; |
904 | /* struct drm_crtc_helper_funcs * crtc_funcs = crtc->helper_private; */ | 872 | const struct psb_offset *map = &dev_priv->regmap[psb_intel_crtc->pipe]; |
905 | int pipeA = (psb_intel_crtc->pipe == 0); | ||
906 | uint32_t paletteReg; | 873 | uint32_t paletteReg; |
907 | int i; | 874 | int i; |
908 | 875 | ||
@@ -912,45 +879,45 @@ static void psb_intel_crtc_restore(struct drm_crtc *crtc) | |||
912 | } | 879 | } |
913 | 880 | ||
914 | if (crtc_state->saveDPLL & DPLL_VCO_ENABLE) { | 881 | if (crtc_state->saveDPLL & DPLL_VCO_ENABLE) { |
915 | REG_WRITE(pipeA ? DPLL_A : DPLL_B, | 882 | REG_WRITE(map->dpll, |
916 | crtc_state->saveDPLL & ~DPLL_VCO_ENABLE); | 883 | crtc_state->saveDPLL & ~DPLL_VCO_ENABLE); |
917 | REG_READ(pipeA ? DPLL_A : DPLL_B); | 884 | REG_READ(map->dpll); |
918 | udelay(150); | 885 | udelay(150); |
919 | } | 886 | } |
920 | 887 | ||
921 | REG_WRITE(pipeA ? FPA0 : FPB0, crtc_state->saveFP0); | 888 | REG_WRITE(map->fp0, crtc_state->saveFP0); |
922 | REG_READ(pipeA ? FPA0 : FPB0); | 889 | REG_READ(map->fp0); |
923 | 890 | ||
924 | REG_WRITE(pipeA ? FPA1 : FPB1, crtc_state->saveFP1); | 891 | REG_WRITE(map->fp1, crtc_state->saveFP1); |
925 | REG_READ(pipeA ? FPA1 : FPB1); | 892 | REG_READ(map->fp1); |
926 | 893 | ||
927 | REG_WRITE(pipeA ? DPLL_A : DPLL_B, crtc_state->saveDPLL); | 894 | REG_WRITE(map->dpll, crtc_state->saveDPLL); |
928 | REG_READ(pipeA ? DPLL_A : DPLL_B); | 895 | REG_READ(map->dpll); |
929 | udelay(150); | 896 | udelay(150); |
930 | 897 | ||
931 | REG_WRITE(pipeA ? HTOTAL_A : HTOTAL_B, crtc_state->saveHTOTAL); | 898 | REG_WRITE(map->htotal, crtc_state->saveHTOTAL); |
932 | REG_WRITE(pipeA ? HBLANK_A : HBLANK_B, crtc_state->saveHBLANK); | 899 | REG_WRITE(map->hblank, crtc_state->saveHBLANK); |
933 | REG_WRITE(pipeA ? HSYNC_A : HSYNC_B, crtc_state->saveHSYNC); | 900 | REG_WRITE(map->hsync, crtc_state->saveHSYNC); |
934 | REG_WRITE(pipeA ? VTOTAL_A : VTOTAL_B, crtc_state->saveVTOTAL); | 901 | REG_WRITE(map->vtotal, crtc_state->saveVTOTAL); |
935 | REG_WRITE(pipeA ? VBLANK_A : VBLANK_B, crtc_state->saveVBLANK); | 902 | REG_WRITE(map->vblank, crtc_state->saveVBLANK); |
936 | REG_WRITE(pipeA ? VSYNC_A : VSYNC_B, crtc_state->saveVSYNC); | 903 | REG_WRITE(map->vsync, crtc_state->saveVSYNC); |
937 | REG_WRITE(pipeA ? DSPASTRIDE : DSPBSTRIDE, crtc_state->saveDSPSTRIDE); | 904 | REG_WRITE(map->stride, crtc_state->saveDSPSTRIDE); |
938 | 905 | ||
939 | REG_WRITE(pipeA ? DSPASIZE : DSPBSIZE, crtc_state->saveDSPSIZE); | 906 | REG_WRITE(map->size, crtc_state->saveDSPSIZE); |
940 | REG_WRITE(pipeA ? DSPAPOS : DSPBPOS, crtc_state->saveDSPPOS); | 907 | REG_WRITE(map->pos, crtc_state->saveDSPPOS); |
941 | 908 | ||
942 | REG_WRITE(pipeA ? PIPEASRC : PIPEBSRC, crtc_state->savePIPESRC); | 909 | REG_WRITE(map->src, crtc_state->savePIPESRC); |
943 | REG_WRITE(pipeA ? DSPABASE : DSPBBASE, crtc_state->saveDSPBASE); | 910 | REG_WRITE(map->base, crtc_state->saveDSPBASE); |
944 | REG_WRITE(pipeA ? PIPEACONF : PIPEBCONF, crtc_state->savePIPECONF); | 911 | REG_WRITE(map->conf, crtc_state->savePIPECONF); |
945 | 912 | ||
946 | psb_intel_wait_for_vblank(dev); | 913 | psb_intel_wait_for_vblank(dev); |
947 | 914 | ||
948 | REG_WRITE(pipeA ? DSPACNTR : DSPBCNTR, crtc_state->saveDSPCNTR); | 915 | REG_WRITE(map->cntr, crtc_state->saveDSPCNTR); |
949 | REG_WRITE(pipeA ? DSPABASE : DSPBBASE, crtc_state->saveDSPBASE); | 916 | REG_WRITE(map->base, crtc_state->saveDSPBASE); |
950 | 917 | ||
951 | psb_intel_wait_for_vblank(dev); | 918 | psb_intel_wait_for_vblank(dev); |
952 | 919 | ||
953 | paletteReg = pipeA ? PALETTE_A : PALETTE_B; | 920 | paletteReg = map->palette; |
954 | for (i = 0; i < 256; ++i) | 921 | for (i = 0; i < 256; ++i) |
955 | REG_WRITE(paletteReg + (i << 2), crtc_state->savePalette[i]); | 922 | REG_WRITE(paletteReg + (i << 2), crtc_state->savePalette[i]); |
956 | } | 923 | } |
@@ -1114,20 +1081,21 @@ static int psb_intel_crtc_clock_get(struct drm_device *dev, | |||
1114 | struct drm_crtc *crtc) | 1081 | struct drm_crtc *crtc) |
1115 | { | 1082 | { |
1116 | struct psb_intel_crtc *psb_intel_crtc = to_psb_intel_crtc(crtc); | 1083 | struct psb_intel_crtc *psb_intel_crtc = to_psb_intel_crtc(crtc); |
1084 | struct drm_psb_private *dev_priv = dev->dev_private; | ||
1117 | int pipe = psb_intel_crtc->pipe; | 1085 | int pipe = psb_intel_crtc->pipe; |
1086 | const struct psb_offset *map = &dev_priv->regmap[pipe]; | ||
1118 | u32 dpll; | 1087 | u32 dpll; |
1119 | u32 fp; | 1088 | u32 fp; |
1120 | struct psb_intel_clock_t clock; | 1089 | struct psb_intel_clock_t clock; |
1121 | bool is_lvds; | 1090 | bool is_lvds; |
1122 | struct drm_psb_private *dev_priv = dev->dev_private; | ||
1123 | struct psb_pipe *p = &dev_priv->regs.pipe[pipe]; | 1091 | struct psb_pipe *p = &dev_priv->regs.pipe[pipe]; |
1124 | 1092 | ||
1125 | if (gma_power_begin(dev, false)) { | 1093 | if (gma_power_begin(dev, false)) { |
1126 | dpll = REG_READ((pipe == 0) ? DPLL_A : DPLL_B); | 1094 | dpll = REG_READ(map->dpll); |
1127 | if ((dpll & DISPLAY_RATE_SELECT_FPA1) == 0) | 1095 | if ((dpll & DISPLAY_RATE_SELECT_FPA1) == 0) |
1128 | fp = REG_READ((pipe == 0) ? FPA0 : FPB0); | 1096 | fp = REG_READ(map->fp0); |
1129 | else | 1097 | else |
1130 | fp = REG_READ((pipe == 0) ? FPA1 : FPB1); | 1098 | fp = REG_READ(map->fp1); |
1131 | is_lvds = (pipe == 1) && (REG_READ(LVDS) & LVDS_PORT_EN); | 1099 | is_lvds = (pipe == 1) && (REG_READ(LVDS) & LVDS_PORT_EN); |
1132 | gma_power_end(dev); | 1100 | gma_power_end(dev); |
1133 | } else { | 1101 | } else { |
@@ -1197,12 +1165,13 @@ struct drm_display_mode *psb_intel_crtc_mode_get(struct drm_device *dev, | |||
1197 | int vsync; | 1165 | int vsync; |
1198 | struct drm_psb_private *dev_priv = dev->dev_private; | 1166 | struct drm_psb_private *dev_priv = dev->dev_private; |
1199 | struct psb_pipe *p = &dev_priv->regs.pipe[pipe]; | 1167 | struct psb_pipe *p = &dev_priv->regs.pipe[pipe]; |
1168 | const struct psb_offset *map = &dev_priv->regmap[pipe]; | ||
1200 | 1169 | ||
1201 | if (gma_power_begin(dev, false)) { | 1170 | if (gma_power_begin(dev, false)) { |
1202 | htot = REG_READ((pipe == 0) ? HTOTAL_A : HTOTAL_B); | 1171 | htot = REG_READ(map->htotal); |
1203 | hsync = REG_READ((pipe == 0) ? HSYNC_A : HSYNC_B); | 1172 | hsync = REG_READ(map->hsync); |
1204 | vtot = REG_READ((pipe == 0) ? VTOTAL_A : VTOTAL_B); | 1173 | vtot = REG_READ(map->vtotal); |
1205 | vsync = REG_READ((pipe == 0) ? VSYNC_A : VSYNC_B); | 1174 | vsync = REG_READ(map->vsync); |
1206 | gma_power_end(dev); | 1175 | gma_power_end(dev); |
1207 | } else { | 1176 | } else { |
1208 | htot = p->htotal; | 1177 | htot = p->htotal; |