36 #define XHI_MAX_BUFFER_BYTES 2048
37 #define XHI_MAX_BUFFER_INTS (XHI_MAX_BUFFER_BYTES >> 2)
40 #define XHI_DEVICE_READ_ERROR -1
41 #define XHI_DEVICE_WRITE_ERROR -2
42 #define XHI_BUFFER_OVERFLOW_ERROR -3
44 #define XHI_DEVICE_READ 0x1
45 #define XHI_DEVICE_WRITE 0x0
48 #define XHI_CYCLE_DONE 0
49 #define XHI_CYCLE_EXECUTING 1
54 #define XHI_SIZE_REG_OFFSET 0x800L
56 #define XHI_BRAM_OFFSET_REG_OFFSET 0x804L
58 #define XHI_RNC_REG_OFFSET 0x808L
60 #define XHI_STATUS_REG_OFFSET 0x80CL
63 #define XHI_CONFIGURE 0x0UL
64 #define XHI_READBACK 0x1UL
67 #define XHI_NOT_FINISHED 0x0UL
68 #define XHI_FINISHED 0x1UL
70 #define XHI_BUFFER_START 0
104 return in_be32(base_address + (offset << 2));
115 static inline bool buffer_icap_busy(
void __iomem *base_address)
129 static inline void buffer_icap_set_size(
void __iomem *base_address,
143 static inline void buffer_icap_set_offset(
void __iomem *base_address,
159 static inline void buffer_icap_set_rnc(
void __iomem *base_address,
174 static inline void buffer_icap_set_bram(
void __iomem *base_address,
177 out_be32(base_address + (offset << 2), data);
194 if (buffer_icap_busy(base_address))
201 buffer_icap_set_size(base_address, (count << 2));
202 buffer_icap_set_offset(base_address, offset);
205 while (buffer_icap_busy(base_address)) {
221 static int buffer_icap_device_write(
struct hwicap_drvdata *drvdata,
228 if (buffer_icap_busy(base_address))
235 buffer_icap_set_size(base_address, count << 2);
236 buffer_icap_set_offset(base_address, offset);
239 while (buffer_icap_busy(base_address)) {
271 s32 buffer_count = 0;
278 for (i = 0, buffer_count = 0; i <
size; i++) {
281 buffer_icap_set_bram(base_address, buffer_count, data[i]);
290 status = buffer_icap_device_write(
330 s32 buffer_count = 0;
338 u32 words_remaining = size -
i;
345 status = buffer_icap_device_read(
360 data[
i] = buffer_icap_get_bram(base_address, buffer_count);