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 | * |
Wolfgang Denk | bd8ec7e | 2013-10-07 13:07:26 +0200 | [diff] [blame] | 7 | * SPDX-License-Identifier: GPL-2.0+ |
Donghwa Lee | 0112fed | 2012-04-05 19:36:17 +0000 | [diff] [blame] | 8 | */ |
| 9 | |
| 10 | #include <config.h> |
| 11 | #include <common.h> |
Simon Glass | c9ed7a4 | 2016-02-21 21:08:48 -0700 | [diff] [blame] | 12 | #include <div64.h> |
Donghwa Lee | 0112fed | 2012-04-05 19:36:17 +0000 | [diff] [blame] | 13 | #include <lcd.h> |
Ajay Kumar | ebbace3 | 2013-02-21 23:53:01 +0000 | [diff] [blame] | 14 | #include <fdtdec.h> |
| 15 | #include <libfdt.h> |
Donghwa Lee | 0112fed | 2012-04-05 19:36:17 +0000 | [diff] [blame] | 16 | #include <asm/io.h> |
| 17 | #include <asm/arch/cpu.h> |
| 18 | #include <asm/arch/clock.h> |
| 19 | #include <asm/arch/clk.h> |
| 20 | #include <asm/arch/mipi_dsim.h> |
Donghwa Lee | bc72aeb | 2012-07-02 01:16:08 +0000 | [diff] [blame] | 21 | #include <asm/arch/dp_info.h> |
Donghwa Lee | 0112fed | 2012-04-05 19:36:17 +0000 | [diff] [blame] | 22 | #include <asm/arch/system.h> |
Ajay Kumar | 39ea08b | 2015-03-04 19:05:26 +0530 | [diff] [blame] | 23 | #include <asm/gpio.h> |
Ajay Kumar | ebbace3 | 2013-02-21 23:53:01 +0000 | [diff] [blame] | 24 | #include <asm-generic/errno.h> |
Donghwa Lee | 0112fed | 2012-04-05 19:36:17 +0000 | [diff] [blame] | 25 | |
| 26 | #include "exynos_fb.h" |
| 27 | |
Ajay Kumar | ebbace3 | 2013-02-21 23:53:01 +0000 | [diff] [blame] | 28 | DECLARE_GLOBAL_DATA_PTR; |
| 29 | |
Simon Glass | 6d27559 | 2016-02-21 21:08:40 -0700 | [diff] [blame] | 30 | struct vidinfo panel_info = { |
Ajay Kumar | 1176348 | 2014-09-05 16:53:30 +0530 | [diff] [blame] | 31 | /* |
| 32 | * Insert a value here so that we don't end up in the BSS |
| 33 | * Reference: drivers/video/tegra.c |
| 34 | */ |
| 35 | .vl_col = -1, |
Ajay Kumar | ebbace3 | 2013-02-21 23:53:01 +0000 | [diff] [blame] | 36 | }; |
Ajay Kumar | ebbace3 | 2013-02-21 23:53:01 +0000 | [diff] [blame] | 37 | |
Simon Glass | 305f581 | 2016-02-21 21:09:00 -0700 | [diff] [blame^] | 38 | static void exynos_fimd_set_dualrgb(struct vidinfo *priv, unsigned int enabled) |
Simon Glass | c9ed7a4 | 2016-02-21 21:08:48 -0700 | [diff] [blame] | 39 | { |
Simon Glass | 305f581 | 2016-02-21 21:09:00 -0700 | [diff] [blame^] | 40 | struct exynos_fb *reg = priv->reg; |
Simon Glass | c9ed7a4 | 2016-02-21 21:08:48 -0700 | [diff] [blame] | 41 | unsigned int cfg = 0; |
| 42 | |
| 43 | if (enabled) { |
| 44 | cfg = EXYNOS_DUALRGB_BYPASS_DUAL | EXYNOS_DUALRGB_LINESPLIT | |
| 45 | EXYNOS_DUALRGB_VDEN_EN_ENABLE; |
| 46 | |
| 47 | /* in case of Line Split mode, MAIN_CNT doesn't neet to set. */ |
Simon Glass | 305f581 | 2016-02-21 21:09:00 -0700 | [diff] [blame^] | 48 | cfg |= EXYNOS_DUALRGB_SUB_CNT(priv->vl_col / 2) | |
Simon Glass | c9ed7a4 | 2016-02-21 21:08:48 -0700 | [diff] [blame] | 49 | EXYNOS_DUALRGB_MAIN_CNT(0); |
| 50 | } |
| 51 | |
Simon Glass | 305f581 | 2016-02-21 21:09:00 -0700 | [diff] [blame^] | 52 | writel(cfg, ®->dualrgb); |
Simon Glass | c9ed7a4 | 2016-02-21 21:08:48 -0700 | [diff] [blame] | 53 | } |
| 54 | |
Simon Glass | 305f581 | 2016-02-21 21:09:00 -0700 | [diff] [blame^] | 55 | static void exynos_fimd_set_dp_clkcon(struct vidinfo *priv, |
Simon Glass | c9ed7a4 | 2016-02-21 21:08:48 -0700 | [diff] [blame] | 56 | unsigned int enabled) |
| 57 | { |
Simon Glass | 305f581 | 2016-02-21 21:09:00 -0700 | [diff] [blame^] | 58 | struct exynos_fb *reg = priv->reg; |
Simon Glass | c9ed7a4 | 2016-02-21 21:08:48 -0700 | [diff] [blame] | 59 | unsigned int cfg = 0; |
| 60 | |
| 61 | if (enabled) |
| 62 | cfg = EXYNOS_DP_CLK_ENABLE; |
| 63 | |
Simon Glass | 305f581 | 2016-02-21 21:09:00 -0700 | [diff] [blame^] | 64 | writel(cfg, ®->dp_mie_clkcon); |
Simon Glass | c9ed7a4 | 2016-02-21 21:08:48 -0700 | [diff] [blame] | 65 | } |
| 66 | |
Simon Glass | 305f581 | 2016-02-21 21:09:00 -0700 | [diff] [blame^] | 67 | static void exynos_fimd_set_par(struct vidinfo *priv, unsigned int win_id) |
Simon Glass | c9ed7a4 | 2016-02-21 21:08:48 -0700 | [diff] [blame] | 68 | { |
Simon Glass | 305f581 | 2016-02-21 21:09:00 -0700 | [diff] [blame^] | 69 | struct exynos_fb *reg = priv->reg; |
Simon Glass | c9ed7a4 | 2016-02-21 21:08:48 -0700 | [diff] [blame] | 70 | unsigned int cfg = 0; |
| 71 | |
| 72 | /* set window control */ |
Simon Glass | 305f581 | 2016-02-21 21:09:00 -0700 | [diff] [blame^] | 73 | cfg = readl((unsigned int)®->wincon0 + |
Simon Glass | c9ed7a4 | 2016-02-21 21:08:48 -0700 | [diff] [blame] | 74 | EXYNOS_WINCON(win_id)); |
| 75 | |
| 76 | cfg &= ~(EXYNOS_WINCON_BITSWP_ENABLE | EXYNOS_WINCON_BYTESWP_ENABLE | |
| 77 | EXYNOS_WINCON_HAWSWP_ENABLE | EXYNOS_WINCON_WSWP_ENABLE | |
| 78 | EXYNOS_WINCON_BURSTLEN_MASK | EXYNOS_WINCON_BPPMODE_MASK | |
| 79 | EXYNOS_WINCON_INRGB_MASK | EXYNOS_WINCON_DATAPATH_MASK); |
| 80 | |
| 81 | /* DATAPATH is DMA */ |
| 82 | cfg |= EXYNOS_WINCON_DATAPATH_DMA; |
| 83 | |
| 84 | cfg |= EXYNOS_WINCON_HAWSWP_ENABLE; |
| 85 | |
| 86 | /* dma burst is 16 */ |
| 87 | cfg |= EXYNOS_WINCON_BURSTLEN_16WORD; |
| 88 | |
Simon Glass | 305f581 | 2016-02-21 21:09:00 -0700 | [diff] [blame^] | 89 | switch (priv->vl_bpix) { |
Simon Glass | c9ed7a4 | 2016-02-21 21:08:48 -0700 | [diff] [blame] | 90 | case 4: |
| 91 | cfg |= EXYNOS_WINCON_BPPMODE_16BPP_565; |
| 92 | break; |
| 93 | default: |
| 94 | cfg |= EXYNOS_WINCON_BPPMODE_24BPP_888; |
| 95 | break; |
| 96 | } |
| 97 | |
Simon Glass | 305f581 | 2016-02-21 21:09:00 -0700 | [diff] [blame^] | 98 | writel(cfg, (unsigned int)®->wincon0 + |
Simon Glass | c9ed7a4 | 2016-02-21 21:08:48 -0700 | [diff] [blame] | 99 | EXYNOS_WINCON(win_id)); |
| 100 | |
| 101 | /* set window position to x=0, y=0*/ |
| 102 | cfg = EXYNOS_VIDOSD_LEFT_X(0) | EXYNOS_VIDOSD_TOP_Y(0); |
Simon Glass | 305f581 | 2016-02-21 21:09:00 -0700 | [diff] [blame^] | 103 | writel(cfg, (unsigned int)®->vidosd0a + |
Simon Glass | c9ed7a4 | 2016-02-21 21:08:48 -0700 | [diff] [blame] | 104 | EXYNOS_VIDOSD(win_id)); |
| 105 | |
Simon Glass | 305f581 | 2016-02-21 21:09:00 -0700 | [diff] [blame^] | 106 | cfg = EXYNOS_VIDOSD_RIGHT_X(priv->vl_col - 1) | |
| 107 | EXYNOS_VIDOSD_BOTTOM_Y(priv->vl_row - 1) | |
Simon Glass | c9ed7a4 | 2016-02-21 21:08:48 -0700 | [diff] [blame] | 108 | EXYNOS_VIDOSD_RIGHT_X_E(1) | |
| 109 | EXYNOS_VIDOSD_BOTTOM_Y_E(0); |
| 110 | |
Simon Glass | 305f581 | 2016-02-21 21:09:00 -0700 | [diff] [blame^] | 111 | writel(cfg, (unsigned int)®->vidosd0b + |
Simon Glass | c9ed7a4 | 2016-02-21 21:08:48 -0700 | [diff] [blame] | 112 | EXYNOS_VIDOSD(win_id)); |
| 113 | |
| 114 | /* set window size for window0*/ |
Simon Glass | 305f581 | 2016-02-21 21:09:00 -0700 | [diff] [blame^] | 115 | cfg = EXYNOS_VIDOSD_SIZE(priv->vl_col * priv->vl_row); |
| 116 | writel(cfg, (unsigned int)®->vidosd0c + |
Simon Glass | c9ed7a4 | 2016-02-21 21:08:48 -0700 | [diff] [blame] | 117 | EXYNOS_VIDOSD(win_id)); |
| 118 | } |
| 119 | |
Simon Glass | 305f581 | 2016-02-21 21:09:00 -0700 | [diff] [blame^] | 120 | static void exynos_fimd_set_buffer_address(struct vidinfo *priv, |
Simon Glass | c9ed7a4 | 2016-02-21 21:08:48 -0700 | [diff] [blame] | 121 | unsigned int win_id, |
| 122 | ulong lcd_base_addr) |
| 123 | { |
Simon Glass | 305f581 | 2016-02-21 21:09:00 -0700 | [diff] [blame^] | 124 | struct exynos_fb *reg = priv->reg; |
Simon Glass | c9ed7a4 | 2016-02-21 21:08:48 -0700 | [diff] [blame] | 125 | unsigned long start_addr, end_addr; |
| 126 | |
| 127 | start_addr = lcd_base_addr; |
Simon Glass | 305f581 | 2016-02-21 21:09:00 -0700 | [diff] [blame^] | 128 | end_addr = start_addr + ((priv->vl_col * (NBITS(priv->vl_bpix) / 8)) * |
| 129 | priv->vl_row); |
Simon Glass | c9ed7a4 | 2016-02-21 21:08:48 -0700 | [diff] [blame] | 130 | |
Simon Glass | 305f581 | 2016-02-21 21:09:00 -0700 | [diff] [blame^] | 131 | writel(start_addr, (unsigned int)®->vidw00add0b0 + |
Simon Glass | c9ed7a4 | 2016-02-21 21:08:48 -0700 | [diff] [blame] | 132 | EXYNOS_BUFFER_OFFSET(win_id)); |
Simon Glass | 305f581 | 2016-02-21 21:09:00 -0700 | [diff] [blame^] | 133 | writel(end_addr, (unsigned int)®->vidw00add1b0 + |
Simon Glass | c9ed7a4 | 2016-02-21 21:08:48 -0700 | [diff] [blame] | 134 | EXYNOS_BUFFER_OFFSET(win_id)); |
| 135 | } |
| 136 | |
Simon Glass | 305f581 | 2016-02-21 21:09:00 -0700 | [diff] [blame^] | 137 | static void exynos_fimd_set_clock(struct vidinfo *priv) |
Simon Glass | c9ed7a4 | 2016-02-21 21:08:48 -0700 | [diff] [blame] | 138 | { |
Simon Glass | 305f581 | 2016-02-21 21:09:00 -0700 | [diff] [blame^] | 139 | struct exynos_fb *reg = priv->reg; |
Simon Glass | c9ed7a4 | 2016-02-21 21:08:48 -0700 | [diff] [blame] | 140 | unsigned int cfg = 0, div = 0, remainder, remainder_div; |
| 141 | unsigned long pixel_clock; |
| 142 | unsigned long long src_clock; |
| 143 | |
Simon Glass | 305f581 | 2016-02-21 21:09:00 -0700 | [diff] [blame^] | 144 | if (priv->dual_lcd_enabled) { |
| 145 | pixel_clock = priv->vl_freq * |
| 146 | (priv->vl_hspw + priv->vl_hfpd + |
| 147 | priv->vl_hbpd + priv->vl_col / 2) * |
| 148 | (priv->vl_vspw + priv->vl_vfpd + |
| 149 | priv->vl_vbpd + priv->vl_row); |
| 150 | } else if (priv->interface_mode == FIMD_CPU_INTERFACE) { |
| 151 | pixel_clock = priv->vl_freq * |
| 152 | priv->vl_width * priv->vl_height * |
| 153 | (priv->cs_setup + priv->wr_setup + |
| 154 | priv->wr_act + priv->wr_hold + 1); |
Simon Glass | c9ed7a4 | 2016-02-21 21:08:48 -0700 | [diff] [blame] | 155 | } else { |
Simon Glass | 305f581 | 2016-02-21 21:09:00 -0700 | [diff] [blame^] | 156 | pixel_clock = priv->vl_freq * |
| 157 | (priv->vl_hspw + priv->vl_hfpd + |
| 158 | priv->vl_hbpd + priv->vl_col) * |
| 159 | (priv->vl_vspw + priv->vl_vfpd + |
| 160 | priv->vl_vbpd + priv->vl_row); |
Simon Glass | c9ed7a4 | 2016-02-21 21:08:48 -0700 | [diff] [blame] | 161 | } |
| 162 | |
Simon Glass | 305f581 | 2016-02-21 21:09:00 -0700 | [diff] [blame^] | 163 | cfg = readl(®->vidcon0); |
Simon Glass | c9ed7a4 | 2016-02-21 21:08:48 -0700 | [diff] [blame] | 164 | cfg &= ~(EXYNOS_VIDCON0_CLKSEL_MASK | EXYNOS_VIDCON0_CLKVALUP_MASK | |
| 165 | EXYNOS_VIDCON0_CLKVAL_F(0xFF) | EXYNOS_VIDCON0_VCLKEN_MASK | |
| 166 | EXYNOS_VIDCON0_CLKDIR_MASK); |
| 167 | cfg |= (EXYNOS_VIDCON0_CLKSEL_SCLK | EXYNOS_VIDCON0_CLKVALUP_ALWAYS | |
| 168 | EXYNOS_VIDCON0_VCLKEN_NORMAL | EXYNOS_VIDCON0_CLKDIR_DIVIDED); |
| 169 | |
| 170 | src_clock = (unsigned long long) get_lcd_clk(); |
| 171 | |
| 172 | /* get quotient and remainder. */ |
| 173 | remainder = do_div(src_clock, pixel_clock); |
| 174 | div = src_clock; |
| 175 | |
| 176 | remainder *= 10; |
| 177 | remainder_div = remainder / pixel_clock; |
| 178 | |
| 179 | /* round about one places of decimals. */ |
| 180 | if (remainder_div >= 5) |
| 181 | div++; |
| 182 | |
| 183 | /* in case of dual lcd mode. */ |
Simon Glass | 305f581 | 2016-02-21 21:09:00 -0700 | [diff] [blame^] | 184 | if (priv->dual_lcd_enabled) |
Simon Glass | c9ed7a4 | 2016-02-21 21:08:48 -0700 | [diff] [blame] | 185 | div--; |
| 186 | |
| 187 | cfg |= EXYNOS_VIDCON0_CLKVAL_F(div - 1); |
Simon Glass | 305f581 | 2016-02-21 21:09:00 -0700 | [diff] [blame^] | 188 | writel(cfg, ®->vidcon0); |
Simon Glass | c9ed7a4 | 2016-02-21 21:08:48 -0700 | [diff] [blame] | 189 | } |
| 190 | |
Simon Glass | 305f581 | 2016-02-21 21:09:00 -0700 | [diff] [blame^] | 191 | void exynos_set_trigger(struct vidinfo *priv) |
Simon Glass | c9ed7a4 | 2016-02-21 21:08:48 -0700 | [diff] [blame] | 192 | { |
Simon Glass | 305f581 | 2016-02-21 21:09:00 -0700 | [diff] [blame^] | 193 | struct exynos_fb *reg = priv->reg; |
Simon Glass | c9ed7a4 | 2016-02-21 21:08:48 -0700 | [diff] [blame] | 194 | unsigned int cfg = 0; |
| 195 | |
Simon Glass | 305f581 | 2016-02-21 21:09:00 -0700 | [diff] [blame^] | 196 | cfg = readl(®->trigcon); |
Simon Glass | c9ed7a4 | 2016-02-21 21:08:48 -0700 | [diff] [blame] | 197 | |
| 198 | cfg |= (EXYNOS_I80SOFT_TRIG_EN | EXYNOS_I80START_TRIG); |
| 199 | |
Simon Glass | 305f581 | 2016-02-21 21:09:00 -0700 | [diff] [blame^] | 200 | writel(cfg, ®->trigcon); |
Simon Glass | c9ed7a4 | 2016-02-21 21:08:48 -0700 | [diff] [blame] | 201 | } |
| 202 | |
Simon Glass | 305f581 | 2016-02-21 21:09:00 -0700 | [diff] [blame^] | 203 | int exynos_is_i80_frame_done(struct vidinfo *priv) |
Simon Glass | c9ed7a4 | 2016-02-21 21:08:48 -0700 | [diff] [blame] | 204 | { |
Simon Glass | 305f581 | 2016-02-21 21:09:00 -0700 | [diff] [blame^] | 205 | struct exynos_fb *reg = priv->reg; |
Simon Glass | c9ed7a4 | 2016-02-21 21:08:48 -0700 | [diff] [blame] | 206 | unsigned int cfg = 0; |
| 207 | int status; |
| 208 | |
Simon Glass | 305f581 | 2016-02-21 21:09:00 -0700 | [diff] [blame^] | 209 | cfg = readl(®->trigcon); |
Simon Glass | c9ed7a4 | 2016-02-21 21:08:48 -0700 | [diff] [blame] | 210 | |
| 211 | /* frame done func is valid only when TRIMODE[0] is set to 1. */ |
| 212 | status = (cfg & EXYNOS_I80STATUS_TRIG_DONE) == |
| 213 | EXYNOS_I80STATUS_TRIG_DONE; |
| 214 | |
| 215 | return status; |
| 216 | } |
| 217 | |
Simon Glass | 305f581 | 2016-02-21 21:09:00 -0700 | [diff] [blame^] | 218 | static void exynos_fimd_lcd_on(struct vidinfo *priv) |
Simon Glass | c9ed7a4 | 2016-02-21 21:08:48 -0700 | [diff] [blame] | 219 | { |
Simon Glass | 305f581 | 2016-02-21 21:09:00 -0700 | [diff] [blame^] | 220 | struct exynos_fb *reg = priv->reg; |
Simon Glass | c9ed7a4 | 2016-02-21 21:08:48 -0700 | [diff] [blame] | 221 | unsigned int cfg = 0; |
| 222 | |
| 223 | /* display on */ |
Simon Glass | 305f581 | 2016-02-21 21:09:00 -0700 | [diff] [blame^] | 224 | cfg = readl(®->vidcon0); |
Simon Glass | c9ed7a4 | 2016-02-21 21:08:48 -0700 | [diff] [blame] | 225 | cfg |= (EXYNOS_VIDCON0_ENVID_ENABLE | EXYNOS_VIDCON0_ENVID_F_ENABLE); |
Simon Glass | 305f581 | 2016-02-21 21:09:00 -0700 | [diff] [blame^] | 226 | writel(cfg, ®->vidcon0); |
Simon Glass | c9ed7a4 | 2016-02-21 21:08:48 -0700 | [diff] [blame] | 227 | } |
| 228 | |
Simon Glass | 305f581 | 2016-02-21 21:09:00 -0700 | [diff] [blame^] | 229 | static void exynos_fimd_window_on(struct vidinfo *priv, unsigned int win_id) |
Simon Glass | c9ed7a4 | 2016-02-21 21:08:48 -0700 | [diff] [blame] | 230 | { |
Simon Glass | 305f581 | 2016-02-21 21:09:00 -0700 | [diff] [blame^] | 231 | struct exynos_fb *reg = priv->reg; |
Simon Glass | c9ed7a4 | 2016-02-21 21:08:48 -0700 | [diff] [blame] | 232 | unsigned int cfg = 0; |
| 233 | |
| 234 | /* enable window */ |
Simon Glass | 305f581 | 2016-02-21 21:09:00 -0700 | [diff] [blame^] | 235 | cfg = readl((unsigned int)®->wincon0 + |
Simon Glass | c9ed7a4 | 2016-02-21 21:08:48 -0700 | [diff] [blame] | 236 | EXYNOS_WINCON(win_id)); |
| 237 | cfg |= EXYNOS_WINCON_ENWIN_ENABLE; |
Simon Glass | 305f581 | 2016-02-21 21:09:00 -0700 | [diff] [blame^] | 238 | writel(cfg, (unsigned int)®->wincon0 + |
Simon Glass | c9ed7a4 | 2016-02-21 21:08:48 -0700 | [diff] [blame] | 239 | EXYNOS_WINCON(win_id)); |
| 240 | |
Simon Glass | 305f581 | 2016-02-21 21:09:00 -0700 | [diff] [blame^] | 241 | cfg = readl(®->winshmap); |
Simon Glass | c9ed7a4 | 2016-02-21 21:08:48 -0700 | [diff] [blame] | 242 | cfg |= EXYNOS_WINSHMAP_CH_ENABLE(win_id); |
Simon Glass | 305f581 | 2016-02-21 21:09:00 -0700 | [diff] [blame^] | 243 | writel(cfg, ®->winshmap); |
Simon Glass | c9ed7a4 | 2016-02-21 21:08:48 -0700 | [diff] [blame] | 244 | } |
| 245 | |
Simon Glass | 305f581 | 2016-02-21 21:09:00 -0700 | [diff] [blame^] | 246 | void exynos_fimd_lcd_off(struct vidinfo *priv) |
Simon Glass | c9ed7a4 | 2016-02-21 21:08:48 -0700 | [diff] [blame] | 247 | { |
Simon Glass | 305f581 | 2016-02-21 21:09:00 -0700 | [diff] [blame^] | 248 | struct exynos_fb *reg = priv->reg; |
Simon Glass | c9ed7a4 | 2016-02-21 21:08:48 -0700 | [diff] [blame] | 249 | unsigned int cfg = 0; |
| 250 | |
Simon Glass | 305f581 | 2016-02-21 21:09:00 -0700 | [diff] [blame^] | 251 | cfg = readl(®->vidcon0); |
Simon Glass | c9ed7a4 | 2016-02-21 21:08:48 -0700 | [diff] [blame] | 252 | cfg &= (EXYNOS_VIDCON0_ENVID_DISABLE | EXYNOS_VIDCON0_ENVID_F_DISABLE); |
Simon Glass | 305f581 | 2016-02-21 21:09:00 -0700 | [diff] [blame^] | 253 | writel(cfg, ®->vidcon0); |
Simon Glass | c9ed7a4 | 2016-02-21 21:08:48 -0700 | [diff] [blame] | 254 | } |
| 255 | |
Simon Glass | 305f581 | 2016-02-21 21:09:00 -0700 | [diff] [blame^] | 256 | void exynos_fimd_window_off(struct vidinfo *priv, unsigned int win_id) |
Simon Glass | c9ed7a4 | 2016-02-21 21:08:48 -0700 | [diff] [blame] | 257 | { |
Simon Glass | 305f581 | 2016-02-21 21:09:00 -0700 | [diff] [blame^] | 258 | struct exynos_fb *reg = priv->reg; |
Simon Glass | c9ed7a4 | 2016-02-21 21:08:48 -0700 | [diff] [blame] | 259 | unsigned int cfg = 0; |
| 260 | |
Simon Glass | 305f581 | 2016-02-21 21:09:00 -0700 | [diff] [blame^] | 261 | cfg = readl((unsigned int)®->wincon0 + |
Simon Glass | c9ed7a4 | 2016-02-21 21:08:48 -0700 | [diff] [blame] | 262 | EXYNOS_WINCON(win_id)); |
| 263 | cfg &= EXYNOS_WINCON_ENWIN_DISABLE; |
Simon Glass | 305f581 | 2016-02-21 21:09:00 -0700 | [diff] [blame^] | 264 | writel(cfg, (unsigned int)®->wincon0 + |
Simon Glass | c9ed7a4 | 2016-02-21 21:08:48 -0700 | [diff] [blame] | 265 | EXYNOS_WINCON(win_id)); |
| 266 | |
Simon Glass | 305f581 | 2016-02-21 21:09:00 -0700 | [diff] [blame^] | 267 | cfg = readl(®->winshmap); |
Simon Glass | c9ed7a4 | 2016-02-21 21:08:48 -0700 | [diff] [blame] | 268 | cfg &= ~EXYNOS_WINSHMAP_CH_DISABLE(win_id); |
Simon Glass | 305f581 | 2016-02-21 21:09:00 -0700 | [diff] [blame^] | 269 | writel(cfg, ®->winshmap); |
Simon Glass | c9ed7a4 | 2016-02-21 21:08:48 -0700 | [diff] [blame] | 270 | } |
| 271 | |
| 272 | /* |
| 273 | * The reset value for FIMD SYSMMU register MMU_CTRL is 3 |
| 274 | * on Exynos5420 and newer versions. |
| 275 | * This means FIMD SYSMMU is on by default on Exynos5420 |
| 276 | * and newer versions. |
| 277 | * Since in u-boot we don't use SYSMMU, we should disable |
| 278 | * those FIMD SYSMMU. |
| 279 | * Note that there are 2 SYSMMU for FIMD: m0 and m1. |
| 280 | * m0 handles windows 0 and 4, and m1 handles windows 1, 2 and 3. |
| 281 | * We disable both of them here. |
| 282 | */ |
| 283 | void exynos_fimd_disable_sysmmu(void) |
| 284 | { |
| 285 | u32 *sysmmufimd; |
| 286 | unsigned int node; |
| 287 | int node_list[2]; |
| 288 | int count; |
| 289 | int i; |
| 290 | |
| 291 | count = fdtdec_find_aliases_for_id(gd->fdt_blob, "fimd", |
| 292 | COMPAT_SAMSUNG_EXYNOS_SYSMMU, node_list, 2); |
| 293 | for (i = 0; i < count; i++) { |
| 294 | node = node_list[i]; |
| 295 | if (node <= 0) { |
| 296 | debug("Can't get device node for fimd sysmmu\n"); |
| 297 | return; |
| 298 | } |
| 299 | |
| 300 | sysmmufimd = (u32 *)fdtdec_get_addr(gd->fdt_blob, node, "reg"); |
| 301 | if (!sysmmufimd) { |
| 302 | debug("Can't get base address for sysmmu fimdm0"); |
| 303 | return; |
| 304 | } |
| 305 | |
| 306 | writel(0x0, sysmmufimd); |
| 307 | } |
| 308 | } |
| 309 | |
Simon Glass | 305f581 | 2016-02-21 21:09:00 -0700 | [diff] [blame^] | 310 | void exynos_fimd_lcd_init(struct vidinfo *priv, ulong lcd_base_address) |
Simon Glass | c9ed7a4 | 2016-02-21 21:08:48 -0700 | [diff] [blame] | 311 | { |
Simon Glass | 305f581 | 2016-02-21 21:09:00 -0700 | [diff] [blame^] | 312 | struct exynos_fb *reg; |
Simon Glass | c9ed7a4 | 2016-02-21 21:08:48 -0700 | [diff] [blame] | 313 | unsigned int cfg = 0, rgb_mode; |
| 314 | unsigned int offset; |
| 315 | unsigned int node; |
| 316 | |
| 317 | node = fdtdec_next_compatible(gd->fdt_blob, |
| 318 | 0, COMPAT_SAMSUNG_EXYNOS_FIMD); |
| 319 | if (node <= 0) |
| 320 | debug("exynos_fb: Can't get device node for fimd\n"); |
| 321 | |
Simon Glass | 305f581 | 2016-02-21 21:09:00 -0700 | [diff] [blame^] | 322 | reg = (struct exynos_fb *)fdtdec_get_addr(gd->fdt_blob, node, |
Simon Glass | c9ed7a4 | 2016-02-21 21:08:48 -0700 | [diff] [blame] | 323 | "reg"); |
Simon Glass | 305f581 | 2016-02-21 21:09:00 -0700 | [diff] [blame^] | 324 | if (reg == NULL) |
Simon Glass | c9ed7a4 | 2016-02-21 21:08:48 -0700 | [diff] [blame] | 325 | debug("Can't get the FIMD base address\n"); |
Simon Glass | 305f581 | 2016-02-21 21:09:00 -0700 | [diff] [blame^] | 326 | priv->reg = reg; |
Simon Glass | c9ed7a4 | 2016-02-21 21:08:48 -0700 | [diff] [blame] | 327 | |
| 328 | if (fdtdec_get_bool(gd->fdt_blob, node, "samsung,disable-sysmmu")) |
| 329 | exynos_fimd_disable_sysmmu(); |
| 330 | |
| 331 | offset = exynos_fimd_get_base_offset(); |
| 332 | |
Simon Glass | 305f581 | 2016-02-21 21:09:00 -0700 | [diff] [blame^] | 333 | rgb_mode = priv->rgb_mode; |
Simon Glass | c9ed7a4 | 2016-02-21 21:08:48 -0700 | [diff] [blame] | 334 | |
Simon Glass | 305f581 | 2016-02-21 21:09:00 -0700 | [diff] [blame^] | 335 | if (priv->interface_mode == FIMD_RGB_INTERFACE) { |
Simon Glass | c9ed7a4 | 2016-02-21 21:08:48 -0700 | [diff] [blame] | 336 | cfg |= EXYNOS_VIDCON0_VIDOUT_RGB; |
Simon Glass | 305f581 | 2016-02-21 21:09:00 -0700 | [diff] [blame^] | 337 | writel(cfg, ®->vidcon0); |
Simon Glass | c9ed7a4 | 2016-02-21 21:08:48 -0700 | [diff] [blame] | 338 | |
Simon Glass | 305f581 | 2016-02-21 21:09:00 -0700 | [diff] [blame^] | 339 | cfg = readl(®->vidcon2); |
Simon Glass | c9ed7a4 | 2016-02-21 21:08:48 -0700 | [diff] [blame] | 340 | cfg &= ~(EXYNOS_VIDCON2_WB_MASK | |
| 341 | EXYNOS_VIDCON2_TVFORMATSEL_MASK | |
| 342 | EXYNOS_VIDCON2_TVFORMATSEL_YUV_MASK); |
| 343 | cfg |= EXYNOS_VIDCON2_WB_DISABLE; |
Simon Glass | 305f581 | 2016-02-21 21:09:00 -0700 | [diff] [blame^] | 344 | writel(cfg, ®->vidcon2); |
Simon Glass | c9ed7a4 | 2016-02-21 21:08:48 -0700 | [diff] [blame] | 345 | |
| 346 | /* set polarity */ |
| 347 | cfg = 0; |
Simon Glass | 305f581 | 2016-02-21 21:09:00 -0700 | [diff] [blame^] | 348 | if (!priv->vl_clkp) |
Simon Glass | c9ed7a4 | 2016-02-21 21:08:48 -0700 | [diff] [blame] | 349 | cfg |= EXYNOS_VIDCON1_IVCLK_RISING_EDGE; |
Simon Glass | 305f581 | 2016-02-21 21:09:00 -0700 | [diff] [blame^] | 350 | if (!priv->vl_hsp) |
Simon Glass | c9ed7a4 | 2016-02-21 21:08:48 -0700 | [diff] [blame] | 351 | cfg |= EXYNOS_VIDCON1_IHSYNC_INVERT; |
Simon Glass | 305f581 | 2016-02-21 21:09:00 -0700 | [diff] [blame^] | 352 | if (!priv->vl_vsp) |
Simon Glass | c9ed7a4 | 2016-02-21 21:08:48 -0700 | [diff] [blame] | 353 | cfg |= EXYNOS_VIDCON1_IVSYNC_INVERT; |
Simon Glass | 305f581 | 2016-02-21 21:09:00 -0700 | [diff] [blame^] | 354 | if (!priv->vl_dp) |
Simon Glass | c9ed7a4 | 2016-02-21 21:08:48 -0700 | [diff] [blame] | 355 | cfg |= EXYNOS_VIDCON1_IVDEN_INVERT; |
| 356 | |
Simon Glass | 305f581 | 2016-02-21 21:09:00 -0700 | [diff] [blame^] | 357 | writel(cfg, (unsigned int)®->vidcon1 + offset); |
Simon Glass | c9ed7a4 | 2016-02-21 21:08:48 -0700 | [diff] [blame] | 358 | |
| 359 | /* set timing */ |
Simon Glass | 305f581 | 2016-02-21 21:09:00 -0700 | [diff] [blame^] | 360 | cfg = EXYNOS_VIDTCON0_VFPD(priv->vl_vfpd - 1); |
| 361 | cfg |= EXYNOS_VIDTCON0_VBPD(priv->vl_vbpd - 1); |
| 362 | cfg |= EXYNOS_VIDTCON0_VSPW(priv->vl_vspw - 1); |
| 363 | writel(cfg, (unsigned int)®->vidtcon0 + offset); |
Simon Glass | c9ed7a4 | 2016-02-21 21:08:48 -0700 | [diff] [blame] | 364 | |
Simon Glass | 305f581 | 2016-02-21 21:09:00 -0700 | [diff] [blame^] | 365 | cfg = EXYNOS_VIDTCON1_HFPD(priv->vl_hfpd - 1); |
| 366 | cfg |= EXYNOS_VIDTCON1_HBPD(priv->vl_hbpd - 1); |
| 367 | cfg |= EXYNOS_VIDTCON1_HSPW(priv->vl_hspw - 1); |
Simon Glass | c9ed7a4 | 2016-02-21 21:08:48 -0700 | [diff] [blame] | 368 | |
Simon Glass | 305f581 | 2016-02-21 21:09:00 -0700 | [diff] [blame^] | 369 | writel(cfg, (unsigned int)®->vidtcon1 + offset); |
Simon Glass | c9ed7a4 | 2016-02-21 21:08:48 -0700 | [diff] [blame] | 370 | |
| 371 | /* set lcd size */ |
Simon Glass | 305f581 | 2016-02-21 21:09:00 -0700 | [diff] [blame^] | 372 | cfg = EXYNOS_VIDTCON2_HOZVAL(priv->vl_col - 1) | |
| 373 | EXYNOS_VIDTCON2_LINEVAL(priv->vl_row - 1) | |
| 374 | EXYNOS_VIDTCON2_HOZVAL_E(priv->vl_col - 1) | |
| 375 | EXYNOS_VIDTCON2_LINEVAL_E(priv->vl_row - 1); |
Simon Glass | c9ed7a4 | 2016-02-21 21:08:48 -0700 | [diff] [blame] | 376 | |
Simon Glass | 305f581 | 2016-02-21 21:09:00 -0700 | [diff] [blame^] | 377 | writel(cfg, (unsigned int)®->vidtcon2 + offset); |
Simon Glass | c9ed7a4 | 2016-02-21 21:08:48 -0700 | [diff] [blame] | 378 | } |
| 379 | |
| 380 | /* set display mode */ |
Simon Glass | 305f581 | 2016-02-21 21:09:00 -0700 | [diff] [blame^] | 381 | cfg = readl(®->vidcon0); |
Simon Glass | c9ed7a4 | 2016-02-21 21:08:48 -0700 | [diff] [blame] | 382 | cfg &= ~EXYNOS_VIDCON0_PNRMODE_MASK; |
| 383 | cfg |= (rgb_mode << EXYNOS_VIDCON0_PNRMODE_SHIFT); |
Simon Glass | 305f581 | 2016-02-21 21:09:00 -0700 | [diff] [blame^] | 384 | writel(cfg, ®->vidcon0); |
Simon Glass | c9ed7a4 | 2016-02-21 21:08:48 -0700 | [diff] [blame] | 385 | |
| 386 | /* set par */ |
Simon Glass | 305f581 | 2016-02-21 21:09:00 -0700 | [diff] [blame^] | 387 | exynos_fimd_set_par(priv, priv->win_id); |
Simon Glass | c9ed7a4 | 2016-02-21 21:08:48 -0700 | [diff] [blame] | 388 | |
| 389 | /* set memory address */ |
Simon Glass | 305f581 | 2016-02-21 21:09:00 -0700 | [diff] [blame^] | 390 | exynos_fimd_set_buffer_address(priv, priv->win_id, lcd_base_address); |
Simon Glass | c9ed7a4 | 2016-02-21 21:08:48 -0700 | [diff] [blame] | 391 | |
| 392 | /* set buffer size */ |
Simon Glass | 305f581 | 2016-02-21 21:09:00 -0700 | [diff] [blame^] | 393 | cfg = EXYNOS_VIDADDR_PAGEWIDTH(priv->vl_col * |
| 394 | NBITS(priv->vl_bpix) / 8) | |
| 395 | EXYNOS_VIDADDR_PAGEWIDTH_E(priv->vl_col * |
| 396 | NBITS(priv->vl_bpix) / 8) | |
Simon Glass | c9ed7a4 | 2016-02-21 21:08:48 -0700 | [diff] [blame] | 397 | EXYNOS_VIDADDR_OFFSIZE(0) | |
| 398 | EXYNOS_VIDADDR_OFFSIZE_E(0); |
| 399 | |
Simon Glass | 305f581 | 2016-02-21 21:09:00 -0700 | [diff] [blame^] | 400 | writel(cfg, (unsigned int)®->vidw00add2 + |
| 401 | EXYNOS_BUFFER_SIZE(priv->win_id)); |
Simon Glass | c9ed7a4 | 2016-02-21 21:08:48 -0700 | [diff] [blame] | 402 | |
| 403 | /* set clock */ |
Simon Glass | 305f581 | 2016-02-21 21:09:00 -0700 | [diff] [blame^] | 404 | exynos_fimd_set_clock(priv); |
Simon Glass | c9ed7a4 | 2016-02-21 21:08:48 -0700 | [diff] [blame] | 405 | |
| 406 | /* set rgb mode to dual lcd. */ |
Simon Glass | 305f581 | 2016-02-21 21:09:00 -0700 | [diff] [blame^] | 407 | exynos_fimd_set_dualrgb(priv, priv->dual_lcd_enabled); |
Simon Glass | c9ed7a4 | 2016-02-21 21:08:48 -0700 | [diff] [blame] | 408 | |
| 409 | /* display on */ |
Simon Glass | 305f581 | 2016-02-21 21:09:00 -0700 | [diff] [blame^] | 410 | exynos_fimd_lcd_on(priv); |
Simon Glass | c9ed7a4 | 2016-02-21 21:08:48 -0700 | [diff] [blame] | 411 | |
| 412 | /* window on */ |
Simon Glass | 305f581 | 2016-02-21 21:09:00 -0700 | [diff] [blame^] | 413 | exynos_fimd_window_on(priv, priv->win_id); |
Simon Glass | c9ed7a4 | 2016-02-21 21:08:48 -0700 | [diff] [blame] | 414 | |
Simon Glass | 305f581 | 2016-02-21 21:09:00 -0700 | [diff] [blame^] | 415 | exynos_fimd_set_dp_clkcon(priv, priv->dp_enabled); |
Simon Glass | c9ed7a4 | 2016-02-21 21:08:48 -0700 | [diff] [blame] | 416 | } |
| 417 | |
Simon Glass | 305f581 | 2016-02-21 21:09:00 -0700 | [diff] [blame^] | 418 | unsigned long exynos_fimd_calc_fbsize(struct vidinfo *priv) |
Simon Glass | c9ed7a4 | 2016-02-21 21:08:48 -0700 | [diff] [blame] | 419 | { |
Simon Glass | 305f581 | 2016-02-21 21:09:00 -0700 | [diff] [blame^] | 420 | return priv->vl_col * priv->vl_row * (NBITS(priv->vl_bpix) / 8); |
Simon Glass | c9ed7a4 | 2016-02-21 21:08:48 -0700 | [diff] [blame] | 421 | } |
| 422 | |
Nikita Kiryanov | ec3685d | 2015-02-03 13:32:21 +0200 | [diff] [blame] | 423 | ushort *configuration_get_cmap(void) |
| 424 | { |
| 425 | #if defined(CONFIG_LCD_LOGO) |
| 426 | return bmp_logo_palette; |
| 427 | #else |
| 428 | return NULL; |
| 429 | #endif |
| 430 | } |
| 431 | |
Simon Glass | 4d022cc | 2016-02-21 21:08:41 -0700 | [diff] [blame] | 432 | static void exynos_lcd_init(struct vidinfo *vid, ulong lcd_base) |
Donghwa Lee | 0112fed | 2012-04-05 19:36:17 +0000 | [diff] [blame] | 433 | { |
Simon Glass | 4d022cc | 2016-02-21 21:08:41 -0700 | [diff] [blame] | 434 | exynos_fimd_lcd_init(vid, lcd_base); |
Łukasz Majewski | 43905f4 | 2013-01-08 03:48:40 +0000 | [diff] [blame] | 435 | |
| 436 | /* Enable flushing after LCD writes if requested */ |
| 437 | lcd_set_flush_dcache(1); |
Donghwa Lee | 0112fed | 2012-04-05 19:36:17 +0000 | [diff] [blame] | 438 | } |
| 439 | |
Jeroen Hofstee | f7ae3ed | 2014-10-08 22:57:30 +0200 | [diff] [blame] | 440 | __weak void exynos_cfg_lcd_gpio(void) |
Ajay Kumar | 41022a1 | 2013-02-21 23:52:57 +0000 | [diff] [blame] | 441 | { |
| 442 | } |
Ajay Kumar | 41022a1 | 2013-02-21 23:52:57 +0000 | [diff] [blame] | 443 | |
Jeroen Hofstee | f7ae3ed | 2014-10-08 22:57:30 +0200 | [diff] [blame] | 444 | __weak void exynos_backlight_on(unsigned int onoff) |
Ajay Kumar | 41022a1 | 2013-02-21 23:52:57 +0000 | [diff] [blame] | 445 | { |
| 446 | } |
Ajay Kumar | 41022a1 | 2013-02-21 23:52:57 +0000 | [diff] [blame] | 447 | |
Jeroen Hofstee | f7ae3ed | 2014-10-08 22:57:30 +0200 | [diff] [blame] | 448 | __weak void exynos_reset_lcd(void) |
Ajay Kumar | 41022a1 | 2013-02-21 23:52:57 +0000 | [diff] [blame] | 449 | { |
| 450 | } |
Ajay Kumar | 41022a1 | 2013-02-21 23:52:57 +0000 | [diff] [blame] | 451 | |
Jeroen Hofstee | f7ae3ed | 2014-10-08 22:57:30 +0200 | [diff] [blame] | 452 | __weak void exynos_lcd_power_on(void) |
Ajay Kumar | 41022a1 | 2013-02-21 23:52:57 +0000 | [diff] [blame] | 453 | { |
| 454 | } |
Ajay Kumar | 41022a1 | 2013-02-21 23:52:57 +0000 | [diff] [blame] | 455 | |
Jeroen Hofstee | f7ae3ed | 2014-10-08 22:57:30 +0200 | [diff] [blame] | 456 | __weak void exynos_cfg_ldo(void) |
Ajay Kumar | 41022a1 | 2013-02-21 23:52:57 +0000 | [diff] [blame] | 457 | { |
| 458 | } |
Ajay Kumar | 41022a1 | 2013-02-21 23:52:57 +0000 | [diff] [blame] | 459 | |
Jeroen Hofstee | f7ae3ed | 2014-10-08 22:57:30 +0200 | [diff] [blame] | 460 | __weak void exynos_enable_ldo(unsigned int onoff) |
Ajay Kumar | 41022a1 | 2013-02-21 23:52:57 +0000 | [diff] [blame] | 461 | { |
| 462 | } |
Ajay Kumar | 41022a1 | 2013-02-21 23:52:57 +0000 | [diff] [blame] | 463 | |
Jeroen Hofstee | f7ae3ed | 2014-10-08 22:57:30 +0200 | [diff] [blame] | 464 | __weak void exynos_backlight_reset(void) |
Ajay Kumar | 41022a1 | 2013-02-21 23:52:57 +0000 | [diff] [blame] | 465 | { |
| 466 | } |
Ajay Kumar | 41022a1 | 2013-02-21 23:52:57 +0000 | [diff] [blame] | 467 | |
Simon Glass | 6d27559 | 2016-02-21 21:08:40 -0700 | [diff] [blame] | 468 | __weak int exynos_lcd_misc_init(struct vidinfo *vid) |
Piotr Wilczek | 386fd02 | 2014-03-07 14:59:40 +0100 | [diff] [blame] | 469 | { |
| 470 | return 0; |
| 471 | } |
Piotr Wilczek | 386fd02 | 2014-03-07 14:59:40 +0100 | [diff] [blame] | 472 | |
Simon Glass | 6d27559 | 2016-02-21 21:08:40 -0700 | [diff] [blame] | 473 | static void lcd_panel_on(struct vidinfo *vid) |
Donghwa Lee | 0112fed | 2012-04-05 19:36:17 +0000 | [diff] [blame] | 474 | { |
Ajay Kumar | 39ea08b | 2015-03-04 19:05:26 +0530 | [diff] [blame] | 475 | struct gpio_desc pwm_out_gpio; |
| 476 | struct gpio_desc bl_en_gpio; |
| 477 | unsigned int node; |
| 478 | |
Donghwa Lee | 0112fed | 2012-04-05 19:36:17 +0000 | [diff] [blame] | 479 | udelay(vid->init_delay); |
| 480 | |
Ajay Kumar | 41022a1 | 2013-02-21 23:52:57 +0000 | [diff] [blame] | 481 | exynos_backlight_reset(); |
Donghwa Lee | 0112fed | 2012-04-05 19:36:17 +0000 | [diff] [blame] | 482 | |
Ajay Kumar | 41022a1 | 2013-02-21 23:52:57 +0000 | [diff] [blame] | 483 | exynos_cfg_lcd_gpio(); |
Donghwa Lee | 0112fed | 2012-04-05 19:36:17 +0000 | [diff] [blame] | 484 | |
Ajay Kumar | 41022a1 | 2013-02-21 23:52:57 +0000 | [diff] [blame] | 485 | exynos_lcd_power_on(); |
Donghwa Lee | 0112fed | 2012-04-05 19:36:17 +0000 | [diff] [blame] | 486 | |
| 487 | udelay(vid->power_on_delay); |
| 488 | |
Donghwa Lee | bc72aeb | 2012-07-02 01:16:08 +0000 | [diff] [blame] | 489 | if (vid->dp_enabled) |
| 490 | exynos_init_dp(); |
| 491 | |
Ajay Kumar | 41022a1 | 2013-02-21 23:52:57 +0000 | [diff] [blame] | 492 | exynos_reset_lcd(); |
Donghwa Lee | 0112fed | 2012-04-05 19:36:17 +0000 | [diff] [blame] | 493 | |
Ajay Kumar | 41022a1 | 2013-02-21 23:52:57 +0000 | [diff] [blame] | 494 | udelay(vid->reset_delay); |
Donghwa Lee | 0112fed | 2012-04-05 19:36:17 +0000 | [diff] [blame] | 495 | |
Ajay Kumar | 41022a1 | 2013-02-21 23:52:57 +0000 | [diff] [blame] | 496 | exynos_backlight_on(1); |
| 497 | |
Ajay Kumar | 39ea08b | 2015-03-04 19:05:26 +0530 | [diff] [blame] | 498 | node = fdtdec_next_compatible(gd->fdt_blob, 0, |
| 499 | COMPAT_SAMSUNG_EXYNOS_FIMD); |
| 500 | if (node <= 0) { |
| 501 | debug("FIMD: Can't get device node for FIMD\n"); |
| 502 | return; |
| 503 | } |
| 504 | gpio_request_by_name_nodev(gd->fdt_blob, node, "samsung,pwm-out-gpio", |
| 505 | 0, &pwm_out_gpio, |
| 506 | GPIOD_IS_OUT | GPIOD_IS_OUT_ACTIVE); |
| 507 | |
| 508 | gpio_request_by_name_nodev(gd->fdt_blob, node, "samsung,bl-en-gpio", 0, |
| 509 | &bl_en_gpio, |
| 510 | GPIOD_IS_OUT | GPIOD_IS_OUT_ACTIVE); |
| 511 | |
Ajay Kumar | 41022a1 | 2013-02-21 23:52:57 +0000 | [diff] [blame] | 512 | exynos_cfg_ldo(); |
Donghwa Lee | 0112fed | 2012-04-05 19:36:17 +0000 | [diff] [blame] | 513 | |
Ajay Kumar | 41022a1 | 2013-02-21 23:52:57 +0000 | [diff] [blame] | 514 | exynos_enable_ldo(1); |
Donghwa Lee | 0112fed | 2012-04-05 19:36:17 +0000 | [diff] [blame] | 515 | |
| 516 | if (vid->mipi_enabled) |
Simon Glass | ef4e779 | 2016-02-21 21:08:46 -0700 | [diff] [blame] | 517 | exynos_mipi_dsi_init(panel_info.dsim_platform_data_dt); |
Donghwa Lee | 0112fed | 2012-04-05 19:36:17 +0000 | [diff] [blame] | 518 | } |
Ajay Kumar | ebbace3 | 2013-02-21 23:53:01 +0000 | [diff] [blame] | 519 | |
Ajay Kumar | 1176348 | 2014-09-05 16:53:30 +0530 | [diff] [blame] | 520 | int exynos_lcd_early_init(const void *blob) |
Ajay Kumar | ebbace3 | 2013-02-21 23:53:01 +0000 | [diff] [blame] | 521 | { |
| 522 | unsigned int node; |
| 523 | node = fdtdec_next_compatible(blob, 0, COMPAT_SAMSUNG_EXYNOS_FIMD); |
| 524 | if (node <= 0) { |
| 525 | debug("exynos_fb: Can't get device node for fimd\n"); |
| 526 | return -ENODEV; |
| 527 | } |
| 528 | |
| 529 | panel_info.vl_col = fdtdec_get_int(blob, node, "samsung,vl-col", 0); |
| 530 | if (panel_info.vl_col == 0) { |
| 531 | debug("Can't get XRES\n"); |
| 532 | return -ENXIO; |
| 533 | } |
| 534 | |
| 535 | panel_info.vl_row = fdtdec_get_int(blob, node, "samsung,vl-row", 0); |
| 536 | if (panel_info.vl_row == 0) { |
| 537 | debug("Can't get YRES\n"); |
| 538 | return -ENXIO; |
| 539 | } |
| 540 | |
| 541 | panel_info.vl_width = fdtdec_get_int(blob, node, |
| 542 | "samsung,vl-width", 0); |
| 543 | |
| 544 | panel_info.vl_height = fdtdec_get_int(blob, node, |
| 545 | "samsung,vl-height", 0); |
| 546 | |
| 547 | panel_info.vl_freq = fdtdec_get_int(blob, node, "samsung,vl-freq", 0); |
| 548 | if (panel_info.vl_freq == 0) { |
| 549 | debug("Can't get refresh rate\n"); |
| 550 | return -ENXIO; |
| 551 | } |
| 552 | |
| 553 | if (fdtdec_get_bool(blob, node, "samsung,vl-clkp")) |
| 554 | panel_info.vl_clkp = CONFIG_SYS_LOW; |
| 555 | |
| 556 | if (fdtdec_get_bool(blob, node, "samsung,vl-oep")) |
| 557 | panel_info.vl_oep = CONFIG_SYS_LOW; |
| 558 | |
| 559 | if (fdtdec_get_bool(blob, node, "samsung,vl-hsp")) |
| 560 | panel_info.vl_hsp = CONFIG_SYS_LOW; |
| 561 | |
| 562 | if (fdtdec_get_bool(blob, node, "samsung,vl-vsp")) |
| 563 | panel_info.vl_vsp = CONFIG_SYS_LOW; |
| 564 | |
| 565 | if (fdtdec_get_bool(blob, node, "samsung,vl-dp")) |
| 566 | panel_info.vl_dp = CONFIG_SYS_LOW; |
| 567 | |
| 568 | panel_info.vl_bpix = fdtdec_get_int(blob, node, "samsung,vl-bpix", 0); |
| 569 | if (panel_info.vl_bpix == 0) { |
| 570 | debug("Can't get bits per pixel\n"); |
| 571 | return -ENXIO; |
| 572 | } |
| 573 | |
| 574 | panel_info.vl_hspw = fdtdec_get_int(blob, node, "samsung,vl-hspw", 0); |
| 575 | if (panel_info.vl_hspw == 0) { |
| 576 | debug("Can't get hsync width\n"); |
| 577 | return -ENXIO; |
| 578 | } |
| 579 | |
| 580 | panel_info.vl_hfpd = fdtdec_get_int(blob, node, "samsung,vl-hfpd", 0); |
| 581 | if (panel_info.vl_hfpd == 0) { |
| 582 | debug("Can't get right margin\n"); |
| 583 | return -ENXIO; |
| 584 | } |
| 585 | |
| 586 | panel_info.vl_hbpd = (u_char)fdtdec_get_int(blob, node, |
| 587 | "samsung,vl-hbpd", 0); |
| 588 | if (panel_info.vl_hbpd == 0) { |
| 589 | debug("Can't get left margin\n"); |
| 590 | return -ENXIO; |
| 591 | } |
| 592 | |
| 593 | panel_info.vl_vspw = (u_char)fdtdec_get_int(blob, node, |
| 594 | "samsung,vl-vspw", 0); |
| 595 | if (panel_info.vl_vspw == 0) { |
| 596 | debug("Can't get vsync width\n"); |
| 597 | return -ENXIO; |
| 598 | } |
| 599 | |
| 600 | panel_info.vl_vfpd = fdtdec_get_int(blob, node, |
| 601 | "samsung,vl-vfpd", 0); |
| 602 | if (panel_info.vl_vfpd == 0) { |
| 603 | debug("Can't get lower margin\n"); |
| 604 | return -ENXIO; |
| 605 | } |
| 606 | |
| 607 | panel_info.vl_vbpd = fdtdec_get_int(blob, node, "samsung,vl-vbpd", 0); |
| 608 | if (panel_info.vl_vbpd == 0) { |
| 609 | debug("Can't get upper margin\n"); |
| 610 | return -ENXIO; |
| 611 | } |
| 612 | |
| 613 | panel_info.vl_cmd_allow_len = fdtdec_get_int(blob, node, |
| 614 | "samsung,vl-cmd-allow-len", 0); |
| 615 | |
| 616 | panel_info.win_id = fdtdec_get_int(blob, node, "samsung,winid", 0); |
| 617 | panel_info.init_delay = fdtdec_get_int(blob, node, |
| 618 | "samsung,init-delay", 0); |
| 619 | panel_info.power_on_delay = fdtdec_get_int(blob, node, |
| 620 | "samsung,power-on-delay", 0); |
| 621 | panel_info.reset_delay = fdtdec_get_int(blob, node, |
| 622 | "samsung,reset-delay", 0); |
| 623 | panel_info.interface_mode = fdtdec_get_int(blob, node, |
| 624 | "samsung,interface-mode", 0); |
| 625 | panel_info.mipi_enabled = fdtdec_get_int(blob, node, |
| 626 | "samsung,mipi-enabled", 0); |
| 627 | panel_info.dp_enabled = fdtdec_get_int(blob, node, |
| 628 | "samsung,dp-enabled", 0); |
| 629 | panel_info.cs_setup = fdtdec_get_int(blob, node, |
| 630 | "samsung,cs-setup", 0); |
| 631 | panel_info.wr_setup = fdtdec_get_int(blob, node, |
| 632 | "samsung,wr-setup", 0); |
| 633 | panel_info.wr_act = fdtdec_get_int(blob, node, "samsung,wr-act", 0); |
| 634 | panel_info.wr_hold = fdtdec_get_int(blob, node, "samsung,wr-hold", 0); |
| 635 | |
| 636 | panel_info.logo_on = fdtdec_get_int(blob, node, "samsung,logo-on", 0); |
| 637 | if (panel_info.logo_on) { |
| 638 | panel_info.logo_width = fdtdec_get_int(blob, node, |
| 639 | "samsung,logo-width", 0); |
| 640 | panel_info.logo_height = fdtdec_get_int(blob, node, |
| 641 | "samsung,logo-height", 0); |
| 642 | panel_info.logo_addr = fdtdec_get_int(blob, node, |
| 643 | "samsung,logo-addr", 0); |
| 644 | } |
| 645 | |
| 646 | panel_info.rgb_mode = fdtdec_get_int(blob, node, |
| 647 | "samsung,rgb-mode", 0); |
| 648 | panel_info.pclk_name = fdtdec_get_int(blob, node, |
| 649 | "samsung,pclk-name", 0); |
| 650 | panel_info.sclk_div = fdtdec_get_int(blob, node, |
| 651 | "samsung,sclk-div", 0); |
| 652 | panel_info.dual_lcd_enabled = fdtdec_get_int(blob, node, |
| 653 | "samsung,dual-lcd-enabled", 0); |
| 654 | |
| 655 | return 0; |
| 656 | } |
Donghwa Lee | 0112fed | 2012-04-05 19:36:17 +0000 | [diff] [blame] | 657 | |
| 658 | void lcd_ctrl_init(void *lcdbase) |
| 659 | { |
| 660 | set_system_display_ctrl(); |
| 661 | set_lcd_clk(); |
| 662 | |
Piotr Wilczek | 386fd02 | 2014-03-07 14:59:40 +0100 | [diff] [blame] | 663 | #ifdef CONFIG_EXYNOS_MIPI_DSIM |
| 664 | exynos_init_dsim_platform_data(&panel_info); |
| 665 | #endif |
| 666 | exynos_lcd_misc_init(&panel_info); |
Piotr Wilczek | 386fd02 | 2014-03-07 14:59:40 +0100 | [diff] [blame] | 667 | |
Simon Glass | 4d022cc | 2016-02-21 21:08:41 -0700 | [diff] [blame] | 668 | exynos_lcd_init(&panel_info, (ulong)lcdbase); |
Donghwa Lee | 0112fed | 2012-04-05 19:36:17 +0000 | [diff] [blame] | 669 | } |
| 670 | |
| 671 | void lcd_enable(void) |
| 672 | { |
Donghwa Lee | 37980dd | 2012-05-09 19:23:46 +0000 | [diff] [blame] | 673 | if (panel_info.logo_on) { |
Simon Glass | 860ef00 | 2016-02-21 21:08:43 -0700 | [diff] [blame] | 674 | memset((void *)gd->fb_base, 0, |
| 675 | panel_info.vl_width * panel_info.vl_height * |
Donghwa Lee | 37980dd | 2012-05-09 19:23:46 +0000 | [diff] [blame] | 676 | (NBITS(panel_info.vl_bpix) >> 3)); |
Donghwa Lee | 37980dd | 2012-05-09 19:23:46 +0000 | [diff] [blame] | 677 | } |
| 678 | |
Donghwa Lee | 0112fed | 2012-04-05 19:36:17 +0000 | [diff] [blame] | 679 | lcd_panel_on(&panel_info); |
| 680 | } |
| 681 | |
| 682 | /* dummy function */ |
| 683 | void lcd_setcolreg(ushort regno, ushort red, ushort green, ushort blue) |
| 684 | { |
| 685 | return; |
| 686 | } |