From patchwork Fri May 20 08:46:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philip Oberfichtner X-Patchwork-Id: 1633752 X-Patchwork-Delegate: sbabic@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=denx.de header.i=@denx.de header.a=rsa-sha256 header.s=phobos-20191101 header.b=feOwmGIz; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4L4L410n2fz9sG0 for ; Fri, 20 May 2022 18:48:49 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 62AC183D90; Fri, 20 May 2022 10:48:12 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1653036492; bh=gvsDeqlioIUgRv8x2yhibdbE3xWkqso0awWq935AiF0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=feOwmGIzE7VKCV8+MwaYE6Ud1fDDCIwl4XeCmeAJKdBPDo8r98Hh5ag/MRVGIq7/X 8P8mmMF8SvrtOKC3Qlq1RXXkK/IUXKi2sJS7QqgCkTzX20wCVWUWLfjJewrGYj2WTo HI7qn0HfogIrpexIGv/KAAKdRtG+Fpps+EyvbN82FXceGBDU51BYD2VOLgN1u230z/ tva3J0JLI2ANizCvCqgDdl03teCBCf/ng0tVTDVa9P6F4am8KVOEaS+Hm7GrRljMA7 eNegOb91X1POmNufFVccQxHMOseXJbWzD3Tlj99DndM7a/Sdu524CsrQa6Pzzx84dg qWr0Y2WzbcicA== Received: by phobos.denx.de (Postfix, from userid 109) id 37ED683994; Fri, 20 May 2022 10:47:21 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.3 required=5.0 tests=BAYES_00,RDNS_NONE, SPF_HELO_NONE,SPF_NEUTRAL,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 Received: from xpert.denx.de (unknown [62.91.23.180]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 5158783994 for ; Fri, 20 May 2022 10:47:04 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=pro@denx.de Received: by xpert.denx.de (Postfix, from userid 535) id 0C7A13E0626; Fri, 20 May 2022 10:47:04 +0200 (CEST) From: Philip Oberfichtner To: u-boot@lists.denx.de Cc: Stefano Babic , Christoph Niedermaier , Peng Fan , Fabio Estevam , Marek Vasut , Philip Oberfichtner , Andreas Geisreiter , Tom Rini , u-boot@dh-electronics.com Subject: [PATCH v2 8/8] ARM: imx6: Adapt device tree selection in DH board file Date: Fri, 20 May 2022 10:46:26 +0200 Message-Id: <20220520084626.656293-9-pro@denx.de> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220520084626.656293-1-pro@denx.de> References: <20220520084626.656293-1-pro@denx.de> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean Before this commit device tree selection could rely solely on differentiating the iMX6 processor variant Q and DL. After adding two new carrier boards, the DRC02 and the picoITX, the interchangeability of SoMs makes this approach infeasible. It is now required to specify the carrier board (dhcom-drc02, dhcom-picoitx or dhcom-pdk2) at compile time using CONFIG_DEFAULT_DEVICETREE. The SoM is determined at runtime as before. Signed-off-by: Philip Oberfichtner Reviewed-by: Marek Vasut --- Changes in v2: - Rewrite board_fit_config_name_match - Return -EINVAL instead of -1 board/dhelectronics/dh_imx6/dh_imx6.c | 31 +++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/board/dhelectronics/dh_imx6/dh_imx6.c b/board/dhelectronics/dh_imx6/dh_imx6.c index 6059f96e80..e8aba83e1a 100644 --- a/board/dhelectronics/dh_imx6/dh_imx6.c +++ b/board/dhelectronics/dh_imx6/dh_imx6.c @@ -225,16 +225,35 @@ int checkboard(void) } #ifdef CONFIG_MULTI_DTB_FIT +static int strcmp_prefix(const char *s1, const char *s2) +{ + size_t n; + + n = min(strlen(s1), strlen(s2)); + return strncmp(s1, s2, n); +} + int board_fit_config_name_match(const char *name) { - if (is_mx6dq()) { - if (!strcmp(name, "imx6q-dhcom-pdk2")) - return 0; - } else if (is_mx6sdl()) { - if (!strcmp(name, "imx6dl-dhcom-pdk2")) + char *want; + char *have; + + /* Test Board suffix, e.g. -dhcom-drc02 */ + want = strchr(CONFIG_DEFAULT_DEVICE_TREE, '-'); + have = strchr(name, '-'); + + if (!want || !have || strcmp(want, have)) + return -EINVAL; + + /* Test SoC prefix */ + if (is_mx6dq() && !strcmp_prefix(name, "imx6q-")) + return 0; + + if (is_mx6sdl()) { + if (!strcmp_prefix(name, "imx6s-") || !strcmp_prefix(name, "imx6dl-")) return 0; } - return -1; + return -EINVAL; } #endif