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 513DEC46467 for ; Tue, 10 Jan 2023 13:13:13 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 9B90A85502; Tue, 10 Jan 2023 14:11:59 +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="SX8IraSS"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 1B4108551B; Tue, 10 Jan 2023 14:11:38 +0100 (CET) Received: from egress-ip33a.ess.de.barracuda.com (egress-ip33a.ess.de.barracuda.com [18.185.115.192]) (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 73F118551C for ; Tue, 10 Jan 2023 14:11:15 +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-pl1-f200.google.com (mail-pl1-f200.google.com [209.85.214.200]) by mx-outbound11-148.eu-central-1a.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 10 Jan 2023 13:10:59 +0000 Received: by mail-pl1-f200.google.com with SMTP id s14-20020a17090302ce00b00192d831a155so8394986plk.11 for ; Tue, 10 Jan 2023 05:10:59 -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=KxPVfAU8wkKGKZh3ktSKviOXb0PLIrA9TH5uy8fPpFw=; b=SX8IraSSNjeKqwWrtcR4wgxbdwRJLhWNjllf1+IBTGvlrnSx1BySHaOt5Niu6m/n8o qF6B5WaFKY5p4vnsx6AFJWJG/Z91OXOwmwJMQ8yG09TB9rrrAf0O4JELELe0xS8ovrKu 3xz3JQ7GsM+LGl3CgtVDTfSyzy8hkD5NKPufc= 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=KxPVfAU8wkKGKZh3ktSKviOXb0PLIrA9TH5uy8fPpFw=; b=4kFigDEacw0eOxjt1anMV65X9xT5saKq+paoykr4YY5+lfqlzca4TFXoDJldXV6QVD IEaIhRbUurOJAt9gRI2MF60Tq9zUXjNTofst5UIv4Culp1T6dBCCiejw6q3bhgDZroh/ O2juT3grC2zjE2I/BZGdxJsHQvvcm3ToWpTjARJz0OpRgDs2wpy6Vu6zlJJoFTOoME4Q 02cBUqYwStu9c7BEYxmvR9V1IeyJcfM/kDXmEivnHvhK3MHUK1Wnyn1dAF3xqQpVd1o/ RcQnWGK3M+aMxydsK3kLaVvX79eK8QJlqQng/h7rpGRF2u8ltW+5q0LyqYaEo9ilfEtl sOSA== X-Gm-Message-State: AFqh2kqp+rQ5isqN41zUb//sbngNIeEMI4XKYjDxWnj0Wvvj2w8weyCj d3m40Z2ozGwpHALBTyol3w/wHugz7k3Kf71wVXjV59/gXLN4Gqmfgtlw9CORkZRSGvD6IzgX7NW 6Df9Camnmv94kgtbiinRk0LgBnBxyT9uCs6QOKE41KxJwJKZrXg== X-Received: by 2002:a05:6a20:2d1f:b0:b5:c751:78bb with SMTP id g31-20020a056a202d1f00b000b5c75178bbmr8266608pzl.6.1673356255008; Tue, 10 Jan 2023 05:10:55 -0800 (PST) X-Google-Smtp-Source: AMrXdXsu6KqVgwOIfwKrIksfKTpDZ2Hi4my+/cAvkPKKTbcocdjhk+YijmJgSscJicJ1/U0qv5Jqxw== X-Received: by 2002:a05:6a20:2d1f:b0:b5:c751:78bb with SMTP id g31-20020a056a202d1f00b000b5c75178bbmr8266581pzl.6.1673356254661; Tue, 10 Jan 2023 05:10:54 -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.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Jan 2023 05:10:54 -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 08/12] board: ti: j721s2: Add board_init and support for selecting DT based on EEPROM Date: Tue, 10 Jan 2023 18:40:12 +0530 Message-Id: <20230110131016.12480-9-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 Content-Transfer-Encoding: 8bit X-BESS-ID: 1673356258-302964-5495-6548-1 X-BESS-VER: 2019.1_20221214.2106 X-BESS-Apparent-Source-IP: 209.85.214.200 X-BESS-Outbound-Spam-Score: 0.40 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.245374 [from cloudscan8-85.eu-central-1a.ess.aws.cudaops.com] Rule breakdown below pts rule name description ---- ---------------------- -------------------------------- 0.00 BSF_BESS_OUTBOUND META: BESS Outbound 0.40 BSF_SC0_SA085b META: Custom Rule SA085b 0.00 BSF_SC0_MISMATCH_TO META: Envelope rcpt doesn't match header X-BESS-Outbound-Spam-Status: SCORE=0.40 using account:ESS91090 scores of KILL_LEVEL=7.0 tests=BSF_BESS_OUTBOUND, BSF_SC0_SA085b, BSF_SC0_MISMATCH_TO 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 Add the board_init_f API for SPL and run the platform-required SoC initialization. Add the functionality for board name-based DTB selection from FIT within SPL. This will make it easier to utilise one defconfig for both the EVM and the SK. Signed-off-by: Sinthu Raja Reviewed-by: Tom Rini --- Changes in V5: ============= Add Reviewed-by tag Changes in V4: ============= Address review comments: - In align wih the macro conditional statement which missed it in the previous version Changes in V3: ============= Address review comments: - Rework on DTB selection API clarity about mini-U-Boot vs EVM and family support as suggested. V2: https://patchwork.ozlabs.org/project/uboot/cover/20221221135219.24702-9-sinthu.raja@ti.com/ V3: https://patchwork.ozlabs.org/project/uboot/patch/20221227121543.22306-9-sinthu.raja@ti.com/ V4: https://patchwork.ozlabs.org/project/uboot/patch/20230104094350.19394-9-sinthu.raja@ti.com/ board/ti/j721s2/evm.c | 64 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/board/ti/j721s2/evm.c b/board/ti/j721s2/evm.c index 63788f8e44..2f6a8b9bee 100644 --- a/board/ti/j721s2/evm.c +++ b/board/ti/j721s2/evm.c @@ -23,6 +23,7 @@ #include #include #include +#include #include "../common/board_detect.h" @@ -206,3 +207,66 @@ int board_late_init(void) void spl_board_init(void) { } + +/* Support for the various EVM / SK families */ +#if defined(CONFIG_SPL_OF_LIST) && defined(CONFIG_TI_I2C_BOARD_DETECT) +void do_dt_magic(void) +{ + int ret, rescan, mmc_dev = -1; + static struct mmc *mmc; + + do_board_detect(); + + /* + * Board detection has been done. + * Let us see if another dtb wouldn't be a better match + * for our board + */ + if (IS_ENABLED(CONFIG_CPU_V7R)) { + ret = fdtdec_resetup(&rescan); + if (!ret && rescan) { + dm_uninit(); + dm_init_and_scan(true); + } + } + + /* + * Because of multi DTB configuration, the MMC device has + * to be re-initialized after reconfiguring FDT inorder to + * boot from MMC. Do this when boot mode is MMC and ROM has + * not loaded SYSFW. + */ + switch (spl_boot_device()) { + case BOOT_DEVICE_MMC1: + mmc_dev = 0; + break; + case BOOT_DEVICE_MMC2: + case BOOT_DEVICE_MMC2_2: + mmc_dev = 1; + break; + } + + if (mmc_dev > 0 && !check_rom_loaded_sysfw()) { + ret = mmc_init_device(mmc_dev); + if (!ret) { + mmc = find_mmc_device(mmc_dev); + if (mmc) { + ret = mmc_init(mmc); + if (ret) + printf("mmc init failed with error: %d\n", ret); + } + } + } +} +#endif + +#ifdef CONFIG_SPL_BUILD +void board_init_f(ulong dummy) +{ + k3_spl_init(); +#if defined(CONFIG_SPL_OF_LIST) && defined(CONFIG_TI_I2C_BOARD_DETECT) + do_dt_magic(); +#endif + k3_mem_init(); +} +#endif -- 2.36.1