Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 83C07C07E95 for ; Sat, 3 Jul 2021 02:55:57 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id AC1C461410 for ; Sat, 3 Jul 2021 02:55:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AC1C461410 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 79A54829E4; Sat, 3 Jul 2021 04:55:54 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1625280954; bh=aF0M5SUz2I+tB233/QeyTfZEPKEMtpcgfeG8R53Odz4=; h=From:To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=UjyWbIqrmTMbOjo5wWUbrGSkdCsOvJcSBU0Vrp/vUC1at+IhYIDhEFyJp/KUn/j6B K0+xlADo+8IDf4wyXgzcWRnUgPyGq68hxL64hOIwzoAiUsN2adAruG5O2AdK7fS0uQ YkUmUZdSoNVj9IjimMNDAcfpftrZjdGwnpGwuQjwQ+shZt2Eje7HR0h29cvxDTFHDs eOv0Ep/WGTWB9jGIoqln48rCif/juubrzRdIuwJ3n3hKLowoUaSB4Q4uKAEV5XV4ks ACId0pKb1aIAhi8RabfZ7qdS9jjpQOYmzPDBJjz6uDRIcpSYz8GcawbOTEUP66TOQb PGhDChAb+jK5w== Received: from tr.lan (ip-89-176-112-137.net.upcbroadband.cz [89.176.112.137]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: marex@denx.de) by phobos.denx.de (Postfix) with ESMTPSA id 8F10182959; Sat, 3 Jul 2021 04:55:52 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1625280952; bh=aF0M5SUz2I+tB233/QeyTfZEPKEMtpcgfeG8R53Odz4=; h=From:To:Cc:Subject:Date:From; b=PxmigUBG/lM2KWNx/4joxtchep5FqIMofa/vT+wu/JZbrrMf7TiNnFo5rCqHGkc6u CSYZUBBjTnTz/90xxGc16ZdBx1wTKA7ZFuw1L0NIUIf9rSXuRPWanoU+RvE3xBQjAg MLXE7lpgHTSufat89qHO3qrMzgYPa9tgjpeJG2HgiNLrHGfYM830aamKjbbRZy2L58 XipV1/S2eja8ejClL12/cvAxbxU9dc6jX5Ezitq8p8QzUsssn/dlWdpTVpEkmBlxUx ZH9TMWwkAv008G3fTWHZRg3Lg6pWamq/1Um1iCXFYmS809xE5Hi77FB60DiHBWuN5Z Mng0cBcF2rT7Q== From: Marek Vasut To: u-boot@lists.denx.de Cc: Marek Vasut , Faiz Abbas , Harald Seiler , Lokesh Vutla , Simon Glass , Fabio Estevam , Peng Fan , Stefano Babic , Ye Li Subject: [PATCH V2 1/2] spl: mmc: Factor out eMMC boot partition selection code Date: Sat, 3 Jul 2021 04:55:32 +0200 Message-Id: <20210703025533.298144-1-marex@denx.de> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.2 at phobos.denx.de X-Virus-Status: Clean Factor out eMMC boot partition selection code into default_spl_mmc_emmc_boot_partition() function and implement weak spl_mmc_emmc_boot_partition(), so that architecture or board code can override the eMMC boot partition selection. Signed-off-by: Marek Vasut Cc: Faiz Abbas Cc: Harald Seiler Cc: Lokesh Vutla Cc: Simon Glass Cc: Fabio Estevam Cc: Peng Fan Cc: Stefano Babic Cc: Ye Li --- V2: Update comments --- common/spl/spl_mmc.c | 37 ++++++++++++++++++++++++------------- include/spl.h | 23 +++++++++++++++++++++++ 2 files changed, 47 insertions(+), 13 deletions(-) diff --git a/common/spl/spl_mmc.c b/common/spl/spl_mmc.c index add2785b4e3..2377d0937d1 100644 --- a/common/spl/spl_mmc.c +++ b/common/spl/spl_mmc.c @@ -324,6 +324,29 @@ unsigned long __weak spl_mmc_get_uboot_raw_sector(struct mmc *mmc, return raw_sect; } +int default_spl_mmc_emmc_boot_partition(struct mmc *mmc) +{ + int part; +#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). + */ + part = (mmc->part_config >> 3) & PART_ACCESS_MASK; + if (part == 7) + part = 0; +#endif + return part; +} + +int __weak spl_mmc_emmc_boot_partition(struct mmc *mmc) +{ + return default_spl_mmc_emmc_boot_partition(mmc); +} + int spl_mmc_load(struct spl_image_info *spl_image, struct spl_boot_device *bootdev, const char *filename, @@ -355,19 +378,7 @@ int spl_mmc_load(struct spl_image_info *spl_image, err = -EINVAL; switch (boot_mode) { case MMCSD_MODE_EMMCBOOT: -#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). - */ - part = (mmc->part_config >> 3) & PART_ACCESS_MASK; - - if (part == 7) - part = 0; -#endif + part = spl_mmc_emmc_boot_partition(mmc); if (CONFIG_IS_ENABLED(MMC_TINY)) err = mmc_switch_part(mmc, part); diff --git a/include/spl.h b/include/spl.h index cee9a42ddb5..c643943482d 100644 --- a/include/spl.h +++ b/include/spl.h @@ -357,6 +357,29 @@ u32 spl_mmc_boot_mode(const u32 boot_device); * If not overridden, it is weakly defined in common/spl/spl_mmc.c. */ int spl_mmc_boot_partition(const u32 boot_device); + +struct mmc; +/** + * default_spl_mmc_emmc_boot_partition() - eMMC boot partition to load U-Boot from. + * mmc: Pointer for the mmc device structure + * + * This function should return the eMMC boot partition number which + * the SPL should load U-Boot from (on the given boot_device). + */ +int default_spl_mmc_emmc_boot_partition(struct mmc *mmc); + +/** + * spl_mmc_emmc_boot_partition() - eMMC boot partition to load U-Boot from. + * mmc: Pointer for the mmc device structure + * + * This function should return the eMMC boot partition number which + * the SPL should load U-Boot from (on the given boot_device). + * + * If not overridden, it is weakly defined in common/spl/spl_mmc.c + * and calls default_spl_mmc_emmc_boot_partition(); + */ +int spl_mmc_emmc_boot_partition(struct mmc *mmc); + void spl_set_bd(void); /** -- 2.30.2