From patchwork Mon Sep 11 15:54:57 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Icenowy Zheng X-Patchwork-Id: 812436 X-Patchwork-Delegate: jagannadh.teki@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3xrXZv33K4z9s7f for ; Tue, 12 Sep 2017 01:55:51 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 00769C21E67; Mon, 11 Sep 2017 15:55:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=RCVD_IN_DNSWL_NONE autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 2F52CC21EEA; Mon, 11 Sep 2017 15:55:36 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id D0211C21E40; Mon, 11 Sep 2017 15:55:30 +0000 (UTC) Received: from eastern.birch.relay.mailchannels.net (eastern.birch.relay.mailchannels.net [23.83.209.55]) by lists.denx.de (Postfix) with ESMTPS id 25E48C21F09 for ; Mon, 11 Sep 2017 15:55:25 +0000 (UTC) X-Sender-Id: lmn-tzduiowcrqmw|x-authsender|icenowy@aosc.io Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 20E61208401; Mon, 11 Sep 2017 15:55:23 +0000 (UTC) Received: from hermes.aosc.io (unknown [100.96.134.127]) (Authenticated sender: lmn-TZDUIOWCRQMW) by relay.mailchannels.net (Postfix) with ESMTPA id 509DF2087B7; Mon, 11 Sep 2017 15:55:22 +0000 (UTC) X-Sender-Id: lmn-tzduiowcrqmw|x-authsender|icenowy@aosc.io Received: from hermes.aosc.io (hermes.aosc.io [172.20.104.49]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384) by 0.0.0.0:2500 (trex/5.9.14); Mon, 11 Sep 2017 15:55:23 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: lmn-tzduiowcrqmw|x-authsender|icenowy@aosc.io X-MailChannels-Auth-Id: lmn-TZDUIOWCRQMW X-Decisive-Madly: 79dd691508a72aed_1505145322883_547197756 X-MC-Loop-Signature: 1505145322883:1487460996 X-MC-Ingress-Time: 1505145322882 Received: from localhost (localhost [127.0.0.1]) (Authenticated sender: icenowy@aosc.io) by hermes.aosc.io (Postfix) with ESMTPSA id AF52B47003; Mon, 11 Sep 2017 15:55:18 +0000 (UTC) From: Icenowy Zheng To: Maxime Ripard , Jagan Teki Date: Mon, 11 Sep 2017 23:54:57 +0800 Message-Id: <20170911155458.62806-2-icenowy@aosc.io> In-Reply-To: <20170911155458.62806-1-icenowy@aosc.io> References: <20170911155458.62806-1-icenowy@aosc.io> Cc: u-boot@lists.denx.de, linux-sunxi@googlegroups.com, Icenowy Zheng Subject: [U-Boot] [PATCH v2 1/2] video: sunxi: extract simplefb match code to a new file X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" As the DE2 simplefb setup code can also benefit from the simplefb match code, extract it to a new source file. Signed-off-by: Icenowy Zheng Reviewed-by: Andre Przywara --- drivers/video/sunxi/Makefile | 2 +- drivers/video/sunxi/simplefb_common.c | 29 +++++++++++++++++++++++++++++ drivers/video/sunxi/simplefb_common.h | 22 ++++++++++++++++++++++ drivers/video/sunxi/sunxi_display.c | 13 ++----------- 4 files changed, 54 insertions(+), 12 deletions(-) create mode 100644 drivers/video/sunxi/simplefb_common.c create mode 100644 drivers/video/sunxi/simplefb_common.h diff --git a/drivers/video/sunxi/Makefile b/drivers/video/sunxi/Makefile index 0d64c2021f..10862edaca 100644 --- a/drivers/video/sunxi/Makefile +++ b/drivers/video/sunxi/Makefile @@ -5,5 +5,5 @@ # SPDX-License-Identifier: GPL-2.0+ # -obj-$(CONFIG_VIDEO_SUNXI) += sunxi_display.o lcdc.o tve_common.o ../videomodes.o +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 diff --git a/drivers/video/sunxi/simplefb_common.c b/drivers/video/sunxi/simplefb_common.c new file mode 100644 index 0000000000..4823f13a0c --- /dev/null +++ b/drivers/video/sunxi/simplefb_common.c @@ -0,0 +1,29 @@ +/* + * Common code for Allwinner SimpleFB with pipeline. + * + * (C) Copyright 2014-2015 Hans de Goede + * (C) Copyright 2017 Icenowy Zheng + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#include + +int sunxi_simplefb_fdt_match(void *blob, const char *pipeline) +{ + int offset, ret; + + /* Find a prefilled simpefb node, matching out pipeline config */ + offset = fdt_node_offset_by_compatible(blob, -1, + "allwinner,simple-framebuffer"); + while (offset >= 0) { + ret = fdt_stringlist_search(blob, offset, "allwinner,pipeline", + pipeline); + if (ret == 0) + break; + offset = fdt_node_offset_by_compatible(blob, offset, + "allwinner,simple-framebuffer"); + } + + return offset; +} diff --git a/drivers/video/sunxi/simplefb_common.h b/drivers/video/sunxi/simplefb_common.h new file mode 100644 index 0000000000..ac9bfcb087 --- /dev/null +++ b/drivers/video/sunxi/simplefb_common.h @@ -0,0 +1,22 @@ +/* + * (C) Copyright 2017 Icenowy Zheng + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#ifndef __SIMPLEFB_COMMON_H +#define __SIMPLEFB_COMMON_H + +/* + * sunxi_simplefb_fdt_match() - match a sunxi simplefb node + * + * Match a sunxi simplefb device node with a specified pipeline, and + * return its offset. + * + * @blob: device tree blob + * @pipeline: display pipeline + * @return device node offset in blob, or negative values if failed + */ +int sunxi_simplefb_fdt_match(void *blob, const char *pipeline); + +#endif diff --git a/drivers/video/sunxi/sunxi_display.c b/drivers/video/sunxi/sunxi_display.c index de768ba94a..7f25ed5f26 100644 --- a/drivers/video/sunxi/sunxi_display.c +++ b/drivers/video/sunxi/sunxi_display.c @@ -29,6 +29,7 @@ #include "../anx9804.h" #include "../hitachi_tx18d42vm_lcd.h" #include "../ssd2828.h" +#include "simplefb_common.h" #ifdef CONFIG_VIDEO_LCD_BL_PWM_ACTIVE_LOW #define PWM_ON 0 @@ -1377,17 +1378,7 @@ int sunxi_simplefb_setup(void *blob) break; } - /* Find a prefilled simpefb node, matching out pipeline config */ - offset = fdt_node_offset_by_compatible(blob, -1, - "allwinner,simple-framebuffer"); - while (offset >= 0) { - ret = fdt_stringlist_search(blob, offset, "allwinner,pipeline", - pipeline); - if (ret == 0) - break; - offset = fdt_node_offset_by_compatible(blob, offset, - "allwinner,simple-framebuffer"); - } + offset = sunxi_simplefb_fdt_match(blob, pipeline); if (offset < 0) { eprintf("Cannot setup simplefb: node not found\n"); return 0; /* Keep older kernels working */ From patchwork Mon Sep 11 15:54:58 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Icenowy Zheng X-Patchwork-Id: 812438 X-Patchwork-Delegate: jagannadh.teki@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3xrXcQ0XWHz9s1h for ; Tue, 12 Sep 2017 01:57:10 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id D1EF4C21F65; Mon, 11 Sep 2017 15:55:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 46C06C21E4B; Mon, 11 Sep 2017 15:55:55 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 12BEAC21EEA; Mon, 11 Sep 2017 15:55:35 +0000 (UTC) Received: from catfish.maple.relay.mailchannels.net (catfish.maple.relay.mailchannels.net [23.83.214.32]) by lists.denx.de (Postfix) with ESMTPS id E58E0C21F32 for ; Mon, 11 Sep 2017 15:55:31 +0000 (UTC) X-Sender-Id: lmn-tzduiowcrqmw|x-authsender|icenowy@aosc.io Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id C7F817C9839; Mon, 11 Sep 2017 15:55:28 +0000 (UTC) Received: from hermes.aosc.io (unknown [100.96.140.134]) (Authenticated sender: lmn-TZDUIOWCRQMW) by relay.mailchannels.net (Postfix) with ESMTPA id D9D1A7C9D71; Mon, 11 Sep 2017 15:55:27 +0000 (UTC) X-Sender-Id: lmn-tzduiowcrqmw|x-authsender|icenowy@aosc.io Received: from hermes.aosc.io (hermes.aosc.io [172.20.96.210]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384) by 0.0.0.0:2500 (trex/5.9.14); Mon, 11 Sep 2017 15:55:28 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: lmn-tzduiowcrqmw|x-authsender|icenowy@aosc.io X-MailChannels-Auth-Id: lmn-TZDUIOWCRQMW X-Chemical-Bubble: 13d00e85209b57c3_1505145328473_2881401468 X-MC-Loop-Signature: 1505145328472:1267140731 X-MC-Ingress-Time: 1505145328472 Received: from localhost (localhost [127.0.0.1]) (Authenticated sender: icenowy@aosc.io) by hermes.aosc.io (Postfix) with ESMTPSA id 7A13747003; Mon, 11 Sep 2017 15:55:24 +0000 (UTC) From: Icenowy Zheng To: Maxime Ripard , Jagan Teki Date: Mon, 11 Sep 2017 23:54:58 +0800 Message-Id: <20170911155458.62806-3-icenowy@aosc.io> In-Reply-To: <20170911155458.62806-1-icenowy@aosc.io> References: <20170911155458.62806-1-icenowy@aosc.io> Cc: u-boot@lists.denx.de, linux-sunxi@googlegroups.com, Icenowy Zheng Subject: [U-Boot] [PATCH v2 2/2] sunxi: setup simplefb for Allwinner DE2 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" 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 --- 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(-) 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 #include #include +#include +#include #include #include #include @@ -17,6 +19,7 @@ #include #include #include +#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