xref: /openbmc/u-boot/drivers/video/bcm2835.c (revision d9b23e26)
1 /*
2  * (C) Copyright 2012 Stephen Warren
3  *
4  * SPDX-License-Identifier:	GPL-2.0+
5  */
6 
7 #include <common.h>
8 #include <dm.h>
9 #include <video.h>
10 #include <asm/arch/mbox.h>
11 #include <asm/arch/msg.h>
12 
13 static int bcm2835_video_probe(struct udevice *dev)
14 {
15 	struct video_uc_platdata *plat = dev_get_uclass_platdata(dev);
16 	struct video_priv *uc_priv = dev_get_uclass_priv(dev);
17 	int ret;
18 	int w, h, pitch;
19 	ulong fb_base, fb_size, fb_start, fb_end;
20 
21 	debug("bcm2835: Query resolution...\n");
22 	ret = bcm2835_get_video_size(&w, &h);
23 	if (ret)
24 		return -EIO;
25 
26 	debug("bcm2835: Setting up display for %d x %d\n", w, h);
27 	ret = bcm2835_set_video_params(&w, &h, 32, BCM2835_MBOX_PIXEL_ORDER_RGB,
28 				       BCM2835_MBOX_ALPHA_MODE_IGNORED,
29 				       &fb_base, &fb_size, &pitch);
30 
31 	debug("bcm2835: Final resolution is %d x %d\n", w, h);
32 
33 	/* Enable dcache for the frame buffer */
34 	fb_start = fb_base & ~(MMU_SECTION_SIZE - 1);
35 	fb_end = fb_base + fb_size;
36 	fb_end = ALIGN(fb_end, 1 << MMU_SECTION_SHIFT);
37 	mmu_set_region_dcache_behaviour(fb_start, fb_end - fb_start,
38 					DCACHE_WRITEBACK);
39 	video_set_flush_dcache(dev, true);
40 
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;
48 }
49 
50 static const struct udevice_id bcm2835_video_ids[] = {
51 	{ .compatible = "brcm,bcm2835-hdmi" },
52 	{ }
53 };
54 
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 };
61