1 // SPDX-License-Identifier: GPL-2.0+
3 * Simplefb device tree support
6 * Stephen Warren <swarren@wwwdotorg.org>
12 #include <fdt_support.h>
13 #include <linux/libfdt.h>
16 DECLARE_GLOBAL_DATA_PTR;
18 static int lcd_dt_simplefb_configure_node(void *blob, int off)
21 int bpix; /* log2 of bits per pixel */
24 #ifdef CONFIG_DM_VIDEO
25 struct video_uc_platdata *plat;
26 struct video_priv *uc_priv;
30 ret = uclass_first_device_err(UCLASS_VIDEO, &dev);
33 uc_priv = dev_get_uclass_priv(dev);
34 plat = dev_get_uclass_platdata(dev);
35 xsize = uc_priv->xsize;
36 ysize = uc_priv->ysize;
40 xsize = lcd_get_pixel_width();
41 ysize = lcd_get_pixel_height();
43 fb_base = gd->fb_base;
46 case 4: /* VIDEO_BPP16 */
49 case 5: /* VIDEO_BPP32 */
56 return fdt_setup_simplefb_node(blob, off, fb_base, xsize, ysize,
57 xsize * (1 << bpix) / 8, name);
60 int lcd_dt_simplefb_add_node(void *blob)
62 static const char compat[] = "simple-framebuffer";
63 static const char disabled[] = "disabled";
66 off = fdt_add_subnode(blob, 0, "framebuffer");
70 ret = fdt_setprop(blob, off, "status", disabled, sizeof(disabled));
74 ret = fdt_setprop(blob, off, "compatible", compat, sizeof(compat));
78 return lcd_dt_simplefb_configure_node(blob, off);
81 int lcd_dt_simplefb_enable_existing_node(void *blob)
85 off = fdt_node_offset_by_compatible(blob, -1, "simple-framebuffer");
89 return lcd_dt_simplefb_configure_node(blob, off);