1 // SPDX-License-Identifier: GPL-2.0+
3 * (C) Copyright 2017 Rob Clark
9 #include <fdt_support.h>
12 #include <asm/global_data.h>
14 static int simple_video_probe(struct udevice *dev)
16 struct video_uc_plat *plat = dev_get_uclass_plat(dev);
17 struct video_priv *uc_priv = dev_get_uclass_priv(dev);
18 const void *blob = gd->fdt_blob;
19 const int node = dev_of_offset(dev);
24 base = fdtdec_get_addr_size_auto_parent(blob, dev_of_offset(dev->parent),
25 node, "reg", 0, &size, false);
26 if (base == FDT_ADDR_T_NONE) {
27 debug("%s: Failed to decode memory region\n", __func__);
31 debug("%s: base=%llx, size=%llu\n", __func__, base, size);
34 * TODO is there some way to reserve the framebuffer
35 * region so it isn't clobbered?
40 video_set_flush_dcache(dev, true);
42 debug("%s: Query resolution...\n", __func__);
44 uc_priv->xsize = fdtdec_get_uint(blob, node, "width", 0);
45 uc_priv->ysize = fdtdec_get_uint(blob, node, "height", 0);
48 format = fdt_getprop(blob, node, "format", NULL);
49 debug("%s: %dx%d@%s\n", __func__, uc_priv->xsize, uc_priv->ysize, format);
51 if (strcmp(format, "r5g6b5") == 0) {
52 uc_priv->bpix = VIDEO_BPP16;
53 } else if (strcmp(format, "a8b8g8r8") == 0 ||
54 strcmp(format, "x8b8g8r8") == 0) {
55 uc_priv->bpix = VIDEO_BPP32;
56 uc_priv->format = VIDEO_X8B8G8R8;
57 } else if (strcmp(format, "a8r8g8b8") == 0 ||
58 strcmp(format, "x8r8g8b8") == 0) {
59 uc_priv->bpix = VIDEO_BPP32;
60 uc_priv->format = VIDEO_X8R8G8B8;
61 } else if (strcmp(format, "a2r10g10b10") == 0 ||
62 strcmp(format, "x2r10g10b10") == 0) {
63 uc_priv->bpix = VIDEO_BPP32;
64 uc_priv->format = VIDEO_X2R10G10B10;
66 printf("%s: invalid format: %s\n", __func__, format);
73 static const struct udevice_id simple_video_ids[] = {
74 { .compatible = "simple-framebuffer" },
78 U_BOOT_DRIVER(simple_video) = {
79 .name = "simple_video",
81 .of_match = simple_video_ids,
82 .probe = simple_video_probe,