1 // SPDX-License-Identifier: GPL-2.0+
3 * Simplefb device tree support
6 * Stephen Warren <swarren@wwwdotorg.org>
10 #include <fdt_support.h>
11 #include <asm/global_data.h>
12 #include <linux/libfdt.h>
17 DECLARE_GLOBAL_DATA_PTR
;
19 static int fdt_simplefb_configure_node(void *blob
, int off
)
22 int bpix
; /* log2 of bits per pixel */
25 struct video_uc_plat
*plat
;
26 struct video_priv
*uc_priv
;
30 if (IS_ENABLED(CONFIG_SPL_VIDEO_HANDOFF
) && xpl_phase() > PHASE_SPL
) {
31 struct video_handoff
*ho
;
33 ho
= bloblist_find(BLOBLISTT_U_BOOT_VIDEO
, sizeof(*ho
));
35 return log_msg_ret("Missing video bloblist", -ENOENT
);
42 ret
= uclass_first_device_err(UCLASS_VIDEO
, &dev
);
45 uc_priv
= dev_get_uclass_priv(dev
);
46 plat
= dev_get_uclass_plat(dev
);
47 xsize
= uc_priv
->xsize
;
48 ysize
= uc_priv
->ysize
;
54 case 4: /* VIDEO_BPP16 */
57 case 5: /* VIDEO_BPP32 */
64 return fdt_setup_simplefb_node(blob
, off
, fb_base
, xsize
, ysize
,
65 xsize
* (1 << bpix
) / 8, name
);
68 int fdt_simplefb_add_node(void *blob
)
70 static const char compat
[] = "simple-framebuffer";
71 static const char disabled
[] = "disabled";
74 off
= fdt_add_subnode(blob
, 0, "framebuffer");
78 ret
= fdt_setprop(blob
, off
, "status", disabled
, sizeof(disabled
));
82 ret
= fdt_setprop(blob
, off
, "compatible", compat
, sizeof(compat
));
86 return fdt_simplefb_configure_node(blob
, off
);
90 * fdt_simplefb_enable_existing_node() - enable simple-framebuffer DT node
93 * Return: 0 on success, non-zero otherwise
95 static int fdt_simplefb_enable_existing_node(void *blob
)
99 off
= fdt_node_offset_by_compatible(blob
, -1, "simple-framebuffer");
103 return fdt_simplefb_configure_node(blob
, off
);
106 int fdt_simplefb_enable_and_mem_rsv(void *blob
)
110 /* nothing to do when video is not active */
111 if (!video_is_active())
114 ret
= fdt_simplefb_enable_existing_node(blob
);
118 return fdt_add_fb_mem_rsv(blob
);