Donghwa Lee | 0112fed | 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 | bc72aeb | 2012-07-02 01:16:08 +0000 | [diff] [blame] | 31 | #include <asm/arch/dp_info.h> |
Donghwa Lee | 0112fed | 2012-04-05 19:36:17 +0000 | [diff] [blame] | 32 | #include <asm/arch/system.h> |
| 33 | |
| 34 | #include "exynos_fb.h" |
| 35 | |
Jeroen Hofstee | 881c4ec | 2013-01-22 10:44:12 +0000 | [diff] [blame^] | 36 | DECLARE_GLOBAL_DATA_PTR; |
Donghwa Lee | 0112fed | 2012-04-05 19:36:17 +0000 | [diff] [blame] | 37 | |
| 38 | static unsigned int panel_width, panel_height; |
| 39 | |
Donghwa Lee | 0112fed | 2012-04-05 19:36:17 +0000 | [diff] [blame] | 40 | static void exynos_lcd_init_mem(void *lcdbase, vidinfo_t *vid) |
| 41 | { |
| 42 | unsigned long palette_size; |
| 43 | unsigned int fb_size; |
| 44 | |
Donghwa Lee | 2386f45 | 2012-04-23 15:37:05 +0000 | [diff] [blame] | 45 | fb_size = vid->vl_row * vid->vl_col * (NBITS(vid->vl_bpix) >> 3); |
Donghwa Lee | 0112fed | 2012-04-05 19:36:17 +0000 | [diff] [blame] | 46 | |
Donghwa Lee | 0112fed | 2012-04-05 19:36:17 +0000 | [diff] [blame] | 47 | palette_size = NBITS(vid->vl_bpix) == 8 ? 256 : 16; |
| 48 | |
Jeroen Hofstee | 881c4ec | 2013-01-22 10:44:12 +0000 | [diff] [blame^] | 49 | exynos_fimd_lcd_init_mem((unsigned long)lcdbase, |
Donghwa Lee | 0112fed | 2012-04-05 19:36:17 +0000 | [diff] [blame] | 50 | (unsigned long)fb_size, palette_size); |
| 51 | } |
| 52 | |
| 53 | static void exynos_lcd_init(vidinfo_t *vid) |
| 54 | { |
| 55 | exynos_fimd_lcd_init(vid); |
Ćukasz Majewski | 43905f4 | 2013-01-08 03:48:40 +0000 | [diff] [blame] | 56 | |
| 57 | /* Enable flushing after LCD writes if requested */ |
| 58 | lcd_set_flush_dcache(1); |
Donghwa Lee | 0112fed | 2012-04-05 19:36:17 +0000 | [diff] [blame] | 59 | } |
| 60 | |
Ajay Kumar | 6c6a822 | 2013-01-13 23:32:16 +0000 | [diff] [blame] | 61 | #ifdef CONFIG_CMD_BMP |
Donghwa Lee | 37980dd | 2012-05-09 19:23:46 +0000 | [diff] [blame] | 62 | static void draw_logo(void) |
| 63 | { |
| 64 | int x, y; |
| 65 | ulong addr; |
| 66 | |
Piotr Wilczek | 79c40e6 | 2012-10-19 05:34:06 +0000 | [diff] [blame] | 67 | if (panel_width >= panel_info.logo_width) { |
| 68 | x = ((panel_width - panel_info.logo_width) >> 1); |
| 69 | } else { |
| 70 | x = 0; |
| 71 | printf("Warning: image width is bigger than display width\n"); |
| 72 | } |
| 73 | |
| 74 | if (panel_height >= panel_info.logo_height) { |
| 75 | y = ((panel_height - panel_info.logo_height) >> 1) - 4; |
| 76 | } else { |
| 77 | y = 0; |
| 78 | printf("Warning: image height is bigger than display height\n"); |
| 79 | } |
Donghwa Lee | 37980dd | 2012-05-09 19:23:46 +0000 | [diff] [blame] | 80 | |
| 81 | addr = panel_info.logo_addr; |
| 82 | bmp_display(addr, x, y); |
| 83 | } |
Ajay Kumar | 6c6a822 | 2013-01-13 23:32:16 +0000 | [diff] [blame] | 84 | #endif |
Donghwa Lee | 37980dd | 2012-05-09 19:23:46 +0000 | [diff] [blame] | 85 | |
Donghwa Lee | 0112fed | 2012-04-05 19:36:17 +0000 | [diff] [blame] | 86 | static void lcd_panel_on(vidinfo_t *vid) |
| 87 | { |
| 88 | udelay(vid->init_delay); |
| 89 | |
| 90 | if (vid->backlight_reset) |
| 91 | vid->backlight_reset(); |
| 92 | |
| 93 | if (vid->cfg_gpio) |
| 94 | vid->cfg_gpio(); |
| 95 | |
| 96 | if (vid->lcd_power_on) |
| 97 | vid->lcd_power_on(); |
| 98 | |
| 99 | udelay(vid->power_on_delay); |
| 100 | |
Donghwa Lee | bc72aeb | 2012-07-02 01:16:08 +0000 | [diff] [blame] | 101 | if (vid->dp_enabled) |
| 102 | exynos_init_dp(); |
| 103 | |
Donghwa Lee | 0112fed | 2012-04-05 19:36:17 +0000 | [diff] [blame] | 104 | if (vid->reset_lcd) { |
| 105 | vid->reset_lcd(); |
| 106 | udelay(vid->reset_delay); |
| 107 | } |
| 108 | |
| 109 | if (vid->backlight_on) |
| 110 | vid->backlight_on(1); |
| 111 | |
| 112 | if (vid->cfg_ldo) |
| 113 | vid->cfg_ldo(); |
| 114 | |
| 115 | if (vid->enable_ldo) |
| 116 | vid->enable_ldo(1); |
| 117 | |
| 118 | if (vid->mipi_enabled) |
| 119 | exynos_mipi_dsi_init(); |
| 120 | } |
| 121 | |
| 122 | void lcd_ctrl_init(void *lcdbase) |
| 123 | { |
| 124 | set_system_display_ctrl(); |
| 125 | set_lcd_clk(); |
| 126 | |
| 127 | /* initialize parameters which is specific to panel. */ |
| 128 | init_panel_info(&panel_info); |
| 129 | |
| 130 | panel_width = panel_info.vl_width; |
| 131 | panel_height = panel_info.vl_height; |
| 132 | |
| 133 | exynos_lcd_init_mem(lcdbase, &panel_info); |
| 134 | |
| 135 | exynos_lcd_init(&panel_info); |
| 136 | } |
| 137 | |
| 138 | void lcd_enable(void) |
| 139 | { |
Donghwa Lee | 37980dd | 2012-05-09 19:23:46 +0000 | [diff] [blame] | 140 | if (panel_info.logo_on) { |
Jeroen Hofstee | 881c4ec | 2013-01-22 10:44:12 +0000 | [diff] [blame^] | 141 | memset((void *) gd->fb_base, 0, panel_width * panel_height * |
Donghwa Lee | 37980dd | 2012-05-09 19:23:46 +0000 | [diff] [blame] | 142 | (NBITS(panel_info.vl_bpix) >> 3)); |
Ajay Kumar | 6c6a822 | 2013-01-13 23:32:16 +0000 | [diff] [blame] | 143 | #ifdef CONFIG_CMD_BMP |
Donghwa Lee | 37980dd | 2012-05-09 19:23:46 +0000 | [diff] [blame] | 144 | draw_logo(); |
Ajay Kumar | 6c6a822 | 2013-01-13 23:32:16 +0000 | [diff] [blame] | 145 | #endif |
Donghwa Lee | 37980dd | 2012-05-09 19:23:46 +0000 | [diff] [blame] | 146 | } |
| 147 | |
Donghwa Lee | 0112fed | 2012-04-05 19:36:17 +0000 | [diff] [blame] | 148 | lcd_panel_on(&panel_info); |
| 149 | } |
| 150 | |
| 151 | /* dummy function */ |
| 152 | void lcd_setcolreg(ushort regno, ushort red, ushort green, ushort blue) |
| 153 | { |
| 154 | return; |
| 155 | } |