Skip to contentSkip to conversation

lcd: add functions to set up simplefb device tree

PATCH New Stephen Warren 2 participants 6 messages May 28, 2013 – Jun 5, 2013 Broadcom BCM2711/BCM2835 Arm architecture

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/2 lcd: add functions to set up simplefb device tree

simple-framebuffer is a new device tree binding that describes a pre- configured frame-buffer memory region and its format. The Linux kernel contains a driver that supports this binding. Implement functions to create a DT node (or fill in an existing node) with parameters that describe the framebuffer format that U-Boot is using.

This will be immediately used by the Raspberry Pi board in U-Boot, and likely will be used by the Samsung ARM ChromeBook support soon too. It could well be used by many other boards (e.g. Tegra boards with built-in LCD panels, which aren't yet supported by the Linux kernel).

---
v2: Add binding doc, remove ifdefs from lcd.h

---
 common/lcd.c                                       |   87 ++++++++++++++++++++
 .../video/simple-framebuffer.txt                   |   25 ++++++
 include/lcd.h                                      |    3 +
 3 files changed, 115 insertions(+)
 create mode 100644 doc/device-tree-bindings/video/simple-framebuffer.txt
common/lcd.c +87 -0
index edae835..3a60484 100644
@@ -57,6 +57,10 @@
 #include <atmel_lcdc.h>
 #endif
 
+#if defined(CONFIG_LCD_DT_SIMPLEFB)
+#include <libfdt.h>
+#endif
+
 /************************************************************************/
 /* ** FONT DATA								*/
 /************************************************************************/
@@ -1182,3 +1186,86 @@ int lcd_get_screen_columns(void)
 {
 	return CONSOLE_COLS;
 }
+
+#if defined(CONFIG_LCD_DT_SIMPLEFB)
+static int lcd_dt_simplefb_configure_node(void *blob, int off)
+{
+	u32 stride;
+	fdt32_t cells[2];
+	int ret;
+	const char format[] =
+#if LCD_BPP == LCD_COLOR16
+		"r5g6b5";
+#else
+		"";
+#endif
+
+	if (!format[0])
+		return -1;
+
+	stride = panel_info.vl_col * 2;
+
+	cells[0] = cpu_to_fdt32(gd->fb_base);
+	cells[1] = cpu_to_fdt32(stride * panel_info.vl_row);
+	ret = fdt_setprop(blob, off, "reg", cells, sizeof(cells[0]) * 2);
+	if (ret < 0)
+		return -1;
+
+	cells[0] = cpu_to_fdt32(panel_info.vl_col);
+	ret = fdt_setprop(blob, off, "width", cells, sizeof(cells[0]));
+	if (ret < 0)
+		return -1;
+
+	cells[0] = cpu_to_fdt32(panel_info.vl_row);
+	ret = fdt_setprop(blob, off, "height", cells, sizeof(cells[0]));
+	if (ret < 0)
+		return -1;
+
+	cells[0] = cpu_to_fdt32(stride);
+	ret = fdt_setprop(blob, off, "stride", cells, sizeof(cells[0]));
+	if (ret < 0)
+		return -1;
+
+	ret = fdt_setprop(blob, off, "format", format, strlen(format) + 1);
+	if (ret < 0)
+		return -1;
+
+	ret = fdt_delprop(blob, off, "status");
+	if (ret < 0)
+		return -1;
+
+	return 0;
+}
+
+int lcd_dt_simplefb_add_node(void *blob)
+{
+	const char compat[] = "simple-framebuffer";
+	const char disabled[] = "disabled";
+	int off, ret;
+
+	off = fdt_add_subnode(blob, 0, "framebuffer");
+	if (off < 0)
+		return -1;
+
+	ret = fdt_setprop(blob, off, "status", disabled, sizeof(disabled));
+	if (ret < 0)
+		return -1;
+
+	ret = fdt_setprop(blob, off, "compatible", compat, sizeof(compat));
+	if (ret < 0)
+		return -1;
+
+	return lcd_dt_simplefb_configure_node(blob, off);
+}
+
+int lcd_dt_simplefb_enable_existing_node(void *blob)
+{
+	int off;
+
+	off = fdt_node_offset_by_compatible(blob, -1, "simple-framebuffer");
+	if (off < 0)
+		return -1;
+
+	return lcd_dt_simplefb_configure_node(blob, off);
+}
+#endif
doc/device-tree-bindings/video/simple-framebuffer.txt new file +25 -0
new file mode 100644
index 0000000..3ea4605
@@ -0,0 +1,25 @@
+Simple Framebuffer
+
+A simple frame-buffer describes a raw memory region that may be rendered to,
+with the assumption that the display hardware has already been set up to scan
+out from that buffer.
+
+Required properties:
+- compatible: "simple-framebuffer"
+- reg: Should contain the location and size of the framebuffer memory.
+- width: The width of the framebuffer in pixels.
+- height: The height of the framebuffer in pixels.
+- stride: The number of bytes in each line of the framebuffer.
+- format: The format of the framebuffer surface. Valid values are:
+  - r5g6b5 (16-bit pixels, d[15:11]=r, d[10:5]=g, d[4:0]=b).
+
+Example:
+
+	framebuffer {
+		compatible = "simple-framebuffer";
+		reg = <0x1d385000 (1600 * 1200 * 2)>;
+		width = <1600>;
+		height = <1200>;
+		stride = <(1600 * 2)>;
+		format = "r5g6b5";
+	};
include/lcd.h +3 -0
index c6e7fc5..30225ed 100644
@@ -324,6 +324,9 @@ void lcd_show_board_info(void);
 /* Return the size of the LCD frame buffer, and the line length */
 int lcd_get_size(int *line_length);
 
+int lcd_dt_simplefb_add_node(void *blob);
+int lcd_dt_simplefb_enable_existing_node(void *blob);
+
 /************************************************************************/
 /* ** BITMAP DISPLAY SUPPORT						*/
 /************************************************************************/
Signature · 1 line
1.7.10.4
#1 lore raw

PATCH v2 1/2 lcd: add functions to set up simplefb device tree

Quoted 10 lines · Stephen Warren

simple-framebuffer is a new device tree binding that describes a pre- configured frame-buffer memory region and its format. The Linux kernel contains a driver that supports this binding. Implement functions to create a DT node (or fill in an existing node) with parameters that describe the framebuffer format that U-Boot is using.

This will be immediately used by the Raspberry Pi board in U-Boot, and likely will be used by the Samsung ARM ChromeBook support soon too. It could well be used by many other boards (e.g. Tegra boards with built-in LCD panels, which aren't yet supported by the Linux kernel).

Anatolij, do these patches look good? Are you waiting for Albert to ack patch 2 in order to take it through the LCD tree? Thanks.

#2 lore raw

PATCH v2 1/2 lcd: add functions to set up simplefb device tree

On Tue, 04 Jun 2013 21:38:19 -0600
Stephen Warren <[email protected]> wrote:
...

Quoted 2 lines

Anatolij, do these patches look good? Are you waiting for Albert to ack patch 2 in order to take it through the LCD tree? Thanks.

these patches look good, I'll queue them. Sorry for delay.

Thanks,

Anatolij

#3 lore raw

PATCH v2 2/2 ARM: bcm2835: add simplefb DT node during bootz/m

In reply to Stephen Warren

Add a DT simple-framebuffer node to DT when booting the Linux kernel. This will allow the kernel to inherit the framebuffer configuration from U-Boot, and display a graphical boot console, and even run a full SW- rendered X server.

---
 board/raspberrypi/rpi_b/rpi_b.c |   14 +++++++++++++-
 include/configs/rpi_b.h         |    2 ++
 2 files changed, 15 insertions(+), 1 deletion(-)
board/raspberrypi/rpi_b/rpi_b.c +13 -1
index 6b3e095..16d442a 100644
@@ -1,5 +1,5 @@
 /*
- * (C) Copyright 2012 Stephen Warren
+ * (C) Copyright 2012-2013 Stephen Warren
  *
  * See file CREDITS for list of people who contributed to this
  * project.
@@ -15,6 +15,8 @@
  */
 
 #include <common.h>
+#include <config.h>
+#include <lcd.h>
 #include <asm/arch/mbox.h>
 #include <asm/arch/sdhci.h>
 #include <asm/global_data.h>
@@ -77,3 +79,13 @@ int board_mmc_init(void)
 	return bcm2835_sdhci_init(BCM2835_SDHCI_BASE,
 				  msg_clk->get_clock_rate.body.resp.rate_hz);
 }
+
+void ft_board_setup(void *blob, bd_t *bd)
+{
+	/*
+	 * For now, we simply always add the simplefb DT node. Later, we
+	 * should be more intelligent, and e.g. only do this if no enabled DT
+	 * node exists for the "real" graphics driver.
+	 */
+	lcd_dt_simplefb_add_node(blob);
+}
include/configs/rpi_b.h +2 -0
index c18b35b..216c6cb 100644
@@ -61,6 +61,7 @@
 #define CONFIG_BCM2835_GPIO
 /* LCD */
 #define CONFIG_LCD
+#define CONFIG_LCD_DT_SIMPLEFB
 #define LCD_BPP				LCD_COLOR16
 /*
  * Prevent allocation of RAM for FB; the real FB address is queried
@@ -175,6 +176,7 @@
 
 /* Device tree support for bootm/bootz */
 #define CONFIG_OF_LIBFDT
+#define CONFIG_OF_BOARD_SETUP
 /* ATAGs support for bootm/bootz */
 #define CONFIG_SETUP_MEMORY_TAGS
 #define CONFIG_CMDLINE_TAG
Signature · 1 line
1.7.10.4
#4 lore raw

PATCH v2 2/2 ARM: bcm2835: add simplefb DT node during bootz/m

Quoted 11 lines · On Mon, 27 May 2013 22:31:18 -0600 Stephen Warren <[email protected]> wrote:

Add a DT simple-framebuffer node to DT when booting the Linux kernel. This will allow the kernel to inherit the framebuffer configuration from U-Boot, and display a graphical boot console, and even run a full SW- rendered X server.

---
 board/raspberrypi/rpi_b/rpi_b.c |   14 +++++++++++++-
 include/configs/rpi_b.h         |    2 ++
 2 files changed, 15 insertions(+), 1 deletion(-)

Applied to u-boot-video/master. Thanks!

Anatolij

#5 lore raw

PATCH v2 1/2 lcd: add functions to set up simplefb device tree

In reply to Stephen Warren
Quoted 13 lines · On Mon, 27 May 2013 22:31:17 -0600 Stephen Warren <[email protected]> wrote:

simple-framebuffer is a new device tree binding that describes a pre- configured frame-buffer memory region and its format. The Linux kernel contains a driver that supports this binding. Implement functions to create a DT node (or fill in an existing node) with parameters that describe the framebuffer format that U-Boot is using.

This will be immediately used by the Raspberry Pi board in U-Boot, and likely will be used by the Samsung ARM ChromeBook support soon too. It could well be used by many other boards (e.g. Tegra boards with built-in LCD panels, which aren't yet supported by the Linux kernel).

Quoted 8 lines

---
v2: Add binding doc, remove ifdefs from lcd.h

---
 common/lcd.c                                       |   87 ++++++++++++++++++++
 .../video/simple-framebuffer.txt                   |   25 ++++++
 include/lcd.h                                      |    3 +
 3 files changed, 115 insertions(+)
 create mode 100644 doc/device-tree-bindings/video/simple-framebuffer.txt

Applied to u-boot-video/master. Thanks!

Anatolij