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