]> Git Repo - u-boot.git/blob - drivers/video/bcm2835.c
Merge branch 'master' of https://source.denx.de/u-boot/custodians/u-boot-sh
[u-boot.git] / drivers / video / bcm2835.c
1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * (C) Copyright 2012 Stephen Warren
4  */
5
6 #include <dm.h>
7 #include <log.h>
8 #include <video.h>
9 #include <asm/arch/mbox.h>
10 #include <asm/arch/msg.h>
11 #include <asm/cache.h>
12
13 static int bcm2835_video_probe(struct udevice *dev)
14 {
15         struct video_uc_plat *plat = dev_get_uclass_plat(dev);
16         struct video_priv *uc_priv = dev_get_uclass_priv(dev);
17         int ret;
18         int w, h, pitch, bpp;
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 || w == 0 || h == 0)
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         if (ret)
31                 return -EIO;
32
33         debug("bcm2835: Final resolution is %d x %d\n", w, h);
34
35         /* Enable dcache for the frame buffer */
36         fb_start = fb_base & ~(MMU_SECTION_SIZE - 1);
37         fb_end = fb_base + fb_size;
38         fb_end = ALIGN(fb_end, 1 << MMU_SECTION_SHIFT);
39         mmu_set_region_dcache_behaviour(fb_start, fb_end - fb_start,
40                                         DCACHE_WRITEBACK);
41         video_set_flush_dcache(dev, true);
42
43         bpp = pitch / w;
44         switch (bpp) {
45         case 2:
46                 uc_priv->bpix = VIDEO_BPP16;
47                 break;
48         case 4:
49                 uc_priv->bpix = VIDEO_BPP32;
50                 break;
51         default:
52                 printf("bcm2835: unexpected bpp %d, pitch %d, width %d\n",
53                        bpp, pitch, w);
54                 uc_priv->bpix = VIDEO_BPP32;
55                 break;
56         }
57
58         uc_priv->xsize = w;
59         uc_priv->ysize = h;
60         plat->base = fb_base;
61         plat->size = fb_size;
62
63         return 0;
64 }
65
66 static const struct udevice_id bcm2835_video_ids[] = {
67         { .compatible = "brcm,bcm2835-hdmi" },
68         { .compatible = "brcm,bcm2711-hdmi0" },
69         { .compatible = "brcm,bcm2708-fb" },
70 #if !IS_ENABLED(CONFIG_VIDEO_DT_SIMPLEFB)
71         { .compatible = "simple-framebuffer" },
72 #endif
73         { }
74 };
75
76 U_BOOT_DRIVER(bcm2835_video) = {
77         .name   = "bcm2835_video",
78         .id     = UCLASS_VIDEO,
79         .of_match = bcm2835_video_ids,
80         .probe  = bcm2835_video_probe,
81 };
This page took 0.031415 seconds and 4 git commands to generate.