wiznet: convert to GPIO descriptors
PATCH v2 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.
---
v2: replace CONFIG_WIZNET_BUS_SHIFT with a constant
--- .../devicetree/bindings/net/wiznet,w5x00.txt | 4 +- drivers/net/ethernet/wiznet/w5100-spi.c | 21 ++----- drivers/net/ethernet/wiznet/w5100.c | 59 ++++++++++--------- drivers/net/ethernet/wiznet/w5100.h | 3 +- drivers/net/ethernet/wiznet/w5300.c | 54 +++++++++-------- include/linux/platform_data/wiznet.h | 23 -------- 6 files changed, 70 insertions(+), 94 deletions(-) delete mode 100644 include/linux/platform_data/wiznet.h
Documentation/devicetree/bindings/net/wiznet,w5x00.txt +3 -1
@@ -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 +5 -16
@@ -423,23 +423,12 @@ static int w5100_spi_probe(struct spi_device *spi)const struct of_device_id *of_id;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; - -if (spi->dev.of_node) { - of_id =of_match_device (w5100_of_match, &spi->dev); -if (!of_id) -return -ENODEV ; - driver_data = (kernel_ulong_t )of_id->data; - }else { - driver_data =spi_get_device_id (spi)->driver_data; - } + of_id =of_match_device (w5100_of_match, &spi->dev); +if (!of_id) +return -ENODEV ; + driver_data = (kernel_ulong_t )of_id->data;switch (driver_data) {case W5100 :
@@ -458,7 +447,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 +31 -28
178 lines not on this page · raw message
drivers/net/ethernet/wiznet/w5100.h +1 -2
@@ -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
@@ -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.0
Quoted 22 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_datastructure 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_SHIFTvalue 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 theCONFIG_prefix.
Quoted 3 lines
Signed-off-by Arnd Bergmann <[email protected]>---
v2: replaceCONFIG_WIZNET_BUS_SHIFTwith a constant
Please disregard v2, I found a build regression in some rare random configurations with CONFIG_GPIOLIB=n, v3 coming up.
Arnd