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 904E3C54EBC for ; Tue, 10 Jan 2023 15:51:03 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 93CA085524; Tue, 10 Jan 2023 16:49:41 +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="JqT5T1Xc"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D2BB0855B2; Tue, 10 Jan 2023 16:49:37 +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 9ADDB8555F for ; Tue, 10 Jan 2023 16:48:38 +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-f72.google.com (mail-pj1-f72.google.com [209.85.216.72]) by mx-outbound46-71.eu-central-1c.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 10 Jan 2023 15:48:30 +0000 Received: by mail-pj1-f72.google.com with SMTP id y2-20020a17090a784200b00225c0839b80so4932378pjl.5 for ; Tue, 10 Jan 2023 07:48:31 -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=GAnrAuxWL+ahygNFeu9syAGmtdUNaH32HFp3PzGmxqc=; b=JqT5T1XcXdE+IvZzFQXOJ+C81Nr6qYLrcc2QRIBe+I7/fBnRw0wCc46A3i9QJhFPFy J7bxUXCZD13sHd0YetTMoHHedZdOVO0S1tRknXJrp4hcZG2zmYfbM5QDRoYPWwLX4fqD bFMvR8SB0yq2+0w0TSqdnnL0JaO9Q4bFZo5ds= 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=GAnrAuxWL+ahygNFeu9syAGmtdUNaH32HFp3PzGmxqc=; b=3SbtvnvewgmOIOjbE5LGQF97NMXWg5kFr4IZ0BP1d/Z2oeHCzIaoSWKnglyvBS+Ryp 49aVaDcDK8QedQU5h8QAiSzoEx2Rz/+XywjtlxXT3p8zBYd8YMEJbPBDNa6bo9K03vXq x2yh9OBVJihKm2Fvhh93jRzPOYfvw+5EbNJ6NCnlHgMY9K2DvWZJcj34Vynv5R2BY5tB JSTgBPqzKOTNIeKi4fy8rJCKOXG/Lkv5ikbieMsb6kKJ9lSP29GslLIpU5dn9rI3p1zD C6zzMWA47d15isqiMwuhwuHE1IUf42EDUoZb1H/WD/wdk4sw1uOVN5pGD5k+j9ug0Pm/ A1Vw== X-Gm-Message-State: AFqh2krpCl8Ej10R2L+1LpNJV2QK2alQmBujc8x11AXZBK6TShsrmOF8 +3ajSMkxB6gZd4Ml7zuVFXTmoAzFvIIzuQZ8TX0BxUCQh/nGMox9TxbdmqlJ00uQ3JHZOuTWI+O joBus4r0q1sqmjyzEGaIeZzLXdET+vq9DI4bsSYsFz5KTGPEJKQ== X-Received: by 2002:a05:6a20:4295:b0:a8:8714:233b with SMTP id o21-20020a056a20429500b000a88714233bmr106363071pzj.57.1673365709034; Tue, 10 Jan 2023 07:48:29 -0800 (PST) X-Google-Smtp-Source: AMrXdXuSkFNC+WHWddTwGkhd4q0lWu5Jj86vdGuDVOBkjNJ3ldbpBxaaSjhBuQYIYCtqWmxOYgvoOQ== X-Received: by 2002:a05:6a20:4295:b0:a8:8714:233b with SMTP id o21-20020a056a20429500b000a88714233bmr106363044pzj.57.1673365708679; Tue, 10 Jan 2023 07:48:28 -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.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Jan 2023 07:48:28 -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 08/12] board: ti: j721s2: Add board_init and support for selecting DT based on EEPROM Date: Tue, 10 Jan 2023 21:17:54 +0530 Message-Id: <20230110154758.16256-9-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: 1673365710-311847-5637-15349-1 X-BESS-VER: 2019.1_20221214.2106 X-BESS-Apparent-Source-IP: 209.85.216.72 X-BESS-Outbound-Spam-Score: 0.40 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.245375 [from cloudscan23-101.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 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 9b159e3d5c..c86715fa21 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" @@ -207,3 +208,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