blob: a62ff53c6a0484b251aedff71d78f04752f6cdf5 [file] [log] [blame]
Jagan Tekicc464432020-01-09 14:22:15 +05301// 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
7#include <common.h>
Simon Glassed38aef2020-05-10 11:40:03 -06008#include <env.h>
Simon Glass97589732020-05-10 11:40:02 -06009#include <init.h>
Jagan Teki4fe57d22020-01-09 14:22:18 +053010#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
Jagan Teki5bbc86b2020-07-21 20:36:03 +053015char *get_reset_cause(void)
Jagan Teki4fe57d22020-01-09 14:22:18 +053016{
17 struct rockchip_cru *cru = rockchip_get_cru();
18 char *cause = NULL;
19
20 if (IS_ERR(cru))
21 return cause;
22
23 switch (cru->glb_rst_st) {
24 case GLB_POR_RST:
25 cause = "POR";
26 break;
27 case FST_GLB_RST_ST:
28 case SND_GLB_RST_ST:
29 cause = "RST";
30 break;
31 case FST_GLB_TSADC_RST_ST:
32 case SND_GLB_TSADC_RST_ST:
33 cause = "THERMAL";
34 break;
35 case FST_GLB_WDT_RST_ST:
36 case SND_GLB_WDT_RST_ST:
37 cause = "WDOG";
38 break;
39 default:
40 cause = "unknown reset";
41 }
42
Jagan Teki4fe57d22020-01-09 14:22:18 +053043 return cause;
44}
Jagan Tekicc464432020-01-09 14:22:15 +053045
Simon Glassb3bb4ab2023-02-05 15:39:36 -070046#if IS_ENABLED(CONFIG_DISPLAY_CPUINFO)
Jagan Tekicc464432020-01-09 14:22:15 +053047int print_cpuinfo(void)
48{
Jagan Teki5bbc86b2020-07-21 20:36:03 +053049 char *cause = get_reset_cause();
50
Jagan Tekicc464432020-01-09 14:22:15 +053051 printf("SoC: Rockchip %s\n", CONFIG_SYS_SOC);
Jagan Teki5bbc86b2020-07-21 20:36:03 +053052 printf("Reset cause: %s\n", cause);
53
54 /**
55 * reset_reason env is used by rk3288, due to special use case
56 * to figure it the boot behavior. so keep this as it is.
57 */
58 env_set("reset_reason", cause);
Jagan Tekicc464432020-01-09 14:22:15 +053059
60 /* TODO print operating temparature and clock */
61
62 return 0;
63}
Jagan Teki5bbc86b2020-07-21 20:36:03 +053064#endif