Skip to contentSkip to conversation

sunxi: video: Add simplefb support

PATCH New Hans de Goede 4 participants 13 messages Nov 19, 2014 – Nov 20, 2014

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

v5 cover sunxi: video: Add simplefb support

Hi All,

Here is v5 of my sunxi simplefb support set.

Changes since v4:
-Make sunxi_simplefb_setup return error codes
-Add a patch to make lcd_dt_simplefb_configure_node use the new
fdt_setup_simplefb_node helper (only compile tested!)

Changes since v3:
-Added a fdt_setup_simplefb_node() helper function (new patch) -Changed how u-boot finds the pre-populated simplefb node to use a
compatible string

Changes since v2:
-Detect and handle address and size #cells

Changes since v1:
-Use fdt_setprop_string for strings

Simon, even though -rc1 is out I would still like to get this upstream for v2015.01 if possible. This is in essence just refactoring of code posted well before -rc1. If I can get your ack on both the fdt_setup_simplefb_node and the lcd patches, then I can take them upstream through the sunxi tree, or if you plan to do a pull-req soon anyways, you can take them upstream through your tree, and I'll wait for that.

Thanks & Regards,

Hans

#1 lore raw

PATCH v5 1/3 fdt_support: Add a fdt_setup_simplefb_node helper function

Add a generic helper to fill and enable simplefb nodes.

The first user of this will be the sunxi display code.

lcd_dt_simplefb_configure_node is also a good candidate to be converted to use this, but that requires someone to run some tests first, as lcd_dt_simplefb_configure_node does not honor #address-cells and #size-cells, but simply assumes 1 and 1 for both.

---
 common/fdt_support.c  | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++
 include/fdt_support.h |  3 +++
 2 files changed, 68 insertions(+)
common/fdt_support.c +65 -0
index 3f64156..0ffa711 100644
@@ -1523,3 +1523,68 @@ int fdt_read_range(void *fdt, int node, int n, uint64_t *child_addr,
 
 	return 0;
 }
+
+/**
+ * fdt_setup_simplefb_node - Fill and enable a simplefb node
+ *
+ * @fdt: ptr to device tree
+ * @node: offset of the simplefb node
+ * @base_address: framebuffer base address
+ * @width: width in pixels
+ * @height: height in pixels
+ * @stride: bytes per line
+ * @format: pixel format string
+ *
+ * Convenience function to fill and enable a simplefb node.
+ */
+int fdt_setup_simplefb_node(void *fdt, int node, u64 base_address, u32 width,
+			    u32 height, u32 stride, const char *format)
+{
+	char name[32];
+	fdt32_t cells[4];
+	int i, addrc, sizec, ret;
+
+	of_bus_default_count_cells(fdt, fdt_parent_offset(fdt, node),
+				   &addrc, &sizec);
+	i = 0;
+	if (addrc == 2)
+		cells[i++] = cpu_to_fdt32(base_address >> 32);
+	cells[i++] = cpu_to_fdt32(base_address);
+	if (sizec == 2)
+		cells[i++] = 0;
+	cells[i++] = cpu_to_fdt32(height * stride);
+
+	ret = fdt_setprop(fdt, node, "reg", cells, sizeof(cells[0]) * i);
+	if (ret < 0)
+		return ret;
+
+	snprintf(name, sizeof(name), "framebuffer@%llx", base_address);
+	ret = fdt_set_name(fdt, node, name);
+	if (ret < 0)
+		return ret;
+
+	cells[0] = cpu_to_fdt32(width);
+	ret = fdt_setprop(fdt, node, "width", cells, sizeof(cells[0]));
+	if (ret < 0)
+		return ret;
+
+	cells[0] = cpu_to_fdt32(height);
+	ret = fdt_setprop(fdt, node, "height", cells, sizeof(cells[0]));
+	if (ret < 0)
+		return ret;
+
+	cells[0] = cpu_to_fdt32(stride);
+	ret = fdt_setprop(fdt, node, "stride", cells, sizeof(cells[0]));
+	if (ret < 0)
+		return ret;
+
+	ret = fdt_setprop_string(fdt, node, "format", format);
+	if (ret < 0)
+		return ret;
+
+	ret = fdt_setprop_string(fdt, node, "status", "okay");
+	if (ret < 0)
+		return ret;
+
+	return 0;
+}
include/fdt_support.h +3 -0
index 55cef94..d5e09e6 100644
@@ -147,6 +147,9 @@ void of_bus_default_count_cells(void *blob, int parentoffset,
 int ft_verify_fdt(void *fdt);
 int arch_fixup_memory_node(void *blob);
 
+int fdt_setup_simplefb_node(void *fdt, int node, u64 base_address, u32 width,
+			    u32 height, u32 stride, const char *format);
+
 #endif /* ifdef CONFIG_OF_LIBFDT */
 
 #ifdef USE_HOSTCC
Signature · 1 line
2.1.0
#2 lore raw

PATCH v5 1/3 fdt_support: Add a fdt_setup_simplefb_node helper function

Quoted 8 lines · Hans de Goede

Add a generic helper to fill and enable simplefb nodes.

The first user of this will be the sunxi display code.

lcd_dt_simplefb_configure_node is also a good candidate to be converted to use this, but that requires someone to run some tests first, as lcd_dt_simplefb_configure_node does not honor #address-cells and #size-cells, but simply assumes 1 and 1 for both.

Sorry, I'd been ignoring all simplefb stuff and hadn't realized this was U-Boot related and needed testing.

Anyway, I've tested patches 1 and 2 on an RPi compute module with kernel next-20141031 and it seems to work fine.

Patches 1, 2,

#3 lore raw

PATCH v5 1/3 fdt_support: Add a fdt_setup_simplefb_node helper function

In reply to Hans de Goede

Hi Hans,

Quoted 10 lines · Hans de Goede

Add a generic helper to fill and enable simplefb nodes.

The first user of this will be the sunxi display code.

lcd_dt_simplefb_configure_node is also a good candidate to be converted to use this, but that requires someone to run some tests first, as lcd_dt_simplefb_configure_node does not honor #address-cells and #size-cells, but simply assumes 1 and 1 for both.

See below if you respin.

Quoted 17 lines
---
 common/fdt_support.c  | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++
 include/fdt_support.h |  3 +++
 2 files changed, 68 insertions(+)
common/fdt_support.c +4 -0
index 3f64156..0ffa711 100644
@@ -1523,3 +1523,68 @@ int fdt_read_range(void *fdt, int node, int n, uint64_t *child_addr,
 
        return 0;
 }
+
+/**
+ * fdt_setup_simplefb_node - Fill and enable a simplefb node
+ *

common/fdt_support.c int fdt_read_range(void *fdt, int node, int n, uint64_t *child_addr, · line 1539

Quoted 10 lines
common/fdt_support.c +10 -0
+ * @fdt: ptr to device tree
+ * @node: offset of the simplefb node
+ * @base_address: framebuffer base address
+ * @width: width in pixels
+ * @height: height in pixels
+ * @stride: bytes per line
+ * @format: pixel format string
+ *
+ * Convenience function to fill and enable a simplefb node.
+ */

Better to put the comment in the header IMO.

Quoted 18 lines
common/fdt_support.c +18 -0
+int fdt_setup_simplefb_node(void *fdt, int node, u64 base_address, u32 width,
+                           u32 height, u32 stride, const char *format)
+{
+       char name[32];
+       fdt32_t cells[4];
+       int i, addrc, sizec, ret;
+
+       of_bus_default_count_cells(fdt, fdt_parent_offset(fdt, node),
+                                  &addrc, &sizec);
+       i = 0;
+       if (addrc == 2)
+               cells[i++] = cpu_to_fdt32(base_address >> 32);
+       cells[i++] = cpu_to_fdt32(base_address);
+       if (sizec == 2)
+               cells[i++] = 0;
+       cells[i++] = cpu_to_fdt32(height * stride);
+
+       ret = fdt_setprop(fdt, node, "reg", cells, sizeof(cells[0]) * i);

common/fdt_support.c int fdt_read_range(void *fdt, int node, int n, uint64_t *child_addr, · line 1567

Quoted 10 lines
common/fdt_support.c +10 -0
+       if (ret < 0)
+               return ret;
+
+       snprintf(name, sizeof(name), "framebuffer@%llx", base_address);
+       ret = fdt_set_name(fdt, node, name);
+       if (ret < 0)
+               return ret;
+
+       cells[0] = cpu_to_fdt32(width);
+       ret = fdt_setprop(fdt, node, "width", cells, sizeof(cells[0]));

How about fdt_setprop_u32() instead?

Quoted 38 lines
common/fdt_support.c +23 -0
+       if (ret < 0)
+               return ret;
+
+       cells[0] = cpu_to_fdt32(height);
+       ret = fdt_setprop(fdt, node, "height", cells, sizeof(cells[0]));
+       if (ret < 0)
+               return ret;
+
+       cells[0] = cpu_to_fdt32(stride);
+       ret = fdt_setprop(fdt, node, "stride", cells, sizeof(cells[0]));
+       if (ret < 0)
+               return ret;
+
+       ret = fdt_setprop_string(fdt, node, "format", format);
+       if (ret < 0)
+               return ret;
+
+       ret = fdt_setprop_string(fdt, node, "status", "okay");
+       if (ret < 0)
+               return ret;
+
+       return 0;
+}
include/fdt_support.h +3 -1
index 55cef94..d5e09e6 100644
@@ -147,6 +147,9 @@ void of_bus_default_count_cells(void *blob, int parentoffset,
 int ft_verify_fdt(void *fdt);
 int arch_fixup_memory_node(void *blob);
 
+int fdt_setup_simplefb_node(void *fdt, int node, u64 base_address, u32 width,
+                           u32 height, u32 stride, const char *format);
+
 #endif /* ifdef CONFIG_OF_LIBFDT */
 
 #ifdef USE_HOSTCC
--
Quoted 1 line

2.1.0

Regards,
Simon

#4 lore raw

PATCH v5 1/3 fdt_support: Add a fdt_setup_simplefb_node helper function

Hi,

Quoted 12 lines · Simon Glass

Hi Hans,

Quoted 9 lines · Hans de Goede

Add a generic helper to fill and enable simplefb nodes.

The first user of this will be the sunxi display code.

lcd_dt_simplefb_configure_node is also a good candidate to be converted to use this, but that requires someone to run some tests first, as lcd_dt_simplefb_configure_node does not honor #address-cells and #size-cells, but simply assumes 1 and 1 for both.

Quoted 5 lines
Quoted 1 line

See below if you respin.

We agreed on getting this in via the sunxi custodian tree right ? Then I can fixup your comments (and re-test things on a sunxi board) before sending a pull-req.

Quoted 21 lines
Quoted 21 lines
---
 common/fdt_support.c  | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++
 include/fdt_support.h |  3 +++
 2 files changed, 68 insertions(+)
common/fdt_support.c +8 -0
index 3f64156..0ffa711 100644
@@ -1523,3 +1523,68 @@ int fdt_read_range(void *fdt, int node, int n, uint64_t *child_addr,
 
        return 0;
 }
+
+/**
+ * fdt_setup_simplefb_node - Fill and enable a simplefb node
+ *
+ * @fdt: ptr to device tree
+ * @node: offset of the simplefb node
+ * @base_address: framebuffer base address
+ * @width: width in pixels
Quoted 8 lines

common/fdt_support.c int fdt_read_range(void *fdt, int node, int n, uint64_t *child_addr, · line 1539

Quoted 6 lines
common/fdt_support.c +6 -0
+ * @height: height in pixels
+ * @stride: bytes per line
+ * @format: pixel format string
+ *
+ * Convenience function to fill and enable a simplefb node.
+ */

Better to put the comment in the header IMO.

I followed the example of other functions in fdt_support, there currently are no doxygen comments in fdt_support.h . Still I can move this over if you want.

Quoted 23 lines
Quoted 23 lines
common/fdt_support.c +22 -0
+int fdt_setup_simplefb_node(void *fdt, int node, u64 base_address, u32 width,
+                           u32 height, u32 stride, const char *format)
+{
+       char name[32];
+       fdt32_t cells[4];
+       int i, addrc, sizec, ret;
+
+       of_bus_default_count_cells(fdt, fdt_parent_offset(fdt, node),
+                                  &addrc, &sizec);
+       i = 0;
+       if (addrc == 2)
+               cells[i++] = cpu_to_fdt32(base_address >> 32);
+       cells[i++] = cpu_to_fdt32(base_address);
+       if (sizec == 2)
+               cells[i++] = 0;
+       cells[i++] = cpu_to_fdt32(height * stride);
+
+       ret = fdt_setprop(fdt, node, "reg", cells, sizeof(cells[0]) * i);
+       if (ret < 0)
+               return ret;
+
+       snprintf(name, sizeof(name), "framebuffer@%llx", base_address);
Quoted 8 lines

common/fdt_support.c int fdt_read_range(void *fdt, int node, int n, uint64_t *child_addr, · line 1567

Quoted 6 lines
common/fdt_support.c +6 -0
+       ret = fdt_set_name(fdt, node, name);
+       if (ret < 0)
+               return ret;
+
+       cells[0] = cpu_to_fdt32(width);
+       ret = fdt_setprop(fdt, node, "width", cells, sizeof(cells[0]));

How about fdt_setprop_u32() instead?

Yeah thats much better, will fix.

Quoted 37 lines
Quoted 37 lines
common/fdt_support.c +23 -0
+       if (ret < 0)
+               return ret;
+
+       cells[0] = cpu_to_fdt32(height);
+       ret = fdt_setprop(fdt, node, "height", cells, sizeof(cells[0]));
+       if (ret < 0)
+               return ret;
+
+       cells[0] = cpu_to_fdt32(stride);
+       ret = fdt_setprop(fdt, node, "stride", cells, sizeof(cells[0]));
+       if (ret < 0)
+               return ret;
+
+       ret = fdt_setprop_string(fdt, node, "format", format);
+       if (ret < 0)
+               return ret;
+
+       ret = fdt_setprop_string(fdt, node, "status", "okay");
+       if (ret < 0)
+               return ret;
+
+       return 0;
+}
include/fdt_support.h +3 -0
index 55cef94..d5e09e6 100644
@@ -147,6 +147,9 @@ void of_bus_default_count_cells(void *blob, int parentoffset,
 int ft_verify_fdt(void *fdt);
 int arch_fixup_memory_node(void *blob);
 
+int fdt_setup_simplefb_node(void *fdt, int node, u64 base_address, u32 width,
+                           u32 height, u32 stride, const char *format);
+
 #endif /* ifdef CONFIG_OF_LIBFDT */
 
Quoted 7 lines
Quoted 3 lines
include/fdt_support.h +0 -1
 #ifdef USE_HOSTCC
--

2.1.0

Regards,
Simon

Regards,

Hans

#5 lore raw

PATCH v5 2/3 common/lcd: Make lcd_dt_simplefb_configure_node use fdt_setup_simplefb_node

In reply to Hans de Goede

Change lcd_dt_simplefb_configure_node into a wrapper around the new generic fdt_setup_simplefb_node helper function.

---
 common/lcd.c | 47 +++++------------------------------------------
 1 file changed, 5 insertions(+), 42 deletions(-)
common/lcd.c +5 -42
index 37147af..54dd294 100644
@@ -30,6 +30,7 @@
 #include <splash.h>
 #include <asm/io.h>
 #include <asm/unaligned.h>
+#include <fdt_support.h>
 
 #if defined(CONFIG_CPU_PXA25X) || defined(CONFIG_CPU_PXA27X) || \
 	defined(CONFIG_CPU_MONAHANS)
@@ -1172,51 +1173,13 @@ int lcd_get_screen_columns(void)
 #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;
-	static const char format[] =
 #if LCD_BPP == LCD_COLOR16
-		"r5g6b5";
+	return fdt_setup_simplefb_node(blob, off, gd->fb_base,
+				       panel_info.vl_col, panel_info.vl_row,
+				       panel_info.vl_col * 2, "r5g6b5");
 #else
-		"";
+	return -1;
 #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)
Signature · 1 line
2.1.0
#7 lore raw

PATCH v5 3/3 sunxi: video: Add simplefb support

In reply to Hans de Goede

From: Luc Verhaegen <[email protected]>

Add simplefb support, note this depends on the kernel having support for the clocks property which has recently been added to the simplefb devicetree binding.

[hdegoede at redhat.com: Use pre-populated simplefb node under /chosen as
disussed on the devicetree list]

---
 arch/arm/include/asm/arch-sunxi/display.h |  4 +++
 board/sunxi/board.c                       | 11 ++++++++
 drivers/video/sunxi_display.c             | 42 +++++++++++++++++++++++++++++++
 include/configs/sunxi-common.h            |  8 ++++++
 4 files changed, 65 insertions(+)
arch/arm/include/asm/arch-sunxi/display.h +4 -0
index 8d80ceb..c9d81ba 100644
@@ -195,4 +195,8 @@ struct sunxi_hdmi_reg {
 #define SUNXI_HDMI_PLL_DBG0_PLL3		(0 << 21)
 #define SUNXI_HDMI_PLL_DBG0_PLL7		(1 << 21)
 
+#ifdef CONFIG_VIDEO_DT_SIMPLEFB
+int sunxi_simplefb_setup(void *blob);
+#endif
+
 #endif /* _SUNXI_DISPLAY_H */
board/sunxi/board.c +11 -0
index e6ec5b8..d4530e8 100644
@@ -24,6 +24,7 @@
 #endif
 #include <asm/arch/clock.h>
 #include <asm/arch/cpu.h>
+#include <asm/arch/display.h>
 #include <asm/arch/dram.h>
 #include <asm/arch/gpio.h>
 #include <asm/arch/mmc.h>
@@ -237,3 +238,13 @@ int misc_init_r(void)
 	return 0;
 }
 #endif
+
+#ifdef CONFIG_OF_BOARD_SETUP
+void
+ft_board_setup(void *blob, bd_t *bd)
+{
+#ifdef CONFIG_VIDEO_DT_SIMPLEFB
+	sunxi_simplefb_setup(blob);
+#endif
+}
+#endif /* CONFIG_OF_BOARD_SETUP */
drivers/video/sunxi_display.c +42 -0

51 lines not on this page · raw message

include/configs/sunxi-common.h +8 -0
index 900ef52..d5d907b 100644
@@ -204,6 +204,9 @@
  */
 #define CONFIG_SUNXI_FB_SIZE (8 << 20)
 
+/* Do we want to initialize a simple FB? */
+#define CONFIG_VIDEO_DT_SIMPLEFB
+
 #define CONFIG_VIDEO_SUNXI
 
 #define CONFIG_CFB_CONSOLE
@@ -217,6 +220,11 @@
 
 #define CONFIG_SYS_MEM_TOP_HIDE ((CONFIG_SUNXI_FB_SIZE + 0xFFF) & ~0xFFF)
 
+/* To be able to hook simplefb into dt */
+#ifdef CONFIG_VIDEO_DT_SIMPLEFB
+#define CONFIG_OF_BOARD_SETUP
+#endif
+
 #endif /* CONFIG_VIDEO */
 
 /* Ethernet support */
Signature · 1 line
2.1.0
#8 lore raw

PATCH v5 3/3 sunxi: video: Add simplefb support

Quoted 10 lines · Hans de Goede

From: Luc Verhaegen <[email protected]>

Add simplefb support, note this depends on the kernel having support for the clocks property which has recently been added to the simplefb devicetree binding.

[hdegoede at redhat.com: Use pre-populated simplefb node under /chosen as
disussed on the devicetree list]

One non-blocking queries:

drivers/video/sunxi_display.c video_hw_init(void) · line 445

Quoted 11 lines
drivers/video/sunxi_display.c +11 -0
+	/* Find a framebuffer node, with pipeline == "de_be0-lcd0-hdmi" */
+	offset = fdt_node_offset_by_compatible(blob, -1,
+					       "allwinner,simple-framebuffer");
+	while (offset >= 0) {
+		ret = fdt_find_string(blob, offset, "allwinner,pipeline",
+				      "de_be0-lcd0-hdmi");
+		if (ret == 0)
+			break;
+		offset = fdt_node_offset_by_compatible(blob, offset,
+					       "allwinner,simple-framebuffer");
+	}

Is this variant non-conformant with coding style?:

	int offset = -1;
	while ( (offset = fdt_node_offset_by_compatible(blob, offset,
                                                        "allwinner,simple-framebuffer") ) {
		LOOP BODY
	}

I expect it is because of the assignment within the while condition, which is a shame, since this is one case where it is IMHO leads to clearer code.

#9 lore raw

PATCH v5 3/3 sunxi: video: Add simplefb support

Hi,

Quoted 7 lines · Ian Campbell
Quoted 6 lines · Hans de Goede

From: Luc Verhaegen <[email protected]>

Add simplefb support, note this depends on the kernel having support for the clocks property which has recently been added to the simplefb devicetree binding.

Quoted 6 lines
Quoted 4 lines

[hdegoede at redhat.com: Use pre-populated simplefb node under /chosen as
disussed on the devicetree list]

Thanks, any chance you could also review v2 of the CONFIG_USB_KEYBOARD patch ?

Quoted 22 lines

One non-blocking queries:

drivers/video/sunxi_display.c video_hw_init(void) · line 445

Quoted 11 lines
drivers/video/sunxi_display.c +11 -0
+	/* Find a framebuffer node, with pipeline == "de_be0-lcd0-hdmi" */
+	offset = fdt_node_offset_by_compatible(blob, -1,
+					       "allwinner,simple-framebuffer");
+	while (offset >= 0) {
+		ret = fdt_find_string(blob, offset, "allwinner,pipeline",
+				      "de_be0-lcd0-hdmi");
+		if (ret == 0)
+			break;
+		offset = fdt_node_offset_by_compatible(blob, offset,
+					       "allwinner,simple-framebuffer");
+	}

Is this variant non-conformant with coding style?:

	int offset = -1;
	while ( (offset = fdt_node_offset_by_compatible(blob, offset,
                                                        "allwinner,simple-framebuffer") ) {
		LOOP BODY
	}
Quoted 3 lines

I expect it is because of the assignment within the while condition, which is a shame, since this is one case where it is IMHO leads to clearer code.

AFAIK this indeed would go against the coding style, and TBH I'm also not sure if I agree it would be cleaner (mainly because indentation would become (even more) messy due to the 80 columns limit).

Regards,

Hans

#10 lore raw

PATCH v5 3/3 sunxi: video: Add simplefb support

In reply to Hans de Goede

Hi Hans,

Quoted 22 lines · Hans de Goede

From: Luc Verhaegen <[email protected]>

Add simplefb support, note this depends on the kernel having support for the clocks property which has recently been added to the simplefb devicetree binding.

[hdegoede at redhat.com: Use pre-populated simplefb node under /chosen as
disussed on the devicetree list]

---
 arch/arm/include/asm/arch-sunxi/display.h |  4 +++
 board/sunxi/board.c                       | 11 ++++++++
 drivers/video/sunxi_display.c             | 42 +++++++++++++++++++++++++++++++
 include/configs/sunxi-common.h            |  8 ++++++
 4 files changed, 65 insertions(+)
arch/arm/include/asm/arch-sunxi/display.h +0 -0
index 8d80ceb..c9d81ba 100644

arch/arm/include/asm/arch-sunxi/display.h struct sunxi_hdmi_reg { · line 200

Quoted 6 lines
arch/arm/include/asm/arch-sunxi/display.h +3 -0
@@ -195,4 +195,8 @@ struct sunxi_hdmi_reg {
 #define SUNXI_HDMI_PLL_DBG0_PLL3               (0 << 21)
 #define SUNXI_HDMI_PLL_DBG0_PLL7               (1 << 21)
 
+#ifdef CONFIG_VIDEO_DT_SIMPLEFB
+int sunxi_simplefb_setup(void *blob);
+#endif

Do you really need this #ifdef?

Quoted 15 lines
arch/arm/include/asm/arch-sunxi/display.h +1 -0
+
 #endif /* _SUNXI_DISPLAY_H */
board/sunxi/board.c +1 -0
index e6ec5b8..d4530e8 100644
@@ -24,6 +24,7 @@
 #endif
 #include <asm/arch/clock.h>
 #include <asm/arch/cpu.h>
+#include <asm/arch/display.h>
 #include <asm/arch/dram.h>
 #include <asm/arch/gpio.h>
 #include <asm/arch/mmc.h>

board/sunxi/board.c int misc_init_r(void) · line 244

Quoted 7 lines
board/sunxi/board.c +4 -0
@@ -237,3 +238,13 @@ int misc_init_r(void)
        return 0;
 }
 #endif
+
+#ifdef CONFIG_OF_BOARD_SETUP
+void
+ft_board_setup(void *blob, bd_t *bd)

void on same line? Also can you make it return int. You could look at u-boot-fdt/next (I am waiting on resolving one patch before sending a pull).

Quoted 20 lines
board/sunxi/board.c +6 -0
+{
+#ifdef CONFIG_VIDEO_DT_SIMPLEFB
+       sunxi_simplefb_setup(blob);
+#endif
+}
+#endif /* CONFIG_OF_BOARD_SETUP */
drivers/video/sunxi_display.c +2 -0
index 3f46c31..2f3f5db 100644
@@ -13,6 +13,8 @@
 #include <asm/arch/display.h>
 #include <asm/global_data.h>
 #include <asm/io.h>
+#include <fdtdec.h>
+#include <fdt_support.h>
 #include <linux/fb.h>
 #include <video_fb.h>
 

drivers/video/sunxi_display.c video_hw_init(void) · line 427

Quoted 10 lines
drivers/video/sunxi_display.c +7 -0
@@ -416,3 +418,43 @@ video_hw_init(void)
 
        return graphic_device;
 }
+
+/*
+ * Simplefb support.
+ */
+#if defined(CONFIG_OF_BOARD_SETUP) && defined(CONFIG_VIDEO_DT_SIMPLEFB)
+int
+sunxi_simplefb_setup(void *blob)

int on same line

Quoted 8 lines
drivers/video/sunxi_display.c +8 -0
+{
+       static GraphicDevice *graphic_device = &sunxi_display.graphic_device;
+       int offset, ret;
+
+       if (!sunxi_display.enabled)
+               return 0;
+
+       /* Find a framebuffer node, with pipeline == "de_be0-lcd0-hdmi" */

drivers/video/sunxi_display.c video_hw_init(void) · line 445

Quoted 10 lines
drivers/video/sunxi_display.c +10 -0
+       offset = fdt_node_offset_by_compatible(blob, -1,
+                                              "allwinner,simple-framebuffer");
+       while (offset >= 0) {
+               ret = fdt_find_string(blob, offset, "allwinner,pipeline",
+                                     "de_be0-lcd0-hdmi");
+               if (ret == 0)
+                       break;
+               offset = fdt_node_offset_by_compatible(blob, offset,
+                                              "allwinner,simple-framebuffer");
+       }

Can you use do...while() to avoid repeating the 'offset =' line?

Quoted 42 lines
drivers/video/sunxi_display.c +15 -0
+       if (offset < 0) {
+               eprintf("Cannot setup simplefb: node not found\n");
+               return 0; /* Keep older kernels working */
+       }
+
+       ret = fdt_setup_simplefb_node(blob, offset, gd->fb_base,
+                       graphic_device->winSizeX, graphic_device->winSizeY,
+                       graphic_device->winSizeX * graphic_device->gdfBytesPP,
+                       "x8r8g8b8");
+       if (ret)
+               eprintf("Cannot setup simplefb: Error setting properties\n");
+
+       return ret;
+}
+#endif /* CONFIG_OF_BOARD_SETUP && CONFIG_VIDEO_DT_SIMPLEFB */
include/configs/sunxi-common.h +8 -1
index 900ef52..d5d907b 100644
@@ -204,6 +204,9 @@
  */
 #define CONFIG_SUNXI_FB_SIZE (8 << 20)
 
+/* Do we want to initialize a simple FB? */
+#define CONFIG_VIDEO_DT_SIMPLEFB
+
 #define CONFIG_VIDEO_SUNXI
 
 #define CONFIG_CFB_CONSOLE
@@ -217,6 +220,11 @@
 
 #define CONFIG_SYS_MEM_TOP_HIDE ((CONFIG_SUNXI_FB_SIZE + 0xFFF) & ~0xFFF)
 
+/* To be able to hook simplefb into dt */
+#ifdef CONFIG_VIDEO_DT_SIMPLEFB
+#define CONFIG_OF_BOARD_SETUP
+#endif
+
 #endif /* CONFIG_VIDEO */
 
 /* Ethernet support */
--
Quoted 2 lines

2.1.0

Regards,
Simon

#11 lore raw

PATCH v5 3/3 sunxi: video: Add simplefb support

Hi,

Quoted 28 lines · Simon Glass

Hi Hans,

Quoted 25 lines · Hans de Goede

From: Luc Verhaegen <[email protected]>

Add simplefb support, note this depends on the kernel having support for the clocks property which has recently been added to the simplefb devicetree binding.

[hdegoede at redhat.com: Use pre-populated simplefb node under /chosen as
disussed on the devicetree list]

---
 arch/arm/include/asm/arch-sunxi/display.h |  4 +++
 board/sunxi/board.c                       | 11 ++++++++
 drivers/video/sunxi_display.c             | 42 +++++++++++++++++++++++++++++++
 include/configs/sunxi-common.h            |  8 ++++++
 4 files changed, 65 insertions(+)
arch/arm/include/asm/arch-sunxi/display.h +0 -0
index 8d80ceb..c9d81ba 100644
@@ -195,4 +195,8 @@ struct sunxi_hdmi_reg {
 #define SUNXI_HDMI_PLL_DBG0_PLL3               (0 << 21)
 #define SUNXI_HDMI_PLL_DBG0_PLL7               (1 << 21)
 
Quoted 5 lines

arch/arm/include/asm/arch-sunxi/display.h struct sunxi_hdmi_reg { · line 200

Quoted 3 lines
arch/arm/include/asm/arch-sunxi/display.h +3 -0
+#ifdef CONFIG_VIDEO_DT_SIMPLEFB
+int sunxi_simplefb_setup(void *blob);
+#endif

Do you really need this #ifdef?

No, I'm not the original author of this patch and I inherited this from the original author, I'm not a big fan either, I'll drop it.

Quoted 17 lines
Quoted 17 lines
arch/arm/include/asm/arch-sunxi/display.h +1 -0
+
 #endif /* _SUNXI_DISPLAY_H */
board/sunxi/board.c +1 -0
index e6ec5b8..d4530e8 100644
@@ -24,6 +24,7 @@
 #endif
 #include <asm/arch/clock.h>
 #include <asm/arch/cpu.h>
+#include <asm/arch/display.h>
 #include <asm/arch/dram.h>
 #include <asm/arch/gpio.h>
 #include <asm/arch/mmc.h>
@@ -237,3 +238,13 @@ int misc_init_r(void)
        return 0;
Quoted 8 lines

board/sunxi/board.c int misc_init_r(void) · line 244

Quoted 6 lines
board/sunxi/board.c +4 -0
 }
 #endif
+
+#ifdef CONFIG_OF_BOARD_SETUP
+void
+ft_board_setup(void *blob, bd_t *bd)

void on same line?

Another inherited thing, will fixup (everywhere).

Quoted 3 lines

Also can you make it return int. You could look at u-boot-fdt/next (I am waiting on resolving one patch before sending a pull).

Ack, will also fix.

Quoted 95 lines
Quoted 21 lines
board/sunxi/board.c +6 -0
+{
+#ifdef CONFIG_VIDEO_DT_SIMPLEFB
+       sunxi_simplefb_setup(blob);
+#endif
+}
+#endif /* CONFIG_OF_BOARD_SETUP */
drivers/video/sunxi_display.c +2 -0
index 3f46c31..2f3f5db 100644
@@ -13,6 +13,8 @@
 #include <asm/arch/display.h>
 #include <asm/global_data.h>
 #include <asm/io.h>
+#include <fdtdec.h>
+#include <fdt_support.h>
 #include <linux/fb.h>
 #include <video_fb.h>
 

drivers/video/sunxi_display.c video_hw_init(void) · line 427

Quoted 10 lines
drivers/video/sunxi_display.c +7 -0
@@ -416,3 +418,43 @@ video_hw_init(void)
 
        return graphic_device;
 }
+
+/*
+ * Simplefb support.
+ */
+#if defined(CONFIG_OF_BOARD_SETUP) && defined(CONFIG_VIDEO_DT_SIMPLEFB)
+int
+sunxi_simplefb_setup(void *blob)

int on same line

Quoted 8 lines
drivers/video/sunxi_display.c +8 -0
+{
+       static GraphicDevice *graphic_device = &sunxi_display.graphic_device;
+       int offset, ret;
+
+       if (!sunxi_display.enabled)
+               return 0;
+
+       /* Find a framebuffer node, with pipeline == "de_be0-lcd0-hdmi" */

drivers/video/sunxi_display.c video_hw_init(void) · line 445

Quoted 10 lines
drivers/video/sunxi_display.c +10 -0
+       offset = fdt_node_offset_by_compatible(blob, -1,
+                                              "allwinner,simple-framebuffer");
+       while (offset >= 0) {
+               ret = fdt_find_string(blob, offset, "allwinner,pipeline",
+                                     "de_be0-lcd0-hdmi");
+               if (ret == 0)
+                       break;
+               offset = fdt_node_offset_by_compatible(blob, offset,
+                                              "allwinner,simple-framebuffer");
+       }

Can you use do...while() to avoid repeating the 'offset =' line?

Quoted 40 lines
drivers/video/sunxi_display.c +15 -0
+       if (offset < 0) {
+               eprintf("Cannot setup simplefb: node not found\n");
+               return 0; /* Keep older kernels working */
+       }
+
+       ret = fdt_setup_simplefb_node(blob, offset, gd->fb_base,
+                       graphic_device->winSizeX, graphic_device->winSizeY,
+                       graphic_device->winSizeX * graphic_device->gdfBytesPP,
+                       "x8r8g8b8");
+       if (ret)
+               eprintf("Cannot setup simplefb: Error setting properties\n");
+
+       return ret;
+}
+#endif /* CONFIG_OF_BOARD_SETUP && CONFIG_VIDEO_DT_SIMPLEFB */
include/configs/sunxi-common.h +8 -0
index 900ef52..d5d907b 100644
@@ -204,6 +204,9 @@
  */
 #define CONFIG_SUNXI_FB_SIZE (8 << 20)
 
+/* Do we want to initialize a simple FB? */
+#define CONFIG_VIDEO_DT_SIMPLEFB
+
 #define CONFIG_VIDEO_SUNXI
 
 #define CONFIG_CFB_CONSOLE
@@ -217,6 +220,11 @@
 
 #define CONFIG_SYS_MEM_TOP_HIDE ((CONFIG_SUNXI_FB_SIZE + 0xFFF) & ~0xFFF)
 
+/* To be able to hook simplefb into dt */
+#ifdef CONFIG_VIDEO_DT_SIMPLEFB
+#define CONFIG_OF_BOARD_SETUP
+#endif
+
 #endif /* CONFIG_VIDEO */
 
Quoted 7 lines
Quoted 4 lines
include/configs/sunxi-common.h +0 -1
 /* Ethernet support */
--

2.1.0

Regards,
Simon

Regards,

Hans

#12 lore raw

v5 cover sunxi: video: Add simplefb support

In reply to Hans de Goede

Hi Hans,

Quoted 20 lines · Hans de Goede

Hi All,

Here is v5 of my sunxi simplefb support set.

Changes since v4:

(quoted diff) +0 -2
-Make sunxi_simplefb_setup return error codes
-Add a patch to make lcd_dt_simplefb_configure_node use the new
 fdt_setup_simplefb_node helper (only compile tested!)

Changes since v3:

(quoted diff) +0 -2
-Added a fdt_setup_simplefb_node() helper function (new patch)
-Changed how u-boot finds the pre-populated simplefb node to use a
 compatible string

Changes since v2:
-Detect and handle address and size #cells

Changes since v1:
-Use fdt_setprop_string for strings

Quoted 6 lines

Simon, even though -rc1 is out I would still like to get this upstream for v2015.01 if possible. This is in essence just refactoring of code posted well before -rc1. If I can get your ack on both the fdt_setup_simplefb_node and the lcd patches, then I can take them upstream through the sunxi tree, or if you plan to do a pull-req soon anyways, you can take them upstream through your tree, and I'll wait for that.

That seems good to me. I'll see if I can test it when I get back. I added Stephen also as he wrote the Raspberry Pi stuff.

Regards,
Simon