Siva Durga Prasad Paladugu | b739897 | 2019-08-05 15:54:59 +0530 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
| 2 | /* |
| 3 | * (C) Copyright 2019, Xilinx, Inc, |
Michal Simek | a8c9436 | 2023-07-10 14:35:49 +0200 | [diff] [blame] | 4 | * Siva Durga Prasad Paladugu <siva.durga.prasad.paladugu@amd.com>> |
Siva Durga Prasad Paladugu | b739897 | 2019-08-05 15:54:59 +0530 | [diff] [blame] | 5 | */ |
| 6 | |
Simon Glass | 6333448 | 2019-11-14 12:57:39 -0700 | [diff] [blame] | 7 | #include <cpu_func.h> |
Simon Glass | 0f2af88 | 2020-05-10 11:40:05 -0600 | [diff] [blame] | 8 | #include <log.h> |
Siva Durga Prasad Paladugu | b739897 | 2019-08-05 15:54:59 +0530 | [diff] [blame] | 9 | #include <asm/arch/sys_proto.h> |
| 10 | #include <memalign.h> |
| 11 | #include <versalpl.h> |
Michal Simek | 81efd2a | 2019-10-04 15:45:29 +0200 | [diff] [blame] | 12 | #include <zynqmp_firmware.h> |
Simon Glass | 274e0b0 | 2020-05-10 11:39:56 -0600 | [diff] [blame] | 13 | #include <asm/cache.h> |
Siva Durga Prasad Paladugu | b739897 | 2019-08-05 15:54:59 +0530 | [diff] [blame] | 14 | |
| 15 | static ulong versal_align_dma_buffer(ulong *buf, u32 len) |
| 16 | { |
| 17 | ulong *new_buf; |
| 18 | |
| 19 | if ((ulong)buf != ALIGN((ulong)buf, ARCH_DMA_MINALIGN)) { |
| 20 | new_buf = (ulong *)ALIGN((ulong)buf, ARCH_DMA_MINALIGN); |
| 21 | memcpy(new_buf, buf, len); |
| 22 | buf = new_buf; |
| 23 | } |
| 24 | |
| 25 | return (ulong)buf; |
| 26 | } |
| 27 | |
| 28 | static int versal_load(xilinx_desc *desc, const void *buf, size_t bsize, |
Oleksandr Suvorov | c0806cc | 2022-07-22 17:16:10 +0300 | [diff] [blame] | 29 | bitstream_type bstype, int flags) |
Siva Durga Prasad Paladugu | b739897 | 2019-08-05 15:54:59 +0530 | [diff] [blame] | 30 | { |
| 31 | ulong bin_buf; |
| 32 | int ret; |
| 33 | u32 buf_lo, buf_hi; |
Ibai Erkiaga | 0768aeb | 2020-08-04 23:17:26 +0100 | [diff] [blame] | 34 | u32 ret_payload[PAYLOAD_ARG_CNT]; |
Siva Durga Prasad Paladugu | b739897 | 2019-08-05 15:54:59 +0530 | [diff] [blame] | 35 | |
| 36 | bin_buf = versal_align_dma_buffer((ulong *)buf, bsize); |
| 37 | |
| 38 | debug("%s called!\n", __func__); |
| 39 | flush_dcache_range(bin_buf, bin_buf + bsize); |
| 40 | |
| 41 | buf_lo = lower_32_bits(bin_buf); |
| 42 | buf_hi = upper_32_bits(bin_buf); |
| 43 | |
Michal Simek | 142fb5b | 2019-10-04 15:52:43 +0200 | [diff] [blame] | 44 | ret = xilinx_pm_request(VERSAL_PM_LOAD_PDI, VERSAL_PM_PDI_TYPE, buf_lo, |
Siva Durga Prasad Paladugu | b739897 | 2019-08-05 15:54:59 +0530 | [diff] [blame] | 45 | buf_hi, 0, ret_payload); |
| 46 | if (ret) |
T Karthik Reddy | 274410a | 2020-05-14 07:49:36 -0600 | [diff] [blame] | 47 | printf("PL FPGA LOAD failed with err: 0x%08x\n", ret); |
Siva Durga Prasad Paladugu | b739897 | 2019-08-05 15:54:59 +0530 | [diff] [blame] | 48 | |
| 49 | return ret; |
| 50 | } |
| 51 | |
| 52 | struct xilinx_fpga_op versal_op = { |
| 53 | .load = versal_load, |
| 54 | }; |