diff options
author | Tom Rini <trini@konsulko.com> | 2024-05-10 10:42:25 -0600 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2024-05-10 11:33:00 -0600 |
commit | f842a7a2c02e400878805a56cef6edfd834c1f9e (patch) | |
tree | 00e88e64cf016ee874cb3aa9fa8b0accefc8cc01 | |
parent | 9419f48deed7805b738f7012382000fc35818395 (diff) | |
parent | ff5672d4d13fd136eee03a41f430411e00c6344e (diff) | |
download | u-boot-f842a7a2c02e400878805a56cef6edfd834c1f9e.zip u-boot-f842a7a2c02e400878805a56cef6edfd834c1f9e.tar.gz u-boot-f842a7a2c02e400878805a56cef6edfd834c1f9e.tar.bz2 |
Merge patch series "*** Commonize board code for K3 based SoMs ***"
Wadim Egorov <w.egorov@phytec.de> says:
Factor out code that we can reuse across all our K3 based SoMs.
2nd patch of this series require patch [1] to be applied first.
[1] https://lists.denx.de/pipermail/u-boot/2024-April/552021.html
-rw-r--r-- | board/phytec/common/Makefile | 2 | ||||
-rw-r--r-- | board/phytec/common/k3/Makefile | 2 | ||||
-rw-r--r-- | board/phytec/common/k3/board.c | 73 | ||||
-rw-r--r-- | board/phytec/phycore_am62x/phycore-am62x.c | 67 | ||||
-rw-r--r-- | configs/phycore_am64x_a53_defconfig | 1 |
5 files changed, 78 insertions, 67 deletions
diff --git a/board/phytec/common/Makefile b/board/phytec/common/Makefile index 3feb00f..c34fc50 100644 --- a/board/phytec/common/Makefile +++ b/board/phytec/common/Makefile @@ -5,6 +5,8 @@ ifdef CONFIG_SPL_BUILD # necessary to create built-in.o obj- := __dummy__.o +else +obj-$(CONFIG_ARCH_K3) += k3/ endif obj-y += phytec_som_detection.o diff --git a/board/phytec/common/k3/Makefile b/board/phytec/common/k3/Makefile new file mode 100644 index 0000000..bcca1a9 --- /dev/null +++ b/board/phytec/common/k3/Makefile @@ -0,0 +1,2 @@ +# SPDX-License-Identifier: GPL-2.0+ +obj-y += board.o diff --git a/board/phytec/common/k3/board.c b/board/phytec/common/k3/board.c new file mode 100644 index 0000000..9cb168c --- /dev/null +++ b/board/phytec/common/k3/board.c @@ -0,0 +1,73 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (C) 2024 PHYTEC Messtechnik GmbH + * Author: Wadim Egorov <w.egorov@phytec.de> + */ + +#include <env_internal.h> +#include <spl.h> +#include <asm/arch/hardware.h> + +#if IS_ENABLED(CONFIG_ENV_IS_IN_FAT) || IS_ENABLED(CONFIG_ENV_IS_IN_MMC) +int mmc_get_env_dev(void) +{ + u32 boot_device = get_boot_device(); + + switch (boot_device) { + case BOOT_DEVICE_MMC1: + return 0; + case BOOT_DEVICE_MMC2: + return 1; + }; + + return CONFIG_SYS_MMC_ENV_DEV; +} +#endif + +enum env_location env_get_location(enum env_operation op, int prio) +{ + u32 boot_device = get_boot_device(); + + if (prio) + return ENVL_UNKNOWN; + + switch (boot_device) { + case BOOT_DEVICE_MMC1: + case BOOT_DEVICE_MMC2: + if (CONFIG_IS_ENABLED(ENV_IS_IN_FAT)) + return ENVL_FAT; + if (CONFIG_IS_ENABLED(ENV_IS_IN_MMC)) + return ENVL_MMC; + case BOOT_DEVICE_SPI: + if (CONFIG_IS_ENABLED(ENV_IS_IN_SPI_FLASH)) + return ENVL_SPI_FLASH; + default: + return ENVL_NOWHERE; + }; +} + +#if IS_ENABLED(CONFIG_BOARD_LATE_INIT) +int board_late_init(void) +{ + u32 boot_device = get_boot_device(); + + switch (boot_device) { + case BOOT_DEVICE_MMC1: + env_set_ulong("mmcdev", 0); + env_set("boot", "mmc"); + break; + case BOOT_DEVICE_MMC2: + env_set_ulong("mmcdev", 1); + env_set("boot", "mmc"); + break; + case BOOT_DEVICE_SPI: + env_set("boot", "spi"); + break; + case BOOT_DEVICE_ETHERNET: + env_set("boot", "net"); + break; + }; + + return 0; +} +#endif diff --git a/board/phytec/phycore_am62x/phycore-am62x.c b/board/phytec/phycore_am62x/phycore-am62x.c index 618b4c3..a082b88 100644 --- a/board/phytec/phycore_am62x/phycore-am62x.c +++ b/board/phytec/phycore_am62x/phycore-am62x.c @@ -5,11 +5,8 @@ */ #include <asm/io.h> -#include <env.h> -#include <env_internal.h> #include <spl.h> #include <fdt_support.h> -#include <asm/arch/hardware.h> DECLARE_GLOBAL_DATA_PTR; @@ -57,67 +54,3 @@ void spl_board_init(void) MCU_CTRL_DEVICE_CLKOUT_32K_CTRL); } #endif - -#if IS_ENABLED(CONFIG_ENV_IS_IN_FAT) || IS_ENABLED(CONFIG_ENV_IS_IN_MMC) -int mmc_get_env_dev(void) -{ - u32 boot_device = get_boot_device(); - - switch (boot_device) { - case BOOT_DEVICE_MMC1: - return 0; - case BOOT_DEVICE_MMC2: - return 1; - }; - - return CONFIG_SYS_MMC_ENV_DEV; -} -#endif - -enum env_location env_get_location(enum env_operation op, int prio) -{ - u32 boot_device = get_boot_device(); - - if (prio) - return ENVL_UNKNOWN; - - switch (boot_device) { - case BOOT_DEVICE_MMC1: - case BOOT_DEVICE_MMC2: - if (CONFIG_IS_ENABLED(ENV_IS_IN_FAT)) - return ENVL_FAT; - if (CONFIG_IS_ENABLED(ENV_IS_IN_MMC)) - return ENVL_MMC; - case BOOT_DEVICE_SPI: - if (CONFIG_IS_ENABLED(ENV_IS_IN_SPI_FLASH)) - return ENVL_SPI_FLASH; - default: - return ENVL_NOWHERE; - }; -} - -#if IS_ENABLED(CONFIG_BOARD_LATE_INIT) -int board_late_init(void) -{ - u32 boot_device = get_boot_device(); - - switch (boot_device) { - case BOOT_DEVICE_MMC1: - env_set_ulong("mmcdev", 0); - env_set("boot", "mmc"); - break; - case BOOT_DEVICE_MMC2: - env_set_ulong("mmcdev", 1); - env_set("boot", "mmc"); - break; - case BOOT_DEVICE_SPI: - env_set("boot", "spi"); - break; - case BOOT_DEVICE_ETHERNET: - env_set("boot", "net"); - break; - }; - - return 0; -} -#endif diff --git a/configs/phycore_am64x_a53_defconfig b/configs/phycore_am64x_a53_defconfig index 1a93597..1064fb0 100644 --- a/configs/phycore_am64x_a53_defconfig +++ b/configs/phycore_am64x_a53_defconfig @@ -38,6 +38,7 @@ CONFIG_SPL_LOAD_FIT_ADDRESS=0x81000000 CONFIG_BOOTSTD_FULL=y CONFIG_BOOTCOMMAND="run mmcboot; bootflow scan -lb" CONFIG_DEFAULT_FDT_FILE="oftree" +CONFIG_BOARD_LATE_INIT=y CONFIG_SPL_MAX_SIZE=0x180000 CONFIG_SPL_BOARD_INIT=y CONFIG_SPL_SYS_MALLOC_SIMPLE=y |