Siew Chin Lim | 954d599 | 2021-03-24 13:11:34 +0800 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 |
| 2 | * |
Jit Loon Lim | 977071e | 2024-03-12 22:01:03 +0800 | [diff] [blame] | 3 | * Copyright (C) 2016-2024 Intel Corporation <www.intel.com> |
Siew Chin Lim | 954d599 | 2021-03-24 13:11:34 +0800 | [diff] [blame] | 4 | * |
| 5 | */ |
| 6 | |
| 7 | #ifndef _HANDOFF_SOC64_H_ |
| 8 | #define _HANDOFF_SOC64_H_ |
| 9 | |
| 10 | /* |
| 11 | * Offset for HW handoff from Quartus tools |
| 12 | */ |
Siew Chin Lim | 02d2500 | 2021-03-24 13:11:37 +0800 | [diff] [blame] | 13 | /* HPS handoff */ |
Siew Chin Lim | ff1eec3 | 2021-03-24 13:11:38 +0800 | [diff] [blame] | 14 | #define SOC64_HANDOFF_MAGIC_BOOT 0x424F4F54 |
Siew Chin Lim | 954d599 | 2021-03-24 13:11:34 +0800 | [diff] [blame] | 15 | #define SOC64_HANDOFF_MAGIC_MUX 0x504D5558 |
| 16 | #define SOC64_HANDOFF_MAGIC_IOCTL 0x494F4354 |
| 17 | #define SOC64_HANDOFF_MAGIC_FPGA 0x46504741 |
| 18 | #define SOC64_HANDOFF_MAGIC_DELAY 0x444C4159 |
| 19 | #define SOC64_HANDOFF_MAGIC_CLOCK 0x434C4B53 |
Jit Loon Lim | 977071e | 2024-03-12 22:01:03 +0800 | [diff] [blame] | 20 | #if IS_ENABLED(CONFIG_TARGET_SOCFPGA_AGILEX5) |
| 21 | #define SOC64_HANDOFF_MAGIC_PERI 0x50455249 |
| 22 | #define SOC64_HANDOFF_MAGIC_SDRAM 0x5344524d |
| 23 | #else |
Siew Chin Lim | 954d599 | 2021-03-24 13:11:34 +0800 | [diff] [blame] | 24 | #define SOC64_HANDOFF_MAGIC_MISC 0x4D495343 |
Jit Loon Lim | 977071e | 2024-03-12 22:01:03 +0800 | [diff] [blame] | 25 | #endif |
Siew Chin Lim | 02d2500 | 2021-03-24 13:11:37 +0800 | [diff] [blame] | 26 | |
Siew Chin Lim | 954d599 | 2021-03-24 13:11:34 +0800 | [diff] [blame] | 27 | #define SOC64_HANDOFF_OFFSET_LENGTH 0x4 |
| 28 | #define SOC64_HANDOFF_OFFSET_DATA 0x10 |
Siew Chin Lim | 02d2500 | 2021-03-24 13:11:37 +0800 | [diff] [blame] | 29 | #define SOC64_HANDOFF_SIZE 4096 |
| 30 | |
Tien Fong Chee | df89b50 | 2021-08-10 11:26:29 +0800 | [diff] [blame] | 31 | #if IS_ENABLED(CONFIG_TARGET_SOCFPGA_STRATIX10) || \ |
| 32 | IS_ENABLED(CONFIG_TARGET_SOCFPGA_AGILEX) |
Siew Chin Lim | 02d2500 | 2021-03-24 13:11:37 +0800 | [diff] [blame] | 33 | #define SOC64_HANDOFF_BASE 0xFFE3F000 |
| 34 | #define SOC64_HANDOFF_MISC (SOC64_HANDOFF_BASE + 0x610) |
Jit Loon Lim | 977071e | 2024-03-12 22:01:03 +0800 | [diff] [blame] | 35 | #elif IS_ENABLED(CONFIG_TARGET_SOCFPGA_AGILEX5) |
| 36 | #define SOC64_HANDOFF_BASE 0x0007F000 |
Tien Fong Chee | df89b50 | 2021-08-10 11:26:29 +0800 | [diff] [blame] | 37 | #elif IS_ENABLED(CONFIG_TARGET_SOCFPGA_N5X) |
| 38 | #define SOC64_HANDOFF_BASE 0xFFE5F000 |
| 39 | #define SOC64_HANDOFF_MISC (SOC64_HANDOFF_BASE + 0x630) |
| 40 | |
| 41 | /* DDR handoff */ |
| 42 | #define SOC64_HANDOFF_DDR_BASE 0xFFE5C000 |
| 43 | #define SOC64_HANDOFF_DDR_MAGIC 0x48524444 |
| 44 | #define SOC64_HANDOFF_DDR_UMCTL2_MAGIC 0x4C54434D |
| 45 | #define SOC64_HANDOFF_DDR_UMCTL2_DDR4_TYPE 0x34524444 |
| 46 | #define SOC64_HANDOFF_DDR_UMCTL2_LPDDR4_0_TYPE 0x3044504C |
| 47 | #define SOC64_HANDOFF_DDR_UMCTL2_LPDDR4_1_TYPE 0x3144504C |
| 48 | #define SOC64_HANDOFF_DDR_MEMRESET_BASE (SOC64_HANDOFF_DDR_BASE + 0xC) |
| 49 | #define SOC64_HANDOFF_DDR_UMCTL2_SECTION (SOC64_HANDOFF_DDR_BASE + 0x10) |
| 50 | #define SOC64_HANDOFF_DDR_PHY_MAGIC 0x43594850 |
| 51 | #define SOC64_HANDOFF_DDR_PHY_INIT_ENGINE_MAGIC 0x45594850 |
| 52 | #define SOC64_HANDOFF_DDR_PHY_BASE_OFFSET 0x8 |
| 53 | #define SOC64_HANDOFF_DDR_UMCTL2_TYPE_OFFSET 0x8 |
| 54 | #define SOC64_HANDOFF_DDR_UMCTL2_BASE_ADDR_OFFSET 0xC |
| 55 | #define SOC64_HANDOFF_DDR_TRAIN_IMEM_1D_SECTION 0xFFE50000 |
| 56 | #define SOC64_HANDOFF_DDR_TRAIN_DMEM_1D_SECTION 0xFFE58000 |
| 57 | #define SOC64_HANDOFF_DDR_TRAIN_IMEM_2D_SECTION 0xFFE44000 |
| 58 | #define SOC64_HANDOFF_DDR_TRAIN_DMEM_2D_SECTION 0xFFE4C000 |
| 59 | #define SOC64_HANDOFF_DDR_TRAIN_IMEM_LENGTH SZ_32K |
| 60 | #define SOC64_HANDOFF_DDR_TRAIN_DMEM_LENGTH SZ_16K |
| 61 | #endif |
| 62 | |
Siew Chin Lim | 02d2500 | 2021-03-24 13:11:37 +0800 | [diff] [blame] | 63 | #define SOC64_HANDOFF_MUX (SOC64_HANDOFF_BASE + 0x10) |
| 64 | #define SOC64_HANDOFF_IOCTL (SOC64_HANDOFF_BASE + 0x1A0) |
| 65 | #define SOC64_HANDOFF_FPGA (SOC64_HANDOFF_BASE + 0x330) |
| 66 | #define SOC64_HANDOFF_DELAY (SOC64_HANDOFF_BASE + 0x3F0) |
| 67 | #define SOC64_HANDOFF_CLOCK (SOC64_HANDOFF_BASE + 0x580) |
Jit Loon Lim | 977071e | 2024-03-12 22:01:03 +0800 | [diff] [blame] | 68 | #if IS_ENABLED(CONFIG_TARGET_SOCFPGA_AGILEX5) |
| 69 | #define SOC64_HANDOFF_PERI (SOC64_HANDOFF_BASE + 0x620) |
| 70 | #define SOC64_HANDOFF_SDRAM (SOC64_HANDOFF_BASE + 0x634) |
| 71 | #define SOC64_HANDOFF_SDRAM_LEN 1 |
| 72 | #endif |
Siew Chin Lim | 954d599 | 2021-03-24 13:11:34 +0800 | [diff] [blame] | 73 | |
Siew Chin Lim | ff1eec3 | 2021-03-24 13:11:38 +0800 | [diff] [blame] | 74 | #if IS_ENABLED(CONFIG_TARGET_SOCFPGA_STRATIX10) |
Jit Loon Lim | 977071e | 2024-03-12 22:01:03 +0800 | [diff] [blame] | 75 | #define SOC64_HANDOFF_CLOCK_OSC (SOC64_HANDOFF_BASE + 0x608) |
| 76 | #define SOC64_HANDOFF_CLOCK_FPGA (SOC64_HANDOFF_BASE + 0x60C) |
| 77 | #elif IS_ENABLED(CONFIG_TARGET_SOCFPGA_AGILEX5) |
| 78 | #define SOC64_HANDOFF_CLOCK_OSC (SOC64_HANDOFF_BASE + 0x60c) |
| 79 | #define SOC64_HANDOFF_CLOCK_FPGA (SOC64_HANDOFF_BASE + 0x610) |
Siew Chin Lim | 954d599 | 2021-03-24 13:11:34 +0800 | [diff] [blame] | 80 | #else |
Jit Loon Lim | 977071e | 2024-03-12 22:01:03 +0800 | [diff] [blame] | 81 | #define SOC64_HANDOFF_CLOCK_OSC (SOC64_HANDOFF_BASE + 0x5fc) |
| 82 | #define SOC64_HANDOFF_CLOCK_FPGA (SOC64_HANDOFF_BASE + 0x600) |
Siew Chin Lim | 954d599 | 2021-03-24 13:11:34 +0800 | [diff] [blame] | 83 | #endif |
| 84 | |
Siew Chin Lim | ff1eec3 | 2021-03-24 13:11:38 +0800 | [diff] [blame] | 85 | #define SOC64_HANDOFF_MUX_LEN 96 |
| 86 | #define SOC64_HANDOFF_IOCTL_LEN 96 |
| 87 | #if IS_ENABLED(CONFIG_TARGET_SOCFPGA_STRATIX10) |
| 88 | #define SOC64_HANDOFF_FPGA_LEN 42 |
| 89 | #else |
| 90 | #define SOC64_HANDOFF_FPGA_LEN 40 |
| 91 | #endif |
| 92 | #define SOC64_HANDOFF_DELAY_LEN 96 |
| 93 | |
| 94 | #ifndef __ASSEMBLY__ |
| 95 | #include <asm/types.h> |
Tien Fong Chee | df89b50 | 2021-08-10 11:26:29 +0800 | [diff] [blame] | 96 | int socfpga_get_handoff_size(void *handoff_address); |
| 97 | int socfpga_handoff_read(void *handoff_address, void *table, u32 table_len); |
Siew Chin Lim | ff1eec3 | 2021-03-24 13:11:38 +0800 | [diff] [blame] | 98 | #endif |
Siew Chin Lim | 954d599 | 2021-03-24 13:11:34 +0800 | [diff] [blame] | 99 | #endif /* _HANDOFF_SOC64_H_ */ |