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 /drivers/gpu/drm/gma500/oaktrail_crtc.c | |
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>
Diffstat (limited to 'drivers/gpu/drm/gma500/oaktrail_crtc.c')
-rw-r--r-- | drivers/gpu/drm/gma500/oaktrail_crtc.c | 134 |
1 files changed, 60 insertions, 74 deletions
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); |