blob: 43a19a90717ca70278596a7b35b58212b61bba04 [file] [log] [blame]
Suneel Garapati0a668f62019-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
8#include <common.h>
9#include <dm.h>
10#include <malloc.h>
11#include <errno.h>
12#include <asm/io.h>
13#include <linux/compiler.h>
14#include <asm/arch/soc.h>
15#include <asm/arch/board.h>
16#include <dm/util.h>
17
18int read_platform(void)
19{
20 int plat = PLATFORM_HW;
21
22 const char *model = fdt_get_board_model();
23
24 if (model && !strncmp(model, "ASIM-", 5))
25 plat = PLATFORM_ASIM;
26 if (model && !strncmp(model, "EMUL-", 5))
27 plat = PLATFORM_EMULATOR;
28
29 return plat;
30}
31
32static inline u64 read_midr(void)
33{
34 u64 result;
35
36 asm ("mrs %[rd],MIDR_EL1" : [rd] "=r" (result));
37 return result;
38}
39
40u8 read_partnum(void)
41{
42 return ((read_midr() >> 4) & 0xFF);
43}
44
45const char *read_board_name(void)
46{
47 return fdt_get_board_model();
48}