summaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-at91/bootm-barebox.c
blob: 5540b8fad35e70142f155bd7e5ea02afe79a563c (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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// SPDX-License-Identifier: GPL-2.0-only

#define pr_fmt(fmt) "at91-bootm-barebox: " fmt

#include <bootm.h>
#include <common.h>
#include <init.h>
#include <memory.h>
#include <mach/at91/sama5_bootsource.h>

unsigned long at91_bootsource;
EXPORT_SYMBOL(at91_bootsource);

static int do_bootm_at91_barebox_image(struct image_data *data)
{
	resource_size_t start, end;
	int ret;

	ret = memory_bank_first_find_space(&start, &end);
	if (ret)
		return ret;

	ret = bootm_load_os(data, start);
	if (ret)
		return ret;

	if (data->verbose)
		printf("Loaded barebox image to 0x%08zx\n", start);

	shutdown_barebox();

	sama5_boot_xload((void *)start, at91_bootsource);

	return -EIO;
}

static struct image_handler image_handler_at91_barebox_image = {
	.name = "AT91 barebox image",
	.bootm = do_bootm_at91_barebox_image,
	.filetype = filetype_arm_barebox,
};

static int at91_register_barebox_image_handler(void)
{
	if (!of_machine_is_compatible("atmel,sama5"))
	    return 0;

	return register_image_handler(&image_handler_at91_barebox_image);
}
late_initcall(at91_register_barebox_image_handler);