[PATCH v1 15/19] ARM: tegra: board2: add generic late init

Thierry Reding thierry.reding at gmail.com
Wed Aug 23 13:13:11 CEST 2023


On Tue, Aug 22, 2023 at 02:22:13PM +0300, Svyatoslav Ryhel wrote:
> Board specific late init allows vendors to set up different device
> or board specific env variables (like serial number, platform name).
> In case this information is missing, u-boot will lack info regards
> serial or platform.
> 
> To avoid this prior nvidia_board_late_init internal generic function
> is called which fills required data. In this case platform name is
> obtained from get_chip and serialno is filled with SoC id.
> 
> Though SoC id is not dedicated to be devices serial but it fits well
> in case of restriction of data about device and since SoC is basically
> a main chip of the device.
> 
> Tested-by: Andreas Westman Dorcsak <hedmoo at yahoo.com> # ASUS Transformers
> Tested-by: Svyatoslav Ryhel <clamor95 at gmail.com> # Nvidia Tegratab
> Signed-off-by: Svyatoslav Ryhel <clamor95 at gmail.com>
> ---
>  arch/arm/mach-tegra/board2.c | 43 ++++++++++++++++++++++++++++++++++++
>  1 file changed, 43 insertions(+)
> 
> diff --git a/arch/arm/mach-tegra/board2.c b/arch/arm/mach-tegra/board2.c
> index 981768bb0e..ee69cb657a 100644
> --- a/arch/arm/mach-tegra/board2.c
> +++ b/arch/arm/mach-tegra/board2.c
> @@ -26,6 +26,10 @@
>  #include <asm/arch-tegra/gpu.h>
>  #include <asm/arch-tegra/usb.h>
>  #include <asm/arch-tegra/xusb-padctl.h>
> +#ifndef CONFIG_TEGRA186
> +#include <asm/arch-tegra/fuse.h>
> +#include <asm/arch/gp_padctrl.h>
> +#endif
>  #if IS_ENABLED(CONFIG_TEGRA_CLKRST)
>  #include <asm/arch/clock.h>
>  #endif
> @@ -256,6 +260,37 @@ int board_early_init_f(void)
>  }
>  #endif	/* EARLY_INIT */
>  
> +#ifndef CONFIG_TEGRA186
> +static void nvidia_board_late_init_generic(void)
> +{
> +	char serialno_str[17];
> +
> +	/* Set chip id as serialno */
> +	sprintf(serialno_str, "%016llx", tegra_chip_uid());
> +	env_set("serial#", serialno_str);
> +
> +	switch (tegra_get_chip()) {
> +	case CHIPID_TEGRA20:
> +		env_set("platform", "Tegra 2 T20");
> +		break;
> +	case CHIPID_TEGRA30:
> +		env_set("platform", "Tegra 3 T30");
> +		break;
> +	case CHIPID_TEGRA114:
> +		env_set("platform", "Tegra 4 T114");
> +		break;
> +	case CHIPID_TEGRA124:
> +		env_set("platform", "Tegra K1 T124");
> +		break;
> +	case CHIPID_TEGRA210:
> +		env_set("platform", "Tegra X1 T210");

This variable is presumably something that you'd want to match on in a
script, so perhaps we can settle on something a bit more canonical. In
upstream Linux we use tegraXYZ quite consistently and you'll see that
reflected in things like compatible strings, so I'd suggest reusing the
same naming scheme here to simplify and avoid confusion.

Thierry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20230823/6fe46473/attachment.sig>


More information about the U-Boot mailing list