Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 90eff909 authored by Florian Fainelli's avatar Florian Fainelli Committed by David S. Miller
Browse files

net: phy: Allow splitting MDIO bus/device support from PHYs



Introduce a new configuration symbol: MDIO_DEVICE which allows building
the MDIO devices and bus code, without pulling in the entire Ethernet
PHY library and devices code.

PHYLIB nows select MDIO_DEVICE and the relevant Makefile files are
updated to reflect that.

When MDIO_DEVICE (MDIO bus/device only) is selected, but not PHYLIB, we
have mdio-bus.ko as a loadable module, and it does not have a
module_exit() function because the safety of removing a bus class is
unclear.

When both MDIO_DEVICE and PHYLIB are enabled, we need to assemble
everything into a common loadable module: libphy.ko because of nasty
circular dependencies between phy.c, phy_device.c and mdio_bus.c which
are really tough to untangle.

Signed-off-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 17487eeb
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -18,7 +18,7 @@ obj-$(CONFIG_MII) += mii.o
obj-$(CONFIG_MDIO) += mdio.o
obj-$(CONFIG_MDIO) += mdio.o
obj-$(CONFIG_NET) += Space.o loopback.o
obj-$(CONFIG_NET) += Space.o loopback.o
obj-$(CONFIG_NETCONSOLE) += netconsole.o
obj-$(CONFIG_NETCONSOLE) += netconsole.o
obj-$(CONFIG_PHYLIB) += phy/
obj-$(CONFIG_MDIO_DEVICE) += phy/
obj-$(CONFIG_RIONET) += rionet.o
obj-$(CONFIG_RIONET) += rionet.o
obj-$(CONFIG_NET_TEAM) += team/
obj-$(CONFIG_NET_TEAM) += team/
obj-$(CONFIG_TUN) += tun.o
obj-$(CONFIG_TUN) += tun.o
+35 −25
Original line number Original line Diff line number Diff line
@@ -2,33 +2,12 @@
# PHY Layer Configuration
# PHY Layer Configuration
#
#


menuconfig PHYLIB
menuconfig MDIO_DEVICE
	tristate "PHY Device support and infrastructure"
	tristate "MDIO bus device drivers"
	depends on NETDEVICES
	help
	help
	  Ethernet controllers are usually attached to PHY
	   MDIO devices and driver infrastructure code.
	  devices.  This option provides infrastructure for
	  managing PHY devices.

if PHYLIB

config SWPHY
	bool

config LED_TRIGGER_PHY
	bool "Support LED triggers for tracking link state"
	depends on LEDS_TRIGGERS
	---help---
	  Adds support for a set of LED trigger events per-PHY.  Link
	  state change will trigger the events, for consumption by an
	  LED class driver.  There are triggers for each link speed currently
	  supported by the phy, and are of the form:
	       <mii bus id>:<phy>:<speed>

	  Where speed is in the form:
		<Speed in megabits>Mbps or <Speed in gigabits>Gbps


comment "MDIO bus device drivers"
if MDIO_DEVICE


config MDIO_BCM_IPROC
config MDIO_BCM_IPROC
	tristate "Broadcom iProc MDIO bus controller"
	tristate "Broadcom iProc MDIO bus controller"
@@ -49,6 +28,7 @@ config MDIO_BCM_UNIMAC


config MDIO_BITBANG
config MDIO_BITBANG
	tristate "Bitbanged MDIO buses"
	tristate "Bitbanged MDIO buses"
	depends on !(MDIO_DEVICE=y && PHYLIB=m)
	help
	help
	  This module implements the MDIO bus protocol in software,
	  This module implements the MDIO bus protocol in software,
	  for use by low level drivers that export the ability to
	  for use by low level drivers that export the ability to
@@ -160,6 +140,36 @@ config MDIO_XGENE
	  This module provides a driver for the MDIO busses found in the
	  This module provides a driver for the MDIO busses found in the
	  APM X-Gene SoC's.
	  APM X-Gene SoC's.


endif

menuconfig PHYLIB
	tristate "PHY Device support and infrastructure"
	depends on NETDEVICES
	select MDIO_DEVICE
	help
	  Ethernet controllers are usually attached to PHY
	  devices.  This option provides infrastructure for
	  managing PHY devices.

if PHYLIB

config SWPHY
	bool

config LED_TRIGGER_PHY
	bool "Support LED triggers for tracking link state"
	depends on LEDS_TRIGGERS
	---help---
	  Adds support for a set of LED trigger events per-PHY.  Link
	  state change will trigger the events, for consumption by an
	  LED class driver.  There are triggers for each link speed currently
	  supported by the phy, and are of the form:
	       <mii bus id>:<phy>:<speed>

	  Where speed is in the form:
		<Speed in megabits>Mbps or <Speed in gigabits>Gbps


comment "MII PHY device drivers"
comment "MII PHY device drivers"


config AMD_PHY
config AMD_PHY
+11 −2
Original line number Original line Diff line number Diff line
# Makefile for Linux PHY drivers and MDIO bus drivers
# Makefile for Linux PHY drivers and MDIO bus drivers


libphy-y			:= phy.o phy_device.o mdio_bus.o mdio_device.o \
libphy-y			:= phy.o phy-core.o phy_device.o
				   mdio-boardinfo.o phy-core.o
mdio-bus-y			+= mdio_bus.o mdio_device.o mdio-boardinfo.o

# PHYLIB implies MDIO_DEVICE, in that case, we have a bunch of circular
# dependencies that does not make it possible to split mdio-bus objects into a
# dedicated loadable module, so we bundle them all together into libphy.ko
ifdef CONFIG_PHYLIB
libphy-y			+= $(mdio-bus-y)
else
obj-$(CONFIG_MDIO_DEVICE)	+= mdio-bus.o
endif
libphy-$(CONFIG_SWPHY)		+= swphy.o
libphy-$(CONFIG_SWPHY)		+= swphy.o
libphy-$(CONFIG_LED_TRIGGER_PHY)	+= phy_led_triggers.o
libphy-$(CONFIG_LED_TRIGGER_PHY)	+= phy_led_triggers.o


+1 −0
Original line number Original line Diff line number Diff line
@@ -84,3 +84,4 @@ int mdiobus_register_board_info(const struct mdio_board_info *info,


	return 0;
	return 0;
}
}
EXPORT_SYMBOL(mdiobus_register_board_info);
+9 −0
Original line number Original line Diff line number Diff line
@@ -648,9 +648,18 @@ int __init mdio_bus_init(void)


	return ret;
	return ret;
}
}
EXPORT_SYMBOL_GPL(mdio_bus_init);


#if IS_ENABLED(CONFIG_PHYLIB)
void mdio_bus_exit(void)
void mdio_bus_exit(void)
{
{
	class_unregister(&mdio_bus_class);
	class_unregister(&mdio_bus_class);
	bus_unregister(&mdio_bus_type);
	bus_unregister(&mdio_bus_type);
}
}
EXPORT_SYMBOL_GPL(mdio_bus_exit);
#else
module_init(mdio_bus_init);
/* no module_exit, intentional */
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("MDIO bus/device layer");
#endif
Loading