summaryrefslogtreecommitdiffstats
path: root/arch/arm/boards/phytec-phycore-stm32mp1/board.c
blob: 6690e36ca7180be2e0928199df514c8e2bde3c08 (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
// SPDX-License-Identifier: GPL-2.0-or-later
#include <common.h>
#include <driver.h>
#include <bootsource.h>
#include <mach/stm32mp/bbu.h>

static int phycore_stm32mp1_probe(struct device *dev)
{
	int sd_bbu_flags = 0, emmc_bbu_flags = 0;

	if (bootsource_get_instance() == 0) {
		of_device_enable_path("/chosen/environment-sd");
		sd_bbu_flags = BBU_HANDLER_FLAG_DEFAULT;
	} else {
		of_device_enable_path("/chosen/environment-emmc");
		emmc_bbu_flags = BBU_HANDLER_FLAG_DEFAULT;
	}

	stm32mp_bbu_mmc_register_handler("sd", "/dev/mmc0.ssbl", sd_bbu_flags);
	stm32mp_bbu_mmc_fip_register("emmc", "/dev/mmc1", emmc_bbu_flags);

	barebox_set_hostname("phyCORE-STM32MP1");

	return 0;
}

static const struct of_device_id phycore_stm32mp1_of_match[] = {
	{ .compatible = "phytec,phycore-stm32mp1-3" },
	{ /* sentinel */ },
};
MODULE_DEVICE_TABLE(of, phycore_stm32mp1_of_match);

static struct driver phycore_stm32mp1_board_driver = {
	.name = "board-phycore-stm32mp1",
	.probe = phycore_stm32mp1_probe,
	.of_compatible = phycore_stm32mp1_of_match,
};
device_platform_driver(phycore_stm32mp1_board_driver);