1 /* 2 * Copyright (c) 2017, ARM Limited and Contributors. All rights reserved. 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 */ 6 7 #include <common/bl_common.h> 8 #include <lib/mmio.h> 9 10 #include "uniphier.h" 11 12 #define UNIPHIER_REVISION 0x5f800000UL 13 #define UNIPHIER_REVISION_NEW 0x1f800000UL 14 uniphier_get_revision_field(unsigned int mask,unsigned int shift)15static unsigned int uniphier_get_revision_field(unsigned int mask, 16 unsigned int shift) 17 { 18 uintptr_t reg; 19 20 if (BL_CODE_BASE >= 0x80000000UL) 21 reg = UNIPHIER_REVISION; 22 else 23 reg = UNIPHIER_REVISION_NEW; 24 25 return (mmio_read_32(reg) >> shift) & mask; 26 } 27 uniphier_get_soc_type(void)28unsigned int uniphier_get_soc_type(void) 29 { 30 return uniphier_get_revision_field(0xff, 16); 31 } 32 uniphier_get_soc_model(void)33unsigned int uniphier_get_soc_model(void) 34 { 35 return uniphier_get_revision_field(0x07, 8); 36 } 37 uniphier_get_soc_revision(void)38unsigned int uniphier_get_soc_revision(void) 39 { 40 return uniphier_get_revision_field(0x1f, 0); 41 } 42 uniphier_get_soc_id(void)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 } 58