blob: 0e7a2d11a3523f5009a6f86c4692380aa4faa754 [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
Masahiro Yamada56da5642020-02-03 19:46:40 +09007#include <common/bl_common.h>
Antonio Nino Diaze0f90632018-12-14 00:18:21 +00008#include <lib/mmio.h>
Masahiro Yamada574388c2016-09-03 11:37:40 +09009
10#include "uniphier.h"
11
Masahiro Yamada56da5642020-02-03 19:46:40 +090012#define UNIPHIER_REVISION 0x5f800000UL
13#define UNIPHIER_REVISION_NEW 0x1f800000UL
Masahiro Yamada574388c2016-09-03 11:37:40 +090014
15static unsigned int uniphier_get_revision_field(unsigned int mask,
16 unsigned int shift)
17{
Masahiro Yamada56da5642020-02-03 19:46:40 +090018 uintptr_t reg;
19
20 if (BL_CODE_BASE >= 0x80000000UL)
21 reg = UNIPHIER_REVISION;
22 else
23 reg = UNIPHIER_REVISION_NEW;
Masahiro Yamada574388c2016-09-03 11:37:40 +090024
Masahiro Yamada56da5642020-02-03 19:46:40 +090025 return (mmio_read_32(reg) >> shift) & mask;
Masahiro Yamada574388c2016-09-03 11:37:40 +090026}
27
28unsigned int uniphier_get_soc_type(void)
29{
30 return uniphier_get_revision_field(0xff, 16);
31}
32
33unsigned int uniphier_get_soc_model(void)
34{
35 return uniphier_get_revision_field(0x07, 8);
36}
37
38unsigned int uniphier_get_soc_revision(void)
39{
40 return uniphier_get_revision_field(0x1f, 0);
41}
42
43unsigned int uniphier_get_soc_id(void)
44{
45 uint32_t type = uniphier_get_soc_type();
46
47 switch (type) {
48 case 0x31:
49 return UNIPHIER_SOC_LD11;
50 case 0x32:
51 return UNIPHIER_SOC_LD20;
52 case 0x35:
53 return UNIPHIER_SOC_PXS3;
54 default:
55 return UNIPHIER_SOC_UNKNOWN;
56 }
57}