blob: bc41090aed76483a790cfbcd0f30d4e662c94fc5 [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Stephen Warren6be3c9f2013-01-29 16:37:40 +00002/*
3 * (C) Copyright 2012 Stephen Warren
Stephen Warren6be3c9f2013-01-29 16:37:40 +00004 */
5
6#include <common.h>
Simon Glassea843b62017-04-05 16:23:44 -06007#include <dm.h>
8#include <video.h>
Stephen Warren6be3c9f2013-01-29 16:37:40 +00009#include <asm/arch/mbox.h>
Simon Glass2e4170b2017-04-05 16:23:40 -060010#include <asm/arch/msg.h>
Stephen Warren6be3c9f2013-01-29 16:37:40 +000011
Simon Glassea843b62017-04-05 16:23:44 -060012static int bcm2835_video_probe(struct udevice *dev)
Stephen Warren6be3c9f2013-01-29 16:37:40 +000013{
Simon Glassea843b62017-04-05 16:23:44 -060014 struct video_uc_platdata *plat = dev_get_uclass_platdata(dev);
15 struct video_priv *uc_priv = dev_get_uclass_priv(dev);
Stephen Warren6be3c9f2013-01-29 16:37:40 +000016 int ret;
Simon Glassea843b62017-04-05 16:23:44 -060017 int w, h, pitch;
Simon Glass7cac2fc2017-04-05 16:23:41 -060018 ulong fb_base, fb_size, fb_start, fb_end;
Stephen Warren6be3c9f2013-01-29 16:37:40 +000019
20 debug("bcm2835: Query resolution...\n");
Simon Glass2e4170b2017-04-05 16:23:40 -060021 ret = bcm2835_get_video_size(&w, &h);
Simon Glassea843b62017-04-05 16:23:44 -060022 if (ret)
23 return -EIO;
Stephen Warren6be3c9f2013-01-29 16:37:40 +000024
Stephen Warren6be3c9f2013-01-29 16:37:40 +000025 debug("bcm2835: Setting up display for %d x %d\n", w, h);
Simon Glass7cac2fc2017-04-05 16:23:41 -060026 ret = bcm2835_set_video_params(&w, &h, 32, BCM2835_MBOX_PIXEL_ORDER_RGB,
27 BCM2835_MBOX_ALPHA_MODE_IGNORED,
Simon Glassea843b62017-04-05 16:23:44 -060028 &fb_base, &fb_size, &pitch);
Stephen Warren6be3c9f2013-01-29 16:37:40 +000029
30 debug("bcm2835: Final resolution is %d x %d\n", w, h);
31
Alexander Graf99de2542016-03-24 10:31:11 +010032 /* Enable dcache for the frame buffer */
Simon Glass7cac2fc2017-04-05 16:23:41 -060033 fb_start = fb_base & ~(MMU_SECTION_SIZE - 1);
34 fb_end = fb_base + fb_size;
Alexander Graf99de2542016-03-24 10:31:11 +010035 fb_end = ALIGN(fb_end, 1 << MMU_SECTION_SHIFT);
36 mmu_set_region_dcache_behaviour(fb_start, fb_end - fb_start,
Simon Glass7cac2fc2017-04-05 16:23:41 -060037 DCACHE_WRITEBACK);
Simon Glassea843b62017-04-05 16:23:44 -060038 video_set_flush_dcache(dev, true);
39
40 uc_priv->xsize = w;
41 uc_priv->ysize = h;
42 uc_priv->bpix = VIDEO_BPP32;
43 plat->base = fb_base;
44 plat->size = fb_size;
45
46 return 0;
Stephen Warren6be3c9f2013-01-29 16:37:40 +000047}
48
Simon Glassea843b62017-04-05 16:23:44 -060049static const struct udevice_id bcm2835_video_ids[] = {
50 { .compatible = "brcm,bcm2835-hdmi" },
Emmanuel Vadot425daac2018-07-02 14:33:14 +020051 { .compatible = "brcm,bcm2708-fb" },
Simon Glassea843b62017-04-05 16:23:44 -060052 { }
53};
Andre Heider44376ef2013-11-09 11:07:53 +010054
Simon Glassea843b62017-04-05 16:23:44 -060055U_BOOT_DRIVER(bcm2835_video) = {
56 .name = "bcm2835_video",
57 .id = UCLASS_VIDEO,
58 .of_match = bcm2835_video_ids,
59 .probe = bcm2835_video_probe,
60};