2 * Simplefb device tree support
5 * Stephen Warren <swarren@wwwdotorg.org>
7 * SPDX-License-Identifier: GPL-2.0+
12 #include <fdt_support.h>
15 DECLARE_GLOBAL_DATA_PTR;
17 static int lcd_dt_simplefb_configure_node(void *blob, int off)
20 int bpix; /* log2 of bits per pixel */
24 xsize = lcd_get_pixel_width();
25 ysize = lcd_get_pixel_height();
27 fb_base = gd->fb_base;
29 case 4: /* VIDEO_BPP16 */
32 case 5: /* VIDEO_BPP32 */
39 return fdt_setup_simplefb_node(blob, off, fb_base, xsize, ysize,
40 xsize * (1 << bpix) / 8, name);
43 int lcd_dt_simplefb_add_node(void *blob)
45 static const char compat[] = "simple-framebuffer";
46 static const char disabled[] = "disabled";
49 off = fdt_add_subnode(blob, 0, "framebuffer");
53 ret = fdt_setprop(blob, off, "status", disabled, sizeof(disabled));
57 ret = fdt_setprop(blob, off, "compatible", compat, sizeof(compat));
61 return lcd_dt_simplefb_configure_node(blob, off);
64 int lcd_dt_simplefb_enable_existing_node(void *blob)
68 off = fdt_node_offset_by_compatible(blob, -1, "simple-framebuffer");
72 return lcd_dt_simplefb_configure_node(blob, off);