summaryrefslogtreecommitdiffstats
path: root/arch/arm/boards/radxa-rock3/board.c
blob: cea00b9773d2c27639a48b4cecb96b3d757adc8d (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
51
52
53
54
55
56
// SPDX-License-Identifier: GPL-2.0-only
#include <bootsource.h>
#include <common.h>
#include <deep-probe.h>
#include <init.h>
#include <mach/bbu.h>

struct rock3_model {
	const char *name;
	const char *shortname;
};

static int rock3_probe(struct device_d *dev)
{
	enum bootsource bootsource = bootsource_get();
	int instance = bootsource_get_instance();
	const struct rock3_model *model;

	model = device_get_match_data(dev);

	barebox_set_model(model->name);
	barebox_set_hostname(model->shortname);

	if (bootsource == BOOTSOURCE_MMC && instance == 0)
		of_device_enable_path("/chosen/environment-sd");
	else
		of_device_enable_path("/chosen/environment-emmc");

	rk3568_bbu_mmc_register("emmc", BBU_HANDLER_FLAG_DEFAULT,
				"/dev/mmc1");
	rk3568_bbu_mmc_register("sd", 0, "/dev/mmc0");

	return 0;
}

static const struct rock3_model rock3a = {
	.name = "Radxa ROCK3 Model A",
	.shortname = "rock3a",
};

static const struct of_device_id rock3_of_match[] = {
	{
		.compatible = "radxa,rock3a",
		.data = &rock3a,
	},
	{ /* sentinel */ },
};

static struct driver_d rock3_board_driver = {
	.name = "board-rock3",
	.probe = rock3_probe,
	.of_compatible = rock3_of_match,
};
coredevice_platform_driver(rock3_board_driver);

BAREBOX_DEEP_PROBE_ENABLE(rock3_of_match);