• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2017, ARM Limited and Contributors. All rights reserved.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 
7 #include <mmio.h>
8 
9 #include "uniphier.h"
10 
11 #define UNIPHIER_REVISION		0x5f800000
12 
uniphier_get_revision_field(unsigned int mask,unsigned int shift)13 static 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 
uniphier_get_soc_type(void)21 unsigned int uniphier_get_soc_type(void)
22 {
23 	return uniphier_get_revision_field(0xff, 16);
24 }
25 
uniphier_get_soc_model(void)26 unsigned int uniphier_get_soc_model(void)
27 {
28 	return uniphier_get_revision_field(0x07, 8);
29 }
30 
uniphier_get_soc_revision(void)31 unsigned int uniphier_get_soc_revision(void)
32 {
33 	return uniphier_get_revision_field(0x1f, 0);
34 }
35 
uniphier_get_soc_id(void)36 unsigned 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 }
51