blob: 377532deba8b66e0159b8f9b6285cb58699e2bb8 [file] [log] [blame]
Masahiro Yamada574388c2016-09-03 11:37:40 +09001/*
2 * Copyright (c) 2017, ARM Limited and Contributors. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
Antonio Nino Diaze0f90632018-12-14 00:18:21 +00007#include <lib/mmio.h>
Masahiro Yamada574388c2016-09-03 11:37:40 +09008
9#include "uniphier.h"
10
11#define UNIPHIER_REVISION 0x5f800000
12
13static unsigned int uniphier_get_revision_field(unsigned int mask,
14 unsigned int shift)
15{
16 uint32_t revision = mmio_read_32(UNIPHIER_REVISION);
17
18 return (revision >> shift) & mask;
19}
20
21unsigned int uniphier_get_soc_type(void)
22{
23 return uniphier_get_revision_field(0xff, 16);
24}
25
26unsigned int uniphier_get_soc_model(void)
27{
28 return uniphier_get_revision_field(0x07, 8);
29}
30
31unsigned int uniphier_get_soc_revision(void)
32{
33 return uniphier_get_revision_field(0x1f, 0);
34}
35
36unsigned int uniphier_get_soc_id(void)
37{
38 uint32_t type = uniphier_get_soc_type();
39
40 switch (type) {
41 case 0x31:
42 return UNIPHIER_SOC_LD11;
43 case 0x32:
44 return UNIPHIER_SOC_LD20;
45 case 0x35:
46 return UNIPHIER_SOC_PXS3;
47 default:
48 return UNIPHIER_SOC_UNKNOWN;
49 }
50}