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