Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'phy-mdio-split'

Florian Fainelli says:

====================
net: phy: Allow splitting MDIO bus/device support

This patch series allows building support for MDIO bus controllers which
are sometimes usable and necessary in cases where there are no Ethernet PHYs.

Changes in v3:
- corrected of_mdio compile guards for prototypes vs. stubs
- added a missing OF_MDIO dependency for MDIO_BCM_UNIMAC
- fixed Kbuild bot reported errors against mdio-bitbang

Changes in v2:
- implement Russell's feedback
- solve the circular dependency in the CONFIG_MDIO_DEVICE + CONFIG_PHYLIB case
====================

Signed-off-by: David S. Miller <davem@davemloft.net>

+79 -33
+1 -1
drivers/net/Makefile
··· 18 18 obj-$(CONFIG_MDIO) += mdio.o 19 19 obj-$(CONFIG_NET) += Space.o loopback.o 20 20 obj-$(CONFIG_NETCONSOLE) += netconsole.o 21 - obj-$(CONFIG_PHYLIB) += phy/ 21 + obj-$(CONFIG_MDIO_DEVICE) += phy/ 22 22 obj-$(CONFIG_RIONET) += rionet.o 23 23 obj-$(CONFIG_NET_TEAM) += team/ 24 24 obj-$(CONFIG_TUN) += tun.o
+36 -26
drivers/net/phy/Kconfig
··· 2 2 # PHY Layer Configuration 3 3 # 4 4 5 - menuconfig PHYLIB 6 - tristate "PHY Device support and infrastructure" 7 - depends on NETDEVICES 5 + menuconfig MDIO_DEVICE 6 + tristate "MDIO bus device drivers" 8 7 help 9 - Ethernet controllers are usually attached to PHY 10 - devices. This option provides infrastructure for 11 - managing PHY devices. 8 + MDIO devices and driver infrastructure code. 12 9 13 - if PHYLIB 14 - 15 - config SWPHY 16 - bool 17 - 18 - config LED_TRIGGER_PHY 19 - bool "Support LED triggers for tracking link state" 20 - depends on LEDS_TRIGGERS 21 - ---help--- 22 - Adds support for a set of LED trigger events per-PHY. Link 23 - state change will trigger the events, for consumption by an 24 - LED class driver. There are triggers for each link speed currently 25 - supported by the phy, and are of the form: 26 - <mii bus id>:<phy>:<speed> 27 - 28 - Where speed is in the form: 29 - <Speed in megabits>Mbps or <Speed in gigabits>Gbps 30 - 31 - comment "MDIO bus device drivers" 10 + if MDIO_DEVICE 32 11 33 12 config MDIO_BCM_IPROC 34 13 tristate "Broadcom iProc MDIO bus controller" ··· 19 40 20 41 config MDIO_BCM_UNIMAC 21 42 tristate "Broadcom UniMAC MDIO bus controller" 22 - depends on HAS_IOMEM 43 + depends on HAS_IOMEM && OF_MDIO 23 44 help 24 45 This module provides a driver for the Broadcom UniMAC MDIO busses. 25 46 This hardware can be found in the Broadcom GENET Ethernet MAC ··· 28 49 29 50 config MDIO_BITBANG 30 51 tristate "Bitbanged MDIO buses" 52 + depends on !(MDIO_DEVICE=y && PHYLIB=m) 31 53 help 32 54 This module implements the MDIO bus protocol in software, 33 55 for use by low level drivers that export the ability to ··· 139 159 help 140 160 This module provides a driver for the MDIO busses found in the 141 161 APM X-Gene SoC's. 162 + 163 + endif 164 + 165 + menuconfig PHYLIB 166 + tristate "PHY Device support and infrastructure" 167 + depends on NETDEVICES 168 + select MDIO_DEVICE 169 + help 170 + Ethernet controllers are usually attached to PHY 171 + devices. This option provides infrastructure for 172 + managing PHY devices. 173 + 174 + if PHYLIB 175 + 176 + config SWPHY 177 + bool 178 + 179 + config LED_TRIGGER_PHY 180 + bool "Support LED triggers for tracking link state" 181 + depends on LEDS_TRIGGERS 182 + ---help--- 183 + Adds support for a set of LED trigger events per-PHY. Link 184 + state change will trigger the events, for consumption by an 185 + LED class driver. There are triggers for each link speed currently 186 + supported by the phy, and are of the form: 187 + <mii bus id>:<phy>:<speed> 188 + 189 + Where speed is in the form: 190 + <Speed in megabits>Mbps or <Speed in gigabits>Gbps 191 + 142 192 143 193 comment "MII PHY device drivers" 144 194
+11 -2
drivers/net/phy/Makefile
··· 1 1 # Makefile for Linux PHY drivers and MDIO bus drivers 2 2 3 - libphy-y := phy.o phy_device.o mdio_bus.o mdio_device.o \ 4 - mdio-boardinfo.o phy-core.o 3 + libphy-y := phy.o phy-core.o phy_device.o 4 + mdio-bus-y += mdio_bus.o mdio_device.o mdio-boardinfo.o 5 + 6 + # PHYLIB implies MDIO_DEVICE, in that case, we have a bunch of circular 7 + # dependencies that does not make it possible to split mdio-bus objects into a 8 + # dedicated loadable module, so we bundle them all together into libphy.ko 9 + ifdef CONFIG_PHYLIB 10 + libphy-y += $(mdio-bus-y) 11 + else 12 + obj-$(CONFIG_MDIO_DEVICE) += mdio-bus.o 13 + endif 5 14 libphy-$(CONFIG_SWPHY) += swphy.o 6 15 libphy-$(CONFIG_LED_TRIGGER_PHY) += phy_led_triggers.o 7 16
+1
drivers/net/phy/mdio-boardinfo.c
··· 84 84 85 85 return 0; 86 86 } 87 + EXPORT_SYMBOL(mdiobus_register_board_info);
+9
drivers/net/phy/mdio_bus.c
··· 648 648 649 649 return ret; 650 650 } 651 + EXPORT_SYMBOL_GPL(mdio_bus_init); 651 652 653 + #if IS_ENABLED(CONFIG_PHYLIB) 652 654 void mdio_bus_exit(void) 653 655 { 654 656 class_unregister(&mdio_bus_class); 655 657 bus_unregister(&mdio_bus_type); 656 658 } 659 + EXPORT_SYMBOL_GPL(mdio_bus_exit); 660 + #else 661 + module_init(mdio_bus_init); 662 + /* no module_exit, intentional */ 663 + MODULE_LICENSE("GPL"); 664 + MODULE_DESCRIPTION("MDIO bus/device layer"); 665 + #endif
+2 -2
include/linux/of_mdio.h
··· 12 12 #include <linux/phy.h> 13 13 #include <linux/of.h> 14 14 15 - #ifdef CONFIG_OF 15 + #if IS_ENABLED(CONFIG_OF_MDIO) 16 16 extern int of_mdiobus_register(struct mii_bus *mdio, struct device_node *np); 17 17 extern struct phy_device *of_phy_find_device(struct device_node *phy_np); 18 18 extern struct phy_device *of_phy_connect(struct net_device *dev, ··· 32 32 extern void of_phy_deregister_fixed_link(struct device_node *np); 33 33 extern bool of_phy_is_fixed_link(struct device_node *np); 34 34 35 - #else /* CONFIG_OF */ 35 + #else /* CONFIG_OF_MDIO */ 36 36 static inline int of_mdiobus_register(struct mii_bus *mdio, struct device_node *np) 37 37 { 38 38 /*
+19 -2
include/linux/phy.h
··· 745 745 struct phy_device *phy_device_create(struct mii_bus *bus, int addr, int phy_id, 746 746 bool is_c45, 747 747 struct phy_c45_device_ids *c45_ids); 748 + #if IS_ENABLED(CONFIG_PHYLIB) 748 749 struct phy_device *get_phy_device(struct mii_bus *bus, int addr, bool is_c45); 749 750 int phy_device_register(struct phy_device *phy); 751 + void phy_device_free(struct phy_device *phydev); 752 + #else 753 + static inline 754 + struct phy_device *get_phy_device(struct mii_bus *bus, int addr, bool is_c45) 755 + { 756 + return NULL; 757 + } 758 + 759 + static inline int phy_device_register(struct phy_device *phy) 760 + { 761 + return 0; 762 + } 763 + 764 + static inline void phy_device_free(struct phy_device *phydev) { } 765 + #endif /* CONFIG_PHYLIB */ 750 766 void phy_device_remove(struct phy_device *phydev); 751 767 int phy_init_hw(struct phy_device *phydev); 752 768 int phy_suspend(struct phy_device *phydev); ··· 843 827 int phy_mii_ioctl(struct phy_device *phydev, struct ifreq *ifr, int cmd); 844 828 int phy_start_interrupts(struct phy_device *phydev); 845 829 void phy_print_status(struct phy_device *phydev); 846 - void phy_device_free(struct phy_device *phydev); 847 830 int phy_set_max_speed(struct phy_device *phydev, u32 max_speed); 848 831 849 832 int phy_register_fixup(const char *bus_id, u32 phy_uid, u32 phy_uid_mask, ··· 869 854 const struct ethtool_link_ksettings *cmd); 870 855 int phy_ethtool_nway_reset(struct net_device *ndev); 871 856 857 + #if IS_ENABLED(CONFIG_PHYLIB) 872 858 int __init mdio_bus_init(void); 873 859 void mdio_bus_exit(void); 860 + #endif 874 861 875 862 extern struct bus_type mdio_bus_type; 876 863 ··· 883 866 const void *platform_data; 884 867 }; 885 868 886 - #if IS_ENABLED(CONFIG_PHYLIB) 869 + #if IS_ENABLED(CONFIG_MDIO_DEVICE) 887 870 int mdiobus_register_board_info(const struct mdio_board_info *info, 888 871 unsigned int n); 889 872 #else