2 * (C) Copyright 2012 Stephen Warren
4 * SPDX-License-Identifier: GPL-2.0+
11 #include <asm/arch/mbox.h>
12 #include <asm/arch/msg.h>
13 #include <asm/global_data.h>
15 DECLARE_GLOBAL_DATA_PTR;
17 /* Global variables that lcd.c expects to exist */
20 static int bcm2835_pitch;
22 void lcd_ctrl_init(void *lcdbase)
26 ulong fb_base, fb_size, fb_start, fb_end;
28 debug("bcm2835: Query resolution...\n");
29 ret = bcm2835_get_video_size(&w, &h);
31 /* FIXME: How to disable the LCD to prevent errors? hang()? */
35 debug("bcm2835: Setting up display for %d x %d\n", w, h);
36 ret = bcm2835_set_video_params(&w, &h, 32, BCM2835_MBOX_PIXEL_ORDER_RGB,
37 BCM2835_MBOX_ALPHA_MODE_IGNORED,
38 &fb_base, &fb_size, &bcm2835_pitch);
40 debug("bcm2835: Final resolution is %d x %d\n", w, h);
42 panel_info.vl_col = w;
43 panel_info.vl_row = h;
44 panel_info.vl_bpix = LCD_COLOR32;
46 gd->fb_base = fb_base;
48 /* Enable dcache for the frame buffer */
49 fb_start = fb_base & ~(MMU_SECTION_SIZE - 1);
50 fb_end = fb_base + fb_size;
51 fb_end = ALIGN(fb_end, 1 << MMU_SECTION_SHIFT);
52 mmu_set_region_dcache_behaviour(fb_start, fb_end - fb_start,
54 lcd_set_flush_dcache(1);
61 int lcd_get_size(int *line_length)
63 *line_length = bcm2835_pitch;
65 return *line_length * panel_info.vl_row;