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