summaryrefslogtreecommitdiff
path: root/board/kontron
diff options
context:
space:
mode:
Diffstat (limited to 'board/kontron')
-rw-r--r--board/kontron/sl-mx8mm/sl-mx8mm.c102
-rw-r--r--board/kontron/sl-mx8mm/spl.c11
2 files changed, 98 insertions, 15 deletions
diff --git a/board/kontron/sl-mx8mm/sl-mx8mm.c b/board/kontron/sl-mx8mm/sl-mx8mm.c
index 2e387038395..df92765cb2d 100644
--- a/board/kontron/sl-mx8mm/sl-mx8mm.c
+++ b/board/kontron/sl-mx8mm/sl-mx8mm.c
@@ -8,12 +8,14 @@
#include <asm/global_data.h>
#include <asm/io.h>
#include <asm/mach-imx/boot_mode.h>
+#include <dm/uclass.h>
#include <efi.h>
#include <efi_loader.h>
#include <env_internal.h>
#include <fdt_support.h>
#include <linux/errno.h>
#include <linux/kernel.h>
+#include <mmc.h>
#include <net.h>
DECLARE_GLOBAL_DATA_PTR;
@@ -108,25 +110,68 @@ int fdt_set_usb_eth_addr(void *blob)
int ft_board_setup(void *blob, struct bd_info *bd)
{
- int ret = fdt_set_usb_eth_addr(blob);
+ enum env_location env_loc;
+ enum boot_device boot_dev;
+ char env_str_sd[] = "sd-card";
+ char env_str_nor[] = "spi-nor";
+ char env_str_emmc[] = "emmc";
+ char *env_config_str;
+ int ret;
+
+ ret = fdt_set_usb_eth_addr(blob);
+ if (ret)
+ return ret;
+ ret = fdt_fixup_memory(blob, PHYS_SDRAM, gd->ram_size);
if (ret)
return ret;
- return fdt_fixup_memory(blob, PHYS_SDRAM, gd->ram_size);
+ env_loc = env_get_location(0, 0);
+ if (env_loc == ENVL_MMC) {
+ boot_dev = get_boot_device();
+ if (boot_dev == SD2_BOOT)
+ env_config_str = env_str_sd;
+ else if (boot_dev == MMC1_BOOT)
+ env_config_str = env_str_emmc;
+ else
+ return 0;
+ } else if (env_loc == ENVL_SPI_FLASH) {
+ env_config_str = env_str_nor;
+ } else {
+ return 0;
+ }
+
+ /*
+ * Export a string to the devicetree that tells userspace tools like
+ * libubootenv where the environment is currently coming from.
+ */
+ return fdt_find_and_setprop(blob, "/chosen", "u-boot,env-config",
+ env_config_str, strlen(env_config_str) + 1, 1);
}
int board_late_init(void)
{
+ struct udevice *dev;
+ int ret;
+
if (!fdt_node_check_compatible(gd->fdt_blob, 0, "kontron,imx8mm-n802x-som") ||
!fdt_node_check_compatible(gd->fdt_blob, 0, "kontron,imx8mm-osm-s")) {
env_set("som_type", "osm-s");
env_set("touch_rst_gpio", "111");
+
+ ret = uclass_get_device_by_name(UCLASS_MISC, "usb-hub@2c", &dev);
+ if (ret)
+ printf("Error bringing up USB hub (%d)\n", ret);
} else {
env_set("som_type", "sl");
env_set("touch_rst_gpio", "87");
}
+ if (is_usb_boot()) {
+ env_set("bootcmd", "fastboot 0");
+ env_set("bootdelay", "0");
+ }
+
return 0;
}
@@ -137,18 +182,25 @@ enum env_location env_get_location(enum env_operation op, int prio)
if (prio)
return ENVL_UNKNOWN;
+ if (CONFIG_IS_ENABLED(ENV_IS_NOWHERE) && is_usb_boot())
+ return ENVL_NOWHERE;
+
/*
* Make sure that the environment is loaded from
* the MMC if we are running from SD card or eMMC.
*/
if (CONFIG_IS_ENABLED(ENV_IS_IN_MMC) &&
- (boot_dev == SD1_BOOT || boot_dev == SD2_BOOT))
+ (boot_dev == SD1_BOOT || boot_dev == SD2_BOOT ||
+ boot_dev == MMC1_BOOT || boot_dev == MMC2_BOOT))
return ENVL_MMC;
if (CONFIG_IS_ENABLED(ENV_IS_IN_SPI_FLASH))
return ENVL_SPI_FLASH;
- return ENVL_NOWHERE;
+ if (CONFIG_IS_ENABLED(ENV_IS_NOWHERE))
+ return ENVL_NOWHERE;
+
+ return ENVL_UNKNOWN;
}
#if defined(CONFIG_ENV_IS_IN_MMC)
@@ -156,4 +208,46 @@ int board_mmc_get_env_dev(int devno)
{
return devno;
}
+
+uint mmc_get_env_part(struct mmc *mmc)
+{
+ if (IS_SD(mmc))
+ return EMMC_HWPART_DEFAULT;
+
+ switch (EXT_CSD_EXTRACT_BOOT_PART(mmc->part_config)) {
+ case EMMC_BOOT_PART_BOOT1:
+ return EMMC_HWPART_BOOT1;
+ case EMMC_BOOT_PART_BOOT2:
+ return EMMC_HWPART_BOOT2;
+ default:
+ return EMMC_HWPART_DEFAULT;
+ }
+}
+
+int mmc_get_env_addr(struct mmc *mmc, int copy, u32 *env_addr)
+{
+ /* use normal offset for SD card */
+ if (IS_SD(mmc)) {
+ *env_addr = CONFIG_ENV_OFFSET;
+ if (copy)
+ *env_addr = CONFIG_ENV_OFFSET_REDUND;
+
+ return 0;
+ }
+
+ switch (EXT_CSD_EXTRACT_BOOT_PART(mmc->part_config)) {
+ case EMMC_BOOT_PART_BOOT1:
+ case EMMC_BOOT_PART_BOOT2:
+ *env_addr = mmc->capacity - CONFIG_ENV_SIZE - CONFIG_ENV_SIZE;
+ if (copy)
+ *env_addr = mmc->capacity - CONFIG_ENV_SIZE;
+ break;
+ default:
+ *env_addr = CONFIG_ENV_OFFSET;
+ if (copy)
+ *env_addr = CONFIG_ENV_OFFSET_REDUND;
+ }
+
+ return 0;
+}
#endif
diff --git a/board/kontron/sl-mx8mm/spl.c b/board/kontron/sl-mx8mm/spl.c
index 54ee1e66a7a..e3b029752b8 100644
--- a/board/kontron/sl-mx8mm/spl.c
+++ b/board/kontron/sl-mx8mm/spl.c
@@ -129,17 +129,6 @@ int do_board_detect(void)
(unsigned int)gd->ram_size);
}
- /*
- * Check the I2C PMIC to detect the deprecated SoM with DA9063.
- */
- imx_iomux_v3_setup_multiple_pads(i2c1_pads, ARRAY_SIZE(i2c1_pads));
-
- if (i2c_get_chip_for_busnum(0, 0x58, 0, &udev) == 0) {
- printf("### ATTENTION: DEPRECATED SOM REVISION (N8010 Rev0) DETECTED! ###\n");
- printf("### THIS HW IS NOT SUPPORTED AND BOOTING WILL PROBABLY FAIL ###\n");
- printf("### PLEASE UPGRADE TO LATEST MODULE ###\n");
- }
-
return 0;
}