public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: "Jernej Škrabec" <jernej.skrabec@gmail.com>
To: Jagan Teki <jagan@amarulasolutions.com>,
	Andre Przywara <andre.przywara@arm.com>
Cc: Icenowy Zheng <uwu@icenowy.me>,
	Jesse Taube <mr.bossman075@gmail.com>, Yifan Gu <me@yifangu.com>,
	Giulio Benetti <giulio.benetti@benettiengineering.com>,
	George Hilliard <thirtythreeforty@gmail.com>,
	Samuel Holland <samuel@sholland.org>,
	u-boot@lists.denx.de, linux-sunxi@lists.linux.dev
Subject: Re: [PATCH 1/6] sunxi: Kconfig: introduce SUNXI_MINIMUM_DRAM_MB
Date: Wed, 12 Oct 2022 23:33:27 +0200	[thread overview]
Message-ID: <2128489.Icojqenx9y@kista> (raw)
In-Reply-To: <20221012163458.1968900-2-andre.przywara@arm.com>

Hi Andre,

Dne sreda, 12. oktober 2022 ob 18:34:53 CEST je Andre Przywara napisal(a):
> Traditionally we assumed that every Allwinner board would come with at
> least 256 MB of DRAM, and set our DRAM layout accordingly. This affected
> both the default load addresses, but also U-Boot's own address
> expectations (like being loaded at 160 MB).
> 
> Some SoCs come with co-packaged DRAM, but only provide 32 or 64MB. So
> far we special-cased those *chips*, as there was only one chip per DRAM
> size. However new chips force us to take a more general approach.
> 
> Introduce a Kconfig symbol, which provides the minimum DRAM size of the
> board. If nothing else is specified, we use 256 MB, and default to
> smaller values for those co-packaged SoCs.
> Then select the different DRAM maps according to this new symbol, so
> that different SoCs with the same DRAM size can share those definitions.
> 
> Inspired by an idea from Icenowy.
> 
> This is just refactoring: compiled for all boards before and after this
> patch: the binaries were identical.
> 
> Signed-off-by: Andre Przywara <andre.przywara@arm.com>

Nice approach.

Reviewed-by: Jernej Skrabec <jernej.skrabec@gmail.com>

Best regards,
Jernej

> ---
>  Kconfig                        |  6 +++---
>  arch/arm/mach-sunxi/Kconfig    | 12 ++++++++++++
>  boot/Kconfig                   |  4 ++--
>  include/configs/sunxi-common.h | 31 +++++++++++++++++--------------
>  4 files changed, 34 insertions(+), 19 deletions(-)
> 
> diff --git a/Kconfig b/Kconfig
> index 2ea735d38e4..d297513bac6 100644
> --- a/Kconfig
> +++ b/Kconfig
> @@ -312,9 +312,9 @@ config SYS_MALLOC_LEN
>  	default 0x4000000 if SANDBOX
>  	default 0x2000000 if ARCH_ROCKCHIP || ARCH_OMAP2PLUS || ARCH_MESON
>  	default 0x200000 if ARCH_BMIPS || X86
> -	default 0x120000 if MACH_SUNIV
> -	default 0x220000 if MACH_SUN8I_V3S
> -	default 0x4020000 if ARCH_SUNXI
> +	default 0x4020000 if SUNXI_MINIMUM_DRAM_MB >= 256
> +	default 0x220000 if SUNXI_MINIMUM_DRAM_MB >= 64
> +	default 0x120000 if SUNXI_MINIMUM_DRAM_MB >= 32
>  	default 0x400000
>  	help
>  	  This defines memory to be allocated for Dynamic allocation
> diff --git a/arch/arm/mach-sunxi/Kconfig b/arch/arm/mach-sunxi/Kconfig
> index 6b16f43494f..9aa66deb9fd 100644
> --- a/arch/arm/mach-sunxi/Kconfig
> +++ b/arch/arm/mach-sunxi/Kconfig
> @@ -615,6 +615,18 @@ config SYS_BOARD
>  config SYS_SOC
>  	default "sunxi"
> 
> +config SUNXI_MINIMUM_DRAM_MB
> +	int "minimum DRAM size"
> +	default 32 if MACH_SUNIV
> +	default 64 if MACH_SUN8I_V3S
> +	default 256
> +	---help---
> +	Minimum DRAM size expected on the board. Traditionally we assumed
> +	256 MB, so that U-Boot would load at 160MB. With co-packaged DRAM
> +	we have smaller sizes, though, so that U-Boot's own load address 
and
> +	the default payload addresses must be shifted down.
> +	This is expected to be fixed by the SoC selection.
> +
>  config UART0_PORT_F
>  	bool "UART0 on MicroSD breakout board"
>  	---help---
> diff --git a/boot/Kconfig b/boot/Kconfig
> index 6b3b8f072cb..45f86e946cd 100644
> --- a/boot/Kconfig
> +++ b/boot/Kconfig
> @@ -499,8 +499,8 @@ config SYS_TEXT_BASE
>  	default 0x80800000 if ARCH_OMAP2PLUS || ARCH_K3
>  	default 0x81700000 if MACH_SUNIV
>  	default 0x2a000000 if MACH_SUN9I
> -	default 0x42e00000 if MACH_SUN8I_V3S
> -	default 0x4a000000 if ARCH_SUNXI
> +	default 0x4a000000 if SUNXI_MINIMUM_DRAM_MB >= 256
> +	default 0x42e00000 if SUNXI_MINIMUM_DRAM_MB >= 64
>  	hex "Text Base"
>  	help
>  	  The address in memory that U-Boot will be running from, 
initially.
> diff --git a/include/configs/sunxi-common.h b/include/configs/sunxi-common.h
> index 0f0ef4f64bb..416a0422861 100644
> --- a/include/configs/sunxi-common.h
> +++ b/include/configs/sunxi-common.h
> @@ -135,7 +135,21 @@
>  #define FDTOVERLAY_ADDR_R __stringify(SDRAM_OFFSET(FE00000))
>  #define RAMDISK_ADDR_R    __stringify(SDRAM_OFFSET(FF00000))
> 
> -#elif defined(CONFIG_MACH_SUN8I_V3S)
> +#elif (CONFIG_SUNXI_MINIMUM_DRAM_MB >= 256)
> +/*
> + * 160M RAM (256M minimum minus 64MB heap + 32MB for u-boot, stack, fb,
> etc. + * 32M uncompressed kernel, 16M compressed kernel, 1M fdt,
> + * 1M script, 1M pxe, 1M dt overlay and the ramdisk at the end.
> + */
> +#define BOOTM_SIZE        __stringify(0xa000000)
> +#define KERNEL_ADDR_R     __stringify(SDRAM_OFFSET(2000000))
> +#define FDT_ADDR_R        __stringify(SDRAM_OFFSET(3000000))
> +#define SCRIPT_ADDR_R     __stringify(SDRAM_OFFSET(3100000))
> +#define PXEFILE_ADDR_R    __stringify(SDRAM_OFFSET(3200000))
> +#define FDTOVERLAY_ADDR_R __stringify(SDRAM_OFFSET(3300000))
> +#define RAMDISK_ADDR_R    __stringify(SDRAM_OFFSET(3400000))
> +
> +#elif (CONFIG_SUNXI_MINIMUM_DRAM_MB >= 64)
>  /*
>   * 64M RAM minus 2MB heap + 16MB for u-boot, stack, fb, etc.
>   * 16M uncompressed kernel, 8M compressed kernel, 1M fdt,
> @@ -149,7 +163,7 @@
>  #define FDTOVERLAY_ADDR_R __stringify(SDRAM_OFFSET(1B00000))
>  #define RAMDISK_ADDR_R    __stringify(SDRAM_OFFSET(1C00000))
> 
> -#elif defined(CONFIG_MACH_SUNIV)
> +#elif (CONFIG_SUNXI_MINIMUM_DRAM_MB >= 32)
>  /*
>   * 32M RAM minus 1MB heap + 8MB for u-boot, stack, fb, etc.
>   * 8M uncompressed kernel, 4M compressed kernel, 512K fdt,
> @@ -164,18 +178,7 @@
>  #define RAMDISK_ADDR_R    __stringify(SDRAM_OFFSET(0D60000))
> 
>  #else
> -/*
> - * 160M RAM (256M minimum minus 64MB heap + 32MB for u-boot, stack, fb,
> etc. - * 32M uncompressed kernel, 16M compressed kernel, 1M fdt,
> - * 1M script, 1M pxe, 1M dt overlay and the ramdisk at the end.
> - */
> -#define BOOTM_SIZE        __stringify(0xa000000)
> -#define KERNEL_ADDR_R     __stringify(SDRAM_OFFSET(2000000))
> -#define FDT_ADDR_R        __stringify(SDRAM_OFFSET(3000000))
> -#define SCRIPT_ADDR_R     __stringify(SDRAM_OFFSET(3100000))
> -#define PXEFILE_ADDR_R    __stringify(SDRAM_OFFSET(3200000))
> -#define FDTOVERLAY_ADDR_R __stringify(SDRAM_OFFSET(3300000))
> -#define RAMDISK_ADDR_R    __stringify(SDRAM_OFFSET(3400000))
> +#error Need at least 32MB of DRAM. Please adjust load addresses.
>  #endif
> 
>  #define MEM_LAYOUT_ENV_SETTINGS \
> --
> 2.25.1



  reply	other threads:[~2022-10-12 21:33 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-12 16:34 [PATCH 0/6] sunxi: improve F1C200s support Andre Przywara
2022-10-12 16:34 ` [PATCH 1/6] sunxi: Kconfig: introduce SUNXI_MINIMUM_DRAM_MB Andre Przywara
2022-10-12 21:33   ` Jernej Škrabec [this message]
2022-10-12 16:34 ` [PATCH 2/6] sunxi: fix 32MB load address layout Andre Przywara
2022-10-12 21:37   ` Jernej Škrabec
2022-10-12 16:34 ` [PATCH 3/6] sunxi: f1c100: move SKIP_LOWLEVEL_INIT_ONLY into Kconfig Andre Przywara
2022-10-12 21:38   ` Jernej Škrabec
2022-10-13  8:51   ` Icenowy Zheng
2022-10-12 16:34 ` [PATCH 4/6] sunxi: f1c100: add UART1 support Andre Przywara
2022-10-12 21:42   ` Jernej Škrabec
2022-10-18  9:23     ` Andre Przywara
2022-10-19  3:55       ` Jernej Škrabec
2022-10-12 16:34 ` [PATCH 5/6] sunxi: f1c100: dtsi: add UART1 pins Andre Przywara
2022-10-12 21:43   ` Jernej Škrabec
2022-10-12 16:34 ` [PATCH 6/6] sunxi: add CherryPi-F1C200s support Andre Przywara
2022-10-13  8:33   ` Clément Péron
2022-10-13  9:53     ` Andre Przywara
2022-10-14  5:04       ` Jesse Taube
2022-10-18 14:01         ` Andre Przywara
2022-10-20 15:52           ` Giulio Benetti

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=2128489.Icojqenx9y@kista \
    --to=jernej.skrabec@gmail.com \
    --cc=andre.przywara@arm.com \
    --cc=giulio.benetti@benettiengineering.com \
    --cc=jagan@amarulasolutions.com \
    --cc=linux-sunxi@lists.linux.dev \
    --cc=me@yifangu.com \
    --cc=mr.bossman075@gmail.com \
    --cc=samuel@sholland.org \
    --cc=thirtythreeforty@gmail.com \
    --cc=u-boot@lists.denx.de \
    --cc=uwu@icenowy.me \
    /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