1.1 --- a/Makefile Sun Jun 07 02:18:33 2015 +0200
1.2 +++ b/Makefile Sun Jun 07 02:20:54 2015 +0200
1.3 @@ -42,9 +42,9 @@
1.4 # Ordering of objects is important and cannot be left to replacement rules.
1.5
1.6 SRC1 = head1.S stage1.c board-nanonote.c
1.7 -SRC2 = head2.S stage2.c board-nanonote.c nanonote_gpm940b0.c
1.8 +SRC2 = head2.S stage2.c board-nanonote.c nanonote_gpm940b0.c lcd.c
1.9 OBJ1 = head1.o stage1.o board-nanonote.o
1.10 -OBJ2 = head2.o stage2.o board-nanonote.o nanonote_gpm940b0.o
1.11 +OBJ2 = head2.o stage2.o board-nanonote.o nanonote_gpm940b0.o lcd.o
1.12 OBJ = $(OBJ1) $(OBJ2)
1.13
1.14 .PHONY: all clean distclean
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2.2 +++ b/include/jz4740_lcd.h Sun Jun 07 02:20:54 2015 +0200
2.3 @@ -0,0 +1,84 @@
2.4 +/*
2.5 + * U-Boot JzRISC lcd controller definitions
2.6 + *
2.7 + * (C) Copyright 2001 Wolfgang Denk, DENX Software Engineering, wd@denx.de.
2.8 + * (C) Copyright Xiangfu Liu <xiangfu@sharism.cc>
2.9 + * (C) Copyright 2015 Paul Boddie <paul@boddie.org.uk>
2.10 + *
2.11 + * This program is free software; you can redistribute it and/or
2.12 + * modify it under the terms of the GNU General Public License as
2.13 + * published by the Free Software Foundation; either version 2 of
2.14 + * the License, or (at your option) any later version.
2.15 + *
2.16 + * This program is distributed in the hope that it will be useful,
2.17 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
2.18 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2.19 + * GNU General Public License for more details.
2.20 + *
2.21 + * You should have received a copy of the GNU General Public License
2.22 + * along with this program; if not, write to the Free Software
2.23 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
2.24 + * MA 02111-1307 USA
2.25 + */
2.26 +
2.27 +#ifndef _LCD_H_
2.28 +#define _LCD_H_
2.29 +
2.30 +/*
2.31 + * LCD controller stucture for JZSOC: JZ4740
2.32 + */
2.33 +struct jz_fb_dma_descriptor {
2.34 + unsigned long fdadr; /* Frame descriptor address register */
2.35 + unsigned long fsadr; /* Frame source address register */
2.36 + unsigned long fidr; /* Frame ID register */
2.37 + unsigned long ldcmd; /* Command register */
2.38 +};
2.39 +
2.40 +/*
2.41 + * Jz LCD info
2.42 + */
2.43 +struct jz_fb_info {
2.44 +
2.45 + unsigned long fdadr0; /* physical address of frame/palette descriptor */
2.46 + unsigned long fdadr1; /* physical address of frame descriptor */
2.47 +
2.48 + /* DMA descriptors */
2.49 + struct jz_fb_dma_descriptor *dmadesc_fblow;
2.50 + struct jz_fb_dma_descriptor *dmadesc_fbhigh;
2.51 + struct jz_fb_dma_descriptor *dmadesc_palette;
2.52 + unsigned long screen; /* address of frame buffer */
2.53 + unsigned long palette; /* address of palette memory */
2.54 + unsigned int palette_size;
2.55 +};
2.56 +
2.57 +typedef struct vidinfo {
2.58 + unsigned short vl_col; /* Number of columns (i.e. 640) */
2.59 + unsigned short vl_row; /* Number of rows (i.e. 480) */
2.60 + unsigned char vl_bpix; /* Bits per pixel, 0 = 1, 1 = 2, 2 = 4, 3 = 8 */
2.61 +
2.62 + struct jz_fb_info jz_fb;
2.63 +} vidinfo_t;
2.64 +
2.65 +extern vidinfo_t panel_info;
2.66 +
2.67 +#define LCD_MONOCHROME 0
2.68 +#define LCD_COLOR2 1
2.69 +#define LCD_COLOR4 2
2.70 +#define LCD_COLOR8 3
2.71 +#define LCD_COLOR16 4
2.72 +#define LCD_COLOR32 5
2.73 +
2.74 +/* Default to 8bpp if bit depth not specified */
2.75 +#ifndef LCD_BPP
2.76 +#define LCD_BPP LCD_COLOR8
2.77 +#endif
2.78 +
2.79 +#ifndef PAGE_SIZE
2.80 +#define PAGE_SIZE 4096
2.81 +#endif
2.82 +
2.83 +/* Calculate nr. of bits per pixel and nr. of colors */
2.84 +#define NBITS(bit_code) (1 << (bit_code))
2.85 +#define NCOLORS(bit_code) (1 << NBITS(bit_code))
2.86 +
2.87 +#endif /* _LCD_H_ */
3.1 --- a/include/lcd.h Sun Jun 07 02:18:33 2015 +0200
3.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
3.3 @@ -1,84 +0,0 @@
3.4 -/*
3.5 - * U-Boot JzRISC lcd controller definitions
3.6 - *
3.7 - * (C) Copyright 2001 Wolfgang Denk, DENX Software Engineering, wd@denx.de.
3.8 - * (C) Copyright Xiangfu Liu <xiangfu@sharism.cc>
3.9 - * (C) Copyright 2015 Paul Boddie <paul@boddie.org.uk>
3.10 - *
3.11 - * This program is free software; you can redistribute it and/or
3.12 - * modify it under the terms of the GNU General Public License as
3.13 - * published by the Free Software Foundation; either version 2 of
3.14 - * the License, or (at your option) any later version.
3.15 - *
3.16 - * This program is distributed in the hope that it will be useful,
3.17 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
3.18 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3.19 - * GNU General Public License for more details.
3.20 - *
3.21 - * You should have received a copy of the GNU General Public License
3.22 - * along with this program; if not, write to the Free Software
3.23 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
3.24 - * MA 02111-1307 USA
3.25 - */
3.26 -
3.27 -#ifndef _LCD_H_
3.28 -#define _LCD_H_
3.29 -
3.30 -/*
3.31 - * LCD controller stucture for JZSOC: JZ4740
3.32 - */
3.33 -struct jz_fb_dma_descriptor {
3.34 - unsigned long fdadr; /* Frame descriptor address register */
3.35 - unsigned long fsadr; /* Frame source address register */
3.36 - unsigned long fidr; /* Frame ID register */
3.37 - unsigned long ldcmd; /* Command register */
3.38 -};
3.39 -
3.40 -/*
3.41 - * Jz LCD info
3.42 - */
3.43 -struct jz_fb_info {
3.44 -
3.45 - unsigned long fdadr0; /* physical address of frame/palette descriptor */
3.46 - unsigned long fdadr1; /* physical address of frame descriptor */
3.47 -
3.48 - /* DMA descriptors */
3.49 - struct jz_fb_dma_descriptor *dmadesc_fblow;
3.50 - struct jz_fb_dma_descriptor *dmadesc_fbhigh;
3.51 - struct jz_fb_dma_descriptor *dmadesc_palette;
3.52 - unsigned long screen; /* address of frame buffer */
3.53 - unsigned long palette; /* address of palette memory */
3.54 - unsigned int palette_size;
3.55 -};
3.56 -
3.57 -typedef struct vidinfo {
3.58 - unsigned short vl_col; /* Number of columns (i.e. 640) */
3.59 - unsigned short vl_row; /* Number of rows (i.e. 480) */
3.60 - unsigned char vl_bpix; /* Bits per pixel, 0 = 1, 1 = 2, 2 = 4, 3 = 8 */
3.61 -
3.62 - struct jz_fb_info jz_fb;
3.63 -} vidinfo_t;
3.64 -
3.65 -extern vidinfo_t panel_info;
3.66 -
3.67 -#define LCD_MONOCHROME 0
3.68 -#define LCD_COLOR2 1
3.69 -#define LCD_COLOR4 2
3.70 -#define LCD_COLOR8 3
3.71 -#define LCD_COLOR16 4
3.72 -#define LCD_COLOR32 5
3.73 -
3.74 -/* Default to 8bpp if bit depth not specified */
3.75 -#ifndef LCD_BPP
3.76 -#define LCD_BPP LCD_COLOR8
3.77 -#endif
3.78 -
3.79 -#ifndef PAGE_SIZE
3.80 -#define PAGE_SIZE 4096
3.81 -#endif
3.82 -
3.83 -/* Calculate nr. of bits per pixel and nr. of colors */
3.84 -#define NBITS(bit_code) (1 << (bit_code))
3.85 -#define NCOLORS(bit_code) (1 << NBITS(bit_code))
3.86 -
3.87 -#endif /* _LCD_H_ */
4.1 --- a/include/nanonote.h Sun Jun 07 02:18:33 2015 +0200
4.2 +++ b/include/nanonote.h Sun Jun 07 02:20:54 2015 +0200
4.3 @@ -20,6 +20,11 @@
4.4 #define LCD_BPP LCD_COLOR32
4.5
4.6 /*
4.7 + * RAM configuration
4.8 + */
4.9 +#define CONFIG_SYS_SDRAM_BASE 0x80000000
4.10 +
4.11 +/*
4.12 * Cache configuration
4.13 */
4.14 #define CONFIG_SYS_DCACHE_SIZE 16384
5.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
5.2 +++ b/lcd.c Sun Jun 07 02:20:54 2015 +0200
5.3 @@ -0,0 +1,88 @@
5.4 +/*
5.5 + * Ben NanoNote LCD initialisation, based on uboot-xburst and xburst-tools.
5.6 + *
5.7 + * Copyright (C) 2015 Paul Boddie <paul@boddie.org.uk>
5.8 + * Copyright (C) 2001-2002 Wolfgang Denk, DENX Software Engineering, <wd@denx.de>
5.9 + *
5.10 + * This program is free software; you can redistribute it and/or modify it under
5.11 + * the terms of the GNU General Public License as published by the Free Software
5.12 + * Foundation; either version 3 of the License, or (at your option) any later
5.13 + * version.
5.14 + *
5.15 + * This program is distributed in the hope that it will be useful, but WITHOUT
5.16 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
5.17 + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
5.18 + * details.
5.19 + *
5.20 + * You should have received a copy of the GNU General Public License along with
5.21 + * this program. If not, see <http://www.gnu.org/licenses/>.
5.22 + */
5.23 +
5.24 +#include "xburst_types.h"
5.25 +#include "nanonote_gpm940b0.h"
5.26 +#include "board-nanonote.h"
5.27 +
5.28 +#define ALIGN(x,a) __ALIGN_MASK((x),(typeof(x))(a)-1)
5.29 +#define __ALIGN_MASK(x,mask) (((x)+(mask))&~(mask))
5.30 +
5.31 +unsigned long lcd_setmem(unsigned long addr)
5.32 +{
5.33 + unsigned long size;
5.34 +
5.35 + size = lcd_get_size();
5.36 +
5.37 + /* Round up to nearest full page, or MMU section if defined */
5.38 + size = ALIGN(size, PAGE_SIZE);
5.39 + addr = ALIGN(addr - PAGE_SIZE + 1, PAGE_SIZE);
5.40 +
5.41 + /* Allocate pages for the frame buffer. */
5.42 + addr -= size;
5.43 +
5.44 + return addr;
5.45 +}
5.46 +
5.47 +#define N_BLK_VERT 2
5.48 +#define N_BLK_HOR 3
5.49 +
5.50 +static int test_colors[N_BLK_HOR * N_BLK_VERT] = {
5.51 + 0x00ff0000, 0x0000ff00, 0x00ffff00,
5.52 + 0x000000ff, 0x00ff00ff, 0x0000ffff,
5.53 +};
5.54 +
5.55 +static void test_pattern(void *lcd_base)
5.56 +{
5.57 + unsigned short v_max = panel_info.vl_row;
5.58 + unsigned short h_max = panel_info.vl_col;
5.59 + unsigned short v_step = (v_max + N_BLK_VERT - 1) / N_BLK_VERT;
5.60 + unsigned short h_step = (h_max + N_BLK_HOR - 1) / N_BLK_HOR;
5.61 + unsigned short v, h;
5.62 + unsigned char *pix = (unsigned char *)lcd_base;
5.63 +
5.64 + /* WARNING: Code silently assumes 8bit/pixel */
5.65 + for (v = 0; v < v_max; ++v) {
5.66 + unsigned char iy = v / v_step;
5.67 + for (h = 0; h < h_max; ++h) {
5.68 + unsigned char ix = N_BLK_HOR * iy + h / h_step;
5.69 + *pix++ = test_colors[ix];
5.70 + }
5.71 + }
5.72 +}
5.73 +
5.74 +void lcd_clear(void *lcd_base)
5.75 +{
5.76 + test_pattern(lcd_base);
5.77 +}
5.78 +
5.79 +/* LCD initialisation. */
5.80 +
5.81 +static void *lcd_base;
5.82 +
5.83 +void lcd_init(void)
5.84 +{
5.85 + /* Start from the top of memory and obtain a framebuffer region. */
5.86 +
5.87 + lcd_base = (void *) lcd_setmem(get_memory_size());
5.88 + lcd_ctrl_init(lcd_base);
5.89 + lcd_clear(lcd_base);
5.90 + lcd_enable();
5.91 +}
6.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
6.2 +++ b/lcd.h Sun Jun 07 02:20:54 2015 +0200
6.3 @@ -0,0 +1,8 @@
6.4 +#ifndef __LCD_H__
6.5 +#define __LCD_H__
6.6 +
6.7 +/* Initialisation functions. */
6.8 +
6.9 +void lcd_init(void);
6.10 +
6.11 +#endif /* __LCD_H__ */
7.1 --- a/nanonote_gpm940b0.c Sun Jun 07 02:18:33 2015 +0200
7.2 +++ b/nanonote_gpm940b0.c Sun Jun 07 02:20:54 2015 +0200
7.3 @@ -1,7 +1,8 @@
7.4 /*
7.5 * JzRISC lcd controller
7.6 *
7.7 - * Xiangfu Liu <xiangfu@sharism.cc>
7.8 + * Copyright (C) Xiangfu Liu <xiangfu@sharism.cc>
7.9 + * Copyright (C) 2015 Paul Boddie <paul@boddie.org.uk>
7.10 *
7.11 * This program is free software; you can redistribute it and/or
7.12 * modify it under the terms of the GNU General Public License as
7.13 @@ -54,26 +55,15 @@
7.14 320, 240, LCD_BPP,
7.15 };
7.16
7.17 -int lcd_line_length;
7.18 -int lcd_color_fg;
7.19 -int lcd_color_bg;
7.20 -/*
7.21 - * Frame buffer memory information
7.22 - */
7.23 -void *lcd_base; /* Start of framebuffer memory */
7.24 -void *lcd_console_address; /* Start of console buffer */
7.25 -
7.26 -short console_col;
7.27 -short console_row;
7.28 -
7.29 -void lcd_ctrl_init (void *lcdbase);
7.30 -void lcd_enable (void);
7.31 -void lcd_disable (void);
7.32 +unsigned long lcd_get_size(void)
7.33 +{
7.34 + int line_length = (panel_info.vl_col * NBITS(panel_info.vl_bpix)) / 8;
7.35 + return line_length * panel_info.vl_row;
7.36 +}
7.37
7.38 static int jz_lcd_init_mem(void *lcdbase, vidinfo_t *vid);
7.39 static void jz_lcd_desc_init(vidinfo_t *vid);
7.40 static int jz_lcd_hw_init(vidinfo_t *vid);
7.41 -/* extern int flush_cache_all(void); */
7.42
7.43 void lcd_ctrl_init (void *lcdbase)
7.44 {
8.1 --- a/nanonote_gpm940b0.h Sun Jun 07 02:18:33 2015 +0200
8.2 +++ b/nanonote_gpm940b0.h Sun Jun 07 02:20:54 2015 +0200
8.3 @@ -23,7 +23,12 @@
8.4 #define __QI_LB60_GPM940B0_H__
8.5
8.6 #include "nanonote.h"
8.7 -#include "lcd.h"
8.8 +#include "jz4740_lcd.h"
8.9 +
8.10 +unsigned long lcd_get_size(void);
8.11 +void lcd_ctrl_init(void *lcdbase);
8.12 +void lcd_enable(void);
8.13 +void lcd_disable(void);
8.14
8.15 struct lcd_desc{
8.16 unsigned int next_desc; /* LCDDAx */
9.1 --- a/stage2.c Sun Jun 07 02:18:33 2015 +0200
9.2 +++ b/stage2.c Sun Jun 07 02:20:54 2015 +0200
9.3 @@ -19,6 +19,7 @@
9.4 */
9.5
9.6 #include "board-nanonote.h"
9.7 +#include "lcd.h"
9.8
9.9 void c_main(void)
9.10 {
9.11 @@ -27,4 +28,5 @@
9.12 cpm_init();
9.13 rtc_init();
9.14 timer_init();
9.15 + lcd_init();
9.16 }