xref: /openbmc/u-boot/drivers/fpga/zynqpl.c (revision c83a35f65250a8bdb519cb26680437e5c93d133d)
1d5dae85fSMichal Simek /*
2d5dae85fSMichal Simek  * (C) Copyright 2012-2013, Xilinx, Michal Simek
3d5dae85fSMichal Simek  *
4d5dae85fSMichal Simek  * (C) Copyright 2012
5d5dae85fSMichal Simek  * Joe Hershberger <joe.hershberger@ni.com>
6d5dae85fSMichal Simek  *
71a459660SWolfgang Denk  * SPDX-License-Identifier:	GPL-2.0+
8d5dae85fSMichal Simek  */
9d5dae85fSMichal Simek 
10d5dae85fSMichal Simek #include <common.h>
11d5dae85fSMichal Simek #include <asm/io.h>
12d5dae85fSMichal Simek #include <zynqpl.h>
13b129e8cfSMichal Simek #include <asm/sizes.h>
14d5dae85fSMichal Simek #include <asm/arch/hardware.h>
15d5dae85fSMichal Simek #include <asm/arch/sys_proto.h>
16d5dae85fSMichal Simek 
17d5dae85fSMichal Simek #define DEVCFG_CTRL_PCFG_PROG_B		0x40000000
18d5dae85fSMichal Simek #define DEVCFG_ISR_FATAL_ERROR_MASK	0x00740040
19d5dae85fSMichal Simek #define DEVCFG_ISR_ERROR_FLAGS_MASK	0x00340840
20d5dae85fSMichal Simek #define DEVCFG_ISR_RX_FIFO_OV		0x00040000
21d5dae85fSMichal Simek #define DEVCFG_ISR_DMA_DONE		0x00002000
22d5dae85fSMichal Simek #define DEVCFG_ISR_PCFG_DONE		0x00000004
23d5dae85fSMichal Simek #define DEVCFG_STATUS_DMA_CMD_Q_F	0x80000000
24d5dae85fSMichal Simek #define DEVCFG_STATUS_DMA_CMD_Q_E	0x40000000
25d5dae85fSMichal Simek #define DEVCFG_STATUS_DMA_DONE_CNT_MASK	0x30000000
26d5dae85fSMichal Simek #define DEVCFG_STATUS_PCFG_INIT		0x00000010
275f93227cSSoren Brinkmann #define DEVCFG_MCTRL_PCAP_LPBK		0x00000010
28d5dae85fSMichal Simek #define DEVCFG_MCTRL_RFIFO_FLUSH	0x00000002
29d5dae85fSMichal Simek #define DEVCFG_MCTRL_WFIFO_FLUSH	0x00000001
30d5dae85fSMichal Simek 
31d5dae85fSMichal Simek #ifndef CONFIG_SYS_FPGA_WAIT
32d5dae85fSMichal Simek #define CONFIG_SYS_FPGA_WAIT CONFIG_SYS_HZ/100	/* 10 ms */
33d5dae85fSMichal Simek #endif
34d5dae85fSMichal Simek 
35d5dae85fSMichal Simek #ifndef CONFIG_SYS_FPGA_PROG_TIME
36fd2b10b6SMichal Simek #define CONFIG_SYS_FPGA_PROG_TIME	(CONFIG_SYS_HZ * 4) /* 4 s */
37d5dae85fSMichal Simek #endif
38d5dae85fSMichal Simek 
39d5dae85fSMichal Simek int zynq_info(Xilinx_desc *desc)
40d5dae85fSMichal Simek {
41d5dae85fSMichal Simek 	return FPGA_SUCCESS;
42d5dae85fSMichal Simek }
43d5dae85fSMichal Simek 
44d5dae85fSMichal Simek #define DUMMY_WORD	0xffffffff
45d5dae85fSMichal Simek 
46d5dae85fSMichal Simek /* Xilinx binary format header */
47d5dae85fSMichal Simek static const u32 bin_format[] = {
48d5dae85fSMichal Simek 	DUMMY_WORD, /* Dummy words */
49d5dae85fSMichal Simek 	DUMMY_WORD,
50d5dae85fSMichal Simek 	DUMMY_WORD,
51d5dae85fSMichal Simek 	DUMMY_WORD,
52d5dae85fSMichal Simek 	DUMMY_WORD,
53d5dae85fSMichal Simek 	DUMMY_WORD,
54d5dae85fSMichal Simek 	DUMMY_WORD,
55d5dae85fSMichal Simek 	DUMMY_WORD,
56d5dae85fSMichal Simek 	0x000000bb, /* Sync word */
57d5dae85fSMichal Simek 	0x11220044, /* Sync word */
58d5dae85fSMichal Simek 	DUMMY_WORD,
59d5dae85fSMichal Simek 	DUMMY_WORD,
60d5dae85fSMichal Simek 	0xaa995566, /* Sync word */
61d5dae85fSMichal Simek };
62d5dae85fSMichal Simek 
63d5dae85fSMichal Simek #define SWAP_NO		1
64d5dae85fSMichal Simek #define SWAP_DONE	2
65d5dae85fSMichal Simek 
66d5dae85fSMichal Simek /*
67d5dae85fSMichal Simek  * Load the whole word from unaligned buffer
68d5dae85fSMichal Simek  * Keep in your mind that it is byte loading on little-endian system
69d5dae85fSMichal Simek  */
70d5dae85fSMichal Simek static u32 load_word(const void *buf, u32 swap)
71d5dae85fSMichal Simek {
72d5dae85fSMichal Simek 	u32 word = 0;
73d5dae85fSMichal Simek 	u8 *bitc = (u8 *)buf;
74d5dae85fSMichal Simek 	int p;
75d5dae85fSMichal Simek 
76d5dae85fSMichal Simek 	if (swap == SWAP_NO) {
77d5dae85fSMichal Simek 		for (p = 0; p < 4; p++) {
78d5dae85fSMichal Simek 			word <<= 8;
79d5dae85fSMichal Simek 			word |= bitc[p];
80d5dae85fSMichal Simek 		}
81d5dae85fSMichal Simek 	} else {
82d5dae85fSMichal Simek 		for (p = 3; p >= 0; p--) {
83d5dae85fSMichal Simek 			word <<= 8;
84d5dae85fSMichal Simek 			word |= bitc[p];
85d5dae85fSMichal Simek 		}
86d5dae85fSMichal Simek 	}
87d5dae85fSMichal Simek 
88d5dae85fSMichal Simek 	return word;
89d5dae85fSMichal Simek }
90d5dae85fSMichal Simek 
91d5dae85fSMichal Simek static u32 check_header(const void *buf)
92d5dae85fSMichal Simek {
93d5dae85fSMichal Simek 	u32 i, pattern;
94d5dae85fSMichal Simek 	int swap = SWAP_NO;
95d5dae85fSMichal Simek 	u32 *test = (u32 *)buf;
96d5dae85fSMichal Simek 
97d5dae85fSMichal Simek 	debug("%s: Let's check bitstream header\n", __func__);
98d5dae85fSMichal Simek 
99d5dae85fSMichal Simek 	/* Checking that passing bin is not a bitstream */
100d5dae85fSMichal Simek 	for (i = 0; i < ARRAY_SIZE(bin_format); i++) {
101d5dae85fSMichal Simek 		pattern = load_word(&test[i], swap);
102d5dae85fSMichal Simek 
103d5dae85fSMichal Simek 		/*
104d5dae85fSMichal Simek 		 * Bitstreams in binary format are swapped
105d5dae85fSMichal Simek 		 * compare to regular bistream.
106d5dae85fSMichal Simek 		 * Do not swap dummy word but if swap is done assume
107d5dae85fSMichal Simek 		 * that parsing buffer is binary format
108d5dae85fSMichal Simek 		 */
109d5dae85fSMichal Simek 		if ((__swab32(pattern) != DUMMY_WORD) &&
110d5dae85fSMichal Simek 		    (__swab32(pattern) == bin_format[i])) {
111d5dae85fSMichal Simek 			pattern = __swab32(pattern);
112d5dae85fSMichal Simek 			swap = SWAP_DONE;
113d5dae85fSMichal Simek 			debug("%s: data swapped - let's swap\n", __func__);
114d5dae85fSMichal Simek 		}
115d5dae85fSMichal Simek 
116d5dae85fSMichal Simek 		debug("%s: %d/%x: pattern %x/%x bin_format\n", __func__, i,
117d5dae85fSMichal Simek 		      (u32)&test[i], pattern, bin_format[i]);
118d5dae85fSMichal Simek 		if (pattern != bin_format[i]) {
119d5dae85fSMichal Simek 			debug("%s: Bitstream is not recognized\n", __func__);
120d5dae85fSMichal Simek 			return 0;
121d5dae85fSMichal Simek 		}
122d5dae85fSMichal Simek 	}
123d5dae85fSMichal Simek 	debug("%s: Found bitstream header at %x %s swapinng\n", __func__,
124d5dae85fSMichal Simek 	      (u32)buf, swap == SWAP_NO ? "without" : "with");
125d5dae85fSMichal Simek 
126d5dae85fSMichal Simek 	return swap;
127d5dae85fSMichal Simek }
128d5dae85fSMichal Simek 
129d5dae85fSMichal Simek static void *check_data(u8 *buf, size_t bsize, u32 *swap)
130d5dae85fSMichal Simek {
131d5dae85fSMichal Simek 	u32 word, p = 0; /* possition */
132d5dae85fSMichal Simek 
133d5dae85fSMichal Simek 	/* Because buf doesn't need to be aligned let's read it by chars */
134d5dae85fSMichal Simek 	for (p = 0; p < bsize; p++) {
135d5dae85fSMichal Simek 		word = load_word(&buf[p], SWAP_NO);
136d5dae85fSMichal Simek 		debug("%s: word %x %x/%x\n", __func__, word, p, (u32)&buf[p]);
137d5dae85fSMichal Simek 
138d5dae85fSMichal Simek 		/* Find the first bitstream dummy word */
139d5dae85fSMichal Simek 		if (word == DUMMY_WORD) {
140d5dae85fSMichal Simek 			debug("%s: Found dummy word at position %x/%x\n",
141d5dae85fSMichal Simek 			      __func__, p, (u32)&buf[p]);
142d5dae85fSMichal Simek 			*swap = check_header(&buf[p]);
143d5dae85fSMichal Simek 			if (*swap) {
144d5dae85fSMichal Simek 				/* FIXME add full bitstream checking here */
145d5dae85fSMichal Simek 				return &buf[p];
146d5dae85fSMichal Simek 			}
147d5dae85fSMichal Simek 		}
148d5dae85fSMichal Simek 		/* Loop can be huge - support CTRL + C */
149d5dae85fSMichal Simek 		if (ctrlc())
150d5dae85fSMichal Simek 			return 0;
151d5dae85fSMichal Simek 	}
152d5dae85fSMichal Simek 	return 0;
153d5dae85fSMichal Simek }
154d5dae85fSMichal Simek 
155d5dae85fSMichal Simek 
156d5dae85fSMichal Simek int zynq_load(Xilinx_desc *desc, const void *buf, size_t bsize)
157d5dae85fSMichal Simek {
158d5dae85fSMichal Simek 	unsigned long ts; /* Timestamp */
159d5dae85fSMichal Simek 	u32 partialbit = 0;
160d5dae85fSMichal Simek 	u32 i, control, isr_status, status, swap, diff;
161d5dae85fSMichal Simek 	u32 *buf_start;
162d5dae85fSMichal Simek 
163d5dae85fSMichal Simek 	/* Detect if we are going working with partial or full bitstream */
164d5dae85fSMichal Simek 	if (bsize != desc->size) {
165d5dae85fSMichal Simek 		printf("%s: Working with partial bitstream\n", __func__);
166d5dae85fSMichal Simek 		partialbit = 1;
167d5dae85fSMichal Simek 	}
168d5dae85fSMichal Simek 
169d5dae85fSMichal Simek 	buf_start = check_data((u8 *)buf, bsize, &swap);
170d5dae85fSMichal Simek 	if (!buf_start)
171d5dae85fSMichal Simek 		return FPGA_FAIL;
172d5dae85fSMichal Simek 
173d5dae85fSMichal Simek 	/* Check if data is postpone from start */
174d5dae85fSMichal Simek 	diff = (u32)buf_start - (u32)buf;
175d5dae85fSMichal Simek 	if (diff) {
176d5dae85fSMichal Simek 		printf("%s: Bitstream is not validated yet (diff %x)\n",
177d5dae85fSMichal Simek 		       __func__, diff);
178d5dae85fSMichal Simek 		return FPGA_FAIL;
179d5dae85fSMichal Simek 	}
180d5dae85fSMichal Simek 
181b129e8cfSMichal Simek 	if ((u32)buf < SZ_1M) {
182b129e8cfSMichal Simek 		printf("%s: Bitstream has to be placed up to 1MB (%x)\n",
183b129e8cfSMichal Simek 		       __func__, (u32)buf);
184b129e8cfSMichal Simek 		return FPGA_FAIL;
185b129e8cfSMichal Simek 	}
186b129e8cfSMichal Simek 
187ec4b73f0SJagannadha Sutradharudu Teki 	if ((u32)buf != ALIGN((u32)buf, ARCH_DMA_MINALIGN)) {
188ec4b73f0SJagannadha Sutradharudu Teki 		u32 *new_buf = (u32 *)ALIGN((u32)buf, ARCH_DMA_MINALIGN);
189d5dae85fSMichal Simek 
190*c83a35f6SNovasys Ingenierie 		/*
191*c83a35f6SNovasys Ingenierie 		 * This might be dangerous but permits to flash if
192*c83a35f6SNovasys Ingenierie 		 * ARCH_DMA_MINALIGN is greater than header size
193*c83a35f6SNovasys Ingenierie 		 */
194*c83a35f6SNovasys Ingenierie 		if (new_buf > buf_start) {
195*c83a35f6SNovasys Ingenierie 			debug("%s: Aligned buffer is after buffer start\n",
196*c83a35f6SNovasys Ingenierie 			      __func__);
197*c83a35f6SNovasys Ingenierie 			new_buf -= ARCH_DMA_MINALIGN;
198*c83a35f6SNovasys Ingenierie 		}
199*c83a35f6SNovasys Ingenierie 
200d5dae85fSMichal Simek 		printf("%s: Align buffer at %x to %x(swap %d)\n", __func__,
201d5dae85fSMichal Simek 		       (u32)buf_start, (u32)new_buf, swap);
202d5dae85fSMichal Simek 
203d5dae85fSMichal Simek 		for (i = 0; i < (bsize/4); i++)
204d5dae85fSMichal Simek 			new_buf[i] = load_word(&buf_start[i], swap);
205d5dae85fSMichal Simek 
206d5dae85fSMichal Simek 		swap = SWAP_DONE;
207d5dae85fSMichal Simek 		buf = new_buf;
208d5dae85fSMichal Simek 	} else if (swap != SWAP_DONE) {
209d5dae85fSMichal Simek 		/* For bitstream which are aligned */
210d5dae85fSMichal Simek 		u32 *new_buf = (u32 *)buf;
211d5dae85fSMichal Simek 
212d5dae85fSMichal Simek 		printf("%s: Bitstream is not swapped(%d) - swap it\n", __func__,
213d5dae85fSMichal Simek 		       swap);
214d5dae85fSMichal Simek 
215d5dae85fSMichal Simek 		for (i = 0; i < (bsize/4); i++)
216d5dae85fSMichal Simek 			new_buf[i] = load_word(&buf_start[i], swap);
217d5dae85fSMichal Simek 
218d5dae85fSMichal Simek 		swap = SWAP_DONE;
219d5dae85fSMichal Simek 	}
220d5dae85fSMichal Simek 
2215f93227cSSoren Brinkmann 	/* Clear loopback bit */
2225f93227cSSoren Brinkmann 	clrbits_le32(&devcfg_base->mctrl, DEVCFG_MCTRL_PCAP_LPBK);
2235f93227cSSoren Brinkmann 
224d5dae85fSMichal Simek 	if (!partialbit) {
225d5dae85fSMichal Simek 		zynq_slcr_devcfg_disable();
226d5dae85fSMichal Simek 
227d5dae85fSMichal Simek 		/* Setting PCFG_PROG_B signal to high */
228d5dae85fSMichal Simek 		control = readl(&devcfg_base->ctrl);
229d5dae85fSMichal Simek 		writel(control | DEVCFG_CTRL_PCFG_PROG_B, &devcfg_base->ctrl);
230d5dae85fSMichal Simek 		/* Setting PCFG_PROG_B signal to low */
231d5dae85fSMichal Simek 		writel(control & ~DEVCFG_CTRL_PCFG_PROG_B, &devcfg_base->ctrl);
232d5dae85fSMichal Simek 
233d5dae85fSMichal Simek 		/* Polling the PCAP_INIT status for Reset */
234d5dae85fSMichal Simek 		ts = get_timer(0);
235d5dae85fSMichal Simek 		while (readl(&devcfg_base->status) & DEVCFG_STATUS_PCFG_INIT) {
236d5dae85fSMichal Simek 			if (get_timer(ts) > CONFIG_SYS_FPGA_WAIT) {
237d5dae85fSMichal Simek 				printf("%s: Timeout wait for INIT to clear\n",
238d5dae85fSMichal Simek 				       __func__);
239d5dae85fSMichal Simek 				return FPGA_FAIL;
240d5dae85fSMichal Simek 			}
241d5dae85fSMichal Simek 		}
242d5dae85fSMichal Simek 
243d5dae85fSMichal Simek 		/* Setting PCFG_PROG_B signal to high */
244d5dae85fSMichal Simek 		writel(control | DEVCFG_CTRL_PCFG_PROG_B, &devcfg_base->ctrl);
245d5dae85fSMichal Simek 
246d5dae85fSMichal Simek 		/* Polling the PCAP_INIT status for Set */
247d5dae85fSMichal Simek 		ts = get_timer(0);
248d5dae85fSMichal Simek 		while (!(readl(&devcfg_base->status) &
249d5dae85fSMichal Simek 			DEVCFG_STATUS_PCFG_INIT)) {
250d5dae85fSMichal Simek 			if (get_timer(ts) > CONFIG_SYS_FPGA_WAIT) {
251d5dae85fSMichal Simek 				printf("%s: Timeout wait for INIT to set\n",
252d5dae85fSMichal Simek 				       __func__);
253d5dae85fSMichal Simek 				return FPGA_FAIL;
254d5dae85fSMichal Simek 			}
255d5dae85fSMichal Simek 		}
256d5dae85fSMichal Simek 	}
257d5dae85fSMichal Simek 
258d5dae85fSMichal Simek 	isr_status = readl(&devcfg_base->int_sts);
259d5dae85fSMichal Simek 
260d5dae85fSMichal Simek 	/* Clear it all, so if Boot ROM comes back, it can proceed */
261d5dae85fSMichal Simek 	writel(0xFFFFFFFF, &devcfg_base->int_sts);
262d5dae85fSMichal Simek 
263d5dae85fSMichal Simek 	if (isr_status & DEVCFG_ISR_FATAL_ERROR_MASK) {
264d5dae85fSMichal Simek 		debug("%s: Fatal errors in PCAP 0x%X\n", __func__, isr_status);
265d5dae85fSMichal Simek 
266d5dae85fSMichal Simek 		/* If RX FIFO overflow, need to flush RX FIFO first */
267d5dae85fSMichal Simek 		if (isr_status & DEVCFG_ISR_RX_FIFO_OV) {
268d5dae85fSMichal Simek 			writel(DEVCFG_MCTRL_RFIFO_FLUSH, &devcfg_base->mctrl);
269d5dae85fSMichal Simek 			writel(0xFFFFFFFF, &devcfg_base->int_sts);
270d5dae85fSMichal Simek 		}
271d5dae85fSMichal Simek 		return FPGA_FAIL;
272d5dae85fSMichal Simek 	}
273d5dae85fSMichal Simek 
274d5dae85fSMichal Simek 	status = readl(&devcfg_base->status);
275d5dae85fSMichal Simek 
276d5dae85fSMichal Simek 	debug("%s: Status = 0x%08X\n", __func__, status);
277d5dae85fSMichal Simek 
278d5dae85fSMichal Simek 	if (status & DEVCFG_STATUS_DMA_CMD_Q_F) {
279d5dae85fSMichal Simek 		debug("%s: Error: device busy\n", __func__);
280d5dae85fSMichal Simek 		return FPGA_FAIL;
281d5dae85fSMichal Simek 	}
282d5dae85fSMichal Simek 
283d5dae85fSMichal Simek 	debug("%s: Device ready\n", __func__);
284d5dae85fSMichal Simek 
285d5dae85fSMichal Simek 	if (!(status & DEVCFG_STATUS_DMA_CMD_Q_E)) {
286d5dae85fSMichal Simek 		if (!(readl(&devcfg_base->int_sts) & DEVCFG_ISR_DMA_DONE)) {
287d5dae85fSMichal Simek 			/* Error state, transfer cannot occur */
288d5dae85fSMichal Simek 			debug("%s: ISR indicates error\n", __func__);
289d5dae85fSMichal Simek 			return FPGA_FAIL;
290d5dae85fSMichal Simek 		} else {
291d5dae85fSMichal Simek 			/* Clear out the status */
292d5dae85fSMichal Simek 			writel(DEVCFG_ISR_DMA_DONE, &devcfg_base->int_sts);
293d5dae85fSMichal Simek 		}
294d5dae85fSMichal Simek 	}
295d5dae85fSMichal Simek 
296d5dae85fSMichal Simek 	if (status & DEVCFG_STATUS_DMA_DONE_CNT_MASK) {
297d5dae85fSMichal Simek 		/* Clear the count of completed DMA transfers */
298d5dae85fSMichal Simek 		writel(DEVCFG_STATUS_DMA_DONE_CNT_MASK, &devcfg_base->status);
299d5dae85fSMichal Simek 	}
300d5dae85fSMichal Simek 
301d5dae85fSMichal Simek 	debug("%s: Source = 0x%08X\n", __func__, (u32)buf);
302d5dae85fSMichal Simek 	debug("%s: Size = %zu\n", __func__, bsize);
303d5dae85fSMichal Simek 
304ec4b73f0SJagannadha Sutradharudu Teki 	/* flush(clean & invalidate) d-cache range buf */
305ec4b73f0SJagannadha Sutradharudu Teki 	flush_dcache_range((u32)buf, (u32)buf +
306ec4b73f0SJagannadha Sutradharudu Teki 			   roundup(bsize, ARCH_DMA_MINALIGN));
307ec4b73f0SJagannadha Sutradharudu Teki 
308d5dae85fSMichal Simek 	/* Set up the transfer */
309d5dae85fSMichal Simek 	writel((u32)buf | 1, &devcfg_base->dma_src_addr);
310d5dae85fSMichal Simek 	writel(0xFFFFFFFF, &devcfg_base->dma_dst_addr);
311d5dae85fSMichal Simek 	writel(bsize >> 2, &devcfg_base->dma_src_len);
312d5dae85fSMichal Simek 	writel(0, &devcfg_base->dma_dst_len);
313d5dae85fSMichal Simek 
314d5dae85fSMichal Simek 	isr_status = readl(&devcfg_base->int_sts);
315d5dae85fSMichal Simek 
316d5dae85fSMichal Simek 	/* Polling the PCAP_INIT status for Set */
317d5dae85fSMichal Simek 	ts = get_timer(0);
318d5dae85fSMichal Simek 	while (!(isr_status & DEVCFG_ISR_DMA_DONE)) {
319d5dae85fSMichal Simek 		if (isr_status & DEVCFG_ISR_ERROR_FLAGS_MASK) {
320d5dae85fSMichal Simek 			debug("%s: Error: isr = 0x%08X\n", __func__,
321d5dae85fSMichal Simek 			      isr_status);
322d5dae85fSMichal Simek 			debug("%s: Write count = 0x%08X\n", __func__,
323d5dae85fSMichal Simek 			      readl(&devcfg_base->write_count));
324d5dae85fSMichal Simek 			debug("%s: Read count = 0x%08X\n", __func__,
325d5dae85fSMichal Simek 			      readl(&devcfg_base->read_count));
326d5dae85fSMichal Simek 
327d5dae85fSMichal Simek 			return FPGA_FAIL;
328d5dae85fSMichal Simek 		}
329d5dae85fSMichal Simek 		if (get_timer(ts) > CONFIG_SYS_FPGA_PROG_TIME) {
330d5dae85fSMichal Simek 			printf("%s: Timeout wait for DMA to complete\n",
331d5dae85fSMichal Simek 			       __func__);
332d5dae85fSMichal Simek 			return FPGA_FAIL;
333d5dae85fSMichal Simek 		}
334d5dae85fSMichal Simek 		isr_status = readl(&devcfg_base->int_sts);
335d5dae85fSMichal Simek 	}
336d5dae85fSMichal Simek 
337d5dae85fSMichal Simek 	debug("%s: DMA transfer is done\n", __func__);
338d5dae85fSMichal Simek 
339d5dae85fSMichal Simek 	/* Check FPGA configuration completion */
340d5dae85fSMichal Simek 	ts = get_timer(0);
341d5dae85fSMichal Simek 	while (!(isr_status & DEVCFG_ISR_PCFG_DONE)) {
342d5dae85fSMichal Simek 		if (get_timer(ts) > CONFIG_SYS_FPGA_WAIT) {
343d5dae85fSMichal Simek 			printf("%s: Timeout wait for FPGA to config\n",
344d5dae85fSMichal Simek 			       __func__);
345d5dae85fSMichal Simek 			return FPGA_FAIL;
346d5dae85fSMichal Simek 		}
347d5dae85fSMichal Simek 		isr_status = readl(&devcfg_base->int_sts);
348d5dae85fSMichal Simek 	}
349d5dae85fSMichal Simek 
350d5dae85fSMichal Simek 	debug("%s: FPGA config done\n", __func__);
351d5dae85fSMichal Simek 
352d5dae85fSMichal Simek 	/* Clear out the DMA status */
353d5dae85fSMichal Simek 	writel(DEVCFG_ISR_DMA_DONE, &devcfg_base->int_sts);
354d5dae85fSMichal Simek 
355d5dae85fSMichal Simek 	if (!partialbit)
356d5dae85fSMichal Simek 		zynq_slcr_devcfg_enable();
357d5dae85fSMichal Simek 
358d5dae85fSMichal Simek 	return FPGA_SUCCESS;
359d5dae85fSMichal Simek }
360d5dae85fSMichal Simek 
361d5dae85fSMichal Simek int zynq_dump(Xilinx_desc *desc, const void *buf, size_t bsize)
362d5dae85fSMichal Simek {
363d5dae85fSMichal Simek 	return FPGA_FAIL;
364d5dae85fSMichal Simek }
365