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,URIBL_BLOCKED, 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 68E33C11F66 for ; Wed, 30 Jun 2021 23:08:16 +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 D032B61453 for ; Wed, 30 Jun 2021 23:08:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D032B61453 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 2D7228317B; Thu, 1 Jul 2021 01:08:14 +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=1625094494; bh=B0FRK5TB+mROWZPbcze2r/LByV8AZaFL/VgfSySG5vs=; h=From:To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=A3N/nZWnUmH1jp1QGou5npCeUZcoSeMPI5Gm2pUV55Pa4vUEPyxyWk0yiz4xWTQKs SI70Pmig+43xCeOckfAWqfa1OAcK+x2Mua/0/OFMTMSIoHjWvjLrOStW1dxYvGZc1N cLCMn/oRbdeDTRYfXxLy5B4PH8M93jPHbluVHl5jjEatQQpGYq/1//ml42LZZLQ9f9 uSQz5JN7n5iruB0vTle68V4OlmUgX5vBQJDvK2rExKqwyfUjTMCscrgQvIg3ZNnx8n REVDBhIQal7L8UvcGux982dHAz6bnFFFmAhMF/Gq51CWT4GGzZv3ZnvYAckZSegI27 XqZJffu3poN4w== 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 25D6A82BF2; Thu, 1 Jul 2021 01:08:12 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1625094492; bh=B0FRK5TB+mROWZPbcze2r/LByV8AZaFL/VgfSySG5vs=; h=From:To:Cc:Subject:Date:From; b=JPAtaCjDSJGzb38SPf8GraBgMPANpJ5zKGPBPw2v8ygAIwf6LUCnDtyRwOuvQDsRs bySBRSd9RVCB91ZL0HsAM81ySVFvF8tDi6RqT6hByQXgewcMKXsL8AwwMwis6kiEd5 rnymm2hq7ldjZYLg7vBZy1ZaEmXnMArlP0BIHgOADX7m3MZ70sepywAuNv/ftHySAL UTUtVGOzAONKx2cUi3R73viKN0QkurCI+GCKvenanH+fnz7GIoRb61jB0TDxQ++Bav ot27LuQpxcg7XA8v82Wp+PqvdGe+tor4tIUxC/uOtw41VLF69XnBjUTptvn9yKwmGO EZ/qTY+Lf1GGA== 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 1/2] spl: mmc: Factor out eMMC boot partition selection code Date: Thu, 1 Jul 2021 01:08:00 +0200 Message-Id: <20210630230801.290195-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 --- common/spl/spl_mmc.c | 37 ++++++++++++++++++++++++------------- include/spl.h | 25 +++++++++++++++++++++++++ 2 files changed, 49 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..b6698a686a7 100644 --- a/include/spl.h +++ b/include/spl.h @@ -357,6 +357,31 @@ 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. + * @boot_device: ID of the device which the MMC driver wants to load + * U-Boot from. + * + * 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. + * @boot_device: ID of the device which the MMC driver wants to load + * U-Boot from. + * + * 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