[PATCH 5/6] net: ftmac100: Add noncached memory support for DMA descriptors
Leo Yu-Chi Liang
ycliang at andestech.com
Thu Mar 19 09:37:12 CET 2026
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 at andestech.com>
---
drivers/net/ftmac100.c | 27 +++++++++++++++++++++++++--
1 file changed, 25 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ftmac100.c b/drivers/net/ftmac100.c
index fa0b3dbb6d1..f7f7db56130 100644
--- a/drivers/net/ftmac100.c
+++ b/drivers/net/ftmac100.c
@@ -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);
--
2.34.1
More information about the U-Boot
mailing list