aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/video/geode/lxfb.h43
-rw-r--r--drivers/video/geode/lxfb_core.c9
-rw-r--r--drivers/video/geode/lxfb_ops.c151
3 files changed, 116 insertions, 87 deletions
diff --git a/drivers/video/geode/lxfb.h b/drivers/video/geode/lxfb.h
index 8c83a1b4439b..60579f4d004a 100644
--- a/drivers/video/geode/lxfb.h
+++ b/drivers/video/geode/lxfb.h
@@ -188,4 +188,47 @@ void lx_set_palette_reg(struct fb_info *, unsigned int, unsigned int,
188#define GP_BS_BLT_BUSY (1 << 0) 188#define GP_BS_BLT_BUSY (1 << 0)
189#define GP_BS_CB_EMPTY (1 << 4) 189#define GP_BS_CB_EMPTY (1 << 4)
190 190
191
192/* register access functions */
193
194static inline uint32_t read_gp(struct lxfb_par *par, int reg)
195{
196 return readl(par->gp_regs + reg);
197}
198
199static inline void write_gp(struct lxfb_par *par, int reg, uint32_t val)
200{
201 writel(val, par->gp_regs + reg);
202}
203
204static inline uint32_t read_dc(struct lxfb_par *par, int reg)
205{
206 return readl(par->dc_regs + reg);
207}
208
209static inline void write_dc(struct lxfb_par *par, int reg, uint32_t val)
210{
211 writel(val, par->dc_regs + reg);
212}
213
214static inline uint32_t read_vp(struct lxfb_par *par, int reg)
215{
216 return readl(par->df_regs + reg);
217}
218
219static inline void write_vp(struct lxfb_par *par, int reg, uint32_t val)
220{
221 writel(val, par->df_regs + reg);
222}
223
224static inline uint32_t read_fp(struct lxfb_par *par, int reg)
225{
226 return readl(par->df_regs + reg);
227}
228
229static inline void write_fp(struct lxfb_par *par, int reg, uint32_t val)
230{
231 writel(val, par->df_regs + reg);
232}
233
191#endif 234#endif
diff --git a/drivers/video/geode/lxfb_core.c b/drivers/video/geode/lxfb_core.c
index eb6b88171538..a1d14e0c3aa9 100644
--- a/drivers/video/geode/lxfb_core.c
+++ b/drivers/video/geode/lxfb_core.c
@@ -366,12 +366,9 @@ static int __init lxfb_map_video_memory(struct fb_info *info,
366 if (par->df_regs == NULL) 366 if (par->df_regs == NULL)
367 return ret; 367 return ret;
368 368
369 writel(DC_UNLOCK_CODE, par->dc_regs + DC_UNLOCK); 369 write_dc(par, DC_UNLOCK, DC_UNLOCK_CODE);
370 370 write_dc(par, DC_PHY_MEM_OFFSET, info->fix.smem_start & 0xFF000000);
371 writel(info->fix.smem_start & 0xFF000000, 371 write_dc(par, DC_UNLOCK, 0);
372 par->dc_regs + DC_PHY_MEM_OFFSET);
373
374 writel(0, par->dc_regs + DC_UNLOCK);
375 372
376 dev_info(&dev->dev, "%d KB of video memory at 0x%lx\n", 373 dev_info(&dev->dev, "%d KB of video memory at 0x%lx\n",
377 info->fix.smem_len / 1024, info->fix.smem_start); 374 info->fix.smem_len / 1024, info->fix.smem_start);
diff --git a/drivers/video/geode/lxfb_ops.c b/drivers/video/geode/lxfb_ops.c
index afe8e33ac1c2..d1210e2d3894 100644
--- a/drivers/video/geode/lxfb_ops.c
+++ b/drivers/video/geode/lxfb_ops.c
@@ -210,49 +210,48 @@ static void lx_graphics_disable(struct fb_info *info)
210 210
211 /* Note: This assumes that the video is in a quitet state */ 211 /* Note: This assumes that the video is in a quitet state */
212 212
213 writel(0, par->df_regs + DF_ALPHA_CONTROL_1); 213 write_vp(par, DF_ALPHA_CONTROL_1, 0);
214 writel(0, par->df_regs + DF_ALPHA_CONTROL_1 + 32); 214 write_vp(par, DF_ALPHA_CONTROL_1 + 32, 0);
215 writel(0, par->df_regs + DF_ALPHA_CONTROL_1 + 64); 215 write_vp(par, DF_ALPHA_CONTROL_1 + 64, 0);
216 216
217 /* Turn off the VGA and video enable */ 217 /* Turn off the VGA and video enable */
218 val = readl (par->dc_regs + DC_GENERAL_CFG) & 218 val = read_dc(par, DC_GENERAL_CFG) & ~(DC_GCFG_VGAE | DC_GCFG_VIDE);
219 ~(DC_GCFG_VGAE | DC_GCFG_VIDE);
220 219
221 writel(val, par->dc_regs + DC_GENERAL_CFG); 220 write_dc(par, DC_GENERAL_CFG, val);
222 221
223 val = readl(par->df_regs + DF_VIDEO_CFG) & ~DF_VCFG_VID_EN; 222 val = read_vp(par, DF_VIDEO_CFG) & ~DF_VCFG_VID_EN;
224 writel(val, par->df_regs + DF_VIDEO_CFG); 223 write_vp(par, DF_VIDEO_CFG, val);
225 224
226 writel( DC_IRQ_MASK | DC_VSYNC_IRQ_MASK | 225 write_dc(par, DC_IRQ, DC_IRQ_MASK | DC_VSYNC_IRQ_MASK | DC_IRQ_STATUS |
227 DC_IRQ_STATUS | DC_VSYNC_IRQ_STATUS, 226 DC_VSYNC_IRQ_STATUS);
228 par->dc_regs + DC_IRQ);
229 227
230 val = readl(par->dc_regs + DC_GENLCK_CTRL) & ~DC_GENLCK_ENABLE; 228 val = read_dc(par, DC_GENLCK_CTRL) & ~DC_GENLCK_ENABLE;
231 writel(val, par->dc_regs + DC_GENLCK_CTRL); 229 write_dc(par, DC_GENLCK_CTRL, val);
232 230
233 val = readl(par->dc_regs + DC_COLOR_KEY) & ~DC_CLR_KEY_ENABLE; 231 val = read_dc(par, DC_COLOR_KEY) & ~DC_CLR_KEY_ENABLE;
234 writel(val & ~DC_CLR_KEY_ENABLE, par->dc_regs + DC_COLOR_KEY); 232 write_dc(par, DC_COLOR_KEY, val & ~DC_CLR_KEY_ENABLE);
235 233
236 /* We don't actually blank the panel, due to the long latency 234 /* We don't actually blank the panel, due to the long latency
237 involved with bringing it back */ 235 involved with bringing it back */
238 236
239 val = readl(par->df_regs + DF_MISC) | DF_MISC_DAC_PWRDN; 237 val = read_vp(par, DF_MISC) | DF_MISC_DAC_PWRDN;
240 writel(val, par->df_regs + DF_MISC); 238 write_vp(par, DF_MISC, val);
241 239
242 /* Turn off the display */ 240 /* Turn off the display */
243 241
244 val = readl(par->df_regs + DF_DISPLAY_CFG); 242 val = read_vp(par, DF_DISPLAY_CFG);
245 writel(val & ~(DF_DCFG_CRT_EN | DF_DCFG_HSYNC_EN | DF_DCFG_VSYNC_EN | 243 write_vp(par, DF_DISPLAY_CFG, val &
246 DF_DCFG_DAC_BL_EN), par->df_regs + DF_DISPLAY_CFG); 244 ~(DF_DCFG_CRT_EN | DF_DCFG_HSYNC_EN |
245 DF_DCFG_VSYNC_EN | DF_DCFG_DAC_BL_EN));
247 246
248 gcfg = readl(par->dc_regs + DC_GENERAL_CFG); 247 gcfg = read_dc(par, DC_GENERAL_CFG);
249 gcfg &= ~(DC_GCFG_CMPE | DC_GCFG_DECE); 248 gcfg &= ~(DC_GCFG_CMPE | DC_GCFG_DECE);
250 writel(gcfg, par->dc_regs + DC_GENERAL_CFG); 249 write_dc(par, DC_GENERAL_CFG, gcfg);
251 250
252 /* Turn off the TGEN */ 251 /* Turn off the TGEN */
253 val = readl(par->dc_regs + DC_DISPLAY_CFG); 252 val = read_dc(par, DC_DISPLAY_CFG);
254 val &= ~DC_DCFG_TGEN; 253 val &= ~DC_DCFG_TGEN;
255 writel(val, par->dc_regs + DC_DISPLAY_CFG); 254 write_dc(par, DC_DISPLAY_CFG, val);
256 255
257 /* Wait 1000 usecs to ensure that the TGEN is clear */ 256 /* Wait 1000 usecs to ensure that the TGEN is clear */
258 udelay(1000); 257 udelay(1000);
@@ -260,12 +259,12 @@ static void lx_graphics_disable(struct fb_info *info)
260 /* Turn off the FIFO loader */ 259 /* Turn off the FIFO loader */
261 260
262 gcfg &= ~DC_GCFG_DFLE; 261 gcfg &= ~DC_GCFG_DFLE;
263 writel(gcfg, par->dc_regs + DC_GENERAL_CFG); 262 write_dc(par, DC_GENERAL_CFG, gcfg);
264 263
265 /* Lastly, wait for the GP to go idle */ 264 /* Lastly, wait for the GP to go idle */
266 265
267 do { 266 do {
268 val = readl(par->gp_regs + GP_BLT_STATUS); 267 val = read_gp(par, GP_BLT_STATUS);
269 } while ((val & GP_BS_BLT_BUSY) || !(val & GP_BS_CB_EMPTY)); 268 } while ((val & GP_BS_BLT_BUSY) || !(val & GP_BS_CB_EMPTY));
270} 269}
271 270
@@ -275,11 +274,11 @@ static void lx_graphics_enable(struct fb_info *info)
275 u32 temp, config; 274 u32 temp, config;
276 275
277 /* Set the video request register */ 276 /* Set the video request register */
278 writel(0, par->df_regs + DF_VIDEO_REQUEST); 277 write_vp(par, DF_VIDEO_REQUEST, 0);
279 278
280 /* Set up the polarities */ 279 /* Set up the polarities */
281 280
282 config = readl(par->df_regs + DF_DISPLAY_CFG); 281 config = read_vp(par, DF_DISPLAY_CFG);
283 282
284 config &= ~(DF_DCFG_CRT_SYNC_SKW_MASK | DF_DCFG_PWR_SEQ_DLY_MASK | 283 config &= ~(DF_DCFG_CRT_SYNC_SKW_MASK | DF_DCFG_PWR_SEQ_DLY_MASK |
285 DF_DCFG_CRT_HSYNC_POL | DF_DCFG_CRT_VSYNC_POL); 284 DF_DCFG_CRT_HSYNC_POL | DF_DCFG_CRT_VSYNC_POL);
@@ -296,12 +295,9 @@ static void lx_graphics_enable(struct fb_info *info)
296 if (par->output & OUTPUT_PANEL) { 295 if (par->output & OUTPUT_PANEL) {
297 u32 msrlo, msrhi; 296 u32 msrlo, msrhi;
298 297
299 writel(DF_DEFAULT_TFT_PMTIM1, 298 write_fp(par, DF_PANEL_TIM1, DF_DEFAULT_TFT_PMTIM1);
300 par->df_regs + DF_PANEL_TIM1); 299 write_fp(par, DF_PANEL_TIM2, DF_DEFAULT_TFT_PMTIM2);
301 writel(DF_DEFAULT_TFT_PMTIM2, 300 write_fp(par, DF_DITHER_CONTROL, DF_DEFAULT_TFT_DITHCTL);
302 par->df_regs + DF_PANEL_TIM2);
303 writel(DF_DEFAULT_TFT_DITHCTL,
304 par->df_regs + DF_DITHER_CONTROL);
305 301
306 msrlo = DF_DEFAULT_TFT_PAD_SEL_LOW; 302 msrlo = DF_DEFAULT_TFT_PAD_SEL_LOW;
307 msrhi = DF_DEFAULT_TFT_PAD_SEL_HIGH; 303 msrhi = DF_DEFAULT_TFT_PAD_SEL_HIGH;
@@ -314,27 +310,24 @@ static void lx_graphics_enable(struct fb_info *info)
314 DF_DCFG_VSYNC_EN | DF_DCFG_DAC_BL_EN; 310 DF_DCFG_VSYNC_EN | DF_DCFG_DAC_BL_EN;
315 } 311 }
316 312
317 writel(config, par->df_regs + DF_DISPLAY_CFG); 313 write_vp(par, DF_DISPLAY_CFG, config);
318 314
319 /* Turn the CRT dacs back on */ 315 /* Turn the CRT dacs back on */
320 316
321 if (par->output & OUTPUT_CRT) { 317 if (par->output & OUTPUT_CRT) {
322 temp = readl(par->df_regs + DF_MISC); 318 temp = read_vp(par, DF_MISC);
323 temp &= ~(DF_MISC_DAC_PWRDN | DF_MISC_A_PWRDN); 319 temp &= ~(DF_MISC_DAC_PWRDN | DF_MISC_A_PWRDN);
324 writel(temp, par->df_regs + DF_MISC); 320 write_vp(par, DF_MISC, temp);
325 } 321 }
326 322
327 /* Turn the panel on (if it isn't already) */ 323 /* Turn the panel on (if it isn't already) */
328 324
329 if (par->output & OUTPUT_PANEL) { 325 if (par->output & OUTPUT_PANEL) {
330 temp = readl(par->df_regs + DF_FP_PM); 326 temp = read_fp(par, DF_FP_PM);
331 327
332 if (!(temp & 0x09)) 328 if (!(temp & 0x09))
333 writel(temp | DF_FP_PM_P, par->df_regs + DF_FP_PM); 329 write_fp(par, DF_FP_PM, temp | DF_FP_PM_P);
334 } 330 }
335
336 temp = readl(par->df_regs + DF_MISC);
337 temp = readl(par->df_regs + DF_DISPLAY_CFG);
338} 331}
339 332
340unsigned int lx_framebuffer_size(void) 333unsigned int lx_framebuffer_size(void)
@@ -364,7 +357,7 @@ void lx_set_mode(struct fb_info *info)
364 int vactive, vblankstart, vsyncstart, vsyncend, vblankend, vtotal; 357 int vactive, vblankstart, vsyncstart, vsyncend, vblankend, vtotal;
365 358
366 /* Unlock the DC registers */ 359 /* Unlock the DC registers */
367 writel(DC_UNLOCK_CODE, par->dc_regs + DC_UNLOCK); 360 write_dc(par, DC_UNLOCK, DC_UNLOCK_CODE);
368 361
369 lx_graphics_disable(info); 362 lx_graphics_disable(info);
370 363
@@ -391,22 +384,22 @@ void lx_set_mode(struct fb_info *info)
391 /* Clear the various buffers */ 384 /* Clear the various buffers */
392 /* FIXME: Adjust for panning here */ 385 /* FIXME: Adjust for panning here */
393 386
394 writel(0, par->dc_regs + DC_FB_START); 387 write_dc(par, DC_FB_START, 0);
395 writel(0, par->dc_regs + DC_CB_START); 388 write_dc(par, DC_CB_START, 0);
396 writel(0, par->dc_regs + DC_CURSOR_START); 389 write_dc(par, DC_CURSOR_START, 0);
397 390
398 /* FIXME: Add support for interlacing */ 391 /* FIXME: Add support for interlacing */
399 /* FIXME: Add support for scaling */ 392 /* FIXME: Add support for scaling */
400 393
401 val = readl(par->dc_regs + DC_GENLCK_CTRL); 394 val = read_dc(par, DC_GENLCK_CTRL);
402 val &= ~(DC_GC_ALPHA_FLICK_ENABLE | 395 val &= ~(DC_GC_ALPHA_FLICK_ENABLE |
403 DC_GC_FLICKER_FILTER_ENABLE | DC_GC_FLICKER_FILTER_MASK); 396 DC_GC_FLICKER_FILTER_ENABLE | DC_GC_FLICKER_FILTER_MASK);
404 397
405 /* Default scaling params */ 398 /* Default scaling params */
406 399
407 writel((0x4000 << 16) | 0x4000, par->dc_regs + DC_GFX_SCALE); 400 write_dc(par, DC_GFX_SCALE, (0x4000 << 16) | 0x4000);
408 writel(0, par->dc_regs + DC_IRQ_FILT_CTL); 401 write_dc(par, DC_IRQ_FILT_CTL, 0);
409 writel(val, par->dc_regs + DC_GENLCK_CTRL); 402 write_dc(par, DC_GENLCK_CTRL, val);
410 403
411 /* FIXME: Support compression */ 404 /* FIXME: Support compression */
412 405
@@ -422,15 +415,15 @@ void lx_set_mode(struct fb_info *info)
422 max = info->fix.line_length * info->var.yres; 415 max = info->fix.line_length * info->var.yres;
423 max = (max + 0x3FF) & 0xFFFFFC00; 416 max = (max + 0x3FF) & 0xFFFFFC00;
424 417
425 writel(max | DC_DV_TOP_ENABLE, par->dc_regs + DC_DV_TOP); 418 write_dc(par, DC_DV_TOP, max | DC_DV_TOP_ENABLE);
426 419
427 val = readl(par->dc_regs + DC_DV_CTL) & ~DC_DV_LINE_SIZE_MASK; 420 val = read_dc(par, DC_DV_CTL) & ~DC_DV_LINE_SIZE_MASK;
428 writel(val | dv, par->dc_regs + DC_DV_CTL); 421 write_dc(par, DC_DV_CTL, val | dv);
429 422
430 size = info->var.xres * (info->var.bits_per_pixel >> 3); 423 size = info->var.xres * (info->var.bits_per_pixel >> 3);
431 424
432 writel(info->fix.line_length >> 3, par->dc_regs + DC_GRAPHICS_PITCH); 425 write_dc(par, DC_GRAPHICS_PITCH, info->fix.line_length >> 3);
433 writel((size + 7) >> 3, par->dc_regs + DC_LINE_SIZE); 426 write_dc(par, DC_LINE_SIZE, (size + 7) >> 3);
434 427
435 /* Set default watermark values */ 428 /* Set default watermark values */
436 429
@@ -487,35 +480,31 @@ void lx_set_mode(struct fb_info *info)
487 vblankend = vsyncend + info->var.upper_margin; 480 vblankend = vsyncend + info->var.upper_margin;
488 vtotal = vblankend; 481 vtotal = vblankend;
489 482
490 writel((hactive - 1) | ((htotal - 1) << 16), 483 write_dc(par, DC_H_ACTIVE_TIMING, (hactive - 1) | ((htotal - 1) << 16));
491 par->dc_regs + DC_H_ACTIVE_TIMING); 484 write_dc(par, DC_H_BLANK_TIMING,
492 writel((hblankstart - 1) | ((hblankend - 1) << 16), 485 (hblankstart - 1) | ((hblankend - 1) << 16));
493 par->dc_regs + DC_H_BLANK_TIMING); 486 write_dc(par, DC_H_SYNC_TIMING,
494 writel((hsyncstart - 1) | ((hsyncend - 1) << 16), 487 (hsyncstart - 1) | ((hsyncend - 1) << 16));
495 par->dc_regs + DC_H_SYNC_TIMING);
496
497 writel((vactive - 1) | ((vtotal - 1) << 16),
498 par->dc_regs + DC_V_ACTIVE_TIMING);
499
500 writel((vblankstart - 1) | ((vblankend - 1) << 16),
501 par->dc_regs + DC_V_BLANK_TIMING);
502 488
503 writel((vsyncstart - 1) | ((vsyncend - 1) << 16), 489 write_dc(par, DC_V_ACTIVE_TIMING, (vactive - 1) | ((vtotal - 1) << 16));
504 par->dc_regs + DC_V_SYNC_TIMING); 490 write_dc(par, DC_V_BLANK_TIMING,
491 (vblankstart - 1) | ((vblankend - 1) << 16));
492 write_dc(par, DC_V_SYNC_TIMING,
493 (vsyncstart - 1) | ((vsyncend - 1) << 16));
505 494
506 writel( (info->var.xres - 1) << 16 | (info->var.yres - 1), 495 write_dc(par, DC_FB_ACTIVE,
507 par->dc_regs + DC_FB_ACTIVE); 496 (info->var.xres - 1) << 16 | (info->var.yres - 1));
508 497
509 /* And re-enable the graphics output */ 498 /* And re-enable the graphics output */
510 lx_graphics_enable(info); 499 lx_graphics_enable(info);
511 500
512 /* Write the two main configuration registers */ 501 /* Write the two main configuration registers */
513 writel(dcfg, par->dc_regs + DC_DISPLAY_CFG); 502 write_dc(par, DC_DISPLAY_CFG, dcfg);
514 writel(0, par->dc_regs + DC_ARB_CFG); 503 write_dc(par, DC_ARB_CFG, 0);
515 writel(gcfg, par->dc_regs + DC_GENERAL_CFG); 504 write_dc(par, DC_GENERAL_CFG, gcfg);
516 505
517 /* Lock the DC registers */ 506 /* Lock the DC registers */
518 writel(0, par->dc_regs + DC_UNLOCK); 507 write_dc(par, DC_UNLOCK, 0);
519} 508}
520 509
521void lx_set_palette_reg(struct fb_info *info, unsigned regno, 510void lx_set_palette_reg(struct fb_info *info, unsigned regno,
@@ -530,8 +519,8 @@ void lx_set_palette_reg(struct fb_info *info, unsigned regno,
530 val |= (green) & 0x00ff00; 519 val |= (green) & 0x00ff00;
531 val |= (blue >> 8) & 0x0000ff; 520 val |= (blue >> 8) & 0x0000ff;
532 521
533 writel(regno, par->dc_regs + DC_PAL_ADDRESS); 522 write_dc(par, DC_PAL_ADDRESS, regno);
534 writel(val, par->dc_regs + DC_PAL_DATA); 523 write_dc(par, DC_PAL_DATA, val);
535} 524}
536 525
537int lx_blank_display(struct fb_info *info, int blank_mode) 526int lx_blank_display(struct fb_info *info, int blank_mode)
@@ -561,7 +550,7 @@ int lx_blank_display(struct fb_info *info, int blank_mode)
561 return -EINVAL; 550 return -EINVAL;
562 } 551 }
563 552
564 dcfg = readl(par->df_regs + DF_DISPLAY_CFG); 553 dcfg = read_vp(par, DF_DISPLAY_CFG);
565 dcfg &= ~(DF_DCFG_DAC_BL_EN 554 dcfg &= ~(DF_DCFG_DAC_BL_EN
566 | DF_DCFG_HSYNC_EN | DF_DCFG_VSYNC_EN); 555 | DF_DCFG_HSYNC_EN | DF_DCFG_VSYNC_EN);
567 if (!blank) 556 if (!blank)
@@ -570,17 +559,17 @@ int lx_blank_display(struct fb_info *info, int blank_mode)
570 dcfg |= DF_DCFG_HSYNC_EN; 559 dcfg |= DF_DCFG_HSYNC_EN;
571 if (vsync) 560 if (vsync)
572 dcfg |= DF_DCFG_VSYNC_EN; 561 dcfg |= DF_DCFG_VSYNC_EN;
573 writel(dcfg, par->df_regs + DF_DISPLAY_CFG); 562 write_vp(par, DF_DISPLAY_CFG, dcfg);
574 563
575 /* Power on/off flat panel */ 564 /* Power on/off flat panel */
576 565
577 if (par->output & OUTPUT_PANEL) { 566 if (par->output & OUTPUT_PANEL) {
578 fp_pm = readl(par->df_regs + DF_FP_PM); 567 fp_pm = read_fp(par, DF_FP_PM);
579 if (blank_mode == FB_BLANK_POWERDOWN) 568 if (blank_mode == FB_BLANK_POWERDOWN)
580 fp_pm &= ~DF_FP_PM_P; 569 fp_pm &= ~DF_FP_PM_P;
581 else 570 else
582 fp_pm |= DF_FP_PM_P; 571 fp_pm |= DF_FP_PM_P;
583 writel(fp_pm, par->df_regs + DF_FP_PM); 572 write_fp(par, DF_FP_PM, fp_pm);
584 } 573 }
585 574
586 return 0; 575 return 0;