From patchwork Tue Jan 10 13:10:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sinthu Raja X-Patchwork-Id: 1724045 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=mistralsolutions.com header.i=@mistralsolutions.com header.a=rsa-sha256 header.s=google header.b=LZVwrsiy; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Nrrp95NsQz23gB for ; Wed, 11 Jan 2023 00:12:49 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 6ABAC854B1; Tue, 10 Jan 2023 14:11:52 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=mistralsolutions.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=mistralsolutions.com header.i=@mistralsolutions.com header.b="LZVwrsiy"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 64F9E85482; Tue, 10 Jan 2023 14:11:20 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.2 Received: from egress-ip4b.ess.de.barracuda.com (egress-ip4b.ess.de.barracuda.com [18.185.115.208]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 30931854D4 for ; Tue, 10 Jan 2023 14:10:54 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=mistralsolutions.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sinthu.raja@mistralsolutions.com Received: from mail-pj1-f70.google.com (mail-pj1-f70.google.com [209.85.216.70]) by mx-outbound22-122.eu-central-1b.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 10 Jan 2023 13:10:51 +0000 Received: by mail-pj1-f70.google.com with SMTP id pi14-20020a17090b1e4e00b0021d20da7a51so9220070pjb.2 for ; Tue, 10 Jan 2023 05:10:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mistralsolutions.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=pHiYTSf7+c7ucGSXHC7E5+qTEYY8eQCsCpJf0O2I0Hs=; b=LZVwrsiytzipA2lugPk7zJDCTmOc2eZPK4165PQSnVA0Fi+fKWG1X82oDK6lkZITd1 TY99EsG0O9e9YxAbta7V3gnCDUqlNd8XGBYkeF2SmQkSYdHFMniwh1rBMitwJyahOeBo Hm9DH7AYQQMolO8WrKrN8tSYkbh2MkaDaqCeA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=pHiYTSf7+c7ucGSXHC7E5+qTEYY8eQCsCpJf0O2I0Hs=; b=oGwNXIrCudYuUjcPvHFekV00nR2rRs3l6HZru5oJz6/ahRzFqh2m4deDSEodsHO4sE ZrvJGODcDtsqqxxhaXKfMtGFBPaKaije/jPDfzrRe7sXx6RcXcpsCzj9ImkULvzR7P// A8DAokyhHo5ttMXOCfemALjutGcg2ysikAz/ZeUP34ex9a2Vg/2A+JrMp1op4evpHgUD RtQq1HjmYc0DQA+wyZUBWFh70dyKjvpee1bQFprFzCfKjo8t4PSx2LMn+20rGRz7b+v+ rJpMD9V/dvRopCVCByh/OZ+/N21OxO08zFI9GnVvqBkKSgVhaecg9fetUIh/eQX0DA6/ tSEA== X-Gm-Message-State: AFqh2kryMTs8j13DgPeXQZuMyXYvDdYlkOe3r0aSrKDJmqQMUtdsNYZL wKW2KL8MCXPiv4dc6zLIMVS66z4ltTFI2GtiCja3XKB3aUxVrc4hQEuDmH+dMjhymvnsYRZed1m PwEPhkIS3dpZSLRrdN/RNtvTevRGBaYxmTcuc3QIdjDQKWpkxCA== X-Received: by 2002:a05:6a20:d817:b0:af:745f:7838 with SMTP id iv23-20020a056a20d81700b000af745f7838mr95792503pzb.30.1673356249462; Tue, 10 Jan 2023 05:10:49 -0800 (PST) X-Google-Smtp-Source: AMrXdXvm09IKYGXA8HO+BYcxmQOnrrC2KfRdyYjZ8uVKI2Zy40PpvRuPU5F+PWcrbA4f8RWCeOcD4g== X-Received: by 2002:a05:6a20:d817:b0:af:745f:7838 with SMTP id iv23-20020a056a20d81700b000af745f7838mr95792483pzb.30.1673356249169; Tue, 10 Jan 2023 05:10:49 -0800 (PST) Received: from LAP568U.mistral.in ([106.51.227.150]) by smtp.gmail.com with ESMTPSA id 14-20020a630c4e000000b00478f87eaa44sm6654907pgm.35.2023.01.10.05.10.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Jan 2023 05:10:48 -0800 (PST) From: Sinthu Raja X-Google-Original-From: Sinthu Raja To: u-boot@lists.denx.de, Tom Rini , Marcel Ziswiler , Marek Vasut , Vignesh Raghavendra Cc: Sinthu Raja Subject: [PATCH V5 06/12] board: ti: j721s2: Add support for detecting multiple device trees Date: Tue, 10 Jan 2023 18:40:10 +0530 Message-Id: <20230110131016.12480-7-sinthu.raja@ti.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20230110131016.12480-1-sinthu.raja@ti.com> References: <20230110131016.12480-1-sinthu.raja@ti.com> MIME-Version: 1.0 X-BESS-ID: 1673356250-305754-5398-7032-1 X-BESS-VER: 2019.1_20221214.2106 X-BESS-Apparent-Source-IP: 209.85.216.70 X-BESS-Outbound-Spam-Score: 0.40 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.245374 [from cloudscan22-139.eu-central-1b.ess.aws.cudaops.com] Rule breakdown below pts rule name description ---- ---------------------- -------------------------------- 0.00 BSF_SC0_MISMATCH_TO META: Envelope rcpt doesn't match header 0.40 BSF_SC0_SA085b META: Custom Rule SA085b 0.00 BSF_BESS_OUTBOUND META: BESS Outbound X-BESS-Outbound-Spam-Status: SCORE=0.40 using account:ESS91090 scores of KILL_LEVEL=7.0 tests=BSF_SC0_MISMATCH_TO, BSF_SC0_SA085b, BSF_BESS_OUTBOUND X-BESS-BRTS-Status: 1 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.6 at phobos.denx.de X-Virus-Status: Clean From: Sinthu Raja Update the board_fit_config_name_match() to choose the right dtb based on the board name read from EEPROM. Also restrict multpile EEPROM reads by verifying if EEPROM is already read Signed-off-by: Sinthu Raja --- Changes in V5: ============= - Add comment to board_fit_config_name_match API as per the review. No Changes in V3 and V4. Changes in V2: ============= Address review comments: - Remove support for detecting multiple device trees using different DTB V1: https://patchwork.ozlabs.org/project/uboot/patch/20221027104846.11820-7-sinthu.raja@ti.com/ V2: https://patchwork.ozlabs.org/project/uboot/patch/20221221135219.24702-7-sinthu.raja@ti.com/ V4: https://patchwork.ozlabs.org/project/uboot/patch/20230104094350.19394-7-sinthu.raja@ti.com/ board/ti/j721s2/evm.c | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/board/ti/j721s2/evm.c b/board/ti/j721s2/evm.c index a3adb8704e..63788f8e44 100644 --- a/board/ti/j721s2/evm.c +++ b/board/ti/j721s2/evm.c @@ -72,16 +72,6 @@ int dram_init_banksize(void) return 0; } -#ifdef CONFIG_SPL_LOAD_FIT -int board_fit_config_name_match(const char *name) -{ - if (!strcmp(name, "k3-j721s2-common-proc-board")) - return 0; - - return -1; -} -#endif - #if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP) int ft_board_setup(void *blob, struct bd_info *bd) { @@ -111,6 +101,9 @@ int do_board_detect(void) { int ret; + if (board_ti_was_eeprom_read()) + return 0; + ret = ti_i2c_eeprom_am6_get_base(CONFIG_EEPROM_BUS_ADDRESS, CONFIG_EEPROM_CHIP_ADDRESS); if (ret) { @@ -179,6 +172,27 @@ static void setup_serial(void) } #endif +/* + * This function chooses the right dtb based on the board name read from + * EEPROM, and it is the safe default for the SoC. + */ +#ifdef CONFIG_SPL_LOAD_FIT +int board_fit_config_name_match(const char *name) +{ + bool eeprom_read = board_ti_was_eeprom_read(); + + if (!eeprom_read || board_is_j721s2_som()) { + if (!strcmp(name, "k3-j721s2-common-proc-board")) + return 0; + } else if (!eeprom_read || board_is_am68_sk_som()) { + if (!strcmp(name, "k3-am68-sk-base-board")) + return 0; + } + + return -1; +} +#endif + int board_late_init(void) { if (IS_ENABLED(CONFIG_TI_I2C_BOARD_DETECT)) {