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 37 void test_pixel(unsigned short h, unsigned short v) 38 { 39 unsigned short v_max = panel_info.vl_row; 40 unsigned short h_max = panel_info.vl_col; 41 u32 *pix = (u32 *)lcd_base + v * h_max + h; 42 43 /* NOTE: Code assumes 32 bits/pixel. */ 44 45 *pix = ( 46 (((255 * (h_max - h)) / (h_max - 1)) << 16) + 47 ((((255 * h) / (h_max - 1) + (255 * (v_max - v)) / (v_max - 1)) / 2) << 8) + 48 ((255 * v) / (v_max - 1)) 49 ); 50 } 51 52 void clear_pixel(unsigned short h, unsigned short v) 53 { 54 unsigned short h_max = panel_info.vl_col; 55 u32 *pix = (u32 *)lcd_base + v * h_max + h; 56 57 *pix = 0; 58 } 59 60 static void test_pattern(void *lcd_base) 61 { 62 unsigned short v_max = panel_info.vl_row; 63 unsigned short h_max = panel_info.vl_col; 64 unsigned short v, h; 65 66 for (v = 0; v < v_max; v += 1) { 67 for (h = 0; h < h_max; h += 1) { 68 test_pixel(h, v); 69 } 70 } 71 } 72 73 void lcd_clear(void *lcd_base) 74 { 75 unsigned short v_max = panel_info.vl_row; 76 unsigned short h_max = panel_info.vl_col; 77 unsigned short v, h; 78 u32 *pix = (u32 *)lcd_base; 79 80 for (v = 0; v < v_max; v += 1) { 81 for (h = 0; h < h_max; h += 1) { 82 *pix++ = 0; 83 } 84 } 85 } 86 87 /* LCD initialisation. */ 88 89 void lcd_init(void) 90 { 91 __lcd_display_pin_init(); 92 __lcd_display_on(); 93 94 lcd_ctrl_init(&lcd_base); 95 lcd_clear(lcd_base); 96 lcd_enable(); 97 }