@@ -30,8 +30,8 @@ DECLARE_GLOBAL_DATA_PTR;
#define FTMAC100_MDIO_TIMEOUT_USEC 10000
struct ftmac100_data {
- struct ftmac100_txdes txdes[1];
- struct ftmac100_rxdes rxdes[PKTBUFSRX];
+ struct ftmac100_txdes *txdes;
+ struct ftmac100_rxdes *rxdes;
int rx_index;
const char *name;
struct ftmac100 *ftmac100;
@@ -403,12 +403,35 @@ static int ftmac100_mdio_init(struct udevice *dev)
return 0;
}
+static void *ftmac100_alloc_descs(unsigned int num, unsigned int size)
+{
+#ifdef CONFIG_SYS_NONCACHED_MEMORY
+ return (void *)noncached_alloc(num * size,
+ ARCH_DMA_MINALIGN);
+#else
+ return memalign(ARCH_DMA_MINALIGN, num * size);
+#endif
+}
+
static int ftmac100_probe(struct udevice *dev)
{
struct ftmac100_data *priv = dev_get_priv(dev);
priv->name = dev->name;
int ret = 0;
+ priv->txdes = ftmac100_alloc_descs(1, sizeof(struct ftmac100_txdes));
+ if (!priv->txdes) {
+ dev_err(dev, "Failed to allocate tx descriptors\n");
+ return -ENOMEM;
+ }
+
+ priv->rxdes = ftmac100_alloc_descs(PKTBUFSRX,
+ sizeof(struct ftmac100_rxdes));
+ if (!priv->rxdes) {
+ dev_err(dev, "Failed to allocate rx descriptors\n");
+ return -ENOMEM;
+ }
+
ret = ftmac100_mdio_init(dev);
if (ret) {
dev_err(dev, "Failed to initialize mdiobus: %d\n", ret);
Change TX and RX DMA descriptors from inline arrays embedded in struct ftmac100_data to dynamically allocated pointers. When CONFIG_SYS_NONCACHED_MEMORY is enabled, allocate descriptors from the noncached memory region using noncached_alloc(); otherwise fall back to memalign(). Signed-off-by: Leo Yu-Chi Liang <ycliang@andestech.com> --- drivers/net/ftmac100.c | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-)