Commit 676d319ef5f450ca7845555f75de496b96cd688e

Authored by Simon Glass
Committed by Tom Warren
1 parent 0dde7f5379

lcd: Add CONFIG_LCD_ALIGNMENT to select frame buffer alignment

The normal alignment is PAGE_SIZE, but if this is defined, we can support
other alignments.

The motivation for this change is to make the display section-aligned on
ARM so that we can easily turn off data caching for the frame buffer region
without resorting to level 2 page tables.

Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Warren <twarren@nvidia.com>

Showing 3 changed files with 29 additions and 5 deletions Side-by-side Diff

... ... @@ -1469,6 +1469,16 @@
1469 1469 Normally display is black on white background; define
1470 1470 CONFIG_SYS_WHITE_ON_BLACK to get it inverted.
1471 1471  
  1472 +
  1473 + CONFIG_LCD_ALIGNMENT
  1474 +
  1475 + Normally the LCD is page-aligned (tyically 4KB). If this is
  1476 + defined then the LCD will be aligned to this value instead.
  1477 + For ARM it is sometimes useful to use MMU_SECTION_SIZE
  1478 + here, since it is cheaper to change data cache settings on
  1479 + a per-section basis.
  1480 +
  1481 +
1472 1482 - Splash Screen Support: CONFIG_SPLASH_SCREEN
1473 1483  
1474 1484 If this option is set, the environment is checked for
... ... @@ -72,6 +72,10 @@
72 72 # endif
73 73 #endif
74 74  
  75 +#ifndef CONFIG_LCD_ALIGNMENT
  76 +#define CONFIG_LCD_ALIGNMENT PAGE_SIZE
  77 +#endif
  78 +
75 79 DECLARE_GLOBAL_DATA_PTR;
76 80  
77 81 ulong lcd_setmem (ulong addr);
... ... @@ -326,6 +330,12 @@
326 330 /* ** GENERIC Initialization Routines */
327 331 /************************************************************************/
328 332  
  333 +int lcd_get_size(int *line_length)
  334 +{
  335 + *line_length = (panel_info.vl_col * NBITS(panel_info.vl_bpix)) / 8;
  336 + return *line_length * panel_info.vl_row;
  337 +}
  338 +
329 339 int drv_lcd_init (void)
330 340 {
331 341 struct stdio_dev lcddev;
... ... @@ -333,7 +343,7 @@
333 343  
334 344 lcd_base = (void *)(gd->fb_base);
335 345  
336   - lcd_line_length = (panel_info.vl_col * NBITS (panel_info.vl_bpix)) / 8;
  346 + lcd_get_size(&lcd_line_length);
337 347  
338 348 lcd_init(lcd_base); /* LCD initialization */
339 349  
340 350  
341 351  
... ... @@ -445,15 +455,16 @@
445 455 ulong lcd_setmem(ulong addr)
446 456 {
447 457 ulong size;
448   - int line_length = (panel_info.vl_col * NBITS(panel_info.vl_bpix)) / 8;
  458 + int line_length;
449 459  
450 460 debug("LCD panel info: %d x %d, %d bit/pix\n", panel_info.vl_col,
451 461 panel_info.vl_row, NBITS(panel_info.vl_bpix));
452 462  
453   - size = line_length * panel_info.vl_row;
  463 + size = lcd_get_size(&line_length);
454 464  
455   - /* Round up to nearest full page */
456   - size = (size + (PAGE_SIZE - 1)) & ~(PAGE_SIZE - 1);
  465 + /* Round up to nearest full page, or MMU section if defined */
  466 + size = ALIGN(size, CONFIG_LCD_ALIGNMENT);
  467 + addr = ALIGN(addr - CONFIG_LCD_ALIGNMENT + 1, CONFIG_LCD_ALIGNMENT);
457 468  
458 469 /* Allocate pages for the frame buffer. */
459 470 addr -= size;
... ... @@ -297,6 +297,9 @@
297 297 /* Allow boards to customize the information displayed */
298 298 void lcd_show_board_info(void);
299 299  
  300 +/* Return the size of the LCD frame buffer, and the line length */
  301 +int lcd_get_size(int *line_length);
  302 +
300 303 /************************************************************************/
301 304 /* ** BITMAP DISPLAY SUPPORT */
302 305 /************************************************************************/