aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux
diff options
context:
space:
mode:
authorFlorian Fainelli <f.fainelli@gmail.com>2017-02-04 16:02:44 -0500
committerDavid S. Miller <davem@davemloft.net>2017-02-07 10:51:46 -0500
commit648ea0134069cda7d4940f397bcc6901fb88752a (patch)
tree2e898d9c56777f31708c0292170eae5d76c13882 /include/linux
parent71e0bbde0d88047f66b25721f69a441d46083748 (diff)
net: phy: Allow pre-declaration of MDIO devices
Allow board support code to collect pre-declarations for MDIO devices by registering them with mdiobus_register_board_info(). SPI and I2C buses have a similar feature, we were missing this for MDIO devices, but this is particularly useful for e.g: MDIO-connected switches which need to provide their port layout (often board-specific) to a MDIO Ethernet switch driver. Signed-off-by: Florian Fainelli <f.fainelli@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/mdio.h3
-rw-r--r--include/linux/mod_devicetable.h1
-rw-r--r--include/linux/phy.h19
3 files changed, 23 insertions, 0 deletions
diff --git a/include/linux/mdio.h b/include/linux/mdio.h
index 55a80d73cfc1..ca08ab16ecdc 100644
--- a/include/linux/mdio.h
+++ b/include/linux/mdio.h
@@ -10,6 +10,7 @@
10#define __LINUX_MDIO_H__ 10#define __LINUX_MDIO_H__
11 11
12#include <uapi/linux/mdio.h> 12#include <uapi/linux/mdio.h>
13#include <linux/mod_devicetable.h>
13 14
14struct mii_bus; 15struct mii_bus;
15 16
@@ -29,6 +30,7 @@ struct mdio_device {
29 30
30 const struct dev_pm_ops *pm_ops; 31 const struct dev_pm_ops *pm_ops;
31 struct mii_bus *bus; 32 struct mii_bus *bus;
33 char modalias[MDIO_NAME_SIZE];
32 34
33 int (*bus_match)(struct device *dev, struct device_driver *drv); 35 int (*bus_match)(struct device *dev, struct device_driver *drv);
34 void (*device_free)(struct mdio_device *mdiodev); 36 void (*device_free)(struct mdio_device *mdiodev);
@@ -71,6 +73,7 @@ int mdio_device_register(struct mdio_device *mdiodev);
71void mdio_device_remove(struct mdio_device *mdiodev); 73void mdio_device_remove(struct mdio_device *mdiodev);
72int mdio_driver_register(struct mdio_driver *drv); 74int mdio_driver_register(struct mdio_driver *drv);
73void mdio_driver_unregister(struct mdio_driver *drv); 75void mdio_driver_unregister(struct mdio_driver *drv);
76int mdio_device_bus_match(struct device *dev, struct device_driver *drv);
74 77
75static inline bool mdio_phy_id_is_c45(int phy_id) 78static inline bool mdio_phy_id_is_c45(int phy_id)
76{ 79{
diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
index 8a57f0b1242d..8850fcaf50db 100644
--- a/include/linux/mod_devicetable.h
+++ b/include/linux/mod_devicetable.h
@@ -501,6 +501,7 @@ struct platform_device_id {
501 kernel_ulong_t driver_data; 501 kernel_ulong_t driver_data;
502}; 502};
503 503
504#define MDIO_NAME_SIZE 32
504#define MDIO_MODULE_PREFIX "mdio:" 505#define MDIO_MODULE_PREFIX "mdio:"
505 506
506#define MDIO_ID_FMT "%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d" 507#define MDIO_ID_FMT "%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d"
diff --git a/include/linux/phy.h b/include/linux/phy.h
index 28ae9eafec19..d9bdf53e0514 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -886,6 +886,25 @@ void mdio_bus_exit(void);
886 886
887extern struct bus_type mdio_bus_type; 887extern struct bus_type mdio_bus_type;
888 888
889struct mdio_board_info {
890 const char *bus_id;
891 char modalias[MDIO_NAME_SIZE];
892 int mdio_addr;
893 const void *platform_data;
894};
895
896#if IS_ENABLED(CONFIG_PHYLIB)
897int mdiobus_register_board_info(const struct mdio_board_info *info,
898 unsigned int n);
899#else
900static inline int mdiobus_register_board_info(const struct mdio_board_info *i,
901 unsigned int n)
902{
903 return 0;
904}
905#endif
906
907
889/** 908/**
890 * module_phy_driver() - Helper macro for registering PHY drivers 909 * module_phy_driver() - Helper macro for registering PHY drivers
891 * @__phy_drivers: array of PHY drivers to register 910 * @__phy_drivers: array of PHY drivers to register