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> |
| 31 | #include <asm/arch/system.h> |
| 32 | |
| 33 | #include "exynos_fb.h" |
| 34 | |
| 35 | int lcd_line_length; |
| 36 | int lcd_color_fg; |
| 37 | int lcd_color_bg; |
| 38 | |
| 39 | void *lcd_base; |
| 40 | void *lcd_console_address; |
| 41 | |
| 42 | short console_col; |
| 43 | short console_row; |
| 44 | |
| 45 | static unsigned int panel_width, panel_height; |
| 46 | |
| 47 | /* LCD Panel data */ |
| 48 | vidinfo_t panel_info; |
| 49 | |
| 50 | static void exynos_lcd_init_mem(void *lcdbase, vidinfo_t *vid) |
| 51 | { |
| 52 | unsigned long palette_size; |
| 53 | unsigned int fb_size; |
| 54 | |
| 55 | fb_size = vid->vl_row * vid->vl_col * (vid->vl_bpix >> 3); |
| 56 | |
| 57 | lcd_base = lcdbase; |
| 58 | |
| 59 | palette_size = NBITS(vid->vl_bpix) == 8 ? 256 : 16; |
| 60 | |
| 61 | exynos_fimd_lcd_init_mem((unsigned long)lcd_base, |
| 62 | (unsigned long)fb_size, palette_size); |
| 63 | } |
| 64 | |
| 65 | static void exynos_lcd_init(vidinfo_t *vid) |
| 66 | { |
| 67 | exynos_fimd_lcd_init(vid); |
| 68 | } |
| 69 | |
| 70 | static void lcd_panel_on(vidinfo_t *vid) |
| 71 | { |
| 72 | udelay(vid->init_delay); |
| 73 | |
| 74 | if (vid->backlight_reset) |
| 75 | vid->backlight_reset(); |
| 76 | |
| 77 | if (vid->cfg_gpio) |
| 78 | vid->cfg_gpio(); |
| 79 | |
| 80 | if (vid->lcd_power_on) |
| 81 | vid->lcd_power_on(); |
| 82 | |
| 83 | udelay(vid->power_on_delay); |
| 84 | |
| 85 | if (vid->reset_lcd) { |
| 86 | vid->reset_lcd(); |
| 87 | udelay(vid->reset_delay); |
| 88 | } |
| 89 | |
| 90 | if (vid->backlight_on) |
| 91 | vid->backlight_on(1); |
| 92 | |
| 93 | if (vid->cfg_ldo) |
| 94 | vid->cfg_ldo(); |
| 95 | |
| 96 | if (vid->enable_ldo) |
| 97 | vid->enable_ldo(1); |
| 98 | |
| 99 | if (vid->mipi_enabled) |
| 100 | exynos_mipi_dsi_init(); |
| 101 | } |
| 102 | |
| 103 | void lcd_ctrl_init(void *lcdbase) |
| 104 | { |
| 105 | set_system_display_ctrl(); |
| 106 | set_lcd_clk(); |
| 107 | |
| 108 | /* initialize parameters which is specific to panel. */ |
| 109 | init_panel_info(&panel_info); |
| 110 | |
| 111 | panel_width = panel_info.vl_width; |
| 112 | panel_height = panel_info.vl_height; |
| 113 | |
| 114 | exynos_lcd_init_mem(lcdbase, &panel_info); |
| 115 | |
| 116 | exynos_lcd_init(&panel_info); |
| 117 | } |
| 118 | |
| 119 | void lcd_enable(void) |
| 120 | { |
| 121 | lcd_panel_on(&panel_info); |
| 122 | } |
| 123 | |
| 124 | /* dummy function */ |
| 125 | void lcd_setcolreg(ushort regno, ushort red, ushort green, ushort blue) |
| 126 | { |
| 127 | return; |
| 128 | } |