Anatolij Gustschin | ef156d2 | 2019-06-12 13:35:25 +0200 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Simon Glass | 0f2af88 | 2020-05-10 11:40:05 -0600 | [diff] [blame] | 2 | #include <log.h> |
Peng Fan | 2e0644a | 2023-04-28 12:08:09 +0800 | [diff] [blame] | 3 | #include <firmware/imx/sci/sci.h> |
Anatolij Gustschin | a8d7797 | 2019-10-26 16:24:04 +0200 | [diff] [blame] | 4 | #include <asm/mach-imx/sys_proto.h> |
Peng Fan | f1863a5 | 2020-04-22 10:50:04 +0800 | [diff] [blame] | 5 | #include <imx_sip.h> |
Peng Fan | 4bd5e43 | 2020-05-11 15:13:34 +0800 | [diff] [blame] | 6 | #include <linux/arm-smccc.h> |
Anatolij Gustschin | ef156d2 | 2019-06-12 13:35:25 +0200 | [diff] [blame] | 7 | |
| 8 | int sc_pm_setup_uart(sc_rsrc_t uart_rsrc, sc_pm_clock_rate_t clk_rate) |
| 9 | { |
| 10 | sc_pm_clock_rate_t rate = clk_rate; |
| 11 | int ret; |
| 12 | |
| 13 | /* Power up UARTn */ |
| 14 | ret = sc_pm_set_resource_power_mode(-1, uart_rsrc, SC_PM_PW_MODE_ON); |
| 15 | if (ret) |
| 16 | return ret; |
| 17 | |
| 18 | /* Set UARTn clock root to 'rate' MHz */ |
| 19 | ret = sc_pm_set_clock_rate(-1, uart_rsrc, SC_PM_CLK_PER, &rate); |
| 20 | if (ret) |
| 21 | return ret; |
| 22 | |
| 23 | /* Enable UARTn clock root */ |
| 24 | ret = sc_pm_clock_enable(-1, uart_rsrc, SC_PM_CLK_PER, true, false); |
| 25 | if (ret) |
| 26 | return ret; |
| 27 | |
| 28 | return 0; |
| 29 | } |
Anatolij Gustschin | 21f2747 | 2019-06-12 13:35:26 +0200 | [diff] [blame] | 30 | |
| 31 | void build_info(void) |
| 32 | { |
Peng Fan | 4bd5e43 | 2020-05-11 15:13:34 +0800 | [diff] [blame] | 33 | struct arm_smccc_res res; |
Anatolij Gustschin | a8d7797 | 2019-10-26 16:24:04 +0200 | [diff] [blame] | 34 | u32 seco_build = 0, seco_commit = 0; |
Anatolij Gustschin | 21f2747 | 2019-06-12 13:35:26 +0200 | [diff] [blame] | 35 | u32 sc_build = 0, sc_commit = 0; |
Anatolij Gustschin | a8d7797 | 2019-10-26 16:24:04 +0200 | [diff] [blame] | 36 | ulong atf_commit = 0; |
Anatolij Gustschin | 21f2747 | 2019-06-12 13:35:26 +0200 | [diff] [blame] | 37 | |
| 38 | /* Get SCFW build and commit id */ |
| 39 | sc_misc_build_info(-1, &sc_build, &sc_commit); |
| 40 | if (!sc_build) { |
| 41 | printf("SCFW does not support build info\n"); |
| 42 | sc_commit = 0; /* Display 0 if build info not supported */ |
| 43 | } |
Anatolij Gustschin | a8d7797 | 2019-10-26 16:24:04 +0200 | [diff] [blame] | 44 | |
| 45 | /* Get SECO FW build and commit id */ |
| 46 | sc_seco_build_info(-1, &seco_build, &seco_commit); |
| 47 | if (!seco_build) { |
| 48 | debug("SECO FW does not support build info\n"); |
| 49 | /* Display 0 when the build info is not supported */ |
| 50 | seco_commit = 0; |
| 51 | } |
| 52 | |
| 53 | /* Get ARM Trusted Firmware commit id */ |
Peng Fan | 4bd5e43 | 2020-05-11 15:13:34 +0800 | [diff] [blame] | 54 | arm_smccc_smc(IMX_SIP_BUILDINFO, IMX_SIP_BUILDINFO_GET_COMMITHASH, |
| 55 | 0, 0, 0, 0, 0, 0, &res); |
| 56 | atf_commit = res.a0; |
Anatolij Gustschin | a8d7797 | 2019-10-26 16:24:04 +0200 | [diff] [blame] | 57 | if (atf_commit == 0xffffffff) { |
| 58 | debug("ATF does not support build info\n"); |
| 59 | atf_commit = 0x30; /* Display 0 */ |
| 60 | } |
| 61 | |
| 62 | printf("Build: SCFW %08x, SECO-FW %08x, ATF %s\n", |
| 63 | sc_commit, seco_commit, (char *)&atf_commit); |
Anatolij Gustschin | 21f2747 | 2019-06-12 13:35:26 +0200 | [diff] [blame] | 64 | } |