# HG changeset patch # User Paul Boddie # Date 1433636454 -7200 # Node ID 6fe88df663446799b65a42328a2d4ca975ec483e # Parent cf7f6d0ea74f0db7f643818fa40a6c802ad5d112 Added generic LCD initialisation, removed superfluous console-related definitions, renamed the board-specific LCD header file. diff -r cf7f6d0ea74f -r 6fe88df66344 Makefile --- a/Makefile Sun Jun 07 02:18:33 2015 +0200 +++ b/Makefile Sun Jun 07 02:20:54 2015 +0200 @@ -42,9 +42,9 @@ # Ordering of objects is important and cannot be left to replacement rules. SRC1 = head1.S stage1.c board-nanonote.c -SRC2 = head2.S stage2.c board-nanonote.c nanonote_gpm940b0.c +SRC2 = head2.S stage2.c board-nanonote.c nanonote_gpm940b0.c lcd.c OBJ1 = head1.o stage1.o board-nanonote.o -OBJ2 = head2.o stage2.o board-nanonote.o nanonote_gpm940b0.o +OBJ2 = head2.o stage2.o board-nanonote.o nanonote_gpm940b0.o lcd.o OBJ = $(OBJ1) $(OBJ2) .PHONY: all clean distclean diff -r cf7f6d0ea74f -r 6fe88df66344 include/jz4740_lcd.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/include/jz4740_lcd.h Sun Jun 07 02:20:54 2015 +0200 @@ -0,0 +1,84 @@ +/* + * U-Boot JzRISC lcd controller definitions + * + * (C) Copyright 2001 Wolfgang Denk, DENX Software Engineering, wd@denx.de. + * (C) Copyright Xiangfu Liu + * (C) Copyright 2015 Paul Boddie + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ + +#ifndef _LCD_H_ +#define _LCD_H_ + +/* + * LCD controller stucture for JZSOC: JZ4740 + */ +struct jz_fb_dma_descriptor { + unsigned long fdadr; /* Frame descriptor address register */ + unsigned long fsadr; /* Frame source address register */ + unsigned long fidr; /* Frame ID register */ + unsigned long ldcmd; /* Command register */ +}; + +/* + * Jz LCD info + */ +struct jz_fb_info { + + unsigned long fdadr0; /* physical address of frame/palette descriptor */ + unsigned long fdadr1; /* physical address of frame descriptor */ + + /* DMA descriptors */ + struct jz_fb_dma_descriptor *dmadesc_fblow; + struct jz_fb_dma_descriptor *dmadesc_fbhigh; + struct jz_fb_dma_descriptor *dmadesc_palette; + unsigned long screen; /* address of frame buffer */ + unsigned long palette; /* address of palette memory */ + unsigned int palette_size; +}; + +typedef struct vidinfo { + unsigned short vl_col; /* Number of columns (i.e. 640) */ + unsigned short vl_row; /* Number of rows (i.e. 480) */ + unsigned char vl_bpix; /* Bits per pixel, 0 = 1, 1 = 2, 2 = 4, 3 = 8 */ + + struct jz_fb_info jz_fb; +} vidinfo_t; + +extern vidinfo_t panel_info; + +#define LCD_MONOCHROME 0 +#define LCD_COLOR2 1 +#define LCD_COLOR4 2 +#define LCD_COLOR8 3 +#define LCD_COLOR16 4 +#define LCD_COLOR32 5 + +/* Default to 8bpp if bit depth not specified */ +#ifndef LCD_BPP +#define LCD_BPP LCD_COLOR8 +#endif + +#ifndef PAGE_SIZE +#define PAGE_SIZE 4096 +#endif + +/* Calculate nr. of bits per pixel and nr. of colors */ +#define NBITS(bit_code) (1 << (bit_code)) +#define NCOLORS(bit_code) (1 << NBITS(bit_code)) + +#endif /* _LCD_H_ */ diff -r cf7f6d0ea74f -r 6fe88df66344 include/lcd.h --- a/include/lcd.h Sun Jun 07 02:18:33 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,84 +0,0 @@ -/* - * U-Boot JzRISC lcd controller definitions - * - * (C) Copyright 2001 Wolfgang Denk, DENX Software Engineering, wd@denx.de. - * (C) Copyright Xiangfu Liu - * (C) Copyright 2015 Paul Boddie - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, - * MA 02111-1307 USA - */ - -#ifndef _LCD_H_ -#define _LCD_H_ - -/* - * LCD controller stucture for JZSOC: JZ4740 - */ -struct jz_fb_dma_descriptor { - unsigned long fdadr; /* Frame descriptor address register */ - unsigned long fsadr; /* Frame source address register */ - unsigned long fidr; /* Frame ID register */ - unsigned long ldcmd; /* Command register */ -}; - -/* - * Jz LCD info - */ -struct jz_fb_info { - - unsigned long fdadr0; /* physical address of frame/palette descriptor */ - unsigned long fdadr1; /* physical address of frame descriptor */ - - /* DMA descriptors */ - struct jz_fb_dma_descriptor *dmadesc_fblow; - struct jz_fb_dma_descriptor *dmadesc_fbhigh; - struct jz_fb_dma_descriptor *dmadesc_palette; - unsigned long screen; /* address of frame buffer */ - unsigned long palette; /* address of palette memory */ - unsigned int palette_size; -}; - -typedef struct vidinfo { - unsigned short vl_col; /* Number of columns (i.e. 640) */ - unsigned short vl_row; /* Number of rows (i.e. 480) */ - unsigned char vl_bpix; /* Bits per pixel, 0 = 1, 1 = 2, 2 = 4, 3 = 8 */ - - struct jz_fb_info jz_fb; -} vidinfo_t; - -extern vidinfo_t panel_info; - -#define LCD_MONOCHROME 0 -#define LCD_COLOR2 1 -#define LCD_COLOR4 2 -#define LCD_COLOR8 3 -#define LCD_COLOR16 4 -#define LCD_COLOR32 5 - -/* Default to 8bpp if bit depth not specified */ -#ifndef LCD_BPP -#define LCD_BPP LCD_COLOR8 -#endif - -#ifndef PAGE_SIZE -#define PAGE_SIZE 4096 -#endif - -/* Calculate nr. of bits per pixel and nr. of colors */ -#define NBITS(bit_code) (1 << (bit_code)) -#define NCOLORS(bit_code) (1 << NBITS(bit_code)) - -#endif /* _LCD_H_ */ diff -r cf7f6d0ea74f -r 6fe88df66344 include/nanonote.h --- a/include/nanonote.h Sun Jun 07 02:18:33 2015 +0200 +++ b/include/nanonote.h Sun Jun 07 02:20:54 2015 +0200 @@ -20,6 +20,11 @@ #define LCD_BPP LCD_COLOR32 /* + * RAM configuration + */ +#define CONFIG_SYS_SDRAM_BASE 0x80000000 + +/* * Cache configuration */ #define CONFIG_SYS_DCACHE_SIZE 16384 diff -r cf7f6d0ea74f -r 6fe88df66344 lcd.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lcd.c Sun Jun 07 02:20:54 2015 +0200 @@ -0,0 +1,88 @@ +/* + * Ben NanoNote LCD initialisation, based on uboot-xburst and xburst-tools. + * + * Copyright (C) 2015 Paul Boddie + * Copyright (C) 2001-2002 Wolfgang Denk, DENX Software Engineering, + * + * This program is free software; you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free Software + * Foundation; either version 3 of the License, or (at your option) any later + * version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . + */ + +#include "xburst_types.h" +#include "nanonote_gpm940b0.h" +#include "board-nanonote.h" + +#define ALIGN(x,a) __ALIGN_MASK((x),(typeof(x))(a)-1) +#define __ALIGN_MASK(x,mask) (((x)+(mask))&~(mask)) + +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; +} + +#define N_BLK_VERT 2 +#define N_BLK_HOR 3 + +static int test_colors[N_BLK_HOR * N_BLK_VERT] = { + 0x00ff0000, 0x0000ff00, 0x00ffff00, + 0x000000ff, 0x00ff00ff, 0x0000ffff, +}; + +static void test_pattern(void *lcd_base) +{ + unsigned short v_max = panel_info.vl_row; + unsigned short h_max = panel_info.vl_col; + unsigned short v_step = (v_max + N_BLK_VERT - 1) / N_BLK_VERT; + unsigned short h_step = (h_max + N_BLK_HOR - 1) / N_BLK_HOR; + unsigned short v, h; + unsigned char *pix = (unsigned char *)lcd_base; + + /* WARNING: Code silently assumes 8bit/pixel */ + for (v = 0; v < v_max; ++v) { + unsigned char iy = v / v_step; + for (h = 0; h < h_max; ++h) { + unsigned char ix = N_BLK_HOR * iy + h / h_step; + *pix++ = test_colors[ix]; + } + } +} + +void lcd_clear(void *lcd_base) +{ + test_pattern(lcd_base); +} + +/* LCD initialisation. */ + +static void *lcd_base; + +void lcd_init(void) +{ + /* 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_clear(lcd_base); + lcd_enable(); +} diff -r cf7f6d0ea74f -r 6fe88df66344 lcd.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lcd.h Sun Jun 07 02:20:54 2015 +0200 @@ -0,0 +1,8 @@ +#ifndef __LCD_H__ +#define __LCD_H__ + +/* Initialisation functions. */ + +void lcd_init(void); + +#endif /* __LCD_H__ */ diff -r cf7f6d0ea74f -r 6fe88df66344 nanonote_gpm940b0.c --- a/nanonote_gpm940b0.c Sun Jun 07 02:18:33 2015 +0200 +++ b/nanonote_gpm940b0.c Sun Jun 07 02:20:54 2015 +0200 @@ -1,7 +1,8 @@ /* * JzRISC lcd controller * - * Xiangfu Liu + * Copyright (C) Xiangfu Liu + * Copyright (C) 2015 Paul Boddie * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -54,26 +55,15 @@ 320, 240, LCD_BPP, }; -int lcd_line_length; -int lcd_color_fg; -int lcd_color_bg; -/* - * Frame buffer memory information - */ -void *lcd_base; /* Start of framebuffer memory */ -void *lcd_console_address; /* Start of console buffer */ - -short console_col; -short console_row; - -void lcd_ctrl_init (void *lcdbase); -void lcd_enable (void); -void lcd_disable (void); +unsigned long lcd_get_size(void) +{ + int line_length = (panel_info.vl_col * NBITS(panel_info.vl_bpix)) / 8; + return line_length * panel_info.vl_row; +} 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); -/* extern int flush_cache_all(void); */ void lcd_ctrl_init (void *lcdbase) { diff -r cf7f6d0ea74f -r 6fe88df66344 nanonote_gpm940b0.h --- a/nanonote_gpm940b0.h Sun Jun 07 02:18:33 2015 +0200 +++ b/nanonote_gpm940b0.h Sun Jun 07 02:20:54 2015 +0200 @@ -23,7 +23,12 @@ #define __QI_LB60_GPM940B0_H__ #include "nanonote.h" -#include "lcd.h" +#include "jz4740_lcd.h" + +unsigned long lcd_get_size(void); +void lcd_ctrl_init(void *lcdbase); +void lcd_enable(void); +void lcd_disable(void); struct lcd_desc{ unsigned int next_desc; /* LCDDAx */ diff -r cf7f6d0ea74f -r 6fe88df66344 stage2.c --- a/stage2.c Sun Jun 07 02:18:33 2015 +0200 +++ b/stage2.c Sun Jun 07 02:20:54 2015 +0200 @@ -19,6 +19,7 @@ */ #include "board-nanonote.h" +#include "lcd.h" void c_main(void) { @@ -27,4 +28,5 @@ cpm_init(); rtc_init(); timer_init(); + lcd_init(); }