wiznet: convert to GPIO descriptors
Subsystems (5)
PATCH 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.
--- .../devicetree/bindings/net/wiznet,w5x00.txt | 4 +- drivers/net/ethernet/wiznet/w5100-spi.c | 21 ++----- drivers/net/ethernet/wiznet/w5100.c | 57 ++++++++++--------- drivers/net/ethernet/wiznet/w5100.h | 3 +- drivers/net/ethernet/wiznet/w5300.c | 52 ++++++++++------- include/linux/platform_data/wiznet.h | 23 -------- 6 files changed, 70 insertions(+), 90 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 -26
165 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 -22
130 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 26 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.
Signed-off-by Arnd Bergmann <[email protected]>--- .../devicetree/bindings/net/wiznet,w5x00.txt | 4 +- drivers/net/ethernet/wiznet/w5100-spi.c | 21 ++----- drivers/net/ethernet/wiznet/w5100.c | 57 ++++++++++--------- drivers/net/ethernet/wiznet/w5100.h | 3 +- drivers/net/ethernet/wiznet/w5300.c | 52 ++++++++++------- include/linux/platform_data/wiznet.h | 23 -------- 6 files changed, 70 insertions(+), 90 deletions(-) delete mode 100644 include/linux/platform_data/wiznet.h
<...>
drivers/net/ethernet/wiznet/w5100.c MODULE_LICENSE("GPL"); · line 144
Quoted 9 lines
#include "
w5100.h"drivers/net/ethernet/wiznet/w5100.c +3
-0@@ -139,6 +139,12 @@ MODULE_LICENSE("GPL");#define W5500_RX_MEM_START 0x30000#define W5500_RX_MEM_SIZE 0x04000 +#ifndef CONFIG_WIZNET_BUS_SHIFT +#define CONFIG_WIZNET_BUS_SHIFT 0 +#endif
I don't see any define of CONFIG_WIZNET_BUS_SHIFT in the code, so it looks like it always zero and can be removed.
Thanks
Quoted 6 lines · Leon Romanovsky
Quoted 5 lines · Arnd Bergmann
drivers/net/ethernet/wiznet/w5100.c +0
-0@@ -139,6 +139,12 @@ MODULE_LICENSE("GPL");#define W5500_RX_MEM_START 0x30000#define W5500_RX_MEM_SIZE 0x04000
Quoted 6 lines
drivers/net/ethernet/wiznet/w5100.c MODULE_LICENSE("GPL"); · line 144
Quoted 3 lines
drivers/net/ethernet/wiznet/w5100.c +3
-0+#ifndef CONFIG_WIZNET_BUS_SHIFT +#define CONFIG_WIZNET_BUS_SHIFT 0 +#endif I don't see any define of
CONFIG_WIZNET_BUS_SHIFTin the code, so it looks like it always zero and can be removed.
Good catch! Evidently the original idea was that this would be set to a machine specific value through Kconfig. I've renamed the constant, removed the #ifdef and explained it in the changelog text now.
Arnd