public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: "Jernej Škrabec" <jernej.skrabec@siol.net>
To: u-boot@lists.denx.de
Subject: [linux-sunxi] [PATCH 07/17] sunxi: support loading with SPL > 32KB
Date: Mon, 11 Jan 2021 19:17:47 +0100	[thread overview]
Message-ID: <1755235.v7npiR6l92@kista> (raw)
In-Reply-To: <ab1c65f0-2fec-5982-04f8-fb3b41e5c6aa@sholland.org>

Dne ponedeljek, 04. januar 2021 ob 03:02:03 CET je Samuel Holland napisal(a):
> On 1/3/21 3:26 AM, Jernej Skrabec wrote:
> > From: Andre Przywara <andre.przywara@arm.com>
> > 
> > H616 supports and needs bigger SPL than 32 KiB, mostly due to big DRAM
> > driver and need for PMIC configuration, which pull several drivers which
> > are not needed otherwise.
> > 
> > Signed-off-by: Andre Przywara <andre.przywara@arm.com>
> > Signed-off-by: Jernej Skrabec <jernej.skrabec@siol.net>
> > ---
> >  arch/arm/mach-sunxi/board.c | 12 ++++++++++++
> >  1 file changed, 12 insertions(+)
> > 
> > diff --git a/arch/arm/mach-sunxi/board.c b/arch/arm/mach-sunxi/board.c
> > index 7a8b303f233c..296efd615769 100644
> > --- a/arch/arm/mach-sunxi/board.c
> > +++ b/arch/arm/mach-sunxi/board.c
> > @@ -277,6 +277,14 @@ uint32_t sunxi_get_boot_device(void)
> >  }
> >  
> >  #ifdef CONFIG_SPL_BUILD
> > +static u32 sunxi_get_spl_size(void)
> > +{
> > +	if (!is_boot0_magic(SPL_ADDR + 4)) /* eGON.BT0 */
> > +		return 32768;
> In the context of the suggestion below, this case could return 0.
> 
> > +
> > +	return readl(SPL_ADDR + 0x10);
> > +}
> > +
> >  /*
> >   * The eGON SPL image can be located at 8KB or at 128KB into an SD card 
or
> >   * an eMMC device. The boot source has bit 4 set in the latter case.
> > @@ -286,6 +294,7 @@ uint32_t sunxi_get_boot_device(void)
> >  unsigned long spl_mmc_get_uboot_raw_sector(struct mmc *mmc)
> 
> As a side note, the prototype for this function was changed in commit
> cf0082559698 ("spl: mmc: Fix spl_mmc_get_uboot_raw_sector()
> implementation"), but nobody noticed since it is not in a header.
> 
> >  {
> >  	unsigned long sector = CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR;
> > +	u32 spl_size = sunxi_get_spl_size();
> >  
> >  	switch (sunxi_get_boot_source()) {
> >  	case SUNXI_BOOTED_FROM_MMC0_HIGH:
> > @@ -294,6 +303,9 @@ unsigned long spl_mmc_get_uboot_raw_sector(struct mmc 
*mmc)
> >  		break;
> >  	}
> >  
> > +	if (spl_size > 32768)
> > +		sector += (spl_size - 32768) / 512;
> > +
> 
> What I would suggest doing instead of this is setting
> SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR=0x40,
> SYS_MMCSD_RAW_MODE_U_BOOT_DATA_PART_OFFSET=0x10, and then before the
> switch statement doing:
> 
>         sector = max(CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR,
>                      spl_size / 512);
> 
> Not only does this get rid of the magic 32768 constant (which is
> meaningless on new platforms), but it also works cleanly for eMMC boot
> partitions (where there's no 0x10 sector offset).

Thanks for the suggestion, this is indeed much cleaner.

Best regards,
Jernej

> 
> >  	return sector;
> >  }
> >  
> > 
> 
> Cheers,
> Samuel
> 

  reply	other threads:[~2021-01-11 18:17 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-03  9:26 [PATCH 00/17] sunxi: Introduce H616 support Jernej Skrabec
2021-01-03  9:26 ` [PATCH 01/17] sunxi: Add support for AXP305 PMIC Jernej Skrabec
2021-01-05 22:36   ` Jaehoon Chung
2021-01-06 10:11     ` André Przywara
2021-01-06 23:33       ` Jaehoon Chung
2021-01-07  9:49         ` André Przywara
2021-01-11  0:02   ` André Przywara
2021-01-11  1:32     ` Jaehoon Chung
2021-01-11 19:48     ` Jernej Škrabec
2021-01-03  9:26 ` [PATCH 02/17] sunxi: Introduce common symbol for H6 like SoCs Jernej Skrabec
2021-01-03 23:43   ` [linux-sunxi] " Samuel Holland
2021-01-04 10:35     ` André Przywara
2021-01-04 18:28       ` Jernej Škrabec
2021-01-11  0:13         ` André Przywara
2021-01-03  9:26 ` [PATCH 03/17] mmc: sunxi: Replace H6 ifdefs with H6 gen macro Jernej Skrabec
2021-01-11  0:13   ` André Przywara
2021-01-03  9:26 ` [PATCH 04/17] i2c: mvtwsi: sunxi: update macro Jernej Skrabec
2021-01-03 23:55   ` [linux-sunxi] " Samuel Holland
2021-01-04  5:57   ` Heiko Schocher
2021-01-03  9:26 ` [PATCH 05/17] sunxi: prcm: Add memory map for H6 like SoCs Jernej Skrabec
2021-01-04  0:03   ` [linux-sunxi] " Samuel Holland
2021-01-11 16:13     ` Jernej Škrabec
2021-01-03  9:26 ` [PATCH 06/17] sunxi: Add support for I2C on " Jernej Skrabec
2021-01-04  0:04   ` [linux-sunxi] " Samuel Holland
2021-01-03  9:26 ` [PATCH 07/17] sunxi: support loading with SPL > 32KB Jernej Skrabec
2021-01-04  2:02   ` [linux-sunxi] " Samuel Holland
2021-01-11 18:17     ` Jernej Škrabec [this message]
2021-01-03  9:26 ` [PATCH 08/17] sunxi: introduce support for H616 clocks Jernej Skrabec
2021-01-04  2:28   ` [linux-sunxi] " Samuel Holland
2021-01-03  9:26 ` [PATCH 09/17] sunxi: add support for H616 uart0 Jernej Skrabec
2021-01-04  2:30   ` [linux-sunxi] " Samuel Holland
2021-01-03  9:26 ` [PATCH 10/17] sunxi: add support for R_I2C on H616 Jernej Skrabec
2021-01-04  2:33   ` [linux-sunxi] " Samuel Holland
2021-01-04 18:36     ` Jernej Škrabec
2021-01-03  9:26 ` [PATCH 11/17] sunxi: Add H616 DRAM support Jernej Skrabec
2021-01-04  2:39   ` [linux-sunxi] " Samuel Holland
2021-01-04 18:39     ` Jernej Škrabec
2021-01-05  3:14       ` Samuel Holland
2021-01-03  9:26 ` [PATCH 12/17] sunxi: Add support for H616 SoC Jernej Skrabec
2021-01-04  2:47   ` [linux-sunxi] " Samuel Holland
2021-01-04 18:43     ` Jernej Škrabec
2021-01-03  9:26 ` [PATCH 13/17] net: sun8i-emac: Determine pinmux based on SoC, not EMAC type Jernej Skrabec
2021-01-03  9:26 ` [PATCH 14/17] arm: sunxi: add initial H616 DTSI and headers Jernej Skrabec
2021-01-03  9:26 ` [PATCH 15/17] sunxi: gpio: introduce compatible for H616 Jernej Skrabec
2021-01-11  0:36   ` André Przywara
2021-01-03  9:26 ` [PATCH 16/17] clk: sunxi: Add support for H616 clocks Jernej Skrabec
2021-01-11  0:44   ` André Przywara
2021-01-03  9:26 ` [PATCH 17/17] sunxi: Add support for OrangePi Zero2 Jernej Skrabec

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1755235.v7npiR6l92@kista \
    --to=jernej.skrabec@siol.net \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox