]> git.kernelconcepts.de Git - karo-tx-uboot.git/blob - common/lcd_simplefb.c
spl: spl_mmc: Clearer structure in spl_mmc_load_image and cosmetics
[karo-tx-uboot.git] / common / lcd_simplefb.c
1 /*
2  * Simplefb device tree support
3  *
4  * (C) Copyright 2015
5  * Stephen Warren <swarren@wwwdotorg.org>
6  *
7  * SPDX-License-Identifier:     GPL-2.0+
8  */
9
10 #include <common.h>
11 #include <lcd.h>
12 #include <fdt_support.h>
13 #include <libfdt.h>
14
15 DECLARE_GLOBAL_DATA_PTR;
16
17 static int lcd_dt_simplefb_configure_node(void *blob, int off)
18 {
19 #if LCD_BPP == LCD_COLOR16
20         int vl_col = lcd_get_pixel_width();
21         int vl_row = lcd_get_pixel_height();
22         return fdt_setup_simplefb_node(blob, off, gd->fb_base, vl_col, vl_row,
23                                        vl_col * 2, "r5g6b5");
24 #else
25         return -1;
26 #endif
27 }
28
29 int lcd_dt_simplefb_add_node(void *blob)
30 {
31         static const char compat[] = "simple-framebuffer";
32         static const char disabled[] = "disabled";
33         int off, ret;
34
35         off = fdt_add_subnode(blob, 0, "framebuffer");
36         if (off < 0)
37                 return -1;
38
39         ret = fdt_setprop(blob, off, "status", disabled, sizeof(disabled));
40         if (ret < 0)
41                 return -1;
42
43         ret = fdt_setprop(blob, off, "compatible", compat, sizeof(compat));
44         if (ret < 0)
45                 return -1;
46
47         return lcd_dt_simplefb_configure_node(blob, off);
48 }
49
50 int lcd_dt_simplefb_enable_existing_node(void *blob)
51 {
52         int off;
53
54         off = fdt_node_offset_by_compatible(blob, -1, "simple-framebuffer");
55         if (off < 0)
56                 return -1;
57
58         return lcd_dt_simplefb_configure_node(blob, off);
59 }