cpu-info.c 1.3 KB

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