]> Git Repo - u-boot.git/blame - common/fdt_simplefb.c
common:autoboot:modify function parameters
[u-boot.git] / common / fdt_simplefb.c
CommitLineData
83d290c5 1// SPDX-License-Identifier: GPL-2.0+
033167c4
NK
2/*
3 * Simplefb device tree support
4 *
5 * (C) Copyright 2015
6 * Stephen Warren <[email protected]>
033167c4
NK
7 */
8
9#include <common.h>
d08e42a8 10#include <dm.h>
033167c4 11#include <fdt_support.h>
401d1c4f 12#include <asm/global_data.h>
b08c8c48 13#include <linux/libfdt.h>
d08e42a8 14#include <video.h>
033167c4
NK
15
16DECLARE_GLOBAL_DATA_PTR;
17
fded97ad 18static int fdt_simplefb_configure_node(void *blob, int off)
033167c4 19{
45261455
SG
20 int xsize, ysize;
21 int bpix; /* log2 of bits per pixel */
22 const char *name;
23 ulong fb_base;
8a8d24bd 24 struct video_uc_plat *plat;
d08e42a8
SG
25 struct video_priv *uc_priv;
26 struct udevice *dev;
27 int ret;
45261455 28
d08e42a8
SG
29 ret = uclass_first_device_err(UCLASS_VIDEO, &dev);
30 if (ret)
31 return ret;
32 uc_priv = dev_get_uclass_priv(dev);
caa4daa2 33 plat = dev_get_uclass_plat(dev);
d08e42a8
SG
34 xsize = uc_priv->xsize;
35 ysize = uc_priv->ysize;
36 bpix = uc_priv->bpix;
37 fb_base = plat->base;
45261455
SG
38 switch (bpix) {
39 case 4: /* VIDEO_BPP16 */
40 name = "r5g6b5";
41 break;
42 case 5: /* VIDEO_BPP32 */
43 name = "a8r8g8b8";
44 break;
45 default:
46 return -EINVAL;
47 }
48
49 return fdt_setup_simplefb_node(blob, off, fb_base, xsize, ysize,
50 xsize * (1 << bpix) / 8, name);
033167c4
NK
51}
52
fded97ad 53int fdt_simplefb_add_node(void *blob)
033167c4
NK
54{
55 static const char compat[] = "simple-framebuffer";
56 static const char disabled[] = "disabled";
57 int off, ret;
58
59 off = fdt_add_subnode(blob, 0, "framebuffer");
60 if (off < 0)
61 return -1;
62
63 ret = fdt_setprop(blob, off, "status", disabled, sizeof(disabled));
64 if (ret < 0)
65 return -1;
66
67 ret = fdt_setprop(blob, off, "compatible", compat, sizeof(compat));
68 if (ret < 0)
69 return -1;
70
fded97ad 71 return fdt_simplefb_configure_node(blob, off);
033167c4
NK
72}
73
fded97ad 74int fdt_simplefb_enable_existing_node(void *blob)
033167c4
NK
75{
76 int off;
77
78 off = fdt_node_offset_by_compatible(blob, -1, "simple-framebuffer");
79 if (off < 0)
80 return -1;
81
fded97ad 82 return fdt_simplefb_configure_node(blob, off);
033167c4 83}
77debf61 84
b86986c7 85#if CONFIG_IS_ENABLED(VIDEO)
77debf61
PD
86int fdt_simplefb_enable_and_mem_rsv(void *blob)
87{
88 struct fdt_memory mem;
89 int ret;
90
91 /* nothing to do when video is not active */
92 if (!video_is_active())
93 return 0;
94
95 ret = fdt_simplefb_enable_existing_node(blob);
96 if (ret)
97 return ret;
98
99 /* nothing to do when the frame buffer is not defined */
100 if (gd->video_bottom == gd->video_top)
101 return 0;
102
103 /* reserved with no-map tag the video buffer */
104 mem.start = gd->video_bottom;
105 mem.end = gd->video_top - 1;
106
107 return fdtdec_add_reserved_memory(blob, "framebuffer", &mem, NULL, 0, NULL,
108 FDTDEC_RESERVED_MEMORY_NO_MAP);
109}
110#endif
This page took 0.180106 seconds and 4 git commands to generate.