Donghwa Lee | 6d4339f | 2012-04-05 19:36:17 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2012 Samsung Electronics |
| 3 | * |
| 4 | * Author: InKi Dae <inki.dae@samsung.com> |
| 5 | * Author: Donghwa Lee <dh09.lee@samsung.com> |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or |
| 8 | * modify it under the terms of the GNU General Public License as |
| 9 | * published by the Free Software Foundation; either version 2 of |
| 10 | * the License, or (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, write to the Free Software |
| 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 20 | * MA 02111-1307 USA |
| 21 | */ |
| 22 | |
| 23 | #include <config.h> |
| 24 | #include <common.h> |
| 25 | #include <lcd.h> |
| 26 | #include <asm/io.h> |
| 27 | #include <asm/arch/cpu.h> |
| 28 | #include <asm/arch/clock.h> |
| 29 | #include <asm/arch/clk.h> |
| 30 | #include <asm/arch/mipi_dsim.h> |
Donghwa Lee | a29c832 | 2012-07-02 01:16:08 +0000 | [diff] [blame] | 31 | #include <asm/arch/dp_info.h> |
Donghwa Lee | 6d4339f | 2012-04-05 19:36:17 +0000 | [diff] [blame] | 32 | #include <asm/arch/system.h> |
| 33 | |
| 34 | #include "exynos_fb.h" |
| 35 | |
| 36 | int lcd_line_length; |
| 37 | int lcd_color_fg; |
| 38 | int lcd_color_bg; |
| 39 | |
| 40 | void *lcd_base; |
| 41 | void *lcd_console_address; |
| 42 | |
| 43 | short console_col; |
| 44 | short console_row; |
| 45 | |
| 46 | static unsigned int panel_width, panel_height; |
| 47 | |
Donghwa Lee | 6d4339f | 2012-04-05 19:36:17 +0000 | [diff] [blame] | 48 | static void exynos_lcd_init_mem(void *lcdbase, vidinfo_t *vid) |
| 49 | { |
| 50 | unsigned long palette_size; |
| 51 | unsigned int fb_size; |
| 52 | |
Donghwa Lee | f78095e | 2012-04-23 15:37:05 +0000 | [diff] [blame] | 53 | fb_size = vid->vl_row * vid->vl_col * (NBITS(vid->vl_bpix) >> 3); |
Donghwa Lee | 6d4339f | 2012-04-05 19:36:17 +0000 | [diff] [blame] | 54 | |
| 55 | lcd_base = lcdbase; |
| 56 | |
| 57 | palette_size = NBITS(vid->vl_bpix) == 8 ? 256 : 16; |
| 58 | |
| 59 | exynos_fimd_lcd_init_mem((unsigned long)lcd_base, |
| 60 | (unsigned long)fb_size, palette_size); |
| 61 | } |
| 62 | |
| 63 | static void exynos_lcd_init(vidinfo_t *vid) |
| 64 | { |
| 65 | exynos_fimd_lcd_init(vid); |
Ćukasz Majewski | c6d647e | 2013-01-08 03:48:40 +0000 | [diff] [blame] | 66 | |
| 67 | /* Enable flushing after LCD writes if requested */ |
| 68 | lcd_set_flush_dcache(1); |
Donghwa Lee | 6d4339f | 2012-04-05 19:36:17 +0000 | [diff] [blame] | 69 | } |
| 70 | |
Ajay Kumar | e4660e0 | 2013-01-13 23:32:16 +0000 | [diff] [blame] | 71 | #ifdef CONFIG_CMD_BMP |
Donghwa Lee | 9046497 | 2012-05-09 19:23:46 +0000 | [diff] [blame] | 72 | static void draw_logo(void) |
| 73 | { |
| 74 | int x, y; |
| 75 | ulong addr; |
| 76 | |
Piotr Wilczek | 28c9e34 | 2012-10-19 05:34:06 +0000 | [diff] [blame] | 77 | if (panel_width >= panel_info.logo_width) { |
| 78 | x = ((panel_width - panel_info.logo_width) >> 1); |
| 79 | } else { |
| 80 | x = 0; |
| 81 | printf("Warning: image width is bigger than display width\n"); |
| 82 | } |
| 83 | |
| 84 | if (panel_height >= panel_info.logo_height) { |
| 85 | y = ((panel_height - panel_info.logo_height) >> 1) - 4; |
| 86 | } else { |
| 87 | y = 0; |
| 88 | printf("Warning: image height is bigger than display height\n"); |
| 89 | } |
Donghwa Lee | 9046497 | 2012-05-09 19:23:46 +0000 | [diff] [blame] | 90 | |
| 91 | addr = panel_info.logo_addr; |
| 92 | bmp_display(addr, x, y); |
| 93 | } |
Ajay Kumar | e4660e0 | 2013-01-13 23:32:16 +0000 | [diff] [blame] | 94 | #endif |
Donghwa Lee | 9046497 | 2012-05-09 19:23:46 +0000 | [diff] [blame] | 95 | |
Ajay Kumar | 29fd570 | 2013-02-21 23:52:57 +0000 | [diff] [blame^] | 96 | void __exynos_cfg_lcd_gpio(void) |
| 97 | { |
| 98 | } |
| 99 | void exynos_cfg_lcd_gpio(void) |
| 100 | __attribute__((weak, alias("__exynos_cfg_lcd_gpio"))); |
| 101 | |
| 102 | void __exynos_backlight_on(unsigned int onoff) |
| 103 | { |
| 104 | } |
| 105 | void exynos_backlight_on(unsigned int onoff) |
| 106 | __attribute__((weak, alias("__exynos_cfg_lcd_gpio"))); |
| 107 | |
| 108 | void __exynos_reset_lcd(void) |
| 109 | { |
| 110 | } |
| 111 | void exynos_reset_lcd(void) |
| 112 | __attribute__((weak, alias("__exynos_reset_lcd"))); |
| 113 | |
| 114 | void __exynos_lcd_power_on(void) |
| 115 | { |
| 116 | } |
| 117 | void exynos_lcd_power_on(void) |
| 118 | __attribute__((weak, alias("__exynos_lcd_power_on"))); |
| 119 | |
| 120 | void __exynos_cfg_ldo(void) |
| 121 | { |
| 122 | } |
| 123 | void exynos_cfg_ldo(void) |
| 124 | __attribute__((weak, alias("__exynos_cfg_ldo"))); |
| 125 | |
| 126 | void __exynos_enable_ldo(unsigned int onoff) |
| 127 | { |
| 128 | } |
| 129 | void exynos_enable_ldo(unsigned int onoff) |
| 130 | __attribute__((weak, alias("__exynos_enable_ldo"))); |
| 131 | |
| 132 | void __exynos_backlight_reset(void) |
| 133 | { |
| 134 | } |
| 135 | void exynos_backlight_reset(void) |
| 136 | __attribute__((weak, alias("__exynos_backlight_reset"))); |
| 137 | |
Donghwa Lee | 6d4339f | 2012-04-05 19:36:17 +0000 | [diff] [blame] | 138 | static void lcd_panel_on(vidinfo_t *vid) |
| 139 | { |
| 140 | udelay(vid->init_delay); |
| 141 | |
Ajay Kumar | 29fd570 | 2013-02-21 23:52:57 +0000 | [diff] [blame^] | 142 | exynos_backlight_reset(); |
Donghwa Lee | 6d4339f | 2012-04-05 19:36:17 +0000 | [diff] [blame] | 143 | |
Ajay Kumar | 29fd570 | 2013-02-21 23:52:57 +0000 | [diff] [blame^] | 144 | exynos_cfg_lcd_gpio(); |
Donghwa Lee | 6d4339f | 2012-04-05 19:36:17 +0000 | [diff] [blame] | 145 | |
Ajay Kumar | 29fd570 | 2013-02-21 23:52:57 +0000 | [diff] [blame^] | 146 | exynos_lcd_power_on(); |
Donghwa Lee | 6d4339f | 2012-04-05 19:36:17 +0000 | [diff] [blame] | 147 | |
| 148 | udelay(vid->power_on_delay); |
| 149 | |
Donghwa Lee | a29c832 | 2012-07-02 01:16:08 +0000 | [diff] [blame] | 150 | if (vid->dp_enabled) |
| 151 | exynos_init_dp(); |
| 152 | |
Ajay Kumar | 29fd570 | 2013-02-21 23:52:57 +0000 | [diff] [blame^] | 153 | exynos_reset_lcd(); |
Donghwa Lee | 6d4339f | 2012-04-05 19:36:17 +0000 | [diff] [blame] | 154 | |
Ajay Kumar | 29fd570 | 2013-02-21 23:52:57 +0000 | [diff] [blame^] | 155 | udelay(vid->reset_delay); |
Donghwa Lee | 6d4339f | 2012-04-05 19:36:17 +0000 | [diff] [blame] | 156 | |
Ajay Kumar | 29fd570 | 2013-02-21 23:52:57 +0000 | [diff] [blame^] | 157 | exynos_backlight_on(1); |
Donghwa Lee | 6d4339f | 2012-04-05 19:36:17 +0000 | [diff] [blame] | 158 | |
Ajay Kumar | 29fd570 | 2013-02-21 23:52:57 +0000 | [diff] [blame^] | 159 | exynos_cfg_ldo(); |
| 160 | |
| 161 | exynos_enable_ldo(1); |
Donghwa Lee | 6d4339f | 2012-04-05 19:36:17 +0000 | [diff] [blame] | 162 | |
| 163 | if (vid->mipi_enabled) |
| 164 | exynos_mipi_dsi_init(); |
| 165 | } |
| 166 | |
| 167 | void lcd_ctrl_init(void *lcdbase) |
| 168 | { |
| 169 | set_system_display_ctrl(); |
| 170 | set_lcd_clk(); |
| 171 | |
| 172 | /* initialize parameters which is specific to panel. */ |
| 173 | init_panel_info(&panel_info); |
| 174 | |
| 175 | panel_width = panel_info.vl_width; |
| 176 | panel_height = panel_info.vl_height; |
| 177 | |
| 178 | exynos_lcd_init_mem(lcdbase, &panel_info); |
| 179 | |
| 180 | exynos_lcd_init(&panel_info); |
| 181 | } |
| 182 | |
| 183 | void lcd_enable(void) |
| 184 | { |
Donghwa Lee | 9046497 | 2012-05-09 19:23:46 +0000 | [diff] [blame] | 185 | if (panel_info.logo_on) { |
| 186 | memset(lcd_base, 0, panel_width * panel_height * |
| 187 | (NBITS(panel_info.vl_bpix) >> 3)); |
Ajay Kumar | e4660e0 | 2013-01-13 23:32:16 +0000 | [diff] [blame] | 188 | #ifdef CONFIG_CMD_BMP |
Donghwa Lee | 9046497 | 2012-05-09 19:23:46 +0000 | [diff] [blame] | 189 | draw_logo(); |
Ajay Kumar | e4660e0 | 2013-01-13 23:32:16 +0000 | [diff] [blame] | 190 | #endif |
Donghwa Lee | 9046497 | 2012-05-09 19:23:46 +0000 | [diff] [blame] | 191 | } |
| 192 | |
Donghwa Lee | 6d4339f | 2012-04-05 19:36:17 +0000 | [diff] [blame] | 193 | lcd_panel_on(&panel_info); |
| 194 | } |
| 195 | |
| 196 | /* dummy function */ |
| 197 | void lcd_setcolreg(ushort regno, ushort red, ushort green, ushort blue) |
| 198 | { |
| 199 | return; |
| 200 | } |