diff options
| author | Florian Fainelli <f.fainelli@gmail.com> | 2014-02-11 20:27:39 -0500 |
|---|---|---|
| committer | David S. Miller <davem@davemloft.net> | 2014-02-12 19:08:20 -0500 |
| commit | 8a2fe56e8827f2b1eb1766702f0215074dd2767e (patch) | |
| tree | 0c01261dde720a3002a9f7a56b87b37c7c61b21b /include/linux | |
| parent | ad033506f5061db818bab1cc07b2c3d8d477cf12 (diff) | |
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')
| -rw-r--r-- | include/linux/phy.h | 42 |
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 { | |||
| 74 | PHY_INTERFACE_MODE_RTBI, | 74 | PHY_INTERFACE_MODE_RTBI, |
| 75 | PHY_INTERFACE_MODE_SMII, | 75 | PHY_INTERFACE_MODE_SMII, |
| 76 | PHY_INTERFACE_MODE_XGMII, | 76 | PHY_INTERFACE_MODE_XGMII, |
| 77 | PHY_INTERFACE_MODE_MAX, | ||
| 77 | } phy_interface_t; | 78 | } phy_interface_t; |
| 78 | 79 | ||
| 80 | /** | ||
| 81 | * It maps 'enum phy_interface_t' found in include/linux/phy.h | ||
| 82 | * into the device tree binding of 'phy-mode', so that Ethernet | ||
| 83 | * device driver can get phy interface from device tree. | ||
| 84 | */ | ||
| 85 | static inline const char *phy_modes(phy_interface_t interface) | ||
| 86 | { | ||
| 87 | switch (interface) { | ||
| 88 | case PHY_INTERFACE_MODE_NA: | ||
| 89 | return ""; | ||
| 90 | case PHY_INTERFACE_MODE_MII: | ||
| 91 | return "mii"; | ||
| 92 | case PHY_INTERFACE_MODE_GMII: | ||
| 93 | return "gmii"; | ||
| 94 | case PHY_INTERFACE_MODE_SGMII: | ||
| 95 | return "sgmii"; | ||
| 96 | case PHY_INTERFACE_MODE_TBI: | ||
| 97 | return "tbi"; | ||
| 98 | case PHY_INTERFACE_MODE_REVMII: | ||
| 99 | return "rev-mii"; | ||
| 100 | case PHY_INTERFACE_MODE_RMII: | ||
| 101 | return "rmii"; | ||
| 102 | case PHY_INTERFACE_MODE_RGMII: | ||
| 103 | return "rgmii"; | ||
| 104 | case PHY_INTERFACE_MODE_RGMII_ID: | ||
| 105 | return "rgmii-id"; | ||
| 106 | case PHY_INTERFACE_MODE_RGMII_RXID: | ||
| 107 | return "rgmii-rxid"; | ||
| 108 | case PHY_INTERFACE_MODE_RGMII_TXID: | ||
| 109 | return "rgmii-txid"; | ||
| 110 | case PHY_INTERFACE_MODE_RTBI: | ||
| 111 | return "rtbi"; | ||
| 112 | case PHY_INTERFACE_MODE_SMII: | ||
| 113 | return "smii"; | ||
| 114 | case PHY_INTERFACE_MODE_XGMII: | ||
| 115 | return "xgmii"; | ||
| 116 | default: | ||
| 117 | return "unknown"; | ||
| 118 | } | ||
| 119 | } | ||
| 120 | |||
| 79 | 121 | ||
| 80 | #define PHY_INIT_TIMEOUT 100000 | 122 | #define PHY_INIT_TIMEOUT 100000 |
| 81 | #define PHY_STATE_TIME 1 | 123 | #define PHY_STATE_TIME 1 |
