mirror of
https://xff.cz/git/u-boot/
synced 2025-09-01 16:52:14 +02:00
usb: ci_udc: lift ilist size calculations to global scope
This will allow functions other than ci_udc_probe() to make use of the constants in a future change. This in turn requires converting the const int variables to #defines, since the initialization of one global const int can't depend on the value of another const int; the compiler thinks it's non-constant if that dependency exists. Signed-off-by: Stephen Warren <swarren@nvidia.com>
This commit is contained in:
committed by
Marek Vasut
parent
8d7c39d3e8
commit
06b38fcbae
@@ -34,6 +34,17 @@
|
|||||||
#error This driver can not work on systems with caches longer than 128b
|
#error This driver can not work on systems with caches longer than 128b
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Each qTD item must be 32-byte aligned, each qTD touple must be
|
||||||
|
* cacheline aligned. There are two qTD items for each endpoint and
|
||||||
|
* only one of them is used for the endpoint at time, so we can group
|
||||||
|
* them together.
|
||||||
|
*/
|
||||||
|
#define ILIST_ALIGN roundup(ARCH_DMA_MINALIGN, 32)
|
||||||
|
#define ILIST_ENT_RAW_SZ (2 * sizeof(struct ept_queue_item))
|
||||||
|
#define ILIST_ENT_SZ roundup(ILIST_ENT_RAW_SZ, ARCH_DMA_MINALIGN)
|
||||||
|
#define ILIST_SZ (NUM_ENDPOINTS * ILIST_ENT_SZ)
|
||||||
|
|
||||||
#ifndef DEBUG
|
#ifndef DEBUG
|
||||||
#define DBG(x...) do {} while (0)
|
#define DBG(x...) do {} while (0)
|
||||||
#else
|
#else
|
||||||
@@ -786,29 +797,18 @@ static int ci_udc_probe(void)
|
|||||||
const int eplist_raw_sz = num * sizeof(struct ept_queue_head);
|
const int eplist_raw_sz = num * sizeof(struct ept_queue_head);
|
||||||
const int eplist_sz = roundup(eplist_raw_sz, ARCH_DMA_MINALIGN);
|
const int eplist_sz = roundup(eplist_raw_sz, ARCH_DMA_MINALIGN);
|
||||||
|
|
||||||
const int ilist_align = roundup(ARCH_DMA_MINALIGN, 32);
|
|
||||||
const int ilist_ent_raw_sz = 2 * sizeof(struct ept_queue_item);
|
|
||||||
const int ilist_ent_sz = roundup(ilist_ent_raw_sz, ARCH_DMA_MINALIGN);
|
|
||||||
const int ilist_sz = NUM_ENDPOINTS * ilist_ent_sz;
|
|
||||||
|
|
||||||
/* The QH list must be aligned to 4096 bytes. */
|
/* The QH list must be aligned to 4096 bytes. */
|
||||||
controller.epts = memalign(eplist_align, eplist_sz);
|
controller.epts = memalign(eplist_align, eplist_sz);
|
||||||
if (!controller.epts)
|
if (!controller.epts)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
memset(controller.epts, 0, eplist_sz);
|
memset(controller.epts, 0, eplist_sz);
|
||||||
|
|
||||||
/*
|
controller.items_mem = memalign(ILIST_ALIGN, ILIST_SZ);
|
||||||
* Each qTD item must be 32-byte aligned, each qTD touple must be
|
|
||||||
* cacheline aligned. There are two qTD items for each endpoint and
|
|
||||||
* only one of them is used for the endpoint at time, so we can group
|
|
||||||
* them together.
|
|
||||||
*/
|
|
||||||
controller.items_mem = memalign(ilist_align, ilist_sz);
|
|
||||||
if (!controller.items_mem) {
|
if (!controller.items_mem) {
|
||||||
free(controller.epts);
|
free(controller.epts);
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
memset(controller.items_mem, 0, ilist_sz);
|
memset(controller.items_mem, 0, ILIST_SZ);
|
||||||
|
|
||||||
for (i = 0; i < 2 * NUM_ENDPOINTS; i++) {
|
for (i = 0; i < 2 * NUM_ENDPOINTS; i++) {
|
||||||
/*
|
/*
|
||||||
@@ -828,7 +828,7 @@ static int ci_udc_probe(void)
|
|||||||
head->next = TERMINATE;
|
head->next = TERMINATE;
|
||||||
head->info = 0;
|
head->info = 0;
|
||||||
|
|
||||||
imem = controller.items_mem + ((i >> 1) * ilist_ent_sz);
|
imem = controller.items_mem + ((i >> 1) * ILIST_ENT_SZ);
|
||||||
if (i & 1)
|
if (i & 1)
|
||||||
imem += sizeof(struct ept_queue_item);
|
imem += sizeof(struct ept_queue_item);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user