diff mbox series

[U-Boot] spl: mmc: Add option to set eMMC HW boot partition

Message ID 20190903141650.5117-1-lukma@denx.de
State Accepted
Commit 17241ea0543a4c998f79bde27b8a6047c8d84d0a
Delegated to: Tom Rini
Headers show
Series [U-Boot] spl: mmc: Add option to set eMMC HW boot partition | expand

Commit Message

Lukasz Majewski Sept. 3, 2019, 2:16 p.m. UTC
From: Mans Rullgard <mans@mansr.com>

This change allows setting pre-defined eMMC boot partition for SPL eMMC
booting. It is necessary in the case when one wants to boot (through falcon
boot) from eMMC after loading SPL from other memory (like SPI-NOR).

Signed-off-by: Mans Rullgard <mans@mansr.com>
[lukma: Edit the commit message]
Signed-off-by: Lukasz Majewski <lukma@denx.de>
Acked-by: Andreas Dannenberg <dannenberg@ti.com>

---

 common/spl/Kconfig   | 6 ++++++
 common/spl/spl_mmc.c | 4 ++++
 2 files changed, 10 insertions(+)

Comments

Marek Vasut Sept. 3, 2019, 2:20 p.m. UTC | #1
On 9/3/19 4:16 PM, Lukasz Majewski wrote:
> From: Mans Rullgard <mans@mansr.com>
> 
> This change allows setting pre-defined eMMC boot partition for SPL eMMC
> booting. It is necessary in the case when one wants to boot (through falcon
> boot) from eMMC after loading SPL from other memory (like SPI-NOR).
> 
> Signed-off-by: Mans Rullgard <mans@mansr.com>
> [lukma: Edit the commit message]
> Signed-off-by: Lukasz Majewski <lukma@denx.de>
> Acked-by: Andreas Dannenberg <dannenberg@ti.com>

Would it be better if this came from /chosen node in DT ?
Måns Rullgård Sept. 3, 2019, 3:16 p.m. UTC | #2
Marek Vasut <marex@denx.de> writes:

> On 9/3/19 4:16 PM, Lukasz Majewski wrote:
>> From: Mans Rullgard <mans@mansr.com>
>> 
>> This change allows setting pre-defined eMMC boot partition for SPL eMMC
>> booting. It is necessary in the case when one wants to boot (through falcon
>> boot) from eMMC after loading SPL from other memory (like SPI-NOR).
>> 
>> Signed-off-by: Mans Rullgard <mans@mansr.com>
>> [lukma: Edit the commit message]
>> Signed-off-by: Lukasz Majewski <lukma@denx.de>
>> Acked-by: Andreas Dannenberg <dannenberg@ti.com>
>
> Would it be better if this came from /chosen node in DT ?

This patch was made for an imx28 based board.  Fitting DT support into
SPL on that chip won't be easy.
Lukasz Majewski Sept. 3, 2019, 3:49 p.m. UTC | #3
Hi Måns, Marek,

> Marek Vasut <marex@denx.de> writes:
> 
> > On 9/3/19 4:16 PM, Lukasz Majewski wrote:  
> >> From: Mans Rullgard <mans@mansr.com>
> >> 
> >> This change allows setting pre-defined eMMC boot partition for SPL
> >> eMMC booting. It is necessary in the case when one wants to boot
> >> (through falcon boot) from eMMC after loading SPL from other
> >> memory (like SPI-NOR).
> >> 
> >> Signed-off-by: Mans Rullgard <mans@mansr.com>
> >> [lukma: Edit the commit message]
> >> Signed-off-by: Lukasz Majewski <lukma@denx.de>
> >> Acked-by: Andreas Dannenberg <dannenberg@ti.com>  
> >
> > Would it be better if this came from /chosen node in DT ?  
> 
> This patch was made for an imx28 based board.  Fitting DT support into
> SPL on that chip won't be easy.

Unfortunately, on purpose the DT support for SPL on this board is
disabled.

This is the case where the only eligible option is to use OF_PLATDATA,
to benefit from DM drivers, but also to keep the size as small as
possible.

(Please refer to xea board support patches for more details).

> 



Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma@denx.de
Marek Vasut Sept. 3, 2019, 5:07 p.m. UTC | #4
On 9/3/19 5:49 PM, Lukasz Majewski wrote:
> Hi Måns, Marek,
> 
>> Marek Vasut <marex@denx.de> writes:
>>
>>> On 9/3/19 4:16 PM, Lukasz Majewski wrote:  
>>>> From: Mans Rullgard <mans@mansr.com>
>>>>
>>>> This change allows setting pre-defined eMMC boot partition for SPL
>>>> eMMC booting. It is necessary in the case when one wants to boot
>>>> (through falcon boot) from eMMC after loading SPL from other
>>>> memory (like SPI-NOR).
>>>>
>>>> Signed-off-by: Mans Rullgard <mans@mansr.com>
>>>> [lukma: Edit the commit message]
>>>> Signed-off-by: Lukasz Majewski <lukma@denx.de>
>>>> Acked-by: Andreas Dannenberg <dannenberg@ti.com>  
>>>
>>> Would it be better if this came from /chosen node in DT ?  
>>
>> This patch was made for an imx28 based board.  Fitting DT support into
>> SPL on that chip won't be easy.
> 
> Unfortunately, on purpose the DT support for SPL on this board is
> disabled.
> 
> This is the case where the only eligible option is to use OF_PLATDATA,
> to benefit from DM drivers, but also to keep the size as small as
> possible.
> 
> (Please refer to xea board support patches for more details).

Hm, then shall we use platdata ? I don't think that fits common code
like this either.
Lukasz Majewski Sept. 3, 2019, 8:34 p.m. UTC | #5
Hi Marek,

> On 9/3/19 5:49 PM, Lukasz Majewski wrote:
> > Hi Måns, Marek,
> >   
> >> Marek Vasut <marex@denx.de> writes:
> >>  
> >>> On 9/3/19 4:16 PM, Lukasz Majewski wrote:    
> >>>> From: Mans Rullgard <mans@mansr.com>
> >>>>
> >>>> This change allows setting pre-defined eMMC boot partition for
> >>>> SPL eMMC booting. It is necessary in the case when one wants to
> >>>> boot (through falcon boot) from eMMC after loading SPL from other
> >>>> memory (like SPI-NOR).
> >>>>
> >>>> Signed-off-by: Mans Rullgard <mans@mansr.com>
> >>>> [lukma: Edit the commit message]
> >>>> Signed-off-by: Lukasz Majewski <lukma@denx.de>
> >>>> Acked-by: Andreas Dannenberg <dannenberg@ti.com>    
> >>>
> >>> Would it be better if this came from /chosen node in DT ?    
> >>
> >> This patch was made for an imx28 based board.  Fitting DT support
> >> into SPL on that chip won't be easy.  
> > 
> > Unfortunately, on purpose the DT support for SPL on this board is
> > disabled.
> > 
> > This is the case where the only eligible option is to use
> > OF_PLATDATA, to benefit from DM drivers, but also to keep the size
> > as small as possible.
> > 
> > (Please refer to xea board support patches for more details).  
> 
> Hm, then shall we use platdata ? 

Yes, correct. The OF_PLATDATA allows you to use DM/DTS converted driver
with platform data encoded in the C structures.

For example such patch adds support for OF_PLATDATA to DM/DTS driver:
https://patchwork.ozlabs.org/patch/1148906/

> I don't think that fits common code
> like this either.

Please see above link.


Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma@denx.de
Lukasz Majewski Oct. 9, 2019, 9:07 a.m. UTC | #6
Dear Tom,

> From: Mans Rullgard <mans@mansr.com>
> 
> This change allows setting pre-defined eMMC boot partition for SPL
> eMMC booting. It is necessary in the case when one wants to boot
> (through falcon boot) from eMMC after loading SPL from other memory
> (like SPI-NOR).
> 
> Signed-off-by: Mans Rullgard <mans@mansr.com>
> [lukma: Edit the commit message]
> Signed-off-by: Lukasz Majewski <lukma@denx.de>
> Acked-by: Andreas Dannenberg <dannenberg@ti.com>
> 

Tom, are there any issues preventing this patch from being applied to
-master?

> ---
> 
>  common/spl/Kconfig   | 6 ++++++
>  common/spl/spl_mmc.c | 4 ++++
>  2 files changed, 10 insertions(+)
> 
> diff --git a/common/spl/Kconfig b/common/spl/Kconfig
> index f467eca2be..5b7667ea16 100644
> --- a/common/spl/Kconfig
> +++ b/common/spl/Kconfig
> @@ -314,6 +314,12 @@ config SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR
>  	  Address on the MMC to load U-Boot from, when the MMC is
> being used in raw mode. Units: MMC sectors (1 sector = 512 bytes).
>  
> +config SYS_MMCSD_RAW_MODE_EMMC_BOOT_PARTITION
> +	int "Number of the eMMC boot partition to use"
> +	default 1
> +	help
> +	  eMMC boot partition number to use when the eMMC in raw
> mode. +
>  config SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION
>  	bool "MMC Raw mode: by partition"
>  	help
> diff --git a/common/spl/spl_mmc.c b/common/spl/spl_mmc.c
> index 2caceb5186..a4d2e63b82 100644
> --- a/common/spl/spl_mmc.c
> +++ b/common/spl/spl_mmc.c
> @@ -334,6 +334,9 @@ 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 @@ -343,6 +346,7 @@ int spl_mmc_load(struct spl_image_info
> *spl_image, 
>  		if (part == 7)
>  			part = 0;
> +#endif
>  
>  		if (CONFIG_IS_ENABLED(MMC_TINY))
>  			err = mmc_switch_part(mmc, part);




Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma@denx.de
Tom Rini Oct. 10, 2019, 7:55 p.m. UTC | #7
On Wed, Oct 09, 2019 at 11:07:18AM +0200, Lukasz Majewski wrote:
> Dear Tom,
> 
> > From: Mans Rullgard <mans@mansr.com>
> > 
> > This change allows setting pre-defined eMMC boot partition for SPL
> > eMMC booting. It is necessary in the case when one wants to boot
> > (through falcon boot) from eMMC after loading SPL from other memory
> > (like SPI-NOR).
> > 
> > Signed-off-by: Mans Rullgard <mans@mansr.com>
> > [lukma: Edit the commit message]
> > Signed-off-by: Lukasz Majewski <lukma@denx.de>
> > Acked-by: Andreas Dannenberg <dannenberg@ti.com>
> > 
> 
> Tom, are there any issues preventing this patch from being applied to
> -master?

Keeping in mind that we do need to allow for SPL to do reasonable things
to retain a smaller footprint, this is fine.  If Peng doesn't pick it up
as an MMC change I'll get it soon.
Peng Fan Oct. 11, 2019, 2:02 a.m. UTC | #8
Hi Tom,

> Subject: Re: [PATCH] spl: mmc: Add option to set eMMC HW boot partition
> 
> On Wed, Oct 09, 2019 at 11:07:18AM +0200, Lukasz Majewski wrote:
> > Dear Tom,
> >
> > > From: Mans Rullgard <mans@mansr.com>
> > >
> > > This change allows setting pre-defined eMMC boot partition for SPL
> > > eMMC booting. It is necessary in the case when one wants to boot
> > > (through falcon boot) from eMMC after loading SPL from other memory
> > > (like SPI-NOR).
> > >
> > > Signed-off-by: Mans Rullgard <mans@mansr.com>
> > > [lukma: Edit the commit message]
> > > Signed-off-by: Lukasz Majewski <lukma@denx.de>
> > > Acked-by: Andreas Dannenberg <dannenberg@ti.com>
> > >
> >
> > Tom, are there any issues preventing this patch from being applied to
> > -master?
> 
> Keeping in mind that we do need to allow for SPL to do reasonable things to
> retain a smaller footprint, this is fine.  If Peng doesn't pick it up as an MMC
> change I'll get it soon.

It not in my patchwork list, so I not pick it. Please directly pick it up since it is ok to you.

Thanks,
Peng.

> 
> --
> Tom
Tom Rini Oct. 12, 2019, 8:23 p.m. UTC | #9
On Tue, Sep 03, 2019 at 04:16:50PM +0200, Lukasz Majewski wrote:

> From: Mans Rullgard <mans@mansr.com>
> 
> This change allows setting pre-defined eMMC boot partition for SPL eMMC
> booting. It is necessary in the case when one wants to boot (through falcon
> boot) from eMMC after loading SPL from other memory (like SPI-NOR).
> 
> Signed-off-by: Mans Rullgard <mans@mansr.com>
> [lukma: Edit the commit message]
> Signed-off-by: Lukasz Majewski <lukma@denx.de>
> Acked-by: Andreas Dannenberg <dannenberg@ti.com>

Applied to u-boot/master, thanks!
diff mbox series

Patch

diff --git a/common/spl/Kconfig b/common/spl/Kconfig
index f467eca2be..5b7667ea16 100644
--- a/common/spl/Kconfig
+++ b/common/spl/Kconfig
@@ -314,6 +314,12 @@  config SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR
 	  Address on the MMC to load U-Boot from, when the MMC is being used
 	  in raw mode. Units: MMC sectors (1 sector = 512 bytes).
 
+config SYS_MMCSD_RAW_MODE_EMMC_BOOT_PARTITION
+	int "Number of the eMMC boot partition to use"
+	default 1
+	help
+	  eMMC boot partition number to use when the eMMC in raw mode.
+
 config SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION
 	bool "MMC Raw mode: by partition"
 	help
diff --git a/common/spl/spl_mmc.c b/common/spl/spl_mmc.c
index 2caceb5186..a4d2e63b82 100644
--- a/common/spl/spl_mmc.c
+++ b/common/spl/spl_mmc.c
@@ -334,6 +334,9 @@  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
@@ -343,6 +346,7 @@  int spl_mmc_load(struct spl_image_info *spl_image,
 
 		if (part == 7)
 			part = 0;
+#endif
 
 		if (CONFIG_IS_ENABLED(MMC_TINY))
 			err = mmc_switch_part(mmc, part);