diff mbox series

[U-Boot,v2,2/2] sunxi: setup simplefb for Allwinner DE2

Message ID 20170911155458.62806-3-icenowy@aosc.io
State Superseded
Delegated to: Jagannadha Sutradharudu Teki
Headers show
Series Allwinner DE2 HDMI SimpleFB support | expand

Commit Message

Icenowy Zheng Sept. 11, 2017, 3:54 p.m. UTC
As the support of EFI boot on Allwinner H3 is broken, we still need to
use simplefb to pass the framebuffer to Linux.

Add code to setup simplefb for Allwinner DE2 driver.

Signed-off-by: Icenowy Zheng <icenowy@aosc.io>
---
Changes in v2:
- Extract the simplefb node searching code.

 drivers/video/sunxi/Makefile    |  2 +-
 drivers/video/sunxi/sunxi_de2.c | 72 +++++++++++++++++++++++++++++++++++++++++
 include/configs/sunxi-common.h  |  4 +++
 3 files changed, 77 insertions(+), 1 deletion(-)

Comments

Maxime Ripard Sept. 12, 2017, 8:18 a.m. UTC | #1
Hi,

On Mon, Sep 11, 2017 at 11:54:58PM +0800, Icenowy Zheng wrote:
> diff --git a/include/configs/sunxi-common.h b/include/configs/sunxi-common.h
> index 1373b1f037..c240fe4403 100644
> --- a/include/configs/sunxi-common.h
> +++ b/include/configs/sunxi-common.h
> @@ -288,6 +288,10 @@ extern int soft_i2c_gpio_scl;
>  
>  #endif /* CONFIG_VIDEO */
>  
> +#ifdef CONFIG_VIDEO_DE2
> +#define CONFIG_VIDEO_DT_SIMPLEFB
> +#endif
> +

Please use a Kconfig option for that one.

Thanks!
Maxime
Icenowy Zheng Sept. 12, 2017, 8:25 a.m. UTC | #2
在 2017-09-12 16:18,Maxime Ripard 写道:
> Hi,
> 
> On Mon, Sep 11, 2017 at 11:54:58PM +0800, Icenowy Zheng wrote:
>> diff --git a/include/configs/sunxi-common.h 
>> b/include/configs/sunxi-common.h
>> index 1373b1f037..c240fe4403 100644
>> --- a/include/configs/sunxi-common.h
>> +++ b/include/configs/sunxi-common.h
>> @@ -288,6 +288,10 @@ extern int soft_i2c_gpio_scl;
>> 
>>  #endif /* CONFIG_VIDEO */
>> 
>> +#ifdef CONFIG_VIDEO_DE2
>> +#define CONFIG_VIDEO_DT_SIMPLEFB
>> +#endif
>> +
> 
> Please use a Kconfig option for that one.

Should I also convert DE1 simplefb to a Kconfig option?

> 
> Thanks!
> Maxime
Maxime Ripard Sept. 12, 2017, 8:03 p.m. UTC | #3
On Tue, Sep 12, 2017 at 04:25:36PM +0800, icenowy@aosc.io wrote:
> 在 2017-09-12 16:18,Maxime Ripard 写道:
> > Hi,
> > 
> > On Mon, Sep 11, 2017 at 11:54:58PM +0800, Icenowy Zheng wrote:
> > > diff --git a/include/configs/sunxi-common.h
> > > b/include/configs/sunxi-common.h
> > > index 1373b1f037..c240fe4403 100644
> > > --- a/include/configs/sunxi-common.h
> > > +++ b/include/configs/sunxi-common.h
> > > @@ -288,6 +288,10 @@ extern int soft_i2c_gpio_scl;
> > > 
> > >  #endif /* CONFIG_VIDEO */
> > > 
> > > +#ifdef CONFIG_VIDEO_DE2
> > > +#define CONFIG_VIDEO_DT_SIMPLEFB
> > > +#endif
> > > +
> > 
> > Please use a Kconfig option for that one.
> 
> Should I also convert DE1 simplefb to a Kconfig option?

If you have some spare time, sure, but it's not a pre-requisite for
this serie.

Maxime
diff mbox series

Patch

diff --git a/drivers/video/sunxi/Makefile b/drivers/video/sunxi/Makefile
index 10862edaca..aec32b79b9 100644
--- a/drivers/video/sunxi/Makefile
+++ b/drivers/video/sunxi/Makefile
@@ -6,4 +6,4 @@ 
 #
 
 obj-$(CONFIG_VIDEO_SUNXI) += sunxi_display.o simplefb_common.o lcdc.o tve_common.o ../videomodes.o
-obj-$(CONFIG_VIDEO_DE2) += sunxi_de2.o sunxi_dw_hdmi.o lcdc.o ../dw_hdmi.o
+obj-$(CONFIG_VIDEO_DE2) += sunxi_de2.o sunxi_dw_hdmi.o simplefb_common.o lcdc.o ../dw_hdmi.o
diff --git a/drivers/video/sunxi/sunxi_de2.c b/drivers/video/sunxi/sunxi_de2.c
index ee67764ac5..67b937098c 100644
--- a/drivers/video/sunxi/sunxi_de2.c
+++ b/drivers/video/sunxi/sunxi_de2.c
@@ -10,6 +10,8 @@ 
 #include <display.h>
 #include <dm.h>
 #include <edid.h>
+#include <fdtdec.h>
+#include <fdt_support.h>
 #include <video.h>
 #include <asm/global_data.h>
 #include <asm/io.h>
@@ -17,6 +19,7 @@ 
 #include <asm/arch/display2.h>
 #include <dm/device-internal.h>
 #include <dm/uclass-internal.h>
+#include "simplefb_common.h"
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -292,3 +295,72 @@  U_BOOT_DRIVER(sunxi_de2) = {
 U_BOOT_DEVICE(sunxi_de2) = {
 	.name = "sunxi_de2"
 };
+
+/*
+ * Simplefb support.
+ */
+#if defined(CONFIG_OF_BOARD_SETUP) && defined(CONFIG_VIDEO_DT_SIMPLEFB)
+int sunxi_simplefb_setup(void *blob)
+{
+	struct udevice *de2, *hdmi;
+	struct video_priv *de2_priv;
+	struct video_uc_platdata *de2_plat;
+	int mux;
+	int offset, ret;
+	u64 start, size;
+	const char *pipeline = NULL;
+
+	debug("Setting up simplefb\n");
+
+	if (IS_ENABLED(CONFIG_MACH_SUNXI_H3_H5))
+		mux = 0;
+	else
+		mux = 1;
+
+	/* Skip simplefb setting if DE2 / HDMI is not present */
+	ret = uclass_find_device_by_name(UCLASS_VIDEO,
+					 "sunxi_de2", &de2);
+	if (ret) {
+		debug("DE2 not present\n");
+		return 0;
+	}
+
+	ret = uclass_find_device_by_name(UCLASS_DISPLAY,
+					 "sunxi_dw_hdmi", &hdmi);
+	if (ret) {
+		debug("HDMI not present\n");
+		return 0;
+	}
+
+	if (mux == 0)
+		pipeline = "mixer0-lcd0-hdmi";
+	else
+		pipeline = "mixer1-lcd1-hdmi";
+
+	de2_priv = dev_get_uclass_priv(de2);
+	de2_plat = dev_get_uclass_platdata(de2);
+
+	offset = sunxi_simplefb_fdt_match(blob, pipeline);
+	if (offset < 0) {
+		eprintf("Cannot setup simplefb: node not found\n");
+		return 0; /* Keep older kernels working */
+	}
+
+	start = gd->bd->bi_dram[0].start;
+	size = de2_plat->base - start;
+	ret = fdt_fixup_memory_banks(blob, &start, &size, 1);
+	if (ret) {
+		eprintf("Cannot setup simplefb: Error reserving memory\n");
+		return ret;
+	}
+
+	ret = fdt_setup_simplefb_node(blob, offset, de2_plat->base,
+			de2_priv->xsize, de2_priv->ysize,
+			VNBYTES(de2_priv->bpix) * de2_priv->xsize,
+			"x8r8g8b8");
+	if (ret)
+		eprintf("Cannot setup simplefb: Error setting properties\n");
+
+	return ret;
+}
+#endif /* CONFIG_OF_BOARD_SETUP && CONFIG_VIDEO_DT_SIMPLEFB */
diff --git a/include/configs/sunxi-common.h b/include/configs/sunxi-common.h
index 1373b1f037..c240fe4403 100644
--- a/include/configs/sunxi-common.h
+++ b/include/configs/sunxi-common.h
@@ -288,6 +288,10 @@  extern int soft_i2c_gpio_scl;
 
 #endif /* CONFIG_VIDEO */
 
+#ifdef CONFIG_VIDEO_DE2
+#define CONFIG_VIDEO_DT_SIMPLEFB
+#endif
+
 /* Ethernet support */
 #ifdef CONFIG_SUNXI_EMAC
 #define CONFIG_PHY_ADDR		1