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