]> git.sur5r.net Git - u-boot/blob - drivers/video/bcm2835.c
video: arm: rpi: Move the video settings out of the driver
[u-boot] / drivers / video / bcm2835.c
1 /*
2  * (C) Copyright 2012 Stephen Warren
3  *
4  * SPDX-License-Identifier:     GPL-2.0+
5  */
6
7 #include <common.h>
8 #include <lcd.h>
9 #include <memalign.h>
10 #include <phys2bus.h>
11 #include <asm/arch/mbox.h>
12 #include <asm/arch/msg.h>
13 #include <asm/global_data.h>
14
15 DECLARE_GLOBAL_DATA_PTR;
16
17 /* Global variables that lcd.c expects to exist */
18 vidinfo_t panel_info;
19
20 static int bcm2835_pitch;
21
22 void lcd_ctrl_init(void *lcdbase)
23 {
24         int ret;
25         int w, h;
26         ulong fb_base, fb_size, fb_start, fb_end;
27
28         debug("bcm2835: Query resolution...\n");
29         ret = bcm2835_get_video_size(&w, &h);
30         if (ret) {
31                 /* FIXME: How to disable the LCD to prevent errors? hang()? */
32                 return;
33         }
34
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);
39
40         debug("bcm2835: Final resolution is %d x %d\n", w, h);
41
42         panel_info.vl_col = w;
43         panel_info.vl_row = h;
44         panel_info.vl_bpix = LCD_COLOR32;
45
46         gd->fb_base = fb_base;
47
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,
53                                         DCACHE_WRITEBACK);
54         lcd_set_flush_dcache(1);
55 }
56
57 void lcd_enable(void)
58 {
59 }
60
61 int lcd_get_size(int *line_length)
62 {
63         *line_length = bcm2835_pitch;
64
65         return *line_length * panel_info.vl_row;
66 }