Suneel Garapati | d9e7246 | 2019-10-19 18:47:37 -0700 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
| 2 | /* |
| 3 | * Copyright (C) 2019 Marvell International Ltd. |
| 4 | * |
| 5 | * https://spdx.org/licenses |
| 6 | */ |
| 7 | |
Suneel Garapati | d9e7246 | 2019-10-19 18:47:37 -0700 | [diff] [blame] | 8 | #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 | |
| 17 | int 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 | |
| 31 | static inline u64 read_midr(void) |
| 32 | { |
| 33 | u64 result; |
| 34 | |
| 35 | asm ("mrs %[rd],MIDR_EL1" : [rd] "=r" (result)); |
| 36 | return result; |
| 37 | } |
| 38 | |
| 39 | u8 read_partnum(void) |
| 40 | { |
| 41 | return ((read_midr() >> 4) & 0xFF); |
| 42 | } |
| 43 | |
| 44 | const char *read_board_name(void) |
| 45 | { |
| 46 | return fdt_get_board_model(); |
| 47 | } |