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 | |
| 7 | #include <common.h> |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 8 | #include <env.h> |
Simon Glass | 9758973 | 2020-05-10 11:40:02 -0600 | [diff] [blame] | 9 | #include <init.h> |
Jagan Teki | 4fe57d2 | 2020-01-09 14:22:18 +0530 | [diff] [blame] | 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 | |
Jagan Teki | 5bbc86b | 2020-07-21 20:36:03 +0530 | [diff] [blame] | 15 | char *get_reset_cause(void) |
Jagan Teki | 4fe57d2 | 2020-01-09 14:22:18 +0530 | [diff] [blame] | 16 | { |
| 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 Teki | 4fe57d2 | 2020-01-09 14:22:18 +0530 | [diff] [blame] | 43 | return cause; |
| 44 | } |
Jagan Teki | cc46443 | 2020-01-09 14:22:15 +0530 | [diff] [blame] | 45 | |
Simon Glass | b3bb4ab | 2023-02-05 15:39:36 -0700 | [diff] [blame] | 46 | #if IS_ENABLED(CONFIG_DISPLAY_CPUINFO) |
Jagan Teki | cc46443 | 2020-01-09 14:22:15 +0530 | [diff] [blame] | 47 | int print_cpuinfo(void) |
| 48 | { |
Jagan Teki | 5bbc86b | 2020-07-21 20:36:03 +0530 | [diff] [blame] | 49 | char *cause = get_reset_cause(); |
| 50 | |
Jagan Teki | cc46443 | 2020-01-09 14:22:15 +0530 | [diff] [blame] | 51 | printf("SoC: Rockchip %s\n", CONFIG_SYS_SOC); |
Jagan Teki | 5bbc86b | 2020-07-21 20:36:03 +0530 | [diff] [blame] | 52 | 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 Teki | cc46443 | 2020-01-09 14:22:15 +0530 | [diff] [blame] | 59 | |
| 60 | /* TODO print operating temparature and clock */ |
| 61 | |
| 62 | return 0; |
| 63 | } |
Jagan Teki | 5bbc86b | 2020-07-21 20:36:03 +0530 | [diff] [blame] | 64 | #endif |