From patchwork Tue May 9 07:23: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: 759922 X-Patchwork-Delegate: jagannadh.teki@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3wMW8V5nmKz9s7f for ; Tue, 9 May 2017 17:24:25 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 6469AC21C66; Tue, 9 May 2017 07:24:20 +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 398B8C21C30; Tue, 9 May 2017 07:24:18 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 82B16C21C30; Tue, 9 May 2017 07:24:16 +0000 (UTC) Received: from cat.maple.relay.mailchannels.net (cat.maple.relay.mailchannels.net [23.83.214.31]) by lists.denx.de (Postfix) with ESMTPS id 8438FC21C27 for ; Tue, 9 May 2017 07:24:15 +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 7B60F204592; Tue, 9 May 2017 07:24:12 +0000 (UTC) Received: from hermes.aosc.io (unknown [100.96.135.123]) (Authenticated sender: lmn-TZDUIOWCRQMW) by relay.mailchannels.net (Postfix) with ESMTPA id B0A1620334A; Tue, 9 May 2017 07:24:11 +0000 (UTC) X-Sender-Id: lmn-tzduiowcrqmw|x-authsender|icenowy@aosc.io Received: from hermes.aosc.io (hermes.aosc.io [172.20.88.133]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384) by 0.0.0.0:2500 (trex/5.9.2); Tue, 09 May 2017 07:24:12 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: lmn-tzduiowcrqmw|x-authsender|icenowy@aosc.io X-MailChannels-Auth-Id: lmn-TZDUIOWCRQMW X-Inform-Tasty: 33bf4d5d1ca0c992_1494314652323_1187852210 X-MC-Loop-Signature: 1494314652323:440870880 X-MC-Ingress-Time: 1494314652323 Received: from localhost (localhost [127.0.0.1]) (Authenticated sender: icenowy@aosc.io) by hermes.aosc.io (Postfix) with ESMTPSA id 8B5B24BE40; Tue, 9 May 2017 07:24:06 +0000 (UTC) From: Icenowy Zheng To: Maxime Ripard , Jagan Teki , Anatolij Gustschin , Jernej Skrabec Date: Tue, 9 May 2017 15:23:58 +0800 Message-Id: <20170509072358.19116-1-icenowy@aosc.io> Cc: u-boot@lists.denx.de, Icenowy Zheng Subject: [U-Boot] [PATCH] 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 --- drivers/video/sunxi/sunxi_de2.c | 81 +++++++++++++++++++++++++++++++++++++++++ include/configs/sunxi-common.h | 4 ++ 2 files changed, 85 insertions(+) diff --git a/drivers/video/sunxi/sunxi_de2.c b/drivers/video/sunxi/sunxi_de2.c index 9a32c3a020..97e0513f04 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 @@ -256,3 +258,82 @@ 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); + + /* 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"); + } + 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, + (1 << de2_priv->bpix) / 8 * 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 997a92c8be..8078ffe82a 100644 --- a/include/configs/sunxi-common.h +++ b/include/configs/sunxi-common.h @@ -286,6 +286,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