2018-05-07 05:58:06 +08:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
2013-01-30 00:37:40 +08:00
|
|
|
/*
|
|
|
|
* (C) Copyright 2012 Stephen Warren
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
2017-04-06 06:23:44 +08:00
|
|
|
#include <dm.h>
|
2020-05-11 01:40:05 +08:00
|
|
|
#include <log.h>
|
2017-04-06 06:23:44 +08:00
|
|
|
#include <video.h>
|
2013-01-30 00:37:40 +08:00
|
|
|
#include <asm/arch/mbox.h>
|
2017-04-06 06:23:40 +08:00
|
|
|
#include <asm/arch/msg.h>
|
2020-05-11 01:39:56 +08:00
|
|
|
#include <asm/cache.h>
|
2013-01-30 00:37:40 +08:00
|
|
|
|
2017-04-06 06:23:44 +08:00
|
|
|
static int bcm2835_video_probe(struct udevice *dev)
|
2013-01-30 00:37:40 +08:00
|
|
|
{
|
2020-12-04 07:55:23 +08:00
|
|
|
struct video_uc_plat *plat = dev_get_uclass_plat(dev);
|
2017-04-06 06:23:44 +08:00
|
|
|
struct video_priv *uc_priv = dev_get_uclass_priv(dev);
|
2013-01-30 00:37:40 +08:00
|
|
|
int ret;
|
2017-04-06 06:23:44 +08:00
|
|
|
int w, h, pitch;
|
2017-04-06 06:23:41 +08:00
|
|
|
ulong fb_base, fb_size, fb_start, fb_end;
|
2013-01-30 00:37:40 +08:00
|
|
|
|
|
|
|
debug("bcm2835: Query resolution...\n");
|
2017-04-06 06:23:40 +08:00
|
|
|
ret = bcm2835_get_video_size(&w, &h);
|
2019-07-11 22:56:24 +08:00
|
|
|
if (ret || w == 0 || h == 0)
|
2017-04-06 06:23:44 +08:00
|
|
|
return -EIO;
|
2013-01-30 00:37:40 +08:00
|
|
|
|
|
|
|
debug("bcm2835: Setting up display for %d x %d\n", w, h);
|
2017-04-06 06:23:41 +08:00
|
|
|
ret = bcm2835_set_video_params(&w, &h, 32, BCM2835_MBOX_PIXEL_ORDER_RGB,
|
|
|
|
BCM2835_MBOX_ALPHA_MODE_IGNORED,
|
2017-04-06 06:23:44 +08:00
|
|
|
&fb_base, &fb_size, &pitch);
|
2019-07-11 22:56:24 +08:00
|
|
|
if (ret)
|
|
|
|
return -EIO;
|
2013-01-30 00:37:40 +08:00
|
|
|
|
|
|
|
debug("bcm2835: Final resolution is %d x %d\n", w, h);
|
|
|
|
|
2016-03-24 17:31:11 +08:00
|
|
|
/* Enable dcache for the frame buffer */
|
2017-04-06 06:23:41 +08:00
|
|
|
fb_start = fb_base & ~(MMU_SECTION_SIZE - 1);
|
|
|
|
fb_end = fb_base + fb_size;
|
2016-03-24 17:31:11 +08:00
|
|
|
fb_end = ALIGN(fb_end, 1 << MMU_SECTION_SHIFT);
|
|
|
|
mmu_set_region_dcache_behaviour(fb_start, fb_end - fb_start,
|
2017-04-06 06:23:41 +08:00
|
|
|
DCACHE_WRITEBACK);
|
2017-04-06 06:23:44 +08:00
|
|
|
video_set_flush_dcache(dev, true);
|
2013-01-30 00:37:40 +08:00
|
|
|
|
2017-04-06 06:23:44 +08:00
|
|
|
uc_priv->xsize = w;
|
|
|
|
uc_priv->ysize = h;
|
|
|
|
uc_priv->bpix = VIDEO_BPP32;
|
|
|
|
plat->base = fb_base;
|
|
|
|
plat->size = fb_size;
|
2013-11-09 18:07:53 +08:00
|
|
|
|
2017-04-06 06:23:44 +08:00
|
|
|
return 0;
|
2013-11-09 18:07:53 +08:00
|
|
|
}
|
2017-04-06 06:23:44 +08:00
|
|
|
|
|
|
|
static const struct udevice_id bcm2835_video_ids[] = {
|
|
|
|
{ .compatible = "brcm,bcm2835-hdmi" },
|
2021-01-12 20:55:31 +08:00
|
|
|
{ .compatible = "brcm,bcm2711-hdmi0" },
|
2018-07-02 20:33:14 +08:00
|
|
|
{ .compatible = "brcm,bcm2708-fb" },
|
2017-04-06 06:23:44 +08:00
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
|
|
|
U_BOOT_DRIVER(bcm2835_video) = {
|
|
|
|
.name = "bcm2835_video",
|
|
|
|
.id = UCLASS_VIDEO,
|
|
|
|
.of_match = bcm2835_video_ids,
|
|
|
|
.probe = bcm2835_video_probe,
|
|
|
|
};
|