blob: 64eb95f3b400d81002ab5585ef6fa5096f7fe50a [file] [log] [blame]
Suneel Garapatid9e72462019-10-19 18:47:37 -07001// SPDX-License-Identifier: GPL-2.0
2/*
3 * Copyright (C) 2019 Marvell International Ltd.
4 *
5 * https://spdx.org/licenses
6 */
7
Suneel Garapatid9e72462019-10-19 18:47:37 -07008#include <dm.h>
9#include <malloc.h>
10#include <errno.h>
11#include <asm/io.h>
12#include <linux/compiler.h>
13#include <asm/arch/soc.h>
14#include <asm/arch/board.h>
15#include <dm/util.h>
16
17int read_platform(void)
18{
19 int plat = PLATFORM_HW;
20
21 const char *model = fdt_get_board_model();
22
23 if (model && !strncmp(model, "ASIM-", 5))
24 plat = PLATFORM_ASIM;
25 if (model && !strncmp(model, "EMUL-", 5))
26 plat = PLATFORM_EMULATOR;
27
28 return plat;
29}
30
31static inline u64 read_midr(void)
32{
33 u64 result;
34
35 asm ("mrs %[rd],MIDR_EL1" : [rd] "=r" (result));
36 return result;
37}
38
39u8 read_partnum(void)
40{
41 return ((read_midr() >> 4) & 0xFF);
42}
43
44const char *read_board_name(void)
45{
46 return fdt_get_board_model();
47}