From patchwork Sun Nov 16 16:06:05 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 411309 X-Patchwork-Delegate: ijc@hellion.org.uk Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id F014C1400DD for ; Mon, 17 Nov 2014 03:06:59 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 2C7024B7CF; Sun, 16 Nov 2014 17:06:47 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id i00WxWbke-d5; Sun, 16 Nov 2014 17:06:47 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id C69A34B83A; Sun, 16 Nov 2014 17:06:38 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 0EB6A4B6F2 for ; Sun, 16 Nov 2014 17:06:29 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id kmzMynRvORC7 for ; Sun, 16 Nov 2014 17:06:28 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by theia.denx.de (Postfix) with ESMTPS id 6DD5C4B6F7 for ; Sun, 16 Nov 2014 17:06:25 +0100 (CET) Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id sAGG6E9b024391 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Sun, 16 Nov 2014 11:06:14 -0500 Received: from shalem.localdomain.com (vpn1-7-133.ams2.redhat.com [10.36.7.133]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id sAGG677s027310; Sun, 16 Nov 2014 11:06:13 -0500 From: Hans de Goede To: Anatolij Gustschin , Ian Campbell Date: Sun, 16 Nov 2014 17:06:05 +0100 Message-Id: <1416153966-3045-4-git-send-email-hdegoede@redhat.com> In-Reply-To: <1416153966-3045-1-git-send-email-hdegoede@redhat.com> References: <1416153966-3045-1-git-send-email-hdegoede@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 Cc: u-boot@lists.denx.de Subject: [U-Boot] [PATCH v2 3/4] sunxi: video: Add simplefb support X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.13 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de From: Luc Verhaegen 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. Signed-off-by: Luc Verhaegen [hdegoede@redhat.com: Use pre-populated simplefb node under /chosen as disussed on the devicetree list] Signed-off-by: Hans de Goede --- arch/arm/include/asm/arch-sunxi/display.h | 4 ++ board/sunxi/board.c | 11 ++++++ drivers/video/sunxi_display.c | 64 +++++++++++++++++++++++++++++++ include/configs/sunxi-common.h | 8 ++++ 4 files changed, 87 insertions(+) diff --git a/arch/arm/include/asm/arch-sunxi/display.h b/arch/arm/include/asm/arch-sunxi/display.h index 8d80ceb..4c694f8 100644 --- a/arch/arm/include/asm/arch-sunxi/display.h +++ b/arch/arm/include/asm/arch-sunxi/display.h @@ -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 +void sunxi_simplefb_setup(void *blob); +#endif + #endif /* _SUNXI_DISPLAY_H */ diff --git a/board/sunxi/board.c b/board/sunxi/board.c index e6ec5b8..d4530e8 100644 --- a/board/sunxi/board.c +++ b/board/sunxi/board.c @@ -24,6 +24,7 @@ #endif #include #include +#include #include #include #include @@ -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 */ diff --git a/drivers/video/sunxi_display.c b/drivers/video/sunxi_display.c index 3f46c31..64c4b8b 100644 --- a/drivers/video/sunxi_display.c +++ b/drivers/video/sunxi_display.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include @@ -416,3 +417,66 @@ video_hw_init(void) return graphic_device; } + +/* + * Simplefb support. + */ +#if defined(CONFIG_OF_BOARD_SETUP) && defined(CONFIG_VIDEO_DT_SIMPLEFB) +void +sunxi_simplefb_setup(void *blob) +{ + static GraphicDevice *graphic_device = &sunxi_display.graphic_device; + const char *node = "/chosen/framebuffer0-hdmi"; + char name[32]; + fdt32_t cells[2]; + int offset, stride, ret; + + if (!sunxi_display.enabled) + return; + + offset = fdt_path_offset(blob, node); + if (offset < 0) { + eprintf("Cannot setup simplefb: %s node not found\n", node); + return; + } + + snprintf(name, sizeof(name), "framebuffer@%08lx", gd->fb_base); + ret = fdt_set_name(blob, offset, name); + if (ret < 0) + goto error; + + cells[0] = cpu_to_fdt32(gd->fb_base); + cells[1] = cpu_to_fdt32(CONFIG_SUNXI_FB_SIZE); + ret = fdt_setprop(blob, offset, "reg", cells, sizeof(cells[0]) * 2); + if (ret < 0) + goto error; + + cells[0] = cpu_to_fdt32(graphic_device->winSizeX); + ret = fdt_setprop(blob, offset, "width", cells, sizeof(cells[0])); + if (ret < 0) + goto error; + + cells[0] = cpu_to_fdt32(graphic_device->winSizeY); + ret = fdt_setprop(blob, offset, "height", cells, sizeof(cells[0])); + if (ret < 0) + goto error; + + stride = graphic_device->winSizeX * graphic_device->gdfBytesPP; + cells[0] = cpu_to_fdt32(stride); + ret = fdt_setprop(blob, offset, "stride", cells, sizeof(cells[0])); + if (ret < 0) + goto error; + + ret = fdt_setprop_string(blob, offset, "format", "x8r8g8b8"); + if (ret < 0) + goto error; + + ret = fdt_setprop_string(blob, offset, "status", "okay"); + if (ret < 0) + goto error; + + return; +error: + eprintf("Cannot setup simplefb: Error setting properties\n"); +} +#endif /* CONFIG_OF_BOARD_SETUP && CONFIG_VIDEO_DT_SIMPLEFB */ diff --git a/include/configs/sunxi-common.h b/include/configs/sunxi-common.h index 900ef52..d5d907b 100644 --- a/include/configs/sunxi-common.h +++ b/include/configs/sunxi-common.h @@ -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 */