Jagan Teki | cc46443 | 2020-01-09 14:22:15 +0530 | [diff] [blame] | 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 | |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 7 | #include <env.h> |
Simon Glass | 9758973 | 2020-05-10 11:40:02 -0600 | [diff] [blame] | 8 | #include <init.h> |
Jagan Teki | 4fe57d2 | 2020-01-09 14:22:18 +0530 | [diff] [blame] | 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 | |
Jagan Teki | 5bbc86b | 2020-07-21 20:36:03 +0530 | [diff] [blame] | 14 | char *get_reset_cause(void) |
Jagan Teki | 4fe57d2 | 2020-01-09 14:22:18 +0530 | [diff] [blame] | 15 | { |
| 16 | struct rockchip_cru *cru = rockchip_get_cru(); |
| 17 | char *cause = NULL; |
| 18 | |
| 19 | if (IS_ERR(cru)) |
| 20 | return cause; |
| 21 | |
| 22 | switch (cru->glb_rst_st) { |
| 23 | case GLB_POR_RST: |
| 24 | cause = "POR"; |
| 25 | break; |
| 26 | case FST_GLB_RST_ST: |
| 27 | case SND_GLB_RST_ST: |
| 28 | cause = "RST"; |
| 29 | break; |
| 30 | case FST_GLB_TSADC_RST_ST: |
| 31 | case SND_GLB_TSADC_RST_ST: |
| 32 | cause = "THERMAL"; |
| 33 | break; |
| 34 | case FST_GLB_WDT_RST_ST: |
| 35 | case SND_GLB_WDT_RST_ST: |
| 36 | cause = "WDOG"; |
| 37 | break; |
| 38 | default: |
| 39 | cause = "unknown reset"; |
| 40 | } |
| 41 | |
Jagan Teki | 4fe57d2 | 2020-01-09 14:22:18 +0530 | [diff] [blame] | 42 | return cause; |
| 43 | } |
Jagan Teki | cc46443 | 2020-01-09 14:22:15 +0530 | [diff] [blame] | 44 | |
Simon Glass | b3bb4ab | 2023-02-05 15:39:36 -0700 | [diff] [blame] | 45 | #if IS_ENABLED(CONFIG_DISPLAY_CPUINFO) |
Jagan Teki | cc46443 | 2020-01-09 14:22:15 +0530 | [diff] [blame] | 46 | int print_cpuinfo(void) |
| 47 | { |
Jagan Teki | 5bbc86b | 2020-07-21 20:36:03 +0530 | [diff] [blame] | 48 | char *cause = get_reset_cause(); |
| 49 | |
Jagan Teki | cc46443 | 2020-01-09 14:22:15 +0530 | [diff] [blame] | 50 | printf("SoC: Rockchip %s\n", CONFIG_SYS_SOC); |
Jagan Teki | 5bbc86b | 2020-07-21 20:36:03 +0530 | [diff] [blame] | 51 | printf("Reset cause: %s\n", cause); |
| 52 | |
| 53 | /** |
| 54 | * reset_reason env is used by rk3288, due to special use case |
| 55 | * to figure it the boot behavior. so keep this as it is. |
| 56 | */ |
| 57 | env_set("reset_reason", cause); |
Jagan Teki | cc46443 | 2020-01-09 14:22:15 +0530 | [diff] [blame] | 58 | |
| 59 | /* TODO print operating temparature and clock */ |
| 60 | |
| 61 | return 0; |
| 62 | } |
Jagan Teki | 5bbc86b | 2020-07-21 20:36:03 +0530 | [diff] [blame] | 63 | #endif |