NanoPayload

stage2/lcd.c

85:430ab64882a1
2015-12-05 Paul Boddie Write through uncached memory to test memory access. This avoids page faults but means that the TLB is not being set up properly. Still, ERL can now be cleared. stage2-non-pic
     1 /*     2  * Ben NanoNote LCD initialisation, based on uboot-xburst and xburst-tools.     3  *     4  * Copyright (C) 2001-2002 Wolfgang Denk, DENX Software Engineering, <wd@denx.de>     5  * Copyright (C) 2015 Paul Boddie <paul@boddie.org.uk>     6  *     7  * This program is free software: you can redistribute it and/or modify     8  * it under the terms of the GNU General Public License as published by     9  * the Free Software Foundation, either version 3 of the License, or    10  * (at your option) any later version.    11  *    12  * This program is distributed in the hope that it will be useful,    13  * but WITHOUT ANY WARRANTY; without even the implied warranty of    14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    15  * GNU General Public License for more details.    16  *    17  * You should have received a copy of the GNU General Public License    18  * along with this program.  If not, see <http://www.gnu.org/licenses/>.    19  */    20     21 #ifdef CONFIG_CPU_JZ4730_MINIPC    22 #include "minipc_claa070vc01.h"    23 #include "minipc.h"    24 #else    25 #include "nanonote_gpm940b0.h"    26 #include "nanonote.h"    27 #endif    28     29 #include "xburst_types.h"    30 #include "jzlcd.h"    31 #include "sdram.h"    32 #include "board.h"    33     34 extern vidinfo_t panel_info;    35 static void *lcd_base;    36 u32 irq_counter = 0;    37     38 void test_pixel(unsigned short h, unsigned short v)    39 {    40 	unsigned short v_max  = panel_info.vl_row;    41 	unsigned short h_max  = panel_info.vl_col;    42 	u32 *pix = (u32 *)lcd_base + 0xa0000000 + v * h_max + h;    43     44 	/* NOTE: Code assumes 32 bits/pixel. */    45 #ifdef NORMAL    46 	*pix = (    47 		(((255 * (h_max - h)) / (h_max - 1)) << 16) +    48 		((((255 * h) / (h_max - 1) + (255 * (v_max - v)) / (v_max - 1)) / 2) << 8) +    49 		((255 * v) / (v_max - 1))    50 		);    51 #elif HANDLER    52 	unsigned short offset, bit;    53 	bit = 31 - (32 * h / (h_max - 1));    54 	offset = v / 4;    55 	*pix = ((*((u32 *) 0x80000200 + offset) & (1 << bit)) >> bit) ? 0xffffffff : 0;    56 #else    57 	unsigned short bit;    58 	volatile unsigned int cp0_register;    59 	asm volatile(    60 		"mfc0 %0, $12\n"    61 		"nop"    62 		: "=r"(cp0_register)    63 		);    64 	bit = 31 - (32 * h / (h_max - 1));    65 	*pix = (((cp0_register & (1 << bit)) >> bit) ? 0x007f0000 : 0x0000001f) * ((bit % 2) ? 2 : 1);    66 	/* *pix = (((irq_counter & (1 << bit)) >> bit) ? 0x007f0000 : 0x0000001f) * ((bit % 2) ? 2 : 1); */    67 #endif    68 }    69     70 void clear_pixel(unsigned short h, unsigned short v)    71 {    72 	unsigned short h_max  = panel_info.vl_col;    73 	u32 *pix = (u32 *)lcd_base + 0xa0000000 + v * h_max + h;    74     75 	*pix = 0;    76 }    77     78 void test_pattern(void *lcd_base)    79 {    80 	unsigned short v_max  = panel_info.vl_row;    81 	unsigned short h_max  = panel_info.vl_col;    82 	unsigned short v, h;    83     84 	for (v = 0; v < v_max; v += 1) {    85 		for (h = 0; h < h_max; h += 1) {    86 			test_pixel(h, v);    87 		}    88 	}    89 }    90     91 void lcd_clear(void *lcd_base)    92 {    93 	unsigned short v_max  = panel_info.vl_row;    94 	unsigned short h_max  = panel_info.vl_col;    95 	unsigned short v, h;    96 	u32 *pix = (u32 *)lcd_base + 0xa0000000;    97     98 	for (v = 0; v < v_max; v += 1) {    99 		for (h = 0; h < h_max; h += 1) {   100 			*pix++ = 0;   101 		}   102 	}   103 }   104    105 /* LCD initialisation. */   106    107 void lcd_init(void)   108 {   109 	__lcd_display_pin_init();   110 	__lcd_display_on();   111    112 	lcd_ctrl_init(&lcd_base);   113 	lcd_clear(lcd_base);   114 	lcd_enable();   115 }