cpu-info.c 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. // SPDX-License-Identifier: (GPL-2.0+ OR MIT)
  2. /*
  3. * (C) Copyright 2019 Amarula Solutions(India)
  4. * Author: Jagan Teki <jagan@amarulasolutions.com>
  5. */
  6. #include <common.h>
  7. #include <init.h>
  8. #include <asm/io.h>
  9. #include <asm/arch-rockchip/clock.h>
  10. #include <asm/arch-rockchip/cru.h>
  11. #include <asm/arch-rockchip/hardware.h>
  12. #include <linux/err.h>
  13. static char *get_reset_cause(void)
  14. {
  15. struct rockchip_cru *cru = rockchip_get_cru();
  16. char *cause = NULL;
  17. if (IS_ERR(cru))
  18. return cause;
  19. switch (cru->glb_rst_st) {
  20. case GLB_POR_RST:
  21. cause = "POR";
  22. break;
  23. case FST_GLB_RST_ST:
  24. case SND_GLB_RST_ST:
  25. cause = "RST";
  26. break;
  27. case FST_GLB_TSADC_RST_ST:
  28. case SND_GLB_TSADC_RST_ST:
  29. cause = "THERMAL";
  30. break;
  31. case FST_GLB_WDT_RST_ST:
  32. case SND_GLB_WDT_RST_ST:
  33. cause = "WDOG";
  34. break;
  35. default:
  36. cause = "unknown reset";
  37. }
  38. /**
  39. * reset_reason env is used by rk3288, due to special use case
  40. * to figure it the boot behavior. so keep this as it is.
  41. */
  42. env_set("reset_reason", cause);
  43. /*
  44. * Clear glb_rst_st, so we can determine the last reset cause
  45. * for following resets.
  46. */
  47. rk_clrreg(&cru->glb_rst_st, GLB_RST_ST_MASK);
  48. return cause;
  49. }
  50. int print_cpuinfo(void)
  51. {
  52. printf("SoC: Rockchip %s\n", CONFIG_SYS_SOC);
  53. printf("Reset cause: %s\n", get_reset_cause());
  54. /* TODO print operating temparature and clock */
  55. return 0;
  56. }