Tom Rini | 83d290c | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Stephen Warren | 6be3c9f | 2013-01-29 16:37:40 +0000 | [diff] [blame] | 2 | /* |
| 3 | * (C) Copyright 2012 Stephen Warren |
Stephen Warren | 6be3c9f | 2013-01-29 16:37:40 +0000 | [diff] [blame] | 4 | */ |
| 5 | |
| 6 | #include <common.h> |
Simon Glass | ea843b6 | 2017-04-05 16:23:44 -0600 | [diff] [blame] | 7 | #include <dm.h> |
| 8 | #include <video.h> |
Stephen Warren | 6be3c9f | 2013-01-29 16:37:40 +0000 | [diff] [blame] | 9 | #include <asm/arch/mbox.h> |
Simon Glass | 2e4170b | 2017-04-05 16:23:40 -0600 | [diff] [blame] | 10 | #include <asm/arch/msg.h> |
Stephen Warren | 6be3c9f | 2013-01-29 16:37:40 +0000 | [diff] [blame] | 11 | |
Simon Glass | ea843b6 | 2017-04-05 16:23:44 -0600 | [diff] [blame] | 12 | static int bcm2835_video_probe(struct udevice *dev) |
Stephen Warren | 6be3c9f | 2013-01-29 16:37:40 +0000 | [diff] [blame] | 13 | { |
Simon Glass | ea843b6 | 2017-04-05 16:23:44 -0600 | [diff] [blame] | 14 | struct video_uc_platdata *plat = dev_get_uclass_platdata(dev); |
| 15 | struct video_priv *uc_priv = dev_get_uclass_priv(dev); |
Stephen Warren | 6be3c9f | 2013-01-29 16:37:40 +0000 | [diff] [blame] | 16 | int ret; |
Simon Glass | ea843b6 | 2017-04-05 16:23:44 -0600 | [diff] [blame] | 17 | int w, h, pitch; |
Simon Glass | 7cac2fc | 2017-04-05 16:23:41 -0600 | [diff] [blame] | 18 | ulong fb_base, fb_size, fb_start, fb_end; |
Stephen Warren | 6be3c9f | 2013-01-29 16:37:40 +0000 | [diff] [blame] | 19 | |
| 20 | debug("bcm2835: Query resolution...\n"); |
Simon Glass | 2e4170b | 2017-04-05 16:23:40 -0600 | [diff] [blame] | 21 | ret = bcm2835_get_video_size(&w, &h); |
Simon Glass | ea843b6 | 2017-04-05 16:23:44 -0600 | [diff] [blame] | 22 | if (ret) |
| 23 | return -EIO; |
Stephen Warren | 6be3c9f | 2013-01-29 16:37:40 +0000 | [diff] [blame] | 24 | |
Stephen Warren | 6be3c9f | 2013-01-29 16:37:40 +0000 | [diff] [blame] | 25 | debug("bcm2835: Setting up display for %d x %d\n", w, h); |
Simon Glass | 7cac2fc | 2017-04-05 16:23:41 -0600 | [diff] [blame] | 26 | ret = bcm2835_set_video_params(&w, &h, 32, BCM2835_MBOX_PIXEL_ORDER_RGB, |
| 27 | BCM2835_MBOX_ALPHA_MODE_IGNORED, |
Simon Glass | ea843b6 | 2017-04-05 16:23:44 -0600 | [diff] [blame] | 28 | &fb_base, &fb_size, &pitch); |
Stephen Warren | 6be3c9f | 2013-01-29 16:37:40 +0000 | [diff] [blame] | 29 | |
| 30 | debug("bcm2835: Final resolution is %d x %d\n", w, h); |
| 31 | |
Alexander Graf | 99de254 | 2016-03-24 10:31:11 +0100 | [diff] [blame] | 32 | /* Enable dcache for the frame buffer */ |
Simon Glass | 7cac2fc | 2017-04-05 16:23:41 -0600 | [diff] [blame] | 33 | fb_start = fb_base & ~(MMU_SECTION_SIZE - 1); |
| 34 | fb_end = fb_base + fb_size; |
Alexander Graf | 99de254 | 2016-03-24 10:31:11 +0100 | [diff] [blame] | 35 | fb_end = ALIGN(fb_end, 1 << MMU_SECTION_SHIFT); |
| 36 | mmu_set_region_dcache_behaviour(fb_start, fb_end - fb_start, |
Simon Glass | 7cac2fc | 2017-04-05 16:23:41 -0600 | [diff] [blame] | 37 | DCACHE_WRITEBACK); |
Simon Glass | ea843b6 | 2017-04-05 16:23:44 -0600 | [diff] [blame] | 38 | 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 Warren | 6be3c9f | 2013-01-29 16:37:40 +0000 | [diff] [blame] | 47 | } |
| 48 | |
Simon Glass | ea843b6 | 2017-04-05 16:23:44 -0600 | [diff] [blame] | 49 | static const struct udevice_id bcm2835_video_ids[] = { |
| 50 | { .compatible = "brcm,bcm2835-hdmi" }, |
Emmanuel Vadot | 425daac | 2018-07-02 14:33:14 +0200 | [diff] [blame] | 51 | { .compatible = "brcm,bcm2708-fb" }, |
Simon Glass | ea843b6 | 2017-04-05 16:23:44 -0600 | [diff] [blame] | 52 | { } |
| 53 | }; |
Andre Heider | 44376ef | 2013-11-09 11:07:53 +0100 | [diff] [blame] | 54 | |
Simon Glass | ea843b6 | 2017-04-05 16:23:44 -0600 | [diff] [blame] | 55 | U_BOOT_DRIVER(bcm2835_video) = { |
| 56 | .name = "bcm2835_video", |
| 57 | .id = UCLASS_VIDEO, |
| 58 | .of_match = bcm2835_video_ids, |
| 59 | .probe = bcm2835_video_probe, |
| 60 | }; |