blob: 952ef5966118ce4f1ea90149120fc19bad93942b [file] [log] [blame]
Stephen Warren6be3c9f2013-01-29 16:37:40 +00001/*
2 * (C) Copyright 2012 Stephen Warren
3 *
Wolfgang Denk1a459662013-07-08 09:37:19 +02004 * SPDX-License-Identifier: GPL-2.0+
Stephen Warren6be3c9f2013-01-29 16:37:40 +00005 */
6
7#include <common.h>
Simon Glassea843b62017-04-05 16:23:44 -06008#include <dm.h>
9#include <video.h>
Stephen Warren6be3c9f2013-01-29 16:37:40 +000010#include <asm/arch/mbox.h>
Simon Glass2e4170b2017-04-05 16:23:40 -060011#include <asm/arch/msg.h>
Stephen Warren6be3c9f2013-01-29 16:37:40 +000012
Simon Glassea843b62017-04-05 16:23:44 -060013static int bcm2835_video_probe(struct udevice *dev)
Stephen Warren6be3c9f2013-01-29 16:37:40 +000014{
Simon Glassea843b62017-04-05 16:23:44 -060015 struct video_uc_platdata *plat = dev_get_uclass_platdata(dev);
16 struct video_priv *uc_priv = dev_get_uclass_priv(dev);
Stephen Warren6be3c9f2013-01-29 16:37:40 +000017 int ret;
Simon Glassea843b62017-04-05 16:23:44 -060018 int w, h, pitch;
Simon Glass7cac2fc2017-04-05 16:23:41 -060019 ulong fb_base, fb_size, fb_start, fb_end;
Stephen Warren6be3c9f2013-01-29 16:37:40 +000020
21 debug("bcm2835: Query resolution...\n");
Simon Glass2e4170b2017-04-05 16:23:40 -060022 ret = bcm2835_get_video_size(&w, &h);
Simon Glassea843b62017-04-05 16:23:44 -060023 if (ret)
24 return -EIO;
Stephen Warren6be3c9f2013-01-29 16:37:40 +000025
Stephen Warren6be3c9f2013-01-29 16:37:40 +000026 debug("bcm2835: Setting up display for %d x %d\n", w, h);
Simon Glass7cac2fc2017-04-05 16:23:41 -060027 ret = bcm2835_set_video_params(&w, &h, 32, BCM2835_MBOX_PIXEL_ORDER_RGB,
28 BCM2835_MBOX_ALPHA_MODE_IGNORED,
Simon Glassea843b62017-04-05 16:23:44 -060029 &fb_base, &fb_size, &pitch);
Stephen Warren6be3c9f2013-01-29 16:37:40 +000030
31 debug("bcm2835: Final resolution is %d x %d\n", w, h);
32
Alexander Graf99de2542016-03-24 10:31:11 +010033 /* Enable dcache for the frame buffer */
Simon Glass7cac2fc2017-04-05 16:23:41 -060034 fb_start = fb_base & ~(MMU_SECTION_SIZE - 1);
35 fb_end = fb_base + fb_size;
Alexander Graf99de2542016-03-24 10:31:11 +010036 fb_end = ALIGN(fb_end, 1 << MMU_SECTION_SHIFT);
37 mmu_set_region_dcache_behaviour(fb_start, fb_end - fb_start,
Simon Glass7cac2fc2017-04-05 16:23:41 -060038 DCACHE_WRITEBACK);
Simon Glassea843b62017-04-05 16:23:44 -060039 video_set_flush_dcache(dev, true);
40
41 uc_priv->xsize = w;
42 uc_priv->ysize = h;
43 uc_priv->bpix = VIDEO_BPP32;
44 plat->base = fb_base;
45 plat->size = fb_size;
46
47 return 0;
Stephen Warren6be3c9f2013-01-29 16:37:40 +000048}
49
Simon Glassea843b62017-04-05 16:23:44 -060050static const struct udevice_id bcm2835_video_ids[] = {
51 { .compatible = "brcm,bcm2835-hdmi" },
52 { }
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};