From mboxrd@z Thu Jan 1 00:00:00 1970 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 66425C6FD1D for ; Tue, 4 Apr 2023 20:30:12 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 7C44F85816; Tue, 4 Apr 2023 22:30:08 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="Vx4SORm9"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 4918585B61; Tue, 4 Apr 2023 22:30:03 +0200 (CEST) Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) (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 C6DB781E3E for ; Tue, 4 Apr 2023 22:29:59 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=pali@kernel.org Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 1A00063760; Tue, 4 Apr 2023 20:29:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5E758C433EF; Tue, 4 Apr 2023 20:29:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1680640197; bh=mPHMyAq7c2IOlt9TocPuX/fknHCI5dZDTkkFBJk2lak=; h=From:To:Cc:Subject:Date:From; b=Vx4SORm9FJd3mPJDX7P1K4yI/xu/R+KrAerQYIcPe2+foj41p8UPtF7/5HWqfQbQo ZsRi51Lhp9NCIW7xaib3R0NgX6mDk7yNx4Nbwdwe0kNsVzm47gxnoPNQGfYWPMp0iA vi35KCME9jT27ECFaMesIqaj7xz5B+X7wjd/wPpbLSVS2RjYRGXHyzOGUBxUZusCfi JktrDsV+YIHVjWuZwrlCPlqHxKW7r6gx11biyo2XfsewtNhjCu96Tnd02tTFV01bCr yBwD5NcF5R2OMHHEwijAW63Zqkzky3w0ZFRYFNtIzkCSY341rVz9ceA8tUQd5tFpOw D+IHCvJwUvWUA== Received: by pali.im (Postfix) id 34457CD5; Tue, 4 Apr 2023 22:29:54 +0200 (CEST) From: =?UTF-8?q?Pali=20Roh=C3=A1r?= To: Jaehoon Chung , Peng Fan , Simon Glass Cc: u-boot@lists.denx.de Subject: [PATCH u-boot] mmc: spl: Add comments for default_spl_mmc_emmc_boot_partition() Date: Tue, 4 Apr 2023 22:28:05 +0200 Message-Id: <20230404202805.8523-1-pali@kernel.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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.8 at phobos.denx.de X-Virus-Status: Clean Add documentation what is default_spl_mmc_emmc_boot_partition() function doing, what each return value from this function means and why there is magic conversion from 7 to 0. Also add FIXME comment for future fixes. All information is based on the JEDEC eMMC JESD84-A441 specification. Signed-off-by: Pali Rohár --- This patch depends on another patch: mmc: Use EXT_CSD_EXTRACT_BOOT_PART() macro for extracting boot part https://patchwork.ozlabs.org/project/uboot/patch/20230311104427.18421-1-pali@kernel.org/ --- common/spl/spl_mmc.c | 42 +++++++++++++++++++++++++++++++++++++++--- 1 file changed, 39 insertions(+), 3 deletions(-) diff --git a/common/spl/spl_mmc.c b/common/spl/spl_mmc.c index a0722167044f..2426500dbcb9 100644 --- a/common/spl/spl_mmc.c +++ b/common/spl/spl_mmc.c @@ -370,13 +370,49 @@ unsigned long __weak spl_mmc_get_uboot_raw_sector(struct mmc *mmc, int default_spl_mmc_emmc_boot_partition(struct mmc *mmc) { int part; + /* + * This function returns the eMMC partition from which + * would be loaded next payload (e.g. U-Boot proper). + * This partition will be set into eMMC partition access + * register and therefore return value of this function + * has same meaning as EXT_CSD_EXTRACT_PARTITION_ACCESS. + * + * Meaning of EXT_CSD_EXTRACT_PARTITION_ACCESS (3-bit) is: + * 0 - User area + * 1 - Boot partition 1 + * 2 - Boot partition 2 + * 3 - Replay Protected Memory Block (RPMB) + * 4 - General Purpose partition 1 + * 5 - General Purpose partition 2 + * 6 - General Purpose partition 3 + * 7 - General Purpose partition 4 + */ #ifdef CONFIG_SYS_MMCSD_RAW_MODE_EMMC_BOOT_PARTITION part = CONFIG_SYS_MMCSD_RAW_MODE_EMMC_BOOT_PARTITION; #else /* - * We need to check what the partition is configured to. - * 1 and 2 match up to boot0 / boot1 and 7 is user data - * which is the first physical partition (0). + * When explicit CONFIG_SYS_MMCSD_RAW_MODE_EMMC_BOOT_PARTITION + * config option was not chosen during build time we choose + * the boot partition based on the eMMC boot partition enable + * register (EXT_CSD_EXTRACT_BOOT_PART). + * + * Meaning of EXT_CSD_EXTRACT_BOOT_PART (3-bit) value is: + * 0 - Booting from this eMMC device is disabled + * 1 - Boot partition 1 is used for booting + * 2 - Boot partition 2 is used for booting + * 3 - Reserved + * 4 - Reserved + * 5 - Reserved + * 6 - Reserved + * 7 - User area is used for booting + * + * Note: See difference between EXT_CSD_EXTRACT_PARTITION_ACCESS + * and EXT_CSD_EXTRACT_BOOT_PART, specially about User area value. + * + * FIXME: When booting from this eMMC device is explicitly + * disabled then we use User area for booting. This is incorrect. + * Probably we should skip this eMMC device and select the next + * one for booting. Or at least throw warning about this fallback. */ part = EXT_CSD_EXTRACT_BOOT_PART(mmc->part_config); if (part == 7) -- 2.20.1