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> |
| 12 | #include <asm/io.h> |
| 13 | #include <lcd.h> |
| 14 | #include <div64.h> |
Ajay Kumar | ebbace3 | 2013-02-21 23:53:01 +0000 | [diff] [blame] | 15 | #include <fdtdec.h> |
| 16 | #include <libfdt.h> |
Donghwa Lee | 0112fed | 2012-04-05 19:36:17 +0000 | [diff] [blame] | 17 | #include <asm/arch/clk.h> |
| 18 | #include <asm/arch/clock.h> |
| 19 | #include <asm/arch/cpu.h> |
| 20 | #include "exynos_fb.h" |
| 21 | |
Ajay Kumar | ebbace3 | 2013-02-21 23:53:01 +0000 | [diff] [blame] | 22 | DECLARE_GLOBAL_DATA_PTR; |
| 23 | |
Simon Glass | 6d27559 | 2016-02-21 21:08:40 -0700 | [diff] [blame] | 24 | static struct vidinfo *pvid; |
Ajay Kumar | 4acd4ee | 2013-02-21 23:52:59 +0000 | [diff] [blame] | 25 | static struct exynos_fb *fimd_ctrl; |
Donghwa Lee | 0112fed | 2012-04-05 19:36:17 +0000 | [diff] [blame] | 26 | |
Donghwa Lee | 0112fed | 2012-04-05 19:36:17 +0000 | [diff] [blame] | 27 | static void exynos_fimd_set_dualrgb(unsigned int enabled) |
| 28 | { |
Donghwa Lee | 0112fed | 2012-04-05 19:36:17 +0000 | [diff] [blame] | 29 | unsigned int cfg = 0; |
| 30 | |
| 31 | if (enabled) { |
| 32 | cfg = EXYNOS_DUALRGB_BYPASS_DUAL | EXYNOS_DUALRGB_LINESPLIT | |
| 33 | EXYNOS_DUALRGB_VDEN_EN_ENABLE; |
| 34 | |
| 35 | /* in case of Line Split mode, MAIN_CNT doesn't neet to set. */ |
| 36 | cfg |= EXYNOS_DUALRGB_SUB_CNT(pvid->vl_col / 2) | |
| 37 | EXYNOS_DUALRGB_MAIN_CNT(0); |
| 38 | } |
| 39 | |
| 40 | writel(cfg, &fimd_ctrl->dualrgb); |
| 41 | } |
| 42 | |
Simon Glass | 4d022cc | 2016-02-21 21:08:41 -0700 | [diff] [blame^] | 43 | static void exynos_fimd_set_dp_clkcon(struct vidinfo *pvid, |
| 44 | unsigned int enabled) |
Donghwa Lee | bc72aeb | 2012-07-02 01:16:08 +0000 | [diff] [blame] | 45 | { |
Donghwa Lee | bc72aeb | 2012-07-02 01:16:08 +0000 | [diff] [blame] | 46 | unsigned int cfg = 0; |
| 47 | |
| 48 | if (enabled) |
| 49 | cfg = EXYNOS_DP_CLK_ENABLE; |
| 50 | |
| 51 | writel(cfg, &fimd_ctrl->dp_mie_clkcon); |
| 52 | } |
| 53 | |
Simon Glass | 4d022cc | 2016-02-21 21:08:41 -0700 | [diff] [blame^] | 54 | static void exynos_fimd_set_par(struct vidinfo *pvid, unsigned int win_id) |
Donghwa Lee | 0112fed | 2012-04-05 19:36:17 +0000 | [diff] [blame] | 55 | { |
| 56 | unsigned int cfg = 0; |
Donghwa Lee | 0112fed | 2012-04-05 19:36:17 +0000 | [diff] [blame] | 57 | |
| 58 | /* set window control */ |
| 59 | cfg = readl((unsigned int)&fimd_ctrl->wincon0 + |
| 60 | EXYNOS_WINCON(win_id)); |
| 61 | |
| 62 | cfg &= ~(EXYNOS_WINCON_BITSWP_ENABLE | EXYNOS_WINCON_BYTESWP_ENABLE | |
| 63 | EXYNOS_WINCON_HAWSWP_ENABLE | EXYNOS_WINCON_WSWP_ENABLE | |
| 64 | EXYNOS_WINCON_BURSTLEN_MASK | EXYNOS_WINCON_BPPMODE_MASK | |
| 65 | EXYNOS_WINCON_INRGB_MASK | EXYNOS_WINCON_DATAPATH_MASK); |
| 66 | |
| 67 | /* DATAPATH is DMA */ |
| 68 | cfg |= EXYNOS_WINCON_DATAPATH_DMA; |
| 69 | |
Przemyslaw Marczak | 65b3f77 | 2014-01-22 11:24:15 +0100 | [diff] [blame] | 70 | cfg |= EXYNOS_WINCON_HAWSWP_ENABLE; |
Donghwa Lee | 0112fed | 2012-04-05 19:36:17 +0000 | [diff] [blame] | 71 | |
| 72 | /* dma burst is 16 */ |
| 73 | cfg |= EXYNOS_WINCON_BURSTLEN_16WORD; |
| 74 | |
Przemyslaw Marczak | 65b3f77 | 2014-01-22 11:24:15 +0100 | [diff] [blame] | 75 | switch (pvid->vl_bpix) { |
| 76 | case 4: |
Ajay Kumar | 1e655b3 | 2013-01-08 20:42:25 +0000 | [diff] [blame] | 77 | cfg |= EXYNOS_WINCON_BPPMODE_16BPP_565; |
Przemyslaw Marczak | 65b3f77 | 2014-01-22 11:24:15 +0100 | [diff] [blame] | 78 | break; |
| 79 | default: |
| 80 | cfg |= EXYNOS_WINCON_BPPMODE_24BPP_888; |
| 81 | break; |
| 82 | } |
Donghwa Lee | 0112fed | 2012-04-05 19:36:17 +0000 | [diff] [blame] | 83 | |
| 84 | writel(cfg, (unsigned int)&fimd_ctrl->wincon0 + |
| 85 | EXYNOS_WINCON(win_id)); |
| 86 | |
| 87 | /* set window position to x=0, y=0*/ |
| 88 | cfg = EXYNOS_VIDOSD_LEFT_X(0) | EXYNOS_VIDOSD_TOP_Y(0); |
| 89 | writel(cfg, (unsigned int)&fimd_ctrl->vidosd0a + |
| 90 | EXYNOS_VIDOSD(win_id)); |
| 91 | |
| 92 | cfg = EXYNOS_VIDOSD_RIGHT_X(pvid->vl_col - 1) | |
Donghwa Lee | 64b45d9 | 2012-07-26 15:30:49 +0000 | [diff] [blame] | 93 | EXYNOS_VIDOSD_BOTTOM_Y(pvid->vl_row - 1) | |
| 94 | EXYNOS_VIDOSD_RIGHT_X_E(1) | |
| 95 | EXYNOS_VIDOSD_BOTTOM_Y_E(0); |
| 96 | |
Donghwa Lee | 0112fed | 2012-04-05 19:36:17 +0000 | [diff] [blame] | 97 | writel(cfg, (unsigned int)&fimd_ctrl->vidosd0b + |
| 98 | EXYNOS_VIDOSD(win_id)); |
| 99 | |
| 100 | /* set window size for window0*/ |
| 101 | cfg = EXYNOS_VIDOSD_SIZE(pvid->vl_col * pvid->vl_row); |
| 102 | writel(cfg, (unsigned int)&fimd_ctrl->vidosd0c + |
| 103 | EXYNOS_VIDOSD(win_id)); |
| 104 | } |
| 105 | |
Simon Glass | 4d022cc | 2016-02-21 21:08:41 -0700 | [diff] [blame^] | 106 | static void exynos_fimd_set_buffer_address(struct vidinfo *pvid, |
| 107 | unsigned int win_id, |
| 108 | ulong lcd_base_addr) |
Donghwa Lee | 0112fed | 2012-04-05 19:36:17 +0000 | [diff] [blame] | 109 | { |
| 110 | unsigned long start_addr, end_addr; |
Donghwa Lee | 0112fed | 2012-04-05 19:36:17 +0000 | [diff] [blame] | 111 | |
Simon Glass | 4d022cc | 2016-02-21 21:08:41 -0700 | [diff] [blame^] | 112 | start_addr = lcd_base_addr; |
Donghwa Lee | 2386f45 | 2012-04-23 15:37:05 +0000 | [diff] [blame] | 113 | end_addr = start_addr + ((pvid->vl_col * (NBITS(pvid->vl_bpix) / 8)) * |
Donghwa Lee | 0112fed | 2012-04-05 19:36:17 +0000 | [diff] [blame] | 114 | pvid->vl_row); |
| 115 | |
| 116 | writel(start_addr, (unsigned int)&fimd_ctrl->vidw00add0b0 + |
| 117 | EXYNOS_BUFFER_OFFSET(win_id)); |
| 118 | writel(end_addr, (unsigned int)&fimd_ctrl->vidw00add1b0 + |
| 119 | EXYNOS_BUFFER_OFFSET(win_id)); |
| 120 | } |
| 121 | |
Simon Glass | 6d27559 | 2016-02-21 21:08:40 -0700 | [diff] [blame] | 122 | static void exynos_fimd_set_clock(struct vidinfo *pvid) |
Donghwa Lee | 0112fed | 2012-04-05 19:36:17 +0000 | [diff] [blame] | 123 | { |
| 124 | unsigned int cfg = 0, div = 0, remainder, remainder_div; |
| 125 | unsigned long pixel_clock; |
| 126 | unsigned long long src_clock; |
Donghwa Lee | 0112fed | 2012-04-05 19:36:17 +0000 | [diff] [blame] | 127 | |
| 128 | if (pvid->dual_lcd_enabled) { |
| 129 | pixel_clock = pvid->vl_freq * |
| 130 | (pvid->vl_hspw + pvid->vl_hfpd + |
| 131 | pvid->vl_hbpd + pvid->vl_col / 2) * |
| 132 | (pvid->vl_vspw + pvid->vl_vfpd + |
| 133 | pvid->vl_vbpd + pvid->vl_row); |
| 134 | } else if (pvid->interface_mode == FIMD_CPU_INTERFACE) { |
| 135 | pixel_clock = pvid->vl_freq * |
| 136 | pvid->vl_width * pvid->vl_height * |
| 137 | (pvid->cs_setup + pvid->wr_setup + |
| 138 | pvid->wr_act + pvid->wr_hold + 1); |
| 139 | } else { |
| 140 | pixel_clock = pvid->vl_freq * |
| 141 | (pvid->vl_hspw + pvid->vl_hfpd + |
| 142 | pvid->vl_hbpd + pvid->vl_col) * |
| 143 | (pvid->vl_vspw + pvid->vl_vfpd + |
| 144 | pvid->vl_vbpd + pvid->vl_row); |
| 145 | } |
| 146 | |
| 147 | cfg = readl(&fimd_ctrl->vidcon0); |
| 148 | cfg &= ~(EXYNOS_VIDCON0_CLKSEL_MASK | EXYNOS_VIDCON0_CLKVALUP_MASK | |
| 149 | EXYNOS_VIDCON0_CLKVAL_F(0xFF) | EXYNOS_VIDCON0_VCLKEN_MASK | |
| 150 | EXYNOS_VIDCON0_CLKDIR_MASK); |
| 151 | cfg |= (EXYNOS_VIDCON0_CLKSEL_SCLK | EXYNOS_VIDCON0_CLKVALUP_ALWAYS | |
| 152 | EXYNOS_VIDCON0_VCLKEN_NORMAL | EXYNOS_VIDCON0_CLKDIR_DIVIDED); |
| 153 | |
Donghwa Lee | 0112fed | 2012-04-05 19:36:17 +0000 | [diff] [blame] | 154 | src_clock = (unsigned long long) get_lcd_clk(); |
| 155 | |
| 156 | /* get quotient and remainder. */ |
| 157 | remainder = do_div(src_clock, pixel_clock); |
| 158 | div = src_clock; |
| 159 | |
| 160 | remainder *= 10; |
| 161 | remainder_div = remainder / pixel_clock; |
| 162 | |
| 163 | /* round about one places of decimals. */ |
| 164 | if (remainder_div >= 5) |
| 165 | div++; |
| 166 | |
| 167 | /* in case of dual lcd mode. */ |
| 168 | if (pvid->dual_lcd_enabled) |
| 169 | div--; |
| 170 | |
| 171 | cfg |= EXYNOS_VIDCON0_CLKVAL_F(div - 1); |
| 172 | writel(cfg, &fimd_ctrl->vidcon0); |
| 173 | } |
| 174 | |
| 175 | void exynos_set_trigger(void) |
| 176 | { |
| 177 | unsigned int cfg = 0; |
Donghwa Lee | 0112fed | 2012-04-05 19:36:17 +0000 | [diff] [blame] | 178 | |
| 179 | cfg = readl(&fimd_ctrl->trigcon); |
| 180 | |
| 181 | cfg |= (EXYNOS_I80SOFT_TRIG_EN | EXYNOS_I80START_TRIG); |
| 182 | |
| 183 | writel(cfg, &fimd_ctrl->trigcon); |
| 184 | } |
| 185 | |
| 186 | int exynos_is_i80_frame_done(void) |
| 187 | { |
| 188 | unsigned int cfg = 0; |
| 189 | int status; |
Donghwa Lee | 0112fed | 2012-04-05 19:36:17 +0000 | [diff] [blame] | 190 | |
| 191 | cfg = readl(&fimd_ctrl->trigcon); |
| 192 | |
| 193 | /* frame done func is valid only when TRIMODE[0] is set to 1. */ |
| 194 | status = (cfg & EXYNOS_I80STATUS_TRIG_DONE) == |
| 195 | EXYNOS_I80STATUS_TRIG_DONE; |
| 196 | |
| 197 | return status; |
| 198 | } |
| 199 | |
| 200 | static void exynos_fimd_lcd_on(void) |
| 201 | { |
| 202 | unsigned int cfg = 0; |
Donghwa Lee | 0112fed | 2012-04-05 19:36:17 +0000 | [diff] [blame] | 203 | |
| 204 | /* display on */ |
| 205 | cfg = readl(&fimd_ctrl->vidcon0); |
| 206 | cfg |= (EXYNOS_VIDCON0_ENVID_ENABLE | EXYNOS_VIDCON0_ENVID_F_ENABLE); |
| 207 | writel(cfg, &fimd_ctrl->vidcon0); |
| 208 | } |
| 209 | |
| 210 | static void exynos_fimd_window_on(unsigned int win_id) |
| 211 | { |
| 212 | unsigned int cfg = 0; |
Donghwa Lee | 0112fed | 2012-04-05 19:36:17 +0000 | [diff] [blame] | 213 | |
| 214 | /* enable window */ |
| 215 | cfg = readl((unsigned int)&fimd_ctrl->wincon0 + |
| 216 | EXYNOS_WINCON(win_id)); |
| 217 | cfg |= EXYNOS_WINCON_ENWIN_ENABLE; |
| 218 | writel(cfg, (unsigned int)&fimd_ctrl->wincon0 + |
| 219 | EXYNOS_WINCON(win_id)); |
| 220 | |
| 221 | cfg = readl(&fimd_ctrl->winshmap); |
| 222 | cfg |= EXYNOS_WINSHMAP_CH_ENABLE(win_id); |
| 223 | writel(cfg, &fimd_ctrl->winshmap); |
| 224 | } |
| 225 | |
| 226 | void exynos_fimd_lcd_off(void) |
| 227 | { |
| 228 | unsigned int cfg = 0; |
Donghwa Lee | 0112fed | 2012-04-05 19:36:17 +0000 | [diff] [blame] | 229 | |
| 230 | cfg = readl(&fimd_ctrl->vidcon0); |
| 231 | cfg &= (EXYNOS_VIDCON0_ENVID_DISABLE | EXYNOS_VIDCON0_ENVID_F_DISABLE); |
| 232 | writel(cfg, &fimd_ctrl->vidcon0); |
| 233 | } |
| 234 | |
| 235 | void exynos_fimd_window_off(unsigned int win_id) |
| 236 | { |
| 237 | unsigned int cfg = 0; |
Donghwa Lee | 0112fed | 2012-04-05 19:36:17 +0000 | [diff] [blame] | 238 | |
| 239 | cfg = readl((unsigned int)&fimd_ctrl->wincon0 + |
| 240 | EXYNOS_WINCON(win_id)); |
| 241 | cfg &= EXYNOS_WINCON_ENWIN_DISABLE; |
| 242 | writel(cfg, (unsigned int)&fimd_ctrl->wincon0 + |
| 243 | EXYNOS_WINCON(win_id)); |
| 244 | |
| 245 | cfg = readl(&fimd_ctrl->winshmap); |
| 246 | cfg &= ~EXYNOS_WINSHMAP_CH_DISABLE(win_id); |
| 247 | writel(cfg, &fimd_ctrl->winshmap); |
| 248 | } |
| 249 | |
Ajay Kumar | e24c502 | 2014-09-05 16:53:33 +0530 | [diff] [blame] | 250 | /* |
| 251 | * The reset value for FIMD SYSMMU register MMU_CTRL is 3 |
| 252 | * on Exynos5420 and newer versions. |
| 253 | * This means FIMD SYSMMU is on by default on Exynos5420 |
| 254 | * and newer versions. |
| 255 | * Since in u-boot we don't use SYSMMU, we should disable |
| 256 | * those FIMD SYSMMU. |
| 257 | * Note that there are 2 SYSMMU for FIMD: m0 and m1. |
| 258 | * m0 handles windows 0 and 4, and m1 handles windows 1, 2 and 3. |
| 259 | * We disable both of them here. |
| 260 | */ |
| 261 | void exynos_fimd_disable_sysmmu(void) |
| 262 | { |
| 263 | u32 *sysmmufimd; |
| 264 | unsigned int node; |
| 265 | int node_list[2]; |
| 266 | int count; |
| 267 | int i; |
| 268 | |
| 269 | count = fdtdec_find_aliases_for_id(gd->fdt_blob, "fimd", |
| 270 | COMPAT_SAMSUNG_EXYNOS_SYSMMU, node_list, 2); |
| 271 | for (i = 0; i < count; i++) { |
| 272 | node = node_list[i]; |
| 273 | if (node <= 0) { |
| 274 | debug("Can't get device node for fimd sysmmu\n"); |
| 275 | return; |
| 276 | } |
| 277 | |
| 278 | sysmmufimd = (u32 *)fdtdec_get_addr(gd->fdt_blob, node, "reg"); |
| 279 | if (!sysmmufimd) { |
| 280 | debug("Can't get base address for sysmmu fimdm0"); |
| 281 | return; |
| 282 | } |
| 283 | |
| 284 | writel(0x0, sysmmufimd); |
| 285 | } |
| 286 | } |
Donghwa Lee | 64b45d9 | 2012-07-26 15:30:49 +0000 | [diff] [blame] | 287 | |
Simon Glass | 4d022cc | 2016-02-21 21:08:41 -0700 | [diff] [blame^] | 288 | void exynos_fimd_lcd_init(struct vidinfo *vid, ulong lcd_base_address) |
Donghwa Lee | 0112fed | 2012-04-05 19:36:17 +0000 | [diff] [blame] | 289 | { |
| 290 | unsigned int cfg = 0, rgb_mode; |
Donghwa Lee | 64b45d9 | 2012-07-26 15:30:49 +0000 | [diff] [blame] | 291 | unsigned int offset; |
Ajay Kumar | ebbace3 | 2013-02-21 23:53:01 +0000 | [diff] [blame] | 292 | unsigned int node; |
| 293 | |
| 294 | node = fdtdec_next_compatible(gd->fdt_blob, |
| 295 | 0, COMPAT_SAMSUNG_EXYNOS_FIMD); |
| 296 | if (node <= 0) |
| 297 | debug("exynos_fb: Can't get device node for fimd\n"); |
| 298 | |
| 299 | fimd_ctrl = (struct exynos_fb *)fdtdec_get_addr(gd->fdt_blob, |
| 300 | node, "reg"); |
| 301 | if (fimd_ctrl == NULL) |
| 302 | debug("Can't get the FIMD base address\n"); |
Ajay Kumar | e24c502 | 2014-09-05 16:53:33 +0530 | [diff] [blame] | 303 | |
| 304 | if (fdtdec_get_bool(gd->fdt_blob, node, "samsung,disable-sysmmu")) |
| 305 | exynos_fimd_disable_sysmmu(); |
| 306 | |
Donghwa Lee | 64b45d9 | 2012-07-26 15:30:49 +0000 | [diff] [blame] | 307 | offset = exynos_fimd_get_base_offset(); |
Donghwa Lee | 0112fed | 2012-04-05 19:36:17 +0000 | [diff] [blame] | 308 | |
| 309 | /* store panel info to global variable */ |
| 310 | pvid = vid; |
| 311 | |
Donghwa Lee | 37980dd | 2012-05-09 19:23:46 +0000 | [diff] [blame] | 312 | rgb_mode = vid->rgb_mode; |
Donghwa Lee | 0112fed | 2012-04-05 19:36:17 +0000 | [diff] [blame] | 313 | |
| 314 | if (vid->interface_mode == FIMD_RGB_INTERFACE) { |
| 315 | cfg |= EXYNOS_VIDCON0_VIDOUT_RGB; |
| 316 | writel(cfg, &fimd_ctrl->vidcon0); |
| 317 | |
| 318 | cfg = readl(&fimd_ctrl->vidcon2); |
| 319 | cfg &= ~(EXYNOS_VIDCON2_WB_MASK | |
| 320 | EXYNOS_VIDCON2_TVFORMATSEL_MASK | |
| 321 | EXYNOS_VIDCON2_TVFORMATSEL_YUV_MASK); |
| 322 | cfg |= EXYNOS_VIDCON2_WB_DISABLE; |
| 323 | writel(cfg, &fimd_ctrl->vidcon2); |
| 324 | |
| 325 | /* set polarity */ |
| 326 | cfg = 0; |
| 327 | if (!pvid->vl_clkp) |
| 328 | cfg |= EXYNOS_VIDCON1_IVCLK_RISING_EDGE; |
| 329 | if (!pvid->vl_hsp) |
| 330 | cfg |= EXYNOS_VIDCON1_IHSYNC_INVERT; |
| 331 | if (!pvid->vl_vsp) |
| 332 | cfg |= EXYNOS_VIDCON1_IVSYNC_INVERT; |
| 333 | if (!pvid->vl_dp) |
| 334 | cfg |= EXYNOS_VIDCON1_IVDEN_INVERT; |
| 335 | |
Donghwa Lee | 64b45d9 | 2012-07-26 15:30:49 +0000 | [diff] [blame] | 336 | writel(cfg, (unsigned int)&fimd_ctrl->vidcon1 + offset); |
Donghwa Lee | 0112fed | 2012-04-05 19:36:17 +0000 | [diff] [blame] | 337 | |
| 338 | /* set timing */ |
| 339 | cfg = EXYNOS_VIDTCON0_VFPD(pvid->vl_vfpd - 1); |
| 340 | cfg |= EXYNOS_VIDTCON0_VBPD(pvid->vl_vbpd - 1); |
| 341 | cfg |= EXYNOS_VIDTCON0_VSPW(pvid->vl_vspw - 1); |
Donghwa Lee | 64b45d9 | 2012-07-26 15:30:49 +0000 | [diff] [blame] | 342 | writel(cfg, (unsigned int)&fimd_ctrl->vidtcon0 + offset); |
Donghwa Lee | 0112fed | 2012-04-05 19:36:17 +0000 | [diff] [blame] | 343 | |
| 344 | cfg = EXYNOS_VIDTCON1_HFPD(pvid->vl_hfpd - 1); |
| 345 | cfg |= EXYNOS_VIDTCON1_HBPD(pvid->vl_hbpd - 1); |
| 346 | cfg |= EXYNOS_VIDTCON1_HSPW(pvid->vl_hspw - 1); |
| 347 | |
Donghwa Lee | 64b45d9 | 2012-07-26 15:30:49 +0000 | [diff] [blame] | 348 | writel(cfg, (unsigned int)&fimd_ctrl->vidtcon1 + offset); |
Donghwa Lee | 0112fed | 2012-04-05 19:36:17 +0000 | [diff] [blame] | 349 | |
| 350 | /* set lcd size */ |
Donghwa Lee | 64b45d9 | 2012-07-26 15:30:49 +0000 | [diff] [blame] | 351 | cfg = EXYNOS_VIDTCON2_HOZVAL(pvid->vl_col - 1) | |
| 352 | EXYNOS_VIDTCON2_LINEVAL(pvid->vl_row - 1) | |
| 353 | EXYNOS_VIDTCON2_HOZVAL_E(pvid->vl_col - 1) | |
| 354 | EXYNOS_VIDTCON2_LINEVAL_E(pvid->vl_row - 1); |
Donghwa Lee | 0112fed | 2012-04-05 19:36:17 +0000 | [diff] [blame] | 355 | |
Donghwa Lee | 64b45d9 | 2012-07-26 15:30:49 +0000 | [diff] [blame] | 356 | writel(cfg, (unsigned int)&fimd_ctrl->vidtcon2 + offset); |
Donghwa Lee | 0112fed | 2012-04-05 19:36:17 +0000 | [diff] [blame] | 357 | } |
| 358 | |
| 359 | /* set display mode */ |
| 360 | cfg = readl(&fimd_ctrl->vidcon0); |
| 361 | cfg &= ~EXYNOS_VIDCON0_PNRMODE_MASK; |
| 362 | cfg |= (rgb_mode << EXYNOS_VIDCON0_PNRMODE_SHIFT); |
| 363 | writel(cfg, &fimd_ctrl->vidcon0); |
| 364 | |
| 365 | /* set par */ |
Simon Glass | 4d022cc | 2016-02-21 21:08:41 -0700 | [diff] [blame^] | 366 | exynos_fimd_set_par(pvid, pvid->win_id); |
Donghwa Lee | 0112fed | 2012-04-05 19:36:17 +0000 | [diff] [blame] | 367 | |
| 368 | /* set memory address */ |
Simon Glass | 4d022cc | 2016-02-21 21:08:41 -0700 | [diff] [blame^] | 369 | exynos_fimd_set_buffer_address(pvid, pvid->win_id, lcd_base_address); |
Donghwa Lee | 0112fed | 2012-04-05 19:36:17 +0000 | [diff] [blame] | 370 | |
| 371 | /* set buffer size */ |
Donghwa Lee | 64b45d9 | 2012-07-26 15:30:49 +0000 | [diff] [blame] | 372 | cfg = EXYNOS_VIDADDR_PAGEWIDTH(pvid->vl_col * NBITS(pvid->vl_bpix) / 8) | |
| 373 | EXYNOS_VIDADDR_PAGEWIDTH_E(pvid->vl_col * NBITS(pvid->vl_bpix) / 8) | |
| 374 | EXYNOS_VIDADDR_OFFSIZE(0) | |
| 375 | EXYNOS_VIDADDR_OFFSIZE_E(0); |
| 376 | |
Donghwa Lee | 0112fed | 2012-04-05 19:36:17 +0000 | [diff] [blame] | 377 | writel(cfg, (unsigned int)&fimd_ctrl->vidw00add2 + |
| 378 | EXYNOS_BUFFER_SIZE(pvid->win_id)); |
| 379 | |
| 380 | /* set clock */ |
| 381 | exynos_fimd_set_clock(pvid); |
| 382 | |
| 383 | /* set rgb mode to dual lcd. */ |
| 384 | exynos_fimd_set_dualrgb(pvid->dual_lcd_enabled); |
| 385 | |
| 386 | /* display on */ |
| 387 | exynos_fimd_lcd_on(); |
| 388 | |
| 389 | /* window on */ |
| 390 | exynos_fimd_window_on(pvid->win_id); |
Donghwa Lee | bc72aeb | 2012-07-02 01:16:08 +0000 | [diff] [blame] | 391 | |
Simon Glass | 4d022cc | 2016-02-21 21:08:41 -0700 | [diff] [blame^] | 392 | exynos_fimd_set_dp_clkcon(pvid, pvid->dp_enabled); |
Donghwa Lee | 0112fed | 2012-04-05 19:36:17 +0000 | [diff] [blame] | 393 | } |
| 394 | |
| 395 | unsigned long exynos_fimd_calc_fbsize(void) |
| 396 | { |
Donghwa Lee | 2386f45 | 2012-04-23 15:37:05 +0000 | [diff] [blame] | 397 | return pvid->vl_col * pvid->vl_row * (NBITS(pvid->vl_bpix) / 8); |
Donghwa Lee | 0112fed | 2012-04-05 19:36:17 +0000 | [diff] [blame] | 398 | } |