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 C906DC54EBC for ; Tue, 10 Jan 2023 15:50:12 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 94E2785531; Tue, 10 Jan 2023 16:49:27 +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="AGd9bcf1"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 2D5648559B; Tue, 10 Jan 2023 16:48:59 +0100 (CET) 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 F38C280843 for ; Tue, 10 Jan 2023 16:48:26 +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-f71.google.com (mail-pj1-f71.google.com [209.85.216.71]) 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 15:48:24 +0000 Received: by mail-pj1-f71.google.com with SMTP id mh11-20020a17090b4acb00b002271dde7ec6so1222266pjb.0 for ; Tue, 10 Jan 2023 07:48:25 -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=ct2gYHx/kmOuRNN48d8E4ul4g/FeaWJvwVBLcGo8MK4=; b=AGd9bcf1X1HWgGfsZfC/da6+YOrRcklpJqHsvRiDe5oPVlJ3KM1y1E411werFmaJGy Cn6CPcwmlSvRTAP0IBSo0zbNAveONQ1J/uLMMhFtRFTQJfHeIo7pJM1uzvm4CBShRuIj SDuqu2o0Vvu+vVBWL7rqE2Lqd9OHA4o4arxdg= 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=ct2gYHx/kmOuRNN48d8E4ul4g/FeaWJvwVBLcGo8MK4=; b=O63imAg2KjGDlt9qLZhsdMOgROLZc2LXSB87YadOHVAVGMx/GmiuzuSnVLNEH1H39y l8EMV349duZ5+/o3PzDJ0KiOd5W6vAeyrA9y4swpviqY2BZ8i85tUQ+4odBUxx8K9VFI Tf+dQ176l5CMjtvGA4a2lrh/Lyaj9Y50jpD3WKCT+wWDJYA02uCuBzU2od9U3V68yYLK FUK/jvUl7tgSDyaiCRNVWtXFNCKkIG4u7lHP3L8OVQvlbETKPwsQY7NKvppqkXKG3ML/ dgFEBdLigSvsRiE9/6rQ/clgspMZenmnfwpEdh2xKgej5FwO83iYAj4HfWBLhKO48FH5 sVyw== X-Gm-Message-State: AFqh2kpHgJNV0eCuityM7gz6nYFdUOH41RZ6+OAG9lEO841BQMf1lF2H ZDvaGQcD9N/OOwgIcEczyEstnNOsl9HD3bi0wfer/2BpPkwzAvqbhGcaedAy4GYvzScw/802Rw+ AEWuVw+O0bB0NjiJ3VVUFTSjBb+sjMai0zE4jCJjJP1Ja3jkjMw== X-Received: by 2002:a05:6a20:4291:b0:b0:47e7:6cba with SMTP id o17-20020a056a20429100b000b047e76cbamr94689977pzj.46.1673365703304; Tue, 10 Jan 2023 07:48:23 -0800 (PST) X-Google-Smtp-Source: AMrXdXvusEtSyBL0XtQ8+jycNrwbKWLHrBxtHNMovbvBUP4HyFZenbPG6pLUWsB7Exx2I93Ldgvx1g== X-Received: by 2002:a05:6a20:4291:b0:b0:47e7:6cba with SMTP id o17-20020a056a20429100b000b047e76cbamr94689952pzj.46.1673365702939; Tue, 10 Jan 2023 07:48:22 -0800 (PST) Received: from localhost.localdomain ([49.207.204.53]) by smtp.gmail.com with ESMTPSA id z18-20020a63e112000000b004767bc37e03sm7047976pgh.39.2023.01.10.07.48.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Jan 2023 07:48:22 -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: [RESEND PATCH V5 06/12] board: ti: j721s2: Add support for detecting multiple device trees Date: Tue, 10 Jan 2023 21:17:52 +0530 Message-Id: <20230110154758.16256-7-sinthu.raja@ti.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20230110154758.16256-1-sinthu.raja@ti.com> References: <20230110154758.16256-1-sinthu.raja@ti.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BESS-ID: 1673365704-305754-5402-16490-1 X-BESS-VER: 2019.1_20221214.2106 X-BESS-Apparent-Source-IP: 209.85.216.71 X-BESS-Outbound-Spam-Score: 0.40 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.245375 [from cloudscan10-87.eu-central-1a.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.00 BSF_BESS_OUTBOUND META: BESS Outbound 0.40 BSF_SC0_SA085b META: Custom Rule SA085b X-BESS-Outbound-Spam-Status: SCORE=0.40 using account:ESS91090 scores of KILL_LEVEL=7.0 tests=BSF_SC0_MISMATCH_TO, BSF_BESS_OUTBOUND, BSF_SC0_SA085b 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 | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/board/ti/j721s2/evm.c b/board/ti/j721s2/evm.c index db69aa1507..9b159e3d5c 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,28 @@ static void setup_serial(void) } #endif +/* + * This function chooses the right dtb based on the board name read from + * EEPROM if the EEPROM is programmed. Also, by default the boot chooses + * the EVM DTB if there is no EEPROM is programmed or not detected. + */ +#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)) { -- 2.36.1