summaryrefslogtreecommitdiffstats
path: root/arch/arm/boards/sama5d27-som1/board.c
blob: 00c0e92a5da3269fae8a516b0308ef70cab3e816 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// SPDX-License-Identifier: GPL-2.0-only

#include <common.h>
#include <linux/sizes.h>
#include <init.h>
#include <asm/memory.h>
#include <bbu.h>
#include <bootsource.h>
#include <of.h>

static int ek_device_init(void)
{
	int flags_sd = 0, flags_usd = 0;
	if (!of_machine_is_compatible("atmel,sama5d27-som1-ek"))
		return 0;

	if (bootsource_get() == BOOTSOURCE_MMC) {
		if (bootsource_get_instance() == 0) {
			flags_sd = BBU_HANDLER_FLAG_DEFAULT;
			of_device_enable_path("/chosen/environment-sd");
		} else {
			flags_usd = BBU_HANDLER_FLAG_DEFAULT;
			of_device_enable_path("/chosen/environment-microsd");
		}
	} else {
		of_device_enable_path("/chosen/environment-qspi");
	}

	bbu_register_std_file_update("SD", flags_sd, "/mnt/mmc0.0/barebox.bin",
				     filetype_arm_barebox);
	bbu_register_std_file_update("microSD", flags_usd, "/mnt/mmc1.0/barebox.bin",
				     filetype_arm_barebox);
	return 0;
}
device_initcall(ek_device_init);