Skip to contentSkip to conversation

net: ftmac110: cosmetics and cleanup

PATCH New Kuo-Jung Su 2 participants 10 messages Jul 4, 2013 – Aug 19, 2013 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: ftmac110: cosmetics and cleanup

From: Kuo-Jung Su <[email protected]>

1. Update license statement

2. struct ftmac110_regs __iomem *regs -> struct ftmac110_regs *regs.

3. Reformat hardware tx/rx descriptor as an uniform one, and replace uint32_t[2] with uint64_t for descriptor control.

CC Joe Hershberger <[email protected]>
CC Tom Rini <[email protected]>
---
 drivers/net/ftmac110.c |  117 ++++++++++++++++++++++++++++--------------------
 drivers/net/ftmac110.h |   87 +++++++++++++++++++----------------
 2 files changed, 117 insertions(+), 87 deletions(-)
drivers/net/ftmac110.c +68 -49
index 579dcc7..d154cb9 100644
@@ -1,11 +1,22 @@
 /*
  * Faraday 10/100Mbps Ethernet Controller
  *
- * (C) Copyright 2010 Faraday Technology
+ * (C) Copyright 2013 Faraday Technology
  * Dante Su <[email protected]>
  *
- * This file is released under the terms of GPL v2 and any later version.
- * See the file COPYING in the root directory of the source tree for details.
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
 #include <common.h>
@@ -55,11 +66,11 @@ struct ftmac110_chip {
 	uint32_t lnkup;
 	uint32_t phy_addr;
 
-	struct ftmac110_rxd *rxd;
+	struct ftmac110_desc *rxd;
 	ulong                rxd_dma;
 	uint32_t             rxd_idx;
 
-	struct ftmac110_txd *txd;
+	struct ftmac110_desc *txd;
 	ulong                txd_dma;
 	uint32_t             txd_idx;
 };
@@ -70,7 +81,7 @@ static uint16_t mdio_read(struct eth_device *dev,
 	uint8_t phyaddr, uint8_t phyreg)
 {
 	struct ftmac110_chip *chip = dev->priv;
-	struct ftmac110_regs __iomem *regs = chip->regs;
+	struct ftmac110_regs *regs = chip->regs;
 	uint32_t tmp, ts;
 	uint16_t ret = 0xffff;
 
@@ -99,7 +110,7 @@ static void mdio_write(struct eth_device *dev,
 	uint8_t phyaddr, uint8_t phyreg, uint16_t phydata)
 {
 	struct ftmac110_chip *chip = dev->priv;
-	struct ftmac110_regs __iomem *regs = chip->regs;
+	struct ftmac110_regs *regs = chip->regs;
 	uint32_t tmp, ts;
 
 	tmp = PHYCR_WRITE
@@ -186,8 +197,8 @@ static uint32_t ftmac110_phyqry(struct eth_device *dev)
 
 exit:
 	printf("ftmac110: %d Mbps, %s\n",
-	       (maccr & MACCR_100M) ? 100 : 10,
-	       (maccr & MACCR_FD) ? "Full" : "half");
+		   (maccr & MACCR_100M) ? 100 : 10,
+		   (maccr & MACCR_FD) ? "Full" : "half");
 	return maccr;
 }
 
@@ -196,7 +207,7 @@ static int ftmac110_reset(struct eth_device *dev)
 	uint8_t *a;
 	uint32_t i, maccr;
 	struct ftmac110_chip *chip = dev->priv;
-	struct ftmac110_regs __iomem *regs = chip->regs;
+	struct ftmac110_regs *regs = chip->regs;
 
 	/* 1. MAC reset */
 	writel(MACCR_RESET, &regs->maccr);
@@ -213,14 +224,15 @@ static int ftmac110_reset(struct eth_device *dev)
 	/* 1-1. Init tx ring */
 	for (i = 0; i < CFG_TXDES_NUM; ++i) {
 		/* owned by SW */
-		chip->txd[i].ct[0] = 0;
+		chip->txd[i].ctrl &= cpu_to_le64(FTMAC110_TXD_CLRMASK);
 	}
 	chip->txd_idx = 0;
 
 	/* 1-2. Init rx ring */
 	for (i = 0; i < CFG_RXDES_NUM; ++i) {
 		/* owned by HW */
-		chip->rxd[i].ct[0] = cpu_to_le32(FTMAC110_RXCT0_OWNER);
+		chip->rxd[i].ctrl &= cpu_to_le64(FTMAC110_RXD_CLRMASK);
+		chip->rxd[i].ctrl |= cpu_to_le64(FTMAC110_RXD_OWNER);
 	}
 	chip->rxd_idx = 0;
 
@@ -269,7 +281,7 @@ static int ftmac110_probe(struct eth_device *dev, bd_t *bis)
 static void ftmac110_halt(struct eth_device *dev)
 {
 	struct ftmac110_chip *chip = dev->priv;
-	struct ftmac110_regs __iomem *regs = chip->regs;
+	struct ftmac110_regs *regs = chip->regs;
 
 	writel(0, &regs->imr);
 	writel(0, &regs->maccr);
@@ -280,8 +292,9 @@ static void ftmac110_halt(struct eth_device *dev)
 static int ftmac110_send(struct eth_device *dev, void *pkt, int len)
 {
 	struct ftmac110_chip *chip = dev->priv;
-	struct ftmac110_regs __iomem *regs = chip->regs;
-	struct ftmac110_txd *des;
+	struct ftmac110_regs *regs = chip->regs;
+	struct ftmac110_desc *txd;
+	uint64_t ctrl;
 
 	if (!chip->lnkup)
 		return 0;
@@ -293,24 +306,26 @@ static int ftmac110_send(struct eth_device *dev, void *pkt, int len)
 
 	len = max(60, len);
 
-	des = &chip->txd[chip->txd_idx];
-	if (le32_to_cpu(des->ct[0]) & FTMAC110_TXCT0_OWNER) {
+	txd = &chip->txd[chip->txd_idx];
+	ctrl = le64_to_cpu(txd->ctrl);
+	if (ctrl & FTMAC110_TXD_OWNER) {
 		/* kick-off Tx DMA */
 		writel(0xffffffff, &regs->txpd);
 		printf("ftmac110: out of txd\n");
 		return 0;
 	}
 
-	memcpy(des->vbuf, (void *)pkt, len);
-	dma_map_single(des->vbuf, len, DMA_TO_DEVICE);
-
-	/* update len, fts and lts */
-	des->ct[1] &= cpu_to_le32(FTMAC110_TXCT1_END);
-	des->ct[1] |= cpu_to_le32(FTMAC110_TXCT1_LEN(len)
-		| FTMAC110_TXCT1_FTS | FTMAC110_TXCT1_LTS);
+	memcpy(txd->vbuf, (void *)pkt, len);
+	dma_map_single(txd->vbuf, len, DMA_TO_DEVICE);
 
-	/* set owner bit and clear others */
-	des->ct[0] = cpu_to_le32(FTMAC110_TXCT0_OWNER);
+	/* clear control bits */
+	ctrl &= FTMAC110_TXD_CLRMASK;
+	/* set len, fts and lts */
+	ctrl |= FTMAC110_TXD_LEN(len) | FTMAC110_TXD_FTS | FTMAC110_TXD_LTS;
+	/* set owner bit */
+	ctrl |= FTMAC110_TXD_OWNER;
+	/* write back to descriptor */
+	txd->ctrl = cpu_to_le64(ctrl);
 
 	/* kick-off Tx DMA */
 	writel(0xffffffff, &regs->txpd);
@@ -323,23 +338,24 @@ static int ftmac110_send(struct eth_device *dev, void *pkt, int len)
 static int ftmac110_recv(struct eth_device *dev)
 {
 	struct ftmac110_chip *chip = dev->priv;
-	struct ftmac110_rxd *des;
-	uint32_t ct0, len, rlen = 0;
+	struct ftmac110_desc *rxd;
+	uint32_t len, rlen = 0;
+	uint64_t ctrl;
 	uint8_t *buf;
 
 	if (!chip->lnkup)
 		return 0;
 
 	do {
-		des = &chip->rxd[chip->rxd_idx];
-		ct0 = le32_to_cpu(des->ct[0]);
-		if (ct0 & FTMAC110_RXCT0_OWNER)
+		rxd = &chip->rxd[chip->rxd_idx];
+		ctrl = le64_to_cpu(rxd->ctrl);
+		if (ctrl & FTMAC110_RXD_OWNER)
 			break;
 
-		len = FTMAC110_RXCT0_LEN(ct0);
-		buf = des->vbuf;
+		len = (uint32_t)FTMAC110_RXD_LEN(ctrl);
+		buf = rxd->vbuf;
 
-		if (ct0 & FTMAC110_RXCT0_ERRMASK) {
+		if (ctrl & FTMAC110_RXD_ERRMASK) {
 			printf("ftmac110: rx error\n");
 		} else {
 			dma_map_single(buf, len, DMA_FROM_DEVICE);
@@ -348,7 +364,9 @@ static int ftmac110_recv(struct eth_device *dev)
 		}
 
 		/* owned by hardware */
-		des->ct[0] = cpu_to_le32(FTMAC110_RXCT0_OWNER);
+		ctrl &= FTMAC110_RXD_CLRMASK;
+		ctrl |= FTMAC110_RXD_OWNER;
+		rxd->ctrl |= cpu_to_le64(ctrl);
 
 		chip->rxd_idx = (chip->rxd_idx + 1) % CFG_RXDES_NUM;
 	} while (0);
@@ -423,42 +441,43 @@ int ftmac110_initialize(bd_t *bis)
 
 	/* allocate tx descriptors (it must be 16 bytes aligned) */
 	chip->txd = dma_alloc_coherent(
-		sizeof(struct ftmac110_txd) * CFG_TXDES_NUM, &chip->txd_dma);
+		sizeof(struct ftmac110_desc) * CFG_TXDES_NUM, &chip->txd_dma);
 	if (!chip->txd)
 		panic("ftmac110: out of memory 3\n");
 	memset(chip->txd, 0,
-	       sizeof(struct ftmac110_txd) * CFG_TXDES_NUM);
+		sizeof(struct ftmac110_desc) * CFG_TXDES_NUM);
 	for (i = 0; i < CFG_TXDES_NUM; ++i) {
 		void *va = memalign(ARCH_DMA_MINALIGN, CFG_XBUF_SIZE);
+
 		if (!va)
 			panic("ftmac110: out of memory 4\n");
-		chip->txd[i].vbuf  = va;
-		chip->txd[i].buf   = cpu_to_le32(virt_to_phys(va));
-		chip->txd[i].ct[1] = 0;
-		chip->txd[i].ct[0] = 0; /* owned by SW */
+		chip->txd[i].vbuf = va;
+		chip->txd[i].pbuf = cpu_to_le32(virt_to_phys(va));
+		chip->txd[i].ctrl = 0;	/* owned by SW */
 	}
-	chip->txd[i - 1].ct[1] |= cpu_to_le32(FTMAC110_TXCT1_END);
+	chip->txd[i - 1].ctrl |= cpu_to_le64(FTMAC110_TXD_END);
 	chip->txd_idx = 0;
 
 	/* allocate rx descriptors (it must be 16 bytes aligned) */
 	chip->rxd = dma_alloc_coherent(
-		sizeof(struct ftmac110_rxd) * CFG_RXDES_NUM, &chip->rxd_dma);
+		sizeof(struct ftmac110_desc) * CFG_RXDES_NUM, &chip->rxd_dma);
 	if (!chip->rxd)
 		panic("ftmac110: out of memory 4\n");
 	memset((void *)chip->rxd, 0,
-	       sizeof(struct ftmac110_rxd) * CFG_RXDES_NUM);
+		sizeof(struct ftmac110_desc) * CFG_RXDES_NUM);
 	for (i = 0; i < CFG_RXDES_NUM; ++i) {
 		void *va = memalign(ARCH_DMA_MINALIGN, CFG_XBUF_SIZE + 2);
+
 		if (!va)
 			panic("ftmac110: out of memory 5\n");
 		/* it needs to be exactly 2 bytes aligned */
 		va = ((uint8_t *)va + 2);
-		chip->rxd[i].vbuf  = va;
-		chip->rxd[i].buf   = cpu_to_le32(virt_to_phys(va));
-		chip->rxd[i].ct[1] = cpu_to_le32(CFG_XBUF_SIZE);
-		chip->rxd[i].ct[0] = cpu_to_le32(FTMAC110_RXCT0_OWNER);
+		chip->rxd[i].vbuf = va;
+		chip->rxd[i].pbuf = cpu_to_le32(virt_to_phys(va));
+		chip->rxd[i].ctrl = cpu_to_le64(FTMAC110_RXD_OWNER
+			| FTMAC110_RXD_BUFSZ(CFG_XBUF_SIZE));
 	}
-	chip->rxd[i - 1].ct[1] |= cpu_to_le32(FTMAC110_RXCT1_END);
+	chip->rxd[i - 1].ctrl |= cpu_to_le64(FTMAC110_RXD_END);
 	chip->rxd_idx = 0;
 
 	eth_register(dev);
drivers/net/ftmac110.h +49 -38

102 lines not on this page · raw message

--
1.7.9.5

#1 lore raw

PATCH 1/1 net: ftmac110: cosmetics and cleanup

Hi Kuo-Jung Su,

Quoted 8 lines · Kuo-Jung Su

From: Kuo-Jung Su <[email protected]>

1. Update license statement

2. struct ftmac110_regs __iomem *regs -> struct ftmac110_regs *regs.

3. Reformat hardware tx/rx descriptor as an uniform one, and replace uint32_t[2] with uint64_t for descriptor control.

Please send these as separate patches that each have a single, complete purpose.

#2 lore raw

PATCH 1/1 net: ftmac110: cosmetics and cleanup

2013/7/9 Joe Hershberger <[email protected]>:

Quoted 5 lines

Hi Kuo-Jung Su,

Quoted 2 lines · Kuo-Jung Su

From: Kuo-Jung Su <[email protected]>

Quoted 8 lines
Quoted 6 lines

1. Update license statement

2. struct ftmac110_regs __iomem *regs -> struct ftmac110_regs *regs.

3. Reformat hardware tx/rx descriptor as an uniform one, and replace uint32_t[2] with uint64_t for descriptor control.

Please send these as separate patches that each have a single, complete purpose.

Got it, thanks

--
Best wishes,
Kuo-Jung Su

#3 lore raw

v2 cover net: ftmac110: cosmetics and cleanup

In reply to Kuo-Jung Su

From: Kuo-Jung Su <[email protected]>

1. Update license statement

2. struct ftmac110_regs __iomem *regs -> struct ftmac110_regs *regs.

3. Reformat hardware tx/rx descriptor as an uniform one, and replace uint32_t[2] with uint64_t for descriptor control.

Changes for v2:
- Re-send these as separate patches that each have a single, complete purpose.

Kuo-Jung Su (3):
net: ftmac110: Update license statement
net: ftmac110: struct ftmac110_regs __iomem * -> struct ftmac110_regs

    *

net: ftmac110: Update tx/rx descriptor format

 drivers/net/ftmac110.c |  113 ++++++++++++++++++++++++++++--------------------
 drivers/net/ftmac110.h |   87 +++++++++++++++++++++----------------
 2 files changed, 115 insertions(+), 85 deletions(-)

--
1.7.9.5

#4 lore raw

PATCH v2 1/3 net: ftmac110: Update license statement

From: Kuo-Jung Su <[email protected]>

CC Joe Hershberger <[email protected]>
---
 drivers/net/ftmac110.c |   17 ++++++++++++++---
 drivers/net/ftmac110.h |   17 ++++++++++++++---
 2 files changed, 28 insertions(+), 6 deletions(-)
drivers/net/ftmac110.c +14 -3
index 35f8633..c7d45e1 100644
@@ -1,11 +1,22 @@
 /*
  * Faraday 10/100Mbps Ethernet Controller
  *
- * (C) Copyright 2010 Faraday Technology
+ * (C) Copyright 2013 Faraday Technology
  * Dante Su <[email protected]>
  *
- * This file is released under the terms of GPL v2 and any later version.
- * See the file COPYING in the root directory of the source tree for details.
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
 #include <common.h>
drivers/net/ftmac110.h +14 -3
index 5b2d23b..4bb8b76 100644
@@ -1,11 +1,22 @@
 /*
  * Faraday 10/100Mbps Ethernet Controller
  *
- * (C) Copyright 2010 Faraday Technology
+ * (C) Copyright 2013 Faraday Technology
  * Dante Su <[email protected]>
  *
- * This file is released under the terms of GPL v2 and any later version.
- * See the file COPYING in the root directory of the source tree for details.
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
 #ifndef _FTMAC110_H

--
1.7.9.5

#6 lore raw

PATCH v2 2/3 net: ftmac110: struct ftmac110_regs __iomem * -> struct ftmac110_regs *

In reply to Kuo-Jung Su

From: Kuo-Jung Su <[email protected]>

CC Joe Hershberger <[email protected]>
---
 drivers/net/ftmac110.c |   10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/net/ftmac110.c +5 -5
index c7d45e1..1afd95a 100644
@@ -81,7 +81,7 @@ static uint16_t mdio_read(struct eth_device *dev,
 	uint8_t phyaddr, uint8_t phyreg)
 {
 	struct ftmac110_chip *chip = dev->priv;
-	struct ftmac110_regs __iomem *regs = chip->regs;
+	struct ftmac110_regs *regs = chip->regs;
 	uint32_t tmp, ts;
 	uint16_t ret = 0xffff;
 
@@ -110,7 +110,7 @@ static void mdio_write(struct eth_device *dev,
 	uint8_t phyaddr, uint8_t phyreg, uint16_t phydata)
 {
 	struct ftmac110_chip *chip = dev->priv;
-	struct ftmac110_regs __iomem *regs = chip->regs;
+	struct ftmac110_regs *regs = chip->regs;
 	uint32_t tmp, ts;
 
 	tmp = PHYCR_WRITE
@@ -207,7 +207,7 @@ static int ftmac110_reset(struct eth_device *dev)
 	uint8_t *a;
 	uint32_t i, maccr;
 	struct ftmac110_chip *chip = dev->priv;
-	struct ftmac110_regs __iomem *regs = chip->regs;
+	struct ftmac110_regs *regs = chip->regs;
 
 	/* 1. MAC reset */
 	writel(MACCR_RESET, &regs->maccr);
@@ -280,7 +280,7 @@ static int ftmac110_probe(struct eth_device *dev, bd_t *bis)
 static void ftmac110_halt(struct eth_device *dev)
 {
 	struct ftmac110_chip *chip = dev->priv;
-	struct ftmac110_regs __iomem *regs = chip->regs;
+	struct ftmac110_regs *regs = chip->regs;
 
 	writel(0, &regs->imr);
 	writel(0, &regs->maccr);
@@ -291,7 +291,7 @@ static void ftmac110_halt(struct eth_device *dev)
 static int ftmac110_send(struct eth_device *dev, void *pkt, int len)
 {
 	struct ftmac110_chip *chip = dev->priv;
-	struct ftmac110_regs __iomem *regs = chip->regs;
+	struct ftmac110_regs *regs = chip->regs;
 	struct ftmac110_txd *des;
 
 	if (!chip->lnkup)

--
1.7.9.5

#8 lore raw

PATCH v2 3/3 net: ftmac110: Update tx/rx descriptor format

In reply to Kuo-Jung Su

From: Kuo-Jung Su <[email protected]>

1. Reformat tx/rx descriptor as an uniform struct.
2. Replace uint32_t[2] with uint64_t for descriptor control.

CC Joe Hershberger <[email protected]>
---
 drivers/net/ftmac110.c |   86 ++++++++++++++++++++++++++----------------------
 drivers/net/ftmac110.h |   70 +++++++++++++++++++--------------------
 2 files changed, 82 insertions(+), 74 deletions(-)
drivers/net/ftmac110.c +47 -39
index 1afd95a..d154cb9 100644
@@ -66,11 +66,11 @@ struct ftmac110_chip {
 	uint32_t lnkup;
 	uint32_t phy_addr;
 
-	struct ftmac110_rxd *rxd;
+	struct ftmac110_desc *rxd;
 	ulong                rxd_dma;
 	uint32_t             rxd_idx;
 
-	struct ftmac110_txd *txd;
+	struct ftmac110_desc *txd;
 	ulong                txd_dma;
 	uint32_t             txd_idx;
 };
@@ -224,14 +224,15 @@ static int ftmac110_reset(struct eth_device *dev)
 	/* 1-1. Init tx ring */
 	for (i = 0; i < CFG_TXDES_NUM; ++i) {
 		/* owned by SW */
-		chip->txd[i].ct[0] = 0;
+		chip->txd[i].ctrl &= cpu_to_le64(FTMAC110_TXD_CLRMASK);
 	}
 	chip->txd_idx = 0;
 
 	/* 1-2. Init rx ring */
 	for (i = 0; i < CFG_RXDES_NUM; ++i) {
 		/* owned by HW */
-		chip->rxd[i].ct[0] = cpu_to_le32(FTMAC110_RXCT0_OWNER);
+		chip->rxd[i].ctrl &= cpu_to_le64(FTMAC110_RXD_CLRMASK);
+		chip->rxd[i].ctrl |= cpu_to_le64(FTMAC110_RXD_OWNER);
 	}
 	chip->rxd_idx = 0;
 
@@ -292,7 +293,8 @@ static int ftmac110_send(struct eth_device *dev, void *pkt, int len)
 {
 	struct ftmac110_chip *chip = dev->priv;
 	struct ftmac110_regs *regs = chip->regs;
-	struct ftmac110_txd *des;
+	struct ftmac110_desc *txd;
+	uint64_t ctrl;
 
 	if (!chip->lnkup)
 		return 0;
@@ -304,24 +306,26 @@ static int ftmac110_send(struct eth_device *dev, void *pkt, int len)
 
 	len = max(60, len);
 
-	des = &chip->txd[chip->txd_idx];
-	if (le32_to_cpu(des->ct[0]) & FTMAC110_TXCT0_OWNER) {
+	txd = &chip->txd[chip->txd_idx];
+	ctrl = le64_to_cpu(txd->ctrl);
+	if (ctrl & FTMAC110_TXD_OWNER) {
 		/* kick-off Tx DMA */
 		writel(0xffffffff, &regs->txpd);
 		printf("ftmac110: out of txd\n");
 		return 0;
 	}
 
-	memcpy(des->vbuf, (void *)pkt, len);
-	dma_map_single(des->vbuf, len, DMA_TO_DEVICE);
+	memcpy(txd->vbuf, (void *)pkt, len);
+	dma_map_single(txd->vbuf, len, DMA_TO_DEVICE);
 
-	/* update len, fts and lts */
-	des->ct[1] &= cpu_to_le32(FTMAC110_TXCT1_END);
-	des->ct[1] |= cpu_to_le32(FTMAC110_TXCT1_LEN(len)
-		| FTMAC110_TXCT1_FTS | FTMAC110_TXCT1_LTS);
-
-	/* set owner bit and clear others */
-	des->ct[0] = cpu_to_le32(FTMAC110_TXCT0_OWNER);
+	/* clear control bits */
+	ctrl &= FTMAC110_TXD_CLRMASK;
+	/* set len, fts and lts */
+	ctrl |= FTMAC110_TXD_LEN(len) | FTMAC110_TXD_FTS | FTMAC110_TXD_LTS;
+	/* set owner bit */
+	ctrl |= FTMAC110_TXD_OWNER;
+	/* write back to descriptor */
+	txd->ctrl = cpu_to_le64(ctrl);
 
 	/* kick-off Tx DMA */
 	writel(0xffffffff, &regs->txpd);
@@ -334,23 +338,24 @@ static int ftmac110_send(struct eth_device *dev, void *pkt, int len)
 static int ftmac110_recv(struct eth_device *dev)
 {
 	struct ftmac110_chip *chip = dev->priv;
-	struct ftmac110_rxd *des;
-	uint32_t ct0, len, rlen = 0;
+	struct ftmac110_desc *rxd;
+	uint32_t len, rlen = 0;
+	uint64_t ctrl;
 	uint8_t *buf;
 
 	if (!chip->lnkup)
 		return 0;
 
 	do {
-		des = &chip->rxd[chip->rxd_idx];
-		ct0 = le32_to_cpu(des->ct[0]);
-		if (ct0 & FTMAC110_RXCT0_OWNER)
+		rxd = &chip->rxd[chip->rxd_idx];
+		ctrl = le64_to_cpu(rxd->ctrl);
+		if (ctrl & FTMAC110_RXD_OWNER)
 			break;
 
-		len = FTMAC110_RXCT0_LEN(ct0);
-		buf = des->vbuf;
+		len = (uint32_t)FTMAC110_RXD_LEN(ctrl);
+		buf = rxd->vbuf;
 
-		if (ct0 & FTMAC110_RXCT0_ERRMASK) {
+		if (ctrl & FTMAC110_RXD_ERRMASK) {
 			printf("ftmac110: rx error\n");
 		} else {
 			dma_map_single(buf, len, DMA_FROM_DEVICE);
@@ -359,7 +364,9 @@ static int ftmac110_recv(struct eth_device *dev)
 		}
 
 		/* owned by hardware */
-		des->ct[0] = cpu_to_le32(FTMAC110_RXCT0_OWNER);
+		ctrl &= FTMAC110_RXD_CLRMASK;
+		ctrl |= FTMAC110_RXD_OWNER;
+		rxd->ctrl |= cpu_to_le64(ctrl);
 
 		chip->rxd_idx = (chip->rxd_idx + 1) % CFG_RXDES_NUM;
 	} while (0);
@@ -434,42 +441,43 @@ int ftmac110_initialize(bd_t *bis)
 
 	/* allocate tx descriptors (it must be 16 bytes aligned) */
 	chip->txd = dma_alloc_coherent(
-		sizeof(struct ftmac110_txd) * CFG_TXDES_NUM, &chip->txd_dma);
+		sizeof(struct ftmac110_desc) * CFG_TXDES_NUM, &chip->txd_dma);
 	if (!chip->txd)
 		panic("ftmac110: out of memory 3\n");
 	memset(chip->txd, 0,
-		sizeof(struct ftmac110_txd) * CFG_TXDES_NUM);
+		sizeof(struct ftmac110_desc) * CFG_TXDES_NUM);
 	for (i = 0; i < CFG_TXDES_NUM; ++i) {
 		void *va = memalign(ARCH_DMA_MINALIGN, CFG_XBUF_SIZE);
+
 		if (!va)
 			panic("ftmac110: out of memory 4\n");
-		chip->txd[i].vbuf  = va;
-		chip->txd[i].buf   = cpu_to_le32(virt_to_phys(va));
-		chip->txd[i].ct[1] = 0;
-		chip->txd[i].ct[0] = 0; /* owned by SW */
+		chip->txd[i].vbuf = va;
+		chip->txd[i].pbuf = cpu_to_le32(virt_to_phys(va));
+		chip->txd[i].ctrl = 0;	/* owned by SW */
 	}
-	chip->txd[i - 1].ct[1] |= cpu_to_le32(FTMAC110_TXCT1_END);
+	chip->txd[i - 1].ctrl |= cpu_to_le64(FTMAC110_TXD_END);
 	chip->txd_idx = 0;
 
 	/* allocate rx descriptors (it must be 16 bytes aligned) */
 	chip->rxd = dma_alloc_coherent(
-		sizeof(struct ftmac110_rxd) * CFG_RXDES_NUM, &chip->rxd_dma);
+		sizeof(struct ftmac110_desc) * CFG_RXDES_NUM, &chip->rxd_dma);
 	if (!chip->rxd)
 		panic("ftmac110: out of memory 4\n");
 	memset((void *)chip->rxd, 0,
-		sizeof(struct ftmac110_rxd) * CFG_RXDES_NUM);
+		sizeof(struct ftmac110_desc) * CFG_RXDES_NUM);
 	for (i = 0; i < CFG_RXDES_NUM; ++i) {
 		void *va = memalign(ARCH_DMA_MINALIGN, CFG_XBUF_SIZE + 2);
+
 		if (!va)
 			panic("ftmac110: out of memory 5\n");
 		/* it needs to be exactly 2 bytes aligned */
 		va = ((uint8_t *)va + 2);
-		chip->rxd[i].vbuf  = va;
-		chip->rxd[i].buf   = cpu_to_le32(virt_to_phys(va));
-		chip->rxd[i].ct[1] = cpu_to_le32(CFG_XBUF_SIZE);
-		chip->rxd[i].ct[0] = cpu_to_le32(FTMAC110_RXCT0_OWNER);
+		chip->rxd[i].vbuf = va;
+		chip->rxd[i].pbuf = cpu_to_le32(virt_to_phys(va));
+		chip->rxd[i].ctrl = cpu_to_le64(FTMAC110_RXD_OWNER
+			| FTMAC110_RXD_BUFSZ(CFG_XBUF_SIZE));
 	}
-	chip->rxd[i - 1].ct[1] |= cpu_to_le32(FTMAC110_RXCT1_END);
+	chip->rxd[i - 1].ctrl |= cpu_to_le64(FTMAC110_RXD_END);
 	chip->rxd_idx = 0;
 
 	eth_register(dev);
drivers/net/ftmac110.h +35 -35

77 lines not on this page · raw message

--
1.7.9.5