Commit ea843b6dabdd0473c5f12e8b7ccb560aededd2e4
Committed by
Tom Rini
1 parent
d08e42a8cb
Exists in
smarc_8mq_lf_v2020.04
and in
17 other branches
dm: video: arm: rpi: Convert to use driver model for video
Adjust the video driver to work with driver model and move over existing baords. There is no need to keep the old code. We can also drop setting of CONFIG_FB_ADDR since driver model doesn't have this problem. Signed-off-by: Simon Glass <sjg@chromium.org> Acked-by: Anatolij Gustschin <agust@denx.de>
Showing 6 changed files with 34 additions and 47 deletions Side-by-side Diff
configs/rpi_2_defconfig
configs/rpi_3_32b_defconfig
configs/rpi_3_defconfig
configs/rpi_defconfig
drivers/video/bcm2835.c
... | ... | @@ -5,63 +5,57 @@ |
5 | 5 | */ |
6 | 6 | |
7 | 7 | #include <common.h> |
8 | -#include <lcd.h> | |
9 | -#include <memalign.h> | |
10 | -#include <phys2bus.h> | |
8 | +#include <dm.h> | |
9 | +#include <video.h> | |
11 | 10 | #include <asm/arch/mbox.h> |
12 | 11 | #include <asm/arch/msg.h> |
13 | -#include <asm/global_data.h> | |
14 | 12 | |
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) | |
13 | +static int bcm2835_video_probe(struct udevice *dev) | |
23 | 14 | { |
15 | + struct video_uc_platdata *plat = dev_get_uclass_platdata(dev); | |
16 | + struct video_priv *uc_priv = dev_get_uclass_priv(dev); | |
24 | 17 | int ret; |
25 | - int w, h; | |
18 | + int w, h, pitch; | |
26 | 19 | ulong fb_base, fb_size, fb_start, fb_end; |
27 | 20 | |
28 | 21 | debug("bcm2835: Query resolution...\n"); |
29 | 22 | ret = bcm2835_get_video_size(&w, &h); |
30 | - if (ret) { | |
31 | - /* FIXME: How to disable the LCD to prevent errors? hang()? */ | |
32 | - return; | |
33 | - } | |
23 | + if (ret) | |
24 | + return -EIO; | |
34 | 25 | |
35 | 26 | debug("bcm2835: Setting up display for %d x %d\n", w, h); |
36 | 27 | ret = bcm2835_set_video_params(&w, &h, 32, BCM2835_MBOX_PIXEL_ORDER_RGB, |
37 | 28 | BCM2835_MBOX_ALPHA_MODE_IGNORED, |
38 | - &fb_base, &fb_size, &bcm2835_pitch); | |
29 | + &fb_base, &fb_size, &pitch); | |
39 | 30 | |
40 | 31 | debug("bcm2835: Final resolution is %d x %d\n", w, h); |
41 | 32 | |
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 | 33 | /* Enable dcache for the frame buffer */ |
49 | 34 | fb_start = fb_base & ~(MMU_SECTION_SIZE - 1); |
50 | 35 | fb_end = fb_base + fb_size; |
51 | 36 | fb_end = ALIGN(fb_end, 1 << MMU_SECTION_SHIFT); |
52 | 37 | mmu_set_region_dcache_behaviour(fb_start, fb_end - fb_start, |
53 | 38 | DCACHE_WRITEBACK); |
54 | - lcd_set_flush_dcache(1); | |
55 | -} | |
39 | + video_set_flush_dcache(dev, true); | |
56 | 40 | |
57 | -void lcd_enable(void) | |
58 | -{ | |
41 | + uc_priv->xsize = w; | |
42 | + uc_priv->ysize = h; | |
43 | + uc_priv->bpix = VIDEO_BPP32; | |
44 | + plat->base = fb_base; | |
45 | + plat->size = fb_size; | |
46 | + | |
47 | + return 0; | |
59 | 48 | } |
60 | 49 | |
61 | -int lcd_get_size(int *line_length) | |
62 | -{ | |
63 | - *line_length = bcm2835_pitch; | |
50 | +static const struct udevice_id bcm2835_video_ids[] = { | |
51 | + { .compatible = "brcm,bcm2835-hdmi" }, | |
52 | + { } | |
53 | +}; | |
64 | 54 | |
65 | - return *line_length * panel_info.vl_row; | |
66 | -} | |
55 | +U_BOOT_DRIVER(bcm2835_video) = { | |
56 | + .name = "bcm2835_video", | |
57 | + .id = UCLASS_VIDEO, | |
58 | + .of_match = bcm2835_video_ids, | |
59 | + .probe = bcm2835_video_probe, | |
60 | +}; |
include/configs/rpi.h
... | ... | @@ -68,13 +68,6 @@ |
68 | 68 | #define CONFIG_BCM2835_GPIO |
69 | 69 | /* LCD */ |
70 | 70 | #define CONFIG_LCD_DT_SIMPLEFB |
71 | -#define LCD_BPP LCD_COLOR32 | |
72 | -/* | |
73 | - * Prevent allocation of RAM for FB; the real FB address is queried | |
74 | - * dynamically from the VideoCore co-processor, and comes from RAM | |
75 | - * not owned by the ARM CPU. | |
76 | - */ | |
77 | -#define CONFIG_FB_ADDR 0 | |
78 | 71 | #define CONFIG_VIDEO_BCM2835 |
79 | 72 | |
80 | 73 | #ifdef CONFIG_CMD_USB |
... | ... | @@ -124,8 +117,8 @@ |
124 | 117 | #define CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG |
125 | 118 | #define ENV_DEVICE_SETTINGS \ |
126 | 119 | "stdin=serial,usbkbd\0" \ |
127 | - "stdout=serial,lcd\0" \ | |
128 | - "stderr=serial,lcd\0" | |
120 | + "stdout=serial,vidconsole\0" \ | |
121 | + "stderr=serial,vidconsole\0" | |
129 | 122 | |
130 | 123 | /* |
131 | 124 | * Memory layout for where various images get loaded by boot scripts: |