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