]> Git Repo - J-u-boot.git/blame - drivers/video/bcm2835.c
treewide: convert (void *)devfdt_get_addr() to dev_read_addr_ptr()
[J-u-boot.git] / drivers / video / bcm2835.c
CommitLineData
83d290c5 1// SPDX-License-Identifier: GPL-2.0+
6be3c9fc
SW
2/*
3 * (C) Copyright 2012 Stephen Warren
6be3c9fc
SW
4 */
5
6#include <common.h>
ea843b6d 7#include <dm.h>
f7ae49fc 8#include <log.h>
ea843b6d 9#include <video.h>
6be3c9fc 10#include <asm/arch/mbox.h>
2e4170b6 11#include <asm/arch/msg.h>
90526e9f 12#include <asm/cache.h>
6be3c9fc 13
ea843b6d 14static int bcm2835_video_probe(struct udevice *dev)
6be3c9fc 15{
ea843b6d
SG
16 struct video_uc_platdata *plat = dev_get_uclass_platdata(dev);
17 struct video_priv *uc_priv = dev_get_uclass_priv(dev);
6be3c9fc 18 int ret;
ea843b6d 19 int w, h, pitch;
7cac2fce 20 ulong fb_base, fb_size, fb_start, fb_end;
6be3c9fc
SW
21
22 debug("bcm2835: Query resolution...\n");
2e4170b6 23 ret = bcm2835_get_video_size(&w, &h);
970baf16 24 if (ret || w == 0 || h == 0)
ea843b6d 25 return -EIO;
6be3c9fc 26
6be3c9fc 27 debug("bcm2835: Setting up display for %d x %d\n", w, h);
7cac2fce
SG
28 ret = bcm2835_set_video_params(&w, &h, 32, BCM2835_MBOX_PIXEL_ORDER_RGB,
29 BCM2835_MBOX_ALPHA_MODE_IGNORED,
ea843b6d 30 &fb_base, &fb_size, &pitch);
970baf16
FV
31 if (ret)
32 return -EIO;
6be3c9fc
SW
33
34 debug("bcm2835: Final resolution is %d x %d\n", w, h);
35
99de254e 36 /* Enable dcache for the frame buffer */
7cac2fce
SG
37 fb_start = fb_base & ~(MMU_SECTION_SIZE - 1);
38 fb_end = fb_base + fb_size;
99de254e
AG
39 fb_end = ALIGN(fb_end, 1 << MMU_SECTION_SHIFT);
40 mmu_set_region_dcache_behaviour(fb_start, fb_end - fb_start,
7cac2fce 41 DCACHE_WRITEBACK);
ea843b6d 42 video_set_flush_dcache(dev, true);
6be3c9fc 43
ea843b6d
SG
44 uc_priv->xsize = w;
45 uc_priv->ysize = h;
46 uc_priv->bpix = VIDEO_BPP32;
47 plat->base = fb_base;
48 plat->size = fb_size;
44376eff 49
ea843b6d 50 return 0;
44376eff 51}
ea843b6d
SG
52
53static const struct udevice_id bcm2835_video_ids[] = {
54 { .compatible = "brcm,bcm2835-hdmi" },
425daac4 55 { .compatible = "brcm,bcm2708-fb" },
ea843b6d
SG
56 { }
57};
58
59U_BOOT_DRIVER(bcm2835_video) = {
60 .name = "bcm2835_video",
61 .id = UCLASS_VIDEO,
62 .of_match = bcm2835_video_ids,
63 .probe = bcm2835_video_probe,
64};
This page took 0.359335 seconds and 4 git commands to generate.