paul@15 | 1 | /* |
paul@15 | 2 | * Ben NanoNote LCD initialisation, based on uboot-xburst and xburst-tools. |
paul@15 | 3 | * |
paul@33 | 4 | * Copyright (C) 2001-2002 Wolfgang Denk, DENX Software Engineering, <wd@denx.de> |
paul@15 | 5 | * Copyright (C) 2015 Paul Boddie <paul@boddie.org.uk> |
paul@15 | 6 | * |
paul@63 | 7 | * This program is free software: you can redistribute it and/or modify |
paul@63 | 8 | * it under the terms of the GNU General Public License as published by |
paul@63 | 9 | * the Free Software Foundation, either version 3 of the License, or |
paul@63 | 10 | * (at your option) any later version. |
paul@15 | 11 | * |
paul@63 | 12 | * This program is distributed in the hope that it will be useful, |
paul@63 | 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
paul@63 | 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
paul@63 | 15 | * GNU General Public License for more details. |
paul@15 | 16 | * |
paul@63 | 17 | * You should have received a copy of the GNU General Public License |
paul@63 | 18 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
paul@15 | 19 | */ |
paul@15 | 20 | |
paul@34 | 21 | #ifdef CONFIG_CPU_JZ4730_MINIPC |
paul@34 | 22 | #include "minipc_claa070vc01.h" |
paul@40 | 23 | #include "minipc.h" |
paul@34 | 24 | #else |
paul@34 | 25 | #include "nanonote_gpm940b0.h" |
paul@40 | 26 | #include "nanonote.h" |
paul@34 | 27 | #endif |
paul@34 | 28 | |
paul@15 | 29 | #include "xburst_types.h" |
paul@33 | 30 | #include "jzlcd.h" |
paul@33 | 31 | #include "sdram.h" |
paul@33 | 32 | #include "board.h" |
paul@15 | 33 | |
paul@40 | 34 | extern vidinfo_t panel_info; |
paul@68 | 35 | static void *lcd_base; |
paul@68 | 36 | |
paul@68 | 37 | void test_pixel(unsigned short h, unsigned short v) |
paul@68 | 38 | { |
paul@68 | 39 | unsigned short v_max = panel_info.vl_row; |
paul@68 | 40 | unsigned short h_max = panel_info.vl_col; |
paul@68 | 41 | u32 *pix = (u32 *)lcd_base + v * h_max + h; |
paul@68 | 42 | |
paul@68 | 43 | /* NOTE: Code assumes 32 bits/pixel. */ |
paul@68 | 44 | |
paul@68 | 45 | *pix = ( |
paul@68 | 46 | (((255 * (h_max - h)) / (h_max - 1)) << 16) + |
paul@68 | 47 | ((((255 * h) / (h_max - 1) + (255 * (v_max - v)) / (v_max - 1)) / 2) << 8) + |
paul@68 | 48 | ((255 * v) / (v_max - 1)) |
paul@68 | 49 | ); |
paul@68 | 50 | } |
paul@68 | 51 | |
paul@68 | 52 | void clear_pixel(unsigned short h, unsigned short v) |
paul@68 | 53 | { |
paul@68 | 54 | unsigned short h_max = panel_info.vl_col; |
paul@68 | 55 | u32 *pix = (u32 *)lcd_base + v * h_max + h; |
paul@68 | 56 | |
paul@68 | 57 | *pix = 0; |
paul@68 | 58 | } |
paul@40 | 59 | |
paul@15 | 60 | static void test_pattern(void *lcd_base) |
paul@15 | 61 | { |
paul@15 | 62 | unsigned short v_max = panel_info.vl_row; |
paul@15 | 63 | unsigned short h_max = panel_info.vl_col; |
paul@15 | 64 | unsigned short v, h; |
paul@68 | 65 | |
paul@68 | 66 | for (v = 0; v < v_max; v += 1) { |
paul@68 | 67 | for (h = 0; h < h_max; h += 1) { |
paul@68 | 68 | test_pixel(h, v); |
paul@68 | 69 | } |
paul@68 | 70 | } |
paul@68 | 71 | } |
paul@68 | 72 | |
paul@68 | 73 | void lcd_clear(void *lcd_base) |
paul@68 | 74 | { |
paul@68 | 75 | unsigned short v_max = panel_info.vl_row; |
paul@68 | 76 | unsigned short h_max = panel_info.vl_col; |
paul@68 | 77 | unsigned short v, h; |
paul@22 | 78 | u32 *pix = (u32 *)lcd_base; |
paul@15 | 79 | |
paul@22 | 80 | for (v = 0; v < v_max; v += 1) { |
paul@22 | 81 | for (h = 0; h < h_max; h += 1) { |
paul@68 | 82 | *pix++ = 0; |
paul@15 | 83 | } |
paul@15 | 84 | } |
paul@15 | 85 | } |
paul@15 | 86 | |
paul@15 | 87 | /* LCD initialisation. */ |
paul@15 | 88 | |
paul@15 | 89 | void lcd_init(void) |
paul@15 | 90 | { |
paul@20 | 91 | __lcd_display_pin_init(); |
paul@20 | 92 | __lcd_display_on(); |
paul@20 | 93 | |
paul@48 | 94 | lcd_ctrl_init(&lcd_base); |
paul@15 | 95 | lcd_clear(lcd_base); |
paul@15 | 96 | lcd_enable(); |
paul@15 | 97 | } |