From patchwork Wed Apr 8 18:45:39 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tim Harvey X-Patchwork-Id: 459421 X-Patchwork-Delegate: sbabic@denx.de 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 003F11401DC for ; Thu, 9 Apr 2015 04:45:58 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id B7804A7429; Wed, 8 Apr 2015 20:45:55 +0200 (CEST) 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 31aSy9L6RZXG; Wed, 8 Apr 2015 20:45:55 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 0D9BCA7421; Wed, 8 Apr 2015 20:45:55 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 90EA9A7421 for ; Wed, 8 Apr 2015 20:45:52 +0200 (CEST) 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 Z0bPJ7gxVOU5 for ; Wed, 8 Apr 2015 20:45:52 +0200 (CEST) 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 mail-pd0-f171.google.com (mail-pd0-f171.google.com [209.85.192.171]) by theia.denx.de (Postfix) with ESMTPS id 10056A7420 for ; Wed, 8 Apr 2015 20:45:49 +0200 (CEST) Received: by pdbqa5 with SMTP id qa5so67228330pdb.1 for ; Wed, 08 Apr 2015 11:45:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=3VkJt6VbqRd8KW6aPT5B4HSXICxo33LvEHz/sjRTAFA=; b=gKtyl9lqncErdZ9OkuQWtBBcveiiB8xwVy3l/TFFN77NNJG4tI59cfqRbhpDqvyZlW SMFC7T8q5btHX447dMYOkbKXV3Fo0IGrL92UFwe+k2naGWhfNFq6uvI90knJXsOHVWNy ArxTv5PaeBkSY//u6rHvIyPIlFZQlt8vhL6KzU95pjNH0NIksGFGIyhhsq2Oq58LUwXx Owjhu5w7XdRdiLwfDF30F33j1n+DbCogd5lCtZQtFyWYTv3ee0KFnaY1y7RssGiXZvfx TOJAgCPsR/QSA1ahd/DyAiwXOF+i53FpeWRUuy5W7HD4T+mrTYpSLML8xxAI/onRs55/ FPKA== X-Gm-Message-State: ALoCoQk2zfiDrpL7Y0t/JF0wVbeDPyMHIawA/KGpPaJ+bHbPb2ZbnPkLS2oS21vRJikFnLQTw7Ha X-Received: by 10.68.223.226 with SMTP id qx2mr48945765pbc.71.1428518747478; Wed, 08 Apr 2015 11:45:47 -0700 (PDT) Received: from tharvey.gw (68-189-91-139.static.snlo.ca.charter.com. [68.189.91.139]) by mx.google.com with ESMTPSA id fa2sm12033461pdb.39.2015.04.08.11.45.46 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 08 Apr 2015 11:45:46 -0700 (PDT) From: Tim Harvey To: Simon Glass Date: Wed, 8 Apr 2015 11:45:39 -0700 Message-Id: <1428518739-4328-1-git-send-email-tharvey@gateworks.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: References: Cc: u-boot@lists.denx.de Subject: [U-Boot] [PATCH v2] fdt: add new fdt_fixup_display function to configure display X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 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" Add 'fdt_fixup_display' function to fixup device-tree native-mode property of display-timings node to select timings for a specific display. This is useful if a device-tree has configurations for multiple display timings for undetectable displays. see kernel Documentation/devicetree/bindings/video/display-timing.txt Signed-off-by: Tim Harvey Acked-by: Simon Glass --- v2: - use explicit error code - return fdt_setprop_u32 to all error checking by caller - add comments to function prototype - added more verbosity to commit log --- common/fdt_support.c | 29 +++++++++++++++++++++++++++++ include/fdt_support.h | 13 +++++++++++++ 2 files changed, 42 insertions(+) diff --git a/common/fdt_support.c b/common/fdt_support.c index 8266bca..c5ed5ad 100644 --- a/common/fdt_support.c +++ b/common/fdt_support.c @@ -1560,3 +1560,32 @@ int fdt_setup_simplefb_node(void *fdt, int node, u64 base_address, u32 width, return 0; } + +/* + * Update native-mode in display-timings from display environment variable. + * The node to update are specified by path. + */ +int fdt_fixup_display(void *blob, const char *path, const char *display) +{ + int off, toff; + + if (!display || !path) + return -FDT_ERR_NOTFOUND; + + toff = fdt_path_offset(blob, path); + if (toff >= 0) + toff = fdt_subnode_offset(blob, toff, "display-timings"); + if (toff < 0) + return toff; + + for (off = fdt_first_subnode(blob, toff); + off >= 0; + off = fdt_next_subnode(blob, off)) { + uint32_t h = fdt_get_phandle(blob, off); + debug("%s:0x%x\n", fdt_get_name(blob, off, NULL), + fdt32_to_cpu(h)); + if (strcasecmp(fdt_get_name(blob, off, NULL), display) == 0) + return fdt_setprop_u32(blob, toff, "native-mode", h); + } + return toff; +} diff --git a/include/fdt_support.h b/include/fdt_support.h index ae5e8a3..5d4f28d 100644 --- a/include/fdt_support.h +++ b/include/fdt_support.h @@ -47,6 +47,19 @@ int fdt_find_and_setprop(void *fdt, const char *node, const char *prop, const void *val, int len, int create); void fdt_fixup_qe_firmware(void *fdt); +/** + * Update native-mode property of display-timings node to the phandle + * of the timings matching a display by name (case insensitive). + * + * see kernel Documentation/devicetree/bindings/video/display-timing.txt + * + * @param blob FDT blob to update + * @param path path within dt + * @param display name of display timing to match + * @return 0 if ok, or -FDT_ERR_... on error + */ +int fdt_fixup_display(void *blob, const char *path, const char *display); + #if defined(CONFIG_HAS_FSL_DR_USB) || defined(CONFIG_HAS_FSL_MPH_USB) void fdt_fixup_dr_usb(void *blob, bd_t *bd); #else