Ley Foon Tan | f80cb34 | 2018-05-24 00:17:24 +0800 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
| 2 | /* |
| 3 | * Copyright (C) 2016-2018 Intel Corporation <www.intel.com> |
| 4 | * |
| 5 | */ |
| 6 | |
| 7 | #include <altera.h> |
| 8 | #include <common.h> |
Chee Hong Ang | f18fe84 | 2020-07-10 23:52:32 +0800 | [diff] [blame] | 9 | #include <asm/arch/mailbox_s10.h> |
| 10 | #include <asm/arch/misc.h> |
Ley Foon Tan | f80cb34 | 2018-05-24 00:17:24 +0800 | [diff] [blame] | 11 | #include <asm/arch/reset_manager.h> |
| 12 | #include <asm/arch/system_manager.h> |
Siew Chin Lim | e377bf2 | 2021-08-10 11:26:35 +0800 | [diff] [blame] | 13 | #include <asm/io.h> |
| 14 | #include <asm/global_data.h> |
| 15 | #include <env.h> |
| 16 | #include <errno.h> |
| 17 | #include <init.h> |
| 18 | #include <log.h> |
Tom Rini | 3fb5b2f | 2022-03-30 18:07:23 -0400 | [diff] [blame] | 19 | #include <mach/clock_manager.h> |
Ley Foon Tan | f80cb34 | 2018-05-24 00:17:24 +0800 | [diff] [blame] | 20 | |
| 21 | DECLARE_GLOBAL_DATA_PTR; |
| 22 | |
Ley Foon Tan | f80cb34 | 2018-05-24 00:17:24 +0800 | [diff] [blame] | 23 | /* |
Ang, Chee Hong | ff14f16 | 2018-12-19 18:35:15 -0800 | [diff] [blame] | 24 | * FPGA programming support for SoC FPGA Stratix 10 |
| 25 | */ |
| 26 | static Altera_desc altera_fpga[] = { |
| 27 | { |
| 28 | /* Family */ |
Chee Hong Ang | 1419245 | 2020-08-07 11:50:03 +0800 | [diff] [blame] | 29 | Intel_FPGA_SDM_Mailbox, |
Ang, Chee Hong | ff14f16 | 2018-12-19 18:35:15 -0800 | [diff] [blame] | 30 | /* Interface type */ |
| 31 | secure_device_manager_mailbox, |
| 32 | /* No limitation as additional data will be ignored */ |
| 33 | -1, |
| 34 | /* No device function table */ |
| 35 | NULL, |
| 36 | /* Base interface address specified in driver */ |
| 37 | NULL, |
| 38 | /* No cookie implementation */ |
| 39 | 0 |
| 40 | }, |
| 41 | }; |
| 42 | |
Ley Foon Tan | f80cb34 | 2018-05-24 00:17:24 +0800 | [diff] [blame] | 43 | |
| 44 | /* |
| 45 | * Print CPU information |
| 46 | */ |
| 47 | #if defined(CONFIG_DISPLAY_CPUINFO) |
| 48 | int print_cpuinfo(void) |
| 49 | { |
| 50 | puts("CPU: Intel FPGA SoCFPGA Platform (ARMv8 64bit Cortex-A53)\n"); |
| 51 | |
| 52 | return 0; |
| 53 | } |
| 54 | #endif |
| 55 | |
| 56 | #ifdef CONFIG_ARCH_MISC_INIT |
| 57 | int arch_misc_init(void) |
| 58 | { |
| 59 | char qspi_string[13]; |
| 60 | |
| 61 | sprintf(qspi_string, "<0x%08x>", cm_get_qspi_controller_clk_hz()); |
| 62 | env_set("qspi_clock", qspi_string); |
| 63 | |
Ley Foon Tan | f80cb34 | 2018-05-24 00:17:24 +0800 | [diff] [blame] | 64 | return 0; |
| 65 | } |
| 66 | #endif |
| 67 | |
| 68 | int arch_early_init_r(void) |
| 69 | { |
Ang, Chee Hong | ff14f16 | 2018-12-19 18:35:15 -0800 | [diff] [blame] | 70 | socfpga_fpga_add(&altera_fpga[0]); |
| 71 | |
Ley Foon Tan | f80cb34 | 2018-05-24 00:17:24 +0800 | [diff] [blame] | 72 | return 0; |
| 73 | } |
| 74 | |
Chee Hong Ang | 61e9199 | 2020-08-06 11:56:29 +0800 | [diff] [blame] | 75 | /* Return 1 if FPGA is ready otherwise return 0 */ |
| 76 | int is_fpga_config_ready(void) |
| 77 | { |
| 78 | return (readl(socfpga_get_sysmgr_addr() + SYSMGR_SOC64_FPGA_CONFIG) & |
| 79 | SYSMGR_FPGACONFIG_READY_MASK) == SYSMGR_FPGACONFIG_READY_MASK; |
| 80 | } |
| 81 | |
Marek Vasut | 713a8a2 | 2019-04-16 22:28:08 +0200 | [diff] [blame] | 82 | void do_bridge_reset(int enable, unsigned int mask) |
Ley Foon Tan | f80cb34 | 2018-05-24 00:17:24 +0800 | [diff] [blame] | 83 | { |
Ang, Chee Hong | d740445 | 2019-05-03 01:18:27 -0700 | [diff] [blame] | 84 | /* Check FPGA status before bridge enable */ |
Chee Hong Ang | 61e9199 | 2020-08-06 11:56:29 +0800 | [diff] [blame] | 85 | if (!is_fpga_config_ready()) { |
| 86 | puts("FPGA not ready. Bridge reset aborted!\n"); |
| 87 | return; |
Ang, Chee Hong | d740445 | 2019-05-03 01:18:27 -0700 | [diff] [blame] | 88 | } |
| 89 | |
Ley Foon Tan | f80cb34 | 2018-05-24 00:17:24 +0800 | [diff] [blame] | 90 | socfpga_bridges_reset(enable); |
| 91 | } |