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