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=-17.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 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 CDABCC11F66 for ; Wed, 30 Jun 2021 23:35:25 +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 9A8B36142C for ; Wed, 30 Jun 2021 23:35:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9A8B36142C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=samsung.com 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 49DFC83169; Thu, 1 Jul 2021 01:35:22 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=samsung.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=samsung.com header.i=@samsung.com header.b="jYMNGHS1"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id F204383169; Thu, 1 Jul 2021 01:35:20 +0200 (CEST) Received: from mailout2.samsung.com (mailout2.samsung.com [203.254.224.25]) (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 0975383144 for ; Thu, 1 Jul 2021 01:35:14 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=samsung.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=jh80.chung@samsung.com Received: from epcas1p2.samsung.com (unknown [182.195.41.46]) by mailout2.samsung.com (KnoxPortal) with ESMTP id 20210630233510epoutp02d8d10eeae7351a2b277a0c9ccc13c38b~NgE168IL60384903849epoutp02S for ; Wed, 30 Jun 2021 23:35:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.samsung.com 20210630233510epoutp02d8d10eeae7351a2b277a0c9ccc13c38b~NgE168IL60384903849epoutp02S DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1625096110; bh=24E87TS0j11JpIOleHXRQ24eiE3tnHqO395VGyK43E0=; h=Subject:To:Cc:From:Date:In-Reply-To:References:From; b=jYMNGHS1MDW0NWODmJmd60YHLcfUqaRkYcygcgG3DwHox+cO1Ft33diXvYmd1QAWQ SYrKmUSXOn4fTaJZ4GFGhGfjJpnYIlhhkGZh72rJ8K2uw/u+huTi3Q6mgc9S/3no4w zlvspQF+qzWACE8o0uOKhnT/WJfDcRlruykIoSdg= Received: from epsnrtp3.localdomain (unknown [182.195.42.164]) by epcas1p3.samsung.com (KnoxPortal) with ESMTP id 20210630233510epcas1p3e9a614059bbadf25b18c4a330a7de3c2~NgE1i-ISr1683716837epcas1p3H; Wed, 30 Jun 2021 23:35:10 +0000 (GMT) Received: from epsmges1p2.samsung.com (unknown [182.195.40.153]) by epsnrtp3.localdomain (Postfix) with ESMTP id 4GFd4C23pXz4x9QG; Wed, 30 Jun 2021 23:35:07 +0000 (GMT) Received: from epcas1p4.samsung.com ( [182.195.41.48]) by epsmges1p2.samsung.com (Symantec Messaging Gateway) with SMTP id CD.0A.09551.AAFFCD06; Thu, 1 Jul 2021 08:35:06 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas1p1.samsung.com (KnoxPortal) with ESMTPA id 20210630233506epcas1p1f56c0fcac0c5053d0e9e53cc13501fac~NgExkNLu92379323793epcas1p1x; Wed, 30 Jun 2021 23:35:06 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20210630233506epsmtrp128092873370de50d5493d1e77b0b71ce~NgExjT_kZ0570805708epsmtrp1R; Wed, 30 Jun 2021 23:35:06 +0000 (GMT) X-AuditID: b6c32a36-2c9ff7000000254f-5d-60dcffaa517e Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id B3.28.08394.9AFFCD06; Thu, 1 Jul 2021 08:35:05 +0900 (KST) Received: from [10.113.113.235] (unknown [10.113.113.235]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20210630233505epsmtip2682b74e05e278dfc10e2da3b9f476e37~NgExUdUkB1069610696epsmtip2O; Wed, 30 Jun 2021 23:35:05 +0000 (GMT) Subject: Re: [PATCH 1/2] spl: mmc: Factor out eMMC boot partition selection code To: Marek Vasut , u-boot@lists.denx.de Cc: Faiz Abbas , Harald Seiler , Lokesh Vutla , Simon Glass , Fabio Estevam , Peng Fan , Stefano Babic , Ye Li From: Jaehoon Chung Message-ID: <0d0b71ef-233f-1107-288a-bd80593a2c0d@samsung.com> Date: Thu, 1 Jul 2021 08:36:00 +0900 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <20210630230801.290195-1-marex@denx.de> Content-Language: en-US Content-Transfer-Encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrNJsWRmVeSWpSXmKPExsWy7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v1p3fVtg1 d9vrtZYH7tmGKlQ5HozKfC/s/3rmDruY/JWOMZe+39j/W/rSabaM5OlTbCZ+dCzvlqpkE7xU N1v7wfl3/yS25XbZrwo55LnqUYjDs1cGHsb68v+VWIozEg21mIuKEwG7lz9sHQMAAA== X-CMS-MailID: 20210630233506epcas1p1f56c0fcac0c5053d0e9e53cc13501fac X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-Sendblock-Type: SVC_REQ_APPROVE CMS-TYPE: 101P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20210630230824epcas1p40231e1adbda82e8ed745349f83e07a5f References: <20210630230801.290195-1-marex@denx.de> 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 Hi Marek, On 7/1/21 8:08 AM, Marek Vasut wrote: > 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. Is "@boot_device" right? Argument is mmc. > + * > + * 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. Ditto. Best Regards, Jaehoon Chung > + * > + * 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); > > /** >