From patchwork Mon Nov 17 15:48:53 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: 411709 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 312F01401EB for ; Tue, 18 Nov 2014 02:49:26 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 6969D4B666; Mon, 17 Nov 2014 16:49:17 +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 hfpAPoqh38Vy; Mon, 17 Nov 2014 16:49:17 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id F30E74B657; Mon, 17 Nov 2014 16:49:13 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 5D6374B62C for ; Mon, 17 Nov 2014 16:49:09 +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 ue4a-3PelqJF for ; Mon, 17 Nov 2014 16:49:09 +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 D4C014B62B for ; Mon, 17 Nov 2014 16:49:05 +0100 (CET) Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id sAHFmwkV008086 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 17 Nov 2014 10:48:58 -0500 Received: from shalem.localdomain.com (vpn1-7-227.ams2.redhat.com [10.36.7.227]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id sAHFmtrw012585; Mon, 17 Nov 2014 10:48:57 -0500 From: Hans de Goede To: Simon Glass , Ian Campbell Date: Mon, 17 Nov 2014 16:48:53 +0100 Message-Id: <1416239334-29802-2-git-send-email-hdegoede@redhat.com> In-Reply-To: <1416239334-29802-1-git-send-email-hdegoede@redhat.com> References: <1416239334-29802-1-git-send-email-hdegoede@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 Cc: u-boot@lists.denx.de Subject: [U-Boot] [PATCH v4 1/2] fdt_support: Add a fdt_setup_simplefb_node helper function 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 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. Signed-off-by: Hans de Goede --- common/fdt_support.c | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++ include/fdt_support.h | 3 +++ 2 files changed, 68 insertions(+) diff --git a/common/fdt_support.c b/common/fdt_support.c index 3f64156..0ffa711 100644 --- a/common/fdt_support.c +++ b/common/fdt_support.c @@ -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; +} diff --git a/include/fdt_support.h b/include/fdt_support.h index 55cef94..d5e09e6 100644 --- a/include/fdt_support.h +++ b/include/fdt_support.h @@ -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