Lines Matching +full:timing +full:- +full:0
1 // SPDX-License-Identifier: GPL-2.0+
20 #include <asm/arch-tegra/dc.h>
21 #include <dm/uclass-internal.h>
25 static int tegra_dc_calc_refresh(const struct display_timing *timing) in tegra_dc_calc_refresh() argument
28 int pclk = timing->pixelclock.typ; in tegra_dc_calc_refresh()
30 h_total = timing->hactive.typ + timing->hfront_porch.typ + in tegra_dc_calc_refresh()
31 timing->hback_porch.typ + timing->hsync_len.typ; in tegra_dc_calc_refresh()
32 v_total = timing->vactive.typ + timing->vfront_porch.typ + in tegra_dc_calc_refresh()
33 timing->vback_porch.typ + timing->vsync_len.typ; in tegra_dc_calc_refresh()
35 return 0; in tegra_dc_calc_refresh()
43 static void print_mode(const struct display_timing *timing) in print_mode() argument
45 int refresh = tegra_dc_calc_refresh(timing); in print_mode()
48 timing->hactive.typ, timing->vactive.typ, refresh / 1000, in print_mode()
49 refresh % 1000, timing->pixelclock.typ); in print_mode()
53 const struct display_timing *timing, in update_display_mode() argument
56 print_mode(timing); in update_display_mode()
58 writel(0x1, &disp_ctrl->disp.disp_timing_opt); in update_display_mode()
61 &disp_ctrl->disp.ref_to_sync); in update_display_mode()
63 writel(timing->vsync_len.typ << 16 | timing->hsync_len.typ, in update_display_mode()
64 &disp_ctrl->disp.sync_width); in update_display_mode()
66 writel(((timing->vback_porch.typ - vref_to_sync) << 16) | in update_display_mode()
67 timing->hback_porch.typ, &disp_ctrl->disp.back_porch); in update_display_mode()
69 writel(((timing->vfront_porch.typ + vref_to_sync) << 16) | in update_display_mode()
70 timing->hfront_porch.typ, &disp_ctrl->disp.front_porch); in update_display_mode()
72 writel(timing->hactive.typ | (timing->vactive.typ << 16), in update_display_mode()
73 &disp_ctrl->disp.disp_active); in update_display_mode()
89 ((shift_clock_div - 1) * 2) << SHIFT_CLK_DIVIDER_SHIFT, in update_display_mode()
90 &disp_ctrl->disp.disp_clk_ctrl); in update_display_mode()
92 timing->pixelclock.typ, shift_clock_div); in update_display_mode()
93 return 0; in update_display_mode()
100 u32 reg_val = 0; in tegra_dc_poll_register()
106 timeout_us -= poll_interval_us; in tegra_dc_poll_register()
112 return 0; /* success */ in tegra_dc_poll_register()
119 writel(GENERAL_ACT_REQ, &disp_ctrl->cmd.state_ctrl); in tegra_dc_sor_general_act()
121 if (tegra_dc_poll_register(&disp_ctrl->cmd.state_ctrl, in tegra_dc_sor_general_act()
122 GENERAL_ACT_REQ, 0, 100, in tegra_dc_sor_general_act()
125 return -ETIMEDOUT; in tegra_dc_sor_general_act()
128 return 0; in tegra_dc_sor_general_act()
135 .vback_porch = { .typ = 0 },
146 const int href_to_sync = 0, vref_to_sync = 1; in tegra_dc_sor_disable_win_short_raster()
149 selected_windows = readl(&disp_ctrl->cmd.disp_win_header); in tegra_dc_sor_disable_win_short_raster()
152 for (i = 0; i < DC_N_WINDOWS; ++i) { in tegra_dc_sor_disable_win_short_raster()
153 writel(WINDOW_A_SELECT << i, &disp_ctrl->cmd.disp_win_header); in tegra_dc_sor_disable_win_short_raster()
154 dc_reg_ctx[i] = readl(&disp_ctrl->win.win_opt); in tegra_dc_sor_disable_win_short_raster()
155 writel(0, &disp_ctrl->win.win_opt); in tegra_dc_sor_disable_win_short_raster()
156 writel(WIN_A_ACT_REQ << i, &disp_ctrl->cmd.state_ctrl); in tegra_dc_sor_disable_win_short_raster()
159 writel(selected_windows, &disp_ctrl->cmd.disp_win_header); in tegra_dc_sor_disable_win_short_raster()
162 dc_reg_ctx[i++] = readl(&disp_ctrl->disp.ref_to_sync); in tegra_dc_sor_disable_win_short_raster()
164 &disp_ctrl->disp.ref_to_sync); in tegra_dc_sor_disable_win_short_raster()
166 dc_reg_ctx[i++] = readl(&disp_ctrl->disp.sync_width); in tegra_dc_sor_disable_win_short_raster()
168 &disp_ctrl->disp.sync_width); in tegra_dc_sor_disable_win_short_raster()
170 dc_reg_ctx[i++] = readl(&disp_ctrl->disp.back_porch); in tegra_dc_sor_disable_win_short_raster()
172 &disp_ctrl->disp.back_porch); in tegra_dc_sor_disable_win_short_raster()
174 dc_reg_ctx[i++] = readl(&disp_ctrl->disp.front_porch); in tegra_dc_sor_disable_win_short_raster()
176 &disp_ctrl->disp.front_porch); in tegra_dc_sor_disable_win_short_raster()
178 dc_reg_ctx[i++] = readl(&disp_ctrl->disp.disp_active); in tegra_dc_sor_disable_win_short_raster()
180 &disp_ctrl->disp.disp_active); in tegra_dc_sor_disable_win_short_raster()
182 writel(GENERAL_ACT_REQ, &disp_ctrl->cmd.state_ctrl); in tegra_dc_sor_disable_win_short_raster()
191 selected_windows = readl(&disp_ctrl->cmd.disp_win_header); in tegra_dc_sor_restore_win_and_raster()
193 for (i = 0; i < DC_N_WINDOWS; ++i) { in tegra_dc_sor_restore_win_and_raster()
194 writel(WINDOW_A_SELECT << i, &disp_ctrl->cmd.disp_win_header); in tegra_dc_sor_restore_win_and_raster()
195 writel(dc_reg_ctx[i], &disp_ctrl->win.win_opt); in tegra_dc_sor_restore_win_and_raster()
196 writel(WIN_A_ACT_REQ << i, &disp_ctrl->cmd.state_ctrl); in tegra_dc_sor_restore_win_and_raster()
199 writel(selected_windows, &disp_ctrl->cmd.disp_win_header); in tegra_dc_sor_restore_win_and_raster()
201 writel(dc_reg_ctx[i++], &disp_ctrl->disp.ref_to_sync); in tegra_dc_sor_restore_win_and_raster()
202 writel(dc_reg_ctx[i++], &disp_ctrl->disp.sync_width); in tegra_dc_sor_restore_win_and_raster()
203 writel(dc_reg_ctx[i++], &disp_ctrl->disp.back_porch); in tegra_dc_sor_restore_win_and_raster()
204 writel(dc_reg_ctx[i++], &disp_ctrl->disp.front_porch); in tegra_dc_sor_restore_win_and_raster()
205 writel(dc_reg_ctx[i++], &disp_ctrl->disp.disp_active); in tegra_dc_sor_restore_win_and_raster()
207 writel(GENERAL_UPDATE, &disp_ctrl->cmd.state_ctrl); in tegra_dc_sor_restore_win_and_raster()
219 return -1; in tegra_depth_for_bpp()
225 const struct display_timing *timing) in update_window() argument
227 const u32 colour_white = 0xffffff; in update_window()
231 writel(WINDOW_A_SELECT, &disp_ctrl->cmd.disp_win_header); in update_window()
233 writel(((timing->vactive.typ << 16) | timing->hactive.typ), in update_window()
234 &disp_ctrl->win.size); in update_window()
235 writel(((timing->vactive.typ << 16) | in update_window()
236 (timing->hactive.typ * fb_bits_per_pixel / 8)), in update_window()
237 &disp_ctrl->win.prescaled_size); in update_window()
238 writel(((timing->hactive.typ * fb_bits_per_pixel / 8 + 31) / in update_window()
239 32 * 32), &disp_ctrl->win.line_stride); in update_window()
242 if (colour_depth == -1) in update_window()
243 return -EINVAL; in update_window()
245 writel(colour_depth, &disp_ctrl->win.color_depth); in update_window()
247 writel(frame_buffer, &disp_ctrl->winbuf.start_addr); in update_window()
248 writel(0x1000 << V_DDA_INC_SHIFT | 0x1000 << H_DDA_INC_SHIFT, in update_window()
249 &disp_ctrl->win.dda_increment); in update_window()
251 writel(colour_white, &disp_ctrl->disp.blend_background_color); in update_window()
253 &disp_ctrl->cmd.disp_cmd); in update_window()
255 writel(WRITE_MUX_ACTIVE, &disp_ctrl->cmd.state_access); in update_window()
259 writel(val, &disp_ctrl->cmd.state_ctrl); in update_window()
262 val = readl(&disp_ctrl->win.win_opt); in update_window()
263 writel(val | WIN_ENABLE, &disp_ctrl->win.win_opt); in update_window()
265 return 0; in update_window()
271 writel(0x00000000, &disp_ctrl->cmd.int_mask); in tegra_dc_init()
273 &disp_ctrl->cmd.state_access); in tegra_dc_init()
274 writel(WINDOW_A_SELECT, &disp_ctrl->cmd.disp_win_header); in tegra_dc_init()
275 writel(0x00000000, &disp_ctrl->win.win_opt); in tegra_dc_init()
276 writel(0x00000000, &disp_ctrl->win.byte_swap); in tegra_dc_init()
277 writel(0x00000000, &disp_ctrl->win.buffer_ctrl); in tegra_dc_init()
279 writel(0x00000000, &disp_ctrl->win.pos); in tegra_dc_init()
280 writel(0x00000000, &disp_ctrl->win.h_initial_dda); in tegra_dc_init()
281 writel(0x00000000, &disp_ctrl->win.v_initial_dda); in tegra_dc_init()
282 writel(0x00000000, &disp_ctrl->win.dda_increment); in tegra_dc_init()
283 writel(0x00000000, &disp_ctrl->win.dv_ctrl); in tegra_dc_init()
285 writel(0x01000000, &disp_ctrl->win.blend_layer_ctrl); in tegra_dc_init()
286 writel(0x00000000, &disp_ctrl->win.blend_match_select); in tegra_dc_init()
287 writel(0x00000000, &disp_ctrl->win.blend_nomatch_select); in tegra_dc_init()
288 writel(0x00000000, &disp_ctrl->win.blend_alpha_1bit); in tegra_dc_init()
290 writel(0x00000000, &disp_ctrl->winbuf.start_addr_hi); in tegra_dc_init()
291 writel(0x00000000, &disp_ctrl->winbuf.addr_h_offset); in tegra_dc_init()
292 writel(0x00000000, &disp_ctrl->winbuf.addr_v_offset); in tegra_dc_init()
294 writel(0x00000000, &disp_ctrl->com.crc_checksum); in tegra_dc_init()
295 writel(0x00000000, &disp_ctrl->com.pin_output_enb[0]); in tegra_dc_init()
296 writel(0x00000000, &disp_ctrl->com.pin_output_enb[1]); in tegra_dc_init()
297 writel(0x00000000, &disp_ctrl->com.pin_output_enb[2]); in tegra_dc_init()
298 writel(0x00000000, &disp_ctrl->com.pin_output_enb[3]); in tegra_dc_init()
299 writel(0x00000000, &disp_ctrl->disp.disp_signal_opt0); in tegra_dc_init()
301 return 0; in tegra_dc_init()
304 static void dump_config(int panel_bpp, struct display_timing *timing) in dump_config() argument
306 printf("timing->hactive.typ = %d\n", timing->hactive.typ); in dump_config()
307 printf("timing->vactive.typ = %d\n", timing->vactive.typ); in dump_config()
308 printf("timing->pixelclock.typ = %d\n", timing->pixelclock.typ); in dump_config()
310 printf("timing->hfront_porch.typ = %d\n", timing->hfront_porch.typ); in dump_config()
311 printf("timing->hsync_len.typ = %d\n", timing->hsync_len.typ); in dump_config()
312 printf("timing->hback_porch.typ = %d\n", timing->hback_porch.typ); in dump_config()
314 printf("timing->vfront_porch.typ %d\n", timing->vfront_porch.typ); in dump_config()
315 printf("timing->vsync_len.typ = %d\n", timing->vsync_len.typ); in dump_config()
316 printf("timing->vback_porch.typ = %d\n", timing->vback_porch.typ); in dump_config()
323 struct display_timing *timing) in display_update_config_from_edid() argument
325 return display_read_timing(dp_dev, timing); in display_update_config_from_edid()
329 int fb_bits_per_pixel, struct display_timing *timing) in display_init() argument
346 dev->name, ret); in display_init()
351 debug("Found device '%s', disp_uc_priv=%p\n", dp_dev->name, in display_init()
353 disp_uc_plat->src_dev = dev; in display_init()
355 ret = uclass_get_device(UCLASS_DISPLAY, 0, &dp_dev); in display_init()
362 if (ofnode_decode_display_timing(dev_ofnode(dev), 0, timing)) { in display_init()
363 debug("%s: Failed to decode display timing\n", __func__); in display_init()
364 return -EINVAL; in display_init()
367 ret = display_update_config_from_edid(dp_dev, &panel_bpp, timing); in display_init()
370 dump_config(panel_bpp, timing); in display_init()
378 plld_rate = clock_set_display_rate(timing->pixelclock.typ * 2); in display_init()
379 if (plld_rate == 0) { in display_init()
381 return -EIO; in display_init()
382 } else if (plld_rate != timing->pixelclock.typ * 2) { in display_init()
384 timing->pixelclock.typ = plld_rate / 2; in display_init()
395 ret = update_display_mode(dc_ctlr, timing, href_to_sync, vref_to_sync); in display_init()
402 ret = display_enable(dp_dev, panel_bpp, timing); in display_init()
408 ret = update_window(dc_ctlr, (ulong)lcdbase, fb_bits_per_pixel, timing); in display_init()
415 return 0; in display_init()
429 struct display_timing timing; in tegra124_lcd_init() local
442 reset_set_enable(PERIPH_ID_HOST1X, 0); in tegra124_lcd_init()
443 reset_set_enable(PERIPH_ID_DISP1, 0); in tegra124_lcd_init()
444 reset_set_enable(PERIPH_ID_PWM, 0); in tegra124_lcd_init()
445 reset_set_enable(PERIPH_ID_DPAUX, 0); in tegra124_lcd_init()
446 reset_set_enable(PERIPH_ID_SOR0, 0); in tegra124_lcd_init()
448 ret = display_init(dev, lcdbase, 1 << l2bpp, &timing); in tegra124_lcd_init()
452 uc_priv->xsize = roundup(timing.hactive.typ, 16); in tegra124_lcd_init()
453 uc_priv->ysize = timing.vactive.typ; in tegra124_lcd_init()
454 uc_priv->bpix = l2bpp; in tegra124_lcd_init()
459 return 0; in tegra124_lcd_init()
468 start = get_timer(0); in tegra124_lcd_probe()
470 ret = tegra124_lcd_init(dev, (void *)plat->base, VIDEO_BPP16); in tegra124_lcd_probe()
476 return 0; in tegra124_lcd_probe()
483 uc_plat->size = LCD_MAX_WIDTH * LCD_MAX_HEIGHT * in tegra124_lcd_bind()
485 debug("%s: Frame buffer size %x\n", __func__, uc_plat->size); in tegra124_lcd_bind()
487 return 0; in tegra124_lcd_bind()
491 { .compatible = "nvidia,tegra124-dc" },
496 .name = "tegra124-dc",