fel: Add fel_readl_n() and fel_writel_n() wrappers
These functions solve the problem that large readl/writel transfers might be limited by insufficient (scratch) buffer size. To solve this, chunks of no more than LCODE_MAX_WORDS get transferred individually. Signed-off-by: Bernhard Nortmann <bernhard.nortmann@web.de>
This commit is contained in:
parent
c4389988aa
commit
8e53d2bf9a
32
fel.c
32
fel.c
@ -550,6 +550,22 @@ uint32_t aw_fel_readl(libusb_device_handle *usb, uint32_t addr)
|
||||
return val;
|
||||
}
|
||||
|
||||
/*
|
||||
* aw_fel_readl_n() wrapper that can handle large transfers. If necessary,
|
||||
* those will be done in separate 'chunks' of no more than LCODE_MAX_WORDS.
|
||||
*/
|
||||
void fel_readl_n(libusb_device_handle *usb, uint32_t addr,
|
||||
uint32_t *dst, size_t count)
|
||||
{
|
||||
while (count > 0) {
|
||||
size_t n = count > LCODE_MAX_WORDS ? LCODE_MAX_WORDS : count;
|
||||
aw_fel_readl_n(usb, addr, dst, n);
|
||||
addr += n * sizeof(uint32_t);
|
||||
dst += n;
|
||||
count -= n;
|
||||
}
|
||||
}
|
||||
|
||||
/* multiple "writel" from a source buffer to sequential addresses */
|
||||
void aw_fel_writel_n(libusb_device_handle *usb, uint32_t addr,
|
||||
uint32_t *src, size_t count)
|
||||
@ -601,6 +617,22 @@ void aw_fel_writel(libusb_device_handle *usb, uint32_t addr, uint32_t val)
|
||||
aw_fel_writel_n(usb, addr, &val, 1);
|
||||
}
|
||||
|
||||
/*
|
||||
* aw_fel_writel_n() wrapper that can handle large transfers. If necessary,
|
||||
* those will be done in separate 'chunks' of no more than LCODE_MAX_WORDS.
|
||||
*/
|
||||
void fel_writel_n(libusb_device_handle *usb, uint32_t addr,
|
||||
uint32_t *src, size_t count)
|
||||
{
|
||||
while (count > 0) {
|
||||
size_t n = count > LCODE_MAX_WORDS ? LCODE_MAX_WORDS : count;
|
||||
aw_fel_writel_n(usb, addr, src, n);
|
||||
addr += n * sizeof(uint32_t);
|
||||
src += n;
|
||||
count -= n;
|
||||
}
|
||||
}
|
||||
|
||||
void aw_fel_print_sid(libusb_device_handle *usb)
|
||||
{
|
||||
soc_info_t *soc_info = aw_fel_get_soc_info(usb);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user