summaryrefslogtreecommitdiffstats
path: root/arch/arm/boards/radxa-cm3/board.c
blob: 14b678417910b6e1a0dc3176b668704e50b5a894 (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/rockchip/bbu.h>

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

static int cm3_probe(struct device *dev)
{
	enum bootsource bootsource = bootsource_get();
	int instance = bootsource_get_instance();
	const struct cm3_model *model;

	model = device_get_match_data(dev);

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

	if (bootsource == BOOTSOURCE_MMC && instance == 1)
		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/mmc0");
	rk3568_bbu_mmc_register("sd", 0, "/dev/mmc1");

	return 0;
}

static const struct cm3_model cm3_io = {
	.name = "Radxa CM3 on IO Board",
	.shortname = "cm3-io",
};

static const struct of_device_id cm3_of_match[] = {
	{
		.compatible = "radxa,cm3-io",
		.data = &cm3_io,
	},
	{ /* sentinel */ },
};

static struct driver cm3_io_board_driver = {
	.name = "board-cm3-io",
	.probe = cm3_probe,
	.of_compatible = cm3_of_match,
};
coredevice_platform_driver(cm3_io_board_driver);

BAREBOX_DEEP_PROBE_ENABLE(cm3_of_match);