Skip to contentSkip to conversation

net: ftmac100: change driver name from nds32_mac to ftmac100

PATCH In review Sergei Antonov 3 participants 9 messages Feb 3, 2023 – Feb 10, 2023 3 messages not in the archive Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/3 net: ftmac100: change driver name from nds32_mac to ftmac100

So it will be named similarly to the related ftgmac100 driver. The old name 'nds32_mac' is not referred to anywhere in U-Boot.

---

v2 -> v3:
no change

v1 -> v2:
no change

 drivers/net/ftmac100.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ftmac100.c +1 -1
index f710c271c64b..7c89d7f67b8d 100644
@@ -348,7 +348,7 @@ static const struct udevice_id ftmac100_ids[] = {
 };
 
 U_BOOT_DRIVER(ftmac100) = {
-	.name	= "nds32_mac",
+	.name	= "ftmac100",
 	.id	= UCLASS_ETH,
 	.of_match = ftmac100_ids,
 	.bind	= ftmac100_bind,
Signature · 1 line
2.34.1
#1 lore raw

PATCH v3 2/3 net: ftmac100: simplify priv->iobase casting

Replace 'phys_addr_t iobase' with 'struct ftmac100 *ftmac100' in struct ftmac100_data. It allows to remove casting in a number of places.

Since priv->iobase is phys_addr_t, use phys_to_virt() to make a pointer from it.

---

v2 -> v3:
Fix the following warning by using phys_to_virt() to get a pointer from phys_addr_t.
(ae350_rv32) drivers/net/ftmac100.c:317:26: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
(ae350_rv32) 317 | priv->ftmac100 = (struct ftmac100 *)pdata->iobase;

v1 -> v2:
no change

 drivers/net/ftmac100.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/net/ftmac100.c +7 -7
index 7c89d7f67b8d..e7b9d88ea9cd 100644
@@ -28,7 +28,7 @@ struct ftmac100_data {
 	struct ftmac100_rxdes rxdes[PKTBUFSRX];
 	int rx_index;
 	const char *name;
-	phys_addr_t iobase;
+	struct ftmac100 *ftmac100;
 };
 
 /*
@@ -36,7 +36,7 @@ struct ftmac100_data {
  */
 static void ftmac100_reset(struct ftmac100_data *priv)
 {
-	struct ftmac100 *ftmac100 = (struct ftmac100 *)(uintptr_t)priv->iobase;
+	struct ftmac100 *ftmac100 = priv->ftmac100;
 
 	debug ("%s()\n", __func__);
 
@@ -57,7 +57,7 @@ static void ftmac100_reset(struct ftmac100_data *priv)
 static void ftmac100_set_mac(struct ftmac100_data *priv ,
 	const unsigned char *mac)
 {
-	struct ftmac100 *ftmac100 = (struct ftmac100 *)(uintptr_t)priv->iobase;
+	struct ftmac100 *ftmac100 = priv->ftmac100;
 	unsigned int maddr = mac[0] << 8 | mac[1];
 	unsigned int laddr = mac[2] << 24 | mac[3] << 16 | mac[4] << 8 | mac[5];
 
@@ -72,7 +72,7 @@ static void ftmac100_set_mac(struct ftmac100_data *priv ,
  */
 static void _ftmac100_halt(struct ftmac100_data *priv)
 {
-	struct ftmac100 *ftmac100 = (struct ftmac100 *)(uintptr_t)priv->iobase;
+	struct ftmac100 *ftmac100 = priv->ftmac100;
 	debug ("%s()\n", __func__);
 	writel (0, &ftmac100->maccr);
 }
@@ -82,7 +82,7 @@ static void _ftmac100_halt(struct ftmac100_data *priv)
  */
 static int _ftmac100_init(struct ftmac100_data *priv, unsigned char enetaddr[6])
 {
-	struct ftmac100 *ftmac100 = (struct ftmac100 *)(uintptr_t)priv->iobase;
+	struct ftmac100 *ftmac100 = priv->ftmac100;
 	struct ftmac100_txdes *txdes = priv->txdes;
 	struct ftmac100_rxdes *rxdes = priv->rxdes;
 	unsigned int maccr;
@@ -187,7 +187,7 @@ static int __ftmac100_recv(struct ftmac100_data *priv)
  */
 static int _ftmac100_send(struct ftmac100_data *priv, void *packet, int length)
 {
-	struct ftmac100 *ftmac100 = (struct ftmac100 *)(uintptr_t)priv->iobase;
+	struct ftmac100 *ftmac100 = priv->ftmac100;
 	struct ftmac100_txdes *curr_des = priv->txdes;
 	ulong start;
 
@@ -314,7 +314,7 @@ static int ftmac100_of_to_plat(struct udevice *dev)
 	struct eth_pdata *pdata = dev_get_plat(dev);
 	const char *mac;
 	pdata->iobase = dev_read_addr(dev);
-	priv->iobase = pdata->iobase;
+	priv->ftmac100 = phys_to_virt(pdata->iobase);
 	mac = dtbmacaddr(0);
 	if (mac)
 		memcpy(pdata->enetaddr , mac , 6);
Signature · 1 line
2.34.1

A message that is not in the archive (sent off-list or not yet received): PU1PR03MB29978B9E3B4A4AF70E5FB191C1D99@PU1PR03MB2997.apcprd03.prod.outlook.com

Reviewed-by
#3 lore raw

Re: [PATCH v3 2/3] net: ftmac100: simplify priv->iobase casting

Quoted 11 lines

From: U-Boot <[email protected]> On Behalf Of Sergei Antonov
Sent: Saturday, February 04, 2023 3:09 AM
To: [email protected]; [email protected]; [email protected]
Cc: Sergei Antonov <[email protected]>
Subject: [PATCH v3 2/3] net: ftmac100: simplify priv->iobase casting

Replace 'phys_addr_t iobase' with 'struct ftmac100 *ftmac100' in struct ftmac100_data. It allows to remove casting in a number of places.

Since priv->iobase is phys_addr_t, use phys_to_virt() to make a pointer from it.

#4 lore raw

Re: [PATCH v3 2/3] net: ftmac100: simplify priv->iobase casting

In reply to Sergei Antonov
Quoted 8 lines · Sergei Antonov

Replace 'phys_addr_t iobase' with 'struct ftmac100 *ftmac100' in struct ftmac100_data. It allows to remove casting in a number of places.

Since priv->iobase is phys_addr_t, use phys_to_virt() to make a pointer from it.

Applied to u-boot/master, thanks!

Signature · 1 line
Tom
#5 lore raw

PATCH v3 3/3 net: ftmac100: add mii read and write callbacks

In reply to Sergei Antonov

Register mii_bus with read and write callbacks to allow the 'mii' command to work. Use a timeout of 10 ms to wait for the R/W operations to complete.

---

v2 -> v3:
no change

v1 -> v2:
* fix a typo in the description
* add a dependency from MII to Kconfig

 drivers/net/Kconfig    |   1 +
 drivers/net/ftmac100.c | 103 +++++++++++++++++++++++++++++++++++++++++
 drivers/net/ftmac100.h |   9 ++++
 3 files changed, 113 insertions(+)
drivers/net/Kconfig +1 -0
index 62d2c03849af..6006cfc82d50 100644
@@ -406,6 +406,7 @@ config FSL_FM_10GEC_REGULAR_NOTATION
 
 config FTMAC100
 	bool "Ftmac100 Ethernet Support"
+	select MII
 	help
 	  This MAC is present in Andestech SoCs.
 
drivers/net/ftmac100.c +103 -0

140 lines not on this page · raw message

drivers/net/ftmac100.h +9 -0
index 75a49f628a69..21d339f835bf 100644
@@ -92,6 +92,15 @@ struct ftmac100 {
 #define FTMAC100_MACCR_RX_MULTIPKT	(1 << 16)
 #define FTMAC100_MACCR_RX_BROADPKT	(1 << 17)
 
+/*
+ * PHY control register
+ */
+#define FTMAC100_PHYCR_MIIRDATA		0xffff
+#define FTMAC100_PHYCR_PHYAD(x)		(((x) & 0x1f) << 16)
+#define FTMAC100_PHYCR_REGAD(x)		(((x) & 0x1f) << 21)
+#define FTMAC100_PHYCR_MIIWR		BIT(27)
+#define FTMAC100_PHYCR_MIIRD		BIT(26)
+
 /*
  * Transmit descriptor, aligned to 16 bytes
  */
Signature · 1 line
2.34.1

A message that is not in the archive (sent off-list or not yet received): PU1PR03MB2997F582BB6AC65F0FF4ABCAC1D99@PU1PR03MB2997.apcprd03.prod.outlook.com

Reviewed-by Tested-by
#7 lore raw

Re: [PATCH v3 3/3] net: ftmac100: add mii read and write callbacks

Quoted 11 lines

From: U-Boot <[email protected]> On Behalf Of Sergei Antonov
Sent: Saturday, February 04, 2023 3:09 AM
To: [email protected]; [email protected]; [email protected]
Cc: Sergei Antonov <[email protected]>
Subject: [PATCH v3 3/3] net: ftmac100: add mii read and write callbacks

Register mii_bus with read and write callbacks to allow the 'mii' command to work. Use a timeout of 10 ms to wait for the R/W operations to complete.

---

I have verified this patch on AE350 platform and it work well with dhcp command as below:

U-Boot 2023.04-rc1-00032-gf9f161b600-dirty (Feb 09 2023 - 10:55:03 +0800)

DRAM:  1 GiB
Core:  16 devices, 12 uclasses, devicetree: board
Flash: 64 MiB

MMC:
Loading Environment from SPIFlash... SF: Detected mx25u1635e with page size 256 Bytes, erase size 4 KiB, total 2 MiB
OK

In:    serial@f0300000
Out:   serial@f0300000
Err:   serial@f0300000
Net:   no alias for ethernet0
eth0: mac@e0100000
Hit any key to stop autoboot:  0

RISC-V #
RISC-V # dhcp 0x06000000 10.0.12.60:Image-518
BOOTP broadcast 1
BOOTP broadcast 2
DHCP client bound to address 10.0.12.91 (280 ms)
Using mac@e0100000 device
TFTP from server 10.0.12.60; our IP address is 10.0.12.91 Filename 'Image-518'.
Load address: 0x6000000
Loading: #################################################################

         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         ###################################################
         300.8 KiB/s

done
Bytes transferred = 14098060 (d71e8c hex)
RISC-V # mii device
MII devices: 'eth0'
Current device: 'eth0'
RISC-V # mii info
PHY 0x00: OUI = 0x606E, Model = 0x0B, Rev = 0x01, 100baseT, FDX RISC-V #

#8 lore raw

Re: [PATCH v3 3/3] net: ftmac100: add mii read and write callbacks

In reply to Sergei Antonov
Quoted 7 lines · Sergei Antonov

Register mii_bus with read and write callbacks to allow the 'mii' command to work. Use a timeout of 10 ms to wait for the R/W operations to complete.

Applied to u-boot/master, thanks!

Signature · 1 line
Tom

A message that is not in the archive (sent off-list or not yet received): PU1PR03MB2997239CB9B1B68FEC3D2929C1D99@PU1PR03MB2997.apcprd03.prod.outlook.com

Reviewed-by
#10 lore raw
Quoted 11 lines

From: U-Boot <[email protected]> On Behalf Of Sergei Antonov
Sent: Saturday, February 04, 2023 3:09 AM
To: [email protected]; [email protected]; [email protected]
Cc: Sergei Antonov <[email protected]>
Subject: [PATCH v3 1/3] net: ftmac100: change driver name from nds32_mac to ftmac100

So it will be named similarly to the related ftgmac100 driver. The old name 'nds32_mac' is not referred to anywhere in U-Boot.