Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 238CFC433EF for ; Thu, 19 May 2022 12:57:42 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C1CA183D9B; Thu, 19 May 2022 14:57:39 +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=1652965060; bh=mK1LnhoCEtqt5v59Wi54ILNOTdqf9EMie3C6bvFWEAY=; h=Date:Subject:To:Cc:References:From:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=WQREivdIAaxR9apM/Yo4LZ1Kdx5bovnv4648l+i1lFj+1VNqiqnUOSZKmNaeo0533 TGiMh1q9Oaj6N6JuZPdgAw17+itpSYp9iaw6QU9aRXrl3e0iXc2xnmCHpo+W4uc3Lv fP2BKIuWIwHpNELAbhO36mOUzIQu7Sk3NvTBaN0keyHqEVHi6d9UAElqJd6Z50EckS yvTL+gs72I7qIdo4YlWBL6eJ4bHOXWoy733gUP1UAwhK5KIMA1Q8EgpVefuNgODUsC DzHc0oany4lzbWzBLu+BAlSXfgw3KBzrYRRn+vUQXSg4OTUqj4drGq7h2l1Ym+qvDi h8Momm4aVFeCw== Received: from [127.0.0.1] (p578adb1c.dip0.t-ipconnect.de [87.138.219.28]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: marex@denx.de) by phobos.denx.de (Postfix) with ESMTPSA id 6D8BB83D5D; Thu, 19 May 2022 14:57:37 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1652965058; bh=mK1LnhoCEtqt5v59Wi54ILNOTdqf9EMie3C6bvFWEAY=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=QSe5hP8DvcjyAfvu3EuOVogjzwyDO4JFm+zQLPJrQA7rT2rKDCXI9jKAIhUEUapQv JuVk+WDEr+T3iG2BIgilcYzTN2rsPcCp5DRqMI87jVbkyn8vnW8IAT/ky3hj62Ovjj xR7m+OXuVRnPq17lq43VjTvog+3HqJqcy7A87FJyPeYAejMvGZWag2e4N594UMCjC+ JpVx6FYR5Iiqm25lCkHtnJlwRtVwS1ai9pyFJOdO3MFyqf61rQ6jfw6VIEMT4wTUnX QaIR+U5TadhmQRCp4ziO5o+KpAMxbD8BaUb1mVLm2E1ItujCE7sEDJDEUe8DN8DJfF HGJ3FNx8aLPzg== Message-ID: <1d333b3b-77ae-7c19-54a1-182d08841306@denx.de> Date: Thu, 19 May 2022 14:57:36 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.8.1 Subject: Re: [PATCH 8/8] ARM: imx6: Adapt device tree selection in DH board file Content-Language: en-US To: Philip Oberfichtner , u-boot@lists.denx.de Cc: Fabio Estevam , Christoph Niedermaier , Stefano Babic , Peng Fan , Andreas Geisreiter , Tom Rini , u-boot@dh-electronics.com References: <20220519110837.245488-1-pro@denx.de> <20220519110837.245488-9-pro@denx.de> From: Marek Vasut In-Reply-To: <20220519110837.245488-9-pro@denx.de> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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 On 5/19/22 13:08, Philip Oberfichtner wrote: > 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 > --- > > board/dhelectronics/dh_imx6/dh_imx6.c | 22 ++++++++++++++-------- > 1 file changed, 14 insertions(+), 8 deletions(-) > > diff --git a/board/dhelectronics/dh_imx6/dh_imx6.c b/board/dhelectronics/dh_imx6/dh_imx6.c > index 6059f96e80..c63fc1dd8a 100644 > --- a/board/dhelectronics/dh_imx6/dh_imx6.c > +++ b/board/dhelectronics/dh_imx6/dh_imx6.c > @@ -227,14 +227,20 @@ int checkboard(void) > #ifdef CONFIG_MULTI_DTB_FIT > int board_fit_config_name_match(const char *name) > { > - if (is_mx6dq()) { > - if (!strcmp(name, "imx6q-dhcom-pdk2")) > - return 0; > - } else if (is_mx6sdl()) { Careful here ^ is_mx6sdl() matches on Solo and DualLite. > - if (!strcmp(name, "imx6dl-dhcom-pdk2")) > - return 0; > - } > + /* Determine carrier board at compile time and SoM at runtime */ > + const size_t size = 32; > + char *car, *som, dt[size]; > + > + car = strchr(CONFIG_DEFAULT_DEVICE_TREE, '-'); /* i.e. -dhcom-drc02 */ > + > + som = is_mx6dq() ? "imx6q" : > + is_mx6dl() ? "imx6dl" : > + is_mx6solo() ? "imx6s" : NULL; > + > + if (!(car && som)) > + return -1; > > - return -1; > + snprintf(dt, size, "%s%s", som, car); > + return strcmp(name, dt); This will break imx6s-dhcom-pdk2 , which used the imx6dl-dhcom-pdk2 DT which was fine, because U-Boot is single core anyway. Try something like this: /* Test SoC prefix */ if (is_mx6dq()) { if (strncmp(name, "imx6q-")) return -1; } else if (is_mx6sdl()) { if (strncmp(name, "imx6s-") && strncmp(name, "imx6dl-")) return -1; } /* Test board suffix */ a = strchr(CONFIG_DEFAULT_DEVICE_TREE, '-'); /* i.e. -dhcom-drc02 */ b = strchr(name, '-'); /* i.e. -dhcom-drc02 */ return strcmp(a, b) ? -1 : 0; I _think_ that should work and cover all combinations. (and of course, pick better variable names than a,b)