summaryrefslogtreecommitdiffstats
path: root/include/linux/phy.h
diff options
context:
space:
mode:
authorFlorian Fainelli2014-02-12 02:27:39 +0100
committerDavid S. Miller2014-02-13 01:08:20 +0100
commit8a2fe56e8827f2b1eb1766702f0215074dd2767e (patch)
tree0c01261dde720a3002a9f7a56b87b37c7c61b21b /include/linux/phy.h
parentnet: phy: fix phy_{clear,config}_interrupt comment typos (diff)
downloadkernel-qcow2-linux-8a2fe56e8827f2b1eb1766702f0215074dd2767e.tar.gz
kernel-qcow2-linux-8a2fe56e8827f2b1eb1766702f0215074dd2767e.tar.xz
kernel-qcow2-linux-8a2fe56e8827f2b1eb1766702f0215074dd2767e.zip
net: phy: re-design phy_modes to be self-contained
of_get_phy_mode() uses a local array to map phy_interface_t values from include/linux/net/phy.h to a string which is read from the 'phy-mode' or 'phy-connection-type' property. In preparation for exposing the PHY interface mode through sysfs, perform the following: - mode phy_modes from drivers/of/of_net.c to include/linux/phy.h such that it is right below the phy_interface_t enum - make it a static inline function returning the string such that we can use it by just including include/linux/net/phy.h - add a PHY_INTERFACE_MODE_MAX enum value to guard the iteration in of_get_phy_mode() Signed-off-by: Florian Fainelli <f.fainelli@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/linux/phy.h')
-rw-r--r--include/linux/phy.h42
1 files changed, 42 insertions, 0 deletions
diff --git a/include/linux/phy.h b/include/linux/phy.h
index eede6579cae7..ef7fa1131145 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -74,8 +74,50 @@ typedef enum {
PHY_INTERFACE_MODE_RTBI,
PHY_INTERFACE_MODE_SMII,
PHY_INTERFACE_MODE_XGMII,
+ PHY_INTERFACE_MODE_MAX,
} phy_interface_t;
+/**
+ * It maps 'enum phy_interface_t' found in include/linux/phy.h
+ * into the device tree binding of 'phy-mode', so that Ethernet
+ * device driver can get phy interface from device tree.
+ */
+static inline const char *phy_modes(phy_interface_t interface)
+{
+ switch (interface) {
+ case PHY_INTERFACE_MODE_NA:
+ return "";
+ case PHY_INTERFACE_MODE_MII:
+ return "mii";
+ case PHY_INTERFACE_MODE_GMII:
+ return "gmii";
+ case PHY_INTERFACE_MODE_SGMII:
+ return "sgmii";
+ case PHY_INTERFACE_MODE_TBI:
+ return "tbi";
+ case PHY_INTERFACE_MODE_REVMII:
+ return "rev-mii";
+ case PHY_INTERFACE_MODE_RMII:
+ return "rmii";
+ case PHY_INTERFACE_MODE_RGMII:
+ return "rgmii";
+ case PHY_INTERFACE_MODE_RGMII_ID:
+ return "rgmii-id";
+ case PHY_INTERFACE_MODE_RGMII_RXID:
+ return "rgmii-rxid";
+ case PHY_INTERFACE_MODE_RGMII_TXID:
+ return "rgmii-txid";
+ case PHY_INTERFACE_MODE_RTBI:
+ return "rtbi";
+ case PHY_INTERFACE_MODE_SMII:
+ return "smii";
+ case PHY_INTERFACE_MODE_XGMII:
+ return "xgmii";
+ default:
+ return "unknown";
+ }
+}
+
#define PHY_INIT_TIMEOUT 100000
#define PHY_STATE_TIME 1