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@15 | 7 | * This program is free software; you can redistribute it and/or modify it under |
paul@15 | 8 | * the terms of the GNU General Public License as published by the Free Software |
paul@15 | 9 | * Foundation; either version 3 of the License, or (at your option) any later |
paul@15 | 10 | * version. |
paul@15 | 11 | * |
paul@15 | 12 | * This program is distributed in the hope that it will be useful, but WITHOUT |
paul@15 | 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
paul@15 | 14 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
paul@15 | 15 | * details. |
paul@15 | 16 | * |
paul@15 | 17 | * You should have received a copy of the GNU General Public License along with |
paul@15 | 18 | * 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@15 | 34 | #define ALIGN(x,a) __ALIGN_MASK((x),(typeof(x))(a)-1) |
paul@15 | 35 | #define __ALIGN_MASK(x,mask) (((x)+(mask))&~(mask)) |
paul@15 | 36 | |
paul@40 | 37 | extern vidinfo_t panel_info; |
paul@40 | 38 | |
paul@15 | 39 | unsigned long lcd_setmem(unsigned long addr) |
paul@15 | 40 | { |
paul@15 | 41 | unsigned long size; |
paul@15 | 42 | |
paul@15 | 43 | size = lcd_get_size(); |
paul@15 | 44 | |
paul@15 | 45 | /* Round up to nearest full page, or MMU section if defined */ |
paul@15 | 46 | size = ALIGN(size, PAGE_SIZE); |
paul@15 | 47 | addr = ALIGN(addr - PAGE_SIZE + 1, PAGE_SIZE); |
paul@15 | 48 | |
paul@15 | 49 | /* Allocate pages for the frame buffer. */ |
paul@15 | 50 | addr -= size; |
paul@15 | 51 | |
paul@15 | 52 | return addr; |
paul@15 | 53 | } |
paul@15 | 54 | |
paul@15 | 55 | static void test_pattern(void *lcd_base) |
paul@15 | 56 | { |
paul@15 | 57 | unsigned short v_max = panel_info.vl_row; |
paul@15 | 58 | unsigned short h_max = panel_info.vl_col; |
paul@15 | 59 | unsigned short v, h; |
paul@22 | 60 | u32 *pix = (u32 *)lcd_base; |
paul@15 | 61 | |
paul@22 | 62 | /* WARNING: Code silently assumes 32 bit/pixel */ |
paul@22 | 63 | for (v = 0; v < v_max; v += 1) { |
paul@22 | 64 | for (h = 0; h < h_max; h += 1) { |
paul@28 | 65 | *pix++ = ( |
paul@28 | 66 | (((255 * (h_max - h)) / (h_max - 1)) << 16) + |
paul@28 | 67 | ((((255 * h) / (h_max - 1) + (255 * (v_max - v)) / (v_max - 1)) / 2) << 8) + |
paul@28 | 68 | ((255 * v) / (v_max - 1)) |
paul@28 | 69 | ); |
paul@15 | 70 | } |
paul@15 | 71 | } |
paul@15 | 72 | } |
paul@15 | 73 | |
paul@15 | 74 | void lcd_clear(void *lcd_base) |
paul@15 | 75 | { |
paul@15 | 76 | test_pattern(lcd_base); |
paul@15 | 77 | } |
paul@15 | 78 | |
paul@15 | 79 | /* LCD initialisation. */ |
paul@15 | 80 | |
paul@15 | 81 | static void *lcd_base; |
paul@15 | 82 | |
paul@15 | 83 | void lcd_init(void) |
paul@15 | 84 | { |
paul@20 | 85 | __lcd_display_pin_init(); |
paul@20 | 86 | __lcd_display_on(); |
paul@20 | 87 | |
paul@15 | 88 | /* Start from the top of memory and obtain a framebuffer region. */ |
paul@15 | 89 | |
paul@15 | 90 | lcd_base = (void *) lcd_setmem(get_memory_size()); |
paul@15 | 91 | lcd_ctrl_init(lcd_base); |
paul@15 | 92 | lcd_clear(lcd_base); |
paul@15 | 93 | lcd_enable(); |
paul@15 | 94 | } |