Skip to contentSkip to conversation

wiznet: convert to GPIO descriptors

PATCH In review Arnd Bergmann 5 participants 7 messages Apr 27 – May 17

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

PATCH v4 1/1 wiznet: convert to GPIO descriptors

From: Arnd Bergmann <[email protected]>

The w5100/w5300 drivers only support probing with old platform data in MMIO mode, or probing with DT in SPI mode. There are no users of this platform data in tree, and from the git history it appears that the only users of MMIO mode were on the (since removed) blackfin architecture.

Remove the platform data option, as it's unlikely to still be needed, and change the internal operation to GPIO descriptors, making the behavior the same for SPI and MMIO mode. The other data in the platform_data structure is the MAC address, so make that also handled the same for both.

It would probably be possible to just remove the MMIO mode driver completely, but it seems fine otherwise, and fixing it to use the modern interface seems easy enough.

The CONFIG_WIZNET_BUS_SHIFT value was apparently meant to be set at compile time to a machine specific value. This was always broken for multiplatform configurations with conflicting requirements, and in the mainline kernel it was set to 0 anyway. Leave it defined locally as 0 but rename it to something without the CONFIG_ prefix.

---
v4: rebase to 7.1
v3: include linux/gpio/consumer.h to avoid build failure without GPIOLIB
v2: replace CONFIG_WIZNET_BUS_SHIFT with a constant

---
 .../devicetree/bindings/net/wiznet,w5x00.txt  |  4 +-
 drivers/net/ethernet/wiznet/w5100-spi.c       |  9 +--
 drivers/net/ethernet/wiznet/w5100.c           | 61 ++++++++++---------
 drivers/net/ethernet/wiznet/w5100.h           |  3 +-
 drivers/net/ethernet/wiznet/w5300.c           | 54 ++++++++--------
 include/linux/platform_data/wiznet.h          | 23 -------
 6 files changed, 67 insertions(+), 87 deletions(-)
 delete mode 100644 include/linux/platform_data/wiznet.h
Documentation/devicetree/bindings/net/wiznet,w5x00.txt +3 -1
index e9665798c4be..e8a802d65817 100644
@@ -1,6 +1,6 @@
 * Wiznet w5x00
 
-This is a standalone 10/100 MBit Ethernet controller with SPI interface.
+This is a standalone 10/100 MBit Ethernet controller with SPI or MMIO interface.
 
 For each device connected to a SPI bus, define a child node within
 the SPI master node.
@@ -9,6 +9,7 @@ Required properties:
 - compatible: Should be one of the following strings:
 	      "wiznet,w5100"
 	      "wiznet,w5200"
+	      "wiznet,w5300"
 	      "wiznet,w5500"
 - reg: Specify the SPI chip select the chip is wired to.
 - interrupts: Specify the interrupt index within the interrupt controller (referred
@@ -25,6 +26,7 @@ Optional properties:
   According to the w5500 datasheet, the chip allows a maximum of 80 MHz, however,
   board designs may need to limit this value.
 - local-mac-address: See ethernet.txt in the same directory.
+- link-gpios: a GPIO line used for the link detection interrupt
 
 
 Example (for Raspberry Pi with pin control stuff for GPIO irq):
drivers/net/ethernet/wiznet/w5100-spi.c +1 -8
index 990a3cce8c0f..0626fcb8db5a 100644
@@ -422,14 +422,7 @@ static int w5100_spi_probe(struct spi_device *spi)
 {
 	const struct w5100_ops *ops;
 	kernel_ulong_t driver_data;
-	const void *mac = NULL;
-	u8 tmpmac[ETH_ALEN];
 	int priv_size;
-	int ret;
-
-	ret = of_get_mac_address(spi->dev.of_node, tmpmac);
-	if (!ret)
-		mac = tmpmac;
 
 	driver_data = (uintptr_t)spi_get_device_match_data(spi);
 
@@ -450,7 +443,7 @@ static int w5100_spi_probe(struct spi_device *spi)
 		return -EINVAL;
 	}
 
-	return w5100_probe(&spi->dev, ops, priv_size, mac, spi->irq, -EINVAL);
+	return w5100_probe(&spi->dev, ops, priv_size, spi->irq);
 }
 
 static void w5100_spi_remove(struct spi_device *spi)
drivers/net/ethernet/wiznet/w5100.c +32 -29

180 lines not on this page · raw message

drivers/net/ethernet/wiznet/w5100.h +1 -2
index 481af3b6d9e8..013ef2835115 100644
@@ -29,8 +29,7 @@ struct w5100_ops {
 void *w5100_ops_priv(const struct net_device *ndev);
 
 int w5100_probe(struct device *dev, const struct w5100_ops *ops,
-		int sizeof_ops_priv, const void *mac_addr, int irq,
-		int link_gpio);
+		int sizeof_ops_priv, int irq);
 void w5100_remove(struct device *dev);
 
 extern const struct dev_pm_ops w5100_pm_ops;
drivers/net/ethernet/wiznet/w5300.c +30 -24

143 lines not on this page · raw message

include/linux/platform_data/wiznet.h deleted +0 -23
deleted file mode 100644
index 1154c4db8a13..000000000000
@@ -1,23 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-or-later */
-/*
- * Ethernet driver for the WIZnet W5x00 chip.
- */
-
-#ifndef PLATFORM_DATA_WIZNET_H
-#define PLATFORM_DATA_WIZNET_H
-
-#include <linux/if_ether.h>
-
-struct wiznet_platform_data {
-	int	link_gpio;
-	u8	mac_addr[ETH_ALEN];
-};
-
-#ifndef CONFIG_WIZNET_BUS_SHIFT
-#define CONFIG_WIZNET_BUS_SHIFT 0
-#endif
-
-#define W5100_BUS_DIRECT_SIZE	(0x8000 << CONFIG_WIZNET_BUS_SHIFT)
-#define W5300_BUS_DIRECT_SIZE	(0x0400 << CONFIG_WIZNET_BUS_SHIFT)
-
-#endif /* PLATFORM_DATA_WIZNET_H */
Signature · 1 line
2.39.5
#1 lore raw
Quoted 6 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

The w5100/w5300 drivers only support probing with old platform data in MMIO mode, or probing with DT in SPI mode. There are no users of this platform data in tree, and from the git history it appears that the only users of MMIO mode were on the (since removed) blackfin architecture.

A quick grep does not find any .dts files referencing the compatible.

Quoted 3 lines

It would probably be possible to just remove the MMIO mode driver completely, but it seems fine otherwise, and fixing it to use the modern interface seems easy enough.

Last real development work on this driver was:

Author: Nicolas Saenz Julienne <[email protected]>
Date:   Wed Jun 12 14:25:25 2019 +0200

net: ethernet: wiznet: w5X00 add device tree support

The w5X00 chip provides an SPI to Ethernet inteface. This patch allows platform devices to be defined through the device tree.

Nicolas, are you still using it?

Andrew

#2 lore raw
Quoted 19 lines · Andrew Lunn
Quoted 6 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

The w5100/w5300 drivers only support probing with old platform data in MMIO mode, or probing with DT in SPI mode. There are no users of this platform data in tree, and from the git history it appears that the only users of MMIO mode were on the (since removed) blackfin architecture.

A quick grep does not find any .dts files referencing the compatible.

Quoted 3 lines

It would probably be possible to just remove the MMIO mode driver completely, but it seems fine otherwise, and fixing it to use the modern interface seems easy enough.

Last real development work on this driver was:

Author: Nicolas Saenz Julienne <[email protected]>
Date:   Wed Jun 12 14:25:25 2019 +0200
Quoted 6 lines

net: ethernet: wiznet: w5X00 add device tree support

The w5X00 chip provides an SPI to Ethernet inteface. This patch allows platform devices to be defined through the device tree.

Nicolas, are you still using it?

Hi Andrew, no I'm not.

Thanks,
Nicolas

maintainer
#3 lore raw
In reply to Arnd Bergmann
Quoted 16 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

The w5100/w5300 drivers only support probing with old platform data in MMIO mode, or probing with DT in SPI mode. There are no users of this platform data in tree, and from the git history it appears that the only users of MMIO mode were on the (since removed) blackfin architecture.

Remove the platform data option, as it's unlikely to still be needed, and change the internal operation to GPIO descriptors, making the behavior the same for SPI and MMIO mode. The other data in the platform_data structure is the MAC address, so make that also handled the same for both.

It would probably be possible to just remove the MMIO mode driver completely, but it seems fine otherwise, and fixing it to use the modern interface seems easy enough.

Quoted 7 lines

The CONFIG_WIZNET_BUS_SHIFT value was apparently meant to be set at compile time to a machine specific value. This was always broken for multiplatform configurations with conflicting requirements, and in the mainline kernel it was set to 0 anyway. Leave it defined locally as 0 but rename it to something without the CONFIG_ prefix.

Well, 3 years later and I'm a bit grumpier seeing .txt binding additions. A new compatible plus new property we generally require converting the binding first. But I'm not going to revoke my ack here.

Is there even a known user for this new compatible?

Rob

#4 lore raw
Quoted 8 lines · Rob Herring
Quoted 7 lines · Arnd Bergmann

The CONFIG_WIZNET_BUS_SHIFT value was apparently meant to be set at compile time to a machine specific value. This was always broken for multiplatform configurations with conflicting requirements, and in the mainline kernel it was set to 0 anyway. Leave it defined locally as 0 but rename it to something without the CONFIG_ prefix.

Quoted 7 lines
Quoted 1 line

Well, 3 years later and I'm a bit grumpier seeing .txt binding additions. A new compatible plus new property we generally require converting the binding first. But I'm not going to revoke my ack here.

Is there even a known user for this new compatible?

No, I'm not aware of any users neither the old nor the new compatible, it only popped up from my backlog of patches because of its usage of legacy GPIOs. From what I can tell, the only users of the non-DT MMIO interface were out of tree arch/blackfin/ boards.

Arnd

#5 lore raw
Quoted 15 lines · Arnd Bergmann
Quoted 14 lines · Rob Herring
Quoted 8 lines · Arnd Bergmann

The CONFIG_WIZNET_BUS_SHIFT value was apparently meant to be set at compile time to a machine specific value. This was always broken for multiplatform configurations with conflicting requirements, and in the mainline kernel it was set to 0 anyway. Leave it defined locally as 0 but rename it to something without the CONFIG_ prefix.

Well, 3 years later and I'm a bit grumpier seeing .txt binding additions. A new compatible plus new property we generally require converting the binding first. But I'm not going to revoke my ack here.

Quoted 7 lines
Quoted 1 line

Is there even a known user for this new compatible?

No, I'm not aware of any users neither the old nor the new compatible, it only popped up from my backlog of patches because of its usage of legacy GPIOs. From what I can tell, the only users of the non-DT MMIO interface were out of tree arch/blackfin/ boards.

I would suggest giving Nicolas Saenz Julienne time to speak up. If Nicolas does not require it any more, i suggest removing it. That fits with what we are trying to do at the moment in netdev, remove old drivers.

Andrew

#6 lore raw
Quoted 6 lines · Andrew Lunn
Quoted 1 line · Arnd Bergmann

On Mon, Apr 27, 2026, at 16:50, Rob Herring wrote:

I would suggest giving Nicolas Saenz Julienne time to speak up. If Nicolas does not require it any more, i suggest removing it. That fits with what we are trying to do at the moment in netdev, remove old drivers.

Sounds good. Even if Nicolas thinks there may be users of the SPI interface with the existing DT binding, we can still decide to remove the MMIO interface entirely, as I first suggested.

Apparently the chips are still in production and are commonly used with microcontrollers, but the only reference I found about using Linux with it is in a blog post that mentions an "official" driver from the manufacturer, with an (incompatible) compatible="w5000-wiz0" DT binding:

https://maker.wiznet.io/gavinchang/projects/linux-w5500-driver-and-use-1/

Arnd