# HG changeset patch # User Paul Boddie # Date 1433950489 -7200 # Node ID 7691d29a3bf1e4644f872bd4c5eebad2657e1010 # Parent 7ceedc59a52b63b137b1d1fa896b3cc75b6bbf72 Moved framebuffer workspace initialisation into the specific driver file. diff -r 7ceedc59a52b -r 7691d29a3bf1 stage2/jzlcd.c --- a/stage2/jzlcd.c Wed Jun 10 16:06:38 2015 +0200 +++ b/stage2/jzlcd.c Wed Jun 10 17:34:49 2015 +0200 @@ -24,6 +24,9 @@ #include "jzlcd.h" #include "board.h" +#define ALIGN(x,a) __ALIGN_MASK((x),(typeof(x))(a)-1) +#define __ALIGN_MASK(x,mask) (((x)+(mask))&~(mask)) + #define align2(n) (n)=((((n)+1)>>1)<<1) #define align4(n) (n)=((((n)+3)>>2)<<2) #define align8(n) (n)=((((n)+7)>>3)<<3) @@ -37,13 +40,32 @@ return line_length * panel_info.vl_row; } +unsigned long lcd_setmem(unsigned long addr) +{ + unsigned long size; + + size = lcd_get_size(); + + /* Round up to nearest full page, or MMU section if defined */ + size = ALIGN(size, PAGE_SIZE); + addr = ALIGN(addr - PAGE_SIZE + 1, PAGE_SIZE); + + /* Allocate pages for the frame buffer. */ + addr -= size; + + return addr; +} + static int jz_lcd_init_mem(void *lcdbase, vidinfo_t *vid); static void jz_lcd_desc_init(vidinfo_t *vid); static int jz_lcd_hw_init(vidinfo_t *vid); -void lcd_ctrl_init (void *lcdbase) +void lcd_ctrl_init (void **lcdbase) { - jz_lcd_init_mem(lcdbase, &panel_info); + /* Start from the top of memory and obtain a framebuffer region. */ + *lcdbase = (void *) lcd_setmem(get_memory_size()); + + jz_lcd_init_mem(*lcdbase, &panel_info); jz_lcd_desc_init(&panel_info); jz_lcd_hw_init(&panel_info); } @@ -60,7 +82,7 @@ void lcd_disable (void) { REG_LCD_CTRL |= (1<<4); /* LCDCTRL.DIS, regular disable */ - /* REG_LCD_CTRL |= (1<<3); */ /* LCDCTRL.DIS, quikly disable */ + /* REG_LCD_CTRL |= (1<<3); */ /* LCDCTRL.DIS, quickly disable */ } static int jz_lcd_init_mem(void *lcdbase, vidinfo_t *vid) @@ -73,7 +95,6 @@ fbi->palette_size = 256; palette_mem_size = fbi->palette_size * sizeof(u16); - /* debug("jz_lcd.c palette_mem_size = 0x%08lx\n", (unsigned long) palette_mem_size); */ /* locate palette and descs at end of page following fb */ fbi->palette = (unsigned long)lcdbase + fb_size + PAGE_SIZE - palette_mem_size; diff -r 7ceedc59a52b -r 7691d29a3bf1 stage2/jzlcd.h --- a/stage2/jzlcd.h Wed Jun 10 16:06:38 2015 +0200 +++ b/stage2/jzlcd.h Wed Jun 10 17:34:49 2015 +0200 @@ -26,7 +26,7 @@ #define __JZLCD_H__ unsigned long lcd_get_size(void); -void lcd_ctrl_init(void *lcdbase); +void lcd_ctrl_init(void **lcdbase); void lcd_enable(void); void lcd_disable(void); diff -r 7ceedc59a52b -r 7691d29a3bf1 stage2/lcd.c --- a/stage2/lcd.c Wed Jun 10 16:06:38 2015 +0200 +++ b/stage2/lcd.c Wed Jun 10 17:34:49 2015 +0200 @@ -31,27 +31,8 @@ #include "sdram.h" #include "board.h" -#define ALIGN(x,a) __ALIGN_MASK((x),(typeof(x))(a)-1) -#define __ALIGN_MASK(x,mask) (((x)+(mask))&~(mask)) - extern vidinfo_t panel_info; -unsigned long lcd_setmem(unsigned long addr) -{ - unsigned long size; - - size = lcd_get_size(); - - /* Round up to nearest full page, or MMU section if defined */ - size = ALIGN(size, PAGE_SIZE); - addr = ALIGN(addr - PAGE_SIZE + 1, PAGE_SIZE); - - /* Allocate pages for the frame buffer. */ - addr -= size; - - return addr; -} - static void test_pattern(void *lcd_base) { unsigned short v_max = panel_info.vl_row; @@ -85,10 +66,7 @@ __lcd_display_pin_init(); __lcd_display_on(); - /* Start from the top of memory and obtain a framebuffer region. */ - - lcd_base = (void *) lcd_setmem(get_memory_size()); - lcd_ctrl_init(lcd_base); + lcd_ctrl_init(&lcd_base); lcd_clear(lcd_base); lcd_enable(); }