]> git.ipfire.org Git - people/ms/u-boot.git/blame - common/lcd_simplefb.c
scsi: move the partition initialization out of the scsi detection
[people/ms/u-boot.git] / common / lcd_simplefb.c
CommitLineData
033167c4
NK
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
15DECLARE_GLOBAL_DATA_PTR;
16
17static int lcd_dt_simplefb_configure_node(void *blob, int off)
18{
033167c4
NK
19 int vl_col = lcd_get_pixel_width();
20 int vl_row = lcd_get_pixel_height();
de934b41 21#if LCD_BPP == LCD_COLOR16
033167c4
NK
22 return fdt_setup_simplefb_node(blob, off, gd->fb_base, vl_col, vl_row,
23 vl_col * 2, "r5g6b5");
de934b41
HP
24#elif LCD_BPP == LCD_COLOR32
25 return fdt_setup_simplefb_node(blob, off, gd->fb_base, vl_col, vl_row,
26 vl_col * 4, "a8r8g8b8");
033167c4
NK
27#else
28 return -1;
29#endif
30}
31
32int lcd_dt_simplefb_add_node(void *blob)
33{
34 static const char compat[] = "simple-framebuffer";
35 static const char disabled[] = "disabled";
36 int off, ret;
37
38 off = fdt_add_subnode(blob, 0, "framebuffer");
39 if (off < 0)
40 return -1;
41
42 ret = fdt_setprop(blob, off, "status", disabled, sizeof(disabled));
43 if (ret < 0)
44 return -1;
45
46 ret = fdt_setprop(blob, off, "compatible", compat, sizeof(compat));
47 if (ret < 0)
48 return -1;
49
50 return lcd_dt_simplefb_configure_node(blob, off);
51}
52
53int lcd_dt_simplefb_enable_existing_node(void *blob)
54{
55 int off;
56
57 off = fdt_node_offset_by_compatible(blob, -1, "simple-framebuffer");
58 if (off < 0)
59 return -1;
60
61 return lcd_dt_simplefb_configure_node(blob, off);
62}