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@34 | 23 | #else |
paul@34 | 24 | #include "nanonote_gpm940b0.h" |
paul@34 | 25 | #endif |
paul@34 | 26 | |
paul@15 | 27 | #include "xburst_types.h" |
paul@33 | 28 | #include "jzlcd.h" |
paul@33 | 29 | #include "sdram.h" |
paul@33 | 30 | #include "board.h" |
paul@15 | 31 | |
paul@15 | 32 | #define ALIGN(x,a) __ALIGN_MASK((x),(typeof(x))(a)-1) |
paul@15 | 33 | #define __ALIGN_MASK(x,mask) (((x)+(mask))&~(mask)) |
paul@15 | 34 | |
paul@15 | 35 | unsigned long lcd_setmem(unsigned long addr) |
paul@15 | 36 | { |
paul@15 | 37 | unsigned long size; |
paul@15 | 38 | |
paul@15 | 39 | size = lcd_get_size(); |
paul@15 | 40 | |
paul@15 | 41 | /* Round up to nearest full page, or MMU section if defined */ |
paul@15 | 42 | size = ALIGN(size, PAGE_SIZE); |
paul@15 | 43 | addr = ALIGN(addr - PAGE_SIZE + 1, PAGE_SIZE); |
paul@15 | 44 | |
paul@15 | 45 | /* Allocate pages for the frame buffer. */ |
paul@15 | 46 | addr -= size; |
paul@15 | 47 | |
paul@15 | 48 | return addr; |
paul@15 | 49 | } |
paul@15 | 50 | |
paul@15 | 51 | static void test_pattern(void *lcd_base) |
paul@15 | 52 | { |
paul@15 | 53 | unsigned short v_max = panel_info.vl_row; |
paul@15 | 54 | unsigned short h_max = panel_info.vl_col; |
paul@15 | 55 | unsigned short v, h; |
paul@22 | 56 | u32 *pix = (u32 *)lcd_base; |
paul@15 | 57 | |
paul@22 | 58 | /* WARNING: Code silently assumes 32 bit/pixel */ |
paul@22 | 59 | for (v = 0; v < v_max; v += 1) { |
paul@22 | 60 | for (h = 0; h < h_max; h += 1) { |
paul@28 | 61 | *pix++ = ( |
paul@28 | 62 | (((255 * (h_max - h)) / (h_max - 1)) << 16) + |
paul@28 | 63 | ((((255 * h) / (h_max - 1) + (255 * (v_max - v)) / (v_max - 1)) / 2) << 8) + |
paul@28 | 64 | ((255 * v) / (v_max - 1)) |
paul@28 | 65 | ); |
paul@15 | 66 | } |
paul@15 | 67 | } |
paul@15 | 68 | } |
paul@15 | 69 | |
paul@15 | 70 | void lcd_clear(void *lcd_base) |
paul@15 | 71 | { |
paul@15 | 72 | test_pattern(lcd_base); |
paul@15 | 73 | } |
paul@15 | 74 | |
paul@15 | 75 | /* LCD initialisation. */ |
paul@15 | 76 | |
paul@15 | 77 | static void *lcd_base; |
paul@15 | 78 | |
paul@15 | 79 | void lcd_init(void) |
paul@15 | 80 | { |
paul@20 | 81 | __lcd_display_pin_init(); |
paul@20 | 82 | __lcd_display_on(); |
paul@20 | 83 | |
paul@15 | 84 | /* Start from the top of memory and obtain a framebuffer region. */ |
paul@15 | 85 | |
paul@15 | 86 | lcd_base = (void *) lcd_setmem(get_memory_size()); |
paul@15 | 87 | lcd_ctrl_init(lcd_base); |
paul@15 | 88 | lcd_clear(lcd_base); |
paul@15 | 89 | lcd_enable(); |
paul@15 | 90 | } |