uniphier_soc_info.c 1.1 KB

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