w5100: detect carrier state using link status bit and optional interrupt

Detect the carrier state on the w5500 Ethernet controller using the
Link Status bit from the PHY Configuration register (PHYCFGR).

On w5100/w5200, which lack this register, get_link() is not implemented
and the carrier state is not reported (netif_carrier_(on|off) is not
called).

For the w5500, add an optional interrupt, wired to the LINKLED pin of
the device, to detect link status changes with a read of the PHYCFGR
register and update of the carrier state with netif_carrier_(on|off).
If this interrupt is not set in the DT binding, get_link() is not
implemented and the carrier state is not reported
(netif_carrier_(on|off) is not called).
The interrupt handler and the PHYCFGR register readings are
synchronized using a mutex.

A few changes are also brought for the bring-up/teardown
synchronization:

 - The net device is registered last in the probe() function so no
   operation can be performed before the probing is finished
 - The net device is unregistered first in remove()
 - dev_name is now used instead of netdev_name
 - w5100_stop() calls cancel_work_sync() and flush_work() to make sure
   there is no race condition or unfinished work
 - w5100_suspend() calls w5100_stop()
 - w5100_resume() calls w5100_open()
 - The main irq is not automatically enabled in w5100_probe() but in
   w5100_open() and disabled in w5100_stop()

Commit dacf281771 ("w5100: remove unused gpio link detection")
dropped the link_gpio/link_irq handling on the grounds that no
devicetree user passed a "link" gpio at the time and that it used the
old gpio interface.
This isn't a plain revert of that removal: link detection is now done
using a second interrupt rather than a gpio with a documented DT
binding.

Set the WIZNET entry as DRIVER and add drivers/net/ethernet/wiznet in
MAINTAINERS file.

Signed-off-by: Arthur Crepin Leblond <arthur@marmottus.net>
Fixes: dacf281771 ("w5100: remove unused gpio link detection")
Link: https://patch.msgid.link/20260924-wiznet-link-gpio-v11-3-42a332517b30@marmottus.net
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
Arthur Crepin Leblond 2026-09-24 11:48:13 +02:00 • committed by Jakub Kicinski
commit 323767fa31
2 changed files with 206 additions and 31 deletions